/**
 * Shared RAG constants used by both page.tsx and ChunkBrowserQA.
 * REGULATIONS_IN_RAG maps regulation codes to their Qdrant collection, chunk count, and qdrant_id.
 * The qdrant_id is the actual `regulation_id` value stored in Qdrant payloads.
 * REGULATION_INFO provides minimal metadata (code, name, type) for all regulations.
 */

export interface RagRegulationEntry {
  collection: string
  chunks: number
  qdrant_id: string  // The actual regulation_id value in Qdrant payload
}

export const REGULATIONS_IN_RAG: Record<string, RagRegulationEntry> = {
  // === EU Verordnungen/Richtlinien (bp_compliance_ce) ===
  GDPR: { collection: 'bp_compliance_ce', chunks: 423, qdrant_id: 'eu_2016_679' },
  EPRIVACY: { collection: 'bp_compliance_ce', chunks: 134, qdrant_id: 'eu_2002_58' },
  SCC: { collection: 'bp_compliance_ce', chunks: 330, qdrant_id: 'eu_2021_914' },
  SCC_FULL_TEXT: { collection: 'bp_compliance_ce', chunks: 330, qdrant_id: 'eu_2021_914' },
  AIACT: { collection: 'bp_compliance_ce', chunks: 726, qdrant_id: 'eu_2024_1689' },
  CRA: { collection: 'bp_compliance_ce', chunks: 429, qdrant_id: 'eu_2024_2847' },
  NIS2: { collection: 'bp_compliance_ce', chunks: 342, qdrant_id: 'eu_2022_2555' },
  DGA: { collection: 'bp_compliance_ce', chunks: 508, qdrant_id: 'eu_2022_868' },
  DSA: { collection: 'bp_compliance_ce', chunks: 1106, qdrant_id: 'eu_2022_2065' },
  PLD: { collection: 'bp_compliance_ce', chunks: 44, qdrant_id: 'eu_1985_374' },
  E_COMMERCE_RL: { collection: 'bp_compliance_ce', chunks: 197, qdrant_id: 'eu_2000_31' },
  VERBRAUCHERRECHTE_RL: { collection: 'bp_compliance_ce', chunks: 266, qdrant_id: 'eu_2011_83' },
  DIGITALE_INHALTE_RL: { collection: 'bp_compliance_ce', chunks: 321, qdrant_id: 'eu_2019_770' },
  DMA: { collection: 'bp_compliance_ce', chunks: 701, qdrant_id: 'eu_2022_1925' },
  DPF: { collection: 'bp_compliance_ce', chunks: 2464, qdrant_id: 'dpf' },
  EUCSA: { collection: 'bp_compliance_ce', chunks: 558, qdrant_id: 'eucsa' },
  DATAACT: { collection: 'bp_compliance_ce', chunks: 809, qdrant_id: 'dataact' },
  DORA: { collection: 'bp_compliance_ce', chunks: 823, qdrant_id: 'dora' },
  PSD2: { collection: 'bp_compliance_ce', chunks: 796, qdrant_id: 'psd2' },
  AMLR: { collection: 'bp_compliance_ce', chunks: 1182, qdrant_id: 'amlr' },
  MiCA: { collection: 'bp_compliance_ce', chunks: 1640, qdrant_id: 'mica' },
  EHDS: { collection: 'bp_compliance_ce', chunks: 1212, qdrant_id: 'ehds' },
  EAA: { collection: 'bp_compliance_ce', chunks: 433, qdrant_id: 'eaa' },
  DSM: { collection: 'bp_compliance_ce', chunks: 416, qdrant_id: 'dsm' },
  GPSR: { collection: 'bp_compliance_ce', chunks: 509, qdrant_id: 'gpsr' },
  MACHINERY_REG: { collection: 'bp_compliance_ce', chunks: 1271, qdrant_id: 'eu_2023_1230' },
  BLUE_GUIDE: { collection: 'bp_compliance_ce', chunks: 2271, qdrant_id: 'eu_blue_guide_2022' },
  EU_IFRS_DE: { collection: 'bp_compliance_ce', chunks: 34388, qdrant_id: 'eu_2023_1803' },
  EU_IFRS_EN: { collection: 'bp_compliance_ce', chunks: 34388, qdrant_id: 'eu_2023_1803' },
  // International standards in bp_compliance_ce
  NIST_SSDF: { collection: 'bp_compliance_ce', chunks: 111, qdrant_id: 'nist_sp_800_218' },
  NIST_CSF_2: { collection: 'bp_compliance_ce', chunks: 67, qdrant_id: 'nist_csf_2_0' },
  OECD_AI_PRINCIPLES: { collection: 'bp_compliance_ce', chunks: 34, qdrant_id: 'oecd_ai_principles' },
  ENISA_SECURE_BY_DESIGN: { collection: 'bp_compliance_ce', chunks: 97, qdrant_id: 'cisa_secure_by_design' },
  ENISA_SUPPLY_CHAIN: { collection: 'bp_compliance_ce', chunks: 110, qdrant_id: 'enisa_supply_chain_good_practices' },
  ENISA_THREAT_LANDSCAPE: { collection: 'bp_compliance_ce', chunks: 118, qdrant_id: 'enisa_threat_landscape_supply_chain' },
  ENISA_ICS_SCADA: { collection: 'bp_compliance_ce', chunks: 195, qdrant_id: 'enisa_ics_scada_dependencies' },
  ENISA_CYBERSECURITY_2024: { collection: 'bp_compliance_ce', chunks: 22, qdrant_id: 'enisa_cybersecurity_state_2024' },

  // === DE Gesetze (bp_compliance_gesetze) ===
  TDDDG: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'tdddg_25' },
  TMG_KOMPLETT: { collection: 'bp_compliance_gesetze', chunks: 108, qdrant_id: 'tmg_komplett' },
  BDSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 1056, qdrant_id: 'bdsg_2018_komplett' },
  DE_DDG: { collection: 'bp_compliance_gesetze', chunks: 40, qdrant_id: 'ddg_5' },
  DE_BGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 4024, qdrant_id: 'bgb_komplett' },
  DE_EGBGB: { collection: 'bp_compliance_gesetze', chunks: 36, qdrant_id: 'egbgb_widerruf' },
  DE_HGB_RET: { collection: 'bp_compliance_gesetze', chunks: 11363, qdrant_id: 'hgb_komplett' },
  DE_AO_RET: { collection: 'bp_compliance_gesetze', chunks: 9669, qdrant_id: 'ao_komplett' },
  DE_TKG: { collection: 'bp_compliance_gesetze', chunks: 1631, qdrant_id: 'de_tkg' },
  DE_DLINFOV: { collection: 'bp_compliance_gesetze', chunks: 21, qdrant_id: 'de_dlinfov' },
  DE_BETRVG: { collection: 'bp_compliance_gesetze', chunks: 498, qdrant_id: 'de_betrvg' },
  DE_GESCHGEHG: { collection: 'bp_compliance_gesetze', chunks: 63, qdrant_id: 'de_geschgehg' },
  DE_USTG_RET: { collection: 'bp_compliance_gesetze', chunks: 1071, qdrant_id: 'de_ustg_ret' },
  DE_URHG: { collection: 'bp_compliance_gesetze', chunks: 626, qdrant_id: 'urhg_komplett' },

  // === BSI Standards (bp_compliance_gesetze) ===
  'BSI-TR-03161-1': { collection: 'bp_compliance_gesetze', chunks: 138, qdrant_id: 'bsi_tr_03161_1' },
  'BSI-TR-03161-2': { collection: 'bp_compliance_gesetze', chunks: 124, qdrant_id: 'bsi_tr_03161_2' },
  'BSI-TR-03161-3': { collection: 'bp_compliance_gesetze', chunks: 121, qdrant_id: 'bsi_tr_03161_3' },

  // === AT Gesetze (bp_compliance_gesetze) ===
  AT_DSG: { collection: 'bp_compliance_gesetze', chunks: 805, qdrant_id: 'at_dsg' },
  AT_DSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 6, qdrant_id: 'at_dsg_full' },
  AT_ECG: { collection: 'bp_compliance_gesetze', chunks: 120, qdrant_id: 'at_ecg' },
  AT_TKG: { collection: 'bp_compliance_gesetze', chunks: 4348, qdrant_id: 'at_tkg' },
  AT_KSCHG: { collection: 'bp_compliance_gesetze', chunks: 402, qdrant_id: 'at_kschg' },
  AT_FAGG: { collection: 'bp_compliance_gesetze', chunks: 2, qdrant_id: 'at_fagg' },
  AT_UGB_RET: { collection: 'bp_compliance_gesetze', chunks: 2828, qdrant_id: 'at_ugb_ret' },
  AT_BAO_RET: { collection: 'bp_compliance_gesetze', chunks: 2246, qdrant_id: 'at_bao_ret' },
  AT_MEDIENG: { collection: 'bp_compliance_gesetze', chunks: 571, qdrant_id: 'at_medieng' },
  AT_ABGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 2521, qdrant_id: 'at_abgb_agb' },
  AT_UWG: { collection: 'bp_compliance_gesetze', chunks: 403, qdrant_id: 'at_uwg' },

  // === CH Gesetze (bp_compliance_gesetze) ===
  CH_DSG: { collection: 'bp_compliance_gesetze', chunks: 180, qdrant_id: 'ch_revdsg' },
  CH_DSV: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_dsv' },
  CH_OR_AGB: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_or_agb' },
  CH_GEBUV: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_gebuv' },
  CH_ZERTES: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_zertes' },
  CH_ZGB_PERS: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_zgb_pers' },

  // === Nationale Gesetze (andere EU) in bp_compliance_gesetze ===
  ES_LOPDGDD: { collection: 'bp_compliance_gesetze', chunks: 782, qdrant_id: 'es_lopdgdd' },
  IT_CODICE_PRIVACY: { collection: 'bp_compliance_gesetze', chunks: 59, qdrant_id: 'it_codice_privacy' },
  NL_UAVG: { collection: 'bp_compliance_gesetze', chunks: 523, qdrant_id: 'nl_uavg' },
  FR_CNIL_GUIDE: { collection: 'bp_compliance_gesetze', chunks: 562, qdrant_id: 'fr_loi_informatique' },
  IE_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 64, qdrant_id: 'ie_dpa_2018' },
  UK_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 156, qdrant_id: 'uk_dpa_2018' },
  UK_GDPR: { collection: 'bp_compliance_gesetze', chunks: 45, qdrant_id: 'uk_gdpr' },
  NO_PERSONOPPLYSNINGSLOVEN: { collection: 'bp_compliance_gesetze', chunks: 41, qdrant_id: 'no_pol' },
  SE_DATASKYDDSLAG: { collection: 'bp_compliance_gesetze', chunks: 56, qdrant_id: 'se_dataskyddslag' },
  PL_UODO: { collection: 'bp_compliance_gesetze', chunks: 39, qdrant_id: 'pl_ustawa' },
  CZ_ZOU: { collection: 'bp_compliance_gesetze', chunks: 238, qdrant_id: 'cz_zakon' },
  HU_INFOTV: { collection: 'bp_compliance_gesetze', chunks: 747, qdrant_id: 'hu_info_tv' },
  LU_DPA_LAW: { collection: 'bp_compliance_gesetze', chunks: 2, qdrant_id: 'lu_dpa_law' },

  // === EDPB Guidelines (bp_compliance_datenschutz) ===
  EDPB_GUIDELINES_5_2020: { collection: 'bp_compliance_datenschutz', chunks: 236, qdrant_id: 'edpb_05_2020' },
  EDPB_GUIDELINES_7_2020: { collection: 'bp_compliance_datenschutz', chunks: 347, qdrant_id: 'edpb_guidelines_7_2020' },
  EDPB_GUIDELINES_1_2020: { collection: 'bp_compliance_datenschutz', chunks: 337, qdrant_id: 'edpb_01_2020' },
  EDPB_GUIDELINES_1_2022: { collection: 'bp_compliance_datenschutz', chunks: 510, qdrant_id: 'edpb_01_2022' },
  EDPB_GUIDELINES_2_2023: { collection: 'bp_compliance_datenschutz', chunks: 94, qdrant_id: 'edpb_02_2023' },
  EDPB_GUIDELINES_2_2024: { collection: 'bp_compliance_datenschutz', chunks: 79, qdrant_id: 'edpb_02_2024' },
  EDPB_GUIDELINES_4_2019: { collection: 'bp_compliance_datenschutz', chunks: 202, qdrant_id: 'edpb_04_2019' },
  EDPB_GUIDELINES_9_2022: { collection: 'bp_compliance_datenschutz', chunks: 243, qdrant_id: 'edpb_09_2022' },
  EDPB_DPIA_LIST: { collection: 'bp_compliance_datenschutz', chunks: 29, qdrant_id: 'edpb_dpia_list' },
  EDPB_LEGITIMATE_INTEREST: { collection: 'bp_compliance_datenschutz', chunks: 336, qdrant_id: 'edpb_legitimate_interest' },
  EDPS_DPIA_LIST: { collection: 'bp_compliance_datenschutz', chunks: 35, qdrant_id: 'edps_dpia_list' },
}

