@office-open/docx 0.10.9 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/{context-CAYk5WLu.mjs → context-nyQP2Fkk.mjs} +21 -5
- package/dist/context-nyQP2Fkk.mjs.map +1 -0
- package/dist/{core-properties-i25gKEDT.d.mts → core-properties-CIG9ZnsW.d.mts} +22 -2
- package/dist/core-properties-CIG9ZnsW.d.mts.map +1 -0
- package/dist/{generate-Di_7M9eJ.mjs → generate-CG1wp4pb.mjs} +41 -37
- package/dist/generate-CG1wp4pb.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -73
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-DPBWKO12.mjs → parse-IeJ0NXYz.mjs} +4 -7
- package/dist/{parse-DPBWKO12.mjs.map → parse-IeJ0NXYz.mjs.map} +1 -1
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/{parts-CATV83XR.mjs → parts-D0KoDfg7.mjs} +355 -110
- package/dist/parts-D0KoDfg7.mjs.map +1 -0
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-CAYk5WLu.mjs.map +0 -1
- package/dist/core-properties-i25gKEDT.d.mts.map +0 -1
- package/dist/generate-Di_7M9eJ.mjs.map +0 -1
- package/dist/parts-CATV83XR.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parts-CATV83XR.mjs","names":["createImageData","xmlChildren","createImageData","parseShading","onOff","cnfStyleStr","xmlChildren","createWrapPolygon","readOnOff","readNum","BORDER_STYLES","THEME_COLORS","fillDesc","outlineDesc","effectListDesc","customGeometryDesc","presetGeometryDesc","md","onOff","NS","NS"],"sources":["../src/parts/paragraph/formatting/alignment.ts","../src/parts/paragraph/formatting/spacing.ts","../src/parts/paragraph/formatting/style.ts","../src/parts/paragraph/properties.ts","../src/parts/paragraph/run/run.ts","../src/parts/paragraph/run/properties.ts","../src/shared/media/media.ts","../src/parts/paragraph/run/image-run.ts","../src/parts/drawing/inline/graphic/graphic-data/wps/body-properties.ts","../src/parts/paragraph/run/underline.ts","../src/parts/paragraph/run/emphasis-mark.ts","../src/parts/paragraph/run/positional-tab.ts","../src/parts/paragraph/run/ruby.ts","../src/parts/paragraph/run/form-field.ts","../src/parts/paragraph/run/proof-error.ts","../src/parts/table/table-cell/table-cell-components.ts","../src/parts/table/table-properties/table-float-properties.ts","../src/parts/table/table-properties/table-layout.ts","../src/shared/border.ts","../src/parts/table/table-properties/table-borders.ts","../src/parts/table/table-width.ts","../src/parts/object/object-element.ts","../src/util/stringify-element.ts","../src/parts/paragraph/run/run-parse.ts","../src/parts/paragraph/stringify.ts","../src/parts/bodychildren.ts","../src/parts/drawing/text-wrap/text-wrapping.ts","../src/parts/drawing/text-wrap/wrap-tight.ts","../src/parts/drawing/text-wrap/wrap-through.ts","../src/shared/constants.ts","../src/parts/drawing/floating/floating-position.ts","../src/parts/drawing/floating/horizontal-position.ts","../src/parts/drawing/floating/vertical-position.ts","../src/parts/document/body/section-properties/properties/page-number.ts","../src/parts/document/body/section-properties/properties/page-size.ts","../src/parts/document/body/section-properties/properties/page-text-direction.ts","../src/parts/document/body/section-properties/section-properties.ts","../src/parts/document/body/section-properties/descriptor.ts","../src/parts/fonts/font-wrapper.ts","../src/parts/sdt/sdt-parse.ts","../src/parts/table-of-contents/descriptor.ts","../src/parts/textbox/shape/shape.ts","../src/parts/paragraph/math/stringify.ts","../src/util/replace-media-placeholders.ts","../src/body.ts","../src/parts/drawing/drawing-parse.ts","../src/parts/drawing/descriptor.ts","../src/parts/paragraph/run/field.ts","../src/parts/inline.ts","../src/parts/table/stringify.ts","../src/parts/table/descriptor.ts","../src/parts/numbering/level.ts","../src/parts/numbering/numbering.ts","../src/parts/document/document-attributes.ts","../src/parts/document/body/section-properties/properties/doc-grid.ts","../src/parts/document/body/section-properties/properties/page-borders.ts","../src/parts/document/body/section-properties/properties/page-margin.ts","../src/parts/document/body/section-properties/properties/line-number.ts","../src/parts/document/body/section-properties/properties/section-type.ts","../src/parts/document/body/section-properties/properties/header-footer-reference.ts","../src/parts/styles/factory.ts","../src/parts/styles/styles.ts","../src/parts/settings/descriptor.ts","../src/parts/table-of-contents/table-of-contents-properties.ts","../src/parts/table-of-contents/sdt-properties.ts","../src/parts/table-of-contents/toc-parse.ts","../src/parts/footnotes/descriptor.ts","../src/parts/endnotes/descriptor.ts","../src/parts/perm-start.ts","../src/parts/fonts/font.ts","../src/parts/fonts/descriptor.ts","../src/parts/bibliography.ts","../src/parts/glossary-document.ts","../src/parts/comments.ts","../src/parts/contenttypes.ts","../src/parts/relationships.ts","../src/parts/core-properties.ts","../src/parts/web-settings.ts"],"sourcesContent":["/**\n * Paragraph and table alignment module for WordprocessingML documents.\n *\n * This module provides justification (alignment) options for paragraphs and tables.\n *\n * Reference: http://officeopenxml.com/WPalignment.php\n *\n * @see http://officeopenxml.com/WPtableAlignment.php\n * @see http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html\n *\n * @module\n */\n/**\n * Paragraph justification (alignment) types.\n *\n * Specifies the horizontal alignment of text within a paragraph.\n *\n * Reference: http://officeopenxml.com/WPalignment.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Jc\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"start\"/>\n * <xsd:enumeration value=\"center\"/>\n * <xsd:enumeration value=\"end\"/>\n * <xsd:enumeration value=\"both\"/>\n * <xsd:enumeration value=\"mediumKashida\"/>\n * <xsd:enumeration value=\"distribute\"/>\n * <xsd:enumeration value=\"numTab\"/>\n * <xsd:enumeration value=\"highKashida\"/>\n * <xsd:enumeration value=\"lowKashida\"/>\n * <xsd:enumeration value=\"thaiDistribute\"/>\n * <xsd:enumeration value=\"left\"/>\n * <xsd:enumeration value=\"right\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const AlignmentType = {\n /** Align Start */\n START: \"start\",\n /** Align Center */\n CENTER: \"center\",\n /** End */\n END: \"end\",\n /** Justified */\n BOTH: \"both\",\n /** Medium Kashida Length */\n MEDIUM_KASHIDA: \"mediumKashida\",\n /** Distribute All Characters Equally */\n DISTRIBUTE: \"distribute\",\n /** Align to List Tab */\n NUM_TAB: \"numTab\",\n /** Widest Kashida Length */\n HIGH_KASHIDA: \"highKashida\",\n /** Low Kashida Length */\n LOW_KASHIDA: \"lowKashida\",\n /** Thai Language Justification */\n THAI_DISTRIBUTE: \"thaiDistribute\",\n /** Align Left */\n LEFT: \"left\",\n /** Align Right */\n RIGHT: \"right\",\n /** Justified */\n JUSTIFIED: \"both\",\n} as const;\n","/**\n * Paragraph spacing module for WordprocessingML documents.\n *\n * This module provides spacing options for paragraphs including space before,\n * space after, and line spacing.\n *\n * Reference: http://officeopenxml.com/WPspacing.php\n *\n * @module\n */\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\n\n/**\n * Line spacing rule types.\n *\n * Specifies how the line height is calculated.\n *\n * @publicApi\n */\nexport const LineRuleType = {\n /** Line spacing is at least the specified value */\n AT_LEAST: \"atLeast\",\n /** Line spacing is exactly the specified value */\n EXACTLY: \"exactly\",\n /** Line spacing is exactly the specified value (alias for EXACTLY) */\n EXACT: \"exact\",\n /** Line spacing is automatically determined based on content */\n AUTO: \"auto\",\n} as const;\n\n/**\n * Properties for configuring paragraph spacing.\n *\n * All values are in twips (twentieths of a point) unless otherwise specified.\n */\nexport interface SpacingProperties {\n /** Spacing after the paragraph in twips or as a PositiveUniversalMeasure */\n after?: number | PositiveUniversalMeasure;\n /** Spacing before the paragraph in twips or as a PositiveUniversalMeasure */\n before?: number | PositiveUniversalMeasure;\n /** Line spacing value in twips or as a PositiveUniversalMeasure (depends on lineRule) */\n line?: number | PositiveUniversalMeasure;\n /** How to interpret the line spacing value */\n lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];\n /** Use automatic spacing before the paragraph */\n beforeAutoSpacing?: boolean;\n /** Use automatic spacing after the paragraph */\n afterAutoSpacing?: boolean;\n /** Spacing before the paragraph in line units */\n beforeLines?: number;\n /** Spacing after the paragraph in line units */\n afterLines?: number;\n}\n","/**\n * Paragraph style module for WordprocessingML documents.\n *\n * This module provides paragraph style references including heading levels.\n *\n * @module\n */\n/**\n * Built-in heading level styles.\n *\n * These are the standard heading styles available in Word documents.\n *\n * @publicApi\n */\nexport const HeadingLevel = {\n /** Heading 1 style */\n HEADING_1: \"Heading1\",\n /** Heading 2 style */\n HEADING_2: \"Heading2\",\n /** Heading 3 style */\n HEADING_3: \"Heading3\",\n /** Heading 4 style */\n HEADING_4: \"Heading4\",\n /** Heading 5 style */\n HEADING_5: \"Heading5\",\n /** Heading 6 style */\n HEADING_6: \"Heading6\",\n /** Title style */\n TITLE: \"Title\",\n} as const;\n","import type { ShadingAttributesProperties } from \"@shared/shading\";\n/**\n * Paragraph properties types for WordprocessingML documents.\n *\n * Reference: http://officeopenxml.com/WPparagraphProperties.php\n *\n * @module\n */\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { AlignmentType } from \"./formatting/alignment\";\nimport type { BordersOptions } from \"./formatting/border\";\nimport type { CnfConditionalOptions } from \"./formatting/cnf-style\";\nimport type { IndentAttributesProperties } from \"./formatting/indent\";\nimport type { SpacingProperties } from \"./formatting/spacing\";\nimport type { HeadingLevel } from \"./formatting/style\";\nimport type { TabStopDefinition } from \"./formatting/tab-stop\";\nimport type { FrameOptions } from \"./frame/frame-properties\";\nimport type { ParagraphRunOptions } from \"./run/run\";\n\n/**\n * Vertical text alignment types for paragraphs.\n *\n * Specifies the vertical alignment of text within the paragraph.\n *\n * @publicApi\n */\nexport const TextAlignmentType = {\n /** Align text to the top */\n TOP: \"top\",\n /** Align text to the center */\n CENTER: \"center\",\n /** Align text to the baseline */\n BASELINE: \"baseline\",\n /** Align text to the bottom */\n BOTTOM: \"bottom\",\n /** Automatically determine vertical alignment */\n AUTO: \"auto\",\n} as const;\n\n/**\n * Textbox tight wrap types for paragraphs.\n *\n * Specifies how tightly text wraps around a textbox.\n *\n * @publicApi\n */\nexport const TextboxTightWrapType = {\n /** No tight wrapping */\n NONE: \"none\",\n /** Tight wrap on all lines */\n ALL_LINES: \"allLines\",\n /** Tight wrap on first and last lines */\n FIRST_AND_LAST_LINE: \"firstAndLastLine\",\n /** Tight wrap on first line only */\n FIRST_LINE_ONLY: \"firstLineOnly\",\n /** Tight wrap on last line only */\n LAST_LINE_ONLY: \"lastLineOnly\",\n} as const;\n\n/**\n * Paragraph style properties for numbering levels.\n *\n * These properties are used when defining paragraph styles within numbering level definitions.\n */\nexport interface LevelParagraphStylePropertiesOptions {\n /** Paragraph text alignment (left, right, center, justified, etc.) */\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n /** Whether to render text right-to-left for bidirectional languages */\n bidirectional?: boolean;\n /** Whether to insert a page break before this paragraph */\n pageBreakBefore?: boolean;\n /** Custom tab stop positions and alignments */\n tabStops?: TabStopDefinition[];\n /** Whether to display a horizontal line (thematic break) below the paragraph */\n thematicBreak?: boolean;\n /** Whether to prevent single lines at top/bottom of page (widow/orphan control), defaults to true */\n widowControl?: boolean;\n /** Whether to ignore spacing before/after when adjacent paragraphs have the same style */\n contextualSpacing?: boolean;\n /** Position in twips for a right-aligned tab stop */\n rightTabStop?: number;\n /** Position in twips for a left-aligned tab stop */\n leftTabStop?: number;\n /** Indentation settings for the paragraph */\n indent?: IndentAttributesProperties;\n /** Spacing before/after paragraph and between lines */\n spacing?: SpacingProperties;\n /**\n * Specifies that the paragraph (or at least part of it) should be rendered on the same page as the next paragraph when possible. If multiple paragraphs are to be kept together but they exceed a page, then the set of paragraphs begin on a new page and page breaks are used thereafter as needed.\n */\n keepNext?: boolean;\n /**\n * Specifies that all lines of the paragraph are to be kept on a single page when possible.\n */\n keepLines?: boolean;\n /** Frame properties for positioning the paragraph */\n frame?: FrameOptions;\n /** Whether to suppress line numbers for this paragraph */\n suppressLineNumbers?: boolean;\n /** Whether to allow word wrapping */\n wordWrap?: boolean;\n /** Whether to allow punctuation to extend beyond text margins */\n overflowPunctuation?: boolean;\n /**\n * This element specifies whether inter-character spacing shall automatically be adjusted between regions of numbers and regions of East Asian text in the current paragraph. These regions shall be determined by the Unicode character values of the text content within the paragraph.\n * This only works in Microsoft Word. It is not part of the ECMA-376 OOXML standard.\n */\n autoSpaceEastAsianText?: boolean;\n /** Whether to prevent text frames from overlapping */\n suppressOverlap?: boolean;\n /** Whether to disable automatic hyphenation for this paragraph */\n suppressAutoHyphens?: boolean;\n /** Whether to automatically adjust right indent for document grid */\n adjustRightInd?: boolean;\n /** Whether to snap the current paragraph to the document grid */\n snapToGrid?: boolean;\n /** Whether to swap left and right indent positions on odd pages for mirrored layouts */\n mirrorIndents?: boolean;\n /** Whether to use Kinsoku forbidden character overflow rules */\n kinsoku?: boolean;\n /** Whether to compress punctuation at the start of a line */\n topLinePunct?: boolean;\n /** Whether to automatically add space between East Asian and Latin text */\n autoSpaceDE?: boolean;\n /** Vertical text alignment within the paragraph */\n textAlignment?: (typeof TextAlignmentType)[keyof typeof TextAlignmentType];\n /** Textbox tight wrap setting */\n textboxTightWrap?: (typeof TextboxTightWrapType)[keyof typeof TextboxTightWrapType];\n /** Text direction for the paragraph (lr, rl, tb, tbV, rlV, lrV) */\n textDirection?: \"lr\" | \"rl\" | \"tb\" | \"tbV\" | \"rlV\" | \"lrV\";\n /** Outline level for table of contents and document outline (0-9) */\n outlineLevel?: number;\n /** HTML div ID reference */\n divId?: number;\n /** Conditional formatting style for table rows/cells */\n cnfStyle?: CnfConditionalOptions;\n}\n\n/**\n * Paragraph style properties options.\n *\n * These properties are used when defining paragraph styles and include\n * border, shading, and numbering options in addition to level properties.\n */\nexport type ParagraphStylePropertiesOptions = {\n /** Border settings for the paragraph */\n border?: BordersOptions;\n /** Background shading/fill color for the paragraph */\n shading?: ShadingAttributesProperties;\n /** Numbering configuration for lists, or false to remove numbering */\n numbering?:\n | {\n /** Reference ID of the numbering definition to use */\n reference: string;\n /** Level in the numbering hierarchy (0-8) */\n level: number;\n /** Instance number for multiple lists with same reference */\n instance?: number;\n /** Whether this is a custom numbering definition */\n custom?: boolean;\n /** Numbering change tracking (CT_TrackChangeNumbering) */\n numberingChange?: {\n /** Original numbering value */\n original: string;\n /** Revision ID */\n id: string;\n /** Author of the change */\n author: string;\n /** Date of the change */\n date?: string;\n };\n }\n | false;\n} & LevelParagraphStylePropertiesOptions;\n\nexport type ParagraphPropertiesOptionsBase = {\n /** Heading level (Heading1, Heading2, etc.) - applies predefined heading style */\n heading?: (typeof HeadingLevel)[keyof typeof HeadingLevel];\n /** Style ID to apply to this paragraph */\n style?: string;\n /** Bullet list configuration */\n bullet?: {\n /** Indentation level for the bullet (0-8) */\n level: number;\n };\n /**\n * Run properties to apply to all runs in the paragraph.\n * Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference § 17.3.1.29.\n */\n run?: ParagraphRunOptions;\n} & ParagraphStylePropertiesOptions;\n\nexport type ParagraphPropertiesChangeOptions = ChangedAttributesProperties &\n ParagraphPropertiesOptionsBase;\n\n/**\n * Options for configuring paragraph properties.\n *\n * These options control all aspects of paragraph formatting including\n * alignment, spacing, indentation, borders, numbering, and more.\n *\n * Reference: http://officeopenxml.com/WPparagraphProperties.php\n */\nexport type ParagraphPropertiesOptions = {\n revision?: ParagraphPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & ParagraphPropertiesOptionsBase;\n","import type { ObjectElementOptions } from \"@parts/object\";\n\n/**\n * Run module for WordprocessingML documents.\n *\n * A run is a region of text with a common set of properties. It is the primary\n * unit of inline content in a paragraph.\n *\n * Reference: http://officeopenxml.com/WPtext.php\n *\n * @module\n */\nimport type {\n AnnotationReference,\n CarriageReturn,\n ContinuationSeparator,\n DayLong,\n DayShort,\n EndnoteReference,\n FootnoteReferenceElement,\n LastRenderedPageBreak,\n MonthLong,\n MonthShort,\n NoBreakHyphen,\n PageNumberElement,\n Separator,\n SoftHyphen,\n Tab,\n YearLong,\n YearShort,\n} from \"./empty-children\";\nimport type { ParagraphRunPropertiesOptions, RunPropertiesOptions } from \"./properties\";\n\n/** w:br/@w:clear values (ST_BrClear) — clears floating content on the given side(s). */\nexport type BreakClear = \"none\" | \"left\" | \"right\" | \"all\";\n\n/** Options for a line break with optional float-clearing (CT_Br). */\nexport interface BreakOptions {\n /** Number of `<w:br/>` elements (defaults to 1). */\n count?: number;\n /** Clear floating content (w:br/@w:clear). */\n clear?: BreakClear;\n}\n\n/**\n * Serialize a break option (count shorthand or structured with clear) to one or\n * more `<w:br/>` tags.\n */\nexport function breakXml(breakOpt: number | BreakOptions | undefined): string {\n if (!breakOpt) return \"\";\n const count = typeof breakOpt === \"number\" ? breakOpt : (breakOpt.count ?? 1);\n if (count <= 0) return \"\";\n const clear = typeof breakOpt === \"object\" ? breakOpt.clear : undefined;\n const one = clear ? `<w:br w:clear=\"${clear}\"/>` : \"<w:br/>\";\n return count === 1 ? one : one.repeat(count);\n}\n\ninterface RunOptionsBase {\n children?: (\n | (typeof PageNumber)[keyof typeof PageNumber]\n | string\n | AnnotationReference\n | CarriageReturn\n | ContinuationSeparator\n | DayLong\n | DayShort\n | EndnoteReference\n | FootnoteReferenceElement\n | LastRenderedPageBreak\n | MonthLong\n | MonthShort\n | NoBreakHyphen\n | PageNumberElement\n | Separator\n | SoftHyphen\n | Tab\n | YearLong\n | YearShort\n | { object: ObjectElementOptions }\n | Record<string, unknown>\n )[];\n break?: number | BreakOptions;\n text?: string;\n}\n\n/**\n * Options for creating a Run element.\n *\n * The run element specifies a region of text with a common set of properties.\n * The children property can contain various inline content elements.\n *\n * @see {@link Run}\n */\nexport type RunOptions = RunOptionsBase &\n RunPropertiesOptions & {\n /** Revision save ID for the run (w:rsidR, hex string e.g. \"00123456\"). */\n rsid?: string;\n /** Revision save ID for run properties (w:rsidRPr, hex string). */\n runPropertiesRsid?: string;\n /** Revision save ID when run was deleted (w:rsidDel, hex string). */\n deletionRsid?: string;\n };\n\nexport type ParagraphRunOptions = RunOptionsBase & ParagraphRunPropertiesOptions;\n\n/**\n * Constants for page number field types.\n *\n * These values are used to insert dynamic page number fields into a document.\n *\n * Reference: http://officeopenxml.com/WPfields.php\n *\n * @publicApi\n */\nexport const PageNumber = {\n /** Inserts the current page number */\n CURRENT: \"CURRENT\",\n /** Inserts the total number of pages in the document */\n TOTAL_PAGES: \"TOTAL_PAGES\",\n /** Inserts the total number of pages in the current section */\n TOTAL_PAGES_IN_SECTION: \"TOTAL_PAGES_IN_SECTION\",\n /** Inserts the current section number */\n CURRENT_SECTION: \"SECTION\",\n} as const;\n","/**\n * Run properties module for WordprocessingML documents.\n *\n * This module provides the run properties (rPr) element which specifies\n * the formatting applied to a run of text.\n *\n * Reference: https://www.ecma-international.org/wp-content/uploads/ECMA-376-1_5th_edition_december_2016.zip\n * Section 17.3.2.21 (page 297)\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { BorderOptions } from \"@shared/border\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { EastAsianLayoutOptions } from \"./east-asian-layout\";\nimport type { EmphasisMarkType } from \"./emphasis-mark\";\nimport type { ColorOptions } from \"./formatting\";\nimport type { LanguageOptions } from \"./language\";\nimport type { FontAttributesProperties } from \"./run-fonts\";\nimport type { UnderlineType } from \"./underline\";\n\ninterface RunFontReference {\n name: string;\n hint?: string;\n}\n\n/**\n * Text animation effect types.\n *\n * Reference: http://officeopenxml.com/WPtextFormatting.php\n *\n * @publicApi\n */\nexport const TextEffect = {\n /** Blinking background animation */\n BLINK_BACKGROUND: \"blinkBackground\",\n /** Lights animation effect */\n LIGHTS: \"lights\",\n /** Black marching ants animation */\n ANTS_BLACK: \"antsBlack\",\n /** Red marching ants animation */\n ANTS_RED: \"antsRed\",\n /** Shimmer animation effect */\n SHIMMER: \"shimmer\",\n /** Sparkle animation effect */\n SPARKLE: \"sparkle\",\n /** No text effect */\n NONE: \"none\",\n} as const;\n\n/**\n * Highlight color values for text highlighting.\n *\n * Reference: http://officeopenxml.com/WPtextShading.php\n */\nexport const HighlightColor = {\n /** Black highlight */\n BLACK: \"black\",\n /** Blue highlight */\n BLUE: \"blue\",\n /** Cyan highlight */\n CYAN: \"cyan\",\n /** Dark blue highlight */\n DARK_BLUE: \"darkBlue\",\n /** Dark cyan highlight */\n DARK_CYAN: \"darkCyan\",\n /** Dark gray highlight */\n DARK_GRAY: \"darkGray\",\n /** Dark green highlight */\n DARK_GREEN: \"darkGreen\",\n /** Dark magenta highlight */\n DARK_MAGENTA: \"darkMagenta\",\n /** Dark red highlight */\n DARK_RED: \"darkRed\",\n /** Dark yellow highlight */\n DARK_YELLOW: \"darkYellow\",\n /** Green highlight */\n GREEN: \"green\",\n /** Light gray highlight */\n LIGHT_GRAY: \"lightGray\",\n /** Magenta highlight */\n MAGENTA: \"magenta\",\n /** No highlight */\n NONE: \"none\",\n /** Red highlight */\n RED: \"red\",\n /** White highlight */\n WHITE: \"white\",\n /** Yellow highlight */\n YELLOW: \"yellow\",\n} as const;\n\n/**\n * Run style properties options.\n *\n * These properties define the formatting that can be applied to a run of text,\n * including font, size, bold, italic, underline, color, and other character formatting.\n *\n * Reference: http://officeopenxml.com/WPtextFormatting.php\n */\nexport interface RunStylePropertiesOptions {\n noProof?: boolean;\n bold?: boolean;\n boldComplexScript?: boolean;\n italic?: boolean;\n italicComplexScript?: boolean;\n underline?: {\n color?: string;\n type?: (typeof UnderlineType)[keyof typeof UnderlineType];\n };\n effect?: (typeof TextEffect)[keyof typeof TextEffect];\n emphasisMark?: {\n type?: (typeof EmphasisMarkType)[keyof typeof EmphasisMarkType];\n };\n color?: string | ColorOptions;\n kern?: number;\n position?: string;\n /** Font size in points. Internally stored as half-points in XML (×2). */\n size?: number;\n /** Complex-script font size in points (w:szCs). Independent from {@link size}. */\n sizeComplexScript?: number;\n rightToLeft?: boolean;\n smallCaps?: boolean;\n allCaps?: boolean;\n strike?: boolean;\n doubleStrike?: boolean;\n subScript?: boolean;\n superScript?: boolean;\n font?: string | RunFontReference | FontAttributesProperties;\n highlight?: (typeof HighlightColor)[keyof typeof HighlightColor];\n /** Complex-script highlight color (w:highlightCs). Independent from {@link highlight}. */\n highlightComplexScript?: string;\n characterSpacing?: number | UniversalMeasure;\n shading?: ShadingAttributesProperties;\n emboss?: boolean;\n imprint?: boolean;\n revision?: RunPropertiesChangeOptions;\n language?: LanguageOptions;\n border?: BorderOptions;\n snapToGrid?: boolean;\n vanish?: boolean;\n specVanish?: boolean;\n scale?: number;\n math?: boolean;\n outline?: boolean;\n shadow?: boolean;\n webHidden?: boolean;\n fitText?: number;\n complexScript?: boolean;\n eastAsianLayout?: EastAsianLayoutOptions;\n /** Relationship ID for a content part (w:contentPart with r:id) */\n contentPartRId?: string;\n /**\n * Raw XML for w14:* text-effect children (glow/shadow/reflection/props3d/...)\n * located in the EG_RPrBase extension slot at the end of rPr. Low-frequency\n * complex subtrees kept verbatim for round-trip fidelity; the rPr backbone\n * stays structured and editable.\n */\n w14RawXml?: string;\n}\n\n/**\n * Options for configuring run properties.\n *\n * Extends RunStylePropertiesOptions with a style reference.\n */\nexport type RunPropertiesOptions = {\n /** Reference to a character style by name */\n style?: string;\n} & RunStylePropertiesOptions;\n\n/**\n * Options for run properties change tracking.\n *\n * Used for revision tracking when run properties have been modified.\n */\nexport type RunPropertiesChangeOptions = {} & RunPropertiesOptions & ChangedAttributesProperties;\n\nexport type ParagraphRunPropertiesOptions = {\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n} & RunPropertiesOptions;\n","import type { UniversalMeasure } from \"@office-open/core\";\nimport { convertEmuToPixels, convertToEmu } from \"@office-open/core\";\n\n/**\n * Media module for WordprocessingML documents.\n *\n * Provides transformation helpers for embedded media (images). The deduplicated\n * media collection itself ({@link Media}) lives in @office-open/core and is\n * re-exported from this package's index so every format package shares one\n * content-based dedup implementation.\n *\n * @module\n */\nimport type { MediaDataTransformation } from \"./data\";\n\n/**\n * Transformation options for media display.\n *\n * Specifies how an image should be transformed when displayed in the document.\n * Width and height can be specified as numbers (in EMUs) or as universal measures\n * (e.g., \"100mm\", \"2in\").\n */\nexport interface MediaTransformation {\n offset?: {\n top?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n };\n width: number | UniversalMeasure;\n /** Display height in EMUs or universal measure */\n height: number | UniversalMeasure;\n /** Optional flip transformations */\n flip?: {\n /** Whether to flip the image vertically */\n vertical?: boolean;\n /** Whether to flip the image horizontally */\n horizontal?: boolean;\n };\n /** Optional rotation angle in degrees */\n rotation?: number;\n /** Effect extent (wp:effectExtent) in raw EMUs — passed through verbatim. */\n effectExtent?: { l: number; t: number; r: number; b: number };\n}\n\n/**\n * Converts user-facing transformation options (EMU or universal measure) to internal\n * transformation data (pixels + EMUs).\n *\n * @param options - User-facing transformation in EMU or universal measure\n * @returns Internal transformation data with both pixel and EMU values\n */\nexport const createTransformation = (options: MediaTransformation): MediaDataTransformation => {\n const widthEmu = convertToEmu(options.width);\n const heightEmu = convertToEmu(options.height);\n const offsetLeftEmu = convertToEmu(options.offset?.left ?? 0);\n const offsetTopEmu = convertToEmu(options.offset?.top ?? 0);\n return {\n emus: { x: widthEmu, y: heightEmu },\n flip: options.flip,\n offset: {\n emus: { x: offsetLeftEmu, y: offsetTopEmu },\n pixels: {\n x: Math.round(convertEmuToPixels(offsetLeftEmu)),\n y: Math.round(convertEmuToPixels(offsetTopEmu)),\n },\n },\n pixels: {\n x: Math.round(convertEmuToPixels(widthEmu)),\n y: Math.round(convertEmuToPixels(heightEmu)),\n },\n rotation: options.rotation ? options.rotation * 60_000 : undefined,\n ...(options.effectExtent ? { effectExtent: options.effectExtent } : {}),\n };\n};\n","import type { DataType } from \"@office-open/core\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\n/**\n * ImageRun types for WordprocessingML documents.\n *\n * This module provides support for inserting images into documents.\n *\n * Reference: http://officeopenxml.com/drwPicInline.php\n *\n * @module\n */\nimport type { DocPropertiesOptions } from \"@parts/drawing/doc-properties/doc-properties\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type { MediaTransformation } from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { MediaData, NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { Floating } from \"../../drawing\";\nimport type { GraphicFrameLocksOptions } from \"../../drawing/descriptor\";\nimport type { BlipEffectsOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { TileOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"../../drawing/inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"../../drawing/inline/graphic/graphic-data/pic/outline/outline\";\n\n/**\n * Core options for image configuration.\n */\ninterface CoreImageOptions {\n transformation: MediaTransformation;\n floating?: Floating;\n altText?: DocPropertiesOptions;\n outline?: OutlineOptions;\n fill?: FillOptions;\n effects?: EffectListOptions;\n blipEffects?: BlipEffectsOptions;\n sourceRectangle?: SourceRectangleOptions;\n tile?: TileOptions;\n /** Picture non-visual properties (pic:cNvPr) — populated by parse */\n nonVisualProperties?: NonVisualPropertiesOptions;\n /** Structured run properties of the wrapping w:r (round-trip) — emitted before the drawing. */\n runProperties?: RunPropertiesOptions;\n /** Graphic frame locks (wp:cNvGraphicFramePr) for round-trip. */\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n /** Blip rendering hint `a14:useLocalDpi` (round-trip). */\n useLocalDpi?: boolean;\n}\n\ninterface RegularImageOptions {\n type: \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n data: DataType;\n}\n\ninterface SvgMediaOptions {\n type: \"svg\";\n data: DataType;\n /**\n * Required in case the Word processor does not support SVG.\n */\n fallback: RegularImageOptions;\n}\n\n/**\n * Options for creating an ImageRun.\n *\n * @see {@link ImageRun}\n */\nexport type ImageOptions = (RegularImageOptions | SvgMediaOptions) & CoreImageOptions;\n\nexport const createImageData = (\n data: Uint8Array,\n transformation: MediaTransformation,\n key: string,\n sourceRectangle?: SourceRectangleOptions,\n nonVisualProperties?: NonVisualPropertiesOptions,\n): Pick<\n MediaData,\n \"data\" | \"fileName\" | \"transformation\" | \"sourceRectangle\" | \"nonVisualProperties\"\n> => ({\n data,\n fileName: key,\n sourceRectangle,\n nonVisualProperties,\n transformation: createTransformation(transformation),\n});\n","/**\n * Text body properties for DrawingML shapes.\n *\n * Provides CT_TextBodyProperties — defines how text is laid out within a shape,\n * including margins, alignment, autofit, vertical text, overflow, columns, and 3D.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TextBodyProperties\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport { convertToEmu } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { scene3DDesc, shape3DDesc } from \"@office-open/core/drawingml\";\nimport { attr, attrBool, attrMeasure, attrNum, element, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { Scene3DOptions } from \"../pic/three-d/scene-3d\";\nimport { createScene3D } from \"../pic/three-d/scene-3d\";\nimport type { Shape3DOptions } from \"../pic/three-d/shape-3d\";\nimport { createShape3D } from \"../pic/three-d/shape-3d\";\n\n// ─── Constants ──────────────────────────────────────────────────────────────\n\n/**\n * Text anchoring type (ST_TextAnchoringType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextAnchoringType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"t\"/>\n * <xsd:enumeration value=\"ctr\"/>\n * <xsd:enumeration value=\"b\"/>\n * <xsd:enumeration value=\"just\"/>\n * <xsd:enumeration value=\"dist\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport enum VerticalAnchor {\n TOP = \"t\",\n CENTER = \"ctr\",\n BOTTOM = \"b\",\n JUSTIFY = \"just\",\n DISTRIBUTED = \"dist\",\n}\n\n/**\n * Text vertical overflow type (ST_TextVertOverflowType).\n */\nexport const TextVertOverflowType = {\n OVERFLOW: \"overflow\",\n ELLIPSIS: \"ellipsis\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text horizontal overflow type (ST_TextHorzOverflowType).\n */\nexport const TextHorzOverflowType = {\n OVERFLOW: \"overflow\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text vertical type (ST_TextVerticalType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextVerticalType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"horz\"/>\n * <xsd:enumeration value=\"vert\"/>\n * <xsd:enumeration value=\"vert270\"/>\n * <xsd:enumeration value=\"wordArtVert\"/>\n * <xsd:enumeration value=\"eaVert\"/>\n * <xsd:enumeration value=\"mongolianVert\"/>\n * <xsd:enumeration value=\"wordArtVertRtl\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const TextVerticalType = {\n HORIZONTAL: \"horz\",\n VERTICAL: \"vert\",\n VERTICAL_270: \"vert270\",\n WORD_ART_VERTICAL: \"wordArtVert\",\n EAST_ASIAN_VERTICAL: \"eaVert\",\n MONGOLIAN_VERTICAL: \"mongolianVert\",\n WORD_ART_VERTICAL_RTL: \"wordArtVertRtl\",\n} as const;\n\n/**\n * Text body wrapping type (ST_TextWrappingType).\n *\n * This is different from text wrapping around shapes (ST_WrapText).\n */\nexport const TextBodyWrappingType = {\n NONE: \"none\",\n SQUARE: \"square\",\n} as const;\n\n// ─── Sub-element Options ────────────────────────────────────────────────────\n\n/**\n * Normal autofit options (CT_TextNormalAutofit).\n *\n * Scales text and line spacing to fit the shape.\n */\nexport interface NormalAutofitOptions {\n /** Font scale percentage (e.g., 100000 = 100%) */\n fontScale?: number;\n /** Line spacing reduction percentage */\n lnSpcReduction?: number;\n}\n\n/**\n * Preset text warp options (CT_PresetTextShape).\n */\nexport interface PresetTextShapeOptions {\n /** Preset shape type (e.g., \"textArchUp\", \"textCircle\") */\n preset: string;\n /** Optional adjustment values */\n adjustments?: { name: string; formula: string }[];\n}\n\n/**\n * Flat text options (CT_FlatText).\n */\nexport interface FlatTextOptions {\n /** Z-offset in EMUs */\n z?: number;\n}\n\n// ─── Main Options ───────────────────────────────────────────────────────────\n\n/**\n * Options for text body properties (CT_TextBodyProperties).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TextBodyProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"prstTxWarp\" type=\"CT_PresetTextShape\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_TextAutofit\" minOccurs=\"0\"/>\n * <xsd:element name=\"scene3d\" type=\"CT_Scene3D\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_Text3D\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <!-- 19 attributes -->\n * </xsd:complexType>\n * ```\n */\nexport interface BodyPropertiesOptions {\n // ── Attributes ──\n\n /** Text rotation angle in 60,000ths of a degree */\n rotation?: number;\n /** Whether to use spcFirstLastPara behavior */\n spcFirstLastPara?: boolean;\n /** Vertical text overflow behavior */\n vertOverflow?: (typeof TextVertOverflowType)[keyof typeof TextVertOverflowType];\n /** Horizontal text overflow behavior */\n horzOverflow?: (typeof TextHorzOverflowType)[keyof typeof TextHorzOverflowType];\n /** Text vertical direction */\n vert?: (typeof TextVerticalType)[keyof typeof TextVerticalType];\n /** Text wrapping type */\n wrap?: (typeof TextBodyWrappingType)[keyof typeof TextBodyWrappingType];\n /** Left inset in EMUs or universal measure (e.g., \"1cm\", \"0.5in\") */\n lIns?: number | UniversalMeasure;\n /** Top inset in EMUs or universal measure */\n tIns?: number | UniversalMeasure;\n /** Right inset in EMUs or universal measure */\n rIns?: number | UniversalMeasure;\n /** Bottom inset in EMUs or universal measure */\n bIns?: number | UniversalMeasure;\n /** Number of text columns (1-16) */\n numCol?: number;\n /** Spacing between columns in EMUs or universal measure */\n spcCol?: number | UniversalMeasure;\n /** Whether columns are right-to-left */\n rtlCol?: boolean;\n /** Whether text is from WordArt */\n fromWordArt?: boolean;\n /** Text anchor position */\n anchor?: (typeof VerticalAnchor)[keyof typeof VerticalAnchor];\n /** Whether to anchor at center */\n anchorCtr?: boolean;\n /** Whether to force anti-aliasing */\n forceAA?: boolean;\n /** Whether text is upright (default false) */\n upright?: boolean;\n /** Whether to use compatible line spacing */\n compatLnSpc?: boolean;\n\n // ── Convenience aliases (backward compatible) ──\n\n /** Vertical anchor position (alias for `anchor`) */\n verticalAnchor?: VerticalAnchor;\n /** Margins shorthand */\n margins?: {\n top?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n };\n\n // ── Child elements ──\n\n /** Preset text warp shape */\n prstTxWarp?: PresetTextShapeOptions;\n /** Disable autofit (EG_TextAutofit choice) */\n noAutoFit?: boolean;\n /** Normal autofit (EG_TextAutofit choice) */\n normAutofit?: NormalAutofitOptions;\n /** Shape autofit (EG_TextAutofit choice) */\n spAutoFit?: boolean;\n /** 3D scene */\n scene3d?: Scene3DOptions;\n /** 3D shape properties (EG_Text3D choice) */\n sp3d?: Shape3DOptions;\n /** Flat text (EG_Text3D choice) */\n flatTx?: FlatTextOptions;\n}\n\n// ─── Internal Helpers ───────────────────────────────────────────────────────\n\nconst filterAttrs = (\n options: Record<string, unknown>,\n): Record<string, string | number | boolean> | undefined => {\n const attrs: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(options)) {\n if (value !== undefined) {\n attrs[key] = value as string | number | boolean;\n }\n }\n return Object.keys(attrs).length > 0 ? attrs : undefined;\n};\n\n// ─── Preset Text Warp ───────────────────────────────────────────────────────\n\nconst createPresetTextShape = (options: PresetTextShapeOptions): string => {\n const adjChildren: string[] = [];\n if (options.adjustments) {\n for (const adj of options.adjustments) {\n adjChildren.push(`<a:gd name=\"${adj.name}\" fmla=\"${adj.formula}\"/>`);\n }\n }\n\n return element(\n \"a:prstTxWarp\",\n { prst: options.preset },\n adjChildren.length > 0 ? [element(\"a:avLst\", undefined, adjChildren)] : undefined,\n );\n};\n\n// ─── Main Factory ───────────────────────────────────────────────────────────\n\n/**\n * Creates a text body properties element (wps:bodyPr).\n *\n * Supports all 19 CT_TextBodyProperties attributes and all child elements\n * including preset text warp, autofit variants, 3D scene, and text 3D.\n *\n * @example\n * ```typescript\n * // Simple margins and anchor\n * createBodyProperties({\n * margins: { top: 100, bottom: 100, left: 200, right: 200 },\n * verticalAnchor: VerticalAnchor.CENTER,\n * });\n *\n * // Full options with vertical text and autofit\n * createBodyProperties({\n * vert: TextVerticalType.VERTICAL,\n * wrap: TextBodyWrappingType.NONE,\n * normAutofit: { fontScale: 80000 },\n * numCol: 2,\n * anchor: VerticalAnchor.TOP,\n * });\n * ```\n */\nexport const createBodyProperties = (options: BodyPropertiesOptions = {}): string => {\n // Resolve anchor (direct `anchor` takes precedence over `verticalAnchor`)\n const anchor = options.anchor ?? options.verticalAnchor;\n\n // Resolve margins\n const lIns = options.lIns ?? options.margins?.left;\n const tIns = options.tIns ?? options.margins?.top;\n const rIns = options.rIns ?? options.margins?.right;\n const bIns = options.bIns ?? options.margins?.bottom;\n\n const attrs = filterAttrs({\n rot: options.rotation,\n spcFirstLastPara: options.spcFirstLastPara,\n vertOverflow: options.vertOverflow,\n horzOverflow: options.horzOverflow,\n vert: options.vert,\n wrap: options.wrap,\n lIns: lIns !== undefined ? convertToEmu(lIns) : undefined,\n tIns: tIns !== undefined ? convertToEmu(tIns) : undefined,\n rIns: rIns !== undefined ? convertToEmu(rIns) : undefined,\n bIns: bIns !== undefined ? convertToEmu(bIns) : undefined,\n numCol: options.numCol,\n spcCol: options.spcCol !== undefined ? convertToEmu(options.spcCol) : undefined,\n rtlCol: options.rtlCol,\n fromWordArt: options.fromWordArt,\n anchor,\n anchorCtr: options.anchorCtr,\n forceAA: options.forceAA,\n upright: options.upright,\n compatLnSpc: options.compatLnSpc,\n });\n\n // Build children in XSD sequence order\n const children: string[] = [];\n\n // a:prstTxWarp\n if (options.prstTxWarp) {\n children.push(createPresetTextShape(options.prstTxWarp));\n }\n\n // EG_TextAutofit (mutually exclusive)\n if (options.noAutoFit) {\n children.push(`<a:noAutofit/>`);\n } else if (options.normAutofit) {\n const normAttrs = filterAttrs({\n fontScale: options.normAutofit.fontScale,\n lnSpcReduction: options.normAutofit.lnSpcReduction,\n });\n children.push(element(\"a:normAutofit\", normAttrs));\n } else if (options.spAutoFit) {\n children.push(`<a:spAutoFit/>`);\n }\n\n // a:scene3d\n if (options.scene3d) {\n children.push(createScene3D(options.scene3d));\n }\n\n // EG_Text3D (mutually exclusive)\n if (options.sp3d) {\n children.push(createShape3D(options.sp3d));\n } else if (options.flatTx) {\n const flatAttrs = filterAttrs({ z: options.flatTx.z });\n children.push(element(\"a:flatTx\", flatAttrs));\n }\n\n return element(\"wps:bodyPr\", attrs, children.length > 0 ? children : undefined);\n};\n\n// ─── Parse ──────────────────────────────────────────────────────────────────\n\n/**\n * Parse a `wps:bodyPr` element into {@link BodyPropertiesOptions}.\n *\n * Reads the CT_TextBodyProperties attributes and the EG_TextAutofit child\n * (noAutofit/normAutofit/spAutoFit). prstTxWarp/scene3d/text-3D are not yet\n * parsed (later phase).\n */\nexport const parseBodyProperties = (el: Element, ctx: ReadContext): BodyPropertiesOptions => {\n const result: BodyPropertiesOptions = {};\n\n const rotation = attrNum(el, \"rot\");\n if (rotation !== undefined) result.rotation = rotation;\n const spcFirstLastPara = attrBool(el, \"spcFirstLastPara\");\n if (spcFirstLastPara !== undefined) result.spcFirstLastPara = spcFirstLastPara;\n const vertOverflow = attr(el, \"vertOverflow\");\n if (vertOverflow !== undefined)\n result.vertOverflow = vertOverflow as BodyPropertiesOptions[\"vertOverflow\"];\n const horzOverflow = attr(el, \"horzOverflow\");\n if (horzOverflow !== undefined)\n result.horzOverflow = horzOverflow as BodyPropertiesOptions[\"horzOverflow\"];\n const vert = attr(el, \"vert\");\n if (vert !== undefined) result.vert = vert as BodyPropertiesOptions[\"vert\"];\n const wrap = attr(el, \"wrap\");\n if (wrap !== undefined) result.wrap = wrap as BodyPropertiesOptions[\"wrap\"];\n const lIns = attrMeasure(el, \"lIns\");\n if (lIns !== undefined) result.lIns = lIns as number | UniversalMeasure;\n const tIns = attrMeasure(el, \"tIns\");\n if (tIns !== undefined) result.tIns = tIns as number | UniversalMeasure;\n const rIns = attrMeasure(el, \"rIns\");\n if (rIns !== undefined) result.rIns = rIns as number | UniversalMeasure;\n const bIns = attrMeasure(el, \"bIns\");\n if (bIns !== undefined) result.bIns = bIns as number | UniversalMeasure;\n const numCol = attrNum(el, \"numCol\");\n if (numCol !== undefined) result.numCol = numCol;\n const spcCol = attrNum(el, \"spcCol\");\n if (spcCol !== undefined) result.spcCol = spcCol;\n const rtlCol = attrBool(el, \"rtlCol\");\n if (rtlCol !== undefined) result.rtlCol = rtlCol;\n const fromWordArt = attrBool(el, \"fromWordArt\");\n if (fromWordArt !== undefined) result.fromWordArt = fromWordArt;\n const anchor = attr(el, \"anchor\");\n if (anchor !== undefined) result.anchor = anchor as BodyPropertiesOptions[\"anchor\"];\n const anchorCtr = attrBool(el, \"anchorCtr\");\n if (anchorCtr !== undefined) result.anchorCtr = anchorCtr;\n const forceAA = attrBool(el, \"forceAA\");\n if (forceAA !== undefined) result.forceAA = forceAA;\n const upright = attrBool(el, \"upright\");\n if (upright !== undefined) result.upright = upright;\n const compatLnSpc = attrBool(el, \"compatLnSpc\");\n if (compatLnSpc !== undefined) result.compatLnSpc = compatLnSpc;\n\n // EG_TextAutofit (mutually exclusive)\n if (findChild(el, \"a:noAutofit\")) {\n result.noAutoFit = true;\n } else {\n const norm = findChild(el, \"a:normAutofit\");\n if (norm) {\n const normOpts: NormalAutofitOptions = {};\n const fontScale = attrNum(norm, \"fontScale\");\n if (fontScale !== undefined) normOpts.fontScale = fontScale;\n const lnSpcReduction = attrNum(norm, \"lnSpcReduction\");\n if (lnSpcReduction !== undefined) normOpts.lnSpcReduction = lnSpcReduction;\n result.normAutofit = normOpts;\n } else if (findChild(el, \"a:spAutoFit\")) {\n result.spAutoFit = true;\n }\n }\n\n // a:prstTxWarp (CT_PresetTextShape)\n const prstTxWarp = findChild(el, \"a:prstTxWarp\");\n if (prstTxWarp) {\n const preset = attr(prstTxWarp, \"prst\") ?? \"\";\n const avLst = findChild(prstTxWarp, \"a:avLst\");\n const adjustments: { name: string; formula: string }[] = [];\n for (const gd of avLst?.elements ?? []) {\n if (gd.type === \"element\" && gd.name === \"a:gd\") {\n adjustments.push({ name: attr(gd, \"name\") ?? \"\", formula: attr(gd, \"fmla\") ?? \"\" });\n }\n }\n result.prstTxWarp = { preset, ...(adjustments.length > 0 ? { adjustments } : {}) };\n }\n\n // a:scene3d\n const scene3d = findChild(el, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n\n // EG_Text3D (mutually exclusive: sp3d | flatTx)\n const sp3d = findChild(el, \"a:sp3d\");\n if (sp3d) {\n result.sp3d = shape3DDesc.parse(sp3d, ctx);\n } else {\n const flatTx = findChild(el, \"a:flatTx\");\n if (flatTx) {\n const z = attrNum(flatTx, \"z\");\n result.flatTx = z !== undefined ? { z } : {};\n }\n }\n\n return result as BodyPropertiesOptions;\n};\n","/**\n * Underline module for WordprocessingML documents.\n *\n * This module provides support for underlining text with various styles and colors.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\n/**\n * Underline style types for text.\n *\n * Defines the various underline patterns that can be applied to text runs.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Underline\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"single\"/>\n * <xsd:enumeration value=\"words\"/>\n * <xsd:enumeration value=\"double\"/>\n * <xsd:enumeration value=\"thick\"/>\n * <xsd:enumeration value=\"dotted\"/>\n * <xsd:enumeration value=\"dottedHeavy\"/>\n * <xsd:enumeration value=\"dash\"/>\n * <xsd:enumeration value=\"dashedHeavy\"/>\n * <xsd:enumeration value=\"dashLong\"/>\n * <xsd:enumeration value=\"dashLongHeavy\"/>\n * <xsd:enumeration value=\"dotDash\"/>\n * <xsd:enumeration value=\"dashDotHeavy\"/>\n * <xsd:enumeration value=\"dotDotDash\"/>\n * <xsd:enumeration value=\"dashDotDotHeavy\"/>\n * <xsd:enumeration value=\"wave\"/>\n * <xsd:enumeration value=\"wavyHeavy\"/>\n * <xsd:enumeration value=\"wavyDouble\"/>\n * <xsd:enumeration value=\"none\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const UnderlineType = {\n /** Single underline */\n SINGLE: \"single\",\n /** Underline words only (not spaces) */\n WORDS: \"words\",\n /** Double underline */\n DOUBLE: \"double\",\n /** Thick single underline */\n THICK: \"thick\",\n /** Dotted underline */\n DOTTED: \"dotted\",\n /** Heavy dotted underline */\n DOTTEDHEAVY: \"dottedHeavy\",\n /** Dashed underline */\n DASH: \"dash\",\n /** Heavy dashed underline */\n DASHEDHEAVY: \"dashedHeavy\",\n /** Long dashed underline */\n DASHLONG: \"dashLong\",\n /** Heavy long dashed underline */\n DASHLONGHEAVY: \"dashLongHeavy\",\n /** Dot-dash underline */\n DOTDASH: \"dotDash\",\n /** Heavy dot-dash underline */\n DASHDOTHEAVY: \"dashDotHeavy\",\n /** Dot-dot-dash underline */\n DOTDOTDASH: \"dotDotDash\",\n /** Heavy dot-dot-dash underline */\n DASHDOTDOTHEAVY: \"dashDotDotHeavy\",\n /** Wave underline */\n WAVE: \"wave\",\n /** Heavy wave underline */\n WAVYHEAVY: \"wavyHeavy\",\n /** Double wave underline */\n WAVYDOUBLE: \"wavyDouble\",\n /** No underline */\n NONE: \"none\",\n} as const;\n","/**\n * Emphasis mark module for WordprocessingML run properties.\n *\n * This module provides support for East Asian emphasis marks, which are\n * characters placed above or below text to emphasize it.\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\n/**\n * Emphasis mark types.\n *\n * Defines the types of emphasis marks that can be applied to text.\n * Emphasis marks are commonly used in East Asian typography.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Em\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"dot\"/>\n * <xsd:enumeration value=\"comma\"/>\n * <xsd:enumeration value=\"circle\"/>\n * <xsd:enumeration value=\"underDot\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const EmphasisMarkType = {\n /** No emphasis mark */\n NONE: \"none\",\n /** Comma emphasis mark */\n COMMA: \"comma\",\n /** Circle emphasis mark */\n CIRCLE: \"circle\",\n /** Dot emphasis mark */\n DOT: \"dot\",\n /** Under dot emphasis mark */\n UNDER_DOT: \"underDot\",\n} as const;\n","/**\n * Positional tab types for WordprocessingML documents.\n *\n * @module\n */\n\nexport const PositionalTabAlignment = {\n LEFT: \"left\",\n CENTER: \"center\",\n RIGHT: \"right\",\n} as const;\n\nexport const PositionalTabRelativeTo = {\n MARGIN: \"margin\",\n INDENT: \"indent\",\n} as const;\n\nexport const PositionalTabLeader = {\n NONE: \"none\",\n DOT: \"dot\",\n HYPHEN: \"hyphen\",\n UNDERSCORE: \"underscore\",\n MIDDLE_DOT: \"middleDot\",\n} as const;\n\nexport interface PositionalTabOptions {\n alignment: (typeof PositionalTabAlignment)[keyof typeof PositionalTabAlignment];\n relativeTo: (typeof PositionalTabRelativeTo)[keyof typeof PositionalTabRelativeTo];\n leader: (typeof PositionalTabLeader)[keyof typeof PositionalTabLeader];\n}\n","/**\n * Ruby annotation module for WordprocessingML documents.\n *\n * Ruby annotations are small text rendered above or below base text,\n * commonly used for pronunciation guides in East Asian languages (furigana\n * in Japanese, pinyin in Chinese, etc.).\n *\n * Used via the JSON API: `{ ruby: { text: \"かな\", base: \"漢字\" } }` as a\n * paragraph or run child.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_Ruby\n *\n * @module\n */\n\n/**\n * Ruby alignment options.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RubyAlign\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"center\"/>\n * <xsd:enumeration value=\"distributeLetter\"/>\n * <xsd:enumeration value=\"distributeSpace\"/>\n * <xsd:enumeration value=\"left\"/>\n * <xsd:enumeration value=\"right\"/>\n * <xsd:enumeration value=\"rightVertical\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const RubyAlign = {\n /** Center alignment */\n CENTER: \"center\",\n /** Distribute letters evenly */\n DISTRIBUTE_LETTER: \"distributeLetter\",\n /** Distribute space evenly */\n DISTRIBUTE_SPACE: \"distributeSpace\",\n /** Left alignment */\n LEFT: \"left\",\n /** Right alignment */\n RIGHT: \"right\",\n /** Right vertical alignment */\n RIGHT_VERTICAL: \"rightVertical\",\n} as const;\n\n/**\n * Options for a Ruby annotation.\n *\n * Used as `{ ruby: RubyOptions }` in paragraph or run children.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Ruby\">\n * <xsd:sequence>\n * <xsd:element name=\"rubyPr\" type=\"CT_RubyPr\"/>\n * <xsd:element name=\"rt\" type=\"CT_RubyContent\"/>\n * <xsd:element name=\"rubyBase\" type=\"CT_RubyContent\"/>\n * </xsd:sequence>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Japanese furigana\n * { ruby: {\n * text: \"かな\",\n * base: \"漢字\",\n * alignment: \"center\",\n * fontSize: 20,\n * languageId: \"ja-JP\",\n * }}\n * ```\n */\nexport interface RubyOptions {\n /** Ruby annotation text (e.g., furigana, pinyin) */\n text: string;\n /** Base text being annotated */\n base: string;\n /** Ruby alignment (defaults to \"center\"). */\n alignment?: (typeof RubyAlign)[keyof typeof RubyAlign];\n /**\n * Font size for the ruby annotation text in points (e.g., 10 = 10pt).\n * Defaults to half the base text size if not specified.\n */\n fontSize?: number;\n /**\n * Vertical offset for the ruby annotation in points.\n * How far the annotation is raised above (or below) the base text.\n */\n raise?: number;\n /**\n * Font size for the base text in points.\n * Used to calculate the ruby annotation positioning.\n */\n baseFontSize?: number;\n /** Language identifier for the ruby annotation (e.g., \"ja-JP\"). */\n languageId?: string;\n /** Whether the ruby annotation is dirty (needs recalculation). */\n dirty?: boolean;\n}\n","/**\n * Form field module for WordprocessingML documents.\n *\n * Form fields allow creating interactive controls (checkboxes, dropdown lists,\n * text inputs) within a document. Each form field is wrapped in a field code\n * region delimited by fldChar elements (begin/separate/end), with ffData\n * attached to the begin fldChar.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_FFData, CT_FFCheckBox, CT_FFDDList, CT_FFTextInput\n *\n * @module\n */\nimport {\n attr,\n attrBool,\n attrNum,\n children as xmlChildren,\n element,\n findChild,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Text input field type (ST_FFTextType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_FFTextType\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"regular\"/>\n * <xsd:enumeration value=\"number\"/>\n * <xsd:enumeration value=\"date\"/>\n * <xsd:enumeration value=\"currentTime\"/>\n * <xsd:enumeration value=\"currentDate\"/>\n * <xsd:enumeration value=\"calculated\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const FormFieldTextType = {\n /** Regular text input */\n REGULAR: \"regular\",\n /** Numeric input */\n NUMBER: \"number\",\n /** Date input */\n DATE: \"date\",\n /** Current time */\n CURRENT_TIME: \"currentTime\",\n /** Current date */\n CURRENT_DATE: \"currentDate\",\n /** Calculated value */\n CALCULATED: \"calculated\",\n} as const;\n\n/**\n * Options for a checkbox form field.\n */\nexport interface CheckBoxOptions {\n /**\n * Checkbox size in half-points.\n *\n * Mutually exclusive with `sizeAuto`.\n */\n size?: number;\n /**\n * Whether to auto-size the checkbox to match surrounding text.\n *\n * Mutually exclusive with `size`.\n */\n sizeAuto?: boolean;\n /** Default checked state */\n default?: boolean;\n /** Current checked state */\n checked?: boolean;\n}\n\n/**\n * Options for a dropdown list form field.\n */\nexport interface DropDownListOptions {\n /** Items in the dropdown list */\n entries: string[];\n /** Index of the currently selected entry */\n result?: number;\n /** Index of the default entry */\n default?: number;\n}\n\n/**\n * Options for a text input form field.\n */\nexport interface TextInputOptions {\n /** Text input type */\n type?: (typeof FormFieldTextType)[keyof typeof FormFieldTextType];\n /**\n * Default text value (placeholder / initial state, serialized as `w:default`\n * inside `w:ffData`).\n */\n default?: string;\n /**\n * Current value the user typed into the field (the result-run text between\n * the `separate` and `end` fldChars).\n *\n * Unlike {@link default} this is NOT stored in `w:ffData`; it is captured on\n * parse for round-trip fidelity. On stringify it is rendered as the field\n * result, falling back to {@link default} when unset.\n */\n value?: string;\n /** Maximum character length */\n maxLength?: number;\n /** Format string */\n format?: string;\n}\n\n/**\n * Help or status text options.\n */\nexport interface FormFieldTextOptions {\n /** Text type: \"text\" for custom text, \"autoText\" for auto text reference */\n type: \"text\" | \"autoText\";\n /** The text value */\n value: string;\n}\n\n/**\n * Common options for all form field types.\n */\nexport interface FormFieldCommonOptions {\n /** Field name (max 65 characters) */\n name?: string;\n /** Numeric label */\n label?: number;\n /** Tab order index */\n tabIndex?: number;\n /** Whether the field is enabled */\n enabled?: boolean;\n /** Recalculate fields when exiting */\n calcOnExit?: boolean;\n /** Entry macro name */\n entryMacro?: string;\n /** Exit macro name */\n exitMacro?: string;\n /** Help text shown when the user presses F1 */\n helpText?: FormFieldTextOptions;\n /** Status bar text */\n statusText?: FormFieldTextOptions;\n}\n\n/**\n * Options for a form field definition (CT_FFData).\n *\n * Exactly one of `checkBox`, `dropDownList`, or `textInput` must be specified.\n */\nexport interface FormFieldOptions extends FormFieldCommonOptions {\n /** Checkbox form field */\n checkBox?: CheckBoxOptions;\n /** Dropdown list form field */\n dropDownList?: DropDownListOptions;\n /** Text input form field */\n textInput?: TextInputOptions;\n}\n\n/** Build a w:val-style element with a single attribute. */\nconst valElement = (name: string, val: string | number): string => `<${name} w:val=\"${val}\"/>`;\n\n/**\n * Creates a help or status text element.\n */\nconst createFormFieldText = (name: string, options: FormFieldTextOptions): string =>\n `<${name} w:type=\"${options.type}\" w:val=\"${options.value}\"/>`;\n\n/**\n * Creates a checkbox form field element (w:checkBox).\n */\nconst createCheckBox = (options: CheckBoxOptions): string => {\n const children: string[] = [];\n\n if (options.size !== undefined) {\n children.push(valElement(\"w:size\", options.size));\n } else if (options.sizeAuto !== undefined) {\n children.push(`<w:sizeAuto/>`);\n }\n\n // <w:default> is the reset/initial state Word renders the box in. Word will\n // not render the box without it, so derive it from `checked` when omitted.\n const defaultVal = options.default ?? options.checked;\n if (defaultVal !== undefined) {\n children.push(defaultVal ? `<w:default/>` : `<w:default w:val=\"0\"/>`);\n }\n if (options.checked !== undefined) {\n children.push(options.checked ? `<w:checked/>` : `<w:checked w:val=\"0\"/>`);\n }\n\n return element(\"w:checkBox\", undefined, children);\n};\n\n/**\n * Creates a dropdown list form field element (w:ddList).\n */\nconst createDropDownList = (options: DropDownListOptions): string => {\n const children: string[] = [];\n\n if (options.result !== undefined) {\n children.push(valElement(\"w:result\", options.result));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n for (const entry of options.entries) {\n children.push(valElement(\"w:listEntry\", entry));\n }\n\n return element(\"w:ddList\", undefined, children);\n};\n\n/**\n * Creates a text input form field element (w:textInput).\n */\nconst createTextInput = (options: TextInputOptions): string => {\n const children: string[] = [];\n\n if (options.type !== undefined) {\n children.push(valElement(\"w:type\", options.type));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n if (options.maxLength !== undefined) {\n children.push(valElement(\"w:maxLength\", options.maxLength));\n }\n if (options.format !== undefined) {\n children.push(valElement(\"w:format\", options.format));\n }\n\n return element(\"w:textInput\", undefined, children);\n};\n\n/**\n * Creates a form field data element (w:ffData).\n *\n * This element contains the definition for an interactive form field\n * (checkbox, dropdown list, or text input) within a document.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FFData\">\n * <xsd:choice maxOccurs=\"unbounded\">\n * <xsd:element name=\"name\" type=\"CT_FFName\"/>\n * <xsd:element name=\"label\" type=\"CT_DecimalNumber\"/>\n * <xsd:element name=\"tabIndex\" type=\"CT_UnsignedDecimalNumber\"/>\n * <xsd:element name=\"enabled\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"calcOnExit\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"entryMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"exitMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"helpText\" type=\"CT_FFHelpText\"/>\n * <xsd:element name=\"statusText\" type=\"CT_FFStatusText\"/>\n * <xsd:choice>\n * <xsd:element name=\"checkBox\" type=\"CT_FFCheckBox\"/>\n * <xsd:element name=\"ddList\" type=\"CT_FFDDList\"/>\n * <xsd:element name=\"textInput\" type=\"CT_FFTextInput\"/>\n * </xsd:choice>\n * </xsd:choice>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Checkbox\n * createFormFieldData({\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n *\n * // Dropdown\n * createFormFieldData({\n * name: \"DropDown1\",\n * dropDownList: { entries: [\"Option A\", \"Option B\", \"Option C\"], result: 0 },\n * });\n *\n * // Text input\n * createFormFieldData({\n * name: \"Text1\",\n * textInput: { type: \"regular\", default: \"Enter text here\" },\n * });\n * ```\n */\nexport const createFormFieldData = (options: FormFieldOptions): string => {\n const children: string[] = [];\n\n if (options.name !== undefined) {\n children.push(valElement(\"w:name\", options.name));\n }\n if (options.label !== undefined) {\n children.push(valElement(\"w:label\", options.label));\n }\n if (options.tabIndex !== undefined) {\n children.push(valElement(\"w:tabIndex\", options.tabIndex));\n }\n // Word requires an explicit <w:enabled/> to render the field; default true.\n // (Previously emitted a val-less tag even for enabled:false, which is \"true\".)\n const enabled = options.enabled ?? true;\n children.push(enabled ? `<w:enabled/>` : `<w:enabled w:val=\"0\"/>`);\n // <w:calcOnExit> defaults to false (Word's standard).\n const calcOnExit = options.calcOnExit ?? false;\n children.push(calcOnExit ? `<w:calcOnExit/>` : `<w:calcOnExit w:val=\"0\"/>`);\n if (options.entryMacro !== undefined) {\n children.push(valElement(\"w:entryMacro\", options.entryMacro));\n }\n if (options.exitMacro !== undefined) {\n children.push(valElement(\"w:exitMacro\", options.exitMacro));\n }\n if (options.helpText) {\n children.push(createFormFieldText(\"w:helpText\", options.helpText));\n }\n if (options.statusText) {\n children.push(createFormFieldText(\"w:statusText\", options.statusText));\n }\n\n // Exactly one of the three mutually exclusive form field types\n if (options.checkBox) {\n children.push(createCheckBox(options.checkBox));\n } else if (options.dropDownList) {\n children.push(createDropDownList(options.dropDownList));\n } else if (options.textInput) {\n children.push(createTextInput(options.textInput));\n }\n\n return element(\"w:ffData\", undefined, children);\n};\n\n/**\n * Parse a w:ffData element back into FormFieldOptions.\n *\n * Inverse of {@link createFormFieldData}. Reads the common form-field metadata\n * (name, label, tabIndex, enabled, calcOnExit) and exactly one of\n * checkBox / dropDownList / textInput.\n */\nexport function parseFormFieldData(el: Element): FormFieldOptions {\n const opts: FormFieldOptions = {};\n\n const name = findChild(el, \"w:name\");\n if (name) opts.name = attr(name, \"w:val\");\n const label = findChild(el, \"w:label\");\n if (label) {\n const v = attrNum(label, \"w:val\");\n if (v !== undefined) opts.label = v;\n }\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const v = attrNum(tabIndex, \"w:val\");\n if (v !== undefined) opts.tabIndex = v;\n }\n const enabled = findChild(el, \"w:enabled\");\n if (enabled) opts.enabled = attrBool(enabled, \"w:val\") ?? true;\n const calcOnExit = findChild(el, \"w:calcOnExit\");\n if (calcOnExit) opts.calcOnExit = attrBool(calcOnExit, \"w:val\") ?? true;\n\n const checkBox = findChild(el, \"w:checkBox\");\n if (checkBox) {\n const cb: CheckBoxOptions = {};\n if (findChild(checkBox, \"w:sizeAuto\")) cb.sizeAuto = true;\n const size = findChild(checkBox, \"w:size\");\n if (size) {\n const v = attrNum(size, \"w:val\");\n if (v !== undefined) cb.size = v;\n }\n const def = findChild(checkBox, \"w:default\");\n if (def) cb.default = attrBool(def, \"w:val\") ?? true;\n const checked = findChild(checkBox, \"w:checked\");\n if (checked) cb.checked = attrBool(checked, \"w:val\") ?? true;\n opts.checkBox = cb as CheckBoxOptions;\n } else {\n const ddList = findChild(el, \"w:ddList\");\n if (ddList) {\n const entries: string[] = [];\n for (const li of xmlChildren(ddList, \"w:listEntry\")) {\n entries.push(attr(li, \"w:val\") ?? \"\");\n }\n const ddl: DropDownListOptions = { entries };\n const result = findChild(ddList, \"w:result\");\n if (result) {\n const v = attrNum(result, \"w:val\");\n if (v !== undefined) ddl.result = v;\n }\n const def = findChild(ddList, \"w:default\");\n if (def) {\n const v = attrNum(def, \"w:val\");\n if (v !== undefined) ddl.default = v;\n }\n opts.dropDownList = ddl as DropDownListOptions;\n } else {\n const textInput = findChild(el, \"w:textInput\");\n if (textInput) {\n const ti: TextInputOptions = {};\n const type = findChild(textInput, \"w:type\");\n if (type) ti.type = attr(type, \"w:val\") as TextInputOptions[\"type\"];\n const def = findChild(textInput, \"w:default\");\n if (def) ti.default = attr(def, \"w:val\");\n const maxLength = findChild(textInput, \"w:maxLength\");\n if (maxLength) {\n const v = attrNum(maxLength, \"w:val\");\n if (v !== undefined) ti.maxLength = v;\n }\n const format = findChild(textInput, \"w:format\");\n if (format) ti.format = attr(format, \"w:val\");\n opts.textInput = ti as TextInputOptions;\n }\n }\n }\n\n return opts as FormFieldOptions;\n}\n","/**\n * Proof error types for WordprocessingML documents.\n *\n * @module\n */\n\nexport const ProofErrorType = {\n SPELL_START: \"spellStart\",\n SPELL_END: \"spellEnd\",\n GRAM_START: \"gramStart\",\n GRAM_END: \"gramEnd\",\n} as const;\n\nexport type ProofErrorTypeValue = (typeof ProofErrorType)[keyof typeof ProofErrorType];\n","/**\n * Table cell components module for WordprocessingML documents.\n *\n * This module provides types and constants for table cell properties including borders,\n * grid span (column span), vertical merge, and text direction.\n *\n * Reference: http://officeopenxml.com/WPtableCell.php\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Options for configuring table cell borders.\n *\n * Defines border settings for individual edges of a table cell.\n */\nexport interface TableCellBordersOptions {\n /** Border for the top edge of the cell */\n top?: BorderOptions;\n /** Border for the start edge (left in LTR, right in RTL) */\n start?: BorderOptions;\n /** Border for the left edge of the cell */\n left?: BorderOptions;\n /** Border for the bottom edge of the cell */\n bottom?: BorderOptions;\n /** Border for the end edge (right in LTR, left in RTL) */\n end?: BorderOptions;\n /** Border for the right edge of the cell */\n right?: BorderOptions;\n /** Inside horizontal border (CT_TcBorders/insideH) */\n insideHorizontal?: BorderOptions;\n /** Inside vertical border (CT_TcBorders/insideV) */\n insideVertical?: BorderOptions;\n /** Diagonal border from top-left to bottom-right */\n topLeftToBottomRight?: BorderOptions;\n /** Diagonal border from top-right to bottom-left */\n topRightToBottomLeft?: BorderOptions;\n}\n\n/**\n * Vertical merge types for table cells.\n *\n * Defines the merge behavior for vertically merged cells (row span).\n */\nexport const VerticalMergeType = {\n /**\n * Cell that is merged with upper one.\n */\n CONTINUE: \"continue\",\n /**\n * Cell that is starting the vertical merge.\n */\n RESTART: \"restart\",\n} as const;\n\n/**\n * Text direction values for table cells.\n *\n * Specifies the direction in which text flows within a table cell.\n */\nexport const TextDirection = {\n /** Text flows from bottom to top, left to right */\n BOTTOM_TO_TOP_LEFT_TO_RIGHT: \"btLr\",\n /** Text flows from left to right, top to bottom (default) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Text flows from top to bottom, right to left */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Table float properties module for WordprocessingML documents.\n *\n * This module provides floating table positioning options, allowing tables\n * to float with text wrapping around them.\n *\n * Reference: http://officeopenxml.com/WPtableFloating.php\n *\n * @module\n */\n\n/**\n * Anchor types for floating table positioning.\n *\n * Specifies the base object from which positioning is determined.\n */\nexport const TableAnchorType = {\n MARGIN: \"margin\",\n PAGE: \"page\",\n TEXT: \"text\",\n} as const;\n\n/**\n * Relative horizontal position values for floating tables.\n */\nexport const RelativeHorizontalPosition = {\n CENTER: \"center\",\n INSIDE: \"inside\",\n LEFT: \"left\",\n OUTSIDE: \"outside\",\n RIGHT: \"right\",\n} as const;\n\n/**\n * Relative vertical position values for floating tables.\n */\nexport const RelativeVerticalPosition = {\n BOTTOM: \"bottom\",\n CENTER: \"center\",\n INLINE: \"inline\",\n INSIDE: \"inside\",\n OUTSIDE: \"outside\",\n TOP: \"top\",\n} as const;\n\n/**\n * Table overlap behavior types.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblOverlap\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"never\"/>\n * <xsd:enumeration value=\"overlap\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const OverlapType = {\n NEVER: \"never\",\n OVERLAP: \"overlap\",\n} as const;\n\nexport interface TableFloatOptions {\n /* CSpell:disable */\n horizontalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];\n absoluteHorizontalPosition?: number;\n relativeHorizontalPosition?: (typeof RelativeHorizontalPosition)[keyof typeof RelativeHorizontalPosition];\n verticalAnchor?: (typeof TableAnchorType)[keyof typeof TableAnchorType];\n absoluteVerticalPosition?: number;\n relativeVerticalPosition?: (typeof RelativeVerticalPosition)[keyof typeof RelativeVerticalPosition];\n bottomFromText?: number;\n topFromText?: number;\n leftFromText?: number;\n rightFromText?: number;\n overlap?: (typeof OverlapType)[keyof typeof OverlapType];\n /* CSpell:enable */\n}\n","/**\n * Table layout module for WordprocessingML documents.\n *\n * This module provides table layout algorithm settings.\n *\n * @module\n */\n\n/**\n * Table layout algorithm types.\n *\n * Specifies how the table width is calculated.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblLayoutType\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"fixed\"/>\n * <xsd:enumeration value=\"autofit\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const TableLayoutType = {\n /** Auto-fit layout - column widths are adjusted based on content */\n AUTOFIT: \"autofit\",\n /** Fixed layout - column widths are fixed as specified */\n FIXED: \"fixed\",\n} as const;\n","/**\n * Border module for WordprocessingML documents.\n *\n * Borders are used in multiple contexts (paragraphs, tables, table cells, sections)\n * and share the same CT_Border type definition. This module provides the BorderStyle\n * constants used throughout the document structure.\n *\n * Reference: http://officeopenxml.com/WPborders.php\n *\n * @see http://officeopenxml.com/WPtableBorders.php\n * @see http://officeopenxml.com/WPtableCellProperties-Borders.php\n * @see http://officeopenxml.com/WPsectionBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Border\">\n * <xsd:attribute name=\"val\" type=\"ST_Border\" use=\"required\"/>\n * <xsd:attribute name=\"color\" type=\"ST_HexColor\" use=\"optional\" default=\"auto\"/>\n * <xsd:attribute name=\"themeColor\" type=\"ST_ThemeColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeTint\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"themeShade\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"sz\" type=\"ST_EighthPointMeasure\" use=\"optional\"/>\n * <xsd:attribute name=\"space\" type=\"ST_PointMeasure\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"shadow\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * <xsd:attribute name=\"frame\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @module\n */\nimport type { ThemeColor } from \"@office-open/core\";\n\n/**\n * Options for configuring a border element.\n *\n * @property style - The border style (single, dashed, dotted, etc.)\n * @property color - Border color in hex format (e.g., \"FF00AA\" for purple)\n * @property size - Border thickness in eighths of a point (1/8 pt)\n * @property space - Spacing offset from the content in points\n */\nexport interface BorderOptions {\n style: (typeof BorderStyle)[keyof typeof BorderStyle];\n /** Border color, in hex (eg 'FF00AA') */\n color?: string;\n /** Theme color reference */\n themeColor?: (typeof ThemeColor)[keyof typeof ThemeColor];\n /** Theme color tint (2-char hex) */\n themeTint?: string;\n /** Theme color shade (2-char hex) */\n themeShade?: string;\n /** Border shadow */\n shadow?: boolean;\n /** Border frame */\n frame?: boolean;\n /** Size of the border in 1/8 pt */\n size?: number;\n /** Spacing offset. Values are specified in pt */\n space?: number;\n}\n\n/**\n * Table borders are defined with the <w:tblBorders> element. Child elements of this element specify the kinds of `border`:\n *\n * `bottom`, `end` (`right` in the previous version of the standard), `insideH`, `insideV`, `start` (`left` in the previous version of the standard), and `top`.\n *\n * Reference: http://officeopenxml.com/WPtableBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Border\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"single\"/>\n * <xsd:enumeration value=\"dashDotStroked\"/>\n * <xsd:enumeration value=\"dashed\"/>\n * <xsd:enumeration value=\"dashSmallGap\"/>\n * <xsd:enumeration value=\"dotDash\"/>\n * <xsd:enumeration value=\"dotDotDash\"/>\n * <xsd:enumeration value=\"dotted\"/>\n * <xsd:enumeration value=\"double\"/>\n * <xsd:enumeration value=\"doubleWave\"/>\n * <xsd:enumeration value=\"inset\"/>\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"outset\"/>\n * <xsd:enumeration value=\"thick\"/>\n * <xsd:enumeration value=\"thickThinLargeGap\"/>\n * <xsd:enumeration value=\"thickThinMediumGap\"/>\n * <xsd:enumeration value=\"thickThinSmallGap\"/>\n * <xsd:enumeration value=\"thinThickLargeGap\"/>\n * <xsd:enumeration value=\"thinThickMediumGap\"/>\n * <xsd:enumeration value=\"thinThickSmallGap\"/>\n * <xsd:enumeration value=\"thinThickThinLargeGap\"/>\n * <xsd:enumeration value=\"thinThickThinMediumGap\"/>\n * <xsd:enumeration value=\"thinThickThinSmallGap\"/>\n * <xsd:enumeration value=\"threeDEmboss\"/>\n * <xsd:enumeration value=\"threeDEngrave\"/>\n * <xsd:enumeration value=\"triple\"/>\n * <xsd:enumeration value=\"wave\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const BorderStyle = {\n /** A single line */\n SINGLE: \"single\",\n /** A line with a series of alternating thin and thick strokes */\n DASH_DOT_STROKED: \"dashDotStroked\",\n /** A dashed line */\n DASHED: \"dashed\",\n /** A dashed line with small gaps */\n DASH_SMALL_GAP: \"dashSmallGap\",\n /** A line with alternating dots and dashes */\n DOT_DASH: \"dotDash\",\n /** A line with a repeating dot - dot - dash sequence */\n DOT_DOT_DASH: \"dotDotDash\",\n /** A dotted line */\n DOTTED: \"dotted\",\n /** A double line */\n DOUBLE: \"double\",\n /** A double wavy line */\n DOUBLE_WAVE: \"doubleWave\",\n /** An inset set of lines */\n INSET: \"inset\",\n /** No border */\n NIL: \"nil\",\n /** No border */\n NONE: \"none\",\n /** An outset set of lines */\n OUTSET: \"outset\",\n /** A single line */\n THICK: \"thick\",\n /** A thick line contained within a thin line with a large-sized intermediate gap */\n THICK_THIN_LARGE_GAP: \"thickThinLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THICK_THIN_MEDIUM_GAP: \"thickThinMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THICK_THIN_SMALL_GAP: \"thickThinSmallGap\",\n /** A thin line contained within a thick line with a large-sized intermediate gap */\n THIN_THICK_LARGE_GAP: \"thinThickLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THIN_THICK_MEDIUM_GAP: \"thinThickMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THIN_THICK_SMALL_GAP: \"thinThickSmallGap\",\n /** A thin-thick-thin line with a large gap */\n THIN_THICK_THIN_LARGE_GAP: \"thinThickThinLargeGap\",\n /** A thin-thick-thin line with a medium gap */\n THIN_THICK_THIN_MEDIUM_GAP: \"thinThickThinMediumGap\",\n /** A thin-thick-thin line with a small gap */\n THIN_THICK_THIN_SMALL_GAP: \"thinThickThinSmallGap\",\n /** A three-staged gradient line, getting darker towards the paragraph */\n THREE_D_EMBOSS: \"threeDEmboss\",\n /** A three-staged gradient like, getting darker away from the paragraph */\n THREE_D_ENGRAVE: \"threeDEngrave\",\n /** A triple line */\n TRIPLE: \"triple\",\n /** A wavy line */\n WAVE: \"wave\",\n} as const;\n","/**\n * Table borders module for WordprocessingML documents.\n *\n * This module provides border options for tables.\n *\n * Reference: http://officeopenxml.com/WPtableBorders.php\n *\n * @module\n */\nimport { BorderStyle } from \"@shared/border\";\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Options for configuring table borders.\n *\n * Borders can be applied to the outside edges (top, bottom, left, right)\n * and inside lines (insideHorizontal, insideVertical) of the table.\n */\nexport interface TableBordersOptions {\n top?: BorderOptions;\n bottom?: BorderOptions;\n left?: BorderOptions;\n right?: BorderOptions;\n insideHorizontal?: BorderOptions;\n insideVertical?: BorderOptions;\n}\n\nconst NONE_BORDER: BorderOptions = {\n color: \"auto\",\n size: 0,\n style: BorderStyle.NONE,\n};\n\nexport const TABLE_BORDERS_NONE: TableBordersOptions = {\n bottom: NONE_BORDER,\n insideHorizontal: NONE_BORDER,\n insideVertical: NONE_BORDER,\n left: NONE_BORDER,\n right: NONE_BORDER,\n top: NONE_BORDER,\n};\n","/**\n * Table width module for WordprocessingML documents.\n *\n * This module provides width specifications for tables and cells.\n *\n * Reference: http://officeopenxml.com/WPtableWidth.php\n *\n * @module\n */\nimport type { Percentage, UniversalMeasure } from \"@office-open/core\";\n\n/**\n * Width type values for tables and cells.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblWidth\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"pct\"/>\n * <xsd:enumeration value=\"dxa\"/>\n * <xsd:enumeration value=\"auto\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const WidthType = {\n /** Auto. */\n AUTO: \"auto\",\n /** Value is in twentieths of a point */\n DXA: \"dxa\",\n /** No (empty) value. */\n NIL: \"nil\",\n /** Value is in percentage. */\n PERCENTAGE: \"pct\",\n} as const;\n\n/**\n * Properties for specifying table or cell width.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TblWidth\">\n * <xsd:attribute name=\"w\" type=\"ST_MeasurementOrPercent\"/>\n * <xsd:attribute name=\"type\" type=\"ST_TblWidth\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface TableWidthProperties {\n size: number | Percentage | UniversalMeasure;\n type?: (typeof WidthType)[keyof typeof WidthType];\n}\n","/**\n * Object element for WordprocessingML documents — w:object.\n *\n * Embeds an OLE object (e.g. an Excel sheet) in a run via a VML preview shape and\n * exactly one of objectEmbed / objectLink / control / movie. The OLE binary is\n * registered as word/embeddings/oleObjectN.bin (EmbeddingCollection); the optional\n * preview icon as word/media/imageN.<type> (Media). Relationship ids are emitted\n * as `{fileName}` placeholders and rewritten by the compiler's media bridge.\n *\n * Reference: OOXML transitional, wml.xsd, CT_Object / CT_ObjectEmbed / CT_ObjectLink\n *\n * @module\n */\nimport { toUint8Array } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, findChild, type Element } from \"@office-open/xml\";\nimport type { EmbeddingData } from \"@shared/embeddings/embeddings\";\nimport type { MediaData } from \"@shared/media/data\";\n\nimport type { BodyContext } from \"../../context\";\nimport { createImageData } from \"../paragraph/run/image-run\";\n\n// ── Options ──\n\nexport interface ObjectEmbedOptions {\n /** OLE container binary — registered as word/embeddings/oleObjectN.bin. */\n data: Uint8Array | string;\n /** OLE program id (e.g. \"Excel.Sheet.12\"). */\n progId?: string;\n /** Draw aspect — how the object displays. */\n drawAspect?: \"content\" | \"icon\";\n /** Shape id (w:objectEmbed/@shapeId). */\n shapeId?: string;\n /** Field codes (w:objectEmbed/@fieldCodes). */\n fieldCodes?: string;\n}\n\nexport interface ObjectLinkOptions extends ObjectEmbedOptions {\n /** Update mode (required for links). */\n updateMode: \"always\" | \"onCall\";\n /** Whether the field is locked. */\n lockedField?: boolean;\n}\n\nexport interface ObjectControlOptions {\n /** Control name (w:control/@name). */\n name?: string;\n /** Shape id (w:control/@shapeid). */\n shapeid?: string;\n /** Relationship id to the ActiveX part (external — not auto-registered). */\n rId: string;\n}\n\nexport interface ObjectIconImageOptions {\n /** Preview image bytes (binary or base64 data URL). */\n data: Uint8Array | string;\n /** Image type / extension (e.g. \"png\", \"emf\"). */\n type: string;\n /** Title for v:imagedata/@o:title. */\n title?: string;\n}\n\nexport interface ObjectElementOptions {\n /** Original width in twips (w:object/@w:dxaOrig). */\n dxaOrig?: number;\n /** Original height in twips (w:object/@w:dyaOrig). */\n dyaOrig?: number;\n /** VML shape id (v:shape/@id). Defaults to a generated id. */\n shapeId?: string;\n /** Display width (px or universal measure) for v:shape style + icon size. */\n width?: number | UniversalMeasure;\n /** Display height (px or universal measure). */\n height?: number | UniversalMeasure;\n /** Preview icon image (v:imagedata). */\n iconImage?: ObjectIconImageOptions;\n /** Embedded OLE object (w:objectEmbed). */\n embed?: ObjectEmbedOptions;\n /** Linked OLE object (w:objectLink). */\n link?: ObjectLinkOptions;\n /** ActiveX control reference (w:control). */\n control?: ObjectControlOptions;\n /** Movie relationship id — CT_Rel (w:movie/@r:id). External. */\n movie?: string;\n}\n\n// ── Descriptor ──\n\nlet objectShapeCounter = 1025;\n\nexport const objectDesc: CustomDescriptor<ObjectElementOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const inner: string[] = [];\n\n // VML preview shape (v:shape + optional v:imagedata)\n const shapeId = opts.shapeId ?? `_x0000_i${objectShapeCounter++}`;\n const widthVal = opts.width ?? 100;\n const heightVal = opts.height ?? 100;\n const styleWidth = typeof widthVal === \"number\" ? `${widthVal}px` : widthVal;\n const styleHeight = typeof heightVal === \"number\" ? `${heightVal}px` : heightVal;\n\n const shapeChildren: string[] = [];\n if (opts.iconImage) {\n const rawData = toUint8Array(opts.iconImage.data) as Uint8Array;\n const iconType = opts.iconImage.type;\n const { fileName: iconFileName } = ctx.file.media.addMedia(\n rawData,\n iconType,\n (fileName) =>\n ({\n type: iconType,\n ...createImageData(rawData, { width: widthVal, height: heightVal }, fileName),\n }) as MediaData,\n );\n const titleAttr = opts.iconImage.title ? ` o:title=\"${opts.iconImage.title}\"` : \"\";\n shapeChildren.push(`<v:imagedata r:id=\"{${iconFileName}}\"${titleAttr}/>`);\n }\n inner.push(\n `<v:shape id=\"${shapeId}\" type=\"#_x0000_t75\" style=\"width:${styleWidth};height:${styleHeight}\">${shapeChildren.join(\"\")}</v:shape>`,\n );\n\n // Choice: objectEmbed | objectLink | control | movie\n if (opts.embed) {\n const fileName = registerEmbedding(opts.embed, ctx);\n inner.push(`<w:objectEmbed r:id=\"{${fileName}}\"${embedAttrs(opts.embed)}/>`);\n } else if (opts.link) {\n const fileName = registerEmbedding(opts.link, ctx);\n const locked = opts.link.lockedField ? ` w:lockedField=\"true\"` : \"\";\n inner.push(\n `<w:objectLink r:id=\"{${fileName}}\"${embedAttrs(opts.link)} w:updateMode=\"${opts.link.updateMode}\"${locked}/>`,\n );\n } else if (opts.control) {\n const c = opts.control;\n const cAttrs: string[] = [` r:id=\"${c.rId}\"`];\n if (c.name) cAttrs.push(` w:name=\"${c.name}\"`);\n if (c.shapeid) cAttrs.push(` w:shapeid=\"${c.shapeid}\"`);\n inner.push(`<w:control${cAttrs.join(\"\")}/>`);\n } else if (opts.movie) {\n inner.push(`<w:movie r:id=\"${opts.movie}\"/>`);\n }\n\n // w:object root attributes\n const objAttrs: string[] = [];\n if (opts.dxaOrig !== undefined) objAttrs.push(` w:dxaOrig=\"${opts.dxaOrig}\"`);\n if (opts.dyaOrig !== undefined) objAttrs.push(` w:dyaOrig=\"${opts.dyaOrig}\"`);\n\n return `<w:object${objAttrs.join(\"\")}>${inner.join(\"\")}</w:object>`;\n },\n\n parse(el, _ctx) {\n const result: Partial<ObjectElementOptions> = {};\n\n const dxaOrig = attrNum(el, \"w:dxaOrig\");\n if (dxaOrig !== undefined) result.dxaOrig = dxaOrig;\n const dyaOrig = attrNum(el, \"w:dyaOrig\");\n if (dyaOrig !== undefined) result.dyaOrig = dyaOrig;\n\n // VML shape — best-effort structural capture (binary media is not re-registered on parse)\n const shape = findChild(el, \"v:shape\");\n if (shape) {\n const id = attr(shape, \"id\");\n if (id) result.shapeId = id;\n const style = attr(shape, \"style\");\n if (style) {\n const w = style.match(/width:([^;]+)/);\n const h = style.match(/height:([^;]+)/);\n if (w) result.width = w[1].trim() as UniversalMeasure;\n if (h) result.height = h[1].trim() as UniversalMeasure;\n }\n }\n\n // Choice elements\n const embedEl = findChild(el, \"w:objectEmbed\");\n if (embedEl) result.embed = parseEmbed(embedEl);\n\n const linkEl = findChild(el, \"w:objectLink\");\n if (linkEl) {\n const base = parseEmbed(linkEl);\n const updateMode = attr(linkEl, \"w:updateMode\");\n const lockedField = attr(linkEl, \"w:lockedField\");\n result.link = {\n ...base,\n ...(updateMode ? { updateMode: updateMode as \"always\" | \"onCall\" } : {}),\n ...(lockedField !== undefined\n ? { lockedField: lockedField === \"true\" || lockedField === \"1\" }\n : {}),\n } as ObjectLinkOptions;\n }\n\n const controlEl = findChild(el, \"w:control\");\n if (controlEl) {\n const rId = attr(controlEl, \"r:id\") ?? \"\";\n const name = attr(controlEl, \"w:name\");\n const shapeid = attr(controlEl, \"w:shapeid\");\n result.control = { rId, ...(name ? { name } : {}), ...(shapeid ? { shapeid } : {}) };\n }\n\n const movieEl = findChild(el, \"w:movie\");\n if (movieEl) {\n const rId = attr(movieEl, \"r:id\");\n if (rId) result.movie = rId;\n }\n\n return result as ObjectElementOptions;\n },\n};\n\n// ── Helpers ──\n\n/** Register an OLE embedding and return its allocated file name. */\nfunction registerEmbedding(opts: ObjectEmbedOptions, ctx: BodyContext): string {\n const fileName = ctx.file.embeddings.nextEmbeddingName();\n const data: EmbeddingData = {\n fileName,\n data: toUint8Array(opts.data) as Uint8Array,\n ...(opts.progId ? { progId: opts.progId } : {}),\n };\n ctx.file.embeddings.addEmbedding(fileName, data);\n return fileName;\n}\n\n/** Build the common objectEmbed/objectLink attribute string (excludes r:id). */\nfunction embedAttrs(opts: ObjectEmbedOptions): string {\n const attrs: string[] = [];\n if (opts.drawAspect) attrs.push(` w:drawAspect=\"${opts.drawAspect}\"`);\n if (opts.progId) attrs.push(` w:progId=\"${opts.progId}\"`);\n if (opts.shapeId) attrs.push(` w:shapeId=\"${opts.shapeId}\"`);\n if (opts.fieldCodes) attrs.push(` w:fieldCodes=\"${opts.fieldCodes}\"`);\n return attrs.join(\"\");\n}\n\n/** Parse common objectEmbed/objectLink attributes (excludes r:id — external on parse). */\nfunction parseEmbed(el: Element): ObjectEmbedOptions {\n const opts: Partial<ObjectEmbedOptions> = {};\n const drawAspect = attr(el, \"w:drawAspect\");\n if (drawAspect === \"content\" || drawAspect === \"icon\") opts.drawAspect = drawAspect;\n const progId = attr(el, \"w:progId\");\n if (progId) opts.progId = progId;\n const shapeId = attr(el, \"w:shapeId\");\n if (shapeId) opts.shapeId = shapeId;\n const fieldCodes = attr(el, \"w:fieldCodes\");\n if (fieldCodes) opts.fieldCodes = fieldCodes;\n // data is not recoverable from the relationship on parse; callers re-supply it.\n opts.data = new Uint8Array();\n return opts as ObjectEmbedOptions;\n}\n","/**\n * Element-to-XML serialization helpers shared across the parse layer.\n *\n * @module\n */\nimport { escapeXml, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Serialize an Element including its own opening/closing tag.\n *\n * `stringify` from @office-open/xml serializes only an element's children\n * (it treats its input as a document root). Raw-XML round-trip of whole\n * elements (TOC paragraphs, range markers, w14 text effects) needs the\n * element's own tag wrapped around its serialized children.\n */\nexport function stringifyElement(el: Element): string {\n if (!el.name) return \"\";\n let attrStr = \"\";\n if (el.attributes) {\n for (const key of Object.keys(el.attributes)) {\n const v = el.attributes[key];\n if (v === null || v === undefined) continue;\n attrStr += ` ${key}=\"${escapeXml(String(v))}\"`;\n }\n }\n const withClosingTag =\n (el.elements?.length ?? 0) > 0 || el.attributes?.[\"xml:space\"] === \"preserve\";\n if (!withClosingTag) return `<${el.name}${attrStr}/>`;\n return `<${el.name}${attrStr}>${stringify(el)}</${el.name}>`;\n}\n","/**\n * Run properties parser for DOCX documents.\n *\n * Parses w:rPr Element trees into RunPropertiesOptions objects.\n *\n * @module\n */\nimport {\n attr,\n attrBool,\n attrMeasure,\n attrNum,\n colorAttr,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { objectDesc } from \"@parts/object\";\nimport type { ObjectElementOptions } from \"@parts/object\";\nimport type { FootnoteEndnoteReferenceOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n BreakClear,\n BreakOptions,\n RunPropertiesOptions,\n RunOptions,\n} from \"@parts/paragraph/run\";\n\nimport type { DocxReadContext } from \"../../../context\";\nimport { stringifyElement } from \"../../../util/stringify-element\";\nimport type { LanguageOptions } from \"./language\";\n\n/**\n * Parse a w:rPr element into RunPropertiesOptions.\n */\nexport function parseRunProperties(el: Element): RunPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n const rStyle = findChild(el, \"w:rStyle\");\n if (rStyle) opts.style = attr(rStyle, \"w:val\");\n\n const font = findChild(el, \"w:rFonts\");\n if (font) {\n const ascii = attr(font, \"w:ascii\");\n const eastAsia = attr(font, \"w:eastAsia\");\n const hAnsi = attr(font, \"w:hAnsi\");\n const cs = attr(font, \"w:cs\");\n const asciiTheme = attr(font, \"w:asciiTheme\");\n const eastAsiaTheme = attr(font, \"w:eastAsiaTheme\");\n const hAnsiTheme = attr(font, \"w:hAnsiTheme\");\n const cstheme = attr(font, \"w:cstheme\");\n const hint = attr(font, \"w:hint\");\n\n if (\n ascii &&\n !eastAsia &&\n !hAnsi &&\n !cs &&\n !asciiTheme &&\n !eastAsiaTheme &&\n !hAnsiTheme &&\n !cstheme\n ) {\n opts.font = hint ? { name: ascii, hint } : ascii;\n } else {\n const fontObj: Record<string, string | undefined> = {};\n if (ascii) fontObj.ascii = ascii;\n if (eastAsia) fontObj.eastAsia = eastAsia;\n if (hAnsi) fontObj.hAnsi = hAnsi;\n if (cs) fontObj.cs = cs;\n if (asciiTheme) fontObj.asciiTheme = asciiTheme;\n if (eastAsiaTheme) fontObj.eastAsiaTheme = eastAsiaTheme;\n if (hAnsiTheme) fontObj.hAnsiTheme = hAnsiTheme;\n if (cstheme) fontObj.cstheme = cstheme;\n if (hint) fontObj.hint = hint;\n opts.font = fontObj;\n }\n }\n\n const bold = findChild(el, \"w:b\");\n if (bold) opts.bold = attrBool(bold, \"w:val\") ?? true;\n\n const boldCs = findChild(el, \"w:bCs\");\n if (boldCs) opts.boldComplexScript = attrBool(boldCs, \"w:val\") ?? true;\n\n const italic = findChild(el, \"w:i\");\n if (italic) opts.italic = attrBool(italic, \"w:val\") ?? true;\n\n const italicCs = findChild(el, \"w:iCs\");\n if (italicCs) opts.italicComplexScript = attrBool(italicCs, \"w:val\") ?? true;\n\n const underline = findChild(el, \"w:u\");\n if (underline) {\n const ul: Record<string, string | undefined> = {};\n const uType = attr(underline, \"w:val\");\n if (uType) ul.type = uType;\n const uColor = colorAttr(underline, \"w:color\");\n if (uColor) ul.color = uColor;\n opts.underline = ul;\n }\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:strike\", \"strike\"],\n [\"w:dstrike\", \"doubleStrike\"],\n [\"w:outline\", \"outline\"],\n [\"w:shadow\", \"shadow\"],\n [\"w:emboss\", \"emboss\"],\n [\"w:imprint\", \"imprint\"],\n [\"w:vanish\", \"vanish\"],\n [\"w:webHidden\", \"webHidden\"],\n [\"w:noProof\", \"noProof\"],\n [\"w:snapToGrid\", \"snapToGrid\"],\n [\"w:smallCaps\", \"smallCaps\"],\n [\"w:caps\", \"allCaps\"],\n [\"w:rtl\", \"rightToLeft\"],\n [\"w:cs\", \"complexScript\"],\n [\"w:specVanish\", \"specVanish\"],\n [\"w:oMath\", \"math\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n const color = findChild(el, \"w:color\");\n if (color) {\n const c = colorAttr(color, \"w:val\");\n const themeColor = attr(color, \"w:themeColor\");\n const themeTint = attr(color, \"w:themeTint\");\n const themeShade = attr(color, \"w:themeShade\");\n if (themeColor || themeTint || themeShade) {\n const colorObj: Record<string, string | undefined> = {};\n if (c) colorObj.val = c;\n if (themeColor) colorObj.themeColor = themeColor;\n if (themeTint) colorObj.themeTint = themeTint;\n if (themeShade) colorObj.themeShade = themeShade;\n opts.color = colorObj;\n } else if (c) {\n opts.color = c;\n }\n }\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const halfPts = attrNum(sz, \"w:val\");\n if (halfPts !== undefined) opts.size = halfPts / 2;\n }\n\n const szCs = findChild(el, \"w:szCs\");\n if (szCs) {\n const halfPts = attrNum(szCs, \"w:val\");\n if (halfPts !== undefined) opts.sizeComplexScript = halfPts / 2;\n }\n\n const highlight = findChild(el, \"w:highlight\");\n if (highlight) {\n const val = attr(highlight, \"w:val\");\n if (val) opts.highlight = val;\n }\n\n const highlightCs = findChild(el, \"w:highlightCs\");\n if (highlightCs) {\n const val = attr(highlightCs, \"w:val\");\n if (val) opts.highlightComplexScript = val;\n }\n\n const vertAlign = findChild(el, \"w:vertAlign\");\n if (vertAlign) {\n const val = attr(vertAlign, \"w:val\");\n if (val === \"subscript\") opts.subScript = true;\n else if (val === \"superscript\") opts.superScript = true;\n }\n\n const effect = findChild(el, \"w:effect\");\n if (effect) {\n const val = attr(effect, \"w:val\");\n if (val) opts.effect = val;\n }\n\n const emphasisMark = findChild(el, \"w:em\");\n if (emphasisMark) {\n const val = attr(emphasisMark, \"w:val\");\n if (val) opts.emphasisMark = { type: val };\n }\n\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const val = attrMeasure(spacing, \"w:val\");\n if (val !== undefined) opts.characterSpacing = val;\n }\n\n const scale = findChild(el, \"w:w\");\n if (scale) {\n const val = attrNum(scale, \"w:val\");\n if (val !== undefined) opts.scale = val;\n }\n\n const kern = findChild(el, \"w:kern\");\n if (kern) {\n const val = attrNum(kern, \"w:val\");\n if (val !== undefined) opts.kern = val;\n }\n\n const position = findChild(el, \"w:position\");\n if (position) {\n const val = attr(position, \"w:val\");\n if (val !== undefined) opts.position = val;\n }\n\n const fitText = findChild(el, \"w:fitText\");\n if (fitText) {\n const val = attrNum(fitText, \"w:val\");\n if (val !== undefined) opts.fitText = val;\n }\n\n const lang = findChild(el, \"w:lang\");\n if (lang) {\n const langObj: LanguageOptions = {};\n const val = attr(lang, \"w:val\");\n if (val) langObj.value = val;\n const eastAsia = attr(lang, \"w:eastAsia\");\n if (eastAsia) langObj.eastAsia = eastAsia;\n const bidi = attr(lang, \"w:bidi\");\n if (bidi) langObj.bidirectional = bidi;\n if (Object.keys(langObj).length > 0) opts.language = langObj;\n }\n\n // Border (w:bdr)\n const bdr = findChild(el, \"w:bdr\");\n if (bdr) {\n opts.border = parseBorder(bdr);\n }\n\n // Shading (w:shd)\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n opts.shading = parseShading(shd);\n }\n\n // East Asian layout (w:eastAsianLayout)\n const eastAsianLayout = findChild(el, \"w:eastAsianLayout\");\n if (eastAsianLayout) {\n opts.eastAsianLayout = parseEastAsianLayout(eastAsianLayout);\n }\n\n // Content part (w:contentPart)\n const contentPart = findChild(el, \"w:contentPart\");\n if (contentPart) {\n const rId = attr(contentPart, \"r:id\");\n if (rId) opts.contentPartRId = rId;\n }\n\n // Revision (w:rPrChange)\n const rPrChange = findChild(el, \"w:rPrChange\");\n if (rPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(rPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(rPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(rPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerRPr = findChild(rPrChange, \"w:rPr\");\n if (innerRPr) {\n Object.assign(rev, parseRunProperties(innerRPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n // w14:* text effects (glow/shadow/reflection/props3d) occupy the EG_RPrBase\n // extension slot at the end of rPr. Low-frequency complex subtrees — kept\n // verbatim as raw XML for fidelity while the rPr backbone stays editable.\n const w14Parts: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name?.startsWith(\"w14:\")) w14Parts.push(stringifyElement(child));\n }\n if (w14Parts.length > 0) opts.w14RawXml = w14Parts.join(\"\");\n\n return opts as RunPropertiesOptions;\n}\n\n/**\n * Parse a w:bdr element into BorderOptions.\n */\nexport function parseBorder(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n const style = attr(el, \"w:val\");\n if (style) opts.style = style;\n const color = colorAttr(el, \"w:color\");\n if (color) opts.color = color;\n const size = attrNum(el, \"w:sz\");\n if (size !== undefined) opts.size = size;\n const space = attrNum(el, \"w:space\");\n if (space !== undefined) opts.space = space;\n const shadow = attrBool(el, \"w:shadow\");\n if (shadow !== undefined) opts.shadow = shadow;\n const frame = attrBool(el, \"w:frame\");\n if (frame !== undefined) opts.frame = frame;\n return opts;\n}\n\n/**\n * Parse a w:shd element into ShadingAttributesProperties.\n */\nexport function parseShading(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n const fill = colorAttr(el, \"w:fill\");\n if (fill) opts.fill = fill;\n const color = colorAttr(el, \"w:color\");\n if (color) opts.color = color;\n const type = attr(el, \"w:val\");\n if (type) opts.type = type;\n return opts;\n}\n\n/**\n * Parse a w:eastAsianLayout element into EastAsianLayoutOptions.\n */\nexport function parseEastAsianLayout(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) opts.id = id;\n const combine = attrBool(el, \"w:combine\");\n if (combine !== undefined) opts.combine = combine;\n const combineBrackets = attr(el, \"w:combineBrackets\");\n if (combineBrackets) opts.combineBrackets = combineBrackets;\n const vert = attrBool(el, \"w:vert\");\n if (vert !== undefined) opts.vert = vert;\n const vertCompress = attrBool(el, \"w:vertCompress\");\n if (vertCompress !== undefined) opts.vertCompress = vertCompress;\n return opts;\n}\n\n// ── Special run child constants ──────────────────────────────────────────────\n\n/** Matches w:br[@w:type=\"page\"] → PageBreak */\nexport const PARSED_PAGE_BREAK = Symbol(\"PageBreak\");\n/** Matches w:br (line break) */\nexport const PARSED_LINE_BREAK = Symbol(\"LineBreak\");\n/** Matches w:tab */\nexport const PARSED_TAB = Symbol(\"Tab\");\n/** Matches w:cr */\nexport const PARSED_CARRIAGE_RETURN = Symbol(\"CarriageReturn\");\n/** Matches w:noBreakHyphen */\nexport const PARSED_NO_BREAK_HYPHEN = Symbol(\"NoBreakHyphen\");\n/** Matches w:softHyphen */\nexport const PARSED_SOFT_HYPHEN = Symbol(\"SoftHyphen\");\n/** Matches w:footnoteRef — auto-generated by Footnote class */\nexport const PARSED_FOOTNOTE_REF = Symbol(\"FootnoteRef\");\n/** Matches w:br[@w:type=\"column\"] */\nexport const PARSED_COLUMN_BREAK = Symbol(\"ColumnBreak\");\n/** Matches w:dayShort */\nexport const PARSED_DAY_SHORT = Symbol(\"DayShort\");\n/** Matches w:monthShort */\nexport const PARSED_MONTH_SHORT = Symbol(\"MonthShort\");\n/** Matches w:yearShort */\nexport const PARSED_YEAR_SHORT = Symbol(\"YearShort\");\n/** Matches w:dayLong */\nexport const PARSED_DAY_LONG = Symbol(\"DayLong\");\n/** Matches w:monthLong */\nexport const PARSED_MONTH_LONG = Symbol(\"MonthLong\");\n/** Matches w:yearLong */\nexport const PARSED_YEAR_LONG = Symbol(\"YearLong\");\n/** Matches w:annotationRef */\nexport const PARSED_ANNOTATION_REF = Symbol(\"AnnotationRef\");\n/** Matches w:separator */\nexport const PARSED_SEPARATOR = Symbol(\"Separator\");\n/** Matches w:continuationSeparator */\nexport const PARSED_CONTINUATION_SEPARATOR = Symbol(\"ContinuationSeparator\");\n/** Matches w:pgNum */\nexport const PARSED_PAGE_NUMBER = Symbol(\"PageNumber\");\n/** Matches w:lastRenderedPageBreak */\nexport const PARSED_LAST_RENDERED_PAGE_BREAK = Symbol(\"LastRenderedPageBreak\");\n\nexport type ParsedRunChild =\n | string\n | typeof PARSED_PAGE_BREAK\n | typeof PARSED_LINE_BREAK\n | typeof PARSED_TAB\n | typeof PARSED_CARRIAGE_RETURN\n | typeof PARSED_NO_BREAK_HYPHEN\n | typeof PARSED_SOFT_HYPHEN\n | typeof PARSED_FOOTNOTE_REF\n | typeof PARSED_COLUMN_BREAK\n | typeof PARSED_DAY_SHORT\n | typeof PARSED_MONTH_SHORT\n | typeof PARSED_YEAR_SHORT\n | typeof PARSED_DAY_LONG\n | typeof PARSED_MONTH_LONG\n | typeof PARSED_YEAR_LONG\n | typeof PARSED_ANNOTATION_REF\n | typeof PARSED_SEPARATOR\n | typeof PARSED_CONTINUATION_SEPARATOR\n | typeof PARSED_PAGE_NUMBER\n | typeof PARSED_LAST_RENDERED_PAGE_BREAK\n | { commentReference: number }\n | { object: ObjectElementOptions }\n | { break: number | BreakOptions }\n | { footnoteReference: number | FootnoteEndnoteReferenceOptions }\n | { endnoteReference: number | FootnoteEndnoteReferenceOptions };\n\n/**\n * Parse a w:r element into run data.\n * Returns { properties, children } where children are parsed run content items.\n */\nexport function parseRun(\n el: Element,\n _ctx: DocxReadContext,\n): {\n properties: RunPropertiesOptions | undefined;\n children: ParsedRunChild[];\n rsid?: string;\n runPropertiesRsid?: string;\n deletionRsid?: string;\n} {\n const rPr = findChild(el, \"w:rPr\");\n const properties = rPr ? parseRunProperties(rPr) : undefined;\n const children: ParsedRunChild[] = [];\n const rsid = attr(el, \"w:rsidR\");\n const runPropertiesRsid = attr(el, \"w:rsidRPr\");\n const deletionRsid = attr(el, \"w:rsidDel\");\n\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:rPr\":\n // already handled above\n break;\n case \"w:t\": {\n const preserveSpace = attrBool(child, \"xml:space\");\n let text = textOf(child);\n if (preserveSpace && text) {\n // keep leading/trailing whitespace\n // textOf already returns the raw text\n }\n children.push(text);\n break;\n }\n case \"w:delText\": {\n // Deleted text in track changes (same format as w:t)\n const text = textOf(child);\n if (text) children.push(text);\n break;\n }\n case \"w:br\": {\n const brType = attr(child, \"w:type\");\n const brClear = attr(child, \"w:clear\");\n if (brType === \"page\") {\n children.push(PARSED_PAGE_BREAK);\n } else if (brType === \"column\") {\n children.push(PARSED_COLUMN_BREAK);\n } else if (brClear) {\n // Line break clearing floating content (w:br/@w:clear) — preserve clear\n children.push({\n break: { count: 1, clear: brClear as BreakClear },\n } as unknown as ParsedRunChild);\n } else {\n children.push(PARSED_LINE_BREAK);\n }\n break;\n }\n case \"w:tab\":\n children.push(PARSED_TAB);\n break;\n case \"w:cr\":\n children.push(PARSED_CARRIAGE_RETURN);\n break;\n case \"w:noBreakHyphen\":\n children.push(PARSED_NO_BREAK_HYPHEN);\n break;\n case \"w:softHyphen\":\n children.push(PARSED_SOFT_HYPHEN);\n break;\n case \"w:commentReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) children.push({ commentReference: id });\n break;\n }\n // Drawing/pict are handled at the paragraph level (parseSectionChild in body.ts)\n // where the drawing is extracted and replaced as a paragraph child.\n case \"w:drawing\":\n case \"w:pict\":\n break;\n case \"w:object\": {\n children.push({ object: objectDesc.parse(child, _ctx) } as unknown as ParsedRunChild);\n break;\n }\n // Symbol run — extract char and font attributes\n case \"w:sym\": {\n const charVal = attr(child, \"w:char\");\n const fontVal = attr(child, \"w:font\");\n if (charVal) {\n children.push({\n symbolRun: { char: charVal, symbolfont: fontVal ?? \"Wingdings\" },\n } as unknown as ParsedRunChild);\n }\n break;\n }\n // Footnote/endnote reference — preserve as { footnoteReference: id } / { endnoteReference: id }\n case \"w:footnoteReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const customMarkFollows = attrBool(child, \"w:customMarkFollows\") === true;\n children.push(\n customMarkFollows\n ? ({\n footnoteReference: { id, customMarkFollows: true },\n } as unknown as ParsedRunChild)\n : ({ footnoteReference: id } as unknown as ParsedRunChild),\n );\n }\n break;\n }\n case \"w:endnoteReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const customMarkFollows = attrBool(child, \"w:customMarkFollows\") === true;\n children.push(\n customMarkFollows\n ? ({ endnoteReference: { id, customMarkFollows: true } } as unknown as ParsedRunChild)\n : ({ endnoteReference: id } as unknown as ParsedRunChild),\n );\n }\n break;\n }\n // Footnote/endnote ref mark inside footnote/endnote content —\n // auto-generated by Footnote/Endnote class, skip to avoid duplication.\n case \"w:footnoteRef\":\n case \"w:endnoteRef\":\n children.push(PARSED_FOOTNOTE_REF);\n break;\n // Date/time field elements\n case \"w:dayShort\":\n children.push(PARSED_DAY_SHORT);\n break;\n case \"w:monthShort\":\n children.push(PARSED_MONTH_SHORT);\n break;\n case \"w:yearShort\":\n children.push(PARSED_YEAR_SHORT);\n break;\n case \"w:dayLong\":\n children.push(PARSED_DAY_LONG);\n break;\n case \"w:monthLong\":\n children.push(PARSED_MONTH_LONG);\n break;\n case \"w:yearLong\":\n children.push(PARSED_YEAR_LONG);\n break;\n // Other empty run elements\n case \"w:annotationRef\":\n children.push(PARSED_ANNOTATION_REF);\n break;\n case \"w:separator\":\n children.push(PARSED_SEPARATOR);\n break;\n case \"w:continuationSeparator\":\n children.push(PARSED_CONTINUATION_SEPARATOR);\n break;\n case \"w:pgNum\":\n children.push(PARSED_PAGE_NUMBER);\n break;\n case \"w:lastRenderedPageBreak\":\n children.push(PARSED_LAST_RENDERED_PAGE_BREAK);\n break;\n default:\n break;\n }\n }\n\n return { properties, children, rsid, runPropertiesRsid, deletionRsid };\n}\n\n/**\n * Convert parsed run data into an RunOptions suitable for the Document constructor.\n * Simplifies the parsed children into text + break format.\n * If the run contains only a commentReference, returns { commentReference: id } instead.\n * If the run only contains footnoteRef/endnoteRef (auto-generated), returns empty options.\n *\n * When empty run elements (tab, noBreakHyphen, date fields, etc.) are present,\n * uses children[] format to preserve them for round-trip fidelity.\n */\n\n/** Mapping from parse symbols to RunOptions child objects for empty elements. */\nconst SYMBOL_TO_CHILD = new Map<symbol, Record<string, true>>([\n [PARSED_TAB, { tab: true }],\n [PARSED_CARRIAGE_RETURN, { carriageReturn: true }],\n [PARSED_NO_BREAK_HYPHEN, { noBreakHyphen: true }],\n [PARSED_SOFT_HYPHEN, { softHyphen: true }],\n [PARSED_DAY_SHORT, { dayShort: true }],\n [PARSED_MONTH_SHORT, { monthShort: true }],\n [PARSED_YEAR_SHORT, { yearShort: true }],\n [PARSED_DAY_LONG, { dayLong: true }],\n [PARSED_MONTH_LONG, { monthLong: true }],\n [PARSED_YEAR_LONG, { yearLong: true }],\n [PARSED_ANNOTATION_REF, { annotationRef: true }],\n [PARSED_SEPARATOR, { separator: true }],\n [PARSED_CONTINUATION_SEPARATOR, { continuationSeparator: true }],\n [PARSED_PAGE_NUMBER, { pgNum: true }],\n [PARSED_LAST_RENDERED_PAGE_BREAK, { lastRenderedPageBreak: true }],\n]);\n\nexport function parsedRunToOptions(\n parsed: ReturnType<typeof parseRun>,\n): RunOptions | { commentReference: number } | null {\n // Filter out footnoteRef/endnoteRef symbols (auto-generated by Footnote/Endnote class)\n const contentChildren = parsed.children.filter((c) => c !== PARSED_FOOTNOTE_REF);\n const isOnlyFootnoteRef =\n contentChildren.length === 0 && parsed.children.some((c) => c === PARSED_FOOTNOTE_REF);\n\n // If the run only contained footnoteRef/endnoteRef (no text, no other content),\n // skip it entirely — the Footnote/Endnote class auto-adds FootnoteRefRun.\n if (isOnlyFootnoteRef) {\n return null;\n }\n\n const opts: Record<string, unknown> = { ...parsed.properties };\n if (parsed.rsid) opts.rsid = parsed.rsid;\n if (parsed.runPropertiesRsid) opts.runPropertiesRsid = parsed.runPropertiesRsid;\n if (parsed.deletionRsid) opts.deletionRsid = parsed.deletionRsid;\n\n // Check if this run is a pure reference run (commentReference, footnoteReference, endnoteReference)\n const isRefChild = (c: unknown): c is Record<string, number> =>\n typeof c === \"object\" &&\n c !== null &&\n (\"commentReference\" in c || \"footnoteReference\" in c || \"endnoteReference\" in c);\n\n const refChildren = contentChildren.filter(isRefChild);\n const nonRefChildren = contentChildren.filter((c) => !isRefChild(c));\n\n // If the run is a pure reference run (no text), return it directly.\n // Drop auto-generated rStyle (e.g., \"FootnoteReference\") since it's implicit.\n if (refChildren.length > 0 && nonRefChildren.length === 0) {\n return refChildren[0] as RunOptions | { commentReference: number };\n }\n\n // If the run only contains a symbolRun, return it directly\n const symbolIdx = nonRefChildren.findIndex(\n (c) => typeof c === \"object\" && c !== null && \"symbolRun\" in c,\n );\n if (symbolIdx >= 0 && nonRefChildren.length === 1 && !parsed.properties) {\n return nonRefChildren[symbolIdx] as unknown as RunOptions;\n }\n\n // If the run contains an OLE object (w:object), return it directly with any\n // run properties — an OLE object occupies its own run.\n const objectIdx = nonRefChildren.findIndex(\n (c) => typeof c === \"object\" && c !== null && \"object\" in c,\n );\n if (objectIdx >= 0) {\n const objectChild = nonRefChildren[objectIdx] as { object: ObjectElementOptions };\n return { ...parsed.properties, ...objectChild } as unknown as RunOptions;\n }\n\n // Collect text and breaks\n const textParts: string[] = [];\n let breakCount = 0;\n const structuredBreaks: BreakOptions[] = [];\n let hasPageBreak = false;\n let hasColumnBreak = false;\n const extraChildren: Record<string, true>[] = [];\n\n for (const child of nonRefChildren) {\n if (typeof child === \"string\") {\n textParts.push(child);\n } else if (child === PARSED_LINE_BREAK) {\n breakCount++;\n } else if (child === PARSED_PAGE_BREAK) {\n hasPageBreak = true;\n } else if (child === PARSED_COLUMN_BREAK) {\n hasColumnBreak = true;\n } else if (typeof child === \"object\" && child !== null && \"break\" in child) {\n // Line break carrying a clear attribute (w:br/@w:clear) — preserve structure\n structuredBreaks.push((child as { break: BreakOptions }).break);\n } else {\n // Empty run elements (tab, noBreakHyphen, date fields, etc.)\n const mapped = SYMBOL_TO_CHILD.get(child as symbol);\n if (mapped) extraChildren.push(mapped);\n }\n }\n\n // A single structured break (with clear) coexists cleanly with text/page/column\n // breaks via opts.break; mixed or multiple breaks fall back to children[] form.\n const hasStructuredBreaks = structuredBreaks.length > 0;\n const useChildrenForm =\n extraChildren.length > 0 ||\n (hasStructuredBreaks &&\n (breakCount > 0 || structuredBreaks.length > 1 || hasPageBreak || hasColumnBreak));\n\n if (useChildrenForm) {\n const children: (string | Record<string, unknown>)[] = [];\n for (const child of nonRefChildren) {\n if (typeof child === \"string\") {\n children.push(child);\n } else if (child === PARSED_LINE_BREAK) {\n children.push({ break: 1 });\n } else if (child === PARSED_PAGE_BREAK) {\n children.push({ pageBreak: true });\n } else if (child === PARSED_COLUMN_BREAK) {\n children.push({ columnBreak: true });\n } else if (typeof child === \"object\" && child !== null && \"break\" in child) {\n children.push({ break: (child as { break: BreakOptions }).break });\n } else {\n const mapped = SYMBOL_TO_CHILD.get(child as symbol);\n if (mapped) children.push(mapped);\n }\n }\n opts.children = children;\n } else {\n if (textParts.length > 0) {\n opts.text = textParts.join(\"\");\n }\n if (breakCount > 0) {\n opts.break = breakCount;\n } else if (hasStructuredBreaks) {\n opts.break = structuredBreaks[0];\n }\n if (hasPageBreak) {\n opts.pageBreak = true;\n }\n if (hasColumnBreak) {\n opts.columnBreak = true;\n }\n }\n\n // If the run has no content and no properties (e.g., a pure drawing run),\n // return null so it can be skipped by the caller.\n if (\n Object.keys(opts).length === 0 &&\n textParts.length === 0 &&\n breakCount === 0 &&\n !hasPageBreak &&\n !hasColumnBreak &&\n extraChildren.length === 0\n ) {\n return null;\n }\n\n return opts as RunOptions;\n}\n","/**\n * Direct XML string builders for paragraph and run properties.\n *\n * Replaces `buildParagraphProperties() + xml()` and `buildRunProperties() + xml()`\n * with direct string concatenation — zero intermediate IXmlableObject allocation,\n * zero recursive xml() traversal. Follows PPTX/XLSX pattern.\n *\n * @module\n */\n\nimport {\n decimalNumber,\n eighthPointMeasureValue,\n hexColorValue,\n hpsMeasureValue,\n pointMeasureValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n uCharHexNumber,\n} from \"@office-open/core\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { CnfConditionalOptions } from \"@parts/paragraph/formatting/cnf-style\";\nimport type { IndentAttributesProperties } from \"@parts/paragraph/formatting/indent\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport type { TabStopDefinition } from \"@parts/paragraph/formatting/tab-stop\";\nimport type { FrameOptions } from \"@parts/paragraph/frame/frame-properties\";\nimport type { ParagraphPropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { EastAsianLayoutOptions } from \"@parts/paragraph/run/east-asian-layout\";\nimport type { ColorOptions } from \"@parts/paragraph/run/formatting\";\nimport type { LanguageOptions } from \"@parts/paragraph/run/language\";\nimport type {\n ParagraphRunPropertiesOptions,\n RunPropertiesChangeOptions,\n RunPropertiesOptions,\n} from \"@parts/paragraph/run/properties\";\nimport type { FontAttributesProperties } from \"@parts/paragraph/run/run-fonts\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\n\n// ── Inline helpers ──\n\n/** On/off: `<w:name/>` for true, `<w:name w:val=\"0\"/>` for false */\nexport function onOff(name: string, val: boolean): string {\n return val ? `<${name}/>` : `<${name} w:val=\"0\"/>`;\n}\n\n/** Build attrs string from key-value pairs, skipping undefined */\nexport function attrParts(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [key, val] of Object.entries(attrs)) {\n if (val !== undefined) parts.push(`${key}=\"${val}\"`);\n }\n return parts.join(\" \");\n}\n\n// ── Border ──\n\nexport function borderStr(name: string, opts: BorderOptions): string {\n const a = attrParts({\n \"w:val\": opts.style,\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:sz\": opts.size !== undefined ? eighthPointMeasureValue(opts.size) : undefined,\n \"w:space\": opts.space !== undefined ? pointMeasureValue(opts.space) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:shadow\": opts.shadow !== undefined ? (opts.shadow ? 1 : 0) : undefined,\n \"w:frame\": opts.frame !== undefined ? (opts.frame ? 1 : 0) : undefined,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Shading ──\n\nexport function shadingStr(opts: ShadingAttributesProperties): string {\n const a = attrParts({\n \"w:val\": opts.type ?? \"clear\",\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:fill\": opts.fill !== undefined ? hexColorValue(opts.fill) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:themeFill\": opts.themeFill,\n \"w:themeFillTint\":\n opts.themeFillTint !== undefined ? uCharHexNumber(opts.themeFillTint) : undefined,\n \"w:themeFillShade\":\n opts.themeFillShade !== undefined ? uCharHexNumber(opts.themeFillShade) : undefined,\n });\n return `<w:shd ${a}/>`;\n}\n\n// ── Spacing ──\n\nfunction spacingStr(opts: SpacingProperties): string {\n const a = attrParts({\n \"w:after\": opts.after !== undefined ? twipsMeasureValue(opts.after) : undefined,\n \"w:afterAutospacing\":\n opts.afterAutoSpacing !== undefined ? (opts.afterAutoSpacing ? 1 : 0) : undefined,\n \"w:afterLines\": opts.afterLines !== undefined ? decimalNumber(opts.afterLines) : undefined,\n \"w:before\": opts.before !== undefined ? twipsMeasureValue(opts.before) : undefined,\n \"w:beforeAutospacing\":\n opts.beforeAutoSpacing !== undefined ? (opts.beforeAutoSpacing ? 1 : 0) : undefined,\n \"w:beforeLines\": opts.beforeLines !== undefined ? decimalNumber(opts.beforeLines) : undefined,\n \"w:line\": opts.line !== undefined ? twipsMeasureValue(opts.line) : undefined,\n \"w:lineRule\": opts.lineRule,\n });\n return `<w:spacing ${a}/>`;\n}\n\n// ── Indent ──\n\nfunction indentStr(opts: IndentAttributesProperties): string {\n const a = attrParts({\n \"w:start\": opts.start !== undefined ? signedTwipsMeasureValue(opts.start) : undefined,\n \"w:startChars\": opts.startChars !== undefined ? decimalNumber(opts.startChars) : undefined,\n \"w:end\": opts.end !== undefined ? signedTwipsMeasureValue(opts.end) : undefined,\n \"w:endChars\": opts.endChars !== undefined ? decimalNumber(opts.endChars) : undefined,\n \"w:left\": opts.left !== undefined ? signedTwipsMeasureValue(opts.left) : undefined,\n \"w:leftChars\": opts.leftChars !== undefined ? decimalNumber(opts.leftChars) : undefined,\n \"w:right\": opts.right !== undefined ? signedTwipsMeasureValue(opts.right) : undefined,\n \"w:rightChars\": opts.rightChars !== undefined ? decimalNumber(opts.rightChars) : undefined,\n \"w:hanging\": opts.hanging !== undefined ? twipsMeasureValue(opts.hanging) : undefined,\n \"w:hangingChars\":\n opts.hangingChars !== undefined ? decimalNumber(opts.hangingChars) : undefined,\n \"w:firstLine\": opts.firstLine !== undefined ? twipsMeasureValue(opts.firstLine) : undefined,\n \"w:firstLineChars\":\n opts.firstLineChars !== undefined ? decimalNumber(opts.firstLineChars) : undefined,\n });\n return `<w:ind ${a}/>`;\n}\n\n// ── Tab stops ──\n\nfunction tabStopsStr(defs: TabStopDefinition[]): string {\n const items = defs.map(({ type, position, leader }) => {\n const a = attrParts({ \"w:val\": type, \"w:pos\": position, \"w:leader\": leader });\n return `<w:tab ${a}/>`;\n });\n return `<w:tabs>${items.join(\"\")}</w:tabs>`;\n}\n\n// ── CNF style ──\n\nfunction cnfStyleStr(opts: CnfConditionalOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow ? \"1\" : \"0\",\n \"w:lastRow\": opts.lastRow ? \"1\" : \"0\",\n \"w:firstColumn\": opts.firstColumn ? \"1\" : \"0\",\n \"w:lastColumn\": opts.lastColumn ? \"1\" : \"0\",\n \"w:oddVBand\": opts.oddVBand ? \"1\" : \"0\",\n \"w:evenVBand\": opts.evenVBand ? \"1\" : \"0\",\n \"w:oddHBand\": opts.oddHBand ? \"1\" : \"0\",\n \"w:evenHBand\": opts.evenHBand ? \"1\" : \"0\",\n \"w:firstRowFirstColumn\": opts.firstRowFirstColumn ? \"1\" : \"0\",\n \"w:firstRowLastColumn\": opts.firstRowLastColumn ? \"1\" : \"0\",\n \"w:lastRowFirstColumn\": opts.lastRowFirstColumn ? \"1\" : \"0\",\n \"w:lastRowLastColumn\": opts.lastRowLastColumn ? \"1\" : \"0\",\n });\n return `<w:cnfStyle ${a}/>`;\n}\n\n// ── Frame properties ──\n\nfunction framePrStr(opts: FrameOptions): string {\n const alignment = (opts as { alignment?: { x?: string; y?: string } }).alignment;\n const position = (opts as { position?: { x?: number; y?: number } }).position;\n const a = attrParts({\n \"w:xAlign\": alignment?.x,\n \"w:yAlign\": alignment?.y,\n \"w:hAnchor\": opts.anchor?.horizontal,\n \"w:anchorLock\": opts.anchorLock,\n \"w:vAnchor\": opts.anchor?.vertical,\n \"w:dropCap\": opts.dropCap,\n \"w:h\": opts.height,\n \"w:lines\": opts.lines,\n \"w:hRule\": opts.rule,\n \"w:hSpace\": opts.space?.horizontal,\n \"w:vSpace\": opts.space?.vertical,\n \"w:w\": opts.width,\n \"w:wrap\": opts.wrap,\n \"w:x\": position?.x,\n \"w:y\": position?.y,\n });\n return `<w:framePr ${a}/>`;\n}\n\n// ── Number properties ──\n\nfunction numPrStr(\n numberId: number | string,\n indentLevel: number,\n numberingChange?: { original: string; id: string; author: string; date?: string },\n): string {\n const idVal = typeof numberId === \"string\" ? `{${numberId}}` : numberId;\n const parts = [`<w:ilvl w:val=\"${Math.min(indentLevel, 9)}\"/>`, `<w:numId w:val=\"${idVal}\"/>`];\n if (numberingChange) {\n const a = attrParts({\n \"w:original\": numberingChange.original,\n \"w:id\": numberingChange.id,\n \"w:author\": numberingChange.author,\n \"w:date\": numberingChange.date,\n });\n parts.push(`<w:numberingChange ${a}/>`);\n }\n return `<w:numPr>${parts.join(\"\")}</w:numPr>`;\n}\n\n// ── Run-level formatting helpers ──\n\nfunction colorStr(colorOrOptions: string | ColorOptions): string {\n if (typeof colorOrOptions === \"string\") {\n return `<w:color w:val=\"${hexColorValue(colorOrOptions)}\"/>`;\n }\n const opts = colorOrOptions;\n const a = attrParts({\n \"w:val\": opts.val !== undefined ? hexColorValue(opts.val) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n });\n return `<w:color ${a}/>`;\n}\n\nfunction runFontsStr(nameOrAttrs: string | FontAttributesProperties, hint?: string): string {\n if (typeof nameOrAttrs === \"string\") {\n const a = attrParts({\n \"w:ascii\": nameOrAttrs,\n \"w:cs\": nameOrAttrs,\n \"w:eastAsia\": nameOrAttrs,\n \"w:hAnsi\": nameOrAttrs,\n \"w:hint\": hint,\n });\n return `<w:rFonts ${a}/>`;\n }\n const attrs = nameOrAttrs;\n const a = attrParts({\n \"w:ascii\": attrs.ascii,\n \"w:asciiTheme\": attrs.asciiTheme,\n \"w:cs\": attrs.cs,\n \"w:cstheme\": attrs.cstheme,\n \"w:eastAsia\": attrs.eastAsia,\n \"w:eastAsiaTheme\": attrs.eastAsiaTheme,\n \"w:hAnsi\": attrs.hAnsi,\n \"w:hAnsiTheme\": attrs.hAnsiTheme,\n \"w:hint\": attrs.hint,\n });\n return `<w:rFonts ${a}/>`;\n}\n\nfunction underlineStr(type: string | undefined, color?: string): string {\n const a = attrParts({\n \"w:val\": type ?? \"single\",\n \"w:color\": color !== undefined ? hexColorValue(color) : undefined,\n });\n return `<w:u ${a}/>`;\n}\n\nfunction eastAsianLayoutStr(opts: EastAsianLayoutOptions): string {\n const a = attrParts({\n \"w:id\": opts.id !== undefined ? decimalNumber(opts.id) : undefined,\n \"w:combine\": opts.combine !== undefined ? (opts.combine ? 1 : 0) : undefined,\n \"w:combineBrackets\": opts.combineBrackets,\n \"w:vert\": opts.vert !== undefined ? (opts.vert ? 1 : 0) : undefined,\n \"w:vertCompress\": opts.vertCompress !== undefined ? (opts.vertCompress ? 1 : 0) : undefined,\n });\n return `<w:eastAsianLayout ${a}/>`;\n}\n\nfunction languageStr(opts: LanguageOptions): string {\n const a = attrParts({\n \"w:val\": opts.value,\n \"w:eastAsia\": opts.eastAsia,\n \"w:bidi\": opts.bidirectional,\n });\n return `<w:lang ${a}/>`;\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Paragraph Properties\n// ════════════════════════════════════════════════════════════════════════════\n\nexport interface StringifyPPrResult {\n xml: string | undefined;\n numberingReferences: { reference: string; instance: number }[];\n}\n\n/**\n * Build `<w:pPr>` XML string directly from options — zero IXmlableObject allocation.\n *\n * Replaces `buildParagraphProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyParagraphProperties(\n options?: ParagraphPropertiesOptions,\n): StringifyPPrResult {\n const numberingReferences: { reference: string; instance: number }[] = [];\n\n if (!options) return { xml: undefined, numberingReferences };\n\n const parts: string[] = [];\n\n // Style / heading / bullet / numbering style references\n if (options.heading) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.heading)}\"/>`);\n }\n\n if (options.bullet) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n\n if (options.numbering) {\n if (!options.style && !options.heading) {\n if (!options.numbering.custom) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n }\n }\n\n if (options.style) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.style)}\"/>`);\n }\n\n // CT_PPrBase element order per XSD (wml.xsd) — strictly ordered sequence.\n // 1-4: keepNext, keepLines, pageBreakBefore\n if (options.keepNext !== undefined) parts.push(onOff(\"w:keepNext\", options.keepNext));\n if (options.keepLines !== undefined) parts.push(onOff(\"w:keepLines\", options.keepLines));\n if (options.pageBreakBefore !== undefined)\n parts.push(onOff(\"w:pageBreakBefore\", options.pageBreakBefore));\n\n // 5: framePr\n if (options.frame) parts.push(framePrStr(options.frame));\n\n // 6: widowControl\n if (options.widowControl !== undefined) parts.push(onOff(\"w:widowControl\", options.widowControl));\n\n // 7: numPr\n if (options.bullet) {\n parts.push(\n `<w:numPr><w:ilvl w:val=\"${Math.min(options.bullet.level, 9)}\"/><w:numId w:val=\"1\"/></w:numPr>`,\n );\n }\n\n if (options.numbering) {\n numberingReferences.push({\n instance: options.numbering.instance ?? 0,\n reference: options.numbering.reference,\n });\n\n const numId = `${options.numbering.reference}-${options.numbering.instance ?? 0}`;\n parts.push(numPrStr(numId, options.numbering.level, options.numbering.numberingChange));\n } else if (options.numbering === false) {\n parts.push(numPrStr(0, 0));\n }\n\n // 8: suppressLineNumbers\n if (options.suppressLineNumbers !== undefined)\n parts.push(onOff(\"w:suppressLineNumbers\", options.suppressLineNumbers));\n\n // 9: pBdr\n if (options.border) {\n const bParts: string[] = [];\n if (options.border.top) bParts.push(borderStr(\"w:top\", options.border.top));\n if (options.border.left) bParts.push(borderStr(\"w:left\", options.border.left));\n if (options.border.bottom) bParts.push(borderStr(\"w:bottom\", options.border.bottom));\n if (options.border.right) bParts.push(borderStr(\"w:right\", options.border.right));\n if (options.border.between) bParts.push(borderStr(\"w:between\", options.border.between));\n if (options.border.bar) bParts.push(borderStr(\"w:bar\", options.border.bar));\n if (bParts.length) parts.push(`<w:pBdr>${bParts.join(\"\")}</w:pBdr>`);\n }\n\n if (options.thematicBreak) {\n parts.push(\n `<w:pBdr>${borderStr(\"w:bottom\", { color: \"auto\", size: 6, space: 1, style: BorderStyle.SINGLE })}</w:pBdr>`,\n );\n }\n\n // 10: shd\n if (options.shading) parts.push(shadingStr(options.shading));\n\n // 11: tabs\n const tabDefs: TabStopDefinition[] = [\n ...(options.rightTabStop !== undefined\n ? [{ position: options.rightTabStop, type: \"right\" as const }]\n : []),\n ...(options.tabStops ? options.tabStops : []),\n ...(options.leftTabStop !== undefined\n ? [{ position: options.leftTabStop, type: \"left\" as const }]\n : []),\n ];\n if (tabDefs.length > 0) parts.push(tabStopsStr(tabDefs));\n\n // 12-18: suppressAutoHyphens, kinsoku, wordWrap, overflowPunct, topLinePunct, autoSpaceDE, autoSpaceDN\n if (options.suppressAutoHyphens !== undefined)\n parts.push(onOff(\"w:suppressAutoHyphens\", options.suppressAutoHyphens));\n if (options.kinsoku !== undefined) parts.push(onOff(\"w:kinsoku\", options.kinsoku));\n if (options.wordWrap !== undefined) parts.push(onOff(\"w:wordWrap\", options.wordWrap));\n if (options.overflowPunctuation)\n parts.push(onOff(\"w:overflowPunct\", options.overflowPunctuation));\n if (options.topLinePunct !== undefined) parts.push(onOff(\"w:topLinePunct\", options.topLinePunct));\n if (options.autoSpaceDE !== undefined) parts.push(onOff(\"w:autoSpaceDE\", options.autoSpaceDE));\n if (options.autoSpaceEastAsianText !== undefined)\n parts.push(onOff(\"w:autoSpaceDN\", options.autoSpaceEastAsianText));\n\n // 19: bidi\n if (options.bidirectional !== undefined) parts.push(onOff(\"w:bidi\", options.bidirectional));\n\n // 20-21: adjustRightInd, snapToGrid\n if (options.adjustRightInd !== undefined)\n parts.push(onOff(\"w:adjustRightInd\", options.adjustRightInd));\n if (options.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", options.snapToGrid));\n\n // 22-24: spacing, ind, contextualSpacing\n if (options.spacing) parts.push(spacingStr(options.spacing));\n if (options.indent) parts.push(indentStr(options.indent));\n if (options.contextualSpacing !== undefined)\n parts.push(onOff(\"w:contextualSpacing\", options.contextualSpacing));\n\n // 25-26: mirrorIndents, suppressOverlap\n if (options.mirrorIndents !== undefined)\n parts.push(onOff(\"w:mirrorIndents\", options.mirrorIndents));\n if (options.suppressOverlap !== undefined)\n parts.push(onOff(\"w:suppressOverlap\", options.suppressOverlap));\n\n // 27: jc\n if (options.alignment) parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n\n // 28-30: textDirection, textAlignment, textboxTightWrap\n if (options.textDirection !== undefined)\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n if (options.textAlignment !== undefined)\n parts.push(`<w:textAlignment w:val=\"${options.textAlignment}\"/>`);\n if (options.textboxTightWrap !== undefined)\n parts.push(`<w:textboxTightWrap w:val=\"${options.textboxTightWrap}\"/>`);\n\n // 31-33: outlineLvl, divId, cnfStyle\n if (options.outlineLevel !== undefined)\n parts.push(`<w:outlineLvl w:val=\"${options.outlineLevel}\"/>`);\n if (options.divId !== undefined) parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n if (options.cnfStyle) parts.push(cnfStyleStr(options.cnfStyle));\n\n // Embedded run properties (w:rPr inside w:pPr)\n if (options.run) {\n const inner = stringifyRunPropertiesInner(options.run);\n if (inner !== undefined) {\n const extra: string[] = [];\n const runOpts = options.run as ParagraphRunPropertiesOptions;\n if (runOpts.insertion) {\n const { id, author, date } = runOpts.insertion;\n extra.push(`<w:ins w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n if (runOpts.deletion) {\n const { id, author, date } = runOpts.deletion;\n extra.push(`<w:del w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n const body = inner + extra.join(\"\");\n parts.push(`<w:rPr>${body}</w:rPr>`);\n }\n }\n\n // Revision (pPrChange)\n if (options.revision) {\n const rev = options.revision;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyParagraphProperties({ ...originalProps, includeIfEmpty: true });\n parts.push(\n `<w:pPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\">${inner.xml ?? \"<w:pPr/>\"}</w:pPrChange>`,\n );\n }\n\n const body = parts.join(\"\");\n const xml = options.includeIfEmpty || body.length > 0 ? `<w:pPr>${body}</w:pPr>` : undefined;\n return { xml, numberingReferences };\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Run Properties\n// ════════════════════════════════════════════════════════════════════════════\n\n/**\n * Build the inner content of `<w:rPr>` as a string.\n * Returns undefined if no properties are set.\n */\nexport function stringifyRunPropertiesInner(opts?: RunPropertiesOptions): string | undefined {\n if (!opts) return undefined;\n\n const parts: string[] = [];\n\n // Style\n if (opts.style) parts.push(`<w:rStyle w:val=\"${escapeXml(opts.style)}\"/>`);\n\n // Font\n if (opts.font) {\n if (typeof opts.font === \"string\") {\n parts.push(runFontsStr(opts.font));\n } else if (\"name\" in opts.font) {\n parts.push(runFontsStr(opts.font.name, opts.font.hint));\n } else {\n parts.push(runFontsStr(opts.font));\n }\n }\n\n // Bold — w:b and w:bCs are independent toggle properties (Latin vs complex\n // script, per ISO/IEC 29500). Emit each only when explicitly set so round-trip\n // is field-faithful (source <w:b/> stays <w:b/>, not inflated to <w:b/><w:bCs/>).\n if (opts.bold !== undefined) parts.push(onOff(\"w:b\", opts.bold));\n if (opts.boldComplexScript !== undefined) parts.push(onOff(\"w:bCs\", opts.boldComplexScript));\n\n // Italic — w:i and w:iCs are independent (same rationale as bold).\n if (opts.italic !== undefined) parts.push(onOff(\"w:i\", opts.italic));\n if (opts.italicComplexScript !== undefined) parts.push(onOff(\"w:iCs\", opts.italicComplexScript));\n\n // Caps\n if (opts.smallCaps !== undefined) {\n parts.push(onOff(\"w:smallCaps\", opts.smallCaps));\n } else if (opts.allCaps !== undefined) {\n parts.push(onOff(\"w:caps\", opts.allCaps));\n }\n\n // Strike\n if (opts.strike !== undefined) parts.push(onOff(\"w:strike\", opts.strike));\n if (opts.doubleStrike !== undefined) parts.push(onOff(\"w:dstrike\", opts.doubleStrike));\n if (opts.emboss !== undefined) parts.push(onOff(\"w:emboss\", opts.emboss));\n if (opts.imprint !== undefined) parts.push(onOff(\"w:imprint\", opts.imprint));\n if (opts.outline !== undefined) parts.push(onOff(\"w:outline\", opts.outline));\n if (opts.shadow !== undefined) parts.push(onOff(\"w:shadow\", opts.shadow));\n if (opts.webHidden !== undefined) parts.push(onOff(\"w:webHidden\", opts.webHidden));\n if (opts.noProof !== undefined) parts.push(onOff(\"w:noProof\", opts.noProof));\n if (opts.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", opts.snapToGrid));\n if (opts.vanish) parts.push(onOff(\"w:vanish\", opts.vanish));\n\n // Color\n if (opts.color) parts.push(colorStr(opts.color));\n\n // Character spacing\n if (opts.characterSpacing) {\n parts.push(`<w:spacing w:val=\"${signedTwipsMeasureValue(opts.characterSpacing)}\"/>`);\n }\n\n // Scale\n if (opts.scale !== undefined) parts.push(`<w:w w:val=\"${opts.scale}\"/>`);\n\n // Kern — w:val=\"0\" is meaningful (explicitly disables kerning), so emit\n // whenever the field is set rather than truthy-checking it.\n if (opts.kern !== undefined) parts.push(`<w:kern w:val=\"${hpsMeasureValue(opts.kern)}\"/>`);\n\n // Position\n if (opts.position) parts.push(`<w:position w:val=\"${opts.position}\"/>`);\n\n // Size (points → half-points). sz and szCs are independent (Latin vs complex\n // script); emit each only when set so round-trip is field-faithful.\n if (opts.size !== undefined) parts.push(`<w:sz w:val=\"${hpsMeasureValue(opts.size * 2)}\"/>`);\n if (opts.sizeComplexScript !== undefined) {\n parts.push(`<w:szCs w:val=\"${hpsMeasureValue(opts.sizeComplexScript * 2)}\"/>`);\n }\n\n // Highlight — independent Latin vs complex-script values.\n if (opts.highlight) parts.push(`<w:highlight w:val=\"${opts.highlight}\"/>`);\n if (opts.highlightComplexScript !== undefined) {\n parts.push(`<w:highlightCs w:val=\"${opts.highlightComplexScript}\"/>`);\n }\n\n // Underline\n if (opts.underline) parts.push(underlineStr(opts.underline.type, opts.underline.color));\n\n // Effect\n if (opts.effect) parts.push(`<w:effect w:val=\"${opts.effect}\"/>`);\n\n // Border\n if (opts.border) parts.push(borderStr(\"w:bdr\", opts.border));\n\n // Shading\n if (opts.shading) parts.push(shadingStr(opts.shading));\n\n // Vertical alignment\n if (opts.subScript) parts.push('<w:vertAlign w:val=\"subscript\"/>');\n if (opts.superScript) parts.push('<w:vertAlign w:val=\"superscript\"/>');\n\n // RTL\n if (opts.rightToLeft !== undefined) parts.push(onOff(\"w:rtl\", opts.rightToLeft));\n\n // Emphasis mark\n if (opts.emphasisMark) parts.push(`<w:em w:val=\"${opts.emphasisMark.type ?? \"dot\"}\"/>`);\n\n // Language\n if (opts.language) parts.push(languageStr(opts.language));\n\n // Spec vanish\n if (opts.specVanish) parts.push(\"<w:specVanish/>\");\n\n // Math\n if (opts.math) parts.push(onOff(\"w:oMath\", opts.math));\n\n // Fit text\n if (opts.fitText !== undefined) parts.push(`<w:fitText w:val=\"${opts.fitText}\"/>`);\n\n // Complex script\n if (opts.complexScript !== undefined) parts.push(onOff(\"w:cs\", opts.complexScript));\n\n // East Asian layout\n if (opts.eastAsianLayout) parts.push(eastAsianLayoutStr(opts.eastAsianLayout));\n\n // Content part\n if (opts.contentPartRId) parts.push(`<w:contentPart r:id=\"${opts.contentPartRId}\"/>`);\n\n // Revision (rPrChange)\n if (opts.revision) {\n const rev = opts.revision as RunPropertiesChangeOptions;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyRunPropertiesInner(originalProps as RunPropertiesOptions);\n parts.push(\n `<w:rPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\"><w:rPr>${inner ?? \"\"}</w:rPr></w:rPrChange>`,\n );\n }\n\n // w14:* text effects — raw passthrough, emitted last (EG_RPrBase extension slot)\n if (opts.w14RawXml) parts.push(opts.w14RawXml);\n\n return parts.length > 0 ? parts.join(\"\") : undefined;\n}\n\n/**\n * Build `<w:rPr>` XML string directly from options — zero IXmlableObject allocation.\n *\n * Replaces `buildRunProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyRunProperties(opts?: RunPropertiesOptions): string | undefined {\n const inner = stringifyRunPropertiesInner(opts);\n return inner ? `<w:rPr>${inner}</w:rPr>` : undefined;\n}\n","/**\n * Body-level child descriptors for DOCX.\n *\n * Provides descriptor-based stringification for section children.\n * All types use pure string builders — zero class instantiation, zero toXml().\n *\n * @module\n */\n\nimport { toUint8Array, uniqueId } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport {\n attr,\n attrBool,\n attrNum,\n children as xmlChildren,\n escapeXml,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AltChunkOptions } from \"@parts/alt-chunk/alt-chunk\";\nimport type { CustomXmlPropertiesOptions } from \"@parts/custom-xml/custom-xml\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport { stringifyRunPropertiesInner } from \"@parts/paragraph/stringify\";\nimport type { SubDocOptions } from \"@parts/sub-doc/sub-doc\";\nimport type {\n SdtCheckboxOptions,\n SdtDateOptions,\n SdtPropertiesOptions,\n} from \"@parts/table-of-contents\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\n// ── AltChunk (pure string — registers relationships + altChunks) ──\n\nconst ALTCHUNK_REL_TYPE =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\";\n\nfunction wrapHtmlDocument(fragment: string): string {\n if (/<(!DOCTYPE|html|HTML)/i.test(fragment)) {\n return fragment;\n }\n return `<!DOCTYPE html>\\n<html><head><meta charset=\"utf-8\"></head>\\n<body>${fragment}</body></html>`;\n}\n\nexport const altChunkDesc: CustomDescriptor<AltChunkOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const relId = uniqueId();\n const extension = opts.extension;\n const partPath = `afchunks/afchunk${relId}.${extension}`;\n const rawData = typeof opts.data === \"string\" ? toUint8Array(opts.data) : opts.data;\n const data =\n opts.contentType === \"text/html\" && typeof opts.data === \"string\"\n ? toUint8Array(wrapHtmlDocument(opts.data))\n : rawData;\n\n ctx.fileData.document.relationships.addRelationship(relId, ALTCHUNK_REL_TYPE, partPath);\n ctx.fileData.altChunks.addAltChunk(relId, {\n key: relId,\n data,\n path: partPath,\n extension,\n contentType: opts.contentType,\n });\n\n const rId = `rId${relId}`;\n if (opts.matchSource) {\n return `<w:altChunk r:id=\"${rId}\"><w:altChunkPr><w:matchSrc/></w:altChunkPr></w:altChunk>`;\n }\n return `<w:altChunk r:id=\"${rId}\"/>`;\n },\n\n parse(el, ctx) {\n const rId = attr(el, \"r:id\");\n const opts: Partial<AltChunkOptions> = {};\n\n // Check for matchSource\n const altChunkPr = findChild(el, \"w:altChunkPr\");\n if (altChunkPr && findChild(altChunkPr, \"w:matchSrc\")) {\n opts.matchSource = true;\n }\n\n // Resolve the altChunk data from relationships\n const dctx = ctx as DocxReadContext;\n if (rId) {\n const path = dctx.resolveRelationship(rId);\n if (path) {\n const data = dctx.getRaw(path);\n if (data) {\n opts.data = data;\n const ext = path.split(\".\").pop() ?? \"txt\";\n switch (ext) {\n case \"html\":\n opts.contentType = \"text/html\";\n opts.extension = \"html\";\n break;\n case \"rtf\":\n opts.contentType = \"application/rtf\";\n opts.extension = \"rtf\";\n break;\n default:\n opts.contentType = \"text/plain\";\n opts.extension = \"txt\";\n break;\n }\n }\n }\n }\n\n return opts as AltChunkOptions;\n },\n};\n\n// ── SubDoc (pure string — registers relationships + subDocs) ──\n\nconst SUBDOC_REL_TYPE =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument\";\n\nexport const subDocDesc: CustomDescriptor<SubDocOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const relId = uniqueId();\n const partPath = `subdocs/subdoc${relId}.docx`;\n const data = toUint8Array(opts.data);\n\n ctx.fileData.document.relationships.addRelationship(relId, SUBDOC_REL_TYPE, partPath);\n ctx.fileData.subDocs.addSubDoc(relId, {\n data,\n path: partPath,\n });\n\n return `<w:subDoc r:id=\"rId${relId}\"/>`;\n },\n\n parse(el, ctx) {\n const rId = attr(el, \"r:id\");\n const dctx = ctx as DocxReadContext;\n if (rId) {\n const path = dctx.resolveRelationship(rId);\n if (path) {\n const data = dctx.getRaw(path);\n if (data) {\n return { data } as SubDocOptions;\n }\n }\n }\n return { data: new Uint8Array(0) } as SubDocOptions;\n },\n};\n\n// ── SDT (pure string — inline sdtPr + stringify children) ──\n\nexport interface SdtBlockOptions {\n properties: SdtPropertiesOptions;\n children?: SectionChild[];\n /** Run properties for the SDT end mark (w:sdtEndPr). */\n endProperties?: RunPropertiesOptions;\n}\n\nfunction sdtListItemXml(\n item: { displayText?: string; value?: string },\n forceValue?: boolean,\n): string {\n const attrs: string[] = [];\n if (item.displayText !== undefined) attrs.push(`w:displayText=\"${escapeXml(item.displayText)}\"`);\n const value = item.value ?? (forceValue ? item.displayText : undefined);\n if (value !== undefined) attrs.push(`w:value=\"${escapeXml(value)}\"`);\n return `<w:listItem ${attrs.join(\" \")}/>`;\n}\n\nfunction sdtListTypeXml(\n name: string,\n options: { items?: { displayText?: string; value?: string }[]; lastValue?: string },\n): string {\n const parts: string[] = [];\n if (options.items) {\n for (const item of options.items) {\n parts.push(sdtListItemXml(item, name === \"w:dropDownList\"));\n }\n }\n const attrs: string[] = [];\n if (options.lastValue !== undefined) attrs.push(`w:lastValue=\"${escapeXml(options.lastValue)}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return parts.length ? `<${name}${attrStr}>${parts.join(\"\")}</${name}>` : `<${name}${attrStr}/>`;\n}\n\nfunction sdtDateXml(options: {\n dateFormat?: string;\n languageId?: string;\n storeMappedDataAs?: string;\n calendar?: string;\n fullDate?: string;\n}): string {\n const parts: string[] = [];\n if (options.dateFormat !== undefined)\n parts.push(`<w:dateFormat w:val=\"${escapeXml(options.dateFormat)}\"/>`);\n if (options.languageId !== undefined)\n parts.push(`<w:lid w:val=\"${escapeXml(options.languageId)}\"/>`);\n if (options.storeMappedDataAs !== undefined)\n parts.push(`<w:storeMappedDataAs w:val=\"${options.storeMappedDataAs}\"/>`);\n if (options.calendar !== undefined) parts.push(`<w:calendar w:val=\"${options.calendar}\"/>`);\n const attrs: string[] = [];\n if (options.fullDate !== undefined) attrs.push(`w:fullDate=\"${options.fullDate}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return parts.length ? `<w:date${attrStr}>${parts.join(\"\")}</w:date>` : `<w:date${attrStr}/>`;\n}\n\nfunction sdtDataBindingXml(options: {\n prefixMappings?: string;\n xpath: string;\n storeItemID: string;\n}): string {\n const attrs: string[] = [\n `w:xpath=\"${escapeXml(options.xpath)}\"`,\n `w:storeItemID=\"${escapeXml(options.storeItemID)}\"`,\n ];\n if (options.prefixMappings !== undefined)\n attrs.push(`w:prefixMappings=\"${escapeXml(options.prefixMappings)}\"`);\n return `<w:dataBinding ${attrs.join(\" \")}/>`;\n}\n\nfunction sdtDocPartXml(\n name: string,\n options: { gallery?: string; category?: string; unique?: boolean },\n): string {\n const parts: string[] = [];\n if (options.gallery !== undefined)\n parts.push(`<w:docPartGallery w:val=\"${escapeXml(options.gallery)}\"/>`);\n if (options.category !== undefined)\n parts.push(`<w:docPartCategory w:val=\"${escapeXml(options.category)}\"/>`);\n if (options.unique !== undefined)\n parts.push(options.unique ? \"<w:docPartUnique/>\" : '<w:docPartUnique w:val=\"0\"/>');\n return parts.length ? `<${name}>${parts.join(\"\")}</${name}>` : `<${name}/>`;\n}\n\nfunction onOffAttr(name: string, val: boolean): string {\n return val ? `<${name}/>` : `<${name} w:val=\"0\"/>`;\n}\n\nconst W14_NS = 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"';\n\n/** Default symbol font for checkbox content controls (CT_SdtCheckboxSymbol). */\nconst CHECKBOX_FONT = \"MS Gothic\";\n\nconst DEFAULT_CHECKED: { val: string; font: string } = { val: \"2612\", font: CHECKBOX_FONT };\nconst DEFAULT_UNCHECKED: { val: string; font: string } = { val: \"2610\", font: CHECKBOX_FONT };\n\n/**\n * Build a w14:checkbox element (Word 2010+ content control checkbox).\n *\n * Lives in the w14 extension namespace; emitted with an inline xmlns:w14 so it\n * is valid wherever w:sdtPr appears. validate.ts tolerates the w14 namespace.\n */\nfunction sdtCheckboxXml(opts: SdtCheckboxOptions): string {\n const checked = opts.checkedState ?? DEFAULT_CHECKED;\n const unchecked = opts.uncheckedState ?? DEFAULT_UNCHECKED;\n const inner =\n (opts.checked ? \"<w14:checked/>\" : '<w14:checked w14:val=\"0\"/>') +\n `<w14:checkedState w14:val=\"${escapeXml(checked.val)}\" w14:font=\"${escapeXml(checked.font ?? CHECKBOX_FONT)}\"/>` +\n `<w14:uncheckedState w14:val=\"${escapeXml(unchecked.val)}\" w14:font=\"${escapeXml(unchecked.font ?? CHECKBOX_FONT)}\"/>`;\n return `<w14:checkbox ${W14_NS}>${inner}</w14:checkbox>`;\n}\n\n/** Build the run that renders a checkbox content control's current state symbol. */\nexport function checkboxSymbolRunInner(cb: SdtCheckboxOptions): string {\n const symbol =\n (cb.checked ?? false)\n ? (cb.checkedState ?? DEFAULT_CHECKED)\n : (cb.uncheckedState ?? DEFAULT_UNCHECKED);\n const font = escapeXml(symbol.font ?? CHECKBOX_FONT);\n const char = escapeXml(String.fromCodePoint(parseInt(symbol.val, 16)));\n return `<w:r><w:rPr><w:rFonts w:ascii=\"${font}\" w:hAnsi=\"${font}\"/></w:rPr><w:t>${char}</w:t></w:r>`;\n}\n\nexport function stringifySdtPr(opts: SdtPropertiesOptions): string {\n const parts: string[] = [];\n\n // rPr is not supported in pure JSON path — skip\n\n if (opts.alias !== undefined) parts.push(`<w:alias w:val=\"${escapeXml(opts.alias)}\"/>`);\n if (opts.tag !== undefined) parts.push(`<w:tag w:val=\"${escapeXml(opts.tag)}\"/>`);\n if (opts.id !== undefined) parts.push(`<w:id w:val=\"${opts.id}\"/>`);\n if (opts.lock !== undefined) parts.push(`<w:lock w:val=\"${opts.lock}\"/>`);\n\n // placeholder not supported in pure JSON path — skip\n\n if (opts.temporary !== undefined) parts.push(onOffAttr(\"w:temporary\", opts.temporary));\n const effectiveShowingPlcHdr = opts.showingPlaceholder ?? false;\n if (opts.showingPlaceholder !== undefined || effectiveShowingPlcHdr) {\n parts.push(onOffAttr(\"w:showingPlcHdr\", effectiveShowingPlcHdr));\n }\n if (opts.dataBinding) parts.push(sdtDataBindingXml(opts.dataBinding));\n if (opts.label !== undefined) parts.push(`<w:label w:val=\"${opts.label}\"/>`);\n if (opts.tabIndex !== undefined) parts.push(`<w:tabIndex w:val=\"${opts.tabIndex}\"/>`);\n\n // Type discriminator (xsd:choice)\n if (opts.equation) {\n parts.push(\"<w:equation/>\");\n } else if (opts.comboBox) {\n parts.push(sdtListTypeXml(\"w:comboBox\", opts.comboBox));\n } else if (opts.date) {\n parts.push(sdtDateXml(opts.date));\n } else if (opts.docPartObj) {\n parts.push(sdtDocPartXml(\"w:docPartObj\", opts.docPartObj));\n } else if (opts.docPartList) {\n parts.push(sdtDocPartXml(\"w:docPartList\", opts.docPartList));\n } else if (opts.dropDownList) {\n parts.push(sdtListTypeXml(\"w:dropDownList\", opts.dropDownList));\n } else if (opts.picture) {\n parts.push(\"<w:picture/>\");\n } else if (opts.richText) {\n parts.push(\"<w:richText/>\");\n } else if (opts.text !== undefined) {\n const multiLine = opts.text.multiLine ?? false;\n parts.push(`<w:text w:multiLine=\"${multiLine}\"/>`);\n } else if (opts.citation) {\n parts.push(\"<w:citation/>\");\n } else if (opts.group) {\n parts.push(\"<w:group/>\");\n } else if (opts.bibliography) {\n parts.push(\"<w:bibliography/>\");\n } else if (opts.checkbox) {\n parts.push(sdtCheckboxXml(opts.checkbox));\n }\n\n return parts.length ? `<w:sdtPr>${parts.join(\"\")}</w:sdtPr>` : \"<w:sdtPr/>\";\n}\n\n/**\n * Build the <w:sdt> shell shared by all four SDT levels (block/run/cell/row).\n * The caller supplies the sdtContent body; sdtPr/sdtEndPr are handled uniformly.\n */\nexport function stringifySdtShell(\n properties: SdtPropertiesOptions,\n endProperties: RunPropertiesOptions | undefined,\n contentXml: string,\n): string {\n const endPrInner = endProperties ? stringifyRunPropertiesInner(endProperties) : undefined;\n const endPr = endPrInner ? `<w:sdtEndPr>${endPrInner}</w:sdtEndPr>` : \"<w:sdtEndPr/>\";\n const content = contentXml ? `<w:sdtContent>${contentXml}</w:sdtContent>` : \"<w:sdtContent/>\";\n return `<w:sdt>${stringifySdtPr(properties)}${endPr}${content}</w:sdt>`;\n}\n\n// ── SDT parse helpers ──\n\n/** Parse w:sdtPr element into SdtPropertiesOptions. */\nfunction parseSdtPr(el: Element): SdtPropertiesOptions {\n const opts: SdtPropertiesOptions = {};\n\n const alias = findChild(el, \"w:alias\");\n if (alias) opts.alias = attr(alias, \"w:val\");\n\n const tag = findChild(el, \"w:tag\");\n if (tag) {\n const val = attr(tag, \"w:val\");\n if (val) opts.tag = val;\n }\n\n const id = findChild(el, \"w:id\");\n if (id) {\n const val = attrNum(id, \"w:val\");\n if (val !== undefined) opts.id = val;\n }\n\n const lock = findChild(el, \"w:lock\");\n if (lock) {\n const val = attr(lock, \"w:val\");\n if (val) opts.lock = val as SdtPropertiesOptions[\"lock\"];\n }\n\n const temporary = findChild(el, \"w:temporary\");\n if (temporary) opts.temporary = attrBool(temporary, \"w:val\") ?? true;\n\n const showingPlcHdr = findChild(el, \"w:showingPlcHdr\");\n if (showingPlcHdr) opts.showingPlaceholder = attrBool(showingPlcHdr, \"w:val\") ?? true;\n\n const label = findChild(el, \"w:label\");\n if (label) {\n const val = attrNum(label, \"w:val\");\n if (val !== undefined) opts.label = val;\n }\n\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const val = attrNum(tabIndex, \"w:val\");\n if (val !== undefined) opts.tabIndex = val;\n }\n\n // Data binding\n const dataBinding = findChild(el, \"w:dataBinding\");\n if (dataBinding) {\n opts.dataBinding = {\n xpath: attr(dataBinding, \"w:xpath\") ?? \"\",\n storeItemID: attr(dataBinding, \"w:storeItemID\") ?? \"\",\n prefixMappings: attr(dataBinding, \"w:prefixMappings\"),\n };\n }\n\n // Type discriminators (xsd:choice)\n if (findChild(el, \"w:equation\")) {\n opts.equation = true;\n } else if (findChild(el, \"w:comboBox\")) {\n const comboBox = findChild(el, \"w:comboBox\")!;\n const items: { displayText?: string; value?: string }[] = [];\n for (const li of xmlChildren(comboBox, \"w:listItem\")) {\n items.push({ displayText: attr(li, \"w:displayText\"), value: attr(li, \"w:value\") });\n }\n opts.comboBox = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(comboBox, \"w:lastValue\"),\n };\n } else if (findChild(el, \"w:date\")) {\n const date = findChild(el, \"w:date\")!;\n const dateOpts: SdtDateOptions = {};\n const dateFormat = findChild(date, \"w:dateFormat\");\n if (dateFormat) dateOpts.dateFormat = textOf(dateFormat);\n const lid = findChild(date, \"w:lid\");\n if (lid) dateOpts.languageId = textOf(lid);\n const storeMapped = findChild(date, \"w:storeMappedDataAs\");\n if (storeMapped)\n dateOpts.storeMappedDataAs = attr(\n storeMapped,\n \"w:val\",\n ) as SdtDateOptions[\"storeMappedDataAs\"];\n const calendar = findChild(date, \"w:calendar\");\n if (calendar) dateOpts.calendar = attr(calendar, \"w:val\");\n const fullDate = attr(date, \"w:fullDate\");\n if (fullDate) dateOpts.fullDate = fullDate;\n opts.date = dateOpts;\n } else if (findChild(el, \"w:docPartObj\")) {\n const dp = findChild(el, \"w:docPartObj\")!;\n const dpObj: NonNullable<SdtPropertiesOptions[\"docPartObj\"]> = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) dpObj.gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) dpObj.category = attr(category, \"w:val\");\n if (findChild(dp, \"w:docPartUnique\")) dpObj.unique = true;\n opts.docPartObj = dpObj;\n } else if (findChild(el, \"w:docPartList\")) {\n const dp = findChild(el, \"w:docPartList\")!;\n const dpObj: NonNullable<SdtPropertiesOptions[\"docPartList\"]> = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) dpObj.gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) dpObj.category = attr(category, \"w:val\");\n if (findChild(dp, \"w:docPartUnique\")) dpObj.unique = true;\n opts.docPartList = dpObj;\n } else if (findChild(el, \"w:dropDownList\")) {\n const ddl = findChild(el, \"w:dropDownList\")!;\n const items: { displayText?: string; value?: string }[] = [];\n for (const li of xmlChildren(ddl, \"w:listItem\")) {\n items.push({ displayText: attr(li, \"w:displayText\"), value: attr(li, \"w:value\") });\n }\n opts.dropDownList = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(ddl, \"w:lastValue\"),\n };\n } else if (findChild(el, \"w:picture\")) {\n opts.picture = true;\n } else if (findChild(el, \"w:richText\")) {\n opts.richText = true;\n } else if (findChild(el, \"w:text\")) {\n const text = findChild(el, \"w:text\")!;\n opts.text = { multiLine: attrBool(text, \"w:multiLine\") };\n } else if (findChild(el, \"w:citation\")) {\n opts.citation = true;\n } else if (findChild(el, \"w:group\")) {\n opts.group = true;\n } else if (findChild(el, \"w:bibliography\")) {\n opts.bibliography = true;\n } else if (findChild(el, \"w14:checkbox\")) {\n const cb = findChild(el, \"w14:checkbox\")!;\n const cbObj: SdtCheckboxOptions = {};\n const checked = findChild(cb, \"w14:checked\");\n if (checked) cbObj.checked = attrBool(checked, \"w14:val\") ?? true;\n const checkedState = findChild(cb, \"w14:checkedState\");\n if (checkedState)\n cbObj.checkedState = {\n val: attr(checkedState, \"w14:val\") ?? \"\",\n font: attr(checkedState, \"w14:font\"),\n };\n const uncheckedState = findChild(cb, \"w14:uncheckedState\");\n if (uncheckedState)\n cbObj.uncheckedState = {\n val: attr(uncheckedState, \"w14:val\") ?? \"\",\n font: attr(uncheckedState, \"w14:font\"),\n };\n opts.checkbox = cbObj;\n }\n\n return opts;\n}\n\n/** Parse w:customXmlPr element into CustomXmlPropertiesOptions. */\nexport function parseCustomXmlProperties(el: Element): CustomXmlPropertiesOptions {\n const opts: CustomXmlPropertiesOptions = {};\n const placeholder = findChild(el, \"w:placeholder\");\n if (placeholder) {\n const val = attr(placeholder, \"w:val\");\n if (val) opts.placeholder = val;\n }\n const attributes: { name: string; val: string; uri?: string }[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:attr\") continue;\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name && val) {\n const attrOpts: { name: string; val: string; uri?: string } = { name, val };\n const uriVal = attr(child, \"w:uri\");\n if (uriVal) attrOpts.uri = uriVal;\n attributes.push(attrOpts);\n }\n }\n if (attributes.length > 0) opts.attributes = attributes;\n return opts;\n}\n\n/** Body child element parsing callback for SDT/customXml content. */\nlet _parseBodyChild: ((el: Element, ctx: DocxReadContext) => SectionChild) | undefined;\n\n/** Register the body child parser (called from parse/body.ts to break circular dependency). */\nexport function setBodyParseChild(\n parser: (el: Element, ctx: DocxReadContext) => SectionChild,\n): void {\n _parseBodyChild = parser;\n}\n\nfunction parseBodyChildren(elements: Element[], ctx: DocxReadContext): SectionChild[] {\n if (!_parseBodyChild) return [];\n const result: SectionChild[] = [];\n for (const el of elements) {\n result.push(_parseBodyChild(el, ctx));\n }\n return result;\n}\n\nexport const sdtBlockDesc: CustomDescriptor<SdtBlockOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [\"<w:sdt>\"];\n\n // sdtPr\n parts.push(stringifySdtPr(opts.properties));\n\n // sdtEndPr — typically empty, included for round-trip fidelity with Word\n const endPrInner = opts.endProperties\n ? stringifyRunPropertiesInner(opts.endProperties)\n : undefined;\n parts.push(endPrInner ? `<w:sdtEndPr>${endPrInner}</w:sdtEndPr>` : \"<w:sdtEndPr/>\");\n\n // sdtContent — checkbox renders its current state symbol; otherwise serialize children\n if (opts.properties.checkbox) {\n parts.push(\n `<w:sdtContent><w:p>${checkboxSymbolRunInner(opts.properties.checkbox)}</w:p></w:sdtContent>`,\n );\n } else if (opts.children && opts.children.length > 0) {\n const contentParts: string[] = [];\n for (const child of opts.children) {\n contentParts.push(ctx.stringifyChild(child, ctx));\n }\n const contentBody = contentParts.join(\"\");\n parts.push(contentBody ? `<w:sdtContent>${contentBody}</w:sdtContent>` : \"<w:sdtContent/>\");\n }\n\n parts.push(\"</w:sdt>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n\n // Parse sdtPr\n const sdtPr = findChild(el, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtPr(sdtPr) : {};\n\n // Parse sdtEndPr (CT_RPr content at the end mark — run properties, no w:rPr wrapper)\n let endProperties: RunPropertiesOptions | undefined;\n const sdtEndPr = findChild(el, \"w:sdtEndPr\");\n if (sdtEndPr) {\n endProperties = parseRunProperties(sdtEndPr);\n }\n\n // Parse sdtContent children\n const sdtContent = findChild(el, \"w:sdtContent\");\n let childList: SectionChild[] | undefined;\n if (sdtContent && sdtContent.elements?.length) {\n childList = parseBodyChildren(sdtContent.elements, dctx);\n if (childList.length === 0) childList = undefined;\n }\n\n return { properties, children: childList, endProperties } as SdtBlockOptions;\n },\n};\n\n// ── Custom XML (pure string — no context side effects) ──\n\nexport interface CustomXmlBlockDescriptorOptions {\n element: string;\n uri?: string;\n customXmlPr?: CustomXmlPropertiesOptions;\n children?: SectionChild[];\n}\n\nfunction buildCustomXmlPropertiesXml(pr: CustomXmlPropertiesOptions): string {\n const parts: string[] = [\"<w:customXmlPr>\"];\n if (pr.placeholder !== undefined) {\n parts.push(`<w:placeholder w:val=\"${escapeXml(pr.placeholder)}\"/>`);\n }\n if (pr.attributes) {\n for (const attr of pr.attributes) {\n const attrParts: string[] = [\n `w:name=\"${escapeXml(attr.name)}\"`,\n `w:val=\"${escapeXml(attr.val)}\"`,\n ];\n if (attr.uri !== undefined) attrParts.push(`w:uri=\"${escapeXml(attr.uri)}\"`);\n parts.push(`<w:attr ${attrParts.join(\" \")}/>`);\n }\n }\n parts.push(\"</w:customXmlPr>\");\n return parts.join(\"\");\n}\n\n/**\n * Serialize the common customXml shell (element/uri/customXmlPr) wrapping\n * arbitrary content. Shared by all four customXml levels (block/run/row/cell).\n *\n * @deprecated Microsoft Word removed support for `w:customXml` inline markup on\n * 2010-01-10 (i4i Inc. v. Microsoft ruling); Word deletes these elements on\n * open. Prefer content controls (`w:sdt`) or a `customXml` part.\n */\nexport function stringifyCustomXmlShell(\n opts: { element: string; uri?: string; customXmlPr?: CustomXmlPropertiesOptions },\n contentXml: string,\n): string {\n const attrs: string[] = [`w:element=\"${escapeXml(opts.element)}\"`];\n if (opts.uri !== undefined) attrs.push(`w:uri=\"${escapeXml(opts.uri)}\"`);\n const prXml = opts.customXmlPr ? buildCustomXmlPropertiesXml(opts.customXmlPr) : \"\";\n return `<w:customXml ${attrs.join(\" \")}>${prXml}${contentXml}</w:customXml>`;\n}\n\nexport const customXmlBlockDesc: CustomDescriptor<CustomXmlBlockDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const contentParts: string[] = [];\n if (opts.children) {\n for (const child of opts.children) {\n contentParts.push(ctx.stringifyChild(child, ctx));\n }\n }\n return stringifyCustomXmlShell(opts, contentParts.join(\"\"));\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n const opts: Partial<CustomXmlBlockDescriptorOptions> = {};\n\n const element = attr(el, \"w:element\");\n if (element) opts.element = element;\n\n const uri = attr(el, \"w:uri\");\n if (uri) opts.uri = uri;\n\n // Parse w:customXmlPr\n const xmlPr = findChild(el, \"w:customXmlPr\");\n if (xmlPr) {\n opts.customXmlPr = parseCustomXmlProperties(xmlPr);\n }\n\n // Parse block-level children\n const childList: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:customXmlPr\") continue;\n if (_parseBodyChild) {\n childList.push(_parseBodyChild(child, dctx));\n }\n }\n if (childList.length > 0) opts.children = childList;\n\n return opts as CustomXmlBlockDescriptorOptions;\n },\n};\n","/**\n * Text wrapping module for DrawingML elements.\n *\n * This module provides text wrapping options for floating/anchored drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport type { Distance } from \"../drawing\";\n\n/**\n * Enumeration of text wrapping types for floating drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingType = {\n NONE: 0,\n SQUARE: 1,\n TIGHT: 2,\n TOP_AND_BOTTOM: 3,\n THROUGH: 4,\n} as const;\n\n/**\n * Enumeration of text wrapping sides for floating drawings.\n *\n * Specifies on which side(s) text can wrap around the drawing.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingSide = {\n /** Text wraps on both sides of the drawing */\n BOTH_SIDES: \"bothSides\",\n /** Text wraps only on the left side */\n LEFT: \"left\",\n /** Text wraps only on the right side */\n RIGHT: \"right\",\n /** Text wraps on the side with more space */\n LARGEST: \"largest\",\n} as const;\n\n/**\n * Options for configuring text wrapping around a drawing.\n */\nexport interface TextWrapping {\n type: (typeof TextWrappingType)[keyof typeof TextWrappingType];\n side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];\n margins?: Distance;\n}\n","/**\n * Wrap Tight module for DrawingML text wrapping.\n *\n * This module provides tight text wrapping for floating drawings\n * where text wraps closely around the image shape.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { Margins } from \"../floating\";\nimport { TextWrappingSide } from \"./text-wrapping\";\nimport type { TextWrapping } from \"./text-wrapping\";\n\n/**\n * Creates a default rectangular wrap polygon matching the image extent.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapPath\">\n * <xsd:sequence>\n * <xsd:element name=\"start\" type=\"a:CT_Point2D\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * <xsd:element name=\"lineTo\" type=\"a:CT_Point2D\" minOccurs=\"2\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"edited\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nconst createWrapPolygon = (cx: number, cy: number): string =>\n element(\"wp:wrapPolygon\", { edited: \"0\" }, [\n `<wp:start x=\"0\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"0\"/>`,\n ]);\n\n/**\n * Creates tight text wrapping for a floating drawing.\n *\n * WrapTight causes text to wrap closely around the contours\n * of the drawing rather than its rectangular bounding box.\n * A default rectangular wrap polygon matching the image extent is generated.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapTight\">\n * <xsd:sequence>\n * <xsd:element name=\"wrapPolygon\" type=\"CT_WrapPath\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"wrapText\" type=\"ST_WrapText\" use=\"required\"/>\n * <xsd:attribute name=\"distL\" type=\"ST_WrapDistance\"/>\n * <xsd:attribute name=\"distR\" type=\"ST_WrapDistance\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createWrapTight = (\n textWrapping: TextWrapping,\n margins: Margins = {\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n },\n extent: { x: number; y: number },\n): string =>\n element(\n \"wp:wrapTight\",\n {\n distL: margins.left,\n distR: margins.right,\n wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,\n },\n [createWrapPolygon(extent.x, extent.y)],\n );\n","/**\n * Wrap Through module for DrawingML text wrapping.\n *\n * This module provides \"through\" text wrapping for floating drawings\n * where text wraps through the image contours, filling any concave areas.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nimport type { Margins } from \"../floating\";\nimport { TextWrappingSide } from \"./text-wrapping\";\nimport type { TextWrapping } from \"./text-wrapping\";\n\n/**\n * Creates a default rectangular wrap polygon matching the image extent.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapPath\">\n * <xsd:sequence>\n * <xsd:element name=\"start\" type=\"a:CT_Point2D\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * <xsd:element name=\"lineTo\" type=\"a:CT_Point2D\" minOccurs=\"2\" maxOccurs=\"unbounded\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"edited\" type=\"xsd:boolean\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nconst createWrapPolygon = (cx: number, cy: number): string =>\n element(\"wp:wrapPolygon\", { edited: \"0\" }, [\n `<wp:start x=\"0\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>`,\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>`,\n `<wp:lineTo x=\"0\" y=\"0\"/>`,\n ]);\n\n/**\n * Creates \"through\" text wrapping for a floating drawing.\n *\n * WrapThrough is similar to WrapTight but allows text to wrap through\n * the concave portions of the drawing shape (e.g., the inside of the letter \"O\").\n * A default rectangular wrap polygon matching the image extent is generated.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_WrapThrough\">\n * <xsd:sequence>\n * <xsd:element name=\"wrapPolygon\" type=\"CT_WrapPath\" minOccurs=\"1\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"wrapText\" type=\"ST_WrapText\" use=\"required\"/>\n * <xsd:attribute name=\"distL\" type=\"ST_WrapDistance\"/>\n * <xsd:attribute name=\"distR\" type=\"ST_WrapDistance\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createWrapThrough = (\n textWrapping: TextWrapping,\n margins: Margins = {\n bottom: 0,\n left: 0,\n right: 0,\n top: 0,\n },\n extent: { x: number; y: number },\n): string =>\n element(\n \"wp:wrapThrough\",\n {\n distL: margins.left,\n distR: margins.right,\n wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,\n },\n [createWrapPolygon(extent.x, extent.y)],\n );\n","/**\n * Shared constants for WordprocessingML documents.\n *\n * Provides alignment, number format, and space type constants\n * used across multiple document components.\n *\n * @module\n */\n\n// ── Alignment ──\n\n/**\n * Horizontal alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignH.html\n *\n * @publicApi\n */\nexport const HorizontalPositionAlign = {\n CENTER: \"center\",\n INSIDE: \"inside\",\n LEFT: \"left\",\n OUTSIDE: \"outside\",\n RIGHT: \"right\",\n} as const;\n\n/**\n * Vertical alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignV.html\n *\n * @publicApi\n */\nexport const VerticalPositionAlign = {\n BOTTOM: \"bottom\",\n CENTER: \"center\",\n INSIDE: \"inside\",\n OUTSIDE: \"outside\",\n TOP: \"top\",\n} as const;\n\n// ── Number format ──\n\n/**\n * Number format types for page numbers and list numbering.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const NumberFormat = {\n AIUEO: \"aiueo\",\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n ARABIC_ABJAD: \"arabicAbjad\",\n ARABIC_ALPHA: \"arabicAlpha\",\n BAHT_TEXT: \"bahtText\",\n BULLET: \"bullet\",\n CARDINAL_TEXT: \"cardinalText\",\n CHICAGO: \"chicago\",\n CHINESE_COUNTING: \"chineseCounting\",\n CHINESE_COUNTING_TEN_THOUSAND: \"chineseCountingThousand\",\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n CHOSUNG: \"chosung\",\n DECIMAL: \"decimal\",\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n DECIMAL_ENCLOSED_FULL_STOP: \"decimalEnclosedFullstop\",\n DECIMAL_ENCLOSED_PAREN: \"decimalEnclosedParen\",\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n DECIMAL_FULL_WIDTH_2: \"decimalFullWidth2\",\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n DECIMAL_ZERO: \"decimalZero\",\n DOLLAR_TEXT: \"dollarText\",\n GANADA: \"ganada\",\n HEBREW_1: \"hebrew1\",\n HEBREW_2: \"hebrew2\",\n HEX: \"hex\",\n HINDI_CONSONANTS: \"hindiConsonants\",\n HINDI_COUNTING: \"hindiCounting\",\n HINDI_NUMBERS: \"hindiNumbers\",\n HINDI_VOWELS: \"hindiVowels\",\n IDEOGRAPH_DIGITAL: \"ideographDigital\",\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n IROHA: \"iroha\",\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n JAPANESE_COUNTING: \"japaneseCounting\",\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n JAPANESE_LEGAL: \"japaneseLegal\",\n KOREAN_COUNTING: \"koreanCounting\",\n KOREAN_DIGITAL: \"koreanDigital\",\n KOREAN_DIGITAL_2: \"koreanDigital2\",\n KOREAN_LEGAL: \"koreanLegal\",\n LOWER_LETTER: \"lowerLetter\",\n LOWER_ROMAN: \"lowerRoman\",\n NONE: \"none\",\n NUMBER_IN_DASH: \"numberInDash\",\n ORDINAL: \"ordinal\",\n ORDINAL_TEXT: \"ordinalText\",\n RUSSIAN_LOWER: \"russianLower\",\n RUSSIAN_UPPER: \"russianUpper\",\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n THAI_COUNTING: \"thaiCounting\",\n THAI_LETTERS: \"thaiLetters\",\n THAI_NUMBERS: \"thaiNumbers\",\n UPPER_LETTER: \"upperLetter\",\n UPPER_ROMAN: \"upperRoman\",\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n} as const;\n\n// ── Space type ──\n\n/**\n * XML space handling modes.\n *\n * @publicApi\n */\nexport const SpaceType = {\n DEFAULT: \"default\",\n PRESERVE: \"preserve\",\n} as const;\n","/**\n * Floating position module for DrawingML elements.\n *\n * This module provides positioning options for floating/anchored drawings,\n * including horizontal and vertical relative positioning.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\nexport { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\n\nimport type { TextWrapping } from \"../text-wrap\";\n\n/**\n * Horizontal Relative Positioning.\n *\n * Specifies the horizontal base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromH.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromH\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"column\"/>\n * <xsd:enumeration value=\"character\"/>\n * <xsd:enumeration value=\"leftMargin\"/>\n * <xsd:enumeration value=\"rightMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const HorizontalPositionRelativeFrom = {\n /**\n * ## Character\n *\n * Specifies that the horizontal positioning shall be relative to the position of the anchor within its run content.\n */\n CHARACTER: \"character\",\n /**\n * ## Column\n *\n * Specifies that the horizontal positioning shall be relative to the extents of the column which contains its anchor.\n */\n COLUMN: \"column\",\n /**\n * ## Inside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the inside margin of the current page (the left margin on odd pages, right on even pages).\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Left Margin\n *\n * Specifies that the horizontal positioning shall be relative to the left margin of the page.\n */\n LEFT_MARGIN: \"leftMargin\",\n /**\n * ## Page Margin\n *\n * Specifies that the horizontal positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the outside margin of the current page (the right margin on odd pages, left on even pages).\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the horizontal positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Right Margin\n *\n * Specifies that the horizontal positioning shall be relative to the right margin of the page.\n */\n RIGHT_MARGIN: \"rightMargin\",\n} as const;\n\n/**\n * Vertical Relative Positioning.\n *\n * Specifies the vertical base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromV.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromV\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"paragraph\"/>\n * <xsd:enumeration value=\"line\"/>\n * <xsd:enumeration value=\"topMargin\"/>\n * <xsd:enumeration value=\"bottomMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const VerticalPositionRelativeFrom = {\n /**\n * ## Bottom Margin\n *\n * Specifies that the vertical positioning shall be relative to the bottom margin of the current page.\n */\n BOTTOM_MARGIN: \"bottomMargin\",\n /**\n * ## Inside Margin\n *\n * Specifies that the vertical positioning shall be relative to the inside margin of the current page.\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Line\n *\n * Specifies that the vertical positioning shall be relative to the line containing the anchor character.\n */\n LINE: \"line\",\n /**\n * ## Page Margin\n *\n * Specifies that the vertical positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the vertical positioning shall be relative to the outside margin of the current page.\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the vertical positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Paragraph\n *\n * Specifies that the vertical positioning shall be relative to the paragraph which contains the drawing anchor.\n */\n PARAGRAPH: \"paragraph\",\n /**\n * ## Top Margin\n *\n * Specifies that the vertical positioning shall be relative to the top margin of the current page.\n */\n TOP_MARGIN: \"topMargin\",\n} as const;\n\n/**\n * Options for horizontal positioning of a floating drawing.\n */\nexport interface HorizontalPositionOptions {\n /** The base from which horizontal position is calculated */\n relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];\n /** Alignment relative to the horizontal base */\n align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];\n /** Offset in EMUs from the horizontal base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Options for vertical positioning of a floating drawing.\n */\nexport interface VerticalPositionOptions {\n /** The base from which vertical position is calculated */\n relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];\n /** Alignment relative to the vertical base */\n align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];\n /** Offset in EMUs from the vertical base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Margin distances around a floating drawing in EMUs or universal measure.\n */\nexport interface Margins {\n left?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n top?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n}\n\n/**\n * Configuration options for a floating/anchored drawing.\n *\n * @see {@link Anchor}\n */\nexport interface Floating {\n horizontalPosition: HorizontalPositionOptions;\n verticalPosition: VerticalPositionOptions;\n allowOverlap?: boolean;\n lockAnchor?: boolean;\n behindDocument?: boolean;\n layoutInCell?: boolean;\n margins?: Margins;\n wrap?: TextWrapping;\n zIndex?: number;\n}\n","/**\n * Horizontal position module for floating drawings in WordprocessingML documents.\n *\n * This module provides horizontal positioning for floating drawing objects,\n * specifying the horizontal placement relative to a base element.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport { convertToEmu } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\nimport { HorizontalPositionAlign, HorizontalPositionRelativeFrom } from \"./floating-position\";\nimport type { HorizontalPositionOptions } from \"./floating-position\";\n\n/**\n * Creates a horizontal position element for floating drawings.\n *\n * The positionH element specifies the horizontal positioning of a floating\n * object relative to a base element (page, margin, column, etc.).\n *\n * Reference: https://www.datypic.com/sc/ooxml/e-wp_positionH-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PosH\">\n * <xsd:choice>\n * <xsd:element name=\"align\" type=\"ST_AlignH\"/>\n * <xsd:element name=\"posOffset\" type=\"ST_PositionOffset\"/>\n * </xsd:choice>\n * <xsd:attribute name=\"relativeFrom\" type=\"ST_RelFromH\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Horizontal position configuration\n * @returns The positionH XML string\n *\n * @example\n * ```typescript\n * // Align to the left of the page\n * createHorizontalPosition({\n * relative: HorizontalPositionRelativeFrom.PAGE,\n * align: HorizontalPositionAlign.LEFT,\n * });\n *\n * // Offset from the margin\n * createHorizontalPosition({\n * relative: HorizontalPositionRelativeFrom.MARGIN,\n * offset: 914400, // 1 inch in EMUs\n * });\n * ```\n */\nexport const createHorizontalPosition = ({\n relative,\n align,\n offset,\n}: HorizontalPositionOptions): string => {\n const child = align\n ? `<wp:align>${align}</wp:align>`\n : offset !== undefined\n ? `<wp:posOffset>${convertToEmu(offset)}</wp:posOffset>`\n : `<wp:align>${HorizontalPositionAlign.LEFT}</wp:align>`;\n\n return element(\n \"wp:positionH\",\n {\n relativeFrom: relative ?? HorizontalPositionRelativeFrom.PAGE,\n },\n [child],\n );\n};\n","/**\n * Vertical position module for floating drawings in WordprocessingML documents.\n *\n * This module provides vertical positioning for floating drawing objects,\n * specifying the vertical placement relative to a base element.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport { convertToEmu } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\nimport { VerticalPositionAlign, VerticalPositionRelativeFrom } from \"./floating-position\";\nimport type { VerticalPositionOptions } from \"./floating-position\";\n\n/**\n * Creates a vertical position element for floating drawings.\n *\n * The positionV element specifies the vertical positioning of a floating\n * object relative to a base element (page, margin, paragraph, line, etc.).\n *\n * Reference: https://www.datypic.com/sc/ooxml/e-wp_positionV-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PosV\">\n * <xsd:choice>\n * <xsd:element name=\"align\" type=\"ST_AlignV\"/>\n * <xsd:element name=\"posOffset\" type=\"ST_PositionOffset\"/>\n * </xsd:choice>\n * <xsd:attribute name=\"relativeFrom\" type=\"ST_RelFromV\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @param options - Vertical position configuration\n * @returns The positionV XML string\n *\n * @example\n * ```typescript\n * // Align to the top of the page\n * createVerticalPosition({\n * relative: VerticalPositionRelativeFrom.PAGE,\n * align: VerticalPositionAlign.TOP,\n * });\n *\n * // Offset from the paragraph\n * createVerticalPosition({\n * relative: VerticalPositionRelativeFrom.PARAGRAPH,\n * offset: 457200, // 0.5 inch in EMUs\n * });\n * ```\n */\nexport const createVerticalPosition = ({\n relative,\n align,\n offset,\n}: VerticalPositionOptions): string => {\n const child = align\n ? `<wp:align>${align}</wp:align>`\n : offset !== undefined\n ? `<wp:posOffset>${convertToEmu(offset)}</wp:posOffset>`\n : `<wp:align>${VerticalPositionAlign.TOP}</wp:align>`;\n\n return element(\n \"wp:positionV\",\n {\n relativeFrom: relative ?? VerticalPositionRelativeFrom.PAGE,\n },\n [child],\n );\n};\n","import { decimalNumber } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n/**\n * Page number module for WordprocessingML section properties.\n *\n * Defines page numbering format and starting value for document sections.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * @module\n */\nimport type { NumberFormat } from \"@shared/constants\";\n\n/**\n * Specifies the separator character between chapter number and page number.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_ChapterSep\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"hyphen\"/>\n * <xsd:enumeration value=\"period\"/>\n * <xsd:enumeration value=\"colon\"/>\n * <xsd:enumeration value=\"emDash\"/>\n * <xsd:enumeration value=\"enDash\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageNumberSeparator = {\n /** Hyphen separator (-) */\n HYPHEN: \"hyphen\",\n /** Period separator (.) */\n PERIOD: \"period\",\n /** Colon separator (:) */\n COLON: \"colon\",\n /** Em dash separator (—) */\n EM_DASH: \"emDash\",\n /** En dash separator (–) */\n EN_DASH: \"enDash\",\n} as const;\n\n/**\n * Options for configuring page numbering.\n *\n * @property start - Starting page number for the section\n * @property formatType - Number format (decimal, roman, letter, etc.)\n * @property separator - Separator between chapter and page number\n */\nexport interface PageNumberTypeAttributes {\n /** Starting page number for the section */\n start?: number;\n /** Number format (decimal, roman, letter, etc., default: decimal) */\n formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];\n /** Separator between chapter and page number (default: hyphen) */\n separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];\n /** Heading style ID for chapter numbering */\n chapStyle?: number;\n}\n\n/**\n * Creates page numbering settings (pgNumType) for a document section.\n *\n * This element specifies the page numbering format and starting value\n * for all pages in a section.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PageNumber\">\n * <xsd:attribute name=\"fmt\" type=\"ST_NumberFormat\" use=\"optional\" default=\"decimal\"/>\n * <xsd:attribute name=\"start\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapStyle\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapSep\" type=\"ST_ChapterSep\" use=\"optional\" default=\"hyphen\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Start page numbering at 5 with lowercase roman numerals\n * createPageNumberType({\n * start: 5,\n * formatType: NumberFormat.LOWER_ROMAN\n * });\n * ```\n */\nexport const createPageNumberType = ({\n start,\n formatType,\n separator,\n chapStyle,\n}: PageNumberTypeAttributes): string =>\n element(\"w:pgNumType\", {\n \"w:chapStyle\": chapStyle === undefined ? undefined : decimalNumber(chapStyle),\n \"w:fmt\": formatType,\n \"w:chapSep\": separator,\n \"w:start\": start === undefined ? undefined : decimalNumber(start),\n });\n","import type { PositiveUniversalMeasure } from \"@office-open/core\";\n\n/**\n * This simple type specifies the orientation of all pages in the parent section. This information is used to determine the actual paper size to use when printing the file.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_PageOrientation_topic_ID0EKBK3.html\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:simpleType name=\"ST_PageOrientation\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"portrait\"/>\n * <xsd:enumeration value=\"landscape\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageOrientation = {\n /**\n * ## Portrait Mode\n *\n * Specifies that pages in this section shall be printed in portrait mode.\n */\n PORTRAIT: \"portrait\",\n /**\n * ## Landscape Mode\n *\n * Specifies that pages in this section shall be printed in landscape mode, which prints the page contents with a 90 degree rotation with respect to the normal page orientation.\n */\n LANDSCAPE: \"landscape\",\n} as const;\n\nexport interface PageSizeAttributes {\n /**\n * ## Page Width\n *\n * This attribute indicates the width (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is 15840 twentieths of a point (11\") wide.\n *\n * The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.18.105).\n */\n width?: number | PositiveUniversalMeasure;\n /**\n * ## Page Height\n *\n * Specifies the height (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is `12240` twentieths of a point (`8.5\"`) tall.\n *\n * The possible values for this attribute are defined by the `ST_TwipsMeasure` simple type (§2.18.105).\n */\n height?: number | PositiveUniversalMeasure;\n /**\n * ## Page Orientation\n *\n * Specifies the orientation of all pages in this section.\n *\n * This information is used to determine the actual paper size to use on the printer.\n *\n * This implies that the actual paper size width and height are reversed for pages in this section. If this attribute is omitted, then portrait shall be implied.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" w:orient=\"landscape\" />\n * ```\n *\n * Although the page width is 11\", and page height is 8.5\", according to the `w` and `h` attributes, because the `orient` attribute is set to landscape, pages in this section are printed on 8.5x11\" paper in landscape mode.\n *\n * The possible values for this attribute are defined by the `ST_PageOrientation` simple type (§2.18.71).\n */\n orientation?: (typeof PageOrientation)[keyof typeof PageOrientation];\n /**\n * ## Printer Paper Code\n *\n * Specifies a printer-specific paper code for the paper type, which shall be used by the printer for pages in this section.\n *\n * This code is stored to ensure the proper paper type is chosen if the specified paper size matches the sizes of multiple paper types supported by the current printer.\n *\n * It will be sent to the printer and used by the printer to determine the appropriate paper type to use when printing.\n *\n * This value is not interpreted or modified other than storing it as specified by the printer.\n *\n * The possible values for this attribute are defined by the `ST_DecimalNumber` simple type (§2.18.16).\n */\n code?: number;\n}\n","/**\n * Page text direction module for WordprocessingML section properties.\n *\n * Defines text flow direction for pages in a section.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * @module\n */\n\n/**\n * Specifies the text flow direction for pages in a section.\n *\n * This controls whether text flows horizontally (left-to-right) or\n * vertically (top-to-bottom), commonly used for East Asian languages.\n */\nexport const PageTextDirectionType = {\n /** Left-to-right, top-to-bottom (standard Western text flow) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Top-to-bottom, right-to-left (vertical East Asian text flow) */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Section properties module for WordprocessingML documents.\n *\n * Section properties define page layout including page size, margins,\n * headers/footers, columns, and page numbering.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * @module\n */\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\nimport type { SectionVerticalAlign } from \"@shared/vertical-align\";\n\nimport type { ColumnsAttributes } from \"./properties/columns\";\nimport type { DocGridAttributesProperties } from \"./properties/doc-grid\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"./properties/footnote-endnote-properties\";\nimport type { LineNumberAttributes } from \"./properties/line-number\";\nimport type { PageBordersOptions } from \"./properties/page-borders\";\nimport type { PageMarginAttributes } from \"./properties/page-margin\";\nimport type { PageNumberTypeAttributes } from \"./properties/page-number\";\nimport { PageOrientation } from \"./properties/page-size\";\nimport type { PageSizeAttributes } from \"./properties/page-size\";\nimport { PageTextDirectionType } from \"./properties/page-text-direction\";\nimport type { SectionType } from \"./properties/section-type\";\n\n/**\n * Header/footer group for specifying different headers/footers\n * for default, first, and even pages.\n */\nexport interface HeaderFooterGroup<T> {\n default?: T;\n first?: T;\n even?: T;\n}\n\nexport interface SectionPropertiesOptionsBase {\n runPropertiesRsid?: string;\n deletionRsid?: string;\n rsid?: string;\n sectionRsid?: string;\n page?: {\n size?: PageSizeAttributes;\n margin?: PageMarginAttributes;\n pageNumbers?: PageNumberTypeAttributes;\n borders?: PageBordersOptions;\n textDirection?: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];\n };\n grid?: DocGridAttributesProperties;\n headerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n footerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n lineNumbers?: LineNumberAttributes;\n titlePage?: boolean;\n verticalAlign?: SectionVerticalAlign;\n column?: ColumnsAttributes;\n type?: (typeof SectionType)[keyof typeof SectionType];\n noEndnote?: boolean;\n formProtection?: boolean;\n bidi?: boolean;\n rtlGutter?: boolean;\n paperSrc?: {\n first?: number;\n other?: number;\n };\n footnotePr?: FootnotePropertiesOptions;\n endnotePr?: EndnotePropertiesOptions;\n printerSettingsId?: string;\n}\n\nexport type SectionPropertiesChangeOptions = ChangedAttributesProperties &\n SectionPropertiesOptionsBase;\n\nexport type SectionPropertiesOptions = {\n revision?: SectionPropertiesChangeOptions;\n} & SectionPropertiesOptionsBase;\n\nexport const sectionMarginDefaults = {\n TOP: 1440,\n RIGHT: 1800,\n BOTTOM: 1440,\n LEFT: 1800,\n HEADER: 851,\n FOOTER: 992,\n GUTTER: 0,\n};\n\nexport const sectionPageSizeDefaults = {\n WIDTH: 11_906,\n HEIGHT: 16_838,\n ORIENTATION: PageOrientation.PORTRAIT,\n};\n","/**\n * Section properties descriptor for DOCX documents.\n *\n * Produces `<w:sectPr>` XML directly from options, eliminating all\n * intermediate XmlComponent instances (create* + toXml pattern).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_SectPr\n *\n * @module\n */\n\nimport { convertToTwip } from \"@office-open/core\";\nimport { twipsMeasureValue } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ColumnAttributes } from \"@parts/document/body/section-properties/properties/column\";\nimport type { ColumnsAttributes } from \"@parts/document/body/section-properties/properties/columns\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"@parts/document/body/section-properties/properties/footnote-endnote-properties\";\nimport type { PageBordersOptions } from \"@parts/document/body/section-properties/properties/page-borders\";\nimport { PageNumberSeparator } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type { PageNumberTypeAttributes } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type {\n SectionPropertiesChangeOptions,\n SectionPropertiesOptions,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport {\n sectionMarginDefaults,\n sectionPageSizeDefaults,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { NumberFormat } from \"@shared/constants\";\nimport type { BodyContext } from \"@shared/index\";\n\n/** Valid page-number @w:fmt values (ST_NumberFormat). */\nconst PAGE_NUMBER_FORMATS = Object.values(NumberFormat) as readonly string[];\n/** Valid page-number @w:chapSep values (ST_ChapterSep). */\nconst PAGE_NUMBER_SEPARATORS = Object.values(PageNumberSeparator) as readonly string[];\n\n// ── Border XML helper ──\n\nfunction stringifyBorderXml(tag: string, opts: BorderOptions): string {\n const attrs: string[] = [];\n if (opts.style !== undefined) attrs.push(`w:val=\"${opts.style}\"`);\n if (opts.color !== undefined) attrs.push(`w:color=\"${opts.color}\"`);\n if (opts.size !== undefined) attrs.push(`w:sz=\"${opts.size}\"`);\n if (opts.space !== undefined) attrs.push(`w:space=\"${opts.space}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${opts.themeTint}\"`);\n if (opts.themeShade !== undefined) attrs.push(`w:themeShade=\"${opts.themeShade}\"`);\n if (opts.shadow !== undefined) attrs.push(`w:shadow=\"${opts.shadow ? 1 : 0}\"`);\n if (opts.frame !== undefined) attrs.push(`w:frame=\"${opts.frame ? 1 : 0}\"`);\n return `<${tag} ${attrs.join(\" \")}/>`;\n}\n\n// ── Inline XML builders (replacing create* + toXml) ──\n\nfunction pageSizeXml(\n w: number | string,\n h: number | string,\n orient?: string,\n code?: number,\n): string {\n const attrs: string[] = [`w:w=\"${w}\"`, `w:h=\"${h}\"`];\n if (orient) attrs.push(`w:orient=\"${orient}\"`);\n if (code !== undefined) attrs.push(`w:code=\"${code}\"`);\n return `<w:pgSz ${attrs.join(\" \")}/>`;\n}\n\nfunction pageMarginXml(\n top: number | string,\n right: number | string,\n bottom: number | string,\n left: number | string,\n header: number | string,\n footer: number | string,\n gutter: number | string,\n): string {\n return `<w:pgMar w:top=\"${top}\" w:right=\"${right}\" w:bottom=\"${bottom}\" w:left=\"${left}\" w:header=\"${header}\" w:footer=\"${footer}\" w:gutter=\"${gutter}\"/>`;\n}\n\nfunction headerFooterRefXml(tag: string, id: number, type: string): string {\n return `<${tag} r:id=\"rId${id}\" w:type=\"${type}\"/>`;\n}\n\nfunction sectionTypeXml(val: string): string {\n return `<w:type w:val=\"${val}\"/>`;\n}\n\nfunction verticalAlignXml(val: string): string {\n return `<w:vAlign w:val=\"${val}\"/>`;\n}\n\nfunction lineNumberXml(opts: NonNullable<SectionPropertiesOptions[\"lineNumbers\"]>): string {\n const attrs: string[] = [];\n if (opts.countBy !== undefined) attrs.push(`w:countBy=\"${opts.countBy}\"`);\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.restart !== undefined) attrs.push(`w:restart=\"${opts.restart}\"`);\n if (opts.distance !== undefined) attrs.push(`w:distance=\"${opts.distance}\"`);\n return attrs.length ? `<w:lnNumType ${attrs.join(\" \")}/>` : \"<w:lnNumType/>\";\n}\n\nfunction pageNumberXml(opts: NonNullable<PageNumberTypeAttributes>): string {\n const attrs: string[] = [];\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.formatType !== undefined) attrs.push(`w:fmt=\"${opts.formatType}\"`);\n if (opts.separator !== undefined) attrs.push(`w:chapSep=\"${opts.separator}\"`);\n if (opts.chapStyle !== undefined) attrs.push(`w:chapStyle=\"${opts.chapStyle}\"`);\n // No attributes → omit pgNumType (never fabricate an empty element).\n return attrs.length ? `<w:pgNumType ${attrs.join(\" \")}/>` : \"\";\n}\n\nfunction docGridXml(linePitch: number, charSpace?: number, type?: string): string {\n const attrs: string[] = [`w:linePitch=\"${linePitch}\"`];\n if (charSpace !== undefined) attrs.push(`w:charSpace=\"${charSpace}\"`);\n if (type !== undefined) attrs.push(`w:type=\"${type}\"`);\n return `<w:docGrid ${attrs.join(\" \")}/>`;\n}\n\nfunction columnsXml(opts: NonNullable<SectionPropertiesOptions[\"column\"]>): string {\n const attrs: string[] = [];\n if (opts.space !== undefined) attrs.push(`w:space=\"${twipsMeasureValue(opts.space)}\"`);\n if (opts.count !== undefined) attrs.push(`w:num=\"${opts.count}\"`);\n if (opts.separate !== undefined) attrs.push(`w:sep=\"${opts.separate ? 1 : 0}\"`);\n if (opts.equalWidth !== undefined) attrs.push(`w:equalWidth=\"${opts.equalWidth ? 1 : 0}\"`);\n\n const attrStr = attrs.join(\" \");\n\n // Custom width columns — children are ColumnAttributes (Column class implements this interface)\n if (!opts.equalWidth && opts.children) {\n const colParts: string[] = [];\n for (const col of opts.children as readonly ColumnAttributes[]) {\n const colAttrs: string[] = [`w:w=\"${twipsMeasureValue(col.width)}\"`];\n if (col.space !== undefined) colAttrs.push(`w:space=\"${twipsMeasureValue(col.space)}\"`);\n colParts.push(`<w:col ${colAttrs.join(\" \")}/>`);\n }\n return `<w:cols ${attrStr}>${colParts.join(\"\")}</w:cols>`;\n }\n return `<w:cols ${attrStr}/>`;\n}\n\nfunction footnotePrXml(\n tag: string,\n opts: FootnotePropertiesOptions | EndnotePropertiesOptions,\n): string {\n const parts: string[] = [];\n if (opts.pos !== undefined) parts.push(`<w:pos w:val=\"${opts.pos}\"/>`);\n if (opts.formatType !== undefined || opts.format !== undefined) {\n const fmtAttrs: string[] = [];\n if (opts.formatType !== undefined) fmtAttrs.push(`w:fmt=\"${opts.formatType}\"`);\n if (opts.format !== undefined) fmtAttrs.push(`w:format=\"${opts.format}\"`);\n parts.push(`<w:numFmt ${fmtAttrs.join(\" \")}/>`);\n }\n if (opts.numStart !== undefined) parts.push(`<w:numStart w:val=\"${opts.numStart}\"/>`);\n if (opts.numRestart !== undefined) parts.push(`<w:numRestart w:val=\"${opts.numRestart}\"/>`);\n const body = parts.join(\"\");\n return body ? `<${tag}>${body}</${tag}>` : `<${tag}/>`;\n}\n\nfunction pageBordersXml(opts: NonNullable<PageBordersOptions>): string {\n const attrs: string[] = [];\n if (opts.display !== undefined) attrs.push(`w:display=\"${opts.display}\"`);\n if (opts.offsetFrom !== undefined) attrs.push(`w:offsetFrom=\"${opts.offsetFrom}\"`);\n if (opts.zOrder !== undefined) attrs.push(`w:zOrder=\"${opts.zOrder}\"`);\n\n const parts: string[] = [];\n if (opts.top) parts.push(stringifyBorderXml(\"w:top\", opts.top));\n if (opts.left) parts.push(stringifyBorderXml(\"w:left\", opts.left));\n if (opts.bottom) parts.push(stringifyBorderXml(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(stringifyBorderXml(\"w:right\", opts.right));\n\n const attrStr = attrs.join(\" \");\n const body = parts.join(\"\");\n if (!body && !attrStr) return \"<w:pgBorders/>\";\n return body ? `<w:pgBorders ${attrStr}>${body}</w:pgBorders>` : `<w:pgBorders ${attrStr}/>`;\n}\n\n// ── Header/footer references ──\n\nfunction appendHeaderFooterRefs(\n parts: string[],\n type: \"w:headerReference\" | \"w:footerReference\",\n group?: { default?: HeaderFooterEntry; first?: HeaderFooterEntry; even?: HeaderFooterEntry },\n): void {\n if (!group) return;\n if (group.default) parts.push(headerFooterRefXml(type, group.default.referenceId, \"default\"));\n if (group.first) parts.push(headerFooterRefXml(type, group.first.referenceId, \"first\"));\n if (group.even) parts.push(headerFooterRefXml(type, group.even.referenceId, \"even\"));\n}\n\n// ── sectPrChange (recursive) ──\n\nfunction stringifySectionPropertiesChange(opts: SectionPropertiesChangeOptions): string {\n const { author, date, id, ...inner } = opts;\n const innerXml = stringifySectionPropertiesInner(inner);\n return `<w:sectPrChange w:author=\"${author}\" w:date=\"${date}\" w:id=\"${id}\"><w:sectPr>${innerXml}</w:sectPr></w:sectPrChange>`;\n}\n\n// ── Core XML builder ──\n\nfunction stringifySectionPropertiesInner(opts: SectionPropertiesOptions): string {\n const parts: string[] = [];\n\n // Header/footer references\n appendHeaderFooterRefs(parts, \"w:headerReference\", opts.headerWrapperGroup);\n appendHeaderFooterRefs(parts, \"w:footerReference\", opts.footerWrapperGroup);\n\n // Destructure page options with defaults\n const {\n size: {\n width = sectionPageSizeDefaults.WIDTH,\n height = sectionPageSizeDefaults.HEIGHT,\n orientation = sectionPageSizeDefaults.ORIENTATION,\n code,\n } = {},\n margin: {\n top = sectionMarginDefaults.TOP,\n right = sectionMarginDefaults.RIGHT,\n bottom = sectionMarginDefaults.BOTTOM,\n left = sectionMarginDefaults.LEFT,\n header = sectionMarginDefaults.HEADER,\n footer = sectionMarginDefaults.FOOTER,\n gutter = sectionMarginDefaults.GUTTER,\n } = {},\n pageNumbers = {},\n borders,\n textDirection,\n } = opts.page ?? {};\n\n const { linePitch = 312, charSpace = 0, type: gridType = \"lines\" } = opts.grid ?? {};\n\n // Footnote/endnote properties\n if (opts.footnotePr) parts.push(footnotePrXml(\"w:footnotePr\", opts.footnotePr));\n if (opts.endnotePr) parts.push(footnotePrXml(\"w:endnotePr\", opts.endnotePr));\n\n // Section type\n if (opts.type) parts.push(sectionTypeXml(opts.type));\n\n // Page size — normalize both logical dimensions to twips, then swap w/h when\n // landscape. UniversalMeasure (\"210mm\") is converted so the emitted w:w/w:h is\n // always a plain twip number that the attrNum-based parse reads back exactly.\n const wTwips = convertToTwip(width);\n const hTwips = convertToTwip(height);\n const pgW = orientation === \"landscape\" ? hTwips : wTwips;\n const pgH = orientation === \"landscape\" ? wTwips : hTwips;\n parts.push(pageSizeXml(pgW, pgH, orientation, code));\n\n // Page margin (always present)\n parts.push(pageMarginXml(top, right, bottom, left, header, footer, gutter));\n\n // Page borders\n if (borders) parts.push(pageBordersXml(borders));\n\n // Line numbers\n if (opts.lineNumbers) parts.push(lineNumberXml(opts.lineNumbers));\n\n // Page numbers\n parts.push(pageNumberXml(pageNumbers));\n\n // Columns\n if (opts.column) parts.push(columnsXml(opts.column));\n\n // Vertical alignment\n if (opts.verticalAlign) parts.push(verticalAlignXml(opts.verticalAlign));\n\n // Boolean on/off elements — direct string output\n if (opts.titlePage !== undefined)\n parts.push(opts.titlePage ? \"<w:titlePg/>\" : '<w:titlePg w:val=\"0\"/>');\n if (textDirection) parts.push(`<w:textDirection w:val=\"${textDirection}\"/>`);\n if (opts.noEndnote !== undefined)\n parts.push(opts.noEndnote ? \"<w:noEndnote/>\" : '<w:noEndnote w:val=\"0\"/>');\n if (opts.formProtection !== undefined)\n parts.push(opts.formProtection ? \"<w:formProt/>\" : '<w:formProt w:val=\"0\"/>');\n if (opts.bidi !== undefined) parts.push(opts.bidi ? \"<w:bidi/>\" : '<w:bidi w:val=\"0\"/>');\n if (opts.rtlGutter !== undefined)\n parts.push(opts.rtlGutter ? \"<w:rtlGutter/>\" : '<w:rtlGutter w:val=\"0\"/>');\n\n // Paper source\n if (opts.paperSrc) {\n const psAttr: string[] = [];\n if (opts.paperSrc.first !== undefined) psAttr.push(`w:first=\"${opts.paperSrc.first}\"`);\n if (opts.paperSrc.other !== undefined) psAttr.push(`w:other=\"${opts.paperSrc.other}\"`);\n parts.push(`<w:paperSrc ${psAttr.join(\" \")}/>`);\n }\n\n // Printer settings\n if (opts.printerSettingsId !== undefined) {\n parts.push(`<w:printerSettings r:id=\"${opts.printerSettingsId}\"/>`);\n }\n\n // Document grid\n parts.push(docGridXml(linePitch, charSpace, gridType));\n\n // Revision (sectPrChange)\n if (opts.revision) {\n parts.push(stringifySectionPropertiesChange(opts.revision));\n }\n\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\n/**\n * Section properties descriptor for DOCX `<w:sectPr>` elements.\n *\n * Produces complete XML directly from options — zero XmlComponent instances\n * in the hot path. All `create*()` + `.toXml()` calls eliminated in favor\n * of direct string concatenation.\n *\n * @example\n * ```typescript\n * const xml = sectionPropertiesDesc.stringify(sectPrOpts, ctx);\n * ```\n */\nexport const sectionPropertiesDesc: CustomDescriptor<SectionPropertiesOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifySectionPropertiesXml(opts);\n },\n\n parse(el, _ctx) {\n return parseSectionPropertiesEl(el);\n },\n};\n\n/** Standalone stringify — no context needed, pure options → XML. */\nexport function stringifySectionPropertiesXml(opts: SectionPropertiesOptions): string {\n const inner = stringifySectionPropertiesInner(opts);\n\n const attrs: string[] = [];\n if (opts.runPropertiesRsid !== undefined) attrs.push(`w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid !== undefined) attrs.push(`w:rsidDel=\"${opts.deletionRsid}\"`);\n if (opts.rsid !== undefined) attrs.push(`w:rsidR=\"${opts.rsid}\"`);\n if (opts.sectionRsid !== undefined) attrs.push(`w:rsidSect=\"${opts.sectionRsid}\"`);\n\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return `<w:sectPr${attrStr}>${inner}</w:sectPr>`;\n}\n\n// ── Parse (Element → SectionPropertiesOptions) ──\n\n/** Parse a w:sectPr element into SectionPropertiesOptions. */\nexport function parseSectionPropertiesEl(el: Element): SectionPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n // rsid attributes on w:sectPr element\n for (const [attrName, optKey] of [\n [\"w:rsidR\", \"rsid\"],\n [\"w:rsidRPr\", \"runPropertiesRsid\"],\n [\"w:rsidDel\", \"deletionRsid\"],\n [\"w:rsidSect\", \"sectionRsid\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n // Page size\n const pgSz = findChild(el, \"w:pgSz\");\n if (pgSz) {\n const page: Record<string, unknown> = {};\n const size: Record<string, unknown> = {};\n const w = attrNum(pgSz, \"w:w\");\n const h = attrNum(pgSz, \"w:h\");\n const orient = attr(pgSz, \"w:orient\");\n if (orient === \"landscape\" && w !== undefined && h !== undefined) {\n size.width = h;\n size.height = w;\n } else {\n if (w !== undefined) size.width = w;\n if (h !== undefined) size.height = h;\n }\n if (orient) size.orientation = orient;\n const code = attrNum(pgSz, \"w:code\");\n if (code !== undefined) size.code = code;\n if (Object.keys(size).length > 0) page.size = size;\n\n // Page margins\n const pgMar = findChild(el, \"w:pgMar\");\n if (pgMar) {\n const margin: Record<string, unknown> = {};\n for (const [a, o] of [\n [\"w:top\", \"top\"],\n [\"w:right\", \"right\"],\n [\"w:bottom\", \"bottom\"],\n [\"w:left\", \"left\"],\n [\"w:header\", \"header\"],\n [\"w:footer\", \"footer\"],\n [\"w:gutter\", \"gutter\"],\n ] as const) {\n const val = attrNum(pgMar, a);\n if (val !== undefined) margin[o] = val;\n }\n if (Object.keys(margin).length > 0) page.margin = margin;\n }\n\n // Page number type\n const pgNumType = findChild(el, \"w:pgNumType\");\n if (pgNumType) {\n const pageNumbers: PageNumberTypeAttributes = {};\n const start = attrNum(pgNumType, \"w:start\");\n if (start !== undefined) pageNumbers.start = start;\n const fmt = attr(pgNumType, \"w:fmt\");\n if (fmt && PAGE_NUMBER_FORMATS.includes(fmt)) {\n pageNumbers.formatType = fmt as PageNumberTypeAttributes[\"formatType\"];\n }\n const chapSep = attr(pgNumType, \"w:chapSep\");\n if (chapSep && PAGE_NUMBER_SEPARATORS.includes(chapSep)) {\n pageNumbers.separator = chapSep as PageNumberTypeAttributes[\"separator\"];\n }\n const chapStyle = attrNum(pgNumType, \"w:chapStyle\");\n if (chapStyle !== undefined) pageNumbers.chapStyle = chapStyle;\n if (Object.keys(pageNumbers).length > 0) page.pageNumbers = pageNumbers;\n }\n\n if (Object.keys(page).length > 0) opts.page = page;\n }\n\n // Columns\n const cols = findChild(el, \"w:cols\");\n if (cols) {\n const column: ColumnsAttributes = {};\n const count = attrNum(cols, \"w:num\");\n if (count !== undefined) column.count = count;\n const space = attrMeasure(cols, \"w:space\");\n if (space !== undefined) column.space = space as ColumnsAttributes[\"space\"];\n const separate = attrBool(cols, \"w:sep\");\n if (separate !== undefined) column.separate = separate;\n const equalWidth = attrBool(cols, \"w:equalWidth\");\n if (equalWidth !== undefined) column.equalWidth = equalWidth;\n const colChildren: ColumnAttributes[] = [];\n for (const colEl of cols.elements ?? []) {\n if (colEl.name !== \"w:col\") continue;\n const width = attrMeasure(colEl, \"w:w\");\n if (width === undefined) continue;\n const colAttr: ColumnAttributes = { width: width as ColumnAttributes[\"width\"] };\n const colSpace = attrMeasure(colEl, \"w:space\");\n if (colSpace !== undefined) colAttr.space = colSpace as ColumnAttributes[\"space\"];\n colChildren.push(colAttr);\n }\n if (colChildren.length > 0) column.children = colChildren;\n if (Object.keys(column).length > 0) opts.column = column;\n }\n\n // Section type\n const type = findChild(el, \"w:type\");\n if (type) {\n const val = attr(type, \"w:val\");\n if (val) opts.type = val;\n }\n\n // Title page\n const titlePg = findChild(el, \"w:titlePg\");\n if (titlePg) opts.titlePage = attrBool(titlePg, \"w:val\") ?? true;\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:noEndnote\", \"noEndnote\"],\n [\"w:formProt\", \"formProtection\"],\n [\"w:bidi\", \"bidi\"],\n [\"w:rtlGutter\", \"rtlGutter\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Document grid\n const docGrid = findChild(el, \"w:docGrid\");\n if (docGrid) {\n const grid: Record<string, unknown> = {};\n const type = attr(docGrid, \"w:type\");\n if (type) grid.type = type;\n const linePitch = attrNum(docGrid, \"w:linePitch\");\n if (linePitch !== undefined) grid.linePitch = linePitch;\n const charSpace = attrNum(docGrid, \"w:charSpace\");\n if (charSpace !== undefined) grid.charSpace = charSpace;\n if (Object.keys(grid).length > 0) opts.grid = grid;\n }\n\n // Line numbers\n const lnNumType = findChild(el, \"w:lnNumType\");\n if (lnNumType) {\n const lineNumbers: Record<string, unknown> = {};\n const countBy = attrNum(lnNumType, \"w:countBy\");\n if (countBy !== undefined) lineNumbers.countBy = countBy;\n const start = attrNum(lnNumType, \"w:start\");\n if (start !== undefined) lineNumbers.start = start;\n const restart = attr(lnNumType, \"w:restart\");\n if (restart) lineNumbers.restart = restart;\n const distance = attrNum(lnNumType, \"w:distance\");\n if (distance !== undefined) lineNumbers.distance = distance;\n if (Object.keys(lineNumbers).length > 0) opts.lineNumbers = lineNumbers;\n }\n\n // Page borders\n const pgBorders = findChild(el, \"w:pgBorders\");\n if (pgBorders) {\n const borders: Record<string, unknown> = {};\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(pgBorders, `w:${side}`);\n if (sideEl) {\n const b: Record<string, unknown> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) b.space = space;\n borders[side] = b;\n }\n }\n const display = attr(pgBorders, \"w:display\");\n if (display) borders.display = display;\n const offsetFrom = attr(pgBorders, \"w:offsetFrom\");\n if (offsetFrom) borders.offsetFrom = offsetFrom;\n const zOrder = attr(pgBorders, \"w:zOrder\");\n if (zOrder) borders.zOrder = zOrder;\n if (Object.keys(borders).length > 0) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.borders = borders;\n opts.page = page;\n }\n }\n\n // Vertical align\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val;\n }\n\n // Text direction\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.textDirection = val;\n opts.page = page;\n }\n }\n\n // Footnote properties\n const footnotePr = findChild(el, \"w:footnotePr\");\n if (footnotePr) {\n opts.footnotePr = parseNotePropertiesEl(footnotePr);\n }\n\n // Endnote properties\n const endnotePr = findChild(el, \"w:endnotePr\");\n if (endnotePr) {\n opts.endnotePr = parseNotePropertiesEl(endnotePr);\n }\n\n // Paper source\n const paperSrc = findChild(el, \"w:paperSrc\");\n if (paperSrc) {\n const ps: Record<string, unknown> = {};\n const first = attrNum(paperSrc, \"w:first\");\n if (first !== undefined) ps.first = first;\n const other = attrNum(paperSrc, \"w:other\");\n if (other !== undefined) ps.other = other;\n if (Object.keys(ps).length > 0) opts.paperSrc = ps;\n }\n\n // Printer settings\n const printerSettings = findChild(el, \"w:printerSettings\");\n if (printerSettings) {\n const rId = attr(printerSettings, \"r:id\");\n if (rId) opts.printerSettingsId = rId;\n }\n\n // Header/footer references\n const headerGroup: Record<string, unknown> = {};\n const footerGroup: Record<string, unknown> = {};\n for (const child of el.elements ?? []) {\n if (child.name === \"w:headerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) headerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n } else if (child.name === \"w:footerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) footerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n }\n }\n if (Object.keys(headerGroup).length > 0) opts.headerWrapperGroup = headerGroup;\n if (Object.keys(footerGroup).length > 0) opts.footerWrapperGroup = footerGroup;\n\n // Revision (w:sectPrChange) — symmetric with stringifySectionPropertiesChange\n const sectPrChange = findChild(el, \"w:sectPrChange\");\n if (sectPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(sectPrChange, \"w:author\");\n if (author) rev.author = author;\n const revDate = attr(sectPrChange, \"w:date\");\n if (revDate) rev.date = revDate;\n const revId = attrNum(sectPrChange, \"w:id\");\n if (revId !== undefined) rev.id = revId;\n const innerSectPr = findChild(sectPrChange, \"w:sectPr\");\n if (innerSectPr) Object.assign(rev, parseSectionPropertiesEl(innerSectPr));\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n return opts as unknown as SectionPropertiesOptions;\n}\n\nfunction parseNotePropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const posEl = findChild(el, \"w:pos\");\n if (posEl) {\n const val = attr(posEl, \"w:val\");\n if (val) opts.pos = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const fmt = attr(numFmt, \"w:fmt\");\n if (fmt) opts.formatType = fmt;\n const format = attr(numFmt, \"w:format\");\n if (format) opts.format = format;\n }\n\n const numStart = findChild(el, \"w:numStart\");\n if (numStart) {\n const val = attrNum(numStart, \"w:val\");\n if (val !== undefined) opts.numStart = val;\n }\n\n const numRestart = findChild(el, \"w:numRestart\");\n if (numRestart) {\n const val = attr(numRestart, \"w:val\");\n if (val) opts.numRestart = val;\n }\n\n return opts;\n}\n","import { Relationships, toUint8Array, uniqueUuid } from \"@office-open/core\";\n\n/**\n * Font Wrapper module for WordprocessingML documents.\n *\n * Manages font table relationships for embedded fonts.\n * Pure data container — no XmlComponent dependency.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html\n *\n * @module\n */\nimport type { ViewWrapper } from \"../../context\";\nimport type { EmbeddedFontOptions } from \"./font-table\";\n\n/**\n * Font options extended with a unique font key.\n */\nexport type EmbeddedFontOptionsWithKey = EmbeddedFontOptions & {\n fontKey: string;\n /** Relationship id assigned to embedRegular (only fonts carrying data). */\n embedRid?: string;\n /** Normalized font bytes (Uint8Array regardless of the input form). */\n data?: Uint8Array;\n};\n\n/**\n * Wrapper class for managing embedded font relationships.\n *\n * Each embedded font is assigned a unique key for obfuscation.\n * The actual font table XML is generated by `fontTableDesc.stringify()`.\n *\n * @example\n * ```typescript\n * const fontWrapper = new FontWrapper([\n * { name: \"CustomFont\", data: fontBuffer }\n * ]);\n * ```\n */\nexport class FontWrapper implements ViewWrapper {\n public relationships: Relationships;\n public fontOptionsWithKey: EmbeddedFontOptionsWithKey[] = [];\n\n public constructor(public options: EmbeddedFontOptions[]) {\n // Keep every font declaration — metadata-only fonts (no `data`) carry no\n // bytes to embed but must still round-trip into fontTable.xml. Only fonts\n // with binary data receive a fontKey + relationship for the .odttf part.\n this.fontOptionsWithKey = options.map(\n (o): EmbeddedFontOptionsWithKey => ({\n ...o,\n data: o.data !== undefined ? toUint8Array(o.data) : undefined,\n fontKey: o.data !== undefined ? (o.fontKey ?? uniqueUuid()) : (o.fontKey ?? \"\"),\n }),\n );\n this.relationships = new Relationships();\n\n let relIdx = 0;\n for (const font of this.fontOptionsWithKey) {\n if (font.data === undefined) continue;\n relIdx++;\n font.embedRid = `rId${relIdx}`;\n const target = font.odttfPath\n ? font.odttfPath.startsWith(\"word/\")\n ? font.odttfPath.slice(5)\n : font.odttfPath\n : `fonts/${font.name}.odttf`;\n this.relationships.addRelationship(\n relIdx,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font\",\n target,\n );\n }\n }\n}\n","/**\n * Structured Document Tag parser for DOCX documents.\n *\n * Parses w:sdt elements into SdtPropertiesOptions + children.\n *\n * @module\n */\nimport { attr, attrBool, attrNum, children, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n SdtPropertiesOptions,\n SdtListItem,\n SdtDateOptions,\n SdtTextOptions,\n SdtComboBoxOptions,\n SdtDropDownListOptions,\n} from \"@parts/table-of-contents\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse w:sdtPr element into SdtPropertiesOptions.\n */\nexport function parseSdtProperties(el: Element): SdtPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n const alias = findChild(el, \"w:alias\");\n if (alias) opts.alias = attr(alias, \"w:val\");\n\n const tag = findChild(el, \"w:tag\");\n if (tag) {\n const val = attr(tag, \"w:val\");\n if (val) opts.tag = val;\n }\n\n const id = findChild(el, \"w:id\");\n if (id) {\n const val = attrNum(id, \"w:val\");\n if (val !== undefined) opts.id = val;\n }\n\n const lock = findChild(el, \"w:lock\");\n if (lock) {\n const val = attr(lock, \"w:val\");\n if (val) opts.lock = val as SdtPropertiesOptions[\"lock\"];\n }\n\n const temporary = findChild(el, \"w:temporary\");\n if (temporary) opts.temporary = attrBool(temporary, \"w:val\") ?? true;\n\n const showingPlcHdr = findChild(el, \"w:showingPlcHdr\");\n if (showingPlcHdr) opts.showingPlaceholder = attrBool(showingPlcHdr, \"w:val\") ?? true;\n\n const label = findChild(el, \"w:label\");\n if (label) {\n const val = attrNum(label, \"w:val\");\n if (val !== undefined) opts.label = val;\n }\n\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const val = attrNum(tabIndex, \"w:val\");\n if (val !== undefined) opts.tabIndex = val;\n }\n\n // Data binding\n const dataBinding = findChild(el, \"w:dataBinding\");\n if (dataBinding) {\n opts.dataBinding = {\n xpath: attr(dataBinding, \"w:xpath\") ?? \"\",\n storeItemID: attr(dataBinding, \"w:storeItemID\") ?? \"\",\n prefixMappings: attr(dataBinding, \"w:prefixMappings\"),\n };\n }\n\n // Type discriminators (xsd:choice)\n if (findChild(el, \"w:equation\")) {\n opts.equation = true;\n } else if (findChild(el, \"w:comboBox\")) {\n const comboBox = findChild(el, \"w:comboBox\")!;\n const items: SdtListItem[] = [];\n for (const li of children(comboBox, \"w:listItem\")) {\n items.push({\n displayText: attr(li, \"w:displayText\"),\n value: attr(li, \"w:value\"),\n });\n }\n opts.comboBox = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(comboBox, \"w:lastValue\"),\n } as SdtComboBoxOptions;\n } else if (findChild(el, \"w:date\")) {\n const date = findChild(el, \"w:date\")!;\n const dateOpts: Record<string, unknown> = {};\n const dateFormat = findChild(date, \"w:dateFormat\");\n if (dateFormat) dateOpts.dateFormat = textOf(dateFormat);\n const lid = findChild(date, \"w:lid\");\n if (lid) dateOpts.languageId = textOf(lid);\n const storeMapped = findChild(date, \"w:storeMappedDataAs\");\n if (storeMapped) dateOpts.storeMappedDataAs = attr(storeMapped, \"w:val\");\n const calendar = findChild(date, \"w:calendar\");\n if (calendar) dateOpts.calendar = attr(calendar, \"w:val\");\n const fullDate = attr(date, \"w:fullDate\");\n if (fullDate) dateOpts.fullDate = fullDate;\n opts.date = dateOpts as SdtDateOptions;\n } else if (findChild(el, \"w:dropDownList\")) {\n const ddl = findChild(el, \"w:dropDownList\")!;\n const items: SdtListItem[] = [];\n for (const li of children(ddl, \"w:listItem\")) {\n items.push({\n displayText: attr(li, \"w:displayText\"),\n value: attr(li, \"w:value\"),\n });\n }\n opts.dropDownList = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(ddl, \"w:lastValue\"),\n } as SdtDropDownListOptions;\n } else if (findChild(el, \"w:picture\")) {\n opts.picture = true;\n } else if (findChild(el, \"w:richText\")) {\n opts.richText = true;\n } else if (findChild(el, \"w:text\")) {\n const text = findChild(el, \"w:text\")!;\n opts.text = {\n multiLine: attrBool(text, \"w:multiLine\"),\n } as SdtTextOptions;\n } else if (findChild(el, \"w:citation\")) {\n opts.citation = true;\n } else if (findChild(el, \"w:group\")) {\n opts.group = true;\n } else if (findChild(el, \"w:bibliography\")) {\n opts.bibliography = true;\n } else if (findChild(el, \"w:docPartObj\")) {\n const dp = findChild(el, \"w:docPartObj\")!;\n opts.docPartObj = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) (opts.docPartObj as Record<string, unknown>).gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) (opts.docPartObj as Record<string, unknown>).category = attr(category, \"w:val\");\n } else if (findChild(el, \"w:docPartList\")) {\n const dp = findChild(el, \"w:docPartList\")!;\n opts.docPartList = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) (opts.docPartList as Record<string, unknown>).gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) (opts.docPartList as Record<string, unknown>).category = attr(category, \"w:val\");\n } else if (findChild(el, \"w14:checkbox\")) {\n const cb = findChild(el, \"w14:checkbox\")!;\n const cbObj: Record<string, unknown> = {};\n const checked = findChild(cb, \"w14:checked\");\n if (checked) cbObj.checked = attrBool(checked, \"w14:val\") ?? true;\n const checkedState = findChild(cb, \"w14:checkedState\");\n if (checkedState)\n cbObj.checkedState = {\n val: attr(checkedState, \"w14:val\") ?? \"\",\n font: attr(checkedState, \"w14:font\"),\n };\n const uncheckedState = findChild(cb, \"w14:uncheckedState\");\n if (uncheckedState)\n cbObj.uncheckedState = {\n val: attr(uncheckedState, \"w14:val\") ?? \"\",\n font: attr(uncheckedState, \"w14:font\"),\n };\n opts.checkbox = cbObj;\n }\n\n return opts as SdtPropertiesOptions;\n}\n\n/**\n * Parse a block-level w:sdt element.\n * Returns an object suitable for the { sdt: ... } SectionChild variant.\n */\nexport function parseSdtBlock(\n el: Element,\n ctx: DocxReadContext,\n parseChildren: (elements: Element[], ctx: DocxReadContext) => unknown[],\n): {\n properties: SdtPropertiesOptions;\n children?: unknown[];\n} {\n const sdtPr = findChild(el, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n\n const sdtContent = findChild(el, \"w:sdtContent\");\n let childList: unknown[] | undefined;\n if (sdtContent) {\n childList = parseChildren(sdtContent.elements ?? [], ctx);\n if (childList.length === 0) childList = undefined;\n }\n\n return { properties, children: childList };\n}\n","/**\n * Table of Contents stringifier for DOCX.\n *\n * Produces `<w:sdt>` XML containing a TOC field code, replacing\n * `new TableOfContents(alias, options).toXml(ctx)` with direct\n * string concatenation — zero XmlComponent instances.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { TableOfContentsOptions } from \"@parts/table-of-contents/table-of-contents-properties\";\n\n// ── Field instruction string ──\n\nfunction tocInstructionStr(opts: TableOfContentsOptions): string {\n let instr = \"TOC\";\n\n if (opts.captionLabel) instr += ` \\\\a \"${opts.captionLabel}\"`;\n if (opts.entriesFromBookmark) instr += ` \\\\b \"${opts.entriesFromBookmark}\"`;\n if (opts.captionLabelIncludingNumbers) instr += ` \\\\c \"${opts.captionLabelIncludingNumbers}\"`;\n if (opts.sequenceAndPageNumbersSeparator)\n instr += ` \\\\d \"${opts.sequenceAndPageNumbersSeparator}\"`;\n if (opts.tcFieldIdentifier) instr += ` \\\\f \"${opts.tcFieldIdentifier}\"`;\n if (opts.hyperlink) instr += \" \\\\h\";\n if (opts.tcFieldLevelRange) instr += ` \\\\l \"${opts.tcFieldLevelRange}\"`;\n if (opts.pageNumbersEntryLevelsRange) instr += ` \\\\n \"${opts.pageNumbersEntryLevelsRange}\"`;\n if (opts.headingStyleRange) instr += ` \\\\o \"${opts.headingStyleRange}\"`;\n if (opts.entryAndPageNumberSeparator) instr += ` \\\\p \"${opts.entryAndPageNumberSeparator}\"`;\n if (opts.seqFieldIdentifierForPrefix) instr += ` \\\\s \"${opts.seqFieldIdentifierForPrefix}\"`;\n if (opts.stylesWithLevels?.length) {\n const styles = opts.stylesWithLevels.map((sl) => `${sl.styleName},${sl.level}`).join(\",\");\n instr += ` \\\\t \"${styles}\"`;\n }\n if (opts.useAppliedParagraphOutlineLevel) instr += \" \\\\u\";\n if (opts.preserveTabInEntries) instr += \" \\\\w\";\n if (opts.preserveNewLineInEntries) instr += \" \\\\x\";\n if (opts.hideTabAndPageNumbersInWebView) instr += \" \\\\z\";\n\n return instr;\n}\n\n// ── Main stringifier ──\n\nexport function stringifyTableOfContents(\n alias: string = \"Table of Contents\",\n options: TableOfContentsOptions = {},\n entriesXml: string = \"\",\n): string {\n const instr = tocInstructionStr(options);\n const aliasAttr = alias ? ` w:val=\"${escapeXml(alias)}\"` : \"\";\n\n // When the rendered entries are carried (round-trip), emit the field clean so\n // both MS Office and WPS display the existing TOC without an update prompt.\n // A freshly generated TOC carries no entries — mark it dirty so the consuming\n // application builds them from headings on open.\n const dirtyAttr = entriesXml.length > 0 ? \"\" : ' w:dirty=\"1\"';\n\n // SDT properties: alias + docPartObj\n const sdtPr =\n `<w:sdtPr>` +\n `<w:alias${aliasAttr}/>` +\n `<w:docPartObj><w:docPartGallery w:val=\"Table of Contents\"/></w:docPartObj>` +\n `</w:sdtPr>`;\n\n // SDT content: begin paragraph (field instruction) + rendered entries + end paragraph\n const content =\n `<w:sdtContent>` +\n `<w:p><w:r><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:cstheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cs=\"Times New Roman\"/></w:rPr><w:fldChar w:fldCharType=\"begin\"${dirtyAttr}/></w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instr} </w:instrText></w:r>` +\n `<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r></w:p>` +\n entriesXml +\n `<w:p><w:r><w:fldChar w:fldCharType=\"end\"/></w:r></w:p>` +\n `</w:sdtContent>`;\n\n return `<w:sdt>${sdtPr}${content}</w:sdt>`;\n}\n","/**\n * VML shape module for WordprocessingML documents.\n *\n * Provides the VmlShapeStyle type and style-to-key mapping used by compile/\n * and parse paths. Runtime shape construction has been migrated to the\n * descriptor pipeline.\n *\n * References:\n * - https://c-rex.net/samples/ooxml/e1/Part3/OOXML_P3_Primer_OfficeArt_topic_ID0ELU5O.html\n * - http://webapp.docx4java.org/OnlineDemo/ecma376/VML/shape.html\n *\n * @module\n */\nimport type { LengthUnit } from \"../types\";\n\n/**\n * Maps VmlShapeStyle property names to their corresponding CSS-style property names.\n * Used internally for converting TypeScript-friendly property names to VML style attributes.\n */\nexport const styleToKeyMap: Record<keyof VmlShapeStyle, string> = {\n flip: \"flip\",\n height: \"height\",\n left: \"left\",\n marginBottom: \"margin-bottom\",\n marginLeft: \"margin-left\",\n marginRight: \"margin-right\",\n marginTop: \"margin-top\",\n position: \"position\",\n positionHorizontal: \"mso-position-horizontal\",\n positionHorizontalRelative: \"mso-position-horizontal-relative\",\n positionVertical: \"mso-position-vertical\",\n positionVerticalRelative: \"mso-position-vertical-relative\",\n rotation: \"rotation\",\n top: \"top\",\n visibility: \"visibility\",\n width: \"width\",\n wrapDistanceBottom: \"mso-wrap-distance-bottom\",\n wrapDistanceLeft: \"mso-wrap-distance-left\",\n wrapDistanceRight: \"mso-wrap-distance-right\",\n wrapDistanceTop: \"mso-wrap-distance-top\",\n wrapEdited: \"mso-wrap-edited\",\n wrapStyle: \"mso-wrap-style\",\n zIndex: \"z-index\",\n};\n\n/**\n * VML shape styling properties for WordprocessingML documents.\n *\n * These properties map to CSS-style attributes on VML shape elements and control\n * the shape's appearance, layout, and interaction with surrounding text.\n */\nexport interface VmlShapeStyle {\n /** Specifies that the orientation of a shape is flipped. Default is no value. */\n flip?: \"x\" | \"y\" | \"xy\" | \"yx\";\n /** Specifies the height of the containing block of the shape. Default is 0. */\n height?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the element left of it. Default is 0. */\n left?: LengthUnit;\n /** Specifies the position of the bottom of the containing block relative to the shape anchor. Default is 0. */\n marginBottom?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the shape anchor. Default is 0. */\n marginLeft?: LengthUnit;\n /** Specifies the position of the right of the containing block relative to the shape anchor. Default is 0. */\n marginRight?: LengthUnit;\n /** Specifies the position of the top of the containing block relative to the shape anchor. Default is 0. */\n marginTop?: LengthUnit;\n /** Specifies the horizontal positioning data. Default is absolute. */\n positionHorizontal?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative horizontal position data. Default is text. */\n positionHorizontalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the vertical positioning data. Default is absolute. */\n positionVertical?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative vertical position data. Default is text. */\n positionVerticalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the distance from the bottom of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceBottom?: number;\n /** Specifies the distance from the left side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceLeft?: number;\n /** Specifies the distance from the right side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceRight?: number;\n /** Specifies the distance from the top of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceTop?: number;\n /** Specifies whether the wrap coordinates were customized by the user. Default is false. */\n wrapEdited?: boolean;\n /** Specifies the wrapping mode for text in shapes. Default is square. */\n wrapStyle?: \"square\" | \"none\";\n /** Specifies the type of positioning used to place an element. Default is static. */\n position?: \"static\" | \"absolute\" | \"relative\";\n /** Specifies the angle that a shape is rotated, in degrees. Default is 0. */\n rotation?: number;\n /** Specifies the position of the top of the containing block. Default is 0. */\n top?: LengthUnit;\n /** Specifies whether a shape is displayed. Default is inherit. */\n visibility?: \"hidden\" | \"inherit\";\n /** Specifies the width of the containing block of the shape. Default is 0. */\n width: LengthUnit;\n /** Specifies the display order of overlapping shapes. Default is 0. */\n zIndex?: \"auto\" | number;\n}\n","/**\n * Direct XML string builders for Office MathML (OMML).\n *\n * Replaces `coerceMathInput()` + `new Math().toXml()` recursive class chain\n * with direct string concatenation — zero XmlComponent instances.\n *\n * Processes `MathInput` discriminated union directly to XML strings.\n *\n * @module\n */\n\nimport { attr, children, escapeXml, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n MathDelimiterProperties,\n MathInput,\n MathNaryProperties,\n MathRunPropertiesOptions,\n} from \"@parts/paragraph/math\";\n\n// ── MathRun properties ──\n\nfunction mathRunPropsStr(opts: MathRunPropertiesOptions): string {\n const parts: string[] = [];\n if (opts.lit) parts.push('<m:lit m:val=\"1\"/>');\n if (opts.normal) parts.push('<m:nor m:val=\"1\"/>');\n if (opts.script) parts.push(`<m:scr m:val=\"${opts.script}\"/>`);\n if (opts.style) parts.push(`<m:sty m:val=\"${opts.style}\"/>`);\n if (opts.breakAlignment) parts.push(`<m:brk m:alnAt=\"${opts.breakAlignment}\"/>`);\n if (opts.align) parts.push('<m:aln m:val=\"1\"/>');\n return parts.length ? `<m:rPr>${parts.join(\"\")}</m:rPr>` : \"\";\n}\n\n// ── Children array ──\n\nfunction stringifyChildren(items: MathInput[]): string {\n return items.map(stringifyMathInput).join(\"\");\n}\n\n// ── Main recursive stringifier ──\n\nexport function stringifyMathInput(value: MathInput): string {\n // String → MathRun shorthand\n if (typeof value === \"string\") {\n return `<m:r><m:t>${escapeXml(value)}</m:t></m:r>`;\n }\n\n // Class instances — still need toXml (shouldn't happen in compile/ JSON path)\n if (typeof value !== \"object\" || value === null) return \"\";\n\n // Discriminated union: check unique keys (order matters — subSuperScript first)\n if (\"subSuperScript\" in value) {\n const opts = value.subSuperScript;\n const pr = opts.alignScript\n ? '<m:sSubSupPr><m:alnScr m:val=\"1\"/></m:sSubSupPr>'\n : \"<m:sSubSupPr/>\";\n return `<m:sSubSup>${pr}<m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSubSup>`;\n }\n\n if (\"preSubSuperScript\" in value) {\n const opts = value.preSubSuperScript;\n return `<m:sPre><m:sPrePr/><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup><m:e>${stringifyChildren(opts.children)}</m:e></m:sPre>`;\n }\n\n if (\"superScript\" in value) {\n const opts = value.superScript;\n return `<m:sSup><m:sSupPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSup>`;\n }\n\n if (\"subScript\" in value) {\n const opts = value.subScript;\n return `<m:sSub><m:sSubPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub></m:sSub>`;\n }\n\n if (\"fraction\" in value) {\n const opts = value.fraction;\n const pr = opts.fractionType ? `<m:fPr><m:type m:val=\"${opts.fractionType}\"/></m:fPr>` : \"\";\n const numArgPr = argPrXml(opts.numeratorArgumentSize);\n const denArgPr = argPrXml(opts.denominatorArgumentSize);\n return `<m:f>${pr}<m:num>${numArgPr}${stringifyChildren(opts.numerator)}</m:num><m:den>${denArgPr}${stringifyChildren(opts.denominator)}</m:den></m:f>`;\n }\n\n if (\"radical\" in value) {\n const opts = value.radical;\n const hasDegree = opts.degree && opts.degree.length > 0;\n const pr = !hasDegree ? '<m:radPr><m:degHide m:val=\"1\"/></m:radPr>' : \"<m:radPr/>\";\n const deg = hasDegree ? `<m:deg>${stringifyChildren(opts.degree!)}</m:deg>` : \"<m:deg/>\";\n return `<m:rad>${pr}${deg}<m:e>${stringifyChildren(opts.children)}</m:e></m:rad>`;\n }\n\n if (\"sum\" in value) {\n return stringifyNAry(value.sum, \"∑\");\n }\n\n if (\"integral\" in value) {\n return stringifyNAry(value.integral, \"∫\");\n }\n\n if (\"limitLower\" in value) {\n const opts = value.limitLower;\n return `<m:limLow><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limLow>`;\n }\n\n if (\"limitUpper\" in value) {\n const opts = value.limitUpper;\n return `<m:limUpp><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limUpp>`;\n }\n\n if (\"function\" in value) {\n const opts = value.function;\n return `<m:func><m:fName>${stringifyChildren(opts.name)}</m:fName><m:e>${stringifyChildren(opts.children)}</m:e></m:func>`;\n }\n\n if (\"matrix\" in value) {\n const opts = value.matrix;\n const rows = opts.rows\n .map(\n (row) =>\n `<m:mr>${row.map((cell) => `<m:e>${stringifyMathInput(cell)}</m:e>`).join(\"\")}</m:mr>`,\n )\n .join(\"\");\n // Matrix properties are complex — emit basic structure only when needed\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const prParts: string[] = [];\n if (p.baseJc) prParts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.plcHide) prParts.push('<m:plcHide m:val=\"1\"/>');\n if (p.rSpRule) prParts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.cGpRule) prParts.push(`<m:cGpRule m:val=\"${p.cGpRule as string}\"/>`);\n if (p.rSp) prParts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (p.cSp) prParts.push(`<m:cSp m:val=\"${p.cSp as string}\"/>`);\n if (p.cGp) prParts.push(`<m:cGp m:val=\"${p.cGp as string}\"/>`);\n if (p.mcs) {\n const mcItems = (p.mcs as Array<{ count: number; mcJc: string }>)\n .map(\n (mc) =>\n `<m:mc><m:mcPr><m:count m:val=\"${mc.count}\"/><m:mcJc m:val=\"${mc.mcJc}\"/></m:mcPr></m:mc>`,\n )\n .join(\"\");\n prParts.push(`<m:mcs>${mcItems}</m:mcs>`);\n }\n if (prParts.length) pr = `<m:mPr>${prParts.join(\"\")}</m:mPr>`;\n }\n return `<m:m>${pr}${rows}</m:m>`;\n }\n\n // Bracket types\n if (\"roundBrackets\" in value) {\n const spec = bracketSpec(value.roundBrackets);\n return stringifyDelimiters(spec.children, \"(\", \")\", spec.properties);\n }\n if (\"curlyBrackets\" in value) {\n const spec = bracketSpec(value.curlyBrackets);\n return stringifyDelimiters(spec.children, \"{\", \"}\", spec.properties);\n }\n if (\"angledBrackets\" in value) {\n const spec = bracketSpec(value.angledBrackets);\n return stringifyDelimiters(spec.children, \"〈\", \"〉\", spec.properties);\n }\n if (\"squareBrackets\" in value) {\n const spec = bracketSpec(value.squareBrackets);\n return stringifyDelimiters(spec.children, \"[\", \"]\", spec.properties);\n }\n\n if (\"borderBox\" in value) {\n const opts = value.borderBox;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.hideTop) parts.push('<m:hideTop m:val=\"1\"/>');\n if (p.hideBottom) parts.push('<m:hideBot m:val=\"1\"/>');\n if (p.hideLeft) parts.push('<m:hideLeft m:val=\"1\"/>');\n if (p.hideRight) parts.push('<m:hideRight m:val=\"1\"/>');\n if (p.strikeHorizontal) parts.push('<m:strikeH m:val=\"1\"/>');\n if (p.strikeVertical) parts.push('<m:strikeV m:val=\"1\"/>');\n if (p.strikeDiagonalUp) parts.push('<m:strikeBLTR m:val=\"1\"/>');\n if (p.strikeDiagonalDown) parts.push('<m:strikeTLBR m:val=\"1\"/>');\n if (parts.length) pr = `<m:borderBoxPr>${parts.join(\"\")}</m:borderBoxPr>`;\n }\n return `<m:borderBox>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:borderBox>`;\n }\n\n if (\"box\" in value) {\n const opts = value.box;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.opEmu) parts.push('<m:opEmu m:val=\"1\"/>');\n if (p.noBreak) parts.push('<m:noBreak m:val=\"1\"/>');\n if (p.diff) parts.push('<m:diff m:val=\"1\"/>');\n if (p.aln) parts.push('<m:aln m:val=\"1\"/>');\n if (parts.length) pr = `<m:boxPr>${parts.join(\"\")}</m:boxPr>`;\n }\n return `<m:box>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:box>`;\n }\n\n if (\"groupChr\" in value) {\n const opts = value.groupChr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.chr) parts.push(`<m:chr m:val=\"${p.chr as string}\"/>`);\n if (p.pos) parts.push(`<m:pos m:val=\"${p.pos as string}\"/>`);\n if (p.vertJc) parts.push(`<m:vertJc m:val=\"${p.vertJc as string}\"/>`);\n if (parts.length) pr = `<m:groupChrPr>${parts.join(\"\")}</m:groupChrPr>`;\n }\n return `<m:groupChr>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:groupChr>`;\n }\n\n if (\"phant\" in value) {\n const opts = value.phant;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.show !== undefined) parts.push(`<m:show m:val=\"${p.show ? 1 : 0}\"/>`);\n if (p.zeroWid) parts.push('<m:zeroWid m:val=\"1\"/>');\n if (p.zeroAsc) parts.push('<m:zeroAsc m:val=\"1\"/>');\n if (p.zeroDesc) parts.push('<m:zeroDesc m:val=\"1\"/>');\n if (p.transp) parts.push('<m:transp m:val=\"1\"/>');\n if (parts.length) pr = `<m:phantPr>${parts.join(\"\")}</m:phantPr>`;\n }\n return `<m:phant>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:phant>`;\n }\n\n if (\"eqArr\" in value) {\n const opts = value.eqArr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.baseJc) parts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.maxDist) parts.push('<m:maxDist m:val=\"1\"/>');\n if (p.objDist) parts.push('<m:objDist m:val=\"1\"/>');\n if (p.rSpRule) parts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.rSp) parts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (parts.length) pr = `<m:eqArrPr>${parts.join(\"\")}</m:eqArrPr>`;\n }\n const rows = opts.rows.map((row) => `<m:e>${stringifyChildren(row)}</m:e>`).join(\"\");\n return `<m:eqArr>${pr}${rows}</m:eqArr>`;\n }\n\n if (\"accent\" in value) {\n const opts = value.accent;\n const pr = opts.accentCharacter\n ? `<m:accPr><m:chr m:val=\"${opts.accentCharacter}\"/></m:accPr>`\n : \"\";\n return `<m:acc>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:acc>`;\n }\n\n if (\"bar\" in value) {\n const opts = value.bar;\n return `<m:bar><m:barPr><m:pos m:val=\"${opts.type}\"/></m:barPr><m:e>${stringifyChildren(opts.children)}</m:e></m:bar>`;\n }\n\n // Fallback: { text: string; properties?: ... } → MathRun\n if (\"text\" in value) {\n const props = value.properties ? mathRunPropsStr(value.properties) : \"\";\n return `<m:r>${props}<m:t>${escapeXml(value.text)}</m:t></m:r>`;\n }\n\n return \"\";\n}\n\n// ── N-ary operator (sum/integral) ──\n\nfunction stringifyNAry(\n opts: {\n children: MathInput[];\n subScript?: MathInput[];\n superScript?: MathInput[];\n properties?: MathNaryProperties;\n },\n chr: string,\n): string {\n const hasSub = opts.subScript && opts.subScript.length > 0;\n const hasSup = opts.superScript && opts.superScript.length > 0;\n const prParts: string[] = [`<m:chr m:val=\"${chr}\"/>`];\n if (opts.properties?.limitLocation)\n prParts.push(`<m:limLoc m:val=\"${opts.properties.limitLocation}\"/>`);\n if (opts.properties?.grow !== undefined)\n prParts.push(`<m:grow m:val=\"${opts.properties.grow ? 1 : 0}\"/>`);\n if (!hasSub) prParts.push('<m:subHide m:val=\"1\"/>');\n if (!hasSup) prParts.push('<m:supHide m:val=\"1\"/>');\n const pr = `<m:naryPr>${prParts.join(\"\")}</m:naryPr>`;\n const sub = hasSub ? `<m:sub>${stringifyChildren(opts.subScript!)}</m:sub>` : \"<m:sub/>\";\n const sup = hasSup ? `<m:sup>${stringifyChildren(opts.superScript!)}</m:sup>` : \"<m:sup/>\";\n return `<m:nary>${pr}${sub}${sup}<m:e>${stringifyChildren(opts.children)}</m:e></m:nary>`;\n}\n\n// ── Delimiters (brackets) ──\n\nfunction stringifyDelimiters(\n children: MathInput[],\n begChr: string,\n endChr: string,\n properties?: MathDelimiterProperties,\n): string {\n const prParts: string[] = [`<m:begChr m:val=\"${properties?.beginCharacter ?? begChr}\"/>`];\n if (properties?.separatorCharacter)\n prParts.push(`<m:sepChr m:val=\"${properties.separatorCharacter}\"/>`);\n prParts.push(`<m:endChr m:val=\"${properties?.endCharacter ?? endChr}\"/>`);\n if (properties?.grow !== undefined) prParts.push(`<m:grow m:val=\"${properties.grow ? 1 : 0}\"/>`);\n if (properties?.shape) prParts.push(`<m:shp m:val=\"${properties.shape}\"/>`);\n return `<m:d><m:dPr>${prParts.join(\"\")}</m:dPr><m:e>${stringifyChildren(children)}</m:e></m:d>`;\n}\n\n/** Build an m:argPr/m:argSz block for an argument size scaling value. */\nfunction argPrXml(size: number | undefined): string {\n return size !== undefined ? `<m:argPr><m:argSz m:val=\"${size}\"/></m:argPr>` : \"\";\n}\n\n/** Split a bracket shorthand into children + optional delimiter properties. */\nfunction bracketSpec(\n v: MathInput[] | { children: MathInput[]; properties?: MathDelimiterProperties },\n): {\n children: MathInput[];\n properties?: MathDelimiterProperties;\n} {\n if (Array.isArray(v)) return { children: v };\n return { children: v.children, properties: v.properties };\n}\n\n// ── Top-level Math wrapper ──\n\nexport function stringifyMath(children: MathInput[]): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n return `<m:oMath>${inner}</m:oMath>`;\n}\n\nexport function stringifyMathParagraph(\n children: MathInput[],\n justification?: \"left\" | \"right\" | \"center\" | \"centerGroup\",\n): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n const pr = justification ? `<m:oMathParaPr><m:jc m:val=\"${justification}\"/></m:oMathParaPr>` : \"\";\n return `<m:oMathPara>${pr}<m:oMath>${inner}</m:oMath></m:oMathPara>`;\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (OMML XML → MathInput)\n// ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Parse all math children from an m:oMath (or similar container) element.\n */\nexport function parseMathChildren(el: Element): MathInput[] {\n const result: MathInput[] = [];\n for (const child of el.elements ?? []) {\n const parsed = parseMathElement(child);\n if (parsed !== undefined) result.push(parsed);\n }\n return result;\n}\n\nfunction parseMathElement(el: Element): MathInput | undefined {\n switch (el.name) {\n case \"m:r\":\n return parseMathRun(el);\n case \"m:f\":\n return parseMathFraction(el);\n case \"m:rad\":\n return parseMathRadical(el);\n case \"m:sSup\":\n return parseMathSuperScript(el);\n case \"m:sSub\":\n return parseMathSubScript(el);\n case \"m:sSubSup\":\n return parseMathSubSuperScript(el);\n case \"m:nary\":\n return parseMathNAry(el);\n case \"m:func\":\n return parseMathFunction(el);\n case \"m:d\":\n return parseMathDelimiter(el);\n case \"m:m\":\n return parseMathMatrix(el);\n case \"m:acc\":\n return parseMathAccent(el);\n case \"m:bar\":\n return parseMathBar(el);\n case \"m:borderBox\":\n return { borderBox: { children: parseMathArg(el, \"m:e\") } };\n case \"m:box\":\n return { box: { children: parseMathArg(el, \"m:e\") } };\n case \"m:groupChr\":\n return { groupChr: { children: parseMathArg(el, \"m:e\") } };\n case \"m:phant\":\n return { phant: { children: parseMathArg(el, \"m:e\") } };\n case \"m:eqArr\":\n return parseMathEqArr(el);\n case \"m:limLow\":\n return parseMathLimitLower(el);\n case \"m:limUpp\":\n return parseMathLimitUpper(el);\n // Property elements — not standalone content\n case \"m:rPr\":\n case \"m:fPr\":\n case \"m:radPr\":\n case \"m:sSupPr\":\n case \"m:sSubPr\":\n case \"m:sSubSupPr\":\n case \"m:naryPr\":\n case \"m:funcPr\":\n case \"m:dPr\":\n case \"m:mPr\":\n case \"m:accPr\":\n case \"m:barPr\":\n case \"m:borderBoxPr\":\n case \"m:boxPr\":\n case \"m:groupChrPr\":\n case \"m:phantPr\":\n case \"m:eqArrPr\":\n case \"m:limLowPr\":\n case \"m:limUppPr\":\n case \"m:ctrlPr\":\n return undefined;\n default:\n return undefined;\n }\n}\n\nfunction parseMathRun(el: Element): MathInput {\n const text = textOf(findChild(el, \"m:t\"));\n return text ?? \"\";\n}\n\n// ── Parse helpers ──\n\n/** Read an m:val on/off attribute (1/0/true/false; empty element = on). */\nfunction readOnOff(el: Element | undefined): boolean | undefined {\n if (!el) return undefined;\n const v = attr(el, \"m:val\");\n return v === undefined ? true : v === \"1\" || v === \"true\" || v === \"on\";\n}\n\n/** Read an m:val numeric attribute. */\nfunction readNum(el: Element | undefined): number | undefined {\n if (!el) return undefined;\n const v = attr(el, \"m:val\");\n if (v === undefined || v === \"\") return undefined;\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n\n/** Read an m:argSz scaling value from an m:argPr-bearing argument element. */\nfunction readArgSize(argEl: Element | undefined): number | undefined {\n if (!argEl) return undefined;\n return readNum(findChild(argEl, \"m:argSz\"));\n}\n\nfunction parseMathFraction(el: Element): MathInput {\n const numeratorArgumentSize = readArgSize(findChild(el, \"m:num\"));\n const denominatorArgumentSize = readArgSize(findChild(el, \"m:den\"));\n return {\n fraction: {\n numerator: parseMathArg(el, \"m:num\"),\n denominator: parseMathArg(el, \"m:den\"),\n ...(numeratorArgumentSize !== undefined ? { numeratorArgumentSize } : {}),\n ...(denominatorArgumentSize !== undefined ? { denominatorArgumentSize } : {}),\n },\n };\n}\n\nfunction parseMathRadical(el: Element): MathInput {\n const degree = parseMathArg(el, \"m:deg\");\n const mathChildren = parseMathArg(el, \"m:e\");\n return {\n radical: {\n children: mathChildren,\n ...(degree.length > 0 ? { degree } : {}),\n },\n };\n}\n\nfunction parseMathSuperScript(el: Element): MathInput {\n return {\n superScript: {\n children: parseMathArg(el, \"m:e\"),\n superScript: parseMathArg(el, \"m:sup\"),\n },\n };\n}\n\nfunction parseMathSubScript(el: Element): MathInput {\n return {\n subScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n },\n };\n}\n\nfunction parseMathSubSuperScript(el: Element): MathInput {\n const pr = findChild(el, \"m:sSubSupPr\");\n const alignScript = pr ? readOnOff(findChild(pr, \"m:alnScr\")) : undefined;\n return {\n subSuperScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n superScript: parseMathArg(el, \"m:sup\"),\n ...(alignScript !== undefined ? { alignScript } : {}),\n },\n };\n}\n\nfunction parseMathNAry(el: Element): MathInput {\n const naryPr = findChild(el, \"m:naryPr\");\n const chrEl = naryPr ? findChild(naryPr, \"m:chr\") : undefined;\n const chrVal = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n const baseChildren = parseMathArg(el, \"m:e\");\n const sub = parseMathArg(el, \"m:sub\");\n const sup = parseMathArg(el, \"m:sup\");\n\n const properties: MathNaryProperties = {};\n if (naryPr) {\n const limLocEl = findChild(naryPr, \"m:limLoc\");\n if (limLocEl) {\n const limLoc = attr(limLocEl, \"m:val\");\n if (limLoc === \"subSup\" || limLoc === \"undOvr\") properties.limitLocation = limLoc;\n }\n const grow = readOnOff(findChild(naryPr, \"m:grow\"));\n if (grow !== undefined) properties.grow = grow;\n }\n\n const common = {\n children: baseChildren,\n ...(sub.length > 0 ? { subScript: sub } : {}),\n ...(sup.length > 0 ? { superScript: sup } : {}),\n ...(Object.keys(properties).length > 0 ? { properties } : {}),\n };\n\n if (chrVal === \"∑\") return { sum: common };\n return { integral: common };\n}\n\nfunction parseMathFunction(el: Element): MathInput {\n return {\n function: {\n name: parseMathArg(el, \"m:fName\"),\n children: parseMathArg(el, \"m:e\"),\n },\n };\n}\n\nfunction parseMathDelimiter(el: Element): MathInput {\n const dPr = findChild(el, \"m:dPr\");\n const begChrEl = dPr ? findChild(dPr, \"m:begChr\") : undefined;\n const begChr = begChrEl ? attr(begChrEl, \"m:val\") : \"(\";\n const mathChildren = parseMathArg(el, \"m:e\");\n\n // Collect delimiter properties when present (sepChr/grow/shp/non-default chars).\n const properties: MathDelimiterProperties = {};\n if (dPr) {\n if (begChrEl) properties.beginCharacter = begChr;\n const endChrEl = findChild(dPr, \"m:endChr\");\n if (endChrEl) properties.endCharacter = attr(endChrEl, \"m:val\");\n const sepChrEl = findChild(dPr, \"m:sepChr\");\n if (sepChrEl) properties.separatorCharacter = attr(sepChrEl, \"m:val\");\n const grow = readOnOff(findChild(dPr, \"m:grow\"));\n if (grow !== undefined) properties.grow = grow;\n const shpEl = findChild(dPr, \"m:shp\");\n if (shpEl) {\n const shp = attr(shpEl, \"m:val\");\n if (shp === \"centered\" || shp === \"match\") properties.shape = shp;\n }\n }\n const hasProperties = Object.keys(properties).length > 0;\n const value = hasProperties ? { children: mathChildren, properties } : mathChildren;\n\n switch (begChr) {\n case \"[\":\n return { squareBrackets: value };\n case \"{\":\n return { curlyBrackets: value };\n case \"<\":\n case \"⟨\":\n return { angledBrackets: value };\n default:\n return { roundBrackets: value };\n }\n}\n\nfunction parseMathMatrix(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const mr of children(el, \"m:mr\")) {\n rows.push(parseMathArg(mr, \"m:e\"));\n }\n return { matrix: { rows } };\n}\n\nfunction parseMathAccent(el: Element): MathInput {\n const accPr = findChild(el, \"m:accPr\");\n const chrEl = accPr ? findChild(accPr, \"m:chr\") : undefined;\n const accentChar = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n return {\n accent: {\n children: parseMathArg(el, \"m:e\"),\n ...(accentChar ? { accentCharacter: accentChar } : {}),\n },\n };\n}\n\nfunction parseMathBar(el: Element): MathInput {\n const barPr = findChild(el, \"m:barPr\");\n const posEl = barPr ? findChild(barPr, \"m:pos\") : undefined;\n const pos = posEl ? attr(posEl, \"m:val\") : \"top\";\n\n return {\n bar: {\n children: parseMathArg(el, \"m:e\"),\n type: (pos as \"top\" | \"bot\") ?? \"top\",\n },\n };\n}\n\nfunction parseMathEqArr(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const e of children(el, \"m:e\")) {\n rows.push(parseMathChildren(e));\n }\n return { eqArr: { rows } };\n}\n\nfunction parseMathLimitLower(el: Element): MathInput {\n return {\n limitLower: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathLimitUpper(el: Element): MathInput {\n return {\n limitUpper: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathArg(parent: Element, childName: string): MathInput[] {\n const container = findChild(parent, childName);\n if (!container) return [];\n return parseMathChildren(container);\n}\n","/**\n * Replace relationship references in raw XML with `{fileName}` placeholders.\n *\n * Raw-XML passthrough paths (document background, mc:AlternateContent VML\n * fallback) carry VML/structured content verbatim. Their r:id / r:embed /\n * r:link references must be replaced with `{fileName}` placeholders and the\n * referenced media collected, so the compiler's placeholder pass registers the\n * media and resolves the placeholders into relationship ids. Otherwise the\n * carried source rIds dangle — they are not defined in the generated rels and\n * Word rejects the package as unreadable.\n */\nimport type { DocxReadContext } from \"../context\";\nimport type { BackgroundRawMediaOptions } from \"../parts/document/document-background/document-background\";\nimport { imageTypeFromPath } from \"../parts/drawing/drawing-parse\";\n\nconst REL_ATTR_RE = /\\br:(id|embed|link)=\"([^\"]+)\"/g;\n\nexport function replaceRelsWithPlaceholders(\n xml: string,\n ctx: DocxReadContext,\n prefix: string,\n): { rawXml: string; rawMedia: BackgroundRawMediaOptions[] } {\n const rawMedia: BackgroundRawMediaOptions[] = [];\n const rawXml = xml.replace(REL_ATTR_RE, (match, attrName: string, rId: string) => {\n const mediaPath = ctx.resolveRelationship(rId);\n const data = mediaPath ? ctx.getRaw(mediaPath) : undefined;\n if (!mediaPath || !data) return match;\n const type = imageTypeFromPath(mediaPath);\n const fileName = `${prefix}-${rId}.${type}`;\n if (!rawMedia.some((m) => m.fileName === fileName)) {\n rawMedia.push({ fileName, data, type });\n }\n return `r:${attrName}=\"{${fileName}}\"`;\n });\n return { rawXml, rawMedia };\n}\n","/**\n * Body-level stringification for DOCX documents.\n *\n * Converts pure JSON options to XML strings for document body content.\n * Pure string concatenation — zero IXmlableObject, zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { hexColorValue, uCharHexNumber } from \"@office-open/core\";\nimport { ThemeColor } from \"@office-open/core\";\nimport {\n attr,\n attrBool,\n attrMeasure,\n attrNum,\n escapeXml,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { sectionPropertiesDesc } from \"@parts/document/body/section-properties/descriptor\";\nimport type {\n BackgroundRawMediaOptions,\n DocumentBackgroundOptions,\n} from \"@parts/document/document-background\";\nimport { parseDrawingRun } from \"@parts/drawing/drawing-parse\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport { objectDesc, type ObjectElementOptions } from \"@parts/object\";\nimport type { BordersOptions } from \"@parts/paragraph/formatting/border\";\nimport type { IndentAttributesProperties } from \"@parts/paragraph/formatting/indent\";\nimport { LineRuleType } from \"@parts/paragraph/formatting/spacing\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport { HeadingLevel } from \"@parts/paragraph/formatting/style\";\nimport type { TabStopDefinition } from \"@parts/paragraph/formatting/tab-stop\";\nimport type { FrameOptions } from \"@parts/paragraph/frame/frame-properties\";\nimport type {\n MarkupRangeOptions,\n BookmarkStartOptions,\n MoveRangeStartOptions,\n} from \"@parts/paragraph/links/bookmark\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n ParagraphPropertiesOptions,\n ParagraphPropertiesChangeOptions,\n} from \"@parts/paragraph/properties\";\nimport { parseFormFieldData } from \"@parts/paragraph/run/form-field\";\nimport type { FormFieldOptions } from \"@parts/paragraph/run/form-field\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport { breakXml, type BreakOptions, type RunOptions } from \"@parts/paragraph/run/run\";\nimport { parseRun, parseRunProperties, parsedRunToOptions } from \"@parts/paragraph/run/run-parse\";\nimport { parseSdtProperties } from \"@parts/sdt/sdt-parse\";\nimport { stringifyTableOfContents } from \"@parts/table-of-contents/descriptor\";\nimport type { VmlShapeStyle } from \"@parts/textbox/shape/shape\";\nimport { styleToKeyMap } from \"@parts/textbox/shape/shape\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { MediaData } from \"@shared/media/data\";\nimport type { SectionChild } from \"@shared/section\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\n\nimport type { DocxReadContext, DocxWriteContext, BodyContext } from \"./context\";\nimport { tableDesc, altChunkDesc, subDocDesc, sdtBlockDesc, customXmlBlockDesc } from \"./parts\";\nimport { parseCustomXmlProperties } from \"./parts/bodychildren\";\nimport { stringifyChildDispatch } from \"./parts/inline\";\nimport { parseMathChildren } from \"./parts/paragraph/math/stringify\";\nimport type { ParagraphChild, SdtRunOptions } from \"./parts/paragraph/paragraph\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./parts/paragraph/stringify\";\nimport { replaceRelsWithPlaceholders } from \"./util/replace-media-placeholders\";\nimport { stringifyElement } from \"./util/stringify-element\";\n\nexport type { BodyContext } from \"./context\";\n\n// ── Run ──\n\n/**\n * Mapping from empty child property name to self-closing XML element.\n *\n * These are single-key objects like `{ noBreakHyphen: true }` that map to\n * self-closing XML elements with no attributes.\n *\n * XSD reference: EG_RunInnerContent group in wml.xsd.\n */\nconst EMPTY_RUN_ELEMENTS: Record<string, string> = {\n noBreakHyphen: \"<w:noBreakHyphen/>\",\n softHyphen: \"<w:softHyphen/>\",\n dayShort: \"<w:dayShort/>\",\n monthShort: \"<w:monthShort/>\",\n yearShort: \"<w:yearShort/>\",\n dayLong: \"<w:dayLong/>\",\n monthLong: \"<w:monthLong/>\",\n yearLong: \"<w:yearLong/>\",\n annotationRef: \"<w:annotationRef/>\",\n footnoteRef: \"<w:footnoteRef/>\",\n endnoteRef: \"<w:endnoteRef/>\",\n separator: \"<w:separator/>\",\n continuationSeparator: \"<w:continuationSeparator/>\",\n pgNum: \"<w:pgNum/>\",\n carriageReturn: \"<w:cr/>\",\n lastRenderedPageBreak: \"<w:lastRenderedPageBreak/>\",\n};\n\n/**\n * Stringify a run (w:r) from pure JSON options.\n *\n * Handles text, children, breaks, and run properties.\n */\nexport function stringifyRun(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n // Pre-scan children for commentReference — needs CommentReference style in rPr\n let commentRefStyle = false;\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"object\" && child !== null && \"commentReference\" in child) {\n commentRefStyle = true;\n break;\n }\n }\n }\n\n // Run properties — inject CommentReference style if needed\n const runOpts = commentRefStyle ? { ...opts, style: \"CommentReference\" as const } : opts;\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n // Breaks (w:br) — count shorthand or structured with clear (CT_Br)\n if (opts.break) {\n parts.push(breakXml(opts.break));\n }\n\n // Children or text\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n // Simple text string — direct output\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else if (typeof child === \"object\" && child !== null) {\n // Simple run-level elements — bare content, no <w:r> wrapper\n if (\"tab\" in child) {\n parts.push(\"<w:tab/>\");\n continue;\n }\n if (\"pageBreak\" in child) {\n parts.push('<w:br w:type=\"page\"/>');\n continue;\n }\n if (\"columnBreak\" in child) {\n parts.push('<w:br w:type=\"column\"/>');\n continue;\n }\n if (\"break\" in child) {\n parts.push(breakXml((child as { break: number | BreakOptions }).break));\n continue;\n }\n if (\"commentReference\" in child) {\n parts.push(`<w:commentReference w:id=\"${Number(child.commentReference)}\"/>`);\n continue;\n }\n\n // Empty run elements — self-closing XML with no attributes\n // { noBreakHyphen: true } → <w:noBreakHyphen/>, etc.\n const emptyXml = EMPTY_RUN_ELEMENTS[Object.keys(child)[0]];\n if (emptyXml) {\n parts.push(emptyXml);\n continue;\n }\n\n // OLE object — w:object (VML shape + objectEmbed/link/control/movie)\n if (\"object\" in child) {\n parts.push(\n objectDesc.stringify((child as { object: ObjectElementOptions }).object, ctx) ?? \"\",\n );\n continue;\n }\n\n // JSON child dispatch (images, charts, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else {\n // Fallback: treat as IXmlableObject-like — should not happen in JSON path\n throw new Error(`Unsupported run child type: ${Object.keys(child).join(\", \")}`);\n }\n }\n }\n } else if (opts.text !== undefined) {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:t>`);\n }\n\n // rsid attributes on <w:r>\n const rsidAttrs: string[] = [];\n if (opts.rsid) rsidAttrs.push(` w:rsidR=\"${opts.rsid}\"`);\n if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${opts.deletionRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body.length === 0 ? (attr ? `<w:r${attr}/>` : \"<w:r/>\") : `<w:r${attr}>${body}</w:r>`;\n}\n\n// ── Paragraph ──\n\n/**\n * Stringify a paragraph (w:p) from pure JSON options or string.\n *\n * Handles paragraph properties, numbering registration, and run children.\n */\nexport function stringifyParagraph(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n sectionPropertiesXml?: string,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n // Build paragraph properties — direct string output, zero IXmlableObject allocation\n const props = stringifyParagraphProperties(resolved);\n\n // Register numbering references\n if (!(ctx.viewWrapper instanceof FontWrapper)) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n // Paragraph properties XML\n if (props.xml) {\n if (sectionPropertiesXml) {\n // Insert sectPr before closing </w:pPr>\n parts.push(props.xml.replace(\"</w:pPr>\", sectionPropertiesXml + \"</w:pPr>\"));\n } else {\n parts.push(props.xml);\n }\n } else if (sectionPropertiesXml) {\n // No pPr but we need sectPr — wrap in pPr\n parts.push(`<w:pPr>${sectionPropertiesXml}</w:pPr>`);\n }\n\n // Text shorthand\n if (resolved.text !== undefined) {\n parts.push(stringifyRun({ text: resolved.text }, ctx));\n }\n\n // Children\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRun({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, pageBreak, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else {\n // RunOptions-like plain object — may be an empty run carrying only\n // run properties (round-tripped from <w:r><w:rPr>…</w:rPr></w:r>).\n parts.push(stringifyRun(child as RunOptions, ctx));\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n const paraAttrs: string[] = [];\n if (resolved.paraId) paraAttrs.push(` w14:paraId=\"${resolved.paraId}\"`);\n if (resolved.textId) paraAttrs.push(` w14:textId=\"${resolved.textId}\"`);\n if (resolved.rsid) paraAttrs.push(` w:rsidR=\"${resolved.rsid}\"`);\n if (resolved.defaultRunRsid) paraAttrs.push(` w:rsidRDefault=\"${resolved.defaultRunRsid}\"`);\n if (resolved.propertiesRsid) paraAttrs.push(` w:rsidP=\"${resolved.propertiesRsid}\"`);\n if (resolved.runPropertiesRsid) paraAttrs.push(` w:rsidRPr=\"${resolved.runPropertiesRsid}\"`);\n if (resolved.deletionRsid) paraAttrs.push(` w:rsidDel=\"${resolved.deletionRsid}\"`);\n const attr = paraAttrs.join(\"\");\n return body ? `<w:p${attr}>${body}</w:p>` : `<w:p${attr}/>`;\n}\n\n// ── Body child dispatch ──\n\n/**\n * Stringify a body-level child element.\n *\n * Dispatches to the appropriate stringifier based on the child type.\n * Pure JSON API — no class instance support.\n */\nexport function stringifyBodyChild(child: SectionChild, ctx: BodyContext): string {\n // Plain object dispatch — all via descriptors\n if (\"paragraph\" in child) {\n return stringifyParagraph(child.paragraph, ctx);\n }\n if (\"table\" in child) {\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n if (\"toc\" in child) {\n const { alias, ...options } = child.toc;\n const entriesXml = (options.entries ?? [])\n .map((entry) => stringifyBodyChild(entry, ctx))\n .join(\"\");\n return stringifyTableOfContents(alias, options, entriesXml);\n }\n if (\"textbox\" in child) {\n return stringifyTextbox(child.textbox, ctx);\n }\n if (\"sdt\" in child) {\n return sdtBlockDesc.stringify(child.sdt, ctx) ?? \"\";\n }\n if (\"altChunk\" in child) {\n return altChunkDesc.stringify(child.altChunk, ctx) ?? \"\";\n }\n if (\"subDoc\" in child) {\n return subDocDesc.stringify(child.subDoc, ctx) ?? \"\";\n }\n if (\"customXml\" in child) {\n return customXmlBlockDesc.stringify(child.customXml, ctx) ?? \"\";\n }\n if (\"bookmarkStart\" in child) {\n const bs = child.bookmarkStart;\n const a: string[] = [`w:id=\"${bs.id}\"`, `w:name=\"${escapeXml(bs.name)}\"`];\n if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${bs.displacedByCustomXml}\"`);\n if (bs.colFirst !== undefined) a.push(`w:colFirst=\"${bs.colFirst}\"`);\n if (bs.colLast !== undefined) a.push(`w:colLast=\"${bs.colLast}\"`);\n return `<w:bookmarkStart ${a.join(\" \")}/>`;\n }\n if (\"bookmarkEnd\" in child) {\n const be = child.bookmarkEnd;\n const a: string[] = [`w:id=\"${be.id}\"`];\n if (be.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${be.displacedByCustomXml}\"`);\n return `<w:bookmarkEnd ${a.join(\" \")}/>`;\n }\n if (\"rawXml\" in child) {\n return child.rawXml;\n }\n\n throw new Error(\"Unknown section child type\");\n}\n\n// ── Document background (pure function, no XmlComponent) ──\n\n/** Re-export styleToKeyMap for use in stringifyTextboxStyle. */\nconst vmlStyleMap = styleToKeyMap;\n\nfunction stringifyDocumentBackground(opts: DocumentBackgroundOptions, ctx: BodyContext): string {\n // Raw-XML passthrough for backgrounds that don't fit the structured model\n // (VML pattern fills, texture images). Register each referenced media item\n // so the compiler resolves the `{fileName}` placeholders into rIds.\n if (opts.rawXml) {\n if (opts.rawMedia) {\n for (const m of opts.rawMedia) {\n const data = toUint8Array(m.data);\n const entry = ctx.file.media.addMedia(\n data,\n m.type,\n (fileName) =>\n ({\n type: m.type,\n data,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n m.fileName,\n );\n // Dedup may reuse an earlier file name; remap the placeholder so the\n // compiler resolves it to the shared media relationship.\n if (entry.fileName !== m.fileName) {\n opts.rawXml = opts.rawXml.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);\n }\n }\n }\n return opts.rawXml;\n }\n\n const attrs: string[] = [];\n if (opts.color !== undefined) attrs.push(`w:color=\"${hexColorValue(opts.color)}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeShade !== undefined)\n attrs.push(`w:themeShade=\"${uCharHexNumber(opts.themeShade)}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${uCharHexNumber(opts.themeTint)}\"`);\n const attrStr = attrs.join(\" \");\n\n if (opts.image) {\n const image = opts.image;\n const rawData = toUint8Array(image.data) as Uint8Array;\n const { fileName } = ctx.file.media.addMedia(\n rawData,\n image.type,\n (name) =>\n ({\n type: image.type as \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\",\n data: rawData,\n fileName: name,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n );\n\n const vmlBg = `<v:background id=\"_x0000_s1025\"><v:fill r:id=\"{${fileName}}\" o:title=\"${fileName}\" recolor=\"t\" type=\"frame\"/></v:background>`;\n return `<w:background ${attrStr}>${vmlBg}</w:background>`;\n }\n\n return `<w:background ${attrStr}/>`;\n}\n\n// ── Textbox (pure function, no XmlComponent) ──\n\nfunction stringifyTextbox(\n opts: Omit<ParagraphOptions, \"style\" | \"children\"> & {\n style?: VmlShapeStyle;\n children?: SectionChild[];\n },\n ctx: BodyContext,\n): string {\n // Destructure to separate VML style/children from paragraph properties\n const { style, children, ...paraOpts } = opts;\n const props = stringifyParagraphProperties(paraOpts);\n const pPrXml = props.xml ?? \"\";\n\n // VML shape style string\n const styleStr = style\n ? Object.entries(style)\n .map(([k, v]) => `${vmlStyleMap[k as keyof VmlShapeStyle]}:${v}`)\n .join(\";\")\n : undefined;\n\n // Shape attributes\n const shapeAttrs: string[] = [`id=\"_x0000_s${uniqueId()}\"`, `type=\"#_x0000_t202\"`];\n if (styleStr) shapeAttrs.push(`style=\"${styleStr}\"`);\n\n // Textbox content — serialize children via stringifyBodyChild\n const contentParts: string[] = [];\n if (children) {\n for (const c of children) {\n contentParts.push(stringifyBodyChild(c, ctx));\n }\n }\n const txbxContent = contentParts.join(\"\");\n\n const vmlTextbox = `<v:textbox style=\"mso-fit-shape-to-text:t;\" insetmode=\"auto\"><w:txbxContent>${txbxContent}</w:txbxContent></v:textbox>`;\n const vshape = `<v:shape ${shapeAttrs.join(\" \")}>${vmlTextbox}</v:shape>`;\n\n return `<w:p>${pPrXml}<w:pict>${vshape}</w:pict></w:p>`;\n}\n\n// ── Document body ──\n\n/** Document-level namespace string (cached). */\nconst DOC_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/**\n * Stringify the complete document.xml from context data.\n *\n * This is the pure JSON path — iterates raw section children via\n * `stringifyBodyChild()` while reusing existing SectionProperties\n * instances for sectPr XML (which are already created with correct\n * header/footer references).\n *\n * Produces the complete `<w:document>` element including namespaces,\n * background, body content with interleaved section properties.\n */\nexport function stringifyDocumentXml(ctx: DocxWriteContext, docCtx: BodyContext): string {\n const sections = ctx._options.sections;\n const bodySections = ctx.sectionProperties;\n const parts: string[] = [];\n\n // <w:document> open tag\n const conformanceAttr = ctx._options.conformance\n ? ` w:conformance=\"${ctx._options.conformance}\"`\n : \"\";\n parts.push(`<w:document ${DOC_NS} mc:Ignorable=\"w14 w15 wp14\"${conformanceAttr}>`);\n\n // Background (if any)\n if (ctx._options.background) {\n parts.push(stringifyDocumentBackground(ctx._options.background, docCtx));\n }\n\n // <w:body>\n const bodyParts: string[] = [];\n\n for (let si = 0; si < sections.length; si++) {\n const section = sections[si];\n\n // Serialize section children using stringifyBodyChild()\n if (section.children) {\n for (const child of section.children) {\n bodyParts.push(stringifyBodyChild(child, docCtx));\n }\n }\n\n // Section properties — pure function, no XmlComponent instance\n const sectPrOpts = bodySections[si];\n if (sectPrOpts) {\n const sectPrXml = sectionPropertiesDesc.stringify(sectPrOpts, docCtx) ?? \"\";\n if (si < sections.length - 1) {\n // Non-last section: embed sectPr in a paragraph's pPr\n bodyParts.push(`<w:p><w:pPr>${sectPrXml}</w:pPr></w:p>`);\n } else {\n // Last section: body-level sectPr\n bodyParts.push(sectPrXml);\n }\n }\n }\n\n parts.push(`<w:body>${bodyParts.join(\"\")}</w:body>`);\n parts.push(\"</w:document>\");\n\n return parts.join(\"\");\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (XML → JSON options)\n// ────────────────────────────────────────────────────────────────────────────────\n\nconst HEADING_MAP: Record<string, (typeof HeadingLevel)[keyof typeof HeadingLevel]> = {\n Heading1: HeadingLevel.HEADING_1,\n Heading2: HeadingLevel.HEADING_2,\n Heading3: HeadingLevel.HEADING_3,\n Heading4: HeadingLevel.HEADING_4,\n Heading5: HeadingLevel.HEADING_5,\n Heading6: HeadingLevel.HEADING_6,\n Title: HeadingLevel.TITLE,\n};\n\n/** Valid w:spacing/@w:lineRule values (ST_LineSpacingRule). */\nconst LINE_RULES = Object.values(LineRuleType) as readonly string[];\n/** Valid border @w:val values (ST_Border). */\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\n/** Valid border @w:themeColor values (ST_ThemeColor). */\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/**\n * Reverse of inline.ts's deleted-page-number field map: maps a w:delInstrText\n * field code to the PageNumber placeholder a deletion run uses on the stringify\n * side, so deleted page-number fields round-trip instead of being dropped.\n */\nconst DELETED_PAGE_FIELD: Record<string, string> = {\n PAGE: \"CURRENT\",\n NUMPAGES: \"TOTAL_PAGES\",\n SECTIONPAGES: \"TOTAL_PAGES_IN_SECTION\",\n};\n\n/**\n * Parsed w:framePr attributes — flat capture of whatever attributes the source\n * carries. The public FrameOptions union (type/position/alignment + required\n * width/height/anchor) is rebuilt on the stringify side; parse preserves raw\n * attributes verbatim so round-trip keeps source fidelity.\n */\ninterface ParsedFrameProperties {\n dropCap?: string;\n lines?: string;\n wrap?: string;\n vAnchor?: string;\n hAnchor?: string;\n x?: string;\n y?: string;\n hRule?: string;\n hSpace?: string;\n vSpace?: string;\n alignment?: { x?: string; y?: string };\n anchor?: { horizontal?: string; vertical?: string };\n anchorLock?: boolean;\n width?: number;\n height?: number;\n}\n\n// Inline element payloads extracted from the ParagraphChild union — used by\n// parse to build typed objects instead of Record<string, unknown>.\ntype SmartTagInlineOptions = Extract<ParagraphChild, { smartTag: unknown }>[\"smartTag\"];\ntype CustomXmlInlineOptions = Extract<ParagraphChild, { customXml: unknown }>[\"customXml\"];\ntype DirInlineOptions = Extract<ParagraphChild, { dir: unknown }>[\"dir\"];\ntype HyperlinkInlineOptions = Extract<ParagraphChild, { hyperlink: unknown }>[\"hyperlink\"];\ntype PermStartInlineOptions = Extract<ParagraphChild, { permStart: unknown }>[\"permStart\"];\n\n/**\n * Parse w:pPr element into paragraph properties (without children).\n */\nexport function parseParagraphProperties(\n el: Element,\n ctx: DocxReadContext,\n): Partial<ParagraphPropertiesOptions> {\n const opts: Partial<ParagraphPropertiesOptions> = {};\n\n // Style / heading\n const pStyle = findChild(el, \"w:pStyle\");\n if (pStyle) {\n const styleVal = attr(pStyle, \"w:val\");\n if (styleVal) {\n if (HEADING_MAP[styleVal]) {\n opts.heading = HEADING_MAP[styleVal];\n } else {\n opts.style = styleVal;\n }\n }\n }\n\n // Alignment\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.alignment = val as ParagraphPropertiesOptions[\"alignment\"];\n }\n\n // Spacing — before/after/line are ST_TwipsMeasure (number | UniversalMeasure);\n // use attrMeasure so UniversalMeasure round-trips with the stringify side.\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const sp: SpacingProperties = {};\n const before = attrMeasure(spacing, \"w:before\");\n if (before !== undefined) sp.before = before as SpacingProperties[\"before\"];\n const after = attrMeasure(spacing, \"w:after\");\n if (after !== undefined) sp.after = after as SpacingProperties[\"after\"];\n const line = attrMeasure(spacing, \"w:line\");\n if (line !== undefined) sp.line = line as SpacingProperties[\"line\"];\n const lineRule = attr(spacing, \"w:lineRule\");\n if (lineRule && (LINE_RULES as readonly string[]).includes(lineRule)) {\n sp.lineRule = lineRule as SpacingProperties[\"lineRule\"];\n }\n const beforeAutoSpacing = attrBool(spacing, \"w:beforeAutospacing\");\n if (beforeAutoSpacing !== undefined) sp.beforeAutoSpacing = beforeAutoSpacing;\n const afterAutoSpacing = attrBool(spacing, \"w:afterAutospacing\");\n if (afterAutoSpacing !== undefined) sp.afterAutoSpacing = afterAutoSpacing;\n const beforeLines = attrNum(spacing, \"w:beforeLines\");\n if (beforeLines !== undefined) sp.beforeLines = beforeLines;\n const afterLines = attrNum(spacing, \"w:afterLines\");\n if (afterLines !== undefined) sp.afterLines = afterLines;\n if (Object.keys(sp).length > 0) opts.spacing = sp;\n }\n\n // Indent — left/right/start/end are ST_SignedTwipsMeasure, hanging/firstLine\n // are ST_TwipsMeasure (number | UniversalMeasure); use attrMeasure so\n // UniversalMeasure round-trips. *Chars are ST_DecimalNumber (pure number).\n const ind = findChild(el, \"w:ind\");\n if (ind) {\n const indentObj: IndentAttributesProperties = {};\n const left = attrMeasure(ind, \"w:left\");\n if (left !== undefined) indentObj.left = left as IndentAttributesProperties[\"left\"];\n const leftChars = attrNum(ind, \"w:leftChars\");\n if (leftChars !== undefined) indentObj.leftChars = leftChars;\n const right = attrMeasure(ind, \"w:right\");\n if (right !== undefined) indentObj.right = right as IndentAttributesProperties[\"right\"];\n const rightChars = attrNum(ind, \"w:rightChars\");\n if (rightChars !== undefined) indentObj.rightChars = rightChars;\n const start = attrMeasure(ind, \"w:start\");\n if (start !== undefined) indentObj.start = start as IndentAttributesProperties[\"start\"];\n const startChars = attrNum(ind, \"w:startChars\");\n if (startChars !== undefined) indentObj.startChars = startChars;\n const end = attrMeasure(ind, \"w:end\");\n if (end !== undefined) indentObj.end = end as IndentAttributesProperties[\"end\"];\n const endChars = attrNum(ind, \"w:endChars\");\n if (endChars !== undefined) indentObj.endChars = endChars;\n const hanging = attrMeasure(ind, \"w:hanging\");\n if (hanging !== undefined) indentObj.hanging = hanging as IndentAttributesProperties[\"hanging\"];\n const hangingChars = attrNum(ind, \"w:hangingChars\");\n if (hangingChars !== undefined) indentObj.hangingChars = hangingChars;\n const firstLine = attrMeasure(ind, \"w:firstLine\");\n if (firstLine !== undefined)\n indentObj.firstLine = firstLine as IndentAttributesProperties[\"firstLine\"];\n const firstLineChars = attrNum(ind, \"w:firstLineChars\");\n if (firstLineChars !== undefined) indentObj.firstLineChars = firstLineChars;\n if (Object.keys(indentObj).length > 0) opts.indent = indentObj;\n }\n\n // Numbering (w:numPr)\n const numPr = findChild(el, \"w:numPr\");\n if (numPr) {\n const ilvl = findChild(numPr, \"w:ilvl\");\n const level = ilvl ? (attrNum(ilvl, \"w:val\") ?? 0) : 0;\n const numIdEl = findChild(numPr, \"w:numId\");\n const numId = numIdEl ? attr(numIdEl, \"w:val\") : undefined;\n if (numId !== undefined && ctx.numberingCache.size > 0) {\n const numEl = ctx.docx.numbering;\n if (numEl) {\n let abstractNumId: string | undefined;\n for (const child of numEl.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n if (attr(child, \"w:numId\") === numId) {\n const absRef = findChild(child, \"w:abstractNumId\");\n abstractNumId = absRef ? attr(absRef, \"w:val\") : undefined;\n break;\n }\n }\n if (abstractNumId !== undefined) {\n // custom: true suppresses the ListParagraph pStyle auto-injection in\n // stringifyParagraphProperties. Round-tripped list paragraphs carry\n // no pStyle in the source (the list formatting lives in numbering);\n // injecting ListParagraph would reference a style that round-tripped\n // styles.xml may not define → dangling reference Word rejects.\n const numberingOpts: {\n reference: string;\n level: number;\n custom: boolean;\n numberingChange?: { original: string; id: string; author: string; date?: string };\n } = { reference: `list_${numId}`, level, custom: true };\n // w:numberingChange (CT_TrackChangeNumbering) — child of w:numPr\n const numberingChangeEl = findChild(numPr, \"w:numberingChange\");\n if (numberingChangeEl) {\n const nc: { original: string; id: string; author: string; date?: string } = {\n original: attr(numberingChangeEl, \"w:original\") ?? \"\",\n id: attr(numberingChangeEl, \"w:id\") ?? \"\",\n author: attr(numberingChangeEl, \"w:author\") ?? \"\",\n };\n const ncDate = attr(numberingChangeEl, \"w:date\");\n if (ncDate) nc.date = ncDate;\n numberingOpts.numberingChange = nc;\n }\n opts.numbering = numberingOpts;\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n }\n\n // Tab stops\n const tabs = findChild(el, \"w:tabs\");\n if (tabs) {\n const tabStops: TabStopDefinition[] = [];\n for (const tab of tabs.elements ?? []) {\n if (tab.name !== \"w:tab\") continue;\n const tabObj: Partial<TabStopDefinition> = {};\n const pos = attrNum(tab, \"w:pos\");\n if (pos !== undefined) tabObj.position = pos;\n const val = attr(tab, \"w:val\");\n if (val) tabObj.type = val as TabStopDefinition[\"type\"];\n const leader = attr(tab, \"w:leader\");\n if (leader) tabObj.leader = leader as TabStopDefinition[\"leader\"];\n tabStops.push(tabObj as TabStopDefinition);\n }\n if (tabStops.length > 0) opts.tabStops = tabStops;\n }\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:keepNext\", \"keepNext\"],\n [\"w:keepLines\", \"keepLines\"],\n [\"w:pageBreakBefore\", \"pageBreakBefore\"],\n [\"w:widowControl\", \"widowControl\"],\n [\"w:suppressLineNumbers\", \"suppressLineNumbers\"],\n [\"w:contextualSpacing\", \"contextualSpacing\"],\n [\"w:bidi\", \"bidirectional\"],\n [\"w:wordWrap\", \"wordWrap\"],\n [\"w:suppressAutoHyphens\", \"suppressAutoHyphens\"],\n [\"w:adjustRightInd\", \"adjustRightInd\"],\n [\"w:snapToGrid\", \"snapToGrid\"],\n [\"w:mirrorIndents\", \"mirrorIndents\"],\n [\"w:kinsoku\", \"kinsoku\"],\n [\"w:topLinePunct\", \"topLinePunct\"],\n [\"w:autoSpaceDE\", \"autoSpaceDE\"],\n [\"w:autoSpaceDN\", \"autoSpaceEastAsianText\"],\n [\"w:overflowPunct\", \"overflowPunctuation\"],\n [\"w:suppressOverlap\", \"suppressOverlap\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Thematic break\n const pBdr = findChild(el, \"w:pBdr\");\n if (pBdr) {\n const border: BordersOptions = {};\n for (const side of [\"top\", \"bottom\", \"left\", \"right\", \"between\", \"bar\"] as const) {\n const sideEl = findChild(pBdr, `w:${side}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n border[side] = sideOpts;\n }\n if (Object.keys(border).length > 0) opts.border = border;\n }\n\n // Shading\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shdObj: ShadingAttributesProperties = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shdObj.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shdObj.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shdObj.type = val as ShadingAttributesProperties[\"type\"];\n if (Object.keys(shdObj).length > 0) opts.shading = shdObj;\n }\n\n // Text alignment\n const textAlignment = findChild(el, \"w:textAlignment\");\n if (textAlignment) {\n const val = attr(textAlignment, \"w:val\");\n if (val) opts.textAlignment = val as ParagraphPropertiesOptions[\"textAlignment\"];\n }\n\n // Outline level\n const outlineLvl = findChild(el, \"w:outlineLvl\");\n if (outlineLvl) {\n const val = attrNum(outlineLvl, \"w:val\");\n if (val !== undefined) opts.outlineLevel = val;\n }\n\n // Run properties (paragraph-level defaults)\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n opts.run = parseRunProperties(rPr);\n }\n\n // Frame properties\n const framePr = findChild(el, \"w:framePr\");\n if (framePr) {\n const frame: ParsedFrameProperties = {};\n for (const [attrName, optName] of [\n [\"w:dropCap\", \"dropCap\"],\n [\"w:lines\", \"lines\"],\n [\"w:wrap\", \"wrap\"],\n [\"w:vAnchor\", \"vAnchor\"],\n [\"w:hAnchor\", \"hAnchor\"],\n [\"w:x\", \"x\"],\n [\"w:y\", \"y\"],\n [\"w:hRule\", \"hRule\"],\n [\"w:hSpace\", \"hSpace\"],\n [\"w:vSpace\", \"vSpace\"],\n ] as const) {\n const val = attr(framePr, attrName);\n if (val !== undefined) frame[optName] = val;\n }\n // Alignment (xAlign/yAlign)\n const xAlign = attr(framePr, \"w:xAlign\");\n const yAlign = attr(framePr, \"w:yAlign\");\n if (xAlign || yAlign) {\n const alignment: NonNullable<ParsedFrameProperties[\"alignment\"]> = {};\n if (xAlign) alignment.x = xAlign;\n if (yAlign) alignment.y = yAlign;\n frame.alignment = alignment;\n }\n // Anchor (hAnchor/vAnchor)\n const hAnchor = attr(framePr, \"w:hAnchor\");\n const vAnchor = attr(framePr, \"w:vAnchor\");\n if (hAnchor || vAnchor) {\n const anchor: NonNullable<ParsedFrameProperties[\"anchor\"]> = {};\n if (hAnchor) anchor.horizontal = hAnchor;\n if (vAnchor) anchor.vertical = vAnchor;\n frame.anchor = anchor;\n }\n // Anchor lock\n const anchorLock = attrBool(framePr, \"w:anchorLock\");\n if (anchorLock !== undefined) frame.anchorLock = anchorLock;\n const w = attrNum(framePr, \"w:w\");\n if (w !== undefined) frame.width = w;\n const h = attrNum(framePr, \"w:h\");\n if (h !== undefined) frame.height = h;\n if (Object.keys(frame).length > 0) opts.frame = frame as unknown as FrameOptions;\n }\n\n // Revision (w:pPrChange) — symmetric with stringifyParagraphProperties\n const pPrChange = findChild(el, \"w:pPrChange\");\n if (pPrChange) {\n const rev: Partial<ParagraphPropertiesChangeOptions> = {};\n const author = attr(pPrChange, \"w:author\");\n if (author) rev.author = author;\n const revDate = attr(pPrChange, \"w:date\");\n if (revDate) rev.date = revDate;\n const revId = attrNum(pPrChange, \"w:id\");\n if (revId !== undefined) rev.id = revId;\n const innerPPr = findChild(pPrChange, \"w:pPr\");\n if (innerPPr) Object.assign(rev, parseParagraphProperties(innerPPr, ctx));\n if (Object.keys(rev).length > 0) opts.revision = rev as ParagraphPropertiesChangeOptions;\n }\n\n return opts;\n}\n\n/**\n * Concatenate `<w:t>` text in a run element.\n *\n * Used to capture a textInput form field's current value from the result run\n * (the runs between the `separate` and `end` fldChars). Only `<w:t>` is read —\n * `<w:tab>`/`<w:br>` in results are ignored as rare for user-entered text.\n */\n/** Parse the w:r children of a track-change wrapper (w:ins/w:moveFrom/w:moveTo). */\nfunction parseTrackChangeRuns(el: Element, ctx: DocxReadContext): RunOptions[] {\n const runs: RunOptions[] = [];\n for (const sub of el.elements ?? []) {\n if (sub.name !== \"w:r\") continue;\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n runs.push(runOpts as RunOptions);\n }\n }\n return runs;\n}\n\nfunction collectRunText(el: Element): string {\n let text = \"\";\n for (const c of el.elements ?? []) {\n if (c.name === \"w:t\") text += textOf(c);\n }\n return text;\n}\n\n/** Concatenate `<w:t>` text across all `<w:r>` children of a container (rt/rubyBase). */\nfunction collectRunsText(el: Element): string {\n let text = \"\";\n for (const r of el.elements ?? []) {\n if (r.name === \"w:r\") text += collectRunText(r);\n }\n return text;\n}\n\n/**\n * Parse the inline children of a smartTag/customXml container (recursive).\n *\n * Handles runs and nested smartTag/customXml. Form fields, hyperlinks and\n * other paragraph-level constructs are rare inside these containers and are\n * not handled here.\n */\nfunction parseContainerChildren(el: Element, ctx: DocxReadContext): ParagraphChild[] {\n const children: ParagraphChild[] = [];\n for (const sub of el.elements ?? []) {\n switch (sub.name) {\n case \"w:r\": {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) children.push(runOpts);\n break;\n }\n case \"w:smartTag\": {\n const smartTag = parseSmartTagInline(sub, ctx);\n if (smartTag) children.push({ smartTag });\n break;\n }\n case \"w:customXml\": {\n const customXml = parseCustomXmlInline(sub, ctx);\n if (customXml) children.push({ customXml });\n break;\n }\n default:\n break;\n }\n }\n return children;\n}\n\n/** Parse a w:smartTag element into its ParagraphChild form. */\nfunction parseSmartTagInline(el: Element, ctx: DocxReadContext): SmartTagInlineOptions | undefined {\n const element = attr(el, \"w:element\");\n if (!element) return undefined;\n const st: SmartTagInlineOptions = { element };\n const uri = attr(el, \"w:uri\");\n if (uri) st.uri = uri;\n const pr = findChild(el, \"w:smartTagPr\");\n if (pr) {\n const props: Array<{ uri?: string; name: string; val: string }> = [];\n for (const a of pr.elements ?? []) {\n if (a.name !== \"w:attr\") continue;\n const prop: { uri?: string; name: string; val: string } = {\n name: attr(a, \"w:name\") ?? \"\",\n val: attr(a, \"w:val\") ?? \"\",\n };\n const auri = attr(a, \"w:uri\");\n if (auri) prop.uri = auri;\n props.push(prop);\n }\n if (props.length > 0) st.properties = props;\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) st.children = content;\n return st;\n}\n\n/** Parse an inline w:customXml element into its ParagraphChild form. */\nfunction parseCustomXmlInline(\n el: Element,\n ctx: DocxReadContext,\n): CustomXmlInlineOptions | undefined {\n const element = attr(el, \"w:element\");\n if (!element) return undefined;\n const cx: CustomXmlInlineOptions = { element };\n const uri = attr(el, \"w:uri\");\n if (uri) cx.uri = uri;\n const pr = findChild(el, \"w:customXmlPr\");\n if (pr) {\n const parsed = parseCustomXmlProperties(pr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined) {\n cx.customXmlPr = parsed;\n }\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) cx.children = content;\n return cx;\n}\n\n/** Parse a move-revision range start (w:moveFromRangeStart / w:moveToRangeStart). */\nfunction parseMoveRangeStart(el: Element): MoveRangeStartOptions | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: Partial<MoveRangeStartOptions> = { id };\n const name = attr(el, \"w:name\");\n if (name !== undefined) m.name = name;\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n const disp = attr(el, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") m.displacedByCustomXml = disp;\n const colFirst = attrNum(el, \"w:colFirst\");\n if (colFirst !== undefined) m.colFirst = colFirst;\n const colLast = attrNum(el, \"w:colLast\");\n if (colLast !== undefined) m.colLast = colLast;\n return m as MoveRangeStartOptions;\n}\n\n/** Parse a customXml range start (Ins/Del/MoveFrom/MoveTo). */\nfunction parseCustomXmlRangeStart(\n el: Element,\n): { id: number; author?: string; date?: string } | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: { id: number; author?: string; date?: string } = { id };\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n return m;\n}\n\n/** Parse a CT_MarkupRange end marker (id + displacedByCustomXml). */\nfunction parseMarkupRangeOptions(el: Element): MarkupRangeOptions | undefined {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return undefined;\n const m: Partial<MarkupRangeOptions> = { id };\n const disp = attr(el, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") m.displacedByCustomXml = disp;\n return m as MarkupRangeOptions;\n}\n\n/**\n * Parse a w:p element into ParagraphOptions.\n */\n/**\n * Parse run-level children shared by paragraphs and inline-SDT content.\n * Includes the field accumulator that collapses form/complex fields spanning\n * multiple w:r runs into a single child.\n */\n/** Serialize a w:r's w:rPr child verbatim (or undefined when the run has none). */\nfunction runRPrXml(run: Element): string | undefined {\n const rPr = findChild(run, \"w:rPr\");\n return rPr ? stringifyElement(rPr) : undefined;\n}\n\nfunction parseRunLevelChildren(\n elements: Element[] | undefined,\n ctx: DocxReadContext,\n): ParagraphChild[] {\n const childList: ParagraphChild[] = [];\n\n // Field accumulator: a field (form field OR plain complex field) spans\n // several w:r elements (begin fldChar → instrText → separate → result → end).\n // - Form fields (checkBox/ddList/textInput) carry w:ffData on the begin\n // fldChar; their state lives there, and only a textInput's result is\n // captured (as `value`).\n // - Plain complex fields (PAGE/DATE/TOC/HYPERLINK...) have no ffData; their\n // instrText + result are captured as a complexField child for round-trip.\n // The whole field collapses to a single child.\n let fieldKind: \"form\" | \"complex\" | null = null;\n let pendingFormField: FormFieldOptions | null = null;\n let pendingInstruction = \"\";\n let pendingResult = \"\";\n // Verbatim rPr of the field's control runs (begin/instrText/separate/end)\n // and result run(s) — Word writes identical rPr across a field's runs, so\n // capturing it preserves field formatting (font/size) through round-trip.\n let pendingControlRPr: string | undefined;\n let pendingResultRPr: string | undefined;\n // True once the `separate` fldChar is seen: subsequent runs (up to `end`)\n // are the field's result.\n let collectingResult = false;\n\n for (const child of elements ?? []) {\n switch (child.name) {\n case \"w:pPr\":\n break;\n case \"w:r\": {\n // Field: fldChar markers + the instrText/result runs between them.\n const fldCharEl = findChild(child, \"w:fldChar\");\n if (fldCharEl) {\n const fctype = attr(fldCharEl, \"w:fldCharType\");\n if (fctype === \"begin\") {\n const ffDataEl = findChild(fldCharEl, \"w:ffData\");\n if (ffDataEl) {\n fieldKind = \"form\";\n pendingFormField = parseFormFieldData(ffDataEl);\n } else {\n fieldKind = \"complex\";\n pendingInstruction = \"\";\n pendingResult = \"\";\n }\n // Capture the begin run's rPr as the field's control-run rPr.\n pendingControlRPr = runRPrXml(child);\n pendingResultRPr = undefined;\n collectingResult = false;\n } else if (fctype === \"separate\") {\n collectingResult = true;\n } else if (fctype === \"end\" && fieldKind) {\n if (fieldKind === \"form\" && pendingFormField) {\n childList.push({ formField: pendingFormField });\n } else if (fieldKind === \"complex\") {\n const cf: {\n instruction: string;\n result?: string;\n rPrXml?: string;\n resultRPrXml?: string;\n } = { instruction: pendingInstruction };\n if (pendingResult) cf.result = pendingResult;\n if (pendingControlRPr) cf.rPrXml = pendingControlRPr;\n if (pendingResultRPr) cf.resultRPrXml = pendingResultRPr;\n childList.push({ complexField: cf });\n }\n fieldKind = null;\n pendingFormField = null;\n collectingResult = false;\n }\n break;\n }\n if (fieldKind) {\n if (fieldKind === \"complex\") {\n // Collect instrText (begin→separate) and result text (separate→end).\n if (collectingResult) {\n // Capture the first result run's rPr for round-trip.\n if (pendingResultRPr === undefined) pendingResultRPr = runRPrXml(child);\n pendingResult += collectRunText(child);\n } else {\n const instrEl = findChild(child, \"w:instrText\");\n if (instrEl) pendingInstruction += textOf(instrEl);\n }\n } else if (collectingResult && pendingFormField?.textInput) {\n // Capture a textInput's current value; checkbox/dropdown results\n // are discarded (their state is in w:ffData).\n const text = collectRunText(child);\n if (text) {\n const ti = pendingFormField.textInput;\n ti.value = (ti.value ?? \"\") + text;\n }\n }\n break; // instrText / result — handled by field state above\n }\n\n // Drawing may be a direct w:drawing child OR wrapped in\n // mc:AlternateContent > mc:Choice (DrawingML shapes wpg/wps use this\n // wrapper; the Fallback holds the VML equivalent). Resolve either and,\n // when an AlternateContent wrapper is present, carry the Fallback as\n // raw XML so the full mc:AlternateContent round-trips verbatim.\n let drawingEl = findChild(child, \"w:drawing\");\n let altFallback: string | undefined;\n let altFallbackMedia: BackgroundRawMediaOptions[] | undefined;\n let altRequires: string | undefined;\n if (!drawingEl) {\n const alt = findChild(child, \"mc:AlternateContent\");\n if (alt) {\n const choice = findChild(alt, \"mc:Choice\");\n if (choice) {\n drawingEl = findChild(choice, \"w:drawing\");\n altRequires = attr(choice, \"Requires\");\n }\n const fallback = findChild(alt, \"mc:Fallback\");\n if (fallback) {\n // Replace the VML fallback's r:id/r:embed/r:link refs with {fileName}\n // placeholders and collect the media; otherwise the carried source\n // rIds dangle (not defined in the generated rels).\n const replaced = replaceRelsWithPlaceholders(stringifyElement(fallback), ctx, \"vml\");\n altFallback = replaced.rawXml;\n altFallbackMedia = replaced.rawMedia.length > 0 ? replaced.rawMedia : undefined;\n }\n }\n }\n if (drawingEl) {\n const drawingChild = parseDrawingRun(drawingEl, ctx);\n if (drawingChild) {\n // Parse the wrapping run's rPr into structured fields so round-trip\n // stays editable (drawings/shapes can be wrapped in <w:r><w:rPr>…</w:rPr>…).\n const rPrEl = findChild(child, \"w:rPr\");\n const runProperties = rPrEl ? parseRunProperties(rPrEl) : undefined;\n // Attach the VML fallback + Choice Requires so stringify can rebuild\n // the mc:AlternateContent wrapper (Choice structured + Fallback raw).\n if (altFallback) {\n if (\"wpsShape\" in drawingChild) {\n drawingChild.wpsShape.vmlFallback = altFallback;\n drawingChild.wpsShape.vmlFallbackMedia = altFallbackMedia;\n if (altRequires) drawingChild.wpsShape.mcChoiceRequires = altRequires;\n } else if (\"wpgGroup\" in drawingChild) {\n drawingChild.wpgGroup.vmlFallback = altFallback;\n drawingChild.wpgGroup.vmlFallbackMedia = altFallbackMedia;\n if (altRequires) drawingChild.wpgGroup.mcChoiceRequires = altRequires;\n }\n }\n if (runProperties) {\n if (\"image\" in drawingChild) {\n drawingChild.image.runProperties = runProperties;\n } else if (\"wpsShape\" in drawingChild) {\n drawingChild.wpsShape.runProperties = runProperties;\n } else if (\"wpgGroup\" in drawingChild) {\n drawingChild.wpgGroup.runProperties = runProperties;\n }\n }\n childList.push(drawingChild);\n break;\n }\n }\n const parsed = parseRun(child, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) childList.push(runOpts);\n break;\n }\n case \"w:hyperlink\": {\n const hl: Partial<HyperlinkInlineOptions> = {};\n const rId = attr(child, \"r:id\");\n if (rId) {\n const target = ctx.docx.partRefs.hyperlinks.get(rId);\n if (target) hl.link = target;\n }\n const anchor = attr(child, \"w:anchor\");\n if (anchor) hl.anchor = anchor;\n const tooltip = attr(child, \"w:tooltip\");\n if (tooltip) hl.tooltip = tooltip;\n const tgtFrame = attr(child, \"w:tgtFrame\");\n if (tgtFrame) hl.tgtFrame = tgtFrame;\n const docLocation = attr(child, \"w:docLocation\");\n if (docLocation) hl.docLocation = docLocation;\n const history = attrBool(child, \"w:history\");\n if (history !== undefined) hl.history = history;\n\n const linkRuns: (RunOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n // parsedRunToOptions returns null for auto-generated/empty runs\n // (e.g. footnoteRef, pure drawing) and { commentReference } for\n // pure comment-reference runs; hyperlink children are\n // (RunOptions | string), so skip both.\n if (runOpts !== null && !(\"commentReference\" in runOpts)) {\n linkRuns.push(runOpts);\n }\n }\n }\n if (linkRuns.length > 0) {\n hl.children = linkRuns;\n childList.push({ hyperlink: hl });\n }\n break;\n }\n case \"w:bookmarkStart\": {\n const id = attrNum(child, \"w:id\");\n const name = attr(child, \"w:name\");\n if (id !== undefined && name) {\n const bookmarkStart: Partial<BookmarkStartOptions> = { id, name };\n const disp = attr(child, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") bookmarkStart.displacedByCustomXml = disp;\n const colFirst = attrNum(child, \"w:colFirst\");\n if (colFirst !== undefined) bookmarkStart.colFirst = colFirst;\n const colLast = attrNum(child, \"w:colLast\");\n if (colLast !== undefined) bookmarkStart.colLast = colLast;\n childList.push({ bookmarkStart: bookmarkStart as BookmarkStartOptions });\n }\n break;\n }\n case \"w:bookmarkEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const bookmarkEnd: Partial<MarkupRangeOptions> = { id };\n const disp = attr(child, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") bookmarkEnd.displacedByCustomXml = disp;\n childList.push({ bookmarkEnd: bookmarkEnd as MarkupRangeOptions });\n }\n break;\n }\n case \"w:commentRangeStart\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ commentRangeStart: m });\n break;\n }\n case \"w:commentRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ commentRangeEnd: m });\n break;\n }\n case \"w:commentReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentReference: id });\n break;\n }\n case \"m:oMath\": {\n const mathChildren = parseMathChildren(child);\n childList.push({ math: { children: mathChildren } });\n break;\n }\n case \"w:ins\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n insertion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:del\": {\n // Deleted page-number fields emit w:delInstrText (not w:instrText);\n // reverse inline.ts's field map so they round-trip as placeholder children.\n const children: (RunOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name !== \"w:r\") continue;\n const delInstrEl = findChild(sub, \"w:delInstrText\");\n if (delInstrEl) {\n const placeholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? \"\").trim()];\n if (placeholder) {\n children.push(placeholder);\n continue;\n }\n }\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n children.push(runOpts as RunOptions);\n }\n }\n if (children.length > 0) {\n childList.push({\n deletion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:moveFrom\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n movedFrom: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:moveTo\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n movedTo: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:fldSimple\": {\n const instruction = attr(child, \"w:instr\");\n if (instruction) {\n const sf: {\n instruction: string;\n cachedValue?: string;\n fldLock?: boolean;\n dirty?: boolean;\n } = { instruction };\n // cachedValue: concatenate the result-run <w:t> text (one or more\n // <w:r> children between the fldSimple tags).\n let cachedValue = \"\";\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") cachedValue += collectRunText(sub);\n }\n if (cachedValue) sf.cachedValue = cachedValue;\n const sfLock = attrBool(child, \"w:fldLock\");\n if (sfLock !== undefined) sf.fldLock = sfLock;\n const sfDirty = attrBool(child, \"w:dirty\");\n if (sfDirty !== undefined) sf.dirty = sfDirty;\n childList.push({ simpleField: sf });\n }\n break;\n }\n case \"w:smartTag\": {\n const st = parseSmartTagInline(child, ctx);\n if (st) childList.push({ smartTag: st });\n break;\n }\n case \"w:customXml\": {\n const cx = parseCustomXmlInline(child, ctx);\n if (cx) childList.push({ customXml: cx });\n break;\n }\n // ── Bidirectional containers (reuse the smartTag/customXml child parser) ──\n case \"w:dir\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const dir: DirInlineOptions = { val: val as \"ltr\" | \"rtl\" };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) dir.children = content;\n childList.push({ dir });\n }\n break;\n }\n case \"w:bdo\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const bdo: DirInlineOptions = { val: val as \"ltr\" | \"rtl\" };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) bdo.children = content;\n childList.push({ bdo });\n }\n break;\n }\n // ── Ruby annotation (East Asian pronunciation guides) ──\n case \"w:ruby\": {\n const rt = findChild(child, \"w:rt\");\n const rubyBase = findChild(child, \"w:rubyBase\");\n // text and base are required by CT_Ruby; skip the ruby if either is missing.\n if (!rt || !rubyBase) break;\n const ruby: RubyOptions = {\n text: collectRunsText(rt),\n base: collectRunsText(rubyBase),\n };\n const pr = findChild(child, \"w:rubyPr\");\n if (pr) {\n const alignEl = findChild(pr, \"w:rubyAlign\");\n if (alignEl) {\n const v = attr(alignEl, \"w:val\");\n if (v) ruby.alignment = v as RubyOptions[\"alignment\"];\n }\n // hps / hpsRaise / hpsBaseText are half-points; the API uses points.\n const hpsEl = findChild(pr, \"w:hps\");\n if (hpsEl) {\n const v = attrNum(hpsEl, \"w:val\");\n if (v !== undefined) ruby.fontSize = v / 2;\n }\n const hpsRaiseEl = findChild(pr, \"w:hpsRaise\");\n if (hpsRaiseEl) {\n const v = attrNum(hpsRaiseEl, \"w:val\");\n if (v !== undefined) ruby.raise = v / 2;\n }\n const hpsBaseEl = findChild(pr, \"w:hpsBaseText\");\n if (hpsBaseEl) {\n const v = attrNum(hpsBaseEl, \"w:val\");\n if (v !== undefined) ruby.baseFontSize = v / 2;\n }\n const lidEl = findChild(pr, \"w:lid\");\n if (lidEl) {\n const v = attr(lidEl, \"w:val\");\n if (v) ruby.languageId = v;\n }\n if (findChild(pr, \"w:dirty\")) ruby.dirty = true;\n }\n childList.push({ ruby });\n break;\n }\n // ── Range markers: proof errors, positional tabs, permissions, revisions ──\n case \"w:proofErr\": {\n const type = attr(child, \"w:type\");\n if (\n type === \"spellStart\" ||\n type === \"spellEnd\" ||\n type === \"gramStart\" ||\n type === \"gramEnd\"\n ) {\n childList.push({ proofErr: type });\n }\n break;\n }\n case \"w:ptab\": {\n const alignment = attr(child, \"w:alignment\");\n const leader = attr(child, \"w:leader\");\n const relativeTo = attr(child, \"w:relativeTo\");\n if (alignment !== undefined && leader !== undefined && relativeTo !== undefined) {\n childList.push({ positionalTab: { alignment, leader, relativeTo } });\n }\n break;\n }\n case \"w:permStart\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) {\n const ps: PermStartInlineOptions = { id };\n const ed = attr(child, \"w:ed\");\n if (ed !== undefined) ps.ed = ed;\n const editGroup = attr(child, \"w:edGrp\");\n if (editGroup !== undefined) ps.editGroup = editGroup;\n const colFirst = attrNum(child, \"w:colFirst\");\n if (colFirst !== undefined) ps.colFirst = colFirst;\n const colLast = attrNum(child, \"w:colLast\");\n if (colLast !== undefined) ps.colLast = colLast;\n childList.push({ permStart: ps });\n }\n break;\n }\n case \"w:permEnd\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) childList.push({ permEnd: id });\n break;\n }\n case \"w:moveFromRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveFromRangeStart: m });\n break;\n }\n case \"w:moveFromRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ moveFromRangeEnd: m });\n break;\n }\n case \"w:moveToRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveToRangeStart: m });\n break;\n }\n case \"w:moveToRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ moveToRangeEnd: m });\n break;\n }\n case \"w:customXmlInsRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlInsRangeStart: m });\n break;\n }\n case \"w:customXmlInsRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlInsRangeEnd: id });\n break;\n }\n case \"w:customXmlDelRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlDelRangeStart: m });\n break;\n }\n case \"w:customXmlDelRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlDelRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveFromRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveFromRangeStart: m });\n break;\n }\n case \"w:customXmlMoveFromRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveFromRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveToRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveToRangeStart: m });\n break;\n }\n case \"w:customXmlMoveToRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveToRangeEnd: id });\n break;\n }\n case \"w:sdt\": {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtChildren = parseRunLevelChildren(sdtContent?.elements, ctx);\n const sdt: SdtRunOptions = { properties };\n if (sdtChildren.length > 0) sdt.children = sdtChildren;\n if (endProperties) sdt.endProperties = endProperties;\n childList.push({ sdt });\n break;\n }\n default:\n break;\n }\n }\n\n return childList;\n}\n\n/** True when a child is a single-field `{ text: string }` run (simple text). */\nfunction isTextOnlyRun(c: unknown): c is { text: string } {\n return typeof c === \"object\" && c !== null && \"text\" in c && Object.keys(c).length === 1;\n}\n\nexport function parseParagraph(el: Element, ctx: DocxReadContext): ParagraphOptions {\n const opts: Partial<ParagraphOptions> = {};\n\n // w:p element attributes: rsid family + w14:paraId/textId (hex string verbatim)\n const paraId = attr(el, \"w14:paraId\");\n if (paraId) opts.paraId = paraId;\n const textId = attr(el, \"w14:textId\");\n if (textId) opts.textId = textId;\n const rsid = attr(el, \"w:rsidR\");\n if (rsid) opts.rsid = rsid;\n const defaultRunRsid = attr(el, \"w:rsidRDefault\");\n if (defaultRunRsid) opts.defaultRunRsid = defaultRunRsid;\n const propertiesRsid = attr(el, \"w:rsidP\");\n if (propertiesRsid) opts.propertiesRsid = propertiesRsid;\n const runPropertiesRsid = attr(el, \"w:rsidRPr\");\n if (runPropertiesRsid) opts.runPropertiesRsid = runPropertiesRsid;\n const deletionRsid = attr(el, \"w:rsidDel\");\n if (deletionRsid) opts.deletionRsid = deletionRsid;\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n Object.assign(opts, parseParagraphProperties(pPr, ctx));\n }\n\n const childList = parseRunLevelChildren(el.elements, ctx);\n\n // Simple text optimization: a run of text-only children collapses into a\n // single opts.text (the canonical ParagraphOptions form) instead of a\n // children array.\n if (childList.length > 0) {\n if (childList.every(isTextOnlyRun)) {\n const combined = childList.map((c) => (isTextOnlyRun(c) ? c.text : \"\")).join(\"\");\n if (combined) {\n opts.text = combined;\n return opts as ParagraphOptions;\n }\n }\n opts.children = childList;\n }\n\n return opts as ParagraphOptions;\n}\n","/**\n * Drawing parser for DOCX documents.\n *\n * Parses w:drawing elements and extracts image, chart, or SmartArt data.\n *\n * @module\n */\nimport {\n blipDesc,\n convertEmuToPixels,\n customGeometryDesc,\n effectListDesc,\n fillDesc,\n outlineDesc,\n parseColorChoice,\n presetGeometryDesc,\n} from \"@office-open/core\";\nimport { scene3DDesc, shape3DDesc } from \"@office-open/core/drawingml\";\nimport { attr, attrBool, attrNum, findChild, findFirst, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ChartOptions } from \"@parts/paragraph/run/chart-run\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\nimport type { WpgGroupRunOptions } from \"@parts/paragraph/run/wpg-group-run\";\nimport type { WpsShapeRunOptions } from \"@parts/paragraph/run/wps-shape-run\";\nimport type {\n GroupChildMediaData,\n MediaData,\n MediaDataTransformation,\n WpgCommonMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { DocxReadContext } from \"../../context\";\nimport type { GraphicFrameLocksOptions, GroupShapeLocksOptions } from \"./descriptor\";\nimport type { DocPropertiesOptions } from \"./doc-properties/doc-properties\";\nimport type {\n Floating,\n HorizontalPositionOptions,\n Margins,\n VerticalPositionOptions,\n} from \"./floating\";\nimport type { SourceRectangleOptions } from \"./inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { ChildOffset, ChildExtent } from \"./inline/graphic/graphic-data/wpg/wpg-group\";\nimport { parseBodyProperties } from \"./inline/graphic/graphic-data/wps/body-properties\";\nimport type { NonVisualShapePropertiesOptions } from \"./inline/graphic/graphic-data/wps/non-visual-shape-properties\";\nimport type {\n ShapeStyleOptions,\n StyleMatrixReferenceOptions,\n WpsShapeCoreOptions,\n} from \"./inline/graphic/graphic-data/wps/wps-shape\";\nimport { TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping } from \"./text-wrap\";\n\n/** Union type for parsed drawing child wrappers. */\nexport type DrawingChild =\n | { image: ImageOptions }\n | { chart: ChartOptions }\n | { smartArt: SmartArtOptions }\n | { wpsShape: WpsShapeRunOptions }\n | { wpgGroup: WpgGroupRunOptions };\n\n/**\n * Parse a w:drawing element and dispatch to the correct parser\n * based on the graphicData URI.\n */\nexport function parseDrawingRun(el: Element, ctx: DocxReadContext): DrawingChild | undefined {\n const graphicData = findFirst(el, \"a:graphicData\");\n if (!graphicData) return undefined;\n\n const uri = attr(graphicData, \"uri\") ?? \"\";\n\n if (uri.includes(\"/chart\")) {\n return parseChartDrawing(el, ctx);\n }\n if (uri.includes(\"/diagram\")) {\n return parseSmartArtDrawing(el, ctx);\n }\n if (uri.includes(\"wordprocessingGroup\")) {\n return parseWpgGroupDrawing(el, ctx);\n }\n if (uri.includes(\"wordprocessingShape\")) {\n return parseWpsShapeDrawing(el, ctx);\n }\n return parseImageRun(el, ctx);\n}\n\n/**\n * Determine image type from file extension or MIME type.\n */\nexport function imageTypeFromPath(\n path: string,\n): \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\" {\n const ext = path.split(\".\").pop()?.toLowerCase() ?? \"\";\n switch (ext) {\n case \"jpg\":\n case \"jpeg\":\n return \"jpg\";\n case \"png\":\n return \"png\";\n case \"gif\":\n return \"gif\";\n case \"bmp\":\n return \"bmp\";\n case \"tif\":\n case \"tiff\":\n return \"tif\";\n case \"ico\":\n return \"ico\";\n case \"emf\":\n return \"emf\";\n case \"wmf\":\n return \"wmf\";\n default:\n return \"png\"; // fallback\n }\n}\n\n/**\n * Extent (EMU→pixels), alt text, and floating properties extracted from a\n * w:drawing's wp:inline or wp:anchor wrapper. Shared by image, wps shape,\n * and wpg group parsing.\n */\ninterface AnchorInfo {\n width?: number;\n height?: number;\n floating?: Floating;\n altText?: DocPropertiesOptions;\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n /** wp:effectExtent in raw EMUs — round-tripped verbatim. */\n effectExtent?: { l: number; t: number; r: number; b: number };\n}\n\n/** Read wp:cNvGraphicFramePr locking flags. An empty element (no graphicFrameLocks\n * child) returns `{}` so it round-trips as `<wp:cNvGraphicFramePr/>`. */\nfunction readGraphicFrameLocks(el: Element): GraphicFrameLocksOptions {\n const locks = findChild(el, \"a:graphicFrameLocks\");\n const result: GraphicFrameLocksOptions = {};\n if (!locks) return result;\n const a = locks.attributes ?? {};\n if (a[\"noGrp\"] !== undefined) result.noGrp = a[\"noGrp\"] !== \"0\";\n if (a[\"noDrilldown\"] !== undefined) result.noDrilldown = a[\"noDrilldown\"] !== \"0\";\n if (a[\"noSelect\"] !== undefined) result.noSelect = a[\"noSelect\"] !== \"0\";\n if (a[\"noChangeAspect\"] !== undefined) result.noChangeAspect = a[\"noChangeAspect\"] !== \"0\";\n if (a[\"noMove\"] !== undefined) result.noMove = a[\"noMove\"] !== \"0\";\n if (a[\"noResize\"] !== undefined) result.noResize = a[\"noResize\"] !== \"0\";\n return result as GraphicFrameLocksOptions;\n}\n\n/**\n * Read wpg:cNvGrpSpPr/a:grpSpLocks (CT_GroupLocking) into GroupShapeLocksOptions.\n * Returns `undefined` when the group has no locks (Word's default → empty cNvGrpSpPr).\n */\nfunction readGrpSpLocks(cNvGrpSpPr: Element | undefined): GroupShapeLocksOptions | undefined {\n if (!cNvGrpSpPr) return undefined;\n const locks = findChild(cNvGrpSpPr, \"a:grpSpLocks\");\n if (!locks) return undefined;\n const result: GroupShapeLocksOptions = {};\n const a = locks.attributes ?? {};\n if (a[\"noGrp\"] !== undefined) result.noGrp = a[\"noGrp\"] !== \"0\";\n if (a[\"noUngrp\"] !== undefined) result.noUngrp = a[\"noUngrp\"] !== \"0\";\n if (a[\"noSelect\"] !== undefined) result.noSelect = a[\"noSelect\"] !== \"0\";\n if (a[\"noRot\"] !== undefined) result.noRot = a[\"noRot\"] !== \"0\";\n if (a[\"noChangeAspect\"] !== undefined) result.noChangeAspect = a[\"noChangeAspect\"] !== \"0\";\n if (a[\"noMove\"] !== undefined) result.noMove = a[\"noMove\"] !== \"0\";\n if (a[\"noResize\"] !== undefined) result.noResize = a[\"noResize\"] !== \"0\";\n return Object.keys(result).length === 0 ? undefined : (result as GroupShapeLocksOptions);\n}\n\n/**\n * Extract {@link AnchorInfo} from the drawing's wp:inline or wp:anchor.\n * Returns `null` when the drawing has neither wrapper.\n */\nfunction parseAnchorOrInline(el: Element): AnchorInfo | null {\n const inline = findFirst(el, \"wp:inline\");\n const anchor = inline ? undefined : findFirst(el, \"wp:anchor\");\n const parent = inline ?? anchor;\n if (!parent) return null;\n\n const info: AnchorInfo = {};\n\n // Extent (EMU)\n const extent = findChild(parent, \"wp:extent\");\n if (extent) {\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n if (cxEmu !== undefined) info.width = cxEmu;\n if (cyEmu !== undefined) info.height = cyEmu;\n }\n\n // Effect extent (raw EMUs — round-tripped verbatim, never converted to pixels)\n const ee = findChild(parent, \"wp:effectExtent\");\n if (ee) {\n info.effectExtent = {\n l: attrNum(ee, \"l\") ?? 0,\n t: attrNum(ee, \"t\") ?? 0,\n r: attrNum(ee, \"r\") ?? 0,\n b: attrNum(ee, \"b\") ?? 0,\n };\n }\n\n // Alt text (wp:docPr) — keep the id too so it round-trips verbatim\n const docPr = findChild(parent, \"wp:docPr\");\n if (docPr) {\n const id = attr(docPr, \"id\");\n const name = attr(docPr, \"name\");\n const descr = attr(docPr, \"descr\");\n const title = attr(docPr, \"title\");\n if (id !== undefined || name || descr || title) {\n const alt: Partial<DocPropertiesOptions> = {};\n if (id !== undefined) alt.id = id;\n if (name) alt.name = name;\n if (descr) alt.description = descr;\n if (title) alt.title = title;\n info.altText = alt as DocPropertiesOptions;\n }\n }\n\n // Graphic frame locks (wp:cNvGraphicFramePr) — preserved verbatim.\n const cNvGraphicFramePr = findChild(parent, \"wp:cNvGraphicFramePr\");\n if (cNvGraphicFramePr) info.graphicFrameLocks = readGraphicFrameLocks(cNvGraphicFramePr);\n\n // Floating (anchor only)\n if (anchor && !inline) {\n const floating: Partial<Floating> = {};\n\n // Margins (distT/distB/distL/distR on wp:anchor)\n const margins: Margins = {};\n const distT = attrNum(anchor, \"distT\");\n if (distT !== undefined) margins.top = distT;\n const distB = attrNum(anchor, \"distB\");\n if (distB !== undefined) margins.bottom = distB;\n const distL = attrNum(anchor, \"distL\");\n if (distL !== undefined) margins.left = distL;\n const distR = attrNum(anchor, \"distR\");\n if (distR !== undefined) margins.right = distR;\n if (Object.keys(margins).length > 0) floating.margins = margins;\n\n // Position H/V (relativeFrom + align/posOffset)\n const posH = findChild(anchor, \"wp:positionH\");\n if (posH) {\n const hp = readPosition(posH);\n if (hp) floating.horizontalPosition = hp as HorizontalPositionOptions;\n }\n const posV = findChild(anchor, \"wp:positionV\");\n if (posV) {\n const vp = readPosition(posV);\n if (vp) floating.verticalPosition = vp as VerticalPositionOptions;\n }\n\n // Wrap (element name → TextWrappingType number) + optional side\n const wrap = readWrap(anchor);\n if (wrap) floating.wrap = wrap;\n\n // Anchor-level flags (stringifyAnchor writes all of these)\n const allowOverlap = attrBool(anchor, \"allowOverlap\");\n if (allowOverlap !== undefined) floating.allowOverlap = allowOverlap;\n const behindDoc = attrBool(anchor, \"behindDoc\");\n if (behindDoc !== undefined) floating.behindDocument = behindDoc;\n const locked = attrBool(anchor, \"locked\");\n if (locked !== undefined) floating.lockAnchor = locked;\n const layoutInCell = attrBool(anchor, \"layoutInCell\");\n if (layoutInCell !== undefined) floating.layoutInCell = layoutInCell;\n const relativeHeight = attrNum(anchor, \"relativeHeight\");\n if (relativeHeight !== undefined) floating.zIndex = relativeHeight;\n\n if (Object.keys(floating).length > 0) info.floating = floating as Floating;\n }\n\n return info;\n}\n\n/**\n * Parse a w:drawing element and return image data wrapped in { image: ... }.\n */\nexport function parseImageRun(\n el: Element,\n ctx: DocxReadContext,\n): { image: ImageOptions } | undefined {\n const info = parseAnchorOrInline(el);\n if (!info) return undefined;\n\n // Get graphic → graphicData → blip\n const blip = findFirst(el, \"a:blip\");\n if (!blip) return undefined;\n\n const rEmbed = attr(blip, \"r:embed\");\n if (!rEmbed) return undefined;\n\n // Resolve the media path against the current part's relationships\n const mediaPath = ctx.resolveRelationship(rEmbed);\n if (!mediaPath) return undefined;\n\n // Read image data from ZIP\n const imageData = ctx.docx.doc.getRaw(mediaPath);\n if (!imageData) return undefined;\n\n const type = imageTypeFromPath(mediaPath);\n\n const imageOpts: Record<string, unknown> = {\n type,\n data: imageData,\n transformation: {\n ...(info.width !== undefined ? { width: info.width } : {}),\n ...(info.height !== undefined ? { height: info.height } : {}),\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (info.altText) imageOpts.altText = info.altText;\n if (info.floating) imageOpts.floating = info.floating;\n if (info.graphicFrameLocks !== undefined) imageOpts.graphicFrameLocks = info.graphicFrameLocks;\n\n // Blip-fill crop (pic:blipFill/a:srcRect)\n const blipFill = findFirst(el, \"pic:blipFill\");\n if (blipFill) {\n const srcRect = readSourceRectangle(blipFill);\n if (srcRect) imageOpts.sourceRectangle = srcRect;\n }\n\n // Picture non-visual properties (pic:nvPicPr/pic:cNvPr)\n const cNvPr = readPicCnvPr(el);\n if (cNvPr) imageOpts.nonVisualProperties = cNvPr;\n\n // Picture shape properties (pic:spPr): outline + fill + effects round-trip\n // via the shared core descriptors (bidirectional).\n const picSpPr = findFirst(el, \"pic:spPr\");\n if (picSpPr) {\n const fill = readShapeFill(picSpPr, ctx);\n if (fill) imageOpts.fill = fill;\n const ln = findChild(picSpPr, \"a:ln\");\n if (ln) imageOpts.outline = outlineDesc.parse(ln, ctx);\n const effectLst = findChild(picSpPr, \"a:effectLst\");\n if (effectLst) imageOpts.effects = effectListDesc.parse(effectLst, ctx);\n }\n\n // Blip recolor effects (a:lum/a:hsl/a:tint/...) under a:blip — image\n // brightness/contrast/tint adjustments applied directly to the image data.\n const blipResult = blipDesc.parse(blip, ctx);\n if (blipResult.blipEffects) imageOpts.blipEffects = blipResult.blipEffects;\n\n // Blip extension: a14:useLocalDpi (rendering hint, round-trip verbatim).\n const useLocalDpi = readBlipUseLocalDpi(blip);\n if (useLocalDpi !== undefined) imageOpts.useLocalDpi = useLocalDpi;\n\n return { image: imageOpts as unknown as ImageOptions };\n}\n\n/**\n * Read the `a14:useLocalDpi` blip extension (val=\"0\" → false, \"1\" → true).\n * Returns undefined when the blip has no useLocalDpi extension.\n */\nfunction readBlipUseLocalDpi(blip: Element): boolean | undefined {\n const extLst = findChild(blip, \"a:extLst\");\n if (!extLst) return undefined;\n for (const ext of extLst.elements ?? []) {\n if (ext.type !== \"element\" || ext.name !== \"a:ext\") continue;\n const useLocalDpiEl = findChild(ext, \"a14:useLocalDpi\");\n if (useLocalDpiEl) {\n const val = useLocalDpiEl.attributes?.[\"val\"];\n return val !== \"0\";\n }\n }\n return undefined;\n}\n\n// ── WPS shape / WPG group parsing ───────────────────────────────────────────\n\n/**\n * Read the blip-fill crop rectangle (`a:srcRect`, l/t/r/b percentage insets)\n * from a `pic:blipFill` parent. Returns undefined when there is no crop.\n */\nfunction readSourceRectangle(parent: Element): SourceRectangleOptions | undefined {\n const sr = findChild(parent, \"a:srcRect\");\n if (!sr) return undefined;\n const result: SourceRectangleOptions = {};\n const left = attrNum(sr, \"l\");\n const top = attrNum(sr, \"t\");\n const right = attrNum(sr, \"r\");\n const bottom = attrNum(sr, \"b\");\n if (left !== undefined) result.left = left;\n if (top !== undefined) result.top = top;\n if (right !== undefined) result.right = right;\n if (bottom !== undefined) result.bottom = bottom;\n // An empty <a:srcRect/> is meaningful (explicit no-crop reset), so return\n // the object even when no l/t/r/b attributes are present.\n return result as SourceRectangleOptions;\n}\n\n/**\n * Read pic:cNvPr (id/name/descr) from a drawing's pic:nvPicPr. Returns\n * undefined when there is no non-visual properties block.\n */\nfunction readPicCnvPr(el: Element): NonVisualPropertiesOptions | undefined {\n const nvPicPr = findFirst(el, \"pic:nvPicPr\");\n if (!nvPicPr) return undefined;\n const result: NonVisualPropertiesOptions = {};\n const cNvPr = findChild(nvPicPr, \"pic:cNvPr\");\n if (cNvPr) {\n const id = attrNum(cNvPr, \"id\");\n const name = attr(cNvPr, \"name\");\n const descr = attr(cNvPr, \"descr\");\n if (id !== undefined) result.id = id;\n if (name) result.name = name;\n if (descr) result.description = descr;\n }\n // pic:cNvPicPr sibling — only preferRelativeResize is tracked (Word omits\n // the default true; an explicit false round-trips as \"0\").\n const cNvPicPr = findChild(nvPicPr, \"pic:cNvPicPr\");\n if (cNvPicPr) {\n const preferRelativeResize = attrBool(cNvPicPr, \"preferRelativeResize\");\n if (preferRelativeResize !== undefined) result.preferRelativeResize = preferRelativeResize;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/**\n * Read a fill element from a shape-properties parent, if present. Delegates to\n * core {@link fillDesc} so solid/gradient/pattern/group/no fills all round-trip\n * through the shared descriptor.\n */\nfunction readShapeFill(parent: Element, ctx: DocxReadContext) {\n const fillChild =\n findChild(parent, \"a:noFill\") ??\n findChild(parent, \"a:solidFill\") ??\n findChild(parent, \"a:gradFill\") ??\n findChild(parent, \"a:pattFill\") ??\n findChild(parent, \"a:grpFill\") ??\n findChild(parent, \"a:blipFill\");\n if (!fillChild) return undefined;\n return fillDesc.parse(parent, ctx);\n}\n\n/**\n * Read a single style-matrix reference (a:lnRef/a:fillRef/a:effectRef/a:fontRef):\n * the `idx` attribute plus an optional EG_ColorChoice color override.\n */\nfunction parseStyleRef(el: Element, ctx: DocxReadContext): StyleMatrixReferenceOptions | undefined {\n const idx = attr(el, \"idx\");\n if (idx === undefined) return undefined;\n const result: StyleMatrixReferenceOptions = { idx };\n const color = parseColorChoice(el, ctx);\n if (color && Object.keys(color).length > 0) result.color = color;\n return result as StyleMatrixReferenceOptions;\n}\n\n/**\n * Parse a wps:style (CT_ShapeStyle): line/fill/effect/font references into the\n * document theme. Delegates color to the shared core {@link parseColorChoice}.\n */\nfunction parseShapeStyle(styleEl: Element, ctx: DocxReadContext): ShapeStyleOptions {\n const result: ShapeStyleOptions = {};\n const lnRef = findChild(styleEl, \"a:lnRef\");\n if (lnRef) result.lineReference = parseStyleRef(lnRef, ctx);\n const fillRef = findChild(styleEl, \"a:fillRef\");\n if (fillRef) result.fillReference = parseStyleRef(fillRef, ctx);\n const effectRef = findChild(styleEl, \"a:effectRef\");\n if (effectRef) result.effectReference = parseStyleRef(effectRef, ctx);\n const fontRef = findChild(styleEl, \"a:fontRef\");\n if (fontRef) result.fontReference = parseStyleRef(fontRef, ctx);\n return result as ShapeStyleOptions;\n}\n\n/**\n * Parse the shared core of a `wps:wsp` element (everything except the outer\n * drawing transformation/floating): text content, body properties, fill, and\n * the txBox non-visual flag. Used both for standalone wps shapes and for wps\n * children nested inside a wpg group.\n */\nfunction parseWpsShapeCore(wspEl: Element, ctx: DocxReadContext): WpsShapeCoreOptions {\n const result: Partial<WpsShapeCoreOptions> = {};\n\n // Text content — w:txbxContent (w namespace, per CT_TxbxContent → w:EG_BlockLevelElts)\n // holds the shape's paragraphs, even when wrapped in wps:txbx.\n const txbxContent = findFirst(wspEl, \"w:txbxContent\");\n const children: WpsShapeCoreOptions[\"children\"] = [];\n if (txbxContent) {\n for (const child of txbxContent.elements ?? []) {\n if (child.name === \"w:p\") children.push(parseParagraph(child, ctx));\n }\n }\n result.children = children;\n\n // Non-visual shape properties: wps:cNvPr (id/name/descr) + a choice of\n // wps:cNvSpPr (txBox marker) or wps:cNvCnPr (connector) — mutually exclusive.\n const cNvPr = findChild(wspEl, \"wps:cNvPr\");\n const cNvSpPr = findChild(wspEl, \"wps:cNvSpPr\");\n const cNvCnPr = findChild(wspEl, \"wps:cNvCnPr\");\n const txBox = cNvSpPr ? attr(cNvSpPr, \"txBox\") : undefined;\n if (cNvPr || txBox !== undefined || cNvCnPr) {\n const nvp: NonVisualShapePropertiesOptions = {};\n if (cNvPr) {\n const id = attrNum(cNvPr, \"id\");\n const name = attr(cNvPr, \"name\");\n const descr = attr(cNvPr, \"descr\");\n const title = attr(cNvPr, \"title\");\n if (id !== undefined) nvp.id = id;\n if (name) nvp.name = name;\n if (descr) nvp.description = descr;\n if (title) nvp.title = title;\n }\n if (cNvCnPr) nvp.connector = true;\n else if (txBox !== undefined) nvp.textBox = txBox;\n result.nonVisualProperties = nvp as NonVisualShapePropertiesOptions;\n }\n\n // Shape properties (wps:spPr) — fill/outline/effects/geometry round-trip via\n // the shared core descriptors (bidirectional) so spPr stays structured.\n const spPr = findChild(wspEl, \"wps:spPr\");\n if (spPr) {\n const fill = readShapeFill(spPr, ctx);\n if (fill) result.fill = fill;\n const ln = findChild(spPr, \"a:ln\");\n if (ln) result.outline = outlineDesc.parse(ln, ctx);\n const effectLst = findChild(spPr, \"a:effectLst\");\n if (effectLst) result.effects = effectListDesc.parse(effectLst, ctx);\n const custGeom = findChild(spPr, \"a:custGeom\");\n if (custGeom) result.customGeometry = customGeometryDesc.parse(custGeom, ctx);\n const prstGeom = findChild(spPr, \"a:prstGeom\");\n if (prstGeom) result.presetGeometry = presetGeometryDesc.parse(prstGeom, ctx);\n const scene3d = findChild(spPr, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n const sp3d = findChild(spPr, \"a:sp3d\");\n if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, ctx);\n }\n\n // Body properties (wps:bodyPr)\n const bodyPr = findChild(wspEl, \"wps:bodyPr\");\n if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr, ctx);\n\n // Shape style (wps:style) — theme references (lnRef/fillRef/effectRef/fontRef)\n const styleEl = findChild(wspEl, \"wps:style\");\n if (styleEl) result.style = parseShapeStyle(styleEl, ctx);\n\n return result as WpsShapeCoreOptions;\n}\n\n/**\n * Build a child's MediaDataTransformation directly from an `a:xfrm`, keeping\n * EMU values intact (no pixel rounding) so group child coordinates survive\n * round-trip without drift.\n */\nfunction readChildTransformation(spPr: Element | undefined): MediaDataTransformation {\n const result: MediaDataTransformation = {\n pixels: { x: 0, y: 0 },\n emus: { x: 0, y: 0 },\n };\n if (!spPr) return result;\n const xfrm = findChild(spPr, \"a:xfrm\");\n if (!xfrm) return result;\n\n const off = findChild(xfrm, \"a:off\");\n if (off?.attributes) {\n const x = Number(off.attributes[\"x\"] ?? 0);\n const y = Number(off.attributes[\"y\"] ?? 0);\n result.offset = {\n emus: { x, y },\n pixels: { x: convertEmuToPixels(x), y: convertEmuToPixels(y) },\n };\n }\n const ext = findChild(xfrm, \"a:ext\");\n if (ext?.attributes) {\n const cx = Number(ext.attributes[\"cx\"] ?? 0);\n const cy = Number(ext.attributes[\"cy\"] ?? 0);\n result.emus = { x: cx, y: cy };\n result.pixels = { x: convertEmuToPixels(cx), y: convertEmuToPixels(cy) };\n }\n\n const flipH = attrBool(xfrm, \"flipH\");\n const flipV = attrBool(xfrm, \"flipV\");\n if (flipH !== undefined || flipV !== undefined) {\n const flip: { horizontal?: boolean; vertical?: boolean } = {};\n if (flipH !== undefined) flip.horizontal = flipH;\n if (flipV !== undefined) flip.vertical = flipV;\n result.flip = flip;\n }\n const rot = attrNum(xfrm, \"rot\");\n if (rot !== undefined) result.rotation = rot;\n\n return result;\n}\n\n/**\n * Parse a `wps:wsp` nested inside a wpg group into a {@link WpsMediaData} child\n * (its transformation kept as EMU via {@link readChildTransformation}).\n */\nfunction parseWpsChildMediaData(wspEl: Element, ctx: DocxReadContext): WpsMediaData | undefined {\n const data = parseWpsShapeCore(wspEl, ctx);\n const spPr = findChild(wspEl, \"wps:spPr\");\n return {\n type: \"wps\",\n transformation: readChildTransformation(spPr),\n data,\n };\n}\n\n/**\n * Parse a `pic:pic` nested inside a wpg group into a {@link MediaData} child.\n * Uses the original media path as the registration key so repeated references\n * to the same image collapse to one media entry.\n */\nfunction parsePicChildMediaData(picEl: Element, ctx: DocxReadContext): MediaData | undefined {\n const blip = findFirst(picEl, \"a:blip\");\n if (!blip) return undefined;\n const rEmbed = attr(blip, \"r:embed\");\n if (!rEmbed) return undefined;\n\n const mediaPath = ctx.resolveRelationship(rEmbed);\n if (!mediaPath) return undefined;\n const data = ctx.docx.doc.getRaw(mediaPath);\n if (!data) return undefined;\n\n const spPr = findChild(picEl, \"pic:spPr\");\n const result: MediaData = {\n type: imageTypeFromPath(mediaPath),\n // fileName is the bare basename; the compiler writes it under word/media/.\n fileName: mediaPath.split(\"/\").pop() ?? mediaPath,\n data,\n transformation: readChildTransformation(spPr),\n };\n const blipFill = findChild(picEl, \"pic:blipFill\");\n if (blipFill) {\n const srcRect = readSourceRectangle(blipFill);\n if (srcRect) result.sourceRectangle = srcRect;\n }\n const cNvPr = readPicCnvPr(picEl);\n if (cNvPr) result.nonVisualProperties = cNvPr;\n // Grouped picture spPr (fill/outline) rides on WpgCommonMediaData so it\n // round-trips through stringifyGroupChild → stringifyShapeProps.\n if (spPr) {\n const fill = readShapeFill(spPr, ctx);\n if (fill) (result as MediaData & WpgCommonMediaData).fill = fill;\n const ln = findChild(spPr, \"a:ln\");\n if (ln) (result as MediaData & WpgCommonMediaData).outline = outlineDesc.parse(ln, ctx);\n }\n return result;\n}\n\n/**\n * Parse a standalone wps shape drawing (graphicData URI wordprocessingShape).\n */\nfunction parseWpsShapeDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { wpsShape: WpsShapeRunOptions } | undefined {\n const wsp = findFirst(el, \"wps:wsp\");\n if (!wsp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const data = parseWpsShapeCore(wsp, ctx);\n\n const shape: WpsShapeRunOptions = {\n ...data,\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (info.floating) shape.floating = info.floating;\n if (info.altText) shape.altText = info.altText;\n if (info.graphicFrameLocks !== undefined) shape.graphicFrameLocks = info.graphicFrameLocks;\n\n return { wpsShape: shape as WpsShapeRunOptions };\n}\n\n/**\n * Parse a wpg group drawing (graphicData URI wordprocessingGroup).\n */\nfunction parseWpgGroupDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { wpgGroup: WpgGroupRunOptions } | undefined {\n const wgp = findFirst(el, \"wpg:wgp\");\n if (!wgp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const grpSpPr = findChild(wgp, \"wpg:grpSpPr\");\n const { childOffset, childExtent } = readGroupCoords(grpSpPr);\n\n const group: WpgGroupRunOptions = {\n children: parseGroupChildren(wgp, ctx),\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (childOffset) group.childOffset = childOffset;\n if (childExtent) group.childExtent = childExtent;\n if (info.floating) group.floating = info.floating;\n if (info.altText) group.altText = info.altText;\n if (info.graphicFrameLocks !== undefined) group.graphicFrameLocks = info.graphicFrameLocks;\n const grpSpLocks = readGrpSpLocks(findChild(wgp, \"wpg:cNvGrpSpPr\"));\n if (grpSpLocks) group.groupShapeLocks = grpSpLocks;\n // Group shape props (grpSpPr): fill + effects round-trip via shared descriptors.\n if (grpSpPr) {\n const fill = readShapeFill(grpSpPr, ctx);\n if (fill) group.fill = fill;\n const effectLst = findChild(grpSpPr, \"a:effectLst\");\n if (effectLst) group.effects = effectListDesc.parse(effectLst, ctx);\n }\n\n return { wpgGroup: group as WpgGroupRunOptions };\n}\n\n/**\n * Read chOff/chExt child coordinate space from a group's grpSpPr/a:xfrm.\n * Shared by the top-level wpg:wgp and nested wpg:grpSp.\n */\nfunction readGroupCoords(grpSpPr: Element | undefined): {\n childOffset?: ChildOffset;\n childExtent?: ChildExtent;\n} {\n if (!grpSpPr) return {};\n const xfrm = findChild(grpSpPr, \"a:xfrm\");\n if (!xfrm) return {};\n let childOffset: ChildOffset | undefined;\n let childExtent: ChildExtent | undefined;\n const off = findChild(xfrm, \"a:chOff\");\n if (off?.attributes) {\n childOffset = { x: Number(off.attributes[\"x\"] ?? 0), y: Number(off.attributes[\"y\"] ?? 0) };\n }\n const ext = findChild(xfrm, \"a:chExt\");\n if (ext?.attributes) {\n childExtent = { cx: Number(ext.attributes[\"cx\"] ?? 0), cy: Number(ext.attributes[\"cy\"] ?? 0) };\n }\n return { childOffset, childExtent };\n}\n\n/**\n * Parse the children of a group element (CT_WordprocessingGroup choice):\n * wps:wsp shapes, pic:pic pictures, and nested wpg:grpSp groups (recursive).\n */\nfunction parseGroupChildren(groupEl: Element, ctx: DocxReadContext): GroupChildMediaData[] {\n const children: GroupChildMediaData[] = [];\n for (const child of groupEl.elements ?? []) {\n if (child.type !== \"element\") continue;\n const md = parseGroupChild(child, ctx);\n if (md) children.push(md);\n }\n return children;\n}\n\nfunction parseGroupChild(el: Element, ctx: DocxReadContext): GroupChildMediaData | undefined {\n if (el.name === \"wps:wsp\") return parseWpsChildMediaData(el, ctx);\n if (el.name === \"pic:pic\") {\n return parsePicChildMediaData(el, ctx) as GroupChildMediaData | undefined;\n }\n if (el.name === \"wpg:grpSp\") return parseNestedGroup(el, ctx);\n return undefined;\n}\n\n/**\n * Parse a nested wpg:grpSp (CT_WordprocessingGroup) into a WpgMediaData child.\n * Mirrors the top-level group: grpSpPr transform + chOff/chExt + fill, with its\n * own children (which may nest further groups).\n */\nfunction parseNestedGroup(grpSpEl: Element, ctx: DocxReadContext): WpgMediaData {\n const grpSpPr = findChild(grpSpEl, \"wpg:grpSpPr\");\n const { childOffset, childExtent } = readGroupCoords(grpSpPr);\n const result: WpgMediaData = {\n type: \"wpg\",\n transformation: readChildTransformation(grpSpPr),\n children: parseGroupChildren(grpSpEl, ctx),\n };\n if (childOffset) result.childOffset = childOffset;\n if (childExtent) result.childExtent = childExtent;\n const grpSpLocks = readGrpSpLocks(findChild(grpSpEl, \"wpg:cNvGrpSpPr\"));\n if (grpSpLocks) result.groupShapeLocks = grpSpLocks;\n if (grpSpPr) {\n const fill = readShapeFill(grpSpPr, ctx);\n if (fill) result.fill = fill;\n }\n return result;\n}\n\n// ── Floating (anchor) parse helpers ─────────────────────────────────────────\n\n/** Map wp:positionH/V children + relativeFrom into a position-options object. */\nfunction readPosition(\n posEl: Element,\n): HorizontalPositionOptions | VerticalPositionOptions | undefined {\n const relative = attr(posEl, \"relativeFrom\");\n const alignEl = findChild(posEl, \"wp:align\");\n const posOffset = findChild(posEl, \"wp:posOffset\");\n const result: { relative?: string; align?: string; offset?: number } = {};\n if (relative) result.relative = relative;\n if (alignEl) {\n const a = textOf(alignEl);\n if (a) result.align = a;\n } else if (posOffset) {\n const val = Number(textOf(posOffset));\n if (!isNaN(val)) result.offset = val;\n }\n return Object.keys(result).length > 0\n ? (result as HorizontalPositionOptions | VerticalPositionOptions)\n : undefined;\n}\n\n/** Map the wp:anchor wrap child element into a TextWrapping ({ type, side? }). */\nfunction readWrap(anchor: Element): TextWrapping | undefined {\n const WRAP_TYPE: ReadonlyArray<[string, TextWrapping[\"type\"]]> = [\n [\"wrapNone\", TextWrappingType.NONE],\n [\"wrapSquare\", TextWrappingType.SQUARE],\n [\"wrapTight\", TextWrappingType.TIGHT],\n [\"wrapTopAndBottom\", TextWrappingType.TOP_AND_BOTTOM],\n [\"wrapThrough\", TextWrappingType.THROUGH],\n ];\n for (const [name, type] of WRAP_TYPE) {\n const el = findChild(anchor, `wp:${name}`);\n if (!el) continue;\n const wrap: TextWrapping = { type };\n const side = attr(el, \"wrapText\");\n if (side) wrap.side = side as TextWrapping[\"side\"];\n return wrap;\n }\n return undefined;\n}\n\n// ── Common helpers ──────────────────────────────────────────────────────────\n\nfunction getDrawingExtent(el: Element): { width?: number; height?: number } {\n const inline = findFirst(el, \"wp:inline\");\n const anchor = inline ? undefined : findFirst(el, \"wp:anchor\");\n const parent = inline ?? anchor;\n if (!parent) return {};\n\n const extent = findChild(parent, \"wp:extent\");\n if (!extent) return {};\n\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n return {\n ...(cxEmu !== undefined ? { width: cxEmu } : {}),\n ...(cyEmu !== undefined ? { height: cyEmu } : {}),\n };\n}\n\n// ── Chart parsing ───────────────────────────────────────────────────────────\n\n/**\n * Look up a relationship ID in a map, with fallback for double \"rId\" prefix\n * that the library's generation code produces (e.g. \"rIdrId7\" → \"rId7\").\n */\nfunction lookupRId(map: Map<string, string>, rId: string | undefined): string | undefined {\n if (!rId) return undefined;\n const direct = map.get(rId);\n if (direct) return direct;\n // Fallback: strip one \"rId\" prefix when the value starts with \"rIdrId\"\n if (rId.startsWith(\"rIdrId\")) return map.get(rId.slice(3));\n return undefined;\n}\n\nfunction parseChartDrawing(el: Element, ctx: DocxReadContext): { chart: ChartOptions } | undefined {\n const chartRef = findFirst(el, \"c:chart\");\n if (!chartRef) return undefined;\n\n const rId = attr(chartRef, \"r:id\");\n const chartPath = lookupRId(ctx.docx.partRefs.charts, rId);\n if (!chartPath) return undefined;\n\n const chartXml = ctx.docx.doc.get(chartPath);\n if (!chartXml) return undefined;\n\n const opts = parseChartXml(chartXml);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { chart: opts as unknown as ChartOptions };\n}\n\n/**\n * Parse c:chartSpace element into ChartOptions.\n */\nfunction parseChartXml(el: Element): Record<string, unknown> | undefined {\n const chart = findChild(el, \"c:chart\");\n if (!chart) return undefined;\n\n const opts: Record<string, unknown> = {};\n\n // Title: c:chart → c:title → c:tx → c:rich → a:p → a:r → a:t\n const titleEl = findChild(chart, \"c:title\");\n if (titleEl) {\n const rich = findFirst(titleEl, \"c:rich\");\n if (rich) {\n const t = findFirst(rich, \"a:t\");\n if (t) {\n const title = textOf(t);\n if (title) opts.title = title;\n }\n }\n }\n\n // Plot area → chart type\n const plotArea = findChild(chart, \"c:plotArea\");\n if (!plotArea) return undefined;\n\n let chartType: string | undefined;\n let typeElement: Element | undefined;\n\n for (const child of plotArea.elements ?? []) {\n switch (child.name) {\n case \"c:barChart\": {\n const barDir = findChild(child, \"c:barDir\");\n chartType = barDir && attr(barDir, \"val\") === \"bar\" ? \"bar\" : \"column\";\n typeElement = child;\n break;\n }\n case \"c:lineChart\":\n chartType = \"line\";\n typeElement = child;\n break;\n case \"c:pieChart\":\n chartType = \"pie\";\n typeElement = child;\n break;\n case \"c:areaChart\":\n chartType = \"area\";\n typeElement = child;\n break;\n case \"c:scatterChart\":\n chartType = \"scatter\";\n typeElement = child;\n break;\n }\n if (chartType) break;\n }\n\n if (!chartType || !typeElement) return undefined;\n opts.type = chartType;\n\n // Parse series\n const series: { name: string; values: number[] }[] = [];\n let categories: string[] | undefined;\n\n for (const serEl of typeElement.elements ?? []) {\n if (serEl.name !== \"c:ser\") continue;\n\n // Series name: c:tx → c:strCache → c:pt → c:v\n const nameParts = extractStrCache(serEl, \"c:tx\");\n // Categories: c:cat → c:strCache → c:pt → c:v\n const cats = extractStrCache(serEl, \"c:cat\");\n if (cats.length > 0 && !categories) categories = cats;\n // Values: c:val → c:numCache → c:pt → c:v\n const vals = extractNumCache(serEl);\n\n series.push({ name: nameParts[0] ?? \"\", values: vals });\n }\n\n opts.categories = categories ?? [];\n opts.series = series;\n\n // Legend\n opts.showLegend = findChild(chart, \"c:legend\") !== undefined;\n\n // Style\n const styleEl = findChild(el, \"c:style\");\n if (styleEl) {\n const val = attrNum(styleEl, \"val\");\n if (val !== undefined) opts.style = val;\n }\n\n return opts;\n}\n\n/**\n * Extract string values from c:strCache within a container element.\n */\nfunction extractStrCache(parent: Element, containerName: string): string[] {\n const container = findChild(parent, containerName);\n if (!container) return [];\n const cache = findFirst(container, \"c:strCache\");\n if (!cache) return [];\n\n const values: string[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) values.push(textOf(v) ?? \"\");\n }\n return values;\n}\n\n/**\n * Extract numeric values from c:numCache within a c:val container.\n */\nfunction extractNumCache(parent: Element): number[] {\n const valEl = findChild(parent, \"c:val\");\n if (!valEl) return [];\n const cache = findFirst(valEl, \"c:numCache\");\n if (!cache) return [];\n\n const values: number[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) {\n const num = Number(textOf(v));\n if (!isNaN(num)) values.push(num);\n }\n }\n return values;\n}\n\n// ── SmartArt parsing ────────────────────────────────────────────────────────\n\nfunction parseSmartArtDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { smartArt: SmartArtOptions } | undefined {\n const relIds = findFirst(el, \"dgm:relIds\");\n if (!relIds) return undefined;\n\n const rId = attr(relIds, \"r:dm\");\n const dataPath = lookupRId(ctx.docx.partRefs.diagramData, rId);\n if (!dataPath) return undefined;\n\n const dataEl = ctx.docx.doc.get(dataPath);\n if (!dataEl) return undefined;\n\n const opts = parseSmartArtDataXml(dataEl);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { smartArt: opts as unknown as SmartArtOptions };\n}\n\n/**\n * Parse dgm:dataModel element into SmartArtOptions.\n */\nfunction parseSmartArtDataXml(el: Element): Record<string, unknown> | undefined {\n const ptLst = findChild(el, \"dgm:ptLst\");\n if (!ptLst) return undefined;\n\n const opts: Record<string, unknown> = {};\n const nodeMap = new Map<string, string>(); // modelId → text\n\n for (const pt of ptLst.elements ?? []) {\n if (pt.name !== \"dgm:pt\") continue;\n const type = attr(pt, \"type\");\n const modelId = attr(pt, \"modelId\");\n\n if (type === \"doc\") {\n // Extract layout/style/color from prSet URIs\n const prSet = findChild(pt, \"dgm:prSet\");\n if (prSet) {\n const loTypeId = attr(prSet, \"loTypeId\") ?? \"\";\n const qsTypeId = attr(prSet, \"qsTypeId\") ?? \"\";\n const csTypeId = attr(prSet, \"csTypeId\") ?? \"\";\n\n const layout = loTypeId.split(\"/\").pop();\n if (layout) opts.layout = layout;\n const style = qsTypeId.split(\"/\").pop();\n if (style) opts.style = style;\n const color = csTypeId.split(\"/\").pop();\n if (color) opts.color = color;\n }\n } else if (type === \"node\" && modelId) {\n // Extract text: dgm:t → a:p → a:r → a:t\n const t = findFirst(pt, \"a:t\");\n nodeMap.set(modelId, t ? (textOf(t) ?? \"\") : \"\");\n }\n }\n\n // Build tree from connections\n const cxnLst = findChild(el, \"dgm:cxnLst\");\n if (!cxnLst) {\n opts.data = { nodes: [] };\n return opts;\n }\n\n // Map: parentId → childIds\n const childrenMap = new Map<string, string[]>();\n for (const cxn of cxnLst.elements ?? []) {\n if (cxn.name !== \"dgm:cxn\") continue;\n const srcId = attr(cxn, \"srcId\");\n const destId = attr(cxn, \"destId\");\n if (!srcId || !destId || !nodeMap.has(destId)) continue;\n\n let arr = childrenMap.get(srcId);\n if (!arr) {\n arr = [];\n childrenMap.set(srcId, arr);\n }\n arr.push(destId);\n }\n\n // Root children are connected from doc node (modelId=\"0\")\n const topIds = childrenMap.get(\"0\") ?? [];\n opts.data = { nodes: topIds.map((id) => buildSmartArtNode(id, nodeMap, childrenMap)) };\n\n return opts;\n}\n\nfunction buildSmartArtNode(\n id: string,\n nodeMap: Map<string, string>,\n childrenMap: Map<string, string[]>,\n): { text: string; children?: unknown[] } {\n const text = nodeMap.get(id) ?? \"\";\n const childIds = childrenMap.get(id) ?? [];\n\n if (childIds.length === 0) return { text };\n return { text, children: childIds.map((cid) => buildSmartArtNode(cid, nodeMap, childrenMap)) };\n}\n","/**\n * Drawing descriptor for DOCX documents.\n *\n * Produces `<w:drawing>` XML directly from media data and options,\n * eliminating the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain (~10 instances per drawing in the old path).\n *\n * Common path (inline image/chart/smartart without advanced properties):\n * zero XmlComponent instances — pure string concatenation.\n *\n * Advanced properties (outline, fill, effects on images) and floating\n * positioning use core `create*()` + `.toXml({stack:[]})` for sub-elements\n * (lightweight BuilderElement instances, not deep hierarchies).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_Drawing\n *\n * @module\n */\n\nimport { TargetModeType } from \"@office-open/core\";\nimport { convertToEmu, uniqueNumericIdCreator, uniqueId } from \"@office-open/core\";\nimport type { CustomDescriptor, WriteContext } from \"@office-open/core/descriptor\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\nimport {\n calculateEffectExtent,\n createColorElement,\n createEffectDag,\n customGeometryDesc,\n effectListDesc,\n fillDesc,\n outlineDesc,\n presetGeometryDesc,\n scene3DDesc,\n shape3DDesc,\n transform2DDesc,\n} from \"@office-open/core/drawingml\";\nimport { escapeXml } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n ChartMediaData,\n ExtendedMediaData,\n GroupChildMediaData,\n MediaData,\n MediaDataTransformation,\n SmartArtMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport type { DocPropertiesOptions, HyperlinkOptions } from \"./doc-properties/doc-properties\";\n// Import parse function from drawing-parse.ts (parse path)\nimport { parseDrawingRun } from \"./drawing-parse\";\nimport type { Floating, HorizontalPositionOptions, VerticalPositionOptions } from \"./floating\";\nimport type { Margins } from \"./floating\";\nimport { HorizontalPositionRelativeFrom, VerticalPositionRelativeFrom } from \"./floating\";\nimport type { BlipEffectsOptions } from \"./inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"./inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { TileOptions } from \"./inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"./inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"./inline/graphic/graphic-data/pic/outline/outline\";\nimport type { ChildOffset, ChildExtent } from \"./inline/graphic/graphic-data/wpg/wpg-group\";\n// wpg/wps types only\nimport {\n createBodyProperties,\n type BodyPropertiesOptions,\n} from \"./inline/graphic/graphic-data/wps/body-properties\";\nimport type { NonVisualShapePropertiesOptions } from \"./inline/graphic/graphic-data/wps/non-visual-shape-properties\";\nimport type {\n ShapeStyleOptions,\n StyleMatrixReferenceOptions,\n WpsShapeCoreOptions,\n} from \"./inline/graphic/graphic-data/wps/wps-shape\";\nimport { TextWrappingSide, TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping } from \"./text-wrap\";\n\n// Noop context for drawingml descriptors that don't use WriteContext\nconst NOOP_CTX: WriteContext = {\n addRelationship: () => \"\",\n addMedia: () => \"\",\n};\n\n// ── Options ──\n\n/**\n * Options for the drawing descriptor.\n *\n * Combines media data with optional visual properties.\n */\n\n/** Locking flags for wp:cNvGraphicFramePr (CT_GraphicalObjectFrameLocking). */\nexport interface GraphicFrameLocksOptions {\n noGrp?: boolean;\n noDrilldown?: boolean;\n noSelect?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\n/**\n * Group shape locks (CT_GroupLocking) carried inside wpg:cNvGrpSpPr.\n * Distinct from GraphicFrameLocksOptions: groups use noUngrp/noRot instead of noDrilldown.\n */\nexport interface GroupShapeLocksOptions {\n noGrp?: boolean;\n noUngrp?: boolean;\n noSelect?: boolean;\n noRot?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\nexport interface DrawingDescriptorOptions {\n /** Media data (image, chart, smartart, wps, wpg) */\n mediaData: ExtendedMediaData;\n /** Non-visual document properties (name, description, hyperlinks) */\n docProperties?: DocPropertiesOptions;\n /** Floating/anchored positioning (omit for inline) */\n floating?: Floating;\n /** Shape outline */\n outline?: OutlineOptions;\n /** Shape fill */\n fill?: FillOptions;\n /** Shape effects (shadow, glow, etc.) */\n effects?: EffectListOptions;\n /** Image blip effects (brightness, contrast, etc.) */\n blipEffects?: BlipEffectsOptions;\n /** Image tile fill mode */\n tile?: TileOptions;\n /** Graphic frame locks (wp:cNvGraphicFramePr). `{}` → empty element; omit → authoring default. */\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n}\n\n// ── ID generation ──\n\nlet _docPropsIdGen = uniqueNumericIdCreator();\n\n/** Reset the doc properties ID generator (for testing). */\nexport const resetDrawingIdGen = (): void => {\n _docPropsIdGen = uniqueNumericIdCreator();\n};\n\n// ── Constants ──\n\nconst GRAPHIC_NS = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\nconst PIC_URI = \"http://schemas.openxmlformats.org/drawingml/2006/picture\";\nconst CHART_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\nconst DGM_URI = \"http://schemas.openxmlformats.org/drawingml/2006/diagram\";\nconst WPS_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\";\nconst WPG_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\";\nconst HYPERLINK_REL =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\";\n// Blip extension URIs (a:extLst under a:blip).\nconst SVG_BLIP_EXT_URI = \"{96DAC541-7B7A-43D3-8B79-37D633B846F1}\";\nconst USE_LOCAL_DPI_EXT_URI = \"{28A0092B-C50C-407E-A947-70E740481C1C}\";\nconst A14_NS = \"http://schemas.microsoft.com/office/drawing/2010/main\";\n\n/**\n * Build the `a14:useLocalDpi` blip extension. Returns \"\" when the hint is\n * absent (undefined) — Word's default. val=\"0\" (useLocalDpi=false) is the\n * common Word emission; val=\"1\" only when explicitly set.\n */\nfunction buildUseLocalDpiExt(useLocalDpi?: boolean): string {\n if (useLocalDpi === undefined) return \"\";\n return `<a:ext uri=\"${USE_LOCAL_DPI_EXT_URI}\"><a14:useLocalDpi xmlns:a14=\"${A14_NS}\" val=\"${\n useLocalDpi ? \"1\" : \"0\"\n }\"/></a:ext>`;\n}\n\n// ── Hyperlink handling ──\n\ninterface HyperlinkIds {\n clickId?: string;\n hoverId?: string;\n}\n\nfunction registerHyperlinks(\n hyperlink: HyperlinkOptions | undefined,\n ctx: BodyContext,\n): HyperlinkIds {\n if (!hyperlink) return {};\n const result: HyperlinkIds = {};\n if (hyperlink.click) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.click,\n TargetModeType.EXTERNAL,\n );\n result.clickId = `rId${linkId}`;\n }\n if (hyperlink.hover) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.hover,\n TargetModeType.EXTERNAL,\n );\n result.hoverId = `rId${linkId}`;\n }\n return result;\n}\n\nfunction buildHyperlinkChildren(ids: HyperlinkIds): string {\n const parts: string[] = [];\n const aNs = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\n if (ids.clickId) parts.push(`<a:hlinkClick r:id=\"${ids.clickId}\" ${aNs}/>`);\n if (ids.hoverId) parts.push(`<a:hlinkHover r:id=\"${ids.hoverId}\" ${aNs}/>`);\n return parts.join(\"\");\n}\n\n// ── DocPr ──\n\nfunction stringifyDocPr(opts: DocPropertiesOptions | undefined, hlIds: HyperlinkIds): string {\n const id = opts?.id ?? _docPropsIdGen();\n const name = opts?.name ?? \"\";\n const attrs: string[] = [`id=\"${id}\"`, `name=\"${escapeXml(name)}\"`];\n if (opts?.description != null && opts.description !== undefined) {\n attrs.push(`descr=\"${escapeXml(opts.description)}\"`);\n }\n if (opts?.title != null && opts.title !== undefined) {\n attrs.push(`title=\"${escapeXml(opts.title)}\"`);\n }\n const hlXml = buildHyperlinkChildren(hlIds);\n if (hlXml) {\n return `<wp:docPr ${attrs.join(\" \")}>${hlXml}</wp:docPr>`;\n }\n return `<wp:docPr ${attrs.join(\" \")}/>`;\n}\n\n// ── BlipFill (image data reference) ──\n\n/** Build `<a:srcRect .../>` from a crop spec, or \"\" when there is no crop. */\nfunction buildSrcRectXml(srcRect: SourceRectangleOptions | undefined): string {\n if (!srcRect) return \"\";\n const srAttrs: string[] = [];\n if (srcRect.left !== undefined) srAttrs.push(`l=\"${srcRect.left}\"`);\n if (srcRect.top !== undefined) srAttrs.push(`t=\"${srcRect.top}\"`);\n if (srcRect.right !== undefined) srAttrs.push(`r=\"${srcRect.right}\"`);\n if (srcRect.bottom !== undefined) srAttrs.push(`b=\"${srcRect.bottom}\"`);\n return srAttrs.length ? `<a:srcRect ${srAttrs.join(\" \")}/>` : \"<a:srcRect/>\";\n}\n\nfunction stringifyBlipFill(\n mediaData: MediaData,\n blipEffects?: BlipEffectsOptions,\n tile?: TileOptions,\n): string {\n const fileName =\n mediaData.type === \"svg\" && \"fallback\" in mediaData\n ? mediaData.fallback.fileName\n : mediaData.fileName;\n\n const parts: string[] = [];\n\n // a:blip — cstate omitted unless set; Word's default is \"none\", so emitting\n // it unconditionally inflates round-trip output that originally had none.\n const blipAttrs: string[] = [`r:embed=\"{${escapeXml(fileName)}}\"`];\n\n // Blip extension list: useLocalDpi (rendering hint) + SVG blip reference.\n // Both live in a single shared a:extLst; emitted only when at least one ext\n // is present so blips without extensions stay self-closing.\n const extParts: string[] = [];\n const useLocalDpiExt = buildUseLocalDpiExt(mediaData.useLocalDpi);\n if (useLocalDpiExt) extParts.push(useLocalDpiExt);\n if (mediaData.type === \"svg\") {\n extParts.push(\n `<a:ext uri=\"${SVG_BLIP_EXT_URI}\"><asvg:svgBlip xmlns:asvg=\"http://schemas.microsoft.com/office/drawing/2016/SVG/main\" r:embed=\"{${escapeXml(\n mediaData.fileName,\n )}}\"/></a:ext>`,\n );\n }\n const extLstXml = extParts.length > 0 ? `<a:extLst>${extParts.join(\"\")}</a:extLst>` : \"\";\n\n // Blip effects\n const blipEffectsXml = blipEffects ? buildBlipEffectsXml(blipEffects) : \"\";\n\n const blipContent = extLstXml + blipEffectsXml;\n if (blipContent) {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}>${blipContent}</a:blip>`);\n } else {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}/>`);\n }\n\n // Source rectangle (blip crop)\n const srcRectXml = buildSrcRectXml(mediaData.sourceRectangle);\n if (srcRectXml) parts.push(srcRectXml);\n\n // Tile or stretch\n if (tile) {\n const tileAttrs: string[] = [];\n if (tile.tx !== undefined) tileAttrs.push(`tx=\"${tile.tx}\"`);\n if (tile.ty !== undefined) tileAttrs.push(`ty=\"${tile.ty}\"`);\n if (tile.sx !== undefined) tileAttrs.push(`sx=\"${tile.sx}\"`);\n if (tile.sy !== undefined) tileAttrs.push(`sy=\"${tile.sy}\"`);\n const tileAttrStr = tileAttrs.length ? \" \" + tileAttrs.join(\" \") : \"\";\n parts.push(`<a:tile${tileAttrStr}/>`);\n } else {\n parts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n\n return `<pic:blipFill>${parts.join(\"\")}</pic:blipFill>`;\n}\n\nfunction buildBlipEffectsXml(opts: BlipEffectsOptions): string {\n const parts: string[] = [];\n if (opts.grayscale) parts.push(\"<a:grayscl/>\");\n if (opts.luminance) {\n const a: string[] = [];\n if (opts.luminance.bright !== undefined) a.push(`bright=\"${opts.luminance.bright}\"`);\n if (opts.luminance.contrast !== undefined) a.push(`contrast=\"${opts.luminance.contrast}\"`);\n parts.push(`<a:lum${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n if (opts.biLevel) parts.push(`<a:biLevel thresh=\"${opts.biLevel.threshold}\"/>`);\n if (opts.blur) {\n const a: string[] = [];\n if (opts.blur.radius !== undefined) a.push(`rad=\"${opts.blur.radius}\"`);\n if (opts.blur.grow === false) a.push('grow=\"0\"');\n parts.push(`<a:blur${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n return parts.join(\"\");\n}\n\n// ── Shape Properties (pic:spPr) ──\n\nfunction stringifyShapeProps(\n transform: MediaDataTransformation,\n outline?: OutlineOptions,\n fill?: FillOptions,\n effects?: EffectListOptions,\n): string {\n const parts: string[] = [];\n\n // Transform\n parts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n\n // Geometry (always rect — preset geometry variations not used for pic)\n parts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n\n if (fill) parts.push(fillDesc.stringify(fill, NOOP_CTX) ?? \"\");\n if (outline) parts.push(outlineDesc.stringify(outline, NOOP_CTX) ?? \"\");\n if (effects) parts.push(effectListDesc.stringify(effects, NOOP_CTX) ?? \"\");\n\n return `<pic:spPr bwMode=\"auto\">${parts.join(\"\")}</pic:spPr>`;\n}\n\n// ── Non-visual picture properties (pic:nvPicPr) ──\n\nfunction stringifyNvPicPr(hlIds: HyperlinkIds, cNvPr?: NonVisualPropertiesOptions): string {\n const hlXml = buildHyperlinkChildren(hlIds);\n const id = cNvPr?.id ?? 0;\n const name = escapeXml(cNvPr?.name ?? \"\");\n // descr omitted when absent — Word never writes an empty descr attribute.\n const descrAttr = cNvPr?.description ? ` descr=\"${escapeXml(cNvPr.description)}\"` : \"\";\n // preferRelativeResize defaults to true; only an explicit false is written.\n const cNvPicPrAttr = cNvPr?.preferRelativeResize === false ? ' preferRelativeResize=\"0\"' : \"\";\n const cNvPrClose = hlXml ? `>${hlXml}</pic:cNvPr>` : \"/>\";\n return (\n `<pic:nvPicPr><pic:cNvPr id=\"${id}\" name=\"${name}\"${descrAttr}${cNvPrClose}` +\n `<pic:cNvPicPr${cNvPicPrAttr}><a:picLocks noChangeAspect=\"1\"/></pic:cNvPicPr></pic:nvPicPr>`\n );\n}\n\n// ── WPS shape (pure string, no class instances) ──\n\nfunction stringifyGroupTransform2D(\n transform: MediaDataTransformation,\n childOffset?: ChildOffset,\n childExtent?: ChildExtent,\n): string {\n const attrs: string[] = [];\n if (transform.flip?.horizontal !== undefined) attrs.push(`flipH=\"${transform.flip.horizontal}\"`);\n if (transform.flip?.vertical !== undefined) attrs.push(`flipV=\"${transform.flip.vertical}\"`);\n if (transform.rotation !== undefined) attrs.push(`rot=\"${transform.rotation}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n\n const off = `<a:off x=\"${transform.offset?.emus?.x ?? 0}\" y=\"${transform.offset?.emus?.y ?? 0}\"/>`;\n const ext = `<a:ext cx=\"${transform.emus.x}\" cy=\"${transform.emus.y}\"/>`;\n const childOffsetXml = childOffset ? `<a:chOff x=\"${childOffset.x}\" y=\"${childOffset.y}\"/>` : \"\";\n const childExtentXml = childExtent\n ? `<a:chExt cx=\"${childExtent.cx}\" cy=\"${childExtent.cy}\"/>`\n : \"\";\n\n return `<a:xfrm${attrStr}>${off}${ext}${childOffsetXml}${childExtentXml}</a:xfrm>`;\n}\n\n/** WpsShape options for stringification (extends WpsShapeCoreOptions with transformation). */\ninterface WpsStringifyOptions extends WpsShapeCoreOptions {\n transformation: MediaDataTransformation;\n}\n\nfunction stringifyWpsShape(opts: WpsStringifyOptions, ctx: BodyContext): string {\n const transform = opts.transformation;\n const spPrParts: string[] = [];\n spPrParts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n if (opts.customGeometry) {\n spPrParts.push(customGeometryDesc.stringify(opts.customGeometry, NOOP_CTX) ?? \"\");\n } else if (opts.presetGeometry) {\n spPrParts.push(presetGeometryDesc.stringify(opts.presetGeometry, NOOP_CTX) ?? \"\");\n } else {\n spPrParts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n }\n if (opts.fill) spPrParts.push(fillDesc.stringify(opts.fill, ctx) ?? \"\");\n if (opts.outline) spPrParts.push(outlineDesc.stringify(opts.outline, NOOP_CTX) ?? \"\");\n if (opts.effectDag) {\n spPrParts.push(createEffectDag(opts.effectDag));\n } else if (opts.effects) {\n spPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n }\n if (opts.scene3d) spPrParts.push(scene3DDesc.stringify(opts.scene3d, NOOP_CTX) ?? \"\");\n if (opts.shape3d) spPrParts.push(shape3DDesc.stringify(opts.shape3d, NOOP_CTX) ?? \"\");\n\n // Non-visual shape properties — default txBox=\"1\"\n const cNvSpPr = opts.nonVisualProperties\n ? stringifyNonVisualShapeProperties(opts.nonVisualProperties)\n : '<wps:cNvSpPr txBox=\"1\"/>';\n\n // Paragraph children — pure JSON stringification\n const childXml =\n opts.children\n ?.map((c) => stringifyParagraphInline(c as ParagraphOptions | string, ctx))\n .join(\"\") ?? \"\";\n\n // Shape style (wps:style) — theme references, emitted after spPr (XSD order)\n const styleXml = opts.style ? stringifyShapeStyle(opts.style) : \"\";\n // wps:txbx — only emit when the shape carries text (text boxes). Pure\n // geometry shapes (no paragraphs) omit txbx in the source.\n const txbxXml = childXml ? `<wps:txbx><w:txbxContent>${childXml}</w:txbxContent></wps:txbx>` : \"\";\n\n return (\n \"<wps:wsp>\" +\n cNvSpPr +\n `<wps:spPr bwMode=\"auto\">${spPrParts.join(\"\")}</wps:spPr>` +\n styleXml +\n txbxXml +\n stringifyBodyPr(opts.bodyProperties) +\n \"</wps:wsp>\"\n );\n}\n\nfunction stringifyNonVisualShapeProperties(opts: NonVisualShapePropertiesOptions): string {\n let xml = \"\";\n // wps:cNvPr — id/name/descr/title (XSD CT_NonVisualDrawingProps)\n if (opts.id !== undefined || opts.name !== undefined) {\n const attrs: string[] = [];\n if (opts.id !== undefined) attrs.push(`id=\"${opts.id}\"`);\n if (opts.name !== undefined) attrs.push(`name=\"${escapeXml(opts.name)}\"`);\n if (opts.description !== undefined) attrs.push(`descr=\"${escapeXml(opts.description)}\"`);\n if (opts.title !== undefined) attrs.push(`title=\"${escapeXml(opts.title)}\"`);\n xml += `<wps:cNvPr ${attrs.join(\" \")}/>`;\n }\n // CT_WordprocessingShape choice: wps:cNvSpPr (text box/autoshape) or\n // wps:cNvCnPr (connector). Connectors carry empty cNvCnPr.\n if (opts.connector) {\n xml += \"<wps:cNvCnPr/>\";\n } else if (opts.textBox !== undefined) {\n xml += `<wps:cNvSpPr txBox=\"${opts.textBox}\"/>`;\n } else {\n xml += \"<wps:cNvSpPr/>\";\n }\n return xml;\n}\n\n/** Stringify a single style-matrix reference (a:lnRef/a:fillRef/...). */\nfunction stringifyStyleRef(name: string, ref: StyleMatrixReferenceOptions | undefined): string {\n if (!ref) return \"\";\n const idx = escapeXml(ref.idx);\n const colorXml = ref.color ? createColorElement(ref.color) : \"\";\n if (colorXml) return `<${name} idx=\"${idx}\">${colorXml}</${name}>`;\n return `<${name} idx=\"${idx}\"/>`;\n}\n\n/** Stringify a wps:style (CT_ShapeStyle): lnRef/fillRef/effectRef/fontRef. */\nfunction stringifyShapeStyle(opts: ShapeStyleOptions): string {\n const inner =\n stringifyStyleRef(\"a:lnRef\", opts.lineReference) +\n stringifyStyleRef(\"a:fillRef\", opts.fillReference) +\n stringifyStyleRef(\"a:effectRef\", opts.effectReference) +\n stringifyStyleRef(\"a:fontRef\", opts.fontReference);\n return inner ? `<wps:style>${inner}</wps:style>` : \"\";\n}\n\nfunction stringifyBodyPr(opts?: BodyPropertiesOptions): string {\n // Delegate to the shared createBodyProperties so attributes + EG_TextAutofit\n // (noAutofit/normAutofit/spAutoFit) + prstTxWarp/3D all round-trip. The old\n // inline copy dropped noAutoFit/spAutoFit and most CT_TextBodyProperties attrs.\n return createBodyProperties(opts ?? {});\n}\n\n// ── WPG group (pure string, no class instances) ──\n\nfunction stringifyWpgGroup(\n opts: {\n children: readonly GroupChildMediaData[];\n transformation: MediaDataTransformation;\n childOffset?: ChildOffset;\n childExtent?: ChildExtent;\n fill?: FillOptions;\n effects?: EffectListOptions;\n groupShapeLocks?: GroupShapeLocksOptions | null;\n },\n ctx: BodyContext,\n): string {\n const transform = opts.transformation;\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.childOffset, opts.childExtent));\n if (opts.fill) grpSpPrParts.push(fillDesc.stringify(opts.fill, ctx) ?? \"\");\n if (opts.effects) grpSpPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n\n // Children — wps shapes, nested wpg groups, or pic elements\n const childXml = opts.children.map((child) => stringifyGroupChild(child, ctx)).join(\"\");\n\n return (\n \"<wpg:wgp>\" +\n stringifyCnvGrpSpPr(opts.groupShapeLocks) +\n `<wpg:grpSpPr>${grpSpPrParts.join(\"\")}</wpg:grpSpPr>` +\n childXml +\n \"</wpg:wgp>\"\n );\n}\n\n/**\n * Stringify one group child: a wps shape, a nested wpg group, or a picture.\n * Shared by the top-level wpg:wgp and nested wpg:grpSp.\n */\nfunction stringifyGroupChild(child: GroupChildMediaData, ctx: BodyContext): string {\n if (child.type === \"wps\") {\n const wpsData = child as WpsMediaData & { outline?: OutlineOptions; fill?: FillOptions };\n return stringifyWpsShape(\n {\n ...wpsData.data,\n outline: wpsData.outline ?? wpsData.data.outline,\n fill: wpsData.fill ?? wpsData.data.fill,\n transformation: wpsData.transformation,\n },\n ctx,\n );\n }\n if (child.type === \"wpg\") {\n return stringifyNestedGroup(child as WpgMediaData, ctx);\n }\n // pic child (MediaData) — fill/outline ride on the group-child extension\n // (WpgCommonMediaData) so a grouped picture's spPr round-trips verbatim.\n const picData = child as MediaData & { outline?: OutlineOptions; fill?: FillOptions };\n const picParts: string[] = [];\n picParts.push(stringifyNvPicPr({}, picData.nonVisualProperties));\n const groupBlipParts: string[] = [];\n const useLocalDpiExt = buildUseLocalDpiExt(picData.useLocalDpi);\n groupBlipParts.push(\n useLocalDpiExt\n ? `<a:blip r:embed=\"{${escapeXml(\n picData.fileName,\n )}}\"><a:extLst>${useLocalDpiExt}</a:extLst></a:blip>`\n : `<a:blip r:embed=\"{${escapeXml(picData.fileName)}}\"/>`,\n );\n const groupSrcRectXml = buildSrcRectXml(picData.sourceRectangle);\n if (groupSrcRectXml) groupBlipParts.push(groupSrcRectXml);\n groupBlipParts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n picParts.push(`<pic:blipFill>${groupBlipParts.join(\"\")}</pic:blipFill>`);\n picParts.push(stringifyShapeProps(picData.transformation, picData.outline, picData.fill));\n return `<pic:pic xmlns:pic=\"${PIC_URI}\">${picParts.join(\"\")}</pic:pic>`;\n}\n\n/**\n * Stringify a nested wpg:grpSp (CT_WordprocessingGroup) group child. Same\n * structure as the top-level group, wrapped in wpg:grpSp with a cNvPr id/name.\n */\nfunction stringifyNestedGroup(grp: WpgMediaData, ctx: BodyContext): string {\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(\n stringifyGroupTransform2D(grp.transformation, grp.childOffset, grp.childExtent),\n );\n if (grp.fill) grpSpPrParts.push(fillDesc.stringify(grp.fill, ctx) ?? \"\");\n if (grp.effects) grpSpPrParts.push(effectListDesc.stringify(grp.effects, NOOP_CTX) ?? \"\");\n return (\n \"<wpg:grpSp>\" +\n '<wpg:cNvPr id=\"0\" name=\"\"/>' +\n stringifyCnvGrpSpPr(grp.groupShapeLocks) +\n `<wpg:grpSpPr>${grpSpPrParts.join(\"\")}</wpg:grpSpPr>` +\n grp.children.map((c) => stringifyGroupChild(c, ctx)).join(\"\") +\n \"</wpg:grpSp>\"\n );\n}\n\n// ── Graphic data content ──\n\nfunction stringifyGraphicDataContent(\n mediaData: ExtendedMediaData,\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { outline, fill, effects, blipEffects, tile } = opts;\n const transform = mediaData.transformation;\n\n if (mediaData.type === \"chart\") {\n const md = mediaData as ChartMediaData;\n return (\n `<a:graphicData uri=\"${CHART_URI}\">` +\n `<c:chart xmlns:c=\"${CHART_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"{chart:${md.chartKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"smartart\") {\n const md = mediaData as SmartArtMediaData;\n return (\n `<a:graphicData uri=\"${DGM_URI}\">` +\n `<dgm:relIds xmlns:dgm=\"${DGM_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:dm=\"{smartart:${md.smartArtKey}}\" r:lo=\"{smartart-lo:${md.smartArtKey}}\" r:qs=\"{smartart-qs:${md.smartArtKey}}\" r:cs=\"{smartart-cs:${md.smartArtKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"wps\") {\n const md = mediaData as WpsMediaData;\n const wpsXml = stringifyWpsShape(\n {\n ...md.data,\n outline,\n fill,\n transformation: transform,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPS_URI}\">${wpsXml}</a:graphicData>`;\n }\n\n if (mediaData.type === \"wpg\") {\n const md = mediaData as WpgMediaData;\n const wpgXml = stringifyWpgGroup(\n {\n children: md.children,\n transformation: transform,\n childOffset: md.childOffset,\n childExtent: md.childExtent,\n fill: md.fill,\n effects: md.effects,\n groupShapeLocks: md.groupShapeLocks,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPG_URI}\">${wpgXml}</a:graphicData>`;\n }\n\n // Default: image (pic:pic)\n const md = mediaData as MediaData;\n return (\n `<a:graphicData uri=\"${PIC_URI}\">` +\n `<pic:pic xmlns:pic=\"${PIC_URI}\">` +\n stringifyNvPicPr(hlIds, md.nonVisualProperties) +\n stringifyBlipFill(md, blipEffects, tile) +\n stringifyShapeProps(transform, outline, fill, effects) +\n `</pic:pic></a:graphicData>`\n );\n}\n\n// ── Position helpers (for anchor) ──\n\nfunction stringifyPositionH(opts: HorizontalPositionOptions): string {\n const rel = opts.relative ?? HorizontalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>`\n : \"<wp:align>left</wp:align>\";\n return `<wp:positionH relativeFrom=\"${rel}\">${child}</wp:positionH>`;\n}\n\nfunction stringifyPositionV(opts: VerticalPositionOptions): string {\n const rel = opts.relative ?? VerticalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>`\n : \"<wp:align>top</wp:align>\";\n return `<wp:positionV relativeFrom=\"${rel}\">${child}</wp:positionV>`;\n}\n\n// ── Text wrapping string builders ──\n\nfunction wrapPolygonStr(cx: number, cy: number): string {\n return (\n `<wp:wrapPolygon edited=\"0\">` +\n `<wp:start x=\"0\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"0\"/>` +\n `</wp:wrapPolygon>`\n );\n}\n\nfunction wrapSquareStr(textWrapping: TextWrapping, margins?: Margins): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const m = margins ?? {};\n const a = [\n `wrapText=\"${side}\"`,\n ...(m.top != null ? [`distT=\"${convertToEmu(m.top)}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${convertToEmu(m.bottom)}\"`] : []),\n ...(m.left != null ? [`distL=\"${convertToEmu(m.left)}\"`] : []),\n ...(m.right != null ? [`distR=\"${convertToEmu(m.right)}\"`] : []),\n ].join(\" \");\n return `<wp:wrapSquare ${a}/>`;\n}\n\nfunction wrapTightStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${convertToEmu(margins.left)}\"`);\n if (margins.right != null) a.push(`distR=\"${convertToEmu(margins.right)}\"`);\n return `<wp:wrapTight ${a.join(\" \")}>${wrapPolygonStr(cx, cy)}</wp:wrapTight>`;\n}\n\nfunction wrapThroughStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${convertToEmu(margins.left)}\"`);\n if (margins.right != null) a.push(`distR=\"${convertToEmu(margins.right)}\"`);\n return `<wp:wrapThrough ${a.join(\" \")}>${wrapPolygonStr(cx, cy)}</wp:wrapThrough>`;\n}\n\nfunction wrapTopAndBottomStr(margins?: Margins): string {\n const m = margins ?? {};\n const a = [\n ...(m.top != null ? [`distT=\"${convertToEmu(m.top)}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${convertToEmu(m.bottom)}\"`] : []),\n ].join(\" \");\n return a ? `<wp:wrapTopAndBottom ${a}/>` : \"<wp:wrapTopAndBottom/>\";\n}\n\n// ── Inline wrapper ──\n\n/** Render wp:cNvGraphicFramePr. Undefined → authoring default (noChangeAspect=1);\n * `{}` → empty element; otherwise the given lock flags. */\nfunction stringifyCnvGraphicFramePr(locks?: GraphicFrameLocksOptions | null): string {\n const resolved = locks ?? { noChangeAspect: true };\n const attrParts: string[] = [];\n if (resolved.noGrp) attrParts.push('noGrp=\"1\"');\n if (resolved.noDrilldown) attrParts.push('noDrilldown=\"1\"');\n if (resolved.noSelect) attrParts.push('noSelect=\"1\"');\n if (resolved.noChangeAspect) attrParts.push('noChangeAspect=\"1\"');\n if (resolved.noMove) attrParts.push('noMove=\"1\"');\n if (resolved.noResize) attrParts.push('noResize=\"1\"');\n if (attrParts.length === 0) return \"<wp:cNvGraphicFramePr/>\";\n const attrStr = \" \" + attrParts.join(\" \");\n return `<wp:cNvGraphicFramePr><a:graphicFrameLocks${attrStr} xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wp:cNvGraphicFramePr>`;\n}\n\n/**\n * Stringify wpg:cNvGrpSpPr (CT_NonVisualGroupShapeDrawingProperties): contains\n * an optional a:grpSpLocks (CT_GroupLocking). When no locks are present (the\n * Word default for groups) the element stays empty — groups do NOT inject a\n * default lock, unlike wp:cNvGraphicFramePr.\n */\nfunction stringifyCnvGrpSpPr(locks?: GroupShapeLocksOptions | null): string {\n if (!locks) return \"<wpg:cNvGrpSpPr/>\";\n const attrParts: string[] = [];\n if (locks.noGrp) attrParts.push('noGrp=\"1\"');\n if (locks.noUngrp) attrParts.push('noUngrp=\"1\"');\n if (locks.noSelect) attrParts.push('noSelect=\"1\"');\n if (locks.noRot) attrParts.push('noRot=\"1\"');\n if (locks.noChangeAspect) attrParts.push('noChangeAspect=\"1\"');\n if (locks.noMove) attrParts.push('noMove=\"1\"');\n if (locks.noResize) attrParts.push('noResize=\"1\"');\n if (attrParts.length === 0) return \"<wpg:cNvGrpSpPr/>\";\n const attrStr = \" \" + attrParts.join(\" \");\n return `<wpg:cNvGrpSpPr><a:grpSpLocks${attrStr} xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wpg:cNvGrpSpPr>`;\n}\n\nfunction stringifyInline(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, effects, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n // Prefer the verbatim source effectExtent (round-trip); fall back to\n // computing it from the shape's effects on the generation path.\n const effectExtent = mediaData.transformation.effectExtent ?? calculateEffectExtent(effects);\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n return (\n `<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">` +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n `<wp:effectExtent l=\"${effectExtent.l}\" t=\"${effectExtent.t}\" r=\"${effectExtent.r}\" b=\"${effectExtent.b}\"/>` +\n stringifyDocPr(docProperties, hlIds) +\n stringifyCnvGraphicFramePr(opts.graphicFrameLocks) +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:inline></w:drawing>`\n );\n}\n\n// ── Anchor (floating) wrapper ──\n\nfunction stringifyAnchor(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, floating: rawFloating, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n const floating: Required<Floating> = {\n allowOverlap: true,\n behindDocument: false,\n horizontalPosition: {},\n layoutInCell: true,\n lockAnchor: false,\n verticalPosition: {},\n zIndex: mediaData.transformation.emus.y,\n margins: {},\n wrap: { type: TextWrappingType.NONE },\n ...rawFloating,\n };\n\n const attrParts = [\n `distT=\"${convertToEmu(floating.margins?.top ?? 0)}\"`,\n `distB=\"${convertToEmu(floating.margins?.bottom ?? 0)}\"`,\n `distL=\"${convertToEmu(floating.margins?.left ?? 0)}\"`,\n `distR=\"${convertToEmu(floating.margins?.right ?? 0)}\"`,\n 'simplePos=\"0\"',\n `allowOverlap=\"${floating.allowOverlap ? 1 : 0}\"`,\n `behindDoc=\"${floating.behindDocument ? 1 : 0}\"`,\n `locked=\"${floating.lockAnchor ? 1 : 0}\"`,\n `layoutInCell=\"${floating.layoutInCell ? 1 : 0}\"`,\n `relativeHeight=\"${floating.zIndex}\"`,\n ];\n\n // Wrap\n let wrapXml: string;\n const rawWrap = rawFloating?.wrap;\n if (rawWrap?.type === TextWrappingType.SQUARE) {\n wrapXml = wrapSquareStr(rawWrap, floating.margins);\n } else if (rawWrap?.type === TextWrappingType.TIGHT) {\n wrapXml = wrapTightStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.THROUGH) {\n wrapXml = wrapThroughStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.TOP_AND_BOTTOM) {\n wrapXml = wrapTopAndBottomStr(floating.margins);\n } else {\n wrapXml = \"<wp:wrapNone/>\";\n }\n\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n // Prefer the verbatim source effectExtent (round-trip); default to zero.\n const ee = mediaData.transformation.effectExtent;\n const effectExtentXml = ee\n ? `<wp:effectExtent l=\"${ee.l}\" t=\"${ee.t}\" r=\"${ee.r}\" b=\"${ee.b}\"/>`\n : '<wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>';\n\n return (\n `<w:drawing><wp:anchor ${attrParts.join(\" \")}>` +\n '<wp:simplePos x=\"0\" y=\"0\"/>' +\n stringifyPositionH(floating.horizontalPosition) +\n stringifyPositionV(floating.verticalPosition) +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n effectExtentXml +\n wrapXml +\n stringifyDocPr(docProperties, hlIds) +\n stringifyCnvGraphicFramePr(opts.graphicFrameLocks) +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:anchor></w:drawing>`\n );\n}\n\n// ── Descriptor ──\n\n/**\n * Drawing descriptor for DOCX `<w:drawing>` elements.\n *\n * Eliminates the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain. Inline images, charts, and smartarts produce XML via pure\n * string concatenation — zero XmlComponent instances.\n *\n * @example\n * ```typescript\n * const xml = drawingDesc.stringify({ mediaData, docProperties: opts.altText, floating: opts.floating }, ctx);\n * ```\n */\nexport const drawingDesc: CustomDescriptor<DrawingDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n // Register hyperlink relationships\n const hlIds = registerHyperlinks(opts.docProperties?.hyperlink, ctx);\n\n if (opts.floating) {\n return stringifyAnchor(opts, hlIds, ctx);\n }\n return stringifyInline(opts, hlIds, ctx);\n },\n\n parse(el, ctx) {\n const result = parseDrawingRun(el, ctx as DocxReadContext);\n return (result ?? {}) as unknown as DrawingDescriptorOptions;\n },\n};\n","/**\n * Field module for WordprocessingML documents.\n *\n * This module provides support for complex fields, which are regions of text\n * that can contain dynamic content such as page numbers, dates, or mail merge fields.\n * Fields are delimited by field character elements (begin, separate, end).\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\nimport { element } from \"@office-open/xml\";\n\nimport type { FormFieldOptions } from \"./form-field\";\nimport { createFormFieldData } from \"./form-field\";\n\n/**\n * Field character types that delimit field regions.\n *\n * @internal\n */\nconst FieldCharacterType = {\n BEGIN: \"begin\",\n END: \"end\",\n SEPARATE: \"separate\",\n} as const;\n\n/**\n * Creates a field character element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FldChar\">\n * <xsd:sequence>\n * <xsd:element name=\"fldData\" type=\"CT_Text\" minOccurs=\"0\"/>\n * <xsd:element name=\"ffData\" type=\"CT_FFData\" minOccurs=\"0\"/>\n * <xsd:element name=\"numberingChange\" type=\"CT_TrackChangeNumbering\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"fldCharType\" type=\"ST_FldCharType\" use=\"required\"/>\n * <xsd:attribute name=\"fldLock\" type=\"s:ST_OnOff\"/>\n * <xsd:attribute name=\"dirty\" type=\"s:ST_OnOff\"/>\n * </xsd:complexType>\n * ```\n * @internal\n */\nconst createFieldChar = (\n type: (typeof FieldCharacterType)[keyof typeof FieldCharacterType],\n dirty?: boolean,\n ffData?: string,\n fldData?: string,\n fieldLock?: boolean,\n): string => {\n const children: string[] = [];\n if (fldData !== undefined) {\n children.push(element(\"w:fldData\", { \"xml:space\": \"preserve\" }, [fldData]));\n }\n if (ffData) {\n children.push(ffData);\n }\n return element(\n \"w:fldChar\",\n {\n \"w:dirty\": dirty,\n \"w:fldLock\": fieldLock,\n \"w:fldCharType\": type,\n },\n children.length > 0 ? children : undefined,\n );\n};\n\n/**\n * Creates the beginning of a complex field.\n *\n * The Begin element marks the start of a field. A field consists of a begin character,\n * field instructions, an optional separate character, field result, and an end character.\n *\n * For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.\n *\n * @param dirty - Whether the field should be recalculated\n * @param formField - Optional form field data to embed in the begin character\n *\n * @example\n * ```typescript\n * // Simple field begin\n * createBegin();\n *\n * // Form field (checkbox)\n * createBegin(false, {\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n * ```\n */\nexport const createBegin = (\n dirty?: boolean,\n formField?: FormFieldOptions,\n fieldLock?: boolean,\n): string =>\n createFieldChar(\n FieldCharacterType.BEGIN,\n dirty,\n formField ? createFormFieldData(formField) : undefined,\n undefined,\n fieldLock,\n );\n\n/**\n * Creates the separator between field code and field result in a complex field.\n *\n * The Separate element divides the field code (instructions) from the field result\n * (the computed value).\n */\nexport const createSeparate = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.SEPARATE, dirty);\n\n/**\n * Creates the end of a complex field.\n *\n * The End element marks the end of a field. Every field that begins with a Begin\n * element must be terminated with an End element.\n */\nexport const createEnd = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.END, dirty);\n","/**\n * Shared inline run/paragraph stringification for DOCX descriptors.\n *\n * Used by table.ts, comments.ts, body.ts, and other descriptors that need to\n * serialize paragraph/run content. Includes JSON child dispatch for all\n * ParagraphChild variants (image, chart, hyperlink, etc.).\n *\n * Pure string concatenation — zero IXmlableObject, zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { TargetModeType } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { chartSpaceDesc } from \"@office-open/core/chart\";\nimport type { SourceRectangleOptions } from \"@office-open/core/drawingml\";\nimport { createDataModel } from \"@office-open/core/smartart\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { BackgroundRawMediaOptions } from \"@parts/document/document-background/document-background\";\nimport type {\n BookmarkOptions,\n BookmarkStartOptions,\n MarkupRangeOptions,\n MoveRangeOptions,\n MoveRangeStartOptions,\n} from \"@parts/paragraph/links/bookmark\";\nimport type { ParagraphChild, ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { CommentChildOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport { breakXml, type RunOptions } from \"@parts/paragraph/run/run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\nimport type {\n ChartMediaData,\n GroupChildMediaData,\n MediaData,\n SmartArtMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { BodyContext } from \"../context\";\nimport { checkboxSymbolRunInner, stringifyCustomXmlShell, stringifySdtShell } from \"./bodychildren\";\nimport { drawingDesc } from \"./drawing\";\nimport { stringifyMath } from \"./paragraph/math/stringify\";\nimport { createBegin, createSeparate, createEnd } from \"./paragraph/run/field\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./paragraph/stringify\";\n\n// ── Run ──\n\n/** Serialize a deleted run: rPr + delText (or field delInstrText). */\nfunction stringifyDeletedRun(c: RunOptions | string): string {\n const opts = typeof c === \"string\" ? { text: c } : c;\n const parts: string[] = [];\n const rPr = stringifyRunProperties(opts);\n if (rPr) parts.push(rPr);\n if (opts.break) parts.push(breakXml(opts.break));\n const fieldMap: Record<string, string> = {\n CURRENT: \"PAGE\",\n TOTAL_PAGES: \"NUMPAGES\",\n TOTAL_PAGES_IN_SECTION: \"SECTIONPAGES\",\n };\n if (opts.children) {\n for (const cc of opts.children) {\n if (typeof cc === \"string\") {\n // Page number fields use delInstrText instead of instrText\n const instrText = fieldMap[cc];\n if (instrText) {\n parts.push(\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:delInstrText xml:space=\"preserve\">${instrText}</w:delInstrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>',\n );\n } else {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(cc)}</w:delText>`);\n }\n }\n }\n } else if (opts.text) {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:delText>`);\n }\n return `<w:r>${parts.join(\"\")}</w:r>`;\n}\n\nexport function stringifyRunInline(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const rPr = stringifyRunProperties(opts);\n if (rPr) parts.push(rPr);\n\n if (opts.break) parts.push(breakXml(opts.break));\n\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else {\n // JSON child dispatch\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n } else if (opts.text !== undefined) {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:t>`);\n }\n\n const rsidAttrs: string[] = [];\n if (opts.rsid) rsidAttrs.push(` w:rsidR=\"${opts.rsid}\"`);\n if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${opts.deletionRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body.length === 0 ? (attr ? `<w:r${attr}/>` : \"<w:r/>\") : `<w:r${attr}>${body}</w:r>`;\n}\n\n// ── Image helpers ──\n\nfunction createImageData(\n data: Uint8Array,\n transformation: ImageOptions[\"transformation\"],\n key: string,\n sourceRectangle?: SourceRectangleOptions,\n nonVisualProperties?: NonVisualPropertiesOptions,\n): Pick<\n MediaData,\n \"data\" | \"fileName\" | \"transformation\" | \"sourceRectangle\" | \"nonVisualProperties\"\n> {\n return {\n data,\n fileName: key,\n sourceRectangle,\n nonVisualProperties,\n transformation: createTransformation(transformation),\n };\n}\n\nlet nextChartId = 1;\n\n// ── JSON child dispatch ──\n\n/**\n * Stringify a ParagraphChild into one or more XML strings.\n *\n * Handles side effects (media, chart, smartArt, relationship registration)\n * directly without creating temporary class instances.\n *\n * Returns `undefined` if the child is not a recognized JSON wrapper.\n */\n/**\n * Wrap a `<w:drawing>` run, rebuilding an mc:AlternateContent wrapper when a\n * VML fallback was carried from parse (Choice stays structured/editable,\n * Fallback round-trips as raw XML for fidelity).\n */\nfunction wrapDrawingRun(\n drawingXml: string | undefined,\n opts: { vmlFallback?: string; mcChoiceRequires?: string; runProperties?: RunPropertiesOptions },\n): string {\n const xml = drawingXml ?? \"\";\n const rPr = stringifyRunProperties(opts.runProperties) ?? \"\";\n if (opts.vmlFallback) {\n const requires = opts.mcChoiceRequires ?? \"wps\";\n // opts.vmlFallback is the serialized <mc:Fallback>…</mc:Fallback> element,\n // so splice it in directly (no extra wrapper).\n return `<w:r>${rPr}<mc:AlternateContent><mc:Choice Requires=\"${requires}\">${xml}</mc:Choice>${opts.vmlFallback}</mc:AlternateContent></w:r>`;\n }\n return `<w:r>${rPr}${xml}</w:r>`;\n}\n\n/**\n * Register media carried by a VML fallback (mc:AlternateContent Fallback) so the\n * compiler resolves the fallback's `{fileName}` placeholders into rIds.\n *\n * A VML fallback image mirrors its Choice blip (same source bytes). When the\n * blip is already registered, reuse it and remap the fallback's `{fileName}`\n * placeholder to the shared media — matching Office, which emits one\n * relationship/file per image rather than a duplicate for the VML branch.\n */\nfunction registerVmlFallbackMedia(\n opts: { vmlFallback?: string; vmlFallbackMedia?: BackgroundRawMediaOptions[] },\n ctx: BodyContext,\n): void {\n if (!opts.vmlFallbackMedia) return;\n for (const m of opts.vmlFallbackMedia) {\n const data = toUint8Array(m.data);\n const entry = ctx.file.media.addMedia(\n data,\n m.type,\n (fileName) =>\n ({\n type: m.type,\n data,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n m.fileName,\n );\n // Dedup may reuse the Choice blip's file name; remap the VML fallback\n // placeholder so both branches share one relationship/file (matches Office).\n if (entry.fileName !== m.fileName && opts.vmlFallback) {\n opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);\n }\n }\n}\n\n/**\n * Build the rPr XML for a break/tab run from its structured run properties.\n */\n/** Shared attribute string for CT_MarkupRange end markers (commentRange, move range end). */\nfunction buildMarkupRangeAttrs(m: MarkupRangeOptions): string {\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${m.displacedByCustomXml}\"`);\n return a.join(\" \");\n}\n\n/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */\nfunction buildBookmarkStartAttrs(bs: BookmarkStartOptions): string {\n const a: string[] = [`w:id=\"${bs.id}\"`, `w:name=\"${escapeXml(bs.name)}\"`];\n if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${bs.displacedByCustomXml}\"`);\n if (bs.colFirst !== undefined) a.push(`w:colFirst=\"${bs.colFirst}\"`);\n if (bs.colLast !== undefined) a.push(`w:colLast=\"${bs.colLast}\"`);\n return a.join(\" \");\n}\n\n/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */\nfunction buildMoveRangeStartAttrs(m: MoveRangeStartOptions): string {\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.name) a.push(`w:name=\"${escapeXml(m.name)}\"`);\n if (m.author) a.push(`w:author=\"${escapeXml(m.author)}\"`);\n if (m.date) a.push(`w:date=\"${m.date}\"`);\n if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${m.displacedByCustomXml}\"`);\n if (m.colFirst !== undefined) a.push(`w:colFirst=\"${m.colFirst}\"`);\n if (m.colLast !== undefined) a.push(`w:colLast=\"${m.colLast}\"`);\n return a.join(\" \");\n}\n\n/** Stringify inline run/text content — the `wrap` shared by every sugar child. */\nfunction stringifyInlineWrap(wrap: (string | RunOptions)[] | undefined, ctx: BodyContext): string {\n const parts: string[] = [];\n for (const item of wrap ?? []) {\n parts.push(\n typeof item === \"string\"\n ? stringifyRunInline({ text: item }, ctx)\n : stringifyRunInline(item, ctx),\n );\n }\n return parts.join(\"\");\n}\n\n/**\n * Expand a `{ comment }` sugar child: allocate the comment id, register the\n * comment entry (side effect, consumed when word/comments.xml is stringified),\n * and emit the range markers + anchored content + reference with one shared id.\n *\n * The caller never supplies an id — the library owns id allocation and pairing.\n */\nfunction stringifyCommentChild(c: CommentChildOptions, ctx: BodyContext): string {\n const id = ctx.file.comments.nextId++;\n ctx.file.comments.entries.push({\n id,\n author: c.author,\n initials: c.initials,\n date: c.date,\n children: c.children,\n });\n\n return (\n `<w:commentRangeStart w:id=\"${id}\"/>` +\n stringifyInlineWrap(c.wrap, ctx) +\n `<w:commentRangeEnd w:id=\"${id}\"/>` +\n `<w:r><w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr><w:commentReference w:id=\"${id}\"/></w:r>`\n );\n}\n\n/**\n * Expand a `{ bookmark }` sugar child: allocate the bookmark id and emit the\n * paired bookmarkStart/bookmarkEnd with the anchored content between them.\n * Bookmarks are pure markup — the only effect is the two markers.\n */\nfunction stringifyBookmarkChild(b: BookmarkOptions, ctx: BodyContext): string {\n const id = ctx.file.markupIds.rangeNext++;\n const startAttrs = buildBookmarkStartAttrs({\n id,\n name: b.name,\n displacedByCustomXml: b.displacedByCustomXml,\n colFirst: b.colFirst,\n colLast: b.colLast,\n });\n const endAttrs = buildMarkupRangeAttrs({ id, displacedByCustomXml: b.displacedByCustomXml });\n return `<w:bookmarkStart ${startAttrs}/>${stringifyInlineWrap(b.wrap, ctx)}<w:bookmarkEnd ${endAttrs}/>`;\n}\n\n/**\n * Expand a `{ moveFrom }` / `{ moveTo }` sugar child: allocate the range id and\n * the move-run id, then emit the paired range markers with the moved run between\n * them. The move run (CT_TrackChange) carries the moved content.\n */\nfunction stringifyMoveRangeChild(\n kind: \"moveFrom\" | \"moveTo\",\n opts: MoveRangeOptions,\n ctx: BodyContext,\n): string {\n const rangeId = ctx.file.markupIds.rangeNext++;\n const runId = ctx.file.markupIds.moveRunNext++;\n const isMoveFrom = kind === \"moveFrom\";\n const startTag = isMoveFrom ? \"w:moveFromRangeStart\" : \"w:moveToRangeStart\";\n const endTag = isMoveFrom ? \"w:moveFromRangeEnd\" : \"w:moveToRangeEnd\";\n const runTag = isMoveFrom ? \"w:moveFrom\" : \"w:moveTo\";\n const rangeStartAttrs = buildMoveRangeStartAttrs({\n id: rangeId,\n name: opts.name,\n author: opts.author,\n date: opts.date,\n displacedByCustomXml: opts.displacedByCustomXml,\n colFirst: opts.colFirst,\n colLast: opts.colLast,\n });\n const endAttrs = buildMarkupRangeAttrs({\n id: rangeId,\n displacedByCustomXml: opts.displacedByCustomXml,\n });\n return (\n `<${startTag} ${rangeStartAttrs}/>` +\n `<${runTag} w:id=\"${runId}\" w:author=\"${escapeXml(opts.author)}\" w:date=\"${opts.date}\">${stringifyInlineWrap(opts.wrap, ctx)}</${runTag}>` +\n `<${endTag} ${endAttrs}/>`\n );\n}\n\nfunction runPropertiesXml(child: ParagraphChild): string {\n return stringifyRunProperties(child as RunOptions) ?? \"\";\n}\n\nexport function stringifyChildDispatch(\n child: ParagraphChild,\n ctx: BodyContext,\n): string | string[] | undefined {\n // Simple break types — pure XML, no side effects. A break run may carry run\n // properties (round-tripped from <w:r><w:rPr>…</w:rPr><w:br…/></w:r>).\n if (\"pageBreak\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:br w:type=\"page\"/></w:r>`;\n }\n if (\"columnBreak\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:br w:type=\"column\"/></w:r>`;\n }\n if (\"tab\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;\n }\n\n // Reference types — pure XML, no side effects\n if (\"footnoteReference\" in child) {\n const ref = child.footnoteReference;\n const id = typeof ref === \"number\" ? ref : ref.id;\n const cmf =\n typeof ref === \"object\" && ref.customMarkFollows ? ' w:customMarkFollows=\"true\"' : \"\";\n return `<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteReference w:id=\"${id}\"${cmf}/></w:r>`;\n }\n if (\"endnoteReference\" in child) {\n const ref = child.endnoteReference;\n const id = typeof ref === \"number\" ? ref : ref.id;\n const cmf =\n typeof ref === \"object\" && ref.customMarkFollows ? ' w:customMarkFollows=\"true\"' : \"\";\n return `<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteReference w:id=\"${id}\"${cmf}/></w:r>`;\n }\n\n // Comment sugar — library allocates the id, emits the range markers +\n // reference, and registers the comment entry (see stringifyCommentChild).\n if (\"comment\" in child) return stringifyCommentChild(child.comment, ctx);\n\n // Comment markers — pure XML\n if (\"commentRangeStart\" in child)\n return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;\n if (\"commentRangeEnd\" in child)\n return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;\n if (\"commentReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr><w:commentReference w:id=\"${child.commentReference}\"/></w:r>`;\n\n // Bookmark markers — pure XML\n if (\"bookmarkStart\" in child) {\n return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;\n }\n if (\"bookmarkEnd\" in child) {\n return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;\n }\n // Bookmark sugar — library allocates the id and pairs start/end.\n if (\"bookmark\" in child) return stringifyBookmarkChild(child.bookmark, ctx);\n\n // Symbol run — direct XML output.\n // <w:sym> is a self-closing element, not text: emit it directly so it is\n // not escaped into a <w:t> by the run children path.\n if (\"symbolRun\" in child) {\n const opts = child.symbolRun;\n const rPr = stringifyRunProperties(opts) ?? \"\";\n return `<w:r>${rPr}<w:sym w:char=\"${opts.char}\" w:font=\"${opts.symbolfont ?? \"Wingdings\"}\"/></w:r>`;\n }\n\n // Form field (checkbox / dropdown list / text input) — fldChar sequence.\n // Word needs the field code (instrText) between begin and separate to\n // recognize the field type and render its result.\n if (\"formField\" in child) {\n const ff = child.formField;\n let result = \"\";\n let instrCode = \"\";\n let symbolFont = false;\n if (ff.checkBox) {\n result = ff.checkBox.checked ? \"☒\" : \"☐\";\n instrCode = \"FORMCHECKBOX\";\n // U+2610/U+2612 are absent from common body fonts (Calibri/Times);\n // MS Gothic holds them and matches the SDT w14:checkbox default.\n symbolFont = true;\n } else if (ff.dropDownList) {\n const idx = ff.dropDownList.result ?? ff.dropDownList.default;\n result = idx !== undefined ? (ff.dropDownList.entries[idx] ?? \"\") : \"\";\n instrCode = \"FORMDROPDOWN\";\n } else if (ff.textInput) {\n // Prefer the user-entered value (result run) over the placeholder default.\n result = ff.textInput.value ?? ff.textInput.default ?? \"\";\n instrCode = \"FORMTEXT\";\n }\n const rPr = symbolFont\n ? '<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>'\n : \"\";\n return (\n `<w:r>${createBegin(false, ff)}</w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instrCode} </w:instrText></w:r>` +\n `<w:r>${createSeparate()}</w:r>` +\n `<w:r>${rPr}<w:t xml:space=\"preserve\">${escapeXml(result)}</w:t></w:r>` +\n `<w:r>${createEnd()}</w:r>`\n );\n }\n\n // Image — side effect: media registration (content-deduplicated via core Media)\n if (\"image\" in child) {\n const opts = child.image;\n const rawData = toUint8Array(opts.data, { encoding: \"base64\" }) as Uint8Array;\n\n let mediaData: MediaData;\n if (opts.type === \"svg\") {\n const fallbackData = toUint8Array(opts.fallback.data, { encoding: \"base64\" }) as Uint8Array;\n const fallbackType = opts.fallback.type;\n // Register the raster fallback first so its file name is allocated, then\n // build the svg entry referencing it. Dedup applies to both independently.\n const fallback = ctx.file.media.addMedia(\n fallbackData,\n fallbackType,\n (fileName) =>\n ({\n type: fallbackType,\n ...createImageData(fallbackData, opts.transformation, fileName),\n }) as MediaData,\n );\n mediaData = ctx.file.media.addMedia(\n rawData,\n \"svg\",\n (fileName) =>\n ({\n type: \"svg\" as const,\n ...createImageData(\n rawData,\n opts.transformation,\n fileName,\n opts.sourceRectangle,\n opts.nonVisualProperties,\n ),\n useLocalDpi: opts.useLocalDpi,\n fallback,\n }) as MediaData,\n );\n } else {\n const type = opts.type;\n mediaData = ctx.file.media.addMedia(\n rawData,\n type,\n (fileName) =>\n ({\n type,\n ...createImageData(\n rawData,\n opts.transformation,\n fileName,\n opts.sourceRectangle,\n opts.nonVisualProperties,\n ),\n useLocalDpi: opts.useLocalDpi,\n }) as MediaData,\n );\n }\n\n // Build drawing XML via descriptor (zero XmlComponent instances)\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n outline: opts.outline,\n fill: opts.fill,\n effects: opts.effects,\n blipEffects: opts.blipEffects,\n tile: opts.tile,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // Chart — side effect: chart registration\n if (\"chart\" in child) {\n const opts = child.chart;\n const chartKey = `chart_${nextChartId++}`;\n const mediaData: ChartMediaData = {\n chartKey,\n transformation: createTransformation(opts.transformation),\n type: \"chart\",\n };\n\n // Register chart\n const chartXml = chartSpaceDesc.stringify(\n {\n categories: opts.categories,\n series: opts.series,\n showLegend: opts.showLegend,\n style: opts.style,\n title: opts.title,\n type: opts.type,\n threeD: opts.threeD,\n },\n ctx.file,\n );\n ctx.file.charts.addChart(chartKey, {\n key: chartKey,\n chartSpaceXml: chartXml ?? \"\",\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // SmartArt — side effect: smartArt registration\n if (\"smartArt\" in child) {\n const opts = child.smartArt;\n const hash = hashSmartArtData(opts);\n const smartArtKey = `smartart_${hash}`;\n const mediaData: SmartArtMediaData = {\n smartArtKey,\n transformation: createTransformation(opts.transformation),\n type: \"smartart\",\n };\n\n // Register SmartArt\n const layoutId = opts.layout ?? \"default\";\n const styleId = opts.style ?? \"simple1\";\n const colorId = opts.color ?? \"accent1_2\";\n const dataModelXml = createDataModel(opts.data.nodes, layoutId, styleId, colorId);\n\n ctx.file.smartArts.addSmartArt(smartArtKey, {\n dataModelXml,\n key: smartArtKey,\n layout: layoutId,\n style: styleId,\n color: colorId,\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // WPS Shape (WordProcessing Shape) — side effect: blip fill media registration\n if (\"wpsShape\" in child) {\n const opts = child.wpsShape;\n const mediaData: WpsMediaData = {\n data: opts,\n transformation: createTransformation(opts.transformation),\n type: \"wps\",\n };\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n outline: opts.outline,\n fill: opts.fill,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n registerVmlFallbackMedia(opts, ctx);\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // WPG Group (WordProcessing Group) — group of shapes/pictures\n if (\"wpgGroup\" in child) {\n const opts = child.wpgGroup;\n const mediaData: WpgMediaData = {\n children: opts.children,\n transformation: createTransformation(opts.transformation),\n childOffset: opts.childOffset,\n childExtent: opts.childExtent,\n fill: opts.fill,\n effects: opts.effects,\n groupShapeLocks: opts.groupShapeLocks,\n type: \"wpg\",\n };\n\n // Register pic children media so {fileName} placeholders resolve, recursing\n // into nested wpg groups. wps children carry shape data, not media.\n const registerMedia = (children: readonly GroupChildMediaData[]): void => {\n for (const c of children) {\n if (c.type === \"wps\") continue;\n if (c.type === \"wpg\") {\n registerMedia(c.children);\n continue;\n }\n ctx.file.media.addMedia(c.data, c.type, () => c as MediaData, c.fileName);\n }\n };\n registerMedia(opts.children);\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n registerVmlFallbackMedia(opts, ctx);\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // Ruby annotation — pure string concatenation\n if (\"ruby\" in child && typeof child.ruby === \"object\" && child.ruby !== null) {\n const r = child.ruby as RubyOptions;\n const align = r.alignment ?? \"center\";\n const hps = (r.fontSize ?? 10) * 2;\n const hpsRaise = (r.raise ?? 10) * 2;\n const hpsBaseText = (r.baseFontSize ?? 20) * 2;\n const lid = r.languageId ?? \"ja-JP\";\n\n const prParts = [\n `<w:rubyAlign w:val=\"${align}\"/>`,\n `<w:hps w:val=\"${hps}\"/>`,\n `<w:hpsRaise w:val=\"${hpsRaise}\"/>`,\n `<w:hpsBaseText w:val=\"${hpsBaseText}\"/>`,\n `<w:lid w:val=\"${lid}\"/>`,\n ];\n if (r.dirty) prParts.push(\"<w:dirty/>\");\n\n const rt = `<w:rt><w:r><w:t xml:space=\"preserve\">${escapeXml(r.text)}</w:t></w:r></w:rt>`;\n const rubyBase = `<w:rubyBase><w:r><w:t xml:space=\"preserve\">${escapeXml(r.base)}</w:t></w:r></w:rubyBase>`;\n\n return `<w:ruby><w:rubyPr>${prParts.join(\"\")}</w:rubyPr>${rt}${rubyBase}</w:ruby>`;\n }\n\n // Math — pure string concatenation\n if (\"math\" in child && typeof child.math === \"object\" && child.math !== null) {\n const mathOpts = child.math;\n const children = mathOpts.children ?? [];\n return stringifyMath(children);\n }\n\n // Inserted text run(s) — w:ins wraps one or more runs (CT_RunTrackChange)\n if (\"insertion\" in child) {\n const { id, author, date, children } = child.insertion;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:ins w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:ins>`;\n }\n\n // Deleted text run(s) — w:del wraps one or more runs (delText content)\n if (\"deletion\" in child) {\n const { id, author, date, children } = child.deletion;\n const body = children.map((c) => stringifyDeletedRun(c)).join(\"\");\n return `<w:del w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:del>`;\n }\n\n // Hyperlink — side effect: relationship registration\n if (\"hyperlink\" in child) {\n const hl = child.hyperlink;\n\n // Serialize children using stringifyRunInline. A top-level `text` is a\n // shorthand for a single text run; without it `{ text, hyperlink }` would\n // emit an empty <w:hyperlink>.\n const childParts: string[] = [];\n if (child.text !== undefined) {\n childParts.push(stringifyRunInline({ text: child.text }, ctx));\n }\n if (hl.children) {\n for (const rc of hl.children) {\n if (typeof rc === \"string\") {\n childParts.push(stringifyRunInline({ text: rc }, ctx));\n } else {\n childParts.push(stringifyRunInline(rc, ctx));\n }\n }\n }\n const body = childParts.join(\"\");\n\n const pushHlAttrs = (attrs: string[]): void => {\n if (hl.history !== false) attrs.push('w:history=\"1\"');\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\n if (hl.tgtFrame) attrs.push(`w:tgtFrame=\"${escapeXml(hl.tgtFrame)}\"`);\n if (hl.docLocation) attrs.push(`w:docLocation=\"${escapeXml(hl.docLocation)}\"`);\n };\n if (hl.link) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hl.link,\n TargetModeType.EXTERNAL,\n );\n const attrs = [`r:id=\"rId${linkId}\"`];\n pushHlAttrs(attrs);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n if (hl.anchor) {\n const attrs = [`w:anchor=\"${escapeXml(hl.anchor)}\"`];\n pushHlAttrs(attrs);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n return \"\";\n }\n\n // ── Proof error markers ──\n if (\"proofErr\" in child) return `<w:proofErr w:type=\"${child.proofErr}\"/>`;\n\n // ── Positional tab ──\n if (\"positionalTab\" in child) {\n const pt = child.positionalTab;\n return `<w:ptab w:alignment=\"${pt.alignment}\" w:leader=\"${pt.leader}\" w:relativeTo=\"${pt.relativeTo}\"/>`;\n }\n\n // ── Permission range markers ──\n if (\"permStart\" in child) {\n const ps = child.permStart;\n const a: string[] = [`w:id=\"${ps.id}\"`];\n if (ps.ed !== undefined) a.push(`w:ed=\"${escapeXml(String(ps.ed))}\"`);\n if (ps.editGroup !== undefined) a.push(`w:edGrp=\"${ps.editGroup}\"`);\n if (ps.colFirst !== undefined) a.push(`w:colFirst=\"${ps.colFirst}\"`);\n if (ps.colLast !== undefined) a.push(`w:colLast=\"${ps.colLast}\"`);\n return `<w:permStart ${a.join(\" \")}/>`;\n }\n if (\"permEnd\" in child) return `<w:permEnd w:id=\"${child.permEnd}\"/>`;\n\n // ── Move revision range markers ──\n if (\"moveFromRangeStart\" in child) {\n return `<w:moveFromRangeStart ${buildMoveRangeStartAttrs(child.moveFromRangeStart)}/>`;\n }\n if (\"moveFromRangeEnd\" in child)\n return `<w:moveFromRangeEnd ${buildMarkupRangeAttrs(child.moveFromRangeEnd)}/>`;\n if (\"moveToRangeStart\" in child) {\n return `<w:moveToRangeStart ${buildMoveRangeStartAttrs(child.moveToRangeStart)}/>`;\n }\n if (\"moveToRangeEnd\" in child)\n return `<w:moveToRangeEnd ${buildMarkupRangeAttrs(child.moveToRangeEnd)}/>`;\n // Move revision sugar — library allocates range + run ids and pairs markers.\n if (\"moveFrom\" in child) return stringifyMoveRangeChild(\"moveFrom\", child.moveFrom, ctx);\n if (\"moveTo\" in child) return stringifyMoveRangeChild(\"moveTo\", child.moveTo, ctx);\n\n // ── Move revision text runs ──\n if (\"movedFrom\" in child) {\n const { id, author, date, children } = child.movedFrom;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:moveFrom w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:moveFrom>`;\n }\n if (\"movedTo\" in child) {\n const { id, author, date, children } = child.movedTo;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:moveTo w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:moveTo>`;\n }\n\n // ── Custom XML range markers (track changes) ──\n if (\"customXmlInsRangeStart\" in child) {\n const o = child.customXmlInsRangeStart;\n return `<w:customXmlInsRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlInsRangeEnd\" in child)\n return `<w:customXmlInsRangeEnd w:id=\"${child.customXmlInsRangeEnd}\"/>`;\n if (\"customXmlDelRangeStart\" in child) {\n const o = child.customXmlDelRangeStart;\n return `<w:customXmlDelRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlDelRangeEnd\" in child)\n return `<w:customXmlDelRangeEnd w:id=\"${child.customXmlDelRangeEnd}\"/>`;\n if (\"customXmlMoveFromRangeStart\" in child) {\n const o = child.customXmlMoveFromRangeStart;\n return `<w:customXmlMoveFromRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveFromRangeEnd\" in child)\n return `<w:customXmlMoveFromRangeEnd w:id=\"${child.customXmlMoveFromRangeEnd}\"/>`;\n if (\"customXmlMoveToRangeStart\" in child) {\n const o = child.customXmlMoveToRangeStart;\n return `<w:customXmlMoveToRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveToRangeEnd\" in child)\n return `<w:customXmlMoveToRangeEnd w:id=\"${child.customXmlMoveToRangeEnd}\"/>`;\n\n // ── Simple field ──\n if (\"simpleField\" in child) {\n const sf = child.simpleField;\n const sfAttrs = [`w:instr=\"${escapeXml(sf.instruction)}\"`];\n if (sf.fldLock !== undefined) sfAttrs.push(`w:fldLock=\"${sf.fldLock ? 1 : 0}\"`);\n if (sf.dirty !== undefined) sfAttrs.push(`w:dirty=\"${sf.dirty ? 1 : 0}\"`);\n if (sf.cachedValue !== undefined) {\n return `<w:fldSimple ${sfAttrs.join(\" \")}><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;\n }\n return `<w:fldSimple ${sfAttrs.join(\" \")}/>`;\n }\n\n // ── Complex field (PAGE/DATE/TOC/... — fldChar field without w:ffData) ──\n if (\"complexField\" in child) {\n const cf = child.complexField;\n // Run-properties: Word writes identical rPr across a field's runs. Apply\n // the captured control-run rPr to begin/instrText/separate/end and the\n // result-run rPr to the result (defaults to the control rPr when the\n // result had none, matching Word's uniform behavior).\n const ctrl = cf.rPrXml ?? \"\";\n const res = cf.resultRPrXml ?? ctrl;\n // `separate` + the result run are emitted only when there is a cached\n // result; a result-less field round-trips as begin/instrText/end.\n const resultXml =\n cf.result !== undefined\n ? `<w:r>${ctrl}<w:fldChar w:fldCharType=\"separate\"/></w:r>` +\n `<w:r>${res}<w:t xml:space=\"preserve\">${escapeXml(cf.result)}</w:t></w:r>`\n : \"\";\n return (\n `<w:r>${ctrl}<w:fldChar w:fldCharType=\"begin\"/></w:r>` +\n `<w:r>${ctrl}<w:instrText xml:space=\"preserve\">${escapeXml(\n cf.instruction,\n )}</w:instrText></w:r>` +\n resultXml +\n `<w:r>${ctrl}<w:fldChar w:fldCharType=\"end\"/></w:r>`\n );\n }\n\n // ── Sequential identifier (SEQ field) ──\n if (\"seqIdentifier\" in child) {\n const id = child.seqIdentifier;\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\"> SEQ ${escapeXml(id)} </w:instrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Page reference (PAGEREF field) ──\n if (\"pageReference\" in child) {\n const pr = child.pageReference;\n let instr = ` PAGEREF ${escapeXml(pr.bookmarkId)} `;\n if (pr.hyperlink) instr += \"\\\\h \";\n if (pr.useRelativePosition) instr += \"\\\\p \";\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\">${instr}</w:instrText>` +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Bidirectional text containers ──\n if (\"dir\" in child) {\n const d = child.dir;\n const childXml = serializeDirChildren(d.children, ctx);\n return `<w:dir w:val=\"${d.val}\">${childXml}</w:dir>`;\n }\n if (\"bdo\" in child) {\n const b = child.bdo;\n const childXml = serializeDirChildren(b.children, ctx);\n return `<w:bdo w:val=\"${b.val}\">${childXml}</w:bdo>`;\n }\n\n // ── Smart tag ──\n if (\"smartTag\" in child) {\n const st = child.smartTag;\n const attrs: string[] = [];\n if (st.uri) attrs.push(`w:uri=\"${escapeXml(st.uri)}\"`);\n attrs.push(`w:element=\"${escapeXml(st.element)}\"`);\n\n const parts: string[] = [];\n if (st.properties?.length) {\n const propParts: string[] = [];\n for (const p of st.properties) {\n const pa: string[] = [];\n if (p.uri) pa.push(`w:uri=\"${escapeXml(p.uri)}\"`);\n pa.push(`w:name=\"${escapeXml(p.name)}\"`, `w:val=\"${escapeXml(p.val)}\"`);\n propParts.push(`<w:attr ${pa.join(\" \")}/>`);\n }\n parts.push(`<w:smartTagPr>${propParts.join(\"\")}</w:smartTagPr>`);\n }\n if (st.children) {\n for (const c of st.children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c, ctx);\n parts.push(\n jr !== undefined\n ? Array.isArray(jr)\n ? jr.join(\"\")\n : jr\n : stringifyRunInline(c as RunOptions, ctx),\n );\n }\n }\n }\n return `<w:smartTag ${attrs.join(\" \")}>${parts.join(\"\")}</w:smartTag>`;\n }\n\n // ── Custom XML run (CT_CustomXmlRun) ──\n if (\"customXml\" in child) {\n const cx = child.customXml;\n const contentParts: string[] = [];\n if (cx.children) {\n for (const c of cx.children) {\n if (typeof c === \"string\") {\n contentParts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c as ParagraphChild, ctx);\n if (jr !== undefined) {\n contentParts.push(Array.isArray(jr) ? jr.join(\"\") : jr);\n } else {\n contentParts.push(stringifyRunInline(c as RunOptions, ctx));\n }\n }\n }\n }\n return stringifyCustomXmlShell(cx, contentParts.join(\"\"));\n }\n\n // ── Inline structured document tag (CT_SdtRun) ──\n if (\"sdt\" in child) {\n const s = child.sdt;\n let contentXml = \"\";\n if (s.properties.checkbox) {\n // Inline checkbox: render the state symbol as a run (no <w:p> wrapper).\n contentXml = checkboxSymbolRunInner(s.properties.checkbox);\n } else if (s.children && s.children.length > 0) {\n const cparts: string[] = [];\n for (const c of s.children) {\n if (typeof c === \"string\") {\n cparts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c as ParagraphChild, ctx);\n if (jr !== undefined) {\n cparts.push(Array.isArray(jr) ? jr.join(\"\") : jr);\n } else if (\"text\" in c || \"children\" in c || \"break\" in c) {\n cparts.push(stringifyRunInline(c as RunOptions, ctx));\n }\n }\n }\n contentXml = cparts.join(\"\");\n }\n return stringifySdtShell(s.properties, s.endProperties, contentXml);\n }\n\n return undefined;\n}\n\n/** Serialize children of Dir/Bdo containers. */\nfunction serializeDirChildren(\n children: (ParagraphChild | string)[] | undefined,\n ctx: BodyContext,\n): string {\n if (!children) return \"\";\n const parts: string[] = [];\n for (const c of children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c, ctx);\n parts.push(\n jr !== undefined\n ? Array.isArray(jr)\n ? jr.join(\"\")\n : jr\n : stringifyRunInline(c as RunOptions, ctx),\n );\n }\n }\n return parts.join(\"\");\n}\n\n/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */\nfunction hashSmartArtData(options: SmartArtOptions): number {\n const data = JSON.stringify(options.data);\n let hash = 0;\n for (let i = 0; i < data.length; i++) {\n const char = data.charCodeAt(i);\n hash = ((hash << 5) - hash + char) | 0;\n }\n return Math.abs(hash);\n}\n\n// ── Paragraph ──\n\nexport function stringifyParagraphInline(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n const props = stringifyParagraphProperties(resolved);\n if (props.xml) parts.push(props.xml);\n\n // Register numbering references from inline paragraphs (footnotes, endnotes, etc.)\n // so that concrete numbering instances are created and placeholders get resolved.\n if (props.numberingReferences.length > 0) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n if (resolved.text !== undefined) {\n parts.push(stringifyRunInline({ text: resolved.text }, ctx));\n }\n\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRunInline({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, hyperlink, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n return body ? `<w:p>${body}</w:p>` : \"<w:p/>\";\n}\n","/**\n * Direct XML string builders for table properties.\n *\n * Replaces `buildTableProperties() + xml()`, `buildTableRowProperties() + xml()`,\n * `buildTableCellProperties() + xml()`, and `new TablePropertyExceptions().toXml()`\n * with direct string concatenation — zero IXmlableObject allocation.\n *\n * @module\n */\n\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport {\n measurementOrPercentValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n} from \"@office-open/core\";\nimport type { AlignmentType } from \"@parts/paragraph\";\nimport type { TableCellSpacingProperties } from \"@parts/table/table-cell-spacing\";\nimport type {\n TableCellBordersOptions,\n TextDirection,\n} from \"@parts/table/table-cell/table-cell-components\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableCellMarginOptions } from \"@parts/table/table-properties/table-cell-margin\";\nimport type { TableFloatOptions } from \"@parts/table/table-properties/table-float-properties\";\nimport type { TableLayoutType } from \"@parts/table/table-properties/table-layout\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type { TablePropertyExOptions } from \"@parts/table/table-properties/table-property-exceptions\";\nimport type {\n CnfStyleOptions,\n TableRowPropertiesOptionsBase,\n} from \"@parts/table/table-row/table-row-properties\";\nimport type { TableWidthProperties } from \"@parts/table/table-width\";\nimport { WidthType } from \"@parts/table/table-width\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\nimport type { CellMergeAttributes } from \"@shared/track-revision\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\nimport type { TableVerticalAlign } from \"@shared/vertical-align\";\n\nimport { attrParts, borderStr, onOff, shadingStr } from \"../paragraph/stringify\";\n\n// ── Table width string ──\n\nfunction tableWidthStr(name: string, opts: TableWidthProperties): string {\n const type = opts.type ?? WidthType.AUTO;\n let w = opts.size;\n if (type === WidthType.PERCENTAGE && typeof w === \"number\") {\n w = `${w}%`;\n }\n const a = attrParts({\n \"w:w\": w !== undefined ? measurementOrPercentValue(w) : undefined,\n \"w:type\": type,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Cell margin string ──\n\nfunction cellMarginChildrenStr(opts: TableCellMarginOptions): string {\n // CT_TblCellMar sequence order: top, start, left, bottom, end, right.\n // Each side is an independent CT_TblWidth; margins default to DXA.\n const parts: string[] = [];\n const side = (name: string, w: TableWidthProperties | undefined): void => {\n if (w === undefined) return;\n parts.push(tableWidthStr(name, { size: w.size, type: w.type ?? WidthType.DXA }));\n };\n side(\"w:top\", opts.top);\n side(\"w:start\", opts.start);\n side(\"w:left\", opts.left);\n side(\"w:bottom\", opts.bottom);\n side(\"w:end\", opts.end);\n side(\"w:right\", opts.right);\n return parts.join(\"\");\n}\n\nfunction cellMarginStr(tag: string, opts: TableCellMarginOptions): string | undefined {\n const inner = cellMarginChildrenStr(opts);\n return inner ? `<${tag}>${inner}</${tag}>` : undefined;\n}\n\n// ── Table borders string ──\n\n// CT_TblBorders — all 6 sides are optional (minOccurs=0); emit only those set.\nfunction tableBordersStr(opts: TableBordersOptions): string | undefined {\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.insideHorizontal) parts.push(borderStr(\"w:insideH\", opts.insideHorizontal));\n if (opts.insideVertical) parts.push(borderStr(\"w:insideV\", opts.insideVertical));\n return parts.length > 0 ? `<w:tblBorders>${parts.join(\"\")}</w:tblBorders>` : undefined;\n}\n\n// ── Cell borders string ──\n\nfunction cellBordersStr(opts: TableCellBordersOptions): string | undefined {\n // CT_TcBorders sequence: top, start, left, bottom, end, right, insideH, insideV, tl2br, tr2bl.\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.start) parts.push(borderStr(\"w:start\", opts.start));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.end) parts.push(borderStr(\"w:end\", opts.end));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.insideHorizontal) parts.push(borderStr(\"w:insideH\", opts.insideHorizontal));\n if (opts.insideVertical) parts.push(borderStr(\"w:insideV\", opts.insideVertical));\n if (opts.topLeftToBottomRight) parts.push(borderStr(\"w:tl2br\", opts.topLeftToBottomRight));\n if (opts.topRightToBottomLeft) parts.push(borderStr(\"w:tr2bl\", opts.topRightToBottomLeft));\n return parts.length > 0 ? `<w:tcBorders>${parts.join(\"\")}</w:tcBorders>` : undefined;\n}\n\n// ── Float properties string ──\n\nfunction floatPropertiesStr(opts: TableFloatOptions): string {\n const a = attrParts({\n \"w:horzAnchor\": opts.horizontalAnchor,\n \"w:vertAnchor\": opts.verticalAnchor,\n \"w:tblpX\":\n opts.absoluteHorizontalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteHorizontalPosition)\n : undefined,\n \"w:tblpXSpec\": opts.relativeHorizontalPosition,\n \"w:tblpY\":\n opts.absoluteVerticalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteVerticalPosition)\n : undefined,\n \"w:tblpYSpec\": opts.relativeVerticalPosition,\n \"w:bottomFromText\":\n opts.bottomFromText !== undefined ? twipsMeasureValue(opts.bottomFromText) : undefined,\n \"w:topFromText\":\n opts.topFromText !== undefined ? twipsMeasureValue(opts.topFromText) : undefined,\n \"w:leftFromText\":\n opts.leftFromText !== undefined ? twipsMeasureValue(opts.leftFromText) : undefined,\n \"w:rightFromText\":\n opts.rightFromText !== undefined ? twipsMeasureValue(opts.rightFromText) : undefined,\n });\n return `<w:tblpPr ${a}/>`;\n}\n\n// ── Table look string ──\n\nfunction tableLookStr(opts: TableLookOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow,\n \"w:lastRow\": opts.lastRow,\n \"w:firstColumn\": opts.firstColumn,\n \"w:lastColumn\": opts.lastColumn,\n \"w:noHBand\": opts.noHBand,\n \"w:noVBand\": opts.noVBand,\n });\n return `<w:tblLook ${a}/>`;\n}\n\n// ── Conditional format style string (CT_Cnf) ──\n\nfunction cnfStyleStr(opts: CnfStyleOptions): string {\n const a = attrParts({\n \"w:val\": opts.val,\n \"w:firstRow\": opts.firstRow,\n \"w:lastRow\": opts.lastRow,\n \"w:firstColumn\": opts.firstColumn,\n \"w:lastColumn\": opts.lastColumn,\n \"w:oddVBand\": opts.oddVBand,\n \"w:evenVBand\": opts.evenVBand,\n \"w:oddHBand\": opts.oddHBand,\n \"w:evenHBand\": opts.evenHBand,\n \"w:firstRowFirstColumn\": opts.firstRowFirstColumn,\n \"w:firstRowLastColumn\": opts.firstRowLastColumn,\n \"w:lastRowFirstColumn\": opts.lastRowFirstColumn,\n \"w:lastRowLastColumn\": opts.lastRowLastColumn,\n });\n return `<w:cnfStyle ${a}/>`;\n}\n\n// ── Change/revision attribute string ──\n\nfunction changeAttrStr(tag: string, opts: ChangedAttributesProperties): string {\n const a = attrParts({ \"w:author\": opts.author, \"w:date\": opts.date, \"w:id\": opts.id });\n return `<${tag} ${a}/>`;\n}\n\n// ── Cell merge revision string ──\n\nfunction cellMergeStr(opts: CellMergeAttributes): string {\n const attrs: Record<string, string | number | boolean | undefined> = {\n \"w:author\": opts.author,\n \"w:date\": opts.date,\n \"w:id\": opts.id,\n };\n if (opts.verticalMerge !== undefined) {\n attrs[\"w:vMerge\"] = xsdVerticalMergeRev.to(opts.verticalMerge);\n }\n if (opts.verticalMergeOriginal !== undefined) {\n attrs[\"w:vMergeOrig\"] = xsdVerticalMergeRev.to(opts.verticalMergeOriginal);\n }\n const a = attrParts(attrs);\n return `<w:cellMerge ${a}/>`;\n}\n\n// ── Cell spacing string ──\n\nfunction cellSpacingStr(opts: TableCellSpacingProperties): string {\n const a = attrParts({\n \"w:type\": opts.type,\n \"w:w\": measurementOrPercentValue(opts.size),\n });\n return `<w:tblCellSpacing ${a}/>`;\n}\n\n// ── Table properties types ──\n\nexport interface TablePropertiesOptionsBase {\n width?: TableWidthProperties;\n indent?: TableWidthProperties;\n layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];\n borders?: TableBordersOptions;\n float?: TableFloatOptions;\n shading?: ShadingAttributesProperties;\n style?: string;\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n cellMargin?: TableCellMarginOptions;\n visuallyRightToLeft?: boolean;\n tableLook?: TableLookOptions;\n cellSpacing?: TableCellSpacingProperties;\n styleRowBandSize?: number;\n styleColBandSize?: number;\n caption?: string;\n description?: string;\n}\n\nexport type TablePropertiesChangeOptions = TablePropertiesOptions & ChangedAttributesProperties;\n\nexport type TablePropertiesOptions = {\n revision?: TablePropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TablePropertiesOptionsBase;\n\n// ── Table properties change (w:tblPrChange) ──\n\nfunction stringifyTablePropertiesChangeInner(options: TablePropertiesChangeOptions): string {\n const inner = stringifyTablePropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tblPrChange ${a}><w:tblPr>${inner}</w:tblPr></w:tblPrChange>`;\n}\n\n// ── Table properties (w:tblPr) ──\n\nfunction stringifyTablePropertiesInner(options: TablePropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.style) {\n parts.push(`<w:tblStyle w:val=\"${options.style}\"/>`);\n }\n\n if (options.float) {\n parts.push(floatPropertiesStr(options.float));\n if (options.float.overlap) {\n parts.push(`<w:tblOverlap w:val=\"${options.float.overlap}\"/>`);\n }\n }\n\n if (options.visuallyRightToLeft !== undefined) {\n parts.push(onOff(\"w:bidiVisual\", options.visuallyRightToLeft));\n }\n\n if (options.styleRowBandSize !== undefined) {\n parts.push(`<w:tblStyleRowBandSize w:val=\"${options.styleRowBandSize}\"/>`);\n }\n\n if (options.styleColBandSize !== undefined) {\n parts.push(`<w:tblStyleColBandSize w:val=\"${options.styleColBandSize}\"/>`);\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.caption !== undefined) {\n parts.push(`<w:tblCaption w:val=\"${options.caption}\"/>`);\n }\n\n if (options.description !== undefined) {\n parts.push(`<w:tblDescription w:val=\"${options.description}\"/>`);\n }\n\n if (options.revision) {\n parts.push(stringifyTablePropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableProperties(options: TablePropertiesOptions): string | undefined {\n const inner = stringifyTablePropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tblPr>${inner}</w:tblPr>`;\n }\n return undefined;\n}\n\n// ── Row properties types ──\n\nexport type TableRowPropertiesChangeOptions = TableRowPropertiesOptionsBase &\n ChangedAttributesProperties;\n\nexport type TableRowPropertiesOptions = TableRowPropertiesOptionsBase & {\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n revision?: TableRowPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n};\n\n// ── Row properties change (w:trPrChange) ──\n\nfunction stringifyTableRowPropertiesChangeInner(options: TableRowPropertiesChangeOptions): string {\n const inner = stringifyTableRowPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:trPrChange ${a}><w:trPr>${inner}</w:trPr></w:trPrChange>`;\n}\n\n// ── Row properties (w:trPr) ──\n\nfunction stringifyTableRowPropertiesInner(options: TableRowPropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n parts.push(cnfStyleStr(options.cnfStyle));\n }\n\n if (options.divId !== undefined) {\n parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n }\n\n if (options.gridBefore !== undefined) {\n parts.push(`<w:gridBefore w:val=\"${options.gridBefore}\"/>`);\n }\n\n if (options.gridAfter !== undefined) {\n parts.push(`<w:gridAfter w:val=\"${options.gridAfter}\"/>`);\n }\n\n if (options.widthBefore) {\n parts.push(tableWidthStr(\"w:wBefore\", options.widthBefore));\n }\n\n if (options.widthAfter) {\n parts.push(tableWidthStr(\"w:wAfter\", options.widthAfter));\n }\n\n if (options.cantSplit !== undefined) {\n parts.push(onOff(\"w:cantSplit\", options.cantSplit));\n }\n\n if (options.tableHeader !== undefined) {\n parts.push(onOff(\"w:tblHeader\", options.tableHeader));\n }\n\n if (options.height) {\n const a = attrParts({\n \"w:val\": twipsMeasureValue(options.height.value),\n \"w:hRule\": options.height.rule,\n });\n parts.push(`<w:trHeight ${a}/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.rowAlignment) {\n parts.push(`<w:jc w:val=\"${options.rowAlignment}\"/>`);\n }\n\n if (options.hidden !== undefined) {\n parts.push(onOff(\"w:hidden\", options.hidden));\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:ins\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:del\", options.deletion));\n }\n\n if (options.revision) {\n parts.push(stringifyTableRowPropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableRowProperties(\n options: TableRowPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableRowPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:trPr>${inner}</w:trPr>`;\n }\n return undefined;\n}\n\n// ── Cell properties types ──\n\nexport interface TableCellPropertiesOptionsBase {\n cnfStyle?: CnfStyleOptions;\n shading?: ShadingAttributesProperties;\n margins?: TableCellMarginOptions;\n verticalAlign?: TableVerticalAlign;\n textDirection?: (typeof TextDirection)[keyof typeof TextDirection];\n verticalMerge?: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];\n width?: TableWidthProperties;\n columnSpan?: number;\n rowSpan?: number;\n borders?: TableCellBordersOptions;\n horizontalMerge?: \"continue\" | \"restart\";\n noWrap?: boolean;\n fitText?: boolean;\n hideMark?: boolean;\n headers?: string[];\n insertion?: ChangedAttributesProperties;\n deletion?: ChangedAttributesProperties;\n cellMerge?: CellMergeAttributes;\n}\n\nexport type TableCellPropertiesChangeOptions = TableCellPropertiesOptionsBase &\n ChangedAttributesProperties;\n\nexport type TableCellPropertiesOptions = {\n revision?: TableCellPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TableCellPropertiesOptionsBase;\n\n// ── Cell properties change (w:tcPrChange) ──\n\nfunction stringifyTableCellPropertiesChangeInner(\n options: TableCellPropertiesChangeOptions,\n): string {\n const inner = stringifyTableCellPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tcPrChange ${a}><w:tcPr>${inner}</w:tcPr></w:tcPrChange>`;\n}\n\n// ── Cell properties (w:tcPr) ──\n\nfunction stringifyTableCellPropertiesInner(options: TableCellPropertiesOptions): string {\n // CT_TcPrBase sequence: cnfStyle, tcW, gridSpan, hMerge, vMerge, tcBorders, shd,\n // noWrap, tcMar, textDirection, tcFitText, vAlign, hideMark, headers;\n // then EG_CellMarkupElements (cellIns/cellDel/cellMerge), then tcPrChange.\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n parts.push(cnfStyleStr(options.cnfStyle));\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tcW\", options.width));\n }\n\n if (options.columnSpan) {\n parts.push(`<w:gridSpan w:val=\"${options.columnSpan}\"/>`);\n }\n\n if (options.horizontalMerge !== undefined) {\n if (options.horizontalMerge === \"restart\") {\n parts.push(`<w:hMerge w:val=\"restart\"/>`);\n } else {\n parts.push(`<w:hMerge/>`);\n }\n }\n\n if (options.verticalMerge) {\n parts.push(`<w:vMerge w:val=\"${options.verticalMerge}\"/>`);\n } else if (options.rowSpan && options.rowSpan > 1) {\n parts.push(`<w:vMerge w:val=\"${VerticalMergeType.RESTART}\"/>`);\n }\n\n if (options.borders) {\n const bs = cellBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.noWrap !== undefined) {\n parts.push(onOff(\"w:noWrap\", options.noWrap));\n }\n\n if (options.margins) {\n const cm = cellMarginStr(\"w:tcMar\", options.margins);\n if (cm) parts.push(cm);\n }\n\n if (options.textDirection) {\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n }\n\n if (options.fitText !== undefined) {\n parts.push(onOff(\"w:tcFitText\", options.fitText));\n }\n\n if (options.verticalAlign) {\n parts.push(`<w:vAlign w:val=\"${options.verticalAlign}\"/>`);\n }\n\n if (options.hideMark !== undefined) {\n parts.push(onOff(\"w:hideMark\", options.hideMark));\n }\n\n if (options.headers !== undefined) {\n const headerParts = options.headers.map((h) => `<w:header w:val=\"${h}\"/>`).join(\"\");\n parts.push(`<w:headers>${headerParts}</w:headers>`);\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:cellIns\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:cellDel\", options.deletion));\n }\n\n if (options.cellMerge) {\n parts.push(cellMergeStr(options.cellMerge));\n }\n\n if (options.revision) {\n parts.push(stringifyTableCellPropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableCellProperties(\n options: TableCellPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableCellPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tcPr>${inner}</w:tcPr>`;\n }\n return undefined;\n}\n\n// ── Table property exceptions (w:tblPrEx) ──\n\nfunction stringifyTablePropertyExceptionsInner(options: TablePropertyExOptions): string {\n const parts: string[] = [];\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.tblPrExChange) {\n const change = options.tblPrExChange;\n const a = attrParts({ \"w:author\": change.author, \"w:date\": change.date, \"w:id\": change.id });\n // CT_TblPrExChange requires a tblPrEx child holding the previous (pre-change) values.\n const revInner = stringifyTablePropertyExceptionsInner(change);\n parts.push(`<w:tblPrExChange ${a}><w:tblPrEx>${revInner}</w:tblPrEx></w:tblPrExChange>`);\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTablePropertyExceptions(options: TablePropertyExOptions): string {\n return `<w:tblPrEx>${stringifyTablePropertyExceptionsInner(options)}</w:tblPrEx>`;\n}\n","/**\n * Table (w:tbl) descriptor for DOCX.\n *\n * Stringifies pure JSON TableOptions into XML using direct string\n * concatenation — zero IXmlableObject, zero xml(), zero BaseXmlComponent.\n *\n * @module\n */\n\nimport { ThemeColor } from \"@office-open/core\";\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, children, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport {\n parseCustomXmlProperties,\n stringifyCustomXmlShell,\n stringifySdtShell,\n} from \"@parts/bodychildren\";\nimport type { CustomXmlCellOptions, CustomXmlRowOptions } from \"@parts/custom-xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport { parseSdtProperties } from \"@parts/sdt/sdt-parse\";\nimport type { TableGridChangeOptions } from \"@parts/table/grid\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport type { TableCellSpacingProperties } from \"@parts/table/table-cell-spacing\";\nimport type { SdtCellOptions, TableCellOptions } from \"@parts/table/table-cell/table-cell\";\nimport type { TableCellBordersOptions } from \"@parts/table/table-cell/table-cell-components\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableCellMarginOptions } from \"@parts/table/table-properties/table-cell-margin\";\nimport type { TableFloatOptions } from \"@parts/table/table-properties/table-float-properties\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type {\n TablePropertyExChangeOptions,\n TablePropertyExOptions,\n} from \"@parts/table/table-properties/table-property-exceptions\";\nimport type { SdtRowOptions, TableRowOptions } from \"@parts/table/table-row/table-row\";\nimport type { CnfStyleOptions } from \"@parts/table/table-row/table-row-properties\";\nimport type { TableWidthProperties } from \"@parts/table/table-width\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { BorderOptions } from \"@shared/border\";\nimport type { SectionChild } from \"@shared/section\";\nimport type { ShadingAttributesProperties } from \"@shared/shading\";\nimport type { CellMergeAttributes } from \"@shared/track-revision\";\nimport type { ChangedAttributesProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTablePropertyExceptions,\n stringifyTableRowProperties,\n type TableCellPropertiesChangeOptions,\n type TableCellPropertiesOptions,\n type TablePropertiesChangeOptions,\n type TablePropertiesOptions,\n type TableRowPropertiesChangeOptions,\n type TableRowPropertiesOptions,\n} from \"./stringify\";\n\n// Valid border @w:val (ST_Border / BorderStyle) and @w:themeColor (ST_ThemeColor) values.\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/** Parse track-change attributes (id/author/date) from w:ins/w:del/w:cellIns/w:cellDel. */\nfunction parseChangeAttrs(el: Element): Partial<ChangedAttributesProperties> {\n const change: Partial<ChangedAttributesProperties> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) change.id = id;\n const author = attr(el, \"w:author\");\n if (author) change.author = author;\n const date = attr(el, \"w:date\");\n if (date) change.date = date;\n return change;\n}\n\n// ── Table grid ──\n\nfunction buildTableGridXml(\n widths: Array<number | string>,\n revision?: TableGridChangeOptions,\n): string {\n const cols = widths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n\n if (revision) {\n const revCols = revision.columnWidths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n return `<w:tblGrid>${cols}<w:tblGridChange w:id=\"${revision.id}\"><w:tblGrid>${revCols}</w:tblGrid></w:tblGridChange></w:tblGrid>`;\n }\n\n return `<w:tblGrid>${cols}</w:tblGrid>`;\n}\n\n// ── Cell span extraction ──\n\n/** Extract column/row span from a plain-object cell. */\nfunction getCellSpans(cell: TableCellOptions): {\n columnSpan: number;\n rowSpan: number;\n} {\n return { columnSpan: cell.columnSpan ?? 1, rowSpan: cell.rowSpan ?? 1 };\n}\n\n// ── Cell children stringification ──\n\n/**\n * Stringify a cell child (SectionChild) inline.\n * Handles strings and plain objects (paragraph/table).\n */\nfunction stringifyCellChild(child: SectionChild, ctx: BodyContext): string {\n if (typeof child === \"string\") {\n return stringifyParagraphInline(child, ctx);\n }\n\n // Plain object dispatch\n if (\"paragraph\" in child) {\n return stringifyParagraphInline(child.paragraph, ctx);\n }\n if (\"table\" in child) {\n // Recursive: nested table via descriptor\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n\n // Fallback for other types — should not happen inside table cells\n return \"\";\n}\n\n// ── Cell stringification ──\n\nfunction stringifyTableCell(cell: TableCellOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const tcPr = stringifyTableCellProperties(cell);\n if (tcPr) parts.push(tcPr);\n\n const children = cell.children as SectionChild[] | undefined;\n if (children) {\n for (const child of children) {\n parts.push(stringifyCellChild(child, ctx));\n }\n }\n\n // Cells must end with a paragraph unless the last child is already one\n const last = children?.[children.length - 1];\n const endsWithParagraph =\n last && typeof last !== \"string\" && (\"paragraph\" in last || \"table\" in last);\n if (!endsWithParagraph) {\n parts.push(\"<w:p/>\");\n }\n\n return `<w:tc>${parts.join(\"\")}</w:tc>`;\n}\n\n// ── Row stringification ──\n\nfunction stringifyTableRow(\n row: TableRowOptions,\n ctx: BodyContext,\n extraCells?: { cell: TableCellOptions; columnIndex: number }[],\n): string {\n const parts: string[] = [];\n\n // Property exceptions (tblPrEx)\n if (row.propertyExceptions) {\n parts.push(stringifyTablePropertyExceptions(row.propertyExceptions));\n }\n\n // Row properties\n const trPr = stringifyTableRowProperties(row);\n if (trPr) parts.push(trPr);\n\n const prefixCount = parts.length;\n\n // Cells (a cell may be wrapped by a cell-level SDT or customXml)\n for (const cell of row.cells) {\n if (\"sdt\" in cell) {\n const s = cell.sdt;\n const contentXml = (s.cells ?? []).map((c) => stringifyTableCell(c, ctx)).join(\"\");\n parts.push(stringifySdtShell(s.properties, s.endProperties, contentXml));\n } else if (\"customXml\" in cell) {\n const cx = cell.customXml;\n const contentXml = (cx.children ?? []).map((c) => stringifyTableCell(c, ctx)).join(\"\");\n parts.push(stringifyCustomXmlShell(cx, contentXml));\n } else {\n parts.push(stringifyTableCell(cell, ctx));\n }\n }\n\n // Insert extra CONTINUE cells at correct positions\n if (extraCells && extraCells.length > 0) {\n for (const { cell, columnIndex } of extraCells) {\n const insertIdx = findInsertIndex(row.cells, columnIndex, prefixCount);\n parts.splice(insertIdx, 0, stringifyTableCell(cell, ctx));\n }\n }\n\n // rsid attributes\n const rsidAttrs: string[] = [];\n if (row.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${row.runPropertiesRsid}\"`);\n if (row.rsid) rsidAttrs.push(` w:rsidR=\"${row.rsid}\"`);\n if (row.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${row.deletionRsid}\"`);\n if (row.tableRowRsid) rsidAttrs.push(` w:rsidTr=\"${row.tableRowRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body ? `<w:tr${attr}>${body}</w:tr>` : attr ? `<w:tr${attr}/>` : \"<w:tr/>\";\n}\n\n// ── Row options type ──\n\n/** Type guard: a plain row (not SDT/customXml-wrapped). */\nfunction isPlainRow(\n r: TableRowOptions | { sdt: SdtRowOptions } | { customXml: CustomXmlRowOptions },\n): r is TableRowOptions {\n return !(\"sdt\" in r) && !(\"customXml\" in r);\n}\n\n/** Type guard: a plain cell (not SDT/customXml-wrapped). */\nfunction isPlainCell(\n c: TableCellOptions | { sdt: SdtCellOptions } | { customXml: CustomXmlCellOptions },\n): c is TableCellOptions {\n return !(\"sdt\" in c) && !(\"customXml\" in c);\n}\n\nfunction findInsertIndex(\n cells: TableRowOptions[\"cells\"],\n columnIndex: number,\n prefixCount: number,\n): number {\n let colIdx = 0;\n for (let i = 0; i < cells.length; i++) {\n const c = cells[i];\n if (!isPlainCell(c)) continue; // SDT/customXml-wrapped cells don't occupy grid columns\n const { columnSpan } = getCellSpans(c);\n colIdx += columnSpan;\n if (colIdx > columnIndex) {\n return i + prefixCount;\n }\n }\n return cells.length + prefixCount;\n}\n\n// ── Vertical merge ──\n\n/**\n * Pre-process rows to compute CONTINUE cells for vertical merge.\n */\nfunction computeVerticalMergeCells(\n rows: TableOptions[\"rows\"],\n): Map<number, { cell: TableCellOptions; columnIndex: number }[]> {\n const extraMap = new Map<number, { cell: TableCellOptions; columnIndex: number }[]>();\n for (let ri = 0; ri < rows.length - 1; ri++) {\n const row = rows[ri];\n if (!isPlainRow(row)) continue; // SDT/customXml-wrapped rows don't participate in merge\n const cells = row.cells;\n let colIdx = 0;\n\n for (const cell of cells) {\n if (!isPlainCell(cell)) continue; // SDT/customXml-wrapped cells don't participate in merge\n const typedCell = cell;\n const { columnSpan, rowSpan } = getCellSpans(typedCell);\n\n if (rowSpan > 1) {\n const continueCell: TableCellOptions = {\n borders: typedCell.borders,\n children: [],\n columnSpan,\n rowSpan: rowSpan - 1,\n verticalMerge: VerticalMergeType.CONTINUE,\n };\n\n if (!extraMap.has(ri + 1)) {\n extraMap.set(ri + 1, []);\n }\n extraMap.get(ri + 1)!.push({ cell: continueCell, columnIndex: colIdx });\n }\n\n colIdx += columnSpan;\n }\n }\n\n return extraMap;\n}\n\n/** Parse a w:tblCellMar / w:tcMar container into TableCellMarginOptions. */\nfunction parseCellMargins(marginEl: Element): TableCellMarginOptions | undefined {\n const margins: TableCellMarginOptions = {};\n // CT_TblCellMar sides: top, start, left, bottom, end, right — each an\n // independent CT_TblWidth ({ size, type }). Parse faithfully: omit type\n // when the XML has none (stringify defaults it to DXA on the way back).\n for (const side of [\"top\", \"start\", \"left\", \"bottom\", \"end\", \"right\"] as const) {\n const sideEl = findChild(marginEl, `w:${side}`);\n if (sideEl) {\n const type = attr(sideEl, \"w:type\");\n const size = attrMeasure(sideEl, \"w:w\", type);\n if (size !== undefined) {\n margins[side] = (\n type ? { size, type: type as TableWidthProperties[\"type\"] } : { size }\n ) as TableWidthProperties;\n }\n }\n }\n if (Object.keys(margins).length === 0) return undefined;\n return margins as TableCellMarginOptions;\n}\n\n/** Parse a w:shd (CT_Shd) element into ShadingAttributesProperties. */\nfunction parseShading(shd: Element): ShadingAttributesProperties | undefined {\n const shading: ShadingAttributesProperties = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shading.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shading.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shading.type = val as ShadingAttributesProperties[\"type\"];\n const themeColor = attr(shd, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n shading.themeColor = themeColor as ShadingAttributesProperties[\"themeColor\"];\n }\n const themeTint = attr(shd, \"w:themeTint\");\n if (themeTint) shading.themeTint = themeTint;\n const themeShade = attr(shd, \"w:themeShade\");\n if (themeShade) shading.themeShade = themeShade;\n const themeFill = attr(shd, \"w:themeFill\");\n if (themeFill && THEME_COLORS.includes(themeFill)) {\n shading.themeFill = themeFill as ShadingAttributesProperties[\"themeFill\"];\n }\n const themeFillTint = attr(shd, \"w:themeFillTint\");\n if (themeFillTint) shading.themeFillTint = themeFillTint;\n const themeFillShade = attr(shd, \"w:themeFillShade\");\n if (themeFillShade) shading.themeFillShade = themeFillShade;\n if (Object.keys(shading).length === 0) return undefined;\n return shading as ShadingAttributesProperties;\n}\n\n/** Parse a w:cnfStyle (CT_Cnf) element into CnfStyleOptions. */\nfunction parseCnfStyle(cnfEl: Element): CnfStyleOptions | undefined {\n const cnf: CnfStyleOptions = {};\n const val = attr(cnfEl, \"w:val\");\n if (val) cnf.val = val;\n const firstRow = attrBool(cnfEl, \"w:firstRow\");\n if (firstRow !== undefined) cnf.firstRow = firstRow;\n const lastRow = attrBool(cnfEl, \"w:lastRow\");\n if (lastRow !== undefined) cnf.lastRow = lastRow;\n const firstColumn = attrBool(cnfEl, \"w:firstColumn\");\n if (firstColumn !== undefined) cnf.firstColumn = firstColumn;\n const lastColumn = attrBool(cnfEl, \"w:lastColumn\");\n if (lastColumn !== undefined) cnf.lastColumn = lastColumn;\n const oddVBand = attrBool(cnfEl, \"w:oddVBand\");\n if (oddVBand !== undefined) cnf.oddVBand = oddVBand;\n const evenVBand = attrBool(cnfEl, \"w:evenVBand\");\n if (evenVBand !== undefined) cnf.evenVBand = evenVBand;\n const oddHBand = attrBool(cnfEl, \"w:oddHBand\");\n if (oddHBand !== undefined) cnf.oddHBand = oddHBand;\n const evenHBand = attrBool(cnfEl, \"w:evenHBand\");\n if (evenHBand !== undefined) cnf.evenHBand = evenHBand;\n const firstRowFirstColumn = attrBool(cnfEl, \"w:firstRowFirstColumn\");\n if (firstRowFirstColumn !== undefined) cnf.firstRowFirstColumn = firstRowFirstColumn;\n const firstRowLastColumn = attrBool(cnfEl, \"w:firstRowLastColumn\");\n if (firstRowLastColumn !== undefined) cnf.firstRowLastColumn = firstRowLastColumn;\n const lastRowFirstColumn = attrBool(cnfEl, \"w:lastRowFirstColumn\");\n if (lastRowFirstColumn !== undefined) cnf.lastRowFirstColumn = lastRowFirstColumn;\n const lastRowLastColumn = attrBool(cnfEl, \"w:lastRowLastColumn\");\n if (lastRowLastColumn !== undefined) cnf.lastRowLastColumn = lastRowLastColumn;\n if (Object.keys(cnf).length === 0) return undefined;\n return cnf as CnfStyleOptions;\n}\n\n/**\n * Parse a w:tblPrEx (CT_TblPrEx) element into TablePropertyExOptions.\n * CT_TblPrExBase shares its child elements with CT_TblPrBase, so this reuses\n * parseTablePropertiesEl and maps the table-level margins field to cellMargin.\n */\nfunction parseTablePropertyExceptions(el: Element): TablePropertyExOptions {\n const base = parseTablePropertiesEl(el);\n const opts: TablePropertyExOptions = {};\n if (base.width !== undefined) opts.width = base.width as TableWidthProperties;\n if (base.indent !== undefined) opts.indent = base.indent as TableWidthProperties;\n if (base.layout !== undefined) opts.layout = base.layout as TablePropertyExOptions[\"layout\"];\n if (base.borders !== undefined) opts.borders = base.borders as TableBordersOptions;\n if (base.shading !== undefined) opts.shading = base.shading as ShadingAttributesProperties;\n if (base.alignment !== undefined) {\n opts.alignment = base.alignment as TablePropertyExOptions[\"alignment\"];\n }\n if (base.cellMargin !== undefined) opts.cellMargin = base.cellMargin;\n if (base.tableLook !== undefined) opts.tableLook = base.tableLook as TableLookOptions;\n if (base.cellSpacing !== undefined) {\n opts.cellSpacing = base.cellSpacing as TableCellSpacingProperties;\n }\n const tblPrExChange = findChild(el, \"w:tblPrExChange\");\n if (tblPrExChange) {\n const change = parseTablePropertyExChange(tblPrExChange);\n if (change) opts.tblPrExChange = change;\n }\n return opts as TablePropertyExOptions;\n}\n\n/** Parse a w:tblPrExChange (CT_TblPrExChange) — track-change wrapper around the previous tblPrEx. */\nfunction parseTablePropertyExChange(el: Element): TablePropertyExChangeOptions | undefined {\n const change: Partial<TablePropertyExChangeOptions> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) change.id = id;\n const author = attr(el, \"w:author\");\n if (author) change.author = author;\n const date = attr(el, \"w:date\");\n if (date) change.date = date;\n const innerTblPrEx = findChild(el, \"w:tblPrEx\");\n if (innerTblPrEx) {\n const inner = parseTablePropertyExceptions(innerTblPrEx);\n if (inner.width !== undefined) change.width = inner.width;\n if (inner.indent !== undefined) change.indent = inner.indent;\n if (inner.layout !== undefined) change.layout = inner.layout;\n if (inner.borders !== undefined) change.borders = inner.borders;\n if (inner.shading !== undefined) change.shading = inner.shading;\n if (inner.alignment !== undefined) change.alignment = inner.alignment;\n if (inner.cellMargin !== undefined) change.cellMargin = inner.cellMargin;\n if (inner.tableLook !== undefined) change.tableLook = inner.tableLook;\n if (inner.cellSpacing !== undefined) change.cellSpacing = inner.cellSpacing;\n }\n if (change.id === undefined || change.author === undefined) return undefined;\n return change as TablePropertyExChangeOptions;\n}\n\n// ── Descriptor ──\n\nexport const tableDesc: CustomDescriptor<TableOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Table properties\n // tblPr is required in CT_Tbl (minOccurs defaults to 1) — always emit it,\n // even when empty; do not inject optional defaults (width/borders are XSD-optional).\n const tblPrOpts: TablePropertiesOptions = {\n alignment: opts.alignment,\n borders: opts.borders,\n caption: opts.caption,\n cellMargin: opts.margins,\n cellSpacing: opts.cellSpacing,\n description: opts.description,\n float: opts.float,\n indent: opts.indent,\n layout: opts.layout,\n revision: opts.revision,\n shading: opts.shading,\n style: opts.style,\n styleColBandSize: opts.styleColBandSize,\n styleRowBandSize: opts.styleRowBandSize,\n tableLook: opts.tableLook,\n visuallyRightToLeft: opts.visuallyRightToLeft,\n width: opts.width,\n includeIfEmpty: true,\n };\n parts.push(stringifyTableProperties(tblPrOpts)!);\n\n // Table grid\n const columnWidths =\n opts.columnWidths ??\n Array(Math.max(1, ...opts.rows.map((r) => (isPlainRow(r) ? r.cells.length : 0)))).fill(100);\n parts.push(buildTableGridXml(columnWidths, opts.columnWidthsRevision));\n\n // Compute vertical merge CONTINUE cells\n const extraCells = computeVerticalMergeCells(opts.rows);\n\n // Rows (a row may be wrapped by a row-level SDT)\n for (let ri = 0; ri < opts.rows.length; ri++) {\n const r = opts.rows[ri];\n if (\"sdt\" in r) {\n const sdt = r.sdt;\n const contentXml = (sdt.rows ?? []).map((rr) => stringifyTableRow(rr, ctx)).join(\"\");\n parts.push(stringifySdtShell(sdt.properties, sdt.endProperties, contentXml));\n } else if (\"customXml\" in r) {\n const cx = r.customXml;\n const contentXml = (cx.children ?? []).map((rr) => stringifyTableRow(rr, ctx)).join(\"\");\n parts.push(stringifyCustomXmlShell(cx, contentXml));\n } else {\n const extras = extraCells.get(ri);\n parts.push(stringifyTableRow(r, ctx, extras));\n }\n }\n\n return `<w:tbl>${parts.join(\"\")}</w:tbl>`;\n },\n\n parse(el, ctx) {\n return parseTableEl(el, ctx as DocxReadContext);\n },\n};\n\n// ── Parse (Element → TableOptions) ──\n\ntype ParseChildFn = (el: Element, ctx: DocxReadContext) => SectionChild;\n\n/** Callback used by table parser to parse body children. */\nlet _parseChild: ParseChildFn | undefined;\n\n/** Set the child parser callback (called from parseBody). */\nexport function setTableParseChild(fn: ParseChildFn): void {\n _parseChild = fn;\n}\n\nexport function parseTablePropertiesEl(el: Element): TablePropertiesOptions {\n const opts: TablePropertiesOptions = {};\n\n const style = findChild(el, \"w:tblStyle\");\n if (style) {\n const val = attr(style, \"w:val\");\n if (val) opts.style = val;\n }\n\n const tblW = findChild(el, \"w:tblW\");\n if (tblW) {\n const type = attr(tblW, \"w:type\");\n const size = attrMeasure(tblW, \"w:w\", type);\n if (size !== undefined || type) {\n opts.width = { size: size ?? 0, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.alignment = val as TablePropertiesOptions[\"alignment\"];\n }\n\n const layout = findChild(el, \"w:tblLayout\");\n if (layout) {\n const val = attr(layout, \"w:type\");\n if (val === \"autofit\" || val === \"fixed\") opts.layout = val;\n }\n\n const tblBorders = findChild(el, \"w:tblBorders\");\n if (tblBorders) {\n // XML side names → TableBordersOptions keys (insideH/insideV map to\n // insideHorizontal/insideVertical); all 6 sides are CT_TblBorders-optional.\n const SIDE_KEYS: ReadonlyArray<[string, keyof TableBordersOptions]> = [\n [\"top\", \"top\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"right\", \"right\"],\n [\"insideH\", \"insideHorizontal\"],\n [\"insideV\", \"insideVertical\"],\n ];\n const borders: TableBordersOptions = {};\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tblBorders, `w:${xmlSide}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n borders[key] = sideOpts;\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const tblCellMar = findChild(el, \"w:tblCellMar\");\n if (tblCellMar) {\n const margins = parseCellMargins(tblCellMar);\n if (margins) opts.cellMargin = margins;\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading = parseShading(shd);\n if (shading) opts.shading = shading;\n }\n\n // description → w:tblDescription/@w:val\n const tblDesc = findChild(el, \"w:tblDescription\");\n if (tblDesc) {\n const val = attr(tblDesc, \"w:val\");\n if (val) opts.description = val;\n }\n\n // float → w:tblpPr attributes + w:tblOverlap (sibling element in CT_TblPrBase)\n const tblpPr = findChild(el, \"w:tblpPr\");\n const tblOverlap = findChild(el, \"w:tblOverlap\");\n if (tblpPr || tblOverlap) {\n const floatOpts: Partial<TableFloatOptions> = {};\n if (tblpPr) {\n const horzAnchor = attr(tblpPr, \"w:horzAnchor\");\n if (horzAnchor)\n floatOpts.horizontalAnchor = horzAnchor as TableFloatOptions[\"horizontalAnchor\"];\n const vertAnchor = attr(tblpPr, \"w:vertAnchor\");\n if (vertAnchor) floatOpts.verticalAnchor = vertAnchor as TableFloatOptions[\"verticalAnchor\"];\n const tblpX = attrNum(tblpPr, \"w:tblpX\");\n if (tblpX !== undefined) floatOpts.absoluteHorizontalPosition = tblpX;\n const tblpXSpec = attr(tblpPr, \"w:tblpXSpec\");\n if (tblpXSpec)\n floatOpts.relativeHorizontalPosition =\n tblpXSpec as TableFloatOptions[\"relativeHorizontalPosition\"];\n const tblpY = attrNum(tblpPr, \"w:tblpY\");\n if (tblpY !== undefined) floatOpts.absoluteVerticalPosition = tblpY;\n const tblpYSpec = attr(tblpPr, \"w:tblpYSpec\");\n if (tblpYSpec)\n floatOpts.relativeVerticalPosition =\n tblpYSpec as TableFloatOptions[\"relativeVerticalPosition\"];\n const bottomFromText = attrNum(tblpPr, \"w:bottomFromText\");\n if (bottomFromText !== undefined) floatOpts.bottomFromText = bottomFromText;\n const topFromText = attrNum(tblpPr, \"w:topFromText\");\n if (topFromText !== undefined) floatOpts.topFromText = topFromText;\n const leftFromText = attrNum(tblpPr, \"w:leftFromText\");\n if (leftFromText !== undefined) floatOpts.leftFromText = leftFromText;\n const rightFromText = attrNum(tblpPr, \"w:rightFromText\");\n if (rightFromText !== undefined) floatOpts.rightFromText = rightFromText;\n }\n if (tblOverlap) {\n const overlap = attr(tblOverlap, \"w:val\");\n if (overlap) floatOpts.overlap = overlap as TableFloatOptions[\"overlap\"];\n }\n if (Object.keys(floatOpts).length > 0) opts.float = floatOpts as TableFloatOptions;\n }\n\n // indent → w:tblInd/@w:w and @w:type\n const tblInd = findChild(el, \"w:tblInd\");\n if (tblInd) {\n const type = attr(tblInd, \"w:type\");\n const size = attrMeasure(tblInd, \"w:w\", type);\n if (size !== undefined) {\n opts.indent = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n // visuallyRightToLeft → w:bidiVisual\n const bidiVisual = findChild(el, \"w:bidiVisual\");\n if (bidiVisual) opts.visuallyRightToLeft = attrBool(bidiVisual, \"w:val\") ?? true;\n\n // styleRowBandSize / styleColBandSize\n const tblStyleRowBandSize = findChild(el, \"w:tblStyleRowBandSize\");\n if (tblStyleRowBandSize) {\n const val = attrNum(tblStyleRowBandSize, \"w:val\");\n if (val !== undefined) opts.styleRowBandSize = val;\n }\n const tblStyleColBandSize = findChild(el, \"w:tblStyleColBandSize\");\n if (tblStyleColBandSize) {\n const val = attrNum(tblStyleColBandSize, \"w:val\");\n if (val !== undefined) opts.styleColBandSize = val;\n }\n\n // caption → w:tblCaption/@w:val\n const tblCaption = findChild(el, \"w:tblCaption\");\n if (tblCaption) {\n const val = attr(tblCaption, \"w:val\");\n if (val) opts.caption = val;\n }\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = attrMeasure(tblCellSpacing, \"w:w\", type);\n if (w !== undefined)\n opts.cellSpacing = { size: w, ...(type ? { type } : {}) } as TableCellSpacingProperties;\n }\n\n // Revision (w:tblPrChange)\n const tblPrChange = findChild(el, \"w:tblPrChange\");\n if (tblPrChange) {\n const rev: Partial<TablePropertiesChangeOptions> = {};\n const author = attr(tblPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tblPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tblPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTblPr = findChild(tblPrChange, \"w:tblPr\");\n if (innerTblPr) {\n Object.assign(rev, parseTablePropertiesEl(innerTblPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TablePropertiesChangeOptions;\n }\n\n // tblLook — conditional formatting flags (CT_TblLook)\n const tblLook = findChild(el, \"w:tblLook\");\n if (tblLook) {\n const look: TableLookOptions = {};\n const firstRow = attrBool(tblLook, \"w:firstRow\");\n if (firstRow !== undefined) look.firstRow = firstRow;\n const lastRow = attrBool(tblLook, \"w:lastRow\");\n if (lastRow !== undefined) look.lastRow = lastRow;\n const firstColumn = attrBool(tblLook, \"w:firstColumn\");\n if (firstColumn !== undefined) look.firstColumn = firstColumn;\n const lastColumn = attrBool(tblLook, \"w:lastColumn\");\n if (lastColumn !== undefined) look.lastColumn = lastColumn;\n const noHBand = attrBool(tblLook, \"w:noHBand\");\n if (noHBand !== undefined) look.noHBand = noHBand;\n const noVBand = attrBool(tblLook, \"w:noVBand\");\n if (noVBand !== undefined) look.noVBand = noVBand;\n if (Object.keys(look).length > 0) opts.tableLook = look;\n }\n\n return opts;\n}\n\nfunction parseColumnWidthsEl(el: Element): {\n widths: Array<number | string>;\n revision?: TableGridChangeOptions;\n} {\n const widths: Array<number | string> = [];\n const tblGrid = findChild(el, \"w:tblGrid\");\n if (!tblGrid) return { widths };\n\n for (const col of children(tblGrid, \"w:gridCol\")) {\n const w = attrMeasure(col, \"w:w\");\n widths.push(w ?? 100);\n }\n\n // CT_TblGrid may carry a tblGridChange (CT_TblGridChange = CT_Markup + tblGrid).\n const tblGridChange = findChild(tblGrid, \"w:tblGridChange\");\n if (tblGridChange) {\n const id = attrNum(tblGridChange, \"w:id\");\n const innerGrid = findChild(tblGridChange, \"w:tblGrid\");\n const revWidths: Array<number | string> = [];\n if (innerGrid) {\n for (const col of children(innerGrid, \"w:gridCol\")) {\n const w = attrMeasure(col, \"w:w\");\n revWidths.push(w ?? 100);\n }\n }\n if (id !== undefined) {\n return {\n widths,\n revision: { id, columnWidths: revWidths as number[] | PositiveUniversalMeasure[] },\n };\n }\n }\n\n return { widths };\n}\n\nexport function parseTableRowPropertiesEl(el: Element): TableRowPropertiesOptions {\n const opts: TableRowPropertiesOptions = {};\n\n const trHeight = findChild(el, \"w:trHeight\");\n if (trHeight) {\n const val = attrMeasure(trHeight, \"w:val\");\n const rule = attr(trHeight, \"w:hRule\");\n if (val !== undefined) {\n opts.height = { value: val, ...(rule ? { rule } : {}) } as NonNullable<\n TableRowPropertiesOptions[\"height\"]\n >;\n }\n }\n\n // cnfStyle → w:cnfStyle (CT_Cnf)\n const cnfStyle = findChild(el, \"w:cnfStyle\");\n if (cnfStyle) {\n const cnf = parseCnfStyle(cnfStyle);\n if (cnf) opts.cnfStyle = cnf;\n }\n\n // divId → w:divId/@w:val\n const divId = findChild(el, \"w:divId\");\n if (divId) {\n const val = attrNum(divId, \"w:val\");\n if (val !== undefined) opts.divId = val;\n }\n\n // gridBefore / gridAfter\n const gridBefore = findChild(el, \"w:gridBefore\");\n if (gridBefore) {\n const val = attrNum(gridBefore, \"w:val\");\n if (val !== undefined) opts.gridBefore = val;\n }\n const gridAfter = findChild(el, \"w:gridAfter\");\n if (gridAfter) {\n const val = attrNum(gridAfter, \"w:val\");\n if (val !== undefined) opts.gridAfter = val;\n }\n\n // wBefore / wAfter → widthBefore / widthAfter\n const wBefore = findChild(el, \"w:wBefore\");\n if (wBefore) {\n const type = attr(wBefore, \"w:type\");\n const size = attrMeasure(wBefore, \"w:w\", type);\n if (size !== undefined)\n opts.widthBefore = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n const wAfter = findChild(el, \"w:wAfter\");\n if (wAfter) {\n const type = attr(wAfter, \"w:type\");\n const size = attrMeasure(wAfter, \"w:w\", type);\n if (size !== undefined)\n opts.widthAfter = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n\n // rowAlignment → w:jc/@w:val\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.rowAlignment = val as TableRowPropertiesOptions[\"rowAlignment\"];\n }\n\n // hidden → w:hidden\n const hidden = findChild(el, \"w:hidden\");\n if (hidden) opts.hidden = attrBool(hidden, \"w:val\") ?? true;\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = attrMeasure(tblCellSpacing, \"w:w\", type);\n if (w !== undefined)\n opts.cellSpacing = { size: w, ...(type ? { type } : {}) } as TableCellSpacingProperties;\n }\n\n // insertion / deletion (track changes)\n const ins = findChild(el, \"w:ins\");\n if (ins) opts.insertion = parseChangeAttrs(ins) as ChangedAttributesProperties;\n const del = findChild(el, \"w:del\");\n if (del) opts.deletion = parseChangeAttrs(del) as ChangedAttributesProperties;\n\n // Revision (w:trPrChange)\n const trPrChange = findChild(el, \"w:trPrChange\");\n if (trPrChange) {\n const rev: Partial<TableRowPropertiesChangeOptions> = {};\n const author = attr(trPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(trPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(trPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTrPr = findChild(trPrChange, \"w:trPr\");\n if (innerTrPr) {\n Object.assign(rev, parseTableRowPropertiesEl(innerTrPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TableRowPropertiesChangeOptions;\n }\n\n const tblHeader = findChild(el, \"w:tblHeader\");\n if (tblHeader) {\n opts.tableHeader = attrBool(tblHeader, \"w:val\") ?? true;\n }\n\n const cantSplit = findChild(el, \"w:cantSplit\");\n if (cantSplit) {\n opts.cantSplit = attrBool(cantSplit, \"w:val\") ?? true;\n }\n\n return opts;\n}\n\nexport function parseTableCellPropertiesEl(el: Element): TableCellPropertiesOptions {\n const opts: TableCellPropertiesOptions = {};\n\n const cnfStyle = findChild(el, \"w:cnfStyle\");\n if (cnfStyle) {\n const cnf = parseCnfStyle(cnfStyle);\n if (cnf) opts.cnfStyle = cnf;\n }\n\n const tcW = findChild(el, \"w:tcW\");\n if (tcW) {\n const type = attr(tcW, \"w:type\");\n const size = attrMeasure(tcW, \"w:w\", type);\n if (size !== undefined) {\n opts.width = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n const gridSpan = findChild(el, \"w:gridSpan\");\n if (gridSpan) {\n const val = attrNum(gridSpan, \"w:val\");\n if (val !== undefined) opts.columnSpan = val;\n }\n\n const vMerge = findChild(el, \"w:vMerge\");\n if (vMerge) {\n const val = attr(vMerge, \"w:val\");\n opts.verticalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val as TableCellPropertiesOptions[\"verticalAlign\"];\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading = parseShading(shd);\n if (shading) opts.shading = shading;\n }\n\n const tcBorders = findChild(el, \"w:tcBorders\");\n if (tcBorders) {\n // XML side name → TableCellBordersOptions key (incl. start/end + diagonals);\n // all sides are CT_TcBorders-optional. Mirrors table-level borders parse.\n const SIDE_KEYS: ReadonlyArray<[string, keyof TableCellBordersOptions]> = [\n [\"top\", \"top\"],\n [\"start\", \"start\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"end\", \"end\"],\n [\"right\", \"right\"],\n [\"insideH\", \"insideHorizontal\"],\n [\"insideV\", \"insideVertical\"],\n [\"tl2br\", \"topLeftToBottomRight\"],\n [\"tr2bl\", \"topRightToBottomLeft\"],\n ];\n const borders: TableCellBordersOptions = {};\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tcBorders, `w:${xmlSide}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n borders[key] = sideOpts;\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const noWrap = findChild(el, \"w:noWrap\");\n if (noWrap) opts.noWrap = attrBool(noWrap, \"w:val\") ?? true;\n\n const tcMar = findChild(el, \"w:tcMar\");\n if (tcMar) {\n const margins = parseCellMargins(tcMar);\n if (margins) opts.margins = margins;\n }\n\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) opts.textDirection = val as TableCellPropertiesOptions[\"textDirection\"];\n }\n\n // horizontalMerge → w:hMerge\n const hMerge = findChild(el, \"w:hMerge\");\n if (hMerge) {\n const val = attr(hMerge, \"w:val\");\n opts.horizontalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n // fitText → w:tcFitText\n const tcFitText = findChild(el, \"w:tcFitText\");\n if (tcFitText) opts.fitText = attrBool(tcFitText, \"w:val\") ?? true;\n\n // hideMark → w:hideMark\n const hideMark = findChild(el, \"w:hideMark\");\n if (hideMark) opts.hideMark = attrBool(hideMark, \"w:val\") ?? true;\n\n // headers → w:headers/w:header\n const headersEl = findChild(el, \"w:headers\");\n if (headersEl) {\n const headerVals: string[] = [];\n for (const h of headersEl.elements ?? []) {\n if (h.name !== \"w:header\") continue;\n const val = attr(h, \"w:val\");\n if (val) headerVals.push(val);\n }\n if (headerVals.length > 0) opts.headers = headerVals;\n }\n\n // insertion / deletion (track changes)\n const cellIns = findChild(el, \"w:cellIns\");\n if (cellIns) opts.insertion = parseChangeAttrs(cellIns) as ChangedAttributesProperties;\n const cellDel = findChild(el, \"w:cellDel\");\n if (cellDel) opts.deletion = parseChangeAttrs(cellDel) as ChangedAttributesProperties;\n\n // Revision (w:tcPrChange)\n const tcPrChange = findChild(el, \"w:tcPrChange\");\n if (tcPrChange) {\n const rev: Partial<TableCellPropertiesChangeOptions> = {};\n const author = attr(tcPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tcPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tcPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTcPr = findChild(tcPrChange, \"w:tcPr\");\n if (innerTcPr) {\n Object.assign(rev, parseTableCellPropertiesEl(innerTcPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TableCellPropertiesChangeOptions;\n }\n\n // cellMerge → w:cellMerge\n const cellMerge = findChild(el, \"w:cellMerge\");\n if (cellMerge) {\n const cm = parseChangeAttrs(cellMerge) as Partial<CellMergeAttributes>;\n const vMerge = attr(cellMerge, \"w:vMerge\");\n if (vMerge) cm.verticalMerge = xsdVerticalMergeRev.from(vMerge) as \"continue\" | \"restart\";\n const vMergeOrig = attr(cellMerge, \"w:vMergeOrig\");\n if (vMergeOrig) {\n cm.verticalMergeOriginal = xsdVerticalMergeRev.from(vMergeOrig) as \"continue\" | \"restart\";\n }\n if (Object.keys(cm).length > 0) opts.cellMerge = cm as CellMergeAttributes;\n }\n\n return opts;\n}\n\nfunction parseTableCellEl(el: Element, ctx: DocxReadContext): TableCellOptions {\n const opts: Partial<TableCellOptions> = {};\n\n const tcPr = findChild(el, \"w:tcPr\");\n if (tcPr) {\n Object.assign(opts, parseTableCellPropertiesEl(tcPr));\n }\n\n const childElements: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:tcPr\":\n break;\n case \"w:p\":\n case \"w:tbl\":\n if (_parseChild) childElements.push(_parseChild(child, ctx));\n break;\n default:\n break;\n }\n }\n\n opts.children = childElements;\n return opts as TableCellOptions;\n}\n\nfunction parseTableRowEl(el: Element, ctx: DocxReadContext): TableRowOptions {\n const opts: Partial<TableRowOptions> = {};\n\n const trPr = findChild(el, \"w:trPr\");\n if (trPr) {\n Object.assign(opts, parseTableRowPropertiesEl(trPr));\n }\n\n // w:tblPrEx (CT_TblPrEx) — per-row table-property exceptions\n const tblPrEx = findChild(el, \"w:tblPrEx\");\n if (tblPrEx) {\n const exceptions = parseTablePropertyExceptions(tblPrEx);\n if (Object.keys(exceptions).length > 0) opts.propertyExceptions = exceptions;\n }\n\n // rsid attributes on w:tr element\n for (const [attrName, optKey] of [\n [\"w:rsidRPr\", \"runPropertiesRsid\"],\n [\"w:rsidR\", \"rsid\"],\n [\"w:rsidDel\", \"deletionRsid\"],\n [\"w:rsidTr\", \"tableRowRsid\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n const childCells: (\n | TableCellOptions\n | { sdt: SdtCellOptions }\n | { customXml: CustomXmlCellOptions }\n )[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tc\") {\n childCells.push(parseTableCellEl(child, ctx));\n } else if (child.name === \"w:sdt\") {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtCells: TableCellOptions[] = [];\n if (sdtContent) {\n for (const sub of sdtContent.elements ?? []) {\n if (sub.name === \"w:tc\") sdtCells.push(parseTableCellEl(sub, ctx));\n }\n }\n const sdt: SdtCellOptions = {\n properties,\n };\n if (sdtCells.length > 0) sdt.cells = sdtCells;\n if (endProperties) sdt.endProperties = endProperties;\n childCells.push({ sdt });\n } else if (child.name === \"w:customXml\") {\n const element = attr(child, \"w:element\") ?? \"\";\n const cx: CustomXmlCellOptions = { element };\n const cxUri = attr(child, \"w:uri\");\n if (cxUri) cx.uri = cxUri;\n const xmlPr = findChild(child, \"w:customXmlPr\");\n if (xmlPr) {\n const parsed = parseCustomXmlProperties(xmlPr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined)\n cx.customXmlPr = parsed;\n }\n const cxCells: TableCellOptions[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:tc\") cxCells.push(parseTableCellEl(sub, ctx));\n }\n if (cxCells.length > 0) cx.children = cxCells;\n childCells.push({ customXml: cx });\n }\n }\n\n opts.cells = childCells;\n return opts as TableRowOptions;\n}\n\nfunction parseTableEl(el: Element, ctx: DocxReadContext): TableOptions {\n const opts: Partial<TableOptions> = {};\n\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n const tblPrParsed = parseTablePropertiesEl(tblPr);\n Object.assign(opts, tblPrParsed);\n // TableOptions exposes w:tblCellMar as `margins`; TablePropertiesOptions\n // uses `cellMargin`. Map back so round-trip keeps the public field name.\n if (tblPrParsed.cellMargin !== undefined) opts.margins = tblPrParsed.cellMargin;\n }\n\n const grid = parseColumnWidthsEl(el);\n if (grid.widths.length > 0) {\n opts.columnWidths = grid.widths as NonNullable<TableOptions[\"columnWidths\"]>;\n }\n if (grid.revision) {\n opts.columnWidthsRevision = grid.revision;\n }\n\n const rows: (TableRowOptions | { sdt: SdtRowOptions } | { customXml: CustomXmlRowOptions })[] =\n [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tr\") {\n rows.push(parseTableRowEl(child, ctx));\n } else if (child.name === \"w:sdt\") {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtRows: TableRowOptions[] = [];\n if (sdtContent) {\n for (const sub of sdtContent.elements ?? []) {\n if (sub.name === \"w:tr\") sdtRows.push(parseTableRowEl(sub, ctx));\n }\n }\n const sdt: SdtRowOptions = {\n properties,\n };\n if (sdtRows.length > 0) sdt.rows = sdtRows;\n if (endProperties) sdt.endProperties = endProperties;\n rows.push({ sdt });\n } else if (child.name === \"w:customXml\") {\n const element = attr(child, \"w:element\") ?? \"\";\n const cx: CustomXmlRowOptions = { element };\n const cxUri = attr(child, \"w:uri\");\n if (cxUri) cx.uri = cxUri;\n const xmlPr = findChild(child, \"w:customXmlPr\");\n if (xmlPr) {\n const parsed = parseCustomXmlProperties(xmlPr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined)\n cx.customXmlPr = parsed;\n }\n const cxRows: TableRowOptions[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:tr\") cxRows.push(parseTableRowEl(sub, ctx));\n }\n if (cxRows.length > 0) cx.children = cxRows;\n rows.push({ customXml: cx });\n }\n }\n\n opts.rows = rows;\n return opts as TableOptions;\n}\n","/**\n * Numbering level definitions module for WordprocessingML documents.\n *\n * This module defines the formatting and behavior of individual levels within\n * a numbered or bulleted list hierarchy.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @module\n */\nimport type { AlignmentType } from \"../paragraph/formatting\";\nimport type { LevelParagraphStylePropertiesOptions } from \"../paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"../paragraph/run/properties\";\n\n/**\n * Number format types for list levels.\n *\n * Defines the various numbering formats available for list levels, including\n * decimal, roman numerals, letters, and various international formats.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const LevelFormat = {\n /** Decimal numbering (1, 2, 3...). */\n DECIMAL: \"decimal\",\n /** Uppercase roman numerals (I, II, III...). */\n UPPER_ROMAN: \"upperRoman\",\n /** Lowercase roman numerals (i, ii, iii...). */\n LOWER_ROMAN: \"lowerRoman\",\n /** Uppercase letters (A, B, C...). */\n UPPER_LETTER: \"upperLetter\",\n /** Lowercase letters (a, b, c...). */\n LOWER_LETTER: \"lowerLetter\",\n /** Ordinal numbers (1st, 2nd, 3rd...). */\n ORDINAL: \"ordinal\",\n /** Cardinal text (one, two, three...). */\n CARDINAL_TEXT: \"cardinalText\",\n /** Ordinal text (first, second, third...). */\n ORDINAL_TEXT: \"ordinalText\",\n /** Hexadecimal numbering. */\n HEX: \"hex\",\n /** Chicago Manual of Style numbering. */\n CHICAGO: \"chicago\",\n /** Ideograph digital numbering. */\n IDEOGRAPH__DIGITAL: \"ideographDigital\",\n /** Japanese counting system. */\n JAPANESE_COUNTING: \"japaneseCounting\",\n /** Japanese aiueo ordering. */\n AIUEO: \"aiueo\",\n /** Japanese iroha ordering. */\n IROHA: \"iroha\",\n /** Full-width decimal numbering. */\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n /** Half-width decimal numbering. */\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n /** Japanese legal numbering. */\n JAPANESE_LEGAL: \"japaneseLegal\",\n /** Japanese digital ten thousand numbering. */\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n /** Decimal numbers enclosed in circles. */\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n /** Full-width decimal numbering variant 2. */\n DECIMAL_FULL_WIDTH2: \"decimalFullWidth2\",\n /** Full-width aiueo ordering. */\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n /** Full-width iroha ordering. */\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n /** Decimal with leading zeros. */\n DECIMAL_ZERO: \"decimalZero\",\n /** Bullet points. */\n BULLET: \"bullet\",\n /** Korean ganada ordering. */\n GANADA: \"ganada\",\n /** Korean chosung ordering. */\n CHOSUNG: \"chosung\",\n /** Decimal enclosed with fullstop. */\n DECIMAL_ENCLOSED_FULLSTOP: \"decimalEnclosedFullstop\",\n /** Decimal enclosed in parentheses. */\n DECIMAL_ENCLOSED_PARENTHESES: \"decimalEnclosedParen\",\n /** Decimal enclosed in circles (Chinese). */\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n /** Ideograph enclosed in circles. */\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n /** Traditional ideograph numbering. */\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n /** Ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n /** Traditional ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n /** Taiwanese counting system. */\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n /** Traditional ideograph legal numbering. */\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n /** Taiwanese counting thousand system. */\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n /** Taiwanese digital numbering. */\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n /** Chinese counting system. */\n CHINESE_COUNTING: \"chineseCounting\",\n /** Simplified Chinese legal numbering. */\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n /** Chinese counting thousand system. */\n CHINESE_COUNTING_THOUSAND: \"chineseCountingThousand\",\n /** Korean digital numbering. */\n KOREAN_DIGITAL: \"koreanDigital\",\n /** Korean counting system. */\n KOREAN_COUNTING: \"koreanCounting\",\n /** Korean legal numbering. */\n KOREAN_LEGAL: \"koreanLegal\",\n /** Korean digital numbering variant 2. */\n KOREAN_DIGITAL2: \"koreanDigital2\",\n /** Vietnamese counting system. */\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n /** Russian lowercase numbering. */\n RUSSIAN_LOWER: \"russianLower\",\n /** Russian uppercase numbering. */\n RUSSIAN_UPPER: \"russianUpper\",\n /** No numbering. */\n NONE: \"none\",\n /** Number enclosed in dashes. */\n NUMBER_IN_DASH: \"numberInDash\",\n /** Hebrew numbering variant 1. */\n HEBREW1: \"hebrew1\",\n /** Hebrew numbering variant 2. */\n HEBREW2: \"hebrew2\",\n /** Arabic alpha numbering. */\n ARABIC_ALPHA: \"arabicAlpha\",\n /** Arabic abjad numbering. */\n ARABIC_ABJAD: \"arabicAbjad\",\n /** Hindi vowels. */\n HINDI_VOWELS: \"hindiVowels\",\n /** Hindi consonants. */\n HINDI_CONSONANTS: \"hindiConsonants\",\n /** Hindi numbers. */\n HINDI_NUMBERS: \"hindiNumbers\",\n /** Hindi counting system. */\n HINDI_COUNTING: \"hindiCounting\",\n /** Thai letters. */\n THAI_LETTERS: \"thaiLetters\",\n /** Thai numbers. */\n THAI_NUMBERS: \"thaiNumbers\",\n /** Thai counting system. */\n THAI_COUNTING: \"thaiCounting\",\n /** Thai Baht text. */\n BAHT_TEXT: \"bahtText\",\n /** Dollar text. */\n DOLLAR_TEXT: \"dollarText\",\n /** Custom numbering format. */\n CUSTOM: \"custom\",\n} as const;\n\n/**\n * Suffix types for list levels.\n *\n * Defines what follows the numbering text (tab, space, or nothing).\n *\n * @publicApi\n */\nexport const LevelSuffix = {\n /** No separator after the numbering. */\n NOTHING: \"nothing\",\n /** Space character after the numbering. */\n SPACE: \"space\",\n /** Tab character after the numbering. */\n TAB: \"tab\",\n} as const;\n\n/**\n * Options for configuring a numbering level.\n *\n * @property level - Level index (0-8)\n * @property format - Number format type (decimal, roman, letter, etc.)\n * @property text - Level text template with placeholders like %1, %2\n * @property alignment - Text alignment for the numbering\n * @property start - Starting number for this level\n * @property suffix - Character(s) following the numbering (tab, space, nothing)\n * @property isLegalNumberingStyle - Use legal numbering style\n * @property style - Run and paragraph style properties\n */\nexport interface LevelsOptions {\n /** Level index (0-8). */\n level: number;\n /** Number format type (decimal, roman, letter, bullet, etc.). */\n format?: (typeof LevelFormat)[keyof typeof LevelFormat];\n /** Level text template with placeholders like %1, %2. */\n text?: string;\n /** Whether this level emits no text (CT_LevelText @w:null). */\n textNull?: boolean;\n /** Text alignment for the numbering. */\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n /** Starting number for this level. */\n start?: number;\n /** Character(s) following the numbering. */\n suffix?: (typeof LevelSuffix)[keyof typeof LevelSuffix];\n /** Use legal numbering style (e.g., 1.1.1). */\n isLegalNumberingStyle?: boolean;\n /** Restart numbering after this level (0-based level index). */\n lvlRestart?: number;\n /** Picture bullet ID reference. */\n lvlPicBulletId?: number;\n /** Template code for the level. */\n templateCode?: string;\n /** Whether this level is tentative (w:tentative attribute). */\n tentative?: boolean;\n /** Whether this level is tentative (w15:tentative attribute). */\n w15Tentative?: boolean;\n /** Legacy spacing/indent settings. `enabled` maps to the required CT_LvlLegacy @w:legacy flag. */\n legacy?: { enabled?: boolean; space?: number; indent?: number };\n /** Run and paragraph style properties. */\n style?: {\n /** Run style properties for the numbering text. */\n run?: RunStylePropertiesOptions;\n /** Paragraph style properties for the level. */\n paragraph?: LevelParagraphStylePropertiesOptions;\n };\n}\n","import { uniqueNumericIdCreator, convertInchesToTwip } from \"@office-open/core\";\nimport { decimalNumber } from \"@office-open/core\";\n/**\n * Numbering module for WordprocessingML documents.\n *\n * Numbering provides support for numbered and bulleted lists.\n * Pure string serialization — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPnumbering.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\nimport type { ParagraphPropertiesOptions } from \"@parts/paragraph/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport { LevelFormat } from \"./level\";\nimport type { LevelsOptions } from \"./level\";\n\n/**\n * Options for configuring numbering definitions.\n */\nexport interface NumberingOptions {\n /** Array of numbering configurations, each with levels and a reference name. */\n config: {\n levels: LevelsOptions[];\n reference: string;\n extraOptions?: AbstractNumberingExtraOptions;\n }[];\n /** Numbering cleanup ID (w:numIdMacAtCleanup) */\n numIdMacAtCleanup?: number;\n /** Picture bullet definitions for numbering (w:numPicBullet) */\n numPicBullets?: {\n numPicBulletId: number;\n pict?: string;\n }[];\n}\n\n/** Namespace attributes for w:numbering (pre-computed constant). */\nconst NUMBERING_ATTRS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n/** Default bullet levels (9 levels: 0-8). */\nconst DEFAULT_BULLET_LEVELS: LevelsOptions[] = [\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 0,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(0.5) } },\n },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 1,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(1) } },\n },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 2,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2160 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 3,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2880 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 4,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 3600 } } },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 5,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 4320 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 6,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5040 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 7,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5760 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 8,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 6480 } } },\n text: \"●\",\n },\n];\n\n/**\n * Numbering definitions for a WordprocessingML document.\n *\n * Pure data accumulator — no XmlComponent inheritance.\n * Serializes via `serialize()` producing a complete XML part.\n */\nexport class Numbering {\n private abstractNumberingData = new Map<\n string,\n { id: number; levels: LevelsOptions[]; extraOptions?: AbstractNumberingExtraOptions }\n >();\n private concreteNumberingData = new Map<\n string,\n {\n numId: number;\n abstractNumId: number;\n reference: string;\n instance: number;\n overrideLevels?: { num: number; start?: number }[];\n }\n >();\n private referenceConfigMap = new Map<string, LevelsOptions[]>();\n private abstractNumUniqueNumericId = uniqueNumericIdCreator();\n private concreteNumUniqueNumericId = uniqueNumericIdCreator(1);\n private _numIdMacAtCleanup?: number;\n private _numPicBullets?: { numPicBulletId: number; pict?: string }[];\n\n public constructor(options: NumberingOptions) {\n this._numIdMacAtCleanup = options.numIdMacAtCleanup;\n this._numPicBullets = options.numPicBullets;\n\n // Only inject the default bullet numbering when the caller supplied no\n // numbering definitions. Round-tripped documents carry their own, so\n // injecting a default would inflate the part (extra abstractNum + 9 levels).\n if (options.config.length === 0) {\n const defaultAbstractId = this.abstractNumUniqueNumericId();\n this.abstractNumberingData.set(\"default-bullet-numbering\", {\n id: defaultAbstractId,\n levels: DEFAULT_BULLET_LEVELS,\n });\n this.concreteNumberingData.set(\"default-bullet-numbering\", {\n abstractNumId: defaultAbstractId,\n instance: 0,\n numId: 1,\n overrideLevels: [{ num: 0, start: 1 }],\n reference: \"default-bullet-numbering\",\n });\n }\n\n for (const con of options.config) {\n this.abstractNumberingData.set(con.reference, {\n id: this.abstractNumUniqueNumericId(),\n levels: con.levels,\n extraOptions: con.extraOptions,\n });\n this.referenceConfigMap.set(con.reference, con.levels);\n }\n }\n\n /** Serialize to word/numbering.xml content (with XML declaration). */\n public serialize(): string {\n const parts: string[] = [];\n parts.push(`<w:numbering ${NUMBERING_ATTRS}>`);\n\n // numPicBullet elements come first (XSD order)\n if (this._numPicBullets) {\n for (const bullet of this._numPicBullets) {\n if (bullet.pict) {\n parts.push(\n `<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\">${bullet.pict}</w:numPicBullet>`,\n );\n } else {\n parts.push(`<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\"/>`);\n }\n }\n }\n\n for (const an of this.abstractNumberingData.values()) {\n parts.push(stringifyAbstractNumbering(an.id, an.levels, an.extraOptions));\n }\n for (const cn of this.concreteNumberingData.values()) {\n parts.push(stringifyConcreteNumbering(cn));\n }\n if (this._numIdMacAtCleanup !== undefined) {\n parts.push(`<w:numIdMacAtCleanup w:val=\"${decimalNumber(this._numIdMacAtCleanup)}\"/>`);\n }\n\n parts.push(\"</w:numbering>\");\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>' + parts.join(\"\");\n }\n\n /**\n * Creates a concrete numbering instance from an abstract numbering definition.\n */\n public createConcreteNumberingInstance(reference: string, instance: number): void {\n const abstractNumbering = this.abstractNumberingData.get(reference);\n if (!abstractNumbering) return;\n\n const fullReference = `${reference}-${instance}`;\n if (this.concreteNumberingData.has(fullReference)) return;\n\n const referenceConfigLevels = this.referenceConfigMap.get(reference);\n const firstLevelStartNumber = referenceConfigLevels?.[0]?.start;\n\n // Only emit a lvlOverride when the instance's start differs from the\n // abstract default (1) — otherwise it is redundant and inflates the part.\n const overrideLevels =\n typeof firstLevelStartNumber === \"number\" &&\n Number.isInteger(firstLevelStartNumber) &&\n firstLevelStartNumber !== 1\n ? [{ num: 0, start: firstLevelStartNumber }]\n : undefined;\n\n this.concreteNumberingData.set(fullReference, {\n abstractNumId: abstractNumbering.id,\n instance,\n numId: this.concreteNumUniqueNumericId(),\n overrideLevels,\n reference,\n });\n }\n\n /** Gets all concrete numbering instances. */\n public get concreteNumbering(): { numId: number; reference: string; instance: number }[] {\n return [...this.concreteNumberingData.values()];\n }\n\n /** Gets all reference configurations. */\n public get referenceConfig(): LevelsOptions[][] {\n return [...this.referenceConfigMap.values()];\n }\n}\n\n// ── Types ──\n\n/** Extra options for abstract numbering. Re-exported from abstract-numbering module. */\ninterface AbstractNumberingExtraOptions {\n nsid?: string;\n /** w:multiLevelType value (singleLevel/multilevel/hybridMultilevel). */\n multiLevelType?: string;\n /** w15:restartNumberingAfterBreak attribute on w:abstractNum. Omitted when undefined. */\n restartNumberingAfterBreak?: boolean;\n tmpl?: string;\n name?: string;\n styleLink?: string;\n numStyleLink?: string;\n}\n\n// ── Pure function serializers ──\n\nfunction stringifyAbstractNumbering(\n id: number,\n levels: LevelsOptions[],\n extraOptions?: AbstractNumberingExtraOptions,\n): string {\n const parts: string[] = [];\n // w15:restartNumberingAfterBreak is optional (w15 extension); only emit when\n // explicitly carried so round-trip matches sources that omit it.\n const restartAttr =\n extraOptions?.restartNumberingAfterBreak !== undefined\n ? ` w15:restartNumberingAfterBreak=\"${extraOptions.restartNumberingAfterBreak ? 1 : 0}\"`\n : \"\";\n parts.push(`<w:abstractNum w:abstractNumId=\"${decimalNumber(id)}\"${restartAttr}>`);\n\n if (extraOptions?.nsid !== undefined) {\n parts.push(`<w:nsid w:val=\"${extraOptions.nsid}\"/>`);\n }\n parts.push(`<w:multiLevelType w:val=\"${extraOptions?.multiLevelType ?? \"hybridMultilevel\"}\"/>`);\n if (extraOptions?.tmpl !== undefined) {\n parts.push(`<w:tmpl w:val=\"${extraOptions.tmpl}\"/>`);\n }\n if (extraOptions?.name !== undefined) {\n parts.push(`<w:name w:val=\"${extraOptions.name}\"/>`);\n }\n if (extraOptions?.styleLink !== undefined) {\n parts.push(`<w:styleLink w:val=\"${extraOptions.styleLink}\"/>`);\n }\n if (extraOptions?.numStyleLink !== undefined) {\n parts.push(`<w:numStyleLink w:val=\"${extraOptions.numStyleLink}\"/>`);\n }\n\n for (const level of levels) {\n parts.push(stringifyLevel(level));\n }\n\n parts.push(\"</w:abstractNum>\");\n return parts.join(\"\");\n}\n\nfunction stringifyConcreteNumbering(cn: {\n numId: number;\n abstractNumId: number;\n overrideLevels?: { num: number; start?: number }[];\n}): string {\n const parts: string[] = [];\n parts.push(`<w:num w:numId=\"${decimalNumber(cn.numId)}\">`);\n parts.push(`<w:abstractNumId w:val=\"${decimalNumber(cn.abstractNumId)}\"/>`);\n\n if (cn.overrideLevels) {\n for (const level of cn.overrideLevels) {\n if (level.start !== undefined) {\n parts.push(\n `<w:lvlOverride w:ilvl=\"${level.num}\"><w:startOverride w:val=\"${level.start}\"/></w:lvlOverride>`,\n );\n } else {\n parts.push(`<w:lvlOverride w:ilvl=\"${level.num}\"/>`);\n }\n }\n }\n\n parts.push(\"</w:num>\");\n return parts.join(\"\");\n}\n\nfunction stringifyLevel(opts: LevelsOptions): string {\n const children: string[] = [];\n\n children.push(`<w:start w:val=\"${decimalNumber(opts.start ?? 1)}\"/>`);\n if (opts.format) children.push(`<w:numFmt w:val=\"${opts.format}\"/>`);\n if (opts.lvlRestart !== undefined)\n children.push(`<w:lvlRestart w:val=\"${decimalNumber(opts.lvlRestart)}\"/>`);\n if (opts.suffix) children.push(`<w:suff w:val=\"${opts.suffix}\"/>`);\n if (opts.isLegalNumberingStyle) children.push(\"<w:isLgl/>\");\n if (opts.text !== undefined || opts.textNull) {\n const lvlTextAttrs: string[] = [];\n if (opts.text !== undefined) lvlTextAttrs.push(`w:val=\"${opts.text}\"`);\n if (opts.textNull) lvlTextAttrs.push('w:null=\"1\"');\n children.push(`<w:lvlText ${lvlTextAttrs.join(\" \")}/>`);\n }\n if (opts.lvlPicBulletId !== undefined)\n children.push(`<w:lvlPicBulletId w:val=\"${decimalNumber(opts.lvlPicBulletId)}\"/>`);\n if (opts.legacy !== undefined) {\n const legacyAttrs: string[] = [`w:legacy=\"${(opts.legacy.enabled ?? true) ? 1 : 0}\"`];\n if (opts.legacy.space !== undefined) legacyAttrs.push(`w:legacySpace=\"${opts.legacy.space}\"`);\n if (opts.legacy.indent !== undefined)\n legacyAttrs.push(`w:legacyIndent=\"${opts.legacy.indent}\"`);\n children.push(`<w:legacy ${legacyAttrs.join(\" \")}/>`);\n }\n children.push(`<w:lvlJc w:val=\"${opts.alignment ?? AlignmentType.START}\"/>`);\n\n // Paragraph/run properties — use compile-path pure string builders\n const pPrXml = stringifyParagraphProperties(opts.style && opts.style.paragraph).xml;\n const rPrXml = stringifyRunProperties(opts.style && opts.style.run);\n if (pPrXml) children.push(pPrXml);\n if (rPrXml) children.push(rPrXml);\n\n const lvlAttrs: string[] = [`w:ilvl=\"${decimalNumber(Math.min(opts.level, 9))}\"`];\n // w15:tentative is optional; only emit when carried (matches sources that omit it).\n if (opts.w15Tentative !== undefined)\n lvlAttrs.push(`w15:tentative=\"${opts.w15Tentative ? 1 : 0}\"`);\n if (opts.templateCode !== undefined) lvlAttrs.push(`w:tplc=\"${opts.templateCode}\"`);\n if (opts.tentative !== undefined) lvlAttrs.push(`w:tentative=\"${opts.tentative ? 1 : 0}\"`);\n\n return `<w:lvl ${lvlAttrs.join(\" \")}>${children.join(\"\")}</w:lvl>`;\n}\n\n// ── Parse (Element → NumberingOptions) ──\n\n/**\n * Parse w:numbering element into NumberingOptions.\n */\nexport function parseNumberingDefinitions(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): NumberingOptions | undefined {\n const abstractNums = new Map<string, Element>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const id = attr(child, \"w:abstractNumId\");\n if (id !== undefined) abstractNums.set(id, child);\n }\n\n const numToAbstract = new Map<string, string>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n const numId = attr(child, \"w:numId\");\n const abstractRef = findChild(child, \"w:abstractNumId\");\n const abstractId = abstractRef ? attr(abstractRef, \"w:val\") : undefined;\n if (numId !== undefined && abstractId !== undefined) {\n numToAbstract.set(numId, abstractId);\n }\n }\n\n const configs: NumberingOptions[\"config\"] = [];\n\n for (const [numId, abstractId] of numToAbstract) {\n const abstractEl = abstractNums.get(abstractId);\n if (!abstractEl) continue;\n\n const levels: LevelsOptions[] = [];\n for (const child of abstractEl.elements ?? []) {\n if (child.name !== \"w:lvl\") continue;\n const levelOpts = parseLevelEl(child, parseParagraphProperties, ctx);\n if (levelOpts) levels.push(levelOpts);\n }\n\n if (levels.length > 0) {\n const extraOptions: AbstractNumberingExtraOptions = {};\n const nsidEl = findChild(abstractEl, \"w:nsid\");\n if (nsidEl) {\n const v = attr(nsidEl, \"w:val\");\n if (v) extraOptions.nsid = v;\n }\n const multiLevelTypeEl = findChild(abstractEl, \"w:multiLevelType\");\n if (multiLevelTypeEl) {\n const v = attr(multiLevelTypeEl, \"w:val\");\n if (v) extraOptions.multiLevelType = v;\n }\n const restartVal = attrBool(abstractEl, \"w15:restartNumberingAfterBreak\");\n if (restartVal !== undefined) extraOptions.restartNumberingAfterBreak = restartVal;\n const tmplEl = findChild(abstractEl, \"w:tmpl\");\n if (tmplEl) {\n const v = attr(tmplEl, \"w:val\");\n if (v) extraOptions.tmpl = v;\n }\n configs.push({ reference: `list_${numId}`, levels, extraOptions });\n }\n }\n\n if (configs.length === 0) return undefined;\n return { config: configs };\n}\n\nfunction parseLevelEl(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): LevelsOptions | undefined {\n const opts: Partial<LevelsOptions> = {};\n\n const level = attrNum(el, \"w:ilvl\");\n if (level !== undefined) opts.level = level;\n\n const start = findChild(el, \"w:start\");\n if (start) {\n const val = attrNum(start, \"w:val\");\n if (val !== undefined) opts.start = val;\n }\n\n const lvlRestart = findChild(el, \"w:lvlRestart\");\n if (lvlRestart) {\n const val = attrNum(lvlRestart, \"w:val\");\n if (val !== undefined) opts.lvlRestart = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const val = attr(numFmt, \"w:val\");\n if (val) opts.format = val as LevelsOptions[\"format\"];\n }\n\n const suff = findChild(el, \"w:suff\");\n if (suff) {\n const val = attr(suff, \"w:val\");\n if (val) opts.suffix = val as LevelsOptions[\"suffix\"];\n }\n\n if (findChild(el, \"w:isLgl\")) opts.isLegalNumberingStyle = true;\n\n const lvlText = findChild(el, \"w:lvlText\");\n if (lvlText) {\n const val = attr(lvlText, \"w:val\");\n if (val) opts.text = val;\n const isNull = attrBool(lvlText, \"w:null\");\n if (isNull) opts.textNull = isNull;\n }\n\n const lvlPicBulletId = findChild(el, \"w:lvlPicBulletId\");\n if (lvlPicBulletId) {\n const val = attrNum(lvlPicBulletId, \"w:val\");\n if (val !== undefined) opts.lvlPicBulletId = val;\n }\n\n // Legacy spacing (w:legacy/@w:legacy [required], @w:legacySpace, @w:legacyIndent)\n const legacyEl = findChild(el, \"w:legacy\");\n if (legacyEl) {\n const legacy: NonNullable<LevelsOptions[\"legacy\"]> = {};\n const enabled = attrBool(legacyEl, \"w:legacy\");\n if (enabled !== undefined) legacy.enabled = enabled;\n const space = attrNum(legacyEl, \"w:legacySpace\");\n if (space !== undefined) legacy.space = space;\n const indent = attrNum(legacyEl, \"w:legacyIndent\");\n if (indent !== undefined) legacy.indent = indent;\n opts.legacy = legacy;\n }\n\n const lvlJc = findChild(el, \"w:lvlJc\");\n if (lvlJc) {\n const val = attr(lvlJc, \"w:val\");\n if (val) opts.alignment = val as LevelsOptions[\"alignment\"];\n }\n\n // Level attributes (w:tplc templateCode; w:tentative; w15:tentative)\n const tplc = attr(el, \"w:tplc\");\n if (tplc) opts.templateCode = tplc;\n const tentative = attrBool(el, \"w:tentative\");\n if (tentative !== undefined) opts.tentative = tentative;\n const w15Tentative = attrBool(el, \"w15:tentative\");\n if (w15Tentative !== undefined) opts.w15Tentative = w15Tentative;\n\n // Run + paragraph properties — reuse the complete parse helpers for full\n // fidelity (stringifyLevel delegates to stringifyRunProperties /\n // stringifyParagraphProperties, so parse must use the matching readers).\n const style: NonNullable<LevelsOptions[\"style\"]> = {};\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) style.run = runOpts;\n }\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n style.paragraph = paraOpts;\n }\n }\n if (Object.keys(style).length > 0) opts.style = style;\n\n return Object.keys(opts).length > 0 ? (opts as LevelsOptions) : undefined;\n}\n","/**\n * Document attributes module for WordprocessingML documents.\n *\n * This module defines the XML namespace declarations used in OOXML documents.\n * These namespaces are required for proper document parsing and generation.\n *\n * Reference: http://officeopenxml.com/anatomyofOOXML.php\n *\n * @module\n */\n\n/**\n * XML namespace URIs used in WordprocessingML documents.\n *\n * These namespaces define the various XML schemas that can be referenced\n * in a document, including WordprocessingML, DrawingML, VML, and others.\n */\n/* CSpell:disable */\nexport const DocumentAttributeNamespaces = {\n aink: \"http://schemas.microsoft.com/office/drawing/2016/ink\",\n am3d: \"http://schemas.microsoft.com/office/drawing/2017/model3d\",\n cp: \"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\",\n cx: \"http://schemas.microsoft.com/office/drawing/2014/chartex\",\n cx1: \"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\",\n cx2: \"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\",\n cx3: \"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\",\n cx4: \"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\",\n cx5: \"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\",\n cx6: \"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\",\n cx7: \"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\",\n cx8: \"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\",\n dc: \"http://purl.org/dc/elements/1.1/\",\n dcmitype: \"http://purl.org/dc/dcmitype/\",\n dcterms: \"http://purl.org/dc/terms/\",\n m: \"http://schemas.openxmlformats.org/officeDocument/2006/math\",\n mc: \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n o: \"urn:schemas-microsoft-com:office:office\",\n r: \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n v: \"urn:schemas-microsoft-com:vml\",\n w: \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n w10: \"urn:schemas-microsoft-com:office:word\",\n w14: \"http://schemas.microsoft.com/office/word/2010/wordml\",\n w15: \"http://schemas.microsoft.com/office/word/2012/wordml\",\n w16: \"http://schemas.microsoft.com/office/word/2018/wordml\",\n w16cex: \"http://schemas.microsoft.com/office/word/2018/wordml/cex\",\n w16cid: \"http://schemas.microsoft.com/office/word/2016/wordml/cid\",\n w16sdtdh: \"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\",\n w16se: \"http://schemas.microsoft.com/office/word/2015/wordml/symex\",\n wne: \"http://schemas.microsoft.com/office/word/2006/wordml\",\n wp: \"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\",\n wp14: \"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\",\n wpc: \"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\",\n wpg: \"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\",\n wpi: \"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\",\n wps: \"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\",\n xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n};\n/* CSpell:enable */\n\n/**\n * Type representing valid namespace keys.\n */\nexport type DocumentAttributeNamespace = keyof typeof DocumentAttributeNamespaces;\n","import { decimalNumber } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\n/**\n * Specifies the type of the current document grid, which defines the grid behavior.\n *\n * The grid can define a grid which snaps all East Asian characters to grid positions, but leaves Latin text with its default spacing; a grid which adds the specified character pitch to all characters on each row; or a grid which affects only the line pitch for the current section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_DocGrid_topic_ID0ELYP2.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_DocGrid\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"default\"/>\n * <xsd:enumeration value=\"lines\"/>\n * <xsd:enumeration value=\"linesAndChars\"/>\n * <xsd:enumeration value=\"snapToChars\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const DocumentGridType = {\n /**\n * Specifies that no document grid shall be applied to the contents of the current section in the document.\n */\n DEFAULT: \"default\",\n /**\n * Specifies that the parent section shall have additional line pitch added to each line within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain the specified number of lines per page.\n */\n LINES: \"lines\",\n /**\n * Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.\n *\n * When this value is set, the input specified via the user interface may be allowed in exact number of line/character pitch units. */\n LINES_AND_CHARS: \"linesAndChars\",\n /**\n * Specifies that the parent section shall have both the additional line pitch and character pitch added to each line and character within it (as specified on the <docGrid> element (§2.6.5)) in order to maintain a specific number of lines per page and characters per line.\n *\n * When this value is set, the input specified via the user interface may be restricted to the number of lines per page and characters per line, with the consumer or producer translating this information based on the current font data to get the resulting line and character pitch values\n */\n SNAP_TO_CHARS: \"snapToChars\",\n} as const;\n\nexport interface DocGridAttributesProperties {\n /**\n * Specifies the type of the current document grid, which defines the grid behavior.\n *\n * The grid can define a grid which snaps all East Asian characters to grid positions, but leaves Latin text with its default spacing; a grid which adds the specified character pitch to each character on each row; or a grid which affects only the line pitch for the current section.\n */\n type?: (typeof DocumentGridType)[keyof typeof DocumentGridType];\n /**\n * Specifies the number of lines to be allowed on the document grid for the current page assuming all lines have equal line pitch applied to them. This line pitch shall not be added to any line which appears within a table cell unless the <adjustLineHeightInTable> element (§2.15.3.1) is present in the document's compatibility settings.\n *\n * This attribute is specified in twentieths of a point, and defines the pitch for each line of text on this page such that the desired number of single spaced lines of text fits on the current page.\n *\n * ```xml\n * <w:docGrid w:linePitch=\"684\" …/>\n * ```\n *\n * The `linePitch` attribute specifies that 34.2 points is to the amount of pitch allowed for each line on this page in order to maintain the specific document grid. ]\n *\n * Individual paragraphs can override the line pitch information specified for the document grid by either:\n *\n * Specifying an exact line spacing value using the `lineRule` attribute of value exact on the <spacing> element (§2.3.1.33).\n *\n * Specifying that the paragraph text shall not snap to the document grid via the <snapToGrid> element (§2.3.1.32).\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n linePitch: number;\n /**\n * Specifies the number of characters to be allowed on the document grid for each line in this section.\n *\n * This attribute's value shall be specified by multiplying the difference between the desired character pitch and the character pitch for that character in the font size of the Normal font by 4096.\n *\n * This value shall then be used to add the character pitch for the specified point size to each character in the section [: This results in text in the Normal style having a specific number of characters per line. ]\n *\n * ```xml\n * <w:docGrid w:charSize=\"40960\" …/>\n * ```\n * The `charSpace` attribute specifies a value of 40960, which means that the delta between the character pitch of each character in the grid and the Normal font is 10 points, resulting in a character pitch of 11+10 = 21 points for all characters in this section. ]\n *\n * Individual runs of text can override the line pitch information specified for the document grid by specifying that the run text shall not snap to the document grid via the <snapToGrid> element (§2.3.2.32).\n *\n * The possible values for this attribute are defined by the `ST_DecimalNumber` simple type (§2.18.16).\n */\n charSpace?: number;\n}\n\n/**\n * This element specifies the settings for the document grid, which enables precise layout of full-width East Asian language characters within a document by specifying the desired number of characters per line and lines per page for all East Asian text content in this section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docGrid_topic_ID0EHU5S.html\n *\n * ```xml\n * <xsd:complexType name=\"CT_DocGrid\">\n * <xsd:attribute name=\"type\" type=\"ST_DocGrid\"/>\n * <xsd:attribute name=\"linePitch\" type=\"ST_DecimalNumber\"/>\n * <xsd:attribute name=\"charSpace\" type=\"ST_DecimalNumber\"/>\n * </xsd:complexType>\n * ```\n * @returns\n */\nexport const createDocumentGrid = ({\n type,\n linePitch,\n charSpace,\n}: DocGridAttributesProperties): string =>\n element(\"w:docGrid\", {\n \"w:charSpace\": charSpace ? decimalNumber(charSpace) : undefined,\n \"w:linePitch\": decimalNumber(linePitch),\n \"w:type\": type,\n });\n","/**\n * Page borders module for WordprocessingML section properties.\n *\n * Defines borders around pages in a document section.\n *\n * Reference: http://officeopenxml.com/WPsectionBorders.php\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Specifies which pages display the page border.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderDisplay\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"allPages\"/>\n * <xsd:enumeration value=\"firstPage\"/>\n * <xsd:enumeration value=\"notFirstPage\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderDisplay = {\n /** Display border on all pages */\n ALL_PAGES: \"allPages\",\n /** Display border only on first page */\n FIRST_PAGE: \"firstPage\",\n /** Display border on all pages except first page */\n NOT_FIRST_PAGE: \"notFirstPage\",\n} as const;\n\n/**\n * Specifies whether page border is positioned relative to page edge or text.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderOffset\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"text\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderOffsetFrom = {\n /** Position border relative to page edge */\n PAGE: \"page\",\n /** Position border relative to text (default) */\n TEXT: \"text\",\n} as const;\n\n/**\n * Specifies z-order of page border relative to intersecting objects.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_PageBorderZOrder\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"front\"/>\n * <xsd:enumeration value=\"back\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageBorderZOrder = {\n /** Display border behind page contents */\n BACK: \"back\",\n /** Display border in front of page contents (default) */\n FRONT: \"front\",\n} as const;\n\n/**\n * Options for configuring page borders.\n *\n * @property display - Which pages display the border\n * @property offsetFrom - Whether border is positioned relative to page or text\n * @property zOrder - Whether border appears in front or behind page contents\n * @property top - Top border styling\n * @property right - Right border styling\n * @property bottom - Bottom border styling\n * @property left - Left border styling\n */\nexport interface PageBordersOptions {\n /** Which pages display the border */\n display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];\n /** Whether border is positioned relative to page or text (default: text) */\n offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];\n /** Whether border appears in front or behind page contents (default: front) */\n zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];\n /** Top border styling */\n top?: BorderOptions;\n /** Right border styling */\n right?: BorderOptions;\n /** Bottom border styling */\n bottom?: BorderOptions;\n /** Left border styling */\n left?: BorderOptions;\n}\n","/**\n * Page margin module for WordprocessingML section properties.\n *\n * Defines page margins for document sections.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * @module\n */\nimport { signedTwipsMeasureValue, twipsMeasureValue } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure, UniversalMeasure } from \"@office-open/core\";\n\n/**\n * Options for configuring page margins.\n *\n * All measurements are in twips (1/20th of a point) or universal measure.\n *\n * @property top - Top margin\n * @property right - Right margin\n * @property bottom - Bottom margin\n * @property left - Left margin\n * @property header - Header margin (distance from top of page to header)\n * @property footer - Footer margin (distance from bottom of page to footer)\n * @property gutter - Gutter margin for binding\n */\nexport interface PageMarginAttributes {\n /** Top margin in twips or universal measure */\n top?: number | UniversalMeasure;\n /** Right margin in twips or universal measure */\n right?: number | PositiveUniversalMeasure;\n /** Bottom margin in twips or universal measure */\n bottom?: number | UniversalMeasure;\n /** Left margin in twips or universal measure */\n left?: number | PositiveUniversalMeasure;\n /** Header margin (distance from top of page to header) in twips or universal measure */\n header?: number | PositiveUniversalMeasure;\n /** Footer margin (distance from bottom of page to footer) in twips or universal measure */\n footer?: number | PositiveUniversalMeasure;\n /** Gutter margin for binding in twips or universal measure */\n gutter?: number | PositiveUniversalMeasure;\n}\n\n/**\n * Creates page margins (pgMar) for a document section.\n *\n * This element specifies the page margins for all pages in a section,\n * including top, bottom, left, right, header, footer, and gutter margins.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PageMar\">\n * <xsd:attribute name=\"top\" type=\"ST_SignedTwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"right\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"bottom\" type=\"ST_SignedTwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"left\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"header\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"footer\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * <xsd:attribute name=\"gutter\" type=\"s:ST_TwipsMeasure\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Create page margins with 1 inch margins (1440 twips = 1 inch)\n * createPageMargin(1440, 1440, 1440, 1440, 720, 720, 0);\n * ```\n */\nexport const createPageMargin = (\n top: number | UniversalMeasure,\n right: number | PositiveUniversalMeasure,\n bottom: number | UniversalMeasure,\n left: number | PositiveUniversalMeasure,\n header: number | PositiveUniversalMeasure,\n footer: number | PositiveUniversalMeasure,\n gutter: number | PositiveUniversalMeasure,\n): string =>\n `<w:pgMar w:bottom=\"${signedTwipsMeasureValue(bottom)}\" w:footer=\"${twipsMeasureValue(footer)}\" w:gutter=\"${twipsMeasureValue(gutter)}\" w:header=\"${twipsMeasureValue(header)}\" w:left=\"${twipsMeasureValue(left)}\" w:right=\"${twipsMeasureValue(right)}\" w:top=\"${signedTwipsMeasureValue(top)}\"/>`;\n","import { decimalNumber, twipsMeasureValue } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n\n/**\n * This simple type specifies when the line numbering in the parent section shall be reset to its restart value. The line numbering increments for each line (even if the line number itself is not displayed) until it reaches the restart point specified by this element.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_LineNumberRestart_topic_ID0EUS42.html\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:simpleType name=\"ST_LineNumberRestart\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"newPage\"/>\n * <xsd:enumeration value=\"newSection\"/>\n * <xsd:enumeration value=\"continuous\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const LineNumberRestartFormat = {\n /**\n * ## Restart Line Numbering on Each Page\n *\n * Specifies that line numbering for the parent section shall restart to the starting value whenever a new page is displayed.\n */\n NEW_PAGE: \"newPage\",\n /**\n * ## Restart Line Numbering for Each Section\n *\n * Specifies that line numbering for the parent section shall restart to the starting value whenever the parent begins.\n */\n NEW_SECTION: \"newSection\",\n /**\n * ## Continue Line Numbering From Previous Section\n *\n * Specifies that line numbering for the parent section shall continue from the line numbering from the end of the previous section, if any.\n */\n CONTINUOUS: \"continuous\",\n} as const;\n\nexport interface LineNumberAttributes {\n /**\n * Specifies the line number increments to be displayed in the current document.\n *\n * Although each line has an associated line number, only lines which are an even multiple of this value shall be displayed.\n *\n * ### Example\n *\n * ```xml\n * <w:lnNumType … w:countBy=\"5\"/>\n * ```\n *\n * This setting ensures that only lines whose number is a multiple of (e.g. 5, 10, and 15) will have a line number displayed. ]\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n countBy?: number;\n /**\n * ## Line Numbering Starting Value\n *\n * Specifies the starting value used for the first line whenever the line numbering is restarted by use of the `restart` attribute.\n *\n * ### Example\n *\n * ```xml\n * <w:lnNumType w:start=\"3\" w:countBy=\"5\"/>\n * ```\n *\n * The `start` attribute specifies that line numbers shall be counted starting from the number 3.\n *\n * The possible values for this attribute are defined by the ST_DecimalNumber simple type (§2.18.16).\n */\n start?: number;\n /**\n * ## Line Numbering Restart Setting\n *\n * Specifies when the line numbering in this section shall be reset to the line number specified by the `start` attribute's value.\n *\n * The line numbering increments for each line (even if it is not displayed) until it reaches the restart point specified by this element.\n *\n * ### Example\n *\n * ```xml\n * <w:sectPr>\n * ...\n * <w:lnNumType w:restart=\"newPage\" ... />\n * </w:sectPr>\n * ```\n *\n * The value of `newPage` specifies that the line numbers shall restart at the top of each page to the value specified by the `start` attribute. In this case, `newPage` is the default, so this value could have been omitted entirely.\n *\n * The possible values for this attribute are defined by the ST_LineNumberRestart simple type (§2.18.54).\n */\n restart?: (typeof LineNumberRestartFormat)[keyof typeof LineNumberRestartFormat];\n /**\n * Specifies the distance between the text margin and the edge of any line numbers appearing in that section.\n *\n * ```xml\n * <w:lnNumType ... w:distance=\"720\"/>\n * ```\n *\n * The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.18.105).\n */\n distance?: number | PositiveUniversalMeasure;\n}\n\n/**\n * This element specifies the settings for line numbering to be displayed before each column of text in this section in the document.\n *\n * References:\n * - https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_lnNumType_topic_ID0EVRAT.html\n * - http://officeopenxml.com/WPsectionLineNumbering.php\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:complexType name=\"CT_LineNumber\">\n * <xsd:attribute name=\"countBy\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"start\" type=\"ST_DecimalNumber\" use=\"optional\" default=\"1\"/>\n * <xsd:attribute name=\"distance\" type=\"s:ST_TwipsMeasure\" use=\"optional\"/>\n * <xsd:attribute name=\"restart\" type=\"ST_LineNumberRestart\" use=\"optional\" default=\"newPage\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createLineNumberType = ({\n countBy,\n start,\n restart,\n distance,\n}: LineNumberAttributes): string =>\n element(\"w:lnNumType\", {\n \"w:countBy\": countBy === undefined ? undefined : decimalNumber(countBy),\n \"w:distance\": distance === undefined ? undefined : twipsMeasureValue(distance),\n \"w:restart\": restart,\n \"w:start\": start === undefined ? undefined : decimalNumber(start),\n });\n","/**\n * Section type module for WordprocessingML section properties.\n *\n * Defines how a section begins relative to the previous section.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * @module\n */\n/**\n * Specifies the type of section break.\n *\n * This determines where the section begins relative to the previous section.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_SectionMark\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nextPage\"/>\n * <xsd:enumeration value=\"nextColumn\"/>\n * <xsd:enumeration value=\"continuous\"/>\n * <xsd:enumeration value=\"evenPage\"/>\n * <xsd:enumeration value=\"oddPage\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const SectionType = {\n /** Section begins on the next page */\n NEXT_PAGE: \"nextPage\",\n /** Section begins on the next column */\n NEXT_COLUMN: \"nextColumn\",\n /** Section begins immediately following the previous section */\n CONTINUOUS: \"continuous\",\n /** Section begins on the next even-numbered page */\n EVEN_PAGE: \"evenPage\",\n /** Section begins on the next odd-numbered page */\n ODD_PAGE: \"oddPage\",\n} as const;\n\n/**\n * Creates section type (type) for a document section.\n *\n * This element specifies the type of section break, which determines\n * where the new section begins relative to the previous section.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_SectType\">\n * <xsd:attribute name=\"val\" type=\"ST_SectionMark\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Create a continuous section (no page break)\n * createSectionType(SectionType.CONTINUOUS);\n *\n * // Create a section that starts on next odd page\n * createSectionType(SectionType.ODD_PAGE);\n * ```\n */\nexport const createSectionType = (value: (typeof SectionType)[keyof typeof SectionType]): string =>\n `<w:type w:val=\"${value}\"/>`;\n","/**\n * This simple type specifies the possible types of headers and footers which may be specified for a given header or footer reference in a document. This value determines the page(s) on which the current header or footer shall be displayed.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_HdrFtr_topic_ID0E2UW2.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_HdrFtr\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"even\"/>\n * <xsd:enumeration value=\"default\"/>\n * <xsd:enumeration value=\"first\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const HeaderFooterReferenceType = {\n /** Specifies that this header or footer shall appear on every page in this section which is not overridden with a specific `even` or `first` page header/footer. In a section with all three types specified, this type shall be used on all odd numbered pages (counting from the `first` page in the section, not the section numbering). */\n DEFAULT: \"default\",\n /** Specifies that this header or footer shall appear on the first page in this section. The appearance of this header or footer is contingent on the setting of the `titlePg` element (§2.10.6). */\n FIRST: \"first\",\n /** Specifies that this header or footer shall appear on all even numbered pages in this section (counting from the first page in the section, not the section numbering). The appearance of this header or footer is contingent on the setting of the `evenAndOddHeaders` element (§2.10.1). */\n EVEN: \"even\",\n} as const;\n\n// <xsd:group name=\"EG_HdrFtrReferences\">\n// <xsd:choice>\n// <xsd:element name=\"headerReference\" type=\"CT_HdrFtrRef\" minOccurs=\"0\"/>\n// <xsd:element name=\"footerReference\" type=\"CT_HdrFtrRef\" minOccurs=\"0\"/>\n// </xsd:choice>\n// </xsd:group>\n\n// <xsd:complexType name=\"CT_HdrFtrRef\">\n// <xsd:complexContent>\n// <xsd:extension base=\"CT_Rel\">\n// <xsd:attribute name=\"type\" type=\"ST_HdrFtr\" use=\"required\"/>\n// </xsd:extension>\n// </xsd:complexContent>\n\n// <xsd:complexType name=\"CT_Rel\">\n// <xsd:attribute ref=\"r:id\" use=\"required\"/>\n// </xsd:complexType>\n\nexport interface HeaderFooterReferenceOptions {\n type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType];\n id?: number;\n}\n\nexport const HeaderFooterType = {\n FOOTER: \"w:footerReference\",\n HEADER: \"w:headerReference\",\n} as const;\n\nexport const createHeaderFooterReference = (\n type: (typeof HeaderFooterType)[keyof typeof HeaderFooterType],\n options: HeaderFooterReferenceOptions,\n): string =>\n `<${type} r:id=\"rId${options.id}\" w:type=\"${options.type || HeaderFooterReferenceType.DEFAULT}\"/>`;\n","import { escapeXml } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\n/**\n * Factory module for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport type { ParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type {\n TableCellPropertiesOptions,\n TablePropertiesOptions,\n TableRowPropertiesOptions,\n} from \"@parts/table/stringify\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTableRowProperties,\n} from \"@parts/table/stringify\";\nimport { WidthType } from \"@parts/table/table-width\";\nimport { BorderStyle, type BorderOptions } from \"@shared/border\";\n\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport type { StylesOptions } from \"./styles\";\n\n// ── Style options interfaces ──\n\nexport interface DefaultStylesOptions {\n document?: DocumentDefaultsOptions;\n title?: ParagraphStyleOptions;\n subtitle?: ParagraphStyleOptions;\n heading1?: ParagraphStyleOptions;\n heading2?: ParagraphStyleOptions;\n heading3?: ParagraphStyleOptions;\n heading4?: ParagraphStyleOptions;\n heading5?: ParagraphStyleOptions;\n heading6?: ParagraphStyleOptions;\n heading7?: ParagraphStyleOptions;\n heading8?: ParagraphStyleOptions;\n heading9?: ParagraphStyleOptions;\n strong?: ParagraphStyleOptions;\n emphasis?: ParagraphStyleOptions;\n listParagraph?: ParagraphStyleOptions;\n quote?: ParagraphStyleOptions;\n intenseQuote?: ParagraphStyleOptions;\n hyperlink?: CharacterStyleOptions;\n footnoteReference?: CharacterStyleOptions;\n footnoteText?: ParagraphStyleOptions;\n footnoteTextChar?: CharacterStyleOptions;\n endnoteReference?: CharacterStyleOptions;\n endnoteText?: ParagraphStyleOptions;\n endnoteTextChar?: CharacterStyleOptions;\n}\n\nexport interface DocumentDefaultsOptions {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n}\n\nexport interface StyleOptions {\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n autoRedefine?: boolean;\n uiPriority?: number;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n quickFormat?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n /** CT_Style w:hidden — style hidden from the UI (CT_OnOff). */\n hidden?: boolean;\n /** CT_Style w:rsid — revision save id (CT_LongHexNumber, hex string verbatim). */\n rsid?: string;\n /** CT_Style @w:default — the default style for its type (CT_OnOff). */\n default?: boolean;\n /** CT_Style @w:customStyle — a user-defined custom style (CT_OnOff). */\n customStyle?: boolean;\n}\n\nexport type ParagraphStyleOptions = {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\nexport type CharacterStyleOptions = {\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\n// ── String builders ──\n\n/**\n * Build CT_Style style-level children (name…rsid), shared by paragraph/character/table styles.\n * Order follows CT_Style sequence: name, aliases, basedOn, next, link, autoRedefine, hidden,\n * uiPriority, semiHidden, unhideWhenUsed, qFormat, locked, personal, personalCompose,\n * personalReply, rsid.\n */\nfunction stringifyStyleLevelChildren(opts: StyleOptions & { id?: string }): string {\n const parts: string[] = [`<w:name w:val=\"${escapeXml(opts.name ?? opts.id ?? \"\")}\"/>`];\n if (opts.aliases) parts.push(`<w:aliases w:val=\"${escapeXml(opts.aliases)}\"/>`);\n if (opts.basedOn) parts.push(`<w:basedOn w:val=\"${escapeXml(opts.basedOn)}\"/>`);\n if (opts.next) parts.push(`<w:next w:val=\"${escapeXml(opts.next)}\"/>`);\n if (opts.link) parts.push(`<w:link w:val=\"${escapeXml(opts.link)}\"/>`);\n if (opts.autoRedefine) parts.push(\"<w:autoRedefine/>\");\n if (opts.hidden) parts.push(\"<w:hidden/>\");\n if (opts.uiPriority !== undefined) parts.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) parts.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) parts.push(\"<w:unhideWhenUsed/>\");\n if (opts.quickFormat) parts.push(\"<w:qFormat/>\");\n if (opts.locked) parts.push(\"<w:locked/>\");\n if (opts.personal) parts.push(\"<w:personal/>\");\n if (opts.personalCompose) parts.push(\"<w:personalCompose/>\");\n if (opts.personalReply) parts.push(\"<w:personalReply/>\");\n if (opts.rsid) parts.push(`<w:rsid w:val=\"${opts.rsid}\"/>`);\n return parts.join(\"\");\n}\n\n/**\n * Build the `<w:style>` opening tag: type/styleId plus the optional w:default\n * and w:customStyle element attributes (CT_Style). Shared by paragraph/\n * character/table styles.\n */\nfunction styleOpenTag(\n type: string,\n opts: { id?: string; default?: boolean; customStyle?: boolean },\n): string {\n let attrs = ` w:type=\"${type}\" w:styleId=\"${escapeXml(opts.id ?? \"\")}\"`;\n if (opts.default) attrs += ' w:default=\"1\"';\n if (opts.customStyle) attrs += ' w:customStyle=\"1\"';\n return `<w:style${attrs}>`;\n}\n\n/** Build `<w:style>` XML for a paragraph style. */\nexport function stringifyParagraphStyle(\n opts: StyleOptions & {\n id: string;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `${styleOpenTag(\"paragraph\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:style>` XML for a character style. */\nexport function stringifyCharacterStyle(\n opts: StyleOptions & {\n id: string;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `${styleOpenTag(\"character\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n// ── Table style (CT_Style type=\"table\") ──\n\n/** ST_TblStyleOverrideType — OOXML tokens verbatim (CT_TblStylePr @w:type). */\nexport type TableStyleOverrideType =\n | \"wholeTable\"\n | \"firstRow\"\n | \"lastRow\"\n | \"firstCol\"\n | \"lastCol\"\n | \"band1Vert\"\n | \"band2Vert\"\n | \"band1Horz\"\n | \"band2Horz\"\n | \"neCell\"\n | \"nwCell\"\n | \"seCell\"\n | \"swCell\";\n\n/** Conditional table style format (CT_TblStylePr). */\nexport interface ConditionalTableStyleOptions {\n /** Which region this format applies to (CT_TblStylePr @w:type, required). */\n type: TableStyleOverrideType;\n /** Paragraph properties (CT_PPrGeneral). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n /** Table properties (CT_TblPrBase). */\n table?: TablePropertiesOptions;\n /** Table row properties (CT_TrPr). */\n row?: TableRowPropertiesOptions;\n /** Table cell properties (CT_TcPr). */\n cell?: TableCellPropertiesOptions;\n}\n\n/** Table style (CT_Style type=\"table\"). */\nexport type TableStyleOptions = {\n /** Paragraph properties (CT_PPrGeneral). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n /** Table properties (CT_TblPrBase). */\n table?: TablePropertiesOptions;\n /** Table row properties (CT_TrPr). */\n row?: TableRowPropertiesOptions;\n /** Table cell properties (CT_TcPr). */\n cell?: TableCellPropertiesOptions;\n /** Conditional formats per region (CT_TblStylePr, unbounded). */\n conditionalFormats?: ConditionalTableStyleOptions[];\n} & StyleOptions & { id: string };\n\n/** Numbering style (CT_Style type=\"numbering\"). */\nexport type NumberingStyleOptions = {\n /** Paragraph properties (CT_PPrGeneral — usually carries numPr). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id: string };\n\n/** Build `<w:tblStylePr>` XML for a conditional table style format. */\nexport function stringifyConditionalTableStyle(opts: ConditionalTableStyleOptions): string {\n const children: string[] = [];\n // CT_TblStylePr child order: pPr, rPr, tblPr, trPr, tcPr\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n if (opts.table) {\n const tblPr = stringifyTableProperties(opts.table);\n if (tblPr) children.push(tblPr);\n }\n if (opts.row) {\n const trPr = stringifyTableRowProperties(opts.row);\n if (trPr) children.push(trPr);\n }\n if (opts.cell) {\n const tcPr = stringifyTableCellProperties(opts.cell);\n if (tcPr) children.push(tcPr);\n }\n return `<w:tblStylePr w:type=\"${opts.type}\">${children.join(\"\")}</w:tblStylePr>`;\n}\n\n/** Build `<w:style type=\"table\">` XML for a table style. */\nexport function stringifyTableStyle(opts: TableStyleOptions): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n // CT_Style child order: style-level, pPr, rPr, tblPr, trPr, tcPr, tblStylePr[]\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n if (opts.table) {\n const tblPr = stringifyTableProperties(opts.table);\n if (tblPr) children.push(tblPr);\n }\n if (opts.row) {\n const trPr = stringifyTableRowProperties(opts.row);\n if (trPr) children.push(trPr);\n }\n if (opts.cell) {\n const tcPr = stringifyTableCellProperties(opts.cell);\n if (tcPr) children.push(tcPr);\n }\n for (const cf of opts.conditionalFormats ?? []) {\n children.push(stringifyConditionalTableStyle(cf));\n }\n return `${styleOpenTag(\"table\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:style type=\"numbering\">` XML for a numbering style. */\nexport function stringifyNumberingStyle(opts: NumberingStyleOptions): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n // CT_Style child order: style-level, pPr, rPr\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n return `${styleOpenTag(\"numbering\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Resolve a user override for heading level N (1-9) from default styles options. */\nfunction headingOverride(\n options: DefaultStylesOptions,\n level: number,\n): ParagraphStyleOptions | undefined {\n switch (level) {\n case 1:\n return options.heading1;\n case 2:\n return options.heading2;\n case 3:\n return options.heading3;\n case 4:\n return options.heading4;\n case 5:\n return options.heading5;\n case 6:\n return options.heading6;\n case 7:\n return options.heading7;\n case 8:\n return options.heading8;\n case 9:\n return options.heading9;\n default:\n return undefined;\n }\n}\n\n/** Build `<w:docDefaults>` XML matching Word's default settings. */\nfunction stringifyDocDefaults(opts: DocumentDefaultsOptions): string {\n const children: string[] = [];\n\n // rPrDefault - Word default: Calibri 11pt (22 half-points), theme fonts\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) {\n children.push(`<w:rPrDefault>${rPr}</w:rPrDefault>`);\n } else {\n // Match Word's default run properties exactly\n children.push(\n `<w:rPrDefault><w:rPr>` +\n `<w:rFonts w:asciiTheme=\"minorHAnsi\" w:eastAsiaTheme=\"minorEastAsia\" w:hAnsiTheme=\"minorHAnsi\" w:cstheme=\"minorBidi\"/>` +\n `<w:kern w:val=\"2\"/>` +\n `<w:sz w:val=\"22\"/><w:szCs w:val=\"24\"/>` +\n `<w:lang w:val=\"en-US\" w:eastAsia=\"zh-CN\" w:bidi=\"ar-SA\"/>` +\n `<w14:ligatures w14:val=\"standardContextual\"/>` +\n `</w:rPr></w:rPrDefault>`,\n );\n }\n\n // pPrDefault - Word default: spacing after 8pt (160 twips), line 1.16 (278 twips)\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) {\n children.push(`<w:pPrDefault>${pPr}</w:pPrDefault>`);\n } else {\n // Match Word's default paragraph properties exactly\n children.push(\n `<w:pPrDefault><w:pPr>` +\n `<w:spacing w:after=\"160\" w:line=\"278\" w:lineRule=\"auto\"/>` +\n `</w:pPr></w:pPrDefault>`,\n );\n }\n\n return `<w:docDefaults>${children.join(\"\")}</w:docDefaults>`;\n}\n\n// ── Factory ──\n\nlet cachedDefaultStyles: StylesOptions | null = null;\n\n/**\n * Factory for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n */\nexport class DefaultStylesFactory {\n public newInstance(options: DefaultStylesOptions = {}): StylesOptions {\n if (Object.keys(options).length === 0) {\n if (!cachedDefaultStyles) {\n cachedDefaultStyles = this.build({});\n }\n return cachedDefaultStyles;\n }\n return this.build(options);\n }\n\n private build(options: DefaultStylesOptions): StylesOptions {\n // importedStyles carries only docDefaults + latentStyles verbatim. Every\n // builtin w:style is emitted as a structured Options object so HTML renderers\n // can consume style attributes directly.\n const importedStyles: { _raw: string }[] = [];\n const paragraphStyles: (ParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (CharacterStyleOptions & { id: string })[] = [];\n const tableStyles: TableStyleOptions[] = [];\n const numberingStyles: NumberingStyleOptions[] = [];\n\n // XML namespace attributes for styles root element (matching Word exactly)\n const initialAttributes: Record<string, string> = {\n \"xmlns:mc\": \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n \"xmlns:r\": \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n \"xmlns:w\": \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n \"xmlns:w14\": \"http://schemas.microsoft.com/office/word/2010/wordml\",\n \"xmlns:w15\": \"http://schemas.microsoft.com/office/word/2012/wordml\",\n \"mc:Ignorable\": \"w14 w15\",\n };\n\n importedStyles.push({ _raw: stringifyDocDefaults(options.document ?? {}) });\n\n // Latent styles - complete list from Word's default template\n // Only include styles that are NOT explicitly defined below\n importedStyles.push({\n _raw:\n `<w:latentStyles w:defLockedState=\"0\" w:defUIPriority=\"99\" w:defSemiHidden=\"0\" w:defUnhideWhenUsed=\"0\" w:defQFormat=\"0\" w:count=\"376\">` +\n `<w:lsdException w:name=\"Normal\" w:uiPriority=\"0\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 1\" w:uiPriority=\"9\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 2\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 3\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 4\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 5\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 6\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 7\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 8\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 9\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Default Paragraph Font\" w:semiHidden=\"1\" w:uiPriority=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Normal Table\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No List\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Subtitle\" w:uiPriority=\"11\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Strong\" w:uiPriority=\"22\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Emphasis\" w:uiPriority=\"20\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Hyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"FollowedHyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No Spacing\" w:uiPriority=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Revision\" w:semiHidden=\"1\"/>` +\n `</w:latentStyles>`,\n });\n\n // Built-in styles required by Word\n // Normal paragraph style (default for paragraphs)\n paragraphStyles.push({\n id: \"Normal\",\n name: \"Normal\",\n default: true,\n quickFormat: true,\n paragraph: { widowControl: false },\n });\n\n // heading 1-9 styles with proper formatting\n const headings = [\n {\n id: \"Heading1\",\n name: \"heading 1\",\n link: \"Heading1Char\",\n sz: 48,\n before: 480,\n after: 80,\n outlineLvl: 0,\n },\n {\n id: \"Heading2\",\n name: \"heading 2\",\n link: \"Heading2Char\",\n sz: 40,\n before: 160,\n after: 80,\n outlineLvl: 1,\n },\n {\n id: \"Heading3\",\n name: \"heading 3\",\n link: \"Heading3Char\",\n sz: 32,\n before: 160,\n after: 80,\n outlineLvl: 2,\n },\n {\n id: \"Heading4\",\n name: \"heading 4\",\n link: \"Heading4Char\",\n sz: 28,\n before: 80,\n after: 40,\n outlineLvl: 3,\n },\n {\n id: \"Heading5\",\n name: \"heading 5\",\n link: \"Heading5Char\",\n sz: 24,\n before: 80,\n after: 40,\n outlineLvl: 4,\n },\n {\n id: \"Heading6\",\n name: \"heading 6\",\n link: \"Heading6Char\",\n sz: undefined,\n before: 40,\n after: 0,\n outlineLvl: 5,\n },\n {\n id: \"Heading7\",\n name: \"heading 7\",\n link: \"Heading7Char\",\n sz: undefined,\n before: 40,\n after: 0,\n outlineLvl: 6,\n },\n {\n id: \"Heading8\",\n name: \"heading 8\",\n link: \"Heading8Char\",\n sz: undefined,\n before: undefined,\n after: 0,\n outlineLvl: 7,\n },\n {\n id: \"Heading9\",\n name: \"heading 9\",\n link: \"Heading9Char\",\n sz: undefined,\n before: undefined,\n after: 0,\n outlineLvl: 8,\n },\n ];\n\n for (let headingIdx = 0; headingIdx < headings.length; headingIdx++) {\n const h = headings[headingIdx];\n const outlineLvl = h.outlineLvl;\n const headingOverrideOpts = headingOverride(options, headingIdx + 1);\n if (headingOverrideOpts) {\n // User-defined heading overrides the built-in entirely.\n paragraphStyles.push({\n id: h.id,\n name: headingOverrideOpts.name ?? h.name,\n basedOn: headingOverrideOpts.basedOn ?? \"Normal\",\n next: headingOverrideOpts.next ?? \"Normal\",\n link: headingOverrideOpts.link ?? h.link,\n uiPriority: headingOverrideOpts.uiPriority ?? 9,\n quickFormat: headingOverrideOpts.quickFormat ?? true,\n semiHidden: headingOverrideOpts.semiHidden,\n unhideWhenUsed: headingOverrideOpts.unhideWhenUsed,\n paragraph: { outlineLevel: headingIdx, ...headingOverrideOpts.paragraph },\n run: headingOverrideOpts.run,\n });\n characterStyles.push({\n id: h.link,\n name: `${h.name} Char`,\n basedOn: \"DefaultParagraphFont\",\n link: h.id,\n run: headingOverrideOpts.run,\n });\n continue;\n }\n\n // heading 1-6 use accent1 color + major theme fonts; 7-9 use text1 color.\n const accentRange = outlineLvl < 6;\n const runProps: RunStylePropertiesOptions = {\n font: accentRange\n ? {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n }\n : { cstheme: \"majorBidi\" },\n color: accentRange\n ? { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" }\n : { val: \"595959\", themeColor: \"text1\", themeTint: \"A6\" },\n };\n if (h.sz) {\n const sizePt = h.sz / 2; // half-points → points\n runProps.size = sizePt;\n runProps.sizeComplexScript = sizePt;\n }\n // heading 6-9 have bold\n if (outlineLvl >= 5) {\n runProps.bold = true;\n runProps.boldComplexScript = true;\n }\n\n paragraphStyles.push({\n id: h.id,\n name: h.name,\n basedOn: \"Normal\",\n next: \"Normal\",\n link: h.link,\n uiPriority: 9,\n semiHidden: outlineLvl > 0,\n unhideWhenUsed: outlineLvl > 0,\n quickFormat: true,\n paragraph: {\n keepNext: true,\n keepLines: true,\n spacing: {\n before: h.before,\n after: h.after,\n },\n outlineLevel: outlineLvl,\n },\n run: runProps,\n });\n\n // Linked character styles for headings\n characterStyles.push({\n id: h.link,\n name: `${h.name} Char`,\n basedOn: \"DefaultParagraphFont\",\n link: h.id,\n uiPriority: 9,\n semiHidden: outlineLvl > 0,\n run: runProps,\n });\n }\n\n // DefaultParagraphFont character style (default for runs)\n characterStyles.push({\n id: \"DefaultParagraphFont\",\n name: \"Default Paragraph Font\",\n default: true,\n uiPriority: 1,\n semiHidden: true,\n unhideWhenUsed: true,\n });\n\n // Normal Table style (default for tables)\n tableStyles.push({\n id: \"NormalTable\",\n name: \"Normal Table\",\n default: true,\n uiPriority: 99,\n semiHidden: true,\n unhideWhenUsed: true,\n table: {\n indent: { size: 0, type: WidthType.DXA },\n cellMargin: {\n top: { size: 0, type: WidthType.DXA },\n left: { size: 108, type: WidthType.DXA },\n bottom: { size: 0, type: WidthType.DXA },\n right: { size: 108, type: WidthType.DXA },\n },\n },\n });\n\n // No List numbering style (default for numbering)\n numberingStyles.push({\n id: \"NoList\",\n name: \"No List\",\n default: true,\n uiPriority: 99,\n semiHidden: true,\n unhideWhenUsed: true,\n });\n\n // Title style (user override via options.title, else built-in default)\n if (options.title) {\n paragraphStyles.push({\n id: \"Title\",\n name: options.title.name ?? \"Title\",\n basedOn: options.title.basedOn ?? \"Normal\",\n next: options.title.next ?? \"Normal\",\n link: options.title.link ?? \"TitleChar\",\n uiPriority: options.title.uiPriority ?? 10,\n quickFormat: options.title.quickFormat ?? true,\n paragraph: options.title.paragraph,\n run: options.title.run,\n });\n characterStyles.push({\n id: \"TitleChar\",\n name: \"Title Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Title\",\n run: options.title.run,\n });\n } else {\n const titleRun: RunStylePropertiesOptions = {\n font: {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n },\n characterSpacing: -10,\n kern: 28,\n size: 28,\n sizeComplexScript: 28,\n };\n paragraphStyles.push({\n id: \"Title\",\n name: \"Title\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"TitleChar\",\n uiPriority: 10,\n quickFormat: true,\n paragraph: {\n spacing: { after: 80, line: 240, lineRule: \"auto\" },\n contextualSpacing: true,\n alignment: AlignmentType.CENTER,\n },\n run: titleRun,\n });\n characterStyles.push({\n id: \"TitleChar\",\n name: \"Title Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Title\",\n uiPriority: 10,\n run: titleRun,\n });\n }\n\n // Subtitle style (user override via options.subtitle, else built-in default)\n if (options.subtitle) {\n paragraphStyles.push({\n id: \"Subtitle\",\n name: options.subtitle.name ?? \"Subtitle\",\n basedOn: options.subtitle.basedOn ?? \"Normal\",\n next: options.subtitle.next ?? \"Normal\",\n link: options.subtitle.link ?? \"SubtitleChar\",\n uiPriority: options.subtitle.uiPriority ?? 11,\n quickFormat: options.subtitle.quickFormat ?? true,\n paragraph: options.subtitle.paragraph,\n run: options.subtitle.run,\n });\n characterStyles.push({\n id: \"SubtitleChar\",\n name: \"Subtitle Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Subtitle\",\n run: options.subtitle.run,\n });\n } else {\n const subtitleRun: RunStylePropertiesOptions = {\n font: {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n },\n color: { val: \"595959\", themeColor: \"text1\", themeTint: \"A6\" },\n characterSpacing: 15,\n size: 14,\n sizeComplexScript: 14,\n };\n paragraphStyles.push({\n id: \"Subtitle\",\n name: \"Subtitle\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"SubtitleChar\",\n uiPriority: 11,\n quickFormat: true,\n paragraph: { alignment: AlignmentType.CENTER },\n run: subtitleRun,\n });\n characterStyles.push({\n id: \"SubtitleChar\",\n name: \"Subtitle Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Subtitle\",\n uiPriority: 11,\n run: subtitleRun,\n });\n }\n\n // List Paragraph style (user override via options.listParagraph, else built-in default)\n if (options.listParagraph) {\n paragraphStyles.push({\n id: \"ListParagraph\",\n name: options.listParagraph.name ?? \"List Paragraph\",\n basedOn: options.listParagraph.basedOn ?? \"Normal\",\n uiPriority: options.listParagraph.uiPriority ?? 34,\n quickFormat: options.listParagraph.quickFormat ?? true,\n paragraph: options.listParagraph.paragraph,\n run: options.listParagraph.run,\n });\n } else {\n paragraphStyles.push({\n id: \"ListParagraph\",\n name: \"List Paragraph\",\n basedOn: \"Normal\",\n uiPriority: 34,\n quickFormat: true,\n paragraph: { indent: { left: 720 }, contextualSpacing: true },\n });\n }\n\n // Strong style — only emitted when the user provides a definition\n if (options.strong) {\n paragraphStyles.push({\n id: \"Strong\",\n name: options.strong.name ?? \"Strong\",\n basedOn: options.strong.basedOn ?? \"Normal\",\n next: options.strong.next ?? \"Normal\",\n quickFormat: options.strong.quickFormat ?? true,\n paragraph: options.strong.paragraph,\n run: options.strong.run,\n });\n }\n\n // Emphasis style — only emitted when the user provides a definition\n if (options.emphasis) {\n paragraphStyles.push({\n id: \"Emphasis\",\n name: options.emphasis.name ?? \"Emphasis\",\n basedOn: options.emphasis.basedOn ?? \"Normal\",\n next: options.emphasis.next ?? \"Normal\",\n quickFormat: options.emphasis.quickFormat ?? true,\n paragraph: options.emphasis.paragraph,\n run: options.emphasis.run,\n });\n }\n\n // Quote style (user override via options.quote, else built-in default)\n const quoteRun: RunStylePropertiesOptions = {\n italic: true,\n italicComplexScript: true,\n color: { val: \"404040\", themeColor: \"text1\", themeTint: \"BF\" },\n };\n if (options.quote) {\n paragraphStyles.push({\n id: \"Quote\",\n name: options.quote.name ?? \"Quote\",\n basedOn: options.quote.basedOn ?? \"Normal\",\n next: options.quote.next ?? \"Normal\",\n link: options.quote.link ?? \"QuoteChar\",\n uiPriority: options.quote.uiPriority ?? 29,\n quickFormat: options.quote.quickFormat ?? true,\n paragraph: options.quote.paragraph,\n run: options.quote.run,\n });\n characterStyles.push({\n id: \"QuoteChar\",\n name: \"Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Quote\",\n run: options.quote.run,\n });\n } else {\n paragraphStyles.push({\n id: \"Quote\",\n name: \"Quote\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"QuoteChar\",\n uiPriority: 29,\n quickFormat: true,\n paragraph: { spacing: { before: 160 }, alignment: AlignmentType.CENTER },\n run: quoteRun,\n });\n characterStyles.push({\n id: \"QuoteChar\",\n name: \"Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Quote\",\n uiPriority: 29,\n run: quoteRun,\n });\n }\n\n // Intense Quote style + linked character style (built-in defaults)\n const intenseQuoteRun: RunStylePropertiesOptions = {\n italic: true,\n italicComplexScript: true,\n color: { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" },\n };\n const intenseQuoteBorder: BorderOptions = {\n style: BorderStyle.SINGLE,\n size: 4,\n space: 10,\n color: \"0F4761\",\n themeColor: \"accent1\",\n themeShade: \"BF\",\n };\n paragraphStyles.push({\n id: \"IntenseQuote\",\n name: \"Intense Quote\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"IntenseQuoteChar\",\n uiPriority: 30,\n quickFormat: true,\n paragraph: {\n border: { top: intenseQuoteBorder, bottom: intenseQuoteBorder },\n spacing: { before: 360, after: 360 },\n indent: { left: 864, right: 864 },\n alignment: AlignmentType.CENTER,\n },\n run: intenseQuoteRun,\n });\n characterStyles.push({\n id: \"IntenseQuoteChar\",\n name: \"Intense Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"IntenseQuote\",\n uiPriority: 30,\n run: intenseQuoteRun,\n });\n\n // Hyperlink character style\n characterStyles.push({\n id: \"Hyperlink\",\n name: \"Hyperlink\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { color: \"0563C1\", underline: { type: \"single\" } },\n ...options.hyperlink,\n });\n\n // Footnote Reference character style\n characterStyles.push({\n id: \"FootnoteReference\",\n name: \"footnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.footnoteReference,\n });\n\n // Footnote Text paragraph style\n paragraphStyles.push({\n id: \"FootnoteText\",\n name: \"footnote text\",\n basedOn: \"Normal\",\n link: \"FootnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.footnoteText,\n });\n\n // Footnote Text Char character style\n characterStyles.push({\n id: \"FootnoteTextChar\",\n name: \"Footnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"FootnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.footnoteTextChar,\n });\n\n // Endnote Reference character style\n characterStyles.push({\n id: \"EndnoteReference\",\n name: \"endnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.endnoteReference,\n });\n\n // Endnote Text paragraph style\n paragraphStyles.push({\n id: \"EndnoteText\",\n name: \"endnote text\",\n basedOn: \"Normal\",\n link: \"EndnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.endnoteText,\n });\n\n // Endnote Text Char character style\n characterStyles.push({\n id: \"EndnoteTextChar\",\n name: \"Endnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"EndnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.endnoteTextChar,\n });\n\n // Intense Reference character style\n characterStyles.push({\n id: \"IntenseReference\",\n name: \"Intense Reference\",\n basedOn: \"DefaultParagraphFont\",\n uiPriority: 32,\n quickFormat: true,\n run: {\n bold: true,\n boldComplexScript: true,\n smallCaps: true,\n color: { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" },\n characterSpacing: 5,\n },\n });\n\n return {\n importedStyles,\n paragraphStyles,\n characterStyles,\n tableStyles,\n numberingStyles,\n initialAttributes,\n };\n }\n}\n","/**\n * Styles module for WordprocessingML documents.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n ParagraphPropertiesOptions,\n ParagraphStylePropertiesOptions,\n} from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport type {\n CharacterStyleOptions,\n ConditionalTableStyleOptions,\n DefaultStylesOptions,\n DocumentDefaultsOptions,\n NumberingStyleOptions,\n ParagraphStyleOptions,\n TableStyleOptions,\n} from \"@parts/styles/factory\";\nimport {\n stringifyCharacterStyle,\n stringifyNumberingStyle,\n stringifyParagraphStyle,\n stringifyTableStyle,\n} from \"@parts/styles/factory\";\nimport {\n parseTableCellPropertiesEl,\n parseTablePropertiesEl,\n parseTableRowPropertiesEl,\n} from \"@parts/table/descriptor\";\nimport type {\n TableCellPropertiesOptions,\n TablePropertiesOptions,\n TableRowPropertiesOptions,\n} from \"@parts/table/stringify\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { stringifyElement } from \"../../util/stringify-element\";\n\n/**\n * Options for configuring document styles.\n */\nexport interface StylesOptions {\n /** Default styles for document, headings, and common elements */\n default?: DefaultStylesOptions;\n /** Initial namespace attributes for the styles root element */\n initialAttributes?: Record<string, string>;\n /** Array of raw XML style elements */\n importedStyles?: { _raw: string }[];\n /** Array of custom paragraph style definitions */\n paragraphStyles?: (ParagraphStyleOptions & { id: string })[];\n /** Array of custom character style definitions */\n characterStyles?: (CharacterStyleOptions & { id: string })[];\n /** Array of custom table style definitions (CT_Style type=\"table\"). */\n tableStyles?: TableStyleOptions[];\n /** Array of numbering style definitions (CT_Style type=\"numbering\"). */\n numberingStyles?: NumberingStyleOptions[];\n /**\n * Verbatim `<w:latentStyles>` XML (CT_LatentStyles + lsdException list).\n * When set (from parse), generate uses it in place of the default factory's\n * latent styles so the full latent-style table round-trips.\n */\n latentStylesXml?: string;\n /**\n * Verbatim `<w:docDefaults>` XML. When set (from parse), generate uses it in\n * place of the default factory's document defaults so rPrDefault/pPrDefault\n * round-trip byte-for-byte.\n */\n docDefaultsXml?: string;\n /**\n * @internal — set by parseStyleDefinitions to mark a round-trip origin so\n * context.ts consumes the parsed structured styles directly (no factory\n * builtin rebuild). Fresh generation never sets this.\n */\n roundTripped?: boolean;\n}\n\n/**\n * Extract the `w:styleId` from a raw `<w:style>` XML string, if present.\n *\n * Returns `undefined` for non-style elements (docDefaults / latentStyles),\n * whose raw XML carries no `w:styleId` attribute.\n */\nexport function extractStyleId(raw: string): string | undefined {\n const m = raw.match(/w:styleId=\"([^\"]+)\"/);\n return m ? m[1] : undefined;\n}\n\n/**\n * Represents the styles definitions in a WordprocessingML document.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n */\nexport class Styles {\n private attributes: Record<string, string> = {};\n private parts: string[] = [];\n\n public constructor(options: StylesOptions) {\n if (options.initialAttributes) {\n this.attributes = options.initialAttributes;\n }\n\n // styleIds explicitly redefined via paragraphStyles/characterStyles take\n // precedence over importedStyles (user definitions override builtins) —\n // skip those imported entries to avoid duplicate styleId in the output.\n const customStyleIds = new Set<string>();\n for (const s of options.paragraphStyles ?? []) customStyleIds.add(s.id);\n for (const s of options.characterStyles ?? []) customStyleIds.add(s.id);\n for (const s of options.tableStyles ?? []) customStyleIds.add(s.id);\n\n if (options.importedStyles) {\n for (const style of options.importedStyles) {\n if (!style._raw) continue;\n if (customStyleIds.size > 0) {\n const id = extractStyleId(style._raw);\n if (id && customStyleIds.has(id)) continue;\n }\n this.parts.push(style._raw);\n }\n }\n\n if (options.paragraphStyles) {\n for (const style of options.paragraphStyles) {\n this.parts.push(stringifyParagraphStyle(style));\n }\n }\n\n if (options.characterStyles) {\n for (const style of options.characterStyles) {\n this.parts.push(stringifyCharacterStyle(style));\n }\n }\n\n if (options.tableStyles) {\n for (const style of options.tableStyles) {\n this.parts.push(stringifyTableStyle(style));\n }\n }\n\n if (options.numberingStyles) {\n for (const style of options.numberingStyles) {\n this.parts.push(stringifyNumberingStyle(style));\n }\n }\n }\n\n /**\n * Serialize to word/styles.xml content (with XML declaration).\n */\n public serialize(): string {\n const attrParts: string[] = [];\n for (const [k, v] of Object.entries(this.attributes)) {\n if (v !== undefined && v !== null) attrParts.push(` ${k}=\"${v}\"`);\n }\n\n const attrs = attrParts.join(\"\");\n const body = this.parts.join(\"\");\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:styles${attrs}>${body}</w:styles>`;\n }\n}\n\n// ── Parse helpers (for descriptor pipeline) ──\n\n/**\n * Build a cache of style elements keyed by styleId.\n */\nexport function buildStyleCache(stylesEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!stylesEl) return cache;\n\n for (const child of stylesEl.elements ?? []) {\n if (child.name !== \"w:style\") continue;\n const styleId = attr(child, \"w:styleId\");\n if (styleId) {\n cache.set(styleId, child);\n }\n }\n\n return cache;\n}\n\n/**\n * Build a cache of abstract numbering elements keyed by abstractNumId.\n */\nexport function buildNumberingCache(numberingEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!numberingEl) return cache;\n\n for (const child of numberingEl.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const abstractNumId = attr(child, \"w:abstractNumId\");\n if (abstractNumId !== undefined) {\n cache.set(abstractNumId, child);\n }\n }\n\n return cache;\n}\n\n/** Parsed style — concrete shape (not Record) with a transient _type marker. */\ninterface ParsedStyle {\n _type?: string;\n id?: string;\n default?: boolean;\n customStyle?: boolean;\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n uiPriority?: number;\n quickFormat?: boolean;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n autoRedefine?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n hidden?: boolean;\n rsid?: string;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n table?: Partial<TablePropertiesOptions>;\n row?: Partial<TableRowPropertiesOptions>;\n cell?: Partial<TableCellPropertiesOptions>;\n conditionalFormats?: ConditionalTableStyleOptions[];\n}\n\n/**\n * Parse w:styles element into StylesOptions.\n *\n * Skips built-in styles that DefaultStylesFactory already generates,\n * keeping only user-defined custom styles for round-trip fidelity.\n */\nexport function parseStyleDefinitions(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): StylesOptions | undefined {\n const opts: StylesOptions = {};\n const paragraphStyles: (ParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (CharacterStyleOptions & { id: string })[] = [];\n const tableStyles: TableStyleOptions[] = [];\n const numberingStyles: NumberingStyleOptions[] = [];\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:docDefaults\") {\n const defOpts = parseDocDefaults(child, parseParagraphProperties, ctx);\n if (defOpts) opts.default = defOpts;\n // Also capture verbatim for byte-exact round-trip (the structured path\n // may re-order or default-fill rPrDefault/pPrDefault children).\n opts.docDefaultsXml = stringifyElement(child);\n } else if (child.name === \"w:latentStyles\") {\n // Preserve the latent-style table verbatim so the full lsdException list\n // round-trips (the default factory only emits ~20 entries).\n opts.latentStylesXml = stringifyElement(child);\n } else if (child.name === \"w:style\") {\n const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);\n // Skip styles without a type or styleId — both are required to be useful.\n if (!styleOpts?._type || !styleOpts.id) continue;\n // All styles (builtin + custom) round-trip structured so HTML renderers\n // can consume style attributes directly. Builtin verbatim _raw is gone —\n // a customized builtin (e.g. recolored Heading1) round-trips losslessly\n // via parseStyleElement ↔ stringify*Style field symmetry.\n const type = styleOpts._type;\n delete styleOpts._type;\n\n if (type === \"table\") {\n tableStyles.push(styleOpts as TableStyleOptions);\n } else if (type === \"numbering\") {\n numberingStyles.push(styleOpts as NumberingStyleOptions);\n } else if (type === \"paragraph\") {\n paragraphStyles.push(styleOpts as ParagraphStyleOptions & { id: string });\n } else if (type === \"character\") {\n characterStyles.push(styleOpts as CharacterStyleOptions & { id: string });\n }\n }\n }\n\n if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;\n if (characterStyles.length > 0) opts.characterStyles = characterStyles;\n if (tableStyles.length > 0) opts.tableStyles = tableStyles;\n if (numberingStyles.length > 0) opts.numberingStyles = numberingStyles;\n // Mark round-trip origin so context.ts consumes parsed structured styles\n // directly instead of rebuilding builtins via the factory.\n opts.roundTripped = true;\n\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseDocDefaults(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): DefaultStylesOptions | undefined {\n const document: DocumentDefaultsOptions = {};\n\n const rPrDefault = findChild(el, \"w:rPrDefault\");\n if (rPrDefault) {\n const rPr = findChild(rPrDefault, \"w:rPr\");\n if (rPr) {\n const runDefaults = parseRunProperties(rPr);\n if (Object.keys(runDefaults).length > 0) document.run = runDefaults;\n }\n }\n\n const pPrDefault = findChild(el, \"w:pPrDefault\");\n if (pPrDefault) {\n const pPr = findChild(pPrDefault, \"w:pPr\");\n if (pPr) {\n // Reuse the full paragraph-properties reader (stringifyDocDefaults uses\n // stringifyParagraphProperties) instead of only reading spacing, so jc/\n // ind/etc. round-trip too.\n const paraDefaults = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraDefaults).length > 0) {\n document.paragraph = paraDefaults;\n }\n }\n }\n\n return Object.keys(document).length > 0 ? { document } : undefined;\n}\n\nfunction parseStyleElement(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): ParsedStyle | undefined {\n const opts: ParsedStyle = {};\n\n const type = attr(el, \"w:type\");\n if (type) opts._type = type;\n\n const id = attr(el, \"w:styleId\");\n if (id) opts.id = id;\n\n if (attrBool(el, \"w:default\")) opts.default = true;\n if (attrBool(el, \"w:customStyle\")) opts.customStyle = true;\n\n const nameEl = findChild(el, \"w:name\");\n if (nameEl) {\n const name = attr(nameEl, \"w:val\");\n if (name) opts.name = name;\n }\n\n const basedOn = findChild(el, \"w:basedOn\");\n if (basedOn) {\n const val = attr(basedOn, \"w:val\");\n if (val) opts.basedOn = val;\n }\n\n const next = findChild(el, \"w:next\");\n if (next) {\n const val = attr(next, \"w:val\");\n if (val) opts.next = val;\n }\n\n const link = findChild(el, \"w:link\");\n if (link) {\n const val = attr(link, \"w:val\");\n if (val) opts.link = val;\n }\n\n const uiPriority = findChild(el, \"w:uiPriority\");\n if (uiPriority) {\n const val = attrNum(uiPriority, \"w:val\");\n if (val !== undefined) opts.uiPriority = val;\n }\n\n if (findChild(el, \"w:qFormat\")) opts.quickFormat = true;\n if (findChild(el, \"w:semiHidden\")) opts.semiHidden = true;\n if (findChild(el, \"w:unhideWhenUsed\")) opts.unhideWhenUsed = true;\n if (findChild(el, \"w:autoRedefine\")) opts.autoRedefine = true;\n if (findChild(el, \"w:locked\")) opts.locked = true;\n if (findChild(el, \"w:personal\")) opts.personal = true;\n if (findChild(el, \"w:personalCompose\")) opts.personalCompose = true;\n if (findChild(el, \"w:personalReply\")) opts.personalReply = true;\n if (findChild(el, \"w:hidden\")) opts.hidden = true;\n\n const rsidEl = findChild(el, \"w:rsid\");\n if (rsidEl) {\n const val = attr(rsidEl, \"w:val\");\n if (val) opts.rsid = val;\n }\n\n const aliases = findChild(el, \"w:aliases\");\n if (aliases) {\n const val = attr(aliases, \"w:val\");\n if (val) opts.aliases = val;\n }\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n opts.paragraph = paraOpts;\n }\n }\n\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) opts.run = runOpts;\n }\n\n // Table-style-only properties (CT_Style type=\"table\").\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n const tableOpts = parseTablePropertiesEl(tblPr);\n if (Object.keys(tableOpts).length > 0) opts.table = tableOpts;\n }\n const trPr = findChild(el, \"w:trPr\");\n if (trPr) {\n const rowOpts = parseTableRowPropertiesEl(trPr);\n if (Object.keys(rowOpts).length > 0) opts.row = rowOpts;\n }\n const tcPr = findChild(el, \"w:tcPr\");\n if (tcPr) {\n const cellOpts = parseTableCellPropertiesEl(tcPr);\n if (Object.keys(cellOpts).length > 0) opts.cell = cellOpts;\n }\n // Conditional table style formats (CT_TblStylePr, unbounded).\n const conditionalFormats: ConditionalTableStyleOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:tblStylePr\") continue;\n const type = attr(child, \"w:type\") as ConditionalTableStyleOptions[\"type\"] | undefined;\n if (!type) continue;\n const cf: ConditionalTableStyleOptions = { type };\n const cfPPr = findChild(child, \"w:pPr\");\n if (cfPPr) {\n const paraOpts = parseParagraphProperties(cfPPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n cf.paragraph = paraOpts;\n }\n }\n const cfRPr = findChild(child, \"w:rPr\");\n if (cfRPr) {\n const runOpts = parseRunProperties(cfRPr);\n if (Object.keys(runOpts).length > 0) cf.run = runOpts;\n }\n const cfTblPr = findChild(child, \"w:tblPr\");\n if (cfTblPr) {\n const tableOpts = parseTablePropertiesEl(cfTblPr);\n if (Object.keys(tableOpts).length > 0) cf.table = tableOpts;\n }\n const cfTrPr = findChild(child, \"w:trPr\");\n if (cfTrPr) {\n const rowOpts = parseTableRowPropertiesEl(cfTrPr);\n if (Object.keys(rowOpts).length > 0) cf.row = rowOpts;\n }\n const cfTcPr = findChild(child, \"w:tcPr\");\n if (cfTcPr) {\n const cellOpts = parseTableCellPropertiesEl(cfTcPr);\n if (Object.keys(cellOpts).length > 0) cf.cell = cellOpts;\n }\n conditionalFormats.push(cf);\n }\n if (conditionalFormats.length > 0) opts.conditionalFormats = conditionalFormats;\n\n return opts;\n}\n","/**\n * Settings descriptor — produces word/settings.xml.\n *\n * Stringifies pure JSON SettingsOptions into XML without creating\n * Settings/Compatibility/DocumentProtection/etc. class instances.\n * Zero XmlComponent allocation — pure string concatenation.\n *\n * @module\n */\n\nimport { derivePasswordHash } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, findChild, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type {\n SettingsOptions,\n DocumentProtectionOptions,\n WriteProtectionOptions,\n MailMergeOptions,\n OdsoOptions,\n OdsoFieldMapDataOptions,\n CompatibilityOptions,\n CompatSettingOptions,\n CaptionsOptions,\n CaptionOptions,\n AutoCaptionOptions,\n MathPropertiesOptions,\n RsidsOptions,\n ReadModeInkLockDownOptions,\n RevisionViewOptions,\n FootnotePropertiesOptions,\n EndnotePropertiesOptions,\n} from \"./settings\";\n\n/** Derive the namespace-prefixed val attribute from the element tag. */\nfunction valAttr(tag: string): string {\n const ns = tag.split(\":\")[0];\n return `${ns}:val`;\n}\n\nfunction onOff(tag: string, val: boolean | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val ? 1 : 0}\"/>` : \"\";\n}\n\nfunction numVal(tag: string, val: number | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val}\"/>` : \"\";\n}\n\nfunction strVal(tag: string, val: string | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${escapeXml(val)}\"/>` : \"\";\n}\n\n/** Build attribute string from key-value pairs, skipping undefined. */\nfunction attrStr(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [k, v] of Object.entries(attrs)) {\n if (v !== undefined) parts.push(`${k}=\"${escapeXml(String(v))}\"`);\n }\n return parts.join(\" \");\n}\n\n/** Self-closing element with attributes only. */\nfunction attrEl(tag: string, attrs: Record<string, string | number | boolean | undefined>): string {\n const a = attrStr(attrs);\n return a ? `<${tag} ${a}/>` : `<${tag}/>`;\n}\n\nfunction compatSetting(name: string, val: string | number, uri?: string): string {\n const u = uri ?? \"http://schemas.microsoft.com/office/word\";\n return `<w:compatSetting w:name=\"${escapeXml(name)}\" w:uri=\"${u}\" w:val=\"${val}\"/>`;\n}\n\n// ── Parse helpers ──\n\n/** Read a CT_OnOff child as boolean (presence true unless val is explicitly false). */\nfunction readOnOff(el: Element | undefined): boolean | undefined {\n if (!el || !el.name) return undefined;\n const v = attr(el, valAttr(el.name));\n return v !== \"false\" && v !== \"0\" && v !== \"off\";\n}\n\n/** Read an attribute as a number, or undefined if absent/unparseable. */\nfunction readNum(el: Element | undefined, name: string): number | undefined {\n if (!el) return undefined;\n const v = attr(el, name);\n if (v === undefined || v === \"\") return undefined;\n const n = parseInt(v, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\n/** Read an attribute as a string, or undefined if absent. */\nfunction readStr(el: Element | undefined, name: string): string | undefined {\n if (!el) return undefined;\n const v = attr(el, name);\n return v === undefined || v === \"\" ? undefined : v;\n}\n\n/** Read an attribute constrained to an enum; undefined if absent or not allowed. */\nfunction readEnum<T extends string>(\n el: Element | undefined,\n name: string,\n allowed: readonly T[],\n): T | undefined {\n const v = readStr(el, name);\n return v !== undefined && (allowed as readonly string[]).includes(v) ? (v as T) : undefined;\n}\n\n/** Shared password/crypto attributes (AG_TransitionalPassword) → options keys. */\nconst PASSWORD_ATTR_MAP: [string, string, boolean][] = [\n [\"hashValue\", \"w:hashValue\", false],\n [\"saltValue\", \"w:saltValue\", false],\n [\"hash\", \"w:hash\", false],\n [\"salt\", \"w:salt\", false],\n [\"spinCount\", \"w:spinCount\", true],\n [\"algorithmName\", \"w:algorithmName\", false],\n [\"cryptoAlgorithmClass\", \"w:cryptAlgorithmClass\", false],\n [\"cryptoAlgorithmSid\", \"w:cryptAlgorithmSid\", true],\n [\"cryptoAlgorithmType\", \"w:cryptAlgorithmType\", false],\n [\"cryptoProvider\", \"w:cryptProvider\", false],\n [\"cryptoProviderType\", \"w:cryptProviderType\", false],\n [\"cryptoProviderTypeExtension\", \"w:cryptProviderTypeExt\", true],\n [\"cryptoProviderTypeExtensionSource\", \"w:cryptProviderTypeExtSource\", false],\n [\"algorithmExtensionId\", \"w:algIdExt\", true],\n [\"algorithmExtensionSource\", \"w:algIdExtSource\", false],\n [\"cryptoSpinCount\", \"w:cryptSpinCount\", true],\n];\n\n/** Read shared password/crypto attributes into an options object. */\nfunction readPasswordAttrs(el: Element): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [key, xmlAttr, isNum] of PASSWORD_ATTR_MAP) {\n const v = attr(el, xmlAttr);\n if (v === undefined || v === \"\") continue;\n out[key] = isNum ? parseInt(v, 10) : v;\n }\n return out;\n}\n\n/**\n * CT_OnOff compat flag elements → CompatibilityOptions keys. The XML tag often\n * differs from the option key (e.g. wordPerfectJustification → w:wpJustification).\n * Order mirrors stringifyCompatibility so round-trip preserves element order.\n */\nconst COMPAT_FLAG_MAP: [string, string][] = [\n [\"useSingleBorderforContiguousCells\", \"w:useSingleBorderforContiguousCells\"],\n [\"wordPerfectJustification\", \"w:wpJustification\"],\n [\"noTabStopForHangingIndent\", \"w:noTabHangInd\"],\n [\"noLeading\", \"w:noLeading\"],\n [\"spaceForUnderline\", \"w:spaceForUL\"],\n [\"noColumnBalance\", \"w:noColumnBalance\"],\n [\"balanceSingleByteDoubleByteWidth\", \"w:balanceSingleByteDoubleByteWidth\"],\n [\"noExtraLineSpacing\", \"w:noExtraLineSpacing\"],\n [\"doNotLeaveBackslashAlone\", \"w:doNotLeaveBackslashAlone\"],\n [\"underlineTrailingSpaces\", \"w:ulTrailSpace\"],\n [\"doNotExpandShiftReturn\", \"w:doNotExpandShiftReturn\"],\n [\"spacingInWholePoints\", \"w:spacingInWholePoints\"],\n [\"lineWrapLikeWord6\", \"w:lineWrapLikeWord6\"],\n [\"printBodyTextBeforeHeader\", \"w:printBodyTextBeforeHeader\"],\n [\"printColorsBlack\", \"w:printColBlack\"],\n [\"spaceWidth\", \"w:wpSpaceWidth\"],\n [\"showBreaksInFrames\", \"w:showBreaksInFrames\"],\n [\"subFontBySize\", \"w:subFontBySize\"],\n [\"suppressBottomSpacing\", \"w:suppressBottomSpacing\"],\n [\"suppressTopSpacing\", \"w:suppressTopSpacing\"],\n [\"suppressSpacingAtTopOfPage\", \"w:suppressSpacingAtTopOfPage\"],\n [\"suppressTopSpacingWP\", \"w:suppressTopSpacingWP\"],\n [\"suppressSpBfAfterPgBrk\", \"w:suppressSpBfAfterPgBrk\"],\n [\"swapBordersFacingPages\", \"w:swapBordersFacingPages\"],\n [\"convertMailMergeEsc\", \"w:convMailMergeEsc\"],\n [\"truncateFontHeightsLikeWP6\", \"w:truncateFontHeightsLikeWP6\"],\n [\"macWordSmallCaps\", \"w:mwSmallCaps\"],\n [\"usePrinterMetrics\", \"w:usePrinterMetrics\"],\n [\"doNotSuppressParagraphBorders\", \"w:doNotSuppressParagraphBorders\"],\n [\"wrapTrailSpaces\", \"w:wrapTrailSpaces\"],\n [\"footnoteLayoutLikeWW8\", \"w:footnoteLayoutLikeWW8\"],\n [\"shapeLayoutLikeWW8\", \"w:shapeLayoutLikeWW8\"],\n [\"alignTablesRowByRow\", \"w:alignTablesRowByRow\"],\n [\"forgetLastTabAlignment\", \"w:forgetLastTabAlignment\"],\n [\"adjustLineHeightInTable\", \"w:adjustLineHeightInTable\"],\n [\"autoSpaceLikeWord95\", \"w:autoSpaceLikeWord95\"],\n [\"noSpaceRaiseLower\", \"w:noSpaceRaiseLower\"],\n [\"doNotUseHTMLParagraphAutoSpacing\", \"w:doNotUseHTMLParagraphAutoSpacing\"],\n [\"layoutRawTableWidth\", \"w:layoutRawTableWidth\"],\n [\"layoutTableRowsApart\", \"w:layoutTableRowsApart\"],\n [\"useWord97LineBreakRules\", \"w:useWord97LineBreakRules\"],\n [\"doNotBreakWrappedTables\", \"w:doNotBreakWrappedTables\"],\n [\"doNotSnapToGridInCell\", \"w:doNotSnapToGridInCell\"],\n [\"selectFieldWithFirstOrLastCharacter\", \"w:selectFldWithFirstOrLastChar\"],\n [\"applyBreakingRules\", \"w:applyBreakingRules\"],\n [\"doNotWrapTextWithPunctuation\", \"w:doNotWrapTextWithPunct\"],\n [\"doNotUseEastAsianBreakRules\", \"w:doNotUseEastAsianBreakRules\"],\n [\"useWord2002TableStyleRules\", \"w:useWord2002TableStyleRules\"],\n [\"growAutofit\", \"w:growAutofit\"],\n [\"useFELayout\", \"w:useFELayout\"],\n [\"useNormalStyleForList\", \"w:useNormalStyleForList\"],\n [\"doNotUseIndentAsNumberingTabStop\", \"w:doNotUseIndentAsNumberingTabStop\"],\n [\"useAlternateEastAsianLineBreakRules\", \"w:useAltKinsokuLineBreakRules\"],\n [\"allowSpaceOfSameStyleInTable\", \"w:allowSpaceOfSameStyleInTable\"],\n [\"doNotSuppressIndentation\", \"w:doNotSuppressIndentation\"],\n [\"doNotAutofitConstrainedTables\", \"w:doNotAutofitConstrainedTables\"],\n [\"autofitToFirstFixedWidthCell\", \"w:autofitToFirstFixedWidthCell\"],\n [\"underlineTabInNumberingList\", \"w:underlineTabInNumList\"],\n [\"displayHangulFixedWidth\", \"w:displayHangulFixedWidth\"],\n [\"splitPgBreakAndParaMark\", \"w:splitPgBreakAndParaMark\"],\n [\"doNotVerticallyAlignCellWithSp\", \"w:doNotVertAlignCellWithSp\"],\n [\"doNotBreakConstrainedForcedTable\", \"w:doNotBreakConstrainedForcedTable\"],\n [\"ignoreVerticalAlignmentInTextboxes\", \"w:doNotVertAlignInTxbx\"],\n [\"useAnsiKerningPairs\", \"w:useAnsiKerningPairs\"],\n [\"cachedColumnBalance\", \"w:cachedColBalance\"],\n];\n\n/** compatSetting names that map to dedicated sugar fields (not into compatSettings[]). */\nconst COMPAT_SETTING_SUGAR: Record<\n string,\n | \"version\"\n | \"overrideTableStyleFontSizeAndJustification\"\n | \"enableOpenTypeFeatures\"\n | \"doNotFlipMirrorIndents\"\n> = {\n compatibilityMode: \"version\",\n overrideTableStyleFontSizeAndJustification: \"overrideTableStyleFontSizeAndJustification\",\n enableOpenTypeFeatures: \"enableOpenTypeFeatures\",\n doNotFlipMirrorIndents: \"doNotFlipMirrorIndents\",\n};\n\n/** Parse w:footnotePr / w:endnotePr (CT_FtnDocProps / CT_EdnDocProps). */\nfunction parseFtnEdnPr(el: Element): Record<string, unknown> | undefined {\n const o: Record<string, unknown> = {};\n const pos = readStr(findChild(el, \"w:pos\"), \"w:val\");\n if (pos) o.pos = pos;\n const numFmtEl = findChild(el, \"w:numFmt\");\n if (numFmtEl) {\n const v = readStr(numFmtEl, \"w:val\");\n if (v) o.numFmt = v;\n const format = readStr(numFmtEl, \"w:format\");\n if (format) o.format = format;\n }\n const numStart = readNum(findChild(el, \"w:numStart\"), \"w:val\");\n if (numStart !== undefined) o.numStart = numStart;\n const numRestart = readStr(findChild(el, \"w:numRestart\"), \"w:val\");\n if (numRestart) o.numRestart = numRestart;\n return Object.keys(o).length > 0 ? o : undefined;\n}\n\n/** Parse w:compat (CT_Compat): on/off flag elements + w:compatSetting entries. */\nfunction parseCompatibility(el: Element): CompatibilityOptions | undefined {\n const o: Record<string, unknown> = {};\n const flagMap: Record<string, string> = Object.fromEntries(\n COMPAT_FLAG_MAP.map(([key, tag]) => [tag, key]),\n );\n const extras: CompatSettingOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.type !== \"element\" || !child.name) continue;\n const key = flagMap[child.name];\n if (key !== undefined) {\n o[key] = true;\n continue;\n }\n if (child.name === \"w:compatSetting\") {\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name === undefined || val === undefined) continue;\n const sugar = COMPAT_SETTING_SUGAR[name];\n if (sugar === \"version\") {\n const n = parseInt(val, 10);\n if (!Number.isNaN(n)) o.version = n;\n } else if (sugar !== undefined) {\n o[sugar] = val !== \"0\" && val !== \"false\";\n } else {\n extras.push({ name, val, uri: attr(child, \"w:uri\") });\n }\n }\n }\n if (extras.length > 0) o.compatSettings = extras;\n return Object.keys(o).length > 0 ? (o as CompatibilityOptions) : undefined;\n}\n\n/** Parse m:mathPr (CT_MathPr). */\nfunction parseMathPr(el: Element): MathPropertiesOptions | undefined {\n const o: Partial<MathPropertiesOptions> = {};\n const mathFont = readStr(findChild(el, \"m:mathFont\"), \"m:val\");\n if (mathFont) o.mathFont = mathFont;\n const binaryOperatorBreak = readEnum(findChild(el, \"m:brkBin\"), \"m:val\", [\n \"before\",\n \"after\",\n \"repeat\",\n ] as const);\n if (binaryOperatorBreak) o.binaryOperatorBreak = binaryOperatorBreak;\n const binaryOperatorBreakSubtraction = readEnum(findChild(el, \"m:brkBinSub\"), \"m:val\", [\n \"--\",\n \"-+\",\n \"+-\",\n ] as const);\n if (binaryOperatorBreakSubtraction)\n o.binaryOperatorBreakSubtraction = binaryOperatorBreakSubtraction;\n const smallFractions = readOnOff(findChild(el, \"m:smallFrac\"));\n if (smallFractions !== undefined) o.smallFractions = smallFractions;\n const displayDefaults = readOnOff(findChild(el, \"m:dispDef\"));\n if (displayDefaults !== undefined) o.displayDefaults = displayDefaults;\n const leftMargin = readNum(findChild(el, \"m:lMargin\"), \"m:val\");\n if (leftMargin !== undefined) o.leftMargin = leftMargin;\n const rightMargin = readNum(findChild(el, \"m:rMargin\"), \"m:val\");\n if (rightMargin !== undefined) o.rightMargin = rightMargin;\n const defaultJustification = readEnum(findChild(el, \"m:defJc\"), \"m:val\", [\n \"left\",\n \"right\",\n \"center\",\n \"centerGroup\",\n ] as const);\n if (defaultJustification) o.defaultJustification = defaultJustification;\n const preSpacing = readNum(findChild(el, \"m:preSp\"), \"m:val\");\n if (preSpacing !== undefined) o.preSpacing = preSpacing;\n const postSpacing = readNum(findChild(el, \"m:postSp\"), \"m:val\");\n if (postSpacing !== undefined) o.postSpacing = postSpacing;\n const interSpacing = readNum(findChild(el, \"m:interSp\"), \"m:val\");\n if (interSpacing !== undefined) o.interSpacing = interSpacing;\n const intraSpacing = readNum(findChild(el, \"m:intraSp\"), \"m:val\");\n if (intraSpacing !== undefined) o.intraSpacing = intraSpacing;\n const wrapIndent = readNum(findChild(el, \"m:wrapIndent\"), \"m:val\");\n if (wrapIndent !== undefined) o.wrapIndent = wrapIndent;\n const wrapRight = readOnOff(findChild(el, \"m:wrapRight\"));\n if (wrapRight !== undefined) o.wrapRight = wrapRight;\n const integralLimitLocation = readEnum(findChild(el, \"m:intLim\"), \"m:val\", [\n \"subSup\",\n \"undOvr\",\n ] as const);\n if (integralLimitLocation) o.integralLimitLocation = integralLimitLocation;\n const naryLimitLocation = readEnum(findChild(el, \"m:naryLim\"), \"m:val\", [\n \"subSup\",\n \"undOvr\",\n ] as const);\n if (naryLimitLocation) o.naryLimitLocation = naryLimitLocation;\n return Object.keys(o).length > 0 ? (o as MathPropertiesOptions) : undefined;\n}\n\n/** Parse w:captions (CT_Captions). */\nfunction parseCaptions(el: Element): CaptionsOptions | undefined {\n const captions: CaptionOptions[] = [];\n const autoCaptions: AutoCaptionOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.type !== \"element\") continue;\n if (child.name === \"w:caption\") {\n const c: CaptionOptions = { name: attr(child, \"w:name\") ?? \"\" };\n const pos = attr(child, \"w:pos\");\n if (pos) c.pos = pos as CaptionOptions[\"pos\"];\n const chapNum = attr(child, \"w:chapNum\");\n if (chapNum !== undefined) c.chapNum = chapNum === \"1\";\n const heading = attr(child, \"w:heading\");\n if (heading !== undefined) c.heading = parseInt(heading, 10);\n const noLabel = attr(child, \"w:noLabel\");\n if (noLabel !== undefined) c.noLabel = noLabel === \"1\";\n const numFmt = attr(child, \"w:numFmt\");\n if (numFmt) c.numFmt = numFmt;\n const sep = attr(child, \"w:sep\");\n if (sep) c.sep = sep as CaptionOptions[\"sep\"];\n captions.push(c);\n } else if (child.name === \"w:autoCaptions\") {\n for (const ac of child.elements ?? []) {\n if (ac.name !== \"w:autoCaption\") continue;\n const name = attr(ac, \"w:name\");\n const caption = attr(ac, \"w:caption\");\n if (name && caption) autoCaptions.push({ name, caption });\n }\n }\n }\n if (captions.length === 0) return undefined;\n const o: CaptionsOptions = { captions };\n if (autoCaptions.length > 0) o.autoCaptions = autoCaptions;\n return o;\n}\n\n/** Parse w:odso (CT_Odso). */\nfunction parseOdso(el: Element): OdsoOptions | undefined {\n const o: OdsoOptions = {};\n const udl = readStr(findChild(el, \"w:udl\"), \"w:val\");\n if (udl) o.udl = udl;\n const table = readStr(findChild(el, \"w:table\"), \"w:val\");\n if (table) o.table = table;\n const srcEl = findChild(el, \"w:src\");\n if (srcEl) {\n const rid = attr(srcEl, \"r:id\");\n if (rid) o.src = rid;\n }\n const colDelim = readNum(findChild(el, \"w:colDelim\"), \"w:val\");\n if (colDelim !== undefined) o.colDelim = colDelim;\n const type = readStr(findChild(el, \"w:type\"), \"w:val\");\n if (type) o.type = type as OdsoOptions[\"type\"];\n const fHdr = readOnOff(findChild(el, \"w:fHdr\"));\n if (fHdr !== undefined) o.fHdr = fHdr;\n const fieldMapData: OdsoFieldMapDataOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:fieldMapData\") continue;\n const fm: OdsoFieldMapDataOptions = {};\n const t = readStr(findChild(child, \"w:type\"), \"w:val\");\n if (t) fm.type = t as OdsoFieldMapDataOptions[\"type\"];\n const n = readStr(findChild(child, \"w:name\"), \"w:val\");\n if (n) fm.name = n;\n const mn = readStr(findChild(child, \"w:mappedName\"), \"w:val\");\n if (mn) fm.mappedName = mn;\n const col = readNum(findChild(child, \"w:column\"), \"w:val\");\n if (col !== undefined) fm.column = col;\n const lid = readStr(findChild(child, \"w:lid\"), \"w:val\");\n if (lid) fm.lid = lid;\n const dyn = readOnOff(findChild(child, \"w:dynamicAddress\"));\n if (dyn !== undefined) fm.dynamicAddress = dyn;\n if (Object.keys(fm).length > 0) fieldMapData.push(fm);\n }\n if (fieldMapData.length > 0) o.fieldMapData = fieldMapData;\n const recipientData: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:recipientData\") continue;\n const rid = attr(child, \"r:id\");\n if (rid) recipientData.push(rid);\n }\n if (recipientData.length > 0) o.recipientData = recipientData;\n const uniqueTag = readStr(findChild(el, \"w:uniqueTag\"), \"w:val\");\n if (uniqueTag) o.uniqueTag = uniqueTag;\n return Object.keys(o).length > 0 ? o : undefined;\n}\n\n/** Parse w:mailMerge (CT_MailMerge). */\nfunction parseMailMerge(el: Element): MailMergeOptions | undefined {\n const o: Partial<MailMergeOptions> = {};\n const mdt = readStr(findChild(el, \"w:mainDocumentType\"), \"w:val\");\n if (mdt) o.mainDocumentType = mdt as MailMergeOptions[\"mainDocumentType\"];\n const dataType = readStr(findChild(el, \"w:dataType\"), \"w:val\");\n if (dataType) o.dataType = dataType as MailMergeOptions[\"dataType\"];\n const dest = readStr(findChild(el, \"w:destination\"), \"w:val\");\n if (dest) o.destination = dest as MailMergeOptions[\"destination\"];\n const connectString = readStr(findChild(el, \"w:connectString\"), \"w:val\");\n if (connectString) o.connectString = connectString;\n const query = readStr(findChild(el, \"w:query\"), \"w:val\");\n if (query) o.query = query;\n const dsEl = findChild(el, \"w:dataSource\");\n if (dsEl) {\n const rid = attr(dsEl, \"r:id\");\n if (rid) o.dataSource = rid;\n }\n const hsEl = findChild(el, \"w:headerSource\");\n if (hsEl) {\n const rid = attr(hsEl, \"r:id\");\n if (rid) o.headerSource = rid;\n }\n const linkToQuery = readOnOff(findChild(el, \"w:linkToQuery\"));\n if (linkToQuery !== undefined) o.linkToQuery = linkToQuery;\n const doNotSuppress = readOnOff(findChild(el, \"w:doNotSuppressBlankLines\"));\n if (doNotSuppress !== undefined) o.doNotSuppressBlankLines = doNotSuppress;\n const addressFieldName = readStr(findChild(el, \"w:addressFieldName\"), \"w:val\");\n if (addressFieldName) o.addressFieldName = addressFieldName;\n const mailSubject = readStr(findChild(el, \"w:mailSubject\"), \"w:val\");\n if (mailSubject) o.mailSubject = mailSubject;\n const mailAsAttachment = readOnOff(findChild(el, \"w:mailAsAttachment\"));\n if (mailAsAttachment !== undefined) o.mailAsAttachment = mailAsAttachment;\n const viewMergedData = readOnOff(findChild(el, \"w:viewMergedData\"));\n if (viewMergedData !== undefined) o.viewMergedData = viewMergedData;\n const activeRecord = readNum(findChild(el, \"w:activeRecord\"), \"w:val\");\n if (activeRecord !== undefined) o.activeRecord = activeRecord;\n const checkErrors = readNum(findChild(el, \"w:checkErrors\"), \"w:val\");\n if (checkErrors !== undefined) o.checkErrors = checkErrors;\n const active = readOnOff(findChild(el, \"w:active\"));\n if (active !== undefined) o.active = active;\n const recipientsEl = findChild(el, \"w:recipients\");\n if (recipientsEl) {\n const rid = attr(recipientsEl, \"r:id\");\n if (rid) o.recipients = rid;\n }\n const odsoEl = findChild(el, \"w:odso\");\n if (odsoEl) {\n const odso = parseOdso(odsoEl);\n if (odso) o.odso = odso;\n }\n if (Object.keys(o).length === 0) return undefined;\n return o as MailMergeOptions;\n}\n\n// ── Password derivation ──\n\ninterface DerivedPassword {\n hashValue: string;\n saltValue: string;\n spinCount: number;\n algorithmName: string;\n}\n\nfunction maybeDerive(\n password: string | undefined,\n hashValue: string | undefined,\n): DerivedPassword | undefined {\n return password !== undefined && hashValue === undefined\n ? derivePasswordHash(password)\n : undefined;\n}\n\n// ── Complex sub-elements ──\n\n/** Valid w:documentProtection/@w:edit values (ST_DocProtect). */\nconst DOC_PROTECT_EDITS = [\"none\", \"readOnly\", \"comments\", \"trackedChanges\", \"forms\"] as const;\n\nfunction stringifyDocProtect(opts: DocumentProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = { \"w:enforcement\": \"1\" };\n if (opts.edit !== undefined) attrs[\"w:edit\"] = opts.edit;\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"1\" : \"0\";\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:documentProtection\", attrs);\n}\n\nfunction stringifyWriteProtect(opts: WriteProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = {};\n if (opts.recommended !== undefined) attrs[\"w:recommended\"] = opts.recommended ? \"1\" : \"0\";\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:writeProtection\", attrs);\n}\n\nfunction stringifyRevisionView(opts: RevisionViewOptions): string {\n const attrs: Record<string, string> = {};\n if (opts.markup !== undefined) attrs[\"w:markup\"] = opts.markup ? \"true\" : \"false\";\n if (opts.comments !== undefined) attrs[\"w:comments\"] = opts.comments ? \"true\" : \"false\";\n if (opts.insDel !== undefined) attrs[\"w:insDel\"] = opts.insDel ? \"true\" : \"false\";\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"true\" : \"false\";\n if (opts.inkAnnotations !== undefined)\n attrs[\"w:inkAnnotations\"] = opts.inkAnnotations ? \"true\" : \"false\";\n return attrEl(\"w:revisionView\", attrs);\n}\n\nfunction stringifyMailMerge(opts: MailMergeOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:mainDocumentType\", opts.mainDocumentType));\n p.push(onOff(\"w:linkToQuery\", opts.linkToQuery));\n p.push(strVal(\"w:dataType\", opts.dataType));\n p.push(strVal(\"w:connectString\", opts.connectString));\n p.push(strVal(\"w:query\", opts.query));\n if (opts.dataSource !== undefined) p.push(attrEl(\"w:dataSource\", { \"r:id\": opts.dataSource }));\n if (opts.headerSource !== undefined)\n p.push(attrEl(\"w:headerSource\", { \"r:id\": opts.headerSource }));\n p.push(onOff(\"w:doNotSuppressBlankLines\", opts.doNotSuppressBlankLines));\n p.push(strVal(\"w:destination\", opts.destination));\n p.push(strVal(\"w:addressFieldName\", opts.addressFieldName));\n p.push(strVal(\"w:mailSubject\", opts.mailSubject));\n p.push(onOff(\"w:mailAsAttachment\", opts.mailAsAttachment));\n p.push(onOff(\"w:viewMergedData\", opts.viewMergedData));\n p.push(numVal(\"w:activeRecord\", opts.activeRecord));\n p.push(numVal(\"w:checkErrors\", opts.checkErrors));\n if (opts.odso !== undefined) p.push(stringifyOdso(opts.odso));\n p.push(onOff(\"w:active\", opts.active));\n if (opts.recipients !== undefined) p.push(attrEl(\"w:recipients\", { \"r:id\": opts.recipients }));\n return `<w:mailMerge>${p.join(\"\")}</w:mailMerge>`;\n}\n\nfunction stringifyOdso(opts: OdsoOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:udl\", opts.udl));\n p.push(strVal(\"w:table\", opts.table));\n if (opts.src !== undefined) p.push(attrEl(\"w:src\", { \"r:id\": opts.src }));\n p.push(numVal(\"w:colDelim\", opts.colDelim));\n p.push(strVal(\"w:type\", opts.type));\n p.push(onOff(\"w:fHdr\", opts.fHdr));\n if (opts.fieldMapData !== undefined) {\n for (const fm of opts.fieldMapData) p.push(stringifyOdsoFieldMap(fm));\n }\n if (opts.recipientData !== undefined) {\n for (const rd of opts.recipientData) p.push(attrEl(\"w:recipientData\", { \"r:id\": rd }));\n }\n p.push(strVal(\"w:uniqueTag\", opts.uniqueTag));\n return `<w:odso>${p.join(\"\")}</w:odso>`;\n}\n\nfunction stringifyOdsoFieldMap(opts: OdsoFieldMapDataOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:type\", opts.type));\n p.push(strVal(\"w:name\", opts.name));\n p.push(strVal(\"w:mappedName\", opts.mappedName));\n p.push(numVal(\"w:column\", opts.column));\n p.push(strVal(\"w:lid\", opts.lid));\n p.push(onOff(\"w:dynamicAddress\", opts.dynamicAddress));\n return `<w:fieldMapData>${p.join(\"\")}</w:fieldMapData>`;\n}\n\nfunction stringifyFootnotePr(opts: FootnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:footnotePr>${p.join(\"\")}</w:footnotePr>`;\n}\n\nfunction stringifyEndnotePr(opts: EndnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:endnotePr>${p.join(\"\")}</w:endnotePr>`;\n}\n\nfunction stringifyRsids(opts: RsidsOptions): string {\n const p: string[] = [];\n if (opts.rsidRoot !== undefined) p.push(attrEl(\"w:rsidRoot\", { \"w:val\": opts.rsidRoot }));\n if (opts.rsids !== undefined) {\n for (const rsid of opts.rsids) p.push(attrEl(\"w:rsid\", { \"w:val\": rsid }));\n }\n return `<w:rsids>${p.join(\"\")}</w:rsids>`;\n}\n\nfunction stringifyReadModeInkLockDown(opts: ReadModeInkLockDownOptions): string {\n return attrEl(\"w:readModeInkLockDown\", {\n \"w:actualPg\": opts.actualPg === false ? \"0\" : \"1\",\n \"w:w\": opts.w,\n \"w:h\": opts.h,\n \"w:fontSz\": opts.fontSz,\n });\n}\n\nfunction stringifyCaptions(opts: CaptionsOptions): string {\n const p: string[] = [];\n for (const cap of opts.captions) {\n const attrs: Record<string, string | number> = { \"w:name\": cap.name };\n if (cap.pos !== undefined) attrs[\"w:pos\"] = cap.pos;\n if (cap.chapNum !== undefined) attrs[\"w:chapNum\"] = cap.chapNum ? \"1\" : \"0\";\n if (cap.heading !== undefined) attrs[\"w:heading\"] = cap.heading;\n if (cap.noLabel !== undefined) attrs[\"w:noLabel\"] = cap.noLabel ? \"1\" : \"0\";\n if (cap.numFmt !== undefined) attrs[\"w:numFmt\"] = cap.numFmt;\n if (cap.sep !== undefined) attrs[\"w:sep\"] = cap.sep;\n p.push(attrEl(\"w:caption\", attrs));\n }\n if (opts.autoCaptions?.length) {\n const acXml = opts.autoCaptions\n .map((ac) => attrEl(\"w:autoCaption\", { \"w:name\": ac.name, \"w:caption\": ac.caption }))\n .join(\"\");\n p.push(`<w:autoCaptions>${acXml}</w:autoCaptions>`);\n }\n return `<w:captions>${p.join(\"\")}</w:captions>`;\n}\n\nfunction stringifyMathPr(opts: MathPropertiesOptions): string {\n const p: string[] = [];\n if (opts.mathFont !== undefined) p.push(attrEl(\"m:mathFont\", { \"m:val\": opts.mathFont }));\n if (opts.binaryOperatorBreak !== undefined)\n p.push(attrEl(\"m:brkBin\", { \"m:val\": opts.binaryOperatorBreak }));\n if (opts.binaryOperatorBreakSubtraction !== undefined)\n p.push(attrEl(\"m:brkBinSub\", { \"m:val\": opts.binaryOperatorBreakSubtraction }));\n p.push(onOff(\"m:smallFrac\", opts.smallFractions));\n p.push(onOff(\"m:dispDef\", opts.displayDefaults));\n p.push(numVal(\"m:lMargin\", opts.leftMargin));\n p.push(numVal(\"m:rMargin\", opts.rightMargin));\n if (opts.defaultJustification !== undefined)\n p.push(attrEl(\"m:defJc\", { \"m:val\": opts.defaultJustification }));\n p.push(numVal(\"m:preSp\", opts.preSpacing));\n p.push(numVal(\"m:postSp\", opts.postSpacing));\n p.push(numVal(\"m:interSp\", opts.interSpacing));\n p.push(numVal(\"m:intraSp\", opts.intraSpacing));\n p.push(numVal(\"m:wrapIndent\", opts.wrapIndent));\n p.push(onOff(\"m:wrapRight\", opts.wrapRight));\n if (opts.integralLimitLocation !== undefined)\n p.push(attrEl(\"m:intLim\", { \"m:val\": opts.integralLimitLocation }));\n if (opts.naryLimitLocation !== undefined)\n p.push(attrEl(\"m:naryLim\", { \"m:val\": opts.naryLimitLocation }));\n return `<m:mathPr>${p.join(\"\")}</m:mathPr>`;\n}\n\nfunction stringifyColorSchemeMapping(\n opts: NonNullable<SettingsOptions[\"colorSchemeMapping\"]>,\n): string {\n const attrs: Record<string, string> = {};\n if (opts.bg1 !== undefined) attrs[\"w:bg1\"] = opts.bg1;\n if (opts.t1 !== undefined) attrs[\"w:t1\"] = opts.t1;\n if (opts.bg2 !== undefined) attrs[\"w:bg2\"] = opts.bg2;\n if (opts.t2 !== undefined) attrs[\"w:t2\"] = opts.t2;\n if (opts.accent1 !== undefined) attrs[\"w:accent1\"] = opts.accent1;\n if (opts.accent2 !== undefined) attrs[\"w:accent2\"] = opts.accent2;\n if (opts.accent3 !== undefined) attrs[\"w:accent3\"] = opts.accent3;\n if (opts.accent4 !== undefined) attrs[\"w:accent4\"] = opts.accent4;\n if (opts.accent5 !== undefined) attrs[\"w:accent5\"] = opts.accent5;\n if (opts.accent6 !== undefined) attrs[\"w:accent6\"] = opts.accent6;\n if (opts.hyperlink !== undefined) attrs[\"w:hyperlink\"] = opts.hyperlink;\n if (opts.followedHyperlink !== undefined) attrs[\"w:followedHyperlink\"] = opts.followedHyperlink;\n return attrEl(\"w:clrSchemeMapping\", attrs);\n}\n\n// ── Compatibility ──\n\nfunction stringifyCompatibility(opts: CompatibilityOptions): string {\n const p: string[] = [];\n // Individual compat on/off elements (XSD order)\n if (opts.useSingleBorderforContiguousCells)\n p.push(onOff(\"w:useSingleBorderforContiguousCells\", true));\n if (opts.wordPerfectJustification) p.push(onOff(\"w:wpJustification\", true));\n if (opts.noTabStopForHangingIndent) p.push(onOff(\"w:noTabHangInd\", true));\n if (opts.noLeading) p.push(onOff(\"w:noLeading\", true));\n if (opts.spaceForUnderline) p.push(onOff(\"w:spaceForUL\", true));\n if (opts.noColumnBalance) p.push(onOff(\"w:noColumnBalance\", true));\n if (opts.balanceSingleByteDoubleByteWidth)\n p.push(onOff(\"w:balanceSingleByteDoubleByteWidth\", true));\n if (opts.noExtraLineSpacing) p.push(onOff(\"w:noExtraLineSpacing\", true));\n if (opts.doNotLeaveBackslashAlone) p.push(onOff(\"w:doNotLeaveBackslashAlone\", true));\n if (opts.underlineTrailingSpaces) p.push(onOff(\"w:ulTrailSpace\", true));\n if (opts.doNotExpandShiftReturn) p.push(onOff(\"w:doNotExpandShiftReturn\", true));\n if (opts.spacingInWholePoints) p.push(onOff(\"w:spacingInWholePoints\", true));\n if (opts.lineWrapLikeWord6) p.push(onOff(\"w:lineWrapLikeWord6\", true));\n if (opts.printBodyTextBeforeHeader) p.push(onOff(\"w:printBodyTextBeforeHeader\", true));\n if (opts.printColorsBlack) p.push(onOff(\"w:printColBlack\", true));\n if (opts.spaceWidth) p.push(onOff(\"w:wpSpaceWidth\", true));\n if (opts.showBreaksInFrames) p.push(onOff(\"w:showBreaksInFrames\", true));\n if (opts.subFontBySize) p.push(onOff(\"w:subFontBySize\", true));\n if (opts.suppressBottomSpacing) p.push(onOff(\"w:suppressBottomSpacing\", true));\n if (opts.suppressTopSpacing) p.push(onOff(\"w:suppressTopSpacing\", true));\n if (opts.suppressSpacingAtTopOfPage) p.push(onOff(\"w:suppressSpacingAtTopOfPage\", true));\n if (opts.suppressTopSpacingWP) p.push(onOff(\"w:suppressTopSpacingWP\", true));\n if (opts.suppressSpBfAfterPgBrk) p.push(onOff(\"w:suppressSpBfAfterPgBrk\", true));\n if (opts.swapBordersFacingPages) p.push(onOff(\"w:swapBordersFacingPages\", true));\n if (opts.convertMailMergeEsc) p.push(onOff(\"w:convMailMergeEsc\", true));\n if (opts.truncateFontHeightsLikeWP6) p.push(onOff(\"w:truncateFontHeightsLikeWP6\", true));\n if (opts.macWordSmallCaps) p.push(onOff(\"w:mwSmallCaps\", true));\n if (opts.usePrinterMetrics) p.push(onOff(\"w:usePrinterMetrics\", true));\n if (opts.doNotSuppressParagraphBorders) p.push(onOff(\"w:doNotSuppressParagraphBorders\", true));\n if (opts.wrapTrailSpaces) p.push(onOff(\"w:wrapTrailSpaces\", true));\n if (opts.footnoteLayoutLikeWW8) p.push(onOff(\"w:footnoteLayoutLikeWW8\", true));\n if (opts.shapeLayoutLikeWW8) p.push(onOff(\"w:shapeLayoutLikeWW8\", true));\n if (opts.alignTablesRowByRow) p.push(onOff(\"w:alignTablesRowByRow\", true));\n if (opts.forgetLastTabAlignment) p.push(onOff(\"w:forgetLastTabAlignment\", true));\n if (opts.adjustLineHeightInTable) p.push(onOff(\"w:adjustLineHeightInTable\", true));\n if (opts.autoSpaceLikeWord95) p.push(onOff(\"w:autoSpaceLikeWord95\", true));\n if (opts.noSpaceRaiseLower) p.push(onOff(\"w:noSpaceRaiseLower\", true));\n if (opts.doNotUseHTMLParagraphAutoSpacing)\n p.push(onOff(\"w:doNotUseHTMLParagraphAutoSpacing\", true));\n if (opts.layoutRawTableWidth) p.push(onOff(\"w:layoutRawTableWidth\", true));\n if (opts.layoutTableRowsApart) p.push(onOff(\"w:layoutTableRowsApart\", true));\n if (opts.useWord97LineBreakRules) p.push(onOff(\"w:useWord97LineBreakRules\", true));\n if (opts.doNotBreakWrappedTables) p.push(onOff(\"w:doNotBreakWrappedTables\", true));\n if (opts.doNotSnapToGridInCell) p.push(onOff(\"w:doNotSnapToGridInCell\", true));\n if (opts.selectFieldWithFirstOrLastCharacter)\n p.push(onOff(\"w:selectFldWithFirstOrLastChar\", true));\n if (opts.applyBreakingRules) p.push(onOff(\"w:applyBreakingRules\", true));\n if (opts.doNotWrapTextWithPunctuation) p.push(onOff(\"w:doNotWrapTextWithPunct\", true));\n if (opts.doNotUseEastAsianBreakRules) p.push(onOff(\"w:doNotUseEastAsianBreakRules\", true));\n if (opts.useWord2002TableStyleRules) p.push(onOff(\"w:useWord2002TableStyleRules\", true));\n if (opts.growAutofit) p.push(onOff(\"w:growAutofit\", true));\n if (opts.useFELayout) p.push(onOff(\"w:useFELayout\", true));\n if (opts.useNormalStyleForList) p.push(onOff(\"w:useNormalStyleForList\", true));\n if (opts.doNotUseIndentAsNumberingTabStop)\n p.push(onOff(\"w:doNotUseIndentAsNumberingTabStop\", true));\n if (opts.useAlternateEastAsianLineBreakRules)\n p.push(onOff(\"w:useAltKinsokuLineBreakRules\", true));\n if (opts.allowSpaceOfSameStyleInTable) p.push(onOff(\"w:allowSpaceOfSameStyleInTable\", true));\n if (opts.doNotSuppressIndentation) p.push(onOff(\"w:doNotSuppressIndentation\", true));\n if (opts.doNotAutofitConstrainedTables) p.push(onOff(\"w:doNotAutofitConstrainedTables\", true));\n if (opts.autofitToFirstFixedWidthCell) p.push(onOff(\"w:autofitToFirstFixedWidthCell\", true));\n if (opts.underlineTabInNumberingList) p.push(onOff(\"w:underlineTabInNumList\", true));\n if (opts.displayHangulFixedWidth) p.push(onOff(\"w:displayHangulFixedWidth\", true));\n if (opts.splitPgBreakAndParaMark) p.push(onOff(\"w:splitPgBreakAndParaMark\", true));\n if (opts.doNotVerticallyAlignCellWithSp) p.push(onOff(\"w:doNotVertAlignCellWithSp\", true));\n if (opts.doNotBreakConstrainedForcedTable)\n p.push(onOff(\"w:doNotBreakConstrainedForcedTable\", true));\n if (opts.ignoreVerticalAlignmentInTextboxes) p.push(onOff(\"w:doNotVertAlignInTxbx\", true));\n if (opts.useAnsiKerningPairs) p.push(onOff(\"w:useAnsiKerningPairs\", true));\n if (opts.cachedColumnBalance) p.push(onOff(\"w:cachedColBalance\", true));\n // compatSetting elements last (XSD order)\n if (opts.version) p.push(compatSetting(\"compatibilityMode\", opts.version));\n if (opts.overrideTableStyleFontSizeAndJustification)\n p.push(compatSetting(\"overrideTableStyleFontSizeAndJustification\", 1));\n if (opts.enableOpenTypeFeatures) p.push(compatSetting(\"enableOpenTypeFeatures\", 1));\n if (opts.doNotFlipMirrorIndents) p.push(compatSetting(\"doNotFlipMirrorIndents\", 1));\n\n // Additional compatSetting entries (sugar fields above take precedence on name clash)\n if (opts.compatSettings) {\n const emitted = new Set<string>();\n if (opts.version) emitted.add(\"compatibilityMode\");\n if (opts.overrideTableStyleFontSizeAndJustification)\n emitted.add(\"overrideTableStyleFontSizeAndJustification\");\n if (opts.enableOpenTypeFeatures) emitted.add(\"enableOpenTypeFeatures\");\n if (opts.doNotFlipMirrorIndents) emitted.add(\"doNotFlipMirrorIndents\");\n for (const cs of opts.compatSettings) {\n if (emitted.has(cs.name)) continue;\n p.push(compatSetting(cs.name, cs.val, cs.uri));\n emitted.add(cs.name);\n }\n }\n return p.length ? `<w:compat>${p.join(\"\")}</w:compat>` : \"\";\n}\n\n// ── Namespace attributes ──\n\nconst SETTINGS_NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n// ── Descriptor ──\n\nexport const settingsDesc: CustomDescriptor<SettingsOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n // Round-trip: when parse captured the settings part verbatim, re-emit it\n // as-is (the structured path below only covers a subset of CT_Settings).\n // Use captured root attributes (xmlns:* + mc:Ignorable) so source-specific\n // namespaces (xmlns:sl, xmlns:wpsCustomData, …) are preserved.\n if (opts.rawXml !== undefined) {\n const ns = opts.rootAttributes ? attrStr(opts.rootAttributes) : SETTINGS_NS;\n return `<w:settings ${ns}>${opts.rawXml}</w:settings>`;\n }\n\n const p: string[] = [];\n\n // XSD CT_Settings sequence order\n if (opts.writeProtection !== undefined) p.push(stringifyWriteProtect(opts.writeProtection));\n if (opts.view !== undefined) p.push(attrEl(\"w:view\", { \"w:val\": opts.view }));\n if (opts.zoom !== undefined)\n p.push(attrEl(\"w:zoom\", { \"w:percent\": opts.zoom.percent ?? 100, \"w:val\": opts.zoom.val }));\n p.push(onOff(\"w:removePersonalInformation\", opts.removePersonalInformation));\n p.push(onOff(\"w:removeDateAndTime\", opts.removeDateAndTime));\n p.push(onOff(\"w:displayBackgroundShape\", opts.displayBackgroundShape));\n p.push(onOff(\"w:doNotDisplayPageBoundaries\", opts.doNotDisplayPageBoundaries));\n p.push(onOff(\"w:printPostScriptOverText\", opts.printPostScriptOverText));\n p.push(onOff(\"w:printFractionalCharacterWidth\", opts.printFractionalCharacterWidth));\n p.push(onOff(\"w:printFormsData\", opts.printFormsData));\n p.push(onOff(\"w:embedTrueTypeFonts\", opts.embedTrueTypeFonts));\n p.push(onOff(\"w:embedSystemFonts\", opts.embedSystemFonts));\n p.push(onOff(\"w:saveSubsetFonts\", opts.saveSubsetFonts));\n p.push(onOff(\"w:saveFormsData\", opts.saveFormsData));\n p.push(onOff(\"w:mirrorMargins\", opts.mirrorMargins));\n p.push(onOff(\"w:alignBordersAndEdges\", opts.alignBordersAndEdges));\n p.push(onOff(\"w:bordersDoNotSurroundHeader\", opts.bordersDoNotSurroundHeader));\n p.push(onOff(\"w:bordersDoNotSurroundFooter\", opts.bordersDoNotSurroundFooter));\n p.push(onOff(\"w:gutterAtTop\", opts.gutterAtTop));\n p.push(onOff(\"w:hideSpellingErrors\", opts.hideSpellingErrors));\n p.push(onOff(\"w:hideGrammaticalErrors\", opts.hideGrammaticalErrors));\n\n // activeWritingStyle\n if (opts.activeWritingStyle !== undefined) {\n for (const ws of opts.activeWritingStyle) {\n const attrs: Record<string, string | number | boolean> = {};\n if (ws.lang !== undefined) attrs[\"w:lang\"] = ws.lang;\n if (ws.vendorID !== undefined) attrs[\"w:vendorID\"] = ws.vendorID;\n if (ws.dllVersion !== undefined) attrs[\"w:dllVersion\"] = ws.dllVersion;\n if (ws.nlCheck !== undefined) attrs[\"w:nlCheck\"] = ws.nlCheck;\n if (ws.checkStyle !== undefined) attrs[\"w:checkStyle\"] = ws.checkStyle;\n if (ws.appCheck !== undefined) attrs[\"w:appCheck\"] = ws.appCheck;\n if (ws.appName !== undefined) attrs[\"w:appName\"] = ws.appName;\n p.push(attrEl(\"w:activeWritingStyle\", attrs));\n }\n }\n\n // proofState\n if (opts.proofState !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.proofState.spelling !== undefined) attrs[\"w:spelling\"] = opts.proofState.spelling;\n if (opts.proofState.grammar !== undefined) attrs[\"w:grammar\"] = opts.proofState.grammar;\n p.push(attrEl(\"w:proofState\", attrs));\n }\n\n p.push(onOff(\"w:formsDesign\", opts.formsDesign));\n\n if (opts.attachedTemplate !== undefined)\n p.push(attrEl(\"w:attachedTemplate\", { \"r:id\": opts.attachedTemplate }));\n p.push(onOff(\"w:linkStyles\", opts.linkStyles));\n\n // stylePaneFormatFilter\n if (opts.stylePaneFormatFilter !== undefined) {\n const f = opts.stylePaneFormatFilter;\n const attrs: Record<string, string> = {};\n const flags: [keyof typeof f, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n [\"latentStyles\", \"w:latentStyles\"],\n ];\n for (const [prop, xmlKey] of flags) {\n if (f[prop] !== undefined) attrs[xmlKey] = f[prop] ? \"1\" : \"0\";\n }\n p.push(attrEl(\"w:stylePaneFormatFilter\", attrs));\n }\n\n p.push(strVal(\"w:stylePaneSortMethod\", opts.stylePaneSortMethod));\n p.push(strVal(\"w:documentType\", opts.documentType));\n\n if (opts.revisionView !== undefined) p.push(stringifyRevisionView(opts.revisionView));\n p.push(onOff(\"w:trackRevisions\", opts.trackRevisions));\n p.push(onOff(\"w:doNotTrackMoves\", opts.doNotTrackMoves));\n p.push(onOff(\"w:doNotTrackFormatting\", opts.doNotTrackFormatting));\n\n if (opts.mailMerge !== undefined) p.push(stringifyMailMerge(opts.mailMerge));\n if (opts.documentProtection !== undefined) p.push(stringifyDocProtect(opts.documentProtection));\n\n p.push(onOff(\"w:autoFormatOverride\", opts.autoFormatOverride));\n p.push(onOff(\"w:styleLockTheme\", opts.styleLockTheme));\n p.push(onOff(\"w:styleLockQFSet\", opts.styleLockQFSet));\n\n // defaultTabStop — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.defaultTabStop !== undefined) p.push(numVal(\"w:defaultTabStop\", opts.defaultTabStop)!);\n\n // hyphenation\n p.push(onOff(\"w:autoHyphenation\", opts.hyphenation?.autoHyphenation));\n p.push(numVal(\"w:consecutiveHyphenLimit\", opts.hyphenation?.consecutiveHyphenLimit));\n p.push(numVal(\"w:hyphenationZone\", opts.hyphenation?.hyphenationZone));\n p.push(onOff(\"w:doNotHyphenateCaps\", opts.hyphenation?.doNotHyphenateCaps));\n\n p.push(onOff(\"w:showEnvelope\", opts.showEnvelope));\n p.push(numVal(\"w:summaryLength\", opts.summaryLength));\n p.push(strVal(\"w:clickAndTypeStyle\", opts.clickAndTypeStyle));\n p.push(strVal(\"w:defaultTableStyle\", opts.defaultTableStyle));\n p.push(onOff(\"w:evenAndOddHeaders\", opts.evenAndOddHeaders));\n p.push(onOff(\"w:bookFoldRevPrinting\", opts.bookFoldRevPrinting));\n p.push(onOff(\"w:bookFoldPrinting\", opts.bookFoldPrinting));\n p.push(numVal(\"w:bookFoldPrintingSheets\", opts.bookFoldPrintingSheets));\n p.push(numVal(\"w:drawingGridHorizontalSpacing\", opts.drawingGridHorizontalSpacing));\n p.push(numVal(\"w:drawingGridVerticalSpacing\", opts.drawingGridVerticalSpacing));\n p.push(numVal(\"w:displayHorizontalDrawingGridEvery\", opts.displayHorizontalDrawingGridEvery));\n p.push(numVal(\"w:displayVerticalDrawingGridEvery\", opts.displayVerticalDrawingGridEvery));\n p.push(numVal(\"w:drawingGridHorizontalOrigin\", opts.drawingGridHorizontalOrigin));\n p.push(numVal(\"w:drawingGridVerticalOrigin\", opts.drawingGridVerticalOrigin));\n p.push(\n onOff(\"w:doNotUseMarginsForDrawingGridOrigin\", opts.doNotUseMarginsForDrawingGridOrigin),\n );\n p.push(onOff(\"w:doNotShadeFormData\", opts.doNotShadeFormData));\n\n // characterSpacingControl — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.characterSpacingControl !== undefined) {\n p.push(strVal(\"w:characterSpacingControl\", opts.characterSpacingControl)!);\n }\n\n p.push(onOff(\"w:noPunctuationKerning\", opts.noPunctuationKerning));\n p.push(onOff(\"w:printTwoOnOne\", opts.printTwoOnOne));\n p.push(onOff(\"w:strictFirstAndLastChars\", opts.strictFirstAndLastChars));\n\n if (opts.noLineBreaksAfter !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksAfter.lang !== undefined) attrs[\"w:lang\"] = opts.noLineBreaksAfter.lang;\n if (opts.noLineBreaksAfter.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksAfter.val;\n p.push(attrEl(\"w:noLineBreaksAfter\", attrs));\n }\n if (opts.noLineBreaksBefore !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksBefore.lang !== undefined)\n attrs[\"w:lang\"] = opts.noLineBreaksBefore.lang;\n if (opts.noLineBreaksBefore.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksBefore.val;\n p.push(attrEl(\"w:noLineBreaksBefore\", attrs));\n }\n\n p.push(onOff(\"w:savePreviewPicture\", opts.savePreviewPicture));\n p.push(onOff(\"w:doNotValidateAgainstSchema\", opts.doNotValidateAgainstSchema));\n p.push(onOff(\"w:saveInvalidXml\", opts.saveInvalidXml));\n p.push(onOff(\"w:ignoreMixedContent\", opts.ignoreMixedContent));\n p.push(onOff(\"w:alwaysShowPlaceholderText\", opts.alwaysShowPlaceholderText));\n p.push(onOff(\"w:doNotDemarcateInvalidXml\", opts.doNotDemarcateInvalidXml));\n p.push(onOff(\"w:saveXmlDataOnly\", opts.saveXmlDataOnly));\n p.push(onOff(\"w:useXSLTWhenSaving\", opts.useXSLTWhenSaving));\n\n if (opts.saveThroughXslt !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.saveThroughXslt.id !== undefined) attrs[\"r:id\"] = opts.saveThroughXslt.id;\n if (opts.saveThroughXslt.val !== undefined) attrs[\"w:val\"] = opts.saveThroughXslt.val;\n if (opts.saveThroughXslt.solutionID !== undefined)\n attrs[\"w:solutionID\"] = opts.saveThroughXslt.solutionID;\n p.push(attrEl(\"w:saveThroughXslt\", attrs));\n }\n\n p.push(onOff(\"w:showXMLTags\", opts.showXMLTags));\n p.push(onOff(\"w:alwaysMergeEmptyNamespace\", opts.alwaysMergeEmptyNamespace));\n p.push(onOff(\"w:updateFields\", opts.updateFields));\n\n if (opts.hdrShapeDefaults !== undefined)\n p.push(`<w:hdrShapeDefaults>${opts.hdrShapeDefaults}</w:hdrShapeDefaults>`);\n if (opts.footnotePr !== undefined) p.push(stringifyFootnotePr(opts.footnotePr));\n if (opts.endnotePr !== undefined) p.push(stringifyEndnotePr(opts.endnotePr));\n\n // Compatibility — optional (CT_Settings minOccurs=0); emit only when configured\n const compatXml = stringifyCompatibility({\n ...opts.compatibility,\n version: opts.compatibility?.version ?? opts.compatibilityModeVersion,\n });\n if (compatXml) p.push(compatXml);\n\n // docVars\n if (opts.docVars?.length) {\n const vars = opts.docVars\n .map((v) => attrEl(\"w:docVar\", { \"w:name\": v.name, \"w:val\": v.val }))\n .join(\"\");\n p.push(`<w:docVars>${vars}</w:docVars>`);\n }\n\n if (opts.rsids !== undefined) p.push(stringifyRsids(opts.rsids));\n if (opts.mathPr !== undefined) p.push(stringifyMathPr(opts.mathPr));\n\n if (opts.attachedSchema !== undefined) {\n for (const schema of opts.attachedSchema) p.push(strVal(\"w:attachedSchema\", schema)!);\n }\n\n if (opts.colorSchemeMapping !== undefined)\n p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));\n if (opts.themeFontLang !== undefined) {\n const a: Record<string, string> = {};\n if (opts.themeFontLang.val !== undefined) a[\"w:val\"] = opts.themeFontLang.val;\n if (opts.themeFontLang.eastAsia !== undefined) a[\"w:eastAsia\"] = opts.themeFontLang.eastAsia;\n if (opts.themeFontLang.bidi !== undefined) a[\"w:bidi\"] = opts.themeFontLang.bidi;\n p.push(attrEl(\"w:themeFontLang\", a));\n }\n p.push(onOff(\"w:doNotIncludeSubdocsInStats\", opts.doNotIncludeSubdocsInStats));\n p.push(onOff(\"w:doNotAutoCompressPictures\", opts.doNotAutoCompressPictures));\n if (opts.forceUpgrade !== undefined) p.push(\"<w:forceUpgrade/>\");\n if (opts.captions !== undefined) p.push(stringifyCaptions(opts.captions));\n if (opts.readModeInkLockDown !== undefined)\n p.push(stringifyReadModeInkLockDown(opts.readModeInkLockDown));\n\n if (opts.smartTagType !== undefined) {\n for (const st of opts.smartTagType) {\n const attrs: Record<string, string> = {};\n if (st.namespace !== undefined) attrs[\"w:namespace\"] = st.namespace;\n if (st.namespaceuri !== undefined) attrs[\"w:namespaceuri\"] = st.namespaceuri;\n if (st.name !== undefined) attrs[\"w:name\"] = st.name;\n if (st.url !== undefined) attrs[\"w:url\"] = st.url;\n p.push(attrEl(\"w:smartTagType\", attrs));\n }\n }\n\n p.push(onOff(\"w:doNotEmbedSmartTags\", opts.doNotEmbedSmartTags));\n if (opts.shapeDefaults !== undefined)\n p.push(`<w:shapeDefaults>${opts.shapeDefaults}</w:shapeDefaults>`);\n p.push(strVal(\"w:decimalSymbol\", opts.decimalSymbol));\n p.push(strVal(\"w:listSeparator\", opts.listSeparator));\n\n const body = p.join(\"\");\n return `<w:settings ${SETTINGS_NS}>${body}</w:settings>`;\n },\n\n parse(el, _ctx) {\n const opts: Record<string, unknown> = {};\n\n // writeProtection (CT_WriteProtection)\n const wpEl = findChild(el, \"w:writeProtection\");\n if (wpEl) {\n const wp = readPasswordAttrs(wpEl) as WriteProtectionOptions;\n const recommended = attr(wpEl, \"w:recommended\");\n if (recommended !== undefined) wp.recommended = recommended === \"1\" || recommended === \"true\";\n if (Object.keys(wp).length > 0) opts.writeProtection = wp;\n }\n\n // view → w:view/@w:val\n const viewVal = readStr(findChild(el, \"w:view\"), \"w:val\");\n if (viewVal) opts.view = viewVal;\n\n // zoom → w:zoom/@w:percent, @w:val\n const zoomEl = findChild(el, \"w:zoom\");\n if (zoomEl) {\n const zoom: Record<string, unknown> = {};\n const percent = attr(zoomEl, \"w:percent\");\n if (percent) zoom.percent = parseInt(percent, 10);\n const zval = attr(zoomEl, \"w:val\");\n if (zval) zoom.val = zval;\n if (Object.keys(zoom).length > 0) opts.zoom = zoom;\n }\n\n // CT_OnOff scalar settings (presence = true unless w:val is explicitly false)\n const onOffScalar: [string, string][] = [\n [\"removePersonalInformation\", \"w:removePersonalInformation\"],\n [\"removeDateAndTime\", \"w:removeDateAndTime\"],\n [\"doNotDisplayPageBoundaries\", \"w:doNotDisplayPageBoundaries\"],\n [\"displayBackgroundShape\", \"w:displayBackgroundShape\"],\n [\"printPostScriptOverText\", \"w:printPostScriptOverText\"],\n [\"printFractionalCharacterWidth\", \"w:printFractionalCharacterWidth\"],\n [\"printFormsData\", \"w:printFormsData\"],\n [\"embedTrueTypeFonts\", \"w:embedTrueTypeFonts\"],\n [\"embedSystemFonts\", \"w:embedSystemFonts\"],\n [\"saveSubsetFonts\", \"w:saveSubsetFonts\"],\n [\"saveFormsData\", \"w:saveFormsData\"],\n [\"mirrorMargins\", \"w:mirrorMargins\"],\n [\"alignBordersAndEdges\", \"w:alignBordersAndEdges\"],\n [\"bordersDoNotSurroundHeader\", \"w:bordersDoNotSurroundHeader\"],\n [\"bordersDoNotSurroundFooter\", \"w:bordersDoNotSurroundFooter\"],\n [\"gutterAtTop\", \"w:gutterAtTop\"],\n [\"hideSpellingErrors\", \"w:hideSpellingErrors\"],\n [\"hideGrammaticalErrors\", \"w:hideGrammaticalErrors\"],\n [\"formsDesign\", \"w:formsDesign\"],\n [\"linkStyles\", \"w:linkStyles\"],\n [\"trackRevisions\", \"w:trackRevisions\"],\n [\"doNotTrackMoves\", \"w:doNotTrackMoves\"],\n [\"doNotTrackFormatting\", \"w:doNotTrackFormatting\"],\n [\"autoFormatOverride\", \"w:autoFormatOverride\"],\n [\"styleLockTheme\", \"w:styleLockTheme\"],\n [\"styleLockQFSet\", \"w:styleLockQFSet\"],\n [\"showEnvelope\", \"w:showEnvelope\"],\n [\"evenAndOddHeaders\", \"w:evenAndOddHeaders\"],\n [\"bookFoldRevPrinting\", \"w:bookFoldRevPrinting\"],\n [\"bookFoldPrinting\", \"w:bookFoldPrinting\"],\n [\"doNotUseMarginsForDrawingGridOrigin\", \"w:doNotUseMarginsForDrawingGridOrigin\"],\n [\"doNotShadeFormData\", \"w:doNotShadeFormData\"],\n [\"noPunctuationKerning\", \"w:noPunctuationKerning\"],\n [\"printTwoOnOne\", \"w:printTwoOnOne\"],\n [\"strictFirstAndLastChars\", \"w:strictFirstAndLastChars\"],\n [\"savePreviewPicture\", \"w:savePreviewPicture\"],\n [\"doNotValidateAgainstSchema\", \"w:doNotValidateAgainstSchema\"],\n [\"saveInvalidXml\", \"w:saveInvalidXml\"],\n [\"ignoreMixedContent\", \"w:ignoreMixedContent\"],\n [\"alwaysShowPlaceholderText\", \"w:alwaysShowPlaceholderText\"],\n [\"doNotDemarcateInvalidXml\", \"w:doNotDemarcateInvalidXml\"],\n [\"saveXmlDataOnly\", \"w:saveXmlDataOnly\"],\n [\"useXSLTWhenSaving\", \"w:useXSLTWhenSaving\"],\n [\"showXMLTags\", \"w:showXMLTags\"],\n [\"alwaysMergeEmptyNamespace\", \"w:alwaysMergeEmptyNamespace\"],\n [\"updateFields\", \"w:updateFields\"],\n [\"doNotIncludeSubdocsInStats\", \"w:doNotIncludeSubdocsInStats\"],\n [\"doNotAutoCompressPictures\", \"w:doNotAutoCompressPictures\"],\n [\"doNotEmbedSmartTags\", \"w:doNotEmbedSmartTags\"],\n ];\n for (const [key, tag] of onOffScalar) {\n const v = readOnOff(findChild(el, tag));\n if (v !== undefined) opts[key] = v;\n }\n\n // activeWritingStyle → w:activeWritingStyle[] (multiple)\n const awsList: Array<Record<string, unknown>> = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:activeWritingStyle\") continue;\n const entry: Record<string, unknown> = {};\n const lang = attr(child, \"w:lang\");\n if (lang) entry.lang = lang;\n const vendorID = attr(child, \"w:vendorID\");\n if (vendorID) entry.vendorID = vendorID;\n const dllVersion = attr(child, \"w:dllVersion\");\n if (dllVersion) entry.dllVersion = dllVersion;\n const nlCheck = attr(child, \"w:nlCheck\");\n if (nlCheck !== undefined) entry.nlCheck = nlCheck !== \"0\" && nlCheck !== \"false\";\n const checkStyle = attr(child, \"w:checkStyle\");\n if (checkStyle !== undefined) entry.checkStyle = checkStyle !== \"0\" && checkStyle !== \"false\";\n const appCheck = attr(child, \"w:appCheck\");\n if (appCheck) entry.appCheck = appCheck;\n const appName = attr(child, \"w:appName\");\n if (appName) entry.appName = appName;\n if (Object.keys(entry).length > 0) awsList.push(entry);\n }\n if (awsList.length > 0) opts.activeWritingStyle = awsList;\n\n // proofState → w:proofState/@w:spelling, @w:grammar\n const proofEl = findChild(el, \"w:proofState\");\n if (proofEl) {\n const proof: Record<string, unknown> = {};\n const spelling = attr(proofEl, \"w:spelling\");\n if (spelling) proof.spelling = spelling;\n const grammar = attr(proofEl, \"w:grammar\");\n if (grammar) proof.grammar = grammar;\n if (Object.keys(proof).length > 0) opts.proofState = proof;\n }\n\n // attachedTemplate → w:attachedTemplate/@r:id\n const attachedTplEl = findChild(el, \"w:attachedTemplate\");\n if (attachedTplEl) {\n const rid = attr(attachedTplEl, \"r:id\");\n if (rid) opts.attachedTemplate = rid;\n }\n\n // stylePaneFormatFilter → w:stylePaneFormatFilter (complex attributes)\n const spffEl = findChild(el, \"w:stylePaneFormatFilter\");\n if (spffEl) {\n const filter: Record<string, boolean> = {};\n const spffFlags: [string, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n [\"latentStyles\", \"w:latentStyles\"],\n ];\n for (const [prop, xmlKey] of spffFlags) {\n const v = attr(spffEl, xmlKey);\n if (v !== undefined) filter[prop] = v !== \"0\" && v !== \"false\" && v !== \"off\";\n }\n if (Object.keys(filter).length > 0) opts.stylePaneFormatFilter = filter;\n }\n\n // stylePaneSortMethod / documentType / clickAndTypeStyle / defaultTableStyle\n const stylePaneSortMethod = readStr(findChild(el, \"w:stylePaneSortMethod\"), \"w:val\");\n if (stylePaneSortMethod)\n opts.stylePaneSortMethod = stylePaneSortMethod as SettingsOptions[\"stylePaneSortMethod\"];\n const documentType = readStr(findChild(el, \"w:documentType\"), \"w:val\");\n if (documentType) opts.documentType = documentType as SettingsOptions[\"documentType\"];\n const clickAndTypeStyle = readStr(findChild(el, \"w:clickAndTypeStyle\"), \"w:val\");\n if (clickAndTypeStyle) opts.clickAndTypeStyle = clickAndTypeStyle;\n const defaultTableStyle = readStr(findChild(el, \"w:defaultTableStyle\"), \"w:val\");\n if (defaultTableStyle) opts.defaultTableStyle = defaultTableStyle;\n\n // mailMerge → w:mailMerge (CT_MailMerge)\n const mailMergeEl = findChild(el, \"w:mailMerge\");\n if (mailMergeEl) {\n const mm = parseMailMerge(mailMergeEl);\n if (mm) opts.mailMerge = mm;\n }\n\n // revisionView → w:revisionView (CT_TrackChangesView)\n const revViewEl = findChild(el, \"w:revisionView\");\n if (revViewEl) {\n const rv: Record<string, boolean> = {};\n const rvFlags: [string, string][] = [\n [\"markup\", \"w:markup\"],\n [\"comments\", \"w:comments\"],\n [\"insDel\", \"w:insDel\"],\n [\"formatting\", \"w:formatting\"],\n [\"inkAnnotations\", \"w:inkAnnotations\"],\n ];\n for (const [k, a] of rvFlags) {\n const v = attr(revViewEl, a);\n if (v !== undefined) rv[k] = v !== \"false\" && v !== \"0\";\n }\n if (Object.keys(rv).length > 0) opts.revisionView = rv as RevisionViewOptions;\n }\n\n // documentProtection → w:documentProtection (CT_DocProtect)\n const docProtEl = findChild(el, \"w:documentProtection\");\n if (docProtEl) {\n const prot: DocumentProtectionOptions = {};\n const edit = attr(docProtEl, \"w:edit\");\n if (edit && (DOC_PROTECT_EDITS as readonly string[]).includes(edit)) {\n prot.edit = edit as DocumentProtectionOptions[\"edit\"];\n }\n const enforcement = attr(docProtEl, \"w:enforcement\");\n if (enforcement !== undefined) {\n Object.assign(prot, readPasswordAttrs(docProtEl));\n const formatting = attr(docProtEl, \"w:formatting\");\n if (formatting !== undefined) prot.formatting = formatting === \"1\" || formatting === \"true\";\n }\n if (Object.keys(prot).length > 0) opts.documentProtection = prot;\n }\n\n // defaultTabStop → w:defaultTabStop/@w:val\n const defaultTabStop = readNum(findChild(el, \"w:defaultTabStop\"), \"w:val\");\n if (defaultTabStop !== undefined) opts.defaultTabStop = defaultTabStop;\n\n // hyphenation (autoHyphenation/consecutiveHyphenLimit/hyphenationZone/doNotHyphenateCaps)\n if (\n findChild(el, \"w:autoHyphenation\") ||\n findChild(el, \"w:doNotHyphenateCaps\") ||\n findChild(el, \"w:consecutiveHyphenLimit\") ||\n findChild(el, \"w:hyphenationZone\")\n ) {\n const hyphenation: Record<string, unknown> = {};\n const autoHyph = readOnOff(findChild(el, \"w:autoHyphenation\"));\n if (autoHyph !== undefined) hyphenation.autoHyphenation = autoHyph;\n const noHyphCaps = readOnOff(findChild(el, \"w:doNotHyphenateCaps\"));\n if (noHyphCaps !== undefined) hyphenation.doNotHyphenateCaps = noHyphCaps;\n const consLimit = readNum(findChild(el, \"w:consecutiveHyphenLimit\"), \"w:val\");\n if (consLimit !== undefined) hyphenation.consecutiveHyphenLimit = consLimit;\n const zone = readNum(findChild(el, \"w:hyphenationZone\"), \"w:val\");\n if (zone !== undefined) hyphenation.hyphenationZone = zone;\n if (Object.keys(hyphenation).length > 0) opts.hyphenation = hyphenation;\n }\n\n // summaryLength → w:summaryLength/@w:val\n const summaryLength = readNum(findChild(el, \"w:summaryLength\"), \"w:val\");\n if (summaryLength !== undefined) opts.summaryLength = summaryLength;\n\n // bookFoldPrintingSheets → w:bookFoldPrintingSheets/@w:val\n const bookFoldSheets = readNum(findChild(el, \"w:bookFoldPrintingSheets\"), \"w:val\");\n if (bookFoldSheets !== undefined) opts.bookFoldPrintingSheets = bookFoldSheets;\n\n // drawing grid numerics\n const drawNum: [string, string][] = [\n [\"drawingGridHorizontalSpacing\", \"w:drawingGridHorizontalSpacing\"],\n [\"drawingGridVerticalSpacing\", \"w:drawingGridVerticalSpacing\"],\n [\"displayHorizontalDrawingGridEvery\", \"w:displayHorizontalDrawingGridEvery\"],\n [\"displayVerticalDrawingGridEvery\", \"w:displayVerticalDrawingGridEvery\"],\n [\"drawingGridHorizontalOrigin\", \"w:drawingGridHorizontalOrigin\"],\n [\"drawingGridVerticalOrigin\", \"w:drawingGridVerticalOrigin\"],\n ];\n for (const [key, tag] of drawNum) {\n const v = readNum(findChild(el, tag), \"w:val\");\n if (v !== undefined) opts[key] = v;\n }\n\n // characterSpacingControl → w:characterSpacingControl/@w:val\n const characterSpacingControl = readStr(findChild(el, \"w:characterSpacingControl\"), \"w:val\");\n if (characterSpacingControl) {\n opts.characterSpacingControl =\n characterSpacingControl as SettingsOptions[\"characterSpacingControl\"];\n }\n\n // noLineBreaksAfter/Before → w:noLineBreaksAfter/Before (w:lang, w:val)\n const lineBreakPairs: [string, string][] = [\n [\"noLineBreaksAfter\", \"w:noLineBreaksAfter\"],\n [\"noLineBreaksBefore\", \"w:noLineBreaksBefore\"],\n ];\n for (const [key, tag] of lineBreakPairs) {\n const lbEl = findChild(el, tag);\n if (!lbEl) continue;\n const entry: Record<string, string> = {};\n const lang = attr(lbEl, \"w:lang\");\n if (lang) entry.lang = lang;\n const val = attr(lbEl, \"w:val\");\n if (val) entry.val = val;\n if (Object.keys(entry).length > 0) opts[key] = entry;\n }\n\n // saveThroughXslt → w:saveThroughXslt (r:id, w:val, w:solutionID)\n const stxEl = findChild(el, \"w:saveThroughXslt\");\n if (stxEl) {\n const stx: Record<string, string> = {};\n const id = attr(stxEl, \"r:id\");\n if (id) stx.id = id;\n const val = attr(stxEl, \"w:val\");\n if (val) stx.val = val;\n const solutionID = attr(stxEl, \"w:solutionID\");\n if (solutionID) stx.solutionID = solutionID;\n if (Object.keys(stx).length > 0) opts.saveThroughXslt = stx;\n }\n\n // hdrShapeDefaults / shapeDefaults → verbatim inner XML (o:shapedefaults/o:shapelayout)\n const hdrSdEl = findChild(el, \"w:hdrShapeDefaults\");\n if (hdrSdEl) opts.hdrShapeDefaults = stringify(hdrSdEl);\n const sdEl = findChild(el, \"w:shapeDefaults\");\n if (sdEl) opts.shapeDefaults = stringify(sdEl);\n\n // footnotePr / endnotePr (CT_FtnDocProps / CT_EdnDocProps)\n const fnPrEl = findChild(el, \"w:footnotePr\");\n if (fnPrEl) {\n const fn = parseFtnEdnPr(fnPrEl);\n if (fn) opts.footnotePr = fn;\n }\n const enPrEl = findChild(el, \"w:endnotePr\");\n if (enPrEl) {\n const en = parseFtnEdnPr(enPrEl);\n if (en) opts.endnotePr = en;\n }\n\n // compatibility (CT_Compat: on/off flags + compatSetting entries)\n const compatEl = findChild(el, \"w:compat\");\n if (compatEl) {\n const compat = parseCompatibility(compatEl);\n if (compat) opts.compatibility = compat;\n }\n\n // docVars → w:docVars/w:docVar\n const docVarsEl = findChild(el, \"w:docVars\");\n if (docVarsEl) {\n const vars: Array<{ name: string; val: string }> = [];\n for (const child of docVarsEl.elements ?? []) {\n if (child.name !== \"w:docVar\") continue;\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name !== undefined && val !== undefined) vars.push({ name, val });\n }\n if (vars.length > 0) opts.docVars = vars;\n }\n\n // rsids → w:rsids (CT_DocRsids)\n const rsidsEl = findChild(el, \"w:rsids\");\n if (rsidsEl) {\n const rsids: Record<string, unknown> = {};\n const root = readStr(findChild(rsidsEl, \"w:rsidRoot\"), \"w:val\");\n if (root) rsids.rsidRoot = root;\n const list: string[] = [];\n for (const child of rsidsEl.elements ?? []) {\n if (child.name !== \"w:rsid\") continue;\n const val = attr(child, \"w:val\");\n if (val) list.push(val);\n }\n if (list.length > 0) rsids.rsids = list;\n if (Object.keys(rsids).length > 0) opts.rsids = rsids as RsidsOptions;\n }\n\n // mathPr → m:mathPr (CT_MathPr)\n const mathPrEl = findChild(el, \"m:mathPr\");\n if (mathPrEl) {\n const mp = parseMathPr(mathPrEl);\n if (mp) opts.mathPr = mp;\n }\n\n // attachedSchema → w:attachedSchema/@w:val (multiple)\n const attachedSchemas: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:attachedSchema\") continue;\n const val = attr(child, \"w:val\");\n if (val) attachedSchemas.push(val);\n }\n if (attachedSchemas.length > 0) opts.attachedSchema = attachedSchemas;\n\n // themeFontLang → w:themeFontLang (CT_Language: val/eastAsia/bidi)\n const tflEl = findChild(el, \"w:themeFontLang\");\n if (tflEl) {\n const tfl: Record<string, string> = {};\n const val = attr(tflEl, \"w:val\");\n if (val) tfl.val = val;\n const eastAsia = attr(tflEl, \"w:eastAsia\");\n if (eastAsia) tfl.eastAsia = eastAsia;\n const bidi = attr(tflEl, \"w:bidi\");\n if (bidi) tfl.bidi = bidi;\n if (Object.keys(tfl).length > 0) opts.themeFontLang = tfl;\n }\n\n // clrSchemeMapping → w:clrSchemeMapping\n const csmEl = findChild(el, \"w:clrSchemeMapping\");\n if (csmEl) {\n const csm: Record<string, string> = {};\n const csmMap: [string, string][] = [\n [\"bg1\", \"w:bg1\"],\n [\"t1\", \"w:t1\"],\n [\"bg2\", \"w:bg2\"],\n [\"t2\", \"w:t2\"],\n [\"accent1\", \"w:accent1\"],\n [\"accent2\", \"w:accent2\"],\n [\"accent3\", \"w:accent3\"],\n [\"accent4\", \"w:accent4\"],\n [\"accent5\", \"w:accent5\"],\n [\"accent6\", \"w:accent6\"],\n [\"hyperlink\", \"w:hyperlink\"],\n [\"followedHyperlink\", \"w:followedHyperlink\"],\n ];\n for (const [key, xmlAttr] of csmMap) {\n const v = attr(csmEl, xmlAttr);\n if (v) csm[key] = v;\n }\n if (Object.keys(csm).length > 0) opts.colorSchemeMapping = csm;\n }\n\n // forceUpgrade → w:forceUpgrade (CT_Empty, presence)\n if (findChild(el, \"w:forceUpgrade\")) opts.forceUpgrade = true;\n\n // captions → w:captions (CT_Captions)\n const captionsEl = findChild(el, \"w:captions\");\n if (captionsEl) {\n const captions = parseCaptions(captionsEl);\n if (captions) opts.captions = captions;\n }\n\n // readModeInkLockDown → w:readModeInkLockDown\n const rmilEl = findChild(el, \"w:readModeInkLockDown\");\n if (rmilEl) {\n opts.readModeInkLockDown = {\n actualPg: attr(rmilEl, \"w:actualPg\") !== \"0\",\n w: parseInt(attr(rmilEl, \"w:w\") ?? \"0\", 10),\n h: parseInt(attr(rmilEl, \"w:h\") ?? \"0\", 10),\n fontSz: parseInt(attr(rmilEl, \"w:fontSz\") ?? \"0\", 10),\n } as ReadModeInkLockDownOptions;\n }\n\n // smartTagType → w:smartTagType[] (multiple)\n const smartTags: Array<Record<string, string>> = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:smartTagType\") continue;\n const entry: Record<string, string> = {};\n const ns = attr(child, \"w:namespace\");\n if (ns) entry.namespace = ns;\n const nsuri = attr(child, \"w:namespaceuri\");\n if (nsuri) entry.namespaceuri = nsuri;\n const name = attr(child, \"w:name\");\n if (name) entry.name = name;\n const url = attr(child, \"w:url\");\n if (url) entry.url = url;\n if (Object.keys(entry).length > 0) smartTags.push(entry);\n }\n if (smartTags.length > 0) opts.smartTagType = smartTags;\n\n // decimalSymbol / listSeparator → w:decimalSymbol|w:listSeparator/@w:val\n const decimalSymbol = readStr(findChild(el, \"w:decimalSymbol\"), \"w:val\");\n if (decimalSymbol) opts.decimalSymbol = decimalSymbol;\n const listSeparator = readStr(findChild(el, \"w:listSeparator\"), \"w:val\");\n if (listSeparator) opts.listSeparator = listSeparator;\n\n return opts as unknown as SettingsOptions;\n },\n};\n","/**\n * Table of Contents Properties module.\n *\n * This module defines configuration options for table of contents generation,\n * including field switches and style mappings.\n *\n * Reference: http://officeopenxml.com/WPtableOfContents.php\n *\n * @module\n */\n\nimport type { SectionChild } from \"@shared/section\";\n\n/**\n * Represents a style-to-level mapping for table of contents entries.\n *\n * StyleLevel associates a paragraph style name with a TOC level, allowing\n * custom styles to be included in the table of contents at specific levels.\n *\n * @publicApi\n */\nexport class StyleLevel {\n /** The name of the paragraph style. */\n public styleName: string;\n /** The TOC level (1-9) to assign to this style. */\n public level: number;\n\n public constructor(styleName: string, level: number) {\n this.styleName = styleName;\n this.level = level;\n }\n}\n\n/**\n * Options for configuring a Table of Contents.\n *\n * These options control which content is included in the TOC and how it is formatted.\n * Options correspond to field switches in the TOC field code.\n *\n * Reference:\n * - https://www.ecma-international.org/publications/standards/Ecma-376.htm (Part 1, Page 1251)\n * - http://officeopenxml.com/WPtableOfContents.php\n */\nexport interface TableOfContentsOptions {\n /**\n * \\a option - Includes captioned items, but omits caption labels and numbers.\n * The identifier designated by text in this switch's field-argument corresponds to the caption label.\n * Use captionLabelIncludingNumbers (\\c) to build a table of captions with labels and numbers.\n */\n captionLabel?: string;\n\n /**\n * \\b option - Includes entries only from the portion of the document marked by\n * the bookmark named by text in this switch's field-argument.\n */\n entriesFromBookmark?: string;\n\n /**\n * \\c option - Includes figures, tables, charts, and other items that are numbered\n * by a SEQ field (§17.16.5.56). The sequence identifier designated by text in this switch's\n * field-argument, which corresponds to the caption label, shall match the identifier in the\n * corresponding SEQ field.\n */\n captionLabelIncludingNumbers?: string;\n\n /**\n * \\d option - When used with \\s, the text in this switch's field-argument defines\n * the separator between sequence and page numbers. The default separator is a hyphen (-).\n */\n sequenceAndPageNumbersSeparator?: string;\n\n /**\n * \\f option - Includes only those TC fields whose identifier exactly matches the\n * text in this switch's field-argument (which is typically a letter).\n */\n tcFieldIdentifier?: string;\n\n /**\n * \\h option - Makes the table of contents entries hyperlinks.\n */\n hyperlink?: boolean;\n\n /**\n * \\l option - Includes TC fields that assign entries to one of the levels specified\n * by text in this switch's field-argument as a range having the form startLevel-endLevel,\n * where startLevel and endLevel are integers, and startLevel has a value equal-to or less-than endLevel.\n * TC fields that assign entries to lower levels are skipped.\n */\n tcFieldLevelRange?: string;\n\n /**\n * \\n option - Without field-argument, omits page numbers from the table of contents.\n * Page numbers are omitted from all levels unless a range of entry levels is specified by\n * text in this switch's field-argument. A range is specified as for \\l.\n */\n pageNumbersEntryLevelsRange?: string;\n\n /**\n * \\o option - Uses paragraphs formatted with all or the specified range of builtin\n * heading styles. Headings in a style range are specified by text in this switch's\n * field-argument using the notation specified as for \\l, where each integer corresponds\n * to the style with a style ID of HeadingX (e.g. 1 corresponds to Heading1).\n * If no heading range is specified, all heading levels used in the document are listed.\n */\n headingStyleRange?: string;\n\n /**\n * \\p option - Text in this switch's field-argument specifies a sequence of characters\n * that separate an entry and its page number. The default is a tab with leader dots.\n */\n entryAndPageNumberSeparator?: string;\n\n /**\n * \\s option - For entries numbered with a SEQ field (§17.16.5.56), adds a prefix to the page number.\n * The prefix depends on the type of entry. text in this switch's field-argument shall match the\n * identifier in the SEQ field.\n */\n seqFieldIdentifierForPrefix?: string;\n\n /**\n * \\t field-argument Uses paragraphs formatted with styles other than the built-in heading styles.\n * Text in this switch's field-argument specifies those styles as a set of comma-separated doublets,\n * with each doublet being a comma-separated set of style name and table of content level.\n * \\t can be combined with \\o.\n */\n stylesWithLevels?: StyleLevel[];\n\n /**\n * \\u Uses the applied paragraph outline level.\n */\n useAppliedParagraphOutlineLevel?: boolean;\n\n /**\n * \\w Preserves tab entries within table entries.\n */\n preserveTabInEntries?: boolean;\n\n /**\n * \\x Preserves newline characters within table entries.\n */\n preserveNewLineInEntries?: boolean;\n\n /**\n * \\z Hides tab leader and page numbers in web page view (§17.18.102).\n */\n hideTabAndPageNumbersInWebView?: boolean;\n\n /**\n * Rendered TOC entries — the paragraph content between the field's `separate`\n * and `end` markers. Round-tripped structurally (each entry is a TOC-style\n * paragraph carrying a HYPERLINK field, tab leader, and PAGEREF page number)\n * so both MS Office and WPS display the existing TOC without regenerating.\n *\n * Omit on fresh generation — the field is then emitted `dirty` so the\n * consuming application builds the entries from headings on open.\n */\n entries?: SectionChild[];\n}\n","/**\n * Structured Document Tag Properties module.\n *\n * Represents CT_SdtPr — the properties of a structured document tag (content control).\n * Supports all SDT types defined in the OOXML specification: comboBox, dropDownList,\n * date, text, equation,richText, picture, citation, group, bibliography, docPartObj,\n * docPartList.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_SdtPr\n *\n * @module\n */\n\n// ─── Lock ───────────────────────────────────────────────────────────────────\n\n/**\n * SDT lock type (ST_Lock).\n */\nexport const SdtLock = {\n /** Lock the SDT itself (cannot delete the control) */\n SDT_LOCKED: \"sdtLocked\",\n /** Lock the content (cannot edit content within the control) */\n CONTENT_LOCKED: \"contentLocked\",\n /** No locking */\n UNLOCKED: \"unlocked\",\n /** Lock both SDT and content */\n SDT_CONTENT_LOCKED: \"sdtContentLocked\",\n} as const;\n\n// ─── Supporting Types ───────────────────────────────────────────────────────\n\n/**\n * A list item for comboBox or dropDownList SDTs (CT_SdtListItem).\n */\nexport interface SdtListItem {\n /** Display text shown in the UI */\n displayText?: string;\n /** Underlying value */\n value?: string;\n}\n\n/**\n * Options for comboBox SDT type (CT_SdtComboBox).\n */\nexport interface SdtComboBoxOptions {\n /** List items */\n items?: SdtListItem[];\n /** Last selected value */\n lastValue?: string;\n}\n\n/**\n * Options for dropDownList SDT type (CT_SdtDropDownList).\n */\nexport interface SdtDropDownListOptions {\n /** List items */\n items?: SdtListItem[];\n /** Last selected value */\n lastValue?: string;\n}\n\n/**\n * Date mapping type (ST_SdtDateMappingType).\n */\nexport const SdtDateMappingType = {\n TEXT: \"text\",\n DATE: \"date\",\n DATE_TIME: \"dateTime\",\n} as const;\n\n/**\n * Options for date SDT type (CT_SdtDate).\n */\nexport interface SdtDateOptions {\n /** Date format string (e.g., \"yyyy-MM-dd\") */\n dateFormat?: string;\n /** Language ID (e.g., \"en-US\") */\n languageId?: string;\n /** How the date value is stored */\n storeMappedDataAs?: (typeof SdtDateMappingType)[keyof typeof SdtDateMappingType];\n /** Calendar type */\n calendar?: string;\n /** Full date value (ISO 8601) */\n fullDate?: string;\n}\n\n/**\n * Options for plain text SDT type (CT_SdtText).\n */\nexport interface SdtTextOptions {\n /** Whether the text control supports multiple lines */\n multiLine?: boolean;\n}\n\n/**\n * Symbol for a checkbox content control state (CT_SdtCheckboxSymbol).\n *\n * `val` is a hex Unicode code point (e.g., \"2612\" for ☒); `font` defaults to\n * \"MS Gothic\" per the OOXML specification.\n */\nexport interface SdtCheckboxSymbol {\n /** Hex Unicode code point of the symbol (e.g., \"2612\") */\n val: string;\n /** Font face; defaults to \"MS Gothic\" */\n font?: string;\n}\n\n/**\n * Options for a checkbox content control (CT_SdtCheckbox, w14:checkbox).\n *\n * Word 2010+ content control checkbox. When present, the SDT renders the\n * current state symbol instead of its declared children.\n */\nexport interface SdtCheckboxOptions {\n /** Whether the checkbox is checked (default: false) */\n checked?: boolean;\n /** Symbol for the checked state (default: ☒ 0x2612, MS Gothic) */\n checkedState?: SdtCheckboxSymbol;\n /** Symbol for the unchecked state (default: ☐ 0x2610, MS Gothic) */\n uncheckedState?: SdtCheckboxSymbol;\n}\n\n/**\n * Data binding options (CT_DataBinding).\n */\nexport interface SdtDataBindingOptions {\n /** XML namespace prefix mappings */\n prefixMappings?: string;\n /** XPath expression (required) */\n xpath: string;\n /** Custom XML store item ID (required) */\n storeItemID: string;\n}\n\n/**\n * Options for CT_SdtPr — structured document tag properties.\n */\nexport interface SdtPropertiesOptions {\n /** Display name */\n alias?: string;\n /** Application-specific tag */\n tag?: string;\n /** Unique ID */\n id?: number;\n /** Lock behavior */\n lock?: (typeof SdtLock)[keyof typeof SdtLock];\n /** Whether the control is temporary */\n temporary?: boolean;\n /** Whether the placeholder text is currently shown */\n showingPlaceholder?: boolean;\n /** Data binding to custom XML */\n dataBinding?: SdtDataBindingOptions;\n /** Numeric label */\n label?: number;\n /** Tab order index */\n tabIndex?: number;\n\n // ─── Type discriminators (xsd:choice, at most one) ───\n\n /** Equation SDT */\n equation?: boolean;\n /** ComboBox SDT (allows free-text entry) */\n comboBox?: SdtComboBoxOptions;\n /** Date SDT */\n date?: SdtDateOptions;\n /** Document part object SDT */\n docPartObj?: {\n gallery?: string;\n category?: string;\n unique?: boolean;\n };\n /** Document part list SDT */\n docPartList?: {\n gallery?: string;\n category?: string;\n unique?: boolean;\n };\n /** DropDownList SDT (selection only) */\n dropDownList?: SdtDropDownListOptions;\n /** Picture SDT */\n picture?: boolean;\n /** Rich text SDT */\n richText?: boolean;\n /** Plain text SDT */\n text?: SdtTextOptions;\n /** Citation SDT */\n citation?: boolean;\n /** Group SDT */\n group?: boolean;\n /** Bibliography SDT */\n bibliography?: boolean;\n /** Checkbox content control SDT (Word 2010+, w14:checkbox) */\n checkbox?: SdtCheckboxOptions;\n}\n","/**\n * Table of Contents parser for DOCX documents.\n *\n * Parses TOC-type SDT elements into TOC options.\n *\n * @module\n */\nimport { attr, children, findChild, findDeep, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n StyleLevel,\n TableOfContentsOptions,\n} from \"@parts/table-of-contents/table-of-contents-properties\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Try to parse a w:sdt element as a TOC.\n * Returns { alias, ...tocOptions } if it's a TOC, or undefined otherwise.\n *\n * Detects TOC in two ways:\n * 1. SDT with w:docPartObj > w:docPartGallery = \"Table of Contents\" (Word-generated)\n * 2. SDT whose content contains a TOC field instruction (library-generated)\n */\nexport function parseToc(\n el: Element,\n ctx: DocxReadContext,\n parseChildren?: (elements: Element[], ctx: DocxReadContext) => SectionChild[],\n):\n | ({\n alias?: string;\n } & TableOfContentsOptions)\n | undefined {\n const sdtPr = findChild(el, \"w:sdtPr\");\n if (!sdtPr) return undefined;\n\n // Detection method 1: docPartObj with gallery \"Table of Contents\"\n const docPartObj = findChild(sdtPr, \"w:docPartObj\");\n let isToc = false;\n\n if (docPartObj) {\n const gallery = findChild(docPartObj, \"w:docPartGallery\");\n if (gallery && textOf(gallery) === \"Table of Contents\") {\n isToc = true;\n }\n }\n\n // Detection method 2: scan content for TOC field instruction\n if (!isToc) {\n const sdtContent = findChild(el, \"w:sdtContent\");\n if (sdtContent) {\n isToc = hasTocFieldInstruction(sdtContent);\n }\n }\n\n if (!isToc) return undefined;\n\n // It's a TOC SDT\n const alias = (() => {\n const aliasEl = findChild(sdtPr, \"w:alias\");\n return aliasEl ? attr(aliasEl, \"w:val\") : undefined;\n })();\n\n // Parse field instruction from content to extract TOC options\n const tocOpts: Record<string, unknown> = {};\n const sdtContent = findChild(el, \"w:sdtContent\");\n\n if (sdtContent) {\n // Look for field instructions\n for (const p of children(sdtContent, \"w:p\")) {\n for (const r of children(p, \"w:r\")) {\n for (const instrText of children(r, \"w:instrText\")) {\n const instruction = textOf(instrText).trim();\n parseTocFieldInstruction(instruction, tocOpts);\n }\n }\n }\n // Rendered entries — the paragraphs between the field's separate and end\n // markers. Captured structurally so MS Office and WPS both display the\n // existing TOC instead of regenerating it from headings.\n if (parseChildren) {\n const entryEls = selectTocEntryElements(sdtContent.elements ?? []);\n if (entryEls.length > 0) {\n tocOpts.entries = parseChildren(entryEls, ctx);\n }\n }\n }\n\n return { alias, ...tocOpts } as { alias?: string } & TableOfContentsOptions;\n}\n\n/**\n * Check whether an element tree contains a TOC field instruction\n * (w:instrText with text starting with \"TOC\").\n */\nfunction hasTocFieldInstruction(el: Element): boolean {\n for (const p of children(el, \"w:p\")) {\n for (const r of children(p, \"w:r\")) {\n for (const instrText of children(r, \"w:instrText\")) {\n const instruction = textOf(instrText)?.trim();\n if (instruction?.startsWith(\"TOC\")) return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Parse a TOC field instruction string (e.g., ' TOC \\o \"1-3\" \\h \\z ')\n * into TableOfContentsOptions properties.\n */\nexport function parseTocFieldInstruction(instruction: string, opts: Record<string, unknown>): void {\n if (!instruction.startsWith(\"TOC\")) return;\n\n const rest = instruction.slice(3).trim();\n const switches = parseFieldSwitches(rest);\n\n if (switches[\"a\"]) opts.captionLabel = switches[\"a\"];\n if (switches[\"b\"]) opts.entriesFromBookmark = switches[\"b\"];\n if (switches[\"c\"]) opts.captionLabelIncludingNumbers = switches[\"c\"];\n if (switches[\"d\"]) opts.sequenceAndPageNumbersSeparator = switches[\"d\"];\n if (switches[\"f\"]) opts.tcFieldIdentifier = switches[\"f\"];\n if (\"h\" in switches) opts.hyperlink = true;\n if (switches[\"l\"]) opts.tcFieldLevelRange = switches[\"l\"];\n if (switches[\"n\"]) opts.pageNumbersEntryLevelsRange = switches[\"n\"];\n if (switches[\"o\"]) opts.headingStyleRange = switches[\"o\"];\n if (switches[\"p\"]) opts.entryAndPageNumberSeparator = switches[\"p\"];\n if (switches[\"s\"]) opts.seqFieldIdentifierForPrefix = switches[\"s\"];\n if (switches[\"t\"]) {\n // \\t \"Style1,1,Style2,2\" -> stylesWithLevels pairs\n const parts = switches[\"t\"]!.split(\",\");\n const stylesWithLevels: StyleLevel[] = [];\n for (let i = 0; i + 1 < parts.length; i += 2) {\n const styleName = parts[i];\n const level = parseInt(parts[i + 1], 10);\n if (styleName && !Number.isNaN(level)) stylesWithLevels.push({ styleName, level });\n }\n if (stylesWithLevels.length > 0) opts.stylesWithLevels = stylesWithLevels;\n }\n if (\"u\" in switches) opts.useAppliedParagraphOutlineLevel = true;\n if (\"w\" in switches) opts.preserveTabInEntries = true;\n if (\"x\" in switches) opts.preserveNewLineInEntries = true;\n if (\"z\" in switches) opts.hideTabAndPageNumbersInWebView = true;\n}\n\n/**\n * Extract TOC options from the elements of a captured TOC field (SDT content or\n * a bare cross-paragraph field). Feeds every w:instrText to the instruction\n * parser; non-TOC fields (HYPERLINK/PAGEREF inside the rendered entries) are\n * ignored — parseTocFieldInstruction only acts on instructions starting \"TOC\".\n */\nexport function parseTocFieldFromElements(els: Element[]): TableOfContentsOptions {\n const opts: Record<string, unknown> = {};\n for (const el of els) collectTocInstructions(el, opts);\n return opts as TableOfContentsOptions;\n}\n\n/**\n * Select the rendered-entry paragraphs of a captured TOC field. Tracks field\n * depth so a nested HYPERLINK/PAGEREF field inside an entry doesn't fool the\n * boundary detection.\n *\n * A paragraph is an entry when, after walking it, the field is past `separate`\n * and not past `end` (depth ≥ 1) and the paragraph carries rendered text (`w:t`).\n * This captures an entry whose paragraph also opens the field (`begin`) or holds\n * the `separate` marker — common when Word emits begin + separate + first entry\n * in one paragraph — while the `w:t` requirement excludes a pure control\n * paragraph (field head / separate-only / end).\n */\nexport function selectTocEntryElements(els: Element[]): Element[] {\n const entries: Element[] = [];\n let depth = 0;\n let afterSeparate = false;\n for (const el of els) {\n const walk = (node: Element): void => {\n if (node.name === \"w:fldChar\") {\n const type = attr(node, \"w:fldCharType\");\n if (type === \"begin\") depth++;\n else if (type === \"separate\" && depth === 1) afterSeparate = true;\n else if (type === \"end\") depth--;\n }\n for (const c of node.elements ?? []) {\n if (c.type === \"element\") walk(c);\n }\n };\n walk(el);\n if (afterSeparate && depth >= 1 && findDeep(el, \"w:t\").length > 0) {\n entries.push(el);\n }\n }\n return entries;\n}\n\n/** Recursively feed every w:instrText to the TOC instruction parser. */\nfunction collectTocInstructions(el: Element, opts: Record<string, unknown>): void {\n if (el.name === \"w:instrText\") {\n const instruction = textOf(el)?.trim();\n if (instruction) parseTocFieldInstruction(instruction, opts);\n }\n for (const c of el.elements ?? []) {\n if (c.type === \"element\") collectTocInstructions(c, opts);\n }\n}\n\n/**\n * Parse field switches like \\o \"1-3\" \\h \\z into a map.\n */\nfunction parseFieldSwitches(text: string): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n let i = 0;\n\n while (i < text.length) {\n // Skip whitespace\n while (i < text.length && text[i] === \" \") i++;\n if (i >= text.length) break;\n\n // Expect backslash\n if (text[i] !== \"\\\\\") {\n i++;\n continue;\n }\n i++;\n\n // Read switch name\n const nameStart = i;\n while (i < text.length && /[a-zA-Z]/.test(text[i])) i++;\n const name = text.slice(nameStart, i);\n if (!name) continue;\n\n // Skip whitespace\n while (i < text.length && text[i] === \" \") i++;\n\n // Read argument (quoted or unquoted)\n if (i < text.length && text[i] === '\"') {\n i++;\n const argStart = i;\n while (i < text.length && text[i] !== '\"') i++;\n result[name] = text.slice(argStart, i);\n if (i < text.length) i++; // skip closing quote\n } else if (i < text.length && text[i] !== \"\\\\\") {\n const argStart = i;\n while (i < text.length && text[i] !== \" \" && text[i] !== \"\\\\\") i++;\n const arg = text.slice(argStart, i).trim();\n if (arg) result[name] = arg;\n else result[name] = undefined;\n } else {\n result[name] = undefined;\n }\n }\n\n return result;\n}\n","/**\n * Footnotes descriptor — produces word/footnotes.xml.\n *\n * Generates the complete `<w:footnotes>` element including:\n * - Separator footnote (id round-tripped from source; default -1)\n * - Continuation separator footnote (id round-tripped from source; default 0)\n * - User footnotes with auto-injected footnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Footnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\n/** System footnote (separator / continuationSeparator). Round-tripped verbatim. */\nexport interface FootnoteSeparator {\n id: number;\n paragraphs: (ParagraphOptions | string)[];\n}\n\nexport interface FootnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n /**\n * Separator footnote — id + content round-tripped from the source so it stays\n * consistent with settings.footnotePr, which references this id.\n */\n separator?: FootnoteSeparator;\n /** Continuation separator footnote — id + content round-tripped from the source. */\n continuationSeparator?: FootnoteSeparator;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the footnoteRef run — auto-injected at start of first paragraph. */\nconst FOOTNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteRef/></w:r>';\n\n/** Default separator footnote (id=-1) for freshly generated documents. */\nconst SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n/** Default continuation separator footnote (id=0) for freshly generated documents. */\nconst CONTINUATION_SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n// ── Descriptor ──\n\n/** Render a system footnote from round-tripped id + content, or the spec default. */\nfunction footnoteSystemNote(\n type: \"separator\" | \"continuationSeparator\",\n sep: FootnoteSeparator | undefined,\n fallback: string,\n ctx: BodyContext,\n): string {\n if (!sep) return fallback;\n const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join(\"\");\n return `<w:footnote w:type=\"${type}\" w:id=\"${sep.id}\">${inner}</w:footnote>`;\n}\n\nexport const footnotesDesc: CustomDescriptor<FootnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [`<w:footnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`];\n\n // Separator / continuation separator: round-trip id + content verbatim so they\n // stay consistent with settings.footnotePr (which references these ids). Fall\n // back to spec defaults only for freshly generated documents.\n parts.push(footnoteSystemNote(\"separator\", data.separator, SEPARATOR_FOOTNOTE, ctx));\n parts.push(\n footnoteSystemNote(\n \"continuationSeparator\",\n data.continuationSeparator,\n CONTINUATION_SEPARATOR_FOOTNOTE,\n ctx,\n ),\n );\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:footnote w:id=\"${id}\">`);\n for (let i = 0; i < paragraphs.length; i++) {\n const pXml = stringifyParagraphInline(paragraphs[i], ctx);\n if (i === 0) {\n // Insert footnoteRef after <w:p> or <w:p ...>\n const openIdx = pXml.indexOf(\">\");\n if (openIdx !== -1) {\n parts.push(pXml.slice(0, openIdx + 1) + FOOTNOTE_REF_RUN + pXml.slice(openIdx + 1));\n } else {\n parts.push(pXml);\n }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:footnote>\");\n }\n\n parts.push(\"</w:footnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n let separator: FootnoteSeparator | undefined;\n let continuationSeparator: FootnoteSeparator | undefined;\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:footnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const type = attr(child, \"w:type\");\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n\n // System footnotes carry type=\"separator\"/\"continuationSeparator\" — capture\n // their id + content so stringify round-trips them verbatim (settings\n // references these ids). Normal footnotes (type absent/\"normal\") go to notes.\n if (type === \"separator\") {\n separator = { id, paragraphs };\n } else if (type === \"continuationSeparator\") {\n continuationSeparator = { id, paragraphs };\n } else {\n notes.set(id, paragraphs);\n }\n }\n return { notes, separator, continuationSeparator } as FootnotesData;\n },\n};\n","/**\n * Endnotes descriptor — produces word/endnotes.xml.\n *\n * Generates the complete `<w:endnotes>` element including:\n * - Separator endnote (id round-tripped from source; default -1)\n * - Continuation separator endnote (id round-tripped from source; default 0)\n * - User endnotes with auto-injected endnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Endnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\n/** System endnote (separator / continuationSeparator). Round-tripped verbatim. */\nexport interface EndnoteSeparator {\n id: number;\n paragraphs: (ParagraphOptions | string)[];\n}\n\nexport interface EndnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n /**\n * Separator endnote — id + content round-tripped from the source so it stays\n * consistent with settings.endnotePr, which references this id.\n */\n separator?: EndnoteSeparator;\n /** Continuation separator endnote — id + content round-tripped from the source. */\n continuationSeparator?: EndnoteSeparator;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the endnoteRef run — auto-injected at start of first paragraph. */\nconst ENDNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteRef/></w:r>';\n\n/** Default separator endnote (id=-1) for freshly generated documents. */\nconst SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n/** Default continuation separator endnote (id=0) for freshly generated documents. */\nconst CONTINUATION_SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n// ── Descriptor ──\n\n/** Render a system endnote from round-tripped id + content, or the spec default. */\nfunction endnoteSystemNote(\n type: \"separator\" | \"continuationSeparator\",\n sep: EndnoteSeparator | undefined,\n fallback: string,\n ctx: BodyContext,\n): string {\n if (!sep) return fallback;\n const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join(\"\");\n return `<w:endnote w:type=\"${type}\" w:id=\"${sep.id}\">${inner}</w:endnote>`;\n}\n\nexport const endnotesDesc: CustomDescriptor<EndnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [`<w:endnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`];\n\n // Separator / continuation separator: round-trip id + content verbatim so they\n // stay consistent with settings.endnotePr (which references these ids). Fall\n // back to spec defaults only for freshly generated documents.\n parts.push(endnoteSystemNote(\"separator\", data.separator, SEPARATOR_ENDNOTE, ctx));\n parts.push(\n endnoteSystemNote(\n \"continuationSeparator\",\n data.continuationSeparator,\n CONTINUATION_SEPARATOR_ENDNOTE,\n ctx,\n ),\n );\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:endnote w:id=\"${id}\">`);\n for (let i = 0; i < paragraphs.length; i++) {\n const pXml = stringifyParagraphInline(paragraphs[i], ctx);\n if (i === 0) {\n // Insert endnoteRef after <w:p> or <w:p ...>\n const openIdx = pXml.indexOf(\">\");\n if (openIdx !== -1) {\n parts.push(pXml.slice(0, openIdx + 1) + ENDNOTE_REF_RUN + pXml.slice(openIdx + 1));\n } else {\n parts.push(pXml);\n }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:endnote>\");\n }\n\n parts.push(\"</w:endnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n let separator: EndnoteSeparator | undefined;\n let continuationSeparator: EndnoteSeparator | undefined;\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:endnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const type = attr(child, \"w:type\");\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n\n // System endnotes carry type=\"separator\"/\"continuationSeparator\" — capture\n // their id + content so stringify round-trips them verbatim (settings\n // references these ids). Normal endnotes (type absent/\"normal\") go to notes.\n if (type === \"separator\") {\n separator = { id, paragraphs };\n } else if (type === \"continuationSeparator\") {\n continuationSeparator = { id, paragraphs };\n } else {\n notes.set(id, paragraphs);\n }\n }\n return { notes, separator, continuationSeparator } as EndnotesData;\n },\n};\n","/**\n * Permission range markers for WordprocessingML document protection.\n *\n * These elements mark editable ranges within a protected document.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_PermStart, CT_PermEnd\n *\n * @module\n */\n\n/**\n * Editing group values for permission ranges.\n *\n * Defines who can edit within a permission range.\n *\n * Reference: ISO/IEC 29500-4, ST_EdGrp\n */\nexport const EditGroupType = {\n NONE: \"none\",\n EVERYONE: \"everyone\",\n ADMINISTRATORS: \"administrators\",\n CONTRIBUTORS: \"contributors\",\n EDITORS: \"editors\",\n OWNERS: \"owners\",\n CURRENT: \"current\",\n} as const;\n\nexport type EditGroup = (typeof EditGroupType)[keyof typeof EditGroupType];\n\n/**\n * Options for creating a permission start marker.\n */\nexport interface PermStartOptions {\n /** Unique identifier for this permission range (typically a number) */\n id: string | number;\n /** Editing group that can edit this range */\n edGroup?: EditGroup;\n /** Individual user who can edit this range */\n ed?: string;\n /** First column this range covers (for table cells) */\n colFirst?: number;\n /** Last column this range covers (for table cells) */\n colLast?: number;\n}\n","/**\n * Font module for WordprocessingML documents.\n *\n * Provides support for font definitions and embedded fonts.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * @module\n */\nimport { element } from \"@office-open/xml\";\n\nconst createStringElement = (name: string, value: string): string =>\n element(name, { \"w:val\": value });\n\n/**\n * Options for a font relationship (embedded font).\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html\n *\n * @property id - Relationship to Part\n * @property fontKey - Embedded Font Obfuscation Key (GUID)\n * @property subsetted - Whether the embedded font is subsetted\n */\nexport interface FontRelationshipOptions {\n /** Relationship to Part */\n id: string;\n /** Embedded Font Obfuscation Key (GUID) */\n fontKey?: string;\n /** Whether the embedded font is subsetted */\n subsetted?: boolean;\n}\n\n/**\n * Character set constants for font definitions.\n * Maps character set names to their hexadecimal identifiers.\n *\n * @publicApi\n */\nexport const CharacterSet = {\n ANSI: \"00\",\n ARABIC: \"B2\",\n BALTIC: \"BA\",\n CHINESEBIG5: \"88\",\n DEFAULT: \"01\",\n EASTEUROPE: \"EE\",\n GB_2312: \"86\",\n GREEK: \"A1\",\n HANGUL: \"81\",\n HEBREW: \"B1\",\n JIS: \"80\",\n JOHAB: \"82\",\n MAC: \"4D\",\n OEM: \"FF\",\n RUSSIAN: \"CC\",\n SYMBOL: \"02\",\n THAI: \"DE\",\n TURKISH: \"A2\",\n VIETNAMESE: \"A3\",\n} as const;\n\n/**\n * Options for defining a font in the document.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * @property name - Font name (required)\n * @property altName - Alternative font name\n * @property panose1 - PANOSE-1 classification\n * @property charset - Character set identifier\n * @property family - Font family\n * @property notTrueType - Whether this is not a TrueType font\n * @property pitch - Font pitch\n * @property sig - Font signature (Unicode and code page ranges)\n * @property embedRegular - Embedded regular font relationship\n * @property embedBold - Embedded bold font relationship\n * @property embedItalic - Embedded italic font relationship\n * @property embedBoldItalic - Embedded bold-italic font relationship\n */\nexport interface FontEntry {\n /** Font name (required) */\n name: string;\n /** Alternative font name */\n altName?: string;\n /** PANOSE-1 classification */\n panose1?: string;\n /** Character set identifier */\n charset?: (typeof CharacterSet)[keyof typeof CharacterSet];\n /** Font family */\n family?: string;\n /** Whether this is not a TrueType font */\n notTrueType?: boolean;\n /** Font pitch */\n pitch?: string;\n /** Font signature (Unicode and code page ranges) */\n sig?: {\n /** Unicode Subset Bitfield 0 */\n usb0: string;\n /** Unicode Subset Bitfield 1 */\n usb1: string;\n /** Unicode Subset Bitfield 2 */\n usb2: string;\n /** Unicode Subset Bitfield 3 */\n usb3: string;\n /** Code Page Bitfield 0 */\n csb0: string;\n /** Code Page Bitfield 1 */\n csb1: string;\n };\n /** Embedded regular font relationship */\n embedRegular?: FontRelationshipOptions;\n /** Embedded bold font relationship */\n embedBold?: FontRelationshipOptions;\n /** Embedded italic font relationship */\n embedItalic?: FontRelationshipOptions;\n /** Embedded bold-italic font relationship */\n embedBoldItalic?: FontRelationshipOptions;\n}\n\n/**\n * Creates a font relationship element for embedding fonts.\n */\nconst createFontRelationship = (\n { id, fontKey, subsetted }: FontRelationshipOptions,\n name: string,\n): string => {\n const attrs: Record<string, string | undefined> = { \"r:id\": id };\n if (fontKey) {\n attrs[\"w:fontKey\"] = `{${fontKey}}`;\n }\n const children = subsetted ? [`<w:subsetted/>`] : undefined;\n return element(name, attrs, children);\n};\n\n/**\n * Creates a font element with the specified options.\n *\n * This function builds a complete font definition including optional embedded font files,\n * font signature, character set, and other font properties.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_font-1.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Font\">\n * <xsd:sequence>\n * <xsd:element name=\"altName\" type=\"CT_String\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"panose1\" type=\"CT_Panose\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"charset\" type=\"CT_Charset\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"family\" type=\"CT_FontFamily\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"notTrueType\" type=\"CT_OnOff\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"pitch\" type=\"CT_Pitch\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"sig\" type=\"CT_FontSig\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedRegular\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedBold\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedItalic\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * <xsd:element name=\"embedBoldItalic\" type=\"CT_FontRel\" minOccurs=\"0\" maxOccurs=\"1\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"name\" type=\"s:ST_String\" use=\"required\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * const font = createFont({\n * name: \"Arial\",\n * family: \"swiss\",\n * pitch: \"variable\",\n * charset: CharacterSet.ANSI\n * });\n * ```\n */\nexport const createFont = ({\n name,\n altName,\n panose1,\n charset,\n family,\n notTrueType,\n pitch,\n sig,\n embedRegular,\n embedBold,\n embedItalic,\n embedBoldItalic,\n}: FontEntry): string => {\n const children: string[] = [];\n\n // http://www.datypic.com/sc/ooxml/e-w_altName-1.html\n if (altName) children.push(createStringElement(\"w:altName\", altName));\n // http://www.datypic.com/sc/ooxml/e-w_panose1-1.html\n if (panose1) children.push(createStringElement(\"w:panose1\", panose1));\n // http://www.datypic.com/sc/ooxml/e-w_charset-1.html\n if (charset) children.push(createStringElement(\"w:charset\", charset));\n // http://www.datypic.com/sc/ooxml/e-w_family-1.html\n if (family) children.push(createStringElement(\"w:family\", family));\n // http://www.datypic.com/sc/ooxml/e-w_notTrueType-1.html\n if (notTrueType) children.push(`<w:notTrueType/>`);\n if (pitch) children.push(createStringElement(\"w:pitch\", pitch));\n // http://www.datypic.com/sc/ooxml/e-w_sig-1.html\n if (sig) {\n children.push(\n `<w:sig w:csb0=\"${sig.csb0}\" w:csb1=\"${sig.csb1}\" w:usb0=\"${sig.usb0}\" w:usb1=\"${sig.usb1}\" w:usb2=\"${sig.usb2}\" w:usb3=\"${sig.usb3}\"/>`,\n );\n }\n // http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html\n if (embedRegular) children.push(createFontRelationship(embedRegular, \"w:embedRegular\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedBold-1.html\n if (embedBold) children.push(createFontRelationship(embedBold, \"w:embedBold\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedItalic-1.html\n if (embedItalic) children.push(createFontRelationship(embedItalic, \"w:embedItalic\"));\n // http://www.datypic.com/sc/ooxml/e-w_embedBoldItalic-1.html\n if (embedBoldItalic) children.push(createFontRelationship(embedBoldItalic, \"w:embedBoldItalic\"));\n\n return element(\"w:font\", { \"w:name\": name }, children);\n};\n","/**\n * Font table descriptor — produces word/fontTable.xml.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html, CT_FontsList\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, escapeXml, findChild } from \"@office-open/xml\";\nimport type { FontSignature } from \"@parts/fonts/font-table\";\nimport type { EmbeddedFontOptionsWithKey } from \"@parts/fonts/font-wrapper\";\n\n// ── Input ──\n\nexport interface FontTableInput {\n fonts: EmbeddedFontOptionsWithKey[];\n}\n\n// ── XML helpers ──\n\nconst NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/** Default font signature for regular embedded fonts. */\nconst DEFAULT_SIG: FontSignature = {\n usb0: \"E0002AFF\",\n usb1: \"C000247B\",\n usb2: \"00000009\",\n usb3: \"00000000\",\n csb0: \"000001FF\",\n csb1: \"00000000\",\n};\n\nfunction fontXml(font: EmbeddedFontOptionsWithKey): string {\n const parts: string[] = [`<w:font w:name=\"${escapeXml(font.name)}\">`];\n\n // CT_Font child order (wml.xsd): altName, panose1, charset, family,\n // notTrueType, pitch, sig, embed*. Embedded fonts (carrying data) fall back\n // to defaults when the parsed value is absent; metadata-only fonts emit only\n // what was parsed.\n if (font.altName) parts.push(`<w:altName w:val=\"${escapeXml(font.altName)}\"/>`);\n if (font.panose1) parts.push(`<w:panose1 w:val=\"${escapeXml(font.panose1)}\"/>`);\n if (font.characterSet || font.characterSetName) {\n const valAttr = font.characterSet ? ` w:val=\"${escapeXml(font.characterSet)}\"` : \"\";\n const csAttr = font.characterSetName\n ? ` w:characterSet=\"${escapeXml(font.characterSetName)}\"`\n : \"\";\n parts.push(`<w:charset${valAttr}${csAttr}/>`);\n }\n const family = font.family ?? (font.embedRid ? \"auto\" : undefined);\n if (family) parts.push(`<w:family w:val=\"${escapeXml(family)}\"/>`);\n const pitch = font.pitch ?? (font.embedRid ? \"variable\" : undefined);\n if (pitch) parts.push(`<w:pitch w:val=\"${escapeXml(pitch)}\"/>`);\n const sig = font.sig ?? (font.embedRid ? DEFAULT_SIG : undefined);\n if (sig) {\n parts.push(\n `<w:sig w:usb0=\"${sig.usb0}\" w:usb1=\"${sig.usb1}\" w:usb2=\"${sig.usb2}\" ` +\n `w:usb3=\"${sig.usb3}\" w:csb0=\"${sig.csb0}\" w:csb1=\"${sig.csb1}\"/>`,\n );\n }\n if (font.embedRid) {\n const embedAttrs = [`r:id=\"${font.embedRid}\"`, `w:fontKey=\"{${font.fontKey}}\"`];\n if (font.subsetted !== undefined) embedAttrs.push(`w:subsetted=\"${font.subsetted ? 1 : 0}\"`);\n parts.push(`<w:embedRegular ${embedAttrs.join(\" \")}/>`);\n }\n\n parts.push(\"</w:font>\");\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\nexport const fontTableDesc: CustomDescriptor<FontTableInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const parts: string[] = [\n `<w:fonts ${NS} mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">`,\n ];\n for (const font of opts.fonts) {\n parts.push(fontXml(font));\n }\n parts.push(\"</w:fonts>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const fonts: EmbeddedFontOptionsWithKey[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:font\") continue;\n const font: Partial<EmbeddedFontOptionsWithKey> = { fontKey: \"\" };\n const name = child.attributes?.[\"w:name\"];\n if (name) font.name = String(name);\n\n const altNameEl = findChild(child, \"w:altName\");\n if (altNameEl) {\n const val = attr(altNameEl, \"w:val\");\n if (val) font.altName = val;\n }\n\n const panose1El = findChild(child, \"w:panose1\");\n if (panose1El) {\n const val = attr(panose1El, \"w:val\");\n if (val) font.panose1 = val;\n }\n\n const charsetEl = findChild(child, \"w:charset\");\n if (charsetEl) {\n const val = attr(charsetEl, \"w:val\");\n if (val) font.characterSet = val as EmbeddedFontOptionsWithKey[\"characterSet\"];\n const csName = attr(charsetEl, \"w:characterSet\");\n if (csName) font.characterSetName = csName;\n }\n\n const familyEl = findChild(child, \"w:family\");\n if (familyEl) {\n const val = attr(familyEl, \"w:val\");\n if (val) font.family = val;\n }\n\n const pitchEl = findChild(child, \"w:pitch\");\n if (pitchEl) {\n const val = attr(pitchEl, \"w:val\");\n if (val) font.pitch = val;\n }\n\n const sigEl = findChild(child, \"w:sig\");\n if (sigEl) {\n const sig: FontSignature = {\n usb0: \"\",\n usb1: \"\",\n usb2: \"\",\n usb3: \"\",\n csb0: \"\",\n csb1: \"\",\n };\n for (const key of [\"usb0\", \"usb1\", \"usb2\", \"usb3\", \"csb0\", \"csb1\"] as const) {\n const val = attr(sigEl, `w:${key}`);\n if (val) sig[key] = val;\n }\n if (Object.values(sig).some(Boolean)) font.sig = sig;\n }\n\n // Obfuscation key + relationship id from embedRegular (the .odttf bytes\n // are resolved separately by parse.ts via fontTable.xml.rels).\n const embedEl = findChild(child, \"w:embedRegular\");\n if (embedEl) {\n const rawKey = attr(embedEl, \"w:fontKey\");\n if (rawKey) {\n font.fontKey = rawKey.replace(/^\\{\\{|\\}\\}$/g, \"\").replace(/^\\{|\\}$/g, \"\");\n }\n const rid = attr(embedEl, \"r:id\");\n if (rid) font.embedRid = rid;\n const subsetted = attrBool(embedEl, \"w:subsetted\");\n if (subsetted !== undefined) font.subsetted = subsetted;\n }\n\n fonts.push(font as EmbeddedFontOptionsWithKey);\n }\n return { fonts };\n },\n};\n","/**\n * Bibliography module for WordprocessingML documents.\n *\n * Provides types for bibliography sources.\n * XML generation is handled by the descriptor pipeline (bibliographyDesc).\n *\n * Reference: ISO/IEC 29500-4, shared-bibliography.xsd, CT_Sources, CT_SourceType\n *\n * @module\n */\n\n/**\n * Options for a single bibliography source entry.\n *\n * Maps to CT_SourceType in the bibliography XSD schema.\n * All fields are optional — include only the relevant ones for each source type.\n *\n * @property type - Source type (Book, JournalArticle, ConferenceProceedings, etc.)\n * @property title - Title of the work\n * @property author - Author names (plain text, semicolon-separated)\n * @property year - Publication year\n * @property month - Publication month\n * @property day - Publication day\n * @property bookTitle - Title of the book (for book sections, articles in collections)\n * @property journal - Journal name (JournalName in XSD)\n * @property volume - Volume number\n * @property issue - Issue number\n * @property pages - Page range\n * @property publisher - Publisher name\n * @property city - City of publication\n * @property url - URL for internet sources\n * @property edition - Edition number or description\n * @property institution - Institution (for theses, reports)\n */\nexport interface SourceTypeOptions {\n type?: string;\n title?: string;\n author?: string;\n year?: string;\n month?: string;\n day?: string;\n bookTitle?: string;\n journal?: string;\n volume?: string;\n issue?: string;\n pages?: string;\n publisher?: string;\n city?: string;\n url?: string;\n edition?: string;\n institution?: string;\n}\n\n/**\n * Options for creating a bibliography container.\n *\n * @property sources - Array of bibliography source entries\n * @property styleName - Bibliography style name (e.g., \"APA\", \"Chicago\", \"IEEE\")\n */\nexport interface BibliographyOptions {\n sources: SourceTypeOptions[];\n styleName?: string;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml, findChild, textOf } from \"@office-open/xml\";\n\nconst SOURCE_FIELDS: readonly (readonly [string, keyof SourceTypeOptions])[] = [\n [\"SourceType\", \"type\"],\n [\"Title\", \"title\"],\n [\"Author\", \"author\"],\n [\"Year\", \"year\"],\n [\"Month\", \"month\"],\n [\"Day\", \"day\"],\n [\"BookTitle\", \"bookTitle\"],\n [\"JournalName\", \"journal\"],\n [\"Volume\", \"volume\"],\n [\"Issue\", \"issue\"],\n [\"Pages\", \"pages\"],\n [\"Publisher\", \"publisher\"],\n [\"City\", \"city\"],\n [\"URL\", \"url\"],\n [\"Edition\", \"edition\"],\n [\"Institution\", \"institution\"],\n] as const;\n\nexport const bibliographyDesc: CustomDescriptor<BibliographyOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const attrParts: string[] = [\n 'xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"',\n ];\n if (opts.styleName !== undefined) {\n attrParts.push(`StyleName=\"${escapeXml(opts.styleName)}\"`);\n }\n\n const parts: string[] = [`<b:Sources ${attrParts.join(\" \")}>`];\n\n for (const source of opts.sources) {\n const sourceParts: string[] = [];\n for (const [tagName, key] of SOURCE_FIELDS) {\n const value = source[key];\n if (value !== undefined) {\n sourceParts.push(`<b:${tagName}>${escapeXml(value)}</b:${tagName}>`);\n }\n }\n parts.push(`<b:Source>${sourceParts.join(\"\")}</b:Source>`);\n }\n\n parts.push(\"</b:Sources>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Partial<BibliographyOptions> = {};\n\n // StyleName attribute\n const styleName = el.attributes?.[\"StyleName\"];\n if (styleName) opts.styleName = styleName as string;\n\n // Parse b:Source children\n const sources: SourceTypeOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"b:Source\") continue;\n const source: SourceTypeOptions = {};\n for (const [, key] of SOURCE_FIELDS) {\n const xmlChild = findChild(child, `b:${SOURCE_FIELDS.find((f) => f[1] === key)![0]}`);\n if (xmlChild) {\n const val = textOf(xmlChild);\n if (val) source[key] = val;\n }\n }\n sources.push(source);\n }\n opts.sources = sources;\n\n return opts as BibliographyOptions;\n },\n};\n","/**\n * Glossary document component — stores building block definitions.\n *\n * Generates word/glossary/document.xml containing Quick Parts entries\n * that appear in Word's Insert > Quick Parts gallery.\n *\n * @module\n */\n\nimport type { SectionChild } from \"@shared/section\";\n\n/** Gallery type for building blocks (ST_DocPartGallery) */\nexport const DocPartGallery = {\n PLACEHOLDER: \"placeholder\",\n DEFAULT: \"default\",\n DOC_PARTS: \"docParts\",\n COVER_PAGE: \"coverPg\",\n EQUATIONS: \"eq\",\n FOOTERS: \"ftrs\",\n HEADERS: \"hdrs\",\n PAGE_NUMBERS: \"pgNum\",\n TABLES: \"tbls\",\n WATERMARKS: \"watermarks\",\n AUTO_TEXT: \"autoTxt\",\n TEXT_BOX: \"txtBox\",\n PAGE_NUMBERS_TOP: \"pgNumT\",\n PAGE_NUMBERS_BOTTOM: \"pgNumB\",\n PAGE_NUMBERS_MARGIN: \"pgNumMargins\",\n TABLE_OF_CONTENTS: \"tblOfContents\",\n BIBLIOGRAPHY: \"bib\",\n CUSTOM_QUICK_PARTS: \"custQuickParts\",\n CUSTOM_COVER_PAGE: \"custCoverPg\",\n CUSTOM_EQUATIONS: \"custEq\",\n CUSTOM_FOOTERS: \"custFtrs\",\n CUSTOM_HEADERS: \"custHdrs\",\n CUSTOM_PAGE_NUMBERS: \"custPgNum\",\n CUSTOM_TABLES: \"custTbls\",\n CUSTOM_WATERMARKS: \"custWatermarks\",\n CUSTOM_AUTO_TEXT: \"custAutoTxt\",\n CUSTOM_TEXT_BOX: \"custTxtBox\",\n CUSTOM_PAGE_NUMBERS_TOP: \"custPgNumT\",\n CUSTOM_PAGE_NUMBERS_BOTTOM: \"custPgNumB\",\n CUSTOM_PAGE_NUMBERS_MARGIN: \"custPgNumMargins\",\n CUSTOM_TABLE_OF_CONTENTS: \"custTblOfContents\",\n CUSTOM_BIBLIOGRAPHY: \"custBib\",\n CUSTOM1: \"custom1\",\n CUSTOM2: \"custom2\",\n CUSTOM3: \"custom3\",\n CUSTOM4: \"custom4\",\n CUSTOM5: \"custom5\",\n} as const;\n\nexport type DocPartGallery = (typeof DocPartGallery)[keyof typeof DocPartGallery];\n\n/** Building block type (ST_DocPartType) */\nexport const DocPartType = {\n NONE: \"none\",\n NORMAL: \"normal\",\n AUTO_EXPAND: \"autoExp\",\n TOOLBAR: \"toolbar\",\n SPELLER: \"speller\",\n FORM_FIELD: \"formFld\",\n BUILDING_BLOCK_PLACEHOLDER: \"bbPlcHdr\",\n} as const;\n\nexport type DocPartType = (typeof DocPartType)[keyof typeof DocPartType];\n\n/** Building block behavior (ST_DocPartBehavior) */\nexport const DocPartBehavior = {\n CONTENT: \"content\",\n PARAGRAPH: \"p\",\n PAGE: \"pg\",\n} as const;\n\nexport type DocPartBehavior = (typeof DocPartBehavior)[keyof typeof DocPartBehavior];\n\n/** A single building block (CT_DocPart) */\nexport interface DocPartOptions {\n /** Building block name (required) */\n name: string;\n /** Gallery category (required) */\n gallery: DocPartGallery;\n /** Category name within the gallery */\n category?: string;\n /** Building block types */\n types?: DocPartType[];\n /** Whether all building block types are included (w:all attribute) */\n allTypes?: boolean;\n /** Insertion behaviors */\n behaviors?: DocPartBehavior[];\n /** Description */\n description?: string;\n /** GUID for this building block */\n guid?: string;\n /** Whether the name is decorated (built-in) */\n decorated?: boolean;\n /** Body content — paragraphs, tables, etc. */\n children: SectionChild[];\n}\n\n/** Glossary document options */\nexport interface GlossaryDocumentOptions {\n /** Building blocks */\n parts: DocPartOptions[];\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, findChild } from \"@office-open/xml\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\nconst GLOSSARY_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\nfunction docPartPrXml(part: GlossaryDocumentOptions[\"parts\"][number]): string {\n const prParts: string[] = [];\n prParts.push(\n `<w:name w:val=\"${escapeXml(part.name)}\"${part.decorated ? ' w:decorated=\"1\"' : \"\"}/>`,\n );\n if (part.category || part.gallery) {\n const catParts: string[] = [];\n if (part.category) {\n catParts.push(`<w:name w:val=\"${escapeXml(part.category)}\"/>`);\n }\n catParts.push(`<w:gallery w:val=\"${part.gallery}\"/>`);\n prParts.push(`<w:category>${catParts.join(\"\")}</w:category>`);\n }\n if (part.types && part.types.length > 0) {\n const typeXml = part.types.map((t) => `<w:type w:val=\"${t}\"/>`).join(\"\");\n const allAttr = part.allTypes ? ' w:all=\"1\"' : \"\";\n prParts.push(`<w:types${allAttr}>${typeXml}</w:types>`);\n }\n if (part.behaviors && part.behaviors.length > 0) {\n const behaviorXml = part.behaviors.map((b) => `<w:behavior w:val=\"${b}\"/>`).join(\"\");\n prParts.push(`<w:behaviors>${behaviorXml}</w:behaviors>`);\n }\n if (part.description) {\n prParts.push(`<w:description w:val=\"${escapeXml(part.description)}\"/>`);\n }\n if (part.guid) {\n prParts.push(`<w:guid w:val=\"${escapeXml(part.guid)}\"/>`);\n }\n return `<w:docPartPr>${prParts.join(\"\")}</w:docPartPr>`;\n}\n\nexport const glossaryDesc: CustomDescriptor<GlossaryDocumentOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const partsXml = opts.parts\n .map((part) => {\n const bodyContent = ((part.children ?? []) as SectionChild[])\n .map((child) => ctx.stringifyChild(child, ctx))\n .join(\"\");\n\n return `<w:docPart>${docPartPrXml(part)}<w:docPartBody>${bodyContent}</w:docPartBody></w:docPart>`;\n })\n .join(\"\");\n\n return `<w:glossaryDocument ${GLOSSARY_NS}><w:docParts>${partsXml}</w:docParts></w:glossaryDocument>`;\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n const parts: DocPartOptions[] = [];\n\n const docPartsEl = findChild(el, \"w:docParts\");\n if (!docPartsEl) return { parts };\n\n for (const docPart of docPartsEl.elements ?? []) {\n if (docPart.name !== \"w:docPart\") continue;\n const part: Partial<DocPartOptions> = {};\n\n // Parse w:docPartPr\n const pr = findChild(docPart, \"w:docPartPr\");\n if (pr) {\n // name\n const name = findChild(pr, \"w:name\");\n if (name) {\n part.name = attr(name, \"w:val\") ?? \"\";\n const decorated = attr(name, \"w:decorated\");\n if (decorated === \"1\") part.decorated = true;\n }\n\n // category\n const category = findChild(pr, \"w:category\");\n if (category) {\n const catName = findChild(category, \"w:name\");\n if (catName) part.category = attr(catName, \"w:val\");\n const gallery = findChild(category, \"w:gallery\");\n if (gallery) part.gallery = attr(gallery, \"w:val\") as DocPartOptions[\"gallery\"];\n }\n\n // types\n const types = findChild(pr, \"w:types\");\n if (types) {\n const typeList: string[] = [];\n for (const t of types.elements ?? []) {\n if (t.name === \"w:type\") {\n const val = attr(t, \"w:val\");\n if (val) typeList.push(val);\n }\n }\n if (typeList.length > 0) part.types = typeList as DocPartOptions[\"types\"];\n const allAttr = attr(types, \"w:all\");\n if (allAttr === \"1\") part.allTypes = true;\n }\n\n // behaviors\n const behaviors = findChild(pr, \"w:behaviors\");\n if (behaviors) {\n const behaviorList: string[] = [];\n for (const b of behaviors.elements ?? []) {\n if (b.name === \"w:behavior\") {\n const val = attr(b, \"w:val\");\n if (val) behaviorList.push(val);\n }\n }\n if (behaviorList.length > 0) part.behaviors = behaviorList as DocPartOptions[\"behaviors\"];\n }\n\n // description\n const desc = findChild(pr, \"w:description\");\n if (desc) {\n const val = attr(desc, \"w:val\");\n if (val) part.description = val;\n }\n\n // guid\n const guid = findChild(pr, \"w:guid\");\n if (guid) {\n const val = attr(guid, \"w:val\");\n if (val) part.guid = val;\n }\n }\n\n // Parse w:docPartBody children\n const body = findChild(docPart, \"w:docPartBody\");\n if (body) {\n const childList: unknown[] = [];\n for (const sub of body.elements ?? []) {\n if (sub.name === \"w:p\") {\n childList.push({ paragraph: parseParagraph(sub, dctx) });\n }\n }\n if (childList.length > 0) part.children = childList as DocPartOptions[\"children\"];\n }\n\n parts.push(part as DocPartOptions);\n }\n\n return { parts };\n },\n};\n","/**\n * Comments descriptor — produces word/comments.xml.\n *\n * Stringifies pure JSON CommentsOptions into XML without creating\n * Comment/Comments class instances.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, escapeXml } from \"@office-open/xml\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { CommentsOptions, CommentOptions } from \"@parts/paragraph/run/comment-run\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext } from \"../context\";\nimport type { DocxReadContext } from \"../context\";\nimport { stringifyParagraphInline } from \"./inline\";\n\nconst COMMENTS_NS =\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n// ── Comment stringification ──\n\nfunction stringifyComment(opts: CommentOptions, ctx: BodyContext): string {\n const dateStr =\n typeof opts.date === \"string\" ? opts.date : (opts.date ?? new Date()).toISOString();\n // w:author is XSD-required (CT_TrackChange); default to empty string when absent.\n const attrs: string[] = [\n `w:id=\"${opts.id}\"`,\n `w:author=\"${escapeXml(opts.author ?? \"\")}\"`,\n `w:date=\"${escapeXml(dateStr)}\"`,\n ];\n if (opts.initials !== undefined) attrs.push(`w:initials=\"${escapeXml(opts.initials)}\"`);\n\n const parts: string[] = [];\n for (const child of opts.children) {\n parts.push(stringifyParagraphInline(child, ctx));\n }\n\n return `<w:comment ${attrs.join(\" \")}>${parts.join(\"\")}</w:comment>`;\n}\n\n// ── Descriptor ──\n\nexport const commentsDesc: CustomDescriptor<CommentsOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [`<w:comments ${COMMENTS_NS}>`];\n\n for (const child of opts.children) {\n parts.push(stringifyComment(child, ctx));\n }\n\n parts.push(\"</w:comments>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const comments: CommentOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:comment\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const comment: Partial<CommentOptions> = { id };\n const date = attr(child, \"w:date\");\n if (date) comment.date = date;\n const author = attr(child, \"w:author\");\n if (author !== undefined) comment.author = author;\n const initials = attr(child, \"w:initials\");\n if (initials !== undefined) comment.initials = initials;\n\n const children: (string | ParagraphOptions)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n children.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n comment.children = children;\n comments.push(comment as CommentOptions);\n }\n return { children: comments };\n },\n};\n","/**\n * Content types descriptor — produces [Content_Types].xml.\n *\n * Reference: OPC, Content_Types.xsd\n *\n * @module\n */\n\nimport { buildContentTypeOverrides, DOCX_PARTS } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\n\nexport interface ContentTypeDefault {\n extension: string;\n contentType: string;\n}\n\nexport interface ContentTypeOverride {\n partName: string;\n contentType: string;\n}\n\nexport interface ContentTypesInput {\n defaults: ContentTypeDefault[];\n overrides: ContentTypeOverride[];\n}\n\nfunction defaultXml(ext: string, ct: string): string {\n return `<Default Extension=\"${ext}\" ContentType=\"${ct}\"/>`;\n}\n\nfunction overrideXml(partName: string, ct: string): string {\n return `<Override PartName=\"${partName}\" ContentType=\"${ct}\"/>`;\n}\n\nexport const contentTypesDesc: CustomDescriptor<ContentTypesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n ];\n for (const d of opts.defaults) {\n p.push(defaultXml(d.extension, d.contentType));\n }\n for (const o of opts.overrides) {\n p.push(overrideXml(o.partName, o.contentType));\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const defaults: ContentTypeDefault[] = [];\n const overrides: ContentTypeOverride[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"Default\") {\n const ext = child.attributes?.[\"Extension\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (ext && ct) defaults.push({ extension: String(ext), contentType: String(ct) });\n } else if (child.name === \"Override\") {\n const pn = child.attributes?.[\"PartName\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (pn && ct) overrides.push({ partName: String(pn), contentType: String(ct) });\n }\n }\n return { defaults, overrides };\n },\n};\n\n/** Standard extension → content-type defaults covering every media type emitted. */\nconst STANDARD_DEFAULTS: ContentTypeDefault[] = [\n { extension: \"png\", contentType: \"image/png\" },\n { extension: \"jpeg\", contentType: \"image/jpeg\" },\n { extension: \"jpg\", contentType: \"image/jpeg\" },\n { extension: \"bmp\", contentType: \"image/bmp\" },\n { extension: \"gif\", contentType: \"image/gif\" },\n { extension: \"tif\", contentType: \"image/tiff\" },\n { extension: \"tiff\", contentType: \"image/tiff\" },\n { extension: \"emf\", contentType: \"image/x-emf\" },\n { extension: \"wmf\", contentType: \"image/x-wmf\" },\n { extension: \"ico\", contentType: \"image/x-icon\" },\n { extension: \"svg\", contentType: \"image/svg+xml\" },\n { extension: \"rels\", contentType: \"application/vnd.openxmlformats-package.relationships+xml\" },\n { extension: \"xml\", contentType: \"application/xml\" },\n {\n extension: \"odttf\",\n contentType: \"application/vnd.openxmlformats-officedocument.obfuscatedFont\",\n },\n {\n extension: \"bin\",\n contentType: \"application/vnd.openxmlformats-officedocument.oleObject\",\n },\n];\n\n/**\n * Ensure every media part in the package has a resolvable content-type Default.\n *\n * Round-tripped packages pass through the source's [Content_Types], which may\n * declare an uppercase extension (e.g. `JPG`) while the media is named `.jpg`.\n * OPC extension matching is case-sensitive, so the media ends up with no\n * content type and Word rejects it as unreadable content. This backfills any\n * missing defaults from the standard set, preserving the case actually used in\n * the media filenames.\n */\nexport function withMediaDefaults(\n input: ContentTypesInput,\n mediaFileNames: string[],\n): ContentTypesInput {\n const have = new Set(input.defaults.map((d) => d.extension));\n const standard = new Map(STANDARD_DEFAULTS.map((d) => [d.extension, d.contentType]));\n const defaults = [...input.defaults];\n for (const fileName of mediaFileNames) {\n const ext = fileName.slice(fileName.lastIndexOf(\".\") + 1);\n if (!ext || have.has(ext)) continue;\n const contentType = standard.get(ext) ?? standard.get(ext.toLowerCase());\n if (contentType) {\n defaults.push({ extension: ext, contentType });\n have.add(ext);\n }\n }\n return { defaults, overrides: input.overrides };\n}\n\n/** Default content types for altChunk part extensions. */\nconst ALTCHUNK_DEFAULTS: Record<string, string> = {\n html: \"text/html\",\n rtf: \"application/rtf\",\n txt: \"text/plain\",\n};\n\n/**\n * Realign [Content_Types] Overrides for altChunk parts on a round-tripped\n * package. The pass-through content types carry Override PartNames from the\n * source, but the compiler regenerates altChunk part paths (uniqueId), so the\n * Override and the written part drift apart (O5/O6). This drops the stale\n * afchunk Overrides and appends ones matching the freshly generated paths,\n * backfilling the extension Default so the part is resolvable either way.\n */\nexport function withAltChunkOverrides(\n input: ContentTypesInput,\n altChunks: readonly { path: string; contentType: string }[],\n): ContentTypesInput {\n const defaults = [...input.defaults];\n const haveExt = new Set(defaults.map((d) => d.extension));\n for (const ac of altChunks) {\n const ext = (ac.path.split(\".\").pop() ?? \"\").toLowerCase();\n if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {\n defaults.push({ extension: ext, contentType: ALTCHUNK_DEFAULTS[ext] });\n haveExt.add(ext);\n }\n }\n const overrides = input.overrides.filter((o) => !o.partName.startsWith(\"/word/afchunks/\"));\n for (const ac of altChunks) {\n const partName = ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`;\n overrides.push({ partName, contentType: ac.contentType });\n }\n return { defaults, overrides };\n}\n\n/**\n * Build [Content_Types].xml for a fresh DOCX compile, driven by the part\n * registry. Static parts (document/styles/…/comments/headers/…) come from\n * {@link buildContentTypeOverrides} over {@link DOCX_PARTS}; dynamic parts whose\n * path or count is runtime-determined (altChunks, sub-documents) are appended\n * here — they are not enumerable in the registry.\n *\n * `facts` keys mirror the registry's `flag` / `countFrom` tokens. The Override\n * set (order-independent) matches the former hand-written builder, so the OPC\n * consistency validator stays green.\n */\nexport function buildContentTypesFromRegistry(\n facts: ReadonlyMap<string, boolean | number>,\n dynamic: {\n altChunks?: ReadonlyArray<{ path: string; contentType: string }>;\n subDocs?: ReadonlyArray<{ path: string }>;\n } = {},\n): ContentTypesInput {\n const overrides: ContentTypeOverride[] = buildContentTypeOverrides(DOCX_PARTS, facts);\n for (const ac of dynamic.altChunks ?? []) {\n overrides.push({\n partName: ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`,\n contentType: ac.contentType,\n });\n }\n for (const sd of dynamic.subDocs ?? []) {\n overrides.push({\n partName: sd.path.startsWith(\"/\") ? sd.path : `/${sd.path}`,\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n });\n }\n // Minimal defaults: rels/xml are present in every package; altChunk\n // extensions only when altChunks exist. Image/font/embedding extensions are\n // backfilled by withMediaDefaults from the actual part file names, so we no\n // longer declare every possible media type unconditionally — Word strips the\n // unused ones when repairing and that pollutes the \"removed unsupported\n // content\" diff.\n const defaults: ContentTypeDefault[] = [\n { extension: \"rels\", contentType: \"application/vnd.openxmlformats-package.relationships+xml\" },\n { extension: \"xml\", contentType: \"application/xml\" },\n ];\n const haveExt = new Set([\"rels\", \"xml\"]);\n for (const ac of dynamic.altChunks ?? []) {\n const ext = (ac.path.split(\".\").pop() ?? \"\").toLowerCase();\n if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {\n defaults.push({ extension: ext, contentType: ALTCHUNK_DEFAULTS[ext] });\n haveExt.add(ext);\n }\n }\n return { defaults, overrides };\n}\n","/**\n * Relationships descriptor — produces .rels XML files.\n *\n * Reference: OPC, Relationships.xsd\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport interface RelationshipEntry {\n id: number | string;\n type: string;\n target: string;\n targetMode?: string;\n}\n\nexport interface RelationshipsInput {\n relationships: RelationshipEntry[];\n}\n\nexport const relationshipsDesc: CustomDescriptor<RelationshipsInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">',\n ];\n for (const rel of opts.relationships) {\n const targetModeAttr = rel.targetMode ? ` TargetMode=\"${escapeXml(rel.targetMode)}\"` : \"\";\n p.push(\n `<Relationship Id=\"rId${rel.id}\" Type=\"${escapeXml(rel.type)}\" Target=\"${escapeXml(rel.target)}\"${targetModeAttr}/>`,\n );\n }\n p.push(\"</Relationships>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const relationships: RelationshipEntry[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"Relationship\") continue;\n const id = child.attributes?.[\"Id\"];\n const type = child.attributes?.[\"Type\"];\n const target = child.attributes?.[\"Target\"];\n const targetMode = child.attributes?.[\"TargetMode\"];\n if (id && type && target) {\n const numId = String(id).replace(\"rId\", \"\");\n relationships.push({\n id: Number(numId) || id,\n type: String(type),\n target: String(target),\n targetMode: targetMode ? String(targetMode) : undefined,\n });\n }\n }\n return { relationships };\n },\n};\n","import type { BibliographyOptions } from \"@parts/bibliography\";\n/**\n * Core Properties module for WordprocessingML documents.\n *\n * Provides the DocumentOptions interface for document metadata.\n * XML generation is handled by the descriptor pipeline (corePropertiesDesc).\n *\n * Reference: ISO-IEC29500-4_2016 shared-documentPropertiesCore.xsd\n *\n * @module\n */\nimport type { ContentTypesInput } from \"@parts/contenttypes\";\nimport type { EmbeddedFontOptions } from \"@parts/fonts/font-table\";\nimport type { GlossaryDocumentOptions } from \"@parts/glossary-document\";\nimport type { CommentsOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { HyphenationOptions } from \"@parts/settings\";\nimport type { CompatibilityOptions } from \"@parts/settings/compatibility\";\nimport type {\n DocumentProtectionOptions,\n SettingsOptions,\n WriteProtectionOptions,\n} from \"@parts/settings/settings\";\nimport type { SectionOptions } from \"@shared/section\";\n\nimport type { AppPropertiesOptions } from \"./app-properties\";\nimport type { CustomPropertyOptions } from \"./custom-properties\";\nimport type { DocumentBackgroundOptions } from \"./document\";\nimport type { EndnoteSeparator } from \"./endnotes/descriptor\";\nimport type { FootnoteSeparator } from \"./footnotes/descriptor\";\nimport type { NumberingOptions } from \"./numbering\";\nimport type { ParagraphOptions } from \"./paragraph\";\nimport type { StylesOptions } from \"./styles\";\nimport type { WebSettingsOptions } from \"./web-settings\";\n\n/**\n * Document-level feature toggles parsed from settings.xml.\n *\n * @property trackRevisions - Track changes\n * @property updateFields - Update fields on open\n * @property documentProtection - Document write protection\n */\nexport interface FeaturesOptions {\n trackRevisions?: boolean;\n updateFields?: boolean;\n documentProtection?: DocumentProtectionOptions;\n}\n\n/**\n * Options for configuring document properties.\n *\n * @property sections - Document section configurations\n * @property title - Document title\n * @property subject - Document subject\n * @property creator - Document creator/author\n * @property keywords - Document keywords for searchability\n * @property description - Document description\n * @property lastModifiedBy - User who last modified the document\n * @property revision - Revision number\n * @property lastPrinted - Last printed timestamp (W3CDTF), round-tripped from cp:lastPrinted\n * @property externalStyles - External stylesheet reference\n * @property styles - Document styles configuration\n * @property numbering - Numbering configuration\n * @property comments - Document comments configuration\n * @property bibliography - Document bibliography sources\n * @property footnotes - Document footnotes\n * @property background - Document background settings\n * @property features - Document features like track changes\n * @property compatabilityModeVersion - Compatibility mode version\n * @property compatibility - Compatibility settings\n * @property customProperties - Custom document properties\n * @property evenAndOddHeaderAndFooters - Enable different headers/footers for even/odd pages\n * @property defaultTabStop - Default tab stop width\n * @property fonts - Font configurations\n * @property hyphenation - Hyphenation settings\n */\nexport interface DocumentOptions extends CorePropertiesOptions {\n sections: SectionOptions[];\n externalStyles?: string;\n styles?: StylesOptions;\n numbering?: NumberingOptions;\n comments?: CommentsOptions;\n bibliography?: BibliographyOptions;\n footnotes?: Record<string, { children: (ParagraphOptions | string)[] }> & {\n /**\n * Separator footnote — id + content round-tripped verbatim from the source\n * so the generated id stays consistent with settings.footnotePr, which\n * references it. Omit for freshly generated documents (defaults apply).\n */\n separator?: FootnoteSeparator;\n /** Continuation separator footnote — round-tripped verbatim from the source. */\n continuationSeparator?: FootnoteSeparator;\n };\n endnotes?: Record<string, { children: (ParagraphOptions | string)[] }> & {\n /** Separator endnote — id + content round-tripped verbatim from the source. */\n separator?: EndnoteSeparator;\n /** Continuation separator endnote — round-tripped verbatim from the source. */\n continuationSeparator?: EndnoteSeparator;\n };\n background?: DocumentBackgroundOptions;\n features?: FeaturesOptions;\n compatabilityModeVersion?: number;\n compatibility?: CompatibilityOptions;\n customProperties?: CustomPropertyOptions[];\n evenAndOddHeaderAndFooters?: boolean;\n defaultTabStop?: number;\n fonts?: EmbeddedFontOptions[];\n hyphenation?: HyphenationOptions;\n /** Document conformance class (w:document/@w:conformance). */\n conformance?: \"strict\" | \"transitional\";\n /** Controls whether punctuation is compressed at line ends */\n characterSpacingControl?: \"compressPunctuation\" | \"doNotCompress\";\n /** Default document view mode */\n view?: \"none\" | \"print\" | \"outline\" | \"masterPages\" | \"normal\" | \"web\";\n /** Default zoom level (percentage) and type */\n zoom?: {\n percent?: number;\n val?: \"none\" | \"fullPage\" | \"bestFit\" | \"textFit\";\n };\n /** Write protection recommendation (not enforcement) */\n writeProtection?: WriteProtectionOptions;\n /** Whether to display the background shape in print layout */\n displayBackgroundShape?: boolean;\n /** Whether to embed TrueType fonts in the document */\n embedTrueTypeFonts?: boolean;\n /** Whether to embed system fonts in the document */\n embedSystemFonts?: boolean;\n /** Whether to save only a subset of the embedded fonts */\n saveSubsetFonts?: boolean;\n /** Document variables (key-value pairs stored in the document) */\n docVars?: { name: string; val: string }[];\n /** Theme color scheme remapping */\n colorSchemeMapping?: SettingsOptions[\"colorSchemeMapping\"];\n /** Mail merge configuration */\n mailMerge?: SettingsOptions[\"mailMerge\"];\n /** Glossary document — building blocks (Quick Parts) */\n glossary?: GlossaryDocumentOptions;\n /** Additional document settings passed through to the settings.xml part */\n settings?: SettingsOptions;\n /** Web settings for browser rendering (word/webSettings.xml) */\n webSettings?: WebSettingsOptions;\n /** Content types from [Content_Types].xml (parse path only) */\n contentTypes?: ContentTypesInput;\n /**\n * Parts carried verbatim from the source that generate() does not rebuild\n * (e.g. word/theme/*, customXml/*). Kept as raw bytes so their [Content_Types]\n * declarations stay valid and the package opens in Word. Media/fonts/headers\n * are rebuilt by the compiler and must NOT be listed here.\n */\n rawParts?: { path: string; data: Uint8Array }[];\n /** Extended properties (docProps/app.xml) */\n appProperties?: AppPropertiesOptions;\n}\n\n// ── Descriptor ──\n\nimport type { CorePropertiesOptions } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport const corePropertiesDesc: CustomDescriptor<CorePropertiesOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const now = new Date().toISOString();\n const p: string[] = [\n '<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"' +\n ' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"' +\n ' xmlns:dcterms=\"http://purl.org/dc/terms/\"' +\n ' xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\"' +\n ' xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">',\n ];\n // Emit in CT_CoreProperties xsd:all schema order: created, creator,\n // description, keywords, lastModifiedBy, lastPrinted, modified, revision,\n // subject, title. created/modified default to now for fresh documents.\n p.push(`<dcterms:created xsi:type=\"dcterms:W3CDTF\">${opts.created ?? now}</dcterms:created>`);\n if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);\n if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);\n if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);\n if (opts.lastModifiedBy)\n p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy)}</cp:lastModifiedBy>`);\n if (opts.lastPrinted) p.push(`<cp:lastPrinted>${escapeXml(opts.lastPrinted)}</cp:lastPrinted>`);\n p.push(\n `<dcterms:modified xsi:type=\"dcterms:W3CDTF\">${opts.modified ?? now}</dcterms:modified>`,\n );\n if (opts.revision !== undefined) p.push(`<cp:revision>${opts.revision}</cp:revision>`);\n if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);\n if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);\n p.push(\"</cp:coreProperties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: CorePropertiesOptions = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n if (typeof text !== \"string\") continue;\n switch (child.name) {\n case \"dc:title\":\n result.title = text;\n break;\n case \"dc:subject\":\n result.subject = text;\n break;\n case \"dc:creator\":\n result.creator = text;\n break;\n case \"cp:keywords\":\n result.keywords = text;\n break;\n case \"dc:description\":\n result.description = text;\n break;\n case \"cp:lastModifiedBy\":\n result.lastModifiedBy = text;\n break;\n case \"cp:revision\":\n result.revision = Number(text);\n break;\n case \"cp:lastPrinted\":\n result.lastPrinted = text;\n break;\n case \"dcterms:created\":\n result.created = text;\n break;\n case \"dcterms:modified\":\n result.modified = text;\n break;\n }\n }\n return result;\n },\n};\n","/**\n * Web Settings module for WordprocessingML documents.\n *\n * Provides types for web settings configuration.\n * XML generation is handled by the descriptor pipeline (webSettingsDesc).\n *\n * Reference: http://officeopenxml.com/WPwebSettings.php\n *\n * @module\n */\n\nimport type { FramesetOptions } from \"@parts/frameset\";\n\n/**\n * Border options for div elements.\n */\nexport interface DivBorderOptions {\n top?: { style: string; color?: string; size?: number };\n left?: { style: string; color?: string; size?: number };\n bottom?: { style: string; color?: string; size?: number };\n right?: { style: string; color?: string; size?: number };\n}\n\n/**\n * Options for a div element (CT_Div).\n */\nexport interface DivOptions {\n /** Unique div identifier (required by CT_Div/@id) */\n id: number;\n marginLeft: number | UniversalMeasure;\n marginRight: number | UniversalMeasure;\n marginTop: number | UniversalMeasure;\n marginBottom: number | UniversalMeasure;\n /** Mark as HTML blockquote element */\n blockQuote?: boolean;\n /** Mark as HTML body element */\n bodyDiv?: boolean;\n border?: DivBorderOptions;\n children?: DivOptions[];\n}\n\n/**\n * Screen size types for web settings target.\n */\nexport const TargetScreenSize = {\n SIZE_544X376: \"544x376\",\n SIZE_640X480: \"640x480\",\n SIZE_720X512: \"720x512\",\n SIZE_800X600: \"800x600\",\n SIZE_1024X768: \"1024x768\",\n SIZE_1152X882: \"1152x882\",\n SIZE_1152X900: \"1152x900\",\n SIZE_1280X1024: \"1280x1024\",\n SIZE_1600X1200: \"1600x1200\",\n SIZE_1800X1440: \"1800x1440\",\n SIZE_1920X1200: \"1920x1200\",\n} as const;\n\n/**\n * Options for the w:optimizeForBrowser element.\n *\n * CT_OptimizeForBrowser extends CT_OnOff with an optional @w:target attribute.\n */\nexport interface OptimizeForBrowserOptions {\n /** On/off value — defaults to true when omitted (CT_OnOff). */\n value?: boolean;\n /** Target screen resolution name (w:optimizeForBrowser/@w:target). */\n target?: string;\n}\n\n/**\n * Options for web settings (CT_WebSettings).\n */\nexport interface WebSettingsOptions {\n /** Frameset definition for web layout */\n frameset?: FramesetOptions;\n /** Div elements for HTML div formatting */\n divs?: DivOptions[];\n /** Character encoding for web output */\n encoding?: string;\n /** Optimize document rendering for web browser (w:optimizeForBrowser). */\n optimizeForBrowser?: boolean | OptimizeForBrowserOptions;\n /** Rely on VML for graphics display */\n relyOnVML?: boolean;\n /** Allow PNG image format in web output */\n allowPNG?: boolean;\n /** Do not rely on CSS for formatting */\n doNotRelyOnCSS?: boolean;\n /** Do not save as single web file */\n doNotSaveAsSingleFile?: boolean;\n /** Do not organize supporting files in folders */\n doNotOrganizeInFolder?: boolean;\n /** Do not use long file names for supporting files */\n doNotUseLongFileNames?: boolean;\n /** Pixels per inch for web output */\n pixelsPerInch?: number;\n /** Target screen size */\n targetScreenSize?: (typeof TargetScreenSize)[keyof typeof TargetScreenSize] | string;\n /** Save smart tags as XML */\n saveSmartTagsAsXml?: boolean;\n}\n\n// ── Descriptor ──\n\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, escapeXml, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { FrameOptions, FramesetSplitbarOptions } from \"@parts/frameset\";\n\n/** Subset of WebSettingsOptions for descriptor stringify. */\nexport interface WebSettingsInput {\n frameset?: FramesetOptions;\n divs?: DivOptions[];\n encoding?: string;\n optimizeForBrowser?: boolean | OptimizeForBrowserOptions;\n relyOnVML?: boolean;\n allowPNG?: boolean;\n doNotRelyOnCSS?: boolean;\n doNotSaveAsSingleFile?: boolean;\n doNotOrganizeInFolder?: boolean;\n doNotUseLongFileNames?: boolean;\n pixelsPerInch?: number;\n targetScreenSize?: string;\n saveSmartTagsAsXml?: boolean;\n}\n\nconst WS_NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\"';\n\nfunction wsOnOff(tag: string, val: boolean): string {\n return `<${tag} w:val=\"${val ? \"true\" : \"false\"}\"/>`;\n}\n\nfunction wsStringVal(tag: string, val: string): string {\n return `<${tag} w:val=\"${escapeXml(val)}\"/>`;\n}\n\nfunction wsNumVal(tag: string, val: number | UniversalMeasure): string {\n return `<${tag} w:val=\"${val}\"/>`;\n}\n\n// ── Parse helpers (for descriptor parse path) ──\n\nfunction parseFramesetEl(el: Element): FramesetOptions {\n const opts: Partial<FramesetOptions> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const splitbar = findChild(el, \"w:framesetSplitbar\");\n if (splitbar) opts.splitbar = parseSplitbarEl(splitbar);\n\n const layout = findChild(el, \"w:frameLayout\");\n if (layout) {\n const val = attr(layout, \"w:val\");\n if (val === \"rows\" || val === \"cols\") opts.layout = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const children: (FramesetOptions | FrameOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:frameset\") {\n children.push(parseFramesetEl(child));\n } else if (child.name === \"w:frame\") {\n children.push(parseFrameEl(child));\n }\n }\n if (children.length > 0) opts.children = children;\n\n return opts as FramesetOptions;\n}\n\nfunction parseSplitbarEl(el: Element): FramesetSplitbarOptions {\n const opts: Partial<FramesetSplitbarOptions> = {};\n\n const w = findChild(el, \"w:w\");\n if (w) {\n const val = attrNum(w, \"w:w\");\n if (val !== undefined) opts.width = val;\n }\n\n const color = findChild(el, \"w:color\");\n if (color) {\n const val = attr(color, \"w:val\");\n if (val) opts.color = val;\n }\n\n if (findChild(el, \"w:noBorder\")) opts.noBorder = true;\n if (findChild(el, \"w:flatBorders\")) opts.flatBorders = true;\n\n return opts as FramesetSplitbarOptions;\n}\n\nfunction parseFrameEl(el: Element): FrameOptions {\n const opts: Partial<FrameOptions> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const name = findChild(el, \"w:name\");\n if (name) {\n const val = attr(name, \"w:val\");\n if (val) opts.name = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const source = findChild(el, \"w:sourceFileName\");\n if (source) {\n const val = attr(source, \"r:id\");\n if (val) opts.sourceRId = val;\n }\n\n const marW = findChild(el, \"w:marW\");\n if (marW) {\n const val = attrNum(marW, \"w:val\");\n if (val !== undefined) opts.marginWidth = val;\n }\n\n const marH = findChild(el, \"w:marH\");\n if (marH) {\n const val = attrNum(marH, \"w:val\");\n if (val !== undefined) opts.marginHeight = val;\n }\n\n const scrollbar = findChild(el, \"w:scrollbar\");\n if (scrollbar) {\n const val = attr(scrollbar, \"w:val\");\n if (val === \"on\" || val === \"off\" || val === \"auto\") opts.scrollbar = val;\n }\n\n if (findChild(el, \"w:noResizeAllowed\")) opts.noResizeAllowed = true;\n if (findChild(el, \"w:linkedToFile\")) opts.linkedToFile = true;\n\n const longDesc = findChild(el, \"w:longDesc\");\n if (longDesc) {\n const val = attr(longDesc, \"r:id\");\n if (val) opts.longDescRId = val;\n }\n\n return opts as FrameOptions;\n}\n\nfunction parseDivsEl(el: Element): DivOptions[] {\n const result: DivOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:div\") {\n result.push(parseDivEl(child));\n }\n }\n return result;\n}\n\nfunction parseDivEl(el: Element): DivOptions {\n const id = attrNum(el, \"w:id\") ?? 0;\n const opts: Partial<DivOptions> = { id };\n\n const marLeft = findChild(el, \"w:marLeft\");\n if (marLeft) {\n const val = attrMeasure(marLeft, \"w:val\");\n if (val !== undefined) opts.marginLeft = val as number | UniversalMeasure;\n }\n\n const marRight = findChild(el, \"w:marRight\");\n if (marRight) {\n const val = attrMeasure(marRight, \"w:val\");\n if (val !== undefined) opts.marginRight = val as number | UniversalMeasure;\n }\n\n const marTop = findChild(el, \"w:marTop\");\n if (marTop) {\n const val = attrMeasure(marTop, \"w:val\");\n if (val !== undefined) opts.marginTop = val as number | UniversalMeasure;\n }\n\n const marBottom = findChild(el, \"w:marBottom\");\n if (marBottom) {\n const val = attrMeasure(marBottom, \"w:val\");\n if (val !== undefined) opts.marginBottom = val as number | UniversalMeasure;\n }\n\n const blockQuote = findChild(el, \"w:blockQuote\");\n if (blockQuote) {\n const val = attr(blockQuote, \"w:val\");\n opts.blockQuote = val !== \"off\";\n }\n\n const bodyDiv = findChild(el, \"w:bodyDiv\");\n if (bodyDiv) {\n const val = attr(bodyDiv, \"w:val\");\n opts.bodyDiv = val !== \"off\";\n }\n\n const divBdr = findChild(el, \"w:divBdr\");\n if (divBdr) {\n opts.border = parseDivBorderEl(divBdr);\n }\n\n const divsChild = findChild(el, \"w:divsChild\");\n if (divsChild) {\n const children = parseDivsEl(divsChild);\n if (children.length > 0) opts.children = children;\n }\n\n return opts as DivOptions;\n}\n\nfunction parseDivBorderEl(el: Element): DivBorderOptions {\n const opts: Partial<DivBorderOptions> = {};\n\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(el, `w:${side}`);\n if (sideEl) {\n const b: Partial<NonNullable<DivBorderOptions[\"top\"]>> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n opts[side] = b as NonNullable<DivBorderOptions[\"top\"]>;\n }\n }\n\n return opts as DivBorderOptions;\n}\n\nfunction wsDivBorderXml(b: NonNullable<DivOptions[\"border\"]>): string {\n const parts: string[] = [\"<w:divBdr>\"];\n const sides: [string, NonNullable<DivOptions[\"border\"]>[\"top\"]][] = [\n [\"w:top\", b.top],\n [\"w:left\", b.left],\n [\"w:bottom\", b.bottom],\n [\"w:right\", b.right],\n ];\n for (const [tag, side] of sides) {\n if (!side) continue;\n const attrParts: string[] = [`w:val=\"${escapeXml(side.style)}\"`];\n if (side.color) attrParts.push(`w:color=\"${escapeXml(side.color)}\"`);\n if (side.size !== undefined) attrParts.push(`w:sz=\"${side.size}\"`);\n parts.push(`<${tag} ${attrParts.join(\" \")}/>`);\n }\n parts.push(\"</w:divBdr>\");\n return parts.join(\"\");\n}\n\nfunction wsDivXml(d: DivOptions): string {\n const parts: string[] = [`<w:div w:id=\"${d.id}\">`];\n if (d.blockQuote !== undefined)\n parts.push(wsStringVal(\"w:blockQuote\", d.blockQuote ? \"on\" : \"off\"));\n if (d.bodyDiv !== undefined) parts.push(wsStringVal(\"w:bodyDiv\", d.bodyDiv ? \"on\" : \"off\"));\n parts.push(wsNumVal(\"w:marLeft\", d.marginLeft));\n parts.push(wsNumVal(\"w:marRight\", d.marginRight));\n parts.push(wsNumVal(\"w:marTop\", d.marginTop));\n parts.push(wsNumVal(\"w:marBottom\", d.marginBottom));\n if (d.border) parts.push(wsDivBorderXml(d.border));\n if (d.children?.length) {\n parts.push(\"<w:divsChild>\");\n for (const child of d.children) parts.push(wsDivXml(child));\n parts.push(\"</w:divsChild>\");\n }\n parts.push(\"</w:div>\");\n return parts.join(\"\");\n}\n\nexport function framesetXml(fs: FramesetOptions): string {\n const parts: string[] = [\"<w:frameset>\"];\n if (fs.size !== undefined) parts.push(wsStringVal(\"w:sz\", fs.size));\n if (fs.splitbar) {\n parts.push(\"<w:framesetSplitbar>\");\n if (fs.splitbar.width !== undefined)\n parts.push(`<w:w w:w=\"${fs.splitbar.width}\" w:type=\"dxa\"/>`);\n if (fs.splitbar.color !== undefined) parts.push(wsStringVal(\"w:color\", fs.splitbar.color));\n if (fs.splitbar.noBorder) parts.push(\"<w:noBorder/>\");\n if (fs.splitbar.flatBorders) parts.push(\"<w:flatBorders/>\");\n parts.push(\"</w:framesetSplitbar>\");\n }\n if (fs.layout !== undefined) parts.push(`<w:frameLayout w:val=\"${fs.layout}\"/>`);\n if (fs.title !== undefined) parts.push(wsStringVal(\"w:title\", fs.title));\n if (fs.children) {\n for (const child of fs.children) {\n if (\"children\" in child || \"layout\" in child || \"splitbar\" in child) {\n parts.push(framesetXml(child as FramesetOptions));\n } else {\n parts.push(frameXml(child as FrameOptions));\n }\n }\n }\n parts.push(\"</w:frameset>\");\n return parts.join(\"\");\n}\n\nexport function frameXml(f: FrameOptions): string {\n const parts: string[] = [\"<w:frame>\"];\n if (f.size !== undefined) parts.push(wsStringVal(\"w:sz\", f.size));\n if (f.name !== undefined) parts.push(wsStringVal(\"w:name\", f.name));\n if (f.title !== undefined) parts.push(wsStringVal(\"w:title\", f.title));\n if (f.sourceRId !== undefined) parts.push(`<w:sourceFileName r:id=\"${escapeXml(f.sourceRId)}\"/>`);\n if (f.marginWidth !== undefined) parts.push(wsNumVal(\"w:marW\", f.marginWidth));\n if (f.marginHeight !== undefined) parts.push(wsNumVal(\"w:marH\", f.marginHeight));\n if (f.scrollbar !== undefined) parts.push(`<w:scrollbar w:val=\"${f.scrollbar}\"/>`);\n if (f.noResizeAllowed) parts.push(\"<w:noResizeAllowed/>\");\n if (f.linkedToFile) parts.push(\"<w:linkedToFile/>\");\n if (f.longDescRId !== undefined) parts.push(`<w:longDesc r:id=\"${escapeXml(f.longDescRId)}\"/>`);\n parts.push(\"</w:frame>\");\n return parts.join(\"\");\n}\n\nexport const webSettingsDesc: CustomDescriptor<WebSettingsInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [`<w:webSettings ${WS_NS}>`];\n\n if (opts.frameset !== undefined) p.push(framesetXml(opts.frameset));\n if (opts.divs?.length) {\n p.push(\"<w:divs>\");\n for (const d of opts.divs) p.push(wsDivXml(d));\n p.push(\"</w:divs>\");\n }\n if (opts.encoding !== undefined) p.push(wsStringVal(\"w:encoding\", opts.encoding));\n if (opts.optimizeForBrowser !== undefined) {\n const ob = opts.optimizeForBrowser;\n if (typeof ob === \"boolean\") {\n p.push(wsOnOff(\"w:optimizeForBrowser\", ob));\n } else {\n // CT_OptimizeForBrowser: CT_OnOff + optional @w:target. Omit w:val when\n // true to match typical Word output; emit w:val=\"false\" only when disabled.\n const valAttr = ob.value === false ? ' w:val=\"false\"' : \"\";\n const targetAttr = ob.target ? ` w:target=\"${escapeXml(ob.target)}\"` : \"\";\n p.push(`<w:optimizeForBrowser${valAttr}${targetAttr}/>`);\n }\n }\n if (opts.relyOnVML !== undefined) p.push(wsOnOff(\"w:relyOnVML\", opts.relyOnVML));\n if (opts.allowPNG !== undefined) p.push(wsOnOff(\"w:allowPNG\", opts.allowPNG));\n if (opts.doNotRelyOnCSS !== undefined) p.push(wsOnOff(\"w:doNotRelyOnCSS\", opts.doNotRelyOnCSS));\n if (opts.doNotSaveAsSingleFile !== undefined)\n p.push(wsOnOff(\"w:doNotSaveAsSingleFile\", opts.doNotSaveAsSingleFile));\n if (opts.doNotOrganizeInFolder !== undefined)\n p.push(wsOnOff(\"w:doNotOrganizeInFolder\", opts.doNotOrganizeInFolder));\n if (opts.doNotUseLongFileNames !== undefined)\n p.push(wsOnOff(\"w:doNotUseLongFileNames\", opts.doNotUseLongFileNames));\n if (opts.pixelsPerInch !== undefined) p.push(wsNumVal(\"w:pixelsPerInch\", opts.pixelsPerInch));\n if (opts.targetScreenSize !== undefined)\n p.push(wsStringVal(\"w:targetScreenSz\", opts.targetScreenSize));\n if (opts.saveSmartTagsAsXml !== undefined)\n p.push(wsOnOff(\"w:saveSmartTagsAsXml\", opts.saveSmartTagsAsXml));\n\n p.push(\"</w:webSettings>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Partial<WebSettingsInput> = {};\n\n // Frameset\n const frameset = findChild(el, \"w:frameset\");\n if (frameset) {\n opts.frameset = parseFramesetEl(frameset);\n }\n\n // Divs\n const divs = findChild(el, \"w:divs\");\n if (divs) {\n const parsed = parseDivsEl(divs);\n if (parsed.length > 0) opts.divs = parsed;\n }\n\n // Encoding\n const encoding = findChild(el, \"w:encoding\");\n if (encoding) {\n const val = attr(encoding, \"w:val\");\n if (val) opts.encoding = val;\n }\n\n // Boolean fields\n for (const [name, optKey] of [\n [\"w:relyOnVML\", \"relyOnVML\"],\n [\"w:allowPNG\", \"allowPNG\"],\n [\"w:doNotRelyOnCSS\", \"doNotRelyOnCSS\"],\n [\"w:doNotSaveAsSingleFile\", \"doNotSaveAsSingleFile\"],\n [\"w:doNotOrganizeInFolder\", \"doNotOrganizeInFolder\"],\n [\"w:doNotUseLongFileNames\", \"doNotUseLongFileNames\"],\n [\"w:saveSmartTagsAsXml\", \"saveSmartTagsAsXml\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // optimizeForBrowser — CT_OptimizeForBrowser (CT_OnOff + optional @w:target)\n const obEl = findChild(el, \"w:optimizeForBrowser\");\n if (obEl) {\n const target = attr(obEl, \"w:target\");\n if (target) {\n opts.optimizeForBrowser = { value: attrBool(obEl, \"w:val\") ?? true, target };\n } else {\n opts.optimizeForBrowser = attrBool(obEl, \"w:val\") ?? true;\n }\n }\n\n // Pixels per inch\n const ppi = findChild(el, \"w:pixelsPerInch\");\n if (ppi) {\n const val = attrNum(ppi, \"w:val\");\n if (val !== undefined) opts.pixelsPerInch = val;\n }\n\n // Target screen size\n const targetScreenSize = findChild(el, \"w:targetScreenSz\");\n if (targetScreenSize) {\n const val = attr(targetScreenSize, \"w:val\");\n if (val) opts.targetScreenSize = val;\n }\n\n return opts as WebSettingsInput;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,gBAAgB;;CAE3B,OAAO;;CAEP,QAAQ;;CAER,KAAK;;CAEL,MAAM;;CAEN,gBAAgB;;CAEhB,YAAY;;CAEZ,SAAS;;CAET,cAAc;;CAEd,aAAa;;CAEb,iBAAiB;;CAEjB,MAAM;;CAEN,OAAO;;CAEP,WAAW;AACb;;;;;;;;;;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