export type LonLat = [number, number];

export interface TrackStats {
  totalDistanceNm: number;
  avgSpeed: number;
  maxSpeed: number;
  pointCount: number;
}

export interface ChnPrmShipInfo {
  name?: string;
  vesselType?: string;
  callsign?: string;
  imo?: number;
}

export interface ProcessedTrack {
  vesselId: string;
  targetId: string;
  sigSrcCd: string;
  shipName: string;
  shipKindCode: string;
  nationalCode: string;
  geometry: LonLat[];
  timestampsMs: number[];
  speeds: number[];
  stats: TrackStats;
  chnPrmShipInfo?: ChnPrmShipInfo;
}

export interface CurrentVesselPosition {
  vesselId: string;
  targetId: string;
  sigSrcCd: string;
  shipName: string;
  shipKindCode: string;
  nationalCode: string;
  position: LonLat;
  heading: number;
  speed: number;
  timestamp: number;
}

export interface TrackQueryRequest {
  mmsi: number;
  minutes: number;
}

export interface TrackQueryContext {
  mmsi: number;
  startTimeIso: string;
  endTimeIso: string;
  shipNameHint?: string;
  shipKindCodeHint?: string;
  nationalCodeHint?: string;
  isPermitted: boolean;
  vesselType?: string;
  ownerCn?: string | null;
  ownerRoman?: string | null;
  permitNo?: string;
  pairPermitNo?: string | null;
  ton?: number | null;
  callSign?: string;
  workSeaArea?: string;
}

export interface MultiTrackQueryContext {
  vessels: Array<{
    mmsi: number;
    shipNameHint?: string;
    isPermitted: boolean;
    vesselType?: string;
    ownerCn?: string | null;
    ownerRoman?: string | null;
    permitNo?: string;
    pairPermitNo?: string | null;
    ton?: number | null;
    callSign?: string;
    workSeaArea?: string;
    shipCode?: string;
  }>;
  startTimeIso: string;
  endTimeIso: string;
}

export interface ReplayStreamQueryRequest {
  startTime: string;
  endTime: string;
  vessels: Array<{ sigSrcCd: string; targetId: string }>;
}
