// =============================================================================
// SDM TYPES (Standard-Datenschutzmodell)
// =============================================================================

import type { ControlCategory } from './enums'

export type SDMGewaehrleistungsziel =
  | 'Verfuegbarkeit'
  | 'Integritaet'
  | 'Vertraulichkeit'
  | 'Nichtverkettung'
  | 'Intervenierbarkeit'
  | 'Transparenz'
  | 'Datenminimierung'

export type TOMModuleCategory =
  | 'IDENTITY_AUTH'
  | 'LOGGING'
  | 'DOCUMENTATION'
  | 'SEPARATION'
  | 'RETENTION'
  | 'DELETION'
  | 'TRAINING'
  | 'REVIEW'

/**
 * Maps ControlCategory to SDM Gewaehrleistungsziele.
 * Used by the TOM Dashboard to display SDM coverage.
 */
export const SDM_CATEGORY_MAPPING: Record<ControlCategory, SDMGewaehrleistungsziel[]> = {
  ACCESS_CONTROL: ['Vertraulichkeit'],
  ADMISSION_CONTROL: ['Vertraulichkeit', 'Integritaet'],
  ACCESS_AUTHORIZATION: ['Vertraulichkeit', 'Nichtverkettung'],
  TRANSFER_CONTROL: ['Vertraulichkeit', 'Integritaet'],
  INPUT_CONTROL: ['Integritaet', 'Transparenz'],
  ORDER_CONTROL: ['Transparenz', 'Intervenierbarkeit'],
  AVAILABILITY: ['Verfuegbarkeit'],
  SEPARATION: ['Nichtverkettung', 'Datenminimierung'],
  ENCRYPTION: ['Vertraulichkeit', 'Integritaet'],
  PSEUDONYMIZATION: ['Datenminimierung', 'Nichtverkettung'],
  RESILIENCE: ['Verfuegbarkeit'],
  RECOVERY: ['Verfuegbarkeit', 'Integritaet'],
  REVIEW: ['Transparenz', 'Intervenierbarkeit'],
}

/**
 * Maps ControlCategory to Spec Module Categories.
 */
export const MODULE_CATEGORY_MAPPING: Record<ControlCategory, TOMModuleCategory[]> = {
  ACCESS_CONTROL: ['IDENTITY_AUTH'],
  ADMISSION_CONTROL: ['IDENTITY_AUTH'],
  ACCESS_AUTHORIZATION: ['IDENTITY_AUTH', 'DOCUMENTATION'],
  TRANSFER_CONTROL: ['DOCUMENTATION'],
  INPUT_CONTROL: ['LOGGING'],
  ORDER_CONTROL: ['DOCUMENTATION'],
  AVAILABILITY: ['REVIEW'],
  SEPARATION: ['SEPARATION'],
  ENCRYPTION: ['IDENTITY_AUTH'],
  PSEUDONYMIZATION: ['SEPARATION', 'DELETION'],
  RESILIENCE: ['REVIEW'],
  RECOVERY: ['REVIEW'],
  REVIEW: ['REVIEW', 'TRAINING'],
}
