// Package storage provides object storage for media files.
// In production, uses GCS. In development (standalone mode), uses in-memory storage.
package storage

import (
	"context"
	"time"
)

// Store abstracts object storage operations.
type Store interface {
	// Upload stores data at the given path and returns its public/signed URL.
	Upload(ctx context.Context, path string, data []byte, contentType string) (string, error)

	// UploadPresigned returns a presigned URL for direct client-to-storage uploads.
	UploadPresigned(ctx context.Context, path string, contentType string) (*PresignedUpload, error)

	// GetURL returns a signed or public URL for the object.
	GetURL(ctx context.Context, path string) (string, error)

	// Delete removes an object.
	Delete(ctx context.Context, path string) error

	// List returns objects matching the given prefix.
	List(ctx context.Context, prefix string) ([]MediaObject, error)
}

// PresignedUpload contains the details for a direct-upload to storage.
type PresignedUpload struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
	Method  string            `json:"method"` // "PUT"
	Expires time.Time         `json:"expires"`
}

// MediaObject represents a stored media file.
type MediaObject struct {
	Path        string    `json:"path"`
	URL         string    `json:"url"`
	ContentType string    `json:"contentType"`
	Size        int64     `json:"size"`
	CreatedAt   time.Time `json:"createdAt"`
}
