"""Template domain entities — 剪辑计划模板."""

from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import List, Optional


@dataclass
class TemplateSegment:
    """模板中的单个片段."""

    id: str
    template_id: str
    segment_order: int
    duration_min: float
    duration_max: float
    material_type: Optional[str] = None  # 仅 voice_over_mix: 人物/场景; 其他模式 null
    created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
    updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))


@dataclass
class Template:
    """剪辑计划模板."""

    id: str
    user_id: str
    name: str
    mode: str  # EditingMode 枚举值: pip / voice_pip / one_take / voice_over
    category: str = ""
    tags: List[str] = field(default_factory=list)
    title_config: dict = field(default_factory=dict)
    subtitle_config: dict = field(default_factory=dict)
    bgm_config: dict = field(default_factory=dict)
    estimated_duration: float = 0.0
    segments: List[TemplateSegment] = field(default_factory=list)
    is_active: bool = True
    created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
    updated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))


@dataclass
class TemplateCategory:
    """模板分类."""

    id: str
    user_id: str
    name: str
    created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
