export interface PaginatedResponse<T> {
  items: T[]
  totalCount: number
  page: number
  pageSize: number
}

export interface Media {
  id: string
  name: string
  path: string
  mediaType: MediaType
  mediaStatus: MediaStatus
  duration: string | null
  annotationCount: number
  waypointId: string | null
  userId: string
}

export enum MediaType { None = 0, Image = 1, Video = 2 }
export enum MediaStatus { New = 0, AiProcessing = 1, AiProcessed = 2, ManualCreated = 3 }
export enum AnnotationSource { AI = 0, Manual = 1 }
export enum AnnotationStatus { Created = 0, Edited = 1, Validated = 2 }
export enum Affiliation { Unknown = 0, Friendly = 1, Hostile = 2 }
export enum CombatReadiness { NotReady = 0, Ready = 1 }

export interface Detection {
  id: string
  classNum: number
  label: string
  confidence: number
  affiliation: Affiliation
  combatReadiness: CombatReadiness
  centerX: number
  centerY: number
  width: number
  height: number
}

export interface AnnotationListItem {
  id: string
  mediaId: string
  time: string | null
  createdDate: string
  userId: string
  source: AnnotationSource
  status: AnnotationStatus
  isSplit: boolean
  splitTile: string | null
  detections: Detection[]
}

export interface DetectionClass {
  id: number
  name: string
  shortName: string
  color: string
  maxSizeM: number
  photoMode: number
}

export interface Flight {
  id: string
  name: string
  createdDate: string
  aircraftId: string | null
}

export interface Aircraft {
  id: string
  model: string
  type: 'Plane' | 'Copter' | 'FixedWing'
  isDefault: boolean
  resolution?: string
  maxMinutes?: number
}

export interface AiRecognitionSettings {
  framesToRecognize: number
  minSecondsBetween: number
  minConfidence: number
}

export interface AiRecognitionTelemetry {
  model: string
  checkpoint: string
  lastRunAt: string | null
  frames: number
  avgConfidence: number
}

export interface AiRecognitionResponse {
  settings: AiRecognitionSettings
  telemetry: AiRecognitionTelemetry
}

export type GpsProtocol = 'NMEA' | 'UBX' | 'MAVLINK'

export interface GpsDeviceSettings {
  address: string
  port: number
  protocol: GpsProtocol
}

export interface GpsDeviceTelemetry {
  socket: string
  connected: boolean
  fix: '2D' | '3D' | 'NO_FIX'
  satellites: number
  hdop: number
  lastPacketMs: number
}

export interface GpsDeviceResponse {
  settings: GpsDeviceSettings
  telemetry: GpsDeviceTelemetry
}

export interface Waypoint {
  id: string
  flightId: string
  name: string
  latitude: number
  longitude: number
  order: number
}

export interface SystemSettings {
  id: string
  name: string | null
  militaryUnit: string | null
  defaultCameraWidth: number | null
  defaultCameraFoV: number | null
  thumbnailWidth: number
  thumbnailHeight: number
  thumbnailBorder: number
  generateAnnotatedImage: boolean
  silentDetection: boolean
}

export interface DirectorySettings {
  id: string
  videosDir: string
  imagesDir: string
  labelsDir: string
  resultsDir: string
  thumbnailsDir: string
  gpsSatDir: string
  gpsRouteDir: string
}

export interface CameraSettings {
  id: string
  altitude: number
  focalLength: number
  sensorWidth: number
}

export interface UserSettings {
  id: string
  userId: string
  selectedFlightId: string | null
  annotationsLeftPanelWidth: number | null
  annotationsRightPanelWidth: number | null
  datasetLeftPanelWidth: number | null
  datasetRightPanelWidth: number | null
}

export interface DatasetItem {
  annotationId: string
  imageName: string
  thumbnailPath: string
  status: AnnotationStatus
  createdDate: string
  createdEmail: string | null
  flightName: string | null
  source: AnnotationSource
  isSeed: boolean
  isSplit: boolean
}

export interface ClassDistributionItem {
  classNum: number
  label: string
  color: string
  count: number
}

export interface User {
  id: string
  name: string
  email: string
  role: string
  isActive: boolean
}

export interface AuthUser {
  id: string
  email: string
  name: string
  role: string
  permissions: string[]
}
