/** TypeScript interfaces matching the Kerf Engine API shapes. */

// -- Preset configuration (mirrors engine/presets/*.json) --

export interface PreprocessingConfig {
  denoise_d?: number;
  denoise_sigma_color?: number;
  denoise_sigma_space?: number;
  clahe_clip_limit?: number;
  clahe_tile_grid_size?: [number, number];
  threshold_manual?: number | null;
  edge_detect?: boolean;
  morph_kernel_size?: number;
  morph_dilate_iterations?: number;
  morph_erode_iterations?: number;
}

export interface PotraceConfig {
  turdsize?: number;
  alphamax?: number;
  opticurve?: boolean;
  opttolerance?: number;
}

export interface VtracerConfig {
  colormode?: string;
  hierarchical?: string;
  filter_speckle?: number;
  corner_threshold?: number;
  length_threshold?: number;
  splice_threshold?: number;
  mode?: string;
  color_precision?: number;
  layer_difference?: number;
  path_precision?: number;
  max_iterations?: number;
}

export interface VectorizationConfig {
  mode: 'potrace' | 'vtracer';
  potrace?: PotraceConfig;
  vtracer?: VtracerConfig;
}

export interface PostprocessingConfig {
  epsilon?: number;
  close_tolerance?: number;
  auto_close?: boolean;
}

export interface PresetConfig {
  name: string;
  description: string;
  preprocessing: PreprocessingConfig;
  vectorization: VectorizationConfig;
  postprocessing: PostprocessingConfig;
}

// -- API responses --

export interface TraceMetadata {
  format: string;
  path_count: number;
  node_count_total: number;
  open_paths: number;
  island_count: number;
  warnings: string[];
  processing_ms: number;
}

export interface TraceResponse {
  output: string;
  format: string;
  metadata: TraceMetadata;
}

export interface PresetsResponse {
  presets: Record<string, PresetConfig>;
}
