from datetime import datetime
from typing import Optional
from pydantic import BaseModel
from ..core.gps_point import GPSPoint
from ..core.camera_parameters import CameraParameters
from ..flight.waypoint import Waypoint
from ..flight.geofences import Geofences


class FlightResponse(BaseModel):
    flight_id: str
    status: str
    message: Optional[str] = None
    created_at: datetime


class FlightDetailResponse(BaseModel):
    flight_id: str
    name: str
    description: str
    start_gps: GPSPoint
    waypoints: list[Waypoint]
    geofences: Geofences
    camera_params: CameraParameters
    altitude: float
    status: str
    frames_processed: int
    frames_total: int
    created_at: datetime
    updated_at: datetime


class FlightStatusResponse(BaseModel):
    status: str
    frames_processed: int
    frames_total: int
    current_frame: Optional[int] = None
    current_heading: Optional[float] = None
    blocked: bool = False
    search_grid_size: Optional[int] = None
    message: Optional[str] = None
    created_at: datetime
    updated_at: datetime


class DeleteResponse(BaseModel):
    deleted: bool
    flight_id: str


class UpdateResponse(BaseModel):
    updated: bool
    waypoint_id: str


class BatchUpdateResponse(BaseModel):
    success: bool
    updated_count: int
    failed_ids: list[str] = []
    errors: Optional[dict[str, str]] = None