/**
 * Minimal regulation info for sidebar display.
 * Full REGULATIONS array with descriptions remains in page.tsx.
 */
export interface RegulationInfo {
  code: string
  name: string
  type: string
}

export const REGULATION_INFO: RegulationInfo[] = [
  // EU Verordnungen
  { code: 'GDPR', name: 'DSGVO', type: 'eu_regulation' },
  { code: 'EPRIVACY', name: 'ePrivacy-Richtlinie', type: 'eu_directive' },
  { code: 'SCC', name: 'Standardvertragsklauseln', type: 'eu_regulation' },
  { code: 'SCC_FULL_TEXT', name: 'SCC Volltext', type: 'eu_regulation' },
  { code: 'DPF', name: 'EU-US Data Privacy Framework', type: 'eu_regulation' },
  { code: 'AIACT', name: 'EU AI Act', type: 'eu_regulation' },
  { code: 'CRA', name: 'Cyber Resilience Act', type: 'eu_regulation' },
  { code: 'NIS2', name: 'NIS2-Richtlinie', type: 'eu_directive' },
  { code: 'EUCSA', name: 'EU Cybersecurity Act', type: 'eu_regulation' },
  { code: 'DATAACT', name: 'Data Act', type: 'eu_regulation' },
  { code: 'DGA', name: 'Data Governance Act', type: 'eu_regulation' },
  { code: 'DSA', name: 'Digital Services Act', type: 'eu_regulation' },
  { code: 'DMA', name: 'Digital Markets Act', type: 'eu_regulation' },
  { code: 'EAA', name: 'European Accessibility Act', type: 'eu_directive' },
  { code: 'DSM', name: 'DSM-Urheberrechtsrichtlinie', type: 'eu_directive' },
  { code: 'PLD', name: 'Produkthaftungsrichtlinie', type: 'eu_directive' },
  { code: 'GPSR', name: 'General Product Safety', type: 'eu_regulation' },
  { code: 'E_COMMERCE_RL', name: 'E-Commerce-Richtlinie', type: 'eu_directive' },
  { code: 'VERBRAUCHERRECHTE_RL', name: 'Verbraucherrechte-RL', type: 'eu_directive' },
  { code: 'DIGITALE_INHALTE_RL', name: 'Digitale-Inhalte-RL', type: 'eu_directive' },
  // Financial
  { code: 'DORA', name: 'DORA', type: 'eu_regulation' },
  { code: 'PSD2', name: 'PSD2', type: 'eu_directive' },
  { code: 'AMLR', name: 'AML-Verordnung', type: 'eu_regulation' },
  { code: 'MiCA', name: 'MiCA', type: 'eu_regulation' },
  { code: 'EHDS', name: 'EHDS', type: 'eu_regulation' },
  { code: 'MACHINERY_REG', name: 'Maschinenverordnung', type: 'eu_regulation' },
  { code: 'BLUE_GUIDE', name: 'Blue Guide', type: 'eu_regulation' },
  { code: 'EU_IFRS_DE', name: 'EU-IFRS (DE)', type: 'eu_regulation' },
  { code: 'EU_IFRS_EN', name: 'EU-IFRS (EN)', type: 'eu_regulation' },
  // DE Gesetze
  { code: 'TDDDG', name: 'TDDDG', type: 'de_law' },
  { code: 'TMG_KOMPLETT', name: 'TMG', type: 'de_law' },
  { code: 'BDSG_FULL', name: 'BDSG', type: 'de_law' },
  { code: 'DE_DDG', name: 'DDG', type: 'de_law' },
  { code: 'DE_BGB_AGB', name: 'BGB/AGB', type: 'de_law' },
  { code: 'DE_EGBGB', name: 'EGBGB', type: 'de_law' },
  { code: 'DE_HGB_RET', name: 'HGB', type: 'de_law' },
  { code: 'DE_AO_RET', name: 'AO', type: 'de_law' },
  { code: 'DE_TKG', name: 'TKG', type: 'de_law' },
  { code: 'DE_DLINFOV', name: 'DL-InfoV', type: 'de_law' },
  { code: 'DE_BETRVG', name: 'BetrVG', type: 'de_law' },
  { code: 'DE_GESCHGEHG', name: 'GeschGehG', type: 'de_law' },
  { code: 'DE_USTG_RET', name: 'UStG', type: 'de_law' },
  { code: 'DE_URHG', name: 'UrhG', type: 'de_law' },
  // BSI
  { code: 'BSI-TR-03161-1', name: 'BSI-TR Teil 1', type: 'bsi_standard' },
  { code: 'BSI-TR-03161-2', name: 'BSI-TR Teil 2', type: 'bsi_standard' },
  { code: 'BSI-TR-03161-3', name: 'BSI-TR Teil 3', type: 'bsi_standard' },
  // AT
  { code: 'AT_DSG', name: 'DSG Oesterreich', type: 'at_law' },
  { code: 'AT_DSG_FULL', name: 'DSG Volltext', type: 'at_law' },
  { code: 'AT_ECG', name: 'ECG', type: 'at_law' },
  { code: 'AT_TKG', name: 'TKG AT', type: 'at_law' },
  { code: 'AT_KSCHG', name: 'KSchG', type: 'at_law' },
  { code: 'AT_FAGG', name: 'FAGG', type: 'at_law' },
  { code: 'AT_UGB_RET', name: 'UGB', type: 'at_law' },
  { code: 'AT_BAO_RET', name: 'BAO', type: 'at_law' },
  { code: 'AT_MEDIENG', name: 'MedienG', type: 'at_law' },
  { code: 'AT_ABGB_AGB', name: 'ABGB/AGB', type: 'at_law' },
  { code: 'AT_UWG', name: 'UWG AT', type: 'at_law' },
  // CH
  { code: 'CH_DSG', name: 'DSG Schweiz', type: 'ch_law' },
  { code: 'CH_DSV', name: 'DSV', type: 'ch_law' },
  { code: 'CH_OR_AGB', name: 'OR/AGB', type: 'ch_law' },
  { code: 'CH_GEBUV', name: 'GeBuV', type: 'ch_law' },
  { code: 'CH_ZERTES', name: 'ZertES', type: 'ch_law' },
  { code: 'CH_ZGB_PERS', name: 'ZGB', type: 'ch_law' },
  // Andere EU nationale
  { code: 'ES_LOPDGDD', name: 'LOPDGDD Spanien', type: 'national_law' },
  { code: 'IT_CODICE_PRIVACY', name: 'Codice Privacy Italien', type: 'national_law' },
  { code: 'NL_UAVG', name: 'UAVG Niederlande', type: 'national_law' },
  { code: 'FR_CNIL_GUIDE', name: 'CNIL Guide RGPD', type: 'national_law' },
  { code: 'IE_DPA_2018', name: 'DPA 2018 Ireland', type: 'national_law' },
  { code: 'UK_DPA_2018', name: 'DPA 2018 UK', type: 'national_law' },
  { code: 'UK_GDPR', name: 'UK GDPR', type: 'national_law' },
  { code: 'NO_PERSONOPPLYSNINGSLOVEN', name: 'Personopplysningsloven', type: 'national_law' },
  { code: 'SE_DATASKYDDSLAG', name: 'Dataskyddslag Schweden', type: 'national_law' },
  { code: 'PL_UODO', name: 'UODO Polen', type: 'national_law' },
  { code: 'CZ_ZOU', name: 'Zakon Tschechien', type: 'national_law' },
  { code: 'HU_INFOTV', name: 'Infotv. Ungarn', type: 'national_law' },
  { code: 'LU_DPA_LAW', name: 'Datenschutzgesetz Luxemburg', type: 'national_law' },
  // EDPB
  { code: 'EDPB_GUIDELINES_5_2020', name: 'EDPB GL Einwilligung', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_7_2020', name: 'EDPB GL C/P Konzepte', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_1_2020', name: 'EDPB GL Fahrzeuge', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_1_2022', name: 'EDPB GL Bussgelder', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_2_2023', name: 'EDPB GL Art. 37 Scope', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_2_2024', name: 'EDPB GL 2024', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_4_2019', name: 'EDPB GL Art. 25 DPbD', type: 'eu_guideline' },
  { code: 'EDPB_GUIDELINES_9_2022', name: 'EDPB GL Datenschutzverletzung', type: 'eu_guideline' },
  { code: 'EDPB_DPIA_LIST', name: 'EDPB DPIA-Liste', type: 'eu_guideline' },
  { code: 'EDPB_LEGITIMATE_INTEREST', name: 'EDPB Berecht. Interesse', type: 'eu_guideline' },
  { code: 'EDPS_DPIA_LIST', name: 'EDPS DPIA-Liste', type: 'eu_guideline' },
  // International Standards
  { code: 'NIST_SSDF', name: 'NIST SSDF', type: 'international_standard' },
  { code: 'NIST_CSF_2', name: 'NIST CSF 2.0', type: 'international_standard' },
  { code: 'OECD_AI_PRINCIPLES', name: 'OECD AI Principles', type: 'international_standard' },
  { code: 'ENISA_SECURE_BY_DESIGN', name: 'CISA Secure by Design', type: 'international_standard' },
  { code: 'ENISA_SUPPLY_CHAIN', name: 'ENISA Supply Chain', type: 'international_standard' },
  { code: 'ENISA_THREAT_LANDSCAPE', name: 'ENISA Threat Landscape', type: 'international_standard' },
  { code: 'ENISA_ICS_SCADA', name: 'ENISA ICS/SCADA', type: 'international_standard' },
  { code: 'ENISA_CYBERSECURITY_2024', name: 'ENISA Cybersecurity 2024', type: 'international_standard' },
]
