# retoor <retoor@molodetz.nl>

from __future__ import annotations

from typing import Any, Optional

from pydantic import BaseModel


class StatisticsMetricOut(BaseModel):
    key: str
    label: str
    value: Any
    format: str = "int"
    delta: Optional[float] = None
    direction: Optional[str] = None


class StatisticsPointOut(BaseModel):
    t: str
    v: float


class StatisticsSeriesOut(BaseModel):
    key: str
    label: str
    points: list[StatisticsPointOut]


class StatisticsTableOut(BaseModel):
    key: str
    title: str
    columns: list[str]
    rows: list[list[Any]]


class StatisticsHighlightOut(BaseModel):
    label: str
    value: Any


class StatisticsPayloadOut(BaseModel):
    tab: str
    window_hours: int
    granularity: str
    generated_at: str
    compare: bool = True
    cards: list[StatisticsMetricOut] = []
    series: list[StatisticsSeriesOut] = []
    tables: list[StatisticsTableOut] = []
    highlights: list[StatisticsHighlightOut] = []
    notes: dict[str, Any] = {}


class StatisticsTabOut(BaseModel):
    key: str
    label: str
    icon: str
    active: bool


class StatisticsOut(BaseModel):
    active_tab: str
    window_hours: int
    tabs: list[StatisticsTabOut] = []
    initial: StatisticsPayloadOut