"""
Response types for the Kronical SDK.

These are TypedDicts for documentation and IDE support. The SDK returns
plain dicts that conform to these shapes — no runtime validation overhead.
"""
from typing import Any, Dict, List, Optional, TypedDict


class HeadlineContext(TypedDict, total=False):
    narrative: Optional[str]
    novelty: Optional[str]
    escalation: Optional[str]
    tone: Optional[str]
    actors: List[str]
    themes: List[str]
    implications: Optional[str]
    shift_justification: Optional[str]
    significance_level: Optional[str]
    assets_referenced: Optional[List[str]]


class Headline(TypedDict, total=False):
    id: str
    text: str
    original_text: str
    timestamp: Optional[str]
    timestamp_unix: Optional[float]
    source: Optional[str]
    url: Optional[str]
    context: Optional[HeadlineContext]


class FeedResponse(TypedDict):
    headlines: List[Headline]
    count: int
    has_more: bool


class EnrichmentResult(TypedDict, total=False):
    context_narrative: str
    novelty: Optional[str]
    escalation: Optional[str]
    tone: Optional[str]
    actors: List[str]
    themes: List[str]
    implications: str
    shift_justification: str
    evidence_used: List[str]
    significance_level: Optional[str]
    assets_referenced: List[str]
    generation_time_ms: int


class EnrichmentResponse(TypedDict):
    headline_text: str
    enrichment: EnrichmentResult


class BatchSubmitResponse(TypedDict):
    batch_id: str
    total_items: int
    status: str


class BatchResultResponse(TypedDict):
    batch: Dict[str, Any]
    items: List[Dict[str, Any]]


class SmartColumn(TypedDict, total=False):
    column_id: str
    name: str
    instruction: str
    enabled: bool
    created_at: Optional[str]


class SmartColumnListResponse(TypedDict):
    columns: List[SmartColumn]
    count: int


class MatchListResponse(TypedDict):
    matches: List[Dict[str, Any]]
    count: int


class PulseColumn(TypedDict, total=False):
    column_id: str
    name: str
    query: str
    filters: Optional[Dict[str, Any]]
    enabled: bool
    created_at: Optional[str]
    updated_at: Optional[str]


class PulseColumnListResponse(TypedDict):
    columns: List[PulseColumn]
    count: int


class TickerState(TypedDict, total=False):
    ticker: str
    company_name: Optional[str]
    state_of_play: Optional[str]
    detailed_analysis: Optional[str]
    sentiment: Optional[str]
    theme_tags: Optional[List[str]]
    state_changed: Optional[bool]
    state_changed_at: Optional[str]
    updated_at: Optional[str]
    earnings_summary: Optional[str]
    pending: Optional[bool]


class Watchlist(TypedDict, total=False):
    watchlist_id: str
    client_id: Optional[str]
    name: str
    tickers: List[str]
    created_at: Optional[str]
    updated_at: Optional[str]


class UsageResponse(TypedDict, total=False):
    client_id: str
    client_name: str
    plan: str
    period_days: int
    summary: Dict[str, Any]
    llm_cost: Dict[str, Any]
    endpoints: List[Dict[str, Any]]
    daily: List[Dict[str, Any]]


class HealthResponse(TypedDict):
    status: str
    version: str
    dependencies: Dict[str, str]
