"""Storage / library statistics response schemas (§A6)."""

import datetime as dt

from pydantic import BaseModel


class DiskUsageOut(BaseModel):
    total: int
    used: int
    free: int


class FormatBreakdownOut(BaseModel):
    file_format: str
    track_count: int
    total_size: int


class GenreCountOut(BaseModel):
    genre: str
    track_count: int


class StorageStatsOut(BaseModel):
    """Everything the Storage screen needs in a single call."""

    # library catalogue
    total_tracks: int
    total_artists: int
    total_albums: int
    total_size: int
    total_duration_seconds: int
    largest_track_size: int
    earliest_added: dt.datetime | None
    latest_added: dt.datetime | None

    # breakdowns
    by_format: list[FormatBreakdownOut]
    by_metadata_status: dict[str, int]
    by_source: dict[str, int]
    top_genres: list[GenreCountOut]

    # backing volume (``None`` for object-store backends)
    disk: DiskUsageOut | None
