export type OfficeKind = 'excel' | 'pptx' | 'docx' | 'pdf';

export interface OfficeDocument {
  kind: OfficeKind;
  source: { path: string; filename: string; mime?: string; sizeBytes?: number };
  metadata: {
    title?: string;
    author?: string;
    createdAt?: string;
    modifiedAt?: string;
    pageCount?: number;
    sheetCount?: number;
    slideCount?: number;
    fileSizeBytes?: number;
    processingTimeMs?: number;
  };
  blocks: OfficeBlock[];
  warnings: OfficeWarning[];
}

export type OfficeBlock =
  | ExcelSheetBlock
  | PptxSlideBlock
  | DocxParagraphBlock
  | DocxTableBlock
  | PdfPageBlock;

export interface ExcelSheetBlock {
  type: 'excel.sheet';
  sheetName: string;
  range: string;
  cells: SheetCell[];
}

export interface SheetCell {
  address: string;
  value?: string | number | boolean | null;
  formula?: string;
  numberFormat?: string;
  row: number;
  col: number;
}

export interface PptxSlideBlock {
  type: 'pptx.slide';
  slideNo: number;
  texts: { shapeId?: string; text: string }[];
  notes?: string;
}

export interface DocxParagraphBlock {
  type: 'docx.paragraph';
  index: number;
  text: string;
  style?: string;
}

export interface DocxTableBlock {
  type: 'docx.table';
  index: number;
  rows: string[][];
}

export interface PdfPageBlock {
  type: 'pdf.page';
  pageNo: number;
  text: string;
}

export interface OfficeWarning {
  code:
    | 'UNSUPPORTED_FORMAT'
    | 'FILE_TOO_LARGE'
    | 'PARSE_PARTIAL_SUCCESS'
    | 'MACRO_DISABLED'
    | 'PASSWORD_PROTECTED'
    | 'CORRUPT_FILE'
    | 'TIMEOUT';
  message: string;
  detail?: unknown;
}
