"""Schemas for Route Chunk Manager (F12)."""

from enum import Enum
from typing import List, Optional

from pydantic import BaseModel

from gps_denied.schemas import GPSPoint


class ChunkStatus(str, Enum):
    """Lifecycle status of a chunk."""
    UNANCHORED = "unanchored"
    MATCHING = "matching"
    ANCHORED = "anchored"
    MERGED = "merged"


class ChunkHandle(BaseModel):
    """Metadata handle for an independent subset of the factor graph."""
    chunk_id: str
    flight_id: str
    start_frame_id: int
    end_frame_id: Optional[int] = None
    frames: List[int] = []

    is_active: bool = True
    has_anchor: bool = False

    anchor_frame_id: Optional[int] = None
    anchor_gps: Optional[GPSPoint] = None
    matching_status: ChunkStatus = ChunkStatus.UNANCHORED
