from abc import ABC, abstractmethod
from typing import Optional

from models.chunks import ChunkHandle, ChunkBounds, Sim3Transform
from models.core import GPSPoint
from models.processing import ChunkAlignmentResult


class RouteChunkManagerBase(ABC):
    @abstractmethod
    async def create_chunk(
        self, flight_id: str, start_frame_id: int
    ) -> ChunkHandle:
        pass

    @abstractmethod
    async def add_frame_to_chunk(
        self, chunk_id: str, frame_id: int
    ) -> bool:
        pass

    @abstractmethod
    async def finalize_chunk(self, chunk_id: str) -> bool:
        pass

    @abstractmethod
    async def get_chunk(self, chunk_id: str) -> Optional[ChunkHandle]:
        pass

    @abstractmethod
    async def get_active_chunk(
        self, flight_id: str
    ) -> Optional[ChunkHandle]:
        pass

    @abstractmethod
    async def get_flight_chunks(
        self, flight_id: str
    ) -> list[ChunkHandle]:
        pass

    @abstractmethod
    async def estimate_chunk_bounds(
        self, chunk_id: str
    ) -> ChunkBounds:
        pass

    @abstractmethod
    async def anchor_chunk(
        self, chunk_id: str, frame_id: int, gps: GPSPoint
    ) -> bool:
        pass

    @abstractmethod
    async def match_chunk_to_satellite(
        self, chunk_id: str
    ) -> Optional[ChunkAlignmentResult]:
        pass

    @abstractmethod
    async def apply_transform_to_chunk(
        self, chunk_id: str, transform: Sim3Transform
    ) -> bool:
        pass

