/**
 * @ai-summary TypeScript types for OCR feature
 */

/** Types of documents that can be processed by OCR */
export type DocumentType = 'vin' | 'receipt' | 'manual' | 'unknown';

/** A single extracted field with confidence score */
export interface ExtractedField {
  value: string;
  confidence: number;
}

/** Response from OCR extraction */
export interface OcrResponse {
  success: boolean;
  documentType: DocumentType;
  rawText: string;
  confidence: number;
  extractedFields: Record<string, ExtractedField>;
  processingTimeMs: number;
}

/** Status of an async OCR job */
export type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';

/** Response for async job status */
export interface JobResponse {
  jobId: string;
  status: JobStatus;
  progress?: number;
  result?: OcrResponse;
  error?: string;
}

/** Request to submit an async OCR job */
export interface JobSubmitRequest {
  callbackUrl?: string;
}

/** Internal request to OCR service */
export interface OcrExtractRequest {
  fileBuffer: Buffer;
  contentType: string;
  preprocess?: boolean;
}

/** Response from VIN-specific extraction */
export interface VinExtractionResponse {
  success: boolean;
  vin: string | null;
  confidence: number;
  boundingBox: { x: number; y: number; width: number; height: number } | null;
  alternatives: { vin: string; confidence: number }[];
  processingTimeMs: number;
  error: string | null;
}

/** Internal request to submit async job */
export interface OcrJobSubmitRequest {
  fileBuffer: Buffer;
  contentType: string;
  callbackUrl?: string;
}
