// =============================================================================
// WIZARD STEP, EXPORT RECORD, TOM GENERATOR STATE & RULES ENGINE
// =============================================================================

import type {
  TOMGeneratorStepId,
  ControlApplicability,
} from './enums'
import type { CompanyProfile, DataProfile, ArchitectureProfile, SecurityProfile, RiskProfile } from './profiles'
import type { EvidenceDocument } from './evidence'
import type { ApplicabilityCondition } from './control-library'
import type { DerivedTOM } from './derived-tom'
import type { GapAnalysisResult } from './gap-analysis'

// =============================================================================
// WIZARD STEP
// =============================================================================

export interface WizardStep {
  id: TOMGeneratorStepId
  completed: boolean
  data: unknown
  validatedAt: Date | null
}

// =============================================================================
// EXPORT RECORD
// =============================================================================

export interface ExportRecord {
  id: string
  format: 'DOCX' | 'PDF' | 'JSON' | 'ZIP'
  generatedAt: Date
  filename: string
}

// =============================================================================
// TOM GENERATOR STATE
// =============================================================================

export interface TOMGeneratorState {
  metadata?: Record<string, unknown>
  id: string
  tenantId: string
  companyProfile: CompanyProfile | null
  dataProfile: DataProfile | null
  architectureProfile: ArchitectureProfile | null
  securityProfile: SecurityProfile | null
  riskProfile: RiskProfile | null
  currentStep: TOMGeneratorStepId
  steps: WizardStep[]
  documents: EvidenceDocument[]
  derivedTOMs: DerivedTOM[]
  gapAnalysis: GapAnalysisResult | null
  exports: ExportRecord[]
  createdAt: Date
  updatedAt: Date
}

// =============================================================================
// RULES ENGINE TYPES
// =============================================================================

export interface RulesEngineResult {
  controlId: string
  applicability: ControlApplicability
  reason: string
  matchedCondition?: ApplicabilityCondition
}

export interface RulesEngineEvaluationContext {
  companyProfile: CompanyProfile | null
  dataProfile: DataProfile | null
  architectureProfile: ArchitectureProfile | null
  securityProfile: SecurityProfile | null
  riskProfile: RiskProfile | null
}
