export type CrosswordRequest = {
  schema_version: string;
  request_id: string;
  requested_at: string;
  generator: {
    topic: string[];
    difficulty: string;
    seed: number | null;
    initial_word_count: number;
    themed_fill_count: number;
    target_empty_ratio: number;
    diffxy: number;
    time_limit_seconds: number;
    max_candidates_per_word: number;
    lexicon_file: string;
    definitions_enabled: boolean;
    definition_style: string;
    preferred_output_language: string;
  };
};

export type CrosswordCell = {
  row: number;
  col: number;
  kind: "letter" | "block";
  solution: string | null;
  display: string | null;
  number: number | null;
  across_entry_id: string | null;
  down_entry_id: string | null;
  is_prefilled: boolean;
};

export type CrosswordClue = {
  number: number;
  entry_id: string;
  text: string;
  enumeration: number;
  topic_match: boolean;
  source: string;
};

export type CrosswordEntry = {
  entry_id: string;
  number: number;
  direction: "across" | "down";
  answer: string;
  answer_length: number;
  row: number;
  col: number;
  cells: [number, number][];
  clue: string;
  clue_source: string;
  topics: string[];
  pos: string;
  is_seed: boolean;
  added_by_filler: boolean;
  confidence: number;
};

export type CrosswordResponse = {
  schema_version: string;
  request_id: string;
  crossword_id: string;
  generated_at: string;
  status: string;
  generator: {
    topic: string[];
    difficulty: string;
    seed: number | null;
    runtime_lexicon: string;
  };
  summary: {
    title: string;
    subtitle: string;
    rows: number;
    cols: number;
    total_words: number;
    intersections: number;
  };
  grid: {
    rows: number;
    cols: number;
    cell_size_hint: number;
    cells: CrosswordCell[];
  };
  entries: CrosswordEntry[];
  clues: {
    across: CrosswordClue[];
    down: CrosswordClue[];
  };
  solution: {
    grid_rows: string[];
    words: string[];
  };
  diagnostics: {
    seed_words_requested: number;
    seed_words_placed: number;
    filler_words_added: number;
    filled_cells: number;
    empty_cells: number;
    empty_ratio: number;
    target_empty_ratio: number;
    topic_words: number;
    off_topic_words: number;
    pos_counts: Record<string, number>;
    generation_seconds: number;
  };
  artifacts: {
    pdf_player: string | null;
    pdf_solution: string | null;
    thumbnail: string | null;
    html_preview: string | null;
  };
};
