/**
 * Shared types and constants for the Ground Truth labeling UI.
 */

// ---------- Types ----------

export interface BBox {
  x: number
  y: number
  w: number
  h: number
}

export interface GTEntry {
  row_index: number
  english: string
  german: string
  example: string
  confidence: number
  bbox: BBox
  bbox_en: BBox
  bbox_de: BBox
  bbox_ex: BBox
  status?: 'pending' | 'confirmed' | 'edited' | 'skipped'
}

export interface GroundTruthPanelProps {
  sessionId: string
  selectedPage: number
  pageImageUrl: string
}

// ---------- Constants ----------

export const KLAUSUR_API = '/klausur-api'

export const STATUS_COLORS: Record<string, { fill: string; stroke: string }> = {
  current:   { fill: 'rgba(250,204,21,0.25)', stroke: '#eab308' },   // yellow
  confirmed: { fill: 'rgba(34,197,94,0.18)',  stroke: '#16a34a' },   // green
  edited:    { fill: 'rgba(59,130,246,0.18)', stroke: '#2563eb' },   // blue
  skipped:   { fill: 'rgba(148,163,184,0.15)', stroke: '#94a3b8' },  // gray
  pending:   { fill: 'rgba(0,0,0,0)',          stroke: '#cbd5e1' },   // outline only
}

// ---------- Helpers ----------

export function getEntryColor(entry: GTEntry, index: number, currentIndex: number) {
  if (index === currentIndex) return STATUS_COLORS.current
  return STATUS_COLORS[entry.status || 'pending']
}
