@office-open/docx 0.9.2 → 0.9.4
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/dist/{context-CERMOUn0.mjs → context-CA7wUvmY.mjs} +1608 -1043
- package/dist/context-CA7wUvmY.mjs.map +1 -0
- package/dist/{core-properties-Bh8_D5Kh.d.mts → core-properties-CR-T1Wqh.d.mts} +59 -10
- package/dist/core-properties-CR-T1Wqh.d.mts.map +1 -0
- package/dist/{document-CeM-U6J3.mjs → document-B_uvEH8b.mjs} +705 -83
- package/dist/document-B_uvEH8b.mjs.map +1 -0
- package/dist/{generate-DiDgl0bc.mjs → generate-_AmBlI4o.mjs} +4 -4
- package/dist/generate-_AmBlI4o.mjs.map +1 -0
- package/dist/generate.d.mts +1 -1
- package/dist/generate.mjs +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{parse-BIJM6_8Y.mjs → parse-7SJ1sm-D.mjs} +17 -4
- package/dist/parse-7SJ1sm-D.mjs.map +1 -0
- package/dist/parse.d.mts +1 -1
- package/dist/parse.mjs +1 -1
- package/dist/patch/index.d.mts +1 -1
- package/dist/patch/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/context-CERMOUn0.mjs.map +0 -1
- package/dist/core-properties-Bh8_D5Kh.d.mts.map +0 -1
- package/dist/document-CeM-U6J3.mjs.map +0 -1
- package/dist/generate-DiDgl0bc.mjs.map +0 -1
- package/dist/parse-BIJM6_8Y.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-CERMOUn0.mjs","names":["escapeAttr","NS","NS","escapeXml","escapeAttr","escapeXml","xmlChildren"],"sources":["../src/parts/paragraph/formatting/alignment.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/parts/paragraph/run/image-run.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-properties/table-float-properties.ts","../src/parts/table/table-properties/table-layout.ts","../src/parts/table/table-properties/table-borders.ts","../src/parts/numbering/level.ts","../src/parts/numbering/numbering.ts","../src/parts/paragraph/run/run-parse.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/table-of-contents/descriptor.ts","../src/parts/fonts/font-wrapper.ts","../src/parts/textbox/shape/shape.ts","../src/body.ts","../src/parts/footnotes/descriptor.ts","../src/parts/endnotes/descriptor.ts","../src/parts/sdt/sdt-parse.ts","../src/parts/perm-start.ts","../src/parts/alt-chunk/alt-chunk-collection.ts","../src/parts/sub-doc/sub-doc-collection.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/bodychildren.ts","../src/parts/core-properties.ts","../src/parts/custom-properties.ts","../src/parts/web-settings.ts","../src/parts/styles/external-styles-factory.ts","../src/context.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 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\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 { 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 } from \"@shared/media/data\";\n\nimport type { Floating } from \"../../drawing\";\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}\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): Pick<MediaData, \"data\" | \"fileName\" | \"transformation\" | \"srcRect\"> => ({\n data,\n fileName: key,\n srcRect,\n transformation: createTransformation(transformation),\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 { 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 /** Default text value */\n default?: 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 if (options.default !== undefined) {\n children.push(`<w:default/>`);\n }\n if (options.checked !== undefined) {\n children.push(`<w:checked/>`);\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 if (options.enabled !== undefined) {\n children.push(`<w:enabled/>`);\n }\n if (options.calcOnExit !== undefined) {\n children.push(`<w:calcOnExit/>`);\n }\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 * 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 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 * 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 * 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, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\n\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 }[];\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, Record<string, any>>();\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 const defaultAbstractId = this.abstractNumUniqueNumericId();\n\n this.abstractNumberingData.set(\"default-bullet-numbering\", {\n id: defaultAbstractId,\n levels: DEFAULT_BULLET_LEVELS,\n });\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 for (const con of options.config) {\n this.abstractNumberingData.set(con.reference, {\n id: this.abstractNumUniqueNumericId(),\n levels: con.levels,\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 && referenceConfigLevels[0].start;\n\n this.concreteNumberingData.set(fullReference, {\n abstractNumId: abstractNumbering.id,\n instance,\n numId: this.concreteNumUniqueNumericId(),\n overrideLevels: [\n typeof firstLevelStartNumber === \"number\" && Number.isInteger(firstLevelStartNumber)\n ? { num: 0, start: firstLevelStartNumber }\n : { num: 0, start: 1 },\n ],\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(): Record<string, any>[] {\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(el: Element): 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);\n if (levelOpts) levels.push(levelOpts);\n }\n\n if (levels.length > 0 && levels.every((l) => l.format === LevelFormat.BULLET)) continue;\n\n if (levels.length > 0) {\n configs.push({ reference: `list_${numId}`, levels });\n }\n }\n\n if (configs.length === 0) return undefined;\n return { config: configs };\n}\n\nfunction parseLevelEl(el: Element): LevelsOptions | undefined {\n const opts: Record<string, unknown> = {};\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 numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const val = attr(numFmt, \"w:val\");\n if (val) opts.format = val;\n }\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 lvlJc = findChild(el, \"w:lvlJc\");\n if (lvlJc) {\n const val = attr(lvlJc, \"w:val\");\n if (val) opts.alignment = val;\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;\n }\n\n if (findChild(el, \"w:isLgl\")) opts.isLegalNumberingStyle = true;\n\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const style: Record<string, unknown> = {};\n const sz = findChild(rPr, \"w:sz\");\n if (sz) {\n const val = attrNum(sz, \"w:val\");\n if (val !== undefined) {\n if (!style.run) style.run = {};\n (style.run as Record<string, unknown>).size = val;\n }\n }\n const rFonts = findChild(rPr, \"w:rFonts\");\n if (rFonts) {\n const ascii = attr(rFonts, \"w:ascii\");\n if (ascii) {\n if (!style.run) style.run = {};\n (style.run as Record<string, unknown>).font = ascii;\n }\n }\n if (Object.keys(style).length > 0) opts.style = style;\n }\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const style = (opts.style as Record<string, unknown>) ?? {};\n const paraStyle: Record<string, unknown> = {};\n\n const ind = findChild(pPr, \"w:ind\");\n if (ind) {\n const indent: Record<string, unknown> = {};\n const left = attrNum(ind, \"w:left\");\n if (left !== undefined) indent.left = left;\n const hanging = attrNum(ind, \"w:hanging\");\n if (hanging !== undefined) indent.hanging = hanging;\n if (Object.keys(indent).length > 0) paraStyle.indent = indent;\n }\n\n if (Object.keys(paraStyle).length > 0) {\n style.paragraph = paraStyle;\n opts.style = style;\n }\n }\n\n return Object.keys(opts).length > 0 ? (opts as unknown as LevelsOptions) : undefined;\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\";\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:math\", \"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 if (c) opts.color = c;\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: Record<string, string | undefined> = {};\n const val = attr(lang, \"w:val\");\n if (val) langObj.val = 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.bidi = 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 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// ── 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 children: ParsedRunChild[];\n} {\n const rPr = findChild(el, \"w:rPr\");\n const properties = rPr ? parseRunProperties(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, 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\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 * 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 { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport type {\n DefaultStylesOptions,\n BaseParagraphStyleOptions,\n BaseCharacterStyleOptions,\n} from \"@parts/styles/factory\";\nimport { stringifyParagraphStyle, stringifyCharacterStyle } from \"@parts/styles/factory\";\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\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/**\n * Parse w:styles element into StylesOptions-like structure.\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: any) => Record<string, unknown>,\n ctx: any,\n): Record<string, unknown> | undefined {\n const opts: Record<string, unknown> = {};\n const paragraphStyles: Record<string, unknown>[] = [];\n const characterStyles: Record<string, unknown>[] = [];\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:docDefaults\") {\n const defOpts = parseDocDefaults(child);\n if (defOpts) opts.default = defOpts;\n } else if (child.name === \"w:style\") {\n const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);\n if (!styleOpts) continue;\n\n const styleId = styleOpts.id as string | undefined;\n if (styleId && BUILTIN_STYLE_IDS.has(styleId)) continue;\n\n const type = styleOpts._type as string | undefined;\n delete styleOpts._type;\n\n if (type === \"paragraph\") {\n paragraphStyles.push(styleOpts);\n } else if (type === \"character\") {\n characterStyles.push(styleOpts);\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(el: Element): Record<string, unknown> | undefined {\n const result: Record<string, unknown> = {};\n const docDefaults: Record<string, unknown> = {};\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) docDefaults.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 const paraDefaults: Record<string, unknown> = {};\n const spacing = findChild(pPr, \"w:spacing\");\n if (spacing) {\n const sp: Record<string, unknown> = {};\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 if (Object.keys(sp).length > 0) paraDefaults.spacing = sp;\n }\n if (Object.keys(paraDefaults).length > 0) docDefaults.paragraph = paraDefaults;\n }\n }\n\n if (Object.keys(docDefaults).length > 0) result.document = docDefaults;\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\nfunction parseStyleElement(\n el: Element,\n parseParagraphProperties: (el: Element, ctx: unknown) => Record<string, unknown>,\n ctx: unknown,\n): (Record<string, unknown> & { _type?: string }) | undefined {\n const opts: Record<string, unknown> & { _type?: string } = {};\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 const isDefault = attrBool(el, \"w:default\");\n if (isDefault) opts.default = true;\n\n const customStyle = attrBool(el, \"w:customStyle\");\n if (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) opts.paragraph = paraOpts;\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, findChild } from \"@office-open/xml\";\n\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\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 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 — always present with default\n p.push(numVal(\"w:defaultTabStop\", opts.defaultTabStop ?? 420)!);\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 — always present with default\n p.push(\n strVal(\"w:characterSpacingControl\", opts.characterSpacingControl ?? \"compressPunctuation\")!,\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 — always present with defaults\n p.push(\n stringifyCompatibility({\n ...opts.compatibility,\n version: opts.compatibility?.version ?? opts.compatibilityModeVersion ?? 15,\n spaceForUnderline: opts.compatibility?.spaceForUnderline ?? true,\n balanceSingleByteDoubleByteWidth:\n opts.compatibility?.balanceSingleByteDoubleByteWidth ?? true,\n doNotLeaveBackslashAlone: opts.compatibility?.doNotLeaveBackslashAlone ?? true,\n underlineTrailingSpaces: opts.compatibility?.underlineTrailingSpaces ?? true,\n doNotExpandShiftReturn: opts.compatibility?.doNotExpandShiftReturn ?? true,\n adjustLineHeightInTable: opts.compatibility?.adjustLineHeightInTable ?? true,\n useFELayout: opts.compatibility?.useFELayout ?? true,\n overrideTableStyleFontSizeAndJustification:\n opts.compatibility?.overrideTableStyleFontSizeAndJustification ?? true,\n enableOpenTypeFeatures: opts.compatibility?.enableOpenTypeFeatures ?? true,\n doNotFlipMirrorIndents: opts.compatibility?.doNotFlipMirrorIndents ?? true,\n }),\n );\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 (presence)\n if (findChild(el, \"w:trackRevisions\")) {\n const features = (opts.features as Record<string, unknown>) ?? {};\n features.trackRevisions = true;\n opts.features = features;\n }\n\n // features.updateFields → w:updateFields (presence)\n if (findChild(el, \"w:updateFields\")) {\n const features = (opts.features as Record<string, unknown>) ?? {};\n features.updateFields = 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\n const docProtEl = findChild(el, \"w:documentProtection\");\n if (docProtEl) {\n const prot: Record<string, unknown> = {};\n const edit = attr(docProtEl, \"w:edit\");\n if (edit) prot.edit = edit;\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) opts.documentProtection = prot;\n }\n\n // doNotTrackMoves → w:doNotTrackMoves (presence)\n if (findChild(el, \"w:doNotTrackMoves\")) {\n opts.doNotTrackMoves = true;\n }\n\n // doNotTrackFormatting → w:doNotTrackFormatting (presence)\n if (findChild(el, \"w:doNotTrackFormatting\")) {\n opts.doNotTrackFormatting = true;\n }\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 * 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}\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 { TableOfContentsOptions } 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 (\"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 * 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","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 & { fontKey: string };\n\n/**\n * Wrapper class for managing embedded font relationships.\n *\n * Each 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 this.fontOptionsWithKey = options.map((o) => ({ ...o, fontKey: uniqueUuid() }));\n this.relationships = new Relationships();\n\n for (let i = 0; i < options.length; i++) {\n this.relationships.addRelationship(\n i + 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font\",\n `fonts/${options[i].name}.odttf`,\n );\n }\n }\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 * 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 { attr, attrBool, attrNum, escapeXml, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { sectionPropertiesDesc } from \"@parts/document/body/section-properties/descriptor\";\nimport type { DocumentBackgroundOptions } from \"@parts/document/document-background\";\nimport { parseDrawingRun } from \"@parts/drawing/drawing-parse\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport { HeadingLevel } from \"@parts/paragraph/formatting/style\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { RunOptions } from \"@parts/paragraph/run/run\";\nimport { parseRun, parseRunProperties, parsedRunToOptions } from \"@parts/paragraph/run/run-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 { SectionChild } from \"@shared/section\";\n\nimport type { DocxReadContext, DocxWriteContext, BodyContext } from \"./context\";\nimport { tableDesc, altChunkDesc, subDocDesc, sdtBlockDesc, customXmlBlockDesc } from \"./parts\";\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\";\n\nexport type { BodyContext } from \"./context\";\n\n// ── Run ──\n\n/**\n * Mapping from empty child property name to self-closing XML element.\n *\n * These are single-key objects like `{ noBreakHyphen: true }` that map to\n * self-closing XML elements with no attributes.\n *\n * XSD reference: EG_RunInnerContent group in wml.xsd.\n */\nconst EMPTY_RUN_ELEMENTS: Record<string, string> = {\n noBreakHyphen: \"<w:noBreakHyphen/>\",\n softHyphen: \"<w:softHyphen/>\",\n dayShort: \"<w:dayShort/>\",\n monthShort: \"<w:monthShort/>\",\n yearShort: \"<w:yearShort/>\",\n dayLong: \"<w:dayLong/>\",\n monthLong: \"<w:monthLong/>\",\n yearLong: \"<w:yearLong/>\",\n annotationRef: \"<w:annotationRef/>\",\n footnoteRef: \"<w:footnoteRef/>\",\n endnoteRef: \"<w:endnoteRef/>\",\n separator: \"<w:separator/>\",\n continuationSeparator: \"<w:continuationSeparator/>\",\n pgNum: \"<w:pgNum/>\",\n carriageReturn: \"<w:cr/>\",\n lastRenderedPageBreak: \"<w:lastRenderedPageBreak/>\",\n};\n\n/**\n * Stringify a run (w:r) from pure JSON options.\n *\n * Handles text, children, breaks, and run properties.\n */\nexport function stringifyRun(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n // Pre-scan children for commentReference — needs CommentReference style in rPr\n let commentRefStyle = false;\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"object\" && child !== null && \"commentReference\" in child) {\n commentRefStyle = true;\n break;\n }\n }\n }\n\n // Run properties — inject CommentReference style if needed\n const runOpts = commentRefStyle ? { ...opts, style: \"CommentReference\" as const } : opts;\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n // Breaks\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 if (\"text\" in child || \"children\" in child || \"break\" in child) {\n // RunOptions-like plain object\n parts.push(stringifyRun(child, ctx));\n } else {\n throw new Error(`Unsupported paragraph child type: ${Object.keys(child).join(\", \")}`);\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 (\"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 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/**\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: Record<string, unknown> = {};\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) sp.lineRule = lineRule;\n const beforeAuto =\n attrBool(spacing, \"w:beforeAutospacing\") ?? attrBool(spacing, \"w:beforeLines\");\n if (beforeAuto !== undefined) sp.beforeAutoSpacing = beforeAuto;\n const afterAuto = attrBool(spacing, \"w:afterAutospacing\") ?? attrBool(spacing, \"w:afterLines\");\n if (afterAuto !== undefined) sp.afterAutoSpacing = afterAuto;\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: Record<string, unknown> = {};\n const left = attrNum(ind, \"w:left\");\n if (left !== undefined) indentObj.left = left;\n const right = attrNum(ind, \"w:right\");\n if (right !== undefined) indentObj.right = right;\n const start = attrNum(ind, \"w:start\");\n if (start !== undefined) indentObj.start = start;\n const end = attrNum(ind, \"w:end\");\n if (end !== undefined) indentObj.end = end;\n const hanging = attrNum(ind, \"w:hanging\");\n if (hanging !== undefined) indentObj.hanging = hanging;\n const firstLine = attrNum(ind, \"w:firstLine\");\n if (firstLine !== undefined) indentObj.firstLine = firstLine;\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: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: Record<string, unknown> = {};\n for (const side of [\"top\", \"bottom\", \"left\", \"right\"] as const) {\n const sideEl = findChild(pBdr, `w:${side}`);\n if (sideEl) {\n const sideOpts: Record<string, unknown> = {};\n const style = attr(sideEl, \"w:val\");\n if (style) sideOpts.style = 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 border[side] = sideOpts;\n }\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 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 * Parse a w:p element into ParagraphOptions.\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 // Parse children\n const childList: unknown[] = [];\n\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:pPr\":\n break;\n case \"w:r\": {\n const drawingEl = findChild(child, \"w:drawing\");\n if (drawingEl) {\n const drawingChild = parseDrawingRun(drawingEl, ctx);\n if (drawingChild) {\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 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 default:\n break;\n }\n }\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 * 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 * 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 */\nfunction 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 }\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 * 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 * AltChunk collection module for managing alternative format content parts.\n *\n * @module\n */\n\n/**\n * Stores alternative format chunk data for later serialization by the compiler.\n */\nexport interface AltChunkData {\n /** Unique key for this alt chunk (e.g., relId) */\n key: string;\n /** Raw content data */\n data: Uint8Array;\n /** Part sub-path within word/ (e.g., \"afchunks/afchunk1.html\") */\n path: string;\n /** File extension (e.g., \"html\", \"rtf\", \"txt\") */\n extension: string;\n /** MIME content type (e.g., \"text/html\", \"application/rtf\") */\n contentType: string;\n}\n\n/**\n * Manages alternative format chunk parts in a document.\n *\n * Stores external content (HTML, RTF, plain text) that will be\n * serialized into separate parts in the DOCX package.\n */\nexport class AltChunkCollection {\n private map: Map<string, AltChunkData>;\n\n public constructor() {\n this.map = new Map<string, AltChunkData>();\n }\n\n public addAltChunk(key: string, data: AltChunkData): void {\n this.map.set(key, data);\n }\n\n public get array(): AltChunkData[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Sub-document collection module for managing sub-document parts.\n *\n * @module\n */\n\n/**\n * Stores sub-document data for later serialization by the compiler.\n */\nexport interface SubDocData {\n /** Raw document data (.docx bytes) */\n data: Uint8Array;\n /** Part sub-path within word/ (e.g., \"subdocs/subdoc1.docx\") */\n path: string;\n}\n\n/**\n * Manages sub-document parts in a document.\n */\nexport class SubDocCollection {\n private map: Map<string, SubDocData>;\n\n public constructor() {\n this.map = new Map<string, SubDocData>();\n }\n\n public addSubDoc(key: string, data: SubDocData): void {\n this.map.set(key, data);\n }\n\n public get array(): SubDocData[] {\n return [...this.map.values()];\n }\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 { 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 = {\n usb0: \"E0002AFF\",\n usb1: \"C000247B\",\n usb2: \"00000009\",\n usb3: \"00000000\",\n csb0: \"000001FF\",\n csb1: \"00000000\",\n};\n\nfunction fontXml(font: EmbeddedFontOptionsWithKey, index: number): string {\n const parts: string[] = [`<w:font w:name=\"${escapeXml(font.name)}\">`];\n\n // Default charset, family, pitch, sig for regular embedded font\n if (font.characterSet) {\n parts.push(`<w:charset w:val=\"${escapeXml(font.characterSet)}\"/>`);\n }\n parts.push(`<w:family w:val=\"auto\"/>`);\n parts.push(`<w:pitch w:val=\"variable\"/>`);\n parts.push(\n `<w:sig w:usb0=\"${DEFAULT_SIG.usb0}\" w:usb1=\"${DEFAULT_SIG.usb1}\" ` +\n `w:usb2=\"${DEFAULT_SIG.usb2}\" w:usb3=\"${DEFAULT_SIG.usb3}\" ` +\n `w:csb0=\"${DEFAULT_SIG.csb0}\" w:csb1=\"${DEFAULT_SIG.csb1}\"/>`,\n );\n // Embedded regular font\n parts.push(`<w:embedRegular r:id=\"rId${index + 1}\" w:fontKey=\"{${font.fontKey}}\"/>`);\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 (let i = 0; i < opts.fonts.length; i++) {\n parts.push(fontXml(opts.fonts[i], i));\n }\n parts.push(\"</w:fonts>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const fonts: Record<string, unknown>[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:font\") continue;\n const font: Record<string, unknown> = {};\n const name = child.attributes?.[\"w:name\"];\n if (name) font.name = String(name);\n\n // charset → w:charset/@w:val\n const charsetEl = findChild(child, \"w:charset\");\n if (charsetEl) {\n const val = attr(charsetEl, \"w:val\");\n if (val) font.characterSet = val;\n }\n\n // family → w:family/@w:val\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 // pitch → w:pitch/@w:val\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 // sig → w:sig attributes\n const sigEl = findChild(child, \"w:sig\");\n if (sigEl) {\n const sig: Record<string, string> = {};\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.keys(sig).length > 0) font.sig = sig;\n }\n\n // fontKey → w:embedRegular/@w:fontKey (strip curly braces)\n for (const embedTag of [\n \"w:embedRegular\",\n \"w:embedBold\",\n \"w:embedItalic\",\n \"w:embedBoldItalic\",\n ] as const) {\n const embedEl = findChild(child, embedTag);\n if (embedEl) {\n const rawKey = attr(embedEl, \"w:fontKey\");\n if (rawKey) {\n // Strip wrapping curly braces: {{...}} → ...\n font.fontKey = rawKey.replace(/^\\{\\{|\\}\\}$/g, \"\").replace(/^\\{|\\}$/g, \"\");\n }\n break; // Use first embed element found\n }\n }\n\n fonts.push(font);\n }\n return { fonts } as unknown as FontTableInput;\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/** 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 hasGlossary?: boolean;\n hasWebSettings?: boolean;\n altChunks?: { path: string; contentType: string }[];\n subDocs?: { path: string }[];\n } = {},\n): ContentTypesInput {\n const 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 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 {\n partName: \"/word/comments.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\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","/**\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 { SubDocOptions } from \"@parts/sub-doc/sub-doc\";\nimport type { 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}\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\nfunction 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 }\n\n return parts.length ? `<w:sdtPr>${parts.join(\"\")}</w:sdtPr>` : \"<w:sdtPr/>\";\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 }\n\n return opts as SdtPropertiesOptions;\n}\n\n/** Parse w:customXmlPr element into CustomXmlPrOptions. */\nfunction 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 parts.push(\"<w:sdtEndPr/>\");\n\n // sdtContent — serialize children directly (no coerce needed)\n 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 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 } 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\nexport const customXmlBlockDesc: CustomDescriptor<CustomXmlBlockDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const attrs: string[] = [`w:element=\"${escapeAttr(opts.element)}\"`];\n if (opts.uri !== undefined) attrs.push(`w:uri=\"${escapeAttr(opts.uri)}\"`);\n const parts: string[] = [`<w:customXml ${attrs.join(\" \")}>`];\n\n if (opts.customXmlPr) {\n parts.push(buildCustomXmlPrXml(opts.customXmlPr));\n }\n\n if (opts.children) {\n for (const child of opts.children) {\n parts.push(ctx.stringifyChild(child, ctx));\n }\n }\n\n parts.push(\"</w:customXml>\");\n return parts.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","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 { 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 * 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 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 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?: {\n trackRevisions?: boolean;\n updateFields?: boolean;\n documentProtection?: DocumentProtectionOptions;\n };\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\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}\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 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: Record<string, unknown> = {};\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 }\n }\n return result as Record<string, unknown>;\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 * 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","/**\n * External styles factory module for WordprocessingML documents.\n *\n * Parses styles from external XML and returns raw XML strings.\n * No XmlComponent dependency.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport { js2xml, xml2js } from \"@office-open/xml\";\nimport type { Element as XMLElement } from \"@office-open/xml\";\n\nimport type { StylesOptions } from \"./styles\";\n\n/**\n * Factory for creating styles from external XML sources.\n *\n * Parses styles from XML (typically from a styles.xml file)\n * and returns raw XML strings for each style element.\n */\nexport class ExternalStylesFactory {\n /**\n * Creates new Styles based on the given XML data.\n *\n * Parses the styles XML and converts each child to a raw XML string.\n */\n public newInstance(xmlData: string): StylesOptions {\n const xmlObj = xml2js(xmlData, { compact: false }) as XMLElement;\n\n let stylesXmlElement: XMLElement | undefined;\n for (const xmlElm of xmlObj.elements || []) {\n if (xmlElm.name === \"w:styles\") {\n stylesXmlElement = xmlElm;\n }\n }\n\n if (stylesXmlElement === undefined) {\n return { importedStyles: [], initialAttributes: {} };\n }\n\n const stylesElements = stylesXmlElement.elements || [];\n\n return {\n importedStyles: stylesElements.map((childElm) => ({\n _raw: js2xml({ elements: [childElm] }),\n })),\n initialAttributes: (stylesXmlElement.attributes as Record<string, string>) ?? {},\n };\n }\n}\n","/**\n * DOCX compilation context.\n *\n * DocxWriteContext holds all mutable state needed during document compilation.\n * generateDocument() creates a DocxWriteContext internally.\n *\n * @module\n */\n\nimport { Relationships } from \"@office-open/core\";\nimport { ChartCollection } from \"@office-open/core/chart\";\nimport type { ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport { SmartArtCollection } from \"@office-open/core/smartart\";\nimport type { Element } from \"@office-open/xml\";\nimport { AltChunkCollection } from \"@parts/alt-chunk/alt-chunk-collection\";\nimport type { DocumentOptions } from \"@parts/core-properties\";\nimport type { SectionPropertiesOptions } from \"@parts/document/body/section-properties/section-properties\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport type { GlossaryDocumentOptions } from \"@parts/glossary-document\";\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport { Numbering } from \"@parts/numbering\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { SettingsOptions } from \"@parts/settings/settings\";\nimport { Styles } from \"@parts/styles\";\nimport { ExternalStylesFactory } from \"@parts/styles/external-styles-factory\";\nimport { DefaultStylesFactory } from \"@parts/styles/factory\";\nimport { SubDocCollection } from \"@parts/sub-doc/sub-doc-collection\";\nimport type { WebSettingsOptions } from \"@parts/web-settings\";\nimport { Media } from \"@shared/media\";\nimport type { SectionOptions } from \"@shared/section\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxDocument } from \"./parse\";\n\n/** Interface for document view wrappers — provides relationships access. */\nexport interface ViewWrapper {\n relationships: Relationships;\n}\n\n// ── BodyContext ──\n\n/**\n * Context for body-level stringification.\n *\n * Pure JSON pipeline context — extends WriteContext for descriptor compatibility.\n * No dependency on XmlComponent Context (compile/ uses zero toXml calls).\n */\nexport interface BodyContext extends WriteContext {\n /** The root write context with all mutable document state. */\n fileData: DocxWriteContext;\n /** Alias for fileData — some descriptor internals access context.file. */\n file: DocxWriteContext;\n /** Current view wrapper for relationship access. */\n viewWrapper: { relationships: Relationships };\n /** Stringify a body-level child element — injected to break circular imports. */\n stringifyChild: (child: SectionChild, ctx: BodyContext) => string;\n}\n\n// ── DocxWriteContext ──\n\nexport class DocxWriteContext implements WriteContext {\n private _currentRelationshipId = 1;\n\n // --- Accessed by XmlComponent via context.file.* during toXml() ---\n declare public document: { relationships: Relationships };\n declare public numbering: Numbering;\n declare public media: Media;\n declare public charts: ChartCollection;\n declare public smartArts: SmartArtCollection;\n declare public altChunks: AltChunkCollection;\n declare public subDocs: SubDocCollection;\n declare public comments: { relationships: Relationships };\n declare public footNotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n };\n declare public endnotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n };\n\n // --- Additional state used by the compiler ---\n declare public fileRelationships: Relationships;\n declare public _settingsOptions: SettingsOptions;\n declare public styles: Styles;\n declare public fontTable: FontWrapper;\n declare public glossaryOptions: GlossaryDocumentOptions | undefined;\n declare public webSettings: WebSettingsOptions | undefined;\n\n // --- Section properties (one per section, raw options for descriptor pipeline) ---\n private _sectionProperties: SectionPropertiesOptions[] = [];\n public get sectionProperties(): readonly SectionPropertiesOptions[] {\n return this._sectionProperties;\n }\n\n // --- WriteContext interface (core descriptor pipeline) ---\n\n public addRelationship(_type: string, _target: string, _mode?: string): string {\n const id = this._currentRelationshipId++;\n return `rId${id}`;\n }\n\n public addMedia(_data: Uint8Array, _type: string): string {\n // DOCX media registration goes through Media.addImage() in compiler.\n return \"\";\n }\n\n // --- Internal tracking ---\n private _headers: HeaderFooterEntry[] = [];\n private _footers: HeaderFooterEntry[] = [];\n\n // --- Original input preserved for descriptor usage ---\n declare public _options: DocumentOptions;\n\n constructor(options: DocumentOptions) {\n this._options = options;\n\n this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });\n\n this.comments = { relationships: new Relationships() };\n this.fileRelationships = new Relationships();\n this.footNotes = { relationships: new Relationships(), notes: new Map() };\n this.endnotes = { relationships: new Relationships(), notes: new Map() };\n this.document = { relationships: new Relationships() };\n this._settingsOptions = {\n compatibility: options.compatibility,\n compatibilityModeVersion: options.compatabilityModeVersion,\n defaultTabStop: options.defaultTabStop,\n evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,\n characterSpacingControl: options.characterSpacingControl,\n hyphenation: {\n autoHyphenation: options.hyphenation?.autoHyphenation,\n consecutiveHyphenLimit: options.hyphenation?.consecutiveHyphenLimit,\n doNotHyphenateCaps: options.hyphenation?.doNotHyphenateCaps,\n hyphenationZone: options.hyphenation?.hyphenationZone,\n },\n trackRevisions: options.features?.trackRevisions,\n updateFields: options.features?.updateFields,\n documentProtection: options.features?.documentProtection,\n view: options.view,\n zoom: options.zoom,\n writeProtection: options.writeProtection,\n displayBackgroundShape:\n options.displayBackgroundShape ?? (options.background?.image ? true : undefined),\n embedTrueTypeFonts: options.embedTrueTypeFonts,\n embedSystemFonts: options.embedSystemFonts,\n saveSubsetFonts: options.saveSubsetFonts,\n docVars: options.docVars,\n colorSchemeMapping: options.colorSchemeMapping,\n mailMerge: options.mailMerge,\n ...options.settings,\n };\n\n this.media = new Media();\n this.charts = new ChartCollection();\n this.smartArts = new SmartArtCollection();\n this.altChunks = new AltChunkCollection();\n this.subDocs = new SubDocCollection();\n\n if (options.externalStyles !== undefined) {\n const defaultFactory = new DefaultStylesFactory();\n const defaultStyles = defaultFactory.newInstance(options.styles?.default);\n const externalFactory = new ExternalStylesFactory();\n const externalStyles = externalFactory.newInstance(options.externalStyles);\n // Skip docDefaults AND latentStyles from default factory —\n // external styles already provide them; XSD requires docDefaults → latentStyles → style sequence\n const defaultStyleElements = defaultStyles.importedStyles!.slice(2);\n this.styles = new Styles({\n ...externalStyles,\n importedStyles: [...externalStyles.importedStyles!, ...defaultStyleElements],\n });\n } else if (options.styles) {\n const stylesFactory = new DefaultStylesFactory();\n const defaultStyles = stylesFactory.newInstance(options.styles.default);\n this.styles = new Styles({\n ...defaultStyles,\n ...options.styles,\n });\n } else {\n const stylesFactory = new DefaultStylesFactory();\n this.styles = new Styles(stylesFactory.newInstance());\n }\n\n // Register numbering references from custom paragraph/character styles.\n // Style definitions may contain numbering properties whose concrete instances\n // are never created through the body paragraph processing path.\n if (options.styles?.paragraphStyles) {\n for (const style of options.styles.paragraphStyles) {\n const num = style.paragraph?.numbering;\n if (num) {\n this.numbering.createConcreteNumberingInstance(num.reference, num.instance ?? 0);\n }\n }\n }\n\n this.addDefaultRelationships();\n\n for (const section of options.sections) {\n this.addSection(section);\n }\n\n if (options.footnotes) {\n for (const key in options.footnotes) {\n this.footNotes.notes.set(parseFloat(key), options.footnotes[key].children);\n }\n }\n\n if (options.endnotes) {\n for (const key in options.endnotes) {\n this.endnotes.notes.set(parseFloat(key), options.endnotes[key].children);\n }\n }\n\n this.fontTable = new FontWrapper(options.fonts ?? []);\n this.glossaryOptions = options.glossary;\n this.webSettings = options.webSettings ?? undefined;\n\n if (options.glossary) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument\",\n \"glossary/document.xml\",\n );\n }\n\n if (this.webSettings) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\",\n \"webSettings.xml\",\n );\n }\n }\n\n get headers(): HeaderFooterEntry[] {\n return this._headers;\n }\n\n get footers(): HeaderFooterEntry[] {\n return this._footers;\n }\n\n // --- Private helpers ---\n\n private addSection({ headers = {}, footers = {}, properties }: SectionOptions): void {\n const sectPrOptions: SectionPropertiesOptions = {\n ...properties,\n footerWrapperGroup: {\n default: footers.default ? this.createFooter(footers.default) : undefined,\n even: footers.even ? this.createFooter(footers.even) : undefined,\n first: footers.first ? this.createFooter(footers.first) : undefined,\n },\n headerWrapperGroup: {\n default: headers.default ? this.createHeader(headers.default) : undefined,\n even: headers.even ? this.createHeader(headers.even) : undefined,\n first: headers.first ? this.createHeader(headers.first) : undefined,\n },\n };\n this._sectionProperties.push(sectPrOptions);\n }\n\n private createHeader(header: SectionChild[]): HeaderFooterEntry {\n const referenceId = this._currentRelationshipId++;\n const entry: HeaderFooterEntry = {\n children: header,\n relationships: new Relationships(),\n referenceId,\n };\n this.addHeaderToDocument(entry);\n return entry;\n }\n\n private createFooter(footer: SectionChild[]): HeaderFooterEntry {\n const referenceId = this._currentRelationshipId++;\n const entry: HeaderFooterEntry = {\n children: footer,\n relationships: new Relationships(),\n referenceId,\n };\n this.addFooterToDocument(entry);\n return entry;\n }\n\n private addHeaderToDocument(header: HeaderFooterEntry): void {\n this._headers.push(header);\n this.document.relationships.addRelationship(\n header.referenceId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header\",\n `header${this._headers.length}.xml`,\n );\n }\n\n private addFooterToDocument(footer: HeaderFooterEntry): void {\n this._footers.push(footer);\n this.document.relationships.addRelationship(\n footer.referenceId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer\",\n `footer${this._footers.length}.xml`,\n );\n }\n\n private addDefaultRelationships(): void {\n this.fileRelationships.addRelationship(\n 1,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\",\n \"word/document.xml\",\n );\n this.fileRelationships.addRelationship(\n 2,\n \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\",\n \"docProps/core.xml\",\n );\n this.fileRelationships.addRelationship(\n 3,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\",\n \"docProps/app.xml\",\n );\n this.fileRelationships.addRelationship(\n 4,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties\",\n \"docProps/custom.xml\",\n );\n\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\",\n \"styles.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering\",\n \"numbering.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes\",\n \"footnotes.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes\",\n \"endnotes.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\",\n \"settings.xml\",\n );\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\",\n \"comments.xml\",\n );\n if (this._options.bibliography) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography\",\n \"bibliography.xml\",\n );\n }\n }\n}\n\n// ── DocxReadContext ──\n\n/**\n * DOCX-specific read context.\n *\n * Holds references to the parsed DocxDocument and cached style/numbering data\n * used throughout the DOCX parsing pipeline. Implements ReadContext for\n * descriptor pipeline compatibility.\n */\nexport class DocxReadContext implements ReadContext {\n constructor(\n public docx: DocxDocument,\n public styleCache: Map<string, Element>,\n public numberingCache: Map<string, Element>,\n ) {}\n\n resolveRelationship(rId: string): string | undefined {\n return (\n this.docx.partRefs.headers.get(rId) ??\n this.docx.partRefs.footers.get(rId) ??\n this.docx.partRefs.media.get(rId) ??\n this.docx.partRefs.charts.get(rId) ??\n this.docx.partRefs.diagramData.get(rId) ??\n this.docx.partRefs.afChunks.get(rId) ??\n this.docx.partRefs.subDocs.get(rId) ??\n this.docx.partRefs.hyperlinks.get(rId)\n );\n }\n\n getPart(path: string): Element | undefined {\n return this.docx.doc.get(path);\n }\n\n getRaw(path: string): Uint8Array | undefined {\n return this.docx.doc.getRaw(path);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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