/**
 * Company Profile types
 *
 * Business context collected before use cases: company info,
 * business model, offerings, target markets, legal form.
 */

import type { SDKPackageId } from './core'

// =============================================================================
// COMPANY PROFILE ENUMS
// =============================================================================

export type BusinessModel = 'B2B' | 'B2C' | 'B2B_B2C'

export type OfferingType =
  | 'app_mobile'           // Mobile App
  | 'app_web'              // Web Application
  | 'website'              // Website/Landing Pages
  | 'webshop'              // E-Commerce
  | 'hardware'             // Hardware sales
  | 'software_saas'        // SaaS/Software products
  | 'software_onpremise'   // On-Premise Software
  | 'services_consulting'  // Consulting/Professional Services
  | 'services_agency'      // Agency Services
  | 'internal_only'        // Internal applications only

export type TargetMarket =
  | 'germany_only'         // Only Germany
  | 'dach'                 // Germany, Austria, Switzerland
  | 'eu'                   // European Union
  | 'ewr'                  // European Economic Area (EU + Iceland, Liechtenstein, Norway)
  | 'eu_uk'                // EU + United Kingdom
  | 'worldwide'            // Global operations

export type CompanySize = 'micro' | 'small' | 'medium' | 'large' | 'enterprise'

export type LegalForm =
  | 'einzelunternehmen'    // Sole proprietorship
  | 'gbr'                  // GbR
  | 'ohg'                  // OHG
  | 'kg'                   // KG
  | 'gmbh'                 // GmbH
  | 'ug'                   // UG (haftungsbeschraenkt)
  | 'ag'                   // AG
  | 'gmbh_co_kg'           // GmbH & Co. KG
  | 'ev'                   // e.V. (Verein)
  | 'stiftung'             // Foundation
  | 'other'                // Other

// =============================================================================
// COMPANY PROFILE INTERFACE
// =============================================================================

export interface CompanyProfile {
  // Basic Info
  companyName: string
  legalForm: LegalForm
  industry: string              // Free text or NACE code
  foundedYear: number | null

  // Business Model
  businessModel: BusinessModel
  offerings: OfferingType[]

  // Size & Scope
  companySize: CompanySize
  employeeCount: string         // Range: "1-9", "10-49", "50-249", "250-999", "1000+"
  annualRevenue: string         // Range: "< 2 Mio", "2-10 Mio", "10-50 Mio", "> 50 Mio"

  // Locations
  headquartersCountry: string   // ISO country code, e.g., "DE"
  headquartersCity: string
  hasInternationalLocations: boolean
  internationalCountries: string[]  // ISO country codes

  // Target Markets & Legal Scope
  targetMarkets: TargetMarket[]
  primaryJurisdiction: string   // Which law primarily applies: "DE", "AT", "CH", etc.

  // Data Processing Role
  isDataController: boolean     // Verantwortlicher (Art. 4 Nr. 7 DSGVO)
  isDataProcessor: boolean      // Auftragsverarbeiter (Art. 4 Nr. 8 DSGVO)

  // AI Usage
  usesAI: boolean
  aiUseCases: string[]          // Brief descriptions

  // Contact Persons
  dpoName: string | null        // Data Protection Officer
  dpoEmail: string | null
  legalContactName: string | null
  legalContactEmail: string | null

  // Completion Status
  isComplete: boolean
  completedAt: Date | null
}

// =============================================================================
// COVERAGE ASSESSMENT
// =============================================================================

export interface SDKCoverageAssessment {
  isFullyCovered: boolean
  coveredRegulations: string[]
  partiallyCoveredRegulations: string[]
  notCoveredRegulations: string[]
  requiresLegalCounsel: boolean
  reasons: string[]
  recommendations: string[]
}

// =============================================================================
// DISPLAY LABELS
// =============================================================================

export const COMPANY_SIZE_LABELS: Record<CompanySize, string> = {
  micro: 'Kleinstunternehmen (< 10 MA)',
  small: 'Kleinunternehmen (10-49 MA)',
  medium: 'Mittelstand (50-249 MA)',
  large: 'Gro\u00dfunternehmen (250-999 MA)',
  enterprise: 'Konzern (1000+ MA)',
}

export const BUSINESS_MODEL_LABELS: Record<BusinessModel, string> = {
  B2B: 'B2B (Gesch\u00e4ftskunden)',
  B2C: 'B2C (Privatkunden)',
  B2B_B2C: 'B2B und B2C',
}

