@office-open/docx 0.9.5 → 0.9.7
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 +10 -10
- package/dist/context-BrtlmvVE.mjs +323 -0
- package/dist/context-BrtlmvVE.mjs.map +1 -0
- package/dist/{core-properties-BMagGcpC.d.mts → core-properties-CBMhgSrn.d.mts} +700 -558
- package/dist/core-properties-CBMhgSrn.d.mts.map +1 -0
- package/dist/{generate-BVfOLdwW.mjs → generate-BMTVflV1.mjs} +50 -34
- package/dist/generate-BMTVflV1.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 -5
- package/dist/parse-K59nx6MF.mjs +1927 -0
- package/dist/parse-K59nx6MF.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/parts-BQBGNSGm.mjs +12090 -0
- package/dist/parts-BQBGNSGm.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-CSBntKXD.mjs +0 -5116
- package/dist/context-CSBntKXD.mjs.map +0 -1
- package/dist/core-properties-BMagGcpC.d.mts.map +0 -1
- package/dist/document-DYH7tGnw.mjs +0 -6227
- package/dist/document-DYH7tGnw.mjs.map +0 -1
- package/dist/generate-BVfOLdwW.mjs.map +0 -1
- package/dist/parse-Db2NGghB.mjs +0 -514
- package/dist/parse-Db2NGghB.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts-BQBGNSGm.mjs","names":["createImageData","xmlChildren","parseShading","onOff","cnfStyleStr","escapeAttr","escapeXml","xmlChildren","createWrapPolygon","BORDER_STYLES","THEME_COLORS","fillDesc","outlineDesc","effectListDesc","customGeometryDesc","md","onOff","escapeAttr","NS","NS","escapeXml"],"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/shared/media/data.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/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/custom-properties.ts","../src/parts/app-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 */\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 */\n after?: number;\n /** Spacing before the paragraph in twips */\n before?: number;\n /** Line spacing value in twips (interpretation depends on lineRule) */\n line?: number;\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","/**\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\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 | Record<string, unknown>\n )[];\n break?: number;\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 run properties (hex string, e.g. \"00123456\"). */\n rsidRPr?: string;\n /** Revision save ID when run was deleted (hex string). */\n rsidDel?: 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 { 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 sizeComplexScript?: boolean | 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 highlightComplexScript?: boolean | string;\n characterSpacing?: number;\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 { convertPixelsToEmu, convertUniversalMeasureToEmu } from \"@office-open/core\";\n\n/**\n * Media module for WordprocessingML documents.\n *\n * This module provides support for managing embedded media (images)\n * within a document.\n *\n * @module\n */\nimport type { MediaDataTransformation } from \"./data\";\nimport type { MediaData } 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 pixels) 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 pixels 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 (pixels or universal measure) to internal\n * transformation data (pixels + EMUs).\n *\n * @param options - User-facing transformation in pixels or universal measure\n * @returns Internal transformation data with both pixel and EMU values\n */\nexport const createTransformation = (options: MediaTransformation): MediaDataTransformation => ({\n emus: {\n x:\n typeof options.width === \"string\"\n ? convertUniversalMeasureToEmu(options.width)\n : convertPixelsToEmu(options.width),\n y:\n typeof options.height === \"string\"\n ? convertUniversalMeasureToEmu(options.height)\n : convertPixelsToEmu(options.height),\n },\n flip: options.flip,\n offset: {\n emus: {\n x:\n typeof options.offset?.left === \"string\"\n ? convertUniversalMeasureToEmu(options.offset.left)\n : convertPixelsToEmu(options.offset?.left ?? 0),\n y:\n typeof options.offset?.top === \"string\"\n ? convertUniversalMeasureToEmu(options.offset.top)\n : convertPixelsToEmu(options.offset?.top ?? 0),\n },\n pixels: {\n x: typeof options.offset?.left === \"number\" ? Math.round(options.offset.left) : 0,\n y: typeof options.offset?.top === \"number\" ? Math.round(options.offset.top) : 0,\n },\n },\n pixels: {\n x: typeof options.width === \"number\" ? Math.round(options.width) : 0,\n y: typeof options.height === \"number\" ? Math.round(options.height) : 0,\n },\n rotation: options.rotation ? options.rotation * 60_000 : undefined,\n ...(options.effectExtent ? { effectExtent: options.effectExtent } : {}),\n});\n\n/**\n * Manages embedded media (images) in a document.\n *\n * Media stores all images referenced in the document and provides\n * access to their data for packaging into the DOCX file. Each image\n * is stored with a unique key for retrieval.\n *\n * @example\n * ```typescript\n * const media = new Media();\n * media.addImage(\"image1\", {\n * type: \"png\",\n * fileName: \"image1.png\",\n * transformation: {\n * pixels: { x: 200, y: 100 },\n * emus: { x: 1828800, y: 914400 }\n * },\n * data: imageBuffer\n * });\n * const allImages = media.Array;\n * ```\n */\nexport class Media {\n private map: Map<string, MediaData>;\n\n public constructor() {\n this.map = new Map<string, MediaData>();\n }\n\n /**\n * Adds an image to the media collection.\n *\n * @param key - Unique identifier for this image\n * @param mediaData - Complete image data including file name, transformation, and raw data\n */\n public addImage(key: string, mediaData: MediaData): void {\n this.map.set(key, mediaData);\n }\n\n /**\n * Gets all images as an array.\n *\n * @returns Read-only array of all media data in the collection\n */\n public get array(): MediaData[] {\n return [...this.map.values()];\n }\n}\n","import type { FillOptions } from \"@office-open/core/drawingml\";\nimport type { GroupShapeLocksOptions } from \"@parts/drawing/descriptor\";\nimport type { SourceRectangleOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { EffectListOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"@parts/drawing/inline/graphic/graphic-data/pic/outline/outline\";\nimport type {\n ChildExtent,\n ChildOffset,\n} from \"@parts/drawing/inline/graphic/graphic-data/wpg/wpg-group\";\nimport type { WpsShapeCoreOptions } from \"@parts/drawing/inline/graphic/graphic-data/wps\";\n\nexport interface MediaDataTransformation {\n offset?: {\n pixels: {\n x: number;\n y: number;\n };\n emus?: {\n x: number;\n y: number;\n };\n };\n pixels: {\n /** Width in pixels */\n x: number;\n /** Height in pixels */\n y: number;\n };\n /** Display dimensions in EMUs (English Metric Units) */\n emus: {\n /** Width in EMUs (1 inch = 914400 EMUs) */\n x: number;\n /** Height in EMUs (1 inch = 914400 EMUs) */\n y: number;\n };\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 /**\n * Effect extent (wp:effectExtent) in raw EMUs — round-tripped verbatim from\n * the source wrapper. When absent (generation path), the descriptor computes\n * it from the shape's effects.\n */\n effectExtent?: { l: number; t: number; r: number; b: number };\n}\n\n/**\n * Round-trip of `pic:cNvPr` — the picture non-visual id/name/description.\n * All fields optional to mirror the source element: `descr` is omitted when\n * absent rather than emitted as an empty attribute (Word never writes it empty).\n */\nexport interface PicCnvPrOptions {\n id?: number;\n name?: string;\n descr?: string;\n /**\n * From the sibling pic:cNvPicPr. Omitted = Word's default (true); only\n * `false` is emitted as preferRelativeResize=\"0\" because Word never writes\n * the default value explicitly.\n */\n preferRelativeResize?: boolean;\n}\n\n/**\n * Core properties shared by all media data types.\n */\ninterface CoreMediaData {\n /** File name for the media in the package */\n fileName: string;\n /** Transformation settings for display */\n transformation: MediaDataTransformation;\n /** Raw image data */\n data: Uint8Array;\n /** Source rectangle for image cropping */\n srcRect?: SourceRectangleOptions;\n /** Picture non-visual properties (pic:cNvPr) for round-trip fidelity */\n cNvPr?: PicCnvPrOptions;\n /**\n * Blip extension `a14:useLocalDpi` (val=\"0\" = use document DPI, not a local\n * override). Word emits this as a rendering hint on a:blip; carried verbatim\n * for round-trip fidelity. Omitted when absent (Word's default behavior).\n */\n useLocalDpi?: boolean;\n}\n\n/**\n * Regular raster image formats.\n */\ninterface RegularMediaData {\n /** Image format type */\n type: \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n}\n\n/**\n * SVG image format with fallback support.\n */\ninterface SvgMediaData {\n /** SVG image type */\n type: \"svg\";\n /**\n * Fallback image for Word processors that do not support SVG.\n * This ensures the document displays correctly in all viewers.\n */\n fallback: RegularMediaData & CoreMediaData;\n}\n\nexport interface WpsMediaData {\n type: \"wps\";\n transformation: MediaDataTransformation;\n data: WpsShapeCoreOptions;\n}\n\nexport interface WpgCommonMediaData {\n outline?: OutlineOptions;\n fill?: FillOptions;\n}\n\nexport type GroupChildMediaData = (WpsMediaData | MediaData | WpgMediaData) & WpgCommonMediaData;\n\nexport interface WpgMediaData {\n type: \"wpg\";\n transformation: MediaDataTransformation;\n children: GroupChildMediaData[];\n /** Child coordinate offset */\n chOff?: ChildOffset;\n /** Child coordinate extent */\n chExt?: ChildExtent;\n /** Group fill */\n fill?: FillOptions;\n /** Group effects */\n effects?: EffectListOptions;\n /** Group shape locks (wpg:cNvGrpSpPr/a:grpSpLocks) for round-trip. */\n grpSpLocks?: GroupShapeLocksOptions;\n}\n\n/**\n * Chart media data — references a chart part via placeholder.\n */\nexport interface ChartMediaData {\n type: \"chart\";\n transformation: MediaDataTransformation;\n chartKey: string;\n}\n\n/**\n * SmartArt media data — references a diagram data part via placeholder.\n */\nexport interface SmartArtMediaData {\n type: \"smartart\";\n transformation: MediaDataTransformation;\n smartArtKey: string;\n}\n\nexport type ExtendedMediaData =\n | MediaData\n | WpsMediaData\n | WpgMediaData\n | ChartMediaData\n | SmartArtMediaData;\n\nexport type MediaData = (RegularMediaData | SvgMediaData) & CoreMediaData;\n\n// Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432\n/**\n * @ignore\n */\nexport const WORKAROUND2 = \"\";\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 { MediaTransformation } from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { MediaData, PicCnvPrOptions } 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 srcRect?: SourceRectangleOptions;\n tile?: TileOptions;\n /** Picture non-visual properties (pic:cNvPr) — populated by parse */\n cNvPr?: PicCnvPrOptions;\n /** Raw XML of the wrapping w:r's rPr (round-trip) — emitted before the drawing. */\n runPropertiesRawXml?: string;\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 srcRect?: SourceRectangleOptions,\n cNvPr?: PicCnvPrOptions,\n): Pick<MediaData, \"data\" | \"fileName\" | \"transformation\" | \"srcRect\" | \"cNvPr\"> => ({\n data,\n fileName: key,\n srcRect,\n cNvPr,\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 { attr, attrBool, 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): BodyPropertiesOptions => {\n const result: Partial<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 = attrNum(el, \"lIns\");\n if (lIns !== undefined) result.lIns = lIns;\n const tIns = attrNum(el, \"tIns\");\n if (tIns !== undefined) result.tIns = tIns;\n const rIns = attrNum(el, \"rIns\");\n if (rIns !== undefined) result.rIns = rIns;\n const bIns = attrNum(el, \"bIns\");\n if (bIns !== undefined) result.bIns = bIns;\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 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: Partial<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: Partial<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: Partial<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: Partial<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 * 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 { attr, attrBool, attrNum, colorAttr, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { RunPropertiesOptions, RunOptions } 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 hint = attr(font, \"w:hint\");\n\n if (ascii && !eastAsia && !hAnsi && !cs) {\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 (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 = attrNum(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_CR = 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_PG_NUM = Symbol(\"PgNum\");\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_CR\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_PG_NUM\n | typeof PARSED_LAST_RENDERED_PAGE_BREAK\n | { commentReference: number };\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 rPrRawXml?: string;\n children: ParsedRunChild[];\n} {\n const rPr = findChild(el, \"w:rPr\");\n const properties = rPr ? parseRunProperties(rPr) : undefined;\n // Preserve the raw rPr so break/tab/pageBreak runs re-emit it verbatim,\n // avoiding authoring-style b/bCs, sz/szCs pairing inflation on round-trip.\n const rPrRawXml = rPr ? stringifyElement(rPr) : undefined;\n const children: ParsedRunChild[] = [];\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 if (brType === \"page\") {\n children.push(PARSED_PAGE_BREAK);\n } else if (brType === \"column\") {\n children.push(PARSED_COLUMN_BREAK);\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_CR);\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 // 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) children.push({ footnoteReference: id } as unknown as ParsedRunChild);\n break;\n }\n case \"w:endnoteReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) children.push({ endnoteReference: id } as unknown as ParsedRunChild);\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_PG_NUM);\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, rPrRawXml, children };\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_CR, { 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_PG_NUM, { 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.rPrRawXml) opts.rPrRawXml = parsed.rPrRawXml;\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 // Collect text and breaks\n const textParts: string[] = [];\n let breakCount = 0;\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 {\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 // When empty elements are present, use children[] format for round-trip fidelity\n if (extraChildren.length > 0) {\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 {\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 }\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,\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,\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,\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\n if (opts.bold !== undefined) parts.push(onOff(\"w:b\", opts.bold));\n const bCs =\n (opts.boldComplexScript === undefined && opts.bold !== undefined) || opts.boldComplexScript;\n if (bCs !== undefined) parts.push(onOff(\"w:bCs\", opts.boldComplexScript ?? opts.bold!));\n\n // Italic\n if (opts.italic !== undefined) parts.push(onOff(\"w:i\", opts.italic));\n const iCs =\n (opts.italicComplexScript === undefined && opts.italic !== undefined) ||\n opts.italicComplexScript;\n if (iCs !== undefined) parts.push(onOff(\"w:iCs\", opts.italicComplexScript ?? opts.italic!));\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)\n if (opts.size !== undefined) parts.push(`<w:sz w:val=\"${hpsMeasureValue(opts.size * 2)}\"/>`);\n const szCs =\n opts.sizeComplexScript === undefined || opts.sizeComplexScript === true\n ? opts.size\n : opts.sizeComplexScript;\n if (szCs) parts.push(`<w:szCs w:val=\"${hpsMeasureValue((szCs as number) * 2)}\"/>`);\n\n // Highlight\n if (opts.highlight) parts.push(`<w:highlight w:val=\"${opts.highlight}\"/>`);\n if (opts.highlightComplexScript === true) {\n if (opts.highlight) parts.push(`<w:highlightCs w:val=\"${opts.highlight}\"/>`);\n } else if (opts.highlightComplexScript !== undefined && opts.highlightComplexScript !== false) {\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 { 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 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 { CustomXmlPrOptions } 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 { SdtCheckboxOptions, SdtPropertiesOptions } from \"@parts/table-of-contents\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\n// ── XML helpers ──\n\nfunction escapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\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\" ? new TextEncoder().encode(opts.data) : opts.data;\n const data =\n opts.contentType === \"text/html\" && typeof opts.data === \"string\"\n ? new TextEncoder().encode(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.matchSrc) {\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: Record<string, unknown> = {};\n\n // Check for matchSrc\n const altChunkPr = findChild(el, \"w:altChunkPr\");\n if (altChunkPr && findChild(altChunkPr, \"w:matchSrc\")) {\n opts.matchSrc = 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 unknown 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 = typeof opts.data === \"string\" ? new TextEncoder().encode(opts.data) : 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 SdtChildOptions {\n properties: SdtPropertiesOptions;\n children?: SectionChild[];\n /** Run properties for the SDT end mark (w:sdtEndPr). */\n endProperties?: RunPropertiesOptions;\n}\n\nfunction escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\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: 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: { 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: 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;\n } else if (findChild(el, \"w:docPartObj\")) {\n const dp = findChild(el, \"w:docPartObj\")!;\n const dpObj: Record<string, unknown> = {};\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: Record<string, unknown> = {};\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: 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/** Parse w:customXmlPr element into CustomXmlPrOptions. */\nexport function parseCustomXmlPr(el: Element): CustomXmlPrOptions {\n const opts: Record<string, unknown> = {};\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 as unknown as CustomXmlPrOptions;\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<SdtChildOptions, 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 SdtChildOptions;\n },\n};\n\n// ── Custom XML (pure string — no context side effects) ──\n\nexport interface CustomXmlBlockDescriptorOptions {\n element: string;\n uri?: string;\n customXmlPr?: CustomXmlPrOptions;\n children?: SectionChild[];\n}\n\nfunction buildCustomXmlPrXml(pr: CustomXmlPrOptions): string {\n const parts: string[] = [\"<w:customXmlPr>\"];\n if (pr.placeholder !== undefined) {\n parts.push(`<w:placeholder w:val=\"${escapeAttr(pr.placeholder)}\"/>`);\n }\n if (pr.attributes) {\n for (const attr of pr.attributes) {\n const attrParts: string[] = [\n `w:name=\"${escapeAttr(attr.name)}\"`,\n `w:val=\"${escapeAttr(attr.val)}\"`,\n ];\n if (attr.uri !== undefined) attrParts.push(`w:uri=\"${escapeAttr(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 */\nexport function stringifyCustomXmlShell(\n opts: { element: string; uri?: string; customXmlPr?: CustomXmlPrOptions },\n contentXml: string,\n): string {\n const attrs: string[] = [`w:element=\"${escapeAttr(opts.element)}\"`];\n if (opts.uri !== undefined) attrs.push(`w:uri=\"${escapeAttr(opts.uri)}\"`);\n const prXml = opts.customXmlPr ? buildCustomXmlPrXml(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: Record<string, unknown> = {};\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 = parseCustomXmlPr(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 unknown 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 { 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>${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 { 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>${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 { 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 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/**\n * This element specifies the properties (size and orientation) for all pages in the current section.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_pgSz_topic_ID0ENEDT.html?hl=pgsz%2Cpage%2Csize\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:complexType name=\"CT_PageSz\">\n * <xsd:attribute name=\"w\" type=\"s:ST_TwipsMeasure\"/>\n * <xsd:attribute name=\"h\" type=\"s:ST_TwipsMeasure\"/>\n * <xsd:attribute name=\"orient\" type=\"ST_PageOrientation\" use=\"optional\"/>\n * <xsd:attribute name=\"code\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n */\nexport const createPageSize = ({\n width,\n height,\n orientation,\n code,\n}: PageSizeAttributes): string => {\n const widthTwips = twipsMeasureValue(width);\n const heightTwips = twipsMeasureValue(height);\n return element(\"w:pgSz\", {\n \"w:code\": code,\n \"w:h\": orientation === PageOrientation.LANDSCAPE ? widthTwips : heightTwips,\n \"w:orient\": orientation,\n \"w:w\": orientation === PageOrientation.LANDSCAPE ? heightTwips : widthTwips,\n });\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 rsidRPr?: string;\n rsidDel?: string;\n rsidR?: string;\n rsidSect?: string;\n page?: {\n size?: Partial<PageSizeAttributes>;\n margin?: PageMarginAttributes;\n pageNumbers?: PageNumberTypeAttributes;\n borders?: PageBordersOptions;\n textDirection?: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];\n };\n grid?: Partial<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, 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 — swap w/h when landscape\n const pgW = orientation === \"landscape\" ? convertToTwip(height) : width;\n const pgH = orientation === \"landscape\" ? convertToTwip(width) : height;\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.rsidRPr !== undefined) attrs.push(`w:rsidRPr=\"${opts.rsidRPr}\"`);\n if (opts.rsidDel !== undefined) attrs.push(`w:rsidDel=\"${opts.rsidDel}\"`);\n if (opts.rsidR !== undefined) attrs.push(`w:rsidR=\"${opts.rsidR}\"`);\n if (opts.rsidSect !== undefined) attrs.push(`w:rsidSect=\"${opts.rsidSect}\"`);\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): Partial<SectionPropertiesOptions> {\n const opts: Record<string, unknown> = {};\n\n // rsid attributes on w:sectPr element\n for (const [attrName, optKey] of [\n [\"w:rsidR\", \"rsidR\"],\n [\"w:rsidRPr\", \"rsidRPr\"],\n [\"w:rsidDel\", \"rsidDel\"],\n [\"w:rsidSect\", \"rsidSect\"],\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 = attrNum(cols, \"w:space\");\n if (space !== undefined) column.space = 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 = attrNum(colEl, \"w:w\");\n if (width === undefined) continue;\n const colAttr: ColumnAttributes = { width };\n const colSpace = attrNum(colEl, \"w:space\");\n if (colSpace !== undefined) colAttr.space = colSpace;\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 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 } from \"@office-open/core\";\nimport { 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};\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 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): string {\n const instr = tocInstructionStr(options);\n const aliasAttr = alias ? ` w:val=\"${escapeXml(alias)}\"` : \"\";\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 (with field instruction) + 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\" w:dirty=\"1\"/></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 `<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 { MathInput, MathRunPropertiesOptions } 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 return `<m:sSubSup><m:sSubSupPr/><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 return `<m:f>${pr}<m:num>${stringifyChildren(opts.numerator)}</m:num><m:den>${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 const pr = opts.properties ? \"\" : \"\"; // controlProperties rare — skip for now\n return `<m:limLow>${pr}<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 const pr = opts.properties ? \"\" : \"\";\n return `<m:limUpp>${pr}<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 const pr = opts.properties ? \"\" : \"\";\n return `<m:func>${pr}<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 return stringifyDelimiters(bracketChildren(value.roundBrackets), \"(\", \")\");\n }\n if (\"curlyBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.curlyBrackets), \"{\", \"}\");\n }\n if (\"angledBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.angledBrackets), \"〈\", \"〉\");\n }\n if (\"squareBrackets\" in value) {\n return stringifyDelimiters(bracketChildren(value.squareBrackets), \"[\", \"]\");\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: { children: MathInput[]; subScript?: MathInput[]; superScript?: MathInput[] },\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 (!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(children: MathInput[], begChr: string, endChr: string): string {\n return `<m:d><m:dPr><m:begChr m:val=\"${begChr}\"/><m:endChr m:val=\"${endChr}\"/></m:dPr><m:e>${stringifyChildren(children)}</m:e></m:d>`;\n}\n\nfunction bracketChildren(v: MathInput[] | { children: MathInput[] }): MathInput[] {\n if (Array.isArray(v)) return v;\n return (v as { children: MathInput[] }).children;\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(children: MathInput[]): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n return `<m:oMathPara><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\nfunction parseMathFraction(el: Element): MathInput {\n return {\n fraction: {\n numerator: parseMathArg(el, \"m:num\"),\n denominator: parseMathArg(el, \"m:den\"),\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 return {\n subSuperScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n superScript: parseMathArg(el, \"m:sup\"),\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 common = {\n children: baseChildren,\n ...(sub.length > 0 ? { subScript: sub } : {}),\n ...(sup.length > 0 ? { superScript: sup } : {}),\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 switch (begChr) {\n case \"[\":\n return { squareBrackets: mathChildren };\n case \"{\":\n return { curlyBrackets: mathChildren };\n case \"<\":\n case \"⟨\":\n return { angledBrackets: mathChildren };\n default:\n return { roundBrackets: mathChildren };\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 { attr, attrBool, attrNum, escapeXml, findChild, textOf } 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 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 { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport { parseFormFieldData } from \"@parts/paragraph/run/form-field\";\nimport type { FormFieldOptions } from \"@parts/paragraph/run/form-field\";\nimport 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 { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext, DocxWriteContext, BodyContext } from \"./context\";\nimport { tableDesc, altChunkDesc, subDocDesc, sdtBlockDesc, customXmlBlockDesc } from \"./parts\";\nimport { parseCustomXmlPr } from \"./parts/bodychildren\";\nimport { stringifyChildDispatch } from \"./parts/inline\";\nimport { parseMathChildren } from \"./parts/paragraph/math/stringify\";\nimport type { ParagraphChild } 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 // Prefer the raw rPr carried from parse (verbatim round-trip) over\n // regenerating from structured fields (avoids b/bCs, sz/szCs pairing).\n const rPr = (runOpts as { rPrRawXml?: string }).rPrRawXml ?? stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n // Breaks\n if (opts.break) {\n for (let i = 0; i < opts.break; i++) {\n parts.push(\"<w:br/>\");\n }\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 (\"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 // 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.rsidRPr) rsidAttrs.push(` w:rsidRPr=\"${opts.rsidRPr}\"`);\n if (opts.rsidDel) rsidAttrs.push(` w:rsidDel=\"${opts.rsidDel}\"`);\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 return body ? `<w:p>${body}</w:p>` : \"<w:p/>\";\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 return stringifyTableOfContents(alias, options);\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 return `<w:bookmarkStart w:id=\"${child.bookmarkStart.id}\" w:name=\"${child.bookmarkStart.name}\"/>`;\n }\n if (\"bookmarkEnd\" in child) {\n return `<w:bookmarkEnd w:id=\"${child.bookmarkEnd}\"/>`;\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 ctx.file.media.addImage(m.fileName, {\n type: m.type,\n data: m.data,\n fileName: m.fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\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 fileName = `${uniqueId()}.${opts.image.type}`;\n const rawData = toUint8Array(opts.image.data) as Uint8Array;\n\n // Register media\n ctx.file.media.addImage(fileName, {\n type: opts.image.type as \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\",\n data: rawData,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\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 parts.push(`<w:document ${DOC_NS} mc:Ignorable=\"w14 w15 wp14\">`);\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, string> = {\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 * Parse w:pPr element into paragraph properties (without children).\n */\nexport function parseParagraphProperties(\n el: Element,\n ctx: DocxReadContext,\n): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\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;\n }\n\n // Spacing\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const sp: SpacingProperties = {};\n const before = attrNum(spacing, \"w:before\");\n if (before !== undefined) sp.before = before;\n const after = attrNum(spacing, \"w:after\");\n if (after !== undefined) sp.after = after;\n const line = attrNum(spacing, \"w:line\");\n if (line !== undefined) sp.line = 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\n const ind = findChild(el, \"w:ind\");\n if (ind) {\n const indentObj: IndentAttributesProperties = {};\n const left = attrNum(ind, \"w:left\");\n if (left !== undefined) indentObj.left = left;\n const leftChars = attrNum(ind, \"w:leftChars\");\n if (leftChars !== undefined) indentObj.leftChars = leftChars;\n const right = attrNum(ind, \"w:right\");\n if (right !== undefined) indentObj.right = right;\n const rightChars = attrNum(ind, \"w:rightChars\");\n if (rightChars !== undefined) indentObj.rightChars = rightChars;\n const start = attrNum(ind, \"w:start\");\n if (start !== undefined) indentObj.start = start;\n const startChars = attrNum(ind, \"w:startChars\");\n if (startChars !== undefined) indentObj.startChars = startChars;\n const end = attrNum(ind, \"w:end\");\n if (end !== undefined) indentObj.end = end;\n const endChars = attrNum(ind, \"w:endChars\");\n if (endChars !== undefined) indentObj.endChars = endChars;\n const hanging = attrNum(ind, \"w:hanging\");\n if (hanging !== undefined) indentObj.hanging = hanging;\n const hangingChars = attrNum(ind, \"w:hangingChars\");\n if (hangingChars !== undefined) indentObj.hangingChars = hangingChars;\n const firstLine = attrNum(ind, \"w:firstLine\");\n if (firstLine !== undefined) indentObj.firstLine = 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 opts.numbering = { reference: `list_${numId}`, level };\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: Record<string, unknown>[] = [];\n for (const tab of tabs.elements ?? []) {\n if (tab.name !== \"w:tab\") continue;\n const tabObj: Record<string, unknown> = {};\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;\n const leader = attr(tab, \"w:leader\");\n if (leader) tabObj.leader = leader;\n tabStops.push(tabObj);\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: Record<string, unknown> = {};\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;\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;\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: Record<string, unknown> = {};\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: Record<string, unknown> = {};\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: Record<string, unknown> = {};\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;\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 */\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): unknown[] {\n const children: unknown[] = [];\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 children.push({ smartTag: parseSmartTagInline(sub, ctx) });\n break;\n case \"w:customXml\":\n children.push({ customXml: parseCustomXmlInline(sub, ctx) });\n break;\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): Record<string, unknown> {\n const st: Record<string, unknown> = {};\n const element = attr(el, \"w:element\");\n if (element) st.element = 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(el: Element, ctx: DocxReadContext): Record<string, unknown> {\n const cx: Record<string, unknown> = {};\n const element = attr(el, \"w:element\");\n if (element) cx.element = 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 = parseCustomXmlPr(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(\n el: Element,\n): { id: number; name?: string; author?: string; date?: string } | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: { id: number; name?: string; author?: string; date?: string } = { 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 return m;\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/**\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(elements: Element[] | undefined, ctx: DocxReadContext): unknown[] {\n const childList: unknown[] = [];\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 // Carry the wrapping run's rPr verbatim so round-trip preserves it\n // (drawings/shapes can be wrapped in <w:r><w:rPr>…</w:rPr>…).\n const rPrEl = findChild(child, \"w:rPr\");\n const runPropertiesRawXml = rPrEl ? stringifyElement(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 (runPropertiesRawXml) {\n if (\"image\" in drawingChild) {\n drawingChild.image.runPropertiesRawXml = runPropertiesRawXml;\n } else if (\"wpsShape\" in drawingChild) {\n drawingChild.wpsShape.runPropertiesRawXml = runPropertiesRawXml;\n } else if (\"wpgGroup\" in drawingChild) {\n drawingChild.wpgGroup.runPropertiesRawXml = runPropertiesRawXml;\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: Record<string, unknown> = {};\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\n const linkRuns: unknown[] = [];\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 linkRuns.push(runOpts);\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 childList.push({ bookmarkStart: { id, name } });\n }\n break;\n }\n case \"w:bookmarkEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ bookmarkEnd: id });\n break;\n }\n case \"w:commentRangeStart\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentRangeStart: id });\n break;\n }\n case \"w:commentRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentRangeEnd: id });\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 insRun = findChild(child, \"w:r\");\n if (insRun) {\n const parsed = parseRun(insRun, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\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 ...(runOpts as Record<string, unknown>),\n },\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 a children\n // placeholder instead of being dropped.\n let delFieldPlaceholder: string | undefined;\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 delFieldPlaceholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? \"\").trim()];\n if (delFieldPlaceholder) break;\n }\n }\n if (delFieldPlaceholder) {\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: [delFieldPlaceholder],\n },\n });\n break;\n }\n const delRun = findChild(child, \"w:r\");\n if (delRun) {\n const parsed = parseRun(delRun, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\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 ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:moveFrom\": {\n const runEl = findChild(child, \"w:r\");\n if (runEl) {\n const parsed = parseRun(runEl, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\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 ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:moveTo\": {\n const runEl = findChild(child, \"w:r\");\n if (runEl) {\n const parsed = parseRun(runEl, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\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 ...(runOpts as Record<string, unknown>),\n },\n });\n }\n }\n break;\n }\n case \"w:fldSimple\": {\n const instruction = attr(child, \"w:instr\");\n if (instruction) {\n const sf: { instruction: string; cachedValue?: string } = { 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 childList.push({ simpleField: sf });\n }\n break;\n }\n case \"w:smartTag\": {\n const st = parseSmartTagInline(child, ctx);\n if (st.element) childList.push({ smartTag: st });\n break;\n }\n case \"w:customXml\": {\n const cx = parseCustomXmlInline(child, ctx);\n if (cx.element) 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: Record<string, unknown> = { val };\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: Record<string, unknown> = { val };\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 ruby: Record<string, unknown> = {};\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;\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 const rt = findChild(child, \"w:rt\");\n if (rt) ruby.text = collectRunsText(rt);\n const rubyBase = findChild(child, \"w:rubyBase\");\n if (rubyBase) ruby.base = collectRunsText(rubyBase);\n // text and base are required by CT_Ruby; drop if either is missing.\n if (ruby.text !== undefined && ruby.base !== undefined) {\n childList.push({ ruby });\n }\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 (type) childList.push({ proofErr: type });\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: Record<string, unknown> = { 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 id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ moveFromRangeEnd: id });\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 id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ moveToRangeEnd: id });\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: { properties: unknown; children?: unknown[]; endProperties?: unknown } = {\n properties,\n };\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\nexport function parseParagraph(el: Element, ctx: DocxReadContext): ParagraphOptions {\n const opts: Record<string, unknown> = {};\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\n if (childList.length > 0) {\n const allStrings = childList.every(\n (c) =>\n typeof c === \"object\" &&\n c !== null &&\n \"text\" in (c as Record<string, unknown>) &&\n Object.keys(c as Record<string, unknown>).length === 1,\n );\n if (allStrings) {\n const combined = childList.map((c) => (c as Record<string, unknown>).text as string).join(\"\");\n if (combined && Object.keys(opts).length === 0) {\n return combined as unknown as ParagraphOptions;\n }\n if (combined) {\n opts.text = combined;\n return opts as ParagraphOptions;\n }\n }\n\n opts.children = childList as (RunOptions | string)[];\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} from \"@office-open/core\";\nimport { attr, attrBool, attrNum, findChild, findDeep, 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 { PicCnvPrOptions } 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 = findDeep(el, \"a:graphicData\")[0];\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: Partial<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: Partial<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 = findDeep(el, \"wp:inline\")[0];\n const anchor = inline ? undefined : findDeep(el, \"wp:anchor\")[0];\n const parent = inline ?? anchor;\n if (!parent) return null;\n\n const info: AnchorInfo = {};\n\n // Extent (EMU → pixels)\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 = convertEmuToPixels(cxEmu);\n if (cyEmu !== undefined) info.height = convertEmuToPixels(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 = findDeep(el, \"a:blip\")[0];\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 = findDeep(el, \"pic:blipFill\")[0];\n if (blipFill) {\n const srcRect = readSourceRectangle(blipFill);\n if (srcRect) imageOpts.srcRect = srcRect;\n }\n\n // Picture non-visual properties (pic:nvPicPr/pic:cNvPr)\n const cNvPr = readPicCnvPr(el);\n if (cNvPr) imageOpts.cNvPr = cNvPr;\n\n // Picture shape properties (pic:spPr): outline + fill + effects round-trip\n // via the shared core descriptors (bidirectional).\n const picSpPr = findDeep(el, \"pic:spPr\")[0];\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: Partial<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): PicCnvPrOptions | undefined {\n const nvPicPr = findDeep(el, \"pic:nvPicPr\")[0];\n if (!nvPicPr) return undefined;\n const result: PicCnvPrOptions = {};\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.descr = 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 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: Partial<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: Partial<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 = findDeep(wspEl, \"w:txbxContent\")[0];\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: Partial<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.txBox = 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 }\n\n // Body properties (wps:bodyPr)\n const bodyPr = findChild(wspEl, \"wps:bodyPr\");\n if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr);\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 = findDeep(picEl, \"a:blip\")[0];\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.srcRect = srcRect;\n }\n const cNvPr = readPicCnvPr(picEl);\n if (cNvPr) result.cNvPr = 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 = findDeep(el, \"wps:wsp\")[0];\n if (!wsp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const data = parseWpsShapeCore(wsp, ctx);\n\n const shape: Partial<WpsShapeRunOptions> = {\n ...data,\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\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 = findDeep(el, \"wpg:wgp\")[0];\n if (!wgp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const grpSpPr = findChild(wgp, \"wpg:grpSpPr\");\n const { chOff, chExt } = readGroupCoords(grpSpPr);\n\n const group: Partial<WpgGroupRunOptions> = {\n children: parseGroupChildren(wgp, ctx),\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\n },\n };\n if (chOff) group.chOff = chOff;\n if (chExt) group.chExt = chExt;\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.grpSpLocks = 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 chOff?: ChildOffset;\n chExt?: ChildExtent;\n} {\n if (!grpSpPr) return {};\n const xfrm = findChild(grpSpPr, \"a:xfrm\");\n if (!xfrm) return {};\n let chOff: ChildOffset | undefined;\n let chExt: ChildExtent | undefined;\n const off = findChild(xfrm, \"a:chOff\");\n if (off?.attributes) {\n chOff = { 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 chExt = { cx: Number(ext.attributes[\"cx\"] ?? 0), cy: Number(ext.attributes[\"cy\"] ?? 0) };\n }\n return { chOff, chExt };\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 { chOff, chExt } = readGroupCoords(grpSpPr);\n const result: WpgMediaData = {\n type: \"wpg\",\n transformation: readChildTransformation(grpSpPr),\n children: parseGroupChildren(grpSpEl, ctx),\n };\n if (chOff) result.chOff = chOff;\n if (chExt) result.chExt = chExt;\n const grpSpLocks = readGrpSpLocks(findChild(grpSpEl, \"wpg:cNvGrpSpPr\"));\n if (grpSpLocks) result.grpSpLocks = 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 = findDeep(el, \"wp:inline\")[0];\n const anchor = inline ? undefined : findDeep(el, \"wp:anchor\")[0];\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: convertEmuToPixels(cxEmu) } : {}),\n ...(cyEmu !== undefined ? { height: convertEmuToPixels(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 = findDeep(el, \"c:chart\")[0];\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 = findDeep(titleEl, \"c:rich\")[0];\n if (rich) {\n const t = findDeep(rich, \"a:t\")[0];\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 = findDeep(container, \"c:strCache\")[0];\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 = findDeep(valEl, \"c:numCache\")[0];\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 = findDeep(el, \"dgm:relIds\")[0];\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 = findDeep(pt, \"a:t\")[0];\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 { 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 extractBlipFillMedia,\n fillDesc,\n outlineDesc,\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 { PicCnvPrOptions } 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.srcRect);\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?: PicCnvPrOptions): 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?.descr ? ` descr=\"${escapeXml(cNvPr.descr)}\"` : \"\";\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 chOff?: ChildOffset,\n chExt?: 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 chOffXml = chOff ? `<a:chOff x=\"${chOff.x}\" y=\"${chOff.y}\"/>` : \"\";\n const chExtXml = chExt ? `<a:chExt cx=\"${chExt.cx}\" cy=\"${chExt.cy}\"/>` : \"\";\n\n return `<a:xfrm${attrStr}>${off}${ext}${chOffXml}${chExtXml}</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 {\n spPrParts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n }\n if (opts.fill) spPrParts.push(fillDesc.stringify(opts.fill, NOOP_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.txBox !== undefined) {\n xml += `<wps:cNvSpPr txBox=\"${opts.txBox}\"/>`;\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 readonly children: readonly GroupChildMediaData[];\n readonly transformation: MediaDataTransformation;\n readonly chOff?: ChildOffset;\n readonly chExt?: ChildExtent;\n readonly fill?: FillOptions;\n readonly effects?: EffectListOptions;\n readonly grpSpLocks?: GroupShapeLocksOptions | null;\n },\n ctx: BodyContext,\n): string {\n const transform = opts.transformation;\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.chOff, opts.chExt));\n if (opts.fill) grpSpPrParts.push(fillDesc.stringify(opts.fill, NOOP_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.grpSpLocks) +\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.cNvPr));\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.srcRect);\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(stringifyGroupTransform2D(grp.transformation, grp.chOff, grp.chExt));\n if (grp.fill) grpSpPrParts.push(fillDesc.stringify(grp.fill, NOOP_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.grpSpLocks) +\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 chOff: md.chOff,\n chExt: md.chExt,\n fill: md.fill,\n effects: md.effects,\n grpSpLocks: md.grpSpLocks,\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.cNvPr) +\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>${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>${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=\"${m.top}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${m.bottom}\"`] : []),\n ...(m.left != null ? [`distL=\"${m.left}\"`] : []),\n ...(m.right != null ? [`distR=\"${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=\"${margins.left}\"`);\n if (margins.right != null) a.push(`distR=\"${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=\"${margins.left}\"`);\n if (margins.right != null) a.push(`distR=\"${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=\"${m.top}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${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=\"${floating.margins?.top ?? 0}\"`,\n `distB=\"${floating.margins?.bottom ?? 0}\"`,\n `distL=\"${floating.margins?.left ?? 0}\"`,\n `distR=\"${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 blip fill media from fill options (shape fill with image)\n if (opts.fill) {\n const media = extractBlipFillMedia(opts.fill);\n if (media) {\n ctx.file.media.addImage(media.fileName, {\n data: media.data,\n fileName: media.fileName,\n type: media.type as \"png\",\n transformation: { pixels: { x: 0, y: 0 }, emus: { x: 0, y: 0 } },\n });\n }\n }\n\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 { ParagraphChild, ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport 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 { PicCnvPrOptions } 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\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) {\n for (let i = 0; i < opts.break; i++) parts.push(\"<w:br/>\");\n }\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.rsidRPr) rsidAttrs.push(` w:rsidRPr=\"${opts.rsidRPr}\"`);\n if (opts.rsidDel) rsidAttrs.push(` w:rsidDel=\"${opts.rsidDel}\"`);\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 srcRect?: SourceRectangleOptions,\n cNvPr?: PicCnvPrOptions,\n): Pick<MediaData, \"data\" | \"fileName\" | \"transformation\" | \"srcRect\" | \"cNvPr\"> {\n return {\n data,\n fileName: key,\n srcRect,\n cNvPr,\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; runPropertiesRawXml?: string },\n): string {\n const xml = drawingXml ?? \"\";\n const rPr = opts.runPropertiesRawXml ?? \"\";\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 */\nfunction registerVmlFallbackMedia(\n opts: { vmlFallbackMedia?: BackgroundRawMediaOptions[] },\n ctx: BodyContext,\n): void {\n if (!opts.vmlFallbackMedia) return;\n for (const m of opts.vmlFallbackMedia) {\n ctx.file.media.addImage(m.fileName, {\n type: m.type,\n data: m.data,\n fileName: m.fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n });\n }\n}\n\n/**\n * Resolve a break/tab run's rPr: prefer the raw rPr carried from parse (verbatim,\n * no b/bCs, sz/szCs pairing), else regenerate from the structured fields.\n */\nfunction runPrOrRaw(child: ParagraphChild): string {\n const raw = (child as { rPrRawXml?: string }).rPrRawXml;\n if (raw) return raw;\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>); prefer\n // the raw rPr when present to avoid b/bCs, sz/szCs pairing inflation.\n if (\"pageBreak\" in child) {\n return `<w:r>${runPrOrRaw(child)}<w:br w:type=\"page\"/></w:r>`;\n }\n if (\"columnBreak\" in child) {\n return `<w:r>${runPrOrRaw(child)}<w:br w:type=\"column\"/></w:r>`;\n }\n if (\"tab\" in child) {\n return `<w:r>${runPrOrRaw(child)}<w:tab/></w:r>`;\n }\n\n // Reference types — pure XML, no side effects\n if (\"footnoteReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteReference w:id=\"${child.footnoteReference}\"/></w:r>`;\n if (\"endnoteReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteReference w:id=\"${child.endnoteReference}\"/></w:r>`;\n\n // Comment markers — pure XML\n if (\"commentRangeStart\" in child)\n return `<w:commentRangeStart w:id=\"${child.commentRangeStart}\"/>`;\n if (\"commentRangeEnd\" in child) return `<w:commentRangeEnd w:id=\"${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 w:id=\"${child.bookmarkStart.id}\" w:name=\"${child.bookmarkStart.name}\"/>`;\n if (\"bookmarkEnd\" in child) return `<w:bookmarkEnd w:id=\"${child.bookmarkEnd}\"/>`;\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\n if (\"image\" in child) {\n const opts = child.image;\n const key = `${uniqueId()}.${opts.type}`;\n const rawData = toUint8Array(opts.data) as Uint8Array;\n\n let mediaData: MediaData;\n if (opts.type === \"svg\") {\n const fallbackData = toUint8Array(opts.fallback.data) as Uint8Array;\n mediaData = {\n type: \"svg\",\n ...createImageData(rawData, opts.transformation, key, opts.srcRect, opts.cNvPr),\n useLocalDpi: opts.useLocalDpi,\n fallback: {\n type: opts.fallback.type,\n ...createImageData(\n fallbackData,\n opts.transformation,\n `${uniqueId()}.${opts.fallback.type}`,\n ),\n },\n } as MediaData;\n } else {\n mediaData = {\n type: opts.type,\n ...createImageData(rawData, opts.transformation, key, opts.srcRect, opts.cNvPr),\n useLocalDpi: opts.useLocalDpi,\n } as MediaData;\n }\n\n // Register media\n ctx.file.media.addImage(mediaData.fileName, mediaData);\n if (mediaData.type === \"svg\") {\n ctx.file.media.addImage(mediaData.fallback.fileName, mediaData.fallback);\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 chOff: opts.chOff,\n chExt: opts.chExt,\n fill: opts.fill,\n effects: opts.effects,\n grpSpLocks: opts.grpSpLocks,\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.addImage(c.fileName, c);\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 — pure function\n if (\"insertion\" in child) {\n const opts = child.insertion;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:ins w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</w:ins>`;\n }\n\n // Deleted text run — pure function\n if (\"deletion\" in child) {\n const opts = child.deletion;\n const { id, author, date, ...runOpts } = opts;\n\n const parts: string[] = [];\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n if (runOpts.break) {\n for (let i = 0; i < runOpts.break; i++) parts.push(\"<w:br/>\");\n }\n\n if (runOpts.children) {\n for (const c of runOpts.children) {\n if (typeof c === \"string\") {\n // Page number fields use delInstrText instead of instrText\n const fieldMap: Record<string, string> = {\n CURRENT: \"PAGE\",\n TOTAL_PAGES: \"NUMPAGES\",\n TOTAL_PAGES_IN_SECTION: \"SECTIONPAGES\",\n };\n const instrText = fieldMap[c];\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(c)}</w:delText>`);\n }\n }\n }\n } else if (runOpts.text) {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(String(runOpts.text))}</w:delText>`);\n }\n\n const runBody = parts.join(\"\");\n return `<w:del w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\"><w:r>${runBody}</w:r></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\n const childParts: string[] = [];\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 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}\"`, 'w:history=\"1\"'];\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n if (hl.anchor) {\n const attrs = [`w:anchor=\"${escapeXml(hl.anchor)}\"`, 'w:history=\"1\"'];\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\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 const m = child.moveFromRangeStart;\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 return `<w:moveFromRangeStart ${a.join(\" \")}/>`;\n }\n if (\"moveFromRangeEnd\" in child) return `<w:moveFromRangeEnd w:id=\"${child.moveFromRangeEnd}\"/>`;\n if (\"moveToRangeStart\" in child) {\n const m = child.moveToRangeStart;\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 return `<w:moveToRangeStart ${a.join(\" \")}/>`;\n }\n if (\"moveToRangeEnd\" in child) return `<w:moveToRangeEnd w:id=\"${child.moveToRangeEnd}\"/>`;\n\n // ── Move revision text runs ──\n if (\"movedFrom\" in child) {\n const opts = child.movedFrom;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:moveFrom w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</w:moveFrom>`;\n }\n if (\"movedTo\" in child) {\n const opts = child.movedTo;\n const { id, author, date, ...runOpts } = opts;\n const runXml = stringifyRunInline(runOpts, ctx);\n return `<w:moveTo w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${runXml}</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}\" 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}\" 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}\" 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}\" 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 if (sf.cachedValue !== undefined) {\n return `<w:fldSimple w:instr=\"${escapeXml(sf.instruction)}\"><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;\n }\n return `<w:fldSimple w:instr=\"${escapeXml(sf.instruction)}\"/>`;\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 parts.push(\n typeof c === \"string\" ? stringifyRunInline({ text: c }, ctx) : stringifyRunInline(c, ctx),\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: (RunOptions | 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 parts.push(stringifyRunInline(c, ctx));\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 { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrNum, children, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { parseCustomXmlPr, stringifyCustomXmlShell, stringifySdtShell } 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 { 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\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTablePropertyExceptions,\n stringifyTableRowProperties,\n type TablePropertiesOptions,\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): Record<string, unknown> {\n const change: Record<string, unknown> = {};\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(widths: number[], revision?: TableGridChangeOptions): 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.rsidRPr) rsidAttrs.push(` w:rsidRPr=\"${row.rsidRPr}\"`);\n if (row.rsidR) rsidAttrs.push(` w:rsidR=\"${row.rsidR}\"`);\n if (row.rsidDel) rsidAttrs.push(` w:rsidDel=\"${row.rsidDel}\"`);\n if (row.rsidTr) rsidAttrs.push(` w:rsidTr=\"${row.rsidTr}\"`);\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: Partial<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 size = attrNum(sideEl, \"w:w\");\n if (size !== undefined) {\n const type = attr(sideEl, \"w:type\");\n margins[side] = type ? { size, type: type as TableWidthProperties[\"type\"] } : { size };\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: Partial<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: Partial<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: Partial<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.margins !== undefined) opts.cellMargin = base.margins as TableCellMarginOptions;\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\nfunction parseTablePropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\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 rawSize = attr(tblW, \"w:w\");\n const type = attr(tblW, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(tblW, \"w:w\");\n if (size !== undefined || type) {\n opts.width = { size: size ?? 0, ...(type ? { type } : {}) };\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;\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: Partial<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.margins = 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: Record<string, unknown> = {};\n if (tblpPr) {\n const horzAnchor = attr(tblpPr, \"w:horzAnchor\");\n if (horzAnchor) floatOpts.horizontalAnchor = horzAnchor;\n const vertAnchor = attr(tblpPr, \"w:vertAnchor\");\n if (vertAnchor) floatOpts.verticalAnchor = vertAnchor;\n const tblpX = attrNum(tblpPr, \"w:tblpX\");\n if (tblpX !== undefined) floatOpts.absoluteHorizontalPosition = tblpX;\n const tblpXSpec = attr(tblpPr, \"w:tblpXSpec\");\n if (tblpXSpec) floatOpts.relativeHorizontalPosition = tblpXSpec;\n const tblpY = attrNum(tblpPr, \"w:tblpY\");\n if (tblpY !== undefined) floatOpts.absoluteVerticalPosition = tblpY;\n const tblpYSpec = attr(tblpPr, \"w:tblpYSpec\");\n if (tblpYSpec) floatOpts.relativeVerticalPosition = tblpYSpec;\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;\n }\n if (Object.keys(floatOpts).length > 0) opts.float = floatOpts;\n }\n\n // indent → w:tblInd/@w:w and @w:type\n const tblInd = findChild(el, \"w:tblInd\");\n if (tblInd) {\n const size = attrNum(tblInd, \"w:w\");\n const type = attr(tblInd, \"w:type\");\n if (size !== undefined) {\n opts.indent = { size, ...(type ? { type } : {}) };\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 = attrNum(tblCellSpacing, \"w:w\");\n if (w !== undefined) opts.cellSpacing = { size: w, ...(type ? { type } : {}) };\n }\n\n // Revision (w:tblPrChange)\n const tblPrChange = findChild(el, \"w:tblPrChange\");\n if (tblPrChange) {\n const rev: Record<string, unknown> = {};\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;\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: number[];\n revision?: TableGridChangeOptions;\n} {\n const widths: number[] = [];\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 = attrNum(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: number[] = [];\n if (innerGrid) {\n for (const col of children(innerGrid, \"w:gridCol\")) {\n const w = attrNum(col, \"w:w\");\n revWidths.push(w ?? 100);\n }\n }\n if (id !== undefined) {\n return { widths, revision: { id, columnWidths: revWidths } };\n }\n }\n\n return { widths };\n}\n\nfunction parseTableRowPropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const trHeight = findChild(el, \"w:trHeight\");\n if (trHeight) {\n const val = attrNum(trHeight, \"w:val\");\n const rule = attr(trHeight, \"w:hRule\");\n if (val !== undefined) {\n opts.height = { value: val, ...(rule ? { rule } : {}) };\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 rawSize = attr(wBefore, \"w:w\");\n const type = attr(wBefore, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(wBefore, \"w:w\");\n if (size !== undefined) opts.widthBefore = { size, ...(type ? { type } : {}) };\n }\n const wAfter = findChild(el, \"w:wAfter\");\n if (wAfter) {\n const rawSize = attr(wAfter, \"w:w\");\n const type = attr(wAfter, \"w:type\");\n const size = type === \"pct\" ? rawSize : attrNum(wAfter, \"w:w\");\n if (size !== undefined) opts.widthAfter = { size, ...(type ? { type } : {}) };\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;\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 = attrNum(tblCellSpacing, \"w:w\");\n if (w !== undefined) opts.cellSpacing = { size: w, ...(type ? { type } : {}) };\n }\n\n // insertion / deletion (track changes)\n const ins = findChild(el, \"w:ins\");\n if (ins) opts.insertion = parseChangeAttrs(ins);\n const del = findChild(el, \"w:del\");\n if (del) opts.deletion = parseChangeAttrs(del);\n\n // Revision (w:trPrChange)\n const trPrChange = findChild(el, \"w:trPrChange\");\n if (trPrChange) {\n const rev: Record<string, unknown> = {};\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;\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\nfunction parseTableCellPropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\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 size = attrNum(tcW, \"w:w\");\n const type = attr(tcW, \"w:type\");\n if (size !== undefined) {\n opts.width = { size, ...(type ? { type } : {}) };\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;\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: Partial<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;\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);\n const cellDel = findChild(el, \"w:cellDel\");\n if (cellDel) opts.deletion = parseChangeAttrs(cellDel);\n\n // Revision (w:tcPrChange)\n const tcPrChange = findChild(el, \"w:tcPrChange\");\n if (tcPrChange) {\n const rev: Record<string, unknown> = {};\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;\n }\n\n // cellMerge → w:cellMerge\n const cellMerge = findChild(el, \"w:cellMerge\");\n if (cellMerge) {\n const cm = parseChangeAttrs(cellMerge);\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;\n }\n\n return opts;\n}\n\nfunction parseTableCellEl(el: Element, ctx: DocxReadContext): TableCellOptions {\n const opts: Record<string, unknown> = {};\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 unknown as TableCellOptions;\n}\n\nfunction parseTableRowEl(el: Element, ctx: DocxReadContext): TableRowOptions {\n const opts: Record<string, unknown> = {};\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\", \"rsidRPr\"],\n [\"w:rsidR\", \"rsidR\"],\n [\"w:rsidDel\", \"rsidDel\"],\n [\"w:rsidTr\", \"rsidTr\"],\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 = parseCustomXmlPr(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 unknown as TableRowOptions;\n}\n\nfunction parseTableEl(el: Element, ctx: DocxReadContext): TableOptions {\n const opts: Record<string, unknown> = {};\n\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n Object.assign(opts, parseTablePropertiesEl(tblPr));\n }\n\n const grid = parseColumnWidthsEl(el);\n if (grid.widths.length > 0) {\n opts.columnWidths = grid.widths;\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 = parseCustomXmlPr(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 unknown 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 /** 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. */\n tentative?: boolean;\n /** Legacy spacing/indent settings. */\n legacy?: { 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 { LevelParagraphStylePropertiesOptions } 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 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 parts.push(\n `<w:abstractNum w:abstractNumId=\"${decimalNumber(id)}\" w15:restartNumberingAfterBreak=\"0\">`,\n );\n\n if (extraOptions?.nsid !== undefined) {\n parts.push(`<w:nsid w:val=\"${extraOptions.nsid}\"/>`);\n }\n parts.push(`<w:multiLevelType w:val=\"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) children.push(`<w:lvlText w:val=\"${opts.text}\"/>`);\n if (opts.lvlPicBulletId !== undefined)\n children.push(`<w:lvlPicBulletId w:val=\"${decimalNumber(opts.lvlPicBulletId)}\"/>`);\n if (opts.legacy !== undefined) {\n const legacyAttrs: string[] = [];\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[] = [\n `w:ilvl=\"${decimalNumber(Math.min(opts.level, 9))}\"`,\n `w15:tentative=\"1\"`,\n ];\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: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\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 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: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\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 }\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:legacySpace, @w:legacyIndent)\n const legacyEl = findChild(el, \"w:legacy\");\n if (legacyEl) {\n const legacy: NonNullable<LevelsOptions[\"legacy\"]> = {};\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 if (Object.keys(legacy).length > 0) 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 — note stringify also\n // emits a fixed w15:tentative=\"1\" which we don't round-trip as it's constant)\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\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 as unknown as LevelParagraphStylePropertiesOptions;\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","/**\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\";\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?: BaseParagraphStyleOptions;\n subtitle?: BaseParagraphStyleOptions;\n heading1?: BaseParagraphStyleOptions;\n heading2?: BaseParagraphStyleOptions;\n heading3?: BaseParagraphStyleOptions;\n heading4?: BaseParagraphStyleOptions;\n heading5?: BaseParagraphStyleOptions;\n heading6?: BaseParagraphStyleOptions;\n heading7?: BaseParagraphStyleOptions;\n heading8?: BaseParagraphStyleOptions;\n heading9?: BaseParagraphStyleOptions;\n strong?: BaseParagraphStyleOptions;\n emphasis?: BaseParagraphStyleOptions;\n listParagraph?: BaseParagraphStyleOptions;\n quote?: BaseParagraphStyleOptions;\n intenseQuote?: BaseParagraphStyleOptions;\n hyperlink?: BaseCharacterStyleOptions;\n footnoteReference?: BaseCharacterStyleOptions;\n footnoteText?: BaseParagraphStyleOptions;\n footnoteTextChar?: BaseCharacterStyleOptions;\n endnoteReference?: BaseCharacterStyleOptions;\n endnoteText?: BaseParagraphStyleOptions;\n endnoteTextChar?: BaseCharacterStyleOptions;\n}\n\nexport interface DocumentDefaultsOptions {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n}\n\ninterface 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}\n\nexport type BaseParagraphStyleOptions = {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\nexport type BaseCharacterStyleOptions = {\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\n// ── String builders ──\n\n/** Escape special XML characters. */\nfunction esc(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\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[] = [];\n\n children.push(`<w:name w:val=\"${esc(opts.name ?? opts.id)}\"/>`);\n if (opts.aliases) children.push(`<w:aliases w:val=\"${esc(opts.aliases)}\"/>`);\n if (opts.basedOn) children.push(`<w:basedOn w:val=\"${esc(opts.basedOn)}\"/>`);\n if (opts.next) children.push(`<w:next w:val=\"${esc(opts.next)}\"/>`);\n if (opts.link) children.push(`<w:link w:val=\"${esc(opts.link)}\"/>`);\n if (opts.autoRedefine) children.push(\"<w:autoRedefine/>\");\n if (opts.uiPriority !== undefined) children.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) children.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) children.push(\"<w:unhideWhenUsed/>\");\n if (opts.quickFormat) children.push(\"<w:qFormat/>\");\n if (opts.locked) children.push(\"<w:locked/>\");\n if (opts.personal) children.push(\"<w:personal/>\");\n if (opts.personalCompose) children.push(\"<w:personalCompose/>\");\n if (opts.personalReply) children.push(\"<w:personalReply/>\");\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 `<w:style w:type=\"paragraph\" w:styleId=\"${esc(opts.id)}\">${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[] = [];\n\n children.push(`<w:name w:val=\"${esc(opts.name ?? opts.id)}\"/>`);\n if (opts.aliases) children.push(`<w:aliases w:val=\"${esc(opts.aliases)}\"/>`);\n if (opts.basedOn) children.push(`<w:basedOn w:val=\"${esc(opts.basedOn)}\"/>`);\n if (opts.link) children.push(`<w:link w:val=\"${esc(opts.link)}\"/>`);\n if (opts.autoRedefine) children.push(\"<w:autoRedefine/>\");\n if (opts.uiPriority !== undefined) children.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) children.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) children.push(\"<w:unhideWhenUsed/>\");\n if (opts.locked) children.push(\"<w:locked/>\");\n if (opts.personal) children.push(\"<w:personal/>\");\n if (opts.personalCompose) children.push(\"<w:personalCompose/>\");\n if (opts.personalReply) children.push(\"<w:personalReply/>\");\n\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `<w:style w:type=\"character\" w:styleId=\"${esc(opts.id)}\">${children.join(\"\")}</w:style>`;\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 const importedStyles: { _raw: string }[] = [];\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 importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:default=\"1\" w:styleId=\"Normal\">` +\n `<w:name w:val=\"Normal\"/><w:qFormat/>` +\n `<w:pPr><w:widowControl w:val=\"0\"/></w:pPr>` +\n `</w:style>`,\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 (const h of headings) {\n const pPrParts: string[] = [`<w:keepNext/>`, `<w:keepLines/>`];\n if (h.before || h.after) {\n const sp: string[] = [];\n if (h.before) sp.push(`w:before=\"${h.before}\"`);\n if (h.after) sp.push(`w:after=\"${h.after}\"`);\n pPrParts.push(`<w:spacing ${sp.join(\" \")}/>`);\n }\n pPrParts.push(`<w:outlineLvl w:val=\"${h.outlineLvl}\"/>`);\n\n const rPrParts: string[] = [];\n // heading 1-6 use accent1 color, 7-9 use text1 color\n if (parseInt(h.outlineLvl) < 6) {\n rPrParts.push(\n `<w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>`,\n );\n rPrParts.push(`<w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/>`);\n } else {\n rPrParts.push(`<w:rFonts w:cstheme=\"majorBidi\"/>`);\n rPrParts.push(`<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>`);\n }\n if (h.sz) {\n rPrParts.push(`<w:sz w:val=\"${h.sz}\"/><w:szCs w:val=\"${h.sz}\"/>`);\n }\n // heading 6-9 have bold\n if (parseInt(h.outlineLvl) >= 5) {\n rPrParts.push(`<w:b/><w:bCs/>`);\n }\n\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"${h.id}\">` +\n `<w:name w:val=\"${h.name}\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"${h.link}\"/>` +\n `<w:uiPriority w:val=\"9\"/>` +\n (parseInt(h.outlineLvl) > 0 ? `<w:semiHidden/><w:unhideWhenUsed/>` : \"\") +\n `<w:qFormat/>` +\n `<w:pPr>${pPrParts.join(\"\")}</w:pPr>` +\n `<w:rPr>${rPrParts.join(\"\")}</w:rPr>` +\n `</w:style>`,\n });\n\n // Linked character styles for headings\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"${h.link}\">` +\n `<w:name w:val=\"${h.name} Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"${h.id}\"/>` +\n `<w:uiPriority w:val=\"9\"/>` +\n (parseInt(h.outlineLvl) > 0 ? `<w:semiHidden/>` : \"\") +\n `<w:rPr>${rPrParts.join(\"\")}</w:rPr>` +\n `</w:style>`,\n });\n }\n\n // DefaultParagraphFont character style (default for runs)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:default=\"1\" w:styleId=\"DefaultParagraphFont\">` +\n `<w:name w:val=\"Default Paragraph Font\"/>` +\n `<w:uiPriority w:val=\"1\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `</w:style>`,\n });\n\n // Normal Table style (default for tables)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"table\" w:default=\"1\" w:styleId=\"NormalTable\">` +\n `<w:name w:val=\"Normal Table\"/>` +\n `<w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `<w:tblPr>` +\n `<w:tblInd w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:tblCellMar>` +\n `<w:top w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:left w:w=\"108\" w:type=\"dxa\"/>` +\n `<w:bottom w:w=\"0\" w:type=\"dxa\"/>` +\n `<w:right w:w=\"108\" w:type=\"dxa\"/>` +\n `</w:tblCellMar>` +\n `</w:tblPr>` +\n `</w:style>`,\n });\n\n // No List numbering style (default for numbering)\n importedStyles.push({\n _raw:\n `<w:style w:type=\"numbering\" w:default=\"1\" w:styleId=\"NoList\">` +\n `<w:name w:val=\"No List\"/>` +\n `<w:uiPriority w:val=\"99\"/><w:semiHidden/><w:unhideWhenUsed/>` +\n `</w:style>`,\n });\n\n // Title style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Title\">` +\n `<w:name w:val=\"Title\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"TitleChar\"/>` +\n `<w:uiPriority w:val=\"10\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/><w:contextualSpacing/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Title Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"TitleChar\">` +\n `<w:name w:val=\"Title Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Title\"/>` +\n `<w:uiPriority w:val=\"10\"/>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:spacing w:val=\"-10\"/><w:kern w:val=\"28\"/><w:sz w:val=\"56\"/><w:szCs w:val=\"56\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Subtitle style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Subtitle\">` +\n `<w:name w:val=\"Subtitle\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"SubtitleChar\"/>` +\n `<w:uiPriority w:val=\"11\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>` +\n `<w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Subtitle Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"SubtitleChar\">` +\n `<w:name w:val=\"Subtitle Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Subtitle\"/>` +\n `<w:uiPriority w:val=\"11\"/>` +\n `<w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:eastAsiaTheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cstheme=\"majorBidi\"/>` +\n `<w:color w:val=\"595959\" w:themeColor=\"text1\" w:themeTint=\"A6\"/>` +\n `<w:spacing w:val=\"15\"/><w:sz w:val=\"28\"/><w:szCs w:val=\"28\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // List Paragraph style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"ListParagraph\">` +\n `<w:name w:val=\"List Paragraph\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:uiPriority w:val=\"34\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:ind w:left=\"720\"/><w:contextualSpacing/></w:pPr>` +\n `</w:style>`,\n });\n\n // Quote style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"Quote\">` +\n `<w:name w:val=\"Quote\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"QuoteChar\"/>` +\n `<w:uiPriority w:val=\"29\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:spacing w:before=\"160\"/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Quote Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"QuoteChar\">` +\n `<w:name w:val=\"Quote Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"Quote\"/>` +\n `<w:uiPriority w:val=\"29\"/>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"404040\" w:themeColor=\"text1\" w:themeTint=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Intense Quote style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"paragraph\" w:styleId=\"IntenseQuote\">` +\n `<w:name w:val=\"Intense Quote\"/>` +\n `<w:basedOn w:val=\"Normal\"/>` +\n `<w:next w:val=\"Normal\"/>` +\n `<w:link w:val=\"IntenseQuoteChar\"/>` +\n `<w:uiPriority w:val=\"30\"/>` +\n `<w:qFormat/>` +\n `<w:pPr><w:pBdr><w:top w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/>` +\n `<w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"10\" w:color=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:pBdr>` +\n `<w:spacing w:before=\"360\" w:after=\"360\"/><w:ind w:left=\"864\" w:right=\"864\"/><w:jc w:val=\"center\"/></w:pPr>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Intense Quote Char style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"IntenseQuoteChar\">` +\n `<w:name w:val=\"Intense Quote Char\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:link w:val=\"IntenseQuote\"/>` +\n `<w:uiPriority w:val=\"30\"/>` +\n `<w:rPr><w:i/><w:iCs/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/></w:rPr>` +\n `</w:style>`,\n });\n\n // Hyperlink character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\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\n // Footnote Reference character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\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\n // Footnote Text paragraph style\n importedStyles.push({\n _raw: stringifyParagraphStyle({\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\n // Footnote Text Char character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\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\n // Endnote Reference character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\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\n // Endnote Text paragraph style\n importedStyles.push({\n _raw: stringifyParagraphStyle({\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\n // Endnote Text Char character style\n importedStyles.push({\n _raw: stringifyCharacterStyle({\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\n // Intense Reference character style\n importedStyles.push({\n _raw:\n `<w:style w:type=\"character\" w:styleId=\"IntenseReference\">` +\n `<w:name w:val=\"Intense Reference\"/>` +\n `<w:basedOn w:val=\"DefaultParagraphFont\"/>` +\n `<w:uiPriority w:val=\"32\"/>` +\n `<w:qFormat/>` +\n `<w:rPr><w:b/><w:bCs/><w:smallCaps/><w:color w:val=\"0F4761\" w:themeColor=\"accent1\" w:themeShade=\"BF\"/><w:spacing w:val=\"5\"/></w:rPr>` +\n `</w:style>`,\n });\n\n return { importedStyles, initialAttributes };\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 { ParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport type {\n BaseCharacterStyleOptions,\n BaseParagraphStyleOptions,\n DefaultStylesOptions,\n DocumentDefaultsOptions,\n} from \"@parts/styles/factory\";\nimport { stringifyCharacterStyle, stringifyParagraphStyle } from \"@parts/styles/factory\";\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?: (BaseParagraphStyleOptions & { id: string })[];\n /** Array of custom character style definitions */\n characterStyles?: (BaseCharacterStyleOptions & { id: string })[];\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\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 if (options.importedStyles) {\n for (const style of options.importedStyles) {\n if (style._raw) this.parts.push(style._raw);\n }\n }\n\n if (options.paragraphStyles) {\n for (const style of options.paragraphStyles) {\n this.parts.push(\n stringifyParagraphStyle({\n id: style.id,\n name: style.name ?? style.id,\n aliases: style.aliases,\n basedOn: style.basedOn,\n next: style.next,\n link: style.link,\n autoRedefine: style.autoRedefine,\n quickFormat: style.quickFormat,\n semiHidden: style.semiHidden,\n uiPriority: style.uiPriority,\n unhideWhenUsed: style.unhideWhenUsed,\n locked: style.locked,\n personal: style.personal,\n personalCompose: style.personalCompose,\n personalReply: style.personalReply,\n paragraph: style.paragraph,\n run: style.run,\n }),\n );\n }\n }\n\n if (options.characterStyles) {\n for (const style of options.characterStyles) {\n this.parts.push(\n stringifyCharacterStyle({\n id: style.id,\n name: style.name ?? style.id,\n aliases: style.aliases,\n basedOn: style.basedOn,\n link: style.link,\n autoRedefine: style.autoRedefine,\n semiHidden: style.semiHidden,\n uiPriority: style.uiPriority,\n unhideWhenUsed: style.unhideWhenUsed,\n locked: style.locked,\n personal: style.personal,\n personalCompose: style.personalCompose,\n personalReply: style.personalReply,\n run: style.run,\n }),\n );\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/** Style IDs generated by DefaultStylesFactory — skip these during parsing. */\nconst BUILTIN_STYLE_IDS = new Set([\n \"Title\",\n \"Heading1\",\n \"Heading2\",\n \"Heading3\",\n \"Heading4\",\n \"Heading5\",\n \"Heading6\",\n \"Strong\",\n \"ListParagraph\",\n \"Hyperlink\",\n \"FootnoteText\",\n \"FootnoteTextChar\",\n \"EndnoteText\",\n \"EndnoteTextChar\",\n \"FootnoteReference\",\n \"EndnoteReference\",\n]);\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?: string;\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 paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\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: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\n ctx: DocxReadContext,\n): StylesOptions | undefined {\n const opts: StylesOptions = {};\n const paragraphStyles: (BaseParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (BaseCharacterStyleOptions & { id: string })[] = [];\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 // Capture every style verbatim so the source's exact definitions\n // (numeric IDs, custom builtin formatting) round-trip instead of being\n // dropped + regenerated by the default factory.\n (opts.importedStyles ??= []).push({ _raw: stringifyElement(child) });\n // Structured parse skips builtins (their state is regenerated by the\n // factory for generation-from-scratch; the raw capture above preserves\n // them for round-trip).\n if (BUILTIN_STYLE_IDS.has(styleOpts.id)) continue;\n\n const type = styleOpts._type;\n delete styleOpts._type;\n\n if (type === \"paragraph\") {\n paragraphStyles.push(styleOpts as BaseParagraphStyleOptions & { id: string });\n } else if (type === \"character\") {\n characterStyles.push(styleOpts as BaseCharacterStyleOptions & { id: string });\n }\n }\n }\n\n if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;\n if (characterStyles.length > 0) opts.characterStyles = characterStyles;\n\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseDocDefaults(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\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 as unknown as ParagraphStylePropertiesOptions;\n }\n }\n }\n\n return Object.keys(document).length > 0 ? { document } : undefined;\n}\n\nfunction parseStyleElement(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: DocxReadContext) => Record<string, unknown>,\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 = \"1\";\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\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 as unknown as ParagraphStylePropertiesOptions;\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 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, attrBool, findChild, stringify } from \"@office-open/xml\";\n\nimport type { FeaturesOptions } from \"../core-properties\";\nimport type {\n SettingsOptions,\n DocumentProtectionOptions,\n WriteProtectionOptions,\n MailMergeOptions,\n OdsoOptions,\n OdsoFieldMapDataOptions,\n CompatibilityOptions,\n CaptionsOptions,\n MathPropertiesOptions,\n RsidsOptions,\n ReadModeInkLockDownOptions,\n RevisionViewOptions,\n FootnotePropertiesOptions,\n EndnotePropertiesOptions,\n} from \"./settings\";\n\n// ── XML string helpers ──\n\nfunction escapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\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)}=\"${escapeAttr(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}=\"${escapeAttr(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): string {\n return `<w:compatSetting w:name=\"${escapeAttr(name)}\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"${val}\"/>`;\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.brkBin !== undefined) p.push(attrEl(\"m:brkBin\", { \"m:val\": opts.brkBin }));\n if (opts.brkBinSub !== undefined) p.push(attrEl(\"m:brkBinSub\", { \"m:val\": opts.brkBinSub }));\n p.push(onOff(\"m:smallFrac\", opts.smallFrac));\n p.push(onOff(\"m:dispDef\", opts.dispDef));\n p.push(numVal(\"m:lMargin\", opts.lMargin));\n p.push(numVal(\"m:rMargin\", opts.rMargin));\n if (opts.defJc !== undefined) p.push(attrEl(\"m:defJc\", { \"m:val\": opts.defJc }));\n p.push(numVal(\"m:wrapIndent\", opts.wrapIndent));\n if (opts.intLim !== undefined) p.push(attrEl(\"m:intLim\", { \"m:val\": opts.intLim }));\n if (opts.naryLim !== undefined) p.push(attrEl(\"m:naryLim\", { \"m:val\": opts.naryLim }));\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 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 ];\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) p.push(\"<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 p.push(attrEl(\"w:themeFontLang\", { \"w:val\": opts.themeFontLang }));\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) p.push(\"<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 // evenAndOddHeaderAndFooters → w:evenAndOddHeaders\n const eohEl = findChild(el, \"w:evenAndOddHeaders\");\n if (eohEl) {\n const val = attr(eohEl, \"w:val\");\n opts.evenAndOddHeaderAndFooters = val !== \"false\" && val !== \"0\" && val !== \"off\";\n }\n\n // view → w:view/@w:val\n const viewEl = findChild(el, \"w:view\");\n if (viewEl) {\n const val = attr(viewEl, \"w:val\");\n if (val) opts.view = val;\n }\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 val = attr(zoomEl, \"w:val\");\n if (val) zoom.val = val;\n if (Object.keys(zoom).length > 0) opts.zoom = zoom;\n }\n\n // defaultTabStop → w:defaultTabStop/@w:val\n const tabStopEl = findChild(el, \"w:defaultTabStop\");\n if (tabStopEl) {\n const val = attr(tabStopEl, \"w:val\");\n if (val) opts.defaultTabStop = parseInt(val, 10);\n }\n\n // features.trackRevisions → w:trackRevisions (onOff: read w:val)\n const trackRevEl = findChild(el, \"w:trackRevisions\");\n if (trackRevEl) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.trackRevisions = attrBool(trackRevEl, \"w:val\") ?? true;\n opts.features = features;\n }\n\n // features.updateFields → w:updateFields (onOff: read w:val)\n const updateFieldsEl = findChild(el, \"w:updateFields\");\n if (updateFieldsEl) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.updateFields = attrBool(updateFieldsEl, \"w:val\") ?? true;\n opts.features = features;\n }\n\n // compatibilityModeVersion → w:compat/w:compatSetting\n const compatEl = findChild(el, \"w:compat\");\n if (compatEl) {\n for (const child of compatEl.elements ?? []) {\n if (child.name === \"w:compatSetting\") {\n const name = attr(child, \"w:name\");\n if (name === \"compatibilityMode\") {\n const val = attr(child, \"w:val\");\n if (val) opts.compatabilityModeVersion = parseInt(val, 10);\n }\n }\n }\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\") {\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name && val) vars.push({ name, val });\n }\n }\n if (vars.length > 0) opts.docVars = vars;\n }\n\n // characterSpacingControl → w:characterSpacingControl/@w:val\n const cscEl = findChild(el, \"w:characterSpacingControl\");\n if (cscEl) {\n const val = attr(cscEl, \"w:val\");\n if (val) opts.characterSpacingControl = val;\n }\n\n // displayBackgroundShape → w:displayBackgroundShape (presence)\n if (findChild(el, \"w:displayBackgroundShape\")) {\n opts.displayBackgroundShape = true;\n }\n\n // embedTrueTypeFonts → w:embedTrueTypeFonts (presence)\n if (findChild(el, \"w:embedTrueTypeFonts\")) {\n opts.embedTrueTypeFonts = true;\n }\n\n // embedSystemFonts → w:embedSystemFonts (presence)\n if (findChild(el, \"w:embedSystemFonts\")) {\n opts.embedSystemFonts = true;\n }\n\n // saveSubsetFonts → w:saveSubsetFonts (presence)\n if (findChild(el, \"w:saveSubsetFonts\")) {\n opts.saveSubsetFonts = true;\n }\n\n // removePersonalInformation → w:removePersonalInformation (presence)\n if (findChild(el, \"w:removePersonalInformation\")) {\n opts.removePersonalInformation = true;\n }\n\n // removeDateAndTime → w:removeDateAndTime (presence)\n if (findChild(el, \"w:removeDateAndTime\")) {\n opts.removeDateAndTime = true;\n }\n\n // hideSpellingErrors → w:hideSpellingErrors (presence)\n if (findChild(el, \"w:hideSpellingErrors\")) {\n opts.hideSpellingErrors = true;\n }\n\n // hideGrammaticalErrors → w:hideGrammaticalErrors (presence)\n if (findChild(el, \"w:hideGrammaticalErrors\")) {\n opts.hideGrammaticalErrors = true;\n }\n\n // mirrorMargins → w:mirrorMargins (presence)\n if (findChild(el, \"w:mirrorMargins\")) {\n opts.mirrorMargins = true;\n }\n\n // saveFormsData → w:saveFormsData (presence)\n if (findChild(el, \"w:saveFormsData\")) {\n opts.saveFormsData = true;\n }\n\n // alignBordersAndEdges → w:alignBordersAndEdges (presence)\n if (findChild(el, \"w:alignBordersAndEdges\")) {\n opts.alignBordersAndEdges = true;\n }\n\n // bordersDoNotSurroundHeader → w:bordersDoNotSurroundHeader (presence)\n if (findChild(el, \"w:bordersDoNotSurroundHeader\")) {\n opts.bordersDoNotSurroundHeader = true;\n }\n\n // bordersDoNotSurroundFooter → w:bordersDoNotSurroundFooter (presence)\n if (findChild(el, \"w:bordersDoNotSurroundFooter\")) {\n opts.bordersDoNotSurroundFooter = true;\n }\n\n // gutterAtTop → w:gutterAtTop (presence)\n if (findChild(el, \"w:gutterAtTop\")) {\n opts.gutterAtTop = true;\n }\n\n // formsDesign → w:formsDesign (presence)\n if (findChild(el, \"w:formsDesign\")) {\n opts.formsDesign = true;\n }\n\n // linkStyles → w:linkStyles (presence)\n if (findChild(el, \"w:linkStyles\")) {\n opts.linkStyles = true;\n }\n\n // autoHyphenation → w:autoHyphenation\n const autoHyphEl = findChild(el, \"w:autoHyphenation\");\n if (autoHyphEl) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.autoHyphenation = true;\n opts.hyphenation = hyphenation;\n }\n\n // doNotHyphenateCaps → w:doNotHyphenateCaps\n const noHyphCapsEl = findChild(el, \"w:doNotHyphenateCaps\");\n if (noHyphCapsEl) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.doNotHyphenateCaps = true;\n opts.hyphenation = hyphenation;\n }\n\n // consecutiveHyphenLimit → w:consecutiveHyphenLimit/@w:val\n const consHyphEl = findChild(el, \"w:consecutiveHyphenLimit\");\n if (consHyphEl) {\n const val = attr(consHyphEl, \"w:val\");\n if (val) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.consecutiveHyphenLimit = parseInt(val, 10);\n opts.hyphenation = hyphenation;\n }\n }\n\n // hyphenationZone → w:hyphenationZone/@w:val\n const hyphZoneEl = findChild(el, \"w:hyphenationZone\");\n if (hyphZoneEl) {\n const val = attr(hyphZoneEl, \"w:val\");\n if (val) {\n const hyphenation = (opts.hyphenation as Record<string, unknown>) ?? {};\n hyphenation.hyphenationZone = parseInt(val, 10);\n opts.hyphenation = hyphenation;\n }\n }\n\n // attachedTemplate → w:attachedTemplate/@r:id\n const attachedTplEl = findChild(el, \"w:attachedTemplate\");\n if (attachedTplEl) {\n const val = attr(attachedTplEl, \"r:id\");\n if (val) opts.attachedTemplate = val;\n }\n\n // stylePaneSortMethod → w:stylePaneSortMethod/@w:val\n const spsmEl = findChild(el, \"w:stylePaneSortMethod\");\n if (spsmEl) {\n const val = attr(spsmEl, \"w:val\");\n if (val) opts.stylePaneSortMethod = val;\n }\n\n // documentType → w:documentType/@w:val\n const docTypeEl = findChild(el, \"w:documentType\");\n if (docTypeEl) {\n const val = attr(docTypeEl, \"w:val\");\n if (val) opts.documentType = val;\n }\n\n // defaultTableStyle → w:defaultTableStyle/@w:val\n const defTblStyleEl = findChild(el, \"w:defaultTableStyle\");\n if (defTblStyleEl) {\n const val = attr(defTblStyleEl, \"w:val\");\n if (val) opts.defaultTableStyle = val;\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 flags: [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 ];\n for (const [prop, xmlKey] of flags) {\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 // clickAndTypeStyle → w:clickAndTypeStyle/@w:val\n const catEl = findChild(el, \"w:clickAndTypeStyle\");\n if (catEl) {\n const val = attr(catEl, \"w:val\");\n if (val) opts.clickAndTypeStyle = val;\n }\n\n // activeWritingStyle → iterate w:activeWritingStyle children\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 // documentProtection → w:documentProtection (written under features)\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 // Only include documentProtection if enforcement is set\n const hash = attr(docProtEl, \"w:hash\");\n if (hash) prot.hash = hash;\n const salt = attr(docProtEl, \"w:salt\");\n if (salt) prot.salt = salt;\n const cryptProviderType = attr(docProtEl, \"w:cryptProviderType\");\n if (cryptProviderType) prot.cryptoProviderType = cryptProviderType;\n const cryptAlgorithmClass = attr(docProtEl, \"w:cryptAlgorithmClass\");\n if (cryptAlgorithmClass) prot.cryptoAlgorithmClass = cryptAlgorithmClass;\n const cryptAlgorithmType = attr(docProtEl, \"w:cryptAlgorithmType\");\n if (cryptAlgorithmType) prot.cryptoAlgorithmType = cryptAlgorithmType;\n const cryptAlgorithmSid = attr(docProtEl, \"w:cryptAlgorithmSid\");\n if (cryptAlgorithmSid) prot.cryptoAlgorithmSid = parseInt(cryptAlgorithmSid, 10);\n const cryptSpinCount = attr(docProtEl, \"w:cryptSpinCount\");\n if (cryptSpinCount) prot.cryptoSpinCount = parseInt(cryptSpinCount, 10);\n const hashValue = attr(docProtEl, \"w:hashValue\");\n if (hashValue) prot.hashValue = hashValue;\n const saltValue = attr(docProtEl, \"w:saltValue\");\n if (saltValue) prot.saltValue = saltValue;\n const spinCount = attr(docProtEl, \"w:spinCount\");\n if (spinCount) prot.spinCount = parseInt(spinCount, 10);\n const algorithmName = attr(docProtEl, \"w:algorithmName\");\n if (algorithmName) prot.algorithmName = algorithmName;\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) {\n const features: FeaturesOptions = (opts.features as FeaturesOptions | undefined) ?? {};\n features.documentProtection = prot;\n opts.features = features;\n }\n }\n\n // doNotTrackMoves → w:doNotTrackMoves (onOff: read w:val)\n const noMovesEl = findChild(el, \"w:doNotTrackMoves\");\n if (noMovesEl) opts.doNotTrackMoves = attrBool(noMovesEl, \"w:val\") ?? true;\n\n // doNotTrackFormatting → w:doNotTrackFormatting (onOff: read w:val)\n const noFmtEl = findChild(el, \"w:doNotTrackFormatting\");\n if (noFmtEl) opts.doNotTrackFormatting = attrBool(noFmtEl, \"w:val\") ?? true;\n\n // Capture the full settings part verbatim (child elements only — the root\n // <w:settings> tag + namespaces are supplied by stringify). CT_Settings has\n // ~100 element types (compat flags, m:mathPr, w:rsids, o:shapelayout,\n // footnote/endnote properties, etc.); the structured reads above cover only\n // a subset. This guarantees byte-exact round-trip; stringify emits it as-is\n // when present. The structured fields above remain for generation-from-scratch\n // and for callers that delete rawXml to edit individual settings.\n opts.rawXml = stringify(el);\n if (el.attributes) opts.rootAttributes = { ...el.attributes };\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\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 * 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, 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\";\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):\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 }\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 */\nfunction 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 * 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=-1)\n * - Continuation separator footnote (id=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\nexport interface FootnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\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/** Separator footnote (id=-1). */\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/** Continuation separator footnote (id=0). */\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\nexport const footnotesDesc: CustomDescriptor<FootnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [\n `<w:footnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`,\n SEPARATOR_FOOTNOTE,\n CONTINUATION_SEPARATOR_FOOTNOTE,\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 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 // Skip system footnotes (separator id=-1, continuationSeparator id=0)\n const type = attr(child, \"w:type\");\n if (type || id < 1) continue;\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 notes.set(id, paragraphs);\n }\n return { notes } 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=-1)\n * - Continuation separator endnote (id=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\nexport interface EndnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\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/** Separator endnote (id=-1). */\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/** Continuation separator endnote (id=0). */\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\nexport const endnotesDesc: CustomDescriptor<EndnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [\n `<w:endnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`,\n SEPARATOR_ENDNOTE,\n CONTINUATION_SEPARATOR_ENDNOTE,\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 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 // Skip system endnotes (separator id=-1, continuationSeparator id=0)\n const type = attr(child, \"w:type\");\n if (type || id < 1) continue;\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 notes.set(id, paragraphs);\n }\n return { notes } 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, 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) {\n parts.push(`<w:charset w:val=\"${escapeXml(font.characterSet)}\"/>`);\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 parts.push(`<w:embedRegular r:id=\"${font.embedRid}\" w:fontKey=\"{${font.fontKey}}\"/>`);\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 }\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 }\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 { findChild, textOf } from \"@office-open/xml\";\n\nfunction escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\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: Record<string, unknown> = {};\n\n // StyleName attribute\n const styleName = el.attributes?.[\"StyleName\"];\n if (styleName) opts.styleName = styleName;\n\n // Parse b:Source children\n const sources: Record<string, unknown>[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"b:Source\") continue;\n const source: Record<string, unknown> = {};\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 unknown 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, 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 glossaryEscapeAttr(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\nfunction docPartPrXml(part: GlossaryDocumentOptions[\"parts\"][number]): string {\n const prParts: string[] = [];\n prParts.push(\n `<w:name w:val=\"${glossaryEscapeAttr(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=\"${glossaryEscapeAttr(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=\"${glossaryEscapeAttr(part.description)}\"/>`);\n }\n if (part.guid) {\n prParts.push(`<w:guid w:val=\"${glossaryEscapeAttr(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: Record<string, unknown>[] = [];\n\n const docPartsEl = findChild(el, \"w:docParts\");\n if (!docPartsEl) return { parts } as unknown as GlossaryDocumentOptions;\n\n for (const docPart of docPartsEl.elements ?? []) {\n if (docPart.name !== \"w:docPart\") continue;\n const part: Record<string, unknown> = {};\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\");\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;\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;\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;\n }\n\n parts.push(part);\n }\n\n return { parts } as unknown as GlossaryDocumentOptions;\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 } 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\n// ── XML helpers ──\n\nfunction escapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\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 const attrs: string[] = [`w:id=\"${opts.id}\"`, `w:date=\"${escapeAttr(dateStr)}\"`];\n if (opts.author !== undefined) attrs.push(`w:author=\"${escapeAttr(opts.author)}\"`);\n if (opts.initials !== undefined) attrs.push(`w:initials=\"${escapeAttr(opts.initials)}\"`);\n\n const parts: string[] = [];\n for (const child of opts.children) {\n parts.push(stringifyParagraphInline(child as string | ParagraphOptions, 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: Record<string, unknown>[] = [];\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: Record<string, unknown> = { id };\n const date = attr(child, \"w:date\");\n if (date) comment.date = date;\n const author = attr(child, \"w:author\");\n if (author) comment.author = author;\n const initials = attr(child, \"w:initials\");\n if (initials) comment.initials = initials;\n\n const children: unknown[] = [];\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);\n }\n return { children: comments } as unknown as CommentsOptions;\n },\n};\n","/**\n * Content types descriptor — produces [Content_Types].xml.\n *\n * Reference: OPC, Content_Types.xsd\n *\n * @module\n */\n\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 } as unknown as ContentTypesInput;\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\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/** Helper to build the standard DOCX content types with dynamic overrides. */\nexport function buildContentTypes(\n extras: {\n headerCount?: number;\n footerCount?: number;\n chartCount?: number;\n smartArtCount?: number;\n hasBibliography?: boolean;\n hasComments?: boolean;\n hasGlossary?: boolean;\n hasWebSettings?: boolean;\n altChunks?: { path: string; contentType: string }[];\n subDocs?: { path: string }[];\n } = {},\n): ContentTypesInput {\n const defaults: ContentTypeDefault[] = [...STANDARD_DEFAULTS];\n\n const overrides: ContentTypeOverride[] = [\n {\n partName: \"/word/document.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n },\n {\n partName: \"/word/styles.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\",\n },\n {\n partName: \"/docProps/core.xml\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n },\n {\n partName: \"/docProps/custom.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.custom-properties+xml\",\n },\n {\n partName: \"/docProps/app.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n },\n {\n partName: \"/word/numbering.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\",\n },\n {\n partName: \"/word/footnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml\",\n },\n {\n partName: \"/word/endnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml\",\n },\n {\n partName: \"/word/settings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\",\n },\n // Comments Override is conditional — declaring it without a comments.xml\n // part (or vice versa) is an OPC mismatch. See hasComments gate.\n ...(extras.hasComments\n ? [\n {\n partName: \"/word/comments.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\n },\n ]\n : []),\n {\n partName: \"/word/fontTable.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\",\n },\n ];\n\n for (let i = 1; i <= (extras.headerCount ?? 0); i++) {\n overrides.push({\n partName: `/word/header${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml\",\n });\n }\n for (let i = 1; i <= (extras.footerCount ?? 0); i++) {\n overrides.push({\n partName: `/word/footer${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml\",\n });\n }\n for (let i = 1; i <= (extras.chartCount ?? 0); i++) {\n overrides.push({\n partName: `/word/charts/chart${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\",\n });\n }\n for (let i = 1; i <= (extras.smartArtCount ?? 0); i++) {\n overrides.push({\n partName: `/word/diagrams/data${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/layout${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/quickStyle${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/colors${i}.xml`,\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml\",\n });\n overrides.push({\n partName: `/word/diagrams/drawing${i}.xml`,\n contentType: \"application/vnd.ms-office.drawingml.diagramDrawing+xml\",\n });\n }\n if (extras.hasBibliography) {\n overrides.push({\n partName: \"/word/bibliography.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.bibliography+xml\",\n });\n }\n if (extras.hasGlossary) {\n overrides.push({\n partName: \"/word/glossary/document.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.glossary+xml\",\n });\n }\n if (extras.hasWebSettings) {\n overrides.push({\n partName: \"/word/webSettings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\",\n });\n }\n for (const ac of extras.altChunks ?? []) {\n overrides.push({\n partName: ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`,\n contentType: ac.contentType,\n });\n }\n for (const sd of extras.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\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 } as unknown as RelationshipsInput;\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 { 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 {\n sections: SectionOptions[];\n title?: string;\n subject?: string;\n creator?: string;\n keywords?: string;\n description?: string;\n lastModifiedBy?: string;\n revision?: number;\n lastPrinted?: string;\n externalStyles?: string;\n styles?: StylesOptions;\n numbering?: NumberingOptions;\n comments?: CommentsOptions;\n bibliography?: BibliographyOptions;\n footnotes?: Readonly<\n Record<\n string,\n {\n children: (ParagraphOptions | string)[];\n }\n >\n >;\n endnotes?: Readonly<\n Record<\n string,\n {\n children: (ParagraphOptions | string)[];\n }\n >\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 /** 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 { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\n/** Subset of DocumentOptions used for core properties XML. */\nexport interface CorePropertiesInput {\n title?: string;\n subject?: string;\n creator?: string;\n keywords?: string;\n description?: string;\n lastModifiedBy?: string;\n revision?: number;\n lastPrinted?: string;\n}\n\nexport const corePropertiesDesc: CustomDescriptor<CorePropertiesInput> = {\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 if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);\n if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);\n if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);\n if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);\n if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);\n if (opts.lastModifiedBy)\n p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy)}</cp:lastModifiedBy>`);\n if (opts.revision !== undefined) p.push(`<cp:revision>${opts.revision}</cp:revision>`);\n if (opts.lastPrinted) p.push(`<cp:lastPrinted>${escapeXml(opts.lastPrinted)}</cp:lastPrinted>`);\n p.push(`<dcterms:created xsi:type=\"dcterms:W3CDTF\">${now}</dcterms:created>`);\n p.push(`<dcterms:modified xsi:type=\"dcterms:W3CDTF\">${now}</dcterms:modified>`);\n p.push(\"</cp:coreProperties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: CorePropertiesInput = {};\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 }\n }\n return result;\n },\n};\n","/**\n * Custom Properties module for WordprocessingML documents.\n *\n * Provides the CustomPropertyOptions interface.\n * XML generation is handled by the descriptor pipeline (customPropertiesDesc).\n *\n * Reference: ISO-IEC29500-4_2016 shared-documentPropertiesCustom.xsd\n *\n * @module\n */\n\n/**\n * Options for creating a custom property.\n *\n * @property name - The property name\n * @property value - The property value (as string)\n */\nexport interface CustomPropertyOptions {\n /** The property name */\n name: string;\n /** The property value (as string) */\n value: string;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, textOf } from \"@office-open/xml\";\n\nexport interface CustomPropertiesInput {\n properties: CustomPropertyOptions[];\n}\n\nexport const customPropertiesDesc: CustomDescriptor<CustomPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n let pid = 2;\n for (const prop of opts.properties) {\n p.push(\n `<property fmtid=\"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}\" pid=\"${pid}\" name=\"${escapeXml(prop.name)}\">` +\n `<vt:lpwstr>${escapeXml(prop.value)}</vt:lpwstr>` +\n `</property>`,\n );\n pid++;\n }\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const properties: CustomPropertyOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"property\") continue;\n const name = attr(child, \"name\");\n if (!name) continue;\n\n // Find the value element (vt:lpwstr, vt:lpstr, vt:i4, etc.)\n const valueEl = child.elements?.find((e) => e.name?.startsWith(\"vt:\"));\n const value = valueEl ? (textOf(valueEl) ?? \"\") : \"\";\n properties.push({ name, value });\n }\n return { properties } as unknown as CustomPropertiesInput;\n },\n};\n","/**\n * App (Extended) Properties module for WordprocessingML documents.\n *\n * Provides the AppPropertiesOptions interface and the appPropertiesDesc\n * descriptor for docProps/app.xml (CT_Properties).\n *\n * Reference: ISO-IEC29500-2_2016 shared-documentPropertiesExtended.xsd\n *\n * @module\n */\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\n/**\n * Options for docProps/app.xml extended properties (CT_Properties).\n *\n * Only the scalar (string/number/boolean) child elements are modelled.\n * Structured vector/blob elements (HeadingPairs, TitlesOfParts, HLinks,\n * DigSig, PresentationFormat) are intentionally omitted.\n *\n * Property order follows the CT_Properties xsd:all sequence so the\n * emitted XML matches the reference schema ordering.\n */\nexport interface AppPropertiesOptions {\n /** Template name */\n template?: string;\n /** Manager name */\n manager?: string;\n /** Company name */\n company?: string;\n /** Page count */\n pages?: number;\n /** Word count */\n words?: number;\n /** Character count */\n characters?: number;\n /** Line count */\n lines?: number;\n /** Paragraph count */\n paragraphs?: number;\n /** Notes count */\n notes?: number;\n /** Slides count */\n slides?: number;\n /** Total editing time (minutes) */\n totalTime?: number;\n /** Hidden slides count */\n hiddenSlides?: number;\n /** Multimedia clips count */\n mmClips?: number;\n /** Characters including spaces */\n charactersWithSpaces?: number;\n /** Document security level */\n docSecurity?: number;\n /** Hyperlink base URL */\n hyperlinkBase?: string;\n /** Application name */\n application?: string;\n /** Application version */\n appVersion?: string;\n /** Whether the document is scaled/cropped */\n scaleCrop?: boolean;\n /** Whether links are up to date */\n linksUpToDate?: boolean;\n /** Whether the document is shared */\n sharedDoc?: boolean;\n /** Whether hyperlinks changed */\n hyperlinksChanged?: boolean;\n}\n\n/** Subset of AppPropertiesOptions accepted by stringify. */\nexport type AppPropertiesInput = AppPropertiesOptions;\n\nexport const appPropertiesDesc: CustomDescriptor<AppPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n // xsd:all is unordered, but emit in schema order for readability.\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n\n // Schema order: Template, Manager, Company, Pages, Words, Characters,\n // PresentationFormat, Lines, Paragraphs, Slides, Notes, TotalTime,\n // HiddenSlides, MMClips, ScaleCrop, HeadingPairs, TitlesOfParts,\n // LinksUpToDate, CharactersWithSpaces, SharedDoc, HyperlinkBase, HLinks,\n // HyperlinksChanged, DigSig, Application, AppVersion, DocSecurity.\n if (opts.template !== undefined) p.push(`<Template>${escapeXml(opts.template)}</Template>`);\n if (opts.manager !== undefined) p.push(`<Manager>${escapeXml(opts.manager)}</Manager>`);\n if (opts.company !== undefined) p.push(`<Company>${escapeXml(opts.company)}</Company>`);\n if (opts.pages !== undefined) p.push(`<Pages>${opts.pages}</Pages>`);\n if (opts.words !== undefined) p.push(`<Words>${opts.words}</Words>`);\n if (opts.characters !== undefined) p.push(`<Characters>${opts.characters}</Characters>`);\n if (opts.lines !== undefined) p.push(`<Lines>${opts.lines}</Lines>`);\n if (opts.paragraphs !== undefined) p.push(`<Paragraphs>${opts.paragraphs}</Paragraphs>`);\n if (opts.slides !== undefined) p.push(`<Slides>${opts.slides}</Slides>`);\n if (opts.notes !== undefined) p.push(`<Notes>${opts.notes}</Notes>`);\n if (opts.totalTime !== undefined) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);\n if (opts.hiddenSlides !== undefined)\n p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);\n if (opts.mmClips !== undefined) p.push(`<MMClips>${opts.mmClips}</MMClips>`);\n if (opts.scaleCrop !== undefined) p.push(`<ScaleCrop>${opts.scaleCrop ? 1 : 0}</ScaleCrop>`);\n if (opts.linksUpToDate !== undefined)\n p.push(`<LinksUpToDate>${opts.linksUpToDate ? 1 : 0}</LinksUpToDate>`);\n if (opts.charactersWithSpaces !== undefined)\n p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);\n if (opts.sharedDoc !== undefined) p.push(`<SharedDoc>${opts.sharedDoc ? 1 : 0}</SharedDoc>`);\n if (opts.hyperlinkBase !== undefined)\n p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);\n if (opts.hyperlinksChanged !== undefined)\n p.push(`<HyperlinksChanged>${opts.hyperlinksChanged ? 1 : 0}</HyperlinksChanged>`);\n if (opts.application !== undefined)\n p.push(`<Application>${escapeXml(opts.application)}</Application>`);\n if (opts.appVersion !== undefined)\n p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);\n if (opts.docSecurity !== undefined) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);\n\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: AppPropertiesOptions = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n switch (child.name) {\n case \"Template\":\n if (typeof text === \"string\") result.template = text;\n break;\n case \"Manager\":\n if (typeof text === \"string\") result.manager = text;\n break;\n case \"Company\":\n if (typeof text === \"string\") result.company = text;\n break;\n case \"Pages\":\n if (typeof text === \"string\") result.pages = Number(text);\n break;\n case \"Words\":\n if (typeof text === \"string\") result.words = Number(text);\n break;\n case \"Characters\":\n if (typeof text === \"string\") result.characters = Number(text);\n break;\n case \"Lines\":\n if (typeof text === \"string\") result.lines = Number(text);\n break;\n case \"Paragraphs\":\n if (typeof text === \"string\") result.paragraphs = Number(text);\n break;\n case \"Slides\":\n if (typeof text === \"string\") result.slides = Number(text);\n break;\n case \"Notes\":\n if (typeof text === \"string\") result.notes = Number(text);\n break;\n case \"TotalTime\":\n if (typeof text === \"string\") result.totalTime = Number(text);\n break;\n case \"HiddenSlides\":\n if (typeof text === \"string\") result.hiddenSlides = Number(text);\n break;\n case \"MMClips\":\n if (typeof text === \"string\") result.mmClips = Number(text);\n break;\n case \"ScaleCrop\":\n if (typeof text === \"string\") result.scaleCrop = text === \"1\" || text === \"true\";\n break;\n case \"LinksUpToDate\":\n if (typeof text === \"string\") result.linksUpToDate = text === \"1\" || text === \"true\";\n break;\n case \"CharactersWithSpaces\":\n if (typeof text === \"string\") result.charactersWithSpaces = Number(text);\n break;\n case \"SharedDoc\":\n if (typeof text === \"string\") result.sharedDoc = text === \"1\" || text === \"true\";\n break;\n case \"HyperlinkBase\":\n if (typeof text === \"string\") result.hyperlinkBase = text;\n break;\n case \"HyperlinksChanged\":\n if (typeof text === \"string\") result.hyperlinksChanged = text === \"1\" || text === \"true\";\n break;\n case \"Application\":\n if (typeof text === \"string\") result.application = text;\n break;\n case \"AppVersion\":\n if (typeof text === \"string\") result.appVersion = text;\n break;\n case \"DocSecurity\":\n if (typeof text === \"string\") result.docSecurity = Number(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;\n marginRight: number;\n marginTop: number;\n marginBottom: number;\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 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 */\n optimizeForBrowser?: boolean;\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 targetScreenSz?: (typeof TargetScreenSize)[keyof typeof TargetScreenSize] | string;\n /** Save smart tags as XML */\n saveSmartTagsAsXml?: boolean;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrNum, 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;\n relyOnVML?: boolean;\n allowPNG?: boolean;\n doNotRelyOnCSS?: boolean;\n doNotSaveAsSingleFile?: boolean;\n doNotOrganizeInFolder?: boolean;\n doNotUseLongFileNames?: boolean;\n pixelsPerInch?: number;\n targetScreenSz?: 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=\"${wsEscapeAttr(val)}\"/>`;\n}\n\nfunction wsNumVal(tag: string, val: number): string {\n return `<${tag} w:val=\"${val}\"/>`;\n}\n\nfunction wsEscapeAttr(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\n// ── Parse helpers (for descriptor parse path) ──\n\nfunction parseFramesetEl(el: Element): FramesetOptions {\n const opts: Record<string, unknown> = {};\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 unknown as FramesetOptions;\n}\n\nfunction parseSplitbarEl(el: Element): FramesetSplitbarOptions {\n const opts: Record<string, unknown> = {};\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 unknown as FramesetSplitbarOptions;\n}\n\nfunction parseFrameEl(el: Element): FrameOptions {\n const opts: Record<string, unknown> = {};\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 unknown 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: Record<string, unknown> = { id };\n\n const marLeft = findChild(el, \"w:marLeft\");\n if (marLeft) {\n const val = attrNum(marLeft, \"w:val\");\n if (val !== undefined) opts.marginLeft = val;\n }\n\n const marRight = findChild(el, \"w:marRight\");\n if (marRight) {\n const val = attrNum(marRight, \"w:val\");\n if (val !== undefined) opts.marginRight = val;\n }\n\n const marTop = findChild(el, \"w:marTop\");\n if (marTop) {\n const val = attrNum(marTop, \"w:val\");\n if (val !== undefined) opts.marginTop = val;\n }\n\n const marBottom = findChild(el, \"w:marBottom\");\n if (marBottom) {\n const val = attrNum(marBottom, \"w:val\");\n if (val !== undefined) opts.marginBottom = val;\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 unknown as DivOptions;\n}\n\nfunction parseDivBorderEl(el: Element): DivBorderOptions {\n const opts: Record<string, unknown> = {};\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: 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 opts[side] = b;\n }\n }\n\n return opts as unknown 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=\"${wsEscapeAttr(side.style)}\"`];\n if (side.color) attrParts.push(`w:color=\"${wsEscapeAttr(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)\n parts.push(`<w:sourceFileName r:id=\"${wsEscapeAttr(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)\n parts.push(`<w:longDesc r:id=\"${wsEscapeAttr(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 p.push(wsOnOff(\"w:optimizeForBrowser\", opts.optimizeForBrowser));\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.targetScreenSz !== undefined)\n p.push(wsStringVal(\"w:targetScreenSz\", opts.targetScreenSz));\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: Record<string, unknown> = {};\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:optimizeForBrowser\", \"optimizeForBrowser\"],\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 // 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 targetSz = findChild(el, \"w:targetScreenSz\");\n if (targetSz) {\n const val = attr(targetSz, \"w:val\");\n if (val) opts.targetScreenSz = val;\n }\n\n return opts as unknown 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;;;;;;;;;;;;;;;;;;;;AClDA,MAAa,eAAe;;CAE1B,UAAU;;CAEV,SAAS;;CAET,OAAO;;CAEP,MAAM;AACR;;;;;;;;;;;;;;;;;ACbA,MAAa,eAAe;;CAE1B,WAAW;;CAEX,WAAW;;CAEX,WAAW;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