{"version":3,"file":"worksheet.mjs","names":[],"sources":["../src/worksheet/auto-filter.ts","../src/worksheet/errors.ts","../src/worksheet/protection.ts","../src/worksheet/protected-ranges.ts","../src/worksheet/sort-state.ts","../src/worksheet/smart-tags.ts","../src/worksheet/ole-objects.ts","../src/worksheet/custom-sheet-views.ts","../src/worksheet/page-setup.ts","../src/worksheet/web-publish.ts","../src/worksheet/phonetic.ts","../src/worksheet/data-consolidate.ts","../src/worksheet/scenarios.ts"],"sourcesContent":["// AutoFilter.\n//\n// **Stage 1**: ref + filterColumns where each entry is the `kind: 'filters'`\n// variant — the value-list dropdown filter that covers >95% of real-world\n// spreadsheets. customFilters / top10 / dynamicFilter / colorFilter /\n// iconFilter / SortState are reserved for later iterations.\n\nimport { OpenXmlSchemaError } from '../utils/exceptions';\n\nexport type FilterColumn = {\n  kind: 'filters';\n  colId: number;\n  /** Discrete values that pass the filter. Stored as strings to match the wire format. */\n  values: string[];\n  /** Whether blanks are visible. */\n  blank?: boolean;\n};\n\nexport interface AutoFilter {\n  /** Excel range the filter covers (`\"A1:E100\"`). */\n  ref: string;\n  filterColumns: FilterColumn[];\n}\n\nexport function makeAutoFilter(opts: { ref: string; filterColumns?: FilterColumn[] }): AutoFilter {\n  return { ref: opts.ref, filterColumns: opts.filterColumns ?? [] };\n}\n\nexport function makeFilterColumn(opts: {\n  colId: number;\n  values: ReadonlyArray<string>;\n  blank?: boolean;\n}): FilterColumn {\n  return {\n    kind: 'filters',\n    colId: opts.colId,\n    values: [...opts.values],\n    ...(opts.blank !== undefined ? { blank: opts.blank } : {}),\n  };\n}\n\n// ---- Worksheet ergonomic builders ---------------------------------------\n\nimport type { Worksheet } from './worksheet';\n\n/** Add an AutoFilter dropdown header strip to the given range. */\nexport const addAutoFilter = (ws: Worksheet, ref: string): AutoFilter => {\n  ws.autoFilter = makeAutoFilter({ ref });\n  return ws.autoFilter;\n};\n\n/**\n * Add a value-list dropdown filter to a column inside the existing AutoFilter\n * range. `colId` is 0-based relative to the AutoFilter left edge.\n */\nexport const addAutoFilterColumn = (\n  ws: Worksheet,\n  colId: number,\n  values: ReadonlyArray<string>,\n  opts: { blank?: boolean } = {},\n): FilterColumn => {\n  if (!ws.autoFilter) {\n    throw new OpenXmlSchemaError('addAutoFilterColumn: call addAutoFilter(ws, ref) first');\n  }\n  const fc = makeFilterColumn({ colId, values, ...(opts.blank !== undefined ? { blank: opts.blank } : {}) });\n  ws.autoFilter.filterColumns.push(fc);\n  return fc;\n};\n\n/** Drop the worksheet's AutoFilter entirely. */\nexport const removeAutoFilter = (ws: Worksheet): void => {\n  delete (ws as { autoFilter?: AutoFilter }).autoFilter;\n};\n","// Cell-level error / watch metadata. (cellWatches / ignoredErrors).\n//\n// `ignoredErrors` lets you tell Excel \"don't flag these cells with the little\n// green triangle for this class of validation\". `cellWatches` records which\n// cells the user has pinned in the Watch Window.\n//\n// Both round-trip via the worksheet `bodyExtras` passthrough already, but\n// promoting them to first-class arrays gives the editor a clean API and the\n// writer a stable position in the worksheet element order (between rowBreaks /\n// colBreaks and the drawing block per ECMA-376 §18.3.1.94 cellWatches /\n// §18.3.1.51 ignoredErrors).\n\nimport type { MultiCellRange } from './cell-range';\n\n/**\n * One Cell-Watch entry. The Watch Window in Excel (Formulas → Watch Window)\n * shows live values for the cells listed here.\n */\nexport interface CellWatch {\n  /** Single-cell reference like \"Sheet1!$A$1\" — kept verbatim. */\n  ref: string;\n}\n\n/**\n * One ignored-error entry. Each Boolean flag corresponds to a class of Excel's\n * background validation; setting any of them to `true` suppresses the green\n * triangle for cells in `sqref`.\n */\nexport interface IgnoredError {\n  /** Cells to which the suppressions apply. */\n  sqref: MultiCellRange;\n  /** \"Formula evaluates to error\" warning. */\n  evalError?: boolean;\n  /** \"Date stored as 2-digit year\" warning. */\n  twoDigitTextYear?: boolean;\n  /** \"Number stored as text\" warning. */\n  numberStoredAsText?: boolean;\n  /** \"Inconsistent formula\" warning. */\n  formula?: boolean;\n  /** \"Formula omits cells\" warning. */\n  formulaRange?: boolean;\n  /** \"Unlocked cells containing formulas\" warning. */\n  unlockedFormula?: boolean;\n  /** \"Empty cells referenced\" warning. */\n  emptyCellReference?: boolean;\n  /** \"Data validation list error\" warning. */\n  listDataValidation?: boolean;\n  /** \"Inconsistent calculated column\" warning (Excel Tables). */\n  calculatedColumn?: boolean;\n}\n\nexport const makeCellWatch = (ref: string): CellWatch => ({ ref });\n\nexport function makeIgnoredError(\n  opts: Partial<IgnoredError> & { sqref: MultiCellRange },\n): IgnoredError {\n  return {\n    sqref: opts.sqref,\n    ...(opts.evalError !== undefined ? { evalError: opts.evalError } : {}),\n    ...(opts.twoDigitTextYear !== undefined ? { twoDigitTextYear: opts.twoDigitTextYear } : {}),\n    ...(opts.numberStoredAsText !== undefined ? { numberStoredAsText: opts.numberStoredAsText } : {}),\n    ...(opts.formula !== undefined ? { formula: opts.formula } : {}),\n    ...(opts.formulaRange !== undefined ? { formulaRange: opts.formulaRange } : {}),\n    ...(opts.unlockedFormula !== undefined ? { unlockedFormula: opts.unlockedFormula } : {}),\n    ...(opts.emptyCellReference !== undefined ? { emptyCellReference: opts.emptyCellReference } : {}),\n    ...(opts.listDataValidation !== undefined ? { listDataValidation: opts.listDataValidation } : {}),\n    ...(opts.calculatedColumn !== undefined ? { calculatedColumn: opts.calculatedColumn } : {}),\n  };\n}\n","// Sheet-protection model. (without password hashing — saltValue / spinCount /\n// algorithmName / hashValue round-trip verbatim, but no helper to compute them\n// yet).\n//\n// Excel uses the listed booleans inversely: `true` typically means \"users CAN\n// do this even when the sheet is locked\" (e.g. `formatCells: true` lets people\n// change cell formatting on a protected sheet). The only universally meaningful\n// field is `sheet: true`, which actually enables the lock.\n\nexport interface SheetProtection {\n  /** Master toggle — when true the sheet is protected. */\n  sheet?: boolean;\n  /** Allow operations on drawing objects when sheet is protected. */\n  objects?: boolean;\n  /** Allow operations on scenarios when sheet is protected. */\n  scenarios?: boolean;\n  formatCells?: boolean;\n  formatColumns?: boolean;\n  formatRows?: boolean;\n  insertColumns?: boolean;\n  insertRows?: boolean;\n  insertHyperlinks?: boolean;\n  deleteColumns?: boolean;\n  deleteRows?: boolean;\n  selectLockedCells?: boolean;\n  selectUnlockedCells?: boolean;\n  sort?: boolean;\n  autoFilter?: boolean;\n  pivotTables?: boolean;\n\n  // Password-protection fields. Round-trip only — computing a fresh hash from a\n  // plaintext password lives behind a future helper.\n  /** Base-64 salt for the password hash. */\n  saltValue?: string;\n  /** Number of hash iterations. */\n  spinCount?: number;\n  /** Hash algorithm name, e.g. \"SHA-512\". */\n  algorithmName?: string;\n  /** Base-64 hashed password. */\n  hashValue?: string;\n}\n\nexport const makeSheetProtection = (opts: SheetProtection = {}): SheetProtection => {\n  const out: SheetProtection = {};\n  for (const k of [\n    'sheet',\n    'objects',\n    'scenarios',\n    'formatCells',\n    'formatColumns',\n    'formatRows',\n    'insertColumns',\n    'insertRows',\n    'insertHyperlinks',\n    'deleteColumns',\n    'deleteRows',\n    'selectLockedCells',\n    'selectUnlockedCells',\n    'sort',\n    'autoFilter',\n    'pivotTables',\n  ] as const) {\n    if (opts[k] !== undefined) out[k] = opts[k];\n  }\n  if (opts.saltValue !== undefined) out.saltValue = opts.saltValue;\n  if (opts.spinCount !== undefined) out.spinCount = opts.spinCount;\n  if (opts.algorithmName !== undefined) out.algorithmName = opts.algorithmName;\n  if (opts.hashValue !== undefined) out.hashValue = opts.hashValue;\n  return out;\n};\n\n// ---- Worksheet ergonomic helpers ----------------------------------------\n\nimport type { Worksheet } from './worksheet';\n\n/**\n * Excel's \"Protect Sheet\" defaults — when you click the dialog without changing\n * any checkbox, it locks structure but allows the listed actions. This matches\n * Excel's wire form (sheet=1 + the listed flags left at their defaults).\n */\nconst PROTECT_SHEET_DEFAULTS: SheetProtection = Object.freeze({\n  sheet: true,\n  objects: true,\n  scenarios: true,\n  formatCells: false,\n  formatColumns: false,\n  formatRows: false,\n  insertColumns: false,\n  insertRows: false,\n  insertHyperlinks: false,\n  deleteColumns: false,\n  deleteRows: false,\n  selectLockedCells: false,\n  selectUnlockedCells: false,\n  sort: false,\n  autoFilter: false,\n  pivotTables: false,\n});\n\n/**\n * Lock a worksheet with Excel's \"Protect Sheet\" defaults. Pass `overrides` to\n * allow specific actions while otherwise locked (e.g. `{ sort: true,\n * autoFilter: true }` for \"allow sort + filter on locked sheet\"). Password-hash\n * fields can be supplied as a quad (algorithmName / hashValue / saltValue /\n * spinCount); plaintext passwords are out of scope until the D-tier hashing\n * helper lands.\n */\nexport const protectSheet = (\n  ws: Worksheet,\n  overrides: Partial<SheetProtection> = {},\n): SheetProtection => {\n  ws.sheetProtection = { ...PROTECT_SHEET_DEFAULTS, ...overrides };\n  return ws.sheetProtection;\n};\n\n/** Drop the typed sheet-protection record. */\nexport const unprotectSheet = (ws: Worksheet): void => {\n  delete (ws as { sheetProtection?: SheetProtection }).sheetProtection;\n};\n\n/** Quick-lock helper that mirrors Excel's \"Allow users to edit ranges → Protect Sheet\" defaults. */\nexport const isSheetProtected = (ws: Worksheet): boolean => ws.sheetProtection?.sheet === true;\n","// Worksheet-level <protectedRanges>. Per ECMA-376 §18.3.1.69.\n//\n// Excel's \"Allow Edit Ranges\" dialog (Review → Allow Edit Ranges).\n// Each entry whitelists a specific range to be editable while the\n// sheet is otherwise protected. Round-tripped verbatim — no password\n// hashing helper yet.\n\nimport type { MultiCellRange } from './cell-range';\n\nexport interface ProtectedRange {\n  /** Range to expose for editing while the sheet is protected. */\n  sqref: MultiCellRange;\n  /** Display name shown in the dialog. */\n  name: string;\n  /** Legacy 16-bit hex password. */\n  password?: string;\n  /** Optional security descriptor (Windows ACL string). */\n  securityDescriptor?: string;\n  // Modern hash quad — round-tripped verbatim.\n  algorithmName?: string;\n  hashValue?: string;\n  saltValue?: string;\n  spinCount?: number;\n}\n\nexport const makeProtectedRange = (\n  opts: Partial<ProtectedRange> & { sqref: MultiCellRange; name: string },\n): ProtectedRange => ({\n  sqref: opts.sqref,\n  name: opts.name,\n  ...(opts.password !== undefined ? { password: opts.password } : {}),\n  ...(opts.securityDescriptor !== undefined ? { securityDescriptor: opts.securityDescriptor } : {}),\n  ...(opts.algorithmName !== undefined ? { algorithmName: opts.algorithmName } : {}),\n  ...(opts.hashValue !== undefined ? { hashValue: opts.hashValue } : {}),\n  ...(opts.saltValue !== undefined ? { saltValue: opts.saltValue } : {}),\n  ...(opts.spinCount !== undefined ? { spinCount: opts.spinCount } : {}),\n});\n","// Worksheet-level <sortState>. Per ECMA-376 §18.3.1.92.\n//\n// Excel persists the last sort the user applied so re-opening the file\n// shows the rows in the same order. The element carries one or more\n// <sortCondition> entries describing the sort key columns (or rows).\n\nexport type SortBy = 'value' | 'cellColor' | 'fontColor' | 'icon';\nexport type SortMethod = 'stroke' | 'pinYin';\nexport type SortIconSet =\n  | '3Arrows'\n  | '3ArrowsGray'\n  | '3Flags'\n  | '3TrafficLights1'\n  | '3TrafficLights2'\n  | '3Signs'\n  | '3Symbols'\n  | '3Symbols2'\n  | '4Arrows'\n  | '4ArrowsGray'\n  | '4RedToBlack'\n  | '4Rating'\n  | '4TrafficLights'\n  | '5Arrows'\n  | '5ArrowsGray'\n  | '5Rating'\n  | '5Quarters';\n\nexport interface SortCondition {\n  /** Column or row that drives this sort key. */\n  ref: string;\n  descending?: boolean;\n  sortBy?: SortBy;\n  /** Reference to a custom-list defined name. */\n  customList?: string;\n  /** Differential-style index (`<dxf>` slot in the stylesheet). */\n  dxfId?: number;\n  iconSet?: SortIconSet;\n  iconId?: number;\n}\n\nexport interface SortState {\n  /** Range the sort applies to (`A1:D20`). */\n  ref: string;\n  conditions: SortCondition[];\n  /** Sort columns instead of rows (rare). */\n  columnSort?: boolean;\n  caseSensitive?: boolean;\n  sortMethod?: SortMethod;\n}\n\nexport const makeSortCondition = (opts: SortCondition): SortCondition => ({ ...opts });\n\nexport const makeSortState = (opts: Partial<SortState> & { ref: string }): SortState => ({\n  ref: opts.ref,\n  conditions: opts.conditions?.slice() ?? [],\n  ...(opts.columnSort !== undefined ? { columnSort: opts.columnSort } : {}),\n  ...(opts.caseSensitive !== undefined ? { caseSensitive: opts.caseSensitive } : {}),\n  ...(opts.sortMethod !== undefined ? { sortMethod: opts.sortMethod } : {}),\n});\n","// Worksheet-level <smartTags>. Per ECMA-376 §18.3.1.93.\n//\n// Per-cell smart-tag annotations from Excel 2003. The element is\n// nested:\n//   <smartTags>\n//     <cellSmartTags r=\"A1\">\n//       <cellSmartTag type=\"0\" deleted=\"0\" xmlBased=\"0\">\n//         <cellSmartTagPr key=\"…\" val=\"…\"/>\n//       </cellSmartTag>\n//     </cellSmartTags>\n//   </smartTags>\n// Almost never seen in modern files; the workbook-level smartTagTypes\n// list registers the schema, this element pins individual cells.\n\nexport interface CellSmartTagProperty {\n  key: string;\n  val: string;\n}\n\nexport interface CellSmartTag {\n  /** 0-based index into the workbook's smartTagTypes list. */\n  type: number;\n  properties: CellSmartTagProperty[];\n  deleted?: boolean;\n  xmlBased?: boolean;\n}\n\nexport interface CellSmartTags {\n  /** Single-cell ref (\"A1\"). */\n  ref: string;\n  tags: CellSmartTag[];\n}\n\nexport const makeCellSmartTagProperty = (key: string, val: string): CellSmartTagProperty => ({ key, val });\n\nexport const makeCellSmartTag = (opts: Partial<CellSmartTag> & { type: number }): CellSmartTag => ({\n  type: opts.type,\n  properties: opts.properties?.slice() ?? [],\n  ...(opts.deleted !== undefined ? { deleted: opts.deleted } : {}),\n  ...(opts.xmlBased !== undefined ? { xmlBased: opts.xmlBased } : {}),\n});\n\nexport const makeCellSmartTags = (opts: Partial<CellSmartTags> & { ref: string }): CellSmartTags => ({\n  ref: opts.ref,\n  tags: opts.tags?.slice() ?? [],\n});\n","// Worksheet-level <oleObjects> + <controls>. Per ECMA-376 §18.3.1.61\n// and §18.3.1.27.\n//\n// Both elements are lists of object references where each entry has a\n// `shapeId` + `r:id` plus a child `<objectPr>` / `<controlPr>` element\n// that holds the anchor / display properties. The objectPr/controlPr\n// children pull in the spreadsheet-drawing namespace, so we round-trip\n// them as opaque XmlNode payloads rather than fully modeling the\n// nested anchor schema. The top-level attrs are typed for editor access.\n\nimport type { XmlNode } from '../xml/tree';\n\nexport type OleDvAspect = 'DVASPECT_CONTENT' | 'DVASPECT_ICON';\nexport type OleUpdateMode = 'OLEUPDATE_ALWAYS' | 'OLEUPDATE_ONCALL';\n\nexport interface OleObject {\n  /** Unique shape id assigned by Excel — required. */\n  shapeId: number;\n  /** rels link to the embedded OLE blob. */\n  rId?: string;\n  progId?: string;\n  dvAspect?: OleDvAspect;\n  link?: string;\n  oleUpdate?: OleUpdateMode;\n  autoLoad?: boolean;\n  /**\n   * Optional `<objectPr>` child preserved verbatim. Modeling its\n   * `<anchor>` schema in detail is deferred — this preserves the\n   * round-trip without re-deriving the anchor attrs.\n   */\n  objectPr?: XmlNode;\n}\n\nexport interface FormControl {\n  shapeId: number;\n  rId?: string;\n  /** ECMA-376 §18.3.1.27 — name shown in the form-control name box. */\n  name?: string;\n  /**\n   * Optional `<controlPr>` child preserved verbatim (similar to\n   * `objectPr` for OLE objects).\n   */\n  controlPr?: XmlNode;\n}\n\nexport const makeOleObject = (opts: Partial<OleObject> & { shapeId: number }): OleObject => ({\n  shapeId: opts.shapeId,\n  ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n  ...(opts.progId !== undefined ? { progId: opts.progId } : {}),\n  ...(opts.dvAspect !== undefined ? { dvAspect: opts.dvAspect } : {}),\n  ...(opts.link !== undefined ? { link: opts.link } : {}),\n  ...(opts.oleUpdate !== undefined ? { oleUpdate: opts.oleUpdate } : {}),\n  ...(opts.autoLoad !== undefined ? { autoLoad: opts.autoLoad } : {}),\n  ...(opts.objectPr !== undefined ? { objectPr: opts.objectPr } : {}),\n});\n\nexport const makeFormControl = (opts: Partial<FormControl> & { shapeId: number }): FormControl => ({\n  shapeId: opts.shapeId,\n  ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n  ...(opts.name !== undefined ? { name: opts.name } : {}),\n  ...(opts.controlPr !== undefined ? { controlPr: opts.controlPr } : {}),\n});\n","// Worksheet-level <customSheetViews> — saved per-user view presets.\n// Per ECMA-376 §18.3.1.26 / §18.3.1.27.\n//\n// Each <customSheetView> snapshots a sheet's view state: zoom level,\n// gridline / formula / heading toggles, plus its own page-setup block\n// and break list. The chartsheet sibling (smaller) has been typed\n// separately in src/chartsheet/chartsheet.ts.\n\nimport type { HeaderFooter, PageBreak, PageMargins, PageSetup, PrintOptions } from './page-setup';\nimport type { Pane, Selection, SheetViewMode } from './views';\n\nexport type CustomSheetViewState = 'visible' | 'hidden' | 'veryHidden';\n\nexport interface CustomSheetView {\n  guid: string;\n  scale?: number;\n  /** 0..64 (legacy palette index) */\n  colorId?: number;\n  showPageBreaks?: boolean;\n  showFormulas?: boolean;\n  showGridLines?: boolean;\n  showRowCol?: boolean;\n  outlineSymbols?: boolean;\n  zeroValues?: boolean;\n  fitToPage?: boolean;\n  /** Print only the print-area selection on this saved view. */\n  printArea?: boolean;\n  /** AutoFilter is active in this saved view. */\n  filter?: boolean;\n  showAutoFilter?: boolean;\n  /** Hidden rows persist for this saved view. */\n  hiddenRows?: boolean;\n  hiddenColumns?: boolean;\n  state?: CustomSheetViewState;\n  filterUnique?: boolean;\n  view?: SheetViewMode;\n  showRuler?: boolean;\n  /** Top-left cell ref shown when this view is restored. */\n  topLeftCell?: string;\n  /** Inner pane split / freeze. */\n  pane?: Pane;\n  /** Selection state for this view (one entry per pane). */\n  selections?: Selection[];\n  rowBreaks?: PageBreak[];\n  colBreaks?: PageBreak[];\n  pageMargins?: PageMargins;\n  printOptions?: PrintOptions;\n  pageSetup?: PageSetup;\n  headerFooter?: HeaderFooter;\n}\n\nexport const makeCustomSheetView = (\n  opts: Partial<CustomSheetView> & { guid: string },\n): CustomSheetView => ({ ...opts });\n","// Page-setup typed model.\n//\n// Promotes <printOptions> / <pageMargins> / <pageSetup> / <headerFooter> from\n// the bodyExtras passthrough into typed Worksheet fields with round-trip\n// readers / writers. Mirrors openpyxl/openpyxl/worksheet/ page.py +\n// header_footer.py.\n\nexport interface PrintOptions {\n  /** Center the printed sheet horizontally on the page. */\n  horizontalCentered?: boolean;\n  /** Center the printed sheet vertically on the page. */\n  verticalCentered?: boolean;\n  /** Print row + column headings (the A B C / 1 2 3 strips). */\n  headings?: boolean;\n  /** Print sheet gridlines. */\n  gridLines?: boolean;\n  /** Mirrors a quirky Excel companion flag for `gridLines`. */\n  gridLinesSet?: boolean;\n}\n\n/** Page margins in inches. ECMA-376 §18.3.1.62. All six fields are required when the element is present. */\nexport interface PageMargins {\n  left: number;\n  right: number;\n  top: number;\n  bottom: number;\n  header: number;\n  footer: number;\n}\n\nexport type PageOrientation = 'default' | 'portrait' | 'landscape';\nexport type PageOrder = 'downThenOver' | 'overThenDown';\nexport type CellCommentMode = 'none' | 'asDisplayed' | 'atEnd';\nexport type PrintErrorMode = 'displayed' | 'blank' | 'dash' | 'NA';\n\nexport interface PageSetup {\n  paperSize?: number;\n  scale?: number;\n  firstPageNumber?: number;\n  fitToWidth?: number;\n  fitToHeight?: number;\n  pageOrder?: PageOrder;\n  orientation?: PageOrientation;\n  usePrinterDefaults?: boolean;\n  blackAndWhite?: boolean;\n  draft?: boolean;\n  cellComments?: CellCommentMode;\n  useFirstPageNumber?: boolean;\n  errors?: PrintErrorMode;\n  horizontalDpi?: number;\n  verticalDpi?: number;\n  copies?: number;\n  /** Optional `r:id` referencing an external printerSettings part — round-tripped verbatim. */\n  rId?: string;\n  /** Paper height (UniversalMeasure, e.g. \"297mm\"). */\n  paperHeight?: string;\n  /** Paper width (UniversalMeasure). */\n  paperWidth?: string;\n}\n\nexport interface HeaderFooter {\n  differentFirst?: boolean;\n  differentOddEven?: boolean;\n  /** Mirror Excel's \"scale header/footer with document\" toggle. Default true. */\n  scaleWithDoc?: boolean;\n  /** Mirror Excel's \"align header/footer with margins\" toggle. Default true. */\n  alignWithMargins?: boolean;\n  /**\n   * Mini-format string. Excel uses `&L` / `&C` / `&R` to split the three\n   * sections, plus codes like `&P` (page number), `&N` (page count), `&F` (file\n   * name), `&A` (sheet name), `&D` / `&T` (date / time). We round-trip the\n   * literal text — no parsing into sections.\n   */\n  oddHeader?: string;\n  oddFooter?: string;\n  evenHeader?: string;\n  evenFooter?: string;\n  firstHeader?: string;\n  firstFooter?: string;\n}\n\nexport const makePageMargins = (opts: Partial<PageMargins> = {}): PageMargins => ({\n  left: opts.left ?? 0.75,\n  right: opts.right ?? 0.75,\n  top: opts.top ?? 1,\n  bottom: opts.bottom ?? 1,\n  header: opts.header ?? 0.5,\n  footer: opts.footer ?? 0.5,\n});\n\nexport const makePrintOptions = (opts: PrintOptions = {}): PrintOptions => ({ ...opts });\n\nexport const makePageSetup = (opts: PageSetup = {}): PageSetup => ({ ...opts });\n\nexport const makeHeaderFooter = (opts: HeaderFooter = {}): HeaderFooter => ({ ...opts });\n\n/**\n * One manual page break. `id` is the row (for rowBreaks) or column (for\n * colBreaks) index where the break sits; `min`/`max` constrain the orthogonal\n * range Excel honours; `man=true` means a user-placed break (default true).\n * `pt` indicates a \"pivot table\" break — rare.\n */\nexport interface PageBreak {\n  id?: number;\n  min?: number;\n  max?: number;\n  man?: boolean;\n  pt?: boolean;\n}\n\nexport const makePageBreak = (opts: PageBreak = {}): PageBreak => ({ ...opts });\n\n// ---- Worksheet ergonomic helpers ----------------------------------------\n// Operate on a Worksheet directly so callers don't have to allocate the\n// individual typed records up front.\n\nimport type { Worksheet } from './worksheet';\n\nconst ensurePageSetup = (ws: Worksheet): PageSetup => {\n  if (!ws.pageSetup) ws.pageSetup = {};\n  return ws.pageSetup;\n};\n\nconst ensureHeaderFooter = (ws: Worksheet): HeaderFooter => {\n  if (!ws.headerFooter) ws.headerFooter = {};\n  return ws.headerFooter;\n};\n\n/** Set page orientation on `ws.pageSetup` (allocates if missing). */\nexport const setPageOrientation = (ws: Worksheet, orientation: PageOrientation): void => {\n  ensurePageSetup(ws).orientation = orientation;\n};\n\n/** Set paper size code (Excel uses ECMA-376 §3.3 paper-size enums; 1=Letter, 9=A4 etc.). */\nexport const setPaperSize = (ws: Worksheet, paperSize: number): void => {\n  ensurePageSetup(ws).paperSize = paperSize;\n};\n\n/** Set the print scale percentage (10..400). */\nexport const setPrintScale = (ws: Worksheet, scale: number): void => {\n  ensurePageSetup(ws).scale = scale;\n};\n\n/** Set fitToWidth + fitToHeight (Excel \"Fit to N pages wide × M tall\" UI). */\nexport const setFitToPage = (ws: Worksheet, opts: { width?: number; height?: number }): void => {\n  const ps = ensurePageSetup(ws);\n  if (opts.width !== undefined) ps.fitToWidth = opts.width;\n  if (opts.height !== undefined) ps.fitToHeight = opts.height;\n};\n\n/** Replace ws.pageMargins with the provided values (uses Excel defaults for missing axes). */\nexport const setPageMargins = (ws: Worksheet, opts: Partial<PageMargins> = {}): void => {\n  ws.pageMargins = {\n    left: opts.left ?? 0.75,\n    right: opts.right ?? 0.75,\n    top: opts.top ?? 1,\n    bottom: opts.bottom ?? 1,\n    header: opts.header ?? 0.5,\n    footer: opts.footer ?? 0.5,\n  };\n};\n\nexport type HeaderFooterSection = 'odd' | 'even' | 'first';\n\n/** Set the header text for a given section. Excel uses `&L` / `&C` / `&R` codes inside the string. */\nexport const setHeader = (ws: Worksheet, section: HeaderFooterSection, text: string): void => {\n  const hf = ensureHeaderFooter(ws);\n  if (section === 'odd') hf.oddHeader = text;\n  else if (section === 'even') {\n    hf.evenHeader = text;\n    hf.differentOddEven = true;\n  } else {\n    hf.firstHeader = text;\n    hf.differentFirst = true;\n  }\n};\n\n/** Set the footer text for a given section. */\nexport const setFooter = (ws: Worksheet, section: HeaderFooterSection, text: string): void => {\n  const hf = ensureHeaderFooter(ws);\n  if (section === 'odd') hf.oddFooter = text;\n  else if (section === 'even') {\n    hf.evenFooter = text;\n    hf.differentOddEven = true;\n  } else {\n    hf.firstFooter = text;\n    hf.differentFirst = true;\n  }\n};\n\n/**\n * Excel's reserved header / footer code tokens. Drop these into the left /\n * center / right text inputs of {@link buildHeaderFooterText} (or directly into\n * a setHeader / setFooter string) to render dynamic values at print time.\n */\nexport const HEADER_FOOTER_CODES = Object.freeze({\n  /** Current page number. */\n  pageNumber: '&P',\n  /** Total number of pages. */\n  pageCount: '&N',\n  /** Print date. */\n  date: '&D',\n  /** Print time. */\n  time: '&T',\n  /** File path + name. */\n  filePath: '&Z&F',\n  /** File name only. */\n  fileName: '&F',\n  /** Sheet name. */\n  sheetName: '&A',\n  /** Embedded image (Excel inserts via \"Insert Picture\" — `&G` is the placeholder). */\n  picture: '&G',\n});\n\n/**\n * Build a header / footer string from optional left / center / right fragments\n * using Excel's `&L` / `&C` / `&R` markers. An empty fragment is omitted (no\n * marker emitted) so a center-only header doesn't leave a stray `&L` prefix.\n * Returns `''` when all three fragments are undefined.\n */\nexport const buildHeaderFooterText = (\n  parts: { left?: string; center?: string; right?: string },\n): string => {\n  let out = '';\n  if (parts.left !== undefined) out += `&L${parts.left}`;\n  if (parts.center !== undefined) out += `&C${parts.center}`;\n  if (parts.right !== undefined) out += `&R${parts.right}`;\n  return out;\n};\n\n/**\n * Set a header by left / center / right parts. `section` defaults to `'odd'`\n * (the standard pages); pass `'first'` or `'even'` to target the alternate\n * sections (Excel auto-flips the corresponding differentOddEven /\n * differentFirst flag).\n */\nexport const setHeaderText = (\n  ws: Worksheet,\n  parts: { left?: string; center?: string; right?: string },\n  section: HeaderFooterSection = 'odd',\n): void => {\n  setHeader(ws, section, buildHeaderFooterText(parts));\n};\n\n/** Same shape as {@link setHeaderText} but writes the corresponding footer slot. */\nexport const setFooterText = (\n  ws: Worksheet,\n  parts: { left?: string; center?: string; right?: string },\n  section: HeaderFooterSection = 'odd',\n): void => {\n  setFooter(ws, section, buildHeaderFooterText(parts));\n};\n\n/** Push a manual horizontal page break above the given row (1-based). Defaults to `man=true`. */\nexport const addRowBreak = (ws: Worksheet, row: number): PageBreak => {\n  const brk: PageBreak = { id: row, man: true, max: 16383 };\n  ws.rowBreaks.push(brk);\n  return brk;\n};\n\n/** Push a manual vertical page break to the left of the given column (1-based). Defaults to `man=true`. */\nexport const addColBreak = (ws: Worksheet, col: number): PageBreak => {\n  const brk: PageBreak = { id: col, man: true, max: 1048575 };\n  ws.colBreaks.push(brk);\n  return brk;\n};\n\nconst ensurePrintOptions = (ws: Worksheet): PrintOptions => {\n  if (!ws.printOptions) ws.printOptions = {};\n  return ws.printOptions;\n};\n\n/** Toggle \"Print gridlines\". Mirrors Excel's \"Page Layout → Sheet Options → Gridlines: Print\". */\nexport const setPrintGridLines = (ws: Worksheet, on: boolean): void => {\n  const po = ensurePrintOptions(ws);\n  po.gridLines = on;\n  // Excel pairs gridLines with the gridLinesSet companion flag.\n  po.gridLinesSet = on;\n};\n\n/** Toggle \"Print row and column headings\" (the A B C / 1 2 3 strips on the printed page). */\nexport const setPrintHeadings = (ws: Worksheet, on: boolean): void => {\n  ensurePrintOptions(ws).headings = on;\n};\n\n/**\n * Toggle horizontal / vertical centering on the printed page. Pass either field\n * to leave the other untouched.\n */\nexport const setPrintCentered = (\n  ws: Worksheet,\n  opts: { horizontal?: boolean; vertical?: boolean },\n): void => {\n  const po = ensurePrintOptions(ws);\n  if (opts.horizontal !== undefined) po.horizontalCentered = opts.horizontal;\n  if (opts.vertical !== undefined) po.verticalCentered = opts.vertical;\n};\n\n","// Worksheet-level <customProperties> and <webPublishItems>.\n//\n// Both elements live near the bottom of <worksheet> (after tableParts, before\n// extLst per ECMA-376 §18.3.1.43 / §18.3.1.97). Each is a thin shell over a\n// list of children. customProperty references a Custom XML part via `r:id` —\n// the underlying rel is already preserved by the worksheet's `relsExtras`\n// machinery, so we just have to keep the inline element from leaking.\n\n/**\n * One <customProperty>. The `rId` points at a Custom XML part registered in the\n * worksheet rels (e.g. for SharePoint sync metadata).\n */\nexport interface WorksheetCustomProperty {\n  name: string;\n  /** Worksheet-rels rId pointing at the Custom XML part backing this entry. */\n  rId?: string;\n}\n\nexport interface WebPublishItem {\n  id: number;\n  divId: string;\n  sourceType: 'sheet' | 'printArea' | 'autoFilter' | 'range' | 'chart' | 'pivotTable' | 'query' | 'label';\n  sourceRef?: string;\n  sourceObject?: string;\n  destinationFile: string;\n  title?: string;\n  autoRepublish?: boolean;\n}\n\nexport const makeWorksheetCustomProperty = (\n  opts: WorksheetCustomProperty,\n): WorksheetCustomProperty => ({\n  name: opts.name,\n  ...(opts.rId !== undefined ? { rId: opts.rId } : {}),\n});\n\nexport const makeWebPublishItem = (opts: WebPublishItem): WebPublishItem => ({\n  id: opts.id,\n  divId: opts.divId,\n  sourceType: opts.sourceType,\n  destinationFile: opts.destinationFile,\n  ...(opts.sourceRef !== undefined ? { sourceRef: opts.sourceRef } : {}),\n  ...(opts.sourceObject !== undefined ? { sourceObject: opts.sourceObject } : {}),\n  ...(opts.title !== undefined ? { title: opts.title } : {}),\n  ...(opts.autoRepublish !== undefined ? { autoRepublish: opts.autoRepublish } : {}),\n});\n","// Worksheet-level <phoneticPr> for East-Asian (mostly Japanese) furigana\n// rendering.\n//\n// Excel uses `<phoneticPr fontId=\"...\" type=\"...\" alignment=\"...\"/>` to drive\n// how it renders the small phonetic annotation strip above CJK characters in\n// cells. The per-cell `<rPh>` annotations live on shared-string entries and are\n// a separate concern (richer model).\n\nexport type PhoneticType = 'halfwidthKatakana' | 'fullwidthKatakana' | 'Hiragana' | 'noConversion';\nexport type PhoneticAlignment = 'noControl' | 'left' | 'center' | 'distributed';\n\nexport interface WorksheetPhoneticProperties {\n  /** Font index in the workbook's stylesheet for the furigana glyphs. */\n  fontId?: number;\n  /** Conversion mode the IME should default to when adding furigana. */\n  type?: PhoneticType;\n  /** Horizontal alignment of the furigana strip relative to the base text. */\n  alignment?: PhoneticAlignment;\n}\n\nexport const makeWorksheetPhoneticProperties = (\n  opts: WorksheetPhoneticProperties = {},\n): WorksheetPhoneticProperties => ({ ...opts });\n","// Worksheet-level <dataConsolidate>. Used by Excel's\n// Data → Consolidate dialog to join multiple ranges into one summary\n// table. Per ECMA-376 §18.3.1.20, §18.3.1.22 (dataRef).\n\nexport type DataConsolidateFunction =\n  | 'average'\n  | 'count'\n  | 'countNums'\n  | 'max'\n  | 'min'\n  | 'product'\n  | 'stdDev'\n  | 'stdDevp'\n  | 'sum'\n  | 'var'\n  | 'varp';\n\nexport interface DataReference {\n  /** Optional name of the source range (defined-name reference). */\n  name?: string;\n  /** External range ref like \"Sheet1!$A$1:$B$10\" — required when no `rId`. */\n  ref?: string;\n  /** Optional friendly sheet name for display. */\n  sheet?: string;\n  /** rels rId pointing at an external workbook part — round-tripped verbatim. */\n  rId?: string;\n}\n\nexport interface DataConsolidate {\n  /** Aggregation function applied to overlapping cells. Default `sum`. */\n  function?: DataConsolidateFunction;\n  /** Use top-row labels as category keys. */\n  topLabels?: boolean;\n  /** Use left-column labels as category keys. */\n  leftLabels?: boolean;\n  /** \"Create links to source data\" (Excel's checkbox). */\n  link?: boolean;\n  /** Optional `<dataRefs>` list (one entry per source range). */\n  dataRefs?: DataReference[];\n  /**\n   * `startLabels` was added in a later schema revision — round-tripped\n   * verbatim when present.\n   */\n  startLabels?: string;\n}\n\nexport const makeDataConsolidate = (opts: DataConsolidate = {}): DataConsolidate => {\n  const out: DataConsolidate = {};\n  if (opts.function !== undefined) out.function = opts.function;\n  if (opts.topLabels !== undefined) out.topLabels = opts.topLabels;\n  if (opts.leftLabels !== undefined) out.leftLabels = opts.leftLabels;\n  if (opts.link !== undefined) out.link = opts.link;\n  if (opts.dataRefs !== undefined) out.dataRefs = opts.dataRefs.map((r) => ({ ...r }));\n  if (opts.startLabels !== undefined) out.startLabels = opts.startLabels;\n  return out;\n};\n","// Worksheet-level <scenarios> — Excel's Data → What-If Analysis →\n// Scenario Manager. Per ECMA-376 §18.3.1.74 / §18.3.1.41 (inputCells)\n// and openpyxl/openpyxl/worksheet/scenario.py.\n\nimport type { MultiCellRange } from './cell-range';\n\n/** One <inputCells> entry — a single (cell, override-value) pair. */\nexport interface ScenarioInputCell {\n  /** Single-cell ref, e.g. \"B5\". */\n  ref: string;\n  /** Stored as a string on the wire (Excel uses int / float / text format codes via numFmtId). */\n  val: string;\n  /** Mark this entry as deleted in the scenario history. */\n  deleted?: boolean;\n  /** Marks an undone change in the scenario history. */\n  undone?: boolean;\n  /** Number-format index used to display the override. */\n  numFmtId?: number;\n}\n\nexport interface Scenario {\n  name: string;\n  inputCells: ScenarioInputCell[];\n  /** When true, Excel disables editing the scenario unless the workbook protection password is supplied. */\n  locked?: boolean;\n  /** Hide the scenario from the picker dialog. */\n  hidden?: boolean;\n  user?: string;\n  comment?: string;\n}\n\nexport interface ScenarioList {\n  scenarios: Scenario[];\n  /** Index of the currently active scenario. */\n  current?: number;\n  /** Index of the scenario shown by default. */\n  show?: number;\n  /** Range that the scenarios change (output cells). */\n  sqref?: MultiCellRange;\n}\n\nexport const makeScenarioInputCell = (opts: ScenarioInputCell): ScenarioInputCell => ({\n  ref: opts.ref,\n  val: opts.val,\n  ...(opts.deleted !== undefined ? { deleted: opts.deleted } : {}),\n  ...(opts.undone !== undefined ? { undone: opts.undone } : {}),\n  ...(opts.numFmtId !== undefined ? { numFmtId: opts.numFmtId } : {}),\n});\n\nexport const makeScenario = (opts: Scenario): Scenario => ({\n  name: opts.name,\n  inputCells: opts.inputCells.slice(),\n  ...(opts.locked !== undefined ? { locked: opts.locked } : {}),\n  ...(opts.hidden !== undefined ? { hidden: opts.hidden } : {}),\n  ...(opts.user !== undefined ? { user: opts.user } : {}),\n  ...(opts.comment !== undefined ? { comment: opts.comment } : {}),\n});\n\nexport const makeScenarioList = (opts: Partial<ScenarioList> = {}): ScenarioList => ({\n  scenarios: opts.scenarios?.slice() ?? [],\n  ...(opts.current !== undefined ? { current: opts.current } : {}),\n  ...(opts.show !== undefined ? { show: opts.show } : {}),\n  ...(opts.sqref !== undefined ? { sqref: opts.sqref } : {}),\n});\n"],"mappings":";;;AAwBA,SAAgB,eAAe,MAAmE;CAChG,OAAO;EAAE,KAAK,KAAK;EAAK,eAAe,KAAK,iBAAiB,CAAC;CAAE;AAClE;AAEA,SAAgB,iBAAiB,MAIhB;CACf,OAAO;EACL,MAAM;EACN,OAAO,KAAK;EACZ,QAAQ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