from __future__ import annotations

from datetime import datetime
from typing import Any

from pydantic import BaseModel, Field


class EmployeeProfilePeerGroupRead(BaseModel):
    key: str = ""
    fallback_level: int = 0
    sample_size: int = 0


class EmployeeProfileRead(BaseModel):
    profile_type: str
    profile_label: str
    score: int
    level: str
    level_label: str
    metrics: dict[str, Any] = Field(default_factory=dict)
    top_contributors: list[dict[str, Any]] = Field(default_factory=list)


class EmployeeProfileTagRead(BaseModel):
    code: str
    label: str
    display_label: str
    category: str
    polarity: str = "behavior"
    score: int
    confidence: float
    reason: str = ""
    evidence: list[dict[str, Any]] = Field(default_factory=list)
    radar_dimensions: list[str] = Field(default_factory=list)
    algorithm_version: str = ""


class EmployeeProfileRadarDimensionRead(BaseModel):
    code: str
    label: str
    score: int
    level: str
    level_label: str
    top_tags: list[str] = Field(default_factory=list)


class EmployeeProfileRadarRead(BaseModel):
    algorithm_version: str = ""
    dimensions: list[EmployeeProfileRadarDimensionRead] = Field(default_factory=list)


class EmployeeProfileLatestRead(BaseModel):
    employee_id: str
    employee_name: str = ""
    scene: str = "approval"
    window_days: int = 90
    expense_type_scope: str = "overall"
    calculated_at: datetime | None = None
    peer_group: EmployeeProfilePeerGroupRead = Field(default_factory=EmployeeProfilePeerGroupRead)
    review_priority_score: int = 0
    review_priority_level: str = "normal"
    review_priority_label: str = "正常"
    profiles: list[EmployeeProfileRead] = Field(default_factory=list)
    profile_tags: list[EmployeeProfileTagRead] = Field(default_factory=list)
    radar: EmployeeProfileRadarRead = Field(default_factory=EmployeeProfileRadarRead)
    review_suggestions: list[dict[str, Any]] = Field(default_factory=list)
    empty_reason: str = ""
