import React from 'react'

export interface Mitigation {
  id: string
  title: string
  description: string
  reduction_type: 'design' | 'protection' | 'information'
  status: 'planned' | 'implemented' | 'verified'
  linked_hazard_ids: string[]
  linked_hazard_names: string[]
  created_at: string
  verified_at: string | null
  verified_by: string | null
  source?: string
  operational_states?: string[]
  // Expert flags (migration 029).
  is_relevant?: boolean
  is_customer_standard?: boolean
}

export interface Hazard {
  id: string
  name: string
  risk_level: string
  category?: string
  operational_states?: string[]
}

export interface ProtectiveMeasure {
  id: string
  reduction_type: string
  sub_type: string
  name: string
  description: string
  hazard_category: string
  examples: string[]
}

export interface SuggestedMeasure {
  id: string
  reduction_type: string
  sub_type: string
  name: string
  description: string
  hazard_category: string
  examples: string[]
  tags?: string[]
}

export interface MitigationFormData {
  title: string
  description: string
  reduction_type: 'design' | 'protection' | 'information'
  linked_hazard_ids: string[]
}

export const REDUCTION_TYPES = {
  design: {
    label: 'Stufe 1: Design',
    description: 'Inhaerent sichere Konstruktion',
    color: 'border-blue-200 bg-blue-50',
    headerColor: 'bg-blue-100 text-blue-800',
    subTypes: [
      { value: 'geometry', label: 'Geometrie & Anordnung' },
      { value: 'force_energy', label: 'Kraft & Energie' },
      { value: 'material', label: 'Material & Stabilitaet' },
      { value: 'ergonomics', label: 'Ergonomie' },
      { value: 'control_design', label: 'Steuerungstechnik' },
      { value: 'fluid_design', label: 'Pneumatik / Hydraulik' },
    ],
    icon: (
      <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 4a2 2 0 114 0v1a1 1 0 001 1h3a1 1 0 011 1v3a1 1 0 01-1 1h-1a2 2 0 100 4h1a1 1 0 011 1v3a1 1 0 01-1 1h-3a1 1 0 01-1-1v-1a2 2 0 10-4 0v1a1 1 0 01-1 1H7a1 1 0 01-1-1v-3a1 1 0 00-1-1H4a2 2 0 110-4h1a1 1 0 001-1V7a1 1 0 011-1h3a1 1 0 001-1V4z" />
      </svg>
    ),
  },
  protection: {
    label: 'Stufe 2: Schutz',
    description: 'Technische Schutzmassnahmen',
    color: 'border-green-200 bg-green-50',
    headerColor: 'bg-green-100 text-green-800',
    subTypes: [
      { value: 'fixed_guard', label: 'Feststehende Schutzeinrichtung' },
      { value: 'movable_guard', label: 'Bewegliche Schutzeinrichtung' },
      { value: 'electro_sensitive', label: 'Optoelektronisch' },
      { value: 'pressure_sensitive', label: 'Druckempfindlich' },
      { value: 'emergency_stop', label: 'Not-Halt' },
      { value: 'electrical_protection', label: 'Elektrischer Schutz' },
      { value: 'thermal_protection', label: 'Thermischer Schutz' },
      { value: 'fluid_protection', label: 'Hydraulik/Pneumatik-Schutz' },
      { value: 'extraction', label: 'Absaugung / Kapselung' },
    ],
    icon: (
      <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
      </svg>
    ),
  },
  information: {
    label: 'Stufe 3: Information',
    description: 'Hinweise und Schulungen',
    color: 'border-yellow-200 bg-yellow-50',
    headerColor: 'bg-yellow-100 text-yellow-800',
    subTypes: [
      { value: 'signage', label: 'Beschilderung & Kennzeichnung' },
      { value: 'manual', label: 'Betriebsanleitung' },
      { value: 'training', label: 'Schulung & Unterweisung' },
      { value: 'ppe', label: 'PSA (Schutzausruestung)' },
      { value: 'organizational', label: 'Organisatorisch' },
      { value: 'marking', label: 'Markierung & Codierung' },
    ],
    icon: (
      <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
      </svg>
    ),
  },
}
