import {
  LEGACY_CODE_COLORS_RGB,
  OVERLAY_RGB,
  rgba as rgbaCss,
} from '../../shared/lib/map/palette';

// ── Re-export palette aliases used throughout Map3D ──

export const LEGACY_CODE_COLORS = LEGACY_CODE_COLORS_RGB;

const OVERLAY_PAIR_NORMAL_RGB = OVERLAY_RGB.pairNormal;
const OVERLAY_PAIR_WARN_RGB = OVERLAY_RGB.pairWarn;
const OVERLAY_FC_TRANSFER_RGB = OVERLAY_RGB.fcTransfer;
const OVERLAY_FLEET_RANGE_RGB = OVERLAY_RGB.fleetRange;
const OVERLAY_SUSPICIOUS_RGB = OVERLAY_RGB.suspicious;

// Ship icon mapping removed — now using shipKind.ts SVG-based icons

// ── Ship constants ──

export const ANCHOR_SPEED_THRESHOLD_KN = 1;
export const ANCHORED_SHIP_ICON_ID = 'ship-globe-anchored-icon';

// ── Geometry constants ──

export const DEG2RAD = Math.PI / 180;
export const RAD2DEG = 180 / Math.PI;
export const EARTH_RADIUS_M = 6371008.8; // MapLibre's `earthRadius`
export const GLOBE_ICON_HEADING_OFFSET_DEG = 0;

// ── Ship color constants ──

export const MAP_SELECTED_SHIP_RGB: [number, number, number] = [34, 211, 238];
export const MAP_HIGHLIGHT_SHIP_RGB: [number, number, number] = [245, 158, 11];
export const MAP_DEFAULT_SHIP_RGB: [number, number, number] = [100, 116, 139];

// ── Ship outline / halo contrast colors ──

export const HALO_OUTLINE_COLOR: [number, number, number, number] = [210, 225, 240, 155];
export const HALO_OUTLINE_COLOR_SELECTED: [number, number, number, number] = [14, 234, 255, 230];
export const HALO_OUTLINE_COLOR_HIGHLIGHTED: [number, number, number, number] = [245, 158, 11, 210];
export const GLOBE_OUTLINE_PERMITTED = 'rgba(210,225,240,0.62)';
export const GLOBE_OUTLINE_OTHER = 'rgba(160,175,195,0.55)';

// ── Flat map icon sizes ──

export const FLAT_OTHER_SHIP_SIZE = 20;
export const FLAT_TARGET_SHIP_SIZE = 26;
export const FLAT_LEGACY_HALO_RADIUS = 14;
export const FLAT_LEGACY_HALO_RADIUS_SELECTED = 18;
export const EMPTY_MMSI_SET = new Set<number>();

// ── 대상 선박 브리딩 애니메이션 ──

export const HALO_BREATHE_PERIOD_MS = 2000;
export const HALO_BREATHE_SELECTED_R_MIN = 16;
export const HALO_BREATHE_SELECTED_R_MAX = 22;
export const HALO_BREATHE_HIGHLIGHTED_R_MIN = 14;
export const HALO_BREATHE_HIGHLIGHTED_R_MAX = 19;

// ── Deck.gl view ID ──

export const DECK_VIEW_ID = 'mapbox';

// ── Depth params ──

// Canonical source: shared/lib/map/mapConstants.ts (re-exported for local usage)
export { DEPTH_DISABLED_PARAMS } from '../../shared/lib/map/mapConstants';

export const GLOBE_OVERLAY_PARAMS = {
  depthCompare: 'less-equal',
  depthWriteEnabled: false,
} as const;

// ── Deck.gl color constants (avoid per-object allocations inside accessors) ──

