from abc import ABC, abstractmethod
from typing import Optional
import numpy as np

from models.recovery import (
    SearchSession,
    ConfidenceAssessment,
    UserAnchor,
    UserInputRequest,
)
from models.core import GPSPoint
from models.satellite import TileCandidate


class FailureRecoveryCoordinatorBase(ABC):
    @abstractmethod
    async def start_search_session(
        self,
        flight_id: str,
        frame_id: int,
        estimated_center: GPSPoint,
    ) -> SearchSession:
        pass

    @abstractmethod
    async def expand_search(
        self, session_id: str
    ) -> Optional[list[TileCandidate]]:
        pass

    @abstractmethod
    async def assess_confidence(
        self, flight_id: str, frame_id: int
    ) -> ConfidenceAssessment:
        pass

    @abstractmethod
    async def request_user_input(
        self,
        flight_id: str,
        frame_id: int,
        uav_image: np.ndarray,
        candidates: list[TileCandidate],
    ) -> UserInputRequest:
        pass

    @abstractmethod
    async def process_user_anchor(
        self, flight_id: str, anchor: UserAnchor
    ) -> bool:
        pass

    @abstractmethod
    async def is_recovery_needed(
        self, confidence: ConfidenceAssessment
    ) -> bool:
        pass

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

    @abstractmethod
    async def cancel_session(self, session_id: str) -> bool:
        pass

