import type { SignalType, RiskLevel, ReviewStatus } from './enums'

export type ContactType = 'EMAIL' | 'PHONE' | 'WEBSITE' | 'LINKEDIN' | 'CONTACT_PERSON'
export type ContactConfidence = 'HIGH' | 'MEDIUM' | 'LOW'

export interface ExtractedContact {
  type: ContactType
  value: string
  confidence: ContactConfidence
  label?: string
}

export interface SignalSource {
  type: 'PRESS' | 'CONSTRUCTION_PERMIT' | 'JOB_POSTING' | 'COMPANY_REPORT' | 'MARKET_DATA' | 'MANUAL' | 'LEASE_CONTRACT'
  url?: string
  publishedAt?: string
  credibility: 'LOW' | 'MEDIUM' | 'HIGH'
}

export interface SignalEvidence {
  summary: string
  sourceUrls?: string[]
  extractedAt?: string
}

export interface FutureSignal {
  id: string
  signalType: SignalType
  companyName?: string
  propertyId?: string
  locationHint: string
  areaSqmEstimate?: number
  probability: number
  confidenceScore: number
  timeHorizonMonths: number
  source: SignalSource
  sensitivityLevel: 'PUBLIC' | 'INTERNAL' | 'CONFIDENTIAL'
  disclaimer: string
  riskLevel: RiskLevel
  marketIndicator?: string
  relevanceScore?: number
  isVerified: boolean
  verifiedBy?: string
  verifiedAt?: string
  expiresAt?: string
  organizationId?: string
  createdAt: string
  updatedAt: string

  // F004 additions
  title?: string                       // short human-readable headline
  evidence?: SignalEvidence            // structured evidence block
  matchabilityScore?: number           // 0–100: how well this signal can be matched to needs
  reviewStatus?: ReviewStatus
  aiSummary?: string                   // AI-generated explanation of what this signal means

  // Strategic intelligence fields
  marketIndicators?: string[]          // ["Mitarbeiterzahl rückläufig -15%", ...]
  strategicInterpretation?: string     // "Die Signale deuten auf ..."
  confirmedFacts?: string[]            // ["Region bestätigt", ...]
  unconfirmedFacts?: string[]          // ["Exakte Fläche unbekannt", ...]

  // Signal direction
  // SUPPLY = space will become available → shown in demand feed
  // DEMAND = company is looking for space → shown as Markt-Lead in Verwaltung
  // undefined = treated as SUPPLY (backwards compat for generated signals)
  signalDirection?: 'SUPPLY' | 'DEMAND'

  // Unit-level reference: if set, this signal is about a specific rentable unit
  unitId?: string

  // KI-extracted contact information from web crawler sources
  extractedContacts?: ExtractedContact[]
}
