import { lazy, type ComponentType } from 'react';

type LazyComponent = React.LazyExoticComponent<ComponentType<unknown>>;

/**
 * DB menu_config.component_key → lazy-loaded React 컴포넌트 매핑.
 * 메뉴 추가 시 이 레지스트리에 1줄만 추가하면 됨.
 */
export const COMPONENT_REGISTRY: Record<string, LazyComponent> = {
  // ── 상황판·감시 ──
  'features/dashboard/Dashboard': lazy(() =>
    import('@features/dashboard/Dashboard').then((m) => ({ default: m.Dashboard })),
  ),
  'features/monitoring/MonitoringDashboard': lazy(() =>
    import('@features/monitoring/MonitoringDashboard').then((m) => ({
      default: m.MonitoringDashboard,
    })),
  ),
  'features/surveillance/LiveMapView': lazy(() =>
    import('@features/surveillance').then((m) => ({ default: m.LiveMapView })),
  ),
  'features/surveillance/MapControl': lazy(() =>
    import('@features/surveillance').then((m) => ({ default: m.MapControl })),
  ),
  // ── 위험도·단속 ──
  'features/risk-assessment/RiskMap': lazy(() =>
    import('@features/risk-assessment').then((m) => ({ default: m.RiskMap })),
  ),
  'features/risk-assessment/EnforcementPlan': lazy(() =>
    import('@features/risk-assessment').then((m) => ({ default: m.EnforcementPlan })),
  ),
  // ── 탐지 ──
  'features/detection/DarkVesselDetection': lazy(() =>
    import('@features/detection').then((m) => ({ default: m.DarkVesselDetection })),
  ),
  'features/detection/GearDetection': lazy(() =>
    import('@features/detection').then((m) => ({ default: m.GearDetection })),
  ),
  'features/detection/ChinaFishing': lazy(() =>
    import('@features/detection').then((m) => ({ default: m.ChinaFishing })),
  ),
  // ── 단속·이벤트 ──
  'features/enforcement/EnforcementHistory': lazy(() =>
    import('@features/enforcement').then((m) => ({ default: m.EnforcementHistory })),
  ),
  'features/enforcement/EventList': lazy(() =>
    import('@features/enforcement').then((m) => ({ default: m.EventList })),
  ),
  // ── 통계 ──
  'features/statistics/Statistics': lazy(() =>
    import('@features/statistics').then((m) => ({ default: m.Statistics })),
  ),
  'features/statistics/ReportManagement': lazy(() =>
    import('@features/statistics').then((m) => ({ default: m.ReportManagement })),
  ),
  'features/statistics/ExternalService': lazy(() =>
    import('@features/statistics').then((m) => ({ default: m.ExternalService })),
  ),
  // ── 순찰 ──
  'features/patrol/PatrolRoute': lazy(() =>
    import('@features/patrol').then((m) => ({ default: m.PatrolRoute })),
  ),
  'features/patrol/FleetOptimization': lazy(() =>
    import('@features/patrol').then((m) => ({ default: m.FleetOptimization })),
  ),
  // ── 현장작전 ──
  'features/field-ops/AIAlert': lazy(() =>
    import('@features/field-ops').then((m) => ({ default: m.AIAlert })),
  ),
  'features/field-ops/MobileService': lazy(() =>
    import('@features/field-ops').then((m) => ({ default: m.MobileService })),
  ),
  'features/field-ops/ShipAgent': lazy(() =>
    import('@features/field-ops').then((m) => ({ default: m.ShipAgent })),
  ),
  // ── AI 운영 ──
  'features/ai-operations/AIModelManagement': lazy(() =>
    import('@features/ai-operations').then((m) => ({ default: m.AIModelManagement })),
  ),
  'features/ai-operations/MLOpsPage': lazy(() =>
    import('@features/ai-operations').then((m) => ({ default: m.MLOpsPage })),
  ),
  'features/ai-operations/LGCNSMLOpsPage': lazy(() =>
    import('@features/ai-operations').then((m) => ({ default: m.LGCNSMLOpsPage })),
  ),
  'features/ai-operations/LLMOpsPage': lazy(() =>
    import('@features/ai-operations').then((m) => ({ default: m.LLMOpsPage })),
  ),
  'features/ai-operations/AIAssistant': lazy(() =>
    import('@features/ai-operations').then((m) => ({ default: m.AIAssistant })),
  ),
  // ── 관리 ──
  'features/admin/AdminPanel': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.AdminPanel })),
  ),
  'features/admin/SystemConfig': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.SystemConfig })),
  ),
  'features/admin/DataHub': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.DataHub })),
  ),
  'features/admin/AccessControl': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.AccessControl })),
  ),
  'features/admin/NoticeManagement': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.NoticeManagement })),
  ),
  'features/admin/AuditLogs': lazy(() =>
    import('@features/admin/AuditLogs').then((m) => ({ default: m.AuditLogs })),
  ),
  'features/admin/AccessLogs': lazy(() =>
    import('@features/admin/AccessLogs').then((m) => ({ default: m.AccessLogs })),
  ),
  'features/admin/LoginHistoryView': lazy(() =>
    import('@features/admin/LoginHistoryView').then((m) => ({
      default: m.LoginHistoryView,
    })),
  ),
  'features/admin/AISecurityPage': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.AISecurityPage })),
  ),
  'features/admin/AIAgentSecurityPage': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.AIAgentSecurityPage })),
  ),
  'features/admin/DataRetentionPolicy': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.DataRetentionPolicy })),
  ),
  'features/admin/DataModelVerification': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.DataModelVerification })),
  ),
  'features/admin/PerformanceMonitoring': lazy(() =>
    import('@features/admin').then((m) => ({ default: m.PerformanceMonitoring })),
  ),
  // ── 모선 워크플로우 ──
  'features/parent-inference/ParentReview': lazy(() =>
    import('@features/parent-inference/ParentReview').then((m) => ({
      default: m.ParentReview,
    })),
  ),
  'features/parent-inference/ParentExclusion': lazy(() =>
    import('@features/parent-inference/ParentExclusion').then((m) => ({
      default: m.ParentExclusion,
    })),
  ),
  'features/parent-inference/LabelSession': lazy(() =>
    import('@features/parent-inference/LabelSession').then((m) => ({
      default: m.LabelSession,
    })),
  ),
  // ── 선박 (숨김 라우트) ──
  'features/vessel/VesselDetail': lazy(() =>
    import('@features/vessel').then((m) => ({ default: m.VesselDetail })),
  ),
};
