"""saju-lab Pydantic 모델."""
from typing import List, Literal, Optional
from pydantic import BaseModel, Field


# --- Input ---

class SajuInterpretRequest(BaseModel):
    year: int = Field(..., ge=1900, le=2100)
    month: int = Field(..., ge=1, le=12)
    day: int = Field(..., ge=1, le=31)
    hour: Optional[int] = Field(None, ge=0, le=23)
    gender: Literal["male", "female"]
    calendar_type: Literal["solar", "lunar"] = "solar"
    is_leap_month: bool = False


class CompatInterpretRequest(BaseModel):
    person_a: SajuInterpretRequest
    person_b: SajuInterpretRequest


# --- Response ---

class SajuInterpretResponse(BaseModel):
    saju: dict
    analysis: dict
    daeun: List[dict]
    interpretation_json: dict
    reading_id: int
    model: str
    tokens_in: int
    tokens_out: int
    cost_usd: float
    latency_ms: int
    reroll_count: int = 0
    fortune_scores: dict
    lucky: dict
    monthly_flow: List[dict]


class CompatInterpretResponse(BaseModel):
    saju_a: dict
    saju_b: dict
    score: int
    breakdown: dict
    interpretation_json: dict
    reading_id: int
    model: str
    tokens_in: int
    tokens_out: int
    cost_usd: float
    latency_ms: int
    reroll_count: int = 0


# --- CRUD ---

class SajuPatchRequest(BaseModel):
    favorite: Optional[bool] = None
    memo: Optional[str] = None


class CompatPatchRequest(BaseModel):
    favorite: Optional[bool] = None
    memo: Optional[str] = None
