// TypeScript interfaces for military situation data

export interface ForceAsset {
  id: string
  name: string
  type: string
  count: number
  status: 'active' | 'standby' | 'alert'
  location?: { lat: number; lng: number }
}

export interface ForceSummary {
  totalAssets: number
  personnel: number
  navalShips: number
  aircraft: number
  groundUnits: number
  uav: number
  missileConsumed: number
  missileStock: number
}

export interface PowerIndex {
  overall: number
  militaryStrength: number
  economicPower: number
  geopoliticalInfluence: number
}

export interface CombatLosses {
  bases: { destroyed: number; damaged: number }
  personnelCasualties: { killed: number; wounded: number }
  /** 平民伤亡 */
  civilianCasualties?: { killed: number; wounded: number }
  aircraft: number
  warships: number
  armor: number
  vehicles: number
  /** 其它 */
  drones?: number
  missiles?: number
  helicopters?: number
  submarines?: number
  /** 航母 */
  carriers?: number
  /** 民船 */
  civilianShips?: number
  /** 机/港（机场/港口） */
  airportPort?: number
}

export interface SituationUpdate {
  id: string
  timestamp: string
  category: 'deployment' | 'alert' | 'intel' | 'diplomatic' | 'other'
  summary: string
  severity: 'low' | 'medium' | 'high' | 'critical'
}

export interface ConflictEvent {
  event_id: string
  event_time: string
  title: string
  lat: number
  lng: number
  impact_score: number
  url?: string
}

export interface ConflictStats {
  total_events: number
  high_impact_events: number
  estimated_casualties: number
  estimated_strike_count: number
}

export interface MilitarySituation {
  lastUpdated: string
  usForces: {
    summary: ForceSummary
    powerIndex: PowerIndex
    assets: ForceAsset[]
    keyLocations: {
      name: string
      lat: number
      lng: number
      type?: string
      region?: string
      id?: number
      status?: 'operational' | 'damaged' | 'attacked'
      damage_level?: number
      /** 遭袭时间 ISO 字符串，用于状态管理与回放 */
      attacked_at?: string | null
    }[]
    combatLosses: CombatLosses
    /** 华尔街财团投入趋势 { time: ISO string, value: 0-100 } */
    wallStreetInvestmentTrend: { time: string; value: number }[]
  }
  iranForces: {
    summary: ForceSummary
    powerIndex: PowerIndex
    assets: ForceAsset[]
    keyLocations: {
      name: string
      lat: number
      lng: number
      type?: string
      region?: string
      id?: number
      status?: 'operational' | 'damaged' | 'attacked'
      damage_level?: number
      attacked_at?: string | null
    }[]
    combatLosses: CombatLosses
    /** 反击情绪指标 0-100 */
    retaliationSentiment: number
    /** 历史情绪曲线 { time: ISO string, value: 0-100 } */
    retaliationSentimentHistory: { time: string; value: number }[]
  }
  recentUpdates: SituationUpdate[]
  /** GDELT 冲突事件 (1–3 绿点, 4–6 橙闪, 7–10 红脉) */
  conflictEvents?: ConflictEvent[]
  /** 战损统计（展示用） */
  conflictStats?: ConflictStats
  /** 平民伤亡合计（不区分阵营） */
  civilianCasualtiesTotal?: { killed: number; wounded: number }
  /** 地图打击数据（来自 DB：被袭美军基地、打击源、源→目标连线；含攻击时间便于回放） */
  mapData?: {
    attackedTargets: [number, number][]
    strikeSources: { id: string; name: string; lng: number; lat: number }[]
    strikeLines: {
      sourceId: string
      targets: { lng: number; lat: number; name?: string; struck_at?: string | null }[]
    }[]
  }
  /** 动画配置：攻击脉冲衰减窗口（天），可在编辑面板调整 */
  animationConfig?: {
    strikeCutoffDays: number
  }
}

