"""Asset Schemas"""
from pydantic import BaseModel, Field
from typing import Optional, Dict, Any
from datetime import datetime
from uuid import UUID


class AssetBase(BaseModel):
    original_filename: Optional[str] = None
    file_type: str
    mime_type: Optional[str] = None
    source_module: Optional[str] = None


class AssetCreate(AssetBase):
    user_id: Optional[UUID] = None
    project_id: Optional[UUID] = None
    stored_filename: str
    file_path: str
    file_size_bytes: Optional[int] = None
    width: Optional[int] = None
    height: Optional[int] = None
    duration_seconds: Optional[float] = None
    asset_metadata: Optional[Dict[str, Any]] = Field(default={}, alias="metadata")
    source_job_id: Optional[UUID] = None
    parent_asset_id: Optional[UUID] = None


class AssetResponse(AssetBase):
    id: UUID
    user_id: Optional[UUID] = None
    project_id: Optional[UUID] = None
    stored_filename: str
    file_path: str
    file_size_bytes: Optional[int] = None
    width: Optional[int] = None
    height: Optional[int] = None
    duration_seconds: Optional[float] = None
    asset_metadata: Dict[str, Any] = Field(default={}, serialization_alias="metadata")
    source_job_id: Optional[UUID] = None
    parent_asset_id: Optional[UUID] = None
    is_temporary: bool = False
    expires_at: Optional[datetime] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
        populate_by_name = True
