"""Media-related Pydantic models."""

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field


class MediaState(str, Enum):
    """Playback state enumeration."""

    PLAYING = "playing"
    PAUSED = "paused"
    STOPPED = "stopped"
    IDLE = "idle"


class MediaInfo(BaseModel):
    """Information about the currently playing media."""

    title: Optional[str] = Field(None, description="Track/media title")
    artist: Optional[str] = Field(None, description="Artist name")
    album: Optional[str] = Field(None, description="Album name")
    album_art_url: Optional[str] = Field(None, description="URL to album artwork")
    duration: Optional[float] = Field(
        None, description="Total duration in seconds", ge=0
    )
    position: Optional[float] = Field(
        None, description="Current position in seconds", ge=0
    )


class MediaStatus(BaseModel):
    """Complete media playback status."""

    state: MediaState = Field(default=MediaState.IDLE, description="Playback state")
    title: Optional[str] = Field(None, description="Track/media title")
    artist: Optional[str] = Field(None, description="Artist name")
    album: Optional[str] = Field(None, description="Album name")
    album_art_url: Optional[str] = Field(None, description="URL to album artwork")
    duration: Optional[float] = Field(
        None, description="Total duration in seconds", ge=0
    )
    position: Optional[float] = Field(
        None, description="Current position in seconds", ge=0
    )
    volume: int = Field(default=100, description="Volume level (0-100)", ge=0, le=100)
    muted: bool = Field(default=False, description="Whether audio is muted")
    source: Optional[str] = Field(None, description="Media source/player name")


class VolumeRequest(BaseModel):
    """Request model for setting volume."""

    volume: int = Field(..., description="Volume level (0-100)", ge=0, le=100)


class SeekRequest(BaseModel):
    """Request model for seeking to a position."""

    position: float = Field(..., description="Position in seconds to seek to", ge=0)