export const PAIR_RANGE_NORMAL_DECK: [number, number, number, number] = [
  OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 110,
];
export const PAIR_RANGE_WARN_DECK: [number, number, number, number] = [
  OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 170,
];
export const PAIR_LINE_NORMAL_DECK: [number, number, number, number] = [
  OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 85,
];
export const PAIR_LINE_WARN_DECK: [number, number, number, number] = [
  OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 220,
];
export const FC_LINE_NORMAL_DECK: [number, number, number, number] = [
  OVERLAY_FC_TRANSFER_RGB[0], OVERLAY_FC_TRANSFER_RGB[1], OVERLAY_FC_TRANSFER_RGB[2], 200,
];
export const FC_LINE_SUSPICIOUS_DECK: [number, number, number, number] = [
  OVERLAY_SUSPICIOUS_RGB[0], OVERLAY_SUSPICIOUS_RGB[1], OVERLAY_SUSPICIOUS_RGB[2], 220,
];
export const FLEET_RANGE_LINE_DECK: [number, number, number, number] = [
  OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 140,
];
export const FLEET_RANGE_FILL_DECK: [number, number, number, number] = [
  OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 0,
];

// ── Highlighted variants ──

export const PAIR_RANGE_NORMAL_DECK_HL: [number, number, number, number] = [
  OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 200,
];
export const PAIR_RANGE_WARN_DECK_HL: [number, number, number, number] = [
  OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 240,
];
export const PAIR_LINE_NORMAL_DECK_HL: [number, number, number, number] = [
  OVERLAY_PAIR_NORMAL_RGB[0], OVERLAY_PAIR_NORMAL_RGB[1], OVERLAY_PAIR_NORMAL_RGB[2], 245,
];
export const PAIR_LINE_WARN_DECK_HL: [number, number, number, number] = [
  OVERLAY_PAIR_WARN_RGB[0], OVERLAY_PAIR_WARN_RGB[1], OVERLAY_PAIR_WARN_RGB[2], 245,
];
export const FC_LINE_NORMAL_DECK_HL: [number, number, number, number] = [
  OVERLAY_FC_TRANSFER_RGB[0], OVERLAY_FC_TRANSFER_RGB[1], OVERLAY_FC_TRANSFER_RGB[2], 235,
];
export const FC_LINE_SUSPICIOUS_DECK_HL: [number, number, number, number] = [
  OVERLAY_SUSPICIOUS_RGB[0], OVERLAY_SUSPICIOUS_RGB[1], OVERLAY_SUSPICIOUS_RGB[2], 245,
];
export const FLEET_RANGE_LINE_DECK_HL: [number, number, number, number] = [
  OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 220,
];
export const FLEET_RANGE_FILL_DECK_HL: [number, number, number, number] = [
  OVERLAY_FLEET_RANGE_RGB[0], OVERLAY_FLEET_RANGE_RGB[1], OVERLAY_FLEET_RANGE_RGB[2], 120,
];

// ── MapLibre overlay colors ──

export const PAIR_LINE_NORMAL_ML = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.55);
export const PAIR_LINE_WARN_ML = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.95);
export const PAIR_LINE_NORMAL_ML_HL = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.95);
export const PAIR_LINE_WARN_ML_HL = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.98);

export const PAIR_RANGE_NORMAL_ML = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.45);
export const PAIR_RANGE_WARN_ML = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.75);
export const PAIR_RANGE_NORMAL_ML_HL = rgbaCss(OVERLAY_PAIR_NORMAL_RGB, 0.92);
export const PAIR_RANGE_WARN_ML_HL = rgbaCss(OVERLAY_PAIR_WARN_RGB, 0.92);

export const FC_LINE_NORMAL_ML = rgbaCss(OVERLAY_FC_TRANSFER_RGB, 0.92);
export const FC_LINE_SUSPICIOUS_ML = rgbaCss(OVERLAY_SUSPICIOUS_RGB, 0.95);
export const FC_LINE_NORMAL_ML_HL = rgbaCss(OVERLAY_FC_TRANSFER_RGB, 0.98);
export const FC_LINE_SUSPICIOUS_ML_HL = rgbaCss(OVERLAY_SUSPICIOUS_RGB, 0.98);

export const FLEET_FILL_ML = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.12);
export const FLEET_FILL_ML_HL = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.42);
export const FLEET_LINE_ML = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.65);
export const FLEET_LINE_ML_HL = rgbaCss(OVERLAY_FLEET_RANGE_RGB, 0.95);

// ── Bathymetry zoom ranges ──
// NOTE: BATHY_ZOOM_RANGES는 bathymetry.ts에서 로컬 정의 + applyBathymetryZoomProfile()에서 사용
// 이 파일의 export는 사용처가 없어 제거됨 (2026-02-16)