export const INITIAL_MOCK_DATA: MilitarySituation = {
  lastUpdated: '2026-03-01T11:45:00.000Z',
  usForces: {
    summary: {
      totalAssets: 1245,
      personnel: 185000,
      navalShips: 292,
      aircraft: 1862,
      groundUnits: 18,
      uav: 418,
      missileConsumed: 1056,
      missileStock: 2840,
    },
    powerIndex: {
      overall: 94,
      militaryStrength: 96,
      economicPower: 98,
      geopoliticalInfluence: 97,
    },
    assets: [
      { id: 'us-1', name: '双航母打击群 (CVN-72 & CVN-78)', type: '航母', count: 2, status: 'active' },
      { id: 'us-2', name: '阿利·伯克级驱逐舰', type: '驱逐舰', count: 4, status: 'active' },
      { id: 'us-3', name: 'F/A-18 中队', type: '战机', count: 48, status: 'active' },
      { id: 'us-4', name: 'F-35 中队', type: '战机', count: 48, status: 'active' },
      { id: 'us-5', name: 'F-22 猛禽', type: '战机', count: 12, status: 'active' },
      { id: 'us-6', name: 'B-2 幽灵', type: '轰炸机', count: 2, status: 'alert' },
      { id: 'us-7', name: '爱国者防空系统', type: '防空', count: 3, status: 'active' },
      { id: 'us-8', name: 'MQ-9 死神', type: '无人机', count: 28, status: 'active' },
      { id: 'us-9', name: 'MQ-1C 灰鹰', type: '无人机', count: 45, status: 'active' },
    ],
    keyLocations: [],
    combatLosses: {
      bases: { destroyed: 0, damaged: 2 },
      personnelCasualties: { killed: 127, wounded: 384 },
      civilianCasualties: { killed: 18, wounded: 52 },
      aircraft: 2,
      warships: 0,
      armor: 0,
      vehicles: 8,
      drones: 4,
      missiles: 12,
      helicopters: 1,
      submarines: 0,
      carriers: 0,
      civilianShips: 0,
      airportPort: 0,
    },
    wallStreetInvestmentTrend: [
      { time: '2025-03-01T00:00:00', value: 82 },
      { time: '2025-03-01T03:00:00', value: 85 },
      { time: '2025-03-01T06:00:00', value: 88 },
      { time: '2025-03-01T09:00:00', value: 90 },
      { time: '2025-03-01T12:00:00', value: 92 },
      { time: '2025-03-01T15:00:00', value: 94 },
      { time: '2025-03-01T18:00:00', value: 95 },
      { time: '2025-03-01T21:00:00', value: 96 },
      { time: '2025-03-01T23:00:00', value: 98 },
    ],
  },
  iranForces: {
    summary: {
      totalAssets: 7850,
      personnel: 2350000,
      navalShips: 4250,
      aircraft: 8200,
      groundUnits: 350,
      uav: 750,
      missileConsumed: 3720,
      missileStock: 13800,
    },
    powerIndex: {
      overall: 42,
      militaryStrength: 58,
      economicPower: 28,
      geopoliticalInfluence: 35,
    },
    assets: [
      { id: 'ir-1', name: '护卫舰', type: '水面舰艇', count: 6, status: 'active' },
      { id: 'ir-2', name: '快攻艇', type: '海军', count: 100, status: 'active' },
      { id: 'ir-3', name: 'F-4 Phantom', type: '战机', count: 62, status: 'standby' },
      { id: 'ir-4', name: 'F-14 Tomcat', type: '战机', count: 24, status: 'active' },
      { id: 'ir-5', name: '弹道导弹', type: '导弹', count: 3400, status: 'alert' },
      { id: 'ir-6', name: '伊斯兰革命卫队海军', type: '准军事', count: 25000, status: 'active' },
      { id: 'ir-7', name: '沙希德-136', type: '无人机', count: 750, status: 'alert' },
      { id: 'ir-8', name: '法塔赫 (Fattah)', type: '导弹', count: 12, status: 'alert' },
      { id: 'ir-9', name: '穆哈杰-6', type: '无人机', count: 280, status: 'active' },
    ],
    keyLocations: [],
    combatLosses: {
      bases: { destroyed: 3, damaged: 8 },
      personnelCasualties: { killed: 2847, wounded: 5620 },
      civilianCasualties: { killed: 412, wounded: 1203 },
      aircraft: 24,
      warships: 12,
      armor: 18,
      vehicles: 42,
      drones: 28,
      missiles: 156,
      helicopters: 8,
      submarines: 2,
      carriers: 0,
      civilianShips: 0,
      airportPort: 0,
    },
    retaliationSentiment: 78,
    retaliationSentimentHistory: [
      { time: '2025-03-01T00:00:00', value: 42 },
      { time: '2025-03-01T03:00:00', value: 48 },
      { time: '2025-03-01T06:00:00', value: 55 },
      { time: '2025-03-01T09:00:00', value: 61 },
      { time: '2025-03-01T12:00:00', value: 58 },
      { time: '2025-03-01T15:00:00', value: 65 },
      { time: '2025-03-01T18:00:00', value: 72 },
      { time: '2025-03-01T21:00:00', value: 76 },
      { time: '2025-03-01T23:00:00', value: 78 },
    ],
  },
  recentUpdates: [
    {
      id: 'u1',
      timestamp: new Date(Date.now() - 3600000).toISOString(),
      category: 'deployment',
      summary: '美军航母打击群在阿拉伯海重新部署',
      severity: 'medium',
    },
    {
      id: 'u2',
      timestamp: new Date(Date.now() - 7200000).toISOString(),
      category: 'alert',
      summary: '霍尔木兹海峡海军巡逻活动加强',
      severity: 'high',
    },
    {
      id: 'u3',
      timestamp: new Date(Date.now() - 10800000).toISOString(),
      category: 'intel',
      summary: '卫星图像显示阿巴斯港活动增加',
      severity: 'low',
    },
    {
      id: 'u4',
      timestamp: new Date(Date.now() - 14400000).toISOString(),
      category: 'diplomatic',
      summary: '阿曼间接谈判进行中',
      severity: 'low',
    },
  ],
  conflictEvents: [],
  conflictStats: { total_events: 0, high_impact_events: 0, estimated_casualties: 0, estimated_strike_count: 0 },
  civilianCasualtiesTotal: { killed: 430, wounded: 1255 },
  // 与 server/seed.js 一致，首屏与未连 API 时也有打击数据，前端可正常绘制攻击线与动画
  mapData: {
    attackedTargets: [
      [42.441, 33.785],
      [44.366, 33.315],
      [51.314, 25.117],
      [43.963, 36.237],
      [35.425, 37.002],
      [47.58, 24.062],
      [44.256, 33.556],
      [42.45, 33.8],
      [38.618, 33.49],
      [40.73, 36.058],
      [40.295, 35.336],
      [41.885, 37.015],
      [47.799, 28.832],
      [47.52, 29.346],
      [50.608, 26.236],
      [54.547, 24.248],
      [46.738, 24.774],
      [35.012, 31.208],
      [47.456, 29.603],
      [51.52, 25.275],
      [34.666, 30.776],
      [36.259, 32.356],
      [37.794, 38.354],
      [54.024, 17.666],
      [58.89, 20.675],
      [30.298, 30.915],
      [43.159, 11.547],
    ] as [number, number][],
    strikeSources: [
      { id: 'israel', name: '以色列', lng: 34.78, lat: 32.08 },
      { id: 'lincoln', name: '林肯号航母', lng: 58.4215, lat: 24.1568 },
      { id: 'ford', name: '福特号航母', lng: 24.1002, lat: 35.7397 },
    ],
    strikeLines: [
      {
        sourceId: 'israel',
        targets: [
          { lng: 50.88, lat: 34.64, name: '库姆' },
          { lng: 50.876409, lat: 34.625448, name: '伊朗专家会议秘书处' },
          { lng: 51.916, lat: 33.666, name: '纳坦兹' },
          { lng: 51.002, lat: 35.808, name: '卡拉季无人机厂' },
          { lng: 35.5, lat: 33.86, name: '贝鲁特南郊指挥所' },
          { lng: 35.32, lat: 33.34, name: '利塔尼弹药库' },
          { lng: 36.2, lat: 34.01, name: '巴勒贝克后勤枢纽' },
          { lng: 35.19, lat: 33.27, name: '提尔海岸阵地' },
          { lng: 36.38, lat: 34.39, name: '赫尔梅勒无人机阵地' },
        ],
      },
      {
        sourceId: 'lincoln',
        targets: [
          { lng: 56.27, lat: 27.18, name: '阿巴斯港海军司令部' },
          { lng: 57.08, lat: 27.13, name: '米纳布' },
          { lng: 56.5, lat: 27.0, name: '霍尔木兹岸防阵地' },
          { lng: 50.838, lat: 28.968, name: '布什尔雷达站' },
          { lng: 51.667, lat: 32.654, name: '伊斯法罕核设施' },
        ],
      },
      {
        sourceId: 'ford',
        targets: [
          { lng: 51.42, lat: 35.69, name: '哈梅内伊官邸' },
          { lng: 51.41, lat: 35.72, name: '总统府/情报部' },
          { lng: 51.15, lat: 35.69, name: '梅赫拉巴德机场' },
          { lng: 46.29, lat: 38.08, name: '大不里士空军基地' },
          { lng: 47.076, lat: 34.314, name: '克尔曼沙赫导弹掩体' },
          { lng: 46.42, lat: 33.64, name: '伊拉姆导弹阵地' },
          { lng: 48.35, lat: 33.48, name: '霍拉马巴德储备库' },
        ],
      },
    ],
  },
}
