/**
 * SDK Flow & Navigation
 *
 * Step definitions, step ordering, and the SDK_STEPS constant
 * that drives the entire compliance workflow.
 */

import type { SDKPhase, SDKPackageId } from './core'

// =============================================================================
// SDK STEP
// =============================================================================

export interface SDKStep {
  id: string
  phase: SDKPhase
  package: SDKPackageId
  order: number
  name: string
  nameShort: string
  description: string
  url: string
  checkpointId: string
  prerequisiteSteps: string[]
  isOptional: boolean
}

// =============================================================================
// SDK_STEPS — All steps in order
// =============================================================================

export const SDK_STEPS: SDKStep[] = [
  // =============================================================================
  // PAKET 1: VORBEREITUNG (Foundation)
  // =============================================================================
  {
    id: 'company-profile',
    phase: 1,
    package: 'vorbereitung',
    order: 1,
    name: 'Unternehmensprofil',
    nameShort: 'Profil',
    description: 'Gesch\u00e4ftsmodell, Gr\u00f6\u00dfe und Zielm\u00e4rkte erfassen',
    url: '/sdk/company-profile',
    checkpointId: 'CP-PROF',
    prerequisiteSteps: [],
    isOptional: false,
  },
  {
    id: 'compliance-scope',
    phase: 1,
    package: 'vorbereitung',
    order: 2,
    name: 'Compliance Scope',
    nameShort: 'Scope',
    description: 'Umfang und Tiefe Ihrer Compliance-Dokumentation bestimmen',
    url: '/sdk/compliance-scope',
    checkpointId: 'CP-SCOPE',
    prerequisiteSteps: ['company-profile'],
    isOptional: false,
  },
  {
    id: 'use-case-assessment',
    phase: 1,
    package: 'vorbereitung',
    order: 3,
    name: 'Anwendungsfall-Erfassung',
    nameShort: 'Anwendung',
    description: 'AI-Anwendungsf\u00e4lle strukturiert dokumentieren',
    url: '/sdk/advisory-board',
    checkpointId: 'CP-UC',
    prerequisiteSteps: ['company-profile'],
    isOptional: false,
  },
  {
    id: 'import',
    phase: 1,
    package: 'vorbereitung',
    order: 4,
    name: 'Dokument-Import',
    nameShort: 'Import',
    description: 'Bestehende Dokumente hochladen (Bestandskunden)',
    url: '/sdk/import',
    checkpointId: 'CP-IMP',
    prerequisiteSteps: ['use-case-assessment'],
    isOptional: true, // Nur fuer Bestandskunden
  },
  {
    id: 'screening',
    phase: 1,
    package: 'vorbereitung',
    order: 5,
    name: 'System Screening',
    nameShort: 'Screening',
    description: 'SBOM + Security Check',
    url: '/sdk/screening',
    checkpointId: 'CP-SCAN',
    prerequisiteSteps: ['use-case-assessment'],
    isOptional: false,
  },
  {
    id: 'modules',
    phase: 1,
    package: 'vorbereitung',
    order: 6,
    name: 'Compliance Modules',
    nameShort: 'Module',
    description: 'Abgleich welche Regulierungen gelten',
    url: '/sdk/modules',
    checkpointId: 'CP-MOD',
    prerequisiteSteps: ['screening'],
    isOptional: false,
  },
  {
    id: 'source-policy',
    phase: 1,
    package: 'vorbereitung',
    order: 7,
    name: 'Source Policy',
    nameShort: 'Quellen',
    description: 'Datenquellen-Governance & Whitelist',
    url: '/sdk/source-policy',
    checkpointId: 'CP-SPOL',
    prerequisiteSteps: ['modules'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 2: ANALYSE (Assessment)
  // =============================================================================
  {
    id: 'requirements',
    phase: 1,
    package: 'analyse',
    order: 1,
    name: 'Requirements',
    nameShort: 'Anforderungen',
    description: 'Pr\u00fcfaspekte aus Regulierungen ableiten',
    url: '/sdk/requirements',
    checkpointId: 'CP-REQ',
    prerequisiteSteps: ['source-policy'],
    isOptional: false,
  },
  {
    id: 'controls',
    phase: 1,
    package: 'analyse',
    order: 2,
    name: 'Controls',
    nameShort: 'Controls',
    description: 'Erforderliche Ma\u00dfnahmen ermitteln',
    url: '/sdk/controls',
    checkpointId: 'CP-CTRL',
    prerequisiteSteps: ['requirements'],
    isOptional: false,
  },
  {
    id: 'evidence',
    phase: 1,
    package: 'analyse',
    order: 3,
    name: 'Evidence',
    nameShort: 'Nachweise',
    description: 'Nachweise dokumentieren',
    url: '/sdk/evidence',
    checkpointId: 'CP-EVI',
    prerequisiteSteps: ['controls'],
    isOptional: false,
  },
  {
    id: 'risks',
    phase: 1,
    package: 'analyse',
    order: 4,
    name: 'Risk Matrix',
    nameShort: 'Risiken',
    description: 'Risikobewertung & Residual Risk',
    url: '/sdk/risks',
    checkpointId: 'CP-RISK',
    prerequisiteSteps: ['evidence'],
    isOptional: false,
  },
  {
    id: 'ai-act',
    phase: 1,
    package: 'analyse',
    order: 5,
    name: 'AI Act Klassifizierung',
    nameShort: 'AI Act',
    description: 'Risikostufe nach EU AI Act',
    url: '/sdk/ai-act',
    checkpointId: 'CP-AI',
    prerequisiteSteps: ['risks'],
    isOptional: false,
  },
  {
    id: 'audit-checklist',
    phase: 1,
    package: 'analyse',
    order: 6,
    name: 'Audit Checklist',
    nameShort: 'Checklist',
    description: 'Pr\u00fcfliste generieren',
    url: '/sdk/audit-checklist',
    checkpointId: 'CP-CHK',
    prerequisiteSteps: ['ai-act'],
    isOptional: false,
  },
  {
    id: 'audit-report',
    phase: 1,
    package: 'analyse',
    order: 7,
    name: 'Audit Report',
    nameShort: 'Report',
    description: 'Audit-Sitzungen & PDF-Report',
    url: '/sdk/audit-report',
    checkpointId: 'CP-AREP',
    prerequisiteSteps: ['audit-checklist'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 3: DOKUMENTATION (Compliance Docs)
  // =============================================================================
  {
    id: 'obligations',
    phase: 2,
    package: 'dokumentation',
    order: 1,
    name: 'Pflichten\u00fcbersicht',
    nameShort: 'Pflichten',
    description: 'NIS2, DSGVO, AI Act Pflichten',
    url: '/sdk/obligations',
    checkpointId: 'CP-OBL',
    prerequisiteSteps: ['audit-report'],
    isOptional: false,
  },
  {
    id: 'dsfa',
    phase: 2,
    package: 'dokumentation',
    order: 2,
    name: 'DSFA',
    nameShort: 'DSFA',
    description: 'Datenschutz-Folgenabsch\u00e4tzung',
    url: '/sdk/dsfa',
    checkpointId: 'CP-DSFA',
    prerequisiteSteps: ['obligations'],
    isOptional: true, // Only if dsfa_recommended
  },
  {
    id: 'tom',
    phase: 2,
    package: 'dokumentation',
    order: 3,
    name: 'TOMs',
    nameShort: 'TOMs',
    description: 'Technische & Org. Ma\u00dfnahmen',
    url: '/sdk/tom',
    checkpointId: 'CP-TOM',
    prerequisiteSteps: ['dsfa'],
    isOptional: false,
  },
  {
    id: 'loeschfristen',
    phase: 2,
    package: 'dokumentation',
    order: 4,
    name: 'L\u00f6schfristen',
    nameShort: 'L\u00f6schfristen',
    description: 'Aufbewahrungsrichtlinien',
    url: '/sdk/loeschfristen',
    checkpointId: 'CP-RET',
    prerequisiteSteps: ['tom'],
    isOptional: false,
  },
  {
    id: 'vvt',
    phase: 2,
    package: 'dokumentation',
    order: 5,
    name: 'Verarbeitungsverzeichnis',
    nameShort: 'VVT',
    description: 'Art. 30 DSGVO Dokumentation',
    url: '/sdk/vvt',
    checkpointId: 'CP-VVT',
    prerequisiteSteps: ['loeschfristen'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 4: RECHTLICHE TEXTE (Legal Outputs)
  // =============================================================================
  {
    id: 'einwilligungen',
    phase: 2,
    package: 'rechtliche-texte',
    order: 1,
    name: 'Einwilligungen',
    nameShort: 'Einwilligungen',
    description: 'Datenpunktkatalog & DSI-Generator',
    url: '/sdk/einwilligungen',
    checkpointId: 'CP-CONS',
    prerequisiteSteps: ['vvt'],
    isOptional: false,
  },
  {
    id: 'consent',
    phase: 2,
    package: 'rechtliche-texte',
    order: 2,
    name: 'Rechtliche Vorlagen',
    nameShort: 'Vorlagen',
    description: 'AGB, Datenschutz, Nutzungsbedingungen',
    url: '/sdk/consent',
    checkpointId: 'CP-DOC',
    prerequisiteSteps: ['einwilligungen'],
    isOptional: false,
  },
  {
    id: 'cookie-banner',
    phase: 2,
    package: 'rechtliche-texte',
    order: 3,
    name: 'Cookie Banner',
    nameShort: 'Cookies',
    description: 'Cookie-Consent Generator',
    url: '/sdk/cookie-banner',
    checkpointId: 'CP-COOK',
    prerequisiteSteps: ['consent'],
    isOptional: false,
  },
  {
    id: 'document-generator',
    phase: 2,
    package: 'rechtliche-texte',
    order: 4,
    name: 'Dokumentengenerator',
    nameShort: 'Generator',
    description: 'Rechtliche Dokumente aus Vorlagen erstellen',
    url: '/sdk/document-generator',
    checkpointId: 'CP-DOCGEN',
    prerequisiteSteps: ['cookie-banner'],
    isOptional: true,
  },
  {
    id: 'workflow',
    phase: 2,
    package: 'rechtliche-texte',
    order: 5,
    name: 'Document Workflow',
    nameShort: 'Workflow',
    description: 'Versionierung & Freigabe-Workflow',
    url: '/sdk/workflow',
    checkpointId: 'CP-WRKF',
    prerequisiteSteps: ['document-generator'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 5: BETRIEB (Operations)
  // =============================================================================
  {
    id: 'dsr',
    phase: 2,
    package: 'betrieb',
    order: 1,
    name: 'DSR Portal',
    nameShort: 'DSR',
    description: 'Betroffenenrechte-Portal',
    url: '/sdk/dsr',
    checkpointId: 'CP-DSR',
    prerequisiteSteps: ['workflow'],
    isOptional: false,
  },
  {
    id: 'escalations',
    phase: 2,
    package: 'betrieb',
    order: 2,
    name: 'Escalations',
    nameShort: 'Eskalationen',
    description: 'Management-Workflows',
    url: '/sdk/escalations',
    checkpointId: 'CP-ESC',
    prerequisiteSteps: ['dsr'],
    isOptional: false,
  },
  {
    id: 'vendor-compliance',
    phase: 2,
    package: 'betrieb',
    order: 3,
    name: 'Vendor Compliance',
    nameShort: 'Vendor',
    description: 'Dienstleister-Management',
    url: '/sdk/vendor-compliance',
    checkpointId: 'CP-VEND',
    prerequisiteSteps: ['escalations'],
    isOptional: false,
  },
  {
    id: 'consent-management',
    phase: 2,
    package: 'betrieb',
    order: 4,
    name: 'Consent Verwaltung',
    nameShort: 'Consent Mgmt',
    description: 'Dokument-Lifecycle & DSGVO-Prozesse',
    url: '/sdk/consent-management',
    checkpointId: 'CP-CMGMT',
    prerequisiteSteps: ['vendor-compliance'],
    isOptional: false,
  },
  {
    id: 'notfallplan',
    phase: 2,
    package: 'betrieb',
    order: 5,
    name: 'Notfallplan & Breach Response',
    nameShort: 'Notfallplan',
    description: 'Datenpannen-Management nach Art. 33/34 DSGVO',
    url: '/sdk/notfallplan',
    checkpointId: 'CP-NOTF',
    prerequisiteSteps: ['consent-management'],
    isOptional: false,
  },
]
