from dataclasses import dataclass
from pathlib import Path
from typing import Optional


@dataclass(frozen=True)
class ClipTask:
    clip_uuid: str
    date_name: str
    vehicle_name: str
    clip_path: str

    @property
    def task_id(self) -> str:
        return self.clip_uuid


@dataclass(frozen=True)
class RawIDTask:
    scenario_key: str
    scenario_name: str
    raw_id: str
    cve_data: Optional[str]
    offset: Optional[str]
    target_speed: Optional[str]
    ego_speed: Optional[str]
    clips: tuple[str, ...]

    @property
    def task_id(self) -> str:
        return self.raw_id


@dataclass
class TaskResult:
    task_id: str
    success: bool
    message: str
    output_dir: Optional[str] = None


@dataclass(frozen=True)
class VideoCaseTask:
    input_path: str
    case_dir: str
    video_path: str
    calib_path: str
    output_rel_dir: str

    @property
    def task_id(self) -> str:
        return self.case_dir

    @property
    def case_name(self) -> str:
        return Path(self.case_dir).name
