@office-open/docx 0.10.14 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -17
- package/dist/index.d.mts +3774 -33
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +16469 -530
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -34
- package/dist/chart.d.mts +0 -1
- package/dist/chart.mjs +0 -2
- package/dist/comments-Cn9Q0iT6.mjs +0 -8509
- package/dist/comments-Cn9Q0iT6.mjs.map +0 -1
- package/dist/context-B5k1UabT.mjs +0 -4530
- package/dist/context-B5k1UabT.mjs.map +0 -1
- package/dist/core-properties-C4tdD3KL.d.mts +0 -4004
- package/dist/core-properties-C4tdD3KL.d.mts.map +0 -1
- package/dist/document-attributes-C6PDT-ap.mjs +0 -60
- package/dist/document-attributes-C6PDT-ap.mjs.map +0 -1
- package/dist/drawingml.d.mts +0 -1
- package/dist/drawingml.mjs +0 -2
- package/dist/generate-BxIo24VV.mjs +0 -535
- package/dist/generate-BxIo24VV.mjs.map +0 -1
- package/dist/generate.d.mts +0 -10
- package/dist/generate.d.mts.map +0 -1
- package/dist/generate.mjs +0 -2
- package/dist/parse-ep7JKATJ.mjs +0 -2115
- package/dist/parse-ep7JKATJ.mjs.map +0 -1
- package/dist/parse.d.mts +0 -2
- package/dist/parse.mjs +0 -2
- package/dist/patch/index.d.mts +0 -47
- package/dist/patch/index.d.mts.map +0 -1
- package/dist/patch/index.mjs +0 -416
- package/dist/patch/index.mjs.map +0 -1
- package/dist/smartart.d.mts +0 -1
- package/dist/smartart.mjs +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-B5k1UabT.mjs","names":["NS","NS"],"sources":["../src/parts/paragraph/formatting/alignment.ts","../src/parts/numbering/level.ts","../src/parts/numbering/numbering.ts","../src/parts/styles/factory.ts","../src/parts/styles/styles.ts","../src/parts/settings/descriptor.ts","../src/parts/footnotes/descriptor.ts","../src/parts/endnotes/descriptor.ts","../src/parts/alt-chunk/alt-chunk-collection.ts","../src/parts/sub-doc/sub-doc-collection.ts","../src/parts/fonts/descriptor.ts","../src/parts/bibliography.ts","../src/parts/glossary-document.ts","../src/parts/contenttypes.ts","../src/parts/core-properties.ts","../src/parts/web-settings.ts","../src/parts/styles/external-styles-factory.ts","../src/shared/embeddings/embeddings.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 * Numbering level definitions module for WordprocessingML documents.\n *\n * This module defines the formatting and behavior of individual levels within\n * a numbered or bulleted list hierarchy.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @module\n */\nimport type { AlignmentType } from \"../paragraph/formatting\";\nimport type { LevelParagraphStylePropertiesOptions } from \"../paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"../paragraph/run/properties\";\n\n/**\n * Number format types for list levels.\n *\n * Defines the various numbering formats available for list levels, including\n * decimal, roman numerals, letters, and various international formats.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const LevelFormat = {\n /** Decimal numbering (1, 2, 3...). */\n DECIMAL: \"decimal\",\n /** Uppercase roman numerals (I, II, III...). */\n UPPER_ROMAN: \"upperRoman\",\n /** Lowercase roman numerals (i, ii, iii...). */\n LOWER_ROMAN: \"lowerRoman\",\n /** Uppercase letters (A, B, C...). */\n UPPER_LETTER: \"upperLetter\",\n /** Lowercase letters (a, b, c...). */\n LOWER_LETTER: \"lowerLetter\",\n /** Ordinal numbers (1st, 2nd, 3rd...). */\n ORDINAL: \"ordinal\",\n /** Cardinal text (one, two, three...). */\n CARDINAL_TEXT: \"cardinalText\",\n /** Ordinal text (first, second, third...). */\n ORDINAL_TEXT: \"ordinalText\",\n /** Hexadecimal numbering. */\n HEX: \"hex\",\n /** Chicago Manual of Style numbering. */\n CHICAGO: \"chicago\",\n /** Ideograph digital numbering. */\n IDEOGRAPH__DIGITAL: \"ideographDigital\",\n /** Japanese counting system. */\n JAPANESE_COUNTING: \"japaneseCounting\",\n /** Japanese aiueo ordering. */\n AIUEO: \"aiueo\",\n /** Japanese iroha ordering. */\n IROHA: \"iroha\",\n /** Full-width decimal numbering. */\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n /** Half-width decimal numbering. */\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n /** Japanese legal numbering. */\n JAPANESE_LEGAL: \"japaneseLegal\",\n /** Japanese digital ten thousand numbering. */\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n /** Decimal numbers enclosed in circles. */\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n /** Full-width decimal numbering variant 2. */\n DECIMAL_FULL_WIDTH2: \"decimalFullWidth2\",\n /** Full-width aiueo ordering. */\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n /** Full-width iroha ordering. */\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n /** Decimal with leading zeros. */\n DECIMAL_ZERO: \"decimalZero\",\n /** Bullet points. */\n BULLET: \"bullet\",\n /** Korean ganada ordering. */\n GANADA: \"ganada\",\n /** Korean chosung ordering. */\n CHOSUNG: \"chosung\",\n /** Decimal enclosed with fullstop. */\n DECIMAL_ENCLOSED_FULLSTOP: \"decimalEnclosedFullstop\",\n /** Decimal enclosed in parentheses. */\n DECIMAL_ENCLOSED_PARENTHESES: \"decimalEnclosedParen\",\n /** Decimal enclosed in circles (Chinese). */\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n /** Ideograph enclosed in circles. */\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n /** Traditional ideograph numbering. */\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n /** Ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n /** Traditional ideograph zodiac numbering. */\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n /** Taiwanese counting system. */\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n /** Traditional ideograph legal numbering. */\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n /** Taiwanese counting thousand system. */\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n /** Taiwanese digital numbering. */\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n /** Chinese counting system. */\n CHINESE_COUNTING: \"chineseCounting\",\n /** Simplified Chinese legal numbering. */\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n /** Chinese counting thousand system. */\n CHINESE_COUNTING_THOUSAND: \"chineseCountingThousand\",\n /** Korean digital numbering. */\n KOREAN_DIGITAL: \"koreanDigital\",\n /** Korean counting system. */\n KOREAN_COUNTING: \"koreanCounting\",\n /** Korean legal numbering. */\n KOREAN_LEGAL: \"koreanLegal\",\n /** Korean digital numbering variant 2. */\n KOREAN_DIGITAL2: \"koreanDigital2\",\n /** Vietnamese counting system. */\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n /** Russian lowercase numbering. */\n RUSSIAN_LOWER: \"russianLower\",\n /** Russian uppercase numbering. */\n RUSSIAN_UPPER: \"russianUpper\",\n /** No numbering. */\n NONE: \"none\",\n /** Number enclosed in dashes. */\n NUMBER_IN_DASH: \"numberInDash\",\n /** Hebrew numbering variant 1. */\n HEBREW1: \"hebrew1\",\n /** Hebrew numbering variant 2. */\n HEBREW2: \"hebrew2\",\n /** Arabic alpha numbering. */\n ARABIC_ALPHA: \"arabicAlpha\",\n /** Arabic abjad numbering. */\n ARABIC_ABJAD: \"arabicAbjad\",\n /** Hindi vowels. */\n HINDI_VOWELS: \"hindiVowels\",\n /** Hindi consonants. */\n HINDI_CONSONANTS: \"hindiConsonants\",\n /** Hindi numbers. */\n HINDI_NUMBERS: \"hindiNumbers\",\n /** Hindi counting system. */\n HINDI_COUNTING: \"hindiCounting\",\n /** Thai letters. */\n THAI_LETTERS: \"thaiLetters\",\n /** Thai numbers. */\n THAI_NUMBERS: \"thaiNumbers\",\n /** Thai counting system. */\n THAI_COUNTING: \"thaiCounting\",\n /** Thai Baht text. */\n BAHT_TEXT: \"bahtText\",\n /** Dollar text. */\n DOLLAR_TEXT: \"dollarText\",\n /** Custom numbering format. */\n CUSTOM: \"custom\",\n} as const;\n\n/**\n * Suffix types for list levels.\n *\n * Defines what follows the numbering text (tab, space, or nothing).\n *\n * @publicApi\n */\nexport const LevelSuffix = {\n /** No separator after the numbering. */\n NOTHING: \"nothing\",\n /** Space character after the numbering. */\n SPACE: \"space\",\n /** Tab character after the numbering. */\n TAB: \"tab\",\n} as const;\n\n/**\n * Options for configuring a numbering level.\n *\n * @property level - Level index (0-8)\n * @property format - Number format type (decimal, roman, letter, etc.)\n * @property text - Level text template with placeholders like %1, %2\n * @property alignment - Text alignment for the numbering\n * @property start - Starting number for this level\n * @property suffix - Character(s) following the numbering (tab, space, nothing)\n * @property isLegalNumberingStyle - Use legal numbering style\n * @property style - Run and paragraph style properties\n */\nexport interface LevelsOptions {\n /** Level index (0-8). */\n level: number;\n /** Number format type (decimal, roman, letter, bullet, etc.). */\n format?: (typeof LevelFormat)[keyof typeof LevelFormat];\n /** Level text template with placeholders like %1, %2. */\n text?: string;\n /** Whether this level emits no text (CT_LevelText @w:null). */\n textNull?: boolean;\n /** Text alignment for the numbering. */\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n /** Starting number for this level. */\n start?: number;\n /** Character(s) following the numbering. */\n suffix?: (typeof LevelSuffix)[keyof typeof LevelSuffix];\n /** Use legal numbering style (e.g., 1.1.1). */\n isLegalNumberingStyle?: boolean;\n /** Restart numbering after this level (0-based level index). */\n lvlRestart?: number;\n /** Paragraph style ID this level is linked to (CT_Lvl pStyle). */\n paragraphStyle?: string;\n /** Picture bullet ID reference. */\n lvlPicBulletId?: number;\n /** Template code for the level. */\n templateCode?: string;\n /** Whether this level is tentative (w:tentative attribute). */\n tentative?: boolean;\n /** Whether this level is tentative (w15:tentative attribute). */\n w15Tentative?: boolean;\n /** Legacy spacing/indent settings. `enabled` maps to the required CT_LvlLegacy @w:legacy flag. */\n legacy?: { enabled?: boolean; space?: number; indent?: number };\n /** Run and paragraph style properties. */\n style?: {\n /** Run style properties for the numbering text. */\n run?: RunStylePropertiesOptions;\n /** Paragraph style properties for the level. */\n paragraph?: LevelParagraphStylePropertiesOptions;\n };\n}\n","import { uniqueNumericIdCreator, convertInchesToTwip } from \"@office-open/core\";\nimport { decimalNumber } from \"@office-open/core\";\n/**\n * Numbering module for WordprocessingML documents.\n *\n * Numbering provides support for numbered and bulleted lists.\n * Pure string serialization — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPnumbering.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\nimport type { ParagraphPropertiesOptions } from \"@parts/paragraph/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport { LevelFormat } from \"./level\";\nimport type { LevelsOptions } from \"./level\";\n\n/**\n * Options for configuring numbering definitions.\n */\nexport interface NumberingOptions {\n /** Array of numbering configurations, each with levels and a reference name. */\n config: {\n levels: LevelsOptions[];\n reference: string;\n extraOptions?: AbstractNumberingExtraOptions;\n }[];\n /** Numbering cleanup ID (w:numIdMacAtCleanup) */\n numIdMacAtCleanup?: number;\n /** Picture bullet definitions for numbering (w:numPicBullet) */\n numPicBullets?: {\n numPicBulletId: number;\n pict?: string;\n }[];\n}\n\n/** Namespace attributes for w:numbering (pre-computed constant). */\nconst NUMBERING_ATTRS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n/** Default bullet levels (9 levels: 0-8). */\nconst DEFAULT_BULLET_LEVELS: LevelsOptions[] = [\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 0,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(0.5) } },\n },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 1,\n style: {\n paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: convertInchesToTwip(1) } },\n },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 2,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2160 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 3,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 2880 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 4,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 3600 } } },\n text: \"○\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 5,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 4320 } } },\n text: \"■\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 6,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5040 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 7,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 5760 } } },\n text: \"●\",\n },\n {\n alignment: AlignmentType.LEFT,\n format: LevelFormat.BULLET,\n level: 8,\n style: { paragraph: { indent: { hanging: convertInchesToTwip(0.25), left: 6480 } } },\n text: \"●\",\n },\n];\n\n/**\n * Numbering definitions for a WordprocessingML document.\n *\n * Pure data accumulator — no XmlComponent inheritance.\n * Serializes via `serialize()` producing a complete XML part.\n */\nexport class Numbering {\n private abstractNumberingData = new Map<\n string,\n { id: number; levels: LevelsOptions[]; extraOptions?: AbstractNumberingExtraOptions }\n >();\n private concreteNumberingData = new Map<\n string,\n {\n numId: number;\n abstractNumId: number;\n reference: string;\n instance: number;\n overrideLevels?: { num: number; start?: number }[];\n }\n >();\n private referenceConfigMap = new Map<string, LevelsOptions[]>();\n private abstractNumUniqueNumericId = uniqueNumericIdCreator();\n private concreteNumUniqueNumericId = uniqueNumericIdCreator(1);\n private _numIdMacAtCleanup?: number;\n private _numPicBullets?: { numPicBulletId: number; pict?: string }[];\n\n public constructor(options: NumberingOptions) {\n this._numIdMacAtCleanup = options.numIdMacAtCleanup;\n this._numPicBullets = options.numPicBullets;\n\n // Only inject the default bullet numbering when the caller supplied no\n // numbering definitions. Round-tripped documents carry their own, so\n // injecting a default would inflate the part (extra abstractNum + 9 levels).\n if (options.config.length === 0) {\n const defaultAbstractId = this.abstractNumUniqueNumericId();\n this.abstractNumberingData.set(\"default-bullet-numbering\", {\n id: defaultAbstractId,\n levels: DEFAULT_BULLET_LEVELS,\n });\n this.concreteNumberingData.set(\"default-bullet-numbering\", {\n abstractNumId: defaultAbstractId,\n instance: 0,\n numId: 1,\n overrideLevels: [{ num: 0, start: 1 }],\n reference: \"default-bullet-numbering\",\n });\n }\n\n for (const con of options.config) {\n this.abstractNumberingData.set(con.reference, {\n id: this.abstractNumUniqueNumericId(),\n levels: con.levels,\n extraOptions: con.extraOptions,\n });\n this.referenceConfigMap.set(con.reference, con.levels);\n }\n }\n\n /** Serialize to word/numbering.xml content (with XML declaration). */\n public serialize(): string {\n const parts: string[] = [];\n parts.push(`<w:numbering ${NUMBERING_ATTRS}>`);\n\n // numPicBullet elements come first (XSD order)\n if (this._numPicBullets) {\n for (const bullet of this._numPicBullets) {\n if (bullet.pict) {\n parts.push(\n `<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\">${bullet.pict}</w:numPicBullet>`,\n );\n } else {\n parts.push(`<w:numPicBullet w:numPicBulletId=\"${bullet.numPicBulletId}\"/>`);\n }\n }\n }\n\n for (const an of this.abstractNumberingData.values()) {\n parts.push(stringifyAbstractNumbering(an.id, an.levels, an.extraOptions));\n }\n for (const cn of this.concreteNumberingData.values()) {\n parts.push(stringifyConcreteNumbering(cn));\n }\n if (this._numIdMacAtCleanup !== undefined) {\n parts.push(`<w:numIdMacAtCleanup w:val=\"${decimalNumber(this._numIdMacAtCleanup)}\"/>`);\n }\n\n parts.push(\"</w:numbering>\");\n return '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>' + parts.join(\"\");\n }\n\n /**\n * Creates a concrete numbering instance from an abstract numbering definition.\n */\n public createConcreteNumberingInstance(reference: string, instance: number): void {\n const abstractNumbering = this.abstractNumberingData.get(reference);\n if (!abstractNumbering) return;\n\n const fullReference = `${reference}-${instance}`;\n if (this.concreteNumberingData.has(fullReference)) return;\n\n const referenceConfigLevels = this.referenceConfigMap.get(reference);\n const firstLevelStartNumber = referenceConfigLevels?.[0]?.start;\n\n // Only emit a lvlOverride when the instance's start differs from the\n // abstract default (1) — otherwise it is redundant and inflates the part.\n const overrideLevels =\n typeof firstLevelStartNumber === \"number\" &&\n Number.isInteger(firstLevelStartNumber) &&\n firstLevelStartNumber !== 1\n ? [{ num: 0, start: firstLevelStartNumber }]\n : undefined;\n\n this.concreteNumberingData.set(fullReference, {\n abstractNumId: abstractNumbering.id,\n instance,\n numId: this.concreteNumUniqueNumericId(),\n overrideLevels,\n reference,\n });\n }\n\n /** Gets all concrete numbering instances. */\n public get concreteNumbering(): { numId: number; reference: string; instance: number }[] {\n return [...this.concreteNumberingData.values()];\n }\n\n /** Gets all reference configurations. */\n public get referenceConfig(): LevelsOptions[][] {\n return [...this.referenceConfigMap.values()];\n }\n}\n\n// ── Types ──\n\n/** Extra options for abstract numbering. Re-exported from abstract-numbering module. */\ninterface AbstractNumberingExtraOptions {\n nsid?: string;\n /** w:multiLevelType value (singleLevel/multilevel/hybridMultilevel). */\n multiLevelType?: string;\n /** w15:restartNumberingAfterBreak attribute on w:abstractNum. Omitted when undefined. */\n restartNumberingAfterBreak?: boolean;\n tmpl?: string;\n name?: string;\n styleLink?: string;\n numStyleLink?: string;\n}\n\n// ── Pure function serializers ──\n\nfunction stringifyAbstractNumbering(\n id: number,\n levels: LevelsOptions[],\n extraOptions?: AbstractNumberingExtraOptions,\n): string {\n const parts: string[] = [];\n // w15:restartNumberingAfterBreak is optional (w15 extension); only emit when\n // explicitly carried so round-trip matches sources that omit it.\n const restartAttr =\n extraOptions?.restartNumberingAfterBreak !== undefined\n ? ` w15:restartNumberingAfterBreak=\"${extraOptions.restartNumberingAfterBreak ? 1 : 0}\"`\n : \"\";\n parts.push(`<w:abstractNum w:abstractNumId=\"${decimalNumber(id)}\"${restartAttr}>`);\n\n if (extraOptions?.nsid !== undefined) {\n parts.push(`<w:nsid w:val=\"${extraOptions.nsid}\"/>`);\n }\n parts.push(`<w:multiLevelType w:val=\"${extraOptions?.multiLevelType ?? \"hybridMultilevel\"}\"/>`);\n if (extraOptions?.tmpl !== undefined) {\n parts.push(`<w:tmpl w:val=\"${extraOptions.tmpl}\"/>`);\n }\n if (extraOptions?.name !== undefined) {\n parts.push(`<w:name w:val=\"${extraOptions.name}\"/>`);\n }\n if (extraOptions?.styleLink !== undefined) {\n parts.push(`<w:styleLink w:val=\"${extraOptions.styleLink}\"/>`);\n }\n if (extraOptions?.numStyleLink !== undefined) {\n parts.push(`<w:numStyleLink w:val=\"${extraOptions.numStyleLink}\"/>`);\n }\n\n for (const level of levels) {\n parts.push(stringifyLevel(level));\n }\n\n parts.push(\"</w:abstractNum>\");\n return parts.join(\"\");\n}\n\nfunction stringifyConcreteNumbering(cn: {\n numId: number;\n abstractNumId: number;\n overrideLevels?: { num: number; start?: number }[];\n}): string {\n const parts: string[] = [];\n parts.push(`<w:num w:numId=\"${decimalNumber(cn.numId)}\">`);\n parts.push(`<w:abstractNumId w:val=\"${decimalNumber(cn.abstractNumId)}\"/>`);\n\n if (cn.overrideLevels) {\n for (const level of cn.overrideLevels) {\n if (level.start !== undefined) {\n parts.push(\n `<w:lvlOverride w:ilvl=\"${level.num}\"><w:startOverride w:val=\"${level.start}\"/></w:lvlOverride>`,\n );\n } else {\n parts.push(`<w:lvlOverride w:ilvl=\"${level.num}\"/>`);\n }\n }\n }\n\n parts.push(\"</w:num>\");\n return parts.join(\"\");\n}\n\nfunction stringifyLevel(opts: LevelsOptions): string {\n const children: string[] = [];\n\n children.push(`<w:start w:val=\"${decimalNumber(opts.start ?? 1)}\"/>`);\n if (opts.format) children.push(`<w:numFmt w:val=\"${opts.format}\"/>`);\n if (opts.lvlRestart !== undefined)\n children.push(`<w:lvlRestart w:val=\"${decimalNumber(opts.lvlRestart)}\"/>`);\n if (opts.paragraphStyle !== undefined)\n children.push(`<w:pStyle w:val=\"${opts.paragraphStyle}\"/>`);\n // CT_Lvl sequence: pStyle → isLgl → suff (XSD). isLgl must precede suff.\n if (opts.isLegalNumberingStyle) children.push(\"<w:isLgl/>\");\n if (opts.suffix) children.push(`<w:suff w:val=\"${opts.suffix}\"/>`);\n if (opts.text !== undefined || opts.textNull) {\n const lvlTextAttrs: string[] = [];\n if (opts.text !== undefined) lvlTextAttrs.push(`w:val=\"${opts.text}\"`);\n if (opts.textNull) lvlTextAttrs.push('w:null=\"1\"');\n children.push(`<w:lvlText ${lvlTextAttrs.join(\" \")}/>`);\n }\n if (opts.lvlPicBulletId !== undefined)\n children.push(`<w:lvlPicBulletId w:val=\"${decimalNumber(opts.lvlPicBulletId)}\"/>`);\n if (opts.legacy !== undefined) {\n const legacyAttrs: string[] = [`w:legacy=\"${(opts.legacy.enabled ?? true) ? 1 : 0}\"`];\n if (opts.legacy.space !== undefined) legacyAttrs.push(`w:legacySpace=\"${opts.legacy.space}\"`);\n if (opts.legacy.indent !== undefined)\n legacyAttrs.push(`w:legacyIndent=\"${opts.legacy.indent}\"`);\n children.push(`<w:legacy ${legacyAttrs.join(\" \")}/>`);\n }\n children.push(`<w:lvlJc w:val=\"${opts.alignment ?? AlignmentType.START}\"/>`);\n\n // Paragraph/run properties — use compile-path pure string builders\n const pPrXml = stringifyParagraphProperties(opts.style && opts.style.paragraph).xml;\n const rPrXml = stringifyRunProperties(opts.style && opts.style.run);\n if (pPrXml) children.push(pPrXml);\n if (rPrXml) children.push(rPrXml);\n\n const lvlAttrs: string[] = [`w:ilvl=\"${decimalNumber(Math.min(opts.level, 9))}\"`];\n // w15:tentative is optional; only emit when carried (matches sources that omit it).\n if (opts.w15Tentative !== undefined)\n lvlAttrs.push(`w15:tentative=\"${opts.w15Tentative ? 1 : 0}\"`);\n if (opts.templateCode !== undefined) lvlAttrs.push(`w:tplc=\"${opts.templateCode}\"`);\n if (opts.tentative !== undefined) lvlAttrs.push(`w:tentative=\"${opts.tentative ? 1 : 0}\"`);\n\n return `<w:lvl ${lvlAttrs.join(\" \")}>${children.join(\"\")}</w:lvl>`;\n}\n\n// ── Parse (Element → NumberingOptions) ──\n\n/**\n * Parse w:numbering element into NumberingOptions.\n */\nexport function parseNumberingDefinitions(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): NumberingOptions | undefined {\n const abstractNums = new Map<string, Element>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const id = attr(child, \"w:abstractNumId\");\n if (id !== undefined) abstractNums.set(id, child);\n }\n\n const numToAbstract = new Map<string, string>();\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n const numId = attr(child, \"w:numId\");\n const abstractRef = findChild(child, \"w:abstractNumId\");\n const abstractId = abstractRef ? attr(abstractRef, \"w:val\") : undefined;\n if (numId !== undefined && abstractId !== undefined) {\n numToAbstract.set(numId, abstractId);\n }\n }\n\n const configs: NumberingOptions[\"config\"] = [];\n\n for (const [numId, abstractId] of numToAbstract) {\n const abstractEl = abstractNums.get(abstractId);\n if (!abstractEl) continue;\n\n const levels: LevelsOptions[] = [];\n for (const child of abstractEl.elements ?? []) {\n if (child.name !== \"w:lvl\") continue;\n const levelOpts = parseLevelEl(child, parseParagraphProperties, ctx);\n if (levelOpts) levels.push(levelOpts);\n }\n\n if (levels.length > 0) {\n const extraOptions: AbstractNumberingExtraOptions = {};\n const nsidEl = findChild(abstractEl, \"w:nsid\");\n if (nsidEl) {\n const v = attr(nsidEl, \"w:val\");\n if (v) extraOptions.nsid = v;\n }\n const multiLevelTypeEl = findChild(abstractEl, \"w:multiLevelType\");\n if (multiLevelTypeEl) {\n const v = attr(multiLevelTypeEl, \"w:val\");\n if (v) extraOptions.multiLevelType = v;\n }\n const restartVal = attrBool(abstractEl, \"w15:restartNumberingAfterBreak\");\n if (restartVal !== undefined) extraOptions.restartNumberingAfterBreak = restartVal;\n const tmplEl = findChild(abstractEl, \"w:tmpl\");\n if (tmplEl) {\n const v = attr(tmplEl, \"w:val\");\n if (v) extraOptions.tmpl = v;\n }\n configs.push({ reference: `list_${numId}`, levels, extraOptions });\n }\n }\n\n if (configs.length === 0) return undefined;\n return { config: configs };\n}\n\nfunction parseLevelEl(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): LevelsOptions | undefined {\n const opts: Partial<LevelsOptions> = {};\n\n const level = attrNum(el, \"w:ilvl\");\n if (level !== undefined) opts.level = level;\n\n const start = findChild(el, \"w:start\");\n if (start) {\n const val = attrNum(start, \"w:val\");\n if (val !== undefined) opts.start = val;\n }\n\n const lvlRestart = findChild(el, \"w:lvlRestart\");\n if (lvlRestart) {\n const val = attrNum(lvlRestart, \"w:val\");\n if (val !== undefined) opts.lvlRestart = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n const val = attr(numFmt, \"w:val\");\n if (val) opts.format = val as LevelsOptions[\"format\"];\n }\n\n const suff = findChild(el, \"w:suff\");\n if (suff) {\n const val = attr(suff, \"w:val\");\n if (val) opts.suffix = val as LevelsOptions[\"suffix\"];\n }\n\n const pStyle = findChild(el, \"w:pStyle\");\n if (pStyle) {\n const val = attr(pStyle, \"w:val\");\n if (val) opts.paragraphStyle = val;\n }\n\n if (findChild(el, \"w:isLgl\")) opts.isLegalNumberingStyle = true;\n\n const lvlText = findChild(el, \"w:lvlText\");\n if (lvlText) {\n const val = attr(lvlText, \"w:val\");\n if (val) opts.text = val;\n const isNull = attrBool(lvlText, \"w:null\");\n if (isNull) opts.textNull = isNull;\n }\n\n const lvlPicBulletId = findChild(el, \"w:lvlPicBulletId\");\n if (lvlPicBulletId) {\n const val = attrNum(lvlPicBulletId, \"w:val\");\n if (val !== undefined) opts.lvlPicBulletId = val;\n }\n\n // Legacy spacing (w:legacy/@w:legacy [required], @w:legacySpace, @w:legacyIndent)\n const legacyEl = findChild(el, \"w:legacy\");\n if (legacyEl) {\n const legacy: NonNullable<LevelsOptions[\"legacy\"]> = {};\n const enabled = attrBool(legacyEl, \"w:legacy\");\n if (enabled !== undefined) legacy.enabled = enabled;\n const space = attrNum(legacyEl, \"w:legacySpace\");\n if (space !== undefined) legacy.space = space;\n const indent = attrNum(legacyEl, \"w:legacyIndent\");\n if (indent !== undefined) legacy.indent = indent;\n opts.legacy = legacy;\n }\n\n const lvlJc = findChild(el, \"w:lvlJc\");\n if (lvlJc) {\n const val = attr(lvlJc, \"w:val\");\n if (val) opts.alignment = val as LevelsOptions[\"alignment\"];\n }\n\n // Level attributes (w:tplc templateCode; w:tentative; w15:tentative)\n const tplc = attr(el, \"w:tplc\");\n if (tplc) opts.templateCode = tplc;\n const tentative = attrBool(el, \"w:tentative\");\n if (tentative !== undefined) opts.tentative = tentative;\n const w15Tentative = attrBool(el, \"w15:tentative\");\n if (w15Tentative !== undefined) opts.w15Tentative = w15Tentative;\n\n // Run + paragraph properties — reuse the complete parse helpers for full\n // fidelity (stringifyLevel delegates to stringifyRunProperties /\n // stringifyParagraphProperties, so parse must use the matching readers).\n const style: NonNullable<LevelsOptions[\"style\"]> = {};\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) style.run = runOpts;\n }\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n style.paragraph = paraOpts;\n }\n }\n if (Object.keys(style).length > 0) opts.style = style;\n\n return Object.keys(opts).length > 0 ? (opts as LevelsOptions) : undefined;\n}\n","import { escapeXml } from \"@office-open/xml\";\nimport { AlignmentType } from \"@parts/paragraph\";\n/**\n * Factory module for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport type { ParagraphStylePropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type {\n TableCellPropertiesOptions,\n TablePropertiesOptions,\n TableRowPropertiesOptions,\n} from \"@parts/table/stringify\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTableRowProperties,\n} from \"@parts/table/stringify\";\nimport { WidthType } from \"@parts/table/table-width\";\nimport { BorderStyle, type BorderOptions } from \"@shared/border\";\n\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"../paragraph/stringify\";\nimport type { StylesOptions } from \"./styles\";\n\n// ── Style options interfaces ──\n\nexport interface DefaultStylesOptions {\n document?: DocumentDefaultsOptions;\n title?: ParagraphStyleOptions;\n subtitle?: ParagraphStyleOptions;\n heading1?: ParagraphStyleOptions;\n heading2?: ParagraphStyleOptions;\n heading3?: ParagraphStyleOptions;\n heading4?: ParagraphStyleOptions;\n heading5?: ParagraphStyleOptions;\n heading6?: ParagraphStyleOptions;\n heading7?: ParagraphStyleOptions;\n heading8?: ParagraphStyleOptions;\n heading9?: ParagraphStyleOptions;\n strong?: ParagraphStyleOptions;\n emphasis?: ParagraphStyleOptions;\n listParagraph?: ParagraphStyleOptions;\n quote?: ParagraphStyleOptions;\n intenseQuote?: ParagraphStyleOptions;\n hyperlink?: CharacterStyleOptions;\n footnoteReference?: CharacterStyleOptions;\n footnoteText?: ParagraphStyleOptions;\n footnoteTextChar?: CharacterStyleOptions;\n endnoteReference?: CharacterStyleOptions;\n endnoteText?: ParagraphStyleOptions;\n endnoteTextChar?: CharacterStyleOptions;\n}\n\nexport interface DocumentDefaultsOptions {\n paragraph?: ParagraphStylePropertiesOptions | null;\n run?: RunStylePropertiesOptions | null;\n}\n\nexport interface StyleOptions {\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n autoRedefine?: boolean;\n uiPriority?: number;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n quickFormat?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n /** CT_Style w:hidden — style hidden from the UI (CT_OnOff). */\n hidden?: boolean;\n /** CT_Style w:rsid — revision save id (CT_LongHexNumber, hex string verbatim). */\n rsid?: string;\n /** CT_Style @w:default — the default style for its type (CT_OnOff). */\n default?: boolean;\n /** CT_Style @w:customStyle — a user-defined custom style (CT_OnOff). */\n customStyle?: boolean;\n}\n\nexport type ParagraphStyleOptions = {\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\nexport type CharacterStyleOptions = {\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id?: string };\n\n// ── String builders ──\n\n/**\n * Build CT_Style style-level children (name…rsid), shared by paragraph/character/table styles.\n * Order follows CT_Style sequence: name, aliases, basedOn, next, link, autoRedefine, hidden,\n * uiPriority, semiHidden, unhideWhenUsed, qFormat, locked, personal, personalCompose,\n * personalReply, rsid.\n */\nfunction stringifyStyleLevelChildren(opts: StyleOptions & { id?: string }): string {\n const parts: string[] = [`<w:name w:val=\"${escapeXml(opts.name ?? opts.id ?? \"\")}\"/>`];\n if (opts.aliases) parts.push(`<w:aliases w:val=\"${escapeXml(opts.aliases)}\"/>`);\n if (opts.basedOn) parts.push(`<w:basedOn w:val=\"${escapeXml(opts.basedOn)}\"/>`);\n if (opts.next) parts.push(`<w:next w:val=\"${escapeXml(opts.next)}\"/>`);\n if (opts.link) parts.push(`<w:link w:val=\"${escapeXml(opts.link)}\"/>`);\n if (opts.autoRedefine) parts.push(\"<w:autoRedefine/>\");\n if (opts.hidden) parts.push(\"<w:hidden/>\");\n if (opts.uiPriority !== undefined) parts.push(`<w:uiPriority w:val=\"${opts.uiPriority}\"/>`);\n if (opts.semiHidden) parts.push(\"<w:semiHidden/>\");\n if (opts.unhideWhenUsed) parts.push(\"<w:unhideWhenUsed/>\");\n if (opts.quickFormat) parts.push(\"<w:qFormat/>\");\n if (opts.locked) parts.push(\"<w:locked/>\");\n if (opts.personal) parts.push(\"<w:personal/>\");\n if (opts.personalCompose) parts.push(\"<w:personalCompose/>\");\n if (opts.personalReply) parts.push(\"<w:personalReply/>\");\n if (opts.rsid) parts.push(`<w:rsid w:val=\"${opts.rsid}\"/>`);\n return parts.join(\"\");\n}\n\n/**\n * Build the `<w:style>` opening tag: type/styleId plus the optional w:default\n * and w:customStyle element attributes (CT_Style). Shared by paragraph/\n * character/table styles.\n */\nfunction styleOpenTag(\n type: string,\n opts: { id?: string; default?: boolean; customStyle?: boolean },\n): string {\n let attrs = ` w:type=\"${type}\" w:styleId=\"${escapeXml(opts.id ?? \"\")}\"`;\n if (opts.default) attrs += ' w:default=\"1\"';\n if (opts.customStyle) attrs += ' w:customStyle=\"1\"';\n return `<w:style${attrs}>`;\n}\n\n/** Build `<w:style>` XML for a paragraph style. */\nexport function stringifyParagraphStyle(\n opts: StyleOptions & {\n id: string;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `${styleOpenTag(\"paragraph\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:style>` XML for a character style. */\nexport function stringifyCharacterStyle(\n opts: StyleOptions & {\n id: string;\n run?: RunStylePropertiesOptions;\n },\n): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n\n return `${styleOpenTag(\"character\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n// ── Table style (CT_Style type=\"table\") ──\n\n/** ST_TblStyleOverrideType — OOXML tokens verbatim (CT_TblStylePr @w:type). */\nexport type TableStyleOverrideType =\n | \"wholeTable\"\n | \"firstRow\"\n | \"lastRow\"\n | \"firstCol\"\n | \"lastCol\"\n | \"band1Vert\"\n | \"band2Vert\"\n | \"band1Horz\"\n | \"band2Horz\"\n | \"neCell\"\n | \"nwCell\"\n | \"seCell\"\n | \"swCell\";\n\n/** Conditional table style format (CT_TblStylePr). */\nexport interface ConditionalTableStyleOptions {\n /** Which region this format applies to (CT_TblStylePr @w:type, required). */\n type: TableStyleOverrideType;\n /** Paragraph properties (CT_PPrGeneral). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n /** Table properties (CT_TblPrBase). */\n table?: TablePropertiesOptions;\n /** Table row properties (CT_TrPr). */\n row?: TableRowPropertiesOptions;\n /** Table cell properties (CT_TcPr). */\n cell?: TableCellPropertiesOptions;\n}\n\n/** Table style (CT_Style type=\"table\"). */\nexport type TableStyleOptions = {\n /** Paragraph properties (CT_PPrGeneral). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n /** Table properties (CT_TblPrBase). */\n table?: TablePropertiesOptions;\n /** Table row properties (CT_TrPr). */\n row?: TableRowPropertiesOptions;\n /** Table cell properties (CT_TcPr). */\n cell?: TableCellPropertiesOptions;\n /** Conditional formats per region (CT_TblStylePr, unbounded). */\n conditionalFormats?: ConditionalTableStyleOptions[];\n} & StyleOptions & { id: string };\n\n/** Numbering style (CT_Style type=\"numbering\"). */\nexport type NumberingStyleOptions = {\n /** Paragraph properties (CT_PPrGeneral — usually carries numPr). */\n paragraph?: ParagraphStylePropertiesOptions;\n /** Run properties (CT_RPr). */\n run?: RunStylePropertiesOptions;\n} & StyleOptions & { id: string };\n\n/** Build `<w:tblStylePr>` XML for a conditional table style format. */\nexport function stringifyConditionalTableStyle(opts: ConditionalTableStyleOptions): string {\n const children: string[] = [];\n // CT_TblStylePr child order: pPr, rPr, tblPr, trPr, tcPr\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n if (opts.table) {\n const tblPr = stringifyTableProperties(opts.table);\n if (tblPr) children.push(tblPr);\n }\n if (opts.row) {\n const trPr = stringifyTableRowProperties(opts.row);\n if (trPr) children.push(trPr);\n }\n if (opts.cell) {\n const tcPr = stringifyTableCellProperties(opts.cell);\n if (tcPr) children.push(tcPr);\n }\n return `<w:tblStylePr w:type=\"${opts.type}\">${children.join(\"\")}</w:tblStylePr>`;\n}\n\n/** Build `<w:style type=\"table\">` XML for a table style. */\nexport function stringifyTableStyle(opts: TableStyleOptions): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n // CT_Style child order: style-level, pPr, rPr, tblPr, trPr, tcPr, tblStylePr[]\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n if (opts.table) {\n const tblPr = stringifyTableProperties(opts.table);\n if (tblPr) children.push(tblPr);\n }\n if (opts.row) {\n const trPr = stringifyTableRowProperties(opts.row);\n if (trPr) children.push(trPr);\n }\n if (opts.cell) {\n const tcPr = stringifyTableCellProperties(opts.cell);\n if (tcPr) children.push(tcPr);\n }\n for (const cf of opts.conditionalFormats ?? []) {\n children.push(stringifyConditionalTableStyle(cf));\n }\n return `${styleOpenTag(\"table\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Build `<w:style type=\"numbering\">` XML for a numbering style. */\nexport function stringifyNumberingStyle(opts: NumberingStyleOptions): string {\n const children: string[] = [stringifyStyleLevelChildren(opts)];\n // CT_Style child order: style-level, pPr, rPr\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n if (pPr) children.push(pPr);\n const rPr = stringifyRunProperties(opts.run);\n if (rPr) children.push(rPr);\n return `${styleOpenTag(\"numbering\", opts)}${children.join(\"\")}</w:style>`;\n}\n\n/** Resolve a user override for heading level N (1-9) from default styles options. */\nfunction headingOverride(\n options: DefaultStylesOptions,\n level: number,\n): ParagraphStyleOptions | undefined {\n switch (level) {\n case 1:\n return options.heading1;\n case 2:\n return options.heading2;\n case 3:\n return options.heading3;\n case 4:\n return options.heading4;\n case 5:\n return options.heading5;\n case 6:\n return options.heading6;\n case 7:\n return options.heading7;\n case 8:\n return options.heading8;\n case 9:\n return options.heading9;\n default:\n return undefined;\n }\n}\n\n/** Word's default `<w:rPrDefault>` — theme fonts, kern, 11pt, ligatures. Injected\n * for fresh documents (no structured docDefaults provided) to mirror Word's\n * Normal.dotx. On round-trip the structured form is used instead. */\nconst WORD_DEFAULT_RPR_DEFAULT =\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/** Word's default `<w:pPrDefault>` — widow/orphan control + 8pt after / 1.16 line.\n * Injected for fresh documents only. */\nconst WORD_DEFAULT_PPR_DEFAULT =\n `<w:pPrDefault><w:pPr>` +\n `<w:widowControl/>` +\n `<w:spacing w:after=\"160\" w:line=\"278\" w:lineRule=\"auto\"/>` +\n `</w:pPr></w:pPrDefault>`;\n\n/**\n * Build `<w:docDefaults>` XML from a structured {@link DocumentDefaultsOptions}.\n *\n * Three states per run/paragraph:\n * - object → structured child element\n * - null → explicit empty tag (`<w:pPrDefault/>`) — the source declared \"no\n * defaults here\", so Word does NOT inject its own spacing. Distinct\n * from absence (ECMA-376: empty pPrDefault suppresses default\n * spacing; a missing pPrDefault is application-defined).\n * - undefined → field is missing. On fresh generation (`injectDefaults`) we\n * mirror Word's Normal.dotx; on round-trip we omit the element\n * to preserve the source's \"this default category is absent\".\n */\nexport function stringifyDocDefaults(opts: DocumentDefaultsOptions, injectDefaults = true): string {\n const children: string[] = [];\n\n // rPrDefault\n if (opts.run) {\n const rPr = stringifyRunProperties(opts.run);\n children.push(rPr ? `<w:rPrDefault>${rPr}</w:rPrDefault>` : `<w:rPrDefault/>`);\n } else if (opts.run === null) {\n children.push(`<w:rPrDefault/>`);\n } else if (injectDefaults) {\n children.push(WORD_DEFAULT_RPR_DEFAULT);\n }\n\n // pPrDefault\n if (opts.paragraph) {\n const pPr = stringifyParagraphProperties(opts.paragraph).xml;\n children.push(pPr ? `<w:pPrDefault>${pPr}</w:pPrDefault>` : `<w:pPrDefault/>`);\n } else if (opts.paragraph === null) {\n children.push(`<w:pPrDefault/>`);\n } else if (injectDefaults) {\n children.push(WORD_DEFAULT_PPR_DEFAULT);\n }\n\n return `<w:docDefaults>${children.join(\"\")}</w:docDefaults>`;\n}\n\n// ── Factory ──\n\nlet cachedDefaultStyles: StylesOptions | null = null;\n\n/**\n * Factory for creating default document styles.\n *\n * Creates styles matching Microsoft Word's default document template.\n * Pure string generation — no XmlComponent inheritance.\n */\nexport class DefaultStylesFactory {\n public newInstance(options: DefaultStylesOptions = {}): StylesOptions {\n if (Object.keys(options).length === 0) {\n if (!cachedDefaultStyles) {\n cachedDefaultStyles = this.build({});\n }\n return cachedDefaultStyles;\n }\n return this.build(options);\n }\n\n private build(options: DefaultStylesOptions): StylesOptions {\n // importedStyles carries only docDefaults + latentStyles verbatim. Every\n // builtin w:style is emitted as a structured Options object so HTML renderers\n // can consume style attributes directly.\n const importedStyles: { _raw: string }[] = [];\n const paragraphStyles: (ParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (CharacterStyleOptions & { id: string })[] = [];\n const tableStyles: TableStyleOptions[] = [];\n const numberingStyles: NumberingStyleOptions[] = [];\n\n // XML namespace attributes for styles root element (matching Word exactly)\n const initialAttributes: Record<string, string> = {\n \"xmlns:mc\": \"http://schemas.openxmlformats.org/markup-compatibility/2006\",\n \"xmlns:r\": \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\",\n \"xmlns:w\": \"http://schemas.openxmlformats.org/wordprocessingml/2006/main\",\n \"xmlns:w14\": \"http://schemas.microsoft.com/office/word/2010/wordml\",\n \"xmlns:w15\": \"http://schemas.microsoft.com/office/word/2012/wordml\",\n \"mc:Ignorable\": \"w14 w15\",\n };\n\n importedStyles.push({ _raw: stringifyDocDefaults(options.document ?? {}) });\n\n // Latent styles - complete list from Word's default template\n // Only include styles that are NOT explicitly defined below\n importedStyles.push({\n _raw:\n `<w:latentStyles w:defLockedState=\"0\" w:defUIPriority=\"99\" w:defSemiHidden=\"0\" w:defUnhideWhenUsed=\"0\" w:defQFormat=\"0\" w:count=\"376\">` +\n `<w:lsdException w:name=\"Normal\" w:uiPriority=\"0\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 1\" w:uiPriority=\"9\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 2\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 3\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 4\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 5\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 6\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 7\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 8\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"heading 9\" w:semiHidden=\"1\" w:uiPriority=\"9\" w:unhideWhenUsed=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Default Paragraph Font\" w:semiHidden=\"1\" w:uiPriority=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Normal Table\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No List\" w:semiHidden=\"1\" w:uiPriority=\"99\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"Subtitle\" w:uiPriority=\"11\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Strong\" w:uiPriority=\"22\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Emphasis\" w:uiPriority=\"20\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Hyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"FollowedHyperlink\" w:semiHidden=\"1\" w:unhideWhenUsed=\"1\"/>` +\n `<w:lsdException w:name=\"No Spacing\" w:uiPriority=\"1\" w:qFormat=\"1\"/>` +\n `<w:lsdException w:name=\"Revision\" w:semiHidden=\"1\"/>` +\n `</w:latentStyles>`,\n });\n\n // Built-in styles required by Word\n // Normal paragraph style (default for paragraphs)\n paragraphStyles.push({\n id: \"Normal\",\n name: \"Normal\",\n default: true,\n quickFormat: true,\n });\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 [headingIdx, h] of headings.entries()) {\n const outlineLvl = h.outlineLvl;\n const headingOverrideOpts = headingOverride(options, headingIdx + 1);\n if (headingOverrideOpts) {\n // User-defined heading overrides the built-in entirely.\n paragraphStyles.push({\n id: h.id,\n name: headingOverrideOpts.name ?? h.name,\n basedOn: headingOverrideOpts.basedOn ?? \"Normal\",\n next: headingOverrideOpts.next ?? \"Normal\",\n link: headingOverrideOpts.link ?? h.link,\n uiPriority: headingOverrideOpts.uiPriority ?? 9,\n quickFormat: headingOverrideOpts.quickFormat ?? true,\n semiHidden: headingOverrideOpts.semiHidden,\n unhideWhenUsed: headingOverrideOpts.unhideWhenUsed,\n paragraph: { outlineLevel: headingIdx, ...headingOverrideOpts.paragraph },\n run: headingOverrideOpts.run,\n });\n characterStyles.push({\n id: h.link,\n name: `${h.name} Char`,\n basedOn: \"DefaultParagraphFont\",\n link: h.id,\n run: headingOverrideOpts.run,\n });\n continue;\n }\n\n // heading 1-6 use accent1 color + major theme fonts; 7-9 use text1 color.\n const accentRange = outlineLvl < 6;\n const runProps: RunStylePropertiesOptions = {\n font: accentRange\n ? {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n }\n : { cstheme: \"majorBidi\" },\n color: accentRange\n ? { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" }\n : { val: \"595959\", themeColor: \"text1\", themeTint: \"A6\" },\n };\n if (h.sz) {\n const sizePt = h.sz / 2; // half-points → points\n runProps.size = sizePt;\n runProps.sizeComplexScript = sizePt;\n }\n // heading 6-9 have bold\n if (outlineLvl >= 5) {\n runProps.bold = true;\n runProps.boldComplexScript = true;\n }\n\n paragraphStyles.push({\n id: h.id,\n name: h.name,\n basedOn: \"Normal\",\n next: \"Normal\",\n link: h.link,\n uiPriority: 9,\n semiHidden: outlineLvl > 0,\n unhideWhenUsed: outlineLvl > 0,\n quickFormat: true,\n paragraph: {\n keepNext: true,\n keepLines: true,\n spacing: {\n before: h.before,\n after: h.after,\n },\n outlineLevel: outlineLvl,\n },\n run: runProps,\n });\n\n // Linked character styles for headings\n characterStyles.push({\n id: h.link,\n name: `${h.name} Char`,\n basedOn: \"DefaultParagraphFont\",\n link: h.id,\n uiPriority: 9,\n semiHidden: outlineLvl > 0,\n run: runProps,\n });\n }\n\n // DefaultParagraphFont character style (default for runs)\n characterStyles.push({\n id: \"DefaultParagraphFont\",\n name: \"Default Paragraph Font\",\n default: true,\n uiPriority: 1,\n semiHidden: true,\n unhideWhenUsed: true,\n });\n\n // Normal Table style (default for tables)\n tableStyles.push({\n id: \"NormalTable\",\n name: \"Normal Table\",\n default: true,\n uiPriority: 99,\n semiHidden: true,\n unhideWhenUsed: true,\n table: {\n indent: { size: 0, type: WidthType.DXA },\n cellMargin: {\n top: { size: 0, type: WidthType.DXA },\n left: { size: 108, type: WidthType.DXA },\n bottom: { size: 0, type: WidthType.DXA },\n right: { size: 108, type: WidthType.DXA },\n },\n },\n });\n\n // No List numbering style (default for numbering)\n numberingStyles.push({\n id: \"NoList\",\n name: \"No List\",\n default: true,\n uiPriority: 99,\n semiHidden: true,\n unhideWhenUsed: true,\n });\n\n // Title style (user override via options.title, else built-in default)\n if (options.title) {\n paragraphStyles.push({\n id: \"Title\",\n name: options.title.name ?? \"Title\",\n basedOn: options.title.basedOn ?? \"Normal\",\n next: options.title.next ?? \"Normal\",\n link: options.title.link ?? \"TitleChar\",\n uiPriority: options.title.uiPriority ?? 10,\n quickFormat: options.title.quickFormat ?? true,\n paragraph: options.title.paragraph,\n run: options.title.run,\n });\n characterStyles.push({\n id: \"TitleChar\",\n name: \"Title Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Title\",\n run: options.title.run,\n });\n } else {\n const titleRun: RunStylePropertiesOptions = {\n font: {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n },\n characterSpacing: -10,\n kern: 28,\n size: 28,\n sizeComplexScript: 28,\n };\n paragraphStyles.push({\n id: \"Title\",\n name: \"Title\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"TitleChar\",\n uiPriority: 10,\n quickFormat: true,\n paragraph: {\n spacing: { after: 80, line: 240, lineRule: \"auto\" },\n contextualSpacing: true,\n alignment: AlignmentType.CENTER,\n },\n run: titleRun,\n });\n characterStyles.push({\n id: \"TitleChar\",\n name: \"Title Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Title\",\n uiPriority: 10,\n run: titleRun,\n });\n }\n\n // Subtitle style (user override via options.subtitle, else built-in default)\n if (options.subtitle) {\n paragraphStyles.push({\n id: \"Subtitle\",\n name: options.subtitle.name ?? \"Subtitle\",\n basedOn: options.subtitle.basedOn ?? \"Normal\",\n next: options.subtitle.next ?? \"Normal\",\n link: options.subtitle.link ?? \"SubtitleChar\",\n uiPriority: options.subtitle.uiPriority ?? 11,\n quickFormat: options.subtitle.quickFormat ?? true,\n paragraph: options.subtitle.paragraph,\n run: options.subtitle.run,\n });\n characterStyles.push({\n id: \"SubtitleChar\",\n name: \"Subtitle Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Subtitle\",\n run: options.subtitle.run,\n });\n } else {\n const subtitleRun: RunStylePropertiesOptions = {\n font: {\n asciiTheme: \"majorHAnsi\",\n eastAsiaTheme: \"majorEastAsia\",\n hAnsiTheme: \"majorHAnsi\",\n cstheme: \"majorBidi\",\n },\n color: { val: \"595959\", themeColor: \"text1\", themeTint: \"A6\" },\n characterSpacing: 15,\n size: 14,\n sizeComplexScript: 14,\n };\n paragraphStyles.push({\n id: \"Subtitle\",\n name: \"Subtitle\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"SubtitleChar\",\n uiPriority: 11,\n quickFormat: true,\n paragraph: { alignment: AlignmentType.CENTER },\n run: subtitleRun,\n });\n characterStyles.push({\n id: \"SubtitleChar\",\n name: \"Subtitle Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Subtitle\",\n uiPriority: 11,\n run: subtitleRun,\n });\n }\n\n // List Paragraph style (user override via options.listParagraph, else built-in default)\n if (options.listParagraph) {\n paragraphStyles.push({\n id: \"ListParagraph\",\n name: options.listParagraph.name ?? \"List Paragraph\",\n basedOn: options.listParagraph.basedOn ?? \"Normal\",\n uiPriority: options.listParagraph.uiPriority ?? 34,\n quickFormat: options.listParagraph.quickFormat ?? true,\n paragraph: options.listParagraph.paragraph,\n run: options.listParagraph.run,\n });\n } else {\n paragraphStyles.push({\n id: \"ListParagraph\",\n name: \"List Paragraph\",\n basedOn: \"Normal\",\n uiPriority: 34,\n quickFormat: true,\n paragraph: { indent: { left: 720 }, contextualSpacing: true },\n });\n }\n\n // Strong style — only emitted when the user provides a definition\n if (options.strong) {\n paragraphStyles.push({\n id: \"Strong\",\n name: options.strong.name ?? \"Strong\",\n basedOn: options.strong.basedOn ?? \"Normal\",\n next: options.strong.next ?? \"Normal\",\n quickFormat: options.strong.quickFormat ?? true,\n paragraph: options.strong.paragraph,\n run: options.strong.run,\n });\n }\n\n // Emphasis style — only emitted when the user provides a definition\n if (options.emphasis) {\n paragraphStyles.push({\n id: \"Emphasis\",\n name: options.emphasis.name ?? \"Emphasis\",\n basedOn: options.emphasis.basedOn ?? \"Normal\",\n next: options.emphasis.next ?? \"Normal\",\n quickFormat: options.emphasis.quickFormat ?? true,\n paragraph: options.emphasis.paragraph,\n run: options.emphasis.run,\n });\n }\n\n // Quote style (user override via options.quote, else built-in default)\n const quoteRun: RunStylePropertiesOptions = {\n italic: true,\n italicComplexScript: true,\n color: { val: \"404040\", themeColor: \"text1\", themeTint: \"BF\" },\n };\n if (options.quote) {\n paragraphStyles.push({\n id: \"Quote\",\n name: options.quote.name ?? \"Quote\",\n basedOn: options.quote.basedOn ?? \"Normal\",\n next: options.quote.next ?? \"Normal\",\n link: options.quote.link ?? \"QuoteChar\",\n uiPriority: options.quote.uiPriority ?? 29,\n quickFormat: options.quote.quickFormat ?? true,\n paragraph: options.quote.paragraph,\n run: options.quote.run,\n });\n characterStyles.push({\n id: \"QuoteChar\",\n name: \"Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Quote\",\n run: options.quote.run,\n });\n } else {\n paragraphStyles.push({\n id: \"Quote\",\n name: \"Quote\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"QuoteChar\",\n uiPriority: 29,\n quickFormat: true,\n paragraph: { spacing: { before: 160 }, alignment: AlignmentType.CENTER },\n run: quoteRun,\n });\n characterStyles.push({\n id: \"QuoteChar\",\n name: \"Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"Quote\",\n uiPriority: 29,\n run: quoteRun,\n });\n }\n\n // Intense Quote style + linked character style (built-in defaults)\n const intenseQuoteRun: RunStylePropertiesOptions = {\n italic: true,\n italicComplexScript: true,\n color: { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" },\n };\n const intenseQuoteBorder: BorderOptions = {\n style: BorderStyle.SINGLE,\n size: 4,\n space: 10,\n color: \"0F4761\",\n themeColor: \"accent1\",\n themeShade: \"BF\",\n };\n paragraphStyles.push({\n id: \"IntenseQuote\",\n name: \"Intense Quote\",\n basedOn: \"Normal\",\n next: \"Normal\",\n link: \"IntenseQuoteChar\",\n uiPriority: 30,\n quickFormat: true,\n paragraph: {\n border: { top: intenseQuoteBorder, bottom: intenseQuoteBorder },\n spacing: { before: 360, after: 360 },\n indent: { left: 864, right: 864 },\n alignment: AlignmentType.CENTER,\n },\n run: intenseQuoteRun,\n });\n characterStyles.push({\n id: \"IntenseQuoteChar\",\n name: \"Intense Quote Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"IntenseQuote\",\n uiPriority: 30,\n run: intenseQuoteRun,\n });\n\n // Hyperlink character style\n characterStyles.push({\n id: \"Hyperlink\",\n name: \"Hyperlink\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { color: \"0563C1\", underline: { type: \"single\" } },\n ...options.hyperlink,\n });\n\n // Footnote Reference character style\n characterStyles.push({\n id: \"FootnoteReference\",\n name: \"footnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.footnoteReference,\n });\n\n // Footnote Text paragraph style\n paragraphStyles.push({\n id: \"FootnoteText\",\n name: \"footnote text\",\n basedOn: \"Normal\",\n link: \"FootnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.footnoteText,\n });\n\n // Footnote Text Char character style\n characterStyles.push({\n id: \"FootnoteTextChar\",\n name: \"Footnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"FootnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.footnoteTextChar,\n });\n\n // Endnote Reference character style\n characterStyles.push({\n id: \"EndnoteReference\",\n name: \"endnote reference\",\n basedOn: \"DefaultParagraphFont\",\n semiHidden: true,\n unhideWhenUsed: true,\n run: { superScript: true },\n ...options.endnoteReference,\n });\n\n // Endnote Text paragraph style\n paragraphStyles.push({\n id: \"EndnoteText\",\n name: \"endnote text\",\n basedOn: \"Normal\",\n link: \"EndnoteTextChar\",\n semiHidden: true,\n uiPriority: 99,\n unhideWhenUsed: true,\n paragraph: { spacing: { after: 0, line: 240, lineRule: \"auto\" } },\n run: { size: 20 },\n ...options.endnoteText,\n });\n\n // Endnote Text Char character style\n characterStyles.push({\n id: \"EndnoteTextChar\",\n name: \"Endnote Text Char\",\n basedOn: \"DefaultParagraphFont\",\n link: \"EndnoteText\",\n semiHidden: true,\n run: { size: 20 },\n ...options.endnoteTextChar,\n });\n\n // Intense Reference character style\n characterStyles.push({\n id: \"IntenseReference\",\n name: \"Intense Reference\",\n basedOn: \"DefaultParagraphFont\",\n uiPriority: 32,\n quickFormat: true,\n run: {\n bold: true,\n boldComplexScript: true,\n smallCaps: true,\n color: { val: \"0F4761\", themeColor: \"accent1\", themeShade: \"BF\" },\n characterSpacing: 5,\n },\n });\n\n return {\n importedStyles,\n paragraphStyles,\n characterStyles,\n tableStyles,\n numberingStyles,\n initialAttributes,\n };\n }\n}\n","/**\n * Styles module for WordprocessingML documents.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n *\n * Reference: http://officeopenxml.com/WPstyles.php\n *\n * @module\n */\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n ParagraphPropertiesOptions,\n ParagraphStylePropertiesOptions,\n} from \"@parts/paragraph/properties\";\nimport type { RunStylePropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport type {\n CharacterStyleOptions,\n ConditionalTableStyleOptions,\n DefaultStylesOptions,\n DocumentDefaultsOptions,\n NumberingStyleOptions,\n ParagraphStyleOptions,\n TableStyleOptions,\n} from \"@parts/styles/factory\";\nimport {\n stringifyCharacterStyle,\n stringifyNumberingStyle,\n stringifyParagraphStyle,\n stringifyTableStyle,\n} from \"@parts/styles/factory\";\nimport {\n parseTableCellPropertiesEl,\n parseTablePropertiesEl,\n parseTableRowPropertiesEl,\n} from \"@parts/table/descriptor\";\nimport type {\n TableCellPropertiesOptions,\n TablePropertiesOptions,\n TableRowPropertiesOptions,\n} from \"@parts/table/stringify\";\n\nimport type { DocxReadContext } from \"../../context\";\nimport { stringifyElement } from \"../../util/stringify-element\";\n\n/**\n * Options for configuring document styles.\n */\nexport interface StylesOptions {\n /** Default styles for document, headings, and common elements */\n default?: DefaultStylesOptions;\n /** Initial namespace attributes for the styles root element */\n initialAttributes?: Record<string, string>;\n /** Array of raw XML style elements */\n importedStyles?: { _raw: string }[];\n /** Array of custom paragraph style definitions */\n paragraphStyles?: (ParagraphStyleOptions & { id: string })[];\n /** Array of custom character style definitions */\n characterStyles?: (CharacterStyleOptions & { id: string })[];\n /** Array of custom table style definitions (CT_Style type=\"table\"). */\n tableStyles?: TableStyleOptions[];\n /** Array of numbering style definitions (CT_Style type=\"numbering\"). */\n numberingStyles?: NumberingStyleOptions[];\n /**\n * Verbatim `<w:latentStyles>` XML (CT_LatentStyles + lsdException list).\n * When set (from parse), generate uses it in place of the default factory's\n * latent styles so the full latent-style table round-trips.\n */\n latentStylesXml?: string;\n /**\n * Verbatim `<w:docDefaults>` XML. When set (from parse), generate uses it in\n * place of the default factory's document defaults so rPrDefault/pPrDefault\n * round-trip byte-for-byte.\n */\n docDefaultsXml?: string;\n /**\n * @internal — set by parseStyleDefinitions to mark a round-trip origin so\n * context.ts consumes the parsed structured styles directly (no factory\n * builtin rebuild). Fresh generation never sets this.\n */\n roundTripped?: boolean;\n}\n\n/**\n * Extract the `w:styleId` from a raw `<w:style>` XML string, if present.\n *\n * Returns `undefined` for non-style elements (docDefaults / latentStyles),\n * whose raw XML carries no `w:styleId` attribute.\n */\nexport function extractStyleId(raw: string): string | undefined {\n const m = raw.match(/w:styleId=\"([^\"]+)\"/);\n return m ? m[1] : undefined;\n}\n\n/**\n * Represents the styles definitions in a WordprocessingML document.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects child elements as raw XML strings and serializes.\n */\nexport class Styles {\n private attributes: Record<string, string> = {};\n private parts: string[] = [];\n\n public constructor(options: StylesOptions) {\n if (options.initialAttributes) {\n this.attributes = options.initialAttributes;\n }\n\n // styleIds explicitly redefined via paragraphStyles/characterStyles take\n // precedence over importedStyles (user definitions override builtins) —\n // skip those imported entries to avoid duplicate styleId in the output.\n const customStyleIds = new Set<string>();\n for (const s of options.paragraphStyles ?? []) customStyleIds.add(s.id);\n for (const s of options.characterStyles ?? []) customStyleIds.add(s.id);\n for (const s of options.tableStyles ?? []) customStyleIds.add(s.id);\n\n if (options.importedStyles) {\n for (const style of options.importedStyles) {\n if (!style._raw) continue;\n if (customStyleIds.size > 0) {\n const id = extractStyleId(style._raw);\n if (id && customStyleIds.has(id)) continue;\n }\n this.parts.push(style._raw);\n }\n }\n\n if (options.paragraphStyles) {\n for (const style of options.paragraphStyles) {\n this.parts.push(stringifyParagraphStyle(style));\n }\n }\n\n if (options.characterStyles) {\n for (const style of options.characterStyles) {\n this.parts.push(stringifyCharacterStyle(style));\n }\n }\n\n if (options.tableStyles) {\n for (const style of options.tableStyles) {\n this.parts.push(stringifyTableStyle(style));\n }\n }\n\n if (options.numberingStyles) {\n for (const style of options.numberingStyles) {\n this.parts.push(stringifyNumberingStyle(style));\n }\n }\n }\n\n /**\n * Serialize to word/styles.xml content (with XML declaration).\n */\n public serialize(): string {\n const attrParts: string[] = [];\n for (const [k, v] of Object.entries(this.attributes)) {\n if (v !== undefined && v !== null) attrParts.push(` ${k}=\"${v}\"`);\n }\n\n const attrs = attrParts.join(\"\");\n const body = this.parts.join(\"\");\n return `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:styles${attrs}>${body}</w:styles>`;\n }\n}\n\n// ── Parse helpers (for descriptor pipeline) ──\n\n/**\n * Build a cache of style elements keyed by styleId.\n */\nexport function buildStyleCache(stylesEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!stylesEl) return cache;\n\n for (const child of stylesEl.elements ?? []) {\n if (child.name !== \"w:style\") continue;\n const styleId = attr(child, \"w:styleId\");\n if (styleId) {\n cache.set(styleId, child);\n }\n }\n\n return cache;\n}\n\n/**\n * Build a cache of abstract numbering elements keyed by abstractNumId.\n */\nexport function buildNumberingCache(numberingEl: Element | undefined): Map<string, Element> {\n const cache = new Map<string, Element>();\n if (!numberingEl) return cache;\n\n for (const child of numberingEl.elements ?? []) {\n if (child.name !== \"w:abstractNum\") continue;\n const abstractNumId = attr(child, \"w:abstractNumId\");\n if (abstractNumId !== undefined) {\n cache.set(abstractNumId, child);\n }\n }\n\n return cache;\n}\n\n/** Parsed style — concrete shape (not Record) with a transient _type marker. */\ninterface ParsedStyle {\n _type?: string;\n id?: string;\n default?: boolean;\n customStyle?: boolean;\n name?: string;\n aliases?: string;\n basedOn?: string;\n next?: string;\n link?: string;\n uiPriority?: number;\n quickFormat?: boolean;\n semiHidden?: boolean;\n unhideWhenUsed?: boolean;\n autoRedefine?: boolean;\n locked?: boolean;\n personal?: boolean;\n personalCompose?: boolean;\n personalReply?: boolean;\n hidden?: boolean;\n rsid?: string;\n paragraph?: ParagraphStylePropertiesOptions;\n run?: RunStylePropertiesOptions;\n table?: Partial<TablePropertiesOptions>;\n row?: Partial<TableRowPropertiesOptions>;\n cell?: Partial<TableCellPropertiesOptions>;\n conditionalFormats?: ConditionalTableStyleOptions[];\n}\n\n/**\n * Parse w:styles element into StylesOptions.\n *\n * Skips built-in styles that DefaultStylesFactory already generates,\n * keeping only user-defined custom styles for round-trip fidelity.\n */\nexport function parseStyleDefinitions(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): StylesOptions | undefined {\n const opts: StylesOptions = {};\n const paragraphStyles: (ParagraphStyleOptions & { id: string })[] = [];\n const characterStyles: (CharacterStyleOptions & { id: string })[] = [];\n const tableStyles: TableStyleOptions[] = [];\n const numberingStyles: NumberingStyleOptions[] = [];\n\n for (const child of el.elements ?? []) {\n if (child.name === \"w:docDefaults\") {\n const defOpts = parseDocDefaults(child, parseParagraphProperties, ctx);\n if (defOpts) opts.default = defOpts;\n // Also capture verbatim for byte-exact round-trip (the structured path\n // may re-order or default-fill rPrDefault/pPrDefault children).\n opts.docDefaultsXml = stringifyElement(child);\n } else if (child.name === \"w:latentStyles\") {\n // Preserve the latent-style table verbatim so the full lsdException list\n // round-trips (the default factory only emits ~20 entries).\n opts.latentStylesXml = stringifyElement(child);\n } else if (child.name === \"w:style\") {\n const styleOpts = parseStyleElement(child, parseParagraphProperties, ctx);\n // Skip styles without a type or styleId — both are required to be useful.\n if (!styleOpts?._type || !styleOpts.id) continue;\n // All styles (builtin + custom) round-trip structured so HTML renderers\n // can consume style attributes directly. Builtin verbatim _raw is gone —\n // a customized builtin (e.g. recolored Heading1) round-trips losslessly\n // via parseStyleElement ↔ stringify*Style field symmetry.\n const type = styleOpts._type;\n delete styleOpts._type;\n\n if (type === \"table\") {\n tableStyles.push(styleOpts as TableStyleOptions);\n } else if (type === \"numbering\") {\n numberingStyles.push(styleOpts as NumberingStyleOptions);\n } else if (type === \"paragraph\") {\n paragraphStyles.push(styleOpts as ParagraphStyleOptions & { id: string });\n } else if (type === \"character\") {\n characterStyles.push(styleOpts as CharacterStyleOptions & { id: string });\n }\n }\n }\n\n if (paragraphStyles.length > 0) opts.paragraphStyles = paragraphStyles;\n if (characterStyles.length > 0) opts.characterStyles = characterStyles;\n if (tableStyles.length > 0) opts.tableStyles = tableStyles;\n if (numberingStyles.length > 0) opts.numberingStyles = numberingStyles;\n // Mark round-trip origin so context.ts consumes parsed structured styles\n // directly instead of rebuilding builtins via the factory.\n opts.roundTripped = true;\n\n return Object.keys(opts).length > 0 ? opts : undefined;\n}\n\nfunction parseDocDefaults(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): DefaultStylesOptions | undefined {\n const document: DocumentDefaultsOptions = {};\n\n // null = explicit empty default element (`<w:rPrDefault/>` or\n // `<w:rPrDefault><w:rPr/></w:rPrDefault>`); distinguishes \"no defaults declared\"\n // (Word suppresses its own) from a missing element (Word injects application\n // defaults). See ECMA-376 CT_DocDefaults.\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 document.run = Object.keys(runDefaults).length > 0 ? runDefaults : null;\n } else {\n document.run = null;\n }\n }\n\n const pPrDefault = findChild(el, \"w:pPrDefault\");\n if (pPrDefault) {\n const pPr = findChild(pPrDefault, \"w:pPr\");\n if (pPr) {\n // Reuse the full paragraph-properties reader (stringifyDocDefaults uses\n // stringifyParagraphProperties) instead of only reading spacing, so jc/\n // ind/etc. round-trip too.\n const paraDefaults = parseParagraphProperties(pPr, ctx);\n document.paragraph = Object.keys(paraDefaults).length > 0 ? paraDefaults : null;\n } else {\n document.paragraph = null;\n }\n }\n\n return Object.keys(document).length > 0 ? { document } : undefined;\n}\n\nfunction parseStyleElement(\n el: Element,\n parseParagraphProperties: (\n el: Element,\n ctx: DocxReadContext,\n ) => Partial<ParagraphPropertiesOptions>,\n ctx: DocxReadContext,\n): ParsedStyle | undefined {\n const opts: ParsedStyle = {};\n\n const type = attr(el, \"w:type\");\n if (type) opts._type = type;\n\n const id = attr(el, \"w:styleId\");\n if (id) opts.id = id;\n\n if (attrBool(el, \"w:default\")) opts.default = true;\n if (attrBool(el, \"w:customStyle\")) opts.customStyle = true;\n\n const nameEl = findChild(el, \"w:name\");\n if (nameEl) {\n const name = attr(nameEl, \"w:val\");\n if (name) opts.name = name;\n }\n\n const basedOn = findChild(el, \"w:basedOn\");\n if (basedOn) {\n const val = attr(basedOn, \"w:val\");\n if (val) opts.basedOn = val;\n }\n\n const next = findChild(el, \"w:next\");\n if (next) {\n const val = attr(next, \"w:val\");\n if (val) opts.next = val;\n }\n\n const link = findChild(el, \"w:link\");\n if (link) {\n const val = attr(link, \"w:val\");\n if (val) opts.link = val;\n }\n\n const uiPriority = findChild(el, \"w:uiPriority\");\n if (uiPriority) {\n const val = attrNum(uiPriority, \"w:val\");\n if (val !== undefined) opts.uiPriority = val;\n }\n\n if (findChild(el, \"w:qFormat\")) opts.quickFormat = true;\n if (findChild(el, \"w:semiHidden\")) opts.semiHidden = true;\n if (findChild(el, \"w:unhideWhenUsed\")) opts.unhideWhenUsed = true;\n if (findChild(el, \"w:autoRedefine\")) opts.autoRedefine = true;\n if (findChild(el, \"w:locked\")) opts.locked = true;\n if (findChild(el, \"w:personal\")) opts.personal = true;\n if (findChild(el, \"w:personalCompose\")) opts.personalCompose = true;\n if (findChild(el, \"w:personalReply\")) opts.personalReply = true;\n if (findChild(el, \"w:hidden\")) opts.hidden = true;\n\n const rsidEl = findChild(el, \"w:rsid\");\n if (rsidEl) {\n const val = attr(rsidEl, \"w:val\");\n if (val) opts.rsid = val;\n }\n\n const aliases = findChild(el, \"w:aliases\");\n if (aliases) {\n const val = attr(aliases, \"w:val\");\n if (val) opts.aliases = val;\n }\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n const paraOpts = parseParagraphProperties(pPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n opts.paragraph = paraOpts;\n }\n }\n\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n const runOpts = parseRunProperties(rPr);\n if (Object.keys(runOpts).length > 0) opts.run = runOpts;\n }\n\n // Table-style-only properties (CT_Style type=\"table\").\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n const tableOpts = parseTablePropertiesEl(tblPr);\n if (Object.keys(tableOpts).length > 0) opts.table = tableOpts;\n }\n const trPr = findChild(el, \"w:trPr\");\n if (trPr) {\n const rowOpts = parseTableRowPropertiesEl(trPr);\n if (Object.keys(rowOpts).length > 0) opts.row = rowOpts;\n }\n const tcPr = findChild(el, \"w:tcPr\");\n if (tcPr) {\n const cellOpts = parseTableCellPropertiesEl(tcPr);\n if (Object.keys(cellOpts).length > 0) opts.cell = cellOpts;\n }\n // Conditional table style formats (CT_TblStylePr, unbounded).\n const conditionalFormats: ConditionalTableStyleOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:tblStylePr\") continue;\n const type = attr(child, \"w:type\") as ConditionalTableStyleOptions[\"type\"] | undefined;\n if (!type) continue;\n const cf: ConditionalTableStyleOptions = { type };\n const cfPPr = findChild(child, \"w:pPr\");\n if (cfPPr) {\n const paraOpts = parseParagraphProperties(cfPPr, ctx);\n if (Object.keys(paraOpts).length > 0) {\n cf.paragraph = paraOpts;\n }\n }\n const cfRPr = findChild(child, \"w:rPr\");\n if (cfRPr) {\n const runOpts = parseRunProperties(cfRPr);\n if (Object.keys(runOpts).length > 0) cf.run = runOpts;\n }\n const cfTblPr = findChild(child, \"w:tblPr\");\n if (cfTblPr) {\n const tableOpts = parseTablePropertiesEl(cfTblPr);\n if (Object.keys(tableOpts).length > 0) cf.table = tableOpts;\n }\n const cfTrPr = findChild(child, \"w:trPr\");\n if (cfTrPr) {\n const rowOpts = parseTableRowPropertiesEl(cfTrPr);\n if (Object.keys(rowOpts).length > 0) cf.row = rowOpts;\n }\n const cfTcPr = findChild(child, \"w:tcPr\");\n if (cfTcPr) {\n const cellOpts = parseTableCellPropertiesEl(cfTcPr);\n if (Object.keys(cellOpts).length > 0) cf.cell = cellOpts;\n }\n conditionalFormats.push(cf);\n }\n if (conditionalFormats.length > 0) opts.conditionalFormats = conditionalFormats;\n\n return opts;\n}\n","/**\n * Settings descriptor — produces word/settings.xml.\n *\n * Stringifies pure JSON SettingsOptions into XML without creating\n * Settings/Compatibility/DocumentProtection/etc. class instances.\n * Zero XmlComponent allocation — pure string concatenation.\n *\n * @module\n */\n\nimport { derivePasswordHash } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, findChild, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type {\n SettingsOptions,\n DocumentProtectionOptions,\n WriteProtectionOptions,\n MailMergeOptions,\n OdsoOptions,\n OdsoFieldMapDataOptions,\n CompatibilityOptions,\n CompatSettingOptions,\n CaptionsOptions,\n CaptionOptions,\n AutoCaptionOptions,\n MathPropertiesOptions,\n RsidsOptions,\n ReadModeInkLockDownOptions,\n RevisionViewOptions,\n FootnotePropertiesOptions,\n EndnotePropertiesOptions,\n} from \"./settings\";\n\n/** Derive the namespace-prefixed val attribute from the element tag. */\nfunction valAttr(tag: string): string {\n const ns = tag.split(\":\")[0];\n return `${ns}:val`;\n}\n\nfunction onOff(tag: string, val: boolean | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val ? 1 : 0}\"/>` : \"\";\n}\n\nfunction numVal(tag: string, val: number | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${val}\"/>` : \"\";\n}\n\nfunction strVal(tag: string, val: string | undefined): string {\n return val !== undefined ? `<${tag} ${valAttr(tag)}=\"${escapeXml(val)}\"/>` : \"\";\n}\n\n/** Build attribute string from key-value pairs, skipping undefined. */\nfunction attrStr(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [k, v] of Object.entries(attrs)) {\n if (v !== undefined) parts.push(`${k}=\"${escapeXml(String(v))}\"`);\n }\n return parts.join(\" \");\n}\n\n/** Self-closing element with attributes only. */\nfunction attrEl(tag: string, attrs: Record<string, string | number | boolean | undefined>): string {\n const a = attrStr(attrs);\n return a ? `<${tag} ${a}/>` : `<${tag}/>`;\n}\n\nfunction compatSetting(name: string, val: string | number, uri?: string): string {\n const u = uri ?? \"http://schemas.microsoft.com/office/word\";\n return `<w:compatSetting w:name=\"${escapeXml(name)}\" w:uri=\"${u}\" w:val=\"${val}\"/>`;\n}\n\n// ── Parse helpers ──\n\n/** Read a CT_OnOff child as boolean (presence true unless val is explicitly false). */\nfunction readOnOff(el: Element | undefined): boolean | undefined {\n if (!el || !el.name) return undefined;\n const v = attr(el, valAttr(el.name));\n return v !== \"false\" && v !== \"0\" && v !== \"off\";\n}\n\n/** Read an attribute as a number, or undefined if absent/unparseable. */\nfunction readNum(el: Element | undefined, name: string): number | undefined {\n if (!el) return undefined;\n const v = attr(el, name);\n if (v === undefined || v === \"\") return undefined;\n const n = parseInt(v, 10);\n return Number.isNaN(n) ? undefined : n;\n}\n\n/** Read an attribute as a string, or undefined if absent. */\nfunction readStr(el: Element | undefined, name: string): string | undefined {\n if (!el) return undefined;\n const v = attr(el, name);\n return v === undefined || v === \"\" ? undefined : v;\n}\n\n/** Read an attribute constrained to an enum; undefined if absent or not allowed. */\nfunction readEnum<T extends string>(\n el: Element | undefined,\n name: string,\n allowed: readonly T[],\n): T | undefined {\n const v = readStr(el, name);\n return v !== undefined && (allowed as readonly string[]).includes(v) ? (v as T) : undefined;\n}\n\n/** Shared password/crypto attributes (AG_TransitionalPassword) → options keys. */\nconst PASSWORD_ATTR_MAP: [string, string, boolean][] = [\n [\"hashValue\", \"w:hashValue\", false],\n [\"saltValue\", \"w:saltValue\", false],\n [\"hash\", \"w:hash\", false],\n [\"salt\", \"w:salt\", false],\n [\"spinCount\", \"w:spinCount\", true],\n [\"algorithmName\", \"w:algorithmName\", false],\n [\"cryptoAlgorithmClass\", \"w:cryptAlgorithmClass\", false],\n [\"cryptoAlgorithmSid\", \"w:cryptAlgorithmSid\", true],\n [\"cryptoAlgorithmType\", \"w:cryptAlgorithmType\", false],\n [\"cryptoProvider\", \"w:cryptProvider\", false],\n [\"cryptoProviderType\", \"w:cryptProviderType\", false],\n [\"cryptoProviderTypeExtension\", \"w:cryptProviderTypeExt\", true],\n [\"cryptoProviderTypeExtensionSource\", \"w:cryptProviderTypeExtSource\", false],\n [\"algorithmExtensionId\", \"w:algIdExt\", true],\n [\"algorithmExtensionSource\", \"w:algIdExtSource\", false],\n [\"cryptoSpinCount\", \"w:cryptSpinCount\", true],\n];\n\n/** Read shared password/crypto attributes into an options object. */\nfunction readPasswordAttrs(el: Element): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [key, xmlAttr, isNum] of PASSWORD_ATTR_MAP) {\n const v = attr(el, xmlAttr);\n if (v === undefined || v === \"\") continue;\n out[key] = isNum ? parseInt(v, 10) : v;\n }\n return out;\n}\n\n/**\n * CT_OnOff compat flag elements → CompatibilityOptions keys. The XML tag often\n * differs from the option key (e.g. wordPerfectJustification → w:wpJustification).\n * Order mirrors stringifyCompatibility so round-trip preserves element order.\n */\nconst COMPAT_FLAG_MAP: [string, string][] = [\n [\"useSingleBorderforContiguousCells\", \"w:useSingleBorderforContiguousCells\"],\n [\"wordPerfectJustification\", \"w:wpJustification\"],\n [\"noTabStopForHangingIndent\", \"w:noTabHangInd\"],\n [\"noLeading\", \"w:noLeading\"],\n [\"spaceForUnderline\", \"w:spaceForUL\"],\n [\"noColumnBalance\", \"w:noColumnBalance\"],\n [\"balanceSingleByteDoubleByteWidth\", \"w:balanceSingleByteDoubleByteWidth\"],\n [\"noExtraLineSpacing\", \"w:noExtraLineSpacing\"],\n [\"doNotLeaveBackslashAlone\", \"w:doNotLeaveBackslashAlone\"],\n [\"underlineTrailingSpaces\", \"w:ulTrailSpace\"],\n [\"doNotExpandShiftReturn\", \"w:doNotExpandShiftReturn\"],\n [\"spacingInWholePoints\", \"w:spacingInWholePoints\"],\n [\"lineWrapLikeWord6\", \"w:lineWrapLikeWord6\"],\n [\"printBodyTextBeforeHeader\", \"w:printBodyTextBeforeHeader\"],\n [\"printColorsBlack\", \"w:printColBlack\"],\n [\"spaceWidth\", \"w:wpSpaceWidth\"],\n [\"showBreaksInFrames\", \"w:showBreaksInFrames\"],\n [\"subFontBySize\", \"w:subFontBySize\"],\n [\"suppressBottomSpacing\", \"w:suppressBottomSpacing\"],\n [\"suppressTopSpacing\", \"w:suppressTopSpacing\"],\n [\"suppressSpacingAtTopOfPage\", \"w:suppressSpacingAtTopOfPage\"],\n [\"suppressTopSpacingWP\", \"w:suppressTopSpacingWP\"],\n [\"suppressSpBfAfterPgBrk\", \"w:suppressSpBfAfterPgBrk\"],\n [\"swapBordersFacingPages\", \"w:swapBordersFacingPages\"],\n [\"convertMailMergeEsc\", \"w:convMailMergeEsc\"],\n [\"truncateFontHeightsLikeWP6\", \"w:truncateFontHeightsLikeWP6\"],\n [\"macWordSmallCaps\", \"w:mwSmallCaps\"],\n [\"usePrinterMetrics\", \"w:usePrinterMetrics\"],\n [\"doNotSuppressParagraphBorders\", \"w:doNotSuppressParagraphBorders\"],\n [\"wrapTrailSpaces\", \"w:wrapTrailSpaces\"],\n [\"footnoteLayoutLikeWW8\", \"w:footnoteLayoutLikeWW8\"],\n [\"shapeLayoutLikeWW8\", \"w:shapeLayoutLikeWW8\"],\n [\"alignTablesRowByRow\", \"w:alignTablesRowByRow\"],\n [\"forgetLastTabAlignment\", \"w:forgetLastTabAlignment\"],\n [\"adjustLineHeightInTable\", \"w:adjustLineHeightInTable\"],\n [\"autoSpaceLikeWord95\", \"w:autoSpaceLikeWord95\"],\n [\"noSpaceRaiseLower\", \"w:noSpaceRaiseLower\"],\n [\"doNotUseHTMLParagraphAutoSpacing\", \"w:doNotUseHTMLParagraphAutoSpacing\"],\n [\"layoutRawTableWidth\", \"w:layoutRawTableWidth\"],\n [\"layoutTableRowsApart\", \"w:layoutTableRowsApart\"],\n [\"useWord97LineBreakRules\", \"w:useWord97LineBreakRules\"],\n [\"doNotBreakWrappedTables\", \"w:doNotBreakWrappedTables\"],\n [\"doNotSnapToGridInCell\", \"w:doNotSnapToGridInCell\"],\n [\"selectFieldWithFirstOrLastCharacter\", \"w:selectFldWithFirstOrLastChar\"],\n [\"applyBreakingRules\", \"w:applyBreakingRules\"],\n [\"doNotWrapTextWithPunctuation\", \"w:doNotWrapTextWithPunct\"],\n [\"doNotUseEastAsianBreakRules\", \"w:doNotUseEastAsianBreakRules\"],\n [\"useWord2002TableStyleRules\", \"w:useWord2002TableStyleRules\"],\n [\"growAutofit\", \"w:growAutofit\"],\n [\"useFELayout\", \"w:useFELayout\"],\n [\"useNormalStyleForList\", \"w:useNormalStyleForList\"],\n [\"doNotUseIndentAsNumberingTabStop\", \"w:doNotUseIndentAsNumberingTabStop\"],\n [\"useAlternateEastAsianLineBreakRules\", \"w:useAltKinsokuLineBreakRules\"],\n [\"allowSpaceOfSameStyleInTable\", \"w:allowSpaceOfSameStyleInTable\"],\n [\"doNotSuppressIndentation\", \"w:doNotSuppressIndentation\"],\n [\"doNotAutofitConstrainedTables\", \"w:doNotAutofitConstrainedTables\"],\n [\"autofitToFirstFixedWidthCell\", \"w:autofitToFirstFixedWidthCell\"],\n [\"underlineTabInNumberingList\", \"w:underlineTabInNumList\"],\n [\"displayHangulFixedWidth\", \"w:displayHangulFixedWidth\"],\n [\"splitPgBreakAndParaMark\", \"w:splitPgBreakAndParaMark\"],\n [\"doNotVerticallyAlignCellWithSp\", \"w:doNotVertAlignCellWithSp\"],\n [\"doNotBreakConstrainedForcedTable\", \"w:doNotBreakConstrainedForcedTable\"],\n [\"ignoreVerticalAlignmentInTextboxes\", \"w:doNotVertAlignInTxbx\"],\n [\"useAnsiKerningPairs\", \"w:useAnsiKerningPairs\"],\n [\"cachedColumnBalance\", \"w:cachedColBalance\"],\n];\n\n/** compatSetting names that map to dedicated sugar fields (not into compatSettings[]). */\nconst COMPAT_SETTING_SUGAR: Record<\n string,\n | \"version\"\n | \"overrideTableStyleFontSizeAndJustification\"\n | \"enableOpenTypeFeatures\"\n | \"doNotFlipMirrorIndents\"\n> = {\n compatibilityMode: \"version\",\n overrideTableStyleFontSizeAndJustification: \"overrideTableStyleFontSizeAndJustification\",\n enableOpenTypeFeatures: \"enableOpenTypeFeatures\",\n doNotFlipMirrorIndents: \"doNotFlipMirrorIndents\",\n};\n\n/** Parse w:footnotePr / w:endnotePr (CT_FtnDocProps / CT_EdnDocProps). */\nfunction parseFtnEdnPr(el: Element): Record<string, unknown> | undefined {\n const o: Record<string, unknown> = {};\n const pos = readStr(findChild(el, \"w:pos\"), \"w:val\");\n if (pos) o.pos = pos;\n const numFmtEl = findChild(el, \"w:numFmt\");\n if (numFmtEl) {\n const v = readStr(numFmtEl, \"w:val\");\n if (v) o.numFmt = v;\n const format = readStr(numFmtEl, \"w:format\");\n if (format) o.format = format;\n }\n const numStart = readNum(findChild(el, \"w:numStart\"), \"w:val\");\n if (numStart !== undefined) o.numStart = numStart;\n const numRestart = readStr(findChild(el, \"w:numRestart\"), \"w:val\");\n if (numRestart) o.numRestart = numRestart;\n return Object.keys(o).length > 0 ? o : undefined;\n}\n\n/** Parse w:compat (CT_Compat): on/off flag elements + w:compatSetting entries. */\nfunction parseCompatibility(el: Element): CompatibilityOptions | undefined {\n const o: Record<string, unknown> = {};\n const flagMap: Record<string, string> = Object.fromEntries(\n COMPAT_FLAG_MAP.map(([key, tag]) => [tag, key]),\n );\n const extras: CompatSettingOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.type !== \"element\" || !child.name) continue;\n const key = flagMap[child.name];\n if (key !== undefined) {\n o[key] = true;\n continue;\n }\n if (child.name === \"w:compatSetting\") {\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name === undefined || val === undefined) continue;\n const sugar = COMPAT_SETTING_SUGAR[name];\n if (sugar === \"version\") {\n const n = parseInt(val, 10);\n if (!Number.isNaN(n)) o.version = n;\n } else if (sugar !== undefined) {\n o[sugar] = val !== \"0\" && val !== \"false\";\n } else {\n extras.push({ name, val, uri: attr(child, \"w:uri\") });\n }\n }\n }\n if (extras.length > 0) o.compatSettings = extras;\n return Object.keys(o).length > 0 ? (o as CompatibilityOptions) : undefined;\n}\n\n/** Parse m:mathPr (CT_MathPr). */\nfunction parseMathPr(el: Element): MathPropertiesOptions | undefined {\n const o: Partial<MathPropertiesOptions> = {};\n const mathFont = readStr(findChild(el, \"m:mathFont\"), \"m:val\");\n if (mathFont) o.mathFont = mathFont;\n const binaryOperatorBreak = readEnum(findChild(el, \"m:brkBin\"), \"m:val\", [\n \"before\",\n \"after\",\n \"repeat\",\n ] as const);\n if (binaryOperatorBreak) o.binaryOperatorBreak = binaryOperatorBreak;\n const binaryOperatorBreakSubtraction = readEnum(findChild(el, \"m:brkBinSub\"), \"m:val\", [\n \"--\",\n \"-+\",\n \"+-\",\n ] as const);\n if (binaryOperatorBreakSubtraction)\n o.binaryOperatorBreakSubtraction = binaryOperatorBreakSubtraction;\n const smallFractions = readOnOff(findChild(el, \"m:smallFrac\"));\n if (smallFractions !== undefined) o.smallFractions = smallFractions;\n const displayDefaults = readOnOff(findChild(el, \"m:dispDef\"));\n if (displayDefaults !== undefined) o.displayDefaults = displayDefaults;\n const leftMargin = readNum(findChild(el, \"m:lMargin\"), \"m:val\");\n if (leftMargin !== undefined) o.leftMargin = leftMargin;\n const rightMargin = readNum(findChild(el, \"m:rMargin\"), \"m:val\");\n if (rightMargin !== undefined) o.rightMargin = rightMargin;\n const defaultJustification = readEnum(findChild(el, \"m:defJc\"), \"m:val\", [\n \"left\",\n \"right\",\n \"center\",\n \"centerGroup\",\n ] as const);\n if (defaultJustification) o.defaultJustification = defaultJustification;\n const preSpacing = readNum(findChild(el, \"m:preSp\"), \"m:val\");\n if (preSpacing !== undefined) o.preSpacing = preSpacing;\n const postSpacing = readNum(findChild(el, \"m:postSp\"), \"m:val\");\n if (postSpacing !== undefined) o.postSpacing = postSpacing;\n const interSpacing = readNum(findChild(el, \"m:interSp\"), \"m:val\");\n if (interSpacing !== undefined) o.interSpacing = interSpacing;\n const intraSpacing = readNum(findChild(el, \"m:intraSp\"), \"m:val\");\n if (intraSpacing !== undefined) o.intraSpacing = intraSpacing;\n const wrapIndent = readNum(findChild(el, \"m:wrapIndent\"), \"m:val\");\n if (wrapIndent !== undefined) o.wrapIndent = wrapIndent;\n const wrapRight = readOnOff(findChild(el, \"m:wrapRight\"));\n if (wrapRight !== undefined) o.wrapRight = wrapRight;\n const integralLimitLocation = readEnum(findChild(el, \"m:intLim\"), \"m:val\", [\n \"subSup\",\n \"undOvr\",\n ] as const);\n if (integralLimitLocation) o.integralLimitLocation = integralLimitLocation;\n const naryLimitLocation = readEnum(findChild(el, \"m:naryLim\"), \"m:val\", [\n \"subSup\",\n \"undOvr\",\n ] as const);\n if (naryLimitLocation) o.naryLimitLocation = naryLimitLocation;\n return Object.keys(o).length > 0 ? (o as MathPropertiesOptions) : undefined;\n}\n\n/** Parse w:captions (CT_Captions). */\nfunction parseCaptions(el: Element): CaptionsOptions | undefined {\n const captions: CaptionOptions[] = [];\n const autoCaptions: AutoCaptionOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.type !== \"element\") continue;\n if (child.name === \"w:caption\") {\n const c: CaptionOptions = { name: attr(child, \"w:name\") ?? \"\" };\n const pos = attr(child, \"w:pos\");\n if (pos) c.pos = pos as CaptionOptions[\"pos\"];\n const chapNum = attr(child, \"w:chapNum\");\n if (chapNum !== undefined) c.chapNum = chapNum === \"1\";\n const heading = attr(child, \"w:heading\");\n if (heading !== undefined) c.heading = parseInt(heading, 10);\n const noLabel = attr(child, \"w:noLabel\");\n if (noLabel !== undefined) c.noLabel = noLabel === \"1\";\n const numFmt = attr(child, \"w:numFmt\");\n if (numFmt) c.numFmt = numFmt;\n const sep = attr(child, \"w:sep\");\n if (sep) c.sep = sep as CaptionOptions[\"sep\"];\n captions.push(c);\n } else if (child.name === \"w:autoCaptions\") {\n for (const ac of child.elements ?? []) {\n if (ac.name !== \"w:autoCaption\") continue;\n const name = attr(ac, \"w:name\");\n const caption = attr(ac, \"w:caption\");\n if (name && caption) autoCaptions.push({ name, caption });\n }\n }\n }\n if (captions.length === 0) return undefined;\n const o: CaptionsOptions = { captions };\n if (autoCaptions.length > 0) o.autoCaptions = autoCaptions;\n return o;\n}\n\n/** Parse w:odso (CT_Odso). */\nfunction parseOdso(el: Element): OdsoOptions | undefined {\n const o: OdsoOptions = {};\n const udl = readStr(findChild(el, \"w:udl\"), \"w:val\");\n if (udl) o.udl = udl;\n const table = readStr(findChild(el, \"w:table\"), \"w:val\");\n if (table) o.table = table;\n const srcEl = findChild(el, \"w:src\");\n if (srcEl) {\n const rid = attr(srcEl, \"r:id\");\n if (rid) o.src = rid;\n }\n const colDelim = readNum(findChild(el, \"w:colDelim\"), \"w:val\");\n if (colDelim !== undefined) o.colDelim = colDelim;\n const type = readStr(findChild(el, \"w:type\"), \"w:val\");\n if (type) o.type = type as OdsoOptions[\"type\"];\n const fHdr = readOnOff(findChild(el, \"w:fHdr\"));\n if (fHdr !== undefined) o.fHdr = fHdr;\n const fieldMapData: OdsoFieldMapDataOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:fieldMapData\") continue;\n const fm: OdsoFieldMapDataOptions = {};\n const t = readStr(findChild(child, \"w:type\"), \"w:val\");\n if (t) fm.type = t as OdsoFieldMapDataOptions[\"type\"];\n const n = readStr(findChild(child, \"w:name\"), \"w:val\");\n if (n) fm.name = n;\n const mn = readStr(findChild(child, \"w:mappedName\"), \"w:val\");\n if (mn) fm.mappedName = mn;\n const col = readNum(findChild(child, \"w:column\"), \"w:val\");\n if (col !== undefined) fm.column = col;\n const lid = readStr(findChild(child, \"w:lid\"), \"w:val\");\n if (lid) fm.lid = lid;\n const dyn = readOnOff(findChild(child, \"w:dynamicAddress\"));\n if (dyn !== undefined) fm.dynamicAddress = dyn;\n if (Object.keys(fm).length > 0) fieldMapData.push(fm);\n }\n if (fieldMapData.length > 0) o.fieldMapData = fieldMapData;\n const recipientData: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:recipientData\") continue;\n const rid = attr(child, \"r:id\");\n if (rid) recipientData.push(rid);\n }\n if (recipientData.length > 0) o.recipientData = recipientData;\n const uniqueTag = readStr(findChild(el, \"w:uniqueTag\"), \"w:val\");\n if (uniqueTag) o.uniqueTag = uniqueTag;\n return Object.keys(o).length > 0 ? o : undefined;\n}\n\n/** Parse w:mailMerge (CT_MailMerge). */\nfunction parseMailMerge(el: Element): MailMergeOptions | undefined {\n const o: Partial<MailMergeOptions> = {};\n const mdt = readStr(findChild(el, \"w:mainDocumentType\"), \"w:val\");\n if (mdt) o.mainDocumentType = mdt as MailMergeOptions[\"mainDocumentType\"];\n const dataType = readStr(findChild(el, \"w:dataType\"), \"w:val\");\n if (dataType) o.dataType = dataType as MailMergeOptions[\"dataType\"];\n const dest = readStr(findChild(el, \"w:destination\"), \"w:val\");\n if (dest) o.destination = dest as MailMergeOptions[\"destination\"];\n const connectString = readStr(findChild(el, \"w:connectString\"), \"w:val\");\n if (connectString) o.connectString = connectString;\n const query = readStr(findChild(el, \"w:query\"), \"w:val\");\n if (query) o.query = query;\n const dsEl = findChild(el, \"w:dataSource\");\n if (dsEl) {\n const rid = attr(dsEl, \"r:id\");\n if (rid) o.dataSource = rid;\n }\n const hsEl = findChild(el, \"w:headerSource\");\n if (hsEl) {\n const rid = attr(hsEl, \"r:id\");\n if (rid) o.headerSource = rid;\n }\n const linkToQuery = readOnOff(findChild(el, \"w:linkToQuery\"));\n if (linkToQuery !== undefined) o.linkToQuery = linkToQuery;\n const doNotSuppress = readOnOff(findChild(el, \"w:doNotSuppressBlankLines\"));\n if (doNotSuppress !== undefined) o.doNotSuppressBlankLines = doNotSuppress;\n const addressFieldName = readStr(findChild(el, \"w:addressFieldName\"), \"w:val\");\n if (addressFieldName) o.addressFieldName = addressFieldName;\n const mailSubject = readStr(findChild(el, \"w:mailSubject\"), \"w:val\");\n if (mailSubject) o.mailSubject = mailSubject;\n const mailAsAttachment = readOnOff(findChild(el, \"w:mailAsAttachment\"));\n if (mailAsAttachment !== undefined) o.mailAsAttachment = mailAsAttachment;\n const viewMergedData = readOnOff(findChild(el, \"w:viewMergedData\"));\n if (viewMergedData !== undefined) o.viewMergedData = viewMergedData;\n const activeRecord = readNum(findChild(el, \"w:activeRecord\"), \"w:val\");\n if (activeRecord !== undefined) o.activeRecord = activeRecord;\n const checkErrors = readNum(findChild(el, \"w:checkErrors\"), \"w:val\");\n if (checkErrors !== undefined) o.checkErrors = checkErrors;\n const active = readOnOff(findChild(el, \"w:active\"));\n if (active !== undefined) o.active = active;\n const recipientsEl = findChild(el, \"w:recipients\");\n if (recipientsEl) {\n const rid = attr(recipientsEl, \"r:id\");\n if (rid) o.recipients = rid;\n }\n const odsoEl = findChild(el, \"w:odso\");\n if (odsoEl) {\n const odso = parseOdso(odsoEl);\n if (odso) o.odso = odso;\n }\n if (Object.keys(o).length === 0) return undefined;\n return o as MailMergeOptions;\n}\n\n// ── Password derivation ──\n\ninterface DerivedPassword {\n hashValue: string;\n saltValue: string;\n spinCount: number;\n algorithmName: string;\n}\n\nfunction maybeDerive(\n password: string | undefined,\n hashValue: string | undefined,\n): DerivedPassword | undefined {\n return password !== undefined && hashValue === undefined\n ? derivePasswordHash(password)\n : undefined;\n}\n\n// ── Complex sub-elements ──\n\n/** Valid w:documentProtection/@w:edit values (ST_DocProtect). */\nconst DOC_PROTECT_EDITS = [\"none\", \"readOnly\", \"comments\", \"trackedChanges\", \"forms\"] as const;\n\nfunction stringifyDocProtect(opts: DocumentProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = { \"w:enforcement\": \"1\" };\n if (opts.edit !== undefined) attrs[\"w:edit\"] = opts.edit;\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"1\" : \"0\";\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:documentProtection\", attrs);\n}\n\nfunction stringifyWriteProtect(opts: WriteProtectionOptions): string {\n const derived = maybeDerive(opts.password, opts.hashValue);\n const attrs: Record<string, string | number> = {};\n if (opts.recommended !== undefined) attrs[\"w:recommended\"] = opts.recommended ? \"1\" : \"0\";\n if (opts.hashValue ?? derived?.hashValue)\n attrs[\"w:hashValue\"] = opts.hashValue ?? derived!.hashValue;\n if (opts.saltValue ?? derived?.saltValue)\n attrs[\"w:saltValue\"] = opts.saltValue ?? derived!.saltValue;\n if (opts.hash !== undefined) attrs[\"w:hash\"] = opts.hash;\n if (opts.salt !== undefined) attrs[\"w:salt\"] = opts.salt;\n if (opts.spinCount ?? derived?.spinCount)\n attrs[\"w:spinCount\"] = opts.spinCount ?? derived!.spinCount;\n if (opts.algorithmName ?? derived?.algorithmName)\n attrs[\"w:algorithmName\"] = opts.algorithmName ?? derived!.algorithmName;\n if (opts.cryptoAlgorithmClass !== undefined)\n attrs[\"w:cryptAlgorithmClass\"] = opts.cryptoAlgorithmClass;\n if (opts.cryptoAlgorithmSid !== undefined) attrs[\"w:cryptAlgorithmSid\"] = opts.cryptoAlgorithmSid;\n if (opts.cryptoAlgorithmType !== undefined)\n attrs[\"w:cryptAlgorithmType\"] = opts.cryptoAlgorithmType;\n if (opts.cryptoProvider !== undefined) attrs[\"w:cryptProvider\"] = opts.cryptoProvider;\n if (opts.cryptoProviderType !== undefined) attrs[\"w:cryptProviderType\"] = opts.cryptoProviderType;\n if (opts.algorithmExtensionId !== undefined) attrs[\"w:algIdExt\"] = opts.algorithmExtensionId;\n if (opts.algorithmExtensionSource !== undefined)\n attrs[\"w:algIdExtSource\"] = opts.algorithmExtensionSource;\n if (opts.cryptoProviderTypeExtension !== undefined)\n attrs[\"w:cryptProviderTypeExt\"] = opts.cryptoProviderTypeExtension;\n if (opts.cryptoProviderTypeExtensionSource !== undefined)\n attrs[\"w:cryptProviderTypeExtSource\"] = opts.cryptoProviderTypeExtensionSource;\n if (opts.cryptoSpinCount !== undefined) attrs[\"w:cryptSpinCount\"] = opts.cryptoSpinCount;\n return attrEl(\"w:writeProtection\", attrs);\n}\n\nfunction stringifyRevisionView(opts: RevisionViewOptions): string {\n const attrs: Record<string, string> = {};\n if (opts.markup !== undefined) attrs[\"w:markup\"] = opts.markup ? \"true\" : \"false\";\n if (opts.comments !== undefined) attrs[\"w:comments\"] = opts.comments ? \"true\" : \"false\";\n if (opts.insDel !== undefined) attrs[\"w:insDel\"] = opts.insDel ? \"true\" : \"false\";\n if (opts.formatting !== undefined) attrs[\"w:formatting\"] = opts.formatting ? \"true\" : \"false\";\n if (opts.inkAnnotations !== undefined)\n attrs[\"w:inkAnnotations\"] = opts.inkAnnotations ? \"true\" : \"false\";\n return attrEl(\"w:revisionView\", attrs);\n}\n\nfunction stringifyMailMerge(opts: MailMergeOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:mainDocumentType\", opts.mainDocumentType));\n p.push(onOff(\"w:linkToQuery\", opts.linkToQuery));\n p.push(strVal(\"w:dataType\", opts.dataType));\n p.push(strVal(\"w:connectString\", opts.connectString));\n p.push(strVal(\"w:query\", opts.query));\n if (opts.dataSource !== undefined) p.push(attrEl(\"w:dataSource\", { \"r:id\": opts.dataSource }));\n if (opts.headerSource !== undefined)\n p.push(attrEl(\"w:headerSource\", { \"r:id\": opts.headerSource }));\n p.push(onOff(\"w:doNotSuppressBlankLines\", opts.doNotSuppressBlankLines));\n p.push(strVal(\"w:destination\", opts.destination));\n p.push(strVal(\"w:addressFieldName\", opts.addressFieldName));\n p.push(strVal(\"w:mailSubject\", opts.mailSubject));\n p.push(onOff(\"w:mailAsAttachment\", opts.mailAsAttachment));\n p.push(onOff(\"w:viewMergedData\", opts.viewMergedData));\n p.push(numVal(\"w:activeRecord\", opts.activeRecord));\n p.push(numVal(\"w:checkErrors\", opts.checkErrors));\n if (opts.odso !== undefined) p.push(stringifyOdso(opts.odso));\n p.push(onOff(\"w:active\", opts.active));\n if (opts.recipients !== undefined) p.push(attrEl(\"w:recipients\", { \"r:id\": opts.recipients }));\n return `<w:mailMerge>${p.join(\"\")}</w:mailMerge>`;\n}\n\nfunction stringifyOdso(opts: OdsoOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:udl\", opts.udl));\n p.push(strVal(\"w:table\", opts.table));\n if (opts.src !== undefined) p.push(attrEl(\"w:src\", { \"r:id\": opts.src }));\n p.push(numVal(\"w:colDelim\", opts.colDelim));\n p.push(strVal(\"w:type\", opts.type));\n p.push(onOff(\"w:fHdr\", opts.fHdr));\n if (opts.fieldMapData !== undefined) {\n for (const fm of opts.fieldMapData) p.push(stringifyOdsoFieldMap(fm));\n }\n if (opts.recipientData !== undefined) {\n for (const rd of opts.recipientData) p.push(attrEl(\"w:recipientData\", { \"r:id\": rd }));\n }\n p.push(strVal(\"w:uniqueTag\", opts.uniqueTag));\n return `<w:odso>${p.join(\"\")}</w:odso>`;\n}\n\nfunction stringifyOdsoFieldMap(opts: OdsoFieldMapDataOptions): string {\n const p: string[] = [];\n p.push(strVal(\"w:type\", opts.type));\n p.push(strVal(\"w:name\", opts.name));\n p.push(strVal(\"w:mappedName\", opts.mappedName));\n p.push(numVal(\"w:column\", opts.column));\n p.push(strVal(\"w:lid\", opts.lid));\n p.push(onOff(\"w:dynamicAddress\", opts.dynamicAddress));\n return `<w:fieldMapData>${p.join(\"\")}</w:fieldMapData>`;\n}\n\nfunction stringifyFootnotePr(opts: FootnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:footnotePr>${p.join(\"\")}</w:footnotePr>`;\n}\n\nfunction stringifyEndnotePr(opts: EndnotePropertiesOptions): string {\n const p: string[] = [];\n if (opts.pos !== undefined) p.push(attrEl(\"w:pos\", { \"w:val\": opts.pos }));\n if (opts.numFmt !== undefined || opts.format !== undefined) {\n const a: Record<string, string> = {};\n if (opts.numFmt !== undefined) a[\"w:val\"] = opts.numFmt;\n if (opts.format !== undefined) a[\"w:format\"] = opts.format;\n p.push(attrEl(\"w:numFmt\", a));\n }\n p.push(numVal(\"w:numStart\", opts.numStart));\n p.push(strVal(\"w:numRestart\", opts.numRestart));\n return `<w:endnotePr>${p.join(\"\")}</w:endnotePr>`;\n}\n\nfunction stringifyRsids(opts: RsidsOptions): string {\n const p: string[] = [];\n if (opts.rsidRoot !== undefined) p.push(attrEl(\"w:rsidRoot\", { \"w:val\": opts.rsidRoot }));\n if (opts.rsids !== undefined) {\n for (const rsid of opts.rsids) p.push(attrEl(\"w:rsid\", { \"w:val\": rsid }));\n }\n return `<w:rsids>${p.join(\"\")}</w:rsids>`;\n}\n\nfunction stringifyReadModeInkLockDown(opts: ReadModeInkLockDownOptions): string {\n return attrEl(\"w:readModeInkLockDown\", {\n \"w:actualPg\": opts.actualPg === false ? \"0\" : \"1\",\n \"w:w\": opts.w,\n \"w:h\": opts.h,\n \"w:fontSz\": opts.fontSz,\n });\n}\n\nfunction stringifyCaptions(opts: CaptionsOptions): string {\n const p: string[] = [];\n for (const cap of opts.captions) {\n const attrs: Record<string, string | number> = { \"w:name\": cap.name };\n if (cap.pos !== undefined) attrs[\"w:pos\"] = cap.pos;\n if (cap.chapNum !== undefined) attrs[\"w:chapNum\"] = cap.chapNum ? \"1\" : \"0\";\n if (cap.heading !== undefined) attrs[\"w:heading\"] = cap.heading;\n if (cap.noLabel !== undefined) attrs[\"w:noLabel\"] = cap.noLabel ? \"1\" : \"0\";\n if (cap.numFmt !== undefined) attrs[\"w:numFmt\"] = cap.numFmt;\n if (cap.sep !== undefined) attrs[\"w:sep\"] = cap.sep;\n p.push(attrEl(\"w:caption\", attrs));\n }\n if (opts.autoCaptions?.length) {\n const acXml = opts.autoCaptions\n .map((ac) => attrEl(\"w:autoCaption\", { \"w:name\": ac.name, \"w:caption\": ac.caption }))\n .join(\"\");\n p.push(`<w:autoCaptions>${acXml}</w:autoCaptions>`);\n }\n return `<w:captions>${p.join(\"\")}</w:captions>`;\n}\n\nfunction stringifyMathPr(opts: MathPropertiesOptions): string {\n const p: string[] = [];\n if (opts.mathFont !== undefined) p.push(attrEl(\"m:mathFont\", { \"m:val\": opts.mathFont }));\n if (opts.binaryOperatorBreak !== undefined)\n p.push(attrEl(\"m:brkBin\", { \"m:val\": opts.binaryOperatorBreak }));\n if (opts.binaryOperatorBreakSubtraction !== undefined)\n p.push(attrEl(\"m:brkBinSub\", { \"m:val\": opts.binaryOperatorBreakSubtraction }));\n p.push(onOff(\"m:smallFrac\", opts.smallFractions));\n p.push(onOff(\"m:dispDef\", opts.displayDefaults));\n p.push(numVal(\"m:lMargin\", opts.leftMargin));\n p.push(numVal(\"m:rMargin\", opts.rightMargin));\n if (opts.defaultJustification !== undefined)\n p.push(attrEl(\"m:defJc\", { \"m:val\": opts.defaultJustification }));\n p.push(numVal(\"m:preSp\", opts.preSpacing));\n p.push(numVal(\"m:postSp\", opts.postSpacing));\n p.push(numVal(\"m:interSp\", opts.interSpacing));\n p.push(numVal(\"m:intraSp\", opts.intraSpacing));\n p.push(numVal(\"m:wrapIndent\", opts.wrapIndent));\n p.push(onOff(\"m:wrapRight\", opts.wrapRight));\n if (opts.integralLimitLocation !== undefined)\n p.push(attrEl(\"m:intLim\", { \"m:val\": opts.integralLimitLocation }));\n if (opts.naryLimitLocation !== undefined)\n p.push(attrEl(\"m:naryLim\", { \"m:val\": opts.naryLimitLocation }));\n return `<m:mathPr>${p.join(\"\")}</m:mathPr>`;\n}\n\nfunction stringifyColorSchemeMapping(\n opts: NonNullable<SettingsOptions[\"colorSchemeMapping\"]>,\n): string {\n const attrs: Record<string, string> = {};\n if (opts.bg1 !== undefined) attrs[\"w:bg1\"] = opts.bg1;\n if (opts.t1 !== undefined) attrs[\"w:t1\"] = opts.t1;\n if (opts.bg2 !== undefined) attrs[\"w:bg2\"] = opts.bg2;\n if (opts.t2 !== undefined) attrs[\"w:t2\"] = opts.t2;\n if (opts.accent1 !== undefined) attrs[\"w:accent1\"] = opts.accent1;\n if (opts.accent2 !== undefined) attrs[\"w:accent2\"] = opts.accent2;\n if (opts.accent3 !== undefined) attrs[\"w:accent3\"] = opts.accent3;\n if (opts.accent4 !== undefined) attrs[\"w:accent4\"] = opts.accent4;\n if (opts.accent5 !== undefined) attrs[\"w:accent5\"] = opts.accent5;\n if (opts.accent6 !== undefined) attrs[\"w:accent6\"] = opts.accent6;\n if (opts.hyperlink !== undefined) attrs[\"w:hyperlink\"] = opts.hyperlink;\n if (opts.followedHyperlink !== undefined) attrs[\"w:followedHyperlink\"] = opts.followedHyperlink;\n return attrEl(\"w:clrSchemeMapping\", attrs);\n}\n\n// ── Compatibility ──\n\nfunction stringifyCompatibility(opts: CompatibilityOptions): string {\n const p: string[] = [];\n // Individual compat on/off elements (XSD order)\n if (opts.useSingleBorderforContiguousCells)\n p.push(onOff(\"w:useSingleBorderforContiguousCells\", true));\n if (opts.wordPerfectJustification) p.push(onOff(\"w:wpJustification\", true));\n if (opts.noTabStopForHangingIndent) p.push(onOff(\"w:noTabHangInd\", true));\n if (opts.noLeading) p.push(onOff(\"w:noLeading\", true));\n if (opts.spaceForUnderline) p.push(onOff(\"w:spaceForUL\", true));\n if (opts.noColumnBalance) p.push(onOff(\"w:noColumnBalance\", true));\n if (opts.balanceSingleByteDoubleByteWidth)\n p.push(onOff(\"w:balanceSingleByteDoubleByteWidth\", true));\n if (opts.noExtraLineSpacing) p.push(onOff(\"w:noExtraLineSpacing\", true));\n if (opts.doNotLeaveBackslashAlone) p.push(onOff(\"w:doNotLeaveBackslashAlone\", true));\n if (opts.underlineTrailingSpaces) p.push(onOff(\"w:ulTrailSpace\", true));\n if (opts.doNotExpandShiftReturn) p.push(onOff(\"w:doNotExpandShiftReturn\", true));\n if (opts.spacingInWholePoints) p.push(onOff(\"w:spacingInWholePoints\", true));\n if (opts.lineWrapLikeWord6) p.push(onOff(\"w:lineWrapLikeWord6\", true));\n if (opts.printBodyTextBeforeHeader) p.push(onOff(\"w:printBodyTextBeforeHeader\", true));\n if (opts.printColorsBlack) p.push(onOff(\"w:printColBlack\", true));\n if (opts.spaceWidth) p.push(onOff(\"w:wpSpaceWidth\", true));\n if (opts.showBreaksInFrames) p.push(onOff(\"w:showBreaksInFrames\", true));\n if (opts.subFontBySize) p.push(onOff(\"w:subFontBySize\", true));\n if (opts.suppressBottomSpacing) p.push(onOff(\"w:suppressBottomSpacing\", true));\n if (opts.suppressTopSpacing) p.push(onOff(\"w:suppressTopSpacing\", true));\n if (opts.suppressSpacingAtTopOfPage) p.push(onOff(\"w:suppressSpacingAtTopOfPage\", true));\n if (opts.suppressTopSpacingWP) p.push(onOff(\"w:suppressTopSpacingWP\", true));\n if (opts.suppressSpBfAfterPgBrk) p.push(onOff(\"w:suppressSpBfAfterPgBrk\", true));\n if (opts.swapBordersFacingPages) p.push(onOff(\"w:swapBordersFacingPages\", true));\n if (opts.convertMailMergeEsc) p.push(onOff(\"w:convMailMergeEsc\", true));\n if (opts.truncateFontHeightsLikeWP6) p.push(onOff(\"w:truncateFontHeightsLikeWP6\", true));\n if (opts.macWordSmallCaps) p.push(onOff(\"w:mwSmallCaps\", true));\n if (opts.usePrinterMetrics) p.push(onOff(\"w:usePrinterMetrics\", true));\n if (opts.doNotSuppressParagraphBorders) p.push(onOff(\"w:doNotSuppressParagraphBorders\", true));\n if (opts.wrapTrailSpaces) p.push(onOff(\"w:wrapTrailSpaces\", true));\n if (opts.footnoteLayoutLikeWW8) p.push(onOff(\"w:footnoteLayoutLikeWW8\", true));\n if (opts.shapeLayoutLikeWW8) p.push(onOff(\"w:shapeLayoutLikeWW8\", true));\n if (opts.alignTablesRowByRow) p.push(onOff(\"w:alignTablesRowByRow\", true));\n if (opts.forgetLastTabAlignment) p.push(onOff(\"w:forgetLastTabAlignment\", true));\n if (opts.adjustLineHeightInTable) p.push(onOff(\"w:adjustLineHeightInTable\", true));\n if (opts.autoSpaceLikeWord95) p.push(onOff(\"w:autoSpaceLikeWord95\", true));\n if (opts.noSpaceRaiseLower) p.push(onOff(\"w:noSpaceRaiseLower\", true));\n if (opts.doNotUseHTMLParagraphAutoSpacing)\n p.push(onOff(\"w:doNotUseHTMLParagraphAutoSpacing\", true));\n if (opts.layoutRawTableWidth) p.push(onOff(\"w:layoutRawTableWidth\", true));\n if (opts.layoutTableRowsApart) p.push(onOff(\"w:layoutTableRowsApart\", true));\n if (opts.useWord97LineBreakRules) p.push(onOff(\"w:useWord97LineBreakRules\", true));\n if (opts.doNotBreakWrappedTables) p.push(onOff(\"w:doNotBreakWrappedTables\", true));\n if (opts.doNotSnapToGridInCell) p.push(onOff(\"w:doNotSnapToGridInCell\", true));\n if (opts.selectFieldWithFirstOrLastCharacter)\n p.push(onOff(\"w:selectFldWithFirstOrLastChar\", true));\n if (opts.applyBreakingRules) p.push(onOff(\"w:applyBreakingRules\", true));\n if (opts.doNotWrapTextWithPunctuation) p.push(onOff(\"w:doNotWrapTextWithPunct\", true));\n if (opts.doNotUseEastAsianBreakRules) p.push(onOff(\"w:doNotUseEastAsianBreakRules\", true));\n if (opts.useWord2002TableStyleRules) p.push(onOff(\"w:useWord2002TableStyleRules\", true));\n if (opts.growAutofit) p.push(onOff(\"w:growAutofit\", true));\n if (opts.useFELayout) p.push(onOff(\"w:useFELayout\", true));\n if (opts.useNormalStyleForList) p.push(onOff(\"w:useNormalStyleForList\", true));\n if (opts.doNotUseIndentAsNumberingTabStop)\n p.push(onOff(\"w:doNotUseIndentAsNumberingTabStop\", true));\n if (opts.useAlternateEastAsianLineBreakRules)\n p.push(onOff(\"w:useAltKinsokuLineBreakRules\", true));\n if (opts.allowSpaceOfSameStyleInTable) p.push(onOff(\"w:allowSpaceOfSameStyleInTable\", true));\n if (opts.doNotSuppressIndentation) p.push(onOff(\"w:doNotSuppressIndentation\", true));\n if (opts.doNotAutofitConstrainedTables) p.push(onOff(\"w:doNotAutofitConstrainedTables\", true));\n if (opts.autofitToFirstFixedWidthCell) p.push(onOff(\"w:autofitToFirstFixedWidthCell\", true));\n if (opts.underlineTabInNumberingList) p.push(onOff(\"w:underlineTabInNumList\", true));\n if (opts.displayHangulFixedWidth) p.push(onOff(\"w:displayHangulFixedWidth\", true));\n if (opts.splitPgBreakAndParaMark) p.push(onOff(\"w:splitPgBreakAndParaMark\", true));\n if (opts.doNotVerticallyAlignCellWithSp) p.push(onOff(\"w:doNotVertAlignCellWithSp\", true));\n if (opts.doNotBreakConstrainedForcedTable)\n p.push(onOff(\"w:doNotBreakConstrainedForcedTable\", true));\n if (opts.ignoreVerticalAlignmentInTextboxes) p.push(onOff(\"w:doNotVertAlignInTxbx\", true));\n if (opts.useAnsiKerningPairs) p.push(onOff(\"w:useAnsiKerningPairs\", true));\n if (opts.cachedColumnBalance) p.push(onOff(\"w:cachedColBalance\", true));\n // compatSetting elements last (XSD order)\n if (opts.version) p.push(compatSetting(\"compatibilityMode\", opts.version));\n if (opts.overrideTableStyleFontSizeAndJustification)\n p.push(compatSetting(\"overrideTableStyleFontSizeAndJustification\", 1));\n if (opts.enableOpenTypeFeatures) p.push(compatSetting(\"enableOpenTypeFeatures\", 1));\n if (opts.doNotFlipMirrorIndents) p.push(compatSetting(\"doNotFlipMirrorIndents\", 1));\n\n // Additional compatSetting entries (sugar fields above take precedence on name clash)\n if (opts.compatSettings) {\n const emitted = new Set<string>();\n if (opts.version) emitted.add(\"compatibilityMode\");\n if (opts.overrideTableStyleFontSizeAndJustification)\n emitted.add(\"overrideTableStyleFontSizeAndJustification\");\n if (opts.enableOpenTypeFeatures) emitted.add(\"enableOpenTypeFeatures\");\n if (opts.doNotFlipMirrorIndents) emitted.add(\"doNotFlipMirrorIndents\");\n for (const cs of opts.compatSettings) {\n if (emitted.has(cs.name)) continue;\n p.push(compatSetting(cs.name, cs.val, cs.uri));\n emitted.add(cs.name);\n }\n }\n return p.length ? `<w:compat>${p.join(\"\")}</w:compat>` : \"\";\n}\n\n// ── Namespace attributes ──\n\nconst SETTINGS_NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'mc:Ignorable=\"w14 w15 wp14\"';\n\n// ── Descriptor ──\n\nexport const settingsDesc: CustomDescriptor<SettingsOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n // Round-trip: when parse captured the settings part verbatim, re-emit it\n // as-is (the structured path below only covers a subset of CT_Settings).\n // Use captured root attributes (xmlns:* + mc:Ignorable) so source-specific\n // namespaces (xmlns:sl, xmlns:wpsCustomData, …) are preserved.\n if (opts.rawXml !== undefined) {\n const ns = opts.rootAttributes ? attrStr(opts.rootAttributes) : SETTINGS_NS;\n return `<w:settings ${ns}>${opts.rawXml}</w:settings>`;\n }\n\n const p: string[] = [];\n\n // XSD CT_Settings sequence order\n if (opts.writeProtection !== undefined) p.push(stringifyWriteProtect(opts.writeProtection));\n if (opts.view !== undefined) p.push(attrEl(\"w:view\", { \"w:val\": opts.view }));\n if (opts.zoom !== undefined)\n p.push(attrEl(\"w:zoom\", { \"w:percent\": opts.zoom.percent ?? 100, \"w:val\": opts.zoom.val }));\n p.push(onOff(\"w:removePersonalInformation\", opts.removePersonalInformation));\n p.push(onOff(\"w:removeDateAndTime\", opts.removeDateAndTime));\n // XSD order: doNotDisplayPageBoundaries (5) → displayBackgroundShape (6)\n p.push(onOff(\"w:doNotDisplayPageBoundaries\", opts.doNotDisplayPageBoundaries));\n p.push(onOff(\"w:displayBackgroundShape\", opts.displayBackgroundShape));\n p.push(onOff(\"w:printPostScriptOverText\", opts.printPostScriptOverText));\n p.push(onOff(\"w:printFractionalCharacterWidth\", opts.printFractionalCharacterWidth));\n p.push(onOff(\"w:printFormsData\", opts.printFormsData));\n p.push(onOff(\"w:embedTrueTypeFonts\", opts.embedTrueTypeFonts));\n p.push(onOff(\"w:embedSystemFonts\", opts.embedSystemFonts));\n p.push(onOff(\"w:saveSubsetFonts\", opts.saveSubsetFonts));\n p.push(onOff(\"w:saveFormsData\", opts.saveFormsData));\n p.push(onOff(\"w:mirrorMargins\", opts.mirrorMargins));\n p.push(onOff(\"w:alignBordersAndEdges\", opts.alignBordersAndEdges));\n p.push(onOff(\"w:bordersDoNotSurroundHeader\", opts.bordersDoNotSurroundHeader));\n p.push(onOff(\"w:bordersDoNotSurroundFooter\", opts.bordersDoNotSurroundFooter));\n p.push(onOff(\"w:gutterAtTop\", opts.gutterAtTop));\n p.push(onOff(\"w:hideSpellingErrors\", opts.hideSpellingErrors));\n p.push(onOff(\"w:hideGrammaticalErrors\", opts.hideGrammaticalErrors));\n\n // activeWritingStyle\n if (opts.activeWritingStyle !== undefined) {\n for (const ws of opts.activeWritingStyle) {\n const attrs: Record<string, string | number | boolean> = {};\n if (ws.lang !== undefined) attrs[\"w:lang\"] = ws.lang;\n if (ws.vendorID !== undefined) attrs[\"w:vendorID\"] = ws.vendorID;\n if (ws.dllVersion !== undefined) attrs[\"w:dllVersion\"] = ws.dllVersion;\n if (ws.nlCheck !== undefined) attrs[\"w:nlCheck\"] = ws.nlCheck;\n if (ws.checkStyle !== undefined) attrs[\"w:checkStyle\"] = ws.checkStyle;\n if (ws.appCheck !== undefined) attrs[\"w:appCheck\"] = ws.appCheck;\n if (ws.appName !== undefined) attrs[\"w:appName\"] = ws.appName;\n p.push(attrEl(\"w:activeWritingStyle\", attrs));\n }\n }\n\n // proofState\n if (opts.proofState !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.proofState.spelling !== undefined) attrs[\"w:spelling\"] = opts.proofState.spelling;\n if (opts.proofState.grammar !== undefined) attrs[\"w:grammar\"] = opts.proofState.grammar;\n p.push(attrEl(\"w:proofState\", attrs));\n }\n\n p.push(onOff(\"w:formsDesign\", opts.formsDesign));\n\n if (opts.attachedTemplate !== undefined)\n p.push(attrEl(\"w:attachedTemplate\", { \"r:id\": opts.attachedTemplate }));\n p.push(onOff(\"w:linkStyles\", opts.linkStyles));\n\n // stylePaneFormatFilter\n if (opts.stylePaneFormatFilter !== undefined) {\n const f = opts.stylePaneFormatFilter;\n const attrs: Record<string, string> = {};\n const flags: [keyof typeof f, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n [\"latentStyles\", \"w:latentStyles\"],\n ];\n for (const [prop, xmlKey] of flags) {\n if (f[prop] !== undefined) attrs[xmlKey] = f[prop] ? \"1\" : \"0\";\n }\n p.push(attrEl(\"w:stylePaneFormatFilter\", attrs));\n }\n\n p.push(strVal(\"w:stylePaneSortMethod\", opts.stylePaneSortMethod));\n p.push(strVal(\"w:documentType\", opts.documentType));\n\n if (opts.revisionView !== undefined) p.push(stringifyRevisionView(opts.revisionView));\n p.push(onOff(\"w:trackRevisions\", opts.trackRevisions));\n p.push(onOff(\"w:doNotTrackMoves\", opts.doNotTrackMoves));\n p.push(onOff(\"w:doNotTrackFormatting\", opts.doNotTrackFormatting));\n\n if (opts.mailMerge !== undefined) p.push(stringifyMailMerge(opts.mailMerge));\n if (opts.documentProtection !== undefined) p.push(stringifyDocProtect(opts.documentProtection));\n\n p.push(onOff(\"w:autoFormatOverride\", opts.autoFormatOverride));\n p.push(onOff(\"w:styleLockTheme\", opts.styleLockTheme));\n p.push(onOff(\"w:styleLockQFSet\", opts.styleLockQFSet));\n\n // defaultTabStop — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.defaultTabStop !== undefined) p.push(numVal(\"w:defaultTabStop\", opts.defaultTabStop)!);\n\n // hyphenation\n p.push(onOff(\"w:autoHyphenation\", opts.hyphenation?.autoHyphenation));\n p.push(numVal(\"w:consecutiveHyphenLimit\", opts.hyphenation?.consecutiveHyphenLimit));\n p.push(numVal(\"w:hyphenationZone\", opts.hyphenation?.hyphenationZone));\n p.push(onOff(\"w:doNotHyphenateCaps\", opts.hyphenation?.doNotHyphenateCaps));\n\n p.push(onOff(\"w:showEnvelope\", opts.showEnvelope));\n p.push(numVal(\"w:summaryLength\", opts.summaryLength));\n p.push(strVal(\"w:clickAndTypeStyle\", opts.clickAndTypeStyle));\n p.push(strVal(\"w:defaultTableStyle\", opts.defaultTableStyle));\n p.push(onOff(\"w:evenAndOddHeaders\", opts.evenAndOddHeaders));\n p.push(onOff(\"w:bookFoldRevPrinting\", opts.bookFoldRevPrinting));\n p.push(onOff(\"w:bookFoldPrinting\", opts.bookFoldPrinting));\n p.push(numVal(\"w:bookFoldPrintingSheets\", opts.bookFoldPrintingSheets));\n p.push(numVal(\"w:drawingGridHorizontalSpacing\", opts.drawingGridHorizontalSpacing));\n p.push(numVal(\"w:drawingGridVerticalSpacing\", opts.drawingGridVerticalSpacing));\n p.push(numVal(\"w:displayHorizontalDrawingGridEvery\", opts.displayHorizontalDrawingGridEvery));\n p.push(numVal(\"w:displayVerticalDrawingGridEvery\", opts.displayVerticalDrawingGridEvery));\n // XSD order: doNotUseMarginsForDrawingGridOrigin (55) → origins (56,57)\n p.push(\n onOff(\"w:doNotUseMarginsForDrawingGridOrigin\", opts.doNotUseMarginsForDrawingGridOrigin),\n );\n p.push(numVal(\"w:drawingGridHorizontalOrigin\", opts.drawingGridHorizontalOrigin));\n p.push(numVal(\"w:drawingGridVerticalOrigin\", opts.drawingGridVerticalOrigin));\n p.push(onOff(\"w:doNotShadeFormData\", opts.doNotShadeFormData));\n p.push(onOff(\"w:noPunctuationKerning\", opts.noPunctuationKerning));\n\n // characterSpacingControl — optional (CT_Settings minOccurs=0); emit only when set\n if (opts.characterSpacingControl !== undefined) {\n p.push(strVal(\"w:characterSpacingControl\", opts.characterSpacingControl)!);\n }\n\n p.push(onOff(\"w:printTwoOnOne\", opts.printTwoOnOne));\n p.push(onOff(\"w:strictFirstAndLastChars\", opts.strictFirstAndLastChars));\n\n if (opts.noLineBreaksAfter !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksAfter.lang !== undefined) attrs[\"w:lang\"] = opts.noLineBreaksAfter.lang;\n if (opts.noLineBreaksAfter.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksAfter.val;\n p.push(attrEl(\"w:noLineBreaksAfter\", attrs));\n }\n if (opts.noLineBreaksBefore !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.noLineBreaksBefore.lang !== undefined)\n attrs[\"w:lang\"] = opts.noLineBreaksBefore.lang;\n if (opts.noLineBreaksBefore.val !== undefined) attrs[\"w:val\"] = opts.noLineBreaksBefore.val;\n p.push(attrEl(\"w:noLineBreaksBefore\", attrs));\n }\n\n p.push(onOff(\"w:savePreviewPicture\", opts.savePreviewPicture));\n p.push(onOff(\"w:doNotValidateAgainstSchema\", opts.doNotValidateAgainstSchema));\n p.push(onOff(\"w:saveInvalidXml\", opts.saveInvalidXml));\n p.push(onOff(\"w:ignoreMixedContent\", opts.ignoreMixedContent));\n p.push(onOff(\"w:alwaysShowPlaceholderText\", opts.alwaysShowPlaceholderText));\n p.push(onOff(\"w:doNotDemarcateInvalidXml\", opts.doNotDemarcateInvalidXml));\n p.push(onOff(\"w:saveXmlDataOnly\", opts.saveXmlDataOnly));\n p.push(onOff(\"w:useXSLTWhenSaving\", opts.useXSLTWhenSaving));\n\n if (opts.saveThroughXslt !== undefined) {\n const attrs: Record<string, string> = {};\n if (opts.saveThroughXslt.id !== undefined) attrs[\"r:id\"] = opts.saveThroughXslt.id;\n if (opts.saveThroughXslt.val !== undefined) attrs[\"w:val\"] = opts.saveThroughXslt.val;\n if (opts.saveThroughXslt.solutionID !== undefined)\n attrs[\"w:solutionID\"] = opts.saveThroughXslt.solutionID;\n p.push(attrEl(\"w:saveThroughXslt\", attrs));\n }\n\n p.push(onOff(\"w:showXMLTags\", opts.showXMLTags));\n p.push(onOff(\"w:alwaysMergeEmptyNamespace\", opts.alwaysMergeEmptyNamespace));\n p.push(onOff(\"w:updateFields\", opts.updateFields));\n\n if (opts.hdrShapeDefaults !== undefined)\n p.push(`<w:hdrShapeDefaults>${opts.hdrShapeDefaults}</w:hdrShapeDefaults>`);\n if (opts.footnotePr !== undefined) p.push(stringifyFootnotePr(opts.footnotePr));\n if (opts.endnotePr !== undefined) p.push(stringifyEndnotePr(opts.endnotePr));\n\n // Compatibility — optional (CT_Settings minOccurs=0); emit only when configured\n const compatXml = stringifyCompatibility({\n ...opts.compatibility,\n version: opts.compatibility?.version ?? opts.compatibilityModeVersion ?? 15,\n });\n if (compatXml) p.push(compatXml);\n\n // docVars\n if (opts.docVars?.length) {\n const vars = opts.docVars\n .map((v) => attrEl(\"w:docVar\", { \"w:name\": v.name, \"w:val\": v.val }))\n .join(\"\");\n p.push(`<w:docVars>${vars}</w:docVars>`);\n }\n\n if (opts.rsids !== undefined) p.push(stringifyRsids(opts.rsids));\n if (opts.mathPr !== undefined) p.push(stringifyMathPr(opts.mathPr));\n\n if (opts.attachedSchema !== undefined) {\n for (const schema of opts.attachedSchema) p.push(strVal(\"w:attachedSchema\", schema)!);\n }\n\n // XSD order: attachedSchema → themeFontLang → clrSchemeMapping → doNotIncludeSubdocsInStats\n if (opts.themeFontLang !== undefined) {\n const a: Record<string, string> = {};\n if (opts.themeFontLang.val !== undefined) a[\"w:val\"] = opts.themeFontLang.val;\n if (opts.themeFontLang.eastAsia !== undefined) a[\"w:eastAsia\"] = opts.themeFontLang.eastAsia;\n if (opts.themeFontLang.bidi !== undefined) a[\"w:bidi\"] = opts.themeFontLang.bidi;\n p.push(attrEl(\"w:themeFontLang\", a));\n }\n if (opts.colorSchemeMapping !== undefined)\n p.push(stringifyColorSchemeMapping(opts.colorSchemeMapping));\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 // XSD order: smartTagType → shapeDefaults → doNotEmbedSmartTags → decimalSymbol\n if (opts.shapeDefaults !== undefined)\n p.push(`<w:shapeDefaults>${opts.shapeDefaults}</w:shapeDefaults>`);\n p.push(onOff(\"w:doNotEmbedSmartTags\", opts.doNotEmbedSmartTags));\n p.push(strVal(\"w:decimalSymbol\", opts.decimalSymbol));\n p.push(strVal(\"w:listSeparator\", opts.listSeparator));\n\n // Word 2010/2013 document identifiers — CT_Settings trailing sequence\n // (decimalSymbol → listSeparator → w14:docId → w15:chartTrackingRefBased → w15:docId).\n // Preserved verbatim for round-trip fidelity; val attribute is namespace-scoped.\n if (opts.w14DocId !== undefined) p.push(strVal(\"w14:docId\", opts.w14DocId));\n if (opts.w15ChartTrackingRefBased) p.push(`<w15:chartTrackingRefBased/>`);\n if (opts.w15DocId !== undefined) p.push(strVal(\"w15:docId\", opts.w15DocId));\n\n const body = p.join(\"\");\n return `<w:settings ${SETTINGS_NS}>${body}</w:settings>`;\n },\n\n parse(el, _ctx) {\n const opts: Record<string, unknown> = {};\n\n // writeProtection (CT_WriteProtection)\n const wpEl = findChild(el, \"w:writeProtection\");\n if (wpEl) {\n const wp = readPasswordAttrs(wpEl) as WriteProtectionOptions;\n const recommended = attr(wpEl, \"w:recommended\");\n if (recommended !== undefined) wp.recommended = recommended === \"1\" || recommended === \"true\";\n if (Object.keys(wp).length > 0) opts.writeProtection = wp;\n }\n\n // view → w:view/@w:val\n const viewVal = readStr(findChild(el, \"w:view\"), \"w:val\");\n if (viewVal) opts.view = viewVal;\n\n // zoom → w:zoom/@w:percent, @w:val\n const zoomEl = findChild(el, \"w:zoom\");\n if (zoomEl) {\n const zoom: Record<string, unknown> = {};\n const percent = attr(zoomEl, \"w:percent\");\n if (percent) zoom.percent = parseInt(percent, 10);\n const zval = attr(zoomEl, \"w:val\");\n if (zval) zoom.val = zval;\n if (Object.keys(zoom).length > 0) opts.zoom = zoom;\n }\n\n // CT_OnOff scalar settings (presence = true unless w:val is explicitly false)\n const onOffScalar: [string, string][] = [\n [\"removePersonalInformation\", \"w:removePersonalInformation\"],\n [\"removeDateAndTime\", \"w:removeDateAndTime\"],\n [\"doNotDisplayPageBoundaries\", \"w:doNotDisplayPageBoundaries\"],\n [\"displayBackgroundShape\", \"w:displayBackgroundShape\"],\n [\"printPostScriptOverText\", \"w:printPostScriptOverText\"],\n [\"printFractionalCharacterWidth\", \"w:printFractionalCharacterWidth\"],\n [\"printFormsData\", \"w:printFormsData\"],\n [\"embedTrueTypeFonts\", \"w:embedTrueTypeFonts\"],\n [\"embedSystemFonts\", \"w:embedSystemFonts\"],\n [\"saveSubsetFonts\", \"w:saveSubsetFonts\"],\n [\"saveFormsData\", \"w:saveFormsData\"],\n [\"mirrorMargins\", \"w:mirrorMargins\"],\n [\"alignBordersAndEdges\", \"w:alignBordersAndEdges\"],\n [\"bordersDoNotSurroundHeader\", \"w:bordersDoNotSurroundHeader\"],\n [\"bordersDoNotSurroundFooter\", \"w:bordersDoNotSurroundFooter\"],\n [\"gutterAtTop\", \"w:gutterAtTop\"],\n [\"hideSpellingErrors\", \"w:hideSpellingErrors\"],\n [\"hideGrammaticalErrors\", \"w:hideGrammaticalErrors\"],\n [\"formsDesign\", \"w:formsDesign\"],\n [\"linkStyles\", \"w:linkStyles\"],\n [\"trackRevisions\", \"w:trackRevisions\"],\n [\"doNotTrackMoves\", \"w:doNotTrackMoves\"],\n [\"doNotTrackFormatting\", \"w:doNotTrackFormatting\"],\n [\"autoFormatOverride\", \"w:autoFormatOverride\"],\n [\"styleLockTheme\", \"w:styleLockTheme\"],\n [\"styleLockQFSet\", \"w:styleLockQFSet\"],\n [\"showEnvelope\", \"w:showEnvelope\"],\n [\"evenAndOddHeaders\", \"w:evenAndOddHeaders\"],\n [\"bookFoldRevPrinting\", \"w:bookFoldRevPrinting\"],\n [\"bookFoldPrinting\", \"w:bookFoldPrinting\"],\n [\"doNotUseMarginsForDrawingGridOrigin\", \"w:doNotUseMarginsForDrawingGridOrigin\"],\n [\"doNotShadeFormData\", \"w:doNotShadeFormData\"],\n [\"noPunctuationKerning\", \"w:noPunctuationKerning\"],\n [\"printTwoOnOne\", \"w:printTwoOnOne\"],\n [\"strictFirstAndLastChars\", \"w:strictFirstAndLastChars\"],\n [\"savePreviewPicture\", \"w:savePreviewPicture\"],\n [\"doNotValidateAgainstSchema\", \"w:doNotValidateAgainstSchema\"],\n [\"saveInvalidXml\", \"w:saveInvalidXml\"],\n [\"ignoreMixedContent\", \"w:ignoreMixedContent\"],\n [\"alwaysShowPlaceholderText\", \"w:alwaysShowPlaceholderText\"],\n [\"doNotDemarcateInvalidXml\", \"w:doNotDemarcateInvalidXml\"],\n [\"saveXmlDataOnly\", \"w:saveXmlDataOnly\"],\n [\"useXSLTWhenSaving\", \"w:useXSLTWhenSaving\"],\n [\"showXMLTags\", \"w:showXMLTags\"],\n [\"alwaysMergeEmptyNamespace\", \"w:alwaysMergeEmptyNamespace\"],\n [\"updateFields\", \"w:updateFields\"],\n [\"doNotIncludeSubdocsInStats\", \"w:doNotIncludeSubdocsInStats\"],\n [\"doNotAutoCompressPictures\", \"w:doNotAutoCompressPictures\"],\n [\"doNotEmbedSmartTags\", \"w:doNotEmbedSmartTags\"],\n ];\n for (const [key, tag] of onOffScalar) {\n const v = readOnOff(findChild(el, tag));\n if (v !== undefined) opts[key] = v;\n }\n\n // activeWritingStyle → w:activeWritingStyle[] (multiple)\n const awsList: Array<Record<string, unknown>> = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:activeWritingStyle\") continue;\n const entry: Record<string, unknown> = {};\n const lang = attr(child, \"w:lang\");\n if (lang) entry.lang = lang;\n const vendorID = attr(child, \"w:vendorID\");\n if (vendorID) entry.vendorID = vendorID;\n const dllVersion = attr(child, \"w:dllVersion\");\n if (dllVersion) entry.dllVersion = dllVersion;\n const nlCheck = attr(child, \"w:nlCheck\");\n if (nlCheck !== undefined) entry.nlCheck = nlCheck !== \"0\" && nlCheck !== \"false\";\n const checkStyle = attr(child, \"w:checkStyle\");\n if (checkStyle !== undefined) entry.checkStyle = checkStyle !== \"0\" && checkStyle !== \"false\";\n const appCheck = attr(child, \"w:appCheck\");\n if (appCheck) entry.appCheck = appCheck;\n const appName = attr(child, \"w:appName\");\n if (appName) entry.appName = appName;\n if (Object.keys(entry).length > 0) awsList.push(entry);\n }\n if (awsList.length > 0) opts.activeWritingStyle = awsList;\n\n // proofState → w:proofState/@w:spelling, @w:grammar\n const proofEl = findChild(el, \"w:proofState\");\n if (proofEl) {\n const proof: Record<string, unknown> = {};\n const spelling = attr(proofEl, \"w:spelling\");\n if (spelling) proof.spelling = spelling;\n const grammar = attr(proofEl, \"w:grammar\");\n if (grammar) proof.grammar = grammar;\n if (Object.keys(proof).length > 0) opts.proofState = proof;\n }\n\n // attachedTemplate → w:attachedTemplate/@r:id\n const attachedTplEl = findChild(el, \"w:attachedTemplate\");\n if (attachedTplEl) {\n const rid = attr(attachedTplEl, \"r:id\");\n if (rid) opts.attachedTemplate = rid;\n }\n\n // stylePaneFormatFilter → w:stylePaneFormatFilter (complex attributes)\n const spffEl = findChild(el, \"w:stylePaneFormatFilter\");\n if (spffEl) {\n const filter: Record<string, boolean> = {};\n const spffFlags: [string, string][] = [\n [\"allStyles\", \"w:allStyles\"],\n [\"customStyles\", \"w:customStyles\"],\n [\"stylesInUse\", \"w:stylesInUse\"],\n [\"headingStyles\", \"w:headingStyles\"],\n [\"numberingStyles\", \"w:numberingStyles\"],\n [\"tableStyles\", \"w:tableStyles\"],\n [\"directFormattingOnRuns\", \"w:directFormattingOnRuns\"],\n [\"directFormattingOnParagraphs\", \"w:directFormattingOnParagraphs\"],\n [\"directFormattingOnNumbering\", \"w:directFormattingOnNumbering\"],\n [\"directFormattingOnTables\", \"w:directFormattingOnTables\"],\n [\"clearFormatting\", \"w:clearFormatting\"],\n [\"top3HeadingStyles\", \"w:top3HeadingStyles\"],\n [\"visibleStyles\", \"w:visibleStyles\"],\n [\"alternateStyleNames\", \"w:alternateStyleNames\"],\n [\"latentStyles\", \"w:latentStyles\"],\n ];\n for (const [prop, xmlKey] of spffFlags) {\n const v = attr(spffEl, xmlKey);\n if (v !== undefined) filter[prop] = v !== \"0\" && v !== \"false\" && v !== \"off\";\n }\n if (Object.keys(filter).length > 0) opts.stylePaneFormatFilter = filter;\n }\n\n // stylePaneSortMethod / documentType / clickAndTypeStyle / defaultTableStyle\n const stylePaneSortMethod = readStr(findChild(el, \"w:stylePaneSortMethod\"), \"w:val\");\n if (stylePaneSortMethod)\n opts.stylePaneSortMethod = stylePaneSortMethod as SettingsOptions[\"stylePaneSortMethod\"];\n const documentType = readStr(findChild(el, \"w:documentType\"), \"w:val\");\n if (documentType) opts.documentType = documentType as SettingsOptions[\"documentType\"];\n const clickAndTypeStyle = readStr(findChild(el, \"w:clickAndTypeStyle\"), \"w:val\");\n if (clickAndTypeStyle) opts.clickAndTypeStyle = clickAndTypeStyle;\n const defaultTableStyle = readStr(findChild(el, \"w:defaultTableStyle\"), \"w:val\");\n if (defaultTableStyle) opts.defaultTableStyle = defaultTableStyle;\n\n // mailMerge → w:mailMerge (CT_MailMerge)\n const mailMergeEl = findChild(el, \"w:mailMerge\");\n if (mailMergeEl) {\n const mm = parseMailMerge(mailMergeEl);\n if (mm) opts.mailMerge = mm;\n }\n\n // revisionView → w:revisionView (CT_TrackChangesView)\n const revViewEl = findChild(el, \"w:revisionView\");\n if (revViewEl) {\n const rv: Record<string, boolean> = {};\n const rvFlags: [string, string][] = [\n [\"markup\", \"w:markup\"],\n [\"comments\", \"w:comments\"],\n [\"insDel\", \"w:insDel\"],\n [\"formatting\", \"w:formatting\"],\n [\"inkAnnotations\", \"w:inkAnnotations\"],\n ];\n for (const [k, a] of rvFlags) {\n const v = attr(revViewEl, a);\n if (v !== undefined) rv[k] = v !== \"false\" && v !== \"0\";\n }\n if (Object.keys(rv).length > 0) opts.revisionView = rv as RevisionViewOptions;\n }\n\n // documentProtection → w:documentProtection (CT_DocProtect)\n const docProtEl = findChild(el, \"w:documentProtection\");\n if (docProtEl) {\n const prot: DocumentProtectionOptions = {};\n const edit = attr(docProtEl, \"w:edit\");\n if (edit && (DOC_PROTECT_EDITS as readonly string[]).includes(edit)) {\n prot.edit = edit as DocumentProtectionOptions[\"edit\"];\n }\n const enforcement = attr(docProtEl, \"w:enforcement\");\n if (enforcement !== undefined) {\n Object.assign(prot, readPasswordAttrs(docProtEl));\n const formatting = attr(docProtEl, \"w:formatting\");\n if (formatting !== undefined) prot.formatting = formatting === \"1\" || formatting === \"true\";\n }\n if (Object.keys(prot).length > 0) opts.documentProtection = prot;\n }\n\n // defaultTabStop → w:defaultTabStop/@w:val\n const defaultTabStop = readNum(findChild(el, \"w:defaultTabStop\"), \"w:val\");\n if (defaultTabStop !== undefined) opts.defaultTabStop = defaultTabStop;\n\n // hyphenation (autoHyphenation/consecutiveHyphenLimit/hyphenationZone/doNotHyphenateCaps)\n if (\n findChild(el, \"w:autoHyphenation\") ||\n findChild(el, \"w:doNotHyphenateCaps\") ||\n findChild(el, \"w:consecutiveHyphenLimit\") ||\n findChild(el, \"w:hyphenationZone\")\n ) {\n const hyphenation: Record<string, unknown> = {};\n const autoHyph = readOnOff(findChild(el, \"w:autoHyphenation\"));\n if (autoHyph !== undefined) hyphenation.autoHyphenation = autoHyph;\n const noHyphCaps = readOnOff(findChild(el, \"w:doNotHyphenateCaps\"));\n if (noHyphCaps !== undefined) hyphenation.doNotHyphenateCaps = noHyphCaps;\n const consLimit = readNum(findChild(el, \"w:consecutiveHyphenLimit\"), \"w:val\");\n if (consLimit !== undefined) hyphenation.consecutiveHyphenLimit = consLimit;\n const zone = readNum(findChild(el, \"w:hyphenationZone\"), \"w:val\");\n if (zone !== undefined) hyphenation.hyphenationZone = zone;\n if (Object.keys(hyphenation).length > 0) opts.hyphenation = hyphenation;\n }\n\n // summaryLength → w:summaryLength/@w:val\n const summaryLength = readNum(findChild(el, \"w:summaryLength\"), \"w:val\");\n if (summaryLength !== undefined) opts.summaryLength = summaryLength;\n\n // bookFoldPrintingSheets → w:bookFoldPrintingSheets/@w:val\n const bookFoldSheets = readNum(findChild(el, \"w:bookFoldPrintingSheets\"), \"w:val\");\n if (bookFoldSheets !== undefined) opts.bookFoldPrintingSheets = bookFoldSheets;\n\n // drawing grid numerics\n const drawNum: [string, string][] = [\n [\"drawingGridHorizontalSpacing\", \"w:drawingGridHorizontalSpacing\"],\n [\"drawingGridVerticalSpacing\", \"w:drawingGridVerticalSpacing\"],\n [\"displayHorizontalDrawingGridEvery\", \"w:displayHorizontalDrawingGridEvery\"],\n [\"displayVerticalDrawingGridEvery\", \"w:displayVerticalDrawingGridEvery\"],\n [\"drawingGridHorizontalOrigin\", \"w:drawingGridHorizontalOrigin\"],\n [\"drawingGridVerticalOrigin\", \"w:drawingGridVerticalOrigin\"],\n ];\n for (const [key, tag] of drawNum) {\n const v = readNum(findChild(el, tag), \"w:val\");\n if (v !== undefined) opts[key] = v;\n }\n\n // characterSpacingControl → w:characterSpacingControl/@w:val\n const characterSpacingControl = readStr(findChild(el, \"w:characterSpacingControl\"), \"w:val\");\n if (characterSpacingControl) {\n opts.characterSpacingControl =\n characterSpacingControl as SettingsOptions[\"characterSpacingControl\"];\n }\n\n // noLineBreaksAfter/Before → w:noLineBreaksAfter/Before (w:lang, w:val)\n const lineBreakPairs: [string, string][] = [\n [\"noLineBreaksAfter\", \"w:noLineBreaksAfter\"],\n [\"noLineBreaksBefore\", \"w:noLineBreaksBefore\"],\n ];\n for (const [key, tag] of lineBreakPairs) {\n const lbEl = findChild(el, tag);\n if (!lbEl) continue;\n const entry: Record<string, string> = {};\n const lang = attr(lbEl, \"w:lang\");\n if (lang) entry.lang = lang;\n const val = attr(lbEl, \"w:val\");\n if (val) entry.val = val;\n if (Object.keys(entry).length > 0) opts[key] = entry;\n }\n\n // saveThroughXslt → w:saveThroughXslt (r:id, w:val, w:solutionID)\n const stxEl = findChild(el, \"w:saveThroughXslt\");\n if (stxEl) {\n const stx: Record<string, string> = {};\n const id = attr(stxEl, \"r:id\");\n if (id) stx.id = id;\n const val = attr(stxEl, \"w:val\");\n if (val) stx.val = val;\n const solutionID = attr(stxEl, \"w:solutionID\");\n if (solutionID) stx.solutionID = solutionID;\n if (Object.keys(stx).length > 0) opts.saveThroughXslt = stx;\n }\n\n // hdrShapeDefaults / shapeDefaults → verbatim inner XML (o:shapedefaults/o:shapelayout)\n const hdrSdEl = findChild(el, \"w:hdrShapeDefaults\");\n if (hdrSdEl) opts.hdrShapeDefaults = stringify(hdrSdEl);\n const sdEl = findChild(el, \"w:shapeDefaults\");\n if (sdEl) opts.shapeDefaults = stringify(sdEl);\n\n // footnotePr / endnotePr (CT_FtnDocProps / CT_EdnDocProps)\n const fnPrEl = findChild(el, \"w:footnotePr\");\n if (fnPrEl) {\n const fn = parseFtnEdnPr(fnPrEl);\n if (fn) opts.footnotePr = fn;\n }\n const enPrEl = findChild(el, \"w:endnotePr\");\n if (enPrEl) {\n const en = parseFtnEdnPr(enPrEl);\n if (en) opts.endnotePr = en;\n }\n\n // compatibility (CT_Compat: on/off flags + compatSetting entries)\n const compatEl = findChild(el, \"w:compat\");\n if (compatEl) {\n const compat = parseCompatibility(compatEl);\n if (compat) opts.compatibility = compat;\n }\n\n // docVars → w:docVars/w:docVar\n const docVarsEl = findChild(el, \"w:docVars\");\n if (docVarsEl) {\n const vars: Array<{ name: string; val: string }> = [];\n for (const child of docVarsEl.elements ?? []) {\n if (child.name !== \"w:docVar\") continue;\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name !== undefined && val !== undefined) vars.push({ name, val });\n }\n if (vars.length > 0) opts.docVars = vars;\n }\n\n // rsids → w:rsids (CT_DocRsids)\n const rsidsEl = findChild(el, \"w:rsids\");\n if (rsidsEl) {\n const rsids: Record<string, unknown> = {};\n const root = readStr(findChild(rsidsEl, \"w:rsidRoot\"), \"w:val\");\n if (root) rsids.rsidRoot = root;\n const list: string[] = [];\n for (const child of rsidsEl.elements ?? []) {\n if (child.name !== \"w:rsid\") continue;\n const val = attr(child, \"w:val\");\n if (val) list.push(val);\n }\n if (list.length > 0) rsids.rsids = list;\n if (Object.keys(rsids).length > 0) opts.rsids = rsids as RsidsOptions;\n }\n\n // mathPr → m:mathPr (CT_MathPr)\n const mathPrEl = findChild(el, \"m:mathPr\");\n if (mathPrEl) {\n const mp = parseMathPr(mathPrEl);\n if (mp) opts.mathPr = mp;\n }\n\n // attachedSchema → w:attachedSchema/@w:val (multiple)\n const attachedSchemas: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:attachedSchema\") continue;\n const val = attr(child, \"w:val\");\n if (val) attachedSchemas.push(val);\n }\n if (attachedSchemas.length > 0) opts.attachedSchema = attachedSchemas;\n\n // themeFontLang → w:themeFontLang (CT_Language: val/eastAsia/bidi)\n const tflEl = findChild(el, \"w:themeFontLang\");\n if (tflEl) {\n const tfl: Record<string, string> = {};\n const val = attr(tflEl, \"w:val\");\n if (val) tfl.val = val;\n const eastAsia = attr(tflEl, \"w:eastAsia\");\n if (eastAsia) tfl.eastAsia = eastAsia;\n const bidi = attr(tflEl, \"w:bidi\");\n if (bidi) tfl.bidi = bidi;\n if (Object.keys(tfl).length > 0) opts.themeFontLang = tfl;\n }\n\n // clrSchemeMapping → w:clrSchemeMapping\n const csmEl = findChild(el, \"w:clrSchemeMapping\");\n if (csmEl) {\n const csm: Record<string, string> = {};\n const csmMap: [string, string][] = [\n [\"bg1\", \"w:bg1\"],\n [\"t1\", \"w:t1\"],\n [\"bg2\", \"w:bg2\"],\n [\"t2\", \"w:t2\"],\n [\"accent1\", \"w:accent1\"],\n [\"accent2\", \"w:accent2\"],\n [\"accent3\", \"w:accent3\"],\n [\"accent4\", \"w:accent4\"],\n [\"accent5\", \"w:accent5\"],\n [\"accent6\", \"w:accent6\"],\n [\"hyperlink\", \"w:hyperlink\"],\n [\"followedHyperlink\", \"w:followedHyperlink\"],\n ];\n for (const [key, xmlAttr] of csmMap) {\n const v = attr(csmEl, xmlAttr);\n if (v) csm[key] = v;\n }\n if (Object.keys(csm).length > 0) opts.colorSchemeMapping = csm;\n }\n\n // forceUpgrade → w:forceUpgrade (CT_Empty, presence)\n if (findChild(el, \"w:forceUpgrade\")) opts.forceUpgrade = true;\n\n // captions → w:captions (CT_Captions)\n const captionsEl = findChild(el, \"w:captions\");\n if (captionsEl) {\n const captions = parseCaptions(captionsEl);\n if (captions) opts.captions = captions;\n }\n\n // readModeInkLockDown → w:readModeInkLockDown\n const rmilEl = findChild(el, \"w:readModeInkLockDown\");\n if (rmilEl) {\n opts.readModeInkLockDown = {\n actualPg: attr(rmilEl, \"w:actualPg\") !== \"0\",\n w: parseInt(attr(rmilEl, \"w:w\") ?? \"0\", 10),\n h: parseInt(attr(rmilEl, \"w:h\") ?? \"0\", 10),\n fontSz: parseInt(attr(rmilEl, \"w:fontSz\") ?? \"0\", 10),\n } as ReadModeInkLockDownOptions;\n }\n\n // smartTagType → w:smartTagType[] (multiple)\n const smartTags: Array<Record<string, string>> = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:smartTagType\") continue;\n const entry: Record<string, string> = {};\n const ns = attr(child, \"w:namespace\");\n if (ns) entry.namespace = ns;\n const nsuri = attr(child, \"w:namespaceuri\");\n if (nsuri) entry.namespaceuri = nsuri;\n const name = attr(child, \"w:name\");\n if (name) entry.name = name;\n const url = attr(child, \"w:url\");\n if (url) entry.url = url;\n if (Object.keys(entry).length > 0) smartTags.push(entry);\n }\n if (smartTags.length > 0) opts.smartTagType = smartTags;\n\n // decimalSymbol / listSeparator → w:decimalSymbol|w:listSeparator/@w:val\n const decimalSymbol = readStr(findChild(el, \"w:decimalSymbol\"), \"w:val\");\n if (decimalSymbol) opts.decimalSymbol = decimalSymbol;\n const listSeparator = readStr(findChild(el, \"w:listSeparator\"), \"w:val\");\n if (listSeparator) opts.listSeparator = listSeparator;\n\n // Word 2010/2013 document identifiers — preserve for round-trip fidelity\n const w14DocId = readStr(findChild(el, \"w14:docId\"), \"w14:val\");\n if (w14DocId) opts.w14DocId = w14DocId;\n if (findChild(el, \"w15:chartTrackingRefBased\")) opts.w15ChartTrackingRefBased = true;\n const w15DocId = readStr(findChild(el, \"w15:docId\"), \"w15:val\");\n if (w15DocId) opts.w15DocId = w15DocId;\n\n return opts as unknown as SettingsOptions;\n },\n};\n","/**\n * Footnotes descriptor — produces word/footnotes.xml.\n *\n * Generates the complete `<w:footnotes>` element including:\n * - Separator footnote (id round-tripped from source; default -1)\n * - Continuation separator footnote (id round-tripped from source; default 0)\n * - User footnotes with auto-injected footnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Footnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\n/** System footnote (separator / continuationSeparator). Round-tripped verbatim. */\nexport interface FootnoteSeparator {\n id: number;\n paragraphs: (ParagraphOptions | string)[];\n}\n\nexport interface FootnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n /**\n * Separator footnote — id + content round-tripped from the source so it stays\n * consistent with settings.footnotePr, which references this id.\n */\n separator?: FootnoteSeparator;\n /** Continuation separator footnote — id + content round-tripped from the source. */\n continuationSeparator?: FootnoteSeparator;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the footnoteRef run — auto-injected at start of first paragraph. */\nconst FOOTNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteRef/></w:r>';\n\n/** Default separator footnote (id=-1) for freshly generated documents. */\nconst SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n/** Default continuation separator footnote (id=0) for freshly generated documents. */\nconst CONTINUATION_SEPARATOR_FOOTNOTE =\n '<w:footnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:footnote>\";\n\n// ── Descriptor ──\n\n/** Render a system footnote from round-tripped id + content, or the spec default. */\nfunction footnoteSystemNote(\n type: \"separator\" | \"continuationSeparator\",\n sep: FootnoteSeparator | undefined,\n fallback: string,\n ctx: BodyContext,\n): string {\n if (!sep) return fallback;\n const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join(\"\");\n return `<w:footnote w:type=\"${type}\" w:id=\"${sep.id}\">${inner}</w:footnote>`;\n}\n\nexport const footnotesDesc: CustomDescriptor<FootnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [`<w:footnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`];\n\n // Separator / continuation separator: round-trip id + content verbatim so they\n // stay consistent with settings.footnotePr (which references these ids). Fall\n // back to spec defaults only for freshly generated documents.\n parts.push(footnoteSystemNote(\"separator\", data.separator, SEPARATOR_FOOTNOTE, ctx));\n parts.push(\n footnoteSystemNote(\n \"continuationSeparator\",\n data.continuationSeparator,\n CONTINUATION_SEPARATOR_FOOTNOTE,\n ctx,\n ),\n );\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:footnote w:id=\"${id}\">`);\n for (const [i, para] of paragraphs.entries()) {\n const pXml = stringifyParagraphInline(para, ctx);\n if (i === 0) {\n // footnoteRef goes after the paragraph open tag, but after <w:pPr>\n // when present — CT_P requires pPr to be the first child.\n const pPrEnd = pXml.indexOf(\"</w:pPr>\");\n if (pPrEnd !== -1) {\n const at = pPrEnd + \"</w:pPr>\".length;\n parts.push(pXml.slice(0, at) + FOOTNOTE_REF_RUN + pXml.slice(at));\n } else {\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 }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:footnote>\");\n }\n\n parts.push(\"</w:footnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n let separator: FootnoteSeparator | undefined;\n let continuationSeparator: FootnoteSeparator | undefined;\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:footnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const type = attr(child, \"w:type\");\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n\n // System footnotes carry type=\"separator\"/\"continuationSeparator\" — capture\n // their id + content so stringify round-trips them verbatim (settings\n // references these ids). Normal footnotes (type absent/\"normal\") go to notes.\n if (type === \"separator\") {\n separator = { id, paragraphs };\n } else if (type === \"continuationSeparator\") {\n continuationSeparator = { id, paragraphs };\n } else {\n notes.set(id, paragraphs);\n }\n }\n return { notes, separator, continuationSeparator } as FootnotesData;\n },\n};\n","/**\n * Endnotes descriptor — produces word/endnotes.xml.\n *\n * Generates the complete `<w:endnotes>` element including:\n * - Separator endnote (id round-tripped from source; default -1)\n * - Continuation separator endnote (id round-tripped from source; default 0)\n * - User endnotes with auto-injected endnoteRef in first paragraph\n *\n * Reference: http://officeopenxml.com/WPfootnotes.php, CT_Endnotes / CT_FtnEdn\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { BodyContext, DocxReadContext } from \"../../context\";\n\n// ── Input ──\n\n/** System endnote (separator / continuationSeparator). Round-tripped verbatim. */\nexport interface EndnoteSeparator {\n id: number;\n paragraphs: (ParagraphOptions | string)[];\n}\n\nexport interface EndnotesData {\n notes: Map<number, (ParagraphOptions | string)[]>;\n /**\n * Separator endnote — id + content round-tripped from the source so it stays\n * consistent with settings.endnotePr, which references this id.\n */\n separator?: EndnoteSeparator;\n /** Continuation separator endnote — id + content round-tripped from the source. */\n continuationSeparator?: EndnoteSeparator;\n}\n\n// ── Constants ──\n\nconst NS =\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n/** XML for the endnoteRef run — auto-injected at start of first paragraph. */\nconst ENDNOTE_REF_RUN =\n '<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteRef/></w:r>';\n\n/** Default separator endnote (id=-1) for freshly generated documents. */\nconst SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"separator\" w:id=\"-1\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:separator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n/** Default continuation separator endnote (id=0) for freshly generated documents. */\nconst CONTINUATION_SEPARATOR_ENDNOTE =\n '<w:endnote w:type=\"continuationSeparator\" w:id=\"0\">' +\n '<w:p><w:pPr><w:spacing w:after=\"0\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr>' +\n \"<w:r><w:continuationSeparator/></w:r>\" +\n \"</w:p>\" +\n \"</w:endnote>\";\n\n// ── Descriptor ──\n\n/** Render a system endnote from round-tripped id + content, or the spec default. */\nfunction endnoteSystemNote(\n type: \"separator\" | \"continuationSeparator\",\n sep: EndnoteSeparator | undefined,\n fallback: string,\n ctx: BodyContext,\n): string {\n if (!sep) return fallback;\n const inner = sep.paragraphs.map((p) => stringifyParagraphInline(p, ctx)).join(\"\");\n return `<w:endnote w:type=\"${type}\" w:id=\"${sep.id}\">${inner}</w:endnote>`;\n}\n\nexport const endnotesDesc: CustomDescriptor<EndnotesData, BodyContext> = {\n kind: \"custom\",\n\n stringify(data, ctx) {\n const parts: string[] = [`<w:endnotes ${NS} mc:Ignorable=\"w14 w15 wp14\">`];\n\n // Separator / continuation separator: round-trip id + content verbatim so they\n // stay consistent with settings.endnotePr (which references these ids). Fall\n // back to spec defaults only for freshly generated documents.\n parts.push(endnoteSystemNote(\"separator\", data.separator, SEPARATOR_ENDNOTE, ctx));\n parts.push(\n endnoteSystemNote(\n \"continuationSeparator\",\n data.continuationSeparator,\n CONTINUATION_SEPARATOR_ENDNOTE,\n ctx,\n ),\n );\n\n for (const [id, paragraphs] of data.notes) {\n parts.push(`<w:endnote w:id=\"${id}\">`);\n for (const [i, para] of paragraphs.entries()) {\n const pXml = stringifyParagraphInline(para, ctx);\n if (i === 0) {\n // Insert endnoteRef after <w:p> or <w:p ...>\n const openIdx = pXml.indexOf(\">\");\n if (openIdx !== -1) {\n parts.push(pXml.slice(0, openIdx + 1) + ENDNOTE_REF_RUN + pXml.slice(openIdx + 1));\n } else {\n parts.push(pXml);\n }\n } else {\n parts.push(pXml);\n }\n }\n parts.push(\"</w:endnote>\");\n }\n\n parts.push(\"</w:endnotes>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const notes = new Map<number, (ParagraphOptions | string)[]>();\n let separator: EndnoteSeparator | undefined;\n let continuationSeparator: EndnoteSeparator | undefined;\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:endnote\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const type = attr(child, \"w:type\");\n\n const paragraphs: (ParagraphOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n paragraphs.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n\n // System endnotes carry type=\"separator\"/\"continuationSeparator\" — capture\n // their id + content so stringify round-trips them verbatim (settings\n // references these ids). Normal endnotes (type absent/\"normal\") go to notes.\n if (type === \"separator\") {\n separator = { id, paragraphs };\n } else if (type === \"continuationSeparator\") {\n continuationSeparator = { id, paragraphs };\n } else {\n notes.set(id, paragraphs);\n }\n }\n return { notes, separator, continuationSeparator } as EndnotesData;\n },\n};\n","/**\n * 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 table descriptor — produces word/fontTable.xml.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html, CT_FontsList\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, escapeXml, findChild } from \"@office-open/xml\";\nimport type { FontSignature } from \"@parts/fonts/font-table\";\nimport type { EmbeddedFontOptionsWithKey } from \"@parts/fonts/font-wrapper\";\n\n// ── Input ──\n\nexport interface FontTableInput {\n fonts: EmbeddedFontOptionsWithKey[];\n}\n\n// ── XML helpers ──\n\nconst NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/** Default font signature for regular embedded fonts. */\nconst DEFAULT_SIG: FontSignature = {\n usb0: \"E0002AFF\",\n usb1: \"C000247B\",\n usb2: \"00000009\",\n usb3: \"00000000\",\n csb0: \"000001FF\",\n csb1: \"00000000\",\n};\n\nfunction fontXml(font: EmbeddedFontOptionsWithKey): string {\n const parts: string[] = [`<w:font w:name=\"${escapeXml(font.name)}\">`];\n\n // CT_Font child order (wml.xsd): altName, panose1, charset, family,\n // notTrueType, pitch, sig, embed*. Embedded fonts (carrying data) fall back\n // to defaults when the parsed value is absent; metadata-only fonts emit only\n // what was parsed.\n if (font.altName) parts.push(`<w:altName w:val=\"${escapeXml(font.altName)}\"/>`);\n if (font.panose1) parts.push(`<w:panose1 w:val=\"${escapeXml(font.panose1)}\"/>`);\n if (font.characterSet || font.characterSetName) {\n const valAttr = font.characterSet ? ` w:val=\"${escapeXml(font.characterSet)}\"` : \"\";\n const csAttr = font.characterSetName\n ? ` w:characterSet=\"${escapeXml(font.characterSetName)}\"`\n : \"\";\n parts.push(`<w:charset${valAttr}${csAttr}/>`);\n }\n const family = font.family ?? (font.embedRid ? \"auto\" : undefined);\n if (family) parts.push(`<w:family w:val=\"${escapeXml(family)}\"/>`);\n const pitch = font.pitch ?? (font.embedRid ? \"variable\" : undefined);\n if (pitch) parts.push(`<w:pitch w:val=\"${escapeXml(pitch)}\"/>`);\n const sig = font.sig ?? (font.embedRid ? DEFAULT_SIG : undefined);\n if (sig) {\n parts.push(\n `<w:sig w:usb0=\"${sig.usb0}\" w:usb1=\"${sig.usb1}\" w:usb2=\"${sig.usb2}\" ` +\n `w:usb3=\"${sig.usb3}\" w:csb0=\"${sig.csb0}\" w:csb1=\"${sig.csb1}\"/>`,\n );\n }\n if (font.embedRid) {\n const embedAttrs = [`r:id=\"${font.embedRid}\"`, `w:fontKey=\"{${font.fontKey}}\"`];\n if (font.subsetted !== undefined) embedAttrs.push(`w:subsetted=\"${font.subsetted ? 1 : 0}\"`);\n parts.push(`<w:embedRegular ${embedAttrs.join(\" \")}/>`);\n }\n\n parts.push(\"</w:font>\");\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\nexport const fontTableDesc: CustomDescriptor<FontTableInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const parts: string[] = [\n `<w:fonts ${NS} mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh\">`,\n ];\n for (const font of opts.fonts) {\n parts.push(fontXml(font));\n }\n parts.push(\"</w:fonts>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const fonts: EmbeddedFontOptionsWithKey[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:font\") continue;\n const font: Partial<EmbeddedFontOptionsWithKey> = { fontKey: \"\" };\n const name = child.attributes?.[\"w:name\"];\n if (name) font.name = String(name);\n\n const altNameEl = findChild(child, \"w:altName\");\n if (altNameEl) {\n const val = attr(altNameEl, \"w:val\");\n if (val) font.altName = val;\n }\n\n const panose1El = findChild(child, \"w:panose1\");\n if (panose1El) {\n const val = attr(panose1El, \"w:val\");\n if (val) font.panose1 = val;\n }\n\n const charsetEl = findChild(child, \"w:charset\");\n if (charsetEl) {\n const val = attr(charsetEl, \"w:val\");\n if (val) font.characterSet = val as EmbeddedFontOptionsWithKey[\"characterSet\"];\n const csName = attr(charsetEl, \"w:characterSet\");\n if (csName) font.characterSetName = csName;\n }\n\n const familyEl = findChild(child, \"w:family\");\n if (familyEl) {\n const val = attr(familyEl, \"w:val\");\n if (val) font.family = val;\n }\n\n const pitchEl = findChild(child, \"w:pitch\");\n if (pitchEl) {\n const val = attr(pitchEl, \"w:val\");\n if (val) font.pitch = val;\n }\n\n const sigEl = findChild(child, \"w:sig\");\n if (sigEl) {\n const sig: FontSignature = {\n usb0: \"\",\n usb1: \"\",\n usb2: \"\",\n usb3: \"\",\n csb0: \"\",\n csb1: \"\",\n };\n for (const key of [\"usb0\", \"usb1\", \"usb2\", \"usb3\", \"csb0\", \"csb1\"] as const) {\n const val = attr(sigEl, `w:${key}`);\n if (val) sig[key] = val;\n }\n if (Object.values(sig).some(Boolean)) font.sig = sig;\n }\n\n // Obfuscation key + relationship id from embedRegular (the .odttf bytes\n // are resolved separately by parse.ts via fontTable.xml.rels).\n const embedEl = findChild(child, \"w:embedRegular\");\n if (embedEl) {\n const rawKey = attr(embedEl, \"w:fontKey\");\n if (rawKey) {\n font.fontKey = rawKey.replace(/^\\{\\{|\\}\\}$/g, \"\").replace(/^\\{|\\}$/g, \"\");\n }\n const rid = attr(embedEl, \"r:id\");\n if (rid) font.embedRid = rid;\n const subsetted = attrBool(embedEl, \"w:subsetted\");\n if (subsetted !== undefined) font.subsetted = subsetted;\n }\n\n fonts.push(font as EmbeddedFontOptionsWithKey);\n }\n return { fonts };\n },\n};\n","/**\n * Bibliography module for WordprocessingML documents.\n *\n * Provides types for bibliography sources.\n * XML generation is handled by the descriptor pipeline (bibliographyDesc).\n *\n * Reference: ISO/IEC 29500-4, shared-bibliography.xsd, CT_Sources, CT_SourceType\n *\n * @module\n */\n\n/**\n * Options for a single bibliography source entry.\n *\n * Maps to CT_SourceType in the bibliography XSD schema.\n * All fields are optional — include only the relevant ones for each source type.\n *\n * @property type - Source type (Book, JournalArticle, ConferenceProceedings, etc.)\n * @property title - Title of the work\n * @property author - Author names (plain text, semicolon-separated)\n * @property year - Publication year\n * @property month - Publication month\n * @property day - Publication day\n * @property bookTitle - Title of the book (for book sections, articles in collections)\n * @property journal - Journal name (JournalName in XSD)\n * @property volume - Volume number\n * @property issue - Issue number\n * @property pages - Page range\n * @property publisher - Publisher name\n * @property city - City of publication\n * @property url - URL for internet sources\n * @property edition - Edition number or description\n * @property institution - Institution (for theses, reports)\n */\nexport interface SourceTypeOptions {\n type?: string;\n title?: string;\n author?: string;\n year?: string;\n month?: string;\n day?: string;\n bookTitle?: string;\n journal?: string;\n volume?: string;\n issue?: string;\n pages?: string;\n publisher?: string;\n city?: string;\n url?: string;\n edition?: string;\n institution?: string;\n}\n\n/**\n * Options for creating a bibliography container.\n *\n * @property sources - Array of bibliography source entries\n * @property styleName - Bibliography style name (e.g., \"APA\", \"Chicago\", \"IEEE\")\n */\nexport interface BibliographyOptions {\n sources: SourceTypeOptions[];\n styleName?: string;\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml, findChild, textOf } from \"@office-open/xml\";\n\nconst SOURCE_FIELDS: readonly (readonly [string, keyof SourceTypeOptions])[] = [\n [\"SourceType\", \"type\"],\n [\"Title\", \"title\"],\n [\"Author\", \"author\"],\n [\"Year\", \"year\"],\n [\"Month\", \"month\"],\n [\"Day\", \"day\"],\n [\"BookTitle\", \"bookTitle\"],\n [\"JournalName\", \"journal\"],\n [\"Volume\", \"volume\"],\n [\"Issue\", \"issue\"],\n [\"Pages\", \"pages\"],\n [\"Publisher\", \"publisher\"],\n [\"City\", \"city\"],\n [\"URL\", \"url\"],\n [\"Edition\", \"edition\"],\n [\"Institution\", \"institution\"],\n] as const;\n\nexport const bibliographyDesc: CustomDescriptor<BibliographyOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const attrParts: string[] = [\n 'xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"',\n ];\n if (opts.styleName !== undefined) {\n attrParts.push(`StyleName=\"${escapeXml(opts.styleName)}\"`);\n }\n\n const parts: string[] = [`<b:Sources ${attrParts.join(\" \")}>`];\n\n for (const source of opts.sources) {\n const sourceParts: string[] = [];\n for (const [tagName, key] of SOURCE_FIELDS) {\n const value = source[key];\n if (value !== undefined) {\n sourceParts.push(`<b:${tagName}>${escapeXml(value)}</b:${tagName}>`);\n }\n }\n parts.push(`<b:Source>${sourceParts.join(\"\")}</b:Source>`);\n }\n\n parts.push(\"</b:Sources>\");\n return parts.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Partial<BibliographyOptions> = {};\n\n // StyleName attribute\n const styleName = el.attributes?.[\"StyleName\"];\n if (styleName) opts.styleName = styleName as string;\n\n // Parse b:Source children\n const sources: SourceTypeOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"b:Source\") continue;\n const source: SourceTypeOptions = {};\n for (const [, key] of SOURCE_FIELDS) {\n const xmlChild = findChild(child, `b:${SOURCE_FIELDS.find((f) => f[1] === key)![0]}`);\n if (xmlChild) {\n const val = textOf(xmlChild);\n if (val) source[key] = val;\n }\n }\n sources.push(source);\n }\n opts.sources = sources;\n\n return opts as BibliographyOptions;\n },\n};\n","/**\n * Glossary document component — stores building block definitions.\n *\n * Generates word/glossary/document.xml containing Quick Parts entries\n * that appear in Word's Insert > Quick Parts gallery.\n *\n * @module\n */\n\nimport type { SectionChild } from \"@shared/section\";\n\n/** Gallery type for building blocks (ST_DocPartGallery) */\nexport const DocPartGallery = {\n PLACEHOLDER: \"placeholder\",\n DEFAULT: \"default\",\n DOC_PARTS: \"docParts\",\n COVER_PAGE: \"coverPg\",\n EQUATIONS: \"eq\",\n FOOTERS: \"ftrs\",\n HEADERS: \"hdrs\",\n PAGE_NUMBERS: \"pgNum\",\n TABLES: \"tbls\",\n WATERMARKS: \"watermarks\",\n AUTO_TEXT: \"autoTxt\",\n TEXT_BOX: \"txtBox\",\n PAGE_NUMBERS_TOP: \"pgNumT\",\n PAGE_NUMBERS_BOTTOM: \"pgNumB\",\n PAGE_NUMBERS_MARGIN: \"pgNumMargins\",\n TABLE_OF_CONTENTS: \"tblOfContents\",\n BIBLIOGRAPHY: \"bib\",\n CUSTOM_QUICK_PARTS: \"custQuickParts\",\n CUSTOM_COVER_PAGE: \"custCoverPg\",\n CUSTOM_EQUATIONS: \"custEq\",\n CUSTOM_FOOTERS: \"custFtrs\",\n CUSTOM_HEADERS: \"custHdrs\",\n CUSTOM_PAGE_NUMBERS: \"custPgNum\",\n CUSTOM_TABLES: \"custTbls\",\n CUSTOM_WATERMARKS: \"custWatermarks\",\n CUSTOM_AUTO_TEXT: \"custAutoTxt\",\n CUSTOM_TEXT_BOX: \"custTxtBox\",\n CUSTOM_PAGE_NUMBERS_TOP: \"custPgNumT\",\n CUSTOM_PAGE_NUMBERS_BOTTOM: \"custPgNumB\",\n CUSTOM_PAGE_NUMBERS_MARGIN: \"custPgNumMargins\",\n CUSTOM_TABLE_OF_CONTENTS: \"custTblOfContents\",\n CUSTOM_BIBLIOGRAPHY: \"custBib\",\n CUSTOM1: \"custom1\",\n CUSTOM2: \"custom2\",\n CUSTOM3: \"custom3\",\n CUSTOM4: \"custom4\",\n CUSTOM5: \"custom5\",\n} as const;\n\nexport type DocPartGallery = (typeof DocPartGallery)[keyof typeof DocPartGallery];\n\n/** Building block type (ST_DocPartType) */\nexport const DocPartType = {\n NONE: \"none\",\n NORMAL: \"normal\",\n AUTO_EXPAND: \"autoExp\",\n TOOLBAR: \"toolbar\",\n SPELLER: \"speller\",\n FORM_FIELD: \"formFld\",\n BUILDING_BLOCK_PLACEHOLDER: \"bbPlcHdr\",\n} as const;\n\nexport type DocPartType = (typeof DocPartType)[keyof typeof DocPartType];\n\n/** Building block behavior (ST_DocPartBehavior) */\nexport const DocPartBehavior = {\n CONTENT: \"content\",\n PARAGRAPH: \"p\",\n PAGE: \"pg\",\n} as const;\n\nexport type DocPartBehavior = (typeof DocPartBehavior)[keyof typeof DocPartBehavior];\n\n/** A single building block (CT_DocPart) */\nexport interface DocPartOptions {\n /** Building block name (required) */\n name: string;\n /** Gallery category (required) */\n gallery: DocPartGallery;\n /** Category name within the gallery */\n category?: string;\n /** Building block types */\n types?: DocPartType[];\n /** Whether all building block types are included (w:all attribute) */\n allTypes?: boolean;\n /** Insertion behaviors */\n behaviors?: DocPartBehavior[];\n /** Description */\n description?: string;\n /** GUID for this building block */\n guid?: string;\n /** Whether the name is decorated (built-in) */\n decorated?: boolean;\n /** Body content — paragraphs, tables, etc. */\n children: SectionChild[];\n}\n\n/** Glossary document options */\nexport interface GlossaryDocumentOptions {\n /** Building blocks */\n parts: DocPartOptions[];\n}\n\n// ── Descriptor ──\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, escapeXml, findChild } from \"@office-open/xml\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\nconst GLOSSARY_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\nfunction docPartPrXml(part: GlossaryDocumentOptions[\"parts\"][number]): string {\n const prParts: string[] = [];\n prParts.push(\n `<w:name w:val=\"${escapeXml(part.name)}\"${part.decorated ? ' w:decorated=\"1\"' : \"\"}/>`,\n );\n if (part.category || part.gallery) {\n const catParts: string[] = [];\n if (part.category) {\n catParts.push(`<w:name w:val=\"${escapeXml(part.category)}\"/>`);\n }\n catParts.push(`<w:gallery w:val=\"${part.gallery}\"/>`);\n prParts.push(`<w:category>${catParts.join(\"\")}</w:category>`);\n }\n if (part.types && part.types.length > 0) {\n const typeXml = part.types.map((t) => `<w:type w:val=\"${t}\"/>`).join(\"\");\n const allAttr = part.allTypes ? ' w:all=\"1\"' : \"\";\n prParts.push(`<w:types${allAttr}>${typeXml}</w:types>`);\n }\n if (part.behaviors && part.behaviors.length > 0) {\n const behaviorXml = part.behaviors.map((b) => `<w:behavior w:val=\"${b}\"/>`).join(\"\");\n prParts.push(`<w:behaviors>${behaviorXml}</w:behaviors>`);\n }\n if (part.description) {\n prParts.push(`<w:description w:val=\"${escapeXml(part.description)}\"/>`);\n }\n if (part.guid) {\n prParts.push(`<w:guid w:val=\"${escapeXml(part.guid)}\"/>`);\n }\n return `<w:docPartPr>${prParts.join(\"\")}</w:docPartPr>`;\n}\n\nexport const glossaryDesc: CustomDescriptor<GlossaryDocumentOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const partsXml = opts.parts\n .map((part) => {\n const bodyContent = ((part.children ?? []) as SectionChild[])\n .map((child) => ctx.stringifyChild(child, ctx))\n .join(\"\");\n\n return `<w:docPart>${docPartPrXml(part)}<w:docPartBody>${bodyContent}</w:docPartBody></w:docPart>`;\n })\n .join(\"\");\n\n return `<w:glossaryDocument ${GLOSSARY_NS}><w:docParts>${partsXml}</w:docParts></w:glossaryDocument>`;\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n const parts: DocPartOptions[] = [];\n\n const docPartsEl = findChild(el, \"w:docParts\");\n if (!docPartsEl) return { parts };\n\n for (const docPart of docPartsEl.elements ?? []) {\n if (docPart.name !== \"w:docPart\") continue;\n const part: Partial<DocPartOptions> = {};\n\n // Parse w:docPartPr\n const pr = findChild(docPart, \"w:docPartPr\");\n if (pr) {\n // name\n const name = findChild(pr, \"w:name\");\n if (name) {\n part.name = attr(name, \"w:val\") ?? \"\";\n const decorated = attr(name, \"w:decorated\");\n if (decorated === \"1\") part.decorated = true;\n }\n\n // category\n const category = findChild(pr, \"w:category\");\n if (category) {\n const catName = findChild(category, \"w:name\");\n if (catName) part.category = attr(catName, \"w:val\");\n const gallery = findChild(category, \"w:gallery\");\n if (gallery) part.gallery = attr(gallery, \"w:val\") as DocPartOptions[\"gallery\"];\n }\n\n // types\n const types = findChild(pr, \"w:types\");\n if (types) {\n const typeList: string[] = [];\n for (const t of types.elements ?? []) {\n if (t.name === \"w:type\") {\n const val = attr(t, \"w:val\");\n if (val) typeList.push(val);\n }\n }\n if (typeList.length > 0) part.types = typeList as DocPartOptions[\"types\"];\n const allAttr = attr(types, \"w:all\");\n if (allAttr === \"1\") part.allTypes = true;\n }\n\n // behaviors\n const behaviors = findChild(pr, \"w:behaviors\");\n if (behaviors) {\n const behaviorList: string[] = [];\n for (const b of behaviors.elements ?? []) {\n if (b.name === \"w:behavior\") {\n const val = attr(b, \"w:val\");\n if (val) behaviorList.push(val);\n }\n }\n if (behaviorList.length > 0) part.behaviors = behaviorList as DocPartOptions[\"behaviors\"];\n }\n\n // description\n const desc = findChild(pr, \"w:description\");\n if (desc) {\n const val = attr(desc, \"w:val\");\n if (val) part.description = val;\n }\n\n // guid\n const guid = findChild(pr, \"w:guid\");\n if (guid) {\n const val = attr(guid, \"w:val\");\n if (val) part.guid = val;\n }\n }\n\n // Parse w:docPartBody children\n const body = findChild(docPart, \"w:docPartBody\");\n if (body) {\n const childList: unknown[] = [];\n for (const sub of body.elements ?? []) {\n if (sub.name === \"w:p\") {\n childList.push({ paragraph: parseParagraph(sub, dctx) });\n }\n }\n if (childList.length > 0) part.children = childList as DocPartOptions[\"children\"];\n }\n\n parts.push(part as DocPartOptions);\n }\n\n return { parts };\n },\n};\n","/**\n * Content types descriptor — produces [Content_Types].xml.\n *\n * Reference: OPC, Content_Types.xsd\n *\n * @module\n */\n\nimport { buildContentTypeOverrides, DOCX_PARTS } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\n\nexport interface ContentTypeDefault {\n extension: string;\n contentType: string;\n}\n\nexport interface ContentTypeOverride {\n partName: string;\n contentType: string;\n}\n\nexport interface ContentTypesInput {\n defaults: ContentTypeDefault[];\n overrides: ContentTypeOverride[];\n}\n\nfunction defaultXml(ext: string, ct: string): string {\n return `<Default Extension=\"${ext}\" ContentType=\"${ct}\"/>`;\n}\n\nfunction overrideXml(partName: string, ct: string): string {\n return `<Override PartName=\"${partName}\" ContentType=\"${ct}\"/>`;\n}\n\nexport const contentTypesDesc: CustomDescriptor<ContentTypesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">',\n ];\n // OPC Default Extension and Override PartName matching are case-insensitive\n // (ECMA-376-2 §10.1.2/§10.1.4): a duplicate differing only in case makes\n // Word reject the package as unreadable content. Dedup case-insensitively\n // as a last line of defense so no input path can emit a colliding pair.\n const seenDefault = new Set<string>();\n for (const d of opts.defaults) {\n const key = d.extension.toLowerCase();\n if (seenDefault.has(key)) continue;\n seenDefault.add(key);\n p.push(defaultXml(d.extension, d.contentType));\n }\n const seenOverride = new Set<string>();\n for (const o of opts.overrides) {\n const key = o.partName.toLowerCase();\n if (seenOverride.has(key)) continue;\n seenOverride.add(key);\n p.push(overrideXml(o.partName, o.contentType));\n }\n p.push(\"</Types>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const defaults: ContentTypeDefault[] = [];\n const overrides: ContentTypeOverride[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"Default\") {\n const ext = child.attributes?.[\"Extension\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (ext && ct) defaults.push({ extension: String(ext), contentType: String(ct) });\n } else if (child.name === \"Override\") {\n const pn = child.attributes?.[\"PartName\"];\n const ct = child.attributes?.[\"ContentType\"];\n if (pn && ct) overrides.push({ partName: String(pn), contentType: String(ct) });\n }\n }\n return { defaults, overrides };\n },\n};\n\n/** Standard extension → content-type defaults covering every media type emitted. */\nconst STANDARD_DEFAULTS: ContentTypeDefault[] = [\n { extension: \"png\", contentType: \"image/png\" },\n { extension: \"jpeg\", contentType: \"image/jpeg\" },\n { extension: \"jpg\", contentType: \"image/jpeg\" },\n { extension: \"bmp\", contentType: \"image/bmp\" },\n { extension: \"gif\", contentType: \"image/gif\" },\n { extension: \"tif\", contentType: \"image/tiff\" },\n { extension: \"tiff\", contentType: \"image/tiff\" },\n { extension: \"emf\", contentType: \"image/x-emf\" },\n { extension: \"wmf\", contentType: \"image/x-wmf\" },\n { extension: \"ico\", contentType: \"image/x-icon\" },\n { extension: \"svg\", contentType: \"image/svg+xml\" },\n { extension: \"rels\", contentType: \"application/vnd.openxmlformats-package.relationships+xml\" },\n { extension: \"xml\", contentType: \"application/xml\" },\n {\n extension: \"odttf\",\n contentType: \"application/vnd.openxmlformats-officedocument.obfuscatedFont\",\n },\n {\n extension: \"bin\",\n contentType: \"application/vnd.openxmlformats-officedocument.oleObject\",\n },\n];\n\n/**\n * Ensure every media part in the package has a resolvable content-type Default.\n *\n * Round-tripped packages pass through the source's [Content_Types], which may\n * declare an uppercase extension (e.g. `JPG`) while the media is named `.jpg`.\n * OPC extension matching is **case-insensitive** (ECMA-376-2 §10.1.2), so `JPG`\n * and `jpg` are one key — emitting both yields a duplicate default that Word\n * rejects as unreadable content. Match existing defaults case-insensitively so\n * we never add a colliding extension; the media then resolves through the\n * source's already-declared default.\n */\nexport function withMediaDefaults(\n input: ContentTypesInput,\n mediaFileNames: string[],\n): ContentTypesInput {\n const have = new Set(input.defaults.map((d) => d.extension.toLowerCase()));\n const standard = new Map(STANDARD_DEFAULTS.map((d) => [d.extension, d.contentType]));\n const defaults = [...input.defaults];\n for (const fileName of mediaFileNames) {\n const ext = fileName.slice(fileName.lastIndexOf(\".\") + 1);\n const key = ext.toLowerCase();\n if (!ext || have.has(key)) continue;\n const contentType = standard.get(key);\n if (contentType) {\n defaults.push({ extension: ext, contentType });\n have.add(key);\n }\n }\n return { defaults, overrides: input.overrides };\n}\n\n/** Default content types for altChunk part extensions. */\nconst ALTCHUNK_DEFAULTS: Record<string, string> = {\n html: \"text/html\",\n rtf: \"application/rtf\",\n txt: \"text/plain\",\n};\n\n/**\n * Realign [Content_Types] Overrides for altChunk parts on a round-tripped\n * package. The pass-through content types carry Override PartNames from the\n * source, but the compiler regenerates altChunk part paths (uniqueId), so the\n * Override and the written part drift apart (O5/O6). This drops the stale\n * afchunk Overrides and appends ones matching the freshly generated paths,\n * backfilling the extension Default so the part is resolvable either way.\n */\nexport function withAltChunkOverrides(\n input: ContentTypesInput,\n altChunks: readonly { path: string; contentType: string }[],\n): ContentTypesInput {\n const defaults = [...input.defaults];\n const haveExt = new Set(defaults.map((d) => d.extension.toLowerCase()));\n for (const ac of altChunks) {\n const ext = (ac.path.split(\".\").pop() ?? \"\").toLowerCase();\n if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {\n defaults.push({ extension: ext, contentType: ALTCHUNK_DEFAULTS[ext] });\n haveExt.add(ext);\n }\n }\n const overrides = input.overrides.filter((o) => !o.partName.startsWith(\"/word/afchunks/\"));\n for (const ac of altChunks) {\n const partName = ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`;\n overrides.push({ partName, contentType: ac.contentType });\n }\n return { defaults, overrides };\n}\n\nconst CUSTOM_PROPERTIES_PART_NAME = \"/docProps/custom.xml\";\nconst CUSTOM_PROPERTIES_CONTENT_TYPE =\n \"application/vnd.openxmlformats-officedocument.custom-properties+xml\";\n\n/**\n * Ensure the docProps/custom.xml Override exists on a round-tripped package.\n * The custom-properties part is always written (even when empty), but a source\n * [Content_Types] may omit its Override — the part then resolves only through\n * the generic `application/xml` Default, which Word rejects as unreadable\n * content (OPC O5). Mirror the unconditional part emission by forcing the\n * Override whenever it is missing.\n */\nexport function ensureCustomPropertiesOverride(input: ContentTypesInput): ContentTypesInput {\n if (input.overrides.some((o) => o.partName.toLowerCase() === CUSTOM_PROPERTIES_PART_NAME)) {\n return input;\n }\n return {\n ...input,\n overrides: [\n ...input.overrides,\n { partName: CUSTOM_PROPERTIES_PART_NAME, contentType: CUSTOM_PROPERTIES_CONTENT_TYPE },\n ],\n };\n}\n\n/**\n * Build [Content_Types].xml for a fresh DOCX compile, driven by the part\n * registry. Static parts (document/styles/…/comments/headers/…) come from\n * {@link buildContentTypeOverrides} over {@link DOCX_PARTS}; dynamic parts whose\n * path or count is runtime-determined (altChunks, sub-documents) are appended\n * here — they are not enumerable in the registry.\n *\n * `facts` keys mirror the registry's `flag` / `countFrom` tokens. The Override\n * set (order-independent) matches the former hand-written builder, so the OPC\n * consistency validator stays green.\n */\nexport function buildContentTypesFromRegistry(\n facts: ReadonlyMap<string, boolean | number>,\n dynamic: {\n altChunks?: ReadonlyArray<{ path: string; contentType: string }>;\n subDocs?: ReadonlyArray<{ path: string }>;\n } = {},\n): ContentTypesInput {\n const overrides: ContentTypeOverride[] = buildContentTypeOverrides(DOCX_PARTS, facts);\n for (const ac of dynamic.altChunks ?? []) {\n overrides.push({\n partName: ac.path.startsWith(\"/\") ? ac.path : `/${ac.path}`,\n contentType: ac.contentType,\n });\n }\n for (const sd of dynamic.subDocs ?? []) {\n overrides.push({\n partName: sd.path.startsWith(\"/\") ? sd.path : `/${sd.path}`,\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n });\n }\n // Minimal defaults: rels/xml are present in every package; altChunk\n // extensions only when altChunks exist. Image/font/embedding extensions are\n // backfilled by withMediaDefaults from the actual part file names, so we no\n // longer declare every possible media type unconditionally — Word strips the\n // unused ones when repairing and that pollutes the \"removed unsupported\n // content\" diff.\n const defaults: ContentTypeDefault[] = [\n { extension: \"rels\", contentType: \"application/vnd.openxmlformats-package.relationships+xml\" },\n { extension: \"xml\", contentType: \"application/xml\" },\n ];\n const haveExt = new Set([\"rels\", \"xml\"]);\n for (const ac of dynamic.altChunks ?? []) {\n const ext = (ac.path.split(\".\").pop() ?? \"\").toLowerCase();\n if (ext && !haveExt.has(ext) && ALTCHUNK_DEFAULTS[ext]) {\n defaults.push({ extension: ext, contentType: ALTCHUNK_DEFAULTS[ext] });\n haveExt.add(ext);\n }\n }\n return { defaults, overrides };\n}\n","import type { BibliographyOptions } from \"@parts/bibliography\";\n/**\n * Core Properties module for WordprocessingML documents.\n *\n * Provides the DocumentOptions interface for document metadata.\n * XML generation is handled by the descriptor pipeline (corePropertiesDesc).\n *\n * Reference: ISO-IEC29500-4_2016 shared-documentPropertiesCore.xsd\n *\n * @module\n */\nimport type { ContentTypesInput } from \"@parts/contenttypes\";\nimport type { EmbeddedFontOptions } from \"@parts/fonts/font-table\";\nimport type { GlossaryDocumentOptions } from \"@parts/glossary-document\";\nimport type { CommentsOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { HyphenationOptions } from \"@parts/settings\";\nimport type { CompatibilityOptions } from \"@parts/settings/compatibility\";\nimport type {\n DocumentProtectionOptions,\n SettingsOptions,\n WriteProtectionOptions,\n} from \"@parts/settings/settings\";\nimport type { SectionOptions } from \"@shared/section\";\n\nimport type { AppPropertiesOptions } from \"./app-properties\";\nimport type { CustomPropertyOptions } from \"./custom-properties\";\nimport type { DocumentBackgroundOptions } from \"./document\";\nimport type { EndnoteSeparator } from \"./endnotes/descriptor\";\nimport type { FootnoteSeparator } from \"./footnotes/descriptor\";\nimport type { NumberingOptions } from \"./numbering\";\nimport type { ParagraphOptions } from \"./paragraph\";\nimport type { StylesOptions } from \"./styles\";\nimport type { WebSettingsOptions } from \"./web-settings\";\n\n/**\n * Document-level feature toggles parsed from settings.xml.\n *\n * @property trackRevisions - Track changes\n * @property updateFields - Update fields on open\n * @property documentProtection - Document write protection\n */\nexport interface FeaturesOptions {\n trackRevisions?: boolean;\n updateFields?: boolean;\n documentProtection?: DocumentProtectionOptions;\n}\n\n/**\n * Options for configuring document properties.\n *\n * @property sections - Document section configurations\n * @property title - Document title\n * @property subject - Document subject\n * @property creator - Document creator/author\n * @property keywords - Document keywords for searchability\n * @property description - Document description\n * @property lastModifiedBy - User who last modified the document\n * @property revision - Revision number\n * @property lastPrinted - Last printed timestamp (W3CDTF), round-tripped from cp:lastPrinted\n * @property externalStyles - External stylesheet reference\n * @property styles - Document styles configuration\n * @property numbering - Numbering configuration\n * @property comments - Document comments configuration\n * @property bibliography - Document bibliography sources\n * @property footnotes - Document footnotes\n * @property background - Document background settings\n * @property features - Document features like track changes\n * @property compatabilityModeVersion - Compatibility mode version\n * @property compatibility - Compatibility settings\n * @property customProperties - Custom document properties\n * @property evenAndOddHeaderAndFooters - Enable different headers/footers for even/odd pages\n * @property defaultTabStop - Default tab stop width\n * @property fonts - Font configurations\n * @property hyphenation - Hyphenation settings\n */\nexport interface DocumentOptions extends CorePropertiesOptions {\n sections: SectionOptions[];\n externalStyles?: string;\n styles?: StylesOptions;\n numbering?: NumberingOptions;\n comments?: CommentsOptions;\n bibliography?: BibliographyOptions;\n footnotes?: Record<string, { children: (ParagraphOptions | string)[] }> & {\n /**\n * Separator footnote — id + content round-tripped verbatim from the source\n * so the generated id stays consistent with settings.footnotePr, which\n * references it. Omit for freshly generated documents (defaults apply).\n */\n separator?: FootnoteSeparator;\n /** Continuation separator footnote — round-tripped verbatim from the source. */\n continuationSeparator?: FootnoteSeparator;\n };\n endnotes?: Record<string, { children: (ParagraphOptions | string)[] }> & {\n /** Separator endnote — id + content round-tripped verbatim from the source. */\n separator?: EndnoteSeparator;\n /** Continuation separator endnote — round-tripped verbatim from the source. */\n continuationSeparator?: EndnoteSeparator;\n };\n background?: DocumentBackgroundOptions;\n features?: FeaturesOptions;\n compatabilityModeVersion?: number;\n compatibility?: CompatibilityOptions;\n customProperties?: CustomPropertyOptions[];\n evenAndOddHeaderAndFooters?: boolean;\n defaultTabStop?: number;\n fonts?: EmbeddedFontOptions[];\n hyphenation?: HyphenationOptions;\n /** Document conformance class (w:document/@w:conformance). */\n conformance?: \"strict\" | \"transitional\";\n /** Controls whether punctuation is compressed at line ends */\n characterSpacingControl?: \"compressPunctuation\" | \"doNotCompress\";\n /** Default document view mode */\n view?: \"none\" | \"print\" | \"outline\" | \"masterPages\" | \"normal\" | \"web\";\n /** Default zoom level (percentage) and type */\n zoom?: {\n percent?: number;\n val?: \"none\" | \"fullPage\" | \"bestFit\" | \"textFit\";\n };\n /** Write protection recommendation (not enforcement) */\n writeProtection?: WriteProtectionOptions;\n /** Whether to display the background shape in print layout */\n displayBackgroundShape?: boolean;\n /** Whether to embed TrueType fonts in the document */\n embedTrueTypeFonts?: boolean;\n /** Whether to embed system fonts in the document */\n embedSystemFonts?: boolean;\n /** Whether to save only a subset of the embedded fonts */\n saveSubsetFonts?: boolean;\n /** Document variables (key-value pairs stored in the document) */\n docVars?: { name: string; val: string }[];\n /** Theme color scheme remapping */\n colorSchemeMapping?: SettingsOptions[\"colorSchemeMapping\"];\n /** Mail merge configuration */\n mailMerge?: SettingsOptions[\"mailMerge\"];\n /** Glossary document — building blocks (Quick Parts) */\n glossary?: GlossaryDocumentOptions;\n /** Additional document settings passed through to the settings.xml part */\n settings?: SettingsOptions;\n /** Web settings for browser rendering (word/webSettings.xml) */\n webSettings?: WebSettingsOptions;\n /** Content types from [Content_Types].xml (parse path only) */\n contentTypes?: ContentTypesInput;\n /**\n * Parts carried verbatim from the source that generate() does not rebuild\n * (e.g. word/theme/*, customXml/*). Kept as raw bytes so their [Content_Types]\n * declarations stay valid and the package opens in Word. Media/fonts/headers\n * are rebuilt by the compiler and must NOT be listed here.\n */\n rawParts?: { path: string; data: Uint8Array }[];\n /** Extended properties (docProps/app.xml) */\n appProperties?: AppPropertiesOptions;\n}\n\n// ── Descriptor ──\n\nimport type { CorePropertiesOptions } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\n\nexport const corePropertiesDesc: CustomDescriptor<CorePropertiesOptions> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const now = new Date().toISOString();\n const p: string[] = [\n '<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"' +\n ' xmlns:dc=\"http://purl.org/dc/elements/1.1/\"' +\n ' xmlns:dcterms=\"http://purl.org/dc/terms/\"' +\n ' xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\"' +\n ' xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">',\n ];\n // Emit in CT_CoreProperties xsd:all schema order: created, creator,\n // description, keywords, lastModifiedBy, lastPrinted, modified, revision,\n // subject, title. created/modified default to now for fresh documents.\n p.push(`<dcterms:created xsi:type=\"dcterms:W3CDTF\">${opts.created ?? now}</dcterms:created>`);\n if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);\n if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);\n if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);\n if (opts.lastModifiedBy)\n p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy)}</cp:lastModifiedBy>`);\n if (opts.lastPrinted) p.push(`<cp:lastPrinted>${escapeXml(opts.lastPrinted)}</cp:lastPrinted>`);\n p.push(\n `<dcterms:modified xsi:type=\"dcterms:W3CDTF\">${opts.modified ?? now}</dcterms:modified>`,\n );\n if (opts.revision !== undefined) p.push(`<cp:revision>${opts.revision}</cp:revision>`);\n if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);\n if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);\n p.push(\"</cp:coreProperties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: CorePropertiesOptions = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n if (typeof text !== \"string\") continue;\n switch (child.name) {\n case \"dc:title\":\n result.title = text;\n break;\n case \"dc:subject\":\n result.subject = text;\n break;\n case \"dc:creator\":\n result.creator = text;\n break;\n case \"cp:keywords\":\n result.keywords = text;\n break;\n case \"dc:description\":\n result.description = text;\n break;\n case \"cp:lastModifiedBy\":\n result.lastModifiedBy = text;\n break;\n case \"cp:revision\":\n result.revision = Number(text);\n break;\n case \"cp:lastPrinted\":\n result.lastPrinted = text;\n break;\n case \"dcterms:created\":\n result.created = text;\n break;\n case \"dcterms:modified\":\n result.modified = text;\n break;\n }\n }\n return result;\n },\n};\n","/**\n * Web Settings module for WordprocessingML documents.\n *\n * Provides types for web settings configuration.\n * XML generation is handled by the descriptor pipeline (webSettingsDesc).\n *\n * Reference: http://officeopenxml.com/WPwebSettings.php\n *\n * @module\n */\n\nimport type { FramesetOptions } from \"@parts/frameset\";\n\n/**\n * Border options for div elements.\n */\nexport interface DivBorderOptions {\n top?: { style: string; color?: string; size?: number };\n left?: { style: string; color?: string; size?: number };\n bottom?: { style: string; color?: string; size?: number };\n right?: { style: string; color?: string; size?: number };\n}\n\n/**\n * Options for a div element (CT_Div).\n */\nexport interface DivOptions {\n /** Unique div identifier (required by CT_Div/@id) */\n id: number;\n marginLeft: number | UniversalMeasure;\n marginRight: number | UniversalMeasure;\n marginTop: number | UniversalMeasure;\n marginBottom: number | UniversalMeasure;\n /** Mark as HTML blockquote element */\n blockQuote?: boolean;\n /** Mark as HTML body element */\n bodyDiv?: boolean;\n border?: DivBorderOptions;\n children?: DivOptions[];\n}\n\n/**\n * Screen size types for web settings target.\n */\nexport const TargetScreenSize = {\n SIZE_544X376: \"544x376\",\n SIZE_640X480: \"640x480\",\n SIZE_720X512: \"720x512\",\n SIZE_800X600: \"800x600\",\n SIZE_1024X768: \"1024x768\",\n SIZE_1152X882: \"1152x882\",\n SIZE_1152X900: \"1152x900\",\n SIZE_1280X1024: \"1280x1024\",\n SIZE_1600X1200: \"1600x1200\",\n SIZE_1800X1440: \"1800x1440\",\n SIZE_1920X1200: \"1920x1200\",\n} as const;\n\n/**\n * Options for the w:optimizeForBrowser element.\n *\n * CT_OptimizeForBrowser extends CT_OnOff with an optional @w:target attribute.\n */\nexport interface OptimizeForBrowserOptions {\n /** On/off value — defaults to true when omitted (CT_OnOff). */\n value?: boolean;\n /** Target screen resolution name (w:optimizeForBrowser/@w:target). */\n target?: string;\n}\n\n/**\n * Options for web settings (CT_WebSettings).\n */\nexport interface WebSettingsOptions {\n /** Frameset definition for web layout */\n frameset?: FramesetOptions;\n /** Div elements for HTML div formatting */\n divs?: DivOptions[];\n /** Character encoding for web output */\n encoding?: string;\n /** Optimize document rendering for web browser (w:optimizeForBrowser). */\n optimizeForBrowser?: boolean | OptimizeForBrowserOptions;\n /** Rely on VML for graphics display */\n relyOnVML?: boolean;\n /** Allow PNG image format in web output */\n allowPNG?: boolean;\n /** Do not rely on CSS for formatting */\n doNotRelyOnCSS?: boolean;\n /** Do not save as single web file */\n doNotSaveAsSingleFile?: boolean;\n /** Do not organize supporting files in folders */\n doNotOrganizeInFolder?: boolean;\n /** Do not use long file names for supporting files */\n doNotUseLongFileNames?: boolean;\n /** Pixels per inch for web output */\n pixelsPerInch?: number;\n /** Target screen size */\n targetScreenSize?: (typeof TargetScreenSize)[keyof typeof TargetScreenSize] | string;\n /** Save smart tags as XML */\n saveSmartTagsAsXml?: boolean;\n}\n\n// ── Descriptor ──\n\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, escapeXml, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { FrameOptions, FramesetSplitbarOptions } from \"@parts/frameset\";\n\n/** Subset of WebSettingsOptions for descriptor stringify. */\nexport interface WebSettingsInput {\n frameset?: FramesetOptions;\n divs?: DivOptions[];\n encoding?: string;\n optimizeForBrowser?: boolean | OptimizeForBrowserOptions;\n relyOnVML?: boolean;\n allowPNG?: boolean;\n doNotRelyOnCSS?: boolean;\n doNotSaveAsSingleFile?: boolean;\n doNotOrganizeInFolder?: boolean;\n doNotUseLongFileNames?: boolean;\n pixelsPerInch?: number;\n targetScreenSize?: string;\n saveSmartTagsAsXml?: boolean;\n}\n\nconst WS_NS =\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\"';\n\nfunction wsOnOff(tag: string, val: boolean): string {\n return `<${tag} w:val=\"${val ? \"true\" : \"false\"}\"/>`;\n}\n\nfunction wsStringVal(tag: string, val: string): string {\n return `<${tag} w:val=\"${escapeXml(val)}\"/>`;\n}\n\nfunction wsNumVal(tag: string, val: number | UniversalMeasure): string {\n return `<${tag} w:val=\"${val}\"/>`;\n}\n\n// ── Parse helpers (for descriptor parse path) ──\n\nfunction parseFramesetEl(el: Element): FramesetOptions {\n const opts: Partial<FramesetOptions> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const splitbar = findChild(el, \"w:framesetSplitbar\");\n if (splitbar) opts.splitbar = parseSplitbarEl(splitbar);\n\n const layout = findChild(el, \"w:frameLayout\");\n if (layout) {\n const val = attr(layout, \"w:val\");\n if (val === \"rows\" || val === \"cols\") opts.layout = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const children: (FramesetOptions | FrameOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:frameset\") {\n children.push(parseFramesetEl(child));\n } else if (child.name === \"w:frame\") {\n children.push(parseFrameEl(child));\n }\n }\n if (children.length > 0) opts.children = children;\n\n return opts as FramesetOptions;\n}\n\nfunction parseSplitbarEl(el: Element): FramesetSplitbarOptions {\n const opts: Partial<FramesetSplitbarOptions> = {};\n\n const w = findChild(el, \"w:w\");\n if (w) {\n const val = attrNum(w, \"w:w\");\n if (val !== undefined) opts.width = val;\n }\n\n const color = findChild(el, \"w:color\");\n if (color) {\n const val = attr(color, \"w:val\");\n if (val) opts.color = val;\n }\n\n if (findChild(el, \"w:noBorder\")) opts.noBorder = true;\n if (findChild(el, \"w:flatBorders\")) opts.flatBorders = true;\n\n return opts as FramesetSplitbarOptions;\n}\n\nfunction parseFrameEl(el: Element): FrameOptions {\n const opts: Partial<FrameOptions> = {};\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const val = attr(sz, \"w:val\");\n if (val) opts.size = val;\n }\n\n const name = findChild(el, \"w:name\");\n if (name) {\n const val = attr(name, \"w:val\");\n if (val) opts.name = val;\n }\n\n const title = findChild(el, \"w:title\");\n if (title) {\n const val = attr(title, \"w:val\");\n if (val) opts.title = val;\n }\n\n const source = findChild(el, \"w:sourceFileName\");\n if (source) {\n const val = attr(source, \"r:id\");\n if (val) opts.sourceRId = val;\n }\n\n const marW = findChild(el, \"w:marW\");\n if (marW) {\n const val = attrNum(marW, \"w:val\");\n if (val !== undefined) opts.marginWidth = val;\n }\n\n const marH = findChild(el, \"w:marH\");\n if (marH) {\n const val = attrNum(marH, \"w:val\");\n if (val !== undefined) opts.marginHeight = val;\n }\n\n const scrollbar = findChild(el, \"w:scrollbar\");\n if (scrollbar) {\n const val = attr(scrollbar, \"w:val\");\n if (val === \"on\" || val === \"off\" || val === \"auto\") opts.scrollbar = val;\n }\n\n if (findChild(el, \"w:noResizeAllowed\")) opts.noResizeAllowed = true;\n if (findChild(el, \"w:linkedToFile\")) opts.linkedToFile = true;\n\n const longDesc = findChild(el, \"w:longDesc\");\n if (longDesc) {\n const val = attr(longDesc, \"r:id\");\n if (val) opts.longDescRId = val;\n }\n\n return opts as FrameOptions;\n}\n\nfunction parseDivsEl(el: Element): DivOptions[] {\n const result: DivOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:div\") {\n result.push(parseDivEl(child));\n }\n }\n return result;\n}\n\nfunction parseDivEl(el: Element): DivOptions {\n const id = attrNum(el, \"w:id\") ?? 0;\n const opts: Partial<DivOptions> = { id };\n\n const marLeft = findChild(el, \"w:marLeft\");\n if (marLeft) {\n const val = attrMeasure(marLeft, \"w:val\");\n if (val !== undefined) opts.marginLeft = val as number | UniversalMeasure;\n }\n\n const marRight = findChild(el, \"w:marRight\");\n if (marRight) {\n const val = attrMeasure(marRight, \"w:val\");\n if (val !== undefined) opts.marginRight = val as number | UniversalMeasure;\n }\n\n const marTop = findChild(el, \"w:marTop\");\n if (marTop) {\n const val = attrMeasure(marTop, \"w:val\");\n if (val !== undefined) opts.marginTop = val as number | UniversalMeasure;\n }\n\n const marBottom = findChild(el, \"w:marBottom\");\n if (marBottom) {\n const val = attrMeasure(marBottom, \"w:val\");\n if (val !== undefined) opts.marginBottom = val as number | UniversalMeasure;\n }\n\n const blockQuote = findChild(el, \"w:blockQuote\");\n if (blockQuote) {\n const val = attr(blockQuote, \"w:val\");\n opts.blockQuote = val !== \"off\";\n }\n\n const bodyDiv = findChild(el, \"w:bodyDiv\");\n if (bodyDiv) {\n const val = attr(bodyDiv, \"w:val\");\n opts.bodyDiv = val !== \"off\";\n }\n\n const divBdr = findChild(el, \"w:divBdr\");\n if (divBdr) {\n opts.border = parseDivBorderEl(divBdr);\n }\n\n const divsChild = findChild(el, \"w:divsChild\");\n if (divsChild) {\n const children = parseDivsEl(divsChild);\n if (children.length > 0) opts.children = children;\n }\n\n return opts as DivOptions;\n}\n\nfunction parseDivBorderEl(el: Element): DivBorderOptions {\n const opts: Partial<DivBorderOptions> = {};\n\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(el, `w:${side}`);\n if (sideEl) {\n const b: Partial<NonNullable<DivBorderOptions[\"top\"]>> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n opts[side] = b as NonNullable<DivBorderOptions[\"top\"]>;\n }\n }\n\n return opts as DivBorderOptions;\n}\n\nfunction wsDivBorderXml(b: NonNullable<DivOptions[\"border\"]>): string {\n const parts: string[] = [\"<w:divBdr>\"];\n const sides: [string, NonNullable<DivOptions[\"border\"]>[\"top\"]][] = [\n [\"w:top\", b.top],\n [\"w:left\", b.left],\n [\"w:bottom\", b.bottom],\n [\"w:right\", b.right],\n ];\n for (const [tag, side] of sides) {\n if (!side) continue;\n const attrParts: string[] = [`w:val=\"${escapeXml(side.style)}\"`];\n if (side.color) attrParts.push(`w:color=\"${escapeXml(side.color)}\"`);\n if (side.size !== undefined) attrParts.push(`w:sz=\"${side.size}\"`);\n parts.push(`<${tag} ${attrParts.join(\" \")}/>`);\n }\n parts.push(\"</w:divBdr>\");\n return parts.join(\"\");\n}\n\nfunction wsDivXml(d: DivOptions): string {\n const parts: string[] = [`<w:div w:id=\"${d.id}\">`];\n if (d.blockQuote !== undefined)\n parts.push(wsStringVal(\"w:blockQuote\", d.blockQuote ? \"on\" : \"off\"));\n if (d.bodyDiv !== undefined) parts.push(wsStringVal(\"w:bodyDiv\", d.bodyDiv ? \"on\" : \"off\"));\n parts.push(wsNumVal(\"w:marLeft\", d.marginLeft));\n parts.push(wsNumVal(\"w:marRight\", d.marginRight));\n parts.push(wsNumVal(\"w:marTop\", d.marginTop));\n parts.push(wsNumVal(\"w:marBottom\", d.marginBottom));\n if (d.border) parts.push(wsDivBorderXml(d.border));\n if (d.children?.length) {\n parts.push(\"<w:divsChild>\");\n for (const child of d.children) parts.push(wsDivXml(child));\n parts.push(\"</w:divsChild>\");\n }\n parts.push(\"</w:div>\");\n return parts.join(\"\");\n}\n\nexport function framesetXml(fs: FramesetOptions): string {\n const parts: string[] = [\"<w:frameset>\"];\n if (fs.size !== undefined) parts.push(wsStringVal(\"w:sz\", fs.size));\n if (fs.splitbar) {\n parts.push(\"<w:framesetSplitbar>\");\n if (fs.splitbar.width !== undefined)\n parts.push(`<w:w w:w=\"${fs.splitbar.width}\" w:type=\"dxa\"/>`);\n if (fs.splitbar.color !== undefined) parts.push(wsStringVal(\"w:color\", fs.splitbar.color));\n if (fs.splitbar.noBorder) parts.push(\"<w:noBorder/>\");\n if (fs.splitbar.flatBorders) parts.push(\"<w:flatBorders/>\");\n parts.push(\"</w:framesetSplitbar>\");\n }\n if (fs.layout !== undefined) parts.push(`<w:frameLayout w:val=\"${fs.layout}\"/>`);\n if (fs.title !== undefined) parts.push(wsStringVal(\"w:title\", fs.title));\n if (fs.children) {\n for (const child of fs.children) {\n if (\"children\" in child || \"layout\" in child || \"splitbar\" in child) {\n parts.push(framesetXml(child as FramesetOptions));\n } else {\n parts.push(frameXml(child as FrameOptions));\n }\n }\n }\n parts.push(\"</w:frameset>\");\n return parts.join(\"\");\n}\n\nexport function frameXml(f: FrameOptions): string {\n const parts: string[] = [\"<w:frame>\"];\n if (f.size !== undefined) parts.push(wsStringVal(\"w:sz\", f.size));\n if (f.name !== undefined) parts.push(wsStringVal(\"w:name\", f.name));\n if (f.title !== undefined) parts.push(wsStringVal(\"w:title\", f.title));\n if (f.sourceRId !== undefined) parts.push(`<w:sourceFileName r:id=\"${escapeXml(f.sourceRId)}\"/>`);\n if (f.marginWidth !== undefined) parts.push(wsNumVal(\"w:marW\", f.marginWidth));\n if (f.marginHeight !== undefined) parts.push(wsNumVal(\"w:marH\", f.marginHeight));\n if (f.scrollbar !== undefined) parts.push(`<w:scrollbar w:val=\"${f.scrollbar}\"/>`);\n if (f.noResizeAllowed) parts.push(\"<w:noResizeAllowed/>\");\n if (f.linkedToFile) parts.push(\"<w:linkedToFile/>\");\n if (f.longDescRId !== undefined) parts.push(`<w:longDesc r:id=\"${escapeXml(f.longDescRId)}\"/>`);\n parts.push(\"</w:frame>\");\n return parts.join(\"\");\n}\n\nexport const webSettingsDesc: CustomDescriptor<WebSettingsInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [`<w:webSettings ${WS_NS}>`];\n\n if (opts.frameset !== undefined) p.push(framesetXml(opts.frameset));\n if (opts.divs?.length) {\n p.push(\"<w:divs>\");\n for (const d of opts.divs) p.push(wsDivXml(d));\n p.push(\"</w:divs>\");\n }\n if (opts.encoding !== undefined) p.push(wsStringVal(\"w:encoding\", opts.encoding));\n if (opts.optimizeForBrowser !== undefined) {\n const ob = opts.optimizeForBrowser;\n if (typeof ob === \"boolean\") {\n p.push(wsOnOff(\"w:optimizeForBrowser\", ob));\n } else {\n // CT_OptimizeForBrowser: CT_OnOff + optional @w:target. Omit w:val when\n // true to match typical Word output; emit w:val=\"false\" only when disabled.\n const valAttr = ob.value === false ? ' w:val=\"false\"' : \"\";\n const targetAttr = ob.target ? ` w:target=\"${escapeXml(ob.target)}\"` : \"\";\n p.push(`<w:optimizeForBrowser${valAttr}${targetAttr}/>`);\n }\n }\n if (opts.relyOnVML !== undefined) p.push(wsOnOff(\"w:relyOnVML\", opts.relyOnVML));\n if (opts.allowPNG !== undefined) p.push(wsOnOff(\"w:allowPNG\", opts.allowPNG));\n if (opts.doNotRelyOnCSS !== undefined) p.push(wsOnOff(\"w:doNotRelyOnCSS\", opts.doNotRelyOnCSS));\n if (opts.doNotSaveAsSingleFile !== undefined)\n p.push(wsOnOff(\"w:doNotSaveAsSingleFile\", opts.doNotSaveAsSingleFile));\n if (opts.doNotOrganizeInFolder !== undefined)\n p.push(wsOnOff(\"w:doNotOrganizeInFolder\", opts.doNotOrganizeInFolder));\n if (opts.doNotUseLongFileNames !== undefined)\n p.push(wsOnOff(\"w:doNotUseLongFileNames\", opts.doNotUseLongFileNames));\n if (opts.pixelsPerInch !== undefined) p.push(wsNumVal(\"w:pixelsPerInch\", opts.pixelsPerInch));\n if (opts.targetScreenSize !== undefined)\n p.push(wsStringVal(\"w:targetScreenSz\", opts.targetScreenSize));\n if (opts.saveSmartTagsAsXml !== undefined)\n p.push(wsOnOff(\"w:saveSmartTagsAsXml\", opts.saveSmartTagsAsXml));\n\n p.push(\"</w:webSettings>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const opts: Partial<WebSettingsInput> = {};\n\n // Frameset\n const frameset = findChild(el, \"w:frameset\");\n if (frameset) {\n opts.frameset = parseFramesetEl(frameset);\n }\n\n // Divs\n const divs = findChild(el, \"w:divs\");\n if (divs) {\n const parsed = parseDivsEl(divs);\n if (parsed.length > 0) opts.divs = parsed;\n }\n\n // Encoding\n const encoding = findChild(el, \"w:encoding\");\n if (encoding) {\n const val = attr(encoding, \"w:val\");\n if (val) opts.encoding = val;\n }\n\n // Boolean fields\n for (const [name, optKey] of [\n [\"w:relyOnVML\", \"relyOnVML\"],\n [\"w:allowPNG\", \"allowPNG\"],\n [\"w:doNotRelyOnCSS\", \"doNotRelyOnCSS\"],\n [\"w:doNotSaveAsSingleFile\", \"doNotSaveAsSingleFile\"],\n [\"w:doNotOrganizeInFolder\", \"doNotOrganizeInFolder\"],\n [\"w:doNotUseLongFileNames\", \"doNotUseLongFileNames\"],\n [\"w:saveSmartTagsAsXml\", \"saveSmartTagsAsXml\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // optimizeForBrowser — CT_OptimizeForBrowser (CT_OnOff + optional @w:target)\n const obEl = findChild(el, \"w:optimizeForBrowser\");\n if (obEl) {\n const target = attr(obEl, \"w:target\");\n if (target) {\n opts.optimizeForBrowser = { value: attrBool(obEl, \"w:val\") ?? true, target };\n } else {\n opts.optimizeForBrowser = attrBool(obEl, \"w:val\") ?? true;\n }\n }\n\n // Pixels per inch\n const ppi = findChild(el, \"w:pixelsPerInch\");\n if (ppi) {\n const val = attrNum(ppi, \"w:val\");\n if (val !== undefined) opts.pixelsPerInch = val;\n }\n\n // Target screen size\n const targetScreenSize = findChild(el, \"w:targetScreenSz\");\n if (targetScreenSize) {\n const val = attr(targetScreenSize, \"w:val\");\n if (val) opts.targetScreenSize = val;\n }\n\n return opts as WebSettingsInput;\n },\n};\n","/**\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 * Embeddings module for WordprocessingML documents.\n *\n * Manages OLE object embeddings (word/embeddings/oleObjectN.bin) referenced by\n * w:object elements. Mirrors the Media collection pattern but targets binary\n * OLE container parts instead of images.\n *\n * @module\n */\n\n/** OLE embedding data stored under word/embeddings/. */\nexport interface EmbeddingData {\n /** File name within word/embeddings/ (e.g. \"oleObject1.bin\"). */\n fileName: string;\n /** Raw OLE container bytes. */\n data: Uint8Array;\n /** OLE program id (e.g. \"Excel.Sheet.12\") — informational only. */\n progId?: string;\n}\n\n/**\n * Collects OLE embeddings allocated during document generation. Each embedding\n * is stored under a sequential `oleObjectN.bin` name in word/embeddings/,\n * mirroring MS Office's numbering so output is deterministic and diffable.\n */\nexport class EmbeddingCollection {\n private map = new Map<string, EmbeddingData>();\n private counter = 0;\n\n /** Allocate the next sequential embedding file name (oleObject1.bin, …). */\n public nextEmbeddingName(): string {\n return `oleObject${++this.counter}.bin`;\n }\n\n /** Register an embedding under a unique key. */\n public addEmbedding(key: string, data: EmbeddingData): void {\n this.map.set(key, data);\n }\n\n /** All registered embeddings in insertion order. */\n public get array(): EmbeddingData[] {\n return [...this.map.values()];\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 type { EndnoteSeparator } from \"@parts/endnotes/descriptor\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport type { FootnoteSeparator } from \"@parts/footnotes/descriptor\";\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 { CommentOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { SettingsOptions } from \"@parts/settings/settings\";\nimport { Styles, extractStyleId } from \"@parts/styles\";\nimport { ExternalStylesFactory } from \"@parts/styles/external-styles-factory\";\nimport { DefaultStylesFactory, stringifyDocDefaults } from \"@parts/styles/factory\";\nimport { SubDocCollection } from \"@parts/sub-doc/sub-doc-collection\";\nimport type { WebSettingsOptions } from \"@parts/web-settings\";\nimport { EmbeddingCollection } from \"@shared/embeddings/embeddings\";\nimport { Media } from \"@shared/media\";\nimport type { MediaData } from \"@shared/media/data\";\nimport type { SectionOptions } from \"@shared/section\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { DocxDocument } from \"./parse\";\n\n/** User styles override factory defaults with the same styleId; keep the rest. */\nfunction mergeById<T extends { id: string }>(\n factoryStyles: T[] | undefined,\n userStyles: T[] | undefined,\n): T[] {\n const factory = factoryStyles ?? [];\n if (!userStyles || userStyles.length === 0) return factory;\n const userIds = new Set(userStyles.map((s) => s.id));\n return [...factory.filter((s) => !userIds.has(s.id)), ...userStyles];\n}\n\n/**\n * Highest comment id in an explicit comments list, or -1 when there are none.\n * Seeds the comment id allocator so auto-allocated ids never collide with ids\n * the caller already assigned (e.g. round-tripped from an existing document).\n */\nfunction maxCommentId(comments: readonly CommentOptions[] | undefined): number {\n let max = -1;\n if (comments) {\n for (const c of comments) {\n if (c.id > max) max = c.id;\n }\n }\n return max;\n}\n\n/** Narrows an object to a `{ id: number }` marker without an `as` cast. */\nfunction isNumericIdMarker(value: unknown): value is { id: number } {\n return (\n typeof value === \"object\" && value !== null && \"id\" in value && typeof value.id === \"number\"\n );\n}\n\n/**\n * Highest w:id among explicit bookmark + move-range start markers (`range`) and\n * explicit movedFrom/movedTo runs (`moveRun`) anywhere in the body tree\n * (paragraphs, tables, textboxes, SDTs, headers/footers nested in sections).\n * Seeds the markup id allocators so `{ bookmark }` / `{ moveFrom }` / `{ moveTo }`\n * sugars never collide with ids the caller already assigned. Comment ids live in\n * their own namespace (comments.nextId) and are intentionally excluded.\n */\nfunction collectMaxMarkupIds(value: unknown, acc: { range: number; moveRun: number }): void {\n if (value === null || value === undefined || typeof value !== \"object\") return;\n if (value instanceof Uint8Array || value instanceof Date) return;\n if (Array.isArray(value)) {\n for (const item of value) collectMaxMarkupIds(item, acc);\n return;\n }\n const obj = value as Record<string, unknown>;\n const rangeMarker = obj.bookmarkStart ?? obj.moveFromRangeStart ?? obj.moveToRangeStart;\n if (isNumericIdMarker(rangeMarker) && rangeMarker.id > acc.range) acc.range = rangeMarker.id;\n const moveRun = obj.movedFrom ?? obj.movedTo;\n if (isNumericIdMarker(moveRun) && moveRun.id > acc.moveRun) acc.moveRun = moveRun.id;\n for (const key of Object.keys(obj)) collectMaxMarkupIds(obj[key], acc);\n}\n\n/**\n * Whether any `{ comment }` sugar child appears anywhere in the body tree\n * (paragraphs, tables, textboxes, SDTs, headers/footers nested in sections).\n * The document→comments relationship must exist whenever comments.xml will be\n * generated; since sugar entries are registered during stringify — after the\n * constructor wires relationships — this pre-scan predicts them so the part and\n * its relationship stay in sync (OPC consistency). Every `{ comment }` always\n * stringifies, so the prediction matches the entries actually registered.\n */\nfunction bodyContainsCommentSugar(value: unknown): boolean {\n if (value === null || value === undefined) return false;\n if (typeof value !== \"object\") return false;\n if (value instanceof Uint8Array || value instanceof Date) return false;\n if (Array.isArray(value)) {\n for (const item of value) {\n if (bodyContainsCommentSugar(item)) return true;\n }\n return false;\n }\n const obj = value as Record<string, unknown>;\n if (typeof obj.comment === \"object\" && obj.comment !== null) return true;\n for (const key of Object.keys(obj)) {\n if (bodyContainsCommentSugar(obj[key])) return true;\n }\n return false;\n}\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<MediaData>;\n declare public charts: ChartCollection;\n declare public smartArts: SmartArtCollection;\n declare public embeddings: EmbeddingCollection;\n declare public altChunks: AltChunkCollection;\n declare public subDocs: SubDocCollection;\n declare public comments: {\n relationships: Relationships;\n /** Comment entries registered by `{ comment }` sugar children during stringify. */\n entries: CommentOptions[];\n /** Next auto-allocated comment id (seeded above any explicit comment id). */\n nextId: number;\n };\n declare public markupIds: {\n /** Next id for bookmark + move-range markers (CT_MarkupRange) — shared, like Word. */\n rangeNext: number;\n /** Next id for movedFrom/movedTo runs (CT_TrackChange). */\n moveRunNext: number;\n };\n declare public footNotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n separator?: FootnoteSeparator;\n continuationSeparator?: FootnoteSeparator;\n };\n declare public endnotes: {\n relationships: Relationships;\n notes: Map<number, (ParagraphOptions | string)[]>;\n separator?: EndnoteSeparator;\n continuationSeparator?: EndnoteSeparator;\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 // Footnotes/endnotes are optional parts. Fresh compile always emits them\n // (Word ships a separators-only file); round-trip emits them only when the\n // source package declared the part — otherwise emitting the part + document\n // relationship without a [Content_Types] Override is an OPC violation that\n // makes Word reject the package as unreadable content.\n private readonly _hasFootnotes: boolean;\n private readonly _hasEndnotes: boolean;\n private readonly _hasNumbering: boolean;\n public get hasFootnotes(): boolean {\n return this._hasFootnotes;\n }\n public get hasEndnotes(): boolean {\n return this._hasEndnotes;\n }\n public get hasNumbering(): boolean {\n return this._hasNumbering;\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 const entry = this.media.addMedia(\n data,\n type,\n (fileName) =>\n ({\n data,\n fileName,\n type,\n transformation: { pixels: { x: 0, y: 0 }, emus: { x: 0, y: 0 } },\n }) as MediaData,\n );\n return `{${entry.fileName}}`;\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 = {\n relationships: new Relationships(),\n entries: [],\n nextId: maxCommentId(options.comments?.children) + 1,\n };\n const markupSeed = { range: -1, moveRun: -1 };\n collectMaxMarkupIds(options.sections, markupSeed);\n this.markupIds = {\n rangeNext: markupSeed.range + 1,\n moveRunNext: markupSeed.moveRun + 1,\n };\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 || undefined,\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<MediaData>();\n this.charts = new ChartCollection();\n this.smartArts = new SmartArtCollection();\n this.embeddings = new EmbeddingCollection();\n this.altChunks = new AltChunkCollection();\n this.subDocs = new SubDocCollection();\n\n if (options.externalStyles !== undefined) {\n const externalStyles = new ExternalStylesFactory().newInstance(options.externalStyles);\n const defaultStyles = new DefaultStylesFactory().newInstance(options.styles?.default ?? {});\n // External (user-provided full styles.xml) wins; factory builtins fill\n // any gaps. Drop factory builtins whose styleId the external XML already\n // defines (no duplicate styleId). docDefaults/latentStyles come from the\n // external XML — the factory's are not mixed in.\n const externalIds = new Set<string>();\n for (const s of externalStyles.importedStyles ?? []) {\n const id = extractStyleId(s._raw);\n if (id) externalIds.add(id);\n }\n const notInExternal = <T extends { id: string }>(arr: T[] | undefined) =>\n (arr ?? []).filter((s) => !externalIds.has(s.id));\n this.styles = new Styles({\n importedStyles: externalStyles.importedStyles,\n initialAttributes: externalStyles.initialAttributes ?? defaultStyles.initialAttributes,\n paragraphStyles: notInExternal(defaultStyles.paragraphStyles),\n characterStyles: notInExternal(defaultStyles.characterStyles),\n tableStyles: notInExternal(defaultStyles.tableStyles),\n numberingStyles: notInExternal(defaultStyles.numberingStyles),\n });\n } else if (options.styles) {\n const s = options.styles;\n if (s.roundTripped) {\n // Round-trip origin (parseStyleDefinitions): structured default.document\n // wins so the visual editor can edit default run/paragraph properties\n // and have them take effect on generate. docDefaultsXml verbatim is only\n // a fallback for older parses without default.document or a completely\n // empty <w:docDefaults/>. No factory builtin rebuild — parsed builtins\n // already carry the source document's customizations.\n const f = new DefaultStylesFactory().newInstance({});\n const docDefaults =\n s.default?.document !== undefined\n ? stringifyDocDefaults(s.default.document, false)\n : (s.docDefaultsXml ?? f.importedStyles?.[0]?._raw ?? \"\");\n const latentStyles = s.latentStylesXml ?? f.importedStyles?.[1]?._raw ?? \"\";\n this.styles = new Styles({\n importedStyles: [{ _raw: docDefaults }, { _raw: latentStyles }],\n initialAttributes: s.initialAttributes ?? f.initialAttributes,\n paragraphStyles: s.paragraphStyles,\n characterStyles: s.characterStyles,\n tableStyles: s.tableStyles,\n numberingStyles: s.numberingStyles,\n });\n } else {\n // Fresh generation: factory default builtins (structured) + user\n // overrides. User paragraphStyles/characterStyles/tableStyles/\n // numberingStyles override factory builtins with the same styleId.\n const f = new DefaultStylesFactory().newInstance(s.default);\n this.styles = new Styles({\n importedStyles: f.importedStyles,\n initialAttributes: s.initialAttributes ?? f.initialAttributes,\n paragraphStyles: mergeById(f.paragraphStyles, s.paragraphStyles),\n characterStyles: mergeById(f.characterStyles, s.characterStyles),\n tableStyles: mergeById(f.tableStyles, s.tableStyles),\n numberingStyles: mergeById(f.numberingStyles, s.numberingStyles),\n });\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 // Resolve footnote/endnote presence from the source [Content_Types]: a\n // round-tripped package only carries these parts when the source declared\n // them. Fresh compile (no contentTypes) always emits both.\n const sourceOverrides = options.contentTypes?.overrides ?? [];\n this._hasFootnotes =\n !options.contentTypes || sourceOverrides.some((o) => o.partName === \"/word/footnotes.xml\");\n this._hasEndnotes =\n !options.contentTypes || sourceOverrides.some((o) => o.partName === \"/word/endnotes.xml\");\n // Numbering follows the source [Content_Types] on round-trip — the part is\n // optional, and emitting it without a matching Override is an OPC violation.\n // Fresh compile always emits it (Word ships a default bullet list).\n this._hasNumbering =\n !options.contentTypes || sourceOverrides.some((o) => o.partName === \"/word/numbering.xml\");\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 // Skip the round-tripped separator markers (they carry no .children).\n if (key === \"separator\" || key === \"continuationSeparator\") continue;\n const note = options.footnotes[key];\n if (!note) continue;\n this.footNotes.notes.set(parseFloat(key), note.children);\n }\n this.footNotes.separator = options.footnotes.separator;\n this.footNotes.continuationSeparator = options.footnotes.continuationSeparator;\n }\n\n if (options.endnotes) {\n for (const key in options.endnotes) {\n if (key === \"separator\" || key === \"continuationSeparator\") continue;\n const note = options.endnotes[key];\n if (!note) continue;\n this.endnotes.notes.set(parseFloat(key), note.children);\n }\n this.endnotes.separator = options.endnotes.separator;\n this.endnotes.continuationSeparator = options.endnotes.continuationSeparator;\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 if (this._hasNumbering) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering\",\n \"numbering.xml\",\n );\n }\n if (this._hasFootnotes) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes\",\n \"footnotes.xml\",\n );\n }\n if (this._hasEndnotes) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes\",\n \"endnotes.xml\",\n );\n }\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\",\n \"settings.xml\",\n );\n // Comments is an optional part — only wire the document→comments relationship\n // when the document actually carries comments. Emitting it unconditionally\n // produces an orphan comments.xml that Word rejects as an OPC violation\n // (empty part with no [Content_Types] Override when content types are\n // passed through from the source on round-trip).\n if (\n this._options.comments?.children?.length ||\n bodyContainsCommentSugar(this._options.sections)\n ) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\",\n \"comments.xml\",\n );\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 // Theme — always present: fresh-compile generates a default theme, round-trip\n // passes the source theme through rawParts. Word needs the document→theme\n // relationship to resolve theme colors/fonts.\n const themePart = this._options.rawParts?.find((p) => p.path.startsWith(\"word/theme/\"));\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\",\n themePart ? themePart.path.replace(/^word\\//, \"\") : \"theme/theme1.xml\",\n );\n\n // customXml storage — raw-passthrough parts. Declare the document→customXml\n // relationship for each item (itemProps are linked via the item's own .rels,\n // not directly by the document) so Word can bind cover-page metadata, etc.\n for (const part of this._options.rawParts ?? []) {\n if (\n part.path.startsWith(\"customXml/\") &&\n part.path.endsWith(\".xml\") &&\n !part.path.includes(\"/_rels/\") &&\n !part.path.includes(\"itemProps\")\n ) {\n this.document.relationships.addRelationship(\n this._currentRelationshipId++,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml\",\n `../${part.path}`,\n );\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 /**\n * Path of the part currently being parsed. Each part carries its own .rels\n * with independent rId numbering, so drawings inside a part must resolve\n * image relationships against that part's rels. Defaults to the document body.\n */\n public currentPart = \"word/document.xml\";\n\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 const partMedia = this.docx.partRefs.partMedia.get(this.currentPart);\n if (partMedia) {\n const media = partMedia.get(rId);\n if (media) return media;\n }\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 /**\n * Run `fn` with `currentPart` temporarily set to `partPath`, restoring the\n * previous value afterwards. Use when parsing a sub-document part (header,\n * footer, footnotes, …) so its drawings resolve images from its own rels.\n */\n withPart<T>(partPath: string, fn: () => T): T {\n const prev = this.currentPart;\n this.currentPart = partPath;\n try {\n return fn();\n } finally {\n this.currentPart = prev;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,gBAAgB;;CAE3B,OAAO;;CAEP,QAAQ;;CAER,KAAK;;CAEL,MAAM;;CAEN,gBAAgB;;CAEhB,YAAY;;CAEZ,SAAS;;CAET,cAA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