export const OFFERING_TYPE_LABELS: Record<OfferingType, { label: string; description: string }> = {
  app_mobile: { label: 'Mobile App', description: 'iOS/Android Anwendungen' },
  app_web: { label: 'Web-Anwendung', description: 'Browser-basierte Software' },
  website: { label: 'Website', description: 'Informationsseiten, Landing Pages' },
  webshop: { label: 'Online-Shop', description: 'E-Commerce, Produktverkauf' },
  hardware: { label: 'Hardware-Verkauf', description: 'Physische Produkte' },
  software_saas: { label: 'SaaS/Cloud', description: 'Software as a Service' },
  software_onpremise: { label: 'On-Premise Software', description: 'Lokale Installation' },
  services_consulting: { label: 'Beratung', description: 'Consulting, Professional Services' },
  services_agency: { label: 'Agentur', description: 'Marketing, Design, Entwicklung' },
  internal_only: { label: 'Nur intern', description: 'Interne Unternehmensanwendungen' },
}

export const TARGET_MARKET_LABELS: Record<TargetMarket, { label: string; description: string; regulations: string[] }> = {
  germany_only: {
    label: 'Nur Deutschland',
    description: 'Verkauf nur in Deutschland',
    regulations: ['DSGVO', 'BDSG', 'TTDSG', 'AI Act'],
  },
  dach: {
    label: 'DACH-Region',
    description: 'Deutschland, \u00d6sterreich, Schweiz',
    regulations: ['DSGVO', 'BDSG', 'DSG (AT)', 'DSG (CH)', 'AI Act'],
  },
  eu: {
    label: 'Europ\u00e4ische Union',
    description: 'Alle EU-Mitgliedsstaaten',
    regulations: ['DSGVO', 'AI Act', 'NIS2', 'DMA/DSA'],
  },
  ewr: {
    label: 'EWR',
    description: 'EU + Island, Liechtenstein, Norwegen',
    regulations: ['DSGVO', 'AI Act', 'NIS2', 'EWR-Sonderregelungen'],
  },
  eu_uk: {
    label: 'EU + Gro\u00dfbritannien',
    description: 'EU plus Vereinigtes K\u00f6nigreich',
    regulations: ['DSGVO', 'UK GDPR', 'AI Act', 'UK AI Framework'],
  },
  worldwide: {
    label: 'Weltweit',
    description: 'Globaler Verkauf/Betrieb',
    regulations: ['DSGVO', 'CCPA', 'LGPD', 'POPIA', 'und weitere...'],
  },
}

// =============================================================================
// SDK PACKAGE DEFINITION
// =============================================================================

export interface SDKPackage {
  id: SDKPackageId
  order: number
  name: string
  nameShort: string
  description: string
  icon: string
  result: string
}

export const SDK_PACKAGES: SDKPackage[] = [
  {
    id: 'vorbereitung',
    order: 1,
    name: 'Vorbereitung',
    nameShort: 'Vorbereitung',
    description: 'Grundlagen erfassen, Ausgangssituation verstehen',
    icon: '\ud83c\udfaf',
    result: 'Klares Verst\u00e4ndnis, welche Regulierungen greifen',
  },
  {
    id: 'analyse',
    order: 2,
    name: 'Analyse',
    nameShort: 'Analyse',
    description: 'Risiken erkennen, Anforderungen ableiten',
    icon: '\ud83d\udd0d',
    result: 'Vollst\u00e4ndige Risikobewertung, Audit-Ready',
  },
  {
    id: 'dokumentation',
    order: 3,
    name: 'Dokumentation',
    nameShort: 'Doku',
    description: 'Rechtliche Pflichtnachweise erstellen',
    icon: '\ud83d\udccb',
    result: 'DSFA, TOMs, VVT, L\u00f6schkonzept',
  },
  {
    id: 'rechtliche-texte',
    order: 4,
    name: 'Rechtliche Texte',
    nameShort: 'Legal',
    description: 'Kundenf\u00e4hige Dokumente generieren',
    icon: '\ud83d\udcdd',
    result: 'AGB, DSI, Nutzungsbedingungen, Cookie-Banner (Code)',
  },
  {
    id: 'betrieb',
    order: 5,
    name: 'Betrieb',
    nameShort: 'Betrieb',
    description: 'Laufender Compliance-Betrieb',
    icon: '\u2699\ufe0f',
    result: 'DSR-Portal, Eskalationsprozesse, Vendor-Management',
  },
]
