from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field

Sentiment = Literal["看多", "看空", "中性"]


class Account(BaseModel):
    id: str
    name: str
    description: str


class DailyInputAccountPayload(BaseModel):
    account_id: str
    links: list[str] = Field(default_factory=list)


class DailyInputUpsertPayload(BaseModel):
    accounts: list[DailyInputAccountPayload] = Field(default_factory=list)


class DailyInputAccount(BaseModel):
    account_id: str
    account_name: str
    links: list[str] = Field(default_factory=list)


class DailyInputDocument(BaseModel):
    date: str
    updated_at: str
    accounts: list[DailyInputAccount] = Field(default_factory=list)


class OpinionArticle(BaseModel):
    id: str
    account_id: str
    account_name: str
    title: str
    published_at: str
    summary: str
    source_url: str
    sectors: list[str] = Field(default_factory=list)
    sentiment: Sentiment
    article_type: str


class ReportDocument(BaseModel):
    date: str
    generated_at: str
    summary: str
    focus_sectors: list[str] = Field(default_factory=list)
    article_count: int
    account_count: int
    articles: list[OpinionArticle] = Field(default_factory=list)


class ReportListItem(BaseModel):
    date: str
    generated_at: str
    summary: str
    article_count: int
    focus_sectors: list[str] = Field(default_factory=list)


class ClsNewsItem(BaseModel):
    id: str
    title: str
    published_at: str
    source: str
    summary: str
    reference_url: str
    sectors: list[str] = Field(default_factory=list)
    sentiment: Sentiment


class ClsNewsSummary(BaseModel):
    overview: str
    hot_topics: str
    watch_list: list[str] = Field(default_factory=list)


class ClsSectorImpact(BaseModel):
    sector: str
    sentiment: Sentiment
    reason: str
    related_titles: list[str] = Field(default_factory=list)


class ClsNewsDocument(BaseModel):
    date: str
    updated_at: str
    window_label: str
    summary: ClsNewsSummary
    sector_impacts: list[ClsSectorImpact] = Field(default_factory=list)
    items: list[ClsNewsItem] = Field(default_factory=list)
