"""Value objects for file storage."""

import datetime as dt
from dataclasses import dataclass


@dataclass(frozen=True, slots=True)
class ObjectStat:
    size: int
    content_type: str | None


@dataclass(frozen=True, slots=True)
class DiskUsage:
    """Capacity of the volume backing the media store. ``None`` for backends
    (e.g. object stores) that expose no notion of total disk capacity."""

    total: int
    used: int
    free: int


@dataclass(frozen=True, slots=True)
class FormatBreakdown:
    """Per-container-format slice of the library (e.g. ``flac`` → 312 tracks)."""

    file_format: str
    track_count: int
    total_size: int


@dataclass(frozen=True, slots=True)
class LibraryStats:
    """Aggregate facts about everything the instance has stored. Computed from
    the catalogue (DB), not the filesystem — ``total_size`` is the sum of the
    recorded ``file_size`` of every track."""

    total_tracks: int
    total_size: int
    total_duration_seconds: int
    by_format: list[FormatBreakdown]
    by_metadata_status: dict[str, int]
    by_source: dict[str, int]
    largest_track_size: int
    earliest_added: dt.datetime | None
    latest_added: dt.datetime | None
