{"version":3,"file":"comments-HOkY82qH.mjs","names":["buildRstXml","buildRstXml"],"sources":["../src/parts/shared-strings.ts","../src/parts/worksheet.ts","../src/parts/comments.ts"],"sourcesContent":["/**\n * Shared Strings Table — generates xl/sharedStrings.xml.\n *\n * XLSX stores repeated string values in a central table to reduce file size.\n * Cells reference strings by index into this table.\n *\n * @module\n */\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml, findChild, attr, attrNum, textOf } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type {\n  RichTextOptions,\n  RichTextRunOptions,\n  RichTextRunPropertiesOptions,\n} from \"./worksheet\";\n\n/** String or rich text entry in the SST. */\ntype SstEntry = string | RichTextOptions;\n\n/**\n * Build rich text run properties XML (CT_RPrElt).\n * Exported for reuse by Comments and other components.\n */\nexport function buildRPrXml(\n  pr: NonNullable<RichTextOptions[\"runs\"]>[number][\"properties\"],\n): string {\n  if (!pr) return \"\";\n  const parts: string[] = [];\n  if (pr.font) parts.push(`<rFont val=\"${escapeXml(pr.font)}\"/>`);\n  if (pr.charset !== undefined) parts.push(`<charset val=\"${pr.charset}\"/>`);\n  if (pr.family !== undefined) parts.push(`<family val=\"${pr.family}\"/>`);\n  if (pr.bold) parts.push(\"<b/>\");\n  if (pr.italic) parts.push(\"<i/>\");\n  if (pr.strike) parts.push(\"<strike/>\");\n  if (pr.outline) parts.push(\"<outline/>\");\n  if (pr.shadow) parts.push(\"<shadow/>\");\n  if (pr.condense) parts.push(\"<condense/>\");\n  if (pr.extend) parts.push(\"<extend/>\");\n  if (pr.color) {\n    // ST_UnsignedIntHex requires 8 hex chars (AARRGGBB).\n    // Auto-prefix FF (fully opaque) when user provides 6-char RGB.\n    const rgb = pr.color.length === 6 ? `FF${pr.color}` : pr.color;\n    parts.push(`<color rgb=\"${escapeXml(rgb)}\"/>`);\n  }\n  if (pr.size !== undefined) parts.push(`<sz val=\"${pr.size}\"/>`);\n  if (pr.underline) {\n    if (pr.underline === \"none\") {\n      parts.push(\"<u/>\");\n    } else {\n      parts.push(`<u val=\"${pr.underline}\"/>`);\n    }\n  }\n  if (pr.vertAlign) parts.push(`<vertAlign val=\"${pr.vertAlign}\"/>`);\n  if (pr.scheme) parts.push(`<scheme val=\"${pr.scheme}\"/>`);\n  return parts.length > 0 ? `<rPr>${parts.join(\"\")}</rPr>` : \"\";\n}\n\n/** Build a CT_Rst XML string from RichTextOptions. */\nexport function buildRstXml(rst: RichTextOptions): string {\n  const parts: string[] = [];\n  if (rst.runs && rst.runs.length > 0) {\n    for (const run of rst.runs) {\n      const rPr = buildRPrXml(run.properties);\n      parts.push(`<r>${rPr}<t>${escapeXml(run.text)}</t></r>`);\n    }\n  } else if (rst.text !== undefined) {\n    parts.push(`<t>${escapeXml(rst.text)}</t>`);\n  }\n  // rPh (phonetics)\n  if (rst.phonetics) {\n    for (const ph of rst.phonetics) {\n      parts.push(`<rPh sb=\"${ph.sb}\" eb=\"${ph.eb}\"><t>${escapeXml(ph.text)}</t></rPh>`);\n    }\n  }\n  return parts.join(\"\");\n}\n\nexport class SharedStrings {\n  private entries: SstEntry[] = [];\n  /** Dedup map for plain strings only. Rich text is not deduped. */\n  private indexMap = new Map<string, number>();\n\n  /**\n   * Register a plain string and return its index.\n   * Returns existing index if the string is already registered.\n   */\n  public register(s: string): number {\n    const existing = this.indexMap.get(s);\n    if (existing !== undefined) return existing;\n\n    const idx = this.entries.length;\n    this.entries.push(s);\n    this.indexMap.set(s, idx);\n    return idx;\n  }\n\n  /**\n   * Register a rich text entry and return its index.\n   * Rich text is not deduped (each call creates a new entry).\n   */\n  public registerRich(rst: RichTextOptions): number {\n    const idx = this.entries.length;\n    this.entries.push(rst);\n    return idx;\n  }\n\n  /**\n   * Bulk-load parsed template entries, preserving their original indices so\n   * existing cell references stay valid. Plain strings populate the dedup map\n   * (first occurrence wins); rich-text entries are appended unchanged.\n   *\n   * Used by patch to extend an existing workbook's shared strings, so appended\n   * worksheets continue registering strings at the correct offset.\n   */\n  public loadEntries(entries: SharedStringsDocOptions[\"entries\"]): void {\n    for (const entry of entries) {\n      const idx = this.entries.length;\n      this.entries.push(entry);\n      if (typeof entry === \"string\" && !this.indexMap.has(entry)) {\n        this.indexMap.set(entry, idx);\n      }\n    }\n  }\n\n  public get count(): number {\n    return this.entries.length;\n  }\n\n  /** Return a serializable snapshot for the descriptor. */\n  public toDescriptorOptions(): { entries: SstEntry[]; uniqueCount: number } {\n    return { entries: this.entries, uniqueCount: this.indexMap.size };\n  }\n\n  /** Serialize to xl/sharedStrings.xml content (without XML declaration). */\n  public serialize(): string {\n    const p: string[] = [\n      '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n      ` count=\"${this.entries.length}\" uniqueCount=\"${this.indexMap.size}\">`,\n    ];\n    for (const entry of this.entries) {\n      if (typeof entry === \"string\") {\n        p.push(`<si><t>${escapeXml(entry)}</t></si>`);\n      } else {\n        // Rich text (CT_Rst)\n        p.push(`<si>${buildRstXml(entry)}</si>`);\n      }\n    }\n    p.push(\"</sst>\");\n    return p.join(\"\");\n  }\n}\n\n// ── Descriptor Types ──\n\n/** Serializable snapshot of the shared string table. */\nexport interface SharedStringsDocOptions {\n  /** All entries (plain strings and rich text), in registration order. */\n  entries: (string | RichTextOptions)[];\n  /** Number of unique plain-string entries (for uniqueCount attribute). */\n  uniqueCount: number;\n}\n\n// ── Descriptor ──\n\nexport const sharedStringsDesc: CustomDescriptor<SharedStringsDocOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    if (opts.entries.length === 0) return undefined;\n\n    const p: string[] = [\n      '<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"',\n      ` count=\"${opts.entries.length}\" uniqueCount=\"${opts.uniqueCount}\">`,\n    ];\n\n    for (const entry of opts.entries) {\n      if (typeof entry === \"string\") {\n        p.push(`<si><t>${escapeXml(entry)}</t></si>`);\n      } else {\n        p.push(`<si>${buildRstXml(entry)}</si>`);\n      }\n    }\n\n    p.push(\"</sst>\");\n    return p.join(\"\");\n  },\n\n  parse(el, _ctx) {\n    const entries: (string | RichTextOptions)[] = [];\n\n    for (const si of el.elements ?? []) {\n      if (si.name !== \"si\") continue;\n\n      // Simple: <si><t>text</t></si>\n      const t = findChild(si, \"t\");\n      if (t) {\n        entries.push(textOf(t) ?? \"\");\n        continue;\n      }\n\n      // Rich text: <si><r>...</r>...</si>\n      const runs: RichTextRunOptions[] = [];\n      for (const r of si.elements ?? []) {\n        if (r.name !== \"r\") continue;\n        const rt = findChild(r, \"t\");\n        if (rt) {\n          const rPrEl = findChild(r, \"rPr\");\n          const run: RichTextRunOptions = { text: textOf(rt) ?? \"\" };\n          if (rPrEl) run.properties = parseRPr(rPrEl);\n          runs.push(run);\n        }\n      }\n\n      // Phonetics: <rPh sb=\"...\" eb=\"...\"><t>...</t></rPh>\n      const phonetics: { sb: number; eb: number; text: string }[] = [];\n      for (const rPh of si.elements ?? []) {\n        if (rPh.name !== \"rPh\") continue;\n        const sb = attrNum(rPh, \"sb\") ?? 0;\n        const eb = attrNum(rPh, \"eb\") ?? 0;\n        const rPhT = findChild(rPh, \"t\");\n        phonetics.push({ sb, eb, text: rPhT ? (textOf(rPhT) ?? \"\") : \"\" });\n      }\n\n      if (runs.length > 0) {\n        const entry: RichTextOptions = { runs };\n        if (phonetics.length > 0) entry.phonetics = phonetics;\n        entries.push(entry);\n      }\n    }\n\n    return {\n      entries,\n      uniqueCount: entries.length,\n    };\n  },\n};\n\n/** Parse CT_RPrElt (run properties inside shared strings r element). */\nfunction parseRPr(el: XmlElement): RichTextRunPropertiesOptions {\n  const result: RichTextRunPropertiesOptions = {};\n  for (const child of el.elements ?? []) {\n    switch (child.name) {\n      case \"rFont\":\n        result.font = attr(child, \"val\") ?? undefined;\n        break;\n      case \"charset\":\n        result.charset = attrNum(child, \"val\");\n        break;\n      case \"family\":\n        result.family = attrNum(child, \"val\");\n        break;\n      case \"b\":\n        result.bold = attr(child, \"val\") !== \"0\";\n        break;\n      case \"i\":\n        result.italic = attr(child, \"val\") !== \"0\";\n        break;\n      case \"strike\":\n        result.strike = true;\n        break;\n      case \"outline\":\n        result.outline = true;\n        break;\n      case \"shadow\":\n        result.shadow = true;\n        break;\n      case \"condense\":\n        result.condense = true;\n        break;\n      case \"extend\":\n        result.extend = true;\n        break;\n      case \"color\": {\n        const rgb = attr(child, \"rgb\");\n        if (rgb) {\n          result.color = rgb.length === 8 ? rgb.slice(2) : rgb;\n        } else {\n          const indexed = attrNum(child, \"indexed\");\n          if (indexed !== undefined) result.color = String(indexed);\n          else {\n            const theme = attr(child, \"theme\");\n            if (theme !== undefined) result.color = `theme:${theme}`;\n          }\n        }\n        break;\n      }\n      case \"sz\":\n        result.size = attrNum(child, \"val\");\n        break;\n      case \"u\": {\n        const uVal = attr(child, \"val\");\n        result.underline =\n          (uVal as RichTextRunPropertiesOptions[\"underline\"] | undefined) ?? \"single\";\n        break;\n      }\n      case \"vertAlign\":\n        result.vertAlign = attr(child, \"val\") as\n          | RichTextRunPropertiesOptions[\"vertAlign\"]\n          | undefined;\n        break;\n      case \"scheme\":\n        result.scheme = attr(child, \"val\") as RichTextRunPropertiesOptions[\"scheme\"] | undefined;\n        break;\n    }\n  }\n  return result;\n}\n","/**\n * Worksheet XML generation — pure functions for xl/worksheets/sheet{n}.xml.\n *\n * All interfaces and the zero-allocation string concatenation fast path\n * are preserved. The `Worksheet` class has been replaced by `buildWorksheetXml()`.\n *\n * @module\n */\n\nimport { convertToPt, derivePasswordHash } from \"@office-open/core\";\nimport type {\n  ChartSpaceOptions,\n  DataType,\n  PositiveUniversalMeasure,\n  UniversalMeasure,\n} from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attrs, attrsRaw, escapeXml, selfCloseElement } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild, attr, attrMeasure, attrNum, textOf } from \"@office-open/xml\";\n\nimport type { XlsxReadContext } from \"../context\";\nimport type { PivotTableOptions } from \"./pivot\";\nimport { buildRstXml } from \"./shared-strings\";\nimport type { SharedStrings } from \"./shared-strings\";\nimport type { Styles, StyleOptions } from \"./styles\";\nimport type { TableOptions } from \"./table\";\n\n// ── Option interfaces ──\n\nexport interface ColumnOptions {\n  min: number;\n  max: number;\n  width?: number;\n  hidden?: boolean;\n  customWidth?: boolean;\n  outlineLevel?: number;\n  collapsed?: boolean;\n  /** Best-fit column width (CT_Col @bestFit) */\n  bestFit?: boolean;\n  /** Phonetic text for CJK (CT_Col @phonetic) */\n  phonetic?: boolean;\n}\n\nexport interface RowOptions {\n  cells?: CellOptions[];\n  height?: number | UniversalMeasure;\n  hidden?: boolean;\n  rowNumber?: number;\n  /** Spans for the row, e.g. \"1:15\" (CT_Row @spans) */\n  spans?: string;\n  /** Custom format applied (CT_Row @customFormat) */\n  customFormat?: boolean;\n  /** Thick top border (CT_Row @thickTop) */\n  thickTop?: boolean;\n  /** Thick bottom border (CT_Row @thickBot) */\n  thickBot?: boolean;\n  /** Phonetic text (CT_Row @ph) */\n  ph?: boolean;\n}\n\n/** Rich text run properties (CT_RPrElt). */\nexport interface RichTextRunPropertiesOptions {\n  /** Font name (CT_FontName → rFont) */\n  font?: string;\n  /** Character set (CT_IntProperty) */\n  charset?: number;\n  /** Font family (CT_IntProperty) */\n  family?: number;\n  /** Bold */\n  bold?: boolean;\n  /** Italic */\n  italic?: boolean;\n  /** Strikethrough */\n  strike?: boolean;\n  /** Outline */\n  outline?: boolean;\n  /** Shadow */\n  shadow?: boolean;\n  /** Condense */\n  condense?: boolean;\n  /** Extend */\n  extend?: boolean;\n  /** Font color (hex RGB, e.g. \"FF0000\") */\n  color?: string;\n  /** Font size in points */\n  size?: number;\n  /** Underline type */\n  underline?: \"single\" | \"double\" | \"singleAccounting\" | \"doubleAccounting\" | \"none\";\n  /** Vertical alignment */\n  vertAlign?: \"superscript\" | \"subscript\" | \"baseline\";\n  /** Font scheme */\n  scheme?: \"major\" | \"minor\" | \"none\";\n}\n\n/** A single rich text run (CT_RElt). */\nexport interface RichTextRunOptions {\n  /** Run properties (optional = inherits from parent) */\n  properties?: RichTextRunPropertiesOptions;\n  /** Run text content */\n  text: string;\n}\n\n/** Phonetics run for CJK (CT_PhoneticRun → rPh). */\nexport interface PhoneticRunOptions {\n  /** Start byte offset in base text */\n  sb: number;\n  /** End byte offset in base text */\n  eb: number;\n  /** Phonetic text */\n  text: string;\n}\n\n/** Rich text content (CT_Rst). Either plain text or rich runs. */\nexport interface RichTextOptions {\n  /** Plain text (mutually exclusive with runs) */\n  text?: string;\n  /** Rich text runs (mutually exclusive with text) */\n  runs?: RichTextRunOptions[];\n  /** Phonetic runs for CJK (CT_PhoneticRun) */\n  phonetics?: PhoneticRunOptions[];\n}\n\nexport interface CellOptions {\n  value?: string | number | boolean | Date | RichTextOptions | null;\n  reference?: string;\n  /** Direct style index (for pre-resolved styles) */\n  styleIndex?: number;\n  /** Style options (resolved to index at compile time) */\n  style?: StyleOptions;\n  /** Formula options. When set, value becomes the cached result. */\n  formula?: FormulaOptions;\n}\n\n/** Cell formula type (maps to ST_CellFormulaType). */\nexport const FormulaType = {\n  NORMAL: \"normal\",\n  ARRAY: \"array\",\n  SHARED: \"shared\",\n} as const;\n\nexport type FormulaType = (typeof FormulaType)[keyof typeof FormulaType];\n\n/** Options for a cell formula (maps to CT_CellFormula). */\nexport interface FormulaOptions {\n  /** Formula expression, e.g. \"SUM(A1:B1)\" */\n  formula: string;\n  /** Formula type (default: \"normal\") */\n  type?: FormulaType;\n  /** Reference range for array/shared formulas, e.g. \"C1:C10\" */\n  reference?: string;\n  /** Shared formula group index (required for shared formulas) */\n  sharedIndex?: number;\n  /** Always calculate array (CT_CellFormula @aca) */\n  aca?: boolean;\n  /** 2-D data table (CT_CellFormula @dt2D) */\n  dt2D?: boolean;\n  /** Data table row (CT_CellFormula @dtr) */\n  dtr?: boolean;\n  /** Delete input cell 1 (CT_CellFormula @del1) */\n  del1?: boolean;\n  /** Delete input cell 2 (CT_CellFormula @del2) */\n  del2?: boolean;\n  /** Input cell 1 reference (CT_CellFormula @r1) */\n  r1?: string;\n  /** Input cell 2 reference (CT_CellFormula @r2) */\n  r2?: string;\n  /** Calculate cell (CT_CellFormula @ca) */\n  ca?: boolean;\n  /** Array formula context (CT_CellFormula @bx) */\n  bx?: boolean;\n}\n\n/** Input cell for a what-if scenario (maps to CT_InputCells). */\nexport interface ScenarioCellOptions {\n  /** Cell reference, e.g. \"B2\" */\n  r: string;\n  /** Cell value for this scenario */\n  val: string | number;\n  /** Whether the value is deleted */\n  deleted?: boolean;\n  /** Whether undone (CT_InputCells @undone) */\n  undone?: boolean;\n}\n\n/** A single what-if scenario (maps to CT_Scenario). */\nexport interface ScenarioDefinition {\n  /** Scenario name */\n  name: string;\n  /** Input cells with their values for this scenario */\n  inputCells: ScenarioCellOptions[];\n  /** Sort/order count */\n  count?: number;\n  /** Creator user name */\n  user?: string;\n  /** Comment */\n  comment?: string;\n  /** Whether the scenario is hidden */\n  hidden?: boolean;\n  /** Whether the scenario is locked */\n  locked?: boolean;\n}\n\n/** Scenarios for what-if analysis (maps to CT_Scenarios). */\nexport interface ScenarioOptions {\n  /** Named scenarios */\n  scenarios: ScenarioDefinition[];\n  /** Current scenario index (0-based) */\n  current?: number;\n  /** Show scenario index (0-based) */\n  show?: number;\n}\n\nexport interface MergeCellOptions {\n  from: { row: number; col: number };\n  to: { row: number; col: number };\n}\n\nexport interface SheetProtectionOptions {\n  /** Plain-text password — legacy Excel hash is computed automatically */\n  password?: string;\n  /** Modern encryption: algorithm name (e.g. \"SHA-512\") */\n  algorithmName?: string;\n  /** Modern encryption: base64-encoded hash value */\n  hashValue?: string;\n  /** Modern encryption: base64-encoded salt value */\n  saltValue?: string;\n  /** Modern encryption: spin count for hash iteration */\n  spinCount?: number;\n  /** Set true to enable sheet protection (required for protection flags to take effect) */\n  sheet?: boolean;\n  objects?: boolean;\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  sort?: boolean;\n  autoFilter?: boolean;\n  pivotTables?: boolean;\n  selectUnlockedCells?: boolean;\n}\n\n/** A named protected range within a sheet (CT_ProtectedRange) */\nexport interface ProtectedRangeOptions {\n  /** Range reference (required), e.g. \"A1:C10\" */\n  sqref: string;\n  /** Range name (required) */\n  name: string;\n  /** Plain-text password — legacy hash computed automatically */\n  password?: string;\n  /** Modern encryption: algorithm name */\n  algorithmName?: string;\n  /** Modern encryption: base64-encoded hash value */\n  hashValue?: string;\n  /** Modern encryption: base64-encoded salt value */\n  saltValue?: string;\n  /** Modern encryption: spin count */\n  spinCount?: number;\n  /** Security descriptor (SID string) */\n  securityDescriptor?: string;\n}\n\nexport interface FreezePaneOptions {\n  /** Row split position (1-based, freezes rows above) */\n  row?: number;\n  /** Column split position (1-based, freezes columns to the left) */\n  col?: number;\n}\n\nexport interface WorksheetImageOptions {\n  data: DataType;\n  type: \"png\" | \"jpg\";\n  col: number;\n  row: number;\n}\n\nexport interface WorksheetChartOptions extends ChartSpaceOptions {\n  /** 1-based column position for the chart */\n  col: number;\n  /** 1-based row position for the chart */\n  row: number;\n}\n\nexport interface SheetViewOptions {\n  showGridLines?: boolean;\n  showRowColHeaders?: boolean;\n  showZeros?: boolean;\n  zoomScale?: number;\n  tabSelected?: boolean;\n  rightToLeft?: boolean;\n  /** Window protection (CT_SheetView @windowProtection) */\n  windowProtection?: boolean;\n  /** Show formulas instead of values (CT_SheetView @showFormulas) */\n  showFormulas?: boolean;\n  /** Show ruler (CT_SheetView @showRuler) */\n  showRuler?: boolean;\n  /** Show outline symbols (CT_SheetView @showOutlineSymbols) */\n  showOutlineSymbols?: boolean;\n  /** Default grid color (CT_SheetView @defaultGridColor) */\n  defaultGridColor?: boolean;\n  /** Show white space (CT_SheetView @showWhiteSpace) */\n  showWhiteSpace?: boolean;\n  /** View type (CT_SheetView @view) */\n  view?: \"normal\" | \"pageBreakPreview\" | \"pageLayout\";\n  /** Tab color ID (CT_SheetView @colorId) */\n  colorId?: number;\n  /** Zoom scale for normal view (CT_SheetView @zoomScaleNormal) */\n  zoomScaleNormal?: number;\n  /** Zoom scale for sheet layout view (CT_SheetView @zoomScaleSheetLayoutView) */\n  zoomScaleSheetLayoutView?: number;\n  /** Zoom scale for page layout view (CT_SheetView @zoomScalePageLayoutView) */\n  zoomScalePageLayoutView?: number;\n  /** Pivot selections (CT_PivotSelection) */\n  pivotSelections?: PivotSelectionOptions[];\n}\n\n/** Pivot selection in sheet view (CT_PivotSelection) */\nexport interface PivotSelectionOptions {\n  /** Pane (default: \"topLeft\") */\n  pane?: \"bottomRight\" | \"topRight\" | \"bottomLeft\" | \"topLeft\";\n  /** Show header (default: false) */\n  showHeader?: boolean;\n  /** Label selected (default: false) */\n  label?: boolean;\n  /** Data selected (default: false) */\n  data?: boolean;\n  /** Extendable (default: false) */\n  extendable?: boolean;\n  /** Selection count */\n  count?: number;\n  /** Axis */\n  axis?: \"axisRow\" | \"axisCol\" | \"axisPage\" | \"axisValues\";\n  /** Dimension */\n  dimension?: number;\n  /** Start index */\n  start?: number;\n  /** Min index */\n  min?: number;\n  /** Max index */\n  max?: number;\n  /** Active row */\n  activeRow?: number;\n  /** Active column */\n  activeCol?: number;\n  /** Previous row */\n  previousRow?: number;\n  /** Previous column */\n  previousCol?: number;\n  /** Clicked row */\n  click?: number;\n  /** Relationship ID (maps to r:id in XML) */\n  rId?: string;\n}\n\nexport type HyperlinkTarget =\n  | { type: \"external\"; url: string }\n  | { type: \"internal\"; location: string };\n\nexport interface HyperlinkOptions {\n  /** Cell reference, e.g. \"A1\" */\n  cell: string;\n  /** Hyperlink target */\n  target: HyperlinkTarget;\n  /** Tooltip text */\n  tooltip?: string;\n  /** Display text */\n  display?: string;\n}\n\nexport interface HeaderFooterOptions {\n  oddHeader?: string;\n  oddFooter?: string;\n  evenHeader?: string;\n  evenFooter?: string;\n  firstHeader?: string;\n  firstFooter?: string;\n  differentOddEven?: boolean;\n  differentFirst?: boolean;\n  /** Scale header/footer with document (CT_HeaderFooter @scaleWithDoc) */\n  scaleWithDoc?: boolean;\n  /** Align with page margins (CT_HeaderFooter @alignWithMargins) */\n  alignWithMargins?: boolean;\n}\n\nexport type PageOrientation = \"default\" | \"portrait\" | \"landscape\";\n\nexport interface PageSetupOptions {\n  paperSize?: number;\n  orientation?: PageOrientation;\n  scale?: number;\n  fitToWidth?: number;\n  fitToHeight?: number;\n  pageOrder?: \"downThenOver\" | \"overThenDown\";\n  useFirstPageNumber?: boolean;\n  firstPageNumber?: number;\n  /** Paper height (CT_PageSetup @paperHeight, ST_PositiveUniversalMeasure) */\n  paperHeight?: number | PositiveUniversalMeasure;\n  /** Paper width (CT_PageSetup @paperWidth, ST_PositiveUniversalMeasure) */\n  paperWidth?: number | PositiveUniversalMeasure;\n  /** Use printer defaults (CT_PageSetup @usePrinterDefaults) */\n  usePrinterDefaults?: boolean;\n  /** Black and white printing (CT_PageSetup @blackAndWhite) */\n  blackAndWhite?: boolean;\n  /** Draft quality printing (CT_PageSetup @draft) */\n  draft?: boolean;\n  /** Print cell comments mode (CT_PageSetup @cellComments) */\n  cellComments?: \"none\" | \"asDisplayed\" | \"atEnd\";\n  /** Print error display mode (CT_PageSetup @errors) */\n  errors?: \"displayed\" | \"blank\" | \"dash\" | \"NA\";\n  /** Auto page breaks (CT_PageSetUpPr @autoPageBreaks) */\n  autoPageBreaks?: boolean;\n  /** Fit to page (CT_PageSetUpPr @fitToPage) */\n  fitToPage?: boolean;\n}\n\nexport interface TabColorOptions {\n  /** RGB color string, e.g. \"FF0000\" */\n  rgb?: string;\n  /** Theme color index (0-based) */\n  theme?: number;\n  /** Tint value (-1.0 to 1.0) */\n  tint?: number;\n  /** Indexed color (CT_Color @indexed) */\n  indexed?: number;\n}\n\n/** Object anchor (CT_ObjectAnchor). */\nexport interface ObjectAnchorOptions {\n  /** Move with cells (default: false) */\n  moveWithCells?: boolean;\n  /** Size with cells (default: false) */\n  sizeWithCells?: boolean;\n}\n\n/** Comment property (CT_CommentPr). */\nexport interface CommentPropertiesOptions {\n  /** Locked */\n  locked?: boolean;\n  /** Default size */\n  defaultSize?: boolean;\n  /** Print */\n  print?: boolean;\n  /** Disabled */\n  disabled?: boolean;\n  /** Auto fill */\n  autoFill?: boolean;\n  /** Auto line */\n  autoLine?: boolean;\n  /** Alt text */\n  altText?: string;\n  /** Text horizontal alignment */\n  textHAlign?: \"left\" | \"center\" | \"right\" | \"justify\" | \"distributed\";\n  /** Text vertical alignment */\n  textVAlign?: \"top\" | \"center\" | \"bottom\" | \"justify\" | \"distributed\";\n  /** Lock text */\n  lockText?: boolean;\n  /** Justify last line */\n  justLastX?: boolean;\n  /** Auto scale */\n  autoScale?: boolean;\n  /** Object anchor position */\n  anchor?: ObjectAnchorOptions;\n}\n\nexport interface CommentOptions {\n  /** Cell reference, e.g. \"A1\" */\n  cell: string;\n  /** Author name */\n  author: string;\n  /** Comment text (plain string or rich text) */\n  text: string | RichTextOptions;\n  /** Comment properties (CT_CommentPr) */\n  commentPr?: CommentPropertiesOptions;\n}\n\nexport type DataValidationType =\n  | \"none\"\n  | \"whole\"\n  | \"decimal\"\n  | \"list\"\n  | \"date\"\n  | \"time\"\n  | \"textLength\"\n  | \"custom\";\nexport type DataValidationOperator =\n  | \"between\"\n  | \"notBetween\"\n  | \"equal\"\n  | \"notEqual\"\n  | \"greaterThan\"\n  | \"lessThan\"\n  | \"greaterThanOrEqual\"\n  | \"lessThanOrEqual\";\n\nexport interface DataValidationOptions {\n  /** Cell range, e.g. \"A1:A10\" */\n  sqref: string;\n  type?: DataValidationType;\n  operator?: DataValidationOperator;\n  formula1?: string;\n  formula2?: string;\n  allowBlank?: boolean;\n  showErrorMessage?: boolean;\n  errorTitle?: string;\n  error?: string;\n  showInputMessage?: boolean;\n  promptTitle?: string;\n  prompt?: string;\n  /** Error style (CT_DataValidation @errorStyle) */\n  errorStyle?: \"stop\" | \"warning\" | \"information\";\n  /** IME mode (CT_DataValidation @imeMode) */\n  imeMode?:\n    | \"noControl\"\n    | \"on\"\n    | \"off\"\n    | \"disabled\"\n    | \"hiragana\"\n    | \"fullKatakana\"\n    | \"halfKatakana\"\n    | \"fullAlpha\"\n    | \"halfAlpha\"\n    | \"fullHangul\"\n    | \"halfHangul\";\n  /** Show drop-down (CT_DataValidation @showDropDown — note inverted semantics in OOXML) */\n  showDropDown?: boolean;\n}\n\nexport type ConditionalFormatType =\n  | \"cellIs\"\n  | \"containsText\"\n  | \"expression\"\n  | \"top10\"\n  | \"aboveAverage\"\n  | \"colorScale\"\n  | \"dataBar\"\n  | \"iconSet\";\nexport type ConditionalFormatOperator =\n  | \"lessThan\"\n  | \"lessThanOrEqual\"\n  | \"equal\"\n  | \"notEqual\"\n  | \"greaterThanOrEqual\"\n  | \"greaterThan\"\n  | \"between\"\n  | \"notBetween\"\n  | \"containsText\"\n  | \"notContains\"\n  | \"beginsWith\"\n  | \"endsWith\";\n\n/** Conditional format value object type (ST_CfvoType) */\nexport type CfvoType = \"num\" | \"percent\" | \"max\" | \"min\" | \"formula\" | \"percentile\";\n\n/** Conditional format value object */\nexport interface CfvoOptions {\n  type: CfvoType;\n  val?: string | number;\n  /** Greater than or equal (default: true) */\n  gte?: boolean;\n}\n\n/** Icon set type (ST_IconSetType) */\nexport type IconSetType =\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\n/** Color scale rule configuration */\nexport interface ColorScaleOptions {\n  /** Conditional format values (minimum 2, typically 2 or 3) */\n  cfvo: CfvoOptions[];\n  /** Colors for each value (same count as cfvo) — RGB hex without alpha, e.g. \"FF0000\" */\n  colors: string[];\n}\n\n/** Data bar rule configuration */\nexport interface DataBarOptions {\n  /** Minimum and maximum value objects (exactly 2) */\n  cfvo: [CfvoOptions, CfvoOptions];\n  /** Bar color — RGB hex without alpha, e.g. \"638EC6\" */\n  color: string;\n  /** Minimum bar length as percentage (default: 10) */\n  minLength?: number;\n  /** Maximum bar length as percentage (default: 90) */\n  maxLength?: number;\n  /** Whether to show cell values (default: true) */\n  showValue?: boolean;\n}\n\n/** Icon set rule configuration */\nexport interface IconSetOptions {\n  /** Conditional format values (minimum 2) */\n  cfvo: CfvoOptions[];\n  /** Icon set type (default: \"3TrafficLights1\") */\n  iconSet?: IconSetType;\n  /** Whether to show cell values (default: true) */\n  showValue?: boolean;\n  /** Whether values are percentages (default: true) */\n  percent?: boolean;\n  /** Whether to reverse icon order (default: false) */\n  reverse?: boolean;\n}\n\nexport interface ConditionalFormatRule {\n  type: ConditionalFormatType;\n  operator?: ConditionalFormatOperator;\n  /** Formula(s) — up to 3 */\n  formulas?: string[];\n  priority?: number;\n  /** Reference to a dxf (differential format) in the styles table */\n  dxfId?: number;\n  /** Color scale configuration (when type is \"colorScale\") */\n  colorScale?: ColorScaleOptions;\n  /** Data bar configuration (when type is \"dataBar\") */\n  dataBar?: DataBarOptions;\n  /** Icon set configuration (when type is \"iconSet\") */\n  iconSet?: IconSetOptions;\n  /** Stop if true — skip remaining rules (CT_CfRule @stopIfTrue) */\n  stopIfTrue?: boolean;\n  /** Time period for date-based highlighting (CT_CfRule @timePeriod) */\n  timePeriod?:\n    | \"today\"\n    | \"yesterday\"\n    | \"tomorrow\"\n    | \"last7Days\"\n    | \"thisMonth\"\n    | \"lastMonth\"\n    | \"nextMonth\"\n    | \"thisWeek\"\n    | \"lastWeek\"\n    | \"nextWeek\";\n  /** Rank for top/bottom rules (CT_CfRule @rank) */\n  rank?: number;\n  /** Equal average flag (CT_CfRule @equalAverage) */\n  equalAverage?: boolean;\n}\n\nexport interface ConditionalFormatOptions {\n  /** Cell range, e.g. \"A1:A10\" */\n  sqref: string;\n  rules: ConditionalFormatRule[];\n}\n\nexport interface Top10FilterOptions {\n  colId: number;\n  top?: boolean;\n  percent?: boolean;\n  val: number;\n  /** Filter value (CT_Top10 @filterVal) */\n  filterVal?: number;\n  /** Hide auto-filter button (CT_FilterColumn @hiddenButton) */\n  hiddenButton?: boolean;\n  /** Show filter button (CT_FilterColumn @showButton) */\n  showButton?: boolean;\n}\n\nexport interface CustomFilterOptions {\n  colId: number;\n  operator?:\n    | \"equal\"\n    | \"notEqual\"\n    | \"greaterThan\"\n    | \"greaterThanOrEqual\"\n    | \"lessThan\"\n    | \"lessThanOrEqual\";\n  val?: string;\n  and?: boolean;\n  val2?: string;\n  /** Hide auto-filter button (CT_FilterColumn @hiddenButton) */\n  hiddenButton?: boolean;\n  /** Show filter button (CT_FilterColumn @showButton) */\n  showButton?: boolean;\n}\n\nexport interface SortCondition {\n  /** Cell reference for the sort column, e.g. \"B1\" */\n  ref: string;\n  descending?: boolean;\n  /** Sort by (CT_SortCondition @sortBy) */\n  sortBy?: \"value\" | \"cellColor\" | \"fontColor\" | \"icon\";\n  /** Custom sort list (CT_SortCondition @customList) */\n  customList?: string;\n  /** Icon set index (CT_SortCondition @iconId) */\n  iconId?: number;\n}\n\nexport interface AutoFilterOptions {\n  /** Range, e.g. \"A1:D10\" */\n  ref: string;\n  top10?: Top10FilterOptions[];\n  customFilters?: CustomFilterOptions[];\n  sort?: SortCondition[];\n  /** Sort state options */\n  sortState?: SortStateOptions;\n  /** Color filters (CT_ColorFilter) */\n  colorFilters?: ColorFilterOptions[];\n  /** Icon filters (CT_IconFilter) */\n  iconFilters?: IconFilterOptions[];\n  /** Dynamic filters (CT_DynamicFilter) */\n  dynamicFilters?: DynamicFilterOptions[];\n  /** Date group items in filters (CT_DateGroupItem) */\n  dateGroupItems?: DateGroupFilterOptions[];\n  /** Simple filters with values (CT_Filters) */\n  filters?: FilterItemsOptions[];\n}\n\n/** Color filter (CT_ColorFilter) */\nexport interface ColorFilterOptions {\n  /** Column ID */\n  colId: number;\n  /** Cell color RGB (dxfId used if not set) */\n  dxfId?: number;\n  /** Filter by cell color (CT_ColorFilter @cellColor) */\n  cellColor?: boolean;\n}\n\n/** Icon filter (CT_IconFilter) */\nexport interface IconFilterOptions {\n  /** Column ID */\n  colId: number;\n  /** Icon set index (CT_IconFilter @iconSet) */\n  iconSet: number;\n  /** Icon ID within set (CT_IconFilter @iconId) */\n  iconId?: number;\n}\n\n/** Filter items (CT_Filters) */\nexport interface FilterItemsOptions {\n  /** Column ID */\n  colId: number;\n  /** Blank filter (CT_Filters @blank) */\n  blank?: boolean;\n  /** Calendar type (CT_Filters @calendarType) */\n  calendarType?: string;\n  /** Filter values */\n  values?: string[];\n}\n\n/** Dynamic filter (CT_DynamicFilter) */\nexport interface DynamicFilterOptions {\n  /** Column ID */\n  colId: number;\n  /** Dynamic filter type (CT_DynamicFilter @type) */\n  type:\n    | \"null\"\n    | \"aboveAverage\"\n    | \"belowAverage\"\n    | \"tomorrow\"\n    | \"today\"\n    | \"yesterday\"\n    | \"nextWeek\"\n    | \"thisWeek\"\n    | \"lastWeek\"\n    | \"nextMonth\"\n    | \"thisMonth\"\n    | \"lastMonth\"\n    | \"nextQuarter\"\n    | \"thisQuarter\"\n    | \"lastQuarter\"\n    | \"nextYear\"\n    | \"thisYear\"\n    | \"lastYear\"\n    | \"yearToDate\"\n    | \"Q1\"\n    | \"Q2\"\n    | \"Q3\"\n    | \"Q4\"\n    | \"M1\"\n    | \"M2\"\n    | \"M3\"\n    | \"M4\"\n    | \"M5\"\n    | \"M6\"\n    | \"M7\"\n    | \"M8\"\n    | \"M9\"\n    | \"M10\"\n    | \"M11\"\n    | \"M12\";\n  /** Max value (CT_DynamicFilter @val) */\n  val?: number;\n  /** Max value as date ISO string (CT_DynamicFilter @maxVal) */\n  maxVal?: number;\n  /** Value ISO date string (CT_DynamicFilter @valIso) */\n  valIso?: string;\n  /** Max value ISO date string (CT_DynamicFilter @maxValIso) */\n  maxValIso?: string;\n}\n\n/** Date group filter item (CT_DateGroupItem) */\nexport interface DateGroupFilterOptions {\n  /** Column ID */\n  colId: number;\n  /** Date grouping level (CT_DateGroupItem @dateTimeGrouping) */\n  dateTimeGrouping: \"year\" | \"month\" | \"day\" | \"hour\" | \"minute\" | \"second\";\n  /** Year (CT_DateGroupItem @year) */\n  year?: number;\n  /** Month (1-12, CT_DateGroupItem @month) */\n  month?: number;\n  /** Day (1-31, CT_DateGroupItem @day) */\n  day?: number;\n  /** Hour (0-23, CT_DateGroupItem @hour) */\n  hour?: number;\n  /** Minute (0-59, CT_DateGroupItem @minute) */\n  minute?: number;\n  /** Second (0-59, CT_DateGroupItem @second) */\n  second?: number;\n}\n\n/** Sort state configuration (CT_SortState) */\nexport interface SortStateOptions {\n  /** Column sort mode (CT_SortState @columnSort) */\n  columnSort?: boolean;\n  /** Case sensitive sorting (CT_SortState @caseSensitive) */\n  caseSensitive?: boolean;\n  /** Sort method (CT_SortState @sortMethod) */\n  sortMethod?: \"pinYin\" | \"stroke\";\n}\n\n/** Print options (CT_PrintOptions) */\nexport interface PrintOptions {\n  /** Center horizontally on page */\n  horizontalCentered?: boolean;\n  /** Center vertically on page */\n  verticalCentered?: boolean;\n  /** Print row/column headings */\n  headings?: boolean;\n  /** Print grid lines */\n  gridLines?: boolean;\n  /** Grid lines set flag */\n  gridLinesSet?: boolean;\n}\n\n/** Sheet format properties (CT_SheetFormatPr) */\nexport interface SheetFormatPropertiesOptions {\n  /** Base column width (CT_SheetFormatPr @baseColWidth) */\n  baseColWidth?: number;\n  /** Default column width (CT_SheetFormatPr @defaultColWidth) */\n  defaultColWidth?: number;\n  /** Default row height */\n  defaultRowHeight?: number;\n  /** Zero height rows hidden (CT_SheetFormatPr @zeroHeight) */\n  zeroHeight?: boolean;\n  /** Thick top borders (CT_SheetFormatPr @thickTop) */\n  thickTop?: boolean;\n  /** Thick bottom borders (CT_SheetFormatPr @thickBottom) */\n  thickBottom?: boolean;\n  /** Outline level row (CT_SheetFormatPr @outlineLevelRow) */\n  outlineLevelRow?: number;\n  /** Outline level column (CT_SheetFormatPr @outlineLevelCol) */\n  outlineLevelCol?: number;\n}\n\n/** Sheet properties extended options (CT_SheetPr attributes) */\nexport interface SheetPropertiesOptions {\n  /** Sync horizontal scroll (CT_SheetPr @syncHorizontal) */\n  syncHorizontal?: boolean;\n  /** Sync vertical scroll (CT_SheetPr @syncVertical) */\n  syncVertical?: boolean;\n  /** Sync reference (CT_SheetPr @syncRef) */\n  syncRef?: string;\n  /** Transition evaluation mode (CT_SheetPr @transitionEvaluation) */\n  transitionEvaluation?: boolean;\n  /** Transition entry mode (CT_SheetPr @transitionEntry) */\n  transitionEntry?: boolean;\n  /** Published to server (CT_SheetPr @published) */\n  published?: boolean;\n  /** Filter mode (CT_SheetPr @filterMode) */\n  filterMode?: boolean;\n  /** Enable format conditions calculation (CT_SheetPr @enableFormatConditionsCalculation) */\n  enableFormatConditionsCalculation?: boolean;\n  /** Outline apply styles (CT_OutlinePr @applyStyles) */\n  outlineApplyStyles?: boolean;\n  /** Outline show symbols (CT_OutlinePr @showOutlineSymbols) */\n  outlineShowSymbols?: boolean;\n  /** Outline summary rows below detail (CT_OutlinePr @summaryBelow) */\n  outlineSummaryBelow?: boolean;\n  /** Outline summary columns right of detail (CT_OutlinePr @summaryRight) */\n  outlineSummaryRight?: boolean;\n}\n\n/** An ignored error entry — suppresses specific Excel error checks for a range. */\nexport interface IgnoredErrorOptions {\n  /** Cell range, e.g. \"A1:A10\" (required) */\n  sqref: string;\n  evalError?: boolean;\n  twoDigitTextYear?: boolean;\n  numberStoredAsText?: boolean;\n  formula?: boolean;\n  formulaRange?: boolean;\n  unlockedFormula?: boolean;\n  emptyCellReference?: boolean;\n  listDataValidation?: boolean;\n  calculatedColumn?: boolean;\n}\n\n/** Phonetic properties for CJK text (CT_PhoneticPr) */\nexport interface PhoneticPropertiesOptions {\n  /** Font ID from the styles table (required) */\n  fontId: number;\n  /** Phonetic type (default: \"fullwidthKatakana\") */\n  type?: \"fullwidthKatakana\" | \"halfwidthKatakana\" | \"Hiragana\" | \"noConversion\";\n  /** Alignment (default: \"left\") */\n  alignment?: \"left\" | \"center\" | \"distributed\";\n}\n\n/** Background image for a worksheet */\nexport interface SheetBackgroundImageOptions {\n  data: DataType;\n  type: \"png\" | \"jpg\";\n}\n\n/** Page break entry (CT_Break) */\nexport interface PageBreakOptions {\n  /** Row or column ID (1-based) */\n  id: number;\n  /** Min value (CT_Break @min) */\n  min?: number;\n  /** Max value (CT_Break @max) */\n  max?: number;\n  /** Manual break (CT_Break @man) */\n  manual?: boolean;\n  /** Pivot break (CT_Break @pt) */\n  pivot?: boolean;\n}\n\n/** Selection in sheet view (CT_Selection) */\nexport interface SelectionOptions {\n  /** Pane (CT_Selection @pane) */\n  pane?: \"bottomRight\" | \"topRight\" | \"bottomLeft\" | \"topLeft\";\n  /** Active cell (CT_Selection @activeCell) */\n  activeCell?: string;\n  /** Active cell index (CT_Selection @activeCellId) */\n  activeCellId?: number;\n  /** Selected range (CT_Selection @sqref) */\n  sqref?: string;\n}\n\n/** Custom sheet view (CT_CustomSheetView) */\nexport interface CustomSheetViewOptions {\n  /** GUID identifier (required, CT_CustomSheetView @guid) */\n  guid: string;\n  /** Zoom scale (CT_CustomSheetView @scale) */\n  scale?: number;\n  /** Show page breaks (CT_CustomSheetView @showPageBreaks) */\n  showPageBreaks?: boolean;\n  /** Show formulas (CT_CustomSheetView @showFormulas) */\n  showFormulas?: boolean;\n  /** Show grid lines (CT_CustomSheetView @showGridLines) */\n  showGridLines?: boolean;\n  /** Show row/column headers (CT_CustomSheetView @showRowCol) */\n  showRowColHeaders?: boolean;\n  /** Show outline symbols (CT_CustomSheetView @outlineSymbols) */\n  outlineSymbols?: boolean;\n  /** Show zero values (CT_CustomSheetView @zeroValues) */\n  zeroValues?: boolean;\n  /** Fit to page (CT_CustomSheetView @fitToPage) */\n  fitToPage?: boolean;\n  /** Print area (CT_CustomSheetView @printArea) */\n  printArea?: boolean;\n  /** Filter applied (CT_CustomSheetView @filter) */\n  filter?: boolean;\n  /** Show auto filter (CT_CustomSheetView @showAutoFilter) */\n  showAutoFilter?: boolean;\n  /** Hidden rows (CT_CustomSheetView @hiddenRows) */\n  hiddenRows?: boolean;\n  /** Hidden columns (CT_CustomSheetView @hiddenColumns) */\n  hiddenColumns?: boolean;\n  /** Sheet state (CT_CustomSheetView @state) */\n  state?: \"visible\" | \"hidden\" | \"veryHidden\";\n  /** Filter unique (CT_CustomSheetView @filterUnique) */\n  filterUnique?: boolean;\n  /** View type (CT_CustomSheetView @view) */\n  view?: \"normal\" | \"pageBreakPreview\" | \"pageLayout\";\n}\n\n/** Cell watch entry (CT_CellWatch) */\nexport interface CellWatchOptions {\n  /** Cell reference, e.g. \"A1\" */\n  r: string;\n}\n\n/** Data consolidation (CT_DataConsolidate) */\nexport interface DataConsolidateOptions {\n  /** Consolidation function (CT_DataConsolidate @function) */\n  function?:\n    | \"average\"\n    | \"count\"\n    | \"countNums\"\n    | \"max\"\n    | \"min\"\n    | \"product\"\n    | \"stdDev\"\n    | \"stdDevp\"\n    | \"sum\"\n    | \"var\"\n    | \"varp\";\n  /** Use top row labels (CT_DataConsolidate @startLabels) */\n  topLabels?: boolean;\n  /** Use left column labels (CT_DataConsolidate @leftLabels) */\n  leftLabels?: boolean;\n  /** Use labels in first row (CT_DataConsolidate @startLabels alias) */\n  startLabels?: boolean;\n  /** Link to source data (CT_DataConsolidate @link) */\n  link?: boolean;\n  /** Source data references */\n  refs?: string[];\n}\n\n/** Drawing in header/footer (CT_DrawingHF) */\nexport interface DrawingHfOptions {\n  /** Relationship ID for the drawing (required) */\n  rId: string;\n  lho?: number;\n  lhe?: number;\n  lhf?: number;\n  cho?: number;\n  che?: number;\n  chf?: number;\n  rho?: number;\n  rhe?: number;\n  rhf?: number;\n  lfo?: number;\n  lfe?: number;\n  lff?: number;\n  cfo?: number;\n  cfe?: number;\n  cff?: number;\n  rfo?: number;\n  rfe?: number;\n  rff?: number;\n}\n\nexport interface WorksheetOptions {\n  name?: string;\n  rows?: RowOptions[];\n  columns?: ColumnOptions[];\n  mergeCells?: MergeCellOptions[];\n  freezePanes?: FreezePaneOptions;\n  protection?: SheetProtectionOptions;\n  /** Named protected ranges within this sheet */\n  protectedRanges?: ProtectedRangeOptions[];\n  /** What-if scenarios */\n  scenarios?: ScenarioOptions;\n  /** Auto-filter configuration */\n  autoFilter?: string | AutoFilterOptions;\n  images?: WorksheetImageOptions[];\n  charts?: WorksheetChartOptions[];\n  dataValidations?: DataValidationOptions[];\n  /** Disable data validation prompts (CT_DataValidations @disablePrompts) */\n  dataValidationsDisablePrompts?: boolean;\n  conditionalFormats?: ConditionalFormatOptions[];\n  hyperlinks?: HyperlinkOptions[];\n  comments?: CommentOptions[];\n  headerFooter?: HeaderFooterOptions;\n  pageSetup?: PageSetupOptions;\n  tabColor?: TabColorOptions;\n  sheetView?: SheetViewOptions;\n  pivotTables?: PivotTableOptions[];\n  /** Tables (list objects) for this worksheet */\n  tables?: TableOptions[];\n  /** Ignored errors — suppress specific Excel error checks for cell ranges */\n  ignoredErrors?: IgnoredErrorOptions[];\n  /** Phonetic properties for CJK text */\n  phoneticPr?: PhoneticPropertiesOptions;\n  /** Background image for the worksheet */\n  backgroundImage?: SheetBackgroundImageOptions;\n  /** Print options (CT_PrintOptions) */\n  printOptions?: PrintOptions;\n  /** Sheet format properties (CT_SheetFormatPr) */\n  sheetFormatPr?: SheetFormatPropertiesOptions;\n  /** Sheet extended properties (CT_SheetPr attributes) */\n  sheetPr?: SheetPropertiesOptions;\n  /** Row page breaks (CT_PageBreaks) */\n  rowBreaks?: PageBreakOptions[];\n  /** Column page breaks (CT_PageBreaks) */\n  colBreaks?: PageBreakOptions[];\n  /** Custom sheet views (CT_CustomSheetViews) */\n  customSheetViews?: CustomSheetViewOptions[];\n  /** Cell watches (CT_CellWatches) */\n  cellWatches?: CellWatchOptions[];\n  /** Data consolidation (CT_DataConsolidate) */\n  dataConsolidate?: DataConsolidateOptions;\n  /** OLE embedded range (CT_OleSize) */\n  oleSize?: string;\n  /** Drawing in header/footer (CT_DrawingHF) */\n  drawingHF?: DrawingHfOptions;\n  /** Legacy drawing for header/footer r:id (CT_LegacyDrawingHF) */\n  legacyDrawingHF?: string;\n  /** Selection in sheet view (CT_Selection) */\n  selection?: SelectionOptions;\n  /** Sheet calc properties (CT_SheetCalcPr) */\n  sheetCalcPr?: SheetCalculationPropertiesOptions;\n  /** Extension list (extLst) */\n  ext?: string;\n  /** Control objects (CT_Controls) */\n  controls?: ControlOptions[];\n  /** Custom sheet properties (CT_CustomProperties) */\n  customProperties?: CustomPropertyOptions[];\n  /** OLE objects (CT_OleObjects) */\n  oleObjects?: OleObjectOptions[];\n  /** Web publish items (CT_WebPublishItems) */\n  webPublishItems?: WebPublishItemOptions[];\n}\n\n/** Sheet calc properties (CT_SheetCalcPr) */\nexport interface SheetCalculationPropertiesOptions {\n  /** Full calc on load (CT_SheetCalcPr @fullCalcOnLoad) */\n  fullCalcOnLoad?: boolean;\n}\n\n/** Form control object (CT_Control) */\nexport interface ControlOptions {\n  /** Shape ID (CT_Control @shapeId) */\n  shapeId: number;\n  /** Control r:id (CT_ControlPr @r:id) */\n  rId: string;\n  /** Control name (CT_ControlPr @name) */\n  name?: string;\n  /** Locked (CT_ControlPr @locked) */\n  locked?: boolean;\n  /** UI-locked (CT_ControlPr @uiObject) */\n  uiObject?: boolean;\n  /** Recalc always (CT_ControlPr @recalcAlways) */\n  recalcAlways?: boolean;\n  /** Linked cell (CT_ControlPr @linkedCell) */\n  linkedCell?: string;\n  /** List fill range (CT_ControlPr @listFillRange) */\n  listFillRange?: string;\n  /** Control formula (CT_ControlPr @cf) */\n  cf?: string;\n}\n\n/** Custom property (CT_CustomProperty) */\nexport interface CustomPropertyOptions {\n  /** Property name */\n  name: string;\n  /** Relationship ID to binary data */\n  rId: string;\n}\n\n/** OLE object (CT_OleObject) */\nexport interface OleObjectOptions {\n  /** Program ID (CT_OleObject @progId) */\n  progId?: string;\n  /** Display aspect (CT_OleObject @dvAspect) */\n  dvAspect?: \"DVASPECT_CONTENT\" | \"DVASPECT_ICON\";\n  /** Linked source (CT_OleObject @link) */\n  link?: string;\n  /** OLE update mode (CT_OleObject @oleUpdate) */\n  oleUpdate?: \"OLEUPDATE_ALWAYS\" | \"OLEUPDATE_ONCALL\";\n  /** Auto load (CT_OleObject @autoLoad) */\n  autoLoad?: boolean;\n  /** Shape ID (CT_OleObject @shapeId) */\n  shapeId: number;\n  /** Relationship ID (CT_OleObject @r:id) */\n  rId?: string;\n  /** Object properties (CT_ObjectPr) */\n  objectPr?: OleObjectPropertiesOptions;\n}\n\n/** OLE object properties (CT_ObjectPr) */\nexport interface OleObjectPropertiesOptions {\n  /** Locked */\n  locked?: boolean;\n  /** Default size */\n  defaultSize?: boolean;\n  /** Print */\n  print?: boolean;\n  /** Disabled */\n  disabled?: boolean;\n  /** UI object */\n  uiObject?: boolean;\n  /** Auto fill */\n  autoFill?: boolean;\n  /** Auto line */\n  autoLine?: boolean;\n  /** Auto picture */\n  autoPict?: boolean;\n  /** Macro */\n  macro?: string;\n  /** Alt text */\n  altText?: string;\n  /** DDE */\n  dde?: boolean;\n  /** Relationship ID */\n  rId?: string;\n}\n\n/** Web publish item (CT_WebPublishItem) */\nexport interface WebPublishItemOptions {\n  /** Item ID */\n  id: number;\n  /** HTML div ID */\n  divId: string;\n  /** Source type */\n  sourceType:\n    | \"sheet\"\n    | \"printArea\"\n    | \"autoFilter\"\n    | \"range\"\n    | \"chart\"\n    | \"pivotTable\"\n    | \"query\"\n    | \"label\";\n  /** Source cell reference */\n  sourceRef?: string;\n  /** Source object name */\n  sourceObject?: string;\n  /** Destination file path */\n  destinationFile: string;\n  /** Title */\n  title?: string;\n  /** Auto republish */\n  autoRepublish?: boolean;\n}\n\n// ── Worksheet XML builder context ──\n\n/** Minimal context needed by buildWorksheetXml. */\nexport interface WorksheetContext {\n  sharedStrings?: SharedStrings;\n  styles?: Styles;\n}\n\n// ── Pure functions ──\n\n// Re-exported for use by the compiler (defined below in this file).\nexport { stringifyWorksheet as buildWorksheetXml };\n// ── Descriptor ──\n\nexport const worksheetDesc: CustomDescriptor<WorksheetOptions> = {\n  kind: \"custom\",\n\n  /**\n   * NOT intended for direct use by the compiler.\n   * The compiler calls `stringifyWorksheet(opts, ctx)` instead, which has\n   * access to the SharedStrings and Styles accumulators.\n   * This method exists to satisfy the CustomDescriptor interface for the read path.\n   */\n  stringify(_opts, _ctx) {\n    throw new Error(\n      \"Use stringifyWorksheet(opts, ctx) for the write path. worksheetDesc.stringify() is not supported.\",\n    );\n  },\n\n  parse(el, ctx) {\n    const result: Partial<WorksheetOptions> = {};\n    let pageSetUpPrCache: Partial<PageSetupOptions> | undefined;\n\n    // Resolve shared strings from context (XlsxReadContext)\n    const strings: string[] =\n      ctx && \"sharedStrings\" in ctx ? (ctx as XlsxReadContext).sharedStrings : [];\n\n    // Sheet properties\n    const sheetPrEl = findChild(el, \"sheetPr\");\n    if (sheetPrEl) {\n      const sp: SheetPropertiesOptions = {};\n      if (attr(sheetPrEl, \"syncHorizontal\") === \"1\") sp.syncHorizontal = true;\n      if (attr(sheetPrEl, \"syncVertical\") === \"1\") sp.syncVertical = true;\n      if (attr(sheetPrEl, \"syncRef\")) sp.syncRef = attr(sheetPrEl, \"syncRef\");\n      if (attr(sheetPrEl, \"transitionEvaluation\") === \"1\") sp.transitionEvaluation = true;\n      if (attr(sheetPrEl, \"transitionEntry\") === \"1\") sp.transitionEntry = true;\n      if (attr(sheetPrEl, \"published\") === \"1\") sp.published = true;\n      if (attr(sheetPrEl, \"filterMode\") === \"1\") sp.filterMode = true;\n      if (attr(sheetPrEl, \"enableFormatConditionsCalculation\") === \"1\")\n        sp.enableFormatConditionsCalculation = true;\n\n      const outlinePr = findChild(sheetPrEl, \"outlinePr\");\n      if (outlinePr) {\n        if (attr(outlinePr, \"applyStyles\") === \"1\") sp.outlineApplyStyles = true;\n        if (attr(outlinePr, \"showOutlineSymbols\") === \"0\") sp.outlineShowSymbols = false;\n        if (attr(outlinePr, \"summaryBelow\") === \"0\") sp.outlineSummaryBelow = false;\n        if (attr(outlinePr, \"summaryRight\") === \"0\") sp.outlineSummaryRight = false;\n      }\n\n      // pageSetUpPr (inside sheetPr) — stash on result.pageSetup; merged into\n      // the <pageSetup> parse below, which owns result.pageSetup.\n      const pageSetUpPr = findChild(sheetPrEl, \"pageSetUpPr\");\n      if (pageSetUpPr) {\n        const psup: Partial<PageSetupOptions> = {};\n        if (attr(pageSetUpPr, \"fitToPage\") === \"1\") psup.fitToPage = true;\n        if (attr(pageSetUpPr, \"autoPageBreaks\") === \"1\") psup.autoPageBreaks = true;\n        if (Object.keys(psup).length > 0) pageSetUpPrCache = psup;\n      }\n      if (Object.keys(sp).length > 0) result.sheetPr = sp;\n\n      // Tab color\n      const tabColorEl = findChild(sheetPrEl, \"tabColor\");\n      if (tabColorEl) {\n        const tc: TabColorOptions = {};\n        if (attr(tabColorEl, \"rgb\")) tc.rgb = attr(tabColorEl, \"rgb\");\n        if (attrNum(tabColorEl, \"theme\") !== undefined) tc.theme = attrNum(tabColorEl, \"theme\");\n        if (attrNum(tabColorEl, \"tint\") !== undefined) tc.tint = attrNum(tabColorEl, \"tint\");\n        if (attrNum(tabColorEl, \"indexed\") !== undefined)\n          tc.indexed = attrNum(tabColorEl, \"indexed\");\n        result.tabColor = tc;\n      }\n    }\n\n    // Sheet views\n    const sheetViewsEl = findChild(el, \"sheetViews\");\n    if (sheetViewsEl) {\n      const svEl = findChild(sheetViewsEl, \"sheetView\");\n      if (svEl) {\n        const sv: SheetViewOptions = {};\n        if (attr(svEl, \"showGridLines\") === \"0\") sv.showGridLines = false;\n        if (attr(svEl, \"showRowColHeaders\") === \"0\") sv.showRowColHeaders = false;\n        if (attr(svEl, \"showZeros\") === \"0\") sv.showZeros = false;\n        const zs = attrNum(svEl, \"zoomScale\");\n        if (zs !== undefined) sv.zoomScale = zs;\n        if (attr(svEl, \"tabSelected\") !== undefined)\n          sv.tabSelected = attr(svEl, \"tabSelected\") !== \"0\";\n        if (attr(svEl, \"rightToLeft\") === \"1\") sv.rightToLeft = true;\n        if (attr(svEl, \"windowProtection\") === \"1\") sv.windowProtection = true;\n        if (attr(svEl, \"showFormulas\") === \"1\") sv.showFormulas = true;\n        if (attr(svEl, \"showRuler\") === \"0\") sv.showRuler = false;\n        if (attr(svEl, \"showOutlineSymbols\") === \"0\") sv.showOutlineSymbols = false;\n        if (attr(svEl, \"defaultGridColor\") === \"0\") sv.defaultGridColor = false;\n        if (attr(svEl, \"showWhiteSpace\") === \"0\") sv.showWhiteSpace = false;\n        const viewVal = attr(svEl, \"view\");\n        if (viewVal) sv.view = viewVal as SheetViewOptions[\"view\"];\n        const colorId = attrNum(svEl, \"colorId\");\n        if (colorId !== undefined) sv.colorId = colorId;\n        const zsn = attrNum(svEl, \"zoomScaleNormal\");\n        if (zsn !== undefined) sv.zoomScaleNormal = zsn;\n        const zssl = attrNum(svEl, \"zoomScaleSheetLayoutView\");\n        if (zssl !== undefined) sv.zoomScaleSheetLayoutView = zssl;\n        const zspl = attrNum(svEl, \"zoomScalePageLayoutView\");\n        if (zspl !== undefined) sv.zoomScalePageLayoutView = zspl;\n        result.sheetView = sv;\n\n        // Freeze pane\n        const paneEl = findChild(svEl, \"pane\");\n        if (paneEl && attr(paneEl, \"state\") === \"frozen\") {\n          const fp: FreezePaneOptions = {};\n          const ys = attrNum(paneEl, \"ySplit\");\n          if (ys && ys > 0) fp.row = ys;\n          const xs = attrNum(paneEl, \"xSplit\");\n          if (xs && xs > 0) fp.col = xs;\n          if (Object.keys(fp).length > 0) result.freezePanes = fp;\n        }\n      }\n    }\n\n    // Sheet format properties\n    const sfpEl = findChild(el, \"sheetFormatPr\");\n    if (sfpEl) {\n      const sfp: SheetFormatPropertiesOptions = {};\n      const bcw = attrNum(sfpEl, \"baseColWidth\");\n      if (bcw !== undefined) sfp.baseColWidth = bcw;\n      const dcw = attrNum(sfpEl, \"defaultColWidth\");\n      if (dcw !== undefined) sfp.defaultColWidth = dcw;\n      const drh = attrNum(sfpEl, \"defaultRowHeight\");\n      if (drh !== undefined) sfp.defaultRowHeight = drh;\n      if (attr(sfpEl, \"zeroHeight\") === \"1\") sfp.zeroHeight = true;\n      if (attr(sfpEl, \"thickTop\") === \"1\") sfp.thickTop = true;\n      if (attr(sfpEl, \"thickBottom\") === \"1\") sfp.thickBottom = true;\n      const olr = attrNum(sfpEl, \"outlineLevelRow\");\n      if (olr !== undefined) sfp.outlineLevelRow = olr;\n      const olc = attrNum(sfpEl, \"outlineLevelCol\");\n      if (olc !== undefined) sfp.outlineLevelCol = olc;\n      result.sheetFormatPr = sfp;\n    }\n\n    // Columns\n    const colsEl = findChild(el, \"cols\");\n    if (colsEl) {\n      const columns: ColumnOptions[] = [];\n      for (const colEl of colsEl.elements ?? []) {\n        if (colEl.name !== \"col\") continue;\n        const col: ColumnOptions = {\n          min: attrNum(colEl, \"min\") ?? 0,\n          max: attrNum(colEl, \"max\") ?? 0,\n        };\n        const w = attrNum(colEl, \"width\");\n        if (w !== undefined) col.width = w;\n        if (attr(colEl, \"hidden\") === \"1\") col.hidden = true;\n        if (attr(colEl, \"customWidth\") === \"1\") col.customWidth = true;\n        const ol = attrNum(colEl, \"outlineLevel\");\n        if (ol !== undefined) col.outlineLevel = ol;\n        if (attr(colEl, \"collapsed\") === \"1\") col.collapsed = true;\n        if (attr(colEl, \"bestFit\") === \"1\") col.bestFit = true;\n        if (attr(colEl, \"phonetic\") === \"1\") col.phonetic = true;\n        columns.push(col);\n      }\n      if (columns.length > 0) result.columns = columns;\n    }\n\n    // Sheet protection\n    const protEl = findChild(el, \"sheetProtection\");\n    if (protEl?.attributes) {\n      const prot: SheetProtectionOptions = {};\n      if (attr(protEl, \"password\")) prot.password = attr(protEl, \"password\");\n      if (attr(protEl, \"algorithmName\")) prot.algorithmName = attr(protEl, \"algorithmName\");\n      if (attr(protEl, \"hashValue\")) prot.hashValue = attr(protEl, \"hashValue\");\n      if (attr(protEl, \"saltValue\")) prot.saltValue = attr(protEl, \"saltValue\");\n      if (attrNum(protEl, \"spinCount\") !== undefined) prot.spinCount = attrNum(protEl, \"spinCount\");\n      if (attr(protEl, \"sheet\") === \"1\") prot.sheet = true;\n      if (attr(protEl, \"objects\") === \"1\") prot.objects = true;\n      if (attr(protEl, \"scenarios\") === \"1\") prot.scenarios = true;\n      if (attr(protEl, \"formatCells\") === \"0\") prot.formatCells = false;\n      if (attr(protEl, \"formatColumns\") === \"0\") prot.formatColumns = false;\n      if (attr(protEl, \"formatRows\") === \"0\") prot.formatRows = false;\n      if (attr(protEl, \"insertColumns\") === \"0\") prot.insertColumns = false;\n      if (attr(protEl, \"insertRows\") === \"0\") prot.insertRows = false;\n      if (attr(protEl, \"insertHyperlinks\") === \"0\") prot.insertHyperlinks = false;\n      if (attr(protEl, \"deleteColumns\") === \"0\") prot.deleteColumns = false;\n      if (attr(protEl, \"deleteRows\") === \"0\") prot.deleteRows = false;\n      if (attr(protEl, \"selectLockedCells\") === \"1\") prot.selectLockedCells = true;\n      if (attr(protEl, \"sort\") === \"0\") prot.sort = false;\n      if (attr(protEl, \"autoFilter\") === \"0\") prot.autoFilter = false;\n      if (attr(protEl, \"pivotTables\") === \"0\") prot.pivotTables = false;\n      if (attr(protEl, \"selectUnlockedCells\") === \"1\") prot.selectUnlockedCells = true;\n      result.protection = prot;\n    }\n\n    // Protected ranges\n    const prEl = findChild(el, \"protectedRanges\");\n    if (prEl) {\n      const ranges: ProtectedRangeOptions[] = [];\n      for (const rEl of prEl.elements ?? []) {\n        if (rEl.name !== \"protectedRange\") continue;\n        const r: ProtectedRangeOptions = {\n          sqref: attr(rEl, \"sqref\") ?? \"\",\n          name: attr(rEl, \"name\") ?? \"\",\n        };\n        if (attr(rEl, \"password\")) r.password = attr(rEl, \"password\");\n        if (attr(rEl, \"algorithmName\")) r.algorithmName = attr(rEl, \"algorithmName\");\n        if (attr(rEl, \"hashValue\")) r.hashValue = attr(rEl, \"hashValue\");\n        if (attr(rEl, \"saltValue\")) r.saltValue = attr(rEl, \"saltValue\");\n        const spinCount = attrNum(rEl, \"spinCount\");\n        if (spinCount !== undefined) r.spinCount = spinCount;\n        const sdEl = findChild(rEl, \"securityDescriptor\");\n        if (sdEl) r.securityDescriptor = textOf(sdEl) ?? undefined;\n        ranges.push(r);\n      }\n      if (ranges.length > 0) result.protectedRanges = ranges;\n    }\n\n    // Auto filter\n    const afEl = findChild(el, \"autoFilter\");\n    if (afEl) {\n      result.autoFilter = attr(afEl, \"ref\") ?? \"\";\n    }\n\n    // Merge cells\n    const mcEl = findChild(el, \"mergeCells\");\n    if (mcEl) {\n      const merges: MergeCellOptions[] = [];\n      for (const mEl of mcEl.elements ?? []) {\n        if (mEl.name !== \"mergeCell\") continue;\n        const ref = attr(mEl, \"ref\") ?? \"\";\n        const parts = ref.split(\":\");\n        if (parts.length === 2) {\n          const from = parseCellRef(parts[0] ?? \"\");\n          const to = parseCellRef(parts[1] ?? \"\");\n          if (from && to) merges.push({ from, to });\n        }\n      }\n      if (merges.length > 0) result.mergeCells = merges;\n    }\n\n    // Conditional formatting\n    const cfEls = el.elements?.filter((e) => e.name === \"conditionalFormatting\") ?? [];\n    if (cfEls.length > 0) {\n      const cfs: ConditionalFormatOptions[] = [];\n      for (const cfEl of cfEls) {\n        const sqref = attr(cfEl, \"sqref\") ?? \"\";\n        const rules: ConditionalFormatRule[] = [];\n        for (const ruleEl of cfEl.elements ?? []) {\n          if (ruleEl.name !== \"cfRule\") continue;\n          const rule: ConditionalFormatRule = {\n            type: attr(ruleEl, \"type\") as ConditionalFormatType,\n            priority: attrNum(ruleEl, \"priority\") ?? 1,\n          };\n          const opVal = attr(ruleEl, \"operator\");\n          if (opVal) rule.operator = opVal as ConditionalFormatOperator;\n          const dxfId = attrNum(ruleEl, \"dxfId\");\n          if (dxfId !== undefined) rule.dxfId = dxfId;\n          if (attr(ruleEl, \"stopIfTrue\") === \"1\") rule.stopIfTrue = true;\n          const tpVal = attr(ruleEl, \"timePeriod\");\n          if (tpVal) rule.timePeriod = tpVal as ConditionalFormatRule[\"timePeriod\"];\n          const rank = attrNum(ruleEl, \"rank\");\n          if (rank !== undefined) rule.rank = rank;\n          if (attr(ruleEl, \"equalAverage\") === \"1\") rule.equalAverage = true;\n\n          // Color scale\n          const csEl = findChild(ruleEl, \"colorScale\");\n          if (csEl) {\n            const cfvo: CfvoOptions[] = [];\n            const colors: string[] = [];\n            for (const child of csEl.elements ?? []) {\n              if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n              if (child.name === \"color\") {\n                const rgb = attr(child, \"rgb\");\n                if (rgb) colors.push(rgb.length === 8 ? rgb.slice(2) : rgb);\n              }\n            }\n            rule.colorScale = { cfvo, colors };\n          }\n\n          // Data bar\n          const dbEl = findChild(ruleEl, \"dataBar\");\n          if (dbEl) {\n            const cfvo: CfvoOptions[] = [];\n            let color = \"\";\n            for (const child of dbEl.elements ?? []) {\n              if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n              if (child.name === \"color\") {\n                const rgb = attr(child, \"rgb\");\n                if (rgb) color = rgb.length === 8 ? rgb.slice(2) : rgb;\n              }\n            }\n            rule.dataBar = { cfvo: cfvo as [CfvoOptions, CfvoOptions], color };\n          }\n\n          // Icon set\n          const isEl = findChild(ruleEl, \"iconSet\");\n          if (isEl) {\n            const cfvo: CfvoOptions[] = [];\n            for (const child of isEl.elements ?? []) {\n              if (child.name === \"cfvo\") cfvo.push(parseCfvo(child));\n            }\n            const iconSet: IconSetOptions = { cfvo };\n            const isVal = attr(isEl, \"iconSet\");\n            if (isVal) iconSet.iconSet = isVal as IconSetType;\n            if (attr(isEl, \"showValue\") === \"0\") iconSet.showValue = false;\n            if (attr(isEl, \"percent\") === \"0\") iconSet.percent = false;\n            if (attr(isEl, \"reverse\") === \"1\") iconSet.reverse = true;\n            rule.iconSet = iconSet;\n          }\n\n          // Formulas\n          const formulas: string[] = [];\n          for (const child of ruleEl.elements ?? []) {\n            if (child.name === \"formula\") formulas.push(textOf(child) ?? \"\");\n          }\n          if (formulas.length > 0) rule.formulas = formulas;\n\n          rules.push(rule);\n        }\n        cfs.push({ sqref, rules });\n      }\n      result.conditionalFormats = cfs;\n    }\n\n    // Data validations\n    const dvEl = findChild(el, \"dataValidations\");\n    if (dvEl) {\n      const dvs: DataValidationOptions[] = [];\n      for (const dEl of dvEl.elements ?? []) {\n        if (dEl.name !== \"dataValidation\") continue;\n        const dv: DataValidationOptions = { sqref: attr(dEl, \"sqref\") ?? \"\" };\n        const typeVal = attr(dEl, \"type\");\n        if (typeVal) dv.type = typeVal as DataValidationType;\n        const opVal = attr(dEl, \"operator\");\n        if (opVal) dv.operator = opVal as DataValidationOperator;\n        if (attr(dEl, \"allowBlank\") === \"1\") dv.allowBlank = true;\n        if (attr(dEl, \"showErrorMessage\") === \"1\") dv.showErrorMessage = true;\n        if (attr(dEl, \"showInputMessage\") === \"1\") dv.showInputMessage = true;\n        if (attr(dEl, \"errorTitle\")) dv.errorTitle = attr(dEl, \"errorTitle\");\n        if (attr(dEl, \"error\")) dv.error = attr(dEl, \"error\");\n        if (attr(dEl, \"promptTitle\")) dv.promptTitle = attr(dEl, \"promptTitle\");\n        if (attr(dEl, \"prompt\")) dv.prompt = attr(dEl, \"prompt\");\n        const esVal = attr(dEl, \"errorStyle\");\n        if (esVal) dv.errorStyle = esVal as DataValidationOptions[\"errorStyle\"];\n        const imVal = attr(dEl, \"imeMode\");\n        if (imVal) dv.imeMode = imVal as DataValidationOptions[\"imeMode\"];\n        if (attr(dEl, \"showDropDown\") === \"1\") dv.showDropDown = true;\n\n        const f1El = findChild(dEl, \"formula1\");\n        if (f1El) dv.formula1 = textOf(f1El);\n        const f2El = findChild(dEl, \"formula2\");\n        if (f2El) dv.formula2 = textOf(f2El);\n\n        dvs.push(dv);\n      }\n      result.dataValidations = dvs;\n    }\n\n    // Hyperlinks\n    const hlEl = findChild(el, \"hyperlinks\");\n    if (hlEl) {\n      const hyperlinks: HyperlinkOptions[] = [];\n      for (const hEl of hlEl.elements ?? []) {\n        if (hEl.name !== \"hyperlink\") continue;\n        const rId = hEl.attributes?.[\"r:id\"] as string | undefined;\n        const location = attr(hEl, \"location\");\n        const target: HyperlinkTarget = rId\n          ? { type: \"external\", url: rId }\n          : { type: \"internal\", location: location ?? \"\" };\n        const hl: HyperlinkOptions = { cell: attr(hEl, \"ref\") ?? \"\", target };\n        if (attr(hEl, \"tooltip\")) hl.tooltip = attr(hEl, \"tooltip\");\n        if (attr(hEl, \"display\")) hl.display = attr(hEl, \"display\");\n        hyperlinks.push(hl);\n      }\n      result.hyperlinks = hyperlinks;\n    }\n\n    // Print options\n    const poEl = findChild(el, \"printOptions\");\n    if (poEl) {\n      const po: PrintOptions = {};\n      if (attr(poEl, \"horizontalCentered\") === \"1\") po.horizontalCentered = true;\n      if (attr(poEl, \"verticalCentered\") === \"1\") po.verticalCentered = true;\n      if (attr(poEl, \"headings\") === \"1\") po.headings = true;\n      if (attr(poEl, \"gridLines\") === \"1\") po.gridLines = true;\n      if (attr(poEl, \"gridLinesSet\") === \"0\") po.gridLinesSet = false;\n      result.printOptions = po;\n    }\n\n    // Page setup\n    const psEl = findChild(el, \"pageSetup\");\n    if (psEl) {\n      const ps: PageSetupOptions = {};\n      const pz = attrNum(psEl, \"paperSize\");\n      if (pz !== undefined) ps.paperSize = pz;\n      const ph = attrMeasure(psEl, \"paperHeight\");\n      if (ph !== undefined) ps.paperHeight = ph as number | PositiveUniversalMeasure;\n      const pw = attrMeasure(psEl, \"paperWidth\");\n      if (pw !== undefined) ps.paperWidth = pw as number | PositiveUniversalMeasure;\n      const orientVal = attr(psEl, \"orientation\");\n      if (orientVal) ps.orientation = orientVal as PageOrientation;\n      const sc = attrNum(psEl, \"scale\");\n      if (sc !== undefined) ps.scale = sc;\n      const ftw = attrNum(psEl, \"fitToWidth\");\n      if (ftw !== undefined) ps.fitToWidth = ftw;\n      const fth = attrNum(psEl, \"fitToHeight\");\n      if (fth !== undefined) ps.fitToHeight = fth;\n      const pageOrderVal = attr(psEl, \"pageOrder\");\n      if (pageOrderVal) ps.pageOrder = pageOrderVal as PageSetupOptions[\"pageOrder\"];\n      if (attr(psEl, \"useFirstPageNumber\") === \"1\") ps.useFirstPageNumber = true;\n      const fpn = attrNum(psEl, \"firstPageNumber\");\n      if (fpn !== undefined) ps.firstPageNumber = fpn;\n      if (pageSetUpPrCache) Object.assign(ps, pageSetUpPrCache);\n      result.pageSetup = ps;\n    } else if (pageSetUpPrCache) {\n      result.pageSetup = pageSetUpPrCache;\n    }\n\n    // Header/footer\n    const hfEl = findChild(el, \"headerFooter\");\n    if (hfEl) {\n      const hf: HeaderFooterOptions = {};\n      if (attr(hfEl, \"differentOddEven\") === \"1\") hf.differentOddEven = true;\n      if (attr(hfEl, \"differentFirst\") === \"1\") hf.differentFirst = true;\n      if (attr(hfEl, \"scaleWithDoc\") === \"0\") hf.scaleWithDoc = false;\n      if (attr(hfEl, \"alignWithMargins\") === \"0\") hf.alignWithMargins = false;\n      const oh = findChild(hfEl, \"oddHeader\");\n      if (oh) hf.oddHeader = textOf(oh);\n      const of2 = findChild(hfEl, \"oddFooter\");\n      if (of2) hf.oddFooter = textOf(of2);\n      const eh = findChild(hfEl, \"evenHeader\");\n      if (eh) hf.evenHeader = textOf(eh);\n      const ef = findChild(hfEl, \"evenFooter\");\n      if (ef) hf.evenFooter = textOf(ef);\n      const fh = findChild(hfEl, \"firstHeader\");\n      if (fh) hf.firstHeader = textOf(fh);\n      const ff = findChild(hfEl, \"firstFooter\");\n      if (ff) hf.firstFooter = textOf(ff);\n      result.headerFooter = hf;\n    }\n\n    // Ignored errors\n    const ieEl = findChild(el, \"ignoredErrors\");\n    if (ieEl) {\n      const errors: IgnoredErrorOptions[] = [];\n      for (const eEl of ieEl.elements ?? []) {\n        if (eEl.name !== \"ignoredError\") continue;\n        const ie: IgnoredErrorOptions = { sqref: attr(eEl, \"sqref\") ?? \"\" };\n        if (attr(eEl, \"evalError\") === \"1\") ie.evalError = true;\n        if (attr(eEl, \"twoDigitTextYear\") === \"1\") ie.twoDigitTextYear = true;\n        if (attr(eEl, \"numberStoredAsText\") === \"1\") ie.numberStoredAsText = true;\n        if (attr(eEl, \"formula\") === \"1\") ie.formula = true;\n        if (attr(eEl, \"formulaRange\") === \"1\") ie.formulaRange = true;\n        if (attr(eEl, \"unlockedFormula\") === \"1\") ie.unlockedFormula = true;\n        if (attr(eEl, \"emptyCellReference\") === \"1\") ie.emptyCellReference = true;\n        if (attr(eEl, \"listDataValidation\") === \"1\") ie.listDataValidation = true;\n        if (attr(eEl, \"calculatedColumn\") === \"1\") ie.calculatedColumn = true;\n        errors.push(ie);\n      }\n      result.ignoredErrors = errors;\n    }\n\n    // Phonetic properties\n    const ppEl = findChild(el, \"phoneticPr\");\n    if (ppEl) {\n      const pp: PhoneticPropertiesOptions = { fontId: attrNum(ppEl, \"fontId\") ?? 0 };\n      const ppType = attr(ppEl, \"type\");\n      if (ppType) pp.type = ppType as PhoneticPropertiesOptions[\"type\"];\n      const ppAlign = attr(ppEl, \"alignment\");\n      if (ppAlign) pp.alignment = ppAlign as PhoneticPropertiesOptions[\"alignment\"];\n      result.phoneticPr = pp;\n    }\n\n    // Sheet calc properties\n    const scEl = findChild(el, \"sheetCalcPr\");\n    if (scEl) {\n      const sc: SheetCalculationPropertiesOptions = {};\n      if (attr(scEl, \"fullCalcOnLoad\") === \"1\") sc.fullCalcOnLoad = true;\n      result.sheetCalcPr = sc;\n    }\n\n    // Sheet data (rows and cells)\n    const sheetDataEl = findChild(el, \"sheetData\");\n    if (sheetDataEl) {\n      const rows: RowOptions[] = [];\n      for (const rowEl of sheetDataEl.elements ?? []) {\n        if (rowEl.name !== \"row\") continue;\n        const row: RowOptions = {};\n        const rowNumber = attrNum(rowEl, \"r\");\n        if (rowNumber !== undefined) row.rowNumber = rowNumber;\n        const ht = attrNum(rowEl, \"ht\");\n        if (ht !== undefined) row.height = ht;\n        if (attr(rowEl, \"hidden\") === \"1\") row.hidden = true;\n        if (attr(rowEl, \"spans\")) row.spans = attr(rowEl, \"spans\");\n        if (attr(rowEl, \"customFormat\") === \"1\") row.customFormat = true;\n        if (attr(rowEl, \"thickTop\") === \"1\") row.thickTop = true;\n        if (attr(rowEl, \"thickBot\") === \"1\") row.thickBot = true;\n        if (attr(rowEl, \"ph\") === \"1\") row.ph = true;\n\n        const cells: CellOptions[] = [];\n        for (const cellEl of rowEl.elements ?? []) {\n          if (cellEl.name !== \"c\") continue;\n          const cell: CellOptions = {};\n          const ref = attr(cellEl, \"r\");\n          if (ref) cell.reference = ref;\n          const type = attr(cellEl, \"t\");\n          const styleIdx = attrNum(cellEl, \"s\");\n          if (styleIdx !== undefined) {\n            // Resolve to a concrete StyleOptions so re-stringify registers it in\n            // the fresh Styles table (whose indices may differ). Keep styleIndex\n            // as a fallback when the styles table cannot be resolved.\n            const resolved =\n              ctx && \"resolveStyle\" in ctx\n                ? (ctx as XlsxReadContext).resolveStyle(styleIdx)\n                : undefined;\n            if (resolved) {\n              cell.style = resolved;\n            } else {\n              cell.styleIndex = styleIdx;\n            }\n          }\n\n          // Cell value\n          const vEl = findChild(cellEl, \"v\");\n          const isEl = findChild(cellEl, \"is\");\n\n          if (type === \"s\" && vEl) {\n            // Shared string\n            const idx = parseInt(textOf(vEl) ?? \"\", 10);\n            cell.value = strings[idx] ?? \"\";\n          } else if (type === \"b\" && vEl) {\n            cell.value = textOf(vEl) === \"1\";\n          } else if (type === \"inlineStr\" && isEl) {\n            const t = findChild(isEl, \"t\");\n            cell.value = textOf(t) ?? \"\";\n          } else if (vEl) {\n            const raw = textOf(vEl) ?? \"\";\n            const num = Number(raw);\n            cell.value = isNaN(num) ? raw : num;\n          }\n\n          // Formula\n          const fEl = findChild(cellEl, \"f\");\n          if (fEl) {\n            const formula: FormulaOptions = { formula: textOf(fEl) ?? \"\" };\n            const ft = attr(fEl, \"t\");\n            if (ft && ft !== \"normal\") formula.type = ft as FormulaType;\n            const fRef = attr(fEl, \"ref\");\n            if (fRef) formula.reference = fRef;\n            const fSi = attrNum(fEl, \"si\");\n            if (fSi !== undefined) formula.sharedIndex = fSi;\n            if (attr(fEl, \"aca\") === \"1\") formula.aca = true;\n            if (attr(fEl, \"ca\") === \"1\") formula.ca = true;\n            if (attr(fEl, \"bx\") === \"1\") formula.bx = true;\n            cell.formula = formula;\n          }\n\n          cells.push(cell);\n        }\n\n        row.cells = cells;\n        rows.push(row);\n      }\n      if (rows.length > 0) result.rows = rows;\n    }\n\n    return result as WorksheetOptions;\n  },\n};\n\n// ── Stringify implementation ──\n\n/**\n * Build the complete worksheet XML string.\n *\n * Zero-allocation fast path: directly concatenates XML string,\n * bypassing the intermediate object tree entirely.\n */\nexport function stringifyWorksheet(opts: WorksheetOptions, ctx: WorksheetContext): string {\n  const sharedStrings = ctx.sharedStrings;\n  const styles = ctx.styles;\n\n  const rows = opts.rows ?? [];\n  const columns = opts.columns ?? [];\n  const mergeCells = opts.mergeCells ?? [];\n  const protectedRanges = opts.protectedRanges ?? [];\n  const ignoredErrors = opts.ignoredErrors ?? [];\n  const rowBreaks = opts.rowBreaks ?? [];\n  const colBreaks = opts.colBreaks ?? [];\n  const customSheetViews = opts.customSheetViews ?? [];\n  const cellWatches = opts.cellWatches ?? [];\n  const controls = opts.controls ?? [];\n  const customProperties = opts.customProperties ?? [];\n  const oleObjects = opts.oleObjects ?? [];\n  const webPublishItems = opts.webPublishItems ?? [];\n\n  const p: string[] = [\n    '<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\"' +\n      ' xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"' +\n      ' xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"' +\n      ' mc:Ignorable=\"x14ac xr xr2 xr3\"' +\n      ' xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\"' +\n      ' xmlns:xr=\"http://schemas.microsoft.com/office/spreadsheetml/2014/revision\"' +\n      ' xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\"' +\n      ' xmlns:xr3=\"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3\">',\n  ];\n\n  // Sheet properties (tabColor, outlinePr go here)\n  const hasTabColor = !!opts.tabColor;\n  const hasOutline = columns.some((c) => c.outlineLevel !== undefined);\n  const sp = opts.sheetPr;\n  const hasSheetPrAttrs =\n    sp &&\n    (sp.syncHorizontal ||\n      sp.syncVertical ||\n      sp.syncRef ||\n      sp.transitionEvaluation ||\n      sp.transitionEntry ||\n      sp.published ||\n      sp.filterMode ||\n      sp.enableFormatConditionsCalculation);\n  const hasPageSetUpPr =\n    !!opts.pageSetup?.fitToWidth ||\n    !!opts.pageSetup?.fitToHeight ||\n    !!opts.pageSetup?.autoPageBreaks;\n  if (hasTabColor || hasOutline || hasSheetPrAttrs || hasPageSetUpPr) {\n    const prParts: string[] = [];\n    const prAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (sp?.syncHorizontal) prAttrs.syncHorizontal = 1;\n    if (sp?.syncVertical) prAttrs.syncVertical = 1;\n    if (sp?.syncRef) prAttrs.syncRef = sp.syncRef;\n    if (sp?.transitionEvaluation) prAttrs.transitionEvaluation = 1;\n    if (sp?.transitionEntry) prAttrs.transitionEntry = 1;\n    if (sp?.published) prAttrs.published = 1;\n    if (sp?.filterMode) prAttrs.filterMode = 1;\n    if (sp?.enableFormatConditionsCalculation) prAttrs.enableFormatConditionsCalculation = 1;\n    if (opts.tabColor) {\n      const tc = opts.tabColor;\n      const tcAttrs: Record<string, string | number | boolean | undefined> = {};\n      if (tc.rgb) tcAttrs.rgb = tc.rgb;\n      if (tc.theme !== undefined) tcAttrs.theme = tc.theme;\n      if (tc.tint !== undefined) tcAttrs.tint = tc.tint;\n      if (tc.indexed !== undefined) tcAttrs.indexed = tc.indexed;\n      prParts.push(`<tabColor${attrs(tcAttrs)}/>`);\n    }\n    if (hasOutline) {\n      const outAttrs: Record<string, string | number | boolean | undefined> = {\n        summaryBelow: 1,\n        summaryRight: 1,\n      };\n      if (sp?.outlineSummaryBelow === false) outAttrs.summaryBelow = 0;\n      if (sp?.outlineSummaryRight === false) outAttrs.summaryRight = 0;\n      if (sp?.outlineApplyStyles) outAttrs.applyStyles = 1;\n      if (sp?.outlineShowSymbols === false) outAttrs.showOutlineSymbols = 0;\n      prParts.push(`<outlinePr${attrs(outAttrs)}/>`);\n    }\n    // pageSetUpPr (inside sheetPr when fitToPage or autoPageBreaks needed)\n    if (\n      opts.pageSetup?.fitToWidth ||\n      opts.pageSetup?.fitToHeight ||\n      opts.pageSetup?.autoPageBreaks\n    ) {\n      const psupAttrs: Record<string, string | number | boolean | undefined> = {};\n      if (opts.pageSetup?.fitToWidth || opts.pageSetup?.fitToHeight) psupAttrs.fitToPage = 1;\n      if (opts.pageSetup?.autoPageBreaks) psupAttrs.autoPageBreaks = 1;\n      prParts.push(`<pageSetUpPr${attrs(psupAttrs)}/>`);\n    }\n    const prAttrStr = Object.keys(prAttrs).length > 0 ? attrs(prAttrs) : \"\";\n    p.push(`<sheetPr${prAttrStr}>${prParts.join(\"\")}</sheetPr>`);\n  }\n\n  // Dimension — defines the used range of the sheet\n  const maxRow = rows.length;\n  let maxCol = 0;\n  for (const row of rows) {\n    if (row.cells && row.cells.length > maxCol) maxCol = row.cells.length;\n  }\n  if (maxRow > 0 && maxCol > 0) {\n    const dimRef = `A1:${defaultCellRef(maxRow, maxCol)}`;\n    p.push(`<dimension ref=\"${dimRef}\"/>`);\n  }\n\n  // Sheet views\n  const pivotSelXml = opts.sheetView?.pivotSelections\n    ? opts.sheetView.pivotSelections.map((ps) => buildPivotSelectionXml(ps)).join(\"\")\n    : \"\";\n  if (opts.freezePanes) {\n    const fp = opts.freezePanes;\n    const ySplit = fp.row ? fp.row : 0;\n    const xSplit = fp.col ? fp.col : 0;\n    const topRow = fp.row ? fp.row + 1 : 1;\n    const leftCol = fp.col ? fp.col + 1 : 1;\n    const topLeftCell = defaultCellRef(topRow, leftCol);\n    const activePane =\n      ySplit > 0 && xSplit > 0 ? \"bottomRight\" : ySplit > 0 ? \"bottomLeft\" : \"topRight\";\n    const svAttrs = buildSheetViewAttrs(opts.sheetView);\n    p.push(\n      `<sheetViews><sheetView${svAttrs}>`,\n      `<pane ySplit=\"${ySplit}\" xSplit=\"${xSplit}\" topLeftCell=\"${topLeftCell}\" activePane=\"${activePane}\" state=\"frozen\"/>`,\n      opts.selection ? buildSelectionXml(opts.selection) : \"\",\n      pivotSelXml,\n      \"</sheetView></sheetViews>\",\n    );\n  } else {\n    const svAttrs = buildSheetViewAttrs(opts.sheetView);\n    const innerXml = (opts.selection ? buildSelectionXml(opts.selection) : \"\") + pivotSelXml;\n    if (innerXml) {\n      p.push(`<sheetViews><sheetView${svAttrs}>${innerXml}</sheetView></sheetViews>`);\n    } else {\n      p.push(`<sheetViews><sheetView${svAttrs}/></sheetViews>`);\n    }\n  }\n\n  // Sheet format — default row height\n  if (opts.sheetFormatPr) {\n    const sfp = opts.sheetFormatPr;\n    const sfpAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (sfp.baseColWidth !== undefined) sfpAttrs.baseColWidth = sfp.baseColWidth;\n    if (sfp.defaultColWidth !== undefined) sfpAttrs.defaultColWidth = sfp.defaultColWidth;\n    sfpAttrs.defaultRowHeight = sfp.defaultRowHeight ?? 15;\n    if (sfp.zeroHeight) sfpAttrs.zeroHeight = 1;\n    if (sfp.thickTop) sfpAttrs.thickTop = 1;\n    if (sfp.thickBottom) sfpAttrs.thickBottom = 1;\n    if (sfp.outlineLevelRow !== undefined) sfpAttrs.outlineLevelRow = sfp.outlineLevelRow;\n    if (sfp.outlineLevelCol !== undefined) sfpAttrs.outlineLevelCol = sfp.outlineLevelCol;\n    p.push(`<sheetFormatPr${attrs(sfpAttrs)}/>`);\n  } else {\n    p.push('<sheetFormatPr defaultRowHeight=\"15\"/>');\n  }\n\n  // Column definitions\n  if (columns.length > 0) {\n    p.push(\"<cols>\");\n    for (const col of columns) {\n      const colAttrs: Record<string, string | number | boolean | undefined> = {\n        min: col.min,\n        max: col.max,\n      };\n      if (col.width !== undefined) {\n        colAttrs.width = col.width;\n        colAttrs.customWidth = 1;\n      }\n      if (col.hidden) {\n        colAttrs.hidden = 1;\n      }\n      if (col.outlineLevel !== undefined) {\n        colAttrs.outlineLevel = col.outlineLevel;\n      }\n      if (col.collapsed) {\n        colAttrs.collapsed = 1;\n      }\n      if (col.bestFit) {\n        colAttrs.bestFit = 1;\n      }\n      if (col.phonetic) {\n        colAttrs.phonetic = 1;\n      }\n      p.push(selfCloseElement(\"col\", attrs(colAttrs)));\n    }\n    p.push(\"</cols>\");\n  }\n\n  // Sheet data (rows + cells) — the hot path\n  p.push(\"<sheetData>\");\n  for (const [i, rowOpts] of rows.entries()) {\n    const rowNumber = rowOpts.rowNumber ?? i + 1;\n    const rowAttrs: Record<string, string | number | boolean | undefined> = { r: rowNumber };\n    if (rowOpts.height !== undefined) {\n      rowAttrs.ht = convertToPt(rowOpts.height);\n      rowAttrs.customHeight = 1;\n    }\n    if (rowOpts.hidden) {\n      rowAttrs.hidden = 1;\n    }\n    if (rowOpts.spans) rowAttrs.spans = rowOpts.spans;\n    if (rowOpts.customFormat) rowAttrs.customFormat = 1;\n    if (rowOpts.thickTop) rowAttrs.thickTop = 1;\n    if (rowOpts.thickBot) rowAttrs.thickBot = 1;\n    if (rowOpts.ph) rowAttrs.ph = 1;\n\n    if (rowOpts.cells) {\n      p.push(`<row${attrsRaw(rowAttrs)}>`);\n      for (const [j, cell] of rowOpts.cells.entries()) {\n        const ref = cell.reference ?? defaultCellRef(rowNumber, j + 1);\n        const cellStr = buildCellString(ref, cell, sharedStrings, styles);\n        if (cellStr) p.push(cellStr);\n      }\n      p.push(\"</row>\");\n    } else {\n      p.push(`<row${attrsRaw(rowAttrs)}/>`);\n    }\n  }\n  p.push(\"</sheetData>\");\n\n  // Sheet calc properties (after sheetData per XSD sequence)\n  if (opts.sheetCalcPr) {\n    const scAttrs: string[] = [];\n    if (opts.sheetCalcPr.fullCalcOnLoad) scAttrs.push('fullCalcOnLoad=\"1\"');\n    p.push(`<sheetCalcPr${scAttrs.length ? \" \" + scAttrs.join(\" \") : \"\"}/>`);\n  }\n\n  // Row breaks (after sheetCalcPr per XSD sequence)\n  if (rowBreaks.length > 0) {\n    let manualCount = 0;\n    const brkParts = rowBreaks.map((b) => {\n      const bAttrs: Record<string, string | number | boolean | undefined> = { id: b.id };\n      if (b.min !== undefined) bAttrs.min = b.min;\n      if (b.max !== undefined) bAttrs.max = b.max;\n      if (b.manual) {\n        bAttrs.man = 1;\n        manualCount++;\n      }\n      if (b.pivot) bAttrs.pt = 1;\n      return `<brk${attrs(bAttrs)}/>`;\n    });\n    p.push(\n      `<rowBreaks count=\"${rowBreaks.length}\" manualBreakCount=\"${manualCount}\">${brkParts.join(\"\")}</rowBreaks>`,\n    );\n  }\n\n  // Column breaks\n  if (colBreaks.length > 0) {\n    let manualCount = 0;\n    const brkParts = colBreaks.map((b) => {\n      const bAttrs: Record<string, string | number | boolean | undefined> = { id: b.id };\n      if (b.min !== undefined) bAttrs.min = b.min;\n      if (b.max !== undefined) bAttrs.max = b.max;\n      if (b.manual) {\n        bAttrs.man = 1;\n        manualCount++;\n      }\n      if (b.pivot) bAttrs.pt = 1;\n      return `<brk${attrs(bAttrs)}/>`;\n    });\n    p.push(\n      `<colBreaks count=\"${colBreaks.length}\" manualBreakCount=\"${manualCount}\">${brkParts.join(\"\")}</colBreaks>`,\n    );\n  }\n\n  // Custom properties (CT_CustomProperties, after colBreaks per XSD sequence)\n  if (customProperties.length > 0) {\n    const cpParts: string[] = [\"<customProperties>\"];\n    for (const cp of customProperties) {\n      cpParts.push(`<customPr name=\"${escapeXml(cp.name)}\" r:id=\"${escapeXml(cp.rId)}\"/>`);\n    }\n    cpParts.push(\"</customProperties>\");\n    p.push(cpParts.join(\"\"));\n  }\n\n  // OLE size\n  if (opts.oleSize) {\n    p.push(`<oleSize ref=\"${escapeXml(opts.oleSize)}\"/>`);\n  }\n\n  // Custom sheet views (after oleSize per XSD sequence)\n  if (customSheetViews.length > 0) {\n    p.push(\"<customSheetViews>\");\n    for (const csv of customSheetViews) {\n      const csvAttrs: Record<string, string | number | boolean | undefined> = { guid: csv.guid };\n      if (csv.scale !== undefined) csvAttrs.scale = csv.scale;\n      if (csv.showPageBreaks) csvAttrs.showPageBreaks = 1;\n      if (csv.showFormulas) csvAttrs.showFormulas = 1;\n      if (csv.showGridLines === false) csvAttrs.showGridLines = 0;\n      if (csv.showRowColHeaders === false) csvAttrs.showRowCol = 0;\n      if (csv.outlineSymbols === false) csvAttrs.outlineSymbols = 0;\n      if (csv.zeroValues === false) csvAttrs.zeroValues = 0;\n      if (csv.fitToPage) csvAttrs.fitToPage = 1;\n      if (csv.printArea) csvAttrs.printArea = 1;\n      if (csv.filter) csvAttrs.filter = 1;\n      if (csv.showAutoFilter) csvAttrs.showAutoFilter = 1;\n      if (csv.hiddenRows) csvAttrs.hiddenRows = 1;\n      if (csv.hiddenColumns) csvAttrs.hiddenColumns = 1;\n      if (csv.state && csv.state !== \"visible\") csvAttrs.state = csv.state;\n      if (csv.filterUnique) csvAttrs.filterUnique = 1;\n      if (csv.view && csv.view !== \"normal\") csvAttrs.view = csv.view;\n      p.push(`<customSheetView${attrs(csvAttrs)}/>`);\n    }\n    p.push(\"</customSheetViews>\");\n  }\n\n  // Cell watches\n  if (cellWatches.length > 0) {\n    p.push(\"<cellWatches>\");\n    for (const cw of cellWatches) {\n      p.push(`<cellWatch r=\"${escapeXml(cw.r)}\"/>`);\n    }\n    p.push(\"</cellWatches>\");\n  }\n\n  // Data consolidation\n  if (opts.dataConsolidate) {\n    const dc = opts.dataConsolidate;\n    const dcAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (dc.function && dc.function !== \"sum\") dcAttrs.function = dc.function;\n    if (dc.topLabels) dcAttrs.topLabels = 1;\n    if (dc.leftLabels) dcAttrs.leftLabels = 1;\n    if (dc.startLabels) dcAttrs.startLabels = 1;\n    if (dc.link) dcAttrs.link = 1;\n    const refsInner = dc.refs?.map((r) => `<dataRef ref=\"${escapeXml(r)}\"/>`).join(\"\") ?? \"\";\n    const refsXml = refsInner ? `<dataRefs>${refsInner}</dataRefs>` : \"\";\n    if (refsXml || Object.keys(dcAttrs).length > 0) {\n      p.push(`<dataConsolidate${attrs(dcAttrs)}>${refsXml}</dataConsolidate>`);\n    }\n  }\n\n  // Sheet protection (after sheetData, before protectedRanges per XSD sequence)\n  if (opts.protection) {\n    const prot = opts.protection;\n    const protAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (prot.password) protAttrs.password = hashPassword(prot.password);\n    // Auto-derive modern hash when password provided without explicit hashValue\n    let derived: ReturnType<typeof derivePasswordHash> | undefined;\n    if (prot.password !== undefined && prot.hashValue === undefined) {\n      derived = derivePasswordHash(prot.password);\n    }\n    protAttrs.algorithmName = prot.algorithmName ?? derived?.algorithmName;\n    protAttrs.hashValue = prot.hashValue ?? derived?.hashValue;\n    protAttrs.saltValue = prot.saltValue ?? derived?.saltValue;\n    if (prot.spinCount !== undefined) protAttrs.spinCount = prot.spinCount;\n    else if (derived) protAttrs.spinCount = derived.spinCount;\n    if (prot.sheet) protAttrs.sheet = 1;\n    if (prot.objects) protAttrs.objects = 1;\n    if (prot.scenarios) protAttrs.scenarios = 1;\n    if (prot.formatCells === false) protAttrs.formatCells = 0;\n    if (prot.formatColumns === false) protAttrs.formatColumns = 0;\n    if (prot.formatRows === false) protAttrs.formatRows = 0;\n    if (prot.insertColumns === false) protAttrs.insertColumns = 0;\n    if (prot.insertRows === false) protAttrs.insertRows = 0;\n    if (prot.insertHyperlinks === false) protAttrs.insertHyperlinks = 0;\n    if (prot.deleteColumns === false) protAttrs.deleteColumns = 0;\n    if (prot.deleteRows === false) protAttrs.deleteRows = 0;\n    if (prot.selectLockedCells) protAttrs.selectLockedCells = 1;\n    if (prot.sort === false) protAttrs.sort = 0;\n    if (prot.autoFilter === false) protAttrs.autoFilter = 0;\n    if (prot.pivotTables === false) protAttrs.pivotTables = 0;\n    if (prot.selectUnlockedCells) protAttrs.selectUnlockedCells = 1;\n    p.push(selfCloseElement(\"sheetProtection\", attrs(protAttrs)));\n  }\n\n  // Protected ranges (after sheetProtection per XSD sequence)\n  if (protectedRanges.length > 0) {\n    const prParts: string[] = [\"<protectedRanges>\"];\n    for (const pr of protectedRanges) {\n      const prAttrs: Record<string, string | number | boolean | undefined> = {\n        name: pr.name,\n        sqref: pr.sqref,\n      };\n      if (pr.password) prAttrs.password = hashPassword(pr.password);\n      // Auto-derive modern hash when password provided without explicit hashValue\n      let prDerived: ReturnType<typeof derivePasswordHash> | undefined;\n      if (pr.password !== undefined && pr.hashValue === undefined) {\n        prDerived = derivePasswordHash(pr.password);\n      }\n      prAttrs.algorithmName = pr.algorithmName ?? prDerived?.algorithmName;\n      prAttrs.hashValue = pr.hashValue ?? prDerived?.hashValue;\n      prAttrs.saltValue = pr.saltValue ?? prDerived?.saltValue;\n      if (pr.spinCount !== undefined) prAttrs.spinCount = pr.spinCount;\n      else if (prDerived) prAttrs.spinCount = prDerived.spinCount;\n      const hasSecurityDescriptor = !!pr.securityDescriptor;\n      if (hasSecurityDescriptor) {\n        prParts.push(\n          `<protectedRange${attrs(prAttrs)}><securityDescriptor>${escapeXml(pr.securityDescriptor!)}</securityDescriptor></protectedRange>`,\n        );\n      } else {\n        prParts.push(selfCloseElement(\"protectedRange\", attrs(prAttrs)));\n      }\n    }\n    prParts.push(\"</protectedRanges>\");\n    p.push(prParts.join(\"\"));\n  }\n\n  // Scenarios (what-if analysis)\n  if (opts.scenarios) {\n    const scParts: string[] = [\"<scenarios\"];\n    const scAttrs: Record<string, string | number> = {};\n    if (opts.scenarios.current !== undefined) scAttrs.current = opts.scenarios.current;\n    if (opts.scenarios.show !== undefined) scAttrs.show = opts.scenarios.show;\n    scParts[0] = `<scenarios${attrs(scAttrs)}>`;\n\n    for (const scenario of opts.scenarios.scenarios) {\n      const sAttrs: Record<string, string | number | boolean | undefined> = {\n        name: scenario.name,\n      };\n      if (scenario.count !== undefined) sAttrs.count = scenario.count;\n      if (scenario.user) sAttrs.user = scenario.user;\n      if (scenario.comment) sAttrs.comment = scenario.comment;\n      if (scenario.hidden) sAttrs.hidden = true;\n      if (scenario.locked) sAttrs.locked = true;\n\n      const sParts: string[] = [`<scenario${attrs(sAttrs)}>`];\n      for (const cell of scenario.inputCells) {\n        const icAttrs: Record<string, string | number | boolean | undefined> = {\n          r: cell.r,\n          val: String(cell.val),\n        };\n        if (cell.deleted) icAttrs.deleted = true;\n        if (cell.undone) icAttrs.undone = true;\n        sParts.push(`<inputCells${attrs(icAttrs)}/>`);\n      }\n      sParts.push(\"</scenario>\");\n      scParts.push(sParts.join(\"\"));\n    }\n    scParts.push(\"</scenarios>\");\n    p.push(scParts.join(\"\"));\n  }\n\n  // Auto filter\n  if (opts.autoFilter) {\n    if (typeof opts.autoFilter === \"string\") {\n      p.push(selfCloseElement(\"autoFilter\", attrs({ ref: opts.autoFilter })));\n    } else {\n      const af = opts.autoFilter;\n      const inner: string[] = [];\n      for (const t10 of af.top10 ?? []) {\n        const fcAttrs: Record<string, string | number | boolean | undefined> = {\n          colId: t10.colId,\n        };\n        if (t10.hiddenButton) fcAttrs.hiddenButton = 1;\n        if (t10.showButton === false) fcAttrs.showButton = 0;\n        const t10Attrs: Record<string, string | number | boolean | undefined> = { val: t10.val };\n        if (t10.top === false) t10Attrs.top = 0;\n        if (t10.percent) t10Attrs.percent = 1;\n        if (t10.filterVal !== undefined) t10Attrs.filterVal = t10.filterVal;\n        inner.push(`<filterColumn${attrs(fcAttrs)}><top10${attrs(t10Attrs)}/></filterColumn>`);\n      }\n      for (const cf of af.customFilters ?? []) {\n        const fcAttrs: Record<string, string | number | boolean | undefined> = {\n          colId: cf.colId,\n        };\n        if (cf.hiddenButton) fcAttrs.hiddenButton = 1;\n        if (cf.showButton === false) fcAttrs.showButton = 0;\n        const cfAttrs: Record<string, string | number | boolean | undefined> = {};\n        if (cf.and) cfAttrs.and = 1;\n        const filters: string[] = [];\n        if (cf.val !== undefined) {\n          const fAttrs: Record<string, string | number | boolean | undefined> = { val: cf.val };\n          if (cf.operator) fAttrs.operator = cf.operator;\n          filters.push(selfCloseElement(\"customFilter\", attrs(fAttrs)));\n        }\n        if (cf.val2 !== undefined) {\n          filters.push(selfCloseElement(\"customFilter\", attrs({ val: cf.val2 })));\n        }\n        if (filters.length > 0) {\n          inner.push(\n            `<filterColumn${attrs(fcAttrs)}><customFilters${attrs(cfAttrs)}>${filters.join(\"\")}</customFilters></filterColumn>`,\n          );\n        }\n      }\n      // Simple filters (CT_Filters)\n      for (const fi of af.filters ?? []) {\n        const fcAttrs: Record<string, string | number | boolean | undefined> = {\n          colId: fi.colId,\n        };\n        const filtersAttrs: Record<string, string | number | boolean | undefined> = {};\n        if (fi.blank) filtersAttrs.blank = 1;\n        if (fi.calendarType) filtersAttrs.calendarType = fi.calendarType;\n        const valParts = (fi.values ?? []).map((v) => `<filter val=\"${escapeXml(v)}\"/>`);\n        inner.push(\n          `<filterColumn${attrs(fcAttrs)}><filters${attrs(filtersAttrs)}>${valParts.join(\"\")}</filters></filterColumn>`,\n        );\n      }\n      if (af.sort && af.sort.length > 0) {\n        const sortParts: string[] = [];\n        for (const sc of af.sort) {\n          const scAttrs: Record<string, string | number | boolean | undefined> = { ref: sc.ref };\n          if (sc.descending) scAttrs.descending = 1;\n          if (sc.sortBy) scAttrs.sortBy = sc.sortBy;\n          if (sc.customList) scAttrs.customList = sc.customList;\n          if (sc.iconId !== undefined) scAttrs.iconId = sc.iconId;\n          sortParts.push(selfCloseElement(\"sortCondition\", attrs(scAttrs)));\n        }\n        const ssAttrs: Record<string, string | number | boolean | undefined> = { ref: af.ref };\n        if (af.sortState?.columnSort) ssAttrs.columnSort = 1;\n        if (af.sortState?.caseSensitive) ssAttrs.caseSensitive = 1;\n        if (af.sortState?.sortMethod) ssAttrs.sortMethod = af.sortState.sortMethod;\n        inner.push(`<sortState${attrs(ssAttrs)}>${sortParts.join(\"\")}</sortState>`);\n      }\n      // Color filters\n      for (const cf of af.colorFilters ?? []) {\n        const cfAttrs: Record<string, string | number | boolean | undefined> = {};\n        if (cf.dxfId !== undefined) cfAttrs.dxfId = cf.dxfId;\n        if (cf.cellColor === false) cfAttrs.cellColor = 0;\n        inner.push(\n          `<filterColumn colId=\"${cf.colId}\"><colorFilter${attrs(cfAttrs)}/></filterColumn>`,\n        );\n      }\n      // Icon filters\n      for (const if_ of af.iconFilters ?? []) {\n        const ifAttrs: Record<string, string | number | boolean | undefined> = {\n          iconSet: if_.iconSet,\n        };\n        if (if_.iconId !== undefined) ifAttrs.iconId = if_.iconId;\n        inner.push(\n          `<filterColumn colId=\"${if_.colId}\"><iconFilter${attrs(ifAttrs)}/></filterColumn>`,\n        );\n      }\n      // Dynamic filters\n      for (const df of af.dynamicFilters ?? []) {\n        const dfAttrs: Record<string, string | number | boolean | undefined> = { type: df.type };\n        if (df.val !== undefined) dfAttrs.val = df.val;\n        if (df.maxVal !== undefined) dfAttrs.maxVal = df.maxVal;\n        if (df.valIso !== undefined) dfAttrs.valIso = df.valIso;\n        if (df.maxValIso !== undefined) dfAttrs.maxValIso = df.maxValIso;\n        inner.push(\n          `<filterColumn colId=\"${df.colId}\"><dynamicFilter${attrs(dfAttrs)}/></filterColumn>`,\n        );\n      }\n      // Date group filters\n      for (const dg of af.dateGroupItems ?? []) {\n        const dgAttrs: Record<string, string | number | boolean | undefined> = {\n          dateTimeGrouping: dg.dateTimeGrouping,\n        };\n        if (dg.year !== undefined) dgAttrs.year = dg.year;\n        if (dg.month !== undefined) dgAttrs.month = dg.month;\n        if (dg.day !== undefined) dgAttrs.day = dg.day;\n        if (dg.hour !== undefined) dgAttrs.hour = dg.hour;\n        if (dg.minute !== undefined) dgAttrs.minute = dg.minute;\n        if (dg.second !== undefined) dgAttrs.second = dg.second;\n        inner.push(\n          `<filterColumn colId=\"${dg.colId}\"><dateGroupItem${attrs(dgAttrs)}/></filterColumn>`,\n        );\n      }\n      if (inner.length > 0) {\n        p.push(`<autoFilter ref=\"${af.ref}\">`, ...inner, \"</autoFilter>\");\n      } else {\n        p.push(selfCloseElement(\"autoFilter\", attrs({ ref: af.ref })));\n      }\n    }\n  }\n\n  // Merge cells\n  if (mergeCells.length > 0) {\n    p.push(`<mergeCells count=\"${mergeCells.length}\">`);\n    for (const mc of mergeCells) {\n      const fromRef = defaultCellRef(mc.from.row, mc.from.col);\n      const toRef = defaultCellRef(mc.to.row, mc.to.col);\n      p.push(selfCloseElement(\"mergeCell\", attrs({ ref: `${fromRef}:${toRef}` })));\n    }\n    p.push(\"</mergeCells>\");\n  }\n\n  // Phonetic properties (after mergeCells per XSD sequence)\n  if (opts.phoneticPr) {\n    const pp = opts.phoneticPr;\n    const ppAttrs: Record<string, string | number> = { fontId: pp.fontId };\n    if (pp.type && pp.type !== \"fullwidthKatakana\") ppAttrs.type = pp.type;\n    if (pp.alignment && pp.alignment !== \"left\") ppAttrs.alignment = pp.alignment;\n    p.push(selfCloseElement(\"phoneticPr\", attrs(ppAttrs)));\n  }\n\n  // Conditional formatting\n  const conditionalFormats = opts.conditionalFormats ?? [];\n  if (conditionalFormats.length > 0) {\n    for (const cf of conditionalFormats) {\n      p.push(`<conditionalFormatting sqref=\"${cf.sqref}\">`);\n      for (const [ri, rule] of cf.rules.entries()) {\n        const ruleAttrs: Record<string, string | number | boolean | undefined> = {\n          type: rule.type,\n          priority: rule.priority ?? ri + 1,\n        };\n        if (rule.operator) ruleAttrs.operator = rule.operator;\n        if (rule.dxfId !== undefined) ruleAttrs.dxfId = rule.dxfId;\n        if (rule.stopIfTrue) ruleAttrs.stopIfTrue = 1;\n        if (rule.timePeriod) ruleAttrs.timePeriod = rule.timePeriod;\n        if (rule.rank !== undefined) ruleAttrs.rank = rule.rank;\n        if (rule.equalAverage) ruleAttrs.equalAverage = 1;\n\n        // Color scale\n        if (rule.type === \"colorScale\" && rule.colorScale) {\n          const cs = rule.colorScale;\n          const inner: string[] = [];\n          for (const v of cs.cfvo) {\n            inner.push(buildCfvoXml(v));\n          }\n          for (const c of cs.colors) {\n            inner.push(`<color rgb=\"FF${c}\"/>`);\n          }\n          p.push(`<cfRule${attrs(ruleAttrs)}><colorScale>${inner.join(\"\")}</colorScale></cfRule>`);\n        }\n        // Data bar\n        else if (rule.type === \"dataBar\" && rule.dataBar) {\n          const db = rule.dataBar;\n          const inner: string[] = [];\n          for (const v of db.cfvo) {\n            inner.push(buildCfvoXml(v));\n          }\n          inner.push(`<color rgb=\"FF${db.color}\"/>`);\n          const dbAttrs: Record<string, string | number | boolean | undefined> = {};\n          if (db.minLength !== undefined && db.minLength !== 10) dbAttrs.minLength = db.minLength;\n          if (db.maxLength !== undefined && db.maxLength !== 90) dbAttrs.maxLength = db.maxLength;\n          if (db.showValue === false) dbAttrs.showValue = 0;\n          const attrStr = Object.keys(dbAttrs).length > 0 ? attrs(dbAttrs) : \"\";\n          p.push(\n            `<cfRule${attrs(ruleAttrs)}><dataBar${attrStr}>${inner.join(\"\")}</dataBar></cfRule>`,\n          );\n        }\n        // Icon set\n        else if (rule.type === \"iconSet\" && rule.iconSet) {\n          const is = rule.iconSet;\n          const inner: string[] = [];\n          for (const v of is.cfvo) {\n            inner.push(buildCfvoXml(v));\n          }\n          const isAttrs: Record<string, string | number | boolean | undefined> = {};\n          if (is.iconSet !== undefined && is.iconSet !== \"3TrafficLights1\")\n            isAttrs.iconSet = is.iconSet;\n          if (is.showValue === false) isAttrs.showValue = 0;\n          if (is.percent === false) isAttrs.percent = 0;\n          if (is.reverse) isAttrs.reverse = 1;\n          const attrStr = Object.keys(isAttrs).length > 0 ? attrs(isAttrs) : \"\";\n          p.push(\n            `<cfRule${attrs(ruleAttrs)}><iconSet${attrStr}>${inner.join(\"\")}</iconSet></cfRule>`,\n          );\n        }\n        // Standard rules (cellIs, containsText, expression, top10, aboveAverage)\n        else {\n          if (rule.formulas && rule.formulas.length > 0) {\n            const formulaParts = rule.formulas.map((f) => `<formula>${escapeXml(f)}</formula>`);\n            p.push(`<cfRule${attrs(ruleAttrs)}>`, ...formulaParts, \"</cfRule>\");\n          } else {\n            p.push(selfCloseElement(\"cfRule\", attrs(ruleAttrs)));\n          }\n        }\n      }\n      p.push(\"</conditionalFormatting>\");\n    }\n  }\n\n  // Data validations\n  const dataValidations = opts.dataValidations ?? [];\n  if (dataValidations.length > 0) {\n    const dvContainerAttrs: Record<string, string | number | boolean | undefined> = {\n      count: dataValidations.length,\n    };\n    if (opts.dataValidationsDisablePrompts) dvContainerAttrs.disablePrompts = 1;\n    p.push(`<dataValidations${attrs(dvContainerAttrs)}>`);\n    for (const dv of dataValidations) {\n      const dvAttrs: Record<string, string | number | boolean | undefined> = { sqref: dv.sqref };\n      if (dv.type && dv.type !== \"none\") dvAttrs.type = dv.type;\n      if (dv.operator) dvAttrs.operator = dv.operator;\n      if (dv.allowBlank) dvAttrs.allowBlank = 1;\n      if (dv.showErrorMessage) dvAttrs.showErrorMessage = 1;\n      if (dv.showInputMessage) dvAttrs.showInputMessage = 1;\n      if (dv.errorTitle) dvAttrs.errorTitle = dv.errorTitle;\n      if (dv.error) dvAttrs.error = dv.error;\n      if (dv.promptTitle) dvAttrs.promptTitle = dv.promptTitle;\n      if (dv.prompt) dvAttrs.prompt = dv.prompt;\n      if (dv.errorStyle) dvAttrs.errorStyle = dv.errorStyle;\n      if (dv.imeMode) dvAttrs.imeMode = dv.imeMode;\n      if (dv.showDropDown) dvAttrs.showDropDown = 1;\n      const inner: string[] = [];\n      if (dv.formula1 !== undefined) inner.push(`<formula1>${escapeXml(dv.formula1)}</formula1>`);\n      if (dv.formula2 !== undefined) inner.push(`<formula2>${escapeXml(dv.formula2)}</formula2>`);\n      if (inner.length > 0) {\n        p.push(`<dataValidation${attrs(dvAttrs)}>`, ...inner, \"</dataValidation>\");\n      } else {\n        p.push(selfCloseElement(\"dataValidation\", attrs(dvAttrs)));\n      }\n    }\n    p.push(\"</dataValidations>\");\n  }\n\n  // Hyperlinks — r:id numbering must match worksheet rels order (compiler handles rels)\n  const hyperlinks = opts.hyperlinks ?? [];\n  if (hyperlinks.length > 0) {\n    p.push(\"<hyperlinks>\");\n    let hlIdx = 0;\n    for (const hl of hyperlinks) {\n      const hlAttrs: Record<string, string | number | boolean | undefined> = { ref: hl.cell };\n      if (hl.target.type === \"external\") {\n        hlIdx++;\n        hlAttrs[\"r:id\"] = `rId${hlIdx}`;\n      } else {\n        hlAttrs.location = hl.target.location;\n      }\n      if (hl.tooltip) hlAttrs.tooltip = hl.tooltip;\n      if (hl.display) hlAttrs.display = hl.display;\n      p.push(selfCloseElement(\"hyperlink\", attrs(hlAttrs)));\n    }\n    p.push(\"</hyperlinks>\");\n  }\n\n  // Print options\n  if (opts.printOptions) {\n    const po = opts.printOptions;\n    const poAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (po.horizontalCentered) poAttrs.horizontalCentered = 1;\n    if (po.verticalCentered) poAttrs.verticalCentered = 1;\n    if (po.headings) poAttrs.headings = 1;\n    if (po.gridLines) poAttrs.gridLines = 1;\n    if (po.gridLinesSet === false) poAttrs.gridLinesSet = 0;\n    p.push(selfCloseElement(\"printOptions\", attrs(poAttrs)));\n  }\n\n  p.push('<pageMargins left=\"0.75\" right=\"0.75\" top=\"1\" bottom=\"1\" header=\"0.5\" footer=\"0.5\"/>');\n\n  // Page setup\n  if (opts.pageSetup) {\n    const ps = opts.pageSetup;\n    const psAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (ps.paperSize !== undefined) psAttrs.paperSize = ps.paperSize;\n    if (ps.orientation && ps.orientation !== \"default\") psAttrs.orientation = ps.orientation;\n    if (ps.scale !== undefined) psAttrs.scale = ps.scale;\n    if (ps.fitToWidth !== undefined) psAttrs.fitToWidth = ps.fitToWidth;\n    if (ps.fitToHeight !== undefined) psAttrs.fitToHeight = ps.fitToHeight;\n    if (ps.pageOrder && ps.pageOrder !== \"downThenOver\") psAttrs.pageOrder = ps.pageOrder;\n    if (ps.useFirstPageNumber) psAttrs.useFirstPageNumber = 1;\n    if (ps.firstPageNumber !== undefined) psAttrs.firstPageNumber = ps.firstPageNumber;\n    if (ps.paperHeight !== undefined) psAttrs.paperHeight = ps.paperHeight;\n    if (ps.paperWidth !== undefined) psAttrs.paperWidth = ps.paperWidth;\n    if (ps.usePrinterDefaults) psAttrs.usePrinterDefaults = 1;\n    if (ps.blackAndWhite) psAttrs.blackAndWhite = 1;\n    if (ps.draft) psAttrs.draft = 1;\n    if (ps.cellComments && ps.cellComments !== \"none\") psAttrs.cellComments = ps.cellComments;\n    if (ps.errors && ps.errors !== \"displayed\") psAttrs.errors = ps.errors;\n    p.push(selfCloseElement(\"pageSetup\", attrs(psAttrs)));\n  }\n\n  // Header/footer\n  if (opts.headerFooter) {\n    const hf = opts.headerFooter;\n    const hfAttrs: Record<string, string | number | boolean | undefined> = {};\n    if (hf.differentOddEven) hfAttrs.differentOddEven = 1;\n    if (hf.differentFirst) hfAttrs.differentFirst = 1;\n    if (hf.scaleWithDoc === false) hfAttrs.scaleWithDoc = 0;\n    if (hf.alignWithMargins === false) hfAttrs.alignWithMargins = 0;\n    const inner: string[] = [];\n    if (hf.oddHeader) inner.push(`<oddHeader>${escapeXml(hf.oddHeader)}</oddHeader>`);\n    if (hf.oddFooter) inner.push(`<oddFooter>${escapeXml(hf.oddFooter)}</oddFooter>`);\n    if (hf.evenHeader) inner.push(`<evenHeader>${escapeXml(hf.evenHeader)}</evenHeader>`);\n    if (hf.evenFooter) inner.push(`<evenFooter>${escapeXml(hf.evenFooter)}</evenFooter>`);\n    if (hf.firstHeader) inner.push(`<firstHeader>${escapeXml(hf.firstHeader)}</firstHeader>`);\n    if (hf.firstFooter) inner.push(`<firstFooter>${escapeXml(hf.firstFooter)}</firstFooter>`);\n    if (inner.length > 0) {\n      p.push(`<headerFooter${attrs(hfAttrs)}>`, ...inner, \"</headerFooter>\");\n    } else if (hfAttrs.differentOddEven || hfAttrs.differentFirst) {\n      p.push(selfCloseElement(\"headerFooter\", attrs(hfAttrs)));\n    }\n  }\n\n  // Drawing in header/footer (after headerFooter per XSD sequence)\n  if (opts.drawingHF) {\n    const dhf = opts.drawingHF;\n    const dhfAttrs: Record<string, string | number | boolean | undefined> = { \"r:id\": dhf.rId };\n    if (dhf.lho !== undefined) dhfAttrs.lho = dhf.lho;\n    if (dhf.lhe !== undefined) dhfAttrs.lhe = dhf.lhe;\n    if (dhf.lhf !== undefined) dhfAttrs.lhf = dhf.lhf;\n    if (dhf.cho !== undefined) dhfAttrs.cho = dhf.cho;\n    if (dhf.che !== undefined) dhfAttrs.che = dhf.che;\n    if (dhf.chf !== undefined) dhfAttrs.chf = dhf.chf;\n    if (dhf.rho !== undefined) dhfAttrs.rho = dhf.rho;\n    if (dhf.rhe !== undefined) dhfAttrs.rhe = dhf.rhe;\n    if (dhf.rhf !== undefined) dhfAttrs.rhf = dhf.rhf;\n    if (dhf.lfo !== undefined) dhfAttrs.lfo = dhf.lfo;\n    if (dhf.lfe !== undefined) dhfAttrs.lfe = dhf.lfe;\n    if (dhf.lff !== undefined) dhfAttrs.lff = dhf.lff;\n    if (dhf.cfo !== undefined) dhfAttrs.cfo = dhf.cfo;\n    if (dhf.cfe !== undefined) dhfAttrs.cfe = dhf.cfe;\n    if (dhf.cff !== undefined) dhfAttrs.cff = dhf.cff;\n    if (dhf.rfo !== undefined) dhfAttrs.rfo = dhf.rfo;\n    if (dhf.rfe !== undefined) dhfAttrs.rfe = dhf.rfe;\n    if (dhf.rff !== undefined) dhfAttrs.rff = dhf.rff;\n    p.push(selfCloseElement(\"drawingHF\", attrs(dhfAttrs)));\n  }\n\n  // Legacy drawing in header/footer\n  if (opts.legacyDrawingHF) {\n    p.push(`<legacyDrawingHF r:id=\"${escapeXml(opts.legacyDrawingHF)}\"/>`);\n  }\n\n  // Ignored errors (after headerFooter per XSD sequence)\n  if (ignoredErrors.length > 0) {\n    const ieParts: string[] = [\"<ignoredErrors>\"];\n    for (const ie of ignoredErrors) {\n      const ieAttrs: Record<string, string | number | boolean | undefined> = {\n        sqref: ie.sqref,\n      };\n      if (ie.evalError) ieAttrs.evalError = 1;\n      if (ie.twoDigitTextYear) ieAttrs.twoDigitTextYear = 1;\n      if (ie.numberStoredAsText) ieAttrs.numberStoredAsText = 1;\n      if (ie.formula) ieAttrs.formula = 1;\n      if (ie.formulaRange) ieAttrs.formulaRange = 1;\n      if (ie.unlockedFormula) ieAttrs.unlockedFormula = 1;\n      if (ie.emptyCellReference) ieAttrs.emptyCellReference = 1;\n      if (ie.listDataValidation) ieAttrs.listDataValidation = 1;\n      if (ie.calculatedColumn) ieAttrs.calculatedColumn = 1;\n      ieParts.push(selfCloseElement(\"ignoredError\", attrs(ieAttrs)));\n    }\n    ieParts.push(\"</ignoredErrors>\");\n    p.push(ieParts.join(\"\"));\n  }\n\n  // Background picture placeholder — compiler replaces with <picture r:id=\"rIdN\"/>\n  if (opts.backgroundImage) {\n    p.push(\"<!--BACKGROUND_PICTURE-->\");\n  }\n\n  // OLE objects (CT_OleObjects, after picture per XSD sequence)\n  if (oleObjects.length > 0) {\n    const oleParts: string[] = [\"<oleObjects>\"];\n    for (const ole of oleObjects) {\n      const oleAttrs: string[] = [`shapeId=\"${ole.shapeId}\"`];\n      if (ole.progId) oleAttrs.push(`progId=\"${escapeXml(ole.progId)}\"`);\n      if (ole.dvAspect && ole.dvAspect !== \"DVASPECT_CONTENT\")\n        oleAttrs.push(`dvAspect=\"${ole.dvAspect}\"`);\n      if (ole.link) oleAttrs.push(`link=\"${escapeXml(ole.link)}\"`);\n      if (ole.oleUpdate) oleAttrs.push(`oleUpdate=\"${ole.oleUpdate}\"`);\n      if (ole.autoLoad) oleAttrs.push('autoLoad=\"1\"');\n      if (ole.rId) oleAttrs.push(`r:id=\"${escapeXml(ole.rId)}\"`);\n      // objectPr (CT_ObjectPr, optional child)\n      if (ole.objectPr) {\n        const opr = ole.objectPr;\n        const oprAttrs: string[] = [];\n        if (opr.locked === false) oprAttrs.push('locked=\"0\"');\n        if (opr.defaultSize === false) oprAttrs.push('defaultSize=\"0\"');\n        if (opr.print === false) oprAttrs.push('print=\"0\"');\n        if (opr.disabled) oprAttrs.push('disabled=\"1\"');\n        if (opr.uiObject) oprAttrs.push('uiObject=\"1\"');\n        if (opr.autoFill === false) oprAttrs.push('autoFill=\"0\"');\n        if (opr.autoLine === false) oprAttrs.push('autoLine=\"0\"');\n        if (opr.autoPict === false) oprAttrs.push('autoPict=\"0\"');\n        if (opr.macro) oprAttrs.push(`macro=\"${escapeXml(opr.macro)}\"`);\n        if (opr.altText) oprAttrs.push(`altText=\"${escapeXml(opr.altText)}\"`);\n        if (opr.dde) oprAttrs.push('dde=\"1\"');\n        if (opr.rId) oprAttrs.push(`r:id=\"${escapeXml(opr.rId)}\"`);\n        oleParts.push(\n          `<oleObject ${oleAttrs.join(\" \")}><objectPr${oprAttrs.length ? \" \" + oprAttrs.join(\" \") : \"\"}/></oleObject>`,\n        );\n      } else {\n        oleParts.push(`<oleObject ${oleAttrs.join(\" \")}/>`);\n      }\n    }\n    oleParts.push(\"</oleObjects>\");\n    p.push(oleParts.join(\"\"));\n  }\n\n  // Controls (CT_Controls, after oleObjects per XSD sequence)\n  if (controls.length > 0) {\n    const ctrlParts: string[] = [\"<controls>\"];\n    for (const c of controls) {\n      const cAttrs: string[] = [`shapeId=\"${c.shapeId}\"`, `r:id=\"${escapeXml(c.rId)}\"`];\n      if (c.name) cAttrs.push(`name=\"${escapeXml(c.name)}\"`);\n      // controlPr (optional)\n      const prAttrs: string[] = [];\n      if (c.locked === false) prAttrs.push('locked=\"0\"');\n      if (c.uiObject) prAttrs.push('uiObject=\"1\"');\n      if (c.recalcAlways) prAttrs.push('recalcAlways=\"1\"');\n      if (c.linkedCell) prAttrs.push(`linkedCell=\"${escapeXml(c.linkedCell)}\"`);\n      if (c.listFillRange) prAttrs.push(`listFillRange=\"${escapeXml(c.listFillRange)}\"`);\n      if (c.cf) prAttrs.push(`cf=\"${escapeXml(c.cf)}\"`);\n      if (prAttrs.length > 0) {\n        ctrlParts.push(\n          `<control ${cAttrs.join(\" \")}><controlPr${prAttrs.length ? \" \" + prAttrs.join(\" \") : \"\"}/></control>`,\n        );\n      } else {\n        ctrlParts.push(`<control ${cAttrs.join(\" \")}/>`);\n      }\n    }\n    ctrlParts.push(\"</controls>\");\n    p.push(ctrlParts.join(\"\"));\n  }\n\n  // Web publish items (CT_WebPublishItems, after controls per XSD sequence)\n  if (webPublishItems.length > 0) {\n    const wpParts: string[] = [`<webPublishItems count=\"${webPublishItems.length}\">`];\n    for (const wpi of webPublishItems) {\n      const wpiAttrs: string[] = [\n        `id=\"${wpi.id}\"`,\n        `divId=\"${escapeXml(wpi.divId)}\"`,\n        `sourceType=\"${wpi.sourceType}\"`,\n        `destinationFile=\"${escapeXml(wpi.destinationFile)}\"`,\n      ];\n      if (wpi.sourceRef) wpiAttrs.push(`sourceRef=\"${escapeXml(wpi.sourceRef)}\"`);\n      if (wpi.sourceObject) wpiAttrs.push(`sourceObject=\"${escapeXml(wpi.sourceObject)}\"`);\n      if (wpi.title) wpiAttrs.push(`title=\"${escapeXml(wpi.title)}\"`);\n      if (wpi.autoRepublish) wpiAttrs.push('autoRepublish=\"1\"');\n      wpParts.push(`<webPublishItem ${wpiAttrs.join(\" \")}/>`);\n    }\n    wpParts.push(\"</webPublishItems>\");\n    p.push(wpParts.join(\"\"));\n  }\n\n  // Extension list (extLst, last per XSD sequence)\n  if (opts.ext) {\n    p.push(`<extLst>${opts.ext}</extLst>`);\n  }\n\n  p.push(\"</worksheet>\");\n  return p.join(\"\");\n}\n\n// ── Stringify helpers ──\n\nfunction buildCfvoXml(cfvo: CfvoOptions): string {\n  const a: Record<string, string | number | boolean | undefined> = { type: cfvo.type };\n  if (cfvo.val !== undefined) a.val = cfvo.val;\n  if (cfvo.gte === false) a.gte = 0;\n  return `<cfvo${attrs(a)}/>`;\n}\n\nfunction buildSheetViewAttrs(sv?: SheetViewOptions): string {\n  const svMap: Record<string, string | number | boolean | undefined> = {\n    workbookViewId: 0,\n  };\n  if (sv?.tabSelected !== undefined) svMap.tabSelected = sv.tabSelected ? 1 : 0;\n  else svMap.tabSelected = 1;\n  if (sv?.showGridLines === false) svMap.showGridLines = 0;\n  if (sv?.showRowColHeaders === false) svMap.showRowColHeaders = 0;\n  if (sv?.showZeros === false) svMap.showZeros = 0;\n  if (sv?.zoomScale !== undefined) svMap.zoomScale = sv.zoomScale;\n  if (sv?.rightToLeft) svMap.rightToLeft = 1;\n  if (sv?.windowProtection) svMap.windowProtection = 1;\n  if (sv?.showFormulas) svMap.showFormulas = 1;\n  if (sv?.showRuler === false) svMap.showRuler = 0;\n  if (sv?.showOutlineSymbols === false) svMap.showOutlineSymbols = 0;\n  if (sv?.defaultGridColor === false) svMap.defaultGridColor = 0;\n  if (sv?.showWhiteSpace === false) svMap.showWhiteSpace = 0;\n  if (sv?.view) svMap.view = sv.view;\n  if (sv?.colorId !== undefined) svMap.colorId = sv.colorId;\n  if (sv?.zoomScaleNormal !== undefined) svMap.zoomScaleNormal = sv.zoomScaleNormal;\n  if (sv?.zoomScaleSheetLayoutView !== undefined)\n    svMap.zoomScaleSheetLayoutView = sv.zoomScaleSheetLayoutView;\n  if (sv?.zoomScalePageLayoutView !== undefined)\n    svMap.zoomScalePageLayoutView = sv.zoomScalePageLayoutView;\n  return attrs(svMap);\n}\n\nfunction buildSelectionXml(sel: SelectionOptions): string {\n  const selAttrs: Record<string, string | number | boolean | undefined> = {};\n  if (sel.pane) selAttrs.pane = sel.pane;\n  if (sel.activeCell) selAttrs.activeCell = sel.activeCell;\n  if (sel.activeCellId !== undefined) selAttrs.activeCellId = sel.activeCellId;\n  if (sel.sqref) selAttrs.sqref = sel.sqref;\n  return `<selection${attrs(selAttrs)}/>`;\n}\n\nfunction buildPivotSelectionXml(_ps: PivotSelectionOptions): string {\n  // pivotSelection is optional; omit if no meaningful pivotArea can be constructed.\n  // An empty <pivotArea/> causes Excel to reject the file.\n  return \"\";\n}\n\nfunction hashPassword(password: string): string {\n  let hash = 0;\n  for (let i = 0; i < password.length; i++) {\n    const c = password.charCodeAt(i);\n    hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n    hash ^= c;\n    hash = hash & 0x4000 ? hash ^ 0x1 : hash;\n  }\n  hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n  hash = ((hash >> 14) & 1) + ((hash << 1) & 0x7fff);\n  hash ^= password.length;\n  return hash.toString(16).toUpperCase().padStart(4, \"0\");\n}\n\nfunction buildFormulaString(fOpts: FormulaOptions): string {\n  const fAttrs: Record<string, string | number | boolean | undefined> = {};\n  if (fOpts.type && fOpts.type !== FormulaType.NORMAL) fAttrs.t = fOpts.type;\n  if (fOpts.reference) fAttrs.ref = fOpts.reference;\n  if (fOpts.sharedIndex !== undefined) fAttrs.si = fOpts.sharedIndex;\n  if (fOpts.aca) fAttrs.aca = 1;\n  if (fOpts.dt2D) fAttrs.dt2D = 1;\n  if (fOpts.dtr) fAttrs.dtr = 1;\n  if (fOpts.del1) fAttrs.del1 = 1;\n  if (fOpts.del2) fAttrs.del2 = 1;\n  if (fOpts.r1) fAttrs.r1 = fOpts.r1;\n  if (fOpts.r2) fAttrs.r2 = fOpts.r2;\n  if (fOpts.ca) fAttrs.ca = 1;\n  if (fOpts.bx) fAttrs.bx = 1;\n\n  const hasContent = fOpts.formula !== undefined && fOpts.formula !== \"\";\n\n  if (hasContent) {\n    return `<f${attrs(fAttrs)}>${escapeXml(fOpts.formula)}</f>`;\n  }\n  if (Object.keys(fAttrs).length > 0) {\n    return selfCloseElement(\"f\", attrs(fAttrs));\n  }\n  return \"\";\n}\n\nfunction buildCellString(\n  ref: string,\n  cell: CellOptions,\n  sharedStrings?: SharedStrings,\n  styles?: Styles,\n): string {\n  const cellAttrs: Record<string, string | number | boolean | undefined> = { r: ref };\n\n  // Resolve style\n  if (cell.style !== undefined && styles) {\n    cellAttrs.s = styles.register(cell.style);\n  } else if (cell.styleIndex !== undefined) {\n    cellAttrs.s = cell.styleIndex;\n  }\n\n  const value = cell.value;\n\n  // Formula path — formula takes precedence; value is the cached result.\n  if (cell.formula) {\n    const fStr = buildFormulaString(cell.formula);\n    let vStr = \"\";\n    if (value === null || value === undefined) {\n      return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;\n    }\n    if (typeof value === \"number\") {\n      vStr = `<v>${value}</v>`;\n    } else if (typeof value === \"boolean\") {\n      cellAttrs.t = \"b\";\n      vStr = `<v>${value ? 1 : 0}</v>`;\n    } else if (typeof value === \"string\") {\n      cellAttrs.t = \"str\";\n      vStr = `<v>${escapeXml(value)}</v>`;\n    } else if (value instanceof Date) {\n      vStr = `<v>${dateToSerialNumber(value)}</v>`;\n    }\n    if (vStr) {\n      return `<c${attrsRaw(cellAttrs)}>${fStr}${vStr}</c>`;\n    }\n    return `<c${attrsRaw(cellAttrs)}>${fStr}</c>`;\n  }\n\n  if (value === null || value === undefined) {\n    if (cell.styleIndex !== undefined) {\n      return selfCloseElement(\"c\", attrsRaw(cellAttrs));\n    }\n    return \"\";\n  }\n\n  // Rich text value (RichTextOptions)\n  if (typeof value === \"object\" && !(value instanceof Date)) {\n    if (sharedStrings) {\n      cellAttrs.t = \"s\";\n      const idx = sharedStrings.registerRich(value);\n      return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;\n    }\n    cellAttrs.t = \"inlineStr\";\n    return `<c${attrsRaw(cellAttrs)}><is>${buildRstXml(value)}</is></c>`;\n  }\n\n  if (typeof value === \"string\") {\n    if (sharedStrings) {\n      cellAttrs.t = \"s\";\n      const idx = sharedStrings.register(value);\n      return `<c${attrsRaw(cellAttrs)}><v>${idx}</v></c>`;\n    }\n    cellAttrs.t = \"inlineStr\";\n    return `<c${attrsRaw(cellAttrs)}><is><t>${escapeXml(value)}</t></is></c>`;\n  }\n\n  if (typeof value === \"number\") {\n    return `<c${attrsRaw(cellAttrs)}><v>${value}</v></c>`;\n  }\n\n  if (typeof value === \"boolean\") {\n    cellAttrs.t = \"b\";\n    return `<c${attrsRaw(cellAttrs)}><v>${value ? 1 : 0}</v></c>`;\n  }\n\n  if (value instanceof Date) {\n    const serial = dateToSerialNumber(value);\n    return `<c${attrsRaw(cellAttrs)}><v>${serial}</v></c>`;\n  }\n\n  return \"\";\n}\n\nfunction defaultCellRef(row: number, col: number): string {\n  return columnToLetter(col) + row;\n}\n\nfunction columnToLetter(col: number): string {\n  let result = \"\";\n  let n = col;\n  while (n > 0) {\n    const remainder = (n - 1) % 26;\n    result = String.fromCharCode(65 + remainder) + result;\n    n = Math.floor((n - 1) / 26);\n  }\n  return result;\n}\n\nfunction dateToSerialNumber(date: Date): number {\n  const epoch = new Date(1899, 11, 30);\n  const msPerDay = 86400000;\n  return (date.getTime() - epoch.getTime()) / msPerDay;\n}\n\n// ── Parse helpers ──\n\nfunction parseCfvo(el: XmlElement): CfvoOptions {\n  const result: CfvoOptions = { type: (attr(el, \"type\") ?? \"num\") as CfvoType };\n  const val = attr(el, \"val\");\n  if (val !== undefined) result.val = isNaN(Number(val)) ? val : Number(val);\n  if (attr(el, \"gte\") === \"0\") result.gte = false;\n  return result;\n}\n\nfunction parseCellRef(ref: string): { row: number; col: number } | undefined {\n  const match = ref.match(/^([A-Z]+)(\\d+)$/);\n  if (!match) return undefined;\n  const colStr = match[1] ?? \"\";\n  const row = parseInt(match[2] ?? \"0\", 10);\n  let col = 0;\n  for (let i = 0; i < colStr.length; i++) {\n    col = col * 26 + (colStr.charCodeAt(i) - 64);\n  }\n  return { row, col };\n}\n","/**\n * Comments + VML notes descriptor for XLSX.\n *\n * Generates both xl/comments{n}.xml and xl/drawings/vmlDrawing{n}.vml\n * from the same CommentOptions array. Follows PPTX CustomDescriptor pattern.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, attr, textOf } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type {\n  CommentOptions,\n  CommentPropertiesOptions,\n  ObjectAnchorOptions,\n  RichTextOptions,\n  RichTextRunOptions,\n  RichTextRunPropertiesOptions,\n} from \"./worksheet\";\n\n// ── Comments descriptor (xl/comments{n}.xml) ──\n\nexport interface CommentsDocOptions {\n  comments: CommentOptions[];\n}\n\nexport const commentsDesc: CustomDescriptor<CommentsDocOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    if (opts.comments.length === 0) return undefined;\n    const authors = collectAuthors(opts.comments);\n    const p: string[] = [\n      `<comments xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\">`,\n      `<authors>`,\n    ];\n\n    for (const author of authors) {\n      p.push(`<author>${escapeXml(author)}</author>`);\n    }\n\n    p.push(\"</authors><commentList>\");\n\n    for (const entry of opts.comments) {\n      const authorId = authors.indexOf(entry.author);\n      const textXml =\n        typeof entry.text === \"string\"\n          ? `<t>${escapeXml(entry.text)}</t>`\n          : buildRstXml(entry.text);\n      // CT_Comment model is text then commentPr (sml.xsd:290-294).\n      const commentPrXml = entry.commentPr ? buildCommentPrXml(entry.commentPr) : \"\";\n      p.push(\n        `<comment ref=\"${entry.cell}\" authorId=\"${authorId}\"><text>${textXml}</text>${commentPrXml}</comment>`,\n      );\n    }\n\n    p.push(\"</commentList></comments>\");\n    return p.join(\"\");\n  },\n\n  parse(el, _ctx) {\n    const comments: CommentOptions[] = [];\n    const authors: string[] = [];\n\n    const authorsEl = findChild(el, \"authors\");\n    if (authorsEl) {\n      for (const a of authorsEl.elements ?? []) {\n        if (a.name === \"author\") authors.push(textOf(a) ?? \"\");\n      }\n    }\n\n    const listEl = findChild(el, \"commentList\");\n    if (listEl) {\n      for (const c of listEl.elements ?? []) {\n        if (c.name !== \"comment\") continue;\n        const ref = attr(c, \"ref\") ?? \"\";\n        const authorId = Number(attr(c, \"authorId\") ?? 0);\n        const textEl = findChild(c, \"text\");\n        const text = textEl ? parseRst(textEl) : \"\";\n        const commentPrEl = findChild(c, \"commentPr\");\n        const comment: CommentOptions = {\n          cell: ref,\n          author: authors[authorId] ?? \"\",\n          text,\n        };\n        if (commentPrEl) comment.commentPr = parseCommentPr(commentPrEl);\n        comments.push(comment);\n      }\n    }\n\n    return { comments } as CommentsDocOptions;\n  },\n};\n\n// ── VML notes descriptor (xl/drawings/vmlDrawing{n}.vml) ──\n\nexport const vmlNotesDesc: CustomDescriptor<CommentsDocOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    if (opts.comments.length === 0) return undefined;\n\n    const p: string[] = [\n      '<xml xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\">',\n      '<o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout>',\n      '<v:shapetype id=\"_x0000_t202\" coordsize=\"21600,21600\" o:spt=\"202\" path=\"m,l,21600r21600,l21600,xe\">',\n      '<v:stroke joinstyle=\"miter\"/>',\n      '<v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>',\n      \"</v:shapetype>\",\n    ];\n\n    for (const [i, c] of opts.comments.entries()) {\n      const { col, row } = cellRefToVmlCoords(c.cell);\n      const anchor = `${col}, 0, ${row}, 0, ${col + 2}, 0, ${row + 2}, 0`;\n      p.push(\n        `<v:shape id=\"_x0000_s${1025 + i}\" type=\"#_x0000_t202\" ` +\n          `style=\"position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;` +\n          `z-index:1;visibility:hidden\" fillcolor=\"infoBackground [80]\" strokecolor=\"none [81]\" o:insetmode=\"auto\">`,\n        `<v:fill color2=\"infoBackground [80]\"/>`,\n        `<v:shadow color=\"none [81]\" obscured=\"t\"/>`,\n        `<v:path o:connecttype=\"none\"/>`,\n        `<v:textbox style=\"mso-direction-alt:auto\"><div style=\"text-align:left\"></div></v:textbox>`,\n        `<x:ClientData ObjectType=\"Note\"><x:MoveWithCells/><x:SizeWithCells/>`,\n        `<x:Anchor>${anchor}</x:Anchor>`,\n        `<x:AutoFill>False</x:AutoFill>`,\n        `<x:Row>${row}</x:Row>`,\n        `<x:Column>${col}</x:Column>`,\n        `</x:ClientData>`,\n        `</v:shape>`,\n      );\n    }\n\n    p.push(\"</xml>\");\n    return p.join(\"\");\n  },\n\n  parse(_el, _ctx) {\n    // VML parsing is not commonly needed — return empty\n    return { comments: [] } as CommentsDocOptions;\n  },\n};\n\n// ── Helpers ──\n\nfunction collectAuthors(comments: CommentOptions[]): string[] {\n  const seen = new Set<string>();\n  const result: string[] = [];\n  for (const entry of comments) {\n    if (!seen.has(entry.author)) {\n      seen.add(entry.author);\n      result.push(entry.author);\n    }\n  }\n  return result.length > 0 ? result : [\"\"];\n}\n\n// ── Comment properties (CT_CommentPr) helpers ──\n\n/** Serialize CT_CommentPr. anchor is required (CT_ObjectAnchor), defaults to empty. */\nfunction buildCommentPrXml(pr: CommentPropertiesOptions): string {\n  const attrs: string[] = [];\n  if (pr.locked !== undefined) attrs.push(`locked=\"${pr.locked ? 1 : 0}\"`);\n  if (pr.defaultSize !== undefined) attrs.push(`defaultSize=\"${pr.defaultSize ? 1 : 0}\"`);\n  if (pr.print !== undefined) attrs.push(`print=\"${pr.print ? 1 : 0}\"`);\n  if (pr.disabled !== undefined) attrs.push(`disabled=\"${pr.disabled ? 1 : 0}\"`);\n  if (pr.autoFill !== undefined) attrs.push(`autoFill=\"${pr.autoFill ? 1 : 0}\"`);\n  if (pr.autoLine !== undefined) attrs.push(`autoLine=\"${pr.autoLine ? 1 : 0}\"`);\n  if (pr.altText !== undefined) attrs.push(`altText=\"${escapeXml(pr.altText)}\"`);\n  if (pr.textHAlign !== undefined) attrs.push(`textHAlign=\"${pr.textHAlign}\"`);\n  if (pr.textVAlign !== undefined) attrs.push(`textVAlign=\"${pr.textVAlign}\"`);\n  if (pr.lockText !== undefined) attrs.push(`lockText=\"${pr.lockText ? 1 : 0}\"`);\n  if (pr.justLastX !== undefined) attrs.push(`justLastX=\"${pr.justLastX ? 1 : 0}\"`);\n  if (pr.autoScale !== undefined) attrs.push(`autoScale=\"${pr.autoScale ? 1 : 0}\"`);\n  return `<commentPr ${attrs.join(\" \")}>${buildAnchorXml(pr.anchor)}</commentPr>`;\n}\n\n/** Serialize CT_ObjectAnchor. from/to/ext are optional in the XSD; attributes required. */\nfunction buildAnchorXml(anchor: ObjectAnchorOptions | undefined): string {\n  const moveWithCells = anchor?.moveWithCells ? 1 : 0;\n  const sizeWithCells = anchor?.sizeWithCells ? 1 : 0;\n  return `<xdr:anchor moveWithCells=\"${moveWithCells}\" sizeWithCells=\"${sizeWithCells}\"/>`;\n}\n\nfunction parseCommentPr(el: XmlElement): CommentPropertiesOptions {\n  const pr: CommentPropertiesOptions = {};\n  const locked = attr(el, \"locked\");\n  if (locked !== undefined) pr.locked = locked === \"1\";\n  const defaultSize = attr(el, \"defaultSize\");\n  if (defaultSize !== undefined) pr.defaultSize = defaultSize === \"1\";\n  const print = attr(el, \"print\");\n  if (print !== undefined) pr.print = print === \"1\";\n  const disabled = attr(el, \"disabled\");\n  if (disabled !== undefined) pr.disabled = disabled === \"1\";\n  const autoFill = attr(el, \"autoFill\");\n  if (autoFill !== undefined) pr.autoFill = autoFill === \"1\";\n  const autoLine = attr(el, \"autoLine\");\n  if (autoLine !== undefined) pr.autoLine = autoLine === \"1\";\n  const altText = attr(el, \"altText\");\n  if (altText !== undefined) pr.altText = altText;\n  const textHAlign = attr(el, \"textHAlign\");\n  if (textHAlign !== undefined)\n    pr.textHAlign = textHAlign as CommentPropertiesOptions[\"textHAlign\"];\n  const textVAlign = attr(el, \"textVAlign\");\n  if (textVAlign !== undefined)\n    pr.textVAlign = textVAlign as CommentPropertiesOptions[\"textVAlign\"];\n  const lockText = attr(el, \"lockText\");\n  if (lockText !== undefined) pr.lockText = lockText === \"1\";\n  const justLastX = attr(el, \"justLastX\");\n  if (justLastX !== undefined) pr.justLastX = justLastX === \"1\";\n  const autoScale = attr(el, \"autoScale\");\n  if (autoScale !== undefined) pr.autoScale = autoScale === \"1\";\n  const anchorEl = findChild(el, \"xdr:anchor\");\n  if (anchorEl) pr.anchor = parseAnchor(anchorEl);\n  return pr;\n}\n\nfunction parseAnchor(el: XmlElement): ObjectAnchorOptions {\n  return {\n    moveWithCells: attr(el, \"moveWithCells\") === \"1\",\n    sizeWithCells: attr(el, \"sizeWithCells\") === \"1\",\n  };\n}\n\n// VML anchors use 0-based column/row; cell refs are 1-based uppercase letters + digits.\nfunction cellRefToVmlCoords(ref: string): { col: number; row: number } {\n  let i = 0;\n  while (i < ref.length && ref.charCodeAt(i) >= 65 && ref.charCodeAt(i) <= 90) i++;\n  let col = 0;\n  for (let j = 0; j < i; j++) col = col * 26 + (ref.charCodeAt(j) - 64);\n  return { col: col - 1, row: parseInt(ref.slice(i), 10) - 1 };\n}\n\n/** Build rich text (CT_Rst) XML from runs. */\nfunction buildRstXml(rst: RichTextOptions): string {\n  const runs = rst.runs ?? [];\n  const parts: string[] = [];\n  for (const run of runs) {\n    const props = run.properties;\n    if (!props) {\n      parts.push(`<r><t>${escapeXml(run.text)}</t></r>`);\n      continue;\n    }\n    const rPr: string[] = [];\n    if (props.bold) rPr.push(\"<b/>\");\n    if (props.italic) rPr.push(\"<i/>\");\n    if (props.underline) rPr.push(`<u val=\"${props.underline}\"/>`);\n    if (props.strike) rPr.push(\"<strike/>\");\n    if (props.size) rPr.push(`<sz val=\"${props.size}\"/>`);\n    if (props.color) rPr.push(`<color rgb=\"${props.color}\"/>`);\n    if (props.font) rPr.push(`<rFont val=\"${props.font}\"/>`);\n    const rPrXml = rPr.length ? `<rPr>${rPr.join(\"\")}</rPr>` : \"\";\n    parts.push(`<r>${rPrXml}<t>${escapeXml(run.text)}</t></r>`);\n  }\n  return parts.join(\"\");\n}\n\n/** Parse rich text element into a plain string or rich runs. */\nfunction parseRst(textEl: XmlElement): string | RichTextOptions {\n  const runs: RichTextRunOptions[] = [];\n  const parts: string[] = [];\n  let hasRuns = false;\n  for (const child of textEl.elements ?? []) {\n    if (child.name === \"t\") {\n      parts.push(textOf(child) ?? \"\");\n    } else if (child.name === \"r\") {\n      hasRuns = true;\n      const t = findChild(child, \"t\");\n      const run: RichTextRunOptions = { text: t ? (textOf(t) ?? \"\") : \"\" };\n      const rPr = findChild(child, \"rPr\");\n      if (rPr) {\n        const props: RichTextRunPropertiesOptions = {};\n        if (findChild(rPr, \"b\")) props.bold = true;\n        if (findChild(rPr, \"i\")) props.italic = true;\n        const uEl = findChild(rPr, \"u\");\n        if (uEl)\n          props.underline =\n            (attr(uEl, \"val\") as RichTextRunPropertiesOptions[\"underline\"]) ?? \"single\";\n        if (findChild(rPr, \"strike\")) props.strike = true;\n        const szEl = findChild(rPr, \"sz\");\n        if (szEl) {\n          const sz = Number(attr(szEl, \"val\"));\n          if (!Number.isNaN(sz)) props.size = sz;\n        }\n        const colorEl = findChild(rPr, \"color\");\n        if (colorEl && attr(colorEl, \"rgb\")) props.color = attr(colorEl, \"rgb\");\n        const rFontEl = findChild(rPr, \"rFont\");\n        if (rFontEl && attr(rFontEl, \"val\")) props.font = attr(rFontEl, \"val\");\n        run.properties = props;\n      }\n      runs.push(run);\n    }\n  }\n  if (hasRuns) return { runs };\n  return parts.join(\"\");\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,YACd,IACQ;CACR,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,QAAkB,CAAC;CACzB,IAAI,GAAG,MAAM,MAAM,KAAK,eAAe,UAAU,GAAG,IAAI,EAAE,IAAI;CAC9D,IAAI,GAAG,YAAY,KAAA,GAAW,MAAM,KAAK,iBAAiB,GAAG,QAAQ,IAAI;CACzE,IAAI,GAAG,WAAW,KAAA,GAAW,MAAM,KAAK,gBAAgB,GAAG,OAAO,IAAI;CACtE,IAAI,GAAG,MAA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