@office-open/docx 0.10.15 → 0.12.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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"comments-D_flVfxw.mjs","names":["createImageData","xmlChildren","createImageData","THEME_COLORS","cnfStyleStr","xmlChildren","BORDER_STYLES","THEME_COLORS","fillDesc","outlineDesc","effectListDesc","customGeometryDesc","presetGeometryDesc","md"],"sources":["../src/parts/paragraph/formatting/spacing.ts","../src/parts/paragraph/formatting/style.ts","../src/parts/paragraph/run/run.ts","../src/shared/media/media.ts","../src/parts/paragraph/run/image-run.ts","../src/parts/drawing/inline/graphic/graphic-data/wps/body-properties.ts","../src/parts/paragraph/run/form-field.ts","../src/parts/table/table-cell/table-cell-components.ts","../src/shared/border.ts","../src/parts/table/table-width.ts","../src/parts/object/object-element.ts","../src/shared/shading.ts","../src/util/stringify-element.ts","../src/parts/paragraph/run/run-parse.ts","../src/parts/paragraph/stringify.ts","../src/parts/bodychildren.ts","../src/parts/drawing/text-wrap/text-wrapping.ts","../src/shared/constants.ts","../src/parts/drawing/floating/floating-position.ts","../src/parts/document/body/section-properties/properties/page-number.ts","../src/parts/document/body/section-properties/properties/page-size.ts","../src/parts/document/body/section-properties/properties/page-text-direction.ts","../src/parts/document/body/section-properties/section-properties.ts","../src/parts/document/body/section-properties/descriptor.ts","../src/parts/fonts/font-wrapper.ts","../src/parts/sdt/sdt-parse.ts","../src/parts/table-of-contents/descriptor.ts","../src/parts/textbox/shape/shape.ts","../src/parts/paragraph/math/stringify.ts","../src/util/replace-media-placeholders.ts","../src/body.ts","../src/parts/drawing/drawing-parse.ts","../src/parts/drawing/descriptor.ts","../src/parts/paragraph/run/field.ts","../src/parts/inline.ts","../src/parts/table/stringify.ts","../src/parts/table/descriptor.ts","../src/parts/comments.ts"],"sourcesContent":["/**\n * Paragraph spacing module for WordprocessingML documents.\n *\n * This module provides spacing options for paragraphs including space before,\n * space after, and line spacing.\n *\n * Reference: http://officeopenxml.com/WPspacing.php\n *\n * @module\n */\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\n\n/**\n * Line spacing rule types.\n *\n * Specifies how the line height is calculated.\n *\n * @publicApi\n */\nexport const LineRuleType = {\n /** Line spacing is at least the specified value */\n AT_LEAST: \"atLeast\",\n /** Line spacing is exactly the specified value */\n EXACTLY: \"exactly\",\n /** Line spacing is exactly the specified value (alias for EXACTLY) */\n EXACT: \"exact\",\n /** Line spacing is automatically determined based on content */\n AUTO: \"auto\",\n} as const;\n\n/**\n * Properties for configuring paragraph spacing.\n *\n * All values are in twips (twentieths of a point) unless otherwise specified.\n */\nexport interface SpacingProperties {\n /** Spacing after the paragraph in twips or as a PositiveUniversalMeasure */\n after?: number | PositiveUniversalMeasure;\n /** Spacing before the paragraph in twips or as a PositiveUniversalMeasure */\n before?: number | PositiveUniversalMeasure;\n /** Line spacing value in twips or as a PositiveUniversalMeasure (depends on lineRule) */\n line?: number | PositiveUniversalMeasure;\n /** How to interpret the line spacing value */\n lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType];\n /** Use automatic spacing before the paragraph */\n beforeAutoSpacing?: boolean;\n /** Use automatic spacing after the paragraph */\n afterAutoSpacing?: boolean;\n /** Spacing before the paragraph in line units */\n beforeLines?: number;\n /** Spacing after the paragraph in line units */\n afterLines?: number;\n}\n","/**\n * Paragraph style module for WordprocessingML documents.\n *\n * This module provides paragraph style references including heading levels.\n *\n * @module\n */\n/**\n * Built-in heading level styles.\n *\n * These are the standard heading styles available in Word documents.\n *\n * @publicApi\n */\nexport const HeadingLevel = {\n /** Heading 1 style */\n HEADING_1: \"Heading1\",\n /** Heading 2 style */\n HEADING_2: \"Heading2\",\n /** Heading 3 style */\n HEADING_3: \"Heading3\",\n /** Heading 4 style */\n HEADING_4: \"Heading4\",\n /** Heading 5 style */\n HEADING_5: \"Heading5\",\n /** Heading 6 style */\n HEADING_6: \"Heading6\",\n /** Title style */\n TITLE: \"Title\",\n} as const;\n","import type { ObjectElementOptions } from \"@parts/object\";\n\n/**\n * Run module for WordprocessingML documents.\n *\n * A run is a region of text with a common set of properties. It is the primary\n * unit of inline content in a paragraph.\n *\n * Reference: http://officeopenxml.com/WPtext.php\n *\n * @module\n */\nimport type {\n AnnotationReference,\n CarriageReturn,\n ContinuationSeparator,\n DayLong,\n DayShort,\n EndnoteReference,\n FootnoteReferenceElement,\n LastRenderedPageBreak,\n MonthLong,\n MonthShort,\n NoBreakHyphen,\n PageNumberElement,\n Separator,\n SoftHyphen,\n Tab,\n YearLong,\n YearShort,\n} from \"./empty-children\";\nimport type { ParagraphRunPropertiesOptions, RunPropertiesOptions } from \"./properties\";\n\n/** w:br/@w:clear values (ST_BrClear) — clears floating content on the given side(s). */\nexport type BreakClear = \"none\" | \"left\" | \"right\" | \"all\";\n\n/** Options for a line break with optional float-clearing (CT_Br). */\nexport interface BreakOptions {\n /** Number of `<w:br/>` elements (defaults to 1). */\n count?: number;\n /** Clear floating content (w:br/@w:clear). */\n clear?: BreakClear;\n}\n\n/**\n * Serialize a break option (count shorthand or structured with clear) to one or\n * more `<w:br/>` tags.\n */\nexport function breakXml(breakOpt: number | BreakOptions | undefined): string {\n if (!breakOpt) return \"\";\n const count = typeof breakOpt === \"number\" ? breakOpt : (breakOpt.count ?? 1);\n if (count <= 0) return \"\";\n const clear = typeof breakOpt === \"object\" ? breakOpt.clear : undefined;\n const one = clear ? `<w:br w:clear=\"${clear}\"/>` : \"<w:br/>\";\n return count === 1 ? one : one.repeat(count);\n}\n\n/**\n * Empty EG_RunInnerContent elements — self-closing XML with no attributes.\n * Shared by the body run stringifier and the inline (footnote/endnote) run\n * stringifier so both emit them identically. Keyed by the RunOptions child\n * property name (e.g. `{ separator: true }` → `separator`).\n *\n * XSD reference: EG_RunInnerContent group in wml.xsd.\n */\nexport const EMPTY_RUN_ELEMENTS: Record<string, string> = {\n noBreakHyphen: \"<w:noBreakHyphen/>\",\n softHyphen: \"<w:softHyphen/>\",\n dayShort: \"<w:dayShort/>\",\n monthShort: \"<w:monthShort/>\",\n yearShort: \"<w:yearShort/>\",\n dayLong: \"<w:dayLong/>\",\n monthLong: \"<w:monthLong/>\",\n yearLong: \"<w:yearLong/>\",\n annotationRef: \"<w:annotationRef/>\",\n footnoteRef: \"<w:footnoteRef/>\",\n endnoteRef: \"<w:endnoteRef/>\",\n separator: \"<w:separator/>\",\n continuationSeparator: \"<w:continuationSeparator/>\",\n pgNum: \"<w:pgNum/>\",\n carriageReturn: \"<w:cr/>\",\n lastRenderedPageBreak: \"<w:lastRenderedPageBreak/>\",\n};\n\ninterface RunOptionsBase {\n children?: (\n | (typeof PageNumber)[keyof typeof PageNumber]\n | string\n | AnnotationReference\n | CarriageReturn\n | ContinuationSeparator\n | DayLong\n | DayShort\n | EndnoteReference\n | FootnoteReferenceElement\n | LastRenderedPageBreak\n | MonthLong\n | MonthShort\n | NoBreakHyphen\n | PageNumberElement\n | Separator\n | SoftHyphen\n | Tab\n | YearLong\n | YearShort\n | { object: ObjectElementOptions }\n | Record<string, unknown>\n )[];\n break?: number | BreakOptions;\n text?: string;\n}\n\n/**\n * Options for creating a Run element.\n *\n * The run element specifies a region of text with a common set of properties.\n * The children property can contain various inline content elements.\n *\n * @see {@link Run}\n */\nexport type RunOptions = RunOptionsBase &\n RunPropertiesOptions & {\n /** Revision save ID for the run (w:rsidR, hex string e.g. \"00123456\"). */\n rsid?: string;\n /** Revision save ID for run properties (w:rsidRPr, hex string). */\n runPropertiesRsid?: string;\n /** Revision save ID when run was deleted (w:rsidDel, hex string). */\n deletionRsid?: string;\n };\n\nexport type ParagraphRunOptions = RunOptionsBase & ParagraphRunPropertiesOptions;\n\n/**\n * Constants for page number field types.\n *\n * These values are used to insert dynamic page number fields into a document.\n *\n * Reference: http://officeopenxml.com/WPfields.php\n *\n * @publicApi\n */\nexport const PageNumber = {\n /** Inserts the current page number */\n CURRENT: \"CURRENT\",\n /** Inserts the total number of pages in the document */\n TOTAL_PAGES: \"TOTAL_PAGES\",\n /** Inserts the total number of pages in the current section */\n TOTAL_PAGES_IN_SECTION: \"TOTAL_PAGES_IN_SECTION\",\n /** Inserts the current section number */\n CURRENT_SECTION: \"SECTION\",\n} as const;\n","import type { UniversalMeasure } from \"@office-open/core\";\nimport { convertEmuToPixels, convertToEmu } from \"@office-open/core\";\n\n/**\n * Media module for WordprocessingML documents.\n *\n * Provides transformation helpers for embedded media (images). The deduplicated\n * media collection itself ({@link Media}) lives in @office-open/core and is\n * re-exported from this package's index so every format package shares one\n * content-based dedup implementation.\n *\n * @module\n */\nimport type { MediaDataTransformation } from \"./data\";\n\n/**\n * Transformation options for media display.\n *\n * Specifies how an image should be transformed when displayed in the document.\n * Width and height can be specified as numbers (in EMUs) or as universal measures\n * (e.g., \"100mm\", \"2in\").\n */\nexport interface MediaTransformation {\n offset?: {\n top?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n };\n width: number | UniversalMeasure;\n /** Display height in EMUs or universal measure */\n height: number | UniversalMeasure;\n /** Optional flip transformations */\n flip?: {\n /** Whether to flip the image vertically */\n vertical?: boolean;\n /** Whether to flip the image horizontally */\n horizontal?: boolean;\n };\n /** Optional rotation angle in degrees */\n rotation?: number;\n /** Effect extent (wp:effectExtent) in raw EMUs — passed through verbatim. */\n effectExtent?: { l: number; t: number; r: number; b: number };\n}\n\n/**\n * Converts user-facing transformation options (EMU or universal measure) to internal\n * transformation data (pixels + EMUs).\n *\n * @param options - User-facing transformation in EMU or universal measure\n * @returns Internal transformation data with both pixel and EMU values\n */\nexport const createTransformation = (options: MediaTransformation): MediaDataTransformation => {\n const widthEmu = convertToEmu(options.width);\n const heightEmu = convertToEmu(options.height);\n const offsetLeftEmu = convertToEmu(options.offset?.left ?? 0);\n const offsetTopEmu = convertToEmu(options.offset?.top ?? 0);\n return {\n emus: { x: widthEmu, y: heightEmu },\n flip: options.flip,\n offset: {\n emus: { x: offsetLeftEmu, y: offsetTopEmu },\n pixels: {\n x: Math.round(convertEmuToPixels(offsetLeftEmu)),\n y: Math.round(convertEmuToPixels(offsetTopEmu)),\n },\n },\n pixels: {\n x: Math.round(convertEmuToPixels(widthEmu)),\n y: Math.round(convertEmuToPixels(heightEmu)),\n },\n rotation: options.rotation ? options.rotation * 60_000 : undefined,\n ...(options.effectExtent ? { effectExtent: options.effectExtent } : {}),\n };\n};\n","import type { DataType } from \"@office-open/core\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\n/**\n * ImageRun types for WordprocessingML documents.\n *\n * This module provides support for inserting images into documents.\n *\n * Reference: http://officeopenxml.com/drwPicInline.php\n *\n * @module\n */\nimport type { DocPropertiesOptions } from \"@parts/drawing/doc-properties/doc-properties\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type { MediaTransformation } from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { MediaData, NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { Floating } from \"../../drawing\";\nimport type { GraphicFrameLocksOptions } from \"../../drawing/descriptor\";\nimport type { BlipEffectsOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { TileOptions } from \"../../drawing/inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"../../drawing/inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"../../drawing/inline/graphic/graphic-data/pic/outline/outline\";\n\n/**\n * Core options for image configuration.\n */\ninterface CoreImageOptions {\n transformation: MediaTransformation;\n floating?: Floating;\n altText?: DocPropertiesOptions;\n outline?: OutlineOptions;\n fill?: FillOptions;\n effects?: EffectListOptions;\n blipEffects?: BlipEffectsOptions;\n sourceRectangle?: SourceRectangleOptions;\n tile?: TileOptions;\n /** Picture non-visual properties (pic:cNvPr) — populated by parse */\n nonVisualProperties?: NonVisualPropertiesOptions;\n /** Structured run properties of the wrapping w:r (round-trip) — emitted before the drawing. */\n runProperties?: RunPropertiesOptions;\n /** Graphic frame locks (wp:cNvGraphicFramePr) for round-trip. */\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n /** Blip rendering hint `a14:useLocalDpi` (round-trip). */\n useLocalDpi?: boolean;\n}\n\ninterface RegularImageOptions {\n type: \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\n data: DataType;\n}\n\ninterface SvgMediaOptions {\n type: \"svg\";\n data: DataType;\n /**\n * Required in case the Word processor does not support SVG.\n */\n fallback: RegularImageOptions;\n}\n\n/**\n * Options for creating an ImageRun.\n *\n * @see {@link ImageRun}\n */\nexport type ImageOptions = (RegularImageOptions | SvgMediaOptions) & CoreImageOptions;\n\nexport const createImageData = (\n data: Uint8Array,\n transformation: MediaTransformation,\n key: string,\n sourceRectangle?: SourceRectangleOptions,\n nonVisualProperties?: NonVisualPropertiesOptions,\n): Pick<\n MediaData,\n \"data\" | \"fileName\" | \"transformation\" | \"sourceRectangle\" | \"nonVisualProperties\"\n> => ({\n data,\n fileName: key,\n sourceRectangle,\n nonVisualProperties,\n transformation: createTransformation(transformation),\n});\n","/**\n * Text body properties for DrawingML shapes.\n *\n * Provides CT_TextBodyProperties — defines how text is laid out within a shape,\n * including margins, alignment, autofit, vertical text, overflow, columns, and 3D.\n *\n * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TextBodyProperties\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport { convertToEmu } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { scene3DDesc, shape3DDesc } from \"@office-open/core/drawingml\";\nimport { attr, attrBool, attrMeasure, attrNum, element, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { Scene3DOptions } from \"../pic/three-d/scene-3d\";\nimport { createScene3D } from \"../pic/three-d/scene-3d\";\nimport type { Shape3DOptions } from \"../pic/three-d/shape-3d\";\nimport { createShape3D } from \"../pic/three-d/shape-3d\";\n\n// ─── Constants ──────────────────────────────────────────────────────────────\n\n/**\n * Text anchoring type (ST_TextAnchoringType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextAnchoringType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"t\"/>\n * <xsd:enumeration value=\"ctr\"/>\n * <xsd:enumeration value=\"b\"/>\n * <xsd:enumeration value=\"just\"/>\n * <xsd:enumeration value=\"dist\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport enum VerticalAnchor {\n TOP = \"t\",\n CENTER = \"ctr\",\n BOTTOM = \"b\",\n JUSTIFY = \"just\",\n DISTRIBUTED = \"dist\",\n}\n\n/**\n * Text vertical overflow type (ST_TextVertOverflowType).\n */\nexport const TextVertOverflowType = {\n OVERFLOW: \"overflow\",\n ELLIPSIS: \"ellipsis\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text horizontal overflow type (ST_TextHorzOverflowType).\n */\nexport const TextHorzOverflowType = {\n OVERFLOW: \"overflow\",\n CLIP: \"clip\",\n} as const;\n\n/**\n * Text vertical type (ST_TextVerticalType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TextVerticalType\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"horz\"/>\n * <xsd:enumeration value=\"vert\"/>\n * <xsd:enumeration value=\"vert270\"/>\n * <xsd:enumeration value=\"wordArtVert\"/>\n * <xsd:enumeration value=\"eaVert\"/>\n * <xsd:enumeration value=\"mongolianVert\"/>\n * <xsd:enumeration value=\"wordArtVertRtl\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const TextVerticalType = {\n HORIZONTAL: \"horz\",\n VERTICAL: \"vert\",\n VERTICAL_270: \"vert270\",\n WORD_ART_VERTICAL: \"wordArtVert\",\n EAST_ASIAN_VERTICAL: \"eaVert\",\n MONGOLIAN_VERTICAL: \"mongolianVert\",\n WORD_ART_VERTICAL_RTL: \"wordArtVertRtl\",\n} as const;\n\n/**\n * Text body wrapping type (ST_TextWrappingType).\n *\n * This is different from text wrapping around shapes (ST_WrapText).\n */\nexport const TextBodyWrappingType = {\n NONE: \"none\",\n SQUARE: \"square\",\n} as const;\n\n// ─── Sub-element Options ────────────────────────────────────────────────────\n\n/**\n * Normal autofit options (CT_TextNormalAutofit).\n *\n * Scales text and line spacing to fit the shape.\n */\nexport interface NormalAutofitOptions {\n /** Font scale percentage (e.g., 100000 = 100%) */\n fontScale?: number;\n /** Line spacing reduction percentage */\n lnSpcReduction?: number;\n}\n\n/**\n * Preset text warp options (CT_PresetTextShape).\n */\nexport interface PresetTextShapeOptions {\n /** Preset shape type (e.g., \"textArchUp\", \"textCircle\") */\n preset: string;\n /** Optional adjustment values */\n adjustments?: { name: string; formula: string }[];\n}\n\n/**\n * Flat text options (CT_FlatText).\n */\nexport interface FlatTextOptions {\n /** Z-offset in EMUs */\n z?: number;\n}\n\n// ─── Main Options ───────────────────────────────────────────────────────────\n\n/**\n * Options for text body properties (CT_TextBodyProperties).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TextBodyProperties\">\n * <xsd:sequence>\n * <xsd:element name=\"prstTxWarp\" type=\"CT_PresetTextShape\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_TextAutofit\" minOccurs=\"0\"/>\n * <xsd:element name=\"scene3d\" type=\"CT_Scene3D\" minOccurs=\"0\"/>\n * <xsd:group ref=\"EG_Text3D\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <!-- 19 attributes -->\n * </xsd:complexType>\n * ```\n */\nexport interface BodyPropertiesOptions {\n // ── Attributes ──\n\n /** Text rotation angle in 60,000ths of a degree */\n rotation?: number;\n /** Whether to use spcFirstLastPara behavior */\n spcFirstLastPara?: boolean;\n /** Vertical text overflow behavior */\n vertOverflow?: (typeof TextVertOverflowType)[keyof typeof TextVertOverflowType];\n /** Horizontal text overflow behavior */\n horzOverflow?: (typeof TextHorzOverflowType)[keyof typeof TextHorzOverflowType];\n /** Text vertical direction */\n vert?: (typeof TextVerticalType)[keyof typeof TextVerticalType];\n /** Text wrapping type */\n wrap?: (typeof TextBodyWrappingType)[keyof typeof TextBodyWrappingType];\n /** Left inset in EMUs or universal measure (e.g., \"1cm\", \"0.5in\") */\n lIns?: number | UniversalMeasure;\n /** Top inset in EMUs or universal measure */\n tIns?: number | UniversalMeasure;\n /** Right inset in EMUs or universal measure */\n rIns?: number | UniversalMeasure;\n /** Bottom inset in EMUs or universal measure */\n bIns?: number | UniversalMeasure;\n /** Number of text columns (1-16) */\n numCol?: number;\n /** Spacing between columns in EMUs or universal measure */\n spcCol?: number | UniversalMeasure;\n /** Whether columns are right-to-left */\n rtlCol?: boolean;\n /** Whether text is from WordArt */\n fromWordArt?: boolean;\n /** Text anchor position */\n anchor?: (typeof VerticalAnchor)[keyof typeof VerticalAnchor];\n /** Whether to anchor at center */\n anchorCtr?: boolean;\n /** Whether to force anti-aliasing */\n forceAA?: boolean;\n /** Whether text is upright (default false) */\n upright?: boolean;\n /** Whether to use compatible line spacing */\n compatLnSpc?: boolean;\n\n // ── Convenience aliases (backward compatible) ──\n\n /** Vertical anchor position (alias for `anchor`) */\n verticalAnchor?: VerticalAnchor;\n /** Margins shorthand */\n margins?: {\n top?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n left?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n };\n\n // ── Child elements ──\n\n /** Preset text warp shape */\n prstTxWarp?: PresetTextShapeOptions;\n /** Disable autofit (EG_TextAutofit choice) */\n noAutoFit?: boolean;\n /** Normal autofit (EG_TextAutofit choice) */\n normAutofit?: NormalAutofitOptions;\n /** Shape autofit (EG_TextAutofit choice) */\n spAutoFit?: boolean;\n /** 3D scene */\n scene3d?: Scene3DOptions;\n /** 3D shape properties (EG_Text3D choice) */\n sp3d?: Shape3DOptions;\n /** Flat text (EG_Text3D choice) */\n flatTx?: FlatTextOptions;\n}\n\n// ─── Internal Helpers ───────────────────────────────────────────────────────\n\nconst filterAttrs = (\n options: Record<string, unknown>,\n): Record<string, string | number | boolean> | undefined => {\n const attrs: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(options)) {\n if (value !== undefined) {\n attrs[key] = value as string | number | boolean;\n }\n }\n return Object.keys(attrs).length > 0 ? attrs : undefined;\n};\n\n// ─── Preset Text Warp ───────────────────────────────────────────────────────\n\nconst createPresetTextShape = (options: PresetTextShapeOptions): string => {\n const adjChildren: string[] = [];\n if (options.adjustments) {\n for (const adj of options.adjustments) {\n adjChildren.push(`<a:gd name=\"${adj.name}\" fmla=\"${adj.formula}\"/>`);\n }\n }\n\n return element(\n \"a:prstTxWarp\",\n { prst: options.preset },\n adjChildren.length > 0 ? [element(\"a:avLst\", undefined, adjChildren)] : undefined,\n );\n};\n\n// ─── Main Factory ───────────────────────────────────────────────────────────\n\n/**\n * Creates a text body properties element (wps:bodyPr).\n *\n * Supports all 19 CT_TextBodyProperties attributes and all child elements\n * including preset text warp, autofit variants, 3D scene, and text 3D.\n *\n * @example\n * ```typescript\n * // Simple margins and anchor\n * createBodyProperties({\n * margins: { top: 100, bottom: 100, left: 200, right: 200 },\n * verticalAnchor: VerticalAnchor.CENTER,\n * });\n *\n * // Full options with vertical text and autofit\n * createBodyProperties({\n * vert: TextVerticalType.VERTICAL,\n * wrap: TextBodyWrappingType.NONE,\n * normAutofit: { fontScale: 80000 },\n * numCol: 2,\n * anchor: VerticalAnchor.TOP,\n * });\n * ```\n */\nexport const createBodyProperties = (options: BodyPropertiesOptions = {}): string => {\n // Resolve anchor (direct `anchor` takes precedence over `verticalAnchor`)\n const anchor = options.anchor ?? options.verticalAnchor;\n\n // Resolve margins\n const lIns = options.lIns ?? options.margins?.left;\n const tIns = options.tIns ?? options.margins?.top;\n const rIns = options.rIns ?? options.margins?.right;\n const bIns = options.bIns ?? options.margins?.bottom;\n\n const attrs = filterAttrs({\n rot: options.rotation,\n spcFirstLastPara: options.spcFirstLastPara,\n vertOverflow: options.vertOverflow,\n horzOverflow: options.horzOverflow,\n vert: options.vert,\n wrap: options.wrap,\n lIns: lIns !== undefined ? convertToEmu(lIns) : undefined,\n tIns: tIns !== undefined ? convertToEmu(tIns) : undefined,\n rIns: rIns !== undefined ? convertToEmu(rIns) : undefined,\n bIns: bIns !== undefined ? convertToEmu(bIns) : undefined,\n numCol: options.numCol,\n spcCol: options.spcCol !== undefined ? convertToEmu(options.spcCol) : undefined,\n rtlCol: options.rtlCol,\n fromWordArt: options.fromWordArt,\n anchor,\n anchorCtr: options.anchorCtr,\n forceAA: options.forceAA,\n upright: options.upright,\n compatLnSpc: options.compatLnSpc,\n });\n\n // Build children in XSD sequence order\n const children: string[] = [];\n\n // a:prstTxWarp\n if (options.prstTxWarp) {\n children.push(createPresetTextShape(options.prstTxWarp));\n }\n\n // EG_TextAutofit (mutually exclusive)\n if (options.noAutoFit) {\n children.push(`<a:noAutofit/>`);\n } else if (options.normAutofit) {\n const normAttrs = filterAttrs({\n fontScale: options.normAutofit.fontScale,\n lnSpcReduction: options.normAutofit.lnSpcReduction,\n });\n children.push(element(\"a:normAutofit\", normAttrs));\n } else if (options.spAutoFit) {\n children.push(`<a:spAutoFit/>`);\n }\n\n // a:scene3d\n if (options.scene3d) {\n children.push(createScene3D(options.scene3d));\n }\n\n // EG_Text3D (mutually exclusive)\n if (options.sp3d) {\n children.push(createShape3D(options.sp3d));\n } else if (options.flatTx) {\n const flatAttrs = filterAttrs({ z: options.flatTx.z });\n children.push(element(\"a:flatTx\", flatAttrs));\n }\n\n return element(\"wps:bodyPr\", attrs, children.length > 0 ? children : undefined);\n};\n\n// ─── Parse ──────────────────────────────────────────────────────────────────\n\n/**\n * Parse a `wps:bodyPr` element into {@link BodyPropertiesOptions}.\n *\n * Reads the CT_TextBodyProperties attributes and the EG_TextAutofit child\n * (noAutofit/normAutofit/spAutoFit). prstTxWarp/scene3d/text-3D are not yet\n * parsed (later phase).\n */\nexport const parseBodyProperties = (el: Element, ctx: ReadContext): BodyPropertiesOptions => {\n const result: BodyPropertiesOptions = {};\n\n const rotation = attrNum(el, \"rot\");\n if (rotation !== undefined) result.rotation = rotation;\n const spcFirstLastPara = attrBool(el, \"spcFirstLastPara\");\n if (spcFirstLastPara !== undefined) result.spcFirstLastPara = spcFirstLastPara;\n const vertOverflow = attr(el, \"vertOverflow\");\n if (vertOverflow !== undefined)\n result.vertOverflow = vertOverflow as BodyPropertiesOptions[\"vertOverflow\"];\n const horzOverflow = attr(el, \"horzOverflow\");\n if (horzOverflow !== undefined)\n result.horzOverflow = horzOverflow as BodyPropertiesOptions[\"horzOverflow\"];\n const vert = attr(el, \"vert\");\n if (vert !== undefined) result.vert = vert as BodyPropertiesOptions[\"vert\"];\n const wrap = attr(el, \"wrap\");\n if (wrap !== undefined) result.wrap = wrap as BodyPropertiesOptions[\"wrap\"];\n const lIns = attrMeasure(el, \"lIns\");\n if (lIns !== undefined) result.lIns = lIns as number | UniversalMeasure;\n const tIns = attrMeasure(el, \"tIns\");\n if (tIns !== undefined) result.tIns = tIns as number | UniversalMeasure;\n const rIns = attrMeasure(el, \"rIns\");\n if (rIns !== undefined) result.rIns = rIns as number | UniversalMeasure;\n const bIns = attrMeasure(el, \"bIns\");\n if (bIns !== undefined) result.bIns = bIns as number | UniversalMeasure;\n const numCol = attrNum(el, \"numCol\");\n if (numCol !== undefined) result.numCol = numCol;\n const spcCol = attrNum(el, \"spcCol\");\n if (spcCol !== undefined) result.spcCol = spcCol;\n const rtlCol = attrBool(el, \"rtlCol\");\n if (rtlCol !== undefined) result.rtlCol = rtlCol;\n const fromWordArt = attrBool(el, \"fromWordArt\");\n if (fromWordArt !== undefined) result.fromWordArt = fromWordArt;\n const anchor = attr(el, \"anchor\");\n if (anchor !== undefined) result.anchor = anchor as BodyPropertiesOptions[\"anchor\"];\n const anchorCtr = attrBool(el, \"anchorCtr\");\n if (anchorCtr !== undefined) result.anchorCtr = anchorCtr;\n const forceAA = attrBool(el, \"forceAA\");\n if (forceAA !== undefined) result.forceAA = forceAA;\n const upright = attrBool(el, \"upright\");\n if (upright !== undefined) result.upright = upright;\n const compatLnSpc = attrBool(el, \"compatLnSpc\");\n if (compatLnSpc !== undefined) result.compatLnSpc = compatLnSpc;\n\n // EG_TextAutofit (mutually exclusive)\n if (findChild(el, \"a:noAutofit\")) {\n result.noAutoFit = true;\n } else {\n const norm = findChild(el, \"a:normAutofit\");\n if (norm) {\n const normOpts: NormalAutofitOptions = {};\n const fontScale = attrNum(norm, \"fontScale\");\n if (fontScale !== undefined) normOpts.fontScale = fontScale;\n const lnSpcReduction = attrNum(norm, \"lnSpcReduction\");\n if (lnSpcReduction !== undefined) normOpts.lnSpcReduction = lnSpcReduction;\n result.normAutofit = normOpts;\n } else if (findChild(el, \"a:spAutoFit\")) {\n result.spAutoFit = true;\n }\n }\n\n // a:prstTxWarp (CT_PresetTextShape)\n const prstTxWarp = findChild(el, \"a:prstTxWarp\");\n if (prstTxWarp) {\n const preset = attr(prstTxWarp, \"prst\") ?? \"\";\n const avLst = findChild(prstTxWarp, \"a:avLst\");\n const adjustments: { name: string; formula: string }[] = [];\n for (const gd of avLst?.elements ?? []) {\n if (gd.type === \"element\" && gd.name === \"a:gd\") {\n adjustments.push({ name: attr(gd, \"name\") ?? \"\", formula: attr(gd, \"fmla\") ?? \"\" });\n }\n }\n result.prstTxWarp = { preset, ...(adjustments.length > 0 ? { adjustments } : {}) };\n }\n\n // a:scene3d\n const scene3d = findChild(el, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n\n // EG_Text3D (mutually exclusive: sp3d | flatTx)\n const sp3d = findChild(el, \"a:sp3d\");\n if (sp3d) {\n result.sp3d = shape3DDesc.parse(sp3d, ctx);\n } else {\n const flatTx = findChild(el, \"a:flatTx\");\n if (flatTx) {\n const z = attrNum(flatTx, \"z\");\n result.flatTx = z !== undefined ? { z } : {};\n }\n }\n\n return result as BodyPropertiesOptions;\n};\n","/**\n * Form field module for WordprocessingML documents.\n *\n * Form fields allow creating interactive controls (checkboxes, dropdown lists,\n * text inputs) within a document. Each form field is wrapped in a field code\n * region delimited by fldChar elements (begin/separate/end), with ffData\n * attached to the begin fldChar.\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_FFData, CT_FFCheckBox, CT_FFDDList, CT_FFTextInput\n *\n * @module\n */\nimport {\n attr,\n attrBool,\n attrNum,\n children as xmlChildren,\n element,\n findChild,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Text input field type (ST_FFTextType).\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_FFTextType\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"regular\"/>\n * <xsd:enumeration value=\"number\"/>\n * <xsd:enumeration value=\"date\"/>\n * <xsd:enumeration value=\"currentTime\"/>\n * <xsd:enumeration value=\"currentDate\"/>\n * <xsd:enumeration value=\"calculated\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n */\nexport const FormFieldTextType = {\n /** Regular text input */\n REGULAR: \"regular\",\n /** Numeric input */\n NUMBER: \"number\",\n /** Date input */\n DATE: \"date\",\n /** Current time */\n CURRENT_TIME: \"currentTime\",\n /** Current date */\n CURRENT_DATE: \"currentDate\",\n /** Calculated value */\n CALCULATED: \"calculated\",\n} as const;\n\n/**\n * Options for a checkbox form field.\n */\nexport interface CheckBoxOptions {\n /**\n * Checkbox size in half-points.\n *\n * Mutually exclusive with `sizeAuto`.\n */\n size?: number;\n /**\n * Whether to auto-size the checkbox to match surrounding text.\n *\n * Mutually exclusive with `size`.\n */\n sizeAuto?: boolean;\n /** Default checked state */\n default?: boolean;\n /** Current checked state */\n checked?: boolean;\n}\n\n/**\n * Options for a dropdown list form field.\n */\nexport interface DropDownListOptions {\n /** Items in the dropdown list */\n entries: string[];\n /** Index of the currently selected entry */\n result?: number;\n /** Index of the default entry */\n default?: number;\n}\n\n/**\n * Options for a text input form field.\n */\nexport interface TextInputOptions {\n /** Text input type */\n type?: (typeof FormFieldTextType)[keyof typeof FormFieldTextType];\n /**\n * Default text value (placeholder / initial state, serialized as `w:default`\n * inside `w:ffData`).\n */\n default?: string;\n /**\n * Current value the user typed into the field (the result-run text between\n * the `separate` and `end` fldChars).\n *\n * Unlike {@link default} this is NOT stored in `w:ffData`; it is captured on\n * parse for round-trip fidelity. On stringify it is rendered as the field\n * result, falling back to {@link default} when unset.\n */\n value?: string;\n /** Maximum character length */\n maxLength?: number;\n /** Format string */\n format?: string;\n}\n\n/**\n * Help or status text options.\n */\nexport interface FormFieldTextOptions {\n /** Text type: \"text\" for custom text, \"autoText\" for auto text reference */\n type: \"text\" | \"autoText\";\n /** The text value */\n value: string;\n}\n\n/**\n * Common options for all form field types.\n */\nexport interface FormFieldCommonOptions {\n /** Field name (max 65 characters) */\n name?: string;\n /** Numeric label */\n label?: number;\n /** Tab order index */\n tabIndex?: number;\n /** Whether the field is enabled */\n enabled?: boolean;\n /** Recalculate fields when exiting */\n calcOnExit?: boolean;\n /** Entry macro name */\n entryMacro?: string;\n /** Exit macro name */\n exitMacro?: string;\n /** Help text shown when the user presses F1 */\n helpText?: FormFieldTextOptions;\n /** Status bar text */\n statusText?: FormFieldTextOptions;\n}\n\n/**\n * Options for a form field definition (CT_FFData).\n *\n * Exactly one of `checkBox`, `dropDownList`, or `textInput` must be specified.\n */\nexport interface FormFieldOptions extends FormFieldCommonOptions {\n /** Checkbox form field */\n checkBox?: CheckBoxOptions;\n /** Dropdown list form field */\n dropDownList?: DropDownListOptions;\n /** Text input form field */\n textInput?: TextInputOptions;\n}\n\n/** Build a w:val-style element with a single attribute. */\nconst valElement = (name: string, val: string | number): string => `<${name} w:val=\"${val}\"/>`;\n\n/**\n * Creates a help or status text element.\n */\nconst createFormFieldText = (name: string, options: FormFieldTextOptions): string =>\n `<${name} w:type=\"${options.type}\" w:val=\"${options.value}\"/>`;\n\n/**\n * Creates a checkbox form field element (w:checkBox).\n */\nconst createCheckBox = (options: CheckBoxOptions): string => {\n const children: string[] = [];\n\n if (options.size !== undefined) {\n children.push(valElement(\"w:size\", options.size));\n } else if (options.sizeAuto !== undefined) {\n children.push(`<w:sizeAuto/>`);\n }\n\n // <w:default> is the reset/initial state Word renders the box in. Word will\n // not render the box without it, so derive it from `checked` when omitted.\n const defaultVal = options.default ?? options.checked;\n if (defaultVal !== undefined) {\n children.push(defaultVal ? `<w:default/>` : `<w:default w:val=\"0\"/>`);\n }\n if (options.checked !== undefined) {\n children.push(options.checked ? `<w:checked/>` : `<w:checked w:val=\"0\"/>`);\n }\n\n return element(\"w:checkBox\", undefined, children);\n};\n\n/**\n * Creates a dropdown list form field element (w:ddList).\n */\nconst createDropDownList = (options: DropDownListOptions): string => {\n const children: string[] = [];\n\n if (options.result !== undefined) {\n children.push(valElement(\"w:result\", options.result));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n for (const entry of options.entries) {\n children.push(valElement(\"w:listEntry\", entry));\n }\n\n return element(\"w:ddList\", undefined, children);\n};\n\n/**\n * Creates a text input form field element (w:textInput).\n */\nconst createTextInput = (options: TextInputOptions): string => {\n const children: string[] = [];\n\n if (options.type !== undefined) {\n children.push(valElement(\"w:type\", options.type));\n }\n if (options.default !== undefined) {\n children.push(valElement(\"w:default\", options.default));\n }\n if (options.maxLength !== undefined) {\n children.push(valElement(\"w:maxLength\", options.maxLength));\n }\n if (options.format !== undefined) {\n children.push(valElement(\"w:format\", options.format));\n }\n\n return element(\"w:textInput\", undefined, children);\n};\n\n/**\n * Creates a form field data element (w:ffData).\n *\n * This element contains the definition for an interactive form field\n * (checkbox, dropdown list, or text input) within a document.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FFData\">\n * <xsd:choice maxOccurs=\"unbounded\">\n * <xsd:element name=\"name\" type=\"CT_FFName\"/>\n * <xsd:element name=\"label\" type=\"CT_DecimalNumber\"/>\n * <xsd:element name=\"tabIndex\" type=\"CT_UnsignedDecimalNumber\"/>\n * <xsd:element name=\"enabled\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"calcOnExit\" type=\"CT_OnOff\"/>\n * <xsd:element name=\"entryMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"exitMacro\" type=\"CT_MacroName\"/>\n * <xsd:element name=\"helpText\" type=\"CT_FFHelpText\"/>\n * <xsd:element name=\"statusText\" type=\"CT_FFStatusText\"/>\n * <xsd:choice>\n * <xsd:element name=\"checkBox\" type=\"CT_FFCheckBox\"/>\n * <xsd:element name=\"ddList\" type=\"CT_FFDDList\"/>\n * <xsd:element name=\"textInput\" type=\"CT_FFTextInput\"/>\n * </xsd:choice>\n * </xsd:choice>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Checkbox\n * createFormFieldData({\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n *\n * // Dropdown\n * createFormFieldData({\n * name: \"DropDown1\",\n * dropDownList: { entries: [\"Option A\", \"Option B\", \"Option C\"], result: 0 },\n * });\n *\n * // Text input\n * createFormFieldData({\n * name: \"Text1\",\n * textInput: { type: \"regular\", default: \"Enter text here\" },\n * });\n * ```\n */\nexport const createFormFieldData = (options: FormFieldOptions): string => {\n const children: string[] = [];\n\n if (options.name !== undefined) {\n children.push(valElement(\"w:name\", options.name));\n }\n if (options.label !== undefined) {\n children.push(valElement(\"w:label\", options.label));\n }\n if (options.tabIndex !== undefined) {\n children.push(valElement(\"w:tabIndex\", options.tabIndex));\n }\n // Word requires an explicit <w:enabled/> to render the field; default true.\n // (Previously emitted a val-less tag even for enabled:false, which is \"true\".)\n const enabled = options.enabled ?? true;\n children.push(enabled ? `<w:enabled/>` : `<w:enabled w:val=\"0\"/>`);\n // <w:calcOnExit> defaults to false (Word's standard).\n const calcOnExit = options.calcOnExit ?? false;\n children.push(calcOnExit ? `<w:calcOnExit/>` : `<w:calcOnExit w:val=\"0\"/>`);\n if (options.entryMacro !== undefined) {\n children.push(valElement(\"w:entryMacro\", options.entryMacro));\n }\n if (options.exitMacro !== undefined) {\n children.push(valElement(\"w:exitMacro\", options.exitMacro));\n }\n if (options.helpText) {\n children.push(createFormFieldText(\"w:helpText\", options.helpText));\n }\n if (options.statusText) {\n children.push(createFormFieldText(\"w:statusText\", options.statusText));\n }\n\n // Exactly one of the three mutually exclusive form field types\n if (options.checkBox) {\n children.push(createCheckBox(options.checkBox));\n } else if (options.dropDownList) {\n children.push(createDropDownList(options.dropDownList));\n } else if (options.textInput) {\n children.push(createTextInput(options.textInput));\n }\n\n return element(\"w:ffData\", undefined, children);\n};\n\n/**\n * Parse a w:ffData element back into FormFieldOptions.\n *\n * Inverse of {@link createFormFieldData}. Reads the common form-field metadata\n * (name, label, tabIndex, enabled, calcOnExit) and exactly one of\n * checkBox / dropDownList / textInput.\n */\nexport function parseFormFieldData(el: Element): FormFieldOptions {\n const opts: FormFieldOptions = {};\n\n const name = findChild(el, \"w:name\");\n if (name) opts.name = attr(name, \"w:val\");\n const label = findChild(el, \"w:label\");\n if (label) {\n const v = attrNum(label, \"w:val\");\n if (v !== undefined) opts.label = v;\n }\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const v = attrNum(tabIndex, \"w:val\");\n if (v !== undefined) opts.tabIndex = v;\n }\n const enabled = findChild(el, \"w:enabled\");\n if (enabled) opts.enabled = attrBool(enabled, \"w:val\") ?? true;\n const calcOnExit = findChild(el, \"w:calcOnExit\");\n if (calcOnExit) opts.calcOnExit = attrBool(calcOnExit, \"w:val\") ?? true;\n\n const checkBox = findChild(el, \"w:checkBox\");\n if (checkBox) {\n const cb: CheckBoxOptions = {};\n if (findChild(checkBox, \"w:sizeAuto\")) cb.sizeAuto = true;\n const size = findChild(checkBox, \"w:size\");\n if (size) {\n const v = attrNum(size, \"w:val\");\n if (v !== undefined) cb.size = v;\n }\n const def = findChild(checkBox, \"w:default\");\n if (def) cb.default = attrBool(def, \"w:val\") ?? true;\n const checked = findChild(checkBox, \"w:checked\");\n if (checked) cb.checked = attrBool(checked, \"w:val\") ?? true;\n opts.checkBox = cb as CheckBoxOptions;\n } else {\n const ddList = findChild(el, \"w:ddList\");\n if (ddList) {\n const entries: string[] = [];\n for (const li of xmlChildren(ddList, \"w:listEntry\")) {\n entries.push(attr(li, \"w:val\") ?? \"\");\n }\n const ddl: DropDownListOptions = { entries };\n const result = findChild(ddList, \"w:result\");\n if (result) {\n const v = attrNum(result, \"w:val\");\n if (v !== undefined) ddl.result = v;\n }\n const def = findChild(ddList, \"w:default\");\n if (def) {\n const v = attrNum(def, \"w:val\");\n if (v !== undefined) ddl.default = v;\n }\n opts.dropDownList = ddl as DropDownListOptions;\n } else {\n const textInput = findChild(el, \"w:textInput\");\n if (textInput) {\n const ti: TextInputOptions = {};\n const type = findChild(textInput, \"w:type\");\n if (type) ti.type = attr(type, \"w:val\") as TextInputOptions[\"type\"];\n const def = findChild(textInput, \"w:default\");\n if (def) ti.default = attr(def, \"w:val\");\n const maxLength = findChild(textInput, \"w:maxLength\");\n if (maxLength) {\n const v = attrNum(maxLength, \"w:val\");\n if (v !== undefined) ti.maxLength = v;\n }\n const format = findChild(textInput, \"w:format\");\n if (format) ti.format = attr(format, \"w:val\");\n opts.textInput = ti as TextInputOptions;\n }\n }\n }\n\n return opts as FormFieldOptions;\n}\n","/**\n * Table cell components module for WordprocessingML documents.\n *\n * This module provides types and constants for table cell properties including borders,\n * grid span (column span), vertical merge, and text direction.\n *\n * Reference: http://officeopenxml.com/WPtableCell.php\n *\n * @module\n */\nimport type { BorderOptions } from \"@shared/border\";\n\n/**\n * Options for configuring table cell borders.\n *\n * Defines border settings for individual edges of a table cell.\n */\nexport interface TableCellBordersOptions {\n /** Border for the top edge of the cell */\n top?: BorderOptions;\n /** Border for the start edge (left in LTR, right in RTL) */\n start?: BorderOptions;\n /** Border for the left edge of the cell */\n left?: BorderOptions;\n /** Border for the bottom edge of the cell */\n bottom?: BorderOptions;\n /** Border for the end edge (right in LTR, left in RTL) */\n end?: BorderOptions;\n /** Border for the right edge of the cell */\n right?: BorderOptions;\n /** Inside horizontal border (CT_TcBorders/insideH) */\n insideHorizontal?: BorderOptions;\n /** Inside vertical border (CT_TcBorders/insideV) */\n insideVertical?: BorderOptions;\n /** Diagonal border from top-left to bottom-right */\n topLeftToBottomRight?: BorderOptions;\n /** Diagonal border from top-right to bottom-left */\n topRightToBottomLeft?: BorderOptions;\n}\n\n/**\n * Vertical merge types for table cells.\n *\n * Defines the merge behavior for vertically merged cells (row span).\n */\nexport const VerticalMergeType = {\n /**\n * Cell that is merged with upper one.\n */\n CONTINUE: \"continue\",\n /**\n * Cell that is starting the vertical merge.\n */\n RESTART: \"restart\",\n} as const;\n\n/**\n * Text direction values for table cells.\n *\n * Specifies the direction in which text flows within a table cell.\n */\nexport const TextDirection = {\n /** Text flows from bottom to top, left to right */\n BOTTOM_TO_TOP_LEFT_TO_RIGHT: \"btLr\",\n /** Text flows from left to right, top to bottom (default) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Text flows from top to bottom, right to left */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Border module for WordprocessingML documents.\n *\n * Borders are used in multiple contexts (paragraphs, tables, table cells, sections)\n * and share the same CT_Border type definition. This module provides the BorderStyle\n * constants used throughout the document structure.\n *\n * Reference: http://officeopenxml.com/WPborders.php\n *\n * @see http://officeopenxml.com/WPtableBorders.php\n * @see http://officeopenxml.com/WPtableCellProperties-Borders.php\n * @see http://officeopenxml.com/WPsectionBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Border\">\n * <xsd:attribute name=\"val\" type=\"ST_Border\" use=\"required\"/>\n * <xsd:attribute name=\"color\" type=\"ST_HexColor\" use=\"optional\" default=\"auto\"/>\n * <xsd:attribute name=\"themeColor\" type=\"ST_ThemeColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeTint\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"themeShade\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"sz\" type=\"ST_EighthPointMeasure\" use=\"optional\"/>\n * <xsd:attribute name=\"space\" type=\"ST_PointMeasure\" use=\"optional\" default=\"0\"/>\n * <xsd:attribute name=\"shadow\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * <xsd:attribute name=\"frame\" type=\"s:ST_OnOff\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @module\n */\nimport type { ThemeColor } from \"@office-open/core\";\n\n/**\n * Options for configuring a border element.\n *\n * @property style - The border style (single, dashed, dotted, etc.)\n * @property color - Border color in hex format (e.g., \"FF00AA\" for purple)\n * @property size - Border thickness in eighths of a point (1/8 pt)\n * @property space - Spacing offset from the content in points\n */\nexport interface BorderOptions {\n style: (typeof BorderStyle)[keyof typeof BorderStyle];\n /** Border color, in hex (eg 'FF00AA') */\n color?: string;\n /** Theme color reference */\n themeColor?: (typeof ThemeColor)[keyof typeof ThemeColor];\n /** Theme color tint (2-char hex) */\n themeTint?: string;\n /** Theme color shade (2-char hex) */\n themeShade?: string;\n /** Border shadow */\n shadow?: boolean;\n /** Border frame */\n frame?: boolean;\n /** Size of the border in 1/8 pt */\n size?: number;\n /** Spacing offset. Values are specified in pt */\n space?: number;\n}\n\n/**\n * Table borders are defined with the <w:tblBorders> element. Child elements of this element specify the kinds of `border`:\n *\n * `bottom`, `end` (`right` in the previous version of the standard), `insideH`, `insideV`, `start` (`left` in the previous version of the standard), and `top`.\n *\n * Reference: http://officeopenxml.com/WPtableBorders.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Border\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"single\"/>\n * <xsd:enumeration value=\"dashDotStroked\"/>\n * <xsd:enumeration value=\"dashed\"/>\n * <xsd:enumeration value=\"dashSmallGap\"/>\n * <xsd:enumeration value=\"dotDash\"/>\n * <xsd:enumeration value=\"dotDotDash\"/>\n * <xsd:enumeration value=\"dotted\"/>\n * <xsd:enumeration value=\"double\"/>\n * <xsd:enumeration value=\"doubleWave\"/>\n * <xsd:enumeration value=\"inset\"/>\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"none\"/>\n * <xsd:enumeration value=\"outset\"/>\n * <xsd:enumeration value=\"thick\"/>\n * <xsd:enumeration value=\"thickThinLargeGap\"/>\n * <xsd:enumeration value=\"thickThinMediumGap\"/>\n * <xsd:enumeration value=\"thickThinSmallGap\"/>\n * <xsd:enumeration value=\"thinThickLargeGap\"/>\n * <xsd:enumeration value=\"thinThickMediumGap\"/>\n * <xsd:enumeration value=\"thinThickSmallGap\"/>\n * <xsd:enumeration value=\"thinThickThinLargeGap\"/>\n * <xsd:enumeration value=\"thinThickThinMediumGap\"/>\n * <xsd:enumeration value=\"thinThickThinSmallGap\"/>\n * <xsd:enumeration value=\"threeDEmboss\"/>\n * <xsd:enumeration value=\"threeDEngrave\"/>\n * <xsd:enumeration value=\"triple\"/>\n * <xsd:enumeration value=\"wave\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const BorderStyle = {\n /** A single line */\n SINGLE: \"single\",\n /** A line with a series of alternating thin and thick strokes */\n DASH_DOT_STROKED: \"dashDotStroked\",\n /** A dashed line */\n DASHED: \"dashed\",\n /** A dashed line with small gaps */\n DASH_SMALL_GAP: \"dashSmallGap\",\n /** A line with alternating dots and dashes */\n DOT_DASH: \"dotDash\",\n /** A line with a repeating dot - dot - dash sequence */\n DOT_DOT_DASH: \"dotDotDash\",\n /** A dotted line */\n DOTTED: \"dotted\",\n /** A double line */\n DOUBLE: \"double\",\n /** A double wavy line */\n DOUBLE_WAVE: \"doubleWave\",\n /** An inset set of lines */\n INSET: \"inset\",\n /** No border */\n NIL: \"nil\",\n /** No border */\n NONE: \"none\",\n /** An outset set of lines */\n OUTSET: \"outset\",\n /** A single line */\n THICK: \"thick\",\n /** A thick line contained within a thin line with a large-sized intermediate gap */\n THICK_THIN_LARGE_GAP: \"thickThinLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THICK_THIN_MEDIUM_GAP: \"thickThinMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THICK_THIN_SMALL_GAP: \"thickThinSmallGap\",\n /** A thin line contained within a thick line with a large-sized intermediate gap */\n THIN_THICK_LARGE_GAP: \"thinThickLargeGap\",\n /** A thick line contained within a thin line with a medium-sized intermediate gap */\n THIN_THICK_MEDIUM_GAP: \"thinThickMediumGap\",\n /** A thick line contained within a thin line with a small intermediate gap */\n THIN_THICK_SMALL_GAP: \"thinThickSmallGap\",\n /** A thin-thick-thin line with a large gap */\n THIN_THICK_THIN_LARGE_GAP: \"thinThickThinLargeGap\",\n /** A thin-thick-thin line with a medium gap */\n THIN_THICK_THIN_MEDIUM_GAP: \"thinThickThinMediumGap\",\n /** A thin-thick-thin line with a small gap */\n THIN_THICK_THIN_SMALL_GAP: \"thinThickThinSmallGap\",\n /** A three-staged gradient line, getting darker towards the paragraph */\n THREE_D_EMBOSS: \"threeDEmboss\",\n /** A three-staged gradient like, getting darker away from the paragraph */\n THREE_D_ENGRAVE: \"threeDEngrave\",\n /** A triple line */\n TRIPLE: \"triple\",\n /** A wavy line */\n WAVE: \"wave\",\n} as const;\n","/**\n * Table width module for WordprocessingML documents.\n *\n * This module provides width specifications for tables and cells.\n *\n * Reference: http://officeopenxml.com/WPtableWidth.php\n *\n * @module\n */\nimport type { Percentage, UniversalMeasure } from \"@office-open/core\";\n\n/**\n * Width type values for tables and cells.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_TblWidth\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"pct\"/>\n * <xsd:enumeration value=\"dxa\"/>\n * <xsd:enumeration value=\"auto\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const WidthType = {\n /** Auto. */\n AUTO: \"auto\",\n /** Value is in twentieths of a point */\n DXA: \"dxa\",\n /** No (empty) value. */\n NIL: \"nil\",\n /** Value is in percentage. */\n PERCENTAGE: \"pct\",\n} as const;\n\n/**\n * Properties for specifying table or cell width.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_TblWidth\">\n * <xsd:attribute name=\"w\" type=\"ST_MeasurementOrPercent\"/>\n * <xsd:attribute name=\"type\" type=\"ST_TblWidth\"/>\n * </xsd:complexType>\n * ```\n */\nexport interface TableWidthProperties {\n size: number | Percentage | UniversalMeasure;\n type?: (typeof WidthType)[keyof typeof WidthType];\n}\n\n/**\n * OOXML stores width percentages as fiftieths-of-a-percent integer\n * (`w:w=\"5000\"`, `w:type=\"pct\"` = 100%). The public API exposes them as plain\n * percentages (`size: 100` = 100%); these helpers convert at the stringify/parse\n * boundary so callers never handle the raw 5000 value. A bare number must never\n * be emitted with a \"%\" suffix — that is a different XSD branch (`s:ST_Percentage`)\n * meaning 5000%, which Word treats as `auto` on `tblW`.\n */\n\n/** Stringify: percentage (`100`, `\"50%\"`) → OOXML fiftieths integer (`5000`). */\nexport const widthPctToFiftieths = (\n size: number | Percentage | UniversalMeasure,\n): number | Percentage | UniversalMeasure => {\n if (typeof size === \"number\") return Math.round(size * 50);\n if (size.endsWith(\"%\")) return Math.round(Number(size.slice(0, -1)) * 50);\n return size;\n};\n\n/** Parse: OOXML fiftieths (`5000`) → percentage (`100`) when `type` is `\"pct\"`. */\nexport const widthFiftiethsToPct = (\n size: number | string | undefined,\n type: string | undefined,\n): number | string | undefined => (type === \"pct\" && typeof size === \"number\" ? size / 50 : size);\n","/**\n * Object element for WordprocessingML documents — w:object.\n *\n * Embeds an OLE object (e.g. an Excel sheet) in a run via a VML preview shape and\n * exactly one of objectEmbed / objectLink / control / movie. The OLE binary is\n * registered as word/embeddings/oleObjectN.bin (EmbeddingCollection); the optional\n * preview icon as word/media/imageN.<type> (Media). Relationship ids are emitted\n * as `{fileName}` placeholders and rewritten by the compiler's media bridge.\n *\n * Reference: OOXML transitional, wml.xsd, CT_Object / CT_ObjectEmbed / CT_ObjectLink\n *\n * @module\n */\nimport { toUint8Array } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, findChild, type Element } from \"@office-open/xml\";\nimport type { EmbeddingData } from \"@shared/embeddings/embeddings\";\nimport type { MediaData } from \"@shared/media/data\";\n\nimport type { BodyContext } from \"../../context\";\nimport { createImageData } from \"../paragraph/run/image-run\";\n\n// ── Options ──\n\nexport interface ObjectEmbedOptions {\n /** OLE container binary — registered as word/embeddings/oleObjectN.bin. */\n data: Uint8Array | string;\n /** OLE program id (e.g. \"Excel.Sheet.12\"). */\n progId?: string;\n /** Draw aspect — how the object displays. */\n drawAspect?: \"content\" | \"icon\";\n /** Shape id (w:objectEmbed/@shapeId). */\n shapeId?: string;\n /** Field codes (w:objectEmbed/@fieldCodes). */\n fieldCodes?: string;\n}\n\nexport interface ObjectLinkOptions extends ObjectEmbedOptions {\n /** Update mode (required for links). */\n updateMode: \"always\" | \"onCall\";\n /** Whether the field is locked. */\n lockedField?: boolean;\n}\n\nexport interface ObjectControlOptions {\n /** Control name (w:control/@name). */\n name?: string;\n /** Shape id (w:control/@shapeid). */\n shapeid?: string;\n /** Relationship id to the ActiveX part (external — not auto-registered). */\n rId: string;\n}\n\nexport interface ObjectIconImageOptions {\n /** Preview image bytes (binary or base64 data URL). */\n data: Uint8Array | string;\n /** Image type / extension (e.g. \"png\", \"emf\"). */\n type: string;\n /** Title for v:imagedata/@o:title. */\n title?: string;\n}\n\nexport interface ObjectElementOptions {\n /** Original width in twips (w:object/@w:dxaOrig). */\n dxaOrig?: number;\n /** Original height in twips (w:object/@w:dyaOrig). */\n dyaOrig?: number;\n /** VML shape id (v:shape/@id). Defaults to a generated id. */\n shapeId?: string;\n /** Display width (px or universal measure) for v:shape style + icon size. */\n width?: number | UniversalMeasure;\n /** Display height (px or universal measure). */\n height?: number | UniversalMeasure;\n /** Preview icon image (v:imagedata). */\n iconImage?: ObjectIconImageOptions;\n /** Embedded OLE object (w:objectEmbed). */\n embed?: ObjectEmbedOptions;\n /** Linked OLE object (w:objectLink). */\n link?: ObjectLinkOptions;\n /** ActiveX control reference (w:control). */\n control?: ObjectControlOptions;\n /** Movie relationship id — CT_Rel (w:movie/@r:id). External. */\n movie?: string;\n}\n\n// ── Descriptor ──\n\nlet objectShapeCounter = 1025;\n\nexport const objectDesc: CustomDescriptor<ObjectElementOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const inner: string[] = [];\n\n // VML preview shape (v:shape + optional v:imagedata)\n const shapeId = opts.shapeId ?? `_x0000_i${objectShapeCounter++}`;\n const widthVal = opts.width ?? 100;\n const heightVal = opts.height ?? 100;\n const styleWidth = typeof widthVal === \"number\" ? `${widthVal}px` : widthVal;\n const styleHeight = typeof heightVal === \"number\" ? `${heightVal}px` : heightVal;\n\n const shapeChildren: string[] = [];\n if (opts.iconImage) {\n const rawData = toUint8Array(opts.iconImage.data) as Uint8Array;\n const iconType = opts.iconImage.type;\n const { fileName: iconFileName } = ctx.file.media.addMedia(\n rawData,\n iconType,\n (fileName) =>\n ({\n type: iconType,\n ...createImageData(rawData, { width: widthVal, height: heightVal }, fileName),\n }) as MediaData,\n );\n const titleAttr = opts.iconImage.title ? ` o:title=\"${opts.iconImage.title}\"` : \"\";\n shapeChildren.push(`<v:imagedata r:id=\"{${iconFileName}}\"${titleAttr}/>`);\n }\n inner.push(\n `<v:shape id=\"${shapeId}\" type=\"#_x0000_t75\" style=\"width:${styleWidth};height:${styleHeight}\">${shapeChildren.join(\"\")}</v:shape>`,\n );\n\n // Choice: objectEmbed | objectLink | control | movie\n if (opts.embed) {\n const fileName = registerEmbedding(opts.embed, ctx);\n inner.push(`<w:objectEmbed r:id=\"{${fileName}}\"${embedAttrs(opts.embed)}/>`);\n } else if (opts.link) {\n const fileName = registerEmbedding(opts.link, ctx);\n const locked = opts.link.lockedField ? ` w:lockedField=\"true\"` : \"\";\n inner.push(\n `<w:objectLink r:id=\"{${fileName}}\"${embedAttrs(opts.link)} w:updateMode=\"${opts.link.updateMode}\"${locked}/>`,\n );\n } else if (opts.control) {\n const c = opts.control;\n const cAttrs: string[] = [` r:id=\"${c.rId}\"`];\n if (c.name) cAttrs.push(` w:name=\"${c.name}\"`);\n if (c.shapeid) cAttrs.push(` w:shapeid=\"${c.shapeid}\"`);\n inner.push(`<w:control${cAttrs.join(\"\")}/>`);\n } else if (opts.movie) {\n inner.push(`<w:movie r:id=\"${opts.movie}\"/>`);\n }\n\n // w:object root attributes\n const objAttrs: string[] = [];\n if (opts.dxaOrig !== undefined) objAttrs.push(` w:dxaOrig=\"${opts.dxaOrig}\"`);\n if (opts.dyaOrig !== undefined) objAttrs.push(` w:dyaOrig=\"${opts.dyaOrig}\"`);\n\n return `<w:object${objAttrs.join(\"\")}>${inner.join(\"\")}</w:object>`;\n },\n\n parse(el, _ctx) {\n const result: Partial<ObjectElementOptions> = {};\n\n const dxaOrig = attrNum(el, \"w:dxaOrig\");\n if (dxaOrig !== undefined) result.dxaOrig = dxaOrig;\n const dyaOrig = attrNum(el, \"w:dyaOrig\");\n if (dyaOrig !== undefined) result.dyaOrig = dyaOrig;\n\n // VML shape — best-effort structural capture (binary media is not re-registered on parse)\n const shape = findChild(el, \"v:shape\");\n if (shape) {\n const id = attr(shape, \"id\");\n if (id) result.shapeId = id;\n const style = attr(shape, \"style\");\n if (style) {\n const w = style.match(/width:([^;]+)/);\n const h = style.match(/height:([^;]+)/);\n if (w) result.width = (w[1] ?? \"\").trim() as UniversalMeasure;\n if (h) result.height = (h[1] ?? \"\").trim() as UniversalMeasure;\n }\n }\n\n // Choice elements\n const embedEl = findChild(el, \"w:objectEmbed\");\n if (embedEl) result.embed = parseEmbed(embedEl);\n\n const linkEl = findChild(el, \"w:objectLink\");\n if (linkEl) {\n const base = parseEmbed(linkEl);\n const updateMode = attr(linkEl, \"w:updateMode\");\n const lockedField = attr(linkEl, \"w:lockedField\");\n result.link = {\n ...base,\n ...(updateMode ? { updateMode: updateMode as \"always\" | \"onCall\" } : {}),\n ...(lockedField !== undefined\n ? { lockedField: lockedField === \"true\" || lockedField === \"1\" }\n : {}),\n } as ObjectLinkOptions;\n }\n\n const controlEl = findChild(el, \"w:control\");\n if (controlEl) {\n const rId = attr(controlEl, \"r:id\") ?? \"\";\n const name = attr(controlEl, \"w:name\");\n const shapeid = attr(controlEl, \"w:shapeid\");\n result.control = { rId, ...(name ? { name } : {}), ...(shapeid ? { shapeid } : {}) };\n }\n\n const movieEl = findChild(el, \"w:movie\");\n if (movieEl) {\n const rId = attr(movieEl, \"r:id\");\n if (rId) result.movie = rId;\n }\n\n return result as ObjectElementOptions;\n },\n};\n\n// ── Helpers ──\n\n/** Register an OLE embedding and return its allocated file name. */\nfunction registerEmbedding(opts: ObjectEmbedOptions, ctx: BodyContext): string {\n const fileName = ctx.file.embeddings.nextEmbeddingName();\n const data: EmbeddingData = {\n fileName,\n data: toUint8Array(opts.data) as Uint8Array,\n ...(opts.progId ? { progId: opts.progId } : {}),\n };\n ctx.file.embeddings.addEmbedding(fileName, data);\n return fileName;\n}\n\n/** Build the common objectEmbed/objectLink attribute string (excludes r:id). */\nfunction embedAttrs(opts: ObjectEmbedOptions): string {\n const attrs: string[] = [];\n if (opts.drawAspect) attrs.push(` w:drawAspect=\"${opts.drawAspect}\"`);\n if (opts.progId) attrs.push(` w:progId=\"${opts.progId}\"`);\n if (opts.shapeId) attrs.push(` w:shapeId=\"${opts.shapeId}\"`);\n if (opts.fieldCodes) attrs.push(` w:fieldCodes=\"${opts.fieldCodes}\"`);\n return attrs.join(\"\");\n}\n\n/** Parse common objectEmbed/objectLink attributes (excludes r:id — external on parse). */\nfunction parseEmbed(el: Element): ObjectEmbedOptions {\n const opts: Partial<ObjectEmbedOptions> = {};\n const drawAspect = attr(el, \"w:drawAspect\");\n if (drawAspect === \"content\" || drawAspect === \"icon\") opts.drawAspect = drawAspect;\n const progId = attr(el, \"w:progId\");\n if (progId) opts.progId = progId;\n const shapeId = attr(el, \"w:shapeId\");\n if (shapeId) opts.shapeId = shapeId;\n const fieldCodes = attr(el, \"w:fieldCodes\");\n if (fieldCodes) opts.fieldCodes = fieldCodes;\n // data is not recoverable from the relationship on parse; callers re-supply it.\n opts.data = new Uint8Array();\n return opts as ObjectEmbedOptions;\n}\n","/**\n * Shading module for WordprocessingML documents.\n *\n * Shading is used to apply background colors and patterns to paragraphs,\n * table cells, and text runs. The shading type is identical in all places.\n *\n * Reference: http://officeopenxml.com/WPshading.php\n *\n * @see http://officeopenxml.com/WPtableShading.php\n * @see http://officeopenxml.com/WPtableCellProperties-Shading.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_Shd\">\n * <xsd:attribute name=\"val\" type=\"ST_Shd\" use=\"required\"/>\n * <xsd:attribute name=\"color\" type=\"ST_HexColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeColor\" type=\"ST_ThemeColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeTint\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"themeShade\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"fill\" type=\"ST_HexColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeFill\" type=\"ST_ThemeColor\" use=\"optional\"/>\n * <xsd:attribute name=\"themeFillTint\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"themeFillShade\" type=\"ST_UcharHexNumber\" use=\"optional\"/>\n * </xsd:complexType>\n * ```\n *\n * @module\n */\nimport { ThemeColor } from \"@office-open/core\";\nimport { attr } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Properties for configuring shading.\n *\n * @property fill - Background fill color in hex format (e.g., \"FF0000\" for red)\n * @property color - Pattern color in hex format\n * @property type - Shading pattern type\n */\nexport interface ShadingProperties {\n fill?: string;\n color?: string;\n type?: (typeof ShadingType)[keyof typeof ShadingType];\n /** Theme color reference */\n themeColor?: (typeof ThemeColor)[keyof typeof ThemeColor];\n /** Theme color tint (2-char hex) */\n themeTint?: string;\n /** Theme color shade (2-char hex) */\n themeShade?: string;\n /** Theme fill color reference */\n themeFill?: (typeof ThemeColor)[keyof typeof ThemeColor];\n /** Theme fill tint (2-char hex) */\n themeFillTint?: string;\n /** Theme fill shade (2-char hex) */\n themeFillShade?: string;\n}\n\n/**\n * Shading pattern types.\n *\n * Specifies the pattern used for shading. The pattern combines the fill\n * color and the pattern color.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_Shd\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"nil\"/>\n * <xsd:enumeration value=\"clear\"/>\n * <xsd:enumeration value=\"solid\"/>\n * <xsd:enumeration value=\"horzStripe\"/>\n * <xsd:enumeration value=\"vertStripe\"/>\n * <xsd:enumeration value=\"reverseDiagStripe\"/>\n * <xsd:enumeration value=\"diagStripe\"/>\n * <xsd:enumeration value=\"horzCross\"/>\n * <xsd:enumeration value=\"diagCross\"/>\n * <!-- ... percent values ... -->\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const ShadingType = {\n /** Clear shading - no pattern, fill color only */\n CLEAR: \"clear\",\n DIAGONAL_CROSS: \"diagCross\",\n DIAGONAL_STRIPE: \"diagStripe\",\n HORIZONTAL_CROSS: \"horzCross\",\n HORIZONTAL_STRIPE: \"horzStripe\",\n NIL: \"nil\",\n PERCENT_10: \"pct10\",\n PERCENT_12: \"pct12\",\n PERCENT_15: \"pct15\",\n PERCENT_20: \"pct20\",\n PERCENT_25: \"pct25\",\n PERCENT_30: \"pct30\",\n PERCENT_35: \"pct35\",\n PERCENT_37: \"pct37\",\n PERCENT_40: \"pct40\",\n PERCENT_45: \"pct45\",\n PERCENT_5: \"pct5\",\n PERCENT_50: \"pct50\",\n PERCENT_55: \"pct55\",\n PERCENT_60: \"pct60\",\n PERCENT_62: \"pct62\",\n PERCENT_65: \"pct65\",\n PERCENT_70: \"pct70\",\n PERCENT_75: \"pct75\",\n PERCENT_80: \"pct80\",\n PERCENT_85: \"pct85\",\n PERCENT_87: \"pct87\",\n PERCENT_90: \"pct90\",\n PERCENT_95: \"pct95\",\n REVERSE_DIAGONAL_STRIPE: \"reverseDiagStripe\",\n SOLID: \"solid\",\n THIN_DIAGONAL_CROSS: \"thinDiagCross\",\n THIN_DIAGONAL_STRIPE: \"thinDiagStripe\",\n THIN_HORIZONTAL_CROSS: \"thinHorzCross\",\n THIN_REVERSE_DIAGONAL_STRIPE: \"thinReverseDiagStripe\",\n THIN_VERTICAL_STRIPE: \"thinVertStripe\",\n VERTICAL_STRIPE: \"vertStripe\",\n} as const;\n\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/**\n * Parse a w:shd (CT_Shd) element into ShadingProperties.\n *\n * Reads every CT_Shd attribute (fill/color/val plus the theme* family), so the\n * result round-trips losslessly — paragraph, table-cell, and run shading all\n * share this single reader. Returns undefined when the element carries no data.\n */\nexport function parseShading(shd: Element): ShadingProperties | undefined {\n const shading: ShadingProperties = {};\n const fill = attr(shd, \"w:fill\");\n if (fill) shading.fill = fill;\n const color = attr(shd, \"w:color\");\n if (color) shading.color = color;\n const val = attr(shd, \"w:val\");\n if (val) shading.type = val as ShadingProperties[\"type\"];\n const themeColor = attr(shd, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n shading.themeColor = themeColor as ShadingProperties[\"themeColor\"];\n }\n const themeTint = attr(shd, \"w:themeTint\");\n if (themeTint) shading.themeTint = themeTint;\n const themeShade = attr(shd, \"w:themeShade\");\n if (themeShade) shading.themeShade = themeShade;\n const themeFill = attr(shd, \"w:themeFill\");\n if (themeFill && THEME_COLORS.includes(themeFill)) {\n shading.themeFill = themeFill as ShadingProperties[\"themeFill\"];\n }\n const themeFillTint = attr(shd, \"w:themeFillTint\");\n if (themeFillTint) shading.themeFillTint = themeFillTint;\n const themeFillShade = attr(shd, \"w:themeFillShade\");\n if (themeFillShade) shading.themeFillShade = themeFillShade;\n if (Object.keys(shading).length === 0) return undefined;\n return shading;\n}\n","/**\n * Element-to-XML serialization helpers shared across the parse layer.\n *\n * @module\n */\nimport { escapeXml, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Serialize an Element including its own opening/closing tag.\n *\n * `stringify` from @office-open/xml serializes only an element's children\n * (it treats its input as a document root). Raw-XML round-trip of whole\n * elements (TOC paragraphs, range markers, w14 text effects) needs the\n * element's own tag wrapped around its serialized children.\n */\nexport function stringifyElement(el: Element): string {\n if (!el.name) return \"\";\n let attrStr = \"\";\n if (el.attributes) {\n for (const key of Object.keys(el.attributes)) {\n const v = el.attributes[key];\n if (v === null || v === undefined) continue;\n attrStr += ` ${key}=\"${escapeXml(String(v))}\"`;\n }\n }\n const withClosingTag =\n (el.elements?.length ?? 0) > 0 || el.attributes?.[\"xml:space\"] === \"preserve\";\n if (!withClosingTag) return `<${el.name}${attrStr}/>`;\n return `<${el.name}${attrStr}>${stringify(el)}</${el.name}>`;\n}\n","/**\n * Run properties parser for DOCX documents.\n *\n * Parses w:rPr Element trees into RunPropertiesOptions objects.\n *\n * @module\n */\nimport {\n attr,\n attrBool,\n attrMeasure,\n attrNum,\n colorAttr,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { objectDesc } from \"@parts/object\";\nimport type { ObjectElementOptions } from \"@parts/object\";\nimport type { FootnoteEndnoteReferenceOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n BreakClear,\n BreakOptions,\n RunPropertiesOptions,\n RunOptions,\n} from \"@parts/paragraph/run\";\nimport { parseShading } from \"@shared/shading\";\n\nimport type { DocxReadContext } from \"../../../context\";\nimport { stringifyElement } from \"../../../util/stringify-element\";\nimport type { LanguageOptions } from \"./language\";\n\n/**\n * Parse a w:rPr element into RunPropertiesOptions.\n */\nexport function parseRunProperties(el: Element): RunPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n const rStyle = findChild(el, \"w:rStyle\");\n if (rStyle) opts.style = attr(rStyle, \"w:val\");\n\n const font = findChild(el, \"w:rFonts\");\n if (font) {\n const ascii = attr(font, \"w:ascii\");\n const eastAsia = attr(font, \"w:eastAsia\");\n const hAnsi = attr(font, \"w:hAnsi\");\n const cs = attr(font, \"w:cs\");\n const asciiTheme = attr(font, \"w:asciiTheme\");\n const eastAsiaTheme = attr(font, \"w:eastAsiaTheme\");\n const hAnsiTheme = attr(font, \"w:hAnsiTheme\");\n const cstheme = attr(font, \"w:cstheme\");\n const hint = attr(font, \"w:hint\");\n\n if (\n ascii &&\n !eastAsia &&\n !hAnsi &&\n !cs &&\n !asciiTheme &&\n !eastAsiaTheme &&\n !hAnsiTheme &&\n !cstheme\n ) {\n opts.font = hint ? { name: ascii, hint } : ascii;\n } else {\n const fontObj: Record<string, string | undefined> = {};\n if (ascii) fontObj.ascii = ascii;\n if (eastAsia) fontObj.eastAsia = eastAsia;\n if (hAnsi) fontObj.hAnsi = hAnsi;\n if (cs) fontObj.cs = cs;\n if (asciiTheme) fontObj.asciiTheme = asciiTheme;\n if (eastAsiaTheme) fontObj.eastAsiaTheme = eastAsiaTheme;\n if (hAnsiTheme) fontObj.hAnsiTheme = hAnsiTheme;\n if (cstheme) fontObj.cstheme = cstheme;\n if (hint) fontObj.hint = hint;\n opts.font = fontObj;\n }\n }\n\n const bold = findChild(el, \"w:b\");\n if (bold) opts.bold = attrBool(bold, \"w:val\") ?? true;\n\n const boldCs = findChild(el, \"w:bCs\");\n if (boldCs) opts.boldComplexScript = attrBool(boldCs, \"w:val\") ?? true;\n\n const italic = findChild(el, \"w:i\");\n if (italic) opts.italic = attrBool(italic, \"w:val\") ?? true;\n\n const italicCs = findChild(el, \"w:iCs\");\n if (italicCs) opts.italicComplexScript = attrBool(italicCs, \"w:val\") ?? true;\n\n const underline = findChild(el, \"w:u\");\n if (underline) {\n const ul: Record<string, string | undefined> = {};\n const uType = attr(underline, \"w:val\");\n if (uType) ul.type = uType;\n const uColor = colorAttr(underline, \"w:color\");\n if (uColor) ul.color = uColor;\n opts.underline = ul;\n }\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:strike\", \"strike\"],\n [\"w:dstrike\", \"doubleStrike\"],\n [\"w:outline\", \"outline\"],\n [\"w:shadow\", \"shadow\"],\n [\"w:emboss\", \"emboss\"],\n [\"w:imprint\", \"imprint\"],\n [\"w:vanish\", \"vanish\"],\n [\"w:webHidden\", \"webHidden\"],\n [\"w:noProof\", \"noProof\"],\n [\"w:snapToGrid\", \"snapToGrid\"],\n [\"w:smallCaps\", \"smallCaps\"],\n [\"w:caps\", \"allCaps\"],\n [\"w:rtl\", \"rightToLeft\"],\n [\"w:cs\", \"complexScript\"],\n [\"w:specVanish\", \"specVanish\"],\n [\"w:oMath\", \"math\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n const color = findChild(el, \"w:color\");\n if (color) {\n const c = colorAttr(color, \"w:val\");\n const themeColor = attr(color, \"w:themeColor\");\n const themeTint = attr(color, \"w:themeTint\");\n const themeShade = attr(color, \"w:themeShade\");\n if (themeColor || themeTint || themeShade) {\n const colorObj: Record<string, string | undefined> = {};\n if (c) colorObj.val = c;\n if (themeColor) colorObj.themeColor = themeColor;\n if (themeTint) colorObj.themeTint = themeTint;\n if (themeShade) colorObj.themeShade = themeShade;\n opts.color = colorObj;\n } else if (c) {\n opts.color = c;\n }\n }\n\n const sz = findChild(el, \"w:sz\");\n if (sz) {\n const halfPts = attrNum(sz, \"w:val\");\n if (halfPts !== undefined) opts.size = halfPts / 2;\n }\n\n const szCs = findChild(el, \"w:szCs\");\n if (szCs) {\n const halfPts = attrNum(szCs, \"w:val\");\n if (halfPts !== undefined) opts.sizeComplexScript = halfPts / 2;\n }\n\n const highlight = findChild(el, \"w:highlight\");\n if (highlight) {\n const val = attr(highlight, \"w:val\");\n if (val) opts.highlight = val;\n }\n\n const highlightCs = findChild(el, \"w:highlightCs\");\n if (highlightCs) {\n const val = attr(highlightCs, \"w:val\");\n if (val) opts.highlightComplexScript = val;\n }\n\n const vertAlign = findChild(el, \"w:vertAlign\");\n if (vertAlign) {\n const val = attr(vertAlign, \"w:val\");\n if (val === \"subscript\") opts.subScript = true;\n else if (val === \"superscript\") opts.superScript = true;\n }\n\n const effect = findChild(el, \"w:effect\");\n if (effect) {\n const val = attr(effect, \"w:val\");\n if (val) opts.effect = val;\n }\n\n const emphasisMark = findChild(el, \"w:em\");\n if (emphasisMark) {\n const val = attr(emphasisMark, \"w:val\");\n if (val) opts.emphasisMark = { type: val };\n }\n\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const val = attrMeasure(spacing, \"w:val\");\n if (val !== undefined) opts.characterSpacing = val;\n }\n\n const scale = findChild(el, \"w:w\");\n if (scale) {\n const val = attrNum(scale, \"w:val\");\n if (val !== undefined) opts.scale = val;\n }\n\n const kern = findChild(el, \"w:kern\");\n if (kern) {\n // w:kern is ST_HpsMeasure (half-points | UniversalMeasure); use attrMeasure\n // to round-trip UniversalMeasure tokens symmetrically with hpsMeasureValue.\n const val = attrMeasure(kern, \"w:val\");\n if (val !== undefined) opts.kern = val;\n }\n\n const position = findChild(el, \"w:position\");\n if (position) {\n const val = attr(position, \"w:val\");\n if (val !== undefined) opts.position = val;\n }\n\n const fitText = findChild(el, \"w:fitText\");\n if (fitText) {\n const val = attrNum(fitText, \"w:val\");\n if (val !== undefined) opts.fitText = val;\n }\n\n const lang = findChild(el, \"w:lang\");\n if (lang) {\n const langObj: LanguageOptions = {};\n const val = attr(lang, \"w:val\");\n if (val) langObj.value = val;\n const eastAsia = attr(lang, \"w:eastAsia\");\n if (eastAsia) langObj.eastAsia = eastAsia;\n const bidi = attr(lang, \"w:bidi\");\n if (bidi) langObj.bidirectional = bidi;\n if (Object.keys(langObj).length > 0) opts.language = langObj;\n }\n\n // Border (w:bdr)\n const bdr = findChild(el, \"w:bdr\");\n if (bdr) {\n opts.border = parseBorder(bdr);\n }\n\n // Shading (w:shd)\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n opts.shading = parseShading(shd);\n }\n\n // East Asian layout (w:eastAsianLayout)\n const eastAsianLayout = findChild(el, \"w:eastAsianLayout\");\n if (eastAsianLayout) {\n opts.eastAsianLayout = parseEastAsianLayout(eastAsianLayout);\n }\n\n // Content part (w:contentPart)\n const contentPart = findChild(el, \"w:contentPart\");\n if (contentPart) {\n const rId = attr(contentPart, \"r:id\");\n if (rId) opts.contentPartRId = rId;\n }\n\n // Revision (w:rPrChange)\n const rPrChange = findChild(el, \"w:rPrChange\");\n if (rPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(rPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(rPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(rPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerRPr = findChild(rPrChange, \"w:rPr\");\n if (innerRPr) {\n Object.assign(rev, parseRunProperties(innerRPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n // w14:* text effects (glow/shadow/reflection/props3d) occupy the EG_RPrBase\n // extension slot at the end of rPr. Low-frequency complex subtrees — kept\n // verbatim as raw XML for fidelity while the rPr backbone stays editable.\n const w14Parts: string[] = [];\n for (const child of el.elements ?? []) {\n if (child.name?.startsWith(\"w14:\")) w14Parts.push(stringifyElement(child));\n }\n if (w14Parts.length > 0) opts.w14RawXml = w14Parts.join(\"\");\n\n return opts as RunPropertiesOptions;\n}\n\n/**\n * Parse a w:bdr element into BorderOptions.\n */\nexport function parseBorder(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n const style = attr(el, \"w:val\");\n if (style) opts.style = style;\n const color = colorAttr(el, \"w:color\");\n if (color) opts.color = color;\n const size = attrNum(el, \"w:sz\");\n if (size !== undefined) opts.size = size;\n const space = attrNum(el, \"w:space\");\n if (space !== undefined) opts.space = space;\n const shadow = attrBool(el, \"w:shadow\");\n if (shadow !== undefined) opts.shadow = shadow;\n const frame = attrBool(el, \"w:frame\");\n if (frame !== undefined) opts.frame = frame;\n return opts;\n}\n\n/**\n * Parse a w:eastAsianLayout element into EastAsianLayoutOptions.\n */\nexport function parseEastAsianLayout(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) opts.id = id;\n const combine = attrBool(el, \"w:combine\");\n if (combine !== undefined) opts.combine = combine;\n const combineBrackets = attr(el, \"w:combineBrackets\");\n if (combineBrackets) opts.combineBrackets = combineBrackets;\n const vert = attrBool(el, \"w:vert\");\n if (vert !== undefined) opts.vert = vert;\n const vertCompress = attrBool(el, \"w:vertCompress\");\n if (vertCompress !== undefined) opts.vertCompress = vertCompress;\n return opts;\n}\n\n// ── Special run child constants ──────────────────────────────────────────────\n\n/** Matches w:br[@w:type=\"page\"] → PageBreak */\nexport const PARSED_PAGE_BREAK = Symbol(\"PageBreak\");\n/** Matches w:br (line break) */\nexport const PARSED_LINE_BREAK = Symbol(\"LineBreak\");\n/** Matches w:tab */\nexport const PARSED_TAB = Symbol(\"Tab\");\n/** Matches w:cr */\nexport const PARSED_CARRIAGE_RETURN = Symbol(\"CarriageReturn\");\n/** Matches w:noBreakHyphen */\nexport const PARSED_NO_BREAK_HYPHEN = Symbol(\"NoBreakHyphen\");\n/** Matches w:softHyphen */\nexport const PARSED_SOFT_HYPHEN = Symbol(\"SoftHyphen\");\n/** Matches w:footnoteRef — auto-generated by Footnote class */\nexport const PARSED_FOOTNOTE_REF = Symbol(\"FootnoteRef\");\n/** Matches w:br[@w:type=\"column\"] */\nexport const PARSED_COLUMN_BREAK = Symbol(\"ColumnBreak\");\n/** Matches w:dayShort */\nexport const PARSED_DAY_SHORT = Symbol(\"DayShort\");\n/** Matches w:monthShort */\nexport const PARSED_MONTH_SHORT = Symbol(\"MonthShort\");\n/** Matches w:yearShort */\nexport const PARSED_YEAR_SHORT = Symbol(\"YearShort\");\n/** Matches w:dayLong */\nexport const PARSED_DAY_LONG = Symbol(\"DayLong\");\n/** Matches w:monthLong */\nexport const PARSED_MONTH_LONG = Symbol(\"MonthLong\");\n/** Matches w:yearLong */\nexport const PARSED_YEAR_LONG = Symbol(\"YearLong\");\n/** Matches w:annotationRef */\nexport const PARSED_ANNOTATION_REF = Symbol(\"AnnotationRef\");\n/** Matches w:separator */\nexport const PARSED_SEPARATOR = Symbol(\"Separator\");\n/** Matches w:continuationSeparator */\nexport const PARSED_CONTINUATION_SEPARATOR = Symbol(\"ContinuationSeparator\");\n/** Matches w:pgNum */\nexport const PARSED_PAGE_NUMBER = Symbol(\"PageNumber\");\n/** Matches w:lastRenderedPageBreak */\nexport const PARSED_LAST_RENDERED_PAGE_BREAK = Symbol(\"LastRenderedPageBreak\");\n\nexport type ParsedRunChild =\n | string\n | typeof PARSED_PAGE_BREAK\n | typeof PARSED_LINE_BREAK\n | typeof PARSED_TAB\n | typeof PARSED_CARRIAGE_RETURN\n | typeof PARSED_NO_BREAK_HYPHEN\n | typeof PARSED_SOFT_HYPHEN\n | typeof PARSED_FOOTNOTE_REF\n | typeof PARSED_COLUMN_BREAK\n | typeof PARSED_DAY_SHORT\n | typeof PARSED_MONTH_SHORT\n | typeof PARSED_YEAR_SHORT\n | typeof PARSED_DAY_LONG\n | typeof PARSED_MONTH_LONG\n | typeof PARSED_YEAR_LONG\n | typeof PARSED_ANNOTATION_REF\n | typeof PARSED_SEPARATOR\n | typeof PARSED_CONTINUATION_SEPARATOR\n | typeof PARSED_PAGE_NUMBER\n | typeof PARSED_LAST_RENDERED_PAGE_BREAK\n | { commentReference: number }\n | { object: ObjectElementOptions }\n | { break: number | BreakOptions }\n | { footnoteReference: number | FootnoteEndnoteReferenceOptions }\n | { endnoteReference: number | FootnoteEndnoteReferenceOptions };\n\n/**\n * Parse a w:r element into run data.\n * Returns { properties, children } where children are parsed run content items.\n */\nexport function parseRun(\n el: Element,\n _ctx: DocxReadContext,\n): {\n properties: RunPropertiesOptions | undefined;\n children: ParsedRunChild[];\n rsid?: string;\n runPropertiesRsid?: string;\n deletionRsid?: string;\n} {\n const rPr = findChild(el, \"w:rPr\");\n const properties = rPr ? parseRunProperties(rPr) : undefined;\n const children: ParsedRunChild[] = [];\n const rsid = attr(el, \"w:rsidR\");\n const runPropertiesRsid = attr(el, \"w:rsidRPr\");\n const deletionRsid = attr(el, \"w:rsidDel\");\n\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:rPr\":\n // already handled above\n break;\n case \"w:t\": {\n const preserveSpace = attrBool(child, \"xml:space\");\n let text = textOf(child);\n if (preserveSpace && text) {\n // keep leading/trailing whitespace\n // textOf already returns the raw text\n }\n children.push(text);\n break;\n }\n case \"w:delText\": {\n // Deleted text in track changes (same format as w:t)\n const text = textOf(child);\n if (text) children.push(text);\n break;\n }\n case \"w:br\": {\n const brType = attr(child, \"w:type\");\n const brClear = attr(child, \"w:clear\");\n if (brType === \"page\") {\n children.push(PARSED_PAGE_BREAK);\n } else if (brType === \"column\") {\n children.push(PARSED_COLUMN_BREAK);\n } else if (brClear) {\n // Line break clearing floating content (w:br/@w:clear) — preserve clear\n children.push({\n break: { count: 1, clear: brClear as BreakClear },\n } as unknown as ParsedRunChild);\n } else {\n children.push(PARSED_LINE_BREAK);\n }\n break;\n }\n case \"w:tab\":\n children.push(PARSED_TAB);\n break;\n case \"w:cr\":\n children.push(PARSED_CARRIAGE_RETURN);\n break;\n case \"w:noBreakHyphen\":\n children.push(PARSED_NO_BREAK_HYPHEN);\n break;\n case \"w:softHyphen\":\n children.push(PARSED_SOFT_HYPHEN);\n break;\n case \"w:commentReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) children.push({ commentReference: id });\n break;\n }\n // Drawing/pict are handled at the paragraph level (parseSectionChild in body.ts)\n // where the drawing is extracted and replaced as a paragraph child.\n case \"w:drawing\":\n case \"w:pict\":\n break;\n case \"w:object\": {\n children.push({ object: objectDesc.parse(child, _ctx) } as unknown as ParsedRunChild);\n break;\n }\n // Symbol run — extract char and font attributes\n case \"w:sym\": {\n const charVal = attr(child, \"w:char\");\n const fontVal = attr(child, \"w:font\");\n if (charVal) {\n children.push({\n symbolRun: { char: charVal, symbolfont: fontVal ?? \"Wingdings\" },\n } as unknown as ParsedRunChild);\n }\n break;\n }\n // Footnote/endnote reference — preserve as { footnoteReference: id } / { endnoteReference: id }\n case \"w:footnoteReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const customMarkFollows = attrBool(child, \"w:customMarkFollows\") === true;\n children.push(\n customMarkFollows\n ? ({\n footnoteReference: { id, customMarkFollows: true },\n } as unknown as ParsedRunChild)\n : ({ footnoteReference: id } as unknown as ParsedRunChild),\n );\n }\n break;\n }\n case \"w:endnoteReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const customMarkFollows = attrBool(child, \"w:customMarkFollows\") === true;\n children.push(\n customMarkFollows\n ? ({ endnoteReference: { id, customMarkFollows: true } } as unknown as ParsedRunChild)\n : ({ endnoteReference: id } as unknown as ParsedRunChild),\n );\n }\n break;\n }\n // Footnote/endnote ref mark inside footnote/endnote content —\n // auto-generated by Footnote/Endnote class, skip to avoid duplication.\n case \"w:footnoteRef\":\n case \"w:endnoteRef\":\n children.push(PARSED_FOOTNOTE_REF);\n break;\n // Date/time field elements\n case \"w:dayShort\":\n children.push(PARSED_DAY_SHORT);\n break;\n case \"w:monthShort\":\n children.push(PARSED_MONTH_SHORT);\n break;\n case \"w:yearShort\":\n children.push(PARSED_YEAR_SHORT);\n break;\n case \"w:dayLong\":\n children.push(PARSED_DAY_LONG);\n break;\n case \"w:monthLong\":\n children.push(PARSED_MONTH_LONG);\n break;\n case \"w:yearLong\":\n children.push(PARSED_YEAR_LONG);\n break;\n // Other empty run elements\n case \"w:annotationRef\":\n children.push(PARSED_ANNOTATION_REF);\n break;\n case \"w:separator\":\n children.push(PARSED_SEPARATOR);\n break;\n case \"w:continuationSeparator\":\n children.push(PARSED_CONTINUATION_SEPARATOR);\n break;\n case \"w:pgNum\":\n children.push(PARSED_PAGE_NUMBER);\n break;\n case \"w:lastRenderedPageBreak\":\n children.push(PARSED_LAST_RENDERED_PAGE_BREAK);\n break;\n default:\n break;\n }\n }\n\n return { properties, children, rsid, runPropertiesRsid, deletionRsid };\n}\n\n/**\n * Convert parsed run data into an RunOptions suitable for the Document constructor.\n * Simplifies the parsed children into text + break format.\n * If the run contains only a commentReference, returns { commentReference: id } instead.\n * If the run only contains footnoteRef/endnoteRef (auto-generated), returns empty options.\n *\n * When empty run elements (tab, noBreakHyphen, date fields, etc.) are present,\n * uses children[] format to preserve them for round-trip fidelity.\n */\n\n/** Mapping from parse symbols to RunOptions child objects for empty elements. */\nconst SYMBOL_TO_CHILD = new Map<symbol, Record<string, true>>([\n [PARSED_TAB, { tab: true }],\n [PARSED_CARRIAGE_RETURN, { carriageReturn: true }],\n [PARSED_NO_BREAK_HYPHEN, { noBreakHyphen: true }],\n [PARSED_SOFT_HYPHEN, { softHyphen: true }],\n [PARSED_DAY_SHORT, { dayShort: true }],\n [PARSED_MONTH_SHORT, { monthShort: true }],\n [PARSED_YEAR_SHORT, { yearShort: true }],\n [PARSED_DAY_LONG, { dayLong: true }],\n [PARSED_MONTH_LONG, { monthLong: true }],\n [PARSED_YEAR_LONG, { yearLong: true }],\n [PARSED_ANNOTATION_REF, { annotationRef: true }],\n [PARSED_SEPARATOR, { separator: true }],\n [PARSED_CONTINUATION_SEPARATOR, { continuationSeparator: true }],\n [PARSED_PAGE_NUMBER, { pgNum: true }],\n [PARSED_LAST_RENDERED_PAGE_BREAK, { lastRenderedPageBreak: true }],\n]);\n\nexport function parsedRunToOptions(\n parsed: ReturnType<typeof parseRun>,\n): RunOptions | { commentReference: number } | null {\n // Filter out footnoteRef/endnoteRef symbols (auto-generated by Footnote/Endnote class)\n const contentChildren = parsed.children.filter((c) => c !== PARSED_FOOTNOTE_REF);\n const isOnlyFootnoteRef =\n contentChildren.length === 0 && parsed.children.some((c) => c === PARSED_FOOTNOTE_REF);\n\n // If the run only contained footnoteRef/endnoteRef (no text, no other content),\n // skip it entirely — the Footnote/Endnote class auto-adds FootnoteRefRun.\n if (isOnlyFootnoteRef) {\n return null;\n }\n\n const opts: Record<string, unknown> = { ...parsed.properties };\n if (parsed.rsid) opts.rsid = parsed.rsid;\n if (parsed.runPropertiesRsid) opts.runPropertiesRsid = parsed.runPropertiesRsid;\n if (parsed.deletionRsid) opts.deletionRsid = parsed.deletionRsid;\n\n // Check if this run is a pure reference run (commentReference, footnoteReference, endnoteReference)\n const isRefChild = (c: unknown): c is Record<string, number> =>\n typeof c === \"object\" &&\n c !== null &&\n (\"commentReference\" in c || \"footnoteReference\" in c || \"endnoteReference\" in c);\n\n const refChildren = contentChildren.filter(isRefChild);\n const nonRefChildren = contentChildren.filter((c) => !isRefChild(c));\n\n // If the run is a pure reference run (no text), return it directly.\n // Drop auto-generated rStyle (e.g., \"FootnoteReference\") since it's implicit.\n if (refChildren.length > 0 && nonRefChildren.length === 0) {\n return refChildren[0] as RunOptions | { commentReference: number };\n }\n\n // If the run only contains a symbolRun, return it directly\n const symbolIdx = nonRefChildren.findIndex(\n (c) => typeof c === \"object\" && c !== null && \"symbolRun\" in c,\n );\n if (symbolIdx >= 0 && nonRefChildren.length === 1 && !parsed.properties) {\n return nonRefChildren[symbolIdx] as unknown as RunOptions;\n }\n\n // If the run contains an OLE object (w:object), return it directly with any\n // run properties — an OLE object occupies its own run.\n const objectIdx = nonRefChildren.findIndex(\n (c) => typeof c === \"object\" && c !== null && \"object\" in c,\n );\n if (objectIdx >= 0) {\n const objectChild = nonRefChildren[objectIdx] as { object: ObjectElementOptions };\n return { ...parsed.properties, ...objectChild } as unknown as RunOptions;\n }\n\n // Collect text and breaks\n const textParts: string[] = [];\n let breakCount = 0;\n const structuredBreaks: BreakOptions[] = [];\n let hasPageBreak = false;\n let hasColumnBreak = false;\n const extraChildren: Record<string, true>[] = [];\n\n for (const child of nonRefChildren) {\n if (typeof child === \"string\") {\n textParts.push(child);\n } else if (child === PARSED_LINE_BREAK) {\n breakCount++;\n } else if (child === PARSED_PAGE_BREAK) {\n hasPageBreak = true;\n } else if (child === PARSED_COLUMN_BREAK) {\n hasColumnBreak = true;\n } else if (typeof child === \"object\" && child !== null && \"break\" in child) {\n // Line break carrying a clear attribute (w:br/@w:clear) — preserve structure\n structuredBreaks.push((child as { break: BreakOptions }).break);\n } else {\n // Empty run elements (tab, noBreakHyphen, date fields, etc.)\n const mapped = SYMBOL_TO_CHILD.get(child as symbol);\n if (mapped) extraChildren.push(mapped);\n }\n }\n\n // A single structured break (with clear) coexists cleanly with text/page/column\n // breaks via opts.break; mixed or multiple breaks fall back to children[] form.\n const hasStructuredBreaks = structuredBreaks.length > 0;\n const useChildrenForm =\n extraChildren.length > 0 ||\n (hasStructuredBreaks &&\n (breakCount > 0 || structuredBreaks.length > 1 || hasPageBreak || hasColumnBreak));\n\n if (useChildrenForm) {\n const children: (string | Record<string, unknown>)[] = [];\n for (const child of nonRefChildren) {\n if (typeof child === \"string\") {\n children.push(child);\n } else if (child === PARSED_LINE_BREAK) {\n children.push({ break: 1 });\n } else if (child === PARSED_PAGE_BREAK) {\n children.push({ pageBreak: true });\n } else if (child === PARSED_COLUMN_BREAK) {\n children.push({ columnBreak: true });\n } else if (typeof child === \"object\" && child !== null && \"break\" in child) {\n children.push({ break: (child as { break: BreakOptions }).break });\n } else {\n const mapped = SYMBOL_TO_CHILD.get(child as symbol);\n if (mapped) children.push(mapped);\n }\n }\n opts.children = children;\n } else {\n if (textParts.length > 0) {\n opts.text = textParts.join(\"\");\n }\n if (breakCount > 0) {\n opts.break = breakCount;\n } else if (hasStructuredBreaks) {\n opts.break = structuredBreaks[0];\n }\n if (hasPageBreak) {\n opts.pageBreak = true;\n }\n if (hasColumnBreak) {\n opts.columnBreak = true;\n }\n }\n\n // If the run has no content and no properties (e.g., a pure drawing run),\n // return null so it can be skipped by the caller.\n if (\n Object.keys(opts).length === 0 &&\n textParts.length === 0 &&\n breakCount === 0 &&\n !hasPageBreak &&\n !hasColumnBreak &&\n extraChildren.length === 0\n ) {\n return null;\n }\n\n return opts as RunOptions;\n}\n","/**\n * Direct XML string builders for paragraph and run properties.\n *\n * Replaces `buildParagraphProperties() + xml()` and `buildRunProperties() + xml()`\n * with direct string concatenation — no intermediate object-tree allocation,\n * no recursive xml() traversal. Follows PPTX/XLSX pattern.\n *\n * @module\n */\n\nimport {\n decimalNumber,\n eighthPointMeasureValue,\n hexColorValue,\n hpsMeasureValue,\n pointMeasureValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n uCharHexNumber,\n} from \"@office-open/core\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { CnfConditionalOptions } from \"@parts/paragraph/formatting/cnf-style\";\nimport type { IndentProperties } from \"@parts/paragraph/formatting/indent\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport type { TabStopDefinition } from \"@parts/paragraph/formatting/tab-stop\";\nimport type { FrameOptions } from \"@parts/paragraph/frame/frame-properties\";\nimport type { ParagraphPropertiesOptions } from \"@parts/paragraph/properties\";\nimport type { EastAsianLayoutOptions } from \"@parts/paragraph/run/east-asian-layout\";\nimport type { ColorOptions } from \"@parts/paragraph/run/formatting\";\nimport type { LanguageOptions } from \"@parts/paragraph/run/language\";\nimport type {\n ParagraphRunPropertiesOptions,\n RunPropertiesChangeOptions,\n RunPropertiesOptions,\n} from \"@parts/paragraph/run/properties\";\nimport type { FontProperties } from \"@parts/paragraph/run/run-fonts\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { ShadingProperties } from \"@shared/shading\";\n\n// ── Inline helpers ──\n\n/** On/off: `<w:name/>` for true, `<w:name w:val=\"0\"/>` for false */\nexport function onOff(name: string, val: boolean): string {\n return val ? `<${name}/>` : `<${name} w:val=\"0\"/>`;\n}\n\n/** Build attrs string from key-value pairs, skipping undefined */\nexport function attrParts(attrs: Record<string, string | number | boolean | undefined>): string {\n const parts: string[] = [];\n for (const [key, val] of Object.entries(attrs)) {\n if (val !== undefined) parts.push(`${key}=\"${val}\"`);\n }\n return parts.join(\" \");\n}\n\n// ── Border ──\n\nexport function borderStr(name: string, opts: BorderOptions): string {\n const a = attrParts({\n \"w:val\": opts.style,\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:sz\": opts.size !== undefined ? eighthPointMeasureValue(opts.size) : undefined,\n \"w:space\": opts.space !== undefined ? pointMeasureValue(opts.space) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:shadow\": opts.shadow !== undefined ? (opts.shadow ? 1 : 0) : undefined,\n \"w:frame\": opts.frame !== undefined ? (opts.frame ? 1 : 0) : undefined,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Shading ──\n\nexport function shadingStr(opts: ShadingProperties): string {\n const a = attrParts({\n \"w:val\": opts.type ?? \"clear\",\n \"w:color\": opts.color !== undefined ? hexColorValue(opts.color) : undefined,\n \"w:fill\": opts.fill !== undefined ? hexColorValue(opts.fill) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n \"w:themeFill\": opts.themeFill,\n \"w:themeFillTint\":\n opts.themeFillTint !== undefined ? uCharHexNumber(opts.themeFillTint) : undefined,\n \"w:themeFillShade\":\n opts.themeFillShade !== undefined ? uCharHexNumber(opts.themeFillShade) : undefined,\n });\n return `<w:shd ${a}/>`;\n}\n\n// ── Spacing ──\n\nfunction spacingStr(opts: SpacingProperties): string {\n const a = attrParts({\n \"w:after\": opts.after !== undefined ? twipsMeasureValue(opts.after) : undefined,\n \"w:afterAutospacing\":\n opts.afterAutoSpacing !== undefined ? (opts.afterAutoSpacing ? 1 : 0) : undefined,\n \"w:afterLines\": opts.afterLines !== undefined ? decimalNumber(opts.afterLines) : undefined,\n \"w:before\": opts.before !== undefined ? twipsMeasureValue(opts.before) : undefined,\n \"w:beforeAutospacing\":\n opts.beforeAutoSpacing !== undefined ? (opts.beforeAutoSpacing ? 1 : 0) : undefined,\n \"w:beforeLines\": opts.beforeLines !== undefined ? decimalNumber(opts.beforeLines) : undefined,\n \"w:line\": opts.line !== undefined ? twipsMeasureValue(opts.line) : undefined,\n \"w:lineRule\": opts.lineRule,\n });\n return `<w:spacing ${a}/>`;\n}\n\n// ── Indent ──\n\nfunction indentStr(opts: IndentProperties): string {\n const a = attrParts({\n \"w:start\": opts.start !== undefined ? signedTwipsMeasureValue(opts.start) : undefined,\n \"w:startChars\": opts.startChars !== undefined ? decimalNumber(opts.startChars) : undefined,\n \"w:end\": opts.end !== undefined ? signedTwipsMeasureValue(opts.end) : undefined,\n \"w:endChars\": opts.endChars !== undefined ? decimalNumber(opts.endChars) : undefined,\n \"w:left\": opts.left !== undefined ? signedTwipsMeasureValue(opts.left) : undefined,\n \"w:leftChars\": opts.leftChars !== undefined ? decimalNumber(opts.leftChars) : undefined,\n \"w:right\": opts.right !== undefined ? signedTwipsMeasureValue(opts.right) : undefined,\n \"w:rightChars\": opts.rightChars !== undefined ? decimalNumber(opts.rightChars) : undefined,\n \"w:hanging\": opts.hanging !== undefined ? twipsMeasureValue(opts.hanging) : undefined,\n \"w:hangingChars\":\n opts.hangingChars !== undefined ? decimalNumber(opts.hangingChars) : undefined,\n \"w:firstLine\": opts.firstLine !== undefined ? twipsMeasureValue(opts.firstLine) : undefined,\n \"w:firstLineChars\":\n opts.firstLineChars !== undefined ? decimalNumber(opts.firstLineChars) : undefined,\n });\n return `<w:ind ${a}/>`;\n}\n\n// ── Tab stops ──\n\nfunction tabStopsStr(defs: TabStopDefinition[]): string {\n const items = defs.map(({ type, position, leader }) => {\n const a = attrParts({ \"w:val\": type, \"w:pos\": position, \"w:leader\": leader });\n return `<w:tab ${a}/>`;\n });\n return `<w:tabs>${items.join(\"\")}</w:tabs>`;\n}\n\n// ── CNF style ──\n\nfunction cnfStyleStr(opts: CnfConditionalOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow ? \"1\" : \"0\",\n \"w:lastRow\": opts.lastRow ? \"1\" : \"0\",\n \"w:firstColumn\": opts.firstColumn ? \"1\" : \"0\",\n \"w:lastColumn\": opts.lastColumn ? \"1\" : \"0\",\n \"w:oddVBand\": opts.oddVBand ? \"1\" : \"0\",\n \"w:evenVBand\": opts.evenVBand ? \"1\" : \"0\",\n \"w:oddHBand\": opts.oddHBand ? \"1\" : \"0\",\n \"w:evenHBand\": opts.evenHBand ? \"1\" : \"0\",\n \"w:firstRowFirstColumn\": opts.firstRowFirstColumn ? \"1\" : \"0\",\n \"w:firstRowLastColumn\": opts.firstRowLastColumn ? \"1\" : \"0\",\n \"w:lastRowFirstColumn\": opts.lastRowFirstColumn ? \"1\" : \"0\",\n \"w:lastRowLastColumn\": opts.lastRowLastColumn ? \"1\" : \"0\",\n });\n return `<w:cnfStyle ${a}/>`;\n}\n\n// ── Frame properties ──\n\nfunction framePrStr(opts: FrameOptions): string {\n const alignment = (opts as { alignment?: { x?: string; y?: string } }).alignment;\n const position = (opts as { position?: { x?: number; y?: number } }).position;\n const a = attrParts({\n \"w:xAlign\": alignment?.x,\n \"w:yAlign\": alignment?.y,\n \"w:hAnchor\": opts.anchor?.horizontal,\n \"w:anchorLock\": opts.anchorLock,\n \"w:vAnchor\": opts.anchor?.vertical,\n \"w:dropCap\": opts.dropCap,\n \"w:h\": opts.height,\n \"w:lines\": opts.lines,\n \"w:hRule\": opts.rule,\n \"w:hSpace\": opts.space?.horizontal,\n \"w:vSpace\": opts.space?.vertical,\n \"w:w\": opts.width,\n \"w:wrap\": opts.wrap,\n \"w:x\": position?.x,\n \"w:y\": position?.y,\n });\n return `<w:framePr ${a}/>`;\n}\n\n// ── Number properties ──\n\nfunction numPrStr(\n numberId: number | string,\n indentLevel: number,\n numberingChange?: { original: string; id: string; author: string; date?: string },\n): string {\n const idVal = typeof numberId === \"string\" ? `{${numberId}}` : numberId;\n const parts = [`<w:ilvl w:val=\"${Math.min(indentLevel, 9)}\"/>`, `<w:numId w:val=\"${idVal}\"/>`];\n if (numberingChange) {\n const a = attrParts({\n \"w:original\": numberingChange.original,\n \"w:id\": numberingChange.id,\n \"w:author\": numberingChange.author,\n \"w:date\": numberingChange.date,\n });\n parts.push(`<w:numberingChange ${a}/>`);\n }\n return `<w:numPr>${parts.join(\"\")}</w:numPr>`;\n}\n\n// ── Run-level formatting helpers ──\n\nfunction colorStr(colorOrOptions: string | ColorOptions): string {\n if (typeof colorOrOptions === \"string\") {\n return `<w:color w:val=\"${hexColorValue(colorOrOptions)}\"/>`;\n }\n const opts = colorOrOptions;\n const a = attrParts({\n \"w:val\": opts.val !== undefined ? hexColorValue(opts.val) : undefined,\n \"w:themeColor\": opts.themeColor,\n \"w:themeTint\": opts.themeTint !== undefined ? uCharHexNumber(opts.themeTint) : undefined,\n \"w:themeShade\": opts.themeShade !== undefined ? uCharHexNumber(opts.themeShade) : undefined,\n });\n return `<w:color ${a}/>`;\n}\n\nfunction runFontsStr(nameOrAttrs: string | FontProperties, hint?: string): string {\n if (typeof nameOrAttrs === \"string\") {\n const a = attrParts({\n \"w:ascii\": nameOrAttrs,\n \"w:cs\": nameOrAttrs,\n \"w:eastAsia\": nameOrAttrs,\n \"w:hAnsi\": nameOrAttrs,\n \"w:hint\": hint,\n });\n return `<w:rFonts ${a}/>`;\n }\n const attrs = nameOrAttrs;\n const a = attrParts({\n \"w:ascii\": attrs.ascii,\n \"w:asciiTheme\": attrs.asciiTheme,\n \"w:cs\": attrs.cs,\n \"w:cstheme\": attrs.cstheme,\n \"w:eastAsia\": attrs.eastAsia,\n \"w:eastAsiaTheme\": attrs.eastAsiaTheme,\n \"w:hAnsi\": attrs.hAnsi,\n \"w:hAnsiTheme\": attrs.hAnsiTheme,\n \"w:hint\": attrs.hint,\n });\n return `<w:rFonts ${a}/>`;\n}\n\nfunction underlineStr(type: string | undefined, color?: string): string {\n const a = attrParts({\n \"w:val\": type ?? \"single\",\n \"w:color\": color !== undefined ? hexColorValue(color) : undefined,\n });\n return `<w:u ${a}/>`;\n}\n\nfunction eastAsianLayoutStr(opts: EastAsianLayoutOptions): string {\n const a = attrParts({\n \"w:id\": opts.id !== undefined ? decimalNumber(opts.id) : undefined,\n \"w:combine\": opts.combine !== undefined ? (opts.combine ? 1 : 0) : undefined,\n \"w:combineBrackets\": opts.combineBrackets,\n \"w:vert\": opts.vert !== undefined ? (opts.vert ? 1 : 0) : undefined,\n \"w:vertCompress\": opts.vertCompress !== undefined ? (opts.vertCompress ? 1 : 0) : undefined,\n });\n return `<w:eastAsianLayout ${a}/>`;\n}\n\nfunction languageStr(opts: LanguageOptions): string {\n const a = attrParts({\n \"w:val\": opts.value,\n \"w:eastAsia\": opts.eastAsia,\n \"w:bidi\": opts.bidirectional,\n });\n return `<w:lang ${a}/>`;\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Paragraph Properties\n// ════════════════════════════════════════════════════════════════════════════\n\nexport interface StringifyPPrResult {\n xml: string | undefined;\n numberingReferences: { reference: string; instance: number }[];\n}\n\n/**\n * Build `<w:pPr>` XML string directly from options — no intermediate object tree.\n *\n * Replaces `buildParagraphProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyParagraphProperties(\n options?: ParagraphPropertiesOptions,\n): StringifyPPrResult {\n const numberingReferences: { reference: string; instance: number }[] = [];\n\n if (!options) return { xml: undefined, numberingReferences };\n\n const parts: string[] = [];\n\n // Style / heading / bullet / numbering style references\n if (options.heading) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.heading)}\"/>`);\n }\n\n if (options.bullet) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n\n if (options.numbering) {\n if (!options.style && !options.heading) {\n if (!options.numbering.custom) {\n parts.push('<w:pStyle w:val=\"ListParagraph\"/>');\n }\n }\n }\n\n if (options.style) {\n parts.push(`<w:pStyle w:val=\"${escapeXml(options.style)}\"/>`);\n }\n\n // CT_PPrBase element order per XSD (wml.xsd) — strictly ordered sequence.\n // 1-4: keepNext, keepLines, pageBreakBefore\n if (options.keepNext !== undefined) parts.push(onOff(\"w:keepNext\", options.keepNext));\n if (options.keepLines !== undefined) parts.push(onOff(\"w:keepLines\", options.keepLines));\n if (options.pageBreakBefore !== undefined)\n parts.push(onOff(\"w:pageBreakBefore\", options.pageBreakBefore));\n\n // 5: framePr\n if (options.frame) parts.push(framePrStr(options.frame));\n\n // 6: widowControl\n if (options.widowControl !== undefined) parts.push(onOff(\"w:widowControl\", options.widowControl));\n\n // 7: numPr\n if (options.bullet) {\n parts.push(\n `<w:numPr><w:ilvl w:val=\"${Math.min(options.bullet.level, 9)}\"/><w:numId w:val=\"1\"/></w:numPr>`,\n );\n }\n\n if (options.numbering) {\n numberingReferences.push({\n instance: options.numbering.instance ?? 0,\n reference: options.numbering.reference,\n });\n\n const numId = `${options.numbering.reference}-${options.numbering.instance ?? 0}`;\n parts.push(numPrStr(numId, options.numbering.level, options.numbering.numberingChange));\n } else if (options.numbering === false) {\n parts.push(numPrStr(0, 0));\n }\n\n // 8: suppressLineNumbers\n if (options.suppressLineNumbers !== undefined)\n parts.push(onOff(\"w:suppressLineNumbers\", options.suppressLineNumbers));\n\n // 9: pBdr\n if (options.border) {\n const bParts: string[] = [];\n if (options.border.top) bParts.push(borderStr(\"w:top\", options.border.top));\n if (options.border.left) bParts.push(borderStr(\"w:left\", options.border.left));\n if (options.border.bottom) bParts.push(borderStr(\"w:bottom\", options.border.bottom));\n if (options.border.right) bParts.push(borderStr(\"w:right\", options.border.right));\n if (options.border.between) bParts.push(borderStr(\"w:between\", options.border.between));\n if (options.border.bar) bParts.push(borderStr(\"w:bar\", options.border.bar));\n if (bParts.length) parts.push(`<w:pBdr>${bParts.join(\"\")}</w:pBdr>`);\n }\n\n if (options.thematicBreak) {\n parts.push(\n `<w:pBdr>${borderStr(\"w:bottom\", { color: \"auto\", size: 6, space: 1, style: BorderStyle.SINGLE })}</w:pBdr>`,\n );\n }\n\n // 10: shd\n if (options.shading) parts.push(shadingStr(options.shading));\n\n // 11: tabs\n const tabDefs: TabStopDefinition[] = [\n ...(options.rightTabStop !== undefined\n ? [{ position: options.rightTabStop, type: \"right\" as const }]\n : []),\n ...(options.tabStops ? options.tabStops : []),\n ...(options.leftTabStop !== undefined\n ? [{ position: options.leftTabStop, type: \"left\" as const }]\n : []),\n ];\n if (tabDefs.length > 0) parts.push(tabStopsStr(tabDefs));\n\n // 12-18: suppressAutoHyphens, kinsoku, wordWrap, overflowPunct, topLinePunct, autoSpaceDE, autoSpaceDN\n if (options.suppressAutoHyphens !== undefined)\n parts.push(onOff(\"w:suppressAutoHyphens\", options.suppressAutoHyphens));\n if (options.kinsoku !== undefined) parts.push(onOff(\"w:kinsoku\", options.kinsoku));\n if (options.wordWrap !== undefined) parts.push(onOff(\"w:wordWrap\", options.wordWrap));\n if (options.overflowPunctuation !== undefined)\n parts.push(onOff(\"w:overflowPunct\", options.overflowPunctuation));\n if (options.topLinePunct !== undefined) parts.push(onOff(\"w:topLinePunct\", options.topLinePunct));\n if (options.autoSpaceDE !== undefined) parts.push(onOff(\"w:autoSpaceDE\", options.autoSpaceDE));\n if (options.autoSpaceEastAsianText !== undefined)\n parts.push(onOff(\"w:autoSpaceDN\", options.autoSpaceEastAsianText));\n\n // 19: bidi\n if (options.bidirectional !== undefined) parts.push(onOff(\"w:bidi\", options.bidirectional));\n\n // 20-21: adjustRightInd, snapToGrid\n if (options.adjustRightInd !== undefined)\n parts.push(onOff(\"w:adjustRightInd\", options.adjustRightInd));\n if (options.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", options.snapToGrid));\n\n // 22-24: spacing, ind, contextualSpacing\n if (options.spacing) parts.push(spacingStr(options.spacing));\n if (options.indent) parts.push(indentStr(options.indent));\n if (options.contextualSpacing !== undefined)\n parts.push(onOff(\"w:contextualSpacing\", options.contextualSpacing));\n\n // 25-26: mirrorIndents, suppressOverlap\n if (options.mirrorIndents !== undefined)\n parts.push(onOff(\"w:mirrorIndents\", options.mirrorIndents));\n if (options.suppressOverlap !== undefined)\n parts.push(onOff(\"w:suppressOverlap\", options.suppressOverlap));\n\n // 27: jc\n if (options.alignment) parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n\n // 28-30: textDirection, textAlignment, textboxTightWrap\n if (options.textDirection !== undefined)\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n if (options.textAlignment !== undefined)\n parts.push(`<w:textAlignment w:val=\"${options.textAlignment}\"/>`);\n if (options.textboxTightWrap !== undefined)\n parts.push(`<w:textboxTightWrap w:val=\"${options.textboxTightWrap}\"/>`);\n\n // 31-33: outlineLvl, divId, cnfStyle\n if (options.outlineLevel !== undefined)\n parts.push(`<w:outlineLvl w:val=\"${options.outlineLevel}\"/>`);\n if (options.divId !== undefined) parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n if (options.cnfStyle) parts.push(cnfStyleStr(options.cnfStyle));\n\n // Embedded run properties (w:rPr inside w:pPr)\n if (options.run) {\n const inner = stringifyRunPropertiesInner(options.run);\n if (inner !== undefined) {\n const extra: string[] = [];\n const runOpts = options.run as ParagraphRunPropertiesOptions;\n if (runOpts.insertion) {\n const { id, author, date } = runOpts.insertion;\n extra.push(`<w:ins w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n if (runOpts.deletion) {\n const { id, author, date } = runOpts.deletion;\n extra.push(`<w:del w:id=\"${id}\" w:author=\"${escapeXml(author)}\" w:date=\"${date}\"/>`);\n }\n const body = inner + extra.join(\"\");\n parts.push(`<w:rPr>${body}</w:rPr>`);\n }\n }\n\n // Revision (pPrChange)\n if (options.revision) {\n const rev = options.revision;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyParagraphProperties({ ...originalProps, includeIfEmpty: true });\n parts.push(\n `<w:pPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\">${inner.xml ?? \"<w:pPr/>\"}</w:pPrChange>`,\n );\n }\n\n const body = parts.join(\"\");\n const xml = options.includeIfEmpty || body.length > 0 ? `<w:pPr>${body}</w:pPr>` : undefined;\n return { xml, numberingReferences };\n}\n\n// ════════════════════════════════════════════════════════════════════════════\n// Run Properties\n// ════════════════════════════════════════════════════════════════════════════\n\n/**\n * Build the inner content of `<w:rPr>` as a string.\n * Returns undefined if no properties are set.\n */\nexport function stringifyRunPropertiesInner(opts?: RunPropertiesOptions): string | undefined {\n if (!opts) return undefined;\n\n const parts: string[] = [];\n\n // Style\n if (opts.style) parts.push(`<w:rStyle w:val=\"${escapeXml(opts.style)}\"/>`);\n\n // Font\n if (opts.font) {\n if (typeof opts.font === \"string\") {\n parts.push(runFontsStr(opts.font));\n } else if (\"name\" in opts.font) {\n parts.push(runFontsStr(opts.font.name, opts.font.hint));\n } else {\n parts.push(runFontsStr(opts.font));\n }\n }\n\n // Bold — w:b and w:bCs are independent toggle properties (Latin vs complex\n // script, per ISO/IEC 29500). Emit each only when explicitly set so round-trip\n // is field-faithful (source <w:b/> stays <w:b/>, not inflated to <w:b/><w:bCs/>).\n if (opts.bold !== undefined) parts.push(onOff(\"w:b\", opts.bold));\n if (opts.boldComplexScript !== undefined) parts.push(onOff(\"w:bCs\", opts.boldComplexScript));\n\n // Italic — w:i and w:iCs are independent (same rationale as bold).\n if (opts.italic !== undefined) parts.push(onOff(\"w:i\", opts.italic));\n if (opts.italicComplexScript !== undefined) parts.push(onOff(\"w:iCs\", opts.italicComplexScript));\n\n // Caps\n if (opts.smallCaps !== undefined) {\n parts.push(onOff(\"w:smallCaps\", opts.smallCaps));\n } else if (opts.allCaps !== undefined) {\n parts.push(onOff(\"w:caps\", opts.allCaps));\n }\n\n // Strike\n if (opts.strike !== undefined) parts.push(onOff(\"w:strike\", opts.strike));\n if (opts.doubleStrike !== undefined) parts.push(onOff(\"w:dstrike\", opts.doubleStrike));\n if (opts.emboss !== undefined) parts.push(onOff(\"w:emboss\", opts.emboss));\n if (opts.imprint !== undefined) parts.push(onOff(\"w:imprint\", opts.imprint));\n if (opts.outline !== undefined) parts.push(onOff(\"w:outline\", opts.outline));\n if (opts.shadow !== undefined) parts.push(onOff(\"w:shadow\", opts.shadow));\n if (opts.webHidden !== undefined) parts.push(onOff(\"w:webHidden\", opts.webHidden));\n if (opts.noProof !== undefined) parts.push(onOff(\"w:noProof\", opts.noProof));\n if (opts.snapToGrid !== undefined) parts.push(onOff(\"w:snapToGrid\", opts.snapToGrid));\n if (opts.vanish) parts.push(onOff(\"w:vanish\", opts.vanish));\n\n // Color\n if (opts.color) parts.push(colorStr(opts.color));\n\n // Character spacing\n if (opts.characterSpacing) {\n parts.push(`<w:spacing w:val=\"${signedTwipsMeasureValue(opts.characterSpacing)}\"/>`);\n }\n\n // Scale\n if (opts.scale !== undefined) parts.push(`<w:w w:val=\"${opts.scale}\"/>`);\n\n // Kern — w:val=\"0\" is meaningful (explicitly disables kerning), so emit\n // whenever the field is set rather than truthy-checking it.\n if (opts.kern !== undefined) parts.push(`<w:kern w:val=\"${hpsMeasureValue(opts.kern)}\"/>`);\n\n // Position\n if (opts.position) parts.push(`<w:position w:val=\"${opts.position}\"/>`);\n\n // Size (points → half-points). sz and szCs are independent (Latin vs complex\n // script); emit each only when set so round-trip is field-faithful.\n if (opts.size !== undefined) parts.push(`<w:sz w:val=\"${hpsMeasureValue(opts.size * 2)}\"/>`);\n if (opts.sizeComplexScript !== undefined) {\n parts.push(`<w:szCs w:val=\"${hpsMeasureValue(opts.sizeComplexScript * 2)}\"/>`);\n }\n\n // Highlight — independent Latin vs complex-script values.\n if (opts.highlight) parts.push(`<w:highlight w:val=\"${opts.highlight}\"/>`);\n if (opts.highlightComplexScript !== undefined) {\n parts.push(`<w:highlightCs w:val=\"${opts.highlightComplexScript}\"/>`);\n }\n\n // Underline\n if (opts.underline) parts.push(underlineStr(opts.underline.type, opts.underline.color));\n\n // Effect\n if (opts.effect) parts.push(`<w:effect w:val=\"${opts.effect}\"/>`);\n\n // Border\n if (opts.border) parts.push(borderStr(\"w:bdr\", opts.border));\n\n // Shading\n if (opts.shading) parts.push(shadingStr(opts.shading));\n\n // Vertical alignment\n if (opts.subScript) parts.push('<w:vertAlign w:val=\"subscript\"/>');\n if (opts.superScript) parts.push('<w:vertAlign w:val=\"superscript\"/>');\n\n // RTL\n if (opts.rightToLeft !== undefined) parts.push(onOff(\"w:rtl\", opts.rightToLeft));\n\n // Emphasis mark\n if (opts.emphasisMark) parts.push(`<w:em w:val=\"${opts.emphasisMark.type ?? \"dot\"}\"/>`);\n\n // Language\n if (opts.language) parts.push(languageStr(opts.language));\n\n // Spec vanish\n if (opts.specVanish) parts.push(\"<w:specVanish/>\");\n\n // Math\n if (opts.math) parts.push(onOff(\"w:oMath\", opts.math));\n\n // Fit text\n if (opts.fitText !== undefined) parts.push(`<w:fitText w:val=\"${opts.fitText}\"/>`);\n\n // Complex script\n if (opts.complexScript !== undefined) parts.push(onOff(\"w:cs\", opts.complexScript));\n\n // East Asian layout\n if (opts.eastAsianLayout) parts.push(eastAsianLayoutStr(opts.eastAsianLayout));\n\n // Content part\n if (opts.contentPartRId) parts.push(`<w:contentPart r:id=\"${opts.contentPartRId}\"/>`);\n\n // Revision (rPrChange)\n if (opts.revision) {\n const rev = opts.revision as RunPropertiesChangeOptions;\n const { author: _a, date: _d, id: _i, ...originalProps } = rev;\n const inner = stringifyRunPropertiesInner(originalProps as RunPropertiesOptions);\n parts.push(\n `<w:rPrChange w:author=\"${escapeXml(rev.author)}\" w:date=\"${rev.date}\" w:id=\"${rev.id}\"><w:rPr>${inner ?? \"\"}</w:rPr></w:rPrChange>`,\n );\n }\n\n // w14:* text effects — raw passthrough, emitted last (EG_RPrBase extension slot)\n if (opts.w14RawXml) parts.push(opts.w14RawXml);\n\n return parts.length > 0 ? parts.join(\"\") : undefined;\n}\n\n/**\n * Build `<w:rPr>` XML string directly from options — no intermediate object tree.\n *\n * Replaces `buildRunProperties() + xml()` with a single-pass string builder.\n */\nexport function stringifyRunProperties(opts?: RunPropertiesOptions): string | undefined {\n const inner = stringifyRunPropertiesInner(opts);\n return inner ? `<w:rPr>${inner}</w:rPr>` : undefined;\n}\n","/**\n * Body-level child descriptors for DOCX.\n *\n * Provides descriptor-based stringification for section children.\n * All types use pure string builders — zero class instantiation, zero toXml().\n *\n * @module\n */\n\nimport { toUint8Array, uniqueId } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport {\n attr,\n attrBool,\n attrNum,\n children as xmlChildren,\n escapeXml,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AltChunkOptions } from \"@parts/alt-chunk/alt-chunk\";\nimport type { CustomXmlPropertiesOptions } from \"@parts/custom-xml/custom-xml\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport { stringifyRunPropertiesInner } from \"@parts/paragraph/stringify\";\nimport type { SubDocOptions } from \"@parts/sub-doc/sub-doc\";\nimport type {\n SdtCheckboxOptions,\n SdtDateOptions,\n SdtPropertiesOptions,\n} from \"@parts/table-of-contents\";\nimport type { SectionChild } from \"@shared/section\";\n\nimport type { BodyContext, DocxReadContext } from \"../context\";\n\n// ── AltChunk (pure string — registers relationships + altChunks) ──\n\nconst ALTCHUNK_REL_TYPE =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\";\n\nfunction wrapHtmlDocument(fragment: string): string {\n if (/<(!DOCTYPE|html|HTML)/i.test(fragment)) {\n return fragment;\n }\n return `<!DOCTYPE html>\\n<html><head><meta charset=\"utf-8\"></head>\\n<body>${fragment}</body></html>`;\n}\n\nexport const altChunkDesc: CustomDescriptor<AltChunkOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const relId = uniqueId();\n const extension = opts.extension;\n const partPath = `afchunks/afchunk${relId}.${extension}`;\n const rawData = typeof opts.data === \"string\" ? toUint8Array(opts.data) : opts.data;\n const data =\n opts.contentType === \"text/html\" && typeof opts.data === \"string\"\n ? toUint8Array(wrapHtmlDocument(opts.data))\n : rawData;\n\n ctx.fileData.document.relationships.addRelationship(relId, ALTCHUNK_REL_TYPE, partPath);\n ctx.fileData.altChunks.addAltChunk(relId, {\n key: relId,\n data,\n path: partPath,\n extension,\n contentType: opts.contentType,\n });\n\n const rId = `rId${relId}`;\n if (opts.matchSource) {\n return `<w:altChunk r:id=\"${rId}\"><w:altChunkPr><w:matchSrc/></w:altChunkPr></w:altChunk>`;\n }\n return `<w:altChunk r:id=\"${rId}\"/>`;\n },\n\n parse(el, ctx) {\n const rId = attr(el, \"r:id\");\n const opts: Partial<AltChunkOptions> = {};\n\n // Check for matchSource\n const altChunkPr = findChild(el, \"w:altChunkPr\");\n if (altChunkPr && findChild(altChunkPr, \"w:matchSrc\")) {\n opts.matchSource = true;\n }\n\n // Resolve the altChunk data from relationships\n const dctx = ctx as DocxReadContext;\n if (rId) {\n const path = dctx.resolveRelationship(rId);\n if (path) {\n const data = dctx.getRaw(path);\n if (data) {\n opts.data = data;\n const ext = path.split(\".\").pop() ?? \"txt\";\n switch (ext) {\n case \"html\":\n opts.contentType = \"text/html\";\n opts.extension = \"html\";\n break;\n case \"rtf\":\n opts.contentType = \"application/rtf\";\n opts.extension = \"rtf\";\n break;\n default:\n opts.contentType = \"text/plain\";\n opts.extension = \"txt\";\n break;\n }\n }\n }\n }\n\n return opts as AltChunkOptions;\n },\n};\n\n// ── SubDoc (pure string — registers relationships + subDocs) ──\n\nconst SUBDOC_REL_TYPE =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument\";\n\nexport const subDocDesc: CustomDescriptor<SubDocOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const relId = uniqueId();\n const partPath = `subdocs/subdoc${relId}.docx`;\n const data = toUint8Array(opts.data);\n\n ctx.fileData.document.relationships.addRelationship(relId, SUBDOC_REL_TYPE, partPath);\n ctx.fileData.subDocs.addSubDoc(relId, {\n data,\n path: partPath,\n });\n\n return `<w:subDoc r:id=\"rId${relId}\"/>`;\n },\n\n parse(el, ctx) {\n const rId = attr(el, \"r:id\");\n const dctx = ctx as DocxReadContext;\n if (rId) {\n const path = dctx.resolveRelationship(rId);\n if (path) {\n const data = dctx.getRaw(path);\n if (data) {\n return { data } as SubDocOptions;\n }\n }\n }\n return { data: new Uint8Array(0) } as SubDocOptions;\n },\n};\n\n// ── SDT (pure string — inline sdtPr + stringify children) ──\n\nexport interface SdtBlockOptions {\n properties: SdtPropertiesOptions;\n children?: SectionChild[];\n /** Run properties for the SDT end mark (w:sdtEndPr). */\n endProperties?: RunPropertiesOptions;\n}\n\nfunction sdtListItemXml(\n item: { displayText?: string; value?: string },\n forceValue?: boolean,\n): string {\n const attrs: string[] = [];\n if (item.displayText !== undefined) attrs.push(`w:displayText=\"${escapeXml(item.displayText)}\"`);\n const value = item.value ?? (forceValue ? item.displayText : undefined);\n if (value !== undefined) attrs.push(`w:value=\"${escapeXml(value)}\"`);\n return `<w:listItem ${attrs.join(\" \")}/>`;\n}\n\nfunction sdtListTypeXml(\n name: string,\n options: { items?: { displayText?: string; value?: string }[]; lastValue?: string },\n): string {\n const parts: string[] = [];\n if (options.items) {\n for (const item of options.items) {\n parts.push(sdtListItemXml(item, name === \"w:dropDownList\"));\n }\n }\n const attrs: string[] = [];\n if (options.lastValue !== undefined) attrs.push(`w:lastValue=\"${escapeXml(options.lastValue)}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return parts.length ? `<${name}${attrStr}>${parts.join(\"\")}</${name}>` : `<${name}${attrStr}/>`;\n}\n\nfunction sdtDateXml(options: {\n dateFormat?: string;\n languageId?: string;\n storeMappedDataAs?: string;\n calendar?: string;\n fullDate?: string;\n}): string {\n const parts: string[] = [];\n if (options.dateFormat !== undefined)\n parts.push(`<w:dateFormat w:val=\"${escapeXml(options.dateFormat)}\"/>`);\n if (options.languageId !== undefined)\n parts.push(`<w:lid w:val=\"${escapeXml(options.languageId)}\"/>`);\n if (options.storeMappedDataAs !== undefined)\n parts.push(`<w:storeMappedDataAs w:val=\"${options.storeMappedDataAs}\"/>`);\n if (options.calendar !== undefined) parts.push(`<w:calendar w:val=\"${options.calendar}\"/>`);\n const attrs: string[] = [];\n if (options.fullDate !== undefined) attrs.push(`w:fullDate=\"${options.fullDate}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return parts.length ? `<w:date${attrStr}>${parts.join(\"\")}</w:date>` : `<w:date${attrStr}/>`;\n}\n\nfunction sdtDataBindingXml(options: {\n prefixMappings?: string;\n xpath: string;\n storeItemID: string;\n}): string {\n const attrs: string[] = [\n `w:xpath=\"${escapeXml(options.xpath)}\"`,\n `w:storeItemID=\"${escapeXml(options.storeItemID)}\"`,\n ];\n if (options.prefixMappings !== undefined)\n attrs.push(`w:prefixMappings=\"${escapeXml(options.prefixMappings)}\"`);\n return `<w:dataBinding ${attrs.join(\" \")}/>`;\n}\n\nfunction sdtDocPartXml(\n name: string,\n options: { gallery?: string; category?: string; unique?: boolean },\n): string {\n const parts: string[] = [];\n if (options.gallery !== undefined)\n parts.push(`<w:docPartGallery w:val=\"${escapeXml(options.gallery)}\"/>`);\n if (options.category !== undefined)\n parts.push(`<w:docPartCategory w:val=\"${escapeXml(options.category)}\"/>`);\n if (options.unique !== undefined)\n parts.push(options.unique ? \"<w:docPartUnique/>\" : '<w:docPartUnique w:val=\"0\"/>');\n return parts.length ? `<${name}>${parts.join(\"\")}</${name}>` : `<${name}/>`;\n}\n\nfunction onOffAttr(name: string, val: boolean): string {\n return val ? `<${name}/>` : `<${name} w:val=\"0\"/>`;\n}\n\nconst W14_NS = 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\"';\n\n/** Default symbol font for checkbox content controls (CT_SdtCheckboxSymbol). */\nconst CHECKBOX_FONT = \"MS Gothic\";\n\nconst DEFAULT_CHECKED: { val: string; font: string } = { val: \"2612\", font: CHECKBOX_FONT };\nconst DEFAULT_UNCHECKED: { val: string; font: string } = { val: \"2610\", font: CHECKBOX_FONT };\n\n/**\n * Build a w14:checkbox element (Word 2010+ content control checkbox).\n *\n * Lives in the w14 extension namespace; emitted with an inline xmlns:w14 so it\n * is valid wherever w:sdtPr appears. validate.ts tolerates the w14 namespace.\n */\nfunction sdtCheckboxXml(opts: SdtCheckboxOptions): string {\n const checked = opts.checkedState ?? DEFAULT_CHECKED;\n const unchecked = opts.uncheckedState ?? DEFAULT_UNCHECKED;\n const inner =\n (opts.checked ? \"<w14:checked/>\" : '<w14:checked w14:val=\"0\"/>') +\n `<w14:checkedState w14:val=\"${escapeXml(checked.val)}\" w14:font=\"${escapeXml(checked.font ?? CHECKBOX_FONT)}\"/>` +\n `<w14:uncheckedState w14:val=\"${escapeXml(unchecked.val)}\" w14:font=\"${escapeXml(unchecked.font ?? CHECKBOX_FONT)}\"/>`;\n return `<w14:checkbox ${W14_NS}>${inner}</w14:checkbox>`;\n}\n\n/** Build the run that renders a checkbox content control's current state symbol. */\nexport function checkboxSymbolRunInner(cb: SdtCheckboxOptions): string {\n const symbol =\n (cb.checked ?? false)\n ? (cb.checkedState ?? DEFAULT_CHECKED)\n : (cb.uncheckedState ?? DEFAULT_UNCHECKED);\n const font = escapeXml(symbol.font ?? CHECKBOX_FONT);\n const char = escapeXml(String.fromCodePoint(parseInt(symbol.val, 16)));\n return `<w:r><w:rPr><w:rFonts w:ascii=\"${font}\" w:hAnsi=\"${font}\"/></w:rPr><w:t>${char}</w:t></w:r>`;\n}\n\nexport function stringifySdtPr(opts: SdtPropertiesOptions): string {\n const parts: string[] = [];\n\n // rPr is not supported in pure JSON path — skip\n\n if (opts.alias !== undefined) parts.push(`<w:alias w:val=\"${escapeXml(opts.alias)}\"/>`);\n if (opts.tag !== undefined) parts.push(`<w:tag w:val=\"${escapeXml(opts.tag)}\"/>`);\n if (opts.id !== undefined) parts.push(`<w:id w:val=\"${opts.id}\"/>`);\n if (opts.lock !== undefined) parts.push(`<w:lock w:val=\"${opts.lock}\"/>`);\n\n // placeholder not supported in pure JSON path — skip\n\n if (opts.temporary !== undefined) parts.push(onOffAttr(\"w:temporary\", opts.temporary));\n const effectiveShowingPlcHdr = opts.showingPlaceholder ?? false;\n if (opts.showingPlaceholder !== undefined || effectiveShowingPlcHdr) {\n parts.push(onOffAttr(\"w:showingPlcHdr\", effectiveShowingPlcHdr));\n }\n if (opts.dataBinding) parts.push(sdtDataBindingXml(opts.dataBinding));\n if (opts.label !== undefined) parts.push(`<w:label w:val=\"${opts.label}\"/>`);\n if (opts.tabIndex !== undefined) parts.push(`<w:tabIndex w:val=\"${opts.tabIndex}\"/>`);\n\n // Type discriminator (xsd:choice)\n if (opts.equation) {\n parts.push(\"<w:equation/>\");\n } else if (opts.comboBox) {\n parts.push(sdtListTypeXml(\"w:comboBox\", opts.comboBox));\n } else if (opts.date) {\n parts.push(sdtDateXml(opts.date));\n } else if (opts.docPartObj) {\n parts.push(sdtDocPartXml(\"w:docPartObj\", opts.docPartObj));\n } else if (opts.docPartList) {\n parts.push(sdtDocPartXml(\"w:docPartList\", opts.docPartList));\n } else if (opts.dropDownList) {\n parts.push(sdtListTypeXml(\"w:dropDownList\", opts.dropDownList));\n } else if (opts.picture) {\n parts.push(\"<w:picture/>\");\n } else if (opts.richText) {\n parts.push(\"<w:richText/>\");\n } else if (opts.text !== undefined) {\n const multiLine = opts.text.multiLine ?? false;\n parts.push(`<w:text w:multiLine=\"${multiLine}\"/>`);\n } else if (opts.citation) {\n parts.push(\"<w:citation/>\");\n } else if (opts.group) {\n parts.push(\"<w:group/>\");\n } else if (opts.bibliography) {\n parts.push(\"<w:bibliography/>\");\n } else if (opts.checkbox) {\n parts.push(sdtCheckboxXml(opts.checkbox));\n }\n\n return parts.length ? `<w:sdtPr>${parts.join(\"\")}</w:sdtPr>` : \"<w:sdtPr/>\";\n}\n\n/**\n * Build the <w:sdt> shell shared by all four SDT levels (block/run/cell/row).\n * The caller supplies the sdtContent body; sdtPr/sdtEndPr are handled uniformly.\n */\nexport function stringifySdtShell(\n properties: SdtPropertiesOptions,\n endProperties: RunPropertiesOptions | undefined,\n contentXml: string,\n): string {\n const endPrInner = endProperties ? stringifyRunPropertiesInner(endProperties) : undefined;\n const endPr = endPrInner ? `<w:sdtEndPr>${endPrInner}</w:sdtEndPr>` : \"<w:sdtEndPr/>\";\n const content = contentXml ? `<w:sdtContent>${contentXml}</w:sdtContent>` : \"<w:sdtContent/>\";\n return `<w:sdt>${stringifySdtPr(properties)}${endPr}${content}</w:sdt>`;\n}\n\n// ── SDT parse helpers ──\n\n/** Parse w:sdtPr element into SdtPropertiesOptions. */\nfunction parseSdtPr(el: Element): SdtPropertiesOptions {\n const opts: SdtPropertiesOptions = {};\n\n const alias = findChild(el, \"w:alias\");\n if (alias) opts.alias = attr(alias, \"w:val\");\n\n const tag = findChild(el, \"w:tag\");\n if (tag) {\n const val = attr(tag, \"w:val\");\n if (val) opts.tag = val;\n }\n\n const id = findChild(el, \"w:id\");\n if (id) {\n const val = attrNum(id, \"w:val\");\n if (val !== undefined) opts.id = val;\n }\n\n const lock = findChild(el, \"w:lock\");\n if (lock) {\n const val = attr(lock, \"w:val\");\n if (val) opts.lock = val as SdtPropertiesOptions[\"lock\"];\n }\n\n const temporary = findChild(el, \"w:temporary\");\n if (temporary) opts.temporary = attrBool(temporary, \"w:val\") ?? true;\n\n const showingPlcHdr = findChild(el, \"w:showingPlcHdr\");\n if (showingPlcHdr) opts.showingPlaceholder = attrBool(showingPlcHdr, \"w:val\") ?? true;\n\n const label = findChild(el, \"w:label\");\n if (label) {\n const val = attrNum(label, \"w:val\");\n if (val !== undefined) opts.label = val;\n }\n\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const val = attrNum(tabIndex, \"w:val\");\n if (val !== undefined) opts.tabIndex = val;\n }\n\n // Data binding\n const dataBinding = findChild(el, \"w:dataBinding\");\n if (dataBinding) {\n opts.dataBinding = {\n xpath: attr(dataBinding, \"w:xpath\") ?? \"\",\n storeItemID: attr(dataBinding, \"w:storeItemID\") ?? \"\",\n prefixMappings: attr(dataBinding, \"w:prefixMappings\"),\n };\n }\n\n // Type discriminators (xsd:choice)\n if (findChild(el, \"w:equation\")) {\n opts.equation = true;\n } else if (findChild(el, \"w:comboBox\")) {\n const comboBox = findChild(el, \"w:comboBox\")!;\n const items: { displayText?: string; value?: string }[] = [];\n for (const li of xmlChildren(comboBox, \"w:listItem\")) {\n items.push({ displayText: attr(li, \"w:displayText\"), value: attr(li, \"w:value\") });\n }\n opts.comboBox = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(comboBox, \"w:lastValue\"),\n };\n } else if (findChild(el, \"w:date\")) {\n const date = findChild(el, \"w:date\")!;\n const dateOpts: SdtDateOptions = {};\n const dateFormat = findChild(date, \"w:dateFormat\");\n if (dateFormat) dateOpts.dateFormat = textOf(dateFormat);\n const lid = findChild(date, \"w:lid\");\n if (lid) dateOpts.languageId = textOf(lid);\n const storeMapped = findChild(date, \"w:storeMappedDataAs\");\n if (storeMapped)\n dateOpts.storeMappedDataAs = attr(\n storeMapped,\n \"w:val\",\n ) as SdtDateOptions[\"storeMappedDataAs\"];\n const calendar = findChild(date, \"w:calendar\");\n if (calendar) dateOpts.calendar = attr(calendar, \"w:val\");\n const fullDate = attr(date, \"w:fullDate\");\n if (fullDate) dateOpts.fullDate = fullDate;\n opts.date = dateOpts;\n } else if (findChild(el, \"w:docPartObj\")) {\n const dp = findChild(el, \"w:docPartObj\")!;\n const dpObj: NonNullable<SdtPropertiesOptions[\"docPartObj\"]> = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) dpObj.gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) dpObj.category = attr(category, \"w:val\");\n if (findChild(dp, \"w:docPartUnique\")) dpObj.unique = true;\n opts.docPartObj = dpObj;\n } else if (findChild(el, \"w:docPartList\")) {\n const dp = findChild(el, \"w:docPartList\")!;\n const dpObj: NonNullable<SdtPropertiesOptions[\"docPartList\"]> = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) dpObj.gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) dpObj.category = attr(category, \"w:val\");\n if (findChild(dp, \"w:docPartUnique\")) dpObj.unique = true;\n opts.docPartList = dpObj;\n } else if (findChild(el, \"w:dropDownList\")) {\n const ddl = findChild(el, \"w:dropDownList\")!;\n const items: { displayText?: string; value?: string }[] = [];\n for (const li of xmlChildren(ddl, \"w:listItem\")) {\n items.push({ displayText: attr(li, \"w:displayText\"), value: attr(li, \"w:value\") });\n }\n opts.dropDownList = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(ddl, \"w:lastValue\"),\n };\n } else if (findChild(el, \"w:picture\")) {\n opts.picture = true;\n } else if (findChild(el, \"w:richText\")) {\n opts.richText = true;\n } else if (findChild(el, \"w:text\")) {\n const text = findChild(el, \"w:text\")!;\n opts.text = { multiLine: attrBool(text, \"w:multiLine\") };\n } else if (findChild(el, \"w:citation\")) {\n opts.citation = true;\n } else if (findChild(el, \"w:group\")) {\n opts.group = true;\n } else if (findChild(el, \"w:bibliography\")) {\n opts.bibliography = true;\n } else if (findChild(el, \"w14:checkbox\")) {\n const cb = findChild(el, \"w14:checkbox\")!;\n const cbObj: SdtCheckboxOptions = {};\n const checked = findChild(cb, \"w14:checked\");\n if (checked) cbObj.checked = attrBool(checked, \"w14:val\") ?? true;\n const checkedState = findChild(cb, \"w14:checkedState\");\n if (checkedState)\n cbObj.checkedState = {\n val: attr(checkedState, \"w14:val\") ?? \"\",\n font: attr(checkedState, \"w14:font\"),\n };\n const uncheckedState = findChild(cb, \"w14:uncheckedState\");\n if (uncheckedState)\n cbObj.uncheckedState = {\n val: attr(uncheckedState, \"w14:val\") ?? \"\",\n font: attr(uncheckedState, \"w14:font\"),\n };\n opts.checkbox = cbObj;\n }\n\n return opts;\n}\n\n/** Parse w:customXmlPr element into CustomXmlPropertiesOptions. */\nexport function parseCustomXmlProperties(el: Element): CustomXmlPropertiesOptions {\n const opts: CustomXmlPropertiesOptions = {};\n const placeholder = findChild(el, \"w:placeholder\");\n if (placeholder) {\n const val = attr(placeholder, \"w:val\");\n if (val) opts.placeholder = val;\n }\n const attributes: { name: string; val: string; uri?: string }[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:attr\") continue;\n const name = attr(child, \"w:name\");\n const val = attr(child, \"w:val\");\n if (name && val) {\n const attrOpts: { name: string; val: string; uri?: string } = { name, val };\n const uriVal = attr(child, \"w:uri\");\n if (uriVal) attrOpts.uri = uriVal;\n attributes.push(attrOpts);\n }\n }\n if (attributes.length > 0) opts.attributes = attributes;\n return opts;\n}\n\n/** Body child element parsing callback for SDT/customXml content. */\nlet _parseBodyChild: ((el: Element, ctx: DocxReadContext) => SectionChild) | undefined;\n\n/** Register the body child parser (called from parse/body.ts to break circular dependency). */\nexport function setBodyParseChild(\n parser: (el: Element, ctx: DocxReadContext) => SectionChild,\n): void {\n _parseBodyChild = parser;\n}\n\nfunction parseBodyChildren(elements: Element[], ctx: DocxReadContext): SectionChild[] {\n if (!_parseBodyChild) return [];\n const result: SectionChild[] = [];\n for (const el of elements) {\n result.push(_parseBodyChild(el, ctx));\n }\n return result;\n}\n\nexport const sdtBlockDesc: CustomDescriptor<SdtBlockOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [\"<w:sdt>\"];\n\n // sdtPr\n parts.push(stringifySdtPr(opts.properties));\n\n // sdtEndPr — typically empty, included for round-trip fidelity with Word\n const endPrInner = opts.endProperties\n ? stringifyRunPropertiesInner(opts.endProperties)\n : undefined;\n parts.push(endPrInner ? `<w:sdtEndPr>${endPrInner}</w:sdtEndPr>` : \"<w:sdtEndPr/>\");\n\n // sdtContent — checkbox renders its current state symbol; otherwise serialize children\n if (opts.properties.checkbox) {\n parts.push(\n `<w:sdtContent><w:p>${checkboxSymbolRunInner(opts.properties.checkbox)}</w:p></w:sdtContent>`,\n );\n } else if (opts.children && opts.children.length > 0) {\n const contentParts: string[] = [];\n for (const child of opts.children) {\n contentParts.push(ctx.stringifyChild(child, ctx));\n }\n const contentBody = contentParts.join(\"\");\n parts.push(contentBody ? `<w:sdtContent>${contentBody}</w:sdtContent>` : \"<w:sdtContent/>\");\n }\n\n parts.push(\"</w:sdt>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n\n // Parse sdtPr\n const sdtPr = findChild(el, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtPr(sdtPr) : {};\n\n // Parse sdtEndPr (CT_RPr content at the end mark — run properties, no w:rPr wrapper)\n let endProperties: RunPropertiesOptions | undefined;\n const sdtEndPr = findChild(el, \"w:sdtEndPr\");\n if (sdtEndPr) {\n endProperties = parseRunProperties(sdtEndPr);\n }\n\n // Parse sdtContent children\n const sdtContent = findChild(el, \"w:sdtContent\");\n let childList: SectionChild[] | undefined;\n if (sdtContent && sdtContent.elements?.length) {\n childList = parseBodyChildren(sdtContent.elements, dctx);\n if (childList.length === 0) childList = undefined;\n }\n\n return { properties, children: childList, endProperties } as SdtBlockOptions;\n },\n};\n\n// ── Custom XML (pure string — no context side effects) ──\n\nexport interface CustomXmlBlockDescriptorOptions {\n element: string;\n uri?: string;\n customXmlPr?: CustomXmlPropertiesOptions;\n children?: SectionChild[];\n}\n\nfunction buildCustomXmlPropertiesXml(pr: CustomXmlPropertiesOptions): string {\n const parts: string[] = [\"<w:customXmlPr>\"];\n if (pr.placeholder !== undefined) {\n parts.push(`<w:placeholder w:val=\"${escapeXml(pr.placeholder)}\"/>`);\n }\n if (pr.attributes) {\n for (const attr of pr.attributes) {\n const attrParts: string[] = [\n `w:name=\"${escapeXml(attr.name)}\"`,\n `w:val=\"${escapeXml(attr.val)}\"`,\n ];\n if (attr.uri !== undefined) attrParts.push(`w:uri=\"${escapeXml(attr.uri)}\"`);\n parts.push(`<w:attr ${attrParts.join(\" \")}/>`);\n }\n }\n parts.push(\"</w:customXmlPr>\");\n return parts.join(\"\");\n}\n\n/**\n * Serialize the common customXml shell (element/uri/customXmlPr) wrapping\n * arbitrary content. Shared by all four customXml levels (block/run/row/cell).\n *\n * @deprecated Microsoft Word removed support for `w:customXml` inline markup on\n * 2010-01-10 (i4i Inc. v. Microsoft ruling); Word deletes these elements on\n * open. Prefer content controls (`w:sdt`) or a `customXml` part.\n */\nexport function stringifyCustomXmlShell(\n opts: { element: string; uri?: string; customXmlPr?: CustomXmlPropertiesOptions },\n contentXml: string,\n): string {\n const attrs: string[] = [`w:element=\"${escapeXml(opts.element)}\"`];\n if (opts.uri !== undefined) attrs.push(`w:uri=\"${escapeXml(opts.uri)}\"`);\n const prXml = opts.customXmlPr ? buildCustomXmlPropertiesXml(opts.customXmlPr) : \"\";\n return `<w:customXml ${attrs.join(\" \")}>${prXml}${contentXml}</w:customXml>`;\n}\n\nexport const customXmlBlockDesc: CustomDescriptor<CustomXmlBlockDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const contentParts: string[] = [];\n if (opts.children) {\n for (const child of opts.children) {\n contentParts.push(ctx.stringifyChild(child, ctx));\n }\n }\n return stringifyCustomXmlShell(opts, contentParts.join(\"\"));\n },\n\n parse(el, ctx) {\n const dctx = ctx as DocxReadContext;\n const opts: Partial<CustomXmlBlockDescriptorOptions> = {};\n\n const element = attr(el, \"w:element\");\n if (element) opts.element = element;\n\n const uri = attr(el, \"w:uri\");\n if (uri) opts.uri = uri;\n\n // Parse w:customXmlPr\n const xmlPr = findChild(el, \"w:customXmlPr\");\n if (xmlPr) {\n opts.customXmlPr = parseCustomXmlProperties(xmlPr);\n }\n\n // Parse block-level children\n const childList: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:customXmlPr\") continue;\n if (_parseBodyChild) {\n childList.push(_parseBodyChild(child, dctx));\n }\n }\n if (childList.length > 0) opts.children = childList;\n\n return opts as CustomXmlBlockDescriptorOptions;\n },\n};\n","/**\n * Text wrapping module for DrawingML elements.\n *\n * This module provides text wrapping options for floating/anchored drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @module\n */\nimport type { Distance } from \"../drawing\";\n\n/**\n * Enumeration of text wrapping types for floating drawings.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingType = {\n NONE: 0,\n SQUARE: 1,\n TIGHT: 2,\n TOP_AND_BOTTOM: 3,\n THROUGH: 4,\n} as const;\n\n/**\n * Enumeration of text wrapping sides for floating drawings.\n *\n * Specifies on which side(s) text can wrap around the drawing.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-textWrap.php\n *\n * @publicApi\n */\nexport const TextWrappingSide = {\n /** Text wraps on both sides of the drawing */\n BOTH_SIDES: \"bothSides\",\n /** Text wraps only on the left side */\n LEFT: \"left\",\n /** Text wraps only on the right side */\n RIGHT: \"right\",\n /** Text wraps on the side with more space */\n LARGEST: \"largest\",\n} as const;\n\n/**\n * A point in a wrap polygon (wrapTight/wrapThrough), in EMUs.\n */\nexport interface WrapPolygonPoint {\n x: number;\n y: number;\n}\n\n/**\n * Wrap polygon for wrapTight/wrapThrough — the contour text wraps around.\n * Round-tripped verbatim so Word's authored contour is preserved.\n */\nexport interface WrapPolygon {\n edited?: boolean;\n points: WrapPolygonPoint[];\n}\n\n/**\n * Options for configuring text wrapping around a drawing.\n */\nexport interface TextWrapping {\n type: (typeof TextWrappingType)[keyof typeof TextWrappingType];\n side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];\n margins?: Distance;\n /** Wrap polygon for wrapTight/wrapThrough. Preserves the source contour on round-trip; defaults to the extent rectangle when unset. */\n polygon?: WrapPolygon;\n}\n","/**\n * Shared constants for WordprocessingML documents.\n *\n * Provides alignment, number format, and space type constants\n * used across multiple document components.\n *\n * @module\n */\n\n// ── Alignment ──\n\n/**\n * Horizontal alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignH.html\n *\n * @publicApi\n */\nexport const HorizontalPositionAlign = {\n CENTER: \"center\",\n INSIDE: \"inside\",\n LEFT: \"left\",\n OUTSIDE: \"outside\",\n RIGHT: \"right\",\n} as const;\n\n/**\n * Vertical alignment options for floating drawings.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_AlignV.html\n *\n * @publicApi\n */\nexport const VerticalPositionAlign = {\n BOTTOM: \"bottom\",\n CENTER: \"center\",\n INSIDE: \"inside\",\n OUTSIDE: \"outside\",\n TOP: \"top\",\n} as const;\n\n// ── Number format ──\n\n/**\n * Number format types for page numbers and list numbering.\n *\n * Reference: http://officeopenxml.com/WPnumbering-numFmt.php\n *\n * @publicApi\n */\nexport const NumberFormat = {\n AIUEO: \"aiueo\",\n AIUEO_FULL_WIDTH: \"aiueoFullWidth\",\n ARABIC_ABJAD: \"arabicAbjad\",\n ARABIC_ALPHA: \"arabicAlpha\",\n BAHT_TEXT: \"bahtText\",\n BULLET: \"bullet\",\n CARDINAL_TEXT: \"cardinalText\",\n CHICAGO: \"chicago\",\n CHINESE_COUNTING: \"chineseCounting\",\n CHINESE_COUNTING_TEN_THOUSAND: \"chineseCountingThousand\",\n CHINESE_LEGAL_SIMPLIFIED: \"chineseLegalSimplified\",\n CHOSUNG: \"chosung\",\n DECIMAL: \"decimal\",\n DECIMAL_ENCLOSED_CIRCLE: \"decimalEnclosedCircle\",\n DECIMAL_ENCLOSED_CIRCLE_CHINESE: \"decimalEnclosedCircleChinese\",\n DECIMAL_ENCLOSED_FULL_STOP: \"decimalEnclosedFullstop\",\n DECIMAL_ENCLOSED_PAREN: \"decimalEnclosedParen\",\n DECIMAL_FULL_WIDTH: \"decimalFullWidth\",\n DECIMAL_FULL_WIDTH_2: \"decimalFullWidth2\",\n DECIMAL_HALF_WIDTH: \"decimalHalfWidth\",\n DECIMAL_ZERO: \"decimalZero\",\n DOLLAR_TEXT: \"dollarText\",\n GANADA: \"ganada\",\n HEBREW_1: \"hebrew1\",\n HEBREW_2: \"hebrew2\",\n HEX: \"hex\",\n HINDI_CONSONANTS: \"hindiConsonants\",\n HINDI_COUNTING: \"hindiCounting\",\n HINDI_NUMBERS: \"hindiNumbers\",\n HINDI_VOWELS: \"hindiVowels\",\n IDEOGRAPH_DIGITAL: \"ideographDigital\",\n IDEOGRAPH_ENCLOSED_CIRCLE: \"ideographEnclosedCircle\",\n IDEOGRAPH_LEGAL_TRADITIONAL: \"ideographLegalTraditional\",\n IDEOGRAPH_TRADITIONAL: \"ideographTraditional\",\n IDEOGRAPH_ZODIAC: \"ideographZodiac\",\n IDEOGRAPH_ZODIAC_TRADITIONAL: \"ideographZodiacTraditional\",\n IROHA: \"iroha\",\n IROHA_FULL_WIDTH: \"irohaFullWidth\",\n JAPANESE_COUNTING: \"japaneseCounting\",\n JAPANESE_DIGITAL_TEN_THOUSAND: \"japaneseDigitalTenThousand\",\n JAPANESE_LEGAL: \"japaneseLegal\",\n KOREAN_COUNTING: \"koreanCounting\",\n KOREAN_DIGITAL: \"koreanDigital\",\n KOREAN_DIGITAL_2: \"koreanDigital2\",\n KOREAN_LEGAL: \"koreanLegal\",\n LOWER_LETTER: \"lowerLetter\",\n LOWER_ROMAN: \"lowerRoman\",\n NONE: \"none\",\n NUMBER_IN_DASH: \"numberInDash\",\n ORDINAL: \"ordinal\",\n ORDINAL_TEXT: \"ordinalText\",\n RUSSIAN_LOWER: \"russianLower\",\n RUSSIAN_UPPER: \"russianUpper\",\n TAIWANESE_COUNTING: \"taiwaneseCounting\",\n TAIWANESE_COUNTING_THOUSAND: \"taiwaneseCountingThousand\",\n TAIWANESE_DIGITAL: \"taiwaneseDigital\",\n THAI_COUNTING: \"thaiCounting\",\n THAI_LETTERS: \"thaiLetters\",\n THAI_NUMBERS: \"thaiNumbers\",\n UPPER_LETTER: \"upperLetter\",\n UPPER_ROMAN: \"upperRoman\",\n VIETNAMESE_COUNTING: \"vietnameseCounting\",\n} as const;\n\n// ── Space type ──\n\n/**\n * XML space handling modes.\n *\n * @publicApi\n */\nexport const SpaceType = {\n DEFAULT: \"default\",\n PRESERVE: \"preserve\",\n} as const;\n","/**\n * Floating position module for DrawingML elements.\n *\n * This module provides positioning options for floating/anchored drawings,\n * including horizontal and vertical relative positioning.\n *\n * Reference: http://officeopenxml.com/drwPicFloating-position.php\n *\n * @module\n */\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\nexport { HorizontalPositionAlign, VerticalPositionAlign } from \"@shared/constants\";\n\nimport type { TextWrapping } from \"../text-wrap\";\n\n/**\n * Horizontal Relative Positioning.\n *\n * Specifies the horizontal base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromH.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromH\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"column\"/>\n * <xsd:enumeration value=\"character\"/>\n * <xsd:enumeration value=\"leftMargin\"/>\n * <xsd:enumeration value=\"rightMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const HorizontalPositionRelativeFrom = {\n /**\n * ## Character\n *\n * Specifies that the horizontal positioning shall be relative to the position of the anchor within its run content.\n */\n CHARACTER: \"character\",\n /**\n * ## Column\n *\n * Specifies that the horizontal positioning shall be relative to the extents of the column which contains its anchor.\n */\n COLUMN: \"column\",\n /**\n * ## Inside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the inside margin of the current page (the left margin on odd pages, right on even pages).\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Left Margin\n *\n * Specifies that the horizontal positioning shall be relative to the left margin of the page.\n */\n LEFT_MARGIN: \"leftMargin\",\n /**\n * ## Page Margin\n *\n * Specifies that the horizontal positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the horizontal positioning shall be relative to the outside margin of the current page (the right margin on odd pages, left on even pages).\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the horizontal positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Right Margin\n *\n * Specifies that the horizontal positioning shall be relative to the right margin of the page.\n */\n RIGHT_MARGIN: \"rightMargin\",\n} as const;\n\n/**\n * Vertical Relative Positioning.\n *\n * Specifies the vertical base from which the drawing position is calculated.\n *\n * Reference: https://www.datypic.com/sc/ooxml/t-wp_ST_RelFromV.html\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_RelFromV\">\n * <xsd:restriction base=\"xsd:token\">\n * <xsd:enumeration value=\"margin\"/>\n * <xsd:enumeration value=\"page\"/>\n * <xsd:enumeration value=\"paragraph\"/>\n * <xsd:enumeration value=\"line\"/>\n * <xsd:enumeration value=\"topMargin\"/>\n * <xsd:enumeration value=\"bottomMargin\"/>\n * <xsd:enumeration value=\"insideMargin\"/>\n * <xsd:enumeration value=\"outsideMargin\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const VerticalPositionRelativeFrom = {\n /**\n * ## Bottom Margin\n *\n * Specifies that the vertical positioning shall be relative to the bottom margin of the current page.\n */\n BOTTOM_MARGIN: \"bottomMargin\",\n /**\n * ## Inside Margin\n *\n * Specifies that the vertical positioning shall be relative to the inside margin of the current page.\n */\n INSIDE_MARGIN: \"insideMargin\",\n /**\n * ## Line\n *\n * Specifies that the vertical positioning shall be relative to the line containing the anchor character.\n */\n LINE: \"line\",\n /**\n * ## Page Margin\n *\n * Specifies that the vertical positioning shall be relative to the page margins.\n */\n MARGIN: \"margin\",\n /**\n * ## Outside Margin\n *\n * Specifies that the vertical positioning shall be relative to the outside margin of the current page.\n */\n OUTSIDE_MARGIN: \"outsideMargin\",\n /**\n * ## Page Edge\n *\n * Specifies that the vertical positioning shall be relative to the edge of the page.\n */\n PAGE: \"page\",\n /**\n * ## Paragraph\n *\n * Specifies that the vertical positioning shall be relative to the paragraph which contains the drawing anchor.\n */\n PARAGRAPH: \"paragraph\",\n /**\n * ## Top Margin\n *\n * Specifies that the vertical positioning shall be relative to the top margin of the current page.\n */\n TOP_MARGIN: \"topMargin\",\n} as const;\n\n/**\n * Options for horizontal positioning of a floating drawing.\n */\nexport interface HorizontalPositionOptions {\n /** The base from which horizontal position is calculated */\n relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom];\n /** Alignment relative to the horizontal base */\n align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign];\n /** Offset in EMUs from the horizontal base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Options for vertical positioning of a floating drawing.\n */\nexport interface VerticalPositionOptions {\n /** The base from which vertical position is calculated */\n relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];\n /** Alignment relative to the vertical base */\n align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign];\n /** Offset in EMUs from the vertical base, or universal measure (e.g., \"1in\", \"2cm\") */\n offset?: number | UniversalMeasure;\n}\n\n/**\n * Margin distances around a floating drawing in EMUs or universal measure.\n */\nexport interface Margins {\n left?: number | UniversalMeasure;\n bottom?: number | UniversalMeasure;\n top?: number | UniversalMeasure;\n right?: number | UniversalMeasure;\n}\n\n/**\n * Configuration options for a floating/anchored drawing.\n *\n * @see {@link Anchor}\n */\nexport interface Floating {\n horizontalPosition: HorizontalPositionOptions;\n verticalPosition: VerticalPositionOptions;\n allowOverlap?: boolean;\n lockAnchor?: boolean;\n behindDocument?: boolean;\n layoutInCell?: boolean;\n margins?: Margins;\n wrap?: TextWrapping;\n zIndex?: number;\n}\n","import { decimalNumber } from \"@office-open/core\";\nimport { element } from \"@office-open/xml\";\n/**\n * Page number module for WordprocessingML section properties.\n *\n * Defines page numbering format and starting value for document sections.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * @module\n */\nimport type { NumberFormat } from \"@shared/constants\";\n\n/**\n * Specifies the separator character between chapter number and page number.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:simpleType name=\"ST_ChapterSep\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"hyphen\"/>\n * <xsd:enumeration value=\"period\"/>\n * <xsd:enumeration value=\"colon\"/>\n * <xsd:enumeration value=\"emDash\"/>\n * <xsd:enumeration value=\"enDash\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageNumberSeparator = {\n /** Hyphen separator (-) */\n HYPHEN: \"hyphen\",\n /** Period separator (.) */\n PERIOD: \"period\",\n /** Colon separator (:) */\n COLON: \"colon\",\n /** Em dash separator (—) */\n EM_DASH: \"emDash\",\n /** En dash separator (–) */\n EN_DASH: \"enDash\",\n} as const;\n\n/**\n * Options for configuring page numbering.\n *\n * @property start - Starting page number for the section\n * @property formatType - Number format (decimal, roman, letter, etc.)\n * @property separator - Separator between chapter and page number\n */\nexport interface PageNumberTypeProperties {\n /** Starting page number for the section */\n start?: number;\n /** Number format (decimal, roman, letter, etc., default: decimal) */\n formatType?: (typeof NumberFormat)[keyof typeof NumberFormat];\n /** Separator between chapter and page number (default: hyphen) */\n separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator];\n /** Heading style ID for chapter numbering */\n chapStyle?: number;\n}\n\n/**\n * Creates page numbering settings (pgNumType) for a document section.\n *\n * This element specifies the page numbering format and starting value\n * for all pages in a section.\n *\n * Reference: http://officeopenxml.com/WPSectionPgNumType.php\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_PageNumber\">\n * <xsd:attribute name=\"fmt\" type=\"ST_NumberFormat\" use=\"optional\" default=\"decimal\"/>\n * <xsd:attribute name=\"start\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapStyle\" type=\"ST_DecimalNumber\" use=\"optional\"/>\n * <xsd:attribute name=\"chapSep\" type=\"ST_ChapterSep\" use=\"optional\" default=\"hyphen\"/>\n * </xsd:complexType>\n * ```\n *\n * @example\n * ```typescript\n * // Start page numbering at 5 with lowercase roman numerals\n * createPageNumberType({\n * start: 5,\n * formatType: NumberFormat.LOWER_ROMAN\n * });\n * ```\n */\nexport const createPageNumberType = ({\n start,\n formatType,\n separator,\n chapStyle,\n}: PageNumberTypeProperties): string =>\n element(\"w:pgNumType\", {\n \"w:chapStyle\": chapStyle === undefined ? undefined : decimalNumber(chapStyle),\n \"w:fmt\": formatType,\n \"w:chapSep\": separator,\n \"w:start\": start === undefined ? undefined : decimalNumber(start),\n });\n","import type { PositiveUniversalMeasure } from \"@office-open/core\";\n\n/**\n * This simple type specifies the orientation of all pages in the parent section. This information is used to determine the actual paper size to use when printing the file.\n *\n * Reference: https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_PageOrientation_topic_ID0EKBK3.html\n *\n * ## XSD Schema\n *\n * ```xml\n * <xsd:simpleType name=\"ST_PageOrientation\">\n * <xsd:restriction base=\"xsd:string\">\n * <xsd:enumeration value=\"portrait\"/>\n * <xsd:enumeration value=\"landscape\"/>\n * </xsd:restriction>\n * </xsd:simpleType>\n * ```\n *\n * @publicApi\n */\nexport const PageOrientation = {\n /**\n * ## Portrait Mode\n *\n * Specifies that pages in this section shall be printed in portrait mode.\n */\n PORTRAIT: \"portrait\",\n /**\n * ## Landscape Mode\n *\n * Specifies that pages in this section shall be printed in landscape mode, which prints the page contents with a 90 degree rotation with respect to the normal page orientation.\n */\n LANDSCAPE: \"landscape\",\n} as const;\n\nexport interface PageSizeProperties {\n /**\n * ## Page Width\n *\n * This attribute indicates the width (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is 15840 twentieths of a point (11\") wide.\n *\n * The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.18.105).\n */\n width?: number | PositiveUniversalMeasure;\n /**\n * ## Page Height\n *\n * Specifies the height (in twentieths of a point) for all pages in the current section.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" />\n * ```\n *\n * All pages in this section are displayed on a page that is `12240` twentieths of a point (`8.5\"`) tall.\n *\n * The possible values for this attribute are defined by the `ST_TwipsMeasure` simple type (§2.18.105).\n */\n height?: number | PositiveUniversalMeasure;\n /**\n * ## Page Orientation\n *\n * Specifies the orientation of all pages in this section.\n *\n * This information is used to determine the actual paper size to use on the printer.\n *\n * This implies that the actual paper size width and height are reversed for pages in this section. If this attribute is omitted, then portrait shall be implied.\n *\n * ### Example\n *\n * ```xml\n * <w:pgSz w:w=\"15840\" w:h=\"12240\" w:orient=\"landscape\" />\n * ```\n *\n * Although the page width is 11\", and page height is 8.5\", according to the `w` and `h` attributes, because the `orient` attribute is set to landscape, pages in this section are printed on 8.5x11\" paper in landscape mode.\n *\n * The possible values for this attribute are defined by the `ST_PageOrientation` simple type (§2.18.71).\n */\n orientation?: (typeof PageOrientation)[keyof typeof PageOrientation];\n /**\n * ## Printer Paper Code\n *\n * Specifies a printer-specific paper code for the paper type, which shall be used by the printer for pages in this section.\n *\n * This code is stored to ensure the proper paper type is chosen if the specified paper size matches the sizes of multiple paper types supported by the current printer.\n *\n * It will be sent to the printer and used by the printer to determine the appropriate paper type to use when printing.\n *\n * This value is not interpreted or modified other than storing it as specified by the printer.\n *\n * The possible values for this attribute are defined by the `ST_DecimalNumber` simple type (§2.18.16).\n */\n code?: number;\n}\n","/**\n * Page text direction module for WordprocessingML section properties.\n *\n * Defines text flow direction for pages in a section.\n *\n * Reference: http://officeopenxml.com/WPsectionPr.php\n *\n * @module\n */\n\n/**\n * Specifies the text flow direction for pages in a section.\n *\n * This controls whether text flows horizontally (left-to-right) or\n * vertically (top-to-bottom), commonly used for East Asian languages.\n */\nexport const PageTextDirectionType = {\n /** Left-to-right, top-to-bottom (standard Western text flow) */\n LEFT_TO_RIGHT_TOP_TO_BOTTOM: \"lrTb\",\n /** Top-to-bottom, right-to-left (vertical East Asian text flow) */\n TOP_TO_BOTTOM_RIGHT_TO_LEFT: \"tbRl\",\n} as const;\n","/**\n * Section properties module for WordprocessingML documents.\n *\n * Section properties define page layout including page size, margins,\n * headers/footers, columns, and page numbering.\n *\n * Reference: http://officeopenxml.com/WPsection.php\n *\n * @module\n */\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { ChangedProperties } from \"@shared/track-revision/track-revision\";\nimport type { SectionVerticalAlign } from \"@shared/vertical-align\";\n\nimport type { ColumnsProperties } from \"./properties/columns\";\nimport type { DocGridProperties } from \"./properties/doc-grid\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"./properties/footnote-endnote-properties\";\nimport type { LineNumberProperties } from \"./properties/line-number\";\nimport type { PageBordersOptions } from \"./properties/page-borders\";\nimport type { PageMarginProperties } from \"./properties/page-margin\";\nimport type { PageNumberTypeProperties } from \"./properties/page-number\";\nimport { PageOrientation } from \"./properties/page-size\";\nimport type { PageSizeProperties } from \"./properties/page-size\";\nimport { PageTextDirectionType } from \"./properties/page-text-direction\";\nimport type { SectionType } from \"./properties/section-type\";\n\n/**\n * Header/footer group for specifying different headers/footers\n * for default, first, and even pages.\n */\nexport interface HeaderFooterGroup<T> {\n default?: T;\n first?: T;\n even?: T;\n}\n\nexport interface SectionPropertiesOptionsBase {\n runPropertiesRsid?: string;\n deletionRsid?: string;\n rsid?: string;\n sectionRsid?: string;\n page?: {\n size?: PageSizeProperties;\n margin?: PageMarginProperties;\n pageNumbers?: PageNumberTypeProperties;\n borders?: PageBordersOptions;\n textDirection?: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType];\n };\n /**\n * Document grid. Three states: omitted (fresh generation emits Word's CJK\n * default line grid — linePitch 312, type \"lines\"); a DocGridProperties object\n * (emits provided values, e.g. from a parsed source); or false (explicit off —\n * a parsed source with no w:docGrid is preserved by emitting nothing).\n */\n grid?: DocGridProperties | false;\n headerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n footerWrapperGroup?: HeaderFooterGroup<HeaderFooterEntry>;\n lineNumbers?: LineNumberProperties;\n titlePage?: boolean;\n verticalAlign?: SectionVerticalAlign;\n column?: ColumnsProperties;\n type?: (typeof SectionType)[keyof typeof SectionType];\n noEndnote?: boolean;\n formProtection?: boolean;\n bidi?: boolean;\n rtlGutter?: boolean;\n paperSrc?: {\n first?: number;\n other?: number;\n };\n footnotePr?: FootnotePropertiesOptions;\n endnotePr?: EndnotePropertiesOptions;\n printerSettingsId?: string;\n}\n\nexport type SectionPropertiesChangeOptions = ChangedProperties & SectionPropertiesOptionsBase;\n\nexport type SectionPropertiesOptions = {\n revision?: SectionPropertiesChangeOptions;\n} & SectionPropertiesOptionsBase;\n\nexport const sectionMarginDefaults = {\n TOP: 1440,\n RIGHT: 1800,\n BOTTOM: 1440,\n LEFT: 1800,\n HEADER: 851,\n FOOTER: 992,\n GUTTER: 0,\n};\n\nexport const sectionPageSizeDefaults = {\n WIDTH: 11_906,\n HEIGHT: 16_838,\n ORIENTATION: PageOrientation.PORTRAIT,\n};\n","/**\n * Section properties descriptor for DOCX documents.\n *\n * Produces `<w:sectPr>` XML directly from options, eliminating all\n * intermediate XmlComponent instances (create* + toXml pattern).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_SectPr\n *\n * @module\n */\n\nimport { convertToTwip } from \"@office-open/core\";\nimport { twipsMeasureValue } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ColumnProperties } from \"@parts/document/body/section-properties/properties/column\";\nimport type { ColumnsProperties } from \"@parts/document/body/section-properties/properties/columns\";\nimport type { DocGridProperties } from \"@parts/document/body/section-properties/properties/doc-grid\";\nimport type {\n EndnotePropertiesOptions,\n FootnotePropertiesOptions,\n} from \"@parts/document/body/section-properties/properties/footnote-endnote-properties\";\nimport type { PageBordersOptions } from \"@parts/document/body/section-properties/properties/page-borders\";\nimport { PageNumberSeparator } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type { PageNumberTypeProperties } from \"@parts/document/body/section-properties/properties/page-number\";\nimport type {\n SectionPropertiesChangeOptions,\n SectionPropertiesOptions,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport {\n sectionMarginDefaults,\n sectionPageSizeDefaults,\n} from \"@parts/document/body/section-properties/section-properties\";\nimport type { HeaderFooterEntry } from \"@parts/header-footer\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { NumberFormat } from \"@shared/constants\";\nimport type { BodyContext } from \"@shared/index\";\n\n/** Valid page-number @w:fmt values (ST_NumberFormat). */\nconst PAGE_NUMBER_FORMATS = Object.values(NumberFormat) as readonly string[];\n/** Valid page-number @w:chapSep values (ST_ChapterSep). */\nconst PAGE_NUMBER_SEPARATORS = Object.values(PageNumberSeparator) as readonly string[];\n\n// ── Border XML helper ──\n\nfunction stringifyBorderXml(tag: string, opts: BorderOptions): string {\n const attrs: string[] = [];\n if (opts.style !== undefined) attrs.push(`w:val=\"${opts.style}\"`);\n if (opts.color !== undefined) attrs.push(`w:color=\"${opts.color}\"`);\n if (opts.size !== undefined) attrs.push(`w:sz=\"${opts.size}\"`);\n if (opts.space !== undefined) attrs.push(`w:space=\"${opts.space}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${opts.themeTint}\"`);\n if (opts.themeShade !== undefined) attrs.push(`w:themeShade=\"${opts.themeShade}\"`);\n if (opts.shadow !== undefined) attrs.push(`w:shadow=\"${opts.shadow ? 1 : 0}\"`);\n if (opts.frame !== undefined) attrs.push(`w:frame=\"${opts.frame ? 1 : 0}\"`);\n return `<${tag} ${attrs.join(\" \")}/>`;\n}\n\n// ── Inline XML builders (replacing create* + toXml) ──\n\nfunction pageSizeXml(\n w: number | string,\n h: number | string,\n orient?: string,\n code?: number,\n): string {\n const attrs: string[] = [`w:w=\"${w}\"`, `w:h=\"${h}\"`];\n if (orient) attrs.push(`w:orient=\"${orient}\"`);\n if (code !== undefined) attrs.push(`w:code=\"${code}\"`);\n return `<w:pgSz ${attrs.join(\" \")}/>`;\n}\n\nfunction pageMarginXml(\n top: number | string,\n right: number | string,\n bottom: number | string,\n left: number | string,\n header: number | string,\n footer: number | string,\n gutter: number | string,\n): string {\n return `<w:pgMar w:top=\"${top}\" w:right=\"${right}\" w:bottom=\"${bottom}\" w:left=\"${left}\" w:header=\"${header}\" w:footer=\"${footer}\" w:gutter=\"${gutter}\"/>`;\n}\n\nfunction headerFooterRefXml(tag: string, id: number, type: string): string {\n return `<${tag} r:id=\"rId${id}\" w:type=\"${type}\"/>`;\n}\n\nfunction sectionTypeXml(val: string): string {\n return `<w:type w:val=\"${val}\"/>`;\n}\n\nfunction verticalAlignXml(val: string): string {\n return `<w:vAlign w:val=\"${val}\"/>`;\n}\n\nfunction lineNumberXml(opts: NonNullable<SectionPropertiesOptions[\"lineNumbers\"]>): string {\n const attrs: string[] = [];\n if (opts.countBy !== undefined) attrs.push(`w:countBy=\"${opts.countBy}\"`);\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.restart !== undefined) attrs.push(`w:restart=\"${opts.restart}\"`);\n if (opts.distance !== undefined) attrs.push(`w:distance=\"${opts.distance}\"`);\n return attrs.length ? `<w:lnNumType ${attrs.join(\" \")}/>` : \"<w:lnNumType/>\";\n}\n\nfunction pageNumberXml(opts: NonNullable<PageNumberTypeProperties>): string {\n const attrs: string[] = [];\n if (opts.start !== undefined) attrs.push(`w:start=\"${opts.start}\"`);\n if (opts.formatType !== undefined) attrs.push(`w:fmt=\"${opts.formatType}\"`);\n if (opts.separator !== undefined) attrs.push(`w:chapSep=\"${opts.separator}\"`);\n if (opts.chapStyle !== undefined) attrs.push(`w:chapStyle=\"${opts.chapStyle}\"`);\n // No attributes → omit pgNumType (never fabricate an empty element).\n return attrs.length ? `<w:pgNumType ${attrs.join(\" \")}/>` : \"\";\n}\n\nfunction docGridXml(linePitch: number, charSpace?: number, type?: string): string {\n const attrs: string[] = [`w:linePitch=\"${linePitch}\"`];\n if (charSpace !== undefined) attrs.push(`w:charSpace=\"${charSpace}\"`);\n if (type !== undefined) attrs.push(`w:type=\"${type}\"`);\n return `<w:docGrid ${attrs.join(\" \")}/>`;\n}\n\nfunction columnsXml(opts: NonNullable<SectionPropertiesOptions[\"column\"]>): string {\n const attrs: string[] = [];\n if (opts.space !== undefined) attrs.push(`w:space=\"${twipsMeasureValue(opts.space)}\"`);\n if (opts.count !== undefined) attrs.push(`w:num=\"${opts.count}\"`);\n if (opts.separate !== undefined) attrs.push(`w:sep=\"${opts.separate ? 1 : 0}\"`);\n if (opts.equalWidth !== undefined) attrs.push(`w:equalWidth=\"${opts.equalWidth ? 1 : 0}\"`);\n\n const attrStr = attrs.join(\" \");\n\n // Custom width columns — children are ColumnProperties (Column class implements this interface)\n if (!opts.equalWidth && opts.children) {\n const colParts: string[] = [];\n for (const col of opts.children as readonly ColumnProperties[]) {\n const colAttrs: string[] = [`w:w=\"${twipsMeasureValue(col.width)}\"`];\n if (col.space !== undefined) colAttrs.push(`w:space=\"${twipsMeasureValue(col.space)}\"`);\n colParts.push(`<w:col ${colAttrs.join(\" \")}/>`);\n }\n return `<w:cols ${attrStr}>${colParts.join(\"\")}</w:cols>`;\n }\n return `<w:cols ${attrStr}/>`;\n}\n\nfunction footnotePrXml(\n tag: string,\n opts: FootnotePropertiesOptions | EndnotePropertiesOptions,\n): string {\n const parts: string[] = [];\n if (opts.pos !== undefined) parts.push(`<w:pos w:val=\"${opts.pos}\"/>`);\n if (opts.formatType !== undefined || opts.format !== undefined) {\n const fmtAttrs: string[] = [];\n // CT_NumFmt uses w:val (required) for the format type; w:fmt belongs to\n // CT_PageNumber (pgNumType). w:format is the optional free-form override.\n if (opts.formatType !== undefined) fmtAttrs.push(`w:val=\"${opts.formatType}\"`);\n if (opts.format !== undefined) fmtAttrs.push(`w:format=\"${opts.format}\"`);\n parts.push(`<w:numFmt ${fmtAttrs.join(\" \")}/>`);\n }\n if (opts.numStart !== undefined) parts.push(`<w:numStart w:val=\"${opts.numStart}\"/>`);\n if (opts.numRestart !== undefined) parts.push(`<w:numRestart w:val=\"${opts.numRestart}\"/>`);\n const body = parts.join(\"\");\n return body ? `<${tag}>${body}</${tag}>` : `<${tag}/>`;\n}\n\nfunction pageBordersXml(opts: NonNullable<PageBordersOptions>): string {\n const attrs: string[] = [];\n if (opts.display !== undefined) attrs.push(`w:display=\"${opts.display}\"`);\n if (opts.offsetFrom !== undefined) attrs.push(`w:offsetFrom=\"${opts.offsetFrom}\"`);\n if (opts.zOrder !== undefined) attrs.push(`w:zOrder=\"${opts.zOrder}\"`);\n\n const parts: string[] = [];\n if (opts.top) parts.push(stringifyBorderXml(\"w:top\", opts.top));\n if (opts.left) parts.push(stringifyBorderXml(\"w:left\", opts.left));\n if (opts.bottom) parts.push(stringifyBorderXml(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(stringifyBorderXml(\"w:right\", opts.right));\n\n const attrStr = attrs.join(\" \");\n const body = parts.join(\"\");\n if (!body && !attrStr) return \"<w:pgBorders/>\";\n return body ? `<w:pgBorders ${attrStr}>${body}</w:pgBorders>` : `<w:pgBorders ${attrStr}/>`;\n}\n\n// ── Header/footer references ──\n\nfunction appendHeaderFooterRefs(\n parts: string[],\n type: \"w:headerReference\" | \"w:footerReference\",\n group?: { default?: HeaderFooterEntry; first?: HeaderFooterEntry; even?: HeaderFooterEntry },\n): void {\n if (!group) return;\n if (group.default) parts.push(headerFooterRefXml(type, group.default.referenceId, \"default\"));\n if (group.first) parts.push(headerFooterRefXml(type, group.first.referenceId, \"first\"));\n if (group.even) parts.push(headerFooterRefXml(type, group.even.referenceId, \"even\"));\n}\n\n// ── sectPrChange (recursive) ──\n\nfunction stringifySectionPropertiesChange(opts: SectionPropertiesChangeOptions): string {\n const { author, date, id, ...inner } = opts;\n const innerXml = stringifySectionPropertiesInner(inner);\n return `<w:sectPrChange w:author=\"${author}\" w:date=\"${date}\" w:id=\"${id}\"><w:sectPr>${innerXml}</w:sectPr></w:sectPrChange>`;\n}\n\n// ── Core XML builder ──\n\nfunction stringifySectionPropertiesInner(opts: SectionPropertiesOptions): string {\n const parts: string[] = [];\n\n // Header/footer references\n appendHeaderFooterRefs(parts, \"w:headerReference\", opts.headerWrapperGroup);\n appendHeaderFooterRefs(parts, \"w:footerReference\", opts.footerWrapperGroup);\n\n // Destructure page options with defaults\n const {\n size: {\n width = sectionPageSizeDefaults.WIDTH,\n height = sectionPageSizeDefaults.HEIGHT,\n orientation = sectionPageSizeDefaults.ORIENTATION,\n code,\n } = {},\n margin: {\n top = sectionMarginDefaults.TOP,\n right = sectionMarginDefaults.RIGHT,\n bottom = sectionMarginDefaults.BOTTOM,\n left = sectionMarginDefaults.LEFT,\n header = sectionMarginDefaults.HEADER,\n footer = sectionMarginDefaults.FOOTER,\n gutter = sectionMarginDefaults.GUTTER,\n } = {},\n pageNumbers = {},\n borders,\n textDirection,\n } = opts.page ?? {};\n\n const {\n linePitch = 312,\n charSpace = 0,\n type: gridType = \"lines\",\n } = typeof opts.grid === \"object\" ? opts.grid : {};\n\n // Footnote/endnote properties\n if (opts.footnotePr) parts.push(footnotePrXml(\"w:footnotePr\", opts.footnotePr));\n if (opts.endnotePr) parts.push(footnotePrXml(\"w:endnotePr\", opts.endnotePr));\n\n // Section type\n if (opts.type) parts.push(sectionTypeXml(opts.type));\n\n // Page size — normalize both logical dimensions to twips, then swap w/h when\n // landscape. UniversalMeasure (\"210mm\") is converted so the emitted w:w/w:h is\n // always a plain twip number that the attrNum-based parse reads back exactly.\n const wTwips = convertToTwip(width);\n const hTwips = convertToTwip(height);\n const pgW = orientation === \"landscape\" ? hTwips : wTwips;\n const pgH = orientation === \"landscape\" ? wTwips : hTwips;\n parts.push(pageSizeXml(pgW, pgH, orientation, code));\n\n // Page margin (always present)\n parts.push(pageMarginXml(top, right, bottom, left, header, footer, gutter));\n\n // Page borders\n if (borders) parts.push(pageBordersXml(borders));\n\n // Line numbers\n if (opts.lineNumbers) parts.push(lineNumberXml(opts.lineNumbers));\n\n // Page numbers\n parts.push(pageNumberXml(pageNumbers));\n\n // Columns\n if (opts.column) parts.push(columnsXml(opts.column));\n\n // Vertical alignment\n if (opts.verticalAlign) parts.push(verticalAlignXml(opts.verticalAlign));\n\n // Boolean on/off elements — direct string output\n if (opts.titlePage !== undefined)\n parts.push(opts.titlePage ? \"<w:titlePg/>\" : '<w:titlePg w:val=\"0\"/>');\n if (textDirection) parts.push(`<w:textDirection w:val=\"${textDirection}\"/>`);\n if (opts.noEndnote !== undefined)\n parts.push(opts.noEndnote ? \"<w:noEndnote/>\" : '<w:noEndnote w:val=\"0\"/>');\n if (opts.formProtection !== undefined)\n parts.push(opts.formProtection ? \"<w:formProt/>\" : '<w:formProt w:val=\"0\"/>');\n if (opts.bidi !== undefined) parts.push(opts.bidi ? \"<w:bidi/>\" : '<w:bidi w:val=\"0\"/>');\n if (opts.rtlGutter !== undefined)\n parts.push(opts.rtlGutter ? \"<w:rtlGutter/>\" : '<w:rtlGutter w:val=\"0\"/>');\n\n // Paper source\n if (opts.paperSrc) {\n const psAttr: string[] = [];\n if (opts.paperSrc.first !== undefined) psAttr.push(`w:first=\"${opts.paperSrc.first}\"`);\n if (opts.paperSrc.other !== undefined) psAttr.push(`w:other=\"${opts.paperSrc.other}\"`);\n parts.push(`<w:paperSrc ${psAttr.join(\" \")}/>`);\n }\n\n // Printer settings\n if (opts.printerSettingsId !== undefined) {\n parts.push(`<w:printerSettings r:id=\"${opts.printerSettingsId}\"/>`);\n }\n\n // Document grid — three states:\n // - undefined (fresh, unset): emit Word's CJK default line grid (linePitch\n // 312, type \"lines\") so generated docs match East Asian line-snapping.\n // - object: emit provided values (round-trip fidelity).\n // - false (explicit off, e.g. parsed source had no w:docGrid): omit.\n if (opts.grid !== false) {\n parts.push(docGridXml(linePitch, charSpace, gridType));\n }\n\n // Revision (sectPrChange)\n if (opts.revision) {\n parts.push(stringifySectionPropertiesChange(opts.revision));\n }\n\n return parts.join(\"\");\n}\n\n// ── Descriptor ──\n\n/**\n * Section properties descriptor for DOCX `<w:sectPr>` elements.\n *\n * Produces complete XML directly from options — zero XmlComponent instances\n * in the hot path. All `create*()` + `.toXml()` calls eliminated in favor\n * of direct string concatenation.\n *\n * @example\n * ```typescript\n * const xml = sectionPropertiesDesc.stringify(sectPrOpts, ctx);\n * ```\n */\nexport const sectionPropertiesDesc: CustomDescriptor<SectionPropertiesOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n return stringifySectionPropertiesXml(opts);\n },\n\n parse(el, _ctx) {\n return parseSectionPropertiesEl(el);\n },\n};\n\n/** Standalone stringify — no context needed, pure options → XML. */\nexport function stringifySectionPropertiesXml(opts: SectionPropertiesOptions): string {\n const inner = stringifySectionPropertiesInner(opts);\n\n const attrs: string[] = [];\n if (opts.runPropertiesRsid !== undefined) attrs.push(`w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid !== undefined) attrs.push(`w:rsidDel=\"${opts.deletionRsid}\"`);\n if (opts.rsid !== undefined) attrs.push(`w:rsidR=\"${opts.rsid}\"`);\n if (opts.sectionRsid !== undefined) attrs.push(`w:rsidSect=\"${opts.sectionRsid}\"`);\n\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n return `<w:sectPr${attrStr}>${inner}</w:sectPr>`;\n}\n\n// ── Parse (Element → SectionPropertiesOptions) ──\n\n/** Parse a w:sectPr element into SectionPropertiesOptions. */\nexport function parseSectionPropertiesEl(el: Element): SectionPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n // rsid attributes on w:sectPr element\n for (const [attrName, optKey] of [\n [\"w:rsidR\", \"rsid\"],\n [\"w:rsidRPr\", \"runPropertiesRsid\"],\n [\"w:rsidDel\", \"deletionRsid\"],\n [\"w:rsidSect\", \"sectionRsid\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n // Page properties — pgSz, pgMar, pgNumType are independent per CT_SectPr\n // (each minOccurs=0). Do not gate pgMar/pgNumType on pgSz: a sectPr that\n // omits <w:pgSz> must still round-trip its margins and page-number type.\n const page: Record<string, unknown> = {};\n\n // Page size\n const pgSz = findChild(el, \"w:pgSz\");\n if (pgSz) {\n const size: Record<string, unknown> = {};\n const w = attrNum(pgSz, \"w:w\");\n const h = attrNum(pgSz, \"w:h\");\n const orient = attr(pgSz, \"w:orient\");\n if (orient === \"landscape\" && w !== undefined && h !== undefined) {\n size.width = h;\n size.height = w;\n } else {\n if (w !== undefined) size.width = w;\n if (h !== undefined) size.height = h;\n }\n if (orient) size.orientation = orient;\n const code = attrNum(pgSz, \"w:code\");\n if (code !== undefined) size.code = code;\n if (Object.keys(size).length > 0) page.size = size;\n }\n\n // Page margins\n const pgMar = findChild(el, \"w:pgMar\");\n if (pgMar) {\n const margin: Record<string, unknown> = {};\n for (const [a, o] of [\n [\"w:top\", \"top\"],\n [\"w:right\", \"right\"],\n [\"w:bottom\", \"bottom\"],\n [\"w:left\", \"left\"],\n [\"w:header\", \"header\"],\n [\"w:footer\", \"footer\"],\n [\"w:gutter\", \"gutter\"],\n ] as const) {\n const val = attrNum(pgMar, a);\n if (val !== undefined) margin[o] = val;\n }\n if (Object.keys(margin).length > 0) page.margin = margin;\n }\n\n // Page number type\n const pgNumType = findChild(el, \"w:pgNumType\");\n if (pgNumType) {\n const pageNumbers: PageNumberTypeProperties = {};\n const start = attrNum(pgNumType, \"w:start\");\n if (start !== undefined) pageNumbers.start = start;\n const fmt = attr(pgNumType, \"w:fmt\");\n if (fmt && PAGE_NUMBER_FORMATS.includes(fmt)) {\n pageNumbers.formatType = fmt as PageNumberTypeProperties[\"formatType\"];\n }\n const chapSep = attr(pgNumType, \"w:chapSep\");\n if (chapSep && PAGE_NUMBER_SEPARATORS.includes(chapSep)) {\n pageNumbers.separator = chapSep as PageNumberTypeProperties[\"separator\"];\n }\n const chapStyle = attrNum(pgNumType, \"w:chapStyle\");\n if (chapStyle !== undefined) pageNumbers.chapStyle = chapStyle;\n if (Object.keys(pageNumbers).length > 0) page.pageNumbers = pageNumbers;\n }\n\n if (Object.keys(page).length > 0) opts.page = page;\n\n // Columns\n const cols = findChild(el, \"w:cols\");\n if (cols) {\n const column: ColumnsProperties = {};\n const count = attrNum(cols, \"w:num\");\n if (count !== undefined) column.count = count;\n const space = attrMeasure(cols, \"w:space\");\n if (space !== undefined) column.space = space as ColumnsProperties[\"space\"];\n const separate = attrBool(cols, \"w:sep\");\n if (separate !== undefined) column.separate = separate;\n const equalWidth = attrBool(cols, \"w:equalWidth\");\n if (equalWidth !== undefined) column.equalWidth = equalWidth;\n const colChildren: ColumnProperties[] = [];\n for (const colEl of cols.elements ?? []) {\n if (colEl.name !== \"w:col\") continue;\n const width = attrMeasure(colEl, \"w:w\");\n if (width === undefined) continue;\n const colAttr: ColumnProperties = { width: width as ColumnProperties[\"width\"] };\n const colSpace = attrMeasure(colEl, \"w:space\");\n if (colSpace !== undefined) colAttr.space = colSpace as ColumnProperties[\"space\"];\n colChildren.push(colAttr);\n }\n if (colChildren.length > 0) column.children = colChildren;\n if (Object.keys(column).length > 0) opts.column = column;\n }\n\n // Section type\n const type = findChild(el, \"w:type\");\n if (type) {\n const val = attr(type, \"w:val\");\n if (val) opts.type = val;\n }\n\n // Title page\n const titlePg = findChild(el, \"w:titlePg\");\n if (titlePg) opts.titlePage = attrBool(titlePg, \"w:val\") ?? true;\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:noEndnote\", \"noEndnote\"],\n [\"w:formProt\", \"formProtection\"],\n [\"w:bidi\", \"bidi\"],\n [\"w:rtlGutter\", \"rtlGutter\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Document grid — three-state: object (source had w:docGrid → preserve),\n // false (source had none → explicit off so stringify omits it), undefined\n // (fresh generation, stringify emits the CJK default line grid).\n const docGrid = findChild(el, \"w:docGrid\");\n if (docGrid) {\n const grid: Partial<DocGridProperties> = {};\n const type = attr(docGrid, \"w:type\");\n if (type) grid.type = type as DocGridProperties[\"type\"];\n const linePitch = attrNum(docGrid, \"w:linePitch\");\n if (linePitch !== undefined) grid.linePitch = linePitch;\n const charSpace = attrNum(docGrid, \"w:charSpace\");\n if (charSpace !== undefined) grid.charSpace = charSpace;\n opts.grid = grid as DocGridProperties;\n } else {\n opts.grid = false;\n }\n\n // Line numbers\n const lnNumType = findChild(el, \"w:lnNumType\");\n if (lnNumType) {\n const lineNumbers: Record<string, unknown> = {};\n const countBy = attrNum(lnNumType, \"w:countBy\");\n if (countBy !== undefined) lineNumbers.countBy = countBy;\n const start = attrNum(lnNumType, \"w:start\");\n if (start !== undefined) lineNumbers.start = start;\n const restart = attr(lnNumType, \"w:restart\");\n if (restart) lineNumbers.restart = restart;\n const distance = attrNum(lnNumType, \"w:distance\");\n if (distance !== undefined) lineNumbers.distance = distance;\n if (Object.keys(lineNumbers).length > 0) opts.lineNumbers = lineNumbers;\n }\n\n // Page borders\n const pgBorders = findChild(el, \"w:pgBorders\");\n if (pgBorders) {\n const borders: Record<string, unknown> = {};\n for (const side of [\"top\", \"left\", \"bottom\", \"right\"] as const) {\n const sideEl = findChild(pgBorders, `w:${side}`);\n if (sideEl) {\n const b: Record<string, unknown> = {};\n const val = attr(sideEl, \"w:val\");\n if (val) b.style = val;\n const color = attr(sideEl, \"w:color\");\n if (color) b.color = color;\n const sz = attrNum(sideEl, \"w:sz\");\n if (sz !== undefined) b.size = sz;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) b.space = space;\n borders[side] = b;\n }\n }\n const display = attr(pgBorders, \"w:display\");\n if (display) borders.display = display;\n const offsetFrom = attr(pgBorders, \"w:offsetFrom\");\n if (offsetFrom) borders.offsetFrom = offsetFrom;\n const zOrder = attr(pgBorders, \"w:zOrder\");\n if (zOrder) borders.zOrder = zOrder;\n if (Object.keys(borders).length > 0) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.borders = borders;\n opts.page = page;\n }\n }\n\n // Vertical align\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val;\n }\n\n // Text direction\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) {\n const page = (opts.page ?? {}) as Record<string, unknown>;\n page.textDirection = val;\n opts.page = page;\n }\n }\n\n // Footnote properties\n const footnotePr = findChild(el, \"w:footnotePr\");\n if (footnotePr) {\n opts.footnotePr = parseNotePropertiesEl(footnotePr);\n }\n\n // Endnote properties\n const endnotePr = findChild(el, \"w:endnotePr\");\n if (endnotePr) {\n opts.endnotePr = parseNotePropertiesEl(endnotePr);\n }\n\n // Paper source\n const paperSrc = findChild(el, \"w:paperSrc\");\n if (paperSrc) {\n const ps: Record<string, unknown> = {};\n const first = attrNum(paperSrc, \"w:first\");\n if (first !== undefined) ps.first = first;\n const other = attrNum(paperSrc, \"w:other\");\n if (other !== undefined) ps.other = other;\n if (Object.keys(ps).length > 0) opts.paperSrc = ps;\n }\n\n // Printer settings\n const printerSettings = findChild(el, \"w:printerSettings\");\n if (printerSettings) {\n const rId = attr(printerSettings, \"r:id\");\n if (rId) opts.printerSettingsId = rId;\n }\n\n // Header/footer references\n const headerGroup: Record<string, unknown> = {};\n const footerGroup: Record<string, unknown> = {};\n for (const child of el.elements ?? []) {\n if (child.name === \"w:headerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) headerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n } else if (child.name === \"w:footerReference\") {\n const type = attr(child, \"w:type\");\n const rId = attr(child, \"r:id\");\n if (type && rId) footerGroup[type] = { referenceId: parseInt(rId.replace(\"rId\", \"\"), 10) };\n }\n }\n if (Object.keys(headerGroup).length > 0) opts.headerWrapperGroup = headerGroup;\n if (Object.keys(footerGroup).length > 0) opts.footerWrapperGroup = footerGroup;\n\n // Revision (w:sectPrChange) — symmetric with stringifySectionPropertiesChange\n const sectPrChange = findChild(el, \"w:sectPrChange\");\n if (sectPrChange) {\n const rev: Record<string, unknown> = {};\n const author = attr(sectPrChange, \"w:author\");\n if (author) rev.author = author;\n const revDate = attr(sectPrChange, \"w:date\");\n if (revDate) rev.date = revDate;\n const revId = attrNum(sectPrChange, \"w:id\");\n if (revId !== undefined) rev.id = revId;\n const innerSectPr = findChild(sectPrChange, \"w:sectPr\");\n if (innerSectPr) Object.assign(rev, parseSectionPropertiesEl(innerSectPr));\n if (Object.keys(rev).length > 0) opts.revision = rev;\n }\n\n return opts as unknown as SectionPropertiesOptions;\n}\n\nfunction parseNotePropertiesEl(el: Element): Record<string, unknown> {\n const opts: Record<string, unknown> = {};\n\n const posEl = findChild(el, \"w:pos\");\n if (posEl) {\n const val = attr(posEl, \"w:val\");\n if (val) opts.pos = val;\n }\n\n const numFmt = findChild(el, \"w:numFmt\");\n if (numFmt) {\n // CT_NumFmt: w:val (format type) + w:format (optional override).\n const fmt = attr(numFmt, \"w:val\");\n if (fmt) opts.formatType = fmt;\n const format = attr(numFmt, \"w:format\");\n if (format) opts.format = format;\n }\n\n const numStart = findChild(el, \"w:numStart\");\n if (numStart) {\n const val = attrNum(numStart, \"w:val\");\n if (val !== undefined) opts.numStart = val;\n }\n\n const numRestart = findChild(el, \"w:numRestart\");\n if (numRestart) {\n const val = attr(numRestart, \"w:val\");\n if (val) opts.numRestart = val;\n }\n\n return opts;\n}\n","import { Relationships, toUint8Array, uniqueUuid } from \"@office-open/core\";\n\n/**\n * Font Wrapper module for WordprocessingML documents.\n *\n * Manages font table relationships for embedded fonts.\n * Pure data container — no XmlComponent dependency.\n *\n * Reference: http://www.datypic.com/sc/ooxml/e-w_fonts.html\n *\n * @module\n */\nimport type { ViewWrapper } from \"../../context\";\nimport type { EmbeddedFontOptions } from \"./font-table\";\n\n/**\n * Font options extended with a unique font key.\n */\nexport type EmbeddedFontOptionsWithKey = EmbeddedFontOptions & {\n fontKey: string;\n /** Relationship id assigned to embedRegular (only fonts carrying data). */\n embedRid?: string;\n /** Normalized font bytes (Uint8Array regardless of the input form). */\n data?: Uint8Array;\n};\n\n/**\n * Wrapper class for managing embedded font relationships.\n *\n * Each embedded font is assigned a unique key for obfuscation.\n * The actual font table XML is generated by `fontTableDesc.stringify()`.\n *\n * @example\n * ```typescript\n * const fontWrapper = new FontWrapper([\n * { name: \"CustomFont\", data: fontBuffer }\n * ]);\n * ```\n */\nexport class FontWrapper implements ViewWrapper {\n public relationships: Relationships;\n public fontOptionsWithKey: EmbeddedFontOptionsWithKey[] = [];\n\n public constructor(public options: EmbeddedFontOptions[]) {\n // Keep every font declaration — metadata-only fonts (no `data`) carry no\n // bytes to embed but must still round-trip into fontTable.xml. Only fonts\n // with binary data receive a fontKey + relationship for the .odttf part.\n this.fontOptionsWithKey = options.map(\n (o): EmbeddedFontOptionsWithKey => ({\n ...o,\n data: o.data !== undefined ? toUint8Array(o.data) : undefined,\n fontKey: o.data !== undefined ? (o.fontKey ?? uniqueUuid()) : (o.fontKey ?? \"\"),\n }),\n );\n this.relationships = new Relationships();\n\n let relIdx = 0;\n for (const font of this.fontOptionsWithKey) {\n if (font.data === undefined) continue;\n relIdx++;\n font.embedRid = `rId${relIdx}`;\n const target = font.odttfPath\n ? font.odttfPath.startsWith(\"word/\")\n ? font.odttfPath.slice(5)\n : font.odttfPath\n : `fonts/${font.name}.odttf`;\n this.relationships.addRelationship(\n relIdx,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font\",\n target,\n );\n }\n }\n}\n","/**\n * Structured Document Tag parser for DOCX documents.\n *\n * Parses w:sdt elements into SdtPropertiesOptions + children.\n *\n * @module\n */\nimport { attr, attrBool, attrNum, children, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n SdtPropertiesOptions,\n SdtListItem,\n SdtDateOptions,\n SdtTextOptions,\n SdtComboBoxOptions,\n SdtDropDownListOptions,\n} from \"@parts/table-of-contents\";\n\nimport type { DocxReadContext } from \"../../context\";\n\n/**\n * Parse w:sdtPr element into SdtPropertiesOptions.\n */\nexport function parseSdtProperties(el: Element): SdtPropertiesOptions {\n const opts: Record<string, unknown> = {};\n\n const alias = findChild(el, \"w:alias\");\n if (alias) opts.alias = attr(alias, \"w:val\");\n\n const tag = findChild(el, \"w:tag\");\n if (tag) {\n const val = attr(tag, \"w:val\");\n if (val) opts.tag = val;\n }\n\n const id = findChild(el, \"w:id\");\n if (id) {\n const val = attrNum(id, \"w:val\");\n if (val !== undefined) opts.id = val;\n }\n\n const lock = findChild(el, \"w:lock\");\n if (lock) {\n const val = attr(lock, \"w:val\");\n if (val) opts.lock = val as SdtPropertiesOptions[\"lock\"];\n }\n\n const temporary = findChild(el, \"w:temporary\");\n if (temporary) opts.temporary = attrBool(temporary, \"w:val\") ?? true;\n\n const showingPlcHdr = findChild(el, \"w:showingPlcHdr\");\n if (showingPlcHdr) opts.showingPlaceholder = attrBool(showingPlcHdr, \"w:val\") ?? true;\n\n const label = findChild(el, \"w:label\");\n if (label) {\n const val = attrNum(label, \"w:val\");\n if (val !== undefined) opts.label = val;\n }\n\n const tabIndex = findChild(el, \"w:tabIndex\");\n if (tabIndex) {\n const val = attrNum(tabIndex, \"w:val\");\n if (val !== undefined) opts.tabIndex = val;\n }\n\n // Data binding\n const dataBinding = findChild(el, \"w:dataBinding\");\n if (dataBinding) {\n opts.dataBinding = {\n xpath: attr(dataBinding, \"w:xpath\") ?? \"\",\n storeItemID: attr(dataBinding, \"w:storeItemID\") ?? \"\",\n prefixMappings: attr(dataBinding, \"w:prefixMappings\"),\n };\n }\n\n // Type discriminators (xsd:choice)\n if (findChild(el, \"w:equation\")) {\n opts.equation = true;\n } else if (findChild(el, \"w:comboBox\")) {\n const comboBox = findChild(el, \"w:comboBox\")!;\n const items: SdtListItem[] = [];\n for (const li of children(comboBox, \"w:listItem\")) {\n items.push({\n displayText: attr(li, \"w:displayText\"),\n value: attr(li, \"w:value\"),\n });\n }\n opts.comboBox = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(comboBox, \"w:lastValue\"),\n } as SdtComboBoxOptions;\n } else if (findChild(el, \"w:date\")) {\n const date = findChild(el, \"w:date\")!;\n const dateOpts: Record<string, unknown> = {};\n const dateFormat = findChild(date, \"w:dateFormat\");\n if (dateFormat) dateOpts.dateFormat = textOf(dateFormat);\n const lid = findChild(date, \"w:lid\");\n if (lid) dateOpts.languageId = textOf(lid);\n const storeMapped = findChild(date, \"w:storeMappedDataAs\");\n if (storeMapped) dateOpts.storeMappedDataAs = attr(storeMapped, \"w:val\");\n const calendar = findChild(date, \"w:calendar\");\n if (calendar) dateOpts.calendar = attr(calendar, \"w:val\");\n const fullDate = attr(date, \"w:fullDate\");\n if (fullDate) dateOpts.fullDate = fullDate;\n opts.date = dateOpts as SdtDateOptions;\n } else if (findChild(el, \"w:dropDownList\")) {\n const ddl = findChild(el, \"w:dropDownList\")!;\n const items: SdtListItem[] = [];\n for (const li of children(ddl, \"w:listItem\")) {\n items.push({\n displayText: attr(li, \"w:displayText\"),\n value: attr(li, \"w:value\"),\n });\n }\n opts.dropDownList = {\n items: items.length > 0 ? items : undefined,\n lastValue: attr(ddl, \"w:lastValue\"),\n } as SdtDropDownListOptions;\n } else if (findChild(el, \"w:picture\")) {\n opts.picture = true;\n } else if (findChild(el, \"w:richText\")) {\n opts.richText = true;\n } else if (findChild(el, \"w:text\")) {\n const text = findChild(el, \"w:text\")!;\n opts.text = {\n multiLine: attrBool(text, \"w:multiLine\"),\n } as SdtTextOptions;\n } else if (findChild(el, \"w:citation\")) {\n opts.citation = true;\n } else if (findChild(el, \"w:group\")) {\n opts.group = true;\n } else if (findChild(el, \"w:bibliography\")) {\n opts.bibliography = true;\n } else if (findChild(el, \"w:docPartObj\")) {\n const dp = findChild(el, \"w:docPartObj\")!;\n opts.docPartObj = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) (opts.docPartObj as Record<string, unknown>).gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) (opts.docPartObj as Record<string, unknown>).category = attr(category, \"w:val\");\n } else if (findChild(el, \"w:docPartList\")) {\n const dp = findChild(el, \"w:docPartList\")!;\n opts.docPartList = {};\n const gallery = findChild(dp, \"w:docPartGallery\");\n if (gallery) (opts.docPartList as Record<string, unknown>).gallery = attr(gallery, \"w:val\");\n const category = findChild(dp, \"w:docPartCategory\");\n if (category) (opts.docPartList as Record<string, unknown>).category = attr(category, \"w:val\");\n } else if (findChild(el, \"w14:checkbox\")) {\n const cb = findChild(el, \"w14:checkbox\")!;\n const cbObj: Record<string, unknown> = {};\n const checked = findChild(cb, \"w14:checked\");\n if (checked) cbObj.checked = attrBool(checked, \"w14:val\") ?? true;\n const checkedState = findChild(cb, \"w14:checkedState\");\n if (checkedState)\n cbObj.checkedState = {\n val: attr(checkedState, \"w14:val\") ?? \"\",\n font: attr(checkedState, \"w14:font\"),\n };\n const uncheckedState = findChild(cb, \"w14:uncheckedState\");\n if (uncheckedState)\n cbObj.uncheckedState = {\n val: attr(uncheckedState, \"w14:val\") ?? \"\",\n font: attr(uncheckedState, \"w14:font\"),\n };\n opts.checkbox = cbObj;\n }\n\n return opts as SdtPropertiesOptions;\n}\n\n/**\n * Parse a block-level w:sdt element.\n * Returns an object suitable for the { sdt: ... } SectionChild variant.\n */\nexport function parseSdtBlock(\n el: Element,\n ctx: DocxReadContext,\n parseChildren: (elements: Element[], ctx: DocxReadContext) => unknown[],\n): {\n properties: SdtPropertiesOptions;\n children?: unknown[];\n} {\n const sdtPr = findChild(el, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n\n const sdtContent = findChild(el, \"w:sdtContent\");\n let childList: unknown[] | undefined;\n if (sdtContent) {\n childList = parseChildren(sdtContent.elements ?? [], ctx);\n if (childList.length === 0) childList = undefined;\n }\n\n return { properties, children: childList };\n}\n","/**\n * Table of Contents stringifier for DOCX.\n *\n * Produces `<w:sdt>` XML containing a TOC field code, replacing\n * `new TableOfContents(alias, options).toXml(ctx)` with direct\n * string concatenation — zero XmlComponent instances.\n *\n * @module\n */\n\nimport { escapeXml } from \"@office-open/xml\";\nimport type { TableOfContentsOptions } from \"@parts/table-of-contents/table-of-contents-properties\";\n\n// ── Field instruction string ──\n\nfunction tocInstructionStr(opts: TableOfContentsOptions): string {\n let instr = \"TOC\";\n\n if (opts.captionLabel) instr += ` \\\\a \"${opts.captionLabel}\"`;\n if (opts.entriesFromBookmark) instr += ` \\\\b \"${opts.entriesFromBookmark}\"`;\n if (opts.captionLabelIncludingNumbers) instr += ` \\\\c \"${opts.captionLabelIncludingNumbers}\"`;\n if (opts.sequenceAndPageNumbersSeparator)\n instr += ` \\\\d \"${opts.sequenceAndPageNumbersSeparator}\"`;\n if (opts.tcFieldIdentifier) instr += ` \\\\f \"${opts.tcFieldIdentifier}\"`;\n if (opts.hyperlink) instr += \" \\\\h\";\n if (opts.tcFieldLevelRange) instr += ` \\\\l \"${opts.tcFieldLevelRange}\"`;\n if (opts.pageNumbersEntryLevelsRange) instr += ` \\\\n \"${opts.pageNumbersEntryLevelsRange}\"`;\n if (opts.headingStyleRange) instr += ` \\\\o \"${opts.headingStyleRange}\"`;\n if (opts.entryAndPageNumberSeparator) instr += ` \\\\p \"${opts.entryAndPageNumberSeparator}\"`;\n if (opts.seqFieldIdentifierForPrefix) instr += ` \\\\s \"${opts.seqFieldIdentifierForPrefix}\"`;\n if (opts.stylesWithLevels?.length) {\n const styles = opts.stylesWithLevels.map((sl) => `${sl.styleName},${sl.level}`).join(\",\");\n instr += ` \\\\t \"${styles}\"`;\n }\n if (opts.useAppliedParagraphOutlineLevel) instr += \" \\\\u\";\n if (opts.preserveTabInEntries) instr += \" \\\\w\";\n if (opts.preserveNewLineInEntries) instr += \" \\\\x\";\n if (opts.hideTabAndPageNumbersInWebView) instr += \" \\\\z\";\n\n return instr;\n}\n\n// ── Main stringifier ──\n\nexport function stringifyTableOfContents(\n alias: string = \"Table of Contents\",\n options: TableOfContentsOptions = {},\n entriesXml: string = \"\",\n): string {\n const instr = tocInstructionStr(options);\n const aliasAttr = alias ? ` w:val=\"${escapeXml(alias)}\"` : \"\";\n\n // When the rendered entries are carried (round-trip), emit the field clean so\n // both MS Office and WPS display the existing TOC without an update prompt.\n // A freshly generated TOC carries no entries — mark it dirty so the consuming\n // application builds them from headings on open.\n const dirtyAttr = entriesXml.length > 0 ? \"\" : ' w:dirty=\"1\"';\n\n // Word shares the field-head control runs (begin/instr/separate) with the\n // first rendered entry's paragraph and the field-end run with the last,\n // rather than emitting standalone control-only paragraphs — those have no\n // w:t and render as blank lines above and below the TOC. So when entries are\n // carried we inject head into the first entry paragraph and end into the\n // last; a freshly generated TOC (no entries) keeps standalone head/end\n // paragraphs since it is dirty and rebuilt on open.\n const headRuns =\n `<w:r><w:rPr><w:rFonts w:asciiTheme=\"majorHAnsi\" w:cstheme=\"majorEastAsia\" w:hAnsiTheme=\"majorHAnsi\" w:cs=\"Times New Roman\"/></w:rPr><w:fldChar w:fldCharType=\"begin\"${dirtyAttr}/></w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instr} </w:instrText></w:r>` +\n `<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>`;\n const endRun = `<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>`;\n const endParagraph = `<w:p>${endRun}</w:p>`;\n\n const body = entriesXml\n ? injectFieldEnd(injectFieldHead(entriesXml, headRuns), endRun)\n : `<w:p>${headRuns}</w:p>` + endParagraph;\n\n // SDT properties: alias + docPartObj\n const sdtPr =\n `<w:sdtPr>` +\n `<w:alias${aliasAttr}/>` +\n `<w:docPartObj><w:docPartGallery w:val=\"Table of Contents\"/></w:docPartObj>` +\n `</w:sdtPr>`;\n\n const content = `<w:sdtContent>${body}</w:sdtContent>`;\n\n return `<w:sdt>${sdtPr}${content}</w:sdt>`;\n}\n\n/**\n * Inject the field-head runs into the first `<w:p>` of `entriesXml`, placing\n * them after the opening tag (and after `<w:pPr>` when present) so the head\n * shares the first entry's paragraph. Returns `entriesXml` unchanged when no\n * `<w:p>` is found.\n */\nfunction injectFieldHead(entriesXml: string, headRuns: string): string {\n const pTagStart = entriesXml.search(/<w:p[ >]/);\n if (pTagStart < 0) return entriesXml;\n const pTagEnd = entriesXml.indexOf(\">\", pTagStart) + 1;\n let injectAt = pTagEnd;\n if (entriesXml.slice(pTagEnd, pTagEnd + 7) === \"<w:pPr>\") {\n const pPrEnd = entriesXml.indexOf(\"</w:pPr>\", pTagEnd);\n if (pPrEnd >= 0) injectAt = pPrEnd + \"</w:pPr>\".length;\n }\n return entriesXml.slice(0, injectAt) + headRuns + entriesXml.slice(injectAt);\n}\n\n/**\n * Inject the field-end run into the last `<w:p>` of `entriesXml` (before its\n * closing `</w:p>`) so the end shares the last entry's paragraph instead of\n * occupying a standalone control-only paragraph that renders as a blank line.\n * Returns `entriesXml` unchanged when no `</w:p>` is found.\n */\nfunction injectFieldEnd(entriesXml: string, endRun: string): string {\n const lastClose = entriesXml.lastIndexOf(\"</w:p>\");\n if (lastClose < 0) return entriesXml;\n return entriesXml.slice(0, lastClose) + endRun + entriesXml.slice(lastClose);\n}\n","/**\n * VML shape module for WordprocessingML documents.\n *\n * Provides the VmlShapeStyle type and style-to-key mapping used by compile/\n * and parse paths. Runtime shape construction has been migrated to the\n * descriptor pipeline.\n *\n * References:\n * - https://c-rex.net/samples/ooxml/e1/Part3/OOXML_P3_Primer_OfficeArt_topic_ID0ELU5O.html\n * - http://webapp.docx4java.org/OnlineDemo/ecma376/VML/shape.html\n *\n * @module\n */\nimport type { LengthUnit } from \"../types\";\n\n/**\n * Maps VmlShapeStyle property names to their corresponding CSS-style property names.\n * Used internally for converting TypeScript-friendly property names to VML style attributes.\n */\nexport const styleToKeyMap: Record<keyof VmlShapeStyle, string> = {\n flip: \"flip\",\n height: \"height\",\n left: \"left\",\n marginBottom: \"margin-bottom\",\n marginLeft: \"margin-left\",\n marginRight: \"margin-right\",\n marginTop: \"margin-top\",\n position: \"position\",\n positionHorizontal: \"mso-position-horizontal\",\n positionHorizontalRelative: \"mso-position-horizontal-relative\",\n positionVertical: \"mso-position-vertical\",\n positionVerticalRelative: \"mso-position-vertical-relative\",\n rotation: \"rotation\",\n top: \"top\",\n visibility: \"visibility\",\n width: \"width\",\n wrapDistanceBottom: \"mso-wrap-distance-bottom\",\n wrapDistanceLeft: \"mso-wrap-distance-left\",\n wrapDistanceRight: \"mso-wrap-distance-right\",\n wrapDistanceTop: \"mso-wrap-distance-top\",\n wrapEdited: \"mso-wrap-edited\",\n wrapStyle: \"mso-wrap-style\",\n zIndex: \"z-index\",\n};\n\n/**\n * VML shape styling properties for WordprocessingML documents.\n *\n * These properties map to CSS-style attributes on VML shape elements and control\n * the shape's appearance, layout, and interaction with surrounding text.\n */\nexport interface VmlShapeStyle {\n /** Specifies that the orientation of a shape is flipped. Default is no value. */\n flip?: \"x\" | \"y\" | \"xy\" | \"yx\";\n /** Specifies the height of the containing block of the shape. Default is 0. */\n height?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the element left of it. Default is 0. */\n left?: LengthUnit;\n /** Specifies the position of the bottom of the containing block relative to the shape anchor. Default is 0. */\n marginBottom?: LengthUnit;\n /** Specifies the position of the left of the containing block relative to the shape anchor. Default is 0. */\n marginLeft?: LengthUnit;\n /** Specifies the position of the right of the containing block relative to the shape anchor. Default is 0. */\n marginRight?: LengthUnit;\n /** Specifies the position of the top of the containing block relative to the shape anchor. Default is 0. */\n marginTop?: LengthUnit;\n /** Specifies the horizontal positioning data. Default is absolute. */\n positionHorizontal?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative horizontal position data. Default is text. */\n positionHorizontalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the vertical positioning data. Default is absolute. */\n positionVertical?: \"absolute\" | \"left\" | \"center\" | \"right\" | \"inside\" | \"outside\";\n /** Specifies relative vertical position data. Default is text. */\n positionVerticalRelative?: \"margin\" | \"page\" | \"text\" | \"char\";\n /** Specifies the distance from the bottom of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceBottom?: number;\n /** Specifies the distance from the left side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceLeft?: number;\n /** Specifies the distance from the right side of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceRight?: number;\n /** Specifies the distance from the top of the shape to the text that wraps around it. Default is 0 pt. */\n wrapDistanceTop?: number;\n /** Specifies whether the wrap coordinates were customized by the user. Default is false. */\n wrapEdited?: boolean;\n /** Specifies the wrapping mode for text in shapes. Default is square. */\n wrapStyle?: \"square\" | \"none\";\n /** Specifies the type of positioning used to place an element. Default is static. */\n position?: \"static\" | \"absolute\" | \"relative\";\n /** Specifies the angle that a shape is rotated, in degrees. Default is 0. */\n rotation?: number;\n /** Specifies the position of the top of the containing block. Default is 0. */\n top?: LengthUnit;\n /** Specifies whether a shape is displayed. Default is inherit. */\n visibility?: \"hidden\" | \"inherit\";\n /** Specifies the width of the containing block of the shape. Default is 0. */\n width: LengthUnit;\n /** Specifies the display order of overlapping shapes. Default is 0. */\n zIndex?: \"auto\" | number;\n}\n","/**\n * Direct XML string builders for Office MathML (OMML).\n *\n * Replaces `coerceMathInput()` + `new Math().toXml()` recursive class chain\n * with direct string concatenation — zero XmlComponent instances.\n *\n * Processes `MathInput` discriminated union directly to XML strings.\n *\n * @module\n */\n\nimport { attr, children, escapeXml, findChild, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type {\n MathDelimiterProperties,\n MathInput,\n MathNaryProperties,\n MathRunPropertiesOptions,\n} from \"@parts/paragraph/math\";\n\n// ── MathRun properties ──\n\nfunction mathRunPropsStr(opts: MathRunPropertiesOptions): string {\n const parts: string[] = [];\n if (opts.lit) parts.push('<m:lit m:val=\"1\"/>');\n if (opts.normal) parts.push('<m:nor m:val=\"1\"/>');\n if (opts.script) parts.push(`<m:scr m:val=\"${opts.script}\"/>`);\n if (opts.style) parts.push(`<m:sty m:val=\"${opts.style}\"/>`);\n if (opts.breakAlignment) parts.push(`<m:brk m:alnAt=\"${opts.breakAlignment}\"/>`);\n if (opts.align) parts.push('<m:aln m:val=\"1\"/>');\n return parts.length ? `<m:rPr>${parts.join(\"\")}</m:rPr>` : \"\";\n}\n\n// ── Children array ──\n\nfunction stringifyChildren(items: MathInput[]): string {\n return items.map(stringifyMathInput).join(\"\");\n}\n\n// ── Main recursive stringifier ──\n\nexport function stringifyMathInput(value: MathInput): string {\n // String → MathRun shorthand\n if (typeof value === \"string\") {\n return `<m:r><m:t>${escapeXml(value)}</m:t></m:r>`;\n }\n\n // Class instances — still need toXml (shouldn't happen in compile/ JSON path)\n if (typeof value !== \"object\" || value === null) return \"\";\n\n // Discriminated union: check unique keys (order matters — subSuperScript first)\n if (\"subSuperScript\" in value) {\n const opts = value.subSuperScript;\n const pr = opts.alignScript\n ? '<m:sSubSupPr><m:alnScr m:val=\"1\"/></m:sSubSupPr>'\n : \"<m:sSubSupPr/>\";\n return `<m:sSubSup>${pr}<m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSubSup>`;\n }\n\n if (\"preSubSuperScript\" in value) {\n const opts = value.preSubSuperScript;\n return `<m:sPre><m:sPrePr/><m:sub>${stringifyChildren(opts.subScript)}</m:sub><m:sup>${stringifyChildren(opts.superScript)}</m:sup><m:e>${stringifyChildren(opts.children)}</m:e></m:sPre>`;\n }\n\n if (\"superScript\" in value) {\n const opts = value.superScript;\n return `<m:sSup><m:sSupPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sup>${stringifyChildren(opts.superScript)}</m:sup></m:sSup>`;\n }\n\n if (\"subScript\" in value) {\n const opts = value.subScript;\n return `<m:sSub><m:sSubPr/><m:e>${stringifyChildren(opts.children)}</m:e><m:sub>${stringifyChildren(opts.subScript)}</m:sub></m:sSub>`;\n }\n\n if (\"fraction\" in value) {\n const opts = value.fraction;\n const pr = opts.fractionType ? `<m:fPr><m:type m:val=\"${opts.fractionType}\"/></m:fPr>` : \"\";\n const numArgPr = argPrXml(opts.numeratorArgumentSize);\n const denArgPr = argPrXml(opts.denominatorArgumentSize);\n return `<m:f>${pr}<m:num>${numArgPr}${stringifyChildren(opts.numerator)}</m:num><m:den>${denArgPr}${stringifyChildren(opts.denominator)}</m:den></m:f>`;\n }\n\n if (\"radical\" in value) {\n const opts = value.radical;\n const hasDegree = opts.degree && opts.degree.length > 0;\n const pr = !hasDegree ? '<m:radPr><m:degHide m:val=\"1\"/></m:radPr>' : \"<m:radPr/>\";\n const deg = hasDegree ? `<m:deg>${stringifyChildren(opts.degree!)}</m:deg>` : \"<m:deg/>\";\n return `<m:rad>${pr}${deg}<m:e>${stringifyChildren(opts.children)}</m:e></m:rad>`;\n }\n\n if (\"sum\" in value) {\n return stringifyNAry(value.sum, \"∑\");\n }\n\n if (\"integral\" in value) {\n return stringifyNAry(value.integral, \"∫\");\n }\n\n if (\"limitLower\" in value) {\n const opts = value.limitLower;\n return `<m:limLow><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limLow>`;\n }\n\n if (\"limitUpper\" in value) {\n const opts = value.limitUpper;\n return `<m:limUpp><m:e>${stringifyChildren(opts.children)}</m:e><m:lim>${stringifyChildren(opts.limit)}</m:lim></m:limUpp>`;\n }\n\n if (\"function\" in value) {\n const opts = value.function;\n return `<m:func><m:fName>${stringifyChildren(opts.name)}</m:fName><m:e>${stringifyChildren(opts.children)}</m:e></m:func>`;\n }\n\n if (\"matrix\" in value) {\n const opts = value.matrix;\n const rows = opts.rows\n .map(\n (row) =>\n `<m:mr>${row.map((cell) => `<m:e>${stringifyMathInput(cell)}</m:e>`).join(\"\")}</m:mr>`,\n )\n .join(\"\");\n // Matrix properties are complex — emit basic structure only when needed\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const prParts: string[] = [];\n if (p.baseJc) prParts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.plcHide) prParts.push('<m:plcHide m:val=\"1\"/>');\n if (p.rSpRule) prParts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.cGpRule) prParts.push(`<m:cGpRule m:val=\"${p.cGpRule as string}\"/>`);\n if (p.rSp) prParts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (p.cSp) prParts.push(`<m:cSp m:val=\"${p.cSp as string}\"/>`);\n if (p.cGp) prParts.push(`<m:cGp m:val=\"${p.cGp as string}\"/>`);\n if (p.mcs) {\n const mcItems = (p.mcs as Array<{ count: number; mcJc: string }>)\n .map(\n (mc) =>\n `<m:mc><m:mcPr><m:count m:val=\"${mc.count}\"/><m:mcJc m:val=\"${mc.mcJc}\"/></m:mcPr></m:mc>`,\n )\n .join(\"\");\n prParts.push(`<m:mcs>${mcItems}</m:mcs>`);\n }\n if (prParts.length) pr = `<m:mPr>${prParts.join(\"\")}</m:mPr>`;\n }\n return `<m:m>${pr}${rows}</m:m>`;\n }\n\n // Bracket types\n if (\"roundBrackets\" in value) {\n const spec = bracketSpec(value.roundBrackets);\n return stringifyDelimiters(spec.children, \"(\", \")\", spec.properties);\n }\n if (\"curlyBrackets\" in value) {\n const spec = bracketSpec(value.curlyBrackets);\n return stringifyDelimiters(spec.children, \"{\", \"}\", spec.properties);\n }\n if (\"angledBrackets\" in value) {\n const spec = bracketSpec(value.angledBrackets);\n return stringifyDelimiters(spec.children, \"〈\", \"〉\", spec.properties);\n }\n if (\"squareBrackets\" in value) {\n const spec = bracketSpec(value.squareBrackets);\n return stringifyDelimiters(spec.children, \"[\", \"]\", spec.properties);\n }\n\n if (\"borderBox\" in value) {\n const opts = value.borderBox;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.hideTop) parts.push('<m:hideTop m:val=\"1\"/>');\n if (p.hideBottom) parts.push('<m:hideBot m:val=\"1\"/>');\n if (p.hideLeft) parts.push('<m:hideLeft m:val=\"1\"/>');\n if (p.hideRight) parts.push('<m:hideRight m:val=\"1\"/>');\n if (p.strikeHorizontal) parts.push('<m:strikeH m:val=\"1\"/>');\n if (p.strikeVertical) parts.push('<m:strikeV m:val=\"1\"/>');\n if (p.strikeDiagonalUp) parts.push('<m:strikeBLTR m:val=\"1\"/>');\n if (p.strikeDiagonalDown) parts.push('<m:strikeTLBR m:val=\"1\"/>');\n if (parts.length) pr = `<m:borderBoxPr>${parts.join(\"\")}</m:borderBoxPr>`;\n }\n return `<m:borderBox>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:borderBox>`;\n }\n\n if (\"box\" in value) {\n const opts = value.box;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.opEmu) parts.push('<m:opEmu m:val=\"1\"/>');\n if (p.noBreak) parts.push('<m:noBreak m:val=\"1\"/>');\n if (p.diff) parts.push('<m:diff m:val=\"1\"/>');\n if (p.aln) parts.push('<m:aln m:val=\"1\"/>');\n if (parts.length) pr = `<m:boxPr>${parts.join(\"\")}</m:boxPr>`;\n }\n return `<m:box>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:box>`;\n }\n\n if (\"groupChr\" in value) {\n const opts = value.groupChr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.chr) parts.push(`<m:chr m:val=\"${p.chr as string}\"/>`);\n if (p.pos) parts.push(`<m:pos m:val=\"${p.pos as string}\"/>`);\n if (p.vertJc) parts.push(`<m:vertJc m:val=\"${p.vertJc as string}\"/>`);\n if (parts.length) pr = `<m:groupChrPr>${parts.join(\"\")}</m:groupChrPr>`;\n }\n return `<m:groupChr>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:groupChr>`;\n }\n\n if (\"phant\" in value) {\n const opts = value.phant;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.show !== undefined) parts.push(`<m:show m:val=\"${p.show ? 1 : 0}\"/>`);\n if (p.zeroWid) parts.push('<m:zeroWid m:val=\"1\"/>');\n if (p.zeroAsc) parts.push('<m:zeroAsc m:val=\"1\"/>');\n if (p.zeroDesc) parts.push('<m:zeroDesc m:val=\"1\"/>');\n if (p.transp) parts.push('<m:transp m:val=\"1\"/>');\n if (parts.length) pr = `<m:phantPr>${parts.join(\"\")}</m:phantPr>`;\n }\n return `<m:phant>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:phant>`;\n }\n\n if (\"eqArr\" in value) {\n const opts = value.eqArr;\n let pr = \"\";\n if (opts.properties) {\n const p = opts.properties;\n const parts: string[] = [];\n if (p.baseJc) parts.push(`<m:baseJc m:val=\"${p.baseJc as string}\"/>`);\n if (p.maxDist) parts.push('<m:maxDist m:val=\"1\"/>');\n if (p.objDist) parts.push('<m:objDist m:val=\"1\"/>');\n if (p.rSpRule) parts.push(`<m:rSpRule m:val=\"${p.rSpRule as string}\"/>`);\n if (p.rSp) parts.push(`<m:rSp m:val=\"${p.rSp as string}\"/>`);\n if (parts.length) pr = `<m:eqArrPr>${parts.join(\"\")}</m:eqArrPr>`;\n }\n const rows = opts.rows.map((row) => `<m:e>${stringifyChildren(row)}</m:e>`).join(\"\");\n return `<m:eqArr>${pr}${rows}</m:eqArr>`;\n }\n\n if (\"accent\" in value) {\n const opts = value.accent;\n const pr = opts.accentCharacter\n ? `<m:accPr><m:chr m:val=\"${opts.accentCharacter}\"/></m:accPr>`\n : \"\";\n return `<m:acc>${pr}<m:e>${stringifyChildren(opts.children)}</m:e></m:acc>`;\n }\n\n if (\"bar\" in value) {\n const opts = value.bar;\n return `<m:bar><m:barPr><m:pos m:val=\"${opts.type}\"/></m:barPr><m:e>${stringifyChildren(opts.children)}</m:e></m:bar>`;\n }\n\n // Fallback: { text: string; properties?: ... } → MathRun\n if (\"text\" in value) {\n const props = value.properties ? mathRunPropsStr(value.properties) : \"\";\n return `<m:r>${props}<m:t>${escapeXml(value.text)}</m:t></m:r>`;\n }\n\n return \"\";\n}\n\n// ── N-ary operator (sum/integral) ──\n\nfunction stringifyNAry(\n opts: {\n children: MathInput[];\n subScript?: MathInput[];\n superScript?: MathInput[];\n properties?: MathNaryProperties;\n },\n chr: string,\n): string {\n const hasSub = opts.subScript && opts.subScript.length > 0;\n const hasSup = opts.superScript && opts.superScript.length > 0;\n const prParts: string[] = [`<m:chr m:val=\"${chr}\"/>`];\n if (opts.properties?.limitLocation)\n prParts.push(`<m:limLoc m:val=\"${opts.properties.limitLocation}\"/>`);\n if (opts.properties?.grow !== undefined)\n prParts.push(`<m:grow m:val=\"${opts.properties.grow ? 1 : 0}\"/>`);\n if (!hasSub) prParts.push('<m:subHide m:val=\"1\"/>');\n if (!hasSup) prParts.push('<m:supHide m:val=\"1\"/>');\n const pr = `<m:naryPr>${prParts.join(\"\")}</m:naryPr>`;\n const sub = hasSub ? `<m:sub>${stringifyChildren(opts.subScript!)}</m:sub>` : \"<m:sub/>\";\n const sup = hasSup ? `<m:sup>${stringifyChildren(opts.superScript!)}</m:sup>` : \"<m:sup/>\";\n return `<m:nary>${pr}${sub}${sup}<m:e>${stringifyChildren(opts.children)}</m:e></m:nary>`;\n}\n\n// ── Delimiters (brackets) ──\n\nfunction stringifyDelimiters(\n children: MathInput[],\n begChr: string,\n endChr: string,\n properties?: MathDelimiterProperties,\n): string {\n const prParts: string[] = [`<m:begChr m:val=\"${properties?.beginCharacter ?? begChr}\"/>`];\n if (properties?.separatorCharacter)\n prParts.push(`<m:sepChr m:val=\"${properties.separatorCharacter}\"/>`);\n prParts.push(`<m:endChr m:val=\"${properties?.endCharacter ?? endChr}\"/>`);\n if (properties?.grow !== undefined) prParts.push(`<m:grow m:val=\"${properties.grow ? 1 : 0}\"/>`);\n if (properties?.shape) prParts.push(`<m:shp m:val=\"${properties.shape}\"/>`);\n return `<m:d><m:dPr>${prParts.join(\"\")}</m:dPr><m:e>${stringifyChildren(children)}</m:e></m:d>`;\n}\n\n/** Build an m:argPr/m:argSz block for an argument size scaling value. */\nfunction argPrXml(size: number | undefined): string {\n return size !== undefined ? `<m:argPr><m:argSz m:val=\"${size}\"/></m:argPr>` : \"\";\n}\n\n/** Split a bracket shorthand into children + optional delimiter properties. */\nfunction bracketSpec(\n v: MathInput[] | { children: MathInput[]; properties?: MathDelimiterProperties },\n): {\n children: MathInput[];\n properties?: MathDelimiterProperties;\n} {\n if (Array.isArray(v)) return { children: v };\n return { children: v.children, properties: v.properties };\n}\n\n// ── Top-level Math wrapper ──\n\nexport function stringifyMath(children: MathInput[]): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n return `<m:oMath>${inner}</m:oMath>`;\n}\n\nexport function stringifyMathParagraph(\n children: MathInput[],\n justification?: \"left\" | \"right\" | \"center\" | \"centerGroup\",\n): string {\n const inner = children.map((c) => stringifyMathInput(c)).join(\"\");\n const pr = justification ? `<m:oMathParaPr><m:jc m:val=\"${justification}\"/></m:oMathParaPr>` : \"\";\n return `<m:oMathPara>${pr}<m:oMath>${inner}</m:oMath></m:oMathPara>`;\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (OMML XML → MathInput)\n// ────────────────────────────────────────────────────────────────────────────────\n\n/**\n * Parse all math children from an m:oMath (or similar container) element.\n */\nexport function parseMathChildren(el: Element): MathInput[] {\n const result: MathInput[] = [];\n for (const child of el.elements ?? []) {\n const parsed = parseMathElement(child);\n if (parsed !== undefined) result.push(parsed);\n }\n return result;\n}\n\nfunction parseMathElement(el: Element): MathInput | undefined {\n switch (el.name) {\n case \"m:r\":\n return parseMathRun(el);\n case \"m:f\":\n return parseMathFraction(el);\n case \"m:rad\":\n return parseMathRadical(el);\n case \"m:sSup\":\n return parseMathSuperScript(el);\n case \"m:sSub\":\n return parseMathSubScript(el);\n case \"m:sSubSup\":\n return parseMathSubSuperScript(el);\n case \"m:nary\":\n return parseMathNAry(el);\n case \"m:func\":\n return parseMathFunction(el);\n case \"m:d\":\n return parseMathDelimiter(el);\n case \"m:m\":\n return parseMathMatrix(el);\n case \"m:acc\":\n return parseMathAccent(el);\n case \"m:bar\":\n return parseMathBar(el);\n case \"m:borderBox\":\n return { borderBox: { children: parseMathArg(el, \"m:e\") } };\n case \"m:box\":\n return { box: { children: parseMathArg(el, \"m:e\") } };\n case \"m:groupChr\":\n return { groupChr: { children: parseMathArg(el, \"m:e\") } };\n case \"m:phant\":\n return { phant: { children: parseMathArg(el, \"m:e\") } };\n case \"m:eqArr\":\n return parseMathEqArr(el);\n case \"m:limLow\":\n return parseMathLimitLower(el);\n case \"m:limUpp\":\n return parseMathLimitUpper(el);\n // Property elements — not standalone content\n case \"m:rPr\":\n case \"m:fPr\":\n case \"m:radPr\":\n case \"m:sSupPr\":\n case \"m:sSubPr\":\n case \"m:sSubSupPr\":\n case \"m:naryPr\":\n case \"m:funcPr\":\n case \"m:dPr\":\n case \"m:mPr\":\n case \"m:accPr\":\n case \"m:barPr\":\n case \"m:borderBoxPr\":\n case \"m:boxPr\":\n case \"m:groupChrPr\":\n case \"m:phantPr\":\n case \"m:eqArrPr\":\n case \"m:limLowPr\":\n case \"m:limUppPr\":\n case \"m:ctrlPr\":\n return undefined;\n default:\n return undefined;\n }\n}\n\nfunction parseMathRun(el: Element): MathInput {\n const text = textOf(findChild(el, \"m:t\"));\n return text ?? \"\";\n}\n\n// ── Parse helpers ──\n\n/** Read an m:val on/off attribute (1/0/true/false; empty element = on). */\nfunction readOnOff(el: Element | undefined): boolean | undefined {\n if (!el) return undefined;\n const v = attr(el, \"m:val\");\n return v === undefined ? true : v === \"1\" || v === \"true\" || v === \"on\";\n}\n\n/** Read an m:val numeric attribute. */\nfunction readNum(el: Element | undefined): number | undefined {\n if (!el) return undefined;\n const v = attr(el, \"m:val\");\n if (v === undefined || v === \"\") return undefined;\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n\n/** Read an m:argSz scaling value from an m:argPr-bearing argument element. */\nfunction readArgSize(argEl: Element | undefined): number | undefined {\n if (!argEl) return undefined;\n return readNum(findChild(argEl, \"m:argSz\"));\n}\n\nfunction parseMathFraction(el: Element): MathInput {\n const numeratorArgumentSize = readArgSize(findChild(el, \"m:num\"));\n const denominatorArgumentSize = readArgSize(findChild(el, \"m:den\"));\n return {\n fraction: {\n numerator: parseMathArg(el, \"m:num\"),\n denominator: parseMathArg(el, \"m:den\"),\n ...(numeratorArgumentSize !== undefined ? { numeratorArgumentSize } : {}),\n ...(denominatorArgumentSize !== undefined ? { denominatorArgumentSize } : {}),\n },\n };\n}\n\nfunction parseMathRadical(el: Element): MathInput {\n const degree = parseMathArg(el, \"m:deg\");\n const mathChildren = parseMathArg(el, \"m:e\");\n return {\n radical: {\n children: mathChildren,\n ...(degree.length > 0 ? { degree } : {}),\n },\n };\n}\n\nfunction parseMathSuperScript(el: Element): MathInput {\n return {\n superScript: {\n children: parseMathArg(el, \"m:e\"),\n superScript: parseMathArg(el, \"m:sup\"),\n },\n };\n}\n\nfunction parseMathSubScript(el: Element): MathInput {\n return {\n subScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n },\n };\n}\n\nfunction parseMathSubSuperScript(el: Element): MathInput {\n const pr = findChild(el, \"m:sSubSupPr\");\n const alignScript = pr ? readOnOff(findChild(pr, \"m:alnScr\")) : undefined;\n return {\n subSuperScript: {\n children: parseMathArg(el, \"m:e\"),\n subScript: parseMathArg(el, \"m:sub\"),\n superScript: parseMathArg(el, \"m:sup\"),\n ...(alignScript !== undefined ? { alignScript } : {}),\n },\n };\n}\n\nfunction parseMathNAry(el: Element): MathInput {\n const naryPr = findChild(el, \"m:naryPr\");\n const chrEl = naryPr ? findChild(naryPr, \"m:chr\") : undefined;\n const chrVal = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n const baseChildren = parseMathArg(el, \"m:e\");\n const sub = parseMathArg(el, \"m:sub\");\n const sup = parseMathArg(el, \"m:sup\");\n\n const properties: MathNaryProperties = {};\n if (naryPr) {\n const limLocEl = findChild(naryPr, \"m:limLoc\");\n if (limLocEl) {\n const limLoc = attr(limLocEl, \"m:val\");\n if (limLoc === \"subSup\" || limLoc === \"undOvr\") properties.limitLocation = limLoc;\n }\n const grow = readOnOff(findChild(naryPr, \"m:grow\"));\n if (grow !== undefined) properties.grow = grow;\n }\n\n const common = {\n children: baseChildren,\n ...(sub.length > 0 ? { subScript: sub } : {}),\n ...(sup.length > 0 ? { superScript: sup } : {}),\n ...(Object.keys(properties).length > 0 ? { properties } : {}),\n };\n\n if (chrVal === \"∑\") return { sum: common };\n return { integral: common };\n}\n\nfunction parseMathFunction(el: Element): MathInput {\n return {\n function: {\n name: parseMathArg(el, \"m:fName\"),\n children: parseMathArg(el, \"m:e\"),\n },\n };\n}\n\nfunction parseMathDelimiter(el: Element): MathInput {\n const dPr = findChild(el, \"m:dPr\");\n const begChrEl = dPr ? findChild(dPr, \"m:begChr\") : undefined;\n const begChr = begChrEl ? attr(begChrEl, \"m:val\") : \"(\";\n const mathChildren = parseMathArg(el, \"m:e\");\n\n // Collect delimiter properties when present (sepChr/grow/shp/non-default chars).\n const properties: MathDelimiterProperties = {};\n if (dPr) {\n if (begChrEl) properties.beginCharacter = begChr;\n const endChrEl = findChild(dPr, \"m:endChr\");\n if (endChrEl) properties.endCharacter = attr(endChrEl, \"m:val\");\n const sepChrEl = findChild(dPr, \"m:sepChr\");\n if (sepChrEl) properties.separatorCharacter = attr(sepChrEl, \"m:val\");\n const grow = readOnOff(findChild(dPr, \"m:grow\"));\n if (grow !== undefined) properties.grow = grow;\n const shpEl = findChild(dPr, \"m:shp\");\n if (shpEl) {\n const shp = attr(shpEl, \"m:val\");\n if (shp === \"centered\" || shp === \"match\") properties.shape = shp;\n }\n }\n const hasProperties = Object.keys(properties).length > 0;\n const value = hasProperties ? { children: mathChildren, properties } : mathChildren;\n\n switch (begChr) {\n case \"[\":\n return { squareBrackets: value };\n case \"{\":\n return { curlyBrackets: value };\n case \"<\":\n case \"⟨\":\n return { angledBrackets: value };\n default:\n return { roundBrackets: value };\n }\n}\n\nfunction parseMathMatrix(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const mr of children(el, \"m:mr\")) {\n rows.push(parseMathArg(mr, \"m:e\"));\n }\n return { matrix: { rows } };\n}\n\nfunction parseMathAccent(el: Element): MathInput {\n const accPr = findChild(el, \"m:accPr\");\n const chrEl = accPr ? findChild(accPr, \"m:chr\") : undefined;\n const accentChar = chrEl ? attr(chrEl, \"m:val\") : undefined;\n\n return {\n accent: {\n children: parseMathArg(el, \"m:e\"),\n ...(accentChar ? { accentCharacter: accentChar } : {}),\n },\n };\n}\n\nfunction parseMathBar(el: Element): MathInput {\n const barPr = findChild(el, \"m:barPr\");\n const posEl = barPr ? findChild(barPr, \"m:pos\") : undefined;\n const pos = posEl ? attr(posEl, \"m:val\") : \"top\";\n\n return {\n bar: {\n children: parseMathArg(el, \"m:e\"),\n type: (pos as \"top\" | \"bot\") ?? \"top\",\n },\n };\n}\n\nfunction parseMathEqArr(el: Element): MathInput {\n const rows: MathInput[][] = [];\n for (const e of children(el, \"m:e\")) {\n rows.push(parseMathChildren(e));\n }\n return { eqArr: { rows } };\n}\n\nfunction parseMathLimitLower(el: Element): MathInput {\n return {\n limitLower: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathLimitUpper(el: Element): MathInput {\n return {\n limitUpper: {\n children: parseMathArg(el, \"m:e\"),\n limit: parseMathArg(el, \"m:lim\"),\n },\n };\n}\n\nfunction parseMathArg(parent: Element, childName: string): MathInput[] {\n const container = findChild(parent, childName);\n if (!container) return [];\n return parseMathChildren(container);\n}\n","/**\n * Replace relationship references in raw XML with `{fileName}` placeholders.\n *\n * Raw-XML passthrough paths (document background, mc:AlternateContent VML\n * fallback) carry VML/structured content verbatim. Their r:id / r:embed /\n * r:link references must be replaced with `{fileName}` placeholders and the\n * referenced media collected, so the compiler's placeholder pass registers the\n * media and resolves the placeholders into relationship ids. Otherwise the\n * carried source rIds dangle — they are not defined in the generated rels and\n * Word rejects the package as unreadable.\n */\nimport type { DocxReadContext } from \"../context\";\nimport type { BackgroundRawMediaOptions } from \"../parts/document/document-background/document-background\";\nimport { imageTypeFromPath } from \"../parts/drawing/drawing-parse\";\n\nconst REL_ATTR_RE = /\\br:(id|embed|link)=\"([^\"]+)\"/g;\n\nexport function replaceRelsWithPlaceholders(\n xml: string,\n ctx: DocxReadContext,\n prefix: string,\n): { rawXml: string; rawMedia: BackgroundRawMediaOptions[] } {\n const rawMedia: BackgroundRawMediaOptions[] = [];\n const rawXml = xml.replace(REL_ATTR_RE, (match, attrName: string, rId: string) => {\n const mediaPath = ctx.resolveRelationship(rId);\n const data = mediaPath ? ctx.getRaw(mediaPath) : undefined;\n if (!mediaPath || !data) return match;\n const type = imageTypeFromPath(mediaPath);\n const fileName = `${prefix}-${rId}.${type}`;\n if (!rawMedia.some((m) => m.fileName === fileName)) {\n rawMedia.push({ fileName, data, type });\n }\n return `r:${attrName}=\"{${fileName}}\"`;\n });\n return { rawXml, rawMedia };\n}\n","/**\n * Body-level stringification for DOCX documents.\n *\n * Converts pure JSON options to XML strings for document body content.\n * Pure string concatenation — no intermediate object tree.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { hexColorValue, uCharHexNumber } from \"@office-open/core\";\nimport { ThemeColor } from \"@office-open/core\";\nimport {\n attr,\n attrBool,\n attrMeasure,\n attrNum,\n escapeXml,\n findChild,\n textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { sectionPropertiesDesc } from \"@parts/document/body/section-properties/descriptor\";\nimport type {\n BackgroundRawMediaOptions,\n DocumentBackgroundOptions,\n} from \"@parts/document/document-background\";\nimport { parseDrawingRun } from \"@parts/drawing/drawing-parse\";\nimport { FontWrapper } from \"@parts/fonts/font-wrapper\";\nimport { objectDesc, type ObjectElementOptions } from \"@parts/object\";\nimport type { BordersOptions } from \"@parts/paragraph/formatting/border\";\nimport type { IndentProperties } from \"@parts/paragraph/formatting/indent\";\nimport { LineRuleType } from \"@parts/paragraph/formatting/spacing\";\nimport type { SpacingProperties } from \"@parts/paragraph/formatting/spacing\";\nimport { HeadingLevel } from \"@parts/paragraph/formatting/style\";\nimport type { TabStopDefinition } from \"@parts/paragraph/formatting/tab-stop\";\nimport type { FrameOptions } from \"@parts/paragraph/frame/frame-properties\";\nimport type {\n MarkupRangeOptions,\n BookmarkStartOptions,\n MoveRangeStartOptions,\n} from \"@parts/paragraph/links/bookmark\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n ParagraphPropertiesOptions,\n ParagraphPropertiesChangeOptions,\n} from \"@parts/paragraph/properties\";\nimport { parseFormFieldData } from \"@parts/paragraph/run/form-field\";\nimport type { FormFieldOptions } from \"@parts/paragraph/run/form-field\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport {\n breakXml,\n EMPTY_RUN_ELEMENTS,\n type BreakOptions,\n type RunOptions,\n} from \"@parts/paragraph/run/run\";\nimport { parseRun, parseRunProperties, parsedRunToOptions } from \"@parts/paragraph/run/run-parse\";\nimport { parseSdtProperties } from \"@parts/sdt/sdt-parse\";\nimport { stringifyTableOfContents } from \"@parts/table-of-contents/descriptor\";\nimport type { VmlShapeStyle } from \"@parts/textbox/shape/shape\";\nimport { styleToKeyMap } from \"@parts/textbox/shape/shape\";\nimport type { BorderOptions } from \"@shared/border\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { MediaData } from \"@shared/media/data\";\nimport type { SectionChild } from \"@shared/section\";\nimport { parseShading } from \"@shared/shading\";\n\nimport type { DocxReadContext, DocxWriteContext, BodyContext } from \"./context\";\nimport { tableDesc, altChunkDesc, subDocDesc, sdtBlockDesc, customXmlBlockDesc } from \"./parts\";\nimport { parseCustomXmlProperties } from \"./parts/bodychildren\";\nimport { stringifyChildDispatch } from \"./parts/inline\";\nimport { parseMathChildren } from \"./parts/paragraph/math/stringify\";\nimport type { ParagraphChild, SdtRunOptions } from \"./parts/paragraph/paragraph\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./parts/paragraph/stringify\";\nimport { replaceRelsWithPlaceholders } from \"./util/replace-media-placeholders\";\nimport { stringifyElement } from \"./util/stringify-element\";\n\nexport type { BodyContext } from \"./context\";\n\n// ── Run ──\n\n/**\n * Stringify a run (w:r) from pure JSON options.\n *\n * Handles text, children, breaks, and run properties.\n */\nexport function stringifyRun(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n // Pre-scan children for commentReference — needs CommentReference style in rPr\n let commentRefStyle = false;\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"object\" && child !== null && \"commentReference\" in child) {\n commentRefStyle = true;\n break;\n }\n }\n }\n\n // Run properties — inject CommentReference style if needed\n const runOpts = commentRefStyle ? { ...opts, style: \"CommentReference\" as const } : opts;\n const rPr = stringifyRunProperties(runOpts);\n if (rPr) parts.push(rPr);\n\n // Breaks (w:br) — count shorthand or structured with clear (CT_Br)\n if (opts.break) {\n parts.push(breakXml(opts.break));\n }\n\n // Children or text\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n // Simple text string — direct output\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else if (typeof child === \"object\" && child !== null) {\n // Simple run-level elements — bare content, no <w:r> wrapper\n if (\"tab\" in child) {\n parts.push(\"<w:tab/>\");\n continue;\n }\n if (\"pageBreak\" in child) {\n parts.push('<w:br w:type=\"page\"/>');\n continue;\n }\n if (\"columnBreak\" in child) {\n parts.push('<w:br w:type=\"column\"/>');\n continue;\n }\n if (\"break\" in child) {\n parts.push(breakXml((child as { break: number | BreakOptions }).break));\n continue;\n }\n if (\"commentReference\" in child) {\n parts.push(`<w:commentReference w:id=\"${Number(child.commentReference)}\"/>`);\n continue;\n }\n\n // Empty run elements — self-closing XML with no attributes\n // { noBreakHyphen: true } → <w:noBreakHyphen/>, etc.\n const emptyXml = EMPTY_RUN_ELEMENTS[Object.keys(child)[0] ?? \"\"];\n if (emptyXml) {\n parts.push(emptyXml);\n continue;\n }\n\n // OLE object — w:object (VML shape + objectEmbed/link/control/movie)\n if (\"object\" in child) {\n parts.push(\n objectDesc.stringify((child as { object: ObjectElementOptions }).object, ctx) ?? \"\",\n );\n continue;\n }\n\n // JSON child dispatch (images, charts, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else {\n // Fallback: treat as an object-tree-like value — should not happen in JSON path\n throw new Error(`Unsupported run child type: ${Object.keys(child).join(\", \")}`);\n }\n }\n }\n } else if (opts.text !== undefined) {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:t>`);\n }\n\n // rsid attributes on <w:r>\n const rsidAttrs: string[] = [];\n if (opts.rsid) rsidAttrs.push(` w:rsidR=\"${opts.rsid}\"`);\n if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${opts.deletionRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body.length === 0 ? (attr ? `<w:r${attr}/>` : \"<w:r/>\") : `<w:r${attr}>${body}</w:r>`;\n}\n\n// ── Paragraph ──\n\n/**\n * Stringify a paragraph (w:p) from pure JSON options or string.\n *\n * Handles paragraph properties, numbering registration, and run children.\n */\nexport function stringifyParagraph(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n sectionPropertiesXml?: string,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n // Build paragraph properties — direct string output, no intermediate object tree\n const props = stringifyParagraphProperties(resolved);\n\n // Register numbering references\n if (!(ctx.viewWrapper instanceof FontWrapper)) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n // Paragraph properties XML\n if (props.xml) {\n if (sectionPropertiesXml) {\n // Insert sectPr before closing </w:pPr>\n parts.push(props.xml.replace(\"</w:pPr>\", sectionPropertiesXml + \"</w:pPr>\"));\n } else {\n parts.push(props.xml);\n }\n } else if (sectionPropertiesXml) {\n // No pPr but we need sectPr — wrap in pPr\n parts.push(`<w:pPr>${sectionPropertiesXml}</w:pPr>`);\n }\n\n // Text shorthand\n if (resolved.text !== undefined) {\n parts.push(stringifyRun({ text: resolved.text }, ctx));\n }\n\n // Children\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRun({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, pageBreak, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else {\n // RunOptions-like plain object — may be an empty run carrying only\n // run properties (round-tripped from <w:r><w:rPr>…</w:rPr></w:r>).\n parts.push(stringifyRun(child as RunOptions, ctx));\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n const paraAttrs: string[] = [];\n if (resolved.paraId) paraAttrs.push(` w14:paraId=\"${resolved.paraId}\"`);\n if (resolved.textId) paraAttrs.push(` w14:textId=\"${resolved.textId}\"`);\n if (resolved.rsid) paraAttrs.push(` w:rsidR=\"${resolved.rsid}\"`);\n if (resolved.defaultRunRsid) paraAttrs.push(` w:rsidRDefault=\"${resolved.defaultRunRsid}\"`);\n if (resolved.propertiesRsid) paraAttrs.push(` w:rsidP=\"${resolved.propertiesRsid}\"`);\n if (resolved.runPropertiesRsid) paraAttrs.push(` w:rsidRPr=\"${resolved.runPropertiesRsid}\"`);\n if (resolved.deletionRsid) paraAttrs.push(` w:rsidDel=\"${resolved.deletionRsid}\"`);\n const attr = paraAttrs.join(\"\");\n return body ? `<w:p${attr}>${body}</w:p>` : `<w:p${attr}/>`;\n}\n\n// ── Body child dispatch ──\n\n/**\n * Stringify a body-level child element.\n *\n * Dispatches to the appropriate stringifier based on the child type.\n * Pure JSON API — no class instance support.\n */\nexport function stringifyBodyChild(\n child: SectionChild,\n ctx: BodyContext,\n sectionPropertiesXml?: string,\n): string {\n // Plain object dispatch — all via descriptors\n if (\"paragraph\" in child) {\n return stringifyParagraph(child.paragraph, ctx, sectionPropertiesXml);\n }\n if (\"table\" in child) {\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n if (\"toc\" in child) {\n const { alias, ...options } = child.toc;\n const entriesXml = (options.entries ?? [])\n .map((entry) => stringifyBodyChild(entry, ctx))\n .join(\"\");\n return stringifyTableOfContents(alias, options, entriesXml);\n }\n if (\"textbox\" in child) {\n return stringifyTextbox(child.textbox, ctx);\n }\n if (\"sdt\" in child) {\n return sdtBlockDesc.stringify(child.sdt, ctx) ?? \"\";\n }\n if (\"altChunk\" in child) {\n return altChunkDesc.stringify(child.altChunk, ctx) ?? \"\";\n }\n if (\"subDoc\" in child) {\n return subDocDesc.stringify(child.subDoc, ctx) ?? \"\";\n }\n if (\"customXml\" in child) {\n return customXmlBlockDesc.stringify(child.customXml, ctx) ?? \"\";\n }\n if (\"bookmarkStart\" in child) {\n const bs = child.bookmarkStart;\n const a: string[] = [`w:id=\"${bs.id}\"`, `w:name=\"${escapeXml(bs.name)}\"`];\n if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${bs.displacedByCustomXml}\"`);\n if (bs.colFirst !== undefined) a.push(`w:colFirst=\"${bs.colFirst}\"`);\n if (bs.colLast !== undefined) a.push(`w:colLast=\"${bs.colLast}\"`);\n return `<w:bookmarkStart ${a.join(\" \")}/>`;\n }\n if (\"bookmarkEnd\" in child) {\n const be = child.bookmarkEnd;\n const a: string[] = [`w:id=\"${be.id}\"`];\n if (be.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${be.displacedByCustomXml}\"`);\n return `<w:bookmarkEnd ${a.join(\" \")}/>`;\n }\n if (\"rawXml\" in child) {\n return child.rawXml;\n }\n\n throw new Error(\"Unknown section child type\");\n}\n\n// ── Document background (pure function, no XmlComponent) ──\n\n/** Re-export styleToKeyMap for use in stringifyTextboxStyle. */\nconst vmlStyleMap = styleToKeyMap;\n\nfunction stringifyDocumentBackground(opts: DocumentBackgroundOptions, ctx: BodyContext): string {\n // Raw-XML passthrough for backgrounds that don't fit the structured model\n // (VML pattern fills, texture images). Register each referenced media item\n // so the compiler resolves the `{fileName}` placeholders into rIds.\n if (opts.rawXml) {\n if (opts.rawMedia) {\n for (const m of opts.rawMedia) {\n const data = toUint8Array(m.data);\n const entry = ctx.file.media.addMedia(\n data,\n m.type,\n (fileName) =>\n ({\n type: m.type,\n data,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n m.fileName,\n );\n // Dedup may reuse an earlier file name; remap the placeholder so the\n // compiler resolves it to the shared media relationship.\n if (entry.fileName !== m.fileName) {\n opts.rawXml = opts.rawXml.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);\n }\n }\n }\n return opts.rawXml;\n }\n\n const attrs: string[] = [];\n if (opts.color !== undefined) attrs.push(`w:color=\"${hexColorValue(opts.color)}\"`);\n if (opts.themeColor !== undefined) attrs.push(`w:themeColor=\"${opts.themeColor}\"`);\n if (opts.themeShade !== undefined)\n attrs.push(`w:themeShade=\"${uCharHexNumber(opts.themeShade)}\"`);\n if (opts.themeTint !== undefined) attrs.push(`w:themeTint=\"${uCharHexNumber(opts.themeTint)}\"`);\n const attrStr = attrs.join(\" \");\n\n if (opts.image) {\n const image = opts.image;\n const rawData = toUint8Array(image.data) as Uint8Array;\n const { fileName } = ctx.file.media.addMedia(\n rawData,\n image.type,\n (name) =>\n ({\n type: image.type as \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\",\n data: rawData,\n fileName: name,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n );\n\n const vmlBg = `<v:background id=\"_x0000_s1025\"><v:fill r:id=\"{${fileName}}\" o:title=\"${fileName}\" recolor=\"t\" type=\"frame\"/></v:background>`;\n return `<w:background ${attrStr}>${vmlBg}</w:background>`;\n }\n\n return `<w:background ${attrStr}/>`;\n}\n\n// ── Textbox (pure function, no XmlComponent) ──\n\nfunction stringifyTextbox(\n opts: Omit<ParagraphOptions, \"style\" | \"children\"> & {\n style?: VmlShapeStyle;\n children?: SectionChild[];\n },\n ctx: BodyContext,\n): string {\n // Destructure to separate VML style/children from paragraph properties\n const { style, children, ...paraOpts } = opts;\n const props = stringifyParagraphProperties(paraOpts);\n const pPrXml = props.xml ?? \"\";\n\n // VML shape style string\n const styleStr = style\n ? Object.entries(style)\n .map(([k, v]) => `${vmlStyleMap[k as keyof VmlShapeStyle]}:${v}`)\n .join(\";\")\n : undefined;\n\n // Shape attributes\n const shapeAttrs: string[] = [`id=\"_x0000_s${uniqueId()}\"`, `type=\"#_x0000_t202\"`];\n if (styleStr) shapeAttrs.push(`style=\"${styleStr}\"`);\n\n // Textbox content — serialize children via stringifyBodyChild\n const contentParts: string[] = [];\n if (children) {\n for (const c of children) {\n contentParts.push(stringifyBodyChild(c, ctx));\n }\n }\n const txbxContent = contentParts.join(\"\");\n\n const vmlTextbox = `<v:textbox style=\"mso-fit-shape-to-text:t;\" insetmode=\"auto\"><w:txbxContent>${txbxContent}</w:txbxContent></v:textbox>`;\n const vshape = `<v:shape ${shapeAttrs.join(\" \")}>${vmlTextbox}</v:shape>`;\n\n return `<w:p>${pPrXml}<w:pict>${vshape}</w:pict></w:p>`;\n}\n\n// ── Document body ──\n\n/** Document-level namespace string (cached). */\nconst DOC_NS =\n 'xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\"';\n\n/**\n * Stringify the complete document.xml from context data.\n *\n * This is the pure JSON path — iterates raw section children via\n * `stringifyBodyChild()` while reusing existing SectionProperties\n * instances for sectPr XML (which are already created with correct\n * header/footer references).\n *\n * Produces the complete `<w:document>` element including namespaces,\n * background, body content with interleaved section properties.\n */\nexport function stringifyDocumentXml(ctx: DocxWriteContext, docCtx: BodyContext): string {\n const sections = ctx._options.sections;\n const bodySections = ctx.sectionProperties;\n const parts: string[] = [];\n\n // <w:document> open tag\n const conformanceAttr = ctx._options.conformance\n ? ` w:conformance=\"${ctx._options.conformance}\"`\n : \"\";\n parts.push(`<w:document ${DOC_NS} mc:Ignorable=\"w14 w15 wp14\"${conformanceAttr}>`);\n\n // Background (if any)\n if (ctx._options.background) {\n parts.push(stringifyDocumentBackground(ctx._options.background, docCtx));\n }\n\n // <w:body>\n const bodyParts: string[] = [];\n\n for (const [si, section] of sections.entries()) {\n const children = section.children ?? [];\n const sectPrOpts = bodySections[si];\n const sectPrXml = sectPrOpts ? (sectionPropertiesDesc.stringify(sectPrOpts, docCtx) ?? \"\") : \"\";\n const isLast = si === sections.length - 1;\n\n // Per OOXML, a non-final section's sectPr lives in the pPr of its LAST\n // paragraph (the section-break paragraph carries both content and sectPr).\n // Host it there when possible; fall back to a dedicated break paragraph if\n // the section is empty or ends in a non-paragraph child. The last section\n // emits its sectPr at the body level.\n let sectPrHosted = isLast || !sectPrXml;\n for (const [ci, child] of children.entries()) {\n const inject = !isLast && sectPrXml && ci === children.length - 1 && \"paragraph\" in child;\n if (inject) sectPrHosted = true;\n bodyParts.push(stringifyBodyChild(child, docCtx, inject ? sectPrXml : undefined));\n }\n if (!isLast && sectPrXml && !sectPrHosted) {\n bodyParts.push(`<w:p><w:pPr>${sectPrXml}</w:pPr></w:p>`);\n }\n if (isLast && sectPrXml) {\n bodyParts.push(sectPrXml);\n }\n }\n\n parts.push(`<w:body>${bodyParts.join(\"\")}</w:body>`);\n parts.push(\"</w:document>\");\n\n return parts.join(\"\");\n}\n\n// ────────────────────────────────────────────────────────────────────────────────\n// Parse (XML → JSON options)\n// ────────────────────────────────────────────────────────────────────────────────\n\nconst HEADING_MAP: Record<string, (typeof HeadingLevel)[keyof typeof HeadingLevel]> = {\n Heading1: HeadingLevel.HEADING_1,\n Heading2: HeadingLevel.HEADING_2,\n Heading3: HeadingLevel.HEADING_3,\n Heading4: HeadingLevel.HEADING_4,\n Heading5: HeadingLevel.HEADING_5,\n Heading6: HeadingLevel.HEADING_6,\n Title: HeadingLevel.TITLE,\n};\n\n/** Valid w:spacing/@w:lineRule values (ST_LineSpacingRule). */\nconst LINE_RULES = Object.values(LineRuleType) as readonly string[];\n/** Valid border @w:val values (ST_Border). */\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\n/** Valid border @w:themeColor values (ST_ThemeColor). */\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/**\n * Reverse of inline.ts's deleted-page-number field map: maps a w:delInstrText\n * field code to the PageNumber placeholder a deletion run uses on the stringify\n * side, so deleted page-number fields round-trip instead of being dropped.\n */\nconst DELETED_PAGE_FIELD: Record<string, string> = {\n PAGE: \"CURRENT\",\n NUMPAGES: \"TOTAL_PAGES\",\n SECTIONPAGES: \"TOTAL_PAGES_IN_SECTION\",\n};\n\n/**\n * Parsed w:framePr attributes — flat capture of whatever attributes the source\n * carries. The public FrameOptions union (type/position/alignment + required\n * width/height/anchor) is rebuilt on the stringify side; parse preserves raw\n * attributes verbatim so round-trip keeps source fidelity.\n */\ninterface ParsedFrameProperties {\n dropCap?: string;\n lines?: string;\n wrap?: string;\n vAnchor?: string;\n hAnchor?: string;\n x?: string;\n y?: string;\n hRule?: string;\n hSpace?: string;\n vSpace?: string;\n alignment?: { x?: string; y?: string };\n anchor?: { horizontal?: string; vertical?: string };\n anchorLock?: boolean;\n width?: number;\n height?: number;\n}\n\n// Inline element payloads extracted from the ParagraphChild union — used by\n// parse to build typed objects instead of Record<string, unknown>.\ntype SmartTagInlineOptions = Extract<ParagraphChild, { smartTag: unknown }>[\"smartTag\"];\ntype CustomXmlInlineOptions = Extract<ParagraphChild, { customXml: unknown }>[\"customXml\"];\ntype DirInlineOptions = Extract<ParagraphChild, { dir: unknown }>[\"dir\"];\ntype HyperlinkInlineOptions = Extract<ParagraphChild, { hyperlink: unknown }>[\"hyperlink\"];\ntype PermStartInlineOptions = Extract<ParagraphChild, { permStart: unknown }>[\"permStart\"];\n\n/**\n * Parse w:pPr element into paragraph properties (without children).\n */\nexport function parseParagraphProperties(\n el: Element,\n ctx: DocxReadContext,\n): Partial<ParagraphPropertiesOptions> {\n const opts: Partial<ParagraphPropertiesOptions> = {};\n\n // Style / heading\n const pStyle = findChild(el, \"w:pStyle\");\n if (pStyle) {\n const styleVal = attr(pStyle, \"w:val\");\n if (styleVal) {\n if (HEADING_MAP[styleVal]) {\n opts.heading = HEADING_MAP[styleVal];\n } else {\n opts.style = styleVal;\n }\n }\n }\n\n // Alignment\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.alignment = val as ParagraphPropertiesOptions[\"alignment\"];\n }\n\n // Spacing — before/after/line are ST_TwipsMeasure (number | UniversalMeasure);\n // use attrMeasure so UniversalMeasure round-trips with the stringify side.\n const spacing = findChild(el, \"w:spacing\");\n if (spacing) {\n const sp: SpacingProperties = {};\n const before = attrMeasure(spacing, \"w:before\");\n if (before !== undefined) sp.before = before as SpacingProperties[\"before\"];\n const after = attrMeasure(spacing, \"w:after\");\n if (after !== undefined) sp.after = after as SpacingProperties[\"after\"];\n const line = attrMeasure(spacing, \"w:line\");\n if (line !== undefined) sp.line = line as SpacingProperties[\"line\"];\n const lineRule = attr(spacing, \"w:lineRule\");\n if (lineRule && (LINE_RULES as readonly string[]).includes(lineRule)) {\n sp.lineRule = lineRule as SpacingProperties[\"lineRule\"];\n }\n const beforeAutoSpacing = attrBool(spacing, \"w:beforeAutospacing\");\n if (beforeAutoSpacing !== undefined) sp.beforeAutoSpacing = beforeAutoSpacing;\n const afterAutoSpacing = attrBool(spacing, \"w:afterAutospacing\");\n if (afterAutoSpacing !== undefined) sp.afterAutoSpacing = afterAutoSpacing;\n const beforeLines = attrNum(spacing, \"w:beforeLines\");\n if (beforeLines !== undefined) sp.beforeLines = beforeLines;\n const afterLines = attrNum(spacing, \"w:afterLines\");\n if (afterLines !== undefined) sp.afterLines = afterLines;\n if (Object.keys(sp).length > 0) opts.spacing = sp;\n }\n\n // Indent — left/right/start/end are ST_SignedTwipsMeasure, hanging/firstLine\n // are ST_TwipsMeasure (number | UniversalMeasure); use attrMeasure so\n // UniversalMeasure round-trips. *Chars are ST_DecimalNumber (pure number).\n const ind = findChild(el, \"w:ind\");\n if (ind) {\n const indentObj: IndentProperties = {};\n const left = attrMeasure(ind, \"w:left\");\n if (left !== undefined) indentObj.left = left as IndentProperties[\"left\"];\n const leftChars = attrNum(ind, \"w:leftChars\");\n if (leftChars !== undefined) indentObj.leftChars = leftChars;\n const right = attrMeasure(ind, \"w:right\");\n if (right !== undefined) indentObj.right = right as IndentProperties[\"right\"];\n const rightChars = attrNum(ind, \"w:rightChars\");\n if (rightChars !== undefined) indentObj.rightChars = rightChars;\n const start = attrMeasure(ind, \"w:start\");\n if (start !== undefined) indentObj.start = start as IndentProperties[\"start\"];\n const startChars = attrNum(ind, \"w:startChars\");\n if (startChars !== undefined) indentObj.startChars = startChars;\n const end = attrMeasure(ind, \"w:end\");\n if (end !== undefined) indentObj.end = end as IndentProperties[\"end\"];\n const endChars = attrNum(ind, \"w:endChars\");\n if (endChars !== undefined) indentObj.endChars = endChars;\n const hanging = attrMeasure(ind, \"w:hanging\");\n if (hanging !== undefined) indentObj.hanging = hanging as IndentProperties[\"hanging\"];\n const hangingChars = attrNum(ind, \"w:hangingChars\");\n if (hangingChars !== undefined) indentObj.hangingChars = hangingChars;\n const firstLine = attrMeasure(ind, \"w:firstLine\");\n if (firstLine !== undefined) indentObj.firstLine = firstLine as IndentProperties[\"firstLine\"];\n const firstLineChars = attrNum(ind, \"w:firstLineChars\");\n if (firstLineChars !== undefined) indentObj.firstLineChars = firstLineChars;\n if (Object.keys(indentObj).length > 0) opts.indent = indentObj;\n }\n\n // Numbering (w:numPr)\n const numPr = findChild(el, \"w:numPr\");\n if (numPr) {\n const ilvl = findChild(numPr, \"w:ilvl\");\n const level = ilvl ? (attrNum(ilvl, \"w:val\") ?? 0) : 0;\n const numIdEl = findChild(numPr, \"w:numId\");\n const numId = numIdEl ? attr(numIdEl, \"w:val\") : undefined;\n if (numId === \"0\") {\n // numId=0 is the OOXML reserved value that cancels numbering inherited\n // from the paragraph style — emit numId=0 verbatim instead of falling\n // back to a bullet (which would inject ListParagraph + numId=1).\n opts.numbering = false;\n } else if (numId !== undefined && ctx.numberingCache.size > 0) {\n const numEl = ctx.docx.numbering;\n if (numEl) {\n let abstractNumId: string | undefined;\n for (const child of numEl.elements ?? []) {\n if (child.name !== \"w:num\") continue;\n if (attr(child, \"w:numId\") === numId) {\n const absRef = findChild(child, \"w:abstractNumId\");\n abstractNumId = absRef ? attr(absRef, \"w:val\") : undefined;\n break;\n }\n }\n if (abstractNumId !== undefined) {\n // custom: true suppresses the ListParagraph pStyle auto-injection in\n // stringifyParagraphProperties. Round-tripped list paragraphs carry\n // no pStyle in the source (the list formatting lives in numbering);\n // injecting ListParagraph would reference a style that round-tripped\n // styles.xml may not define → dangling reference Word rejects.\n const numberingOpts: {\n reference: string;\n level: number;\n custom: boolean;\n numberingChange?: { original: string; id: string; author: string; date?: string };\n } = { reference: `list_${numId}`, level, custom: true };\n // w:numberingChange (CT_TrackChangeNumbering) — child of w:numPr\n const numberingChangeEl = findChild(numPr, \"w:numberingChange\");\n if (numberingChangeEl) {\n const nc: { original: string; id: string; author: string; date?: string } = {\n original: attr(numberingChangeEl, \"w:original\") ?? \"\",\n id: attr(numberingChangeEl, \"w:id\") ?? \"\",\n author: attr(numberingChangeEl, \"w:author\") ?? \"\",\n };\n const ncDate = attr(numberingChangeEl, \"w:date\");\n if (ncDate) nc.date = ncDate;\n numberingOpts.numberingChange = nc;\n }\n opts.numbering = numberingOpts;\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n } else {\n opts.bullet = { level };\n }\n }\n\n // Tab stops\n const tabs = findChild(el, \"w:tabs\");\n if (tabs) {\n const tabStops: TabStopDefinition[] = [];\n for (const tab of tabs.elements ?? []) {\n if (tab.name !== \"w:tab\") continue;\n const tabObj: Partial<TabStopDefinition> = {};\n const pos = attrNum(tab, \"w:pos\");\n if (pos !== undefined) tabObj.position = pos;\n const val = attr(tab, \"w:val\");\n if (val) tabObj.type = val as TabStopDefinition[\"type\"];\n const leader = attr(tab, \"w:leader\");\n if (leader) tabObj.leader = leader as TabStopDefinition[\"leader\"];\n tabStops.push(tabObj as TabStopDefinition);\n }\n if (tabStops.length > 0) opts.tabStops = tabStops;\n }\n\n // On/off properties\n for (const [name, optKey] of [\n [\"w:keepNext\", \"keepNext\"],\n [\"w:keepLines\", \"keepLines\"],\n [\"w:pageBreakBefore\", \"pageBreakBefore\"],\n [\"w:widowControl\", \"widowControl\"],\n [\"w:suppressLineNumbers\", \"suppressLineNumbers\"],\n [\"w:contextualSpacing\", \"contextualSpacing\"],\n [\"w:bidi\", \"bidirectional\"],\n [\"w:wordWrap\", \"wordWrap\"],\n [\"w:suppressAutoHyphens\", \"suppressAutoHyphens\"],\n [\"w:adjustRightInd\", \"adjustRightInd\"],\n [\"w:snapToGrid\", \"snapToGrid\"],\n [\"w:mirrorIndents\", \"mirrorIndents\"],\n [\"w:kinsoku\", \"kinsoku\"],\n [\"w:topLinePunct\", \"topLinePunct\"],\n [\"w:autoSpaceDE\", \"autoSpaceDE\"],\n [\"w:autoSpaceDN\", \"autoSpaceEastAsianText\"],\n [\"w:overflowPunct\", \"overflowPunctuation\"],\n [\"w:suppressOverlap\", \"suppressOverlap\"],\n ] as const) {\n const child = findChild(el, name);\n if (child) opts[optKey] = attrBool(child, \"w:val\") ?? true;\n }\n\n // Thematic break\n const pBdr = findChild(el, \"w:pBdr\");\n if (pBdr) {\n const border: BordersOptions = {};\n for (const side of [\"top\", \"bottom\", \"left\", \"right\", \"between\", \"bar\"] as const) {\n const sideEl = findChild(pBdr, `w:${side}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n border[side] = sideOpts;\n }\n if (Object.keys(border).length > 0) opts.border = border;\n }\n\n // Shading\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading = parseShading(shd);\n if (shading) opts.shading = shading;\n }\n\n // Text alignment\n const textAlignment = findChild(el, \"w:textAlignment\");\n if (textAlignment) {\n const val = attr(textAlignment, \"w:val\");\n if (val) opts.textAlignment = val as ParagraphPropertiesOptions[\"textAlignment\"];\n }\n\n // Outline level\n const outlineLvl = findChild(el, \"w:outlineLvl\");\n if (outlineLvl) {\n const val = attrNum(outlineLvl, \"w:val\");\n if (val !== undefined) opts.outlineLevel = val;\n }\n\n // Run properties (paragraph-level defaults)\n const rPr = findChild(el, \"w:rPr\");\n if (rPr) {\n opts.run = parseRunProperties(rPr);\n }\n\n // Frame properties\n const framePr = findChild(el, \"w:framePr\");\n if (framePr) {\n const frame: ParsedFrameProperties = {};\n for (const [attrName, optName] of [\n [\"w:dropCap\", \"dropCap\"],\n [\"w:lines\", \"lines\"],\n [\"w:wrap\", \"wrap\"],\n [\"w:vAnchor\", \"vAnchor\"],\n [\"w:hAnchor\", \"hAnchor\"],\n [\"w:x\", \"x\"],\n [\"w:y\", \"y\"],\n [\"w:hRule\", \"hRule\"],\n [\"w:hSpace\", \"hSpace\"],\n [\"w:vSpace\", \"vSpace\"],\n ] as const) {\n const val = attr(framePr, attrName);\n if (val !== undefined) frame[optName] = val;\n }\n // Alignment (xAlign/yAlign)\n const xAlign = attr(framePr, \"w:xAlign\");\n const yAlign = attr(framePr, \"w:yAlign\");\n if (xAlign || yAlign) {\n const alignment: NonNullable<ParsedFrameProperties[\"alignment\"]> = {};\n if (xAlign) alignment.x = xAlign;\n if (yAlign) alignment.y = yAlign;\n frame.alignment = alignment;\n }\n // Anchor (hAnchor/vAnchor)\n const hAnchor = attr(framePr, \"w:hAnchor\");\n const vAnchor = attr(framePr, \"w:vAnchor\");\n if (hAnchor || vAnchor) {\n const anchor: NonNullable<ParsedFrameProperties[\"anchor\"]> = {};\n if (hAnchor) anchor.horizontal = hAnchor;\n if (vAnchor) anchor.vertical = vAnchor;\n frame.anchor = anchor;\n }\n // Anchor lock\n const anchorLock = attrBool(framePr, \"w:anchorLock\");\n if (anchorLock !== undefined) frame.anchorLock = anchorLock;\n const w = attrNum(framePr, \"w:w\");\n if (w !== undefined) frame.width = w;\n const h = attrNum(framePr, \"w:h\");\n if (h !== undefined) frame.height = h;\n if (Object.keys(frame).length > 0) opts.frame = frame as unknown as FrameOptions;\n }\n\n // Revision (w:pPrChange) — symmetric with stringifyParagraphProperties\n const pPrChange = findChild(el, \"w:pPrChange\");\n if (pPrChange) {\n const rev: Partial<ParagraphPropertiesChangeOptions> = {};\n const author = attr(pPrChange, \"w:author\");\n if (author) rev.author = author;\n const revDate = attr(pPrChange, \"w:date\");\n if (revDate) rev.date = revDate;\n const revId = attrNum(pPrChange, \"w:id\");\n if (revId !== undefined) rev.id = revId;\n const innerPPr = findChild(pPrChange, \"w:pPr\");\n if (innerPPr) Object.assign(rev, parseParagraphProperties(innerPPr, ctx));\n if (Object.keys(rev).length > 0) opts.revision = rev as ParagraphPropertiesChangeOptions;\n }\n\n return opts;\n}\n\n/**\n * Concatenate `<w:t>` text in a run element.\n *\n * Used to capture a textInput form field's current value from the result run\n * (the runs between the `separate` and `end` fldChars). Only `<w:t>` is read —\n * `<w:tab>`/`<w:br>` in results are ignored as rare for user-entered text.\n */\n/** Parse the w:r children of a track-change wrapper (w:ins/w:moveFrom/w:moveTo). */\nfunction parseTrackChangeRuns(el: Element, ctx: DocxReadContext): RunOptions[] {\n const runs: RunOptions[] = [];\n for (const sub of el.elements ?? []) {\n if (sub.name !== \"w:r\") continue;\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n runs.push(runOpts as RunOptions);\n }\n }\n return runs;\n}\n\nfunction collectRunText(el: Element): string {\n let text = \"\";\n for (const c of el.elements ?? []) {\n if (c.name === \"w:t\") text += textOf(c);\n }\n return text;\n}\n\n/** Concatenate `<w:t>` text across all `<w:r>` children of a container (rt/rubyBase). */\nfunction collectRunsText(el: Element): string {\n let text = \"\";\n for (const r of el.elements ?? []) {\n if (r.name === \"w:r\") text += collectRunText(r);\n }\n return text;\n}\n\n/**\n * Parse the inline children of a smartTag/customXml container (recursive).\n *\n * Handles runs and nested smartTag/customXml. Form fields, hyperlinks and\n * other paragraph-level constructs are rare inside these containers and are\n * not handled here.\n */\nfunction parseContainerChildren(el: Element, ctx: DocxReadContext): ParagraphChild[] {\n const children: ParagraphChild[] = [];\n for (const sub of el.elements ?? []) {\n switch (sub.name) {\n case \"w:r\": {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) children.push(runOpts);\n break;\n }\n case \"w:smartTag\": {\n const smartTag = parseSmartTagInline(sub, ctx);\n if (smartTag) children.push({ smartTag });\n break;\n }\n case \"w:customXml\": {\n const customXml = parseCustomXmlInline(sub, ctx);\n if (customXml) children.push({ customXml });\n break;\n }\n default:\n break;\n }\n }\n return children;\n}\n\n/** Parse a w:smartTag element into its ParagraphChild form. */\nfunction parseSmartTagInline(el: Element, ctx: DocxReadContext): SmartTagInlineOptions | undefined {\n const element = attr(el, \"w:element\");\n if (!element) return undefined;\n const st: SmartTagInlineOptions = { element };\n const uri = attr(el, \"w:uri\");\n if (uri) st.uri = uri;\n const pr = findChild(el, \"w:smartTagPr\");\n if (pr) {\n const props: Array<{ uri?: string; name: string; val: string }> = [];\n for (const a of pr.elements ?? []) {\n if (a.name !== \"w:attr\") continue;\n const prop: { uri?: string; name: string; val: string } = {\n name: attr(a, \"w:name\") ?? \"\",\n val: attr(a, \"w:val\") ?? \"\",\n };\n const auri = attr(a, \"w:uri\");\n if (auri) prop.uri = auri;\n props.push(prop);\n }\n if (props.length > 0) st.properties = props;\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) st.children = content;\n return st;\n}\n\n/** Parse an inline w:customXml element into its ParagraphChild form. */\nfunction parseCustomXmlInline(\n el: Element,\n ctx: DocxReadContext,\n): CustomXmlInlineOptions | undefined {\n const element = attr(el, \"w:element\");\n if (!element) return undefined;\n const cx: CustomXmlInlineOptions = { element };\n const uri = attr(el, \"w:uri\");\n if (uri) cx.uri = uri;\n const pr = findChild(el, \"w:customXmlPr\");\n if (pr) {\n const parsed = parseCustomXmlProperties(pr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined) {\n cx.customXmlPr = parsed;\n }\n }\n const content = parseContainerChildren(el, ctx);\n if (content.length > 0) cx.children = content;\n return cx;\n}\n\n/** Parse a move-revision range start (w:moveFromRangeStart / w:moveToRangeStart). */\nfunction parseMoveRangeStart(el: Element): MoveRangeStartOptions | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: Partial<MoveRangeStartOptions> = { id };\n const name = attr(el, \"w:name\");\n if (name !== undefined) m.name = name;\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n const disp = attr(el, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") m.displacedByCustomXml = disp;\n const colFirst = attrNum(el, \"w:colFirst\");\n if (colFirst !== undefined) m.colFirst = colFirst;\n const colLast = attrNum(el, \"w:colLast\");\n if (colLast !== undefined) m.colLast = colLast;\n return m as MoveRangeStartOptions;\n}\n\n/** Parse a customXml range start (Ins/Del/MoveFrom/MoveTo). */\nfunction parseCustomXmlRangeStart(\n el: Element,\n): { id: number; author?: string; date?: string } | null {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return null;\n const m: { id: number; author?: string; date?: string } = { id };\n const author = attr(el, \"w:author\");\n if (author !== undefined) m.author = author;\n const date = attr(el, \"w:date\");\n if (date !== undefined) m.date = date;\n return m;\n}\n\n/** Parse a CT_MarkupRange end marker (id + displacedByCustomXml). */\nfunction parseMarkupRangeOptions(el: Element): MarkupRangeOptions | undefined {\n const id = attrNum(el, \"w:id\");\n if (id === undefined) return undefined;\n const m: Partial<MarkupRangeOptions> = { id };\n const disp = attr(el, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") m.displacedByCustomXml = disp;\n return m as MarkupRangeOptions;\n}\n\n/**\n * Parse a w:p element into ParagraphOptions.\n */\n/**\n * Parse run-level children shared by paragraphs and inline-SDT content.\n * Includes the field accumulator that collapses form/complex fields spanning\n * multiple w:r runs into a single child.\n */\n/** Serialize a w:r's w:rPr child verbatim (or undefined when the run has none). */\nfunction runRPrXml(run: Element): string | undefined {\n const rPr = findChild(run, \"w:rPr\");\n return rPr ? stringifyElement(rPr) : undefined;\n}\n\nfunction parseRunLevelChildren(\n elements: Element[] | undefined,\n ctx: DocxReadContext,\n): ParagraphChild[] {\n const childList: ParagraphChild[] = [];\n\n // Field accumulator: a field (form field OR plain complex field) spans\n // several w:r elements (begin fldChar → instrText → separate → result → end).\n // - Form fields (checkBox/ddList/textInput) carry w:ffData on the begin\n // fldChar; their state lives there, and only a textInput's result is\n // captured (as `value`).\n // - Plain complex fields (PAGE/DATE/TOC/HYPERLINK...) have no ffData; their\n // instrText + result are captured as a complexField child for round-trip.\n // The whole field collapses to a single child.\n let fieldKind: \"form\" | \"complex\" | null = null;\n let pendingFormField: FormFieldOptions | null = null;\n let pendingInstruction = \"\";\n let pendingResult = \"\";\n // Verbatim rPr of the field's control runs (begin/instrText/separate/end)\n // and result run(s) — Word writes identical rPr across a field's runs, so\n // capturing it preserves field formatting (font/size) through round-trip.\n let pendingControlRPr: string | undefined;\n let pendingResultRPr: string | undefined;\n // True once the `separate` fldChar is seen: subsequent runs (up to `end`)\n // are the field's result.\n let collectingResult = false;\n\n for (const child of elements ?? []) {\n switch (child.name) {\n case \"w:pPr\":\n break;\n case \"w:r\": {\n // Field: fldChar markers + the instrText/result runs between them.\n const fldCharEl = findChild(child, \"w:fldChar\");\n if (fldCharEl) {\n const fctype = attr(fldCharEl, \"w:fldCharType\");\n if (fctype === \"begin\") {\n const ffDataEl = findChild(fldCharEl, \"w:ffData\");\n if (ffDataEl) {\n fieldKind = \"form\";\n pendingFormField = parseFormFieldData(ffDataEl);\n } else {\n fieldKind = \"complex\";\n pendingInstruction = \"\";\n pendingResult = \"\";\n }\n // Capture the begin run's rPr as the field's control-run rPr.\n pendingControlRPr = runRPrXml(child);\n pendingResultRPr = undefined;\n collectingResult = false;\n } else if (fctype === \"separate\") {\n collectingResult = true;\n } else if (fctype === \"end\" && fieldKind) {\n if (fieldKind === \"form\" && pendingFormField) {\n childList.push({ formField: pendingFormField });\n } else if (fieldKind === \"complex\") {\n const cf: {\n instruction: string;\n result?: string;\n rPrXml?: string;\n resultRPrXml?: string;\n } = { instruction: pendingInstruction };\n if (pendingResult) cf.result = pendingResult;\n if (pendingControlRPr) cf.rPrXml = pendingControlRPr;\n if (pendingResultRPr) cf.resultRPrXml = pendingResultRPr;\n childList.push({ complexField: cf });\n }\n fieldKind = null;\n pendingFormField = null;\n collectingResult = false;\n }\n break;\n }\n if (fieldKind) {\n if (fieldKind === \"complex\") {\n // Collect instrText (begin→separate) and result text (separate→end).\n if (collectingResult) {\n // Capture the first result run's rPr for round-trip.\n if (pendingResultRPr === undefined) pendingResultRPr = runRPrXml(child);\n pendingResult += collectRunText(child);\n } else {\n const instrEl = findChild(child, \"w:instrText\");\n if (instrEl) pendingInstruction += textOf(instrEl);\n }\n } else if (collectingResult && pendingFormField?.textInput) {\n // Capture a textInput's current value; checkbox/dropdown results\n // are discarded (their state is in w:ffData).\n const text = collectRunText(child);\n if (text) {\n const ti = pendingFormField.textInput;\n ti.value = (ti.value ?? \"\") + text;\n }\n }\n break; // instrText / result — handled by field state above\n }\n\n // Drawing may be a direct w:drawing child OR wrapped in\n // mc:AlternateContent > mc:Choice (DrawingML shapes wpg/wps use this\n // wrapper; the Fallback holds the VML equivalent). Resolve either and,\n // when an AlternateContent wrapper is present, carry the Fallback as\n // raw XML so the full mc:AlternateContent round-trips verbatim.\n let drawingEl = findChild(child, \"w:drawing\");\n let altFallback: string | undefined;\n let altFallbackMedia: BackgroundRawMediaOptions[] | undefined;\n let altRequires: string | undefined;\n if (!drawingEl) {\n const alt = findChild(child, \"mc:AlternateContent\");\n if (alt) {\n const choice = findChild(alt, \"mc:Choice\");\n if (choice) {\n drawingEl = findChild(choice, \"w:drawing\");\n altRequires = attr(choice, \"Requires\");\n }\n const fallback = findChild(alt, \"mc:Fallback\");\n if (fallback) {\n // Replace the VML fallback's r:id/r:embed/r:link refs with {fileName}\n // placeholders and collect the media; otherwise the carried source\n // rIds dangle (not defined in the generated rels).\n const replaced = replaceRelsWithPlaceholders(stringifyElement(fallback), ctx, \"vml\");\n altFallback = replaced.rawXml;\n altFallbackMedia = replaced.rawMedia.length > 0 ? replaced.rawMedia : undefined;\n }\n }\n }\n if (drawingEl) {\n const drawingChild = parseDrawingRun(drawingEl, ctx);\n if (drawingChild) {\n // Parse the wrapping run's rPr into structured fields so round-trip\n // stays editable (drawings/shapes can be wrapped in <w:r><w:rPr>…</w:rPr>…).\n const rPrEl = findChild(child, \"w:rPr\");\n const runProperties = rPrEl ? parseRunProperties(rPrEl) : undefined;\n // Attach the VML fallback + Choice Requires so stringify can rebuild\n // the mc:AlternateContent wrapper (Choice structured + Fallback raw).\n if (altFallback) {\n if (\"wpsShape\" in drawingChild) {\n drawingChild.wpsShape.vmlFallback = altFallback;\n drawingChild.wpsShape.vmlFallbackMedia = altFallbackMedia;\n if (altRequires) drawingChild.wpsShape.mcChoiceRequires = altRequires;\n } else if (\"wpgGroup\" in drawingChild) {\n drawingChild.wpgGroup.vmlFallback = altFallback;\n drawingChild.wpgGroup.vmlFallbackMedia = altFallbackMedia;\n if (altRequires) drawingChild.wpgGroup.mcChoiceRequires = altRequires;\n }\n }\n if (runProperties) {\n if (\"image\" in drawingChild) {\n drawingChild.image.runProperties = runProperties;\n } else if (\"wpsShape\" in drawingChild) {\n drawingChild.wpsShape.runProperties = runProperties;\n } else if (\"wpgGroup\" in drawingChild) {\n drawingChild.wpgGroup.runProperties = runProperties;\n }\n }\n childList.push(drawingChild);\n break;\n }\n }\n const parsed = parseRun(child, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null) childList.push(runOpts);\n break;\n }\n case \"w:hyperlink\": {\n const hl: Partial<HyperlinkInlineOptions> = {};\n const rId = attr(child, \"r:id\");\n if (rId) {\n const target = ctx.docx.partRefs.hyperlinks.get(rId);\n if (target) hl.link = target;\n }\n const anchor = attr(child, \"w:anchor\");\n if (anchor) hl.anchor = anchor;\n const tooltip = attr(child, \"w:tooltip\");\n if (tooltip) hl.tooltip = tooltip;\n const tgtFrame = attr(child, \"w:tgtFrame\");\n if (tgtFrame) hl.tgtFrame = tgtFrame;\n const docLocation = attr(child, \"w:docLocation\");\n if (docLocation) hl.docLocation = docLocation;\n const history = attrBool(child, \"w:history\");\n if (history !== undefined) hl.history = history;\n\n const linkRuns: (RunOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") {\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n // parsedRunToOptions returns null for auto-generated/empty runs\n // (e.g. footnoteRef, pure drawing) and { commentReference } for\n // pure comment-reference runs; hyperlink children are\n // (RunOptions | string), so skip both.\n if (runOpts !== null && !(\"commentReference\" in runOpts)) {\n linkRuns.push(runOpts);\n }\n }\n }\n if (linkRuns.length > 0) {\n hl.children = linkRuns;\n childList.push({ hyperlink: hl });\n }\n break;\n }\n case \"w:bookmarkStart\": {\n const id = attrNum(child, \"w:id\");\n const name = attr(child, \"w:name\");\n if (id !== undefined && name) {\n const bookmarkStart: Partial<BookmarkStartOptions> = { id, name };\n const disp = attr(child, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") bookmarkStart.displacedByCustomXml = disp;\n const colFirst = attrNum(child, \"w:colFirst\");\n if (colFirst !== undefined) bookmarkStart.colFirst = colFirst;\n const colLast = attrNum(child, \"w:colLast\");\n if (colLast !== undefined) bookmarkStart.colLast = colLast;\n childList.push({ bookmarkStart: bookmarkStart as BookmarkStartOptions });\n }\n break;\n }\n case \"w:bookmarkEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) {\n const bookmarkEnd: Partial<MarkupRangeOptions> = { id };\n const disp = attr(child, \"w:displacedByCustomXml\");\n if (disp === \"before\" || disp === \"after\") bookmarkEnd.displacedByCustomXml = disp;\n childList.push({ bookmarkEnd: bookmarkEnd as MarkupRangeOptions });\n }\n break;\n }\n case \"w:commentRangeStart\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ commentRangeStart: m });\n break;\n }\n case \"w:commentRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ commentRangeEnd: m });\n break;\n }\n case \"w:commentReference\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ commentReference: id });\n break;\n }\n case \"m:oMath\": {\n const mathChildren = parseMathChildren(child);\n childList.push({ math: { children: mathChildren } });\n break;\n }\n case \"w:ins\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n insertion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:del\": {\n // Deleted page-number fields emit w:delInstrText (not w:instrText);\n // reverse inline.ts's field map so they round-trip as placeholder children.\n const children: (RunOptions | string)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name !== \"w:r\") continue;\n const delInstrEl = findChild(sub, \"w:delInstrText\");\n if (delInstrEl) {\n const placeholder = DELETED_PAGE_FIELD[(textOf(delInstrEl) ?? \"\").trim()];\n if (placeholder) {\n children.push(placeholder);\n continue;\n }\n }\n const parsed = parseRun(sub, ctx);\n const runOpts = parsedRunToOptions(parsed);\n if (runOpts !== null && typeof runOpts === \"object\" && !(\"commentReference\" in runOpts)) {\n children.push(runOpts as RunOptions);\n }\n }\n if (children.length > 0) {\n childList.push({\n deletion: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:moveFrom\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n movedFrom: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:moveTo\": {\n const children = parseTrackChangeRuns(child, ctx);\n if (children.length > 0) {\n childList.push({\n movedTo: {\n id: attrNum(child, \"w:id\") ?? 0,\n author: attr(child, \"w:author\") ?? \"\",\n date: attr(child, \"w:date\") ?? \"\",\n children,\n },\n });\n }\n break;\n }\n case \"w:fldSimple\": {\n const instruction = attr(child, \"w:instr\");\n if (instruction) {\n const sf: {\n instruction: string;\n cachedValue?: string;\n fldLock?: boolean;\n dirty?: boolean;\n } = { instruction };\n // cachedValue: concatenate the result-run <w:t> text (one or more\n // <w:r> children between the fldSimple tags).\n let cachedValue = \"\";\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:r\") cachedValue += collectRunText(sub);\n }\n if (cachedValue) sf.cachedValue = cachedValue;\n const sfLock = attrBool(child, \"w:fldLock\");\n if (sfLock !== undefined) sf.fldLock = sfLock;\n const sfDirty = attrBool(child, \"w:dirty\");\n if (sfDirty !== undefined) sf.dirty = sfDirty;\n childList.push({ simpleField: sf });\n }\n break;\n }\n case \"w:smartTag\": {\n const st = parseSmartTagInline(child, ctx);\n if (st) childList.push({ smartTag: st });\n break;\n }\n case \"w:customXml\": {\n const cx = parseCustomXmlInline(child, ctx);\n if (cx) childList.push({ customXml: cx });\n break;\n }\n // ── Bidirectional containers (reuse the smartTag/customXml child parser) ──\n case \"w:dir\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const dir: DirInlineOptions = { val: val as \"ltr\" | \"rtl\" };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) dir.children = content;\n childList.push({ dir });\n }\n break;\n }\n case \"w:bdo\": {\n const val = attr(child, \"w:val\");\n if (val) {\n const bdo: DirInlineOptions = { val: val as \"ltr\" | \"rtl\" };\n const content = parseContainerChildren(child, ctx);\n if (content.length > 0) bdo.children = content;\n childList.push({ bdo });\n }\n break;\n }\n // ── Ruby annotation (East Asian pronunciation guides) ──\n case \"w:ruby\": {\n const rt = findChild(child, \"w:rt\");\n const rubyBase = findChild(child, \"w:rubyBase\");\n // text and base are required by CT_Ruby; skip the ruby if either is missing.\n if (!rt || !rubyBase) break;\n const ruby: RubyOptions = {\n text: collectRunsText(rt),\n base: collectRunsText(rubyBase),\n };\n const pr = findChild(child, \"w:rubyPr\");\n if (pr) {\n const alignEl = findChild(pr, \"w:rubyAlign\");\n if (alignEl) {\n const v = attr(alignEl, \"w:val\");\n if (v) ruby.alignment = v as RubyOptions[\"alignment\"];\n }\n // hps / hpsRaise / hpsBaseText are half-points; the API uses points.\n const hpsEl = findChild(pr, \"w:hps\");\n if (hpsEl) {\n const v = attrNum(hpsEl, \"w:val\");\n if (v !== undefined) ruby.fontSize = v / 2;\n }\n const hpsRaiseEl = findChild(pr, \"w:hpsRaise\");\n if (hpsRaiseEl) {\n const v = attrNum(hpsRaiseEl, \"w:val\");\n if (v !== undefined) ruby.raise = v / 2;\n }\n const hpsBaseEl = findChild(pr, \"w:hpsBaseText\");\n if (hpsBaseEl) {\n const v = attrNum(hpsBaseEl, \"w:val\");\n if (v !== undefined) ruby.baseFontSize = v / 2;\n }\n const lidEl = findChild(pr, \"w:lid\");\n if (lidEl) {\n const v = attr(lidEl, \"w:val\");\n if (v) ruby.languageId = v;\n }\n if (findChild(pr, \"w:dirty\")) ruby.dirty = true;\n }\n childList.push({ ruby });\n break;\n }\n // ── Range markers: proof errors, positional tabs, permissions, revisions ──\n case \"w:proofErr\": {\n const type = attr(child, \"w:type\");\n if (\n type === \"spellStart\" ||\n type === \"spellEnd\" ||\n type === \"gramStart\" ||\n type === \"gramEnd\"\n ) {\n childList.push({ proofErr: type });\n }\n break;\n }\n case \"w:ptab\": {\n const alignment = attr(child, \"w:alignment\");\n const leader = attr(child, \"w:leader\");\n const relativeTo = attr(child, \"w:relativeTo\");\n if (alignment !== undefined && leader !== undefined && relativeTo !== undefined) {\n childList.push({ positionalTab: { alignment, leader, relativeTo } });\n }\n break;\n }\n case \"w:permStart\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) {\n const ps: PermStartInlineOptions = { id };\n const ed = attr(child, \"w:ed\");\n if (ed !== undefined) ps.ed = ed;\n const editGroup = attr(child, \"w:edGrp\");\n if (editGroup !== undefined) ps.editGroup = editGroup;\n const colFirst = attrNum(child, \"w:colFirst\");\n if (colFirst !== undefined) ps.colFirst = colFirst;\n const colLast = attrNum(child, \"w:colLast\");\n if (colLast !== undefined) ps.colLast = colLast;\n childList.push({ permStart: ps });\n }\n break;\n }\n case \"w:permEnd\": {\n const id = attr(child, \"w:id\");\n if (id !== undefined) childList.push({ permEnd: id });\n break;\n }\n case \"w:moveFromRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveFromRangeStart: m });\n break;\n }\n case \"w:moveFromRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ moveFromRangeEnd: m });\n break;\n }\n case \"w:moveToRangeStart\": {\n const m = parseMoveRangeStart(child);\n if (m) childList.push({ moveToRangeStart: m });\n break;\n }\n case \"w:moveToRangeEnd\": {\n const m = parseMarkupRangeOptions(child);\n if (m) childList.push({ moveToRangeEnd: m });\n break;\n }\n case \"w:customXmlInsRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlInsRangeStart: m });\n break;\n }\n case \"w:customXmlInsRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlInsRangeEnd: id });\n break;\n }\n case \"w:customXmlDelRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlDelRangeStart: m });\n break;\n }\n case \"w:customXmlDelRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlDelRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveFromRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveFromRangeStart: m });\n break;\n }\n case \"w:customXmlMoveFromRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveFromRangeEnd: id });\n break;\n }\n case \"w:customXmlMoveToRangeStart\": {\n const m = parseCustomXmlRangeStart(child);\n if (m) childList.push({ customXmlMoveToRangeStart: m });\n break;\n }\n case \"w:customXmlMoveToRangeEnd\": {\n const id = attrNum(child, \"w:id\");\n if (id !== undefined) childList.push({ customXmlMoveToRangeEnd: id });\n break;\n }\n case \"w:sdt\": {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtChildren = parseRunLevelChildren(sdtContent?.elements, ctx);\n const sdt: SdtRunOptions = { properties };\n if (sdtChildren.length > 0) sdt.children = sdtChildren;\n if (endProperties) sdt.endProperties = endProperties;\n childList.push({ sdt });\n break;\n }\n default:\n break;\n }\n }\n\n return childList;\n}\n\n/** True when a child is a single-field `{ text: string }` run (simple text). */\nfunction isTextOnlyRun(c: unknown): c is { text: string } {\n return typeof c === \"object\" && c !== null && \"text\" in c && Object.keys(c).length === 1;\n}\n\nexport function parseParagraph(el: Element, ctx: DocxReadContext): ParagraphOptions {\n const opts: Partial<ParagraphOptions> = {};\n\n // w:p element attributes: rsid family + w14:paraId/textId (hex string verbatim)\n const paraId = attr(el, \"w14:paraId\");\n if (paraId) opts.paraId = paraId;\n const textId = attr(el, \"w14:textId\");\n if (textId) opts.textId = textId;\n const rsid = attr(el, \"w:rsidR\");\n if (rsid) opts.rsid = rsid;\n const defaultRunRsid = attr(el, \"w:rsidRDefault\");\n if (defaultRunRsid) opts.defaultRunRsid = defaultRunRsid;\n const propertiesRsid = attr(el, \"w:rsidP\");\n if (propertiesRsid) opts.propertiesRsid = propertiesRsid;\n const runPropertiesRsid = attr(el, \"w:rsidRPr\");\n if (runPropertiesRsid) opts.runPropertiesRsid = runPropertiesRsid;\n const deletionRsid = attr(el, \"w:rsidDel\");\n if (deletionRsid) opts.deletionRsid = deletionRsid;\n\n const pPr = findChild(el, \"w:pPr\");\n if (pPr) {\n Object.assign(opts, parseParagraphProperties(pPr, ctx));\n }\n\n const childList = parseRunLevelChildren(el.elements, ctx);\n\n // Simple text optimization: a run of text-only children collapses into a\n // single opts.text (the canonical ParagraphOptions form) instead of a\n // children array.\n if (childList.length > 0) {\n if (childList.every(isTextOnlyRun)) {\n const combined = childList.map((c) => (isTextOnlyRun(c) ? c.text : \"\")).join(\"\");\n if (combined) {\n opts.text = combined;\n return opts as ParagraphOptions;\n }\n }\n opts.children = childList;\n }\n\n return opts as ParagraphOptions;\n}\n","/**\n * Drawing parser for DOCX documents.\n *\n * Parses w:drawing elements and extracts image, chart, or SmartArt data.\n *\n * @module\n */\nimport {\n blipDesc,\n convertEmuToPixels,\n customGeometryDesc,\n effectListDesc,\n fillDesc,\n outlineDesc,\n parseColorChoice,\n presetGeometryDesc,\n} from \"@office-open/core\";\nimport { scene3DDesc, shape3DDesc } from \"@office-open/core/drawingml\";\nimport { attr, attrBool, attrNum, findChild, findFirst, textOf } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ChartOptions } from \"@parts/paragraph/run/chart-run\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\nimport type { WpgGroupRunOptions } from \"@parts/paragraph/run/wpg-group-run\";\nimport type { WpsShapeRunOptions } from \"@parts/paragraph/run/wps-shape-run\";\nimport type {\n GroupChildMediaData,\n MediaData,\n MediaDataTransformation,\n WpgCommonMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport { parseParagraph } from \"../../body\";\nimport type { DocxReadContext } from \"../../context\";\nimport type { GraphicFrameLocksOptions, GroupShapeLocksOptions } from \"./descriptor\";\nimport type { DocPropertiesOptions } from \"./doc-properties/doc-properties\";\nimport type {\n Floating,\n HorizontalPositionOptions,\n Margins,\n VerticalPositionOptions,\n} from \"./floating\";\nimport type { SourceRectangleOptions } from \"./inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { ChildOffset, ChildExtent } from \"./inline/graphic/graphic-data/wpg/wpg-group\";\nimport { parseBodyProperties } from \"./inline/graphic/graphic-data/wps/body-properties\";\nimport type { NonVisualShapePropertiesOptions } from \"./inline/graphic/graphic-data/wps/non-visual-shape-properties\";\nimport type {\n ShapeStyleOptions,\n StyleMatrixReferenceOptions,\n WpsShapeCoreOptions,\n} from \"./inline/graphic/graphic-data/wps/wps-shape\";\nimport { TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping, WrapPolygon } from \"./text-wrap\";\n\n/** Union type for parsed drawing child wrappers. */\nexport type DrawingChild =\n | { image: ImageOptions }\n | { chart: ChartOptions }\n | { smartArt: SmartArtOptions }\n | { wpsShape: WpsShapeRunOptions }\n | { wpgGroup: WpgGroupRunOptions };\n\n/**\n * Parse a w:drawing element and dispatch to the correct parser\n * based on the graphicData URI.\n */\nexport function parseDrawingRun(el: Element, ctx: DocxReadContext): DrawingChild | undefined {\n const graphicData = findFirst(el, \"a:graphicData\");\n if (!graphicData) return undefined;\n\n const uri = attr(graphicData, \"uri\") ?? \"\";\n\n if (uri.includes(\"/chart\")) {\n return parseChartDrawing(el, ctx);\n }\n if (uri.includes(\"/diagram\")) {\n return parseSmartArtDrawing(el, ctx);\n }\n if (uri.includes(\"wordprocessingGroup\")) {\n return parseWpgGroupDrawing(el, ctx);\n }\n if (uri.includes(\"wordprocessingShape\")) {\n return parseWpsShapeDrawing(el, ctx);\n }\n return parseImageRun(el, ctx);\n}\n\n/**\n * Determine image type from file extension or MIME type.\n */\nexport function imageTypeFromPath(\n path: string,\n): \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\" {\n const ext = path.split(\".\").pop()?.toLowerCase() ?? \"\";\n switch (ext) {\n case \"jpg\":\n case \"jpeg\":\n return \"jpg\";\n case \"png\":\n return \"png\";\n case \"gif\":\n return \"gif\";\n case \"bmp\":\n return \"bmp\";\n case \"tif\":\n case \"tiff\":\n return \"tif\";\n case \"ico\":\n return \"ico\";\n case \"emf\":\n return \"emf\";\n case \"wmf\":\n return \"wmf\";\n default:\n return \"png\"; // fallback\n }\n}\n\n/**\n * Extent (EMU→pixels), alt text, and floating properties extracted from a\n * w:drawing's wp:inline or wp:anchor wrapper. Shared by image, wps shape,\n * and wpg group parsing.\n */\ninterface AnchorInfo {\n width?: number;\n height?: number;\n floating?: Floating;\n altText?: DocPropertiesOptions;\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n /** wp:effectExtent in raw EMUs — round-tripped verbatim. */\n effectExtent?: { l: number; t: number; r: number; b: number };\n}\n\n/** Read wp:cNvGraphicFramePr locking flags. An empty element (no graphicFrameLocks\n * child) returns `{}` so it round-trips as `<wp:cNvGraphicFramePr/>`. */\nfunction readGraphicFrameLocks(el: Element): GraphicFrameLocksOptions {\n const locks = findChild(el, \"a:graphicFrameLocks\");\n const result: GraphicFrameLocksOptions = {};\n if (!locks) return result;\n const a = locks.attributes ?? {};\n if (a[\"noGrp\"] !== undefined) result.noGrp = a[\"noGrp\"] !== \"0\";\n if (a[\"noDrilldown\"] !== undefined) result.noDrilldown = a[\"noDrilldown\"] !== \"0\";\n if (a[\"noSelect\"] !== undefined) result.noSelect = a[\"noSelect\"] !== \"0\";\n if (a[\"noChangeAspect\"] !== undefined) result.noChangeAspect = a[\"noChangeAspect\"] !== \"0\";\n if (a[\"noMove\"] !== undefined) result.noMove = a[\"noMove\"] !== \"0\";\n if (a[\"noResize\"] !== undefined) result.noResize = a[\"noResize\"] !== \"0\";\n return result as GraphicFrameLocksOptions;\n}\n\n/**\n * Read wpg:cNvGrpSpPr/a:grpSpLocks (CT_GroupLocking) into GroupShapeLocksOptions.\n * Returns `undefined` when the group has no locks (Word's default → empty cNvGrpSpPr).\n */\nfunction readGrpSpLocks(cNvGrpSpPr: Element | undefined): GroupShapeLocksOptions | undefined {\n if (!cNvGrpSpPr) return undefined;\n const locks = findChild(cNvGrpSpPr, \"a:grpSpLocks\");\n if (!locks) return undefined;\n const result: GroupShapeLocksOptions = {};\n const a = locks.attributes ?? {};\n if (a[\"noGrp\"] !== undefined) result.noGrp = a[\"noGrp\"] !== \"0\";\n if (a[\"noUngrp\"] !== undefined) result.noUngrp = a[\"noUngrp\"] !== \"0\";\n if (a[\"noSelect\"] !== undefined) result.noSelect = a[\"noSelect\"] !== \"0\";\n if (a[\"noRot\"] !== undefined) result.noRot = a[\"noRot\"] !== \"0\";\n if (a[\"noChangeAspect\"] !== undefined) result.noChangeAspect = a[\"noChangeAspect\"] !== \"0\";\n if (a[\"noMove\"] !== undefined) result.noMove = a[\"noMove\"] !== \"0\";\n if (a[\"noResize\"] !== undefined) result.noResize = a[\"noResize\"] !== \"0\";\n return Object.keys(result).length === 0 ? undefined : (result as GroupShapeLocksOptions);\n}\n\n/**\n * Extract {@link AnchorInfo} from the drawing's wp:inline or wp:anchor.\n * Returns `null` when the drawing has neither wrapper.\n */\nfunction parseAnchorOrInline(el: Element): AnchorInfo | null {\n const inline = findFirst(el, \"wp:inline\");\n const anchor = inline ? undefined : findFirst(el, \"wp:anchor\");\n const parent = inline ?? anchor;\n if (!parent) return null;\n\n const info: AnchorInfo = {};\n\n // Extent (EMU)\n const extent = findChild(parent, \"wp:extent\");\n if (extent) {\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n if (cxEmu !== undefined) info.width = cxEmu;\n if (cyEmu !== undefined) info.height = cyEmu;\n }\n\n // Effect extent (raw EMUs — round-tripped verbatim, never converted to pixels)\n const ee = findChild(parent, \"wp:effectExtent\");\n if (ee) {\n info.effectExtent = {\n l: attrNum(ee, \"l\") ?? 0,\n t: attrNum(ee, \"t\") ?? 0,\n r: attrNum(ee, \"r\") ?? 0,\n b: attrNum(ee, \"b\") ?? 0,\n };\n }\n\n // Alt text (wp:docPr) — keep the id too so it round-trips verbatim\n const docPr = findChild(parent, \"wp:docPr\");\n if (docPr) {\n const id = attr(docPr, \"id\");\n const name = attr(docPr, \"name\");\n const descr = attr(docPr, \"descr\");\n const title = attr(docPr, \"title\");\n if (id !== undefined || name || descr || title) {\n const alt: Partial<DocPropertiesOptions> = {};\n if (id !== undefined) alt.id = id;\n if (name) alt.name = name;\n if (descr) alt.description = descr;\n if (title) alt.title = title;\n info.altText = alt as DocPropertiesOptions;\n }\n }\n\n // Graphic frame locks (wp:cNvGraphicFramePr) — preserved verbatim.\n const cNvGraphicFramePr = findChild(parent, \"wp:cNvGraphicFramePr\");\n if (cNvGraphicFramePr) info.graphicFrameLocks = readGraphicFrameLocks(cNvGraphicFramePr);\n\n // Floating (anchor only)\n if (anchor && !inline) {\n const floating: Partial<Floating> = {};\n\n // Margins (distT/distB/distL/distR on wp:anchor)\n const margins: Margins = {};\n const distT = attrNum(anchor, \"distT\");\n if (distT !== undefined) margins.top = distT;\n const distB = attrNum(anchor, \"distB\");\n if (distB !== undefined) margins.bottom = distB;\n const distL = attrNum(anchor, \"distL\");\n if (distL !== undefined) margins.left = distL;\n const distR = attrNum(anchor, \"distR\");\n if (distR !== undefined) margins.right = distR;\n if (Object.keys(margins).length > 0) floating.margins = margins;\n\n // Position H/V (relativeFrom + align/posOffset)\n const posH = findChild(anchor, \"wp:positionH\");\n if (posH) {\n const hp = readPosition(posH);\n if (hp) floating.horizontalPosition = hp as HorizontalPositionOptions;\n }\n const posV = findChild(anchor, \"wp:positionV\");\n if (posV) {\n const vp = readPosition(posV);\n if (vp) floating.verticalPosition = vp as VerticalPositionOptions;\n }\n\n // Wrap (element name → TextWrappingType number) + optional side\n const wrap = readWrap(anchor);\n if (wrap) floating.wrap = wrap;\n\n // Anchor-level flags (stringifyAnchor writes all of these)\n const allowOverlap = attrBool(anchor, \"allowOverlap\");\n if (allowOverlap !== undefined) floating.allowOverlap = allowOverlap;\n const behindDoc = attrBool(anchor, \"behindDoc\");\n if (behindDoc !== undefined) floating.behindDocument = behindDoc;\n const locked = attrBool(anchor, \"locked\");\n if (locked !== undefined) floating.lockAnchor = locked;\n const layoutInCell = attrBool(anchor, \"layoutInCell\");\n if (layoutInCell !== undefined) floating.layoutInCell = layoutInCell;\n const relativeHeight = attrNum(anchor, \"relativeHeight\");\n if (relativeHeight !== undefined) floating.zIndex = relativeHeight;\n\n if (Object.keys(floating).length > 0) info.floating = floating as Floating;\n }\n\n return info;\n}\n\n/**\n * Parse a w:drawing element and return image data wrapped in { image: ... }.\n */\nexport function parseImageRun(\n el: Element,\n ctx: DocxReadContext,\n): { image: ImageOptions } | undefined {\n const info = parseAnchorOrInline(el);\n if (!info) return undefined;\n\n // Get graphic → graphicData → blip\n const blip = findFirst(el, \"a:blip\");\n if (!blip) return undefined;\n\n const rEmbed = attr(blip, \"r:embed\");\n if (!rEmbed) return undefined;\n\n // Resolve the media path against the current part's relationships\n const mediaPath = ctx.resolveRelationship(rEmbed);\n if (!mediaPath) return undefined;\n\n // Read image data from ZIP\n const imageData = ctx.docx.doc.getRaw(mediaPath);\n if (!imageData) return undefined;\n\n const type = imageTypeFromPath(mediaPath);\n\n const imageOpts: Record<string, unknown> = {\n type,\n data: imageData,\n transformation: {\n ...(info.width !== undefined ? { width: info.width } : {}),\n ...(info.height !== undefined ? { height: info.height } : {}),\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (info.altText) imageOpts.altText = info.altText;\n if (info.floating) imageOpts.floating = info.floating;\n if (info.graphicFrameLocks !== undefined) imageOpts.graphicFrameLocks = info.graphicFrameLocks;\n\n // Blip-fill crop (pic:blipFill/a:srcRect)\n const blipFill = findFirst(el, \"pic:blipFill\");\n if (blipFill) {\n const srcRect = readSourceRectangle(blipFill);\n if (srcRect) imageOpts.sourceRectangle = srcRect;\n }\n\n // Picture non-visual properties (pic:nvPicPr/pic:cNvPr)\n const cNvPr = readPicCnvPr(el);\n if (cNvPr) imageOpts.nonVisualProperties = cNvPr;\n\n // Picture shape properties (pic:spPr): outline + fill + effects round-trip\n // via the shared core descriptors (bidirectional).\n const picSpPr = findFirst(el, \"pic:spPr\");\n if (picSpPr) {\n const fill = readShapeFill(picSpPr, ctx);\n if (fill) imageOpts.fill = fill;\n const ln = findChild(picSpPr, \"a:ln\");\n if (ln) imageOpts.outline = outlineDesc.parse(ln, ctx);\n const effectLst = findChild(picSpPr, \"a:effectLst\");\n if (effectLst) imageOpts.effects = effectListDesc.parse(effectLst, ctx);\n // Rotation/flip live on pic:spPr/a:xfrm (ST_Angle in 1/60000 deg). Convert\n // to degrees to match the MediaTransformation API — createTransformation\n // multiplies back by 60_000 on stringify, so integer-degree rotation stays\n // lossless across round-trip.\n const xfrm = findChild(picSpPr, \"a:xfrm\");\n if (xfrm) {\n const transform = imageOpts.transformation as {\n rotation?: number;\n flip?: { horizontal?: boolean; vertical?: boolean };\n };\n const rot = attrNum(xfrm, \"rot\");\n if (rot !== undefined) transform.rotation = rot / 60_000;\n const flipH = attrBool(xfrm, \"flipH\");\n const flipV = attrBool(xfrm, \"flipV\");\n if (flipH !== undefined || flipV !== undefined) {\n transform.flip = {\n ...(flipH !== undefined ? { horizontal: flipH } : {}),\n ...(flipV !== undefined ? { vertical: flipV } : {}),\n };\n }\n }\n }\n\n // Blip recolor effects (a:lum/a:hsl/a:tint/...) under a:blip — image\n // brightness/contrast/tint adjustments applied directly to the image data.\n const blipResult = blipDesc.parse(blip, ctx);\n if (blipResult.blipEffects) imageOpts.blipEffects = blipResult.blipEffects;\n\n // Blip extension: a14:useLocalDpi (rendering hint, round-trip verbatim).\n const useLocalDpi = readBlipUseLocalDpi(blip);\n if (useLocalDpi !== undefined) imageOpts.useLocalDpi = useLocalDpi;\n\n // Blip extension: asvg:svgBlip — when present, the a:blip r:embed is the\n // raster fallback and the SVG part is referenced here. Restructure into an\n // SvgMediaOptions (vector primary + raster fallback) so stringify re-emits\n // both branches; otherwise the SVG is dropped on round-trip.\n const svg = readBlipSvg(blip, ctx);\n if (svg) {\n imageOpts.fallback = { type, data: imageData };\n imageOpts.type = \"svg\";\n imageOpts.data = svg.data;\n }\n\n return { image: imageOpts as unknown as ImageOptions };\n}\n\n/**\n * Read the `a14:useLocalDpi` blip extension (val=\"0\" → false, \"1\" → true).\n * Returns undefined when the blip has no useLocalDpi extension.\n */\nfunction readBlipUseLocalDpi(blip: Element): boolean | undefined {\n const extLst = findChild(blip, \"a:extLst\");\n if (!extLst) return undefined;\n for (const ext of extLst.elements ?? []) {\n if (ext.type !== \"element\" || ext.name !== \"a:ext\") continue;\n const useLocalDpiEl = findChild(ext, \"a14:useLocalDpi\");\n if (useLocalDpiEl) {\n const val = useLocalDpiEl.attributes?.[\"val\"];\n return val !== \"0\";\n }\n }\n return undefined;\n}\n\n/**\n * Read the `asvg:svgBlip` blip extension. When present, the surrounding\n * `a:blip` r:embed carries the raster fallback and this extension targets the\n * vector SVG part. Returns the SVG bytes so the picture round-trips as an\n * SvgMediaOptions (vector primary + raster fallback); undefined when no SVG\n * extension exists.\n */\nfunction readBlipSvg(\n blip: Element,\n ctx: DocxReadContext,\n): { data: Uint8Array; fileName: string } | undefined {\n const extLst = findChild(blip, \"a:extLst\");\n if (!extLst) return undefined;\n for (const ext of extLst.elements ?? []) {\n if (ext.type !== \"element\" || ext.name !== \"a:ext\") continue;\n const svgBlip = findChild(ext, \"asvg:svgBlip\");\n if (svgBlip) {\n const rEmbed = attr(svgBlip, \"r:embed\");\n if (!rEmbed) return undefined;\n const svgPath = ctx.resolveRelationship(rEmbed);\n if (!svgPath) return undefined;\n const data = ctx.docx.doc.getRaw(svgPath);\n if (!data) return undefined;\n return { data, fileName: svgPath.split(\"/\").pop() ?? svgPath };\n }\n }\n return undefined;\n}\n\n// ── WPS shape / WPG group parsing ───────────────────────────────────────────\n\n/**\n * Read the blip-fill crop rectangle (`a:srcRect`, l/t/r/b percentage insets)\n * from a `pic:blipFill` parent. Returns undefined when there is no crop.\n */\nfunction readSourceRectangle(parent: Element): SourceRectangleOptions | undefined {\n const sr = findChild(parent, \"a:srcRect\");\n if (!sr) return undefined;\n const result: SourceRectangleOptions = {};\n const left = attrNum(sr, \"l\");\n const top = attrNum(sr, \"t\");\n const right = attrNum(sr, \"r\");\n const bottom = attrNum(sr, \"b\");\n if (left !== undefined) result.left = left;\n if (top !== undefined) result.top = top;\n if (right !== undefined) result.right = right;\n if (bottom !== undefined) result.bottom = bottom;\n // An empty <a:srcRect/> is meaningful (explicit no-crop reset), so return\n // the object even when no l/t/r/b attributes are present.\n return result as SourceRectangleOptions;\n}\n\n/**\n * Read pic:cNvPr (id/name/descr) from a drawing's pic:nvPicPr. Returns\n * undefined when there is no non-visual properties block.\n */\nfunction readPicCnvPr(el: Element): NonVisualPropertiesOptions | undefined {\n const nvPicPr = findFirst(el, \"pic:nvPicPr\");\n if (!nvPicPr) return undefined;\n const result: NonVisualPropertiesOptions = {};\n const cNvPr = findChild(nvPicPr, \"pic:cNvPr\");\n if (cNvPr) {\n const id = attrNum(cNvPr, \"id\");\n const name = attr(cNvPr, \"name\");\n const descr = attr(cNvPr, \"descr\");\n if (id !== undefined) result.id = id;\n if (name) result.name = name;\n if (descr) result.description = descr;\n }\n // pic:cNvPicPr sibling — only preferRelativeResize is tracked (Word omits\n // the default true; an explicit false round-trips as \"0\").\n const cNvPicPr = findChild(nvPicPr, \"pic:cNvPicPr\");\n if (cNvPicPr) {\n const preferRelativeResize = attrBool(cNvPicPr, \"preferRelativeResize\");\n if (preferRelativeResize !== undefined) result.preferRelativeResize = preferRelativeResize;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/**\n * Read a fill element from a shape-properties parent, if present. Delegates to\n * core {@link fillDesc} so solid/gradient/pattern/group/no fills all round-trip\n * through the shared descriptor.\n */\nfunction readShapeFill(parent: Element, ctx: DocxReadContext) {\n const fillChild =\n findChild(parent, \"a:noFill\") ??\n findChild(parent, \"a:solidFill\") ??\n findChild(parent, \"a:gradFill\") ??\n findChild(parent, \"a:pattFill\") ??\n findChild(parent, \"a:grpFill\") ??\n findChild(parent, \"a:blipFill\");\n if (!fillChild) return undefined;\n return fillDesc.parse(parent, ctx);\n}\n\n/**\n * Read a single style-matrix reference (a:lnRef/a:fillRef/a:effectRef/a:fontRef):\n * the `idx` attribute plus an optional EG_ColorChoice color override.\n */\nfunction parseStyleRef(el: Element, ctx: DocxReadContext): StyleMatrixReferenceOptions | undefined {\n const idx = attr(el, \"idx\");\n if (idx === undefined) return undefined;\n const result: StyleMatrixReferenceOptions = { idx };\n const color = parseColorChoice(el, ctx);\n if (color && Object.keys(color).length > 0) result.color = color;\n return result as StyleMatrixReferenceOptions;\n}\n\n/**\n * Parse a wps:style (CT_ShapeStyle): line/fill/effect/font references into the\n * document theme. Delegates color to the shared core {@link parseColorChoice}.\n */\nfunction parseShapeStyle(styleEl: Element, ctx: DocxReadContext): ShapeStyleOptions {\n const result: ShapeStyleOptions = {};\n const lnRef = findChild(styleEl, \"a:lnRef\");\n if (lnRef) result.lineReference = parseStyleRef(lnRef, ctx);\n const fillRef = findChild(styleEl, \"a:fillRef\");\n if (fillRef) result.fillReference = parseStyleRef(fillRef, ctx);\n const effectRef = findChild(styleEl, \"a:effectRef\");\n if (effectRef) result.effectReference = parseStyleRef(effectRef, ctx);\n const fontRef = findChild(styleEl, \"a:fontRef\");\n if (fontRef) result.fontReference = parseStyleRef(fontRef, ctx);\n return result as ShapeStyleOptions;\n}\n\n/**\n * Parse the shared core of a `wps:wsp` element (everything except the outer\n * drawing transformation/floating): text content, body properties, fill, and\n * the txBox non-visual flag. Used both for standalone wps shapes and for wps\n * children nested inside a wpg group.\n */\nfunction parseWpsShapeCore(wspEl: Element, ctx: DocxReadContext): WpsShapeCoreOptions {\n const result: Partial<WpsShapeCoreOptions> = {};\n\n // Text content — w:txbxContent (w namespace, per CT_TxbxContent → w:EG_BlockLevelElts)\n // holds the shape's paragraphs, even when wrapped in wps:txbx.\n const txbxContent = findFirst(wspEl, \"w:txbxContent\");\n const children: WpsShapeCoreOptions[\"children\"] = [];\n if (txbxContent) {\n for (const child of txbxContent.elements ?? []) {\n if (child.name === \"w:p\") children.push(parseParagraph(child, ctx));\n }\n }\n result.children = children;\n\n // Non-visual shape properties: wps:cNvPr (id/name/descr) + a choice of\n // wps:cNvSpPr (txBox marker) or wps:cNvCnPr (connector) — mutually exclusive.\n const cNvPr = findChild(wspEl, \"wps:cNvPr\");\n const cNvSpPr = findChild(wspEl, \"wps:cNvSpPr\");\n const cNvCnPr = findChild(wspEl, \"wps:cNvCnPr\");\n const txBox = cNvSpPr ? attr(cNvSpPr, \"txBox\") : undefined;\n if (cNvPr || txBox !== undefined || cNvCnPr) {\n const nvp: NonVisualShapePropertiesOptions = {};\n if (cNvPr) {\n const id = attrNum(cNvPr, \"id\");\n const name = attr(cNvPr, \"name\");\n const descr = attr(cNvPr, \"descr\");\n const title = attr(cNvPr, \"title\");\n if (id !== undefined) nvp.id = id;\n if (name) nvp.name = name;\n if (descr) nvp.description = descr;\n if (title) nvp.title = title;\n }\n if (cNvCnPr) nvp.connector = true;\n else if (txBox !== undefined) nvp.textBox = txBox;\n result.nonVisualProperties = nvp as NonVisualShapePropertiesOptions;\n }\n\n // Shape properties (wps:spPr) — fill/outline/effects/geometry round-trip via\n // the shared core descriptors (bidirectional) so spPr stays structured.\n const spPr = findChild(wspEl, \"wps:spPr\");\n if (spPr) {\n const fill = readShapeFill(spPr, ctx);\n if (fill) result.fill = fill;\n const ln = findChild(spPr, \"a:ln\");\n if (ln) result.outline = outlineDesc.parse(ln, ctx);\n const effectLst = findChild(spPr, \"a:effectLst\");\n if (effectLst) result.effects = effectListDesc.parse(effectLst, ctx);\n const custGeom = findChild(spPr, \"a:custGeom\");\n if (custGeom) result.customGeometry = customGeometryDesc.parse(custGeom, ctx);\n const prstGeom = findChild(spPr, \"a:prstGeom\");\n if (prstGeom) result.presetGeometry = presetGeometryDesc.parse(prstGeom, ctx);\n const scene3d = findChild(spPr, \"a:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n const sp3d = findChild(spPr, \"a:sp3d\");\n if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, ctx);\n }\n\n // Body properties (wps:bodyPr)\n const bodyPr = findChild(wspEl, \"wps:bodyPr\");\n if (bodyPr) result.bodyProperties = parseBodyProperties(bodyPr, ctx);\n\n // Shape style (wps:style) — theme references (lnRef/fillRef/effectRef/fontRef)\n const styleEl = findChild(wspEl, \"wps:style\");\n if (styleEl) result.style = parseShapeStyle(styleEl, ctx);\n\n return result as WpsShapeCoreOptions;\n}\n\n/**\n * Build a child's MediaDataTransformation directly from an `a:xfrm`, keeping\n * EMU values intact (no pixel rounding) so group child coordinates survive\n * round-trip without drift.\n */\nfunction readChildTransformation(spPr: Element | undefined): MediaDataTransformation {\n const result: MediaDataTransformation = {\n pixels: { x: 0, y: 0 },\n emus: { x: 0, y: 0 },\n };\n if (!spPr) return result;\n const xfrm = findChild(spPr, \"a:xfrm\");\n if (!xfrm) return result;\n\n const off = findChild(xfrm, \"a:off\");\n if (off?.attributes) {\n const x = Number(off.attributes[\"x\"] ?? 0);\n const y = Number(off.attributes[\"y\"] ?? 0);\n result.offset = {\n emus: { x, y },\n pixels: { x: convertEmuToPixels(x), y: convertEmuToPixels(y) },\n };\n }\n const ext = findChild(xfrm, \"a:ext\");\n if (ext?.attributes) {\n const cx = Number(ext.attributes[\"cx\"] ?? 0);\n const cy = Number(ext.attributes[\"cy\"] ?? 0);\n result.emus = { x: cx, y: cy };\n result.pixels = { x: convertEmuToPixels(cx), y: convertEmuToPixels(cy) };\n }\n\n const flipH = attrBool(xfrm, \"flipH\");\n const flipV = attrBool(xfrm, \"flipV\");\n if (flipH !== undefined || flipV !== undefined) {\n const flip: { horizontal?: boolean; vertical?: boolean } = {};\n if (flipH !== undefined) flip.horizontal = flipH;\n if (flipV !== undefined) flip.vertical = flipV;\n result.flip = flip;\n }\n const rot = attrNum(xfrm, \"rot\");\n if (rot !== undefined) result.rotation = rot;\n\n return result;\n}\n\n/**\n * Parse a `wps:wsp` nested inside a wpg group into a {@link WpsMediaData} child\n * (its transformation kept as EMU via {@link readChildTransformation}).\n */\nfunction parseWpsChildMediaData(wspEl: Element, ctx: DocxReadContext): WpsMediaData | undefined {\n const data = parseWpsShapeCore(wspEl, ctx);\n const spPr = findChild(wspEl, \"wps:spPr\");\n return {\n type: \"wps\",\n transformation: readChildTransformation(spPr),\n data,\n };\n}\n\n/**\n * Parse a `pic:pic` nested inside a wpg group into a {@link MediaData} child.\n * Uses the original media path as the registration key so repeated references\n * to the same image collapse to one media entry.\n */\nfunction parsePicChildMediaData(picEl: Element, ctx: DocxReadContext): MediaData | undefined {\n const blip = findFirst(picEl, \"a:blip\");\n if (!blip) return undefined;\n const rEmbed = attr(blip, \"r:embed\");\n if (!rEmbed) return undefined;\n\n const mediaPath = ctx.resolveRelationship(rEmbed);\n if (!mediaPath) return undefined;\n const data = ctx.docx.doc.getRaw(mediaPath);\n if (!data) return undefined;\n\n const spPr = findChild(picEl, \"pic:spPr\");\n const result: MediaData = {\n type: imageTypeFromPath(mediaPath),\n // fileName is the bare basename; the compiler writes it under word/media/.\n fileName: mediaPath.split(\"/\").pop() ?? mediaPath,\n data,\n transformation: readChildTransformation(spPr),\n };\n const blipFill = findChild(picEl, \"pic:blipFill\");\n if (blipFill) {\n const srcRect = readSourceRectangle(blipFill);\n if (srcRect) result.sourceRectangle = srcRect;\n }\n const cNvPr = readPicCnvPr(picEl);\n if (cNvPr) result.nonVisualProperties = cNvPr;\n // Grouped picture spPr (fill/outline) rides on WpgCommonMediaData so it\n // round-trips through stringifyGroupChild → stringifyShapeProps.\n if (spPr) {\n const fill = readShapeFill(spPr, ctx);\n if (fill) (result as MediaData & WpgCommonMediaData).fill = fill;\n const ln = findChild(spPr, \"a:ln\");\n if (ln) (result as MediaData & WpgCommonMediaData).outline = outlineDesc.parse(ln, ctx);\n }\n // asvg:svgBlip extension — when present, the a:blip r:embed is the raster\n // fallback and the vector SVG lives in the extension. Reshape into an\n // SvgMediaData so stringify re-emits both (vector + fallback); otherwise the\n // SVG is dropped on round-trip.\n const svg = readBlipSvg(blip, ctx);\n if (svg) {\n return {\n ...result,\n type: \"svg\",\n data: svg.data,\n fileName: svg.fileName,\n fallback: {\n type: result.type,\n fileName: result.fileName,\n data,\n transformation: result.transformation,\n },\n } as MediaData;\n }\n return result;\n}\n\n/**\n * Parse a standalone wps shape drawing (graphicData URI wordprocessingShape).\n */\nfunction parseWpsShapeDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { wpsShape: WpsShapeRunOptions } | undefined {\n const wsp = findFirst(el, \"wps:wsp\");\n if (!wsp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const data = parseWpsShapeCore(wsp, ctx);\n\n const shape: WpsShapeRunOptions = {\n ...data,\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (info.floating) shape.floating = info.floating;\n if (info.altText) shape.altText = info.altText;\n if (info.graphicFrameLocks !== undefined) shape.graphicFrameLocks = info.graphicFrameLocks;\n\n return { wpsShape: shape as WpsShapeRunOptions };\n}\n\n/**\n * Parse a wpg group drawing (graphicData URI wordprocessingGroup).\n */\nfunction parseWpgGroupDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { wpgGroup: WpgGroupRunOptions } | undefined {\n const wgp = findFirst(el, \"wpg:wgp\");\n if (!wgp) return undefined;\n\n const info = parseAnchorOrInline(el) ?? {};\n const grpSpPr = findChild(wgp, \"wpg:grpSpPr\");\n const { childOffset, childExtent } = readGroupCoords(grpSpPr);\n\n const group: WpgGroupRunOptions = {\n children: parseGroupChildren(wgp, ctx),\n transformation: {\n width: info.width ?? 0,\n height: info.height ?? 0,\n ...(info.effectExtent ? { effectExtent: info.effectExtent } : {}),\n },\n };\n if (childOffset) group.childOffset = childOffset;\n if (childExtent) group.childExtent = childExtent;\n if (info.floating) group.floating = info.floating;\n if (info.altText) group.altText = info.altText;\n if (info.graphicFrameLocks !== undefined) group.graphicFrameLocks = info.graphicFrameLocks;\n const grpSpLocks = readGrpSpLocks(findChild(wgp, \"wpg:cNvGrpSpPr\"));\n if (grpSpLocks) group.groupShapeLocks = grpSpLocks;\n // Group shape props (grpSpPr): fill + effects round-trip via shared descriptors.\n if (grpSpPr) {\n const fill = readShapeFill(grpSpPr, ctx);\n if (fill) group.fill = fill;\n const effectLst = findChild(grpSpPr, \"a:effectLst\");\n if (effectLst) group.effects = effectListDesc.parse(effectLst, ctx);\n }\n\n return { wpgGroup: group as WpgGroupRunOptions };\n}\n\n/**\n * Read chOff/chExt child coordinate space from a group's grpSpPr/a:xfrm.\n * Shared by the top-level wpg:wgp and nested wpg:grpSp.\n */\nfunction readGroupCoords(grpSpPr: Element | undefined): {\n childOffset?: ChildOffset;\n childExtent?: ChildExtent;\n} {\n if (!grpSpPr) return {};\n const xfrm = findChild(grpSpPr, \"a:xfrm\");\n if (!xfrm) return {};\n let childOffset: ChildOffset | undefined;\n let childExtent: ChildExtent | undefined;\n const off = findChild(xfrm, \"a:chOff\");\n if (off?.attributes) {\n childOffset = { x: Number(off.attributes[\"x\"] ?? 0), y: Number(off.attributes[\"y\"] ?? 0) };\n }\n const ext = findChild(xfrm, \"a:chExt\");\n if (ext?.attributes) {\n childExtent = { cx: Number(ext.attributes[\"cx\"] ?? 0), cy: Number(ext.attributes[\"cy\"] ?? 0) };\n }\n return { childOffset, childExtent };\n}\n\n/**\n * Parse the children of a group element (CT_WordprocessingGroup choice):\n * wps:wsp shapes, pic:pic pictures, and nested wpg:grpSp groups (recursive).\n */\nfunction parseGroupChildren(groupEl: Element, ctx: DocxReadContext): GroupChildMediaData[] {\n const children: GroupChildMediaData[] = [];\n for (const child of groupEl.elements ?? []) {\n if (child.type !== \"element\") continue;\n const md = parseGroupChild(child, ctx);\n if (md) children.push(md);\n }\n return children;\n}\n\nfunction parseGroupChild(el: Element, ctx: DocxReadContext): GroupChildMediaData | undefined {\n if (el.name === \"wps:wsp\") return parseWpsChildMediaData(el, ctx);\n if (el.name === \"pic:pic\") {\n return parsePicChildMediaData(el, ctx) as GroupChildMediaData | undefined;\n }\n if (el.name === \"wpg:grpSp\") return parseNestedGroup(el, ctx);\n return undefined;\n}\n\n/**\n * Parse a nested wpg:grpSp (CT_WordprocessingGroup) into a WpgMediaData child.\n * Mirrors the top-level group: grpSpPr transform + chOff/chExt + fill, with its\n * own children (which may nest further groups).\n */\nfunction parseNestedGroup(grpSpEl: Element, ctx: DocxReadContext): WpgMediaData {\n const grpSpPr = findChild(grpSpEl, \"wpg:grpSpPr\");\n const { childOffset, childExtent } = readGroupCoords(grpSpPr);\n const result: WpgMediaData = {\n type: \"wpg\",\n transformation: readChildTransformation(grpSpPr),\n children: parseGroupChildren(grpSpEl, ctx),\n };\n if (childOffset) result.childOffset = childOffset;\n if (childExtent) result.childExtent = childExtent;\n const grpSpLocks = readGrpSpLocks(findChild(grpSpEl, \"wpg:cNvGrpSpPr\"));\n if (grpSpLocks) result.groupShapeLocks = grpSpLocks;\n if (grpSpPr) {\n const fill = readShapeFill(grpSpPr, ctx);\n if (fill) result.fill = fill;\n }\n return result;\n}\n\n// ── Floating (anchor) parse helpers ─────────────────────────────────────────\n\n/** Map wp:positionH/V children + relativeFrom into a position-options object. */\nfunction readPosition(\n posEl: Element,\n): HorizontalPositionOptions | VerticalPositionOptions | undefined {\n const relative = attr(posEl, \"relativeFrom\");\n const alignEl = findChild(posEl, \"wp:align\");\n const posOffset = findChild(posEl, \"wp:posOffset\");\n const result: { relative?: string; align?: string; offset?: number } = {};\n if (relative) result.relative = relative;\n if (alignEl) {\n const a = textOf(alignEl);\n if (a) result.align = a;\n } else if (posOffset) {\n const val = Number(textOf(posOffset));\n if (!isNaN(val)) result.offset = val;\n }\n return Object.keys(result).length > 0\n ? (result as HorizontalPositionOptions | VerticalPositionOptions)\n : undefined;\n}\n\n/** Read wp:wrapPolygon (start + lineTo points) into a WrapPolygon, if present. */\nfunction readWrapPolygon(el: Element): WrapPolygon | undefined {\n const poly = findChild(el, \"wp:wrapPolygon\");\n if (!poly) return undefined;\n const points: { x: number; y: number }[] = [];\n const start = findChild(poly, \"wp:start\");\n if (start) points.push({ x: attrNum(start, \"x\") ?? 0, y: attrNum(start, \"y\") ?? 0 });\n for (const child of poly.elements ?? []) {\n if (child.name === \"wp:lineTo\") {\n points.push({ x: attrNum(child, \"x\") ?? 0, y: attrNum(child, \"y\") ?? 0 });\n }\n }\n if (points.length === 0) return undefined;\n return { edited: attrBool(poly, \"edited\"), points };\n}\n\n/** Map the wp:anchor wrap child element into a TextWrapping ({ type, side? }). */\nfunction readWrap(anchor: Element): TextWrapping | undefined {\n const WRAP_TYPE: ReadonlyArray<[string, TextWrapping[\"type\"]]> = [\n [\"wrapNone\", TextWrappingType.NONE],\n [\"wrapSquare\", TextWrappingType.SQUARE],\n [\"wrapTight\", TextWrappingType.TIGHT],\n [\"wrapTopAndBottom\", TextWrappingType.TOP_AND_BOTTOM],\n [\"wrapThrough\", TextWrappingType.THROUGH],\n ];\n for (const [name, type] of WRAP_TYPE) {\n const el = findChild(anchor, `wp:${name}`);\n if (!el) continue;\n const wrap: TextWrapping = { type };\n const side = attr(el, \"wrapText\");\n if (side) wrap.side = side as TextWrapping[\"side\"];\n // wrapTight/wrapThrough carry a contour polygon; preserve it verbatim.\n if (name === \"wrapTight\" || name === \"wrapThrough\") {\n const polygon = readWrapPolygon(el);\n if (polygon) wrap.polygon = polygon;\n }\n return wrap;\n }\n return undefined;\n}\n\n// ── Common helpers ──────────────────────────────────────────────────────────\n\nfunction getDrawingExtent(el: Element): { width?: number; height?: number } {\n const inline = findFirst(el, \"wp:inline\");\n const anchor = inline ? undefined : findFirst(el, \"wp:anchor\");\n const parent = inline ?? anchor;\n if (!parent) return {};\n\n const extent = findChild(parent, \"wp:extent\");\n if (!extent) return {};\n\n const cxEmu = attrNum(extent, \"cx\");\n const cyEmu = attrNum(extent, \"cy\");\n return {\n ...(cxEmu !== undefined ? { width: cxEmu } : {}),\n ...(cyEmu !== undefined ? { height: cyEmu } : {}),\n };\n}\n\n// ── Chart parsing ───────────────────────────────────────────────────────────\n\n/**\n * Look up a relationship ID in a map, with fallback for double \"rId\" prefix\n * that the library's generation code produces (e.g. \"rIdrId7\" → \"rId7\").\n */\nfunction lookupRId(map: Map<string, string>, rId: string | undefined): string | undefined {\n if (!rId) return undefined;\n const direct = map.get(rId);\n if (direct) return direct;\n // Fallback: strip one \"rId\" prefix when the value starts with \"rIdrId\"\n if (rId.startsWith(\"rIdrId\")) return map.get(rId.slice(3));\n return undefined;\n}\n\nfunction parseChartDrawing(el: Element, ctx: DocxReadContext): { chart: ChartOptions } | undefined {\n const chartRef = findFirst(el, \"c:chart\");\n if (!chartRef) return undefined;\n\n const rId = attr(chartRef, \"r:id\");\n const chartPath = lookupRId(ctx.docx.partRefs.charts, rId);\n if (!chartPath) return undefined;\n\n const chartXml = ctx.docx.doc.get(chartPath);\n if (!chartXml) return undefined;\n\n const opts = parseChartXml(chartXml);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { chart: opts as unknown as ChartOptions };\n}\n\n/**\n * Parse c:chartSpace element into ChartOptions.\n */\nfunction parseChartXml(el: Element): Record<string, unknown> | undefined {\n const chart = findChild(el, \"c:chart\");\n if (!chart) return undefined;\n\n const opts: Record<string, unknown> = {};\n\n // Title: c:chart → c:title → c:tx → c:rich → a:p → a:r → a:t\n const titleEl = findChild(chart, \"c:title\");\n if (titleEl) {\n const rich = findFirst(titleEl, \"c:rich\");\n if (rich) {\n const t = findFirst(rich, \"a:t\");\n if (t) {\n const title = textOf(t);\n if (title) opts.title = title;\n }\n }\n }\n\n // Plot area → chart type\n const plotArea = findChild(chart, \"c:plotArea\");\n if (!plotArea) return undefined;\n\n let chartType: string | undefined;\n let typeElement: Element | undefined;\n\n for (const child of plotArea.elements ?? []) {\n switch (child.name) {\n case \"c:barChart\": {\n const barDir = findChild(child, \"c:barDir\");\n chartType = barDir && attr(barDir, \"val\") === \"bar\" ? \"bar\" : \"column\";\n typeElement = child;\n break;\n }\n case \"c:lineChart\":\n chartType = \"line\";\n typeElement = child;\n break;\n case \"c:pieChart\":\n chartType = \"pie\";\n typeElement = child;\n break;\n case \"c:areaChart\":\n chartType = \"area\";\n typeElement = child;\n break;\n case \"c:scatterChart\":\n chartType = \"scatter\";\n typeElement = child;\n break;\n }\n if (chartType) break;\n }\n\n if (!chartType || !typeElement) return undefined;\n opts.type = chartType;\n\n // Parse series\n const series: { name: string; values: number[] }[] = [];\n let categories: string[] | undefined;\n\n for (const serEl of typeElement.elements ?? []) {\n if (serEl.name !== \"c:ser\") continue;\n\n // Series name: c:tx → c:strCache → c:pt → c:v\n const nameParts = extractStrCache(serEl, \"c:tx\");\n // Categories: c:cat → c:strCache → c:pt → c:v\n const cats = extractStrCache(serEl, \"c:cat\");\n if (cats.length > 0 && !categories) categories = cats;\n // Values: c:val → c:numCache → c:pt → c:v\n const vals = extractNumCache(serEl);\n\n series.push({ name: nameParts[0] ?? \"\", values: vals });\n }\n\n opts.categories = categories ?? [];\n opts.series = series;\n\n // Legend\n opts.showLegend = findChild(chart, \"c:legend\") !== undefined;\n\n // Style\n const styleEl = findChild(el, \"c:style\");\n if (styleEl) {\n const val = attrNum(styleEl, \"val\");\n if (val !== undefined) opts.style = val;\n }\n\n return opts;\n}\n\n/**\n * Extract string values from c:strCache within a container element.\n */\nfunction extractStrCache(parent: Element, containerName: string): string[] {\n const container = findChild(parent, containerName);\n if (!container) return [];\n const cache = findFirst(container, \"c:strCache\");\n if (!cache) return [];\n\n const values: string[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) values.push(textOf(v) ?? \"\");\n }\n return values;\n}\n\n/**\n * Extract numeric values from c:numCache within a c:val container.\n */\nfunction extractNumCache(parent: Element): number[] {\n const valEl = findChild(parent, \"c:val\");\n if (!valEl) return [];\n const cache = findFirst(valEl, \"c:numCache\");\n if (!cache) return [];\n\n const values: number[] = [];\n for (const pt of cache.elements ?? []) {\n if (pt.name !== \"c:pt\") continue;\n const v = findChild(pt, \"c:v\");\n if (v) {\n const num = Number(textOf(v));\n if (!isNaN(num)) values.push(num);\n }\n }\n return values;\n}\n\n// ── SmartArt parsing ────────────────────────────────────────────────────────\n\nfunction parseSmartArtDrawing(\n el: Element,\n ctx: DocxReadContext,\n): { smartArt: SmartArtOptions } | undefined {\n const relIds = findFirst(el, \"dgm:relIds\");\n if (!relIds) return undefined;\n\n const rId = attr(relIds, \"r:dm\");\n const dataPath = lookupRId(ctx.docx.partRefs.diagramData, rId);\n if (!dataPath) return undefined;\n\n const dataEl = ctx.docx.doc.get(dataPath);\n if (!dataEl) return undefined;\n\n const opts = parseSmartArtDataXml(dataEl);\n if (!opts) return undefined;\n\n const ext = getDrawingExtent(el);\n if (ext.width !== undefined || ext.height !== undefined) {\n (opts as Record<string, unknown>).transformation = {\n ...ext,\n };\n }\n\n return { smartArt: opts as unknown as SmartArtOptions };\n}\n\n/**\n * Parse dgm:dataModel element into SmartArtOptions.\n */\nfunction parseSmartArtDataXml(el: Element): Record<string, unknown> | undefined {\n const ptLst = findChild(el, \"dgm:ptLst\");\n if (!ptLst) return undefined;\n\n const opts: Record<string, unknown> = {};\n const nodeMap = new Map<string, string>(); // modelId → text\n\n for (const pt of ptLst.elements ?? []) {\n if (pt.name !== \"dgm:pt\") continue;\n const type = attr(pt, \"type\");\n const modelId = attr(pt, \"modelId\");\n\n if (type === \"doc\") {\n // Extract layout/style/color from prSet URIs\n const prSet = findChild(pt, \"dgm:prSet\");\n if (prSet) {\n const loTypeId = attr(prSet, \"loTypeId\") ?? \"\";\n const qsTypeId = attr(prSet, \"qsTypeId\") ?? \"\";\n const csTypeId = attr(prSet, \"csTypeId\") ?? \"\";\n\n const layout = loTypeId.split(\"/\").pop();\n if (layout) opts.layout = layout;\n const style = qsTypeId.split(\"/\").pop();\n if (style) opts.style = style;\n const color = csTypeId.split(\"/\").pop();\n if (color) opts.color = color;\n }\n } else if (type === \"node\" && modelId) {\n // Extract text: dgm:t → a:p → a:r → a:t\n const t = findFirst(pt, \"a:t\");\n nodeMap.set(modelId, t ? (textOf(t) ?? \"\") : \"\");\n }\n }\n\n // Build tree from connections\n const cxnLst = findChild(el, \"dgm:cxnLst\");\n if (!cxnLst) {\n opts.data = { nodes: [] };\n return opts;\n }\n\n // Map: parentId → childIds\n const childrenMap = new Map<string, string[]>();\n for (const cxn of cxnLst.elements ?? []) {\n if (cxn.name !== \"dgm:cxn\") continue;\n const srcId = attr(cxn, \"srcId\");\n const destId = attr(cxn, \"destId\");\n if (!srcId || !destId || !nodeMap.has(destId)) continue;\n\n let arr = childrenMap.get(srcId);\n if (!arr) {\n arr = [];\n childrenMap.set(srcId, arr);\n }\n arr.push(destId);\n }\n\n // Root children are connected from doc node (modelId=\"0\")\n const topIds = childrenMap.get(\"0\") ?? [];\n opts.data = { nodes: topIds.map((id) => buildSmartArtNode(id, nodeMap, childrenMap)) };\n\n return opts;\n}\n\nfunction buildSmartArtNode(\n id: string,\n nodeMap: Map<string, string>,\n childrenMap: Map<string, string[]>,\n): { text: string; children?: unknown[] } {\n const text = nodeMap.get(id) ?? \"\";\n const childIds = childrenMap.get(id) ?? [];\n\n if (childIds.length === 0) return { text };\n return { text, children: childIds.map((cid) => buildSmartArtNode(cid, nodeMap, childrenMap)) };\n}\n","/**\n * Drawing descriptor for DOCX documents.\n *\n * Produces `<w:drawing>` XML directly from media data and options,\n * eliminating the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain (~10 instances per drawing in the old path).\n *\n * Common path (inline image/chart/smartart without advanced properties):\n * zero XmlComponent instances — pure string concatenation.\n *\n * Advanced properties (outline, fill, effects on images) and floating\n * positioning use core `create*()` + `.toXml({stack:[]})` for sub-elements\n * (lightweight BuilderElement instances, not deep hierarchies).\n *\n * Reference: ISO/IEC 29500-4, wml.xsd, CT_Drawing\n *\n * @module\n */\n\nimport { TargetModeType } from \"@office-open/core\";\nimport { convertToEmu, uniqueNumericIdCreator, uniqueId } from \"@office-open/core\";\nimport type { CustomDescriptor, WriteContext } from \"@office-open/core/descriptor\";\nimport type { FillOptions } from \"@office-open/core/drawingml\";\nimport {\n calculateEffectExtent,\n createColorElement,\n createEffectDag,\n customGeometryDesc,\n effectListDesc,\n fillDesc,\n outlineDesc,\n presetGeometryDesc,\n scene3DDesc,\n shape3DDesc,\n transform2DDesc,\n} from \"@office-open/core/drawingml\";\nimport { escapeXml } from \"@office-open/xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type {\n ChartMediaData,\n ExtendedMediaData,\n GroupChildMediaData,\n MediaData,\n MediaDataTransformation,\n SmartArtMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport type { DocPropertiesOptions, HyperlinkOptions } from \"./doc-properties/doc-properties\";\n// Import parse function from drawing-parse.ts (parse path)\nimport { parseDrawingRun } from \"./drawing-parse\";\nimport type { Floating, HorizontalPositionOptions, VerticalPositionOptions } from \"./floating\";\nimport type { Margins } from \"./floating\";\nimport { HorizontalPositionRelativeFrom, VerticalPositionRelativeFrom } from \"./floating\";\nimport type { BlipEffectsOptions } from \"./inline/graphic/graphic-data/pic/blip/blip-effects\";\nimport type { SourceRectangleOptions } from \"./inline/graphic/graphic-data/pic/blip/source-rectangle\";\nimport type { TileOptions } from \"./inline/graphic/graphic-data/pic/blip/tile\";\nimport type { EffectListOptions } from \"./inline/graphic/graphic-data/pic/effects/effect-list\";\nimport type { OutlineOptions } from \"./inline/graphic/graphic-data/pic/outline/outline\";\nimport type { ChildOffset, ChildExtent } from \"./inline/graphic/graphic-data/wpg/wpg-group\";\n// wpg/wps types only\nimport {\n createBodyProperties,\n type BodyPropertiesOptions,\n} from \"./inline/graphic/graphic-data/wps/body-properties\";\nimport type { NonVisualShapePropertiesOptions } from \"./inline/graphic/graphic-data/wps/non-visual-shape-properties\";\nimport type {\n ShapeStyleOptions,\n StyleMatrixReferenceOptions,\n WpsShapeCoreOptions,\n} from \"./inline/graphic/graphic-data/wps/wps-shape\";\nimport { TextWrappingSide, TextWrappingType } from \"./text-wrap\";\nimport type { TextWrapping, WrapPolygon } from \"./text-wrap\";\n\n// Noop context for drawingml descriptors that don't use WriteContext\nconst NOOP_CTX: WriteContext = {\n addRelationship: () => \"\",\n addMedia: () => \"\",\n};\n\n// ── Options ──\n\n/**\n * Options for the drawing descriptor.\n *\n * Combines media data with optional visual properties.\n */\n\n/** Locking flags for wp:cNvGraphicFramePr (CT_GraphicalObjectFrameLocking). */\nexport interface GraphicFrameLocksOptions {\n noGrp?: boolean;\n noDrilldown?: boolean;\n noSelect?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\n/**\n * Group shape locks (CT_GroupLocking) carried inside wpg:cNvGrpSpPr.\n * Distinct from GraphicFrameLocksOptions: groups use noUngrp/noRot instead of noDrilldown.\n */\nexport interface GroupShapeLocksOptions {\n noGrp?: boolean;\n noUngrp?: boolean;\n noSelect?: boolean;\n noRot?: boolean;\n noChangeAspect?: boolean;\n noMove?: boolean;\n noResize?: boolean;\n}\n\nexport interface DrawingDescriptorOptions {\n /** Media data (image, chart, smartart, wps, wpg) */\n mediaData: ExtendedMediaData;\n /** Non-visual document properties (name, description, hyperlinks) */\n docProperties?: DocPropertiesOptions;\n /** Floating/anchored positioning (omit for inline) */\n floating?: Floating;\n /** Shape outline */\n outline?: OutlineOptions;\n /** Shape fill */\n fill?: FillOptions;\n /** Shape effects (shadow, glow, etc.) */\n effects?: EffectListOptions;\n /** Image blip effects (brightness, contrast, etc.) */\n blipEffects?: BlipEffectsOptions;\n /** Image tile fill mode */\n tile?: TileOptions;\n /** Graphic frame locks (wp:cNvGraphicFramePr). `{}` → empty element; omit → authoring default. */\n graphicFrameLocks?: GraphicFrameLocksOptions | null;\n}\n\n// ── ID generation ──\n\nlet _docPropsIdGen = uniqueNumericIdCreator();\n\n/** Reset the doc properties ID generator (for testing). */\nexport const resetDrawingIdGen = (): void => {\n _docPropsIdGen = uniqueNumericIdCreator();\n};\n\n// ── Constants ──\n\nconst GRAPHIC_NS = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\nconst PIC_URI = \"http://schemas.openxmlformats.org/drawingml/2006/picture\";\nconst CHART_URI = \"http://schemas.openxmlformats.org/drawingml/2006/chart\";\nconst DGM_URI = \"http://schemas.openxmlformats.org/drawingml/2006/diagram\";\nconst WPS_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\";\nconst WPG_URI = \"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\";\nconst HYPERLINK_REL =\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\";\n// Blip extension URIs (a:extLst under a:blip).\nconst SVG_BLIP_EXT_URI = \"{96DAC541-7B7A-43D3-8B79-37D633B846F1}\";\nconst USE_LOCAL_DPI_EXT_URI = \"{28A0092B-C50C-407E-A947-70E740481C1C}\";\nconst A14_NS = \"http://schemas.microsoft.com/office/drawing/2010/main\";\n\n/**\n * Build the `a14:useLocalDpi` blip extension. Returns \"\" when the hint is\n * absent (undefined) — Word's default. val=\"0\" (useLocalDpi=false) is the\n * common Word emission; val=\"1\" only when explicitly set.\n */\nfunction buildUseLocalDpiExt(useLocalDpi?: boolean): string {\n if (useLocalDpi === undefined) return \"\";\n return `<a:ext uri=\"${USE_LOCAL_DPI_EXT_URI}\"><a14:useLocalDpi xmlns:a14=\"${A14_NS}\" val=\"${\n useLocalDpi ? \"1\" : \"0\"\n }\"/></a:ext>`;\n}\n\n// ── Hyperlink handling ──\n\ninterface HyperlinkIds {\n clickId?: string;\n hoverId?: string;\n}\n\nfunction registerHyperlinks(\n hyperlink: HyperlinkOptions | undefined,\n ctx: BodyContext,\n): HyperlinkIds {\n if (!hyperlink) return {};\n const result: HyperlinkIds = {};\n if (hyperlink.click) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.click,\n TargetModeType.EXTERNAL,\n );\n result.clickId = `rId${linkId}`;\n }\n if (hyperlink.hover) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n HYPERLINK_REL,\n hyperlink.hover,\n TargetModeType.EXTERNAL,\n );\n result.hoverId = `rId${linkId}`;\n }\n return result;\n}\n\nfunction buildHyperlinkChildren(ids: HyperlinkIds): string {\n const parts: string[] = [];\n const aNs = 'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"';\n if (ids.clickId) parts.push(`<a:hlinkClick r:id=\"${ids.clickId}\" ${aNs}/>`);\n if (ids.hoverId) parts.push(`<a:hlinkHover r:id=\"${ids.hoverId}\" ${aNs}/>`);\n return parts.join(\"\");\n}\n\n// ── DocPr ──\n\nfunction stringifyDocPr(opts: DocPropertiesOptions | undefined, hlIds: HyperlinkIds): string {\n const id = opts?.id ?? _docPropsIdGen();\n const name = opts?.name ?? \"\";\n const attrs: string[] = [`id=\"${id}\"`, `name=\"${escapeXml(name)}\"`];\n if (opts?.description != null && opts.description !== undefined) {\n attrs.push(`descr=\"${escapeXml(opts.description)}\"`);\n }\n if (opts?.title != null && opts.title !== undefined) {\n attrs.push(`title=\"${escapeXml(opts.title)}\"`);\n }\n const hlXml = buildHyperlinkChildren(hlIds);\n if (hlXml) {\n return `<wp:docPr ${attrs.join(\" \")}>${hlXml}</wp:docPr>`;\n }\n return `<wp:docPr ${attrs.join(\" \")}/>`;\n}\n\n// ── BlipFill (image data reference) ──\n\n/** Build `<a:srcRect .../>` from a crop spec, or \"\" when there is no crop. */\nfunction buildSrcRectXml(srcRect: SourceRectangleOptions | undefined): string {\n if (!srcRect) return \"\";\n const srAttrs: string[] = [];\n if (srcRect.left !== undefined) srAttrs.push(`l=\"${srcRect.left}\"`);\n if (srcRect.top !== undefined) srAttrs.push(`t=\"${srcRect.top}\"`);\n if (srcRect.right !== undefined) srAttrs.push(`r=\"${srcRect.right}\"`);\n if (srcRect.bottom !== undefined) srAttrs.push(`b=\"${srcRect.bottom}\"`);\n return srAttrs.length ? `<a:srcRect ${srAttrs.join(\" \")}/>` : \"<a:srcRect/>\";\n}\n\nfunction stringifyBlipFill(\n mediaData: MediaData,\n blipEffects?: BlipEffectsOptions,\n tile?: TileOptions,\n): string {\n const fileName =\n mediaData.type === \"svg\" && \"fallback\" in mediaData\n ? mediaData.fallback.fileName\n : mediaData.fileName;\n\n const parts: string[] = [];\n\n // a:blip — cstate omitted unless set; Word's default is \"none\", so emitting\n // it unconditionally inflates round-trip output that originally had none.\n const blipAttrs: string[] = [`r:embed=\"{${escapeXml(fileName)}}\"`];\n\n // Blip extension list: useLocalDpi (rendering hint) + SVG blip reference.\n // Both live in a single shared a:extLst; emitted only when at least one ext\n // is present so blips without extensions stay self-closing.\n const extParts: string[] = [];\n const useLocalDpiExt = buildUseLocalDpiExt(mediaData.useLocalDpi);\n if (useLocalDpiExt) extParts.push(useLocalDpiExt);\n if (mediaData.type === \"svg\") {\n extParts.push(\n `<a:ext uri=\"${SVG_BLIP_EXT_URI}\"><asvg:svgBlip xmlns:asvg=\"http://schemas.microsoft.com/office/drawing/2016/SVG/main\" r:embed=\"{${escapeXml(\n mediaData.fileName,\n )}}\"/></a:ext>`,\n );\n }\n const extLstXml = extParts.length > 0 ? `<a:extLst>${extParts.join(\"\")}</a:extLst>` : \"\";\n\n // Blip effects\n const blipEffectsXml = blipEffects ? buildBlipEffectsXml(blipEffects) : \"\";\n\n const blipContent = extLstXml + blipEffectsXml;\n if (blipContent) {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}>${blipContent}</a:blip>`);\n } else {\n parts.push(`<a:blip ${blipAttrs.join(\" \")}/>`);\n }\n\n // Source rectangle (blip crop)\n const srcRectXml = buildSrcRectXml(mediaData.sourceRectangle);\n if (srcRectXml) parts.push(srcRectXml);\n\n // Tile or stretch\n if (tile) {\n const tileAttrs: string[] = [];\n if (tile.tx !== undefined) tileAttrs.push(`tx=\"${tile.tx}\"`);\n if (tile.ty !== undefined) tileAttrs.push(`ty=\"${tile.ty}\"`);\n if (tile.sx !== undefined) tileAttrs.push(`sx=\"${tile.sx}\"`);\n if (tile.sy !== undefined) tileAttrs.push(`sy=\"${tile.sy}\"`);\n const tileAttrStr = tileAttrs.length ? \" \" + tileAttrs.join(\" \") : \"\";\n parts.push(`<a:tile${tileAttrStr}/>`);\n } else {\n parts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n }\n\n return `<pic:blipFill>${parts.join(\"\")}</pic:blipFill>`;\n}\n\nfunction buildBlipEffectsXml(opts: BlipEffectsOptions): string {\n const parts: string[] = [];\n if (opts.grayscale) parts.push(\"<a:grayscl/>\");\n if (opts.luminance) {\n const a: string[] = [];\n if (opts.luminance.bright !== undefined) a.push(`bright=\"${opts.luminance.bright}\"`);\n if (opts.luminance.contrast !== undefined) a.push(`contrast=\"${opts.luminance.contrast}\"`);\n parts.push(`<a:lum${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n if (opts.biLevel) parts.push(`<a:biLevel thresh=\"${opts.biLevel.threshold}\"/>`);\n if (opts.blur) {\n const a: string[] = [];\n if (opts.blur.radius !== undefined) a.push(`rad=\"${opts.blur.radius}\"`);\n if (opts.blur.grow === false) a.push('grow=\"0\"');\n parts.push(`<a:blur${a.length ? \" \" + a.join(\" \") : \"\"}/>`);\n }\n return parts.join(\"\");\n}\n\n// ── Shape Properties (pic:spPr) ──\n\nfunction stringifyShapeProps(\n transform: MediaDataTransformation,\n outline?: OutlineOptions,\n fill?: FillOptions,\n effects?: EffectListOptions,\n): string {\n const parts: string[] = [];\n\n // Transform\n parts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n\n // Geometry (always rect — preset geometry variations not used for pic)\n parts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n\n if (fill) parts.push(fillDesc.stringify(fill, NOOP_CTX) ?? \"\");\n if (outline) parts.push(outlineDesc.stringify(outline, NOOP_CTX) ?? \"\");\n if (effects) parts.push(effectListDesc.stringify(effects, NOOP_CTX) ?? \"\");\n\n return `<pic:spPr bwMode=\"auto\">${parts.join(\"\")}</pic:spPr>`;\n}\n\n// ── Non-visual picture properties (pic:nvPicPr) ──\n\nfunction stringifyNvPicPr(hlIds: HyperlinkIds, cNvPr?: NonVisualPropertiesOptions): string {\n const hlXml = buildHyperlinkChildren(hlIds);\n const id = cNvPr?.id ?? 0;\n const name = escapeXml(cNvPr?.name ?? \"\");\n // descr omitted when absent — Word never writes an empty descr attribute.\n const descrAttr = cNvPr?.description ? ` descr=\"${escapeXml(cNvPr.description)}\"` : \"\";\n // preferRelativeResize defaults to true; only an explicit false is written.\n const cNvPicPrAttr = cNvPr?.preferRelativeResize === false ? ' preferRelativeResize=\"0\"' : \"\";\n const cNvPrClose = hlXml ? `>${hlXml}</pic:cNvPr>` : \"/>\";\n return (\n `<pic:nvPicPr><pic:cNvPr id=\"${id}\" name=\"${name}\"${descrAttr}${cNvPrClose}` +\n `<pic:cNvPicPr${cNvPicPrAttr}><a:picLocks noChangeAspect=\"1\"/></pic:cNvPicPr></pic:nvPicPr>`\n );\n}\n\n// ── WPS shape (pure string, no class instances) ──\n\nfunction stringifyGroupTransform2D(\n transform: MediaDataTransformation,\n childOffset?: ChildOffset,\n childExtent?: ChildExtent,\n): string {\n const attrs: string[] = [];\n if (transform.flip?.horizontal !== undefined) attrs.push(`flipH=\"${transform.flip.horizontal}\"`);\n if (transform.flip?.vertical !== undefined) attrs.push(`flipV=\"${transform.flip.vertical}\"`);\n if (transform.rotation !== undefined) attrs.push(`rot=\"${transform.rotation}\"`);\n const attrStr = attrs.length ? \" \" + attrs.join(\" \") : \"\";\n\n const off = `<a:off x=\"${transform.offset?.emus?.x ?? 0}\" y=\"${transform.offset?.emus?.y ?? 0}\"/>`;\n const ext = `<a:ext cx=\"${transform.emus.x}\" cy=\"${transform.emus.y}\"/>`;\n const childOffsetXml = childOffset ? `<a:chOff x=\"${childOffset.x}\" y=\"${childOffset.y}\"/>` : \"\";\n const childExtentXml = childExtent\n ? `<a:chExt cx=\"${childExtent.cx}\" cy=\"${childExtent.cy}\"/>`\n : \"\";\n\n return `<a:xfrm${attrStr}>${off}${ext}${childOffsetXml}${childExtentXml}</a:xfrm>`;\n}\n\n/** WpsShape options for stringification (extends WpsShapeCoreOptions with transformation). */\ninterface WpsStringifyOptions extends WpsShapeCoreOptions {\n transformation: MediaDataTransformation;\n}\n\nfunction stringifyWpsShape(opts: WpsStringifyOptions, ctx: BodyContext): string {\n const transform = opts.transformation;\n const spPrParts: string[] = [];\n spPrParts.push(\n transform2DDesc.stringify(\n {\n x: transform.offset?.emus?.x ?? 0,\n y: transform.offset?.emus?.y ?? 0,\n width: transform.emus.x,\n height: transform.emus.y,\n flipHorizontal: transform.flip?.horizontal,\n flipVertical: transform.flip?.vertical,\n rotation: transform.rotation,\n },\n NOOP_CTX,\n ) ?? \"\",\n );\n if (opts.customGeometry) {\n spPrParts.push(customGeometryDesc.stringify(opts.customGeometry, NOOP_CTX) ?? \"\");\n } else if (opts.presetGeometry) {\n spPrParts.push(presetGeometryDesc.stringify(opts.presetGeometry, NOOP_CTX) ?? \"\");\n } else {\n spPrParts.push('<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>');\n }\n if (opts.fill) spPrParts.push(fillDesc.stringify(opts.fill, ctx) ?? \"\");\n if (opts.outline) spPrParts.push(outlineDesc.stringify(opts.outline, NOOP_CTX) ?? \"\");\n if (opts.effectDag) {\n spPrParts.push(createEffectDag(opts.effectDag));\n } else if (opts.effects) {\n spPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n }\n if (opts.scene3d) spPrParts.push(scene3DDesc.stringify(opts.scene3d, NOOP_CTX) ?? \"\");\n if (opts.shape3d) spPrParts.push(shape3DDesc.stringify(opts.shape3d, NOOP_CTX) ?? \"\");\n\n // Non-visual shape properties — default txBox=\"1\"\n const cNvSpPr = opts.nonVisualProperties\n ? stringifyNonVisualShapeProperties(opts.nonVisualProperties)\n : '<wps:cNvSpPr txBox=\"1\"/>';\n\n // Paragraph children — pure JSON stringification\n const childXml =\n opts.children\n ?.map((c) => stringifyParagraphInline(c as ParagraphOptions | string, ctx))\n .join(\"\") ?? \"\";\n\n // Shape style (wps:style) — theme references, emitted after spPr (XSD order)\n const styleXml = opts.style ? stringifyShapeStyle(opts.style) : \"\";\n // wps:txbx — only emit when the shape carries text (text boxes). Pure\n // geometry shapes (no paragraphs) omit txbx in the source.\n const txbxXml = childXml ? `<wps:txbx><w:txbxContent>${childXml}</w:txbxContent></wps:txbx>` : \"\";\n\n return (\n \"<wps:wsp>\" +\n cNvSpPr +\n `<wps:spPr bwMode=\"auto\">${spPrParts.join(\"\")}</wps:spPr>` +\n styleXml +\n txbxXml +\n stringifyBodyPr(opts.bodyProperties) +\n \"</wps:wsp>\"\n );\n}\n\nfunction stringifyNonVisualShapeProperties(opts: NonVisualShapePropertiesOptions): string {\n let xml = \"\";\n // wps:cNvPr — id/name/descr/title (XSD CT_NonVisualDrawingProps)\n if (opts.id !== undefined || opts.name !== undefined) {\n const attrs: string[] = [];\n if (opts.id !== undefined) attrs.push(`id=\"${opts.id}\"`);\n if (opts.name !== undefined) attrs.push(`name=\"${escapeXml(opts.name)}\"`);\n if (opts.description !== undefined) attrs.push(`descr=\"${escapeXml(opts.description)}\"`);\n if (opts.title !== undefined) attrs.push(`title=\"${escapeXml(opts.title)}\"`);\n xml += `<wps:cNvPr ${attrs.join(\" \")}/>`;\n }\n // CT_WordprocessingShape choice: wps:cNvSpPr (text box/autoshape) or\n // wps:cNvCnPr (connector). Connectors carry empty cNvCnPr.\n if (opts.connector) {\n xml += \"<wps:cNvCnPr/>\";\n } else if (opts.textBox !== undefined) {\n xml += `<wps:cNvSpPr txBox=\"${opts.textBox}\"/>`;\n } else {\n xml += \"<wps:cNvSpPr/>\";\n }\n return xml;\n}\n\n/** Stringify a single style-matrix reference (a:lnRef/a:fillRef/...). */\nfunction stringifyStyleRef(name: string, ref: StyleMatrixReferenceOptions | undefined): string {\n if (!ref) return \"\";\n const idx = escapeXml(ref.idx);\n const colorXml = ref.color ? createColorElement(ref.color) : \"\";\n if (colorXml) return `<${name} idx=\"${idx}\">${colorXml}</${name}>`;\n return `<${name} idx=\"${idx}\"/>`;\n}\n\n/** Stringify a wps:style (CT_ShapeStyle): lnRef/fillRef/effectRef/fontRef. */\nfunction stringifyShapeStyle(opts: ShapeStyleOptions): string {\n const inner =\n stringifyStyleRef(\"a:lnRef\", opts.lineReference) +\n stringifyStyleRef(\"a:fillRef\", opts.fillReference) +\n stringifyStyleRef(\"a:effectRef\", opts.effectReference) +\n stringifyStyleRef(\"a:fontRef\", opts.fontReference);\n return inner ? `<wps:style>${inner}</wps:style>` : \"\";\n}\n\nfunction stringifyBodyPr(opts?: BodyPropertiesOptions): string {\n // Delegate to the shared createBodyProperties so attributes + EG_TextAutofit\n // (noAutofit/normAutofit/spAutoFit) + prstTxWarp/3D all round-trip. The old\n // inline copy dropped noAutoFit/spAutoFit and most CT_TextBodyProperties attrs.\n return createBodyProperties(opts ?? {});\n}\n\n// ── WPG group (pure string, no class instances) ──\n\nfunction stringifyWpgGroup(\n opts: {\n children: readonly GroupChildMediaData[];\n transformation: MediaDataTransformation;\n childOffset?: ChildOffset;\n childExtent?: ChildExtent;\n fill?: FillOptions;\n effects?: EffectListOptions;\n groupShapeLocks?: GroupShapeLocksOptions | null;\n },\n ctx: BodyContext,\n): string {\n const transform = opts.transformation;\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(stringifyGroupTransform2D(transform, opts.childOffset, opts.childExtent));\n if (opts.fill) grpSpPrParts.push(fillDesc.stringify(opts.fill, ctx) ?? \"\");\n if (opts.effects) grpSpPrParts.push(effectListDesc.stringify(opts.effects, NOOP_CTX) ?? \"\");\n\n // Children — wps shapes, nested wpg groups, or pic elements\n const childXml = opts.children.map((child) => stringifyGroupChild(child, ctx)).join(\"\");\n\n return (\n \"<wpg:wgp>\" +\n stringifyCnvGrpSpPr(opts.groupShapeLocks) +\n `<wpg:grpSpPr>${grpSpPrParts.join(\"\")}</wpg:grpSpPr>` +\n childXml +\n \"</wpg:wgp>\"\n );\n}\n\n/**\n * Stringify one group child: a wps shape, a nested wpg group, or a picture.\n * Shared by the top-level wpg:wgp and nested wpg:grpSp.\n */\nfunction stringifyGroupChild(child: GroupChildMediaData, ctx: BodyContext): string {\n if (child.type === \"wps\") {\n const wpsData = child as WpsMediaData & { outline?: OutlineOptions; fill?: FillOptions };\n return stringifyWpsShape(\n {\n ...wpsData.data,\n outline: wpsData.outline ?? wpsData.data.outline,\n fill: wpsData.fill ?? wpsData.data.fill,\n transformation: wpsData.transformation,\n },\n ctx,\n );\n }\n if (child.type === \"wpg\") {\n return stringifyNestedGroup(child as WpgMediaData, ctx);\n }\n // pic child (MediaData) — fill/outline ride on the group-child extension\n // (WpgCommonMediaData) so a grouped picture's spPr round-trips verbatim.\n const picData = child as MediaData & { outline?: OutlineOptions; fill?: FillOptions };\n const isSvg = picData.type === \"svg\";\n // a:blip r:embed targets the raster fallback for SVG pictures (what legacy\n // viewers render); the vector SVG lives in the svgBlip extension below.\n const blipTarget = isSvg && \"fallback\" in picData ? picData.fallback.fileName : picData.fileName;\n const picParts: string[] = [];\n picParts.push(stringifyNvPicPr({}, picData.nonVisualProperties));\n const groupBlipParts: string[] = [];\n const extParts: string[] = [];\n const useLocalDpiExt = buildUseLocalDpiExt(picData.useLocalDpi);\n if (useLocalDpiExt) extParts.push(useLocalDpiExt);\n if (isSvg) {\n extParts.push(\n `<a:ext uri=\"${SVG_BLIP_EXT_URI}\"><asvg:svgBlip xmlns:asvg=\"http://schemas.microsoft.com/office/drawing/2016/SVG/main\" r:embed=\"{${escapeXml(\n picData.fileName,\n )}}\"/></a:ext>`,\n );\n }\n const extLst = extParts.length > 0 ? `<a:extLst>${extParts.join(\"\")}</a:extLst>` : \"\";\n groupBlipParts.push(\n extLst\n ? `<a:blip r:embed=\"{${escapeXml(blipTarget)}}\">${extLst}</a:blip>`\n : `<a:blip r:embed=\"{${escapeXml(blipTarget)}}\"/>`,\n );\n const groupSrcRectXml = buildSrcRectXml(picData.sourceRectangle);\n if (groupSrcRectXml) groupBlipParts.push(groupSrcRectXml);\n groupBlipParts.push(\"<a:stretch><a:fillRect/></a:stretch>\");\n picParts.push(`<pic:blipFill>${groupBlipParts.join(\"\")}</pic:blipFill>`);\n picParts.push(stringifyShapeProps(picData.transformation, picData.outline, picData.fill));\n return `<pic:pic xmlns:pic=\"${PIC_URI}\">${picParts.join(\"\")}</pic:pic>`;\n}\n\n/**\n * Stringify a nested wpg:grpSp (CT_WordprocessingGroup) group child. Same\n * structure as the top-level group, wrapped in wpg:grpSp with a cNvPr id/name.\n */\nfunction stringifyNestedGroup(grp: WpgMediaData, ctx: BodyContext): string {\n const grpSpPrParts: string[] = [];\n grpSpPrParts.push(\n stringifyGroupTransform2D(grp.transformation, grp.childOffset, grp.childExtent),\n );\n if (grp.fill) grpSpPrParts.push(fillDesc.stringify(grp.fill, ctx) ?? \"\");\n if (grp.effects) grpSpPrParts.push(effectListDesc.stringify(grp.effects, NOOP_CTX) ?? \"\");\n return (\n \"<wpg:grpSp>\" +\n '<wpg:cNvPr id=\"0\" name=\"\"/>' +\n stringifyCnvGrpSpPr(grp.groupShapeLocks) +\n `<wpg:grpSpPr>${grpSpPrParts.join(\"\")}</wpg:grpSpPr>` +\n grp.children.map((c) => stringifyGroupChild(c, ctx)).join(\"\") +\n \"</wpg:grpSp>\"\n );\n}\n\n// ── Graphic data content ──\n\nfunction stringifyGraphicDataContent(\n mediaData: ExtendedMediaData,\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { outline, fill, effects, blipEffects, tile } = opts;\n const transform = mediaData.transformation;\n\n if (mediaData.type === \"chart\") {\n const md = mediaData as ChartMediaData;\n return (\n `<a:graphicData uri=\"${CHART_URI}\">` +\n `<c:chart xmlns:c=\"${CHART_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"{chart:${md.chartKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"smartart\") {\n const md = mediaData as SmartArtMediaData;\n return (\n `<a:graphicData uri=\"${DGM_URI}\">` +\n `<dgm:relIds xmlns:dgm=\"${DGM_URI}\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:dm=\"{smartart:${md.smartArtKey}}\" r:lo=\"{smartart-lo:${md.smartArtKey}}\" r:qs=\"{smartart-qs:${md.smartArtKey}}\" r:cs=\"{smartart-cs:${md.smartArtKey}}\"/>` +\n `</a:graphicData>`\n );\n }\n\n if (mediaData.type === \"wps\") {\n const md = mediaData as WpsMediaData;\n const wpsXml = stringifyWpsShape(\n {\n ...md.data,\n outline,\n fill,\n transformation: transform,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPS_URI}\">${wpsXml}</a:graphicData>`;\n }\n\n if (mediaData.type === \"wpg\") {\n const md = mediaData as WpgMediaData;\n const wpgXml = stringifyWpgGroup(\n {\n children: md.children,\n transformation: transform,\n childOffset: md.childOffset,\n childExtent: md.childExtent,\n fill: md.fill,\n effects: md.effects,\n groupShapeLocks: md.groupShapeLocks,\n },\n ctx,\n );\n return `<a:graphicData uri=\"${WPG_URI}\">${wpgXml}</a:graphicData>`;\n }\n\n // Default: image (pic:pic)\n const md = mediaData as MediaData;\n return (\n `<a:graphicData uri=\"${PIC_URI}\">` +\n `<pic:pic xmlns:pic=\"${PIC_URI}\">` +\n stringifyNvPicPr(hlIds, md.nonVisualProperties) +\n stringifyBlipFill(md, blipEffects, tile) +\n stringifyShapeProps(transform, outline, fill, effects) +\n `</pic:pic></a:graphicData>`\n );\n}\n\n// ── Position helpers (for anchor) ──\n\nfunction stringifyPositionH(opts: HorizontalPositionOptions): string {\n const rel = opts.relative ?? HorizontalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>`\n : \"<wp:align>left</wp:align>\";\n return `<wp:positionH relativeFrom=\"${rel}\">${child}</wp:positionH>`;\n}\n\nfunction stringifyPositionV(opts: VerticalPositionOptions): string {\n const rel = opts.relative ?? VerticalPositionRelativeFrom.PAGE;\n const child = opts.align\n ? `<wp:align>${opts.align}</wp:align>`\n : opts.offset !== undefined\n ? `<wp:posOffset>${convertToEmu(opts.offset)}</wp:posOffset>`\n : \"<wp:align>top</wp:align>\";\n return `<wp:positionV relativeFrom=\"${rel}\">${child}</wp:positionV>`;\n}\n\n// ── Text wrapping string builders ──\n\nfunction wrapPolygonStr(cx: number, cy: number, polygon?: WrapPolygon): string {\n // Preserve the source contour verbatim when round-tripped.\n if (polygon?.points.length) {\n // Emit `edited` only when the source had it — keeps the polygon byte-faithful on round-trip.\n const editedAttr = polygon.edited !== undefined ? ` edited=\"${polygon.edited ? 1 : 0}\"` : \"\";\n const [start, ...rest] = polygon.points;\n // length guard above guarantees `start` exists\n const startStr = `<wp:start x=\"${start!.x}\" y=\"${start!.y}\"/>`;\n const lineToStr = rest.map((p) => `<wp:lineTo x=\"${p.x}\" y=\"${p.y}\"/>`).join(\"\");\n return `<wp:wrapPolygon${editedAttr}>${startStr}${lineToStr}</wp:wrapPolygon>`;\n }\n // Default contour: extent rectangle (origin at top-left, y negated).\n return (\n `<wp:wrapPolygon edited=\"0\">` +\n `<wp:start x=\"0\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"${-cy}\"/>` +\n `<wp:lineTo x=\"${cx}\" y=\"0\"/>` +\n `<wp:lineTo x=\"0\" y=\"0\"/>` +\n `</wp:wrapPolygon>`\n );\n}\n\nfunction wrapSquareStr(textWrapping: TextWrapping, margins?: Margins): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const m = margins ?? {};\n const a = [\n `wrapText=\"${side}\"`,\n ...(m.top != null ? [`distT=\"${convertToEmu(m.top)}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${convertToEmu(m.bottom)}\"`] : []),\n ...(m.left != null ? [`distL=\"${convertToEmu(m.left)}\"`] : []),\n ...(m.right != null ? [`distR=\"${convertToEmu(m.right)}\"`] : []),\n ].join(\" \");\n return `<wp:wrapSquare ${a}/>`;\n}\n\nfunction wrapTightStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${convertToEmu(margins.left)}\"`);\n if (margins.right != null) a.push(`distR=\"${convertToEmu(margins.right)}\"`);\n return `<wp:wrapTight ${a.join(\" \")}>${wrapPolygonStr(cx, cy, textWrapping.polygon)}</wp:wrapTight>`;\n}\n\nfunction wrapThroughStr(\n textWrapping: TextWrapping,\n margins: Margins,\n cx: number,\n cy: number,\n): string {\n const side = textWrapping.side ?? TextWrappingSide.BOTH_SIDES;\n const a = [`wrapText=\"${side}\"`];\n if (margins.left != null) a.push(`distL=\"${convertToEmu(margins.left)}\"`);\n if (margins.right != null) a.push(`distR=\"${convertToEmu(margins.right)}\"`);\n return `<wp:wrapThrough ${a.join(\" \")}>${wrapPolygonStr(cx, cy, textWrapping.polygon)}</wp:wrapThrough>`;\n}\n\nfunction wrapTopAndBottomStr(margins?: Margins): string {\n const m = margins ?? {};\n const a = [\n ...(m.top != null ? [`distT=\"${convertToEmu(m.top)}\"`] : []),\n ...(m.bottom != null ? [`distB=\"${convertToEmu(m.bottom)}\"`] : []),\n ].join(\" \");\n return a ? `<wp:wrapTopAndBottom ${a}/>` : \"<wp:wrapTopAndBottom/>\";\n}\n\n// ── Inline wrapper ──\n\n/** Render wp:cNvGraphicFramePr. Undefined → authoring default (noChangeAspect=1);\n * `{}` → empty element; otherwise the given lock flags. */\nfunction stringifyCnvGraphicFramePr(locks?: GraphicFrameLocksOptions | null): string {\n const resolved = locks ?? { noChangeAspect: true };\n const attrParts: string[] = [];\n if (resolved.noGrp) attrParts.push('noGrp=\"1\"');\n if (resolved.noDrilldown) attrParts.push('noDrilldown=\"1\"');\n if (resolved.noSelect) attrParts.push('noSelect=\"1\"');\n if (resolved.noChangeAspect) attrParts.push('noChangeAspect=\"1\"');\n if (resolved.noMove) attrParts.push('noMove=\"1\"');\n if (resolved.noResize) attrParts.push('noResize=\"1\"');\n if (attrParts.length === 0) return \"<wp:cNvGraphicFramePr/>\";\n const attrStr = \" \" + attrParts.join(\" \");\n return `<wp:cNvGraphicFramePr><a:graphicFrameLocks${attrStr} xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wp:cNvGraphicFramePr>`;\n}\n\n/**\n * Stringify wpg:cNvGrpSpPr (CT_NonVisualGroupShapeDrawingProperties): contains\n * an optional a:grpSpLocks (CT_GroupLocking). When no locks are present (the\n * Word default for groups) the element stays empty — groups do NOT inject a\n * default lock, unlike wp:cNvGraphicFramePr.\n */\nfunction stringifyCnvGrpSpPr(locks?: GroupShapeLocksOptions | null): string {\n if (!locks) return \"<wpg:cNvGrpSpPr/>\";\n const attrParts: string[] = [];\n if (locks.noGrp) attrParts.push('noGrp=\"1\"');\n if (locks.noUngrp) attrParts.push('noUngrp=\"1\"');\n if (locks.noSelect) attrParts.push('noSelect=\"1\"');\n if (locks.noRot) attrParts.push('noRot=\"1\"');\n if (locks.noChangeAspect) attrParts.push('noChangeAspect=\"1\"');\n if (locks.noMove) attrParts.push('noMove=\"1\"');\n if (locks.noResize) attrParts.push('noResize=\"1\"');\n if (attrParts.length === 0) return \"<wpg:cNvGrpSpPr/>\";\n const attrStr = \" \" + attrParts.join(\" \");\n return `<wpg:cNvGrpSpPr><a:grpSpLocks${attrStr} xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/></wpg:cNvGrpSpPr>`;\n}\n\nfunction stringifyInline(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, effects, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n // Prefer the verbatim source effectExtent (round-trip); fall back to\n // computing it from the shape's effects on the generation path.\n const effectExtent = mediaData.transformation.effectExtent ?? calculateEffectExtent(effects);\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n return (\n `<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">` +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n `<wp:effectExtent l=\"${effectExtent.l}\" t=\"${effectExtent.t}\" r=\"${effectExtent.r}\" b=\"${effectExtent.b}\"/>` +\n stringifyDocPr(docProperties, hlIds) +\n stringifyCnvGraphicFramePr(opts.graphicFrameLocks) +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:inline></w:drawing>`\n );\n}\n\n// ── Anchor (floating) wrapper ──\n\nfunction stringifyAnchor(\n opts: DrawingDescriptorOptions,\n hlIds: HyperlinkIds,\n ctx: BodyContext,\n): string {\n const { mediaData, floating: rawFloating, docProperties } = opts;\n const cx = mediaData.transformation.emus.x;\n const cy = mediaData.transformation.emus.y;\n\n const floating: Required<Floating> = {\n allowOverlap: true,\n behindDocument: false,\n horizontalPosition: {},\n layoutInCell: true,\n lockAnchor: false,\n verticalPosition: {},\n zIndex: mediaData.transformation.emus.y,\n margins: {},\n wrap: { type: TextWrappingType.NONE },\n ...rawFloating,\n };\n\n const attrParts = [\n `distT=\"${convertToEmu(floating.margins?.top ?? 0)}\"`,\n `distB=\"${convertToEmu(floating.margins?.bottom ?? 0)}\"`,\n `distL=\"${convertToEmu(floating.margins?.left ?? 0)}\"`,\n `distR=\"${convertToEmu(floating.margins?.right ?? 0)}\"`,\n 'simplePos=\"0\"',\n `allowOverlap=\"${floating.allowOverlap ? 1 : 0}\"`,\n `behindDoc=\"${floating.behindDocument ? 1 : 0}\"`,\n `locked=\"${floating.lockAnchor ? 1 : 0}\"`,\n `layoutInCell=\"${floating.layoutInCell ? 1 : 0}\"`,\n `relativeHeight=\"${floating.zIndex}\"`,\n ];\n\n // Wrap\n let wrapXml: string;\n const rawWrap = rawFloating?.wrap;\n if (rawWrap?.type === TextWrappingType.SQUARE) {\n wrapXml = wrapSquareStr(rawWrap, floating.margins);\n } else if (rawWrap?.type === TextWrappingType.TIGHT) {\n wrapXml = wrapTightStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.THROUGH) {\n wrapXml = wrapThroughStr(rawWrap, floating.margins, cx, cy);\n } else if (rawWrap?.type === TextWrappingType.TOP_AND_BOTTOM) {\n wrapXml = wrapTopAndBottomStr(floating.margins);\n } else {\n wrapXml = \"<wp:wrapNone/>\";\n }\n\n const graphicDataXml = stringifyGraphicDataContent(mediaData, opts, hlIds, ctx);\n\n // Prefer the verbatim source effectExtent (round-trip); default to zero.\n const ee = mediaData.transformation.effectExtent;\n const effectExtentXml = ee\n ? `<wp:effectExtent l=\"${ee.l}\" t=\"${ee.t}\" r=\"${ee.r}\" b=\"${ee.b}\"/>`\n : '<wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>';\n\n return (\n `<w:drawing><wp:anchor ${attrParts.join(\" \")}>` +\n '<wp:simplePos x=\"0\" y=\"0\"/>' +\n stringifyPositionH(floating.horizontalPosition) +\n stringifyPositionV(floating.verticalPosition) +\n `<wp:extent cx=\"${cx}\" cy=\"${cy}\"/>` +\n effectExtentXml +\n wrapXml +\n stringifyDocPr(docProperties, hlIds) +\n stringifyCnvGraphicFramePr(opts.graphicFrameLocks) +\n `<a:graphic ${GRAPHIC_NS}>${graphicDataXml}</a:graphic>` +\n `</wp:anchor></w:drawing>`\n );\n}\n\n// ── Descriptor ──\n\n/**\n * Drawing descriptor for DOCX `<w:drawing>` elements.\n *\n * Eliminates the Drawing/Inline/Anchor/Graphic/GraphicData/Pic XmlComponent\n * class chain. Inline images, charts, and smartarts produce XML via pure\n * string concatenation — zero XmlComponent instances.\n *\n * @example\n * ```typescript\n * const xml = drawingDesc.stringify({ mediaData, docProperties: opts.altText, floating: opts.floating }, ctx);\n * ```\n */\nexport const drawingDesc: CustomDescriptor<DrawingDescriptorOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n // Register hyperlink relationships\n const hlIds = registerHyperlinks(opts.docProperties?.hyperlink, ctx);\n\n if (opts.floating) {\n return stringifyAnchor(opts, hlIds, ctx);\n }\n return stringifyInline(opts, hlIds, ctx);\n },\n\n parse(el, ctx) {\n const result = parseDrawingRun(el, ctx as DocxReadContext);\n return (result ?? {}) as unknown as DrawingDescriptorOptions;\n },\n};\n","/**\n * Field module for WordprocessingML documents.\n *\n * This module provides support for complex fields, which are regions of text\n * that can contain dynamic content such as page numbers, dates, or mail merge fields.\n * Fields are delimited by field character elements (begin, separate, end).\n *\n * Reference: http://officeopenxml.com/WPrun.php\n *\n * @module\n */\n\nimport { element } from \"@office-open/xml\";\n\nimport type { FormFieldOptions } from \"./form-field\";\nimport { createFormFieldData } from \"./form-field\";\n\n/**\n * Field character types that delimit field regions.\n *\n * @internal\n */\nconst FieldCharacterType = {\n BEGIN: \"begin\",\n END: \"end\",\n SEPARATE: \"separate\",\n} as const;\n\n/**\n * Creates a field character element.\n *\n * ## XSD Schema\n * ```xml\n * <xsd:complexType name=\"CT_FldChar\">\n * <xsd:sequence>\n * <xsd:element name=\"fldData\" type=\"CT_Text\" minOccurs=\"0\"/>\n * <xsd:element name=\"ffData\" type=\"CT_FFData\" minOccurs=\"0\"/>\n * <xsd:element name=\"numberingChange\" type=\"CT_TrackChangeNumbering\" minOccurs=\"0\"/>\n * </xsd:sequence>\n * <xsd:attribute name=\"fldCharType\" type=\"ST_FldCharType\" use=\"required\"/>\n * <xsd:attribute name=\"fldLock\" type=\"s:ST_OnOff\"/>\n * <xsd:attribute name=\"dirty\" type=\"s:ST_OnOff\"/>\n * </xsd:complexType>\n * ```\n * @internal\n */\nconst createFieldChar = (\n type: (typeof FieldCharacterType)[keyof typeof FieldCharacterType],\n dirty?: boolean,\n ffData?: string,\n fldData?: string,\n fieldLock?: boolean,\n): string => {\n const children: string[] = [];\n if (fldData !== undefined) {\n children.push(element(\"w:fldData\", { \"xml:space\": \"preserve\" }, [fldData]));\n }\n if (ffData) {\n children.push(ffData);\n }\n return element(\n \"w:fldChar\",\n {\n \"w:dirty\": dirty,\n \"w:fldLock\": fieldLock,\n \"w:fldCharType\": type,\n },\n children.length > 0 ? children : undefined,\n );\n};\n\n/**\n * Creates the beginning of a complex field.\n *\n * The Begin element marks the start of a field. A field consists of a begin character,\n * field instructions, an optional separate character, field result, and an end character.\n *\n * For form fields, pass `formField` to embed `w:ffData` within the begin `w:fldChar`.\n *\n * @param dirty - Whether the field should be recalculated\n * @param formField - Optional form field data to embed in the begin character\n *\n * @example\n * ```typescript\n * // Simple field begin\n * createBegin();\n *\n * // Form field (checkbox)\n * createBegin(false, {\n * name: \"Check1\",\n * checkBox: { checked: true, sizeAuto: true },\n * });\n * ```\n */\nexport const createBegin = (\n dirty?: boolean,\n formField?: FormFieldOptions,\n fieldLock?: boolean,\n): string =>\n createFieldChar(\n FieldCharacterType.BEGIN,\n dirty,\n formField ? createFormFieldData(formField) : undefined,\n undefined,\n fieldLock,\n );\n\n/**\n * Creates the separator between field code and field result in a complex field.\n *\n * The Separate element divides the field code (instructions) from the field result\n * (the computed value).\n */\nexport const createSeparate = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.SEPARATE, dirty);\n\n/**\n * Creates the end of a complex field.\n *\n * The End element marks the end of a field. Every field that begins with a Begin\n * element must be terminated with an End element.\n */\nexport const createEnd = (dirty?: boolean): string =>\n createFieldChar(FieldCharacterType.END, dirty);\n","/**\n * Shared inline run/paragraph stringification for DOCX descriptors.\n *\n * Used by table.ts, comments.ts, body.ts, and other descriptors that need to\n * serialize paragraph/run content. Includes JSON child dispatch for all\n * ParagraphChild variants (image, chart, hyperlink, etc.).\n *\n * Pure string concatenation — no intermediate object tree.\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport { TargetModeType } from \"@office-open/core\";\nimport { uniqueId } from \"@office-open/core\";\nimport { chartSpaceDesc } from \"@office-open/core/chart\";\nimport type { SourceRectangleOptions } from \"@office-open/core/drawingml\";\nimport { createDataModel } from \"@office-open/core/smartart\";\nimport { escapeXml } from \"@office-open/xml\";\nimport type { BackgroundRawMediaOptions } from \"@parts/document/document-background/document-background\";\nimport type {\n BookmarkOptions,\n BookmarkStartOptions,\n MarkupRangeOptions,\n MoveRangeOptions,\n MoveRangeStartOptions,\n} from \"@parts/paragraph/links/bookmark\";\nimport type { ParagraphChild, ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { CommentChildOptions } from \"@parts/paragraph/run/comment-run\";\nimport type { ImageOptions } from \"@parts/paragraph/run/image-run\";\nimport type { RunPropertiesOptions } from \"@parts/paragraph/run/properties\";\nimport type { RubyOptions } from \"@parts/paragraph/run/ruby\";\nimport {\n breakXml,\n EMPTY_RUN_ELEMENTS,\n type BreakOptions,\n type RunOptions,\n} from \"@parts/paragraph/run/run\";\nimport type { SmartArtOptions } from \"@parts/paragraph/run/smartart-run\";\nimport type {\n ChartMediaData,\n GroupChildMediaData,\n MediaData,\n SmartArtMediaData,\n WpgMediaData,\n WpsMediaData,\n} from \"@shared/media\";\nimport { createTransformation } from \"@shared/media\";\nimport type { NonVisualPropertiesOptions } from \"@shared/media/data\";\n\nimport type { BodyContext } from \"../context\";\nimport { checkboxSymbolRunInner, stringifyCustomXmlShell, stringifySdtShell } from \"./bodychildren\";\nimport { drawingDesc } from \"./drawing\";\nimport { stringifyMath } from \"./paragraph/math/stringify\";\nimport { createBegin, createSeparate, createEnd } from \"./paragraph/run/field\";\nimport { stringifyParagraphProperties, stringifyRunProperties } from \"./paragraph/stringify\";\n\n// ── Run ──\n\n/** Serialize a deleted run: rPr + delText (or field delInstrText). */\nfunction stringifyDeletedRun(c: RunOptions | string): string {\n const opts = typeof c === \"string\" ? { text: c } : c;\n const parts: string[] = [];\n const rPr = stringifyRunProperties(opts);\n if (rPr) parts.push(rPr);\n if (opts.break) parts.push(breakXml(opts.break));\n const fieldMap: Record<string, string> = {\n CURRENT: \"PAGE\",\n TOTAL_PAGES: \"NUMPAGES\",\n TOTAL_PAGES_IN_SECTION: \"SECTIONPAGES\",\n };\n if (opts.children) {\n for (const cc of opts.children) {\n if (typeof cc === \"string\") {\n // Page number fields use delInstrText instead of instrText\n const instrText = fieldMap[cc];\n if (instrText) {\n parts.push(\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:delInstrText xml:space=\"preserve\">${instrText}</w:delInstrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>',\n );\n } else {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(cc)}</w:delText>`);\n }\n }\n }\n } else if (opts.text) {\n parts.push(`<w:delText xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:delText>`);\n }\n return `<w:r>${parts.join(\"\")}</w:r>`;\n}\n\nexport function stringifyRunInline(opts: RunOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const rPr = stringifyRunProperties(opts);\n if (rPr) parts.push(rPr);\n\n if (opts.break) parts.push(breakXml(opts.break));\n\n if (opts.children) {\n for (const child of opts.children) {\n if (typeof child === \"string\") {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(child)}</w:t>`);\n } else if (typeof child === \"object\" && child !== null) {\n // Bare run-inner elements — emit directly inside this <w:r>. Must run\n // before stringifyChildDispatch, which wraps paragraph-level children\n // in their own <w:r> (correct for paragraphs, nested/invalid in a run).\n if (\"tab\" in child) {\n parts.push(\"<w:tab/>\");\n continue;\n }\n if (\"pageBreak\" in child) {\n parts.push('<w:br w:type=\"page\"/>');\n continue;\n }\n if (\"columnBreak\" in child) {\n parts.push('<w:br w:type=\"column\"/>');\n continue;\n }\n if (\"break\" in child) {\n parts.push(breakXml((child as { break: number | BreakOptions }).break));\n continue;\n }\n // Empty run elements — separator, noBreakHyphen, pgNum, etc.\n const emptyXml = EMPTY_RUN_ELEMENTS[Object.keys(child)[0] ?? \"\"];\n if (emptyXml) {\n parts.push(emptyXml);\n continue;\n }\n // JSON child dispatch (images, charts, hyperlinks, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n } else if (opts.text !== undefined) {\n parts.push(`<w:t xml:space=\"preserve\">${escapeXml(String(opts.text))}</w:t>`);\n }\n\n const rsidAttrs: string[] = [];\n if (opts.rsid) rsidAttrs.push(` w:rsidR=\"${opts.rsid}\"`);\n if (opts.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${opts.runPropertiesRsid}\"`);\n if (opts.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${opts.deletionRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body.length === 0 ? (attr ? `<w:r${attr}/>` : \"<w:r/>\") : `<w:r${attr}>${body}</w:r>`;\n}\n\n// ── Image helpers ──\n\nfunction createImageData(\n data: Uint8Array,\n transformation: ImageOptions[\"transformation\"],\n key: string,\n sourceRectangle?: SourceRectangleOptions,\n nonVisualProperties?: NonVisualPropertiesOptions,\n): Pick<\n MediaData,\n \"data\" | \"fileName\" | \"transformation\" | \"sourceRectangle\" | \"nonVisualProperties\"\n> {\n return {\n data,\n fileName: key,\n sourceRectangle,\n nonVisualProperties,\n transformation: createTransformation(transformation),\n };\n}\n\nlet nextChartId = 1;\n\n// ── JSON child dispatch ──\n\n/**\n * Stringify a ParagraphChild into one or more XML strings.\n *\n * Handles side effects (media, chart, smartArt, relationship registration)\n * directly without creating temporary class instances.\n *\n * Returns `undefined` if the child is not a recognized JSON wrapper.\n */\n/**\n * Wrap a `<w:drawing>` run, rebuilding an mc:AlternateContent wrapper when a\n * VML fallback was carried from parse (Choice stays structured/editable,\n * Fallback round-trips as raw XML for fidelity).\n */\nfunction wrapDrawingRun(\n drawingXml: string | undefined,\n opts: { vmlFallback?: string; mcChoiceRequires?: string; runProperties?: RunPropertiesOptions },\n): string {\n const xml = drawingXml ?? \"\";\n const rPr = stringifyRunProperties(opts.runProperties) ?? \"\";\n if (opts.vmlFallback) {\n const requires = opts.mcChoiceRequires ?? \"wps\";\n // opts.vmlFallback is the serialized <mc:Fallback>…</mc:Fallback> element,\n // so splice it in directly (no extra wrapper).\n return `<w:r>${rPr}<mc:AlternateContent><mc:Choice Requires=\"${requires}\">${xml}</mc:Choice>${opts.vmlFallback}</mc:AlternateContent></w:r>`;\n }\n return `<w:r>${rPr}${xml}</w:r>`;\n}\n\n/**\n * Register media carried by a VML fallback (mc:AlternateContent Fallback) so the\n * compiler resolves the fallback's `{fileName}` placeholders into rIds.\n *\n * A VML fallback image mirrors its Choice blip (same source bytes). When the\n * blip is already registered, reuse it and remap the fallback's `{fileName}`\n * placeholder to the shared media — matching Office, which emits one\n * relationship/file per image rather than a duplicate for the VML branch.\n */\nfunction registerVmlFallbackMedia(\n opts: { vmlFallback?: string; vmlFallbackMedia?: BackgroundRawMediaOptions[] },\n ctx: BodyContext,\n): void {\n if (!opts.vmlFallbackMedia) return;\n for (const m of opts.vmlFallbackMedia) {\n const data = toUint8Array(m.data);\n const entry = ctx.file.media.addMedia(\n data,\n m.type,\n (fileName) =>\n ({\n type: m.type,\n data,\n fileName,\n transformation: { emus: { x: 0, y: 0 }, pixels: { x: 0, y: 0 } },\n }) as MediaData,\n m.fileName,\n );\n // Dedup may reuse the Choice blip's file name; remap the VML fallback\n // placeholder so both branches share one relationship/file (matches Office).\n if (entry.fileName !== m.fileName && opts.vmlFallback) {\n opts.vmlFallback = opts.vmlFallback.split(`{${m.fileName}}`).join(`{${entry.fileName}}`);\n }\n }\n}\n\n/**\n * Build the rPr XML for a break/tab run from its structured run properties.\n */\n/** Shared attribute string for CT_MarkupRange end markers (commentRange, move range end). */\nfunction buildMarkupRangeAttrs(m: MarkupRangeOptions): string {\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${m.displacedByCustomXml}\"`);\n return a.join(\" \");\n}\n\n/** Shared attribute string for w:bookmarkStart (CT_Bookmark). */\nfunction buildBookmarkStartAttrs(bs: BookmarkStartOptions): string {\n const a: string[] = [`w:id=\"${bs.id}\"`, `w:name=\"${escapeXml(bs.name)}\"`];\n if (bs.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${bs.displacedByCustomXml}\"`);\n if (bs.colFirst !== undefined) a.push(`w:colFirst=\"${bs.colFirst}\"`);\n if (bs.colLast !== undefined) a.push(`w:colLast=\"${bs.colLast}\"`);\n return a.join(\" \");\n}\n\n/** Shared attribute string for w:moveFromRangeStart / w:moveToRangeStart (CT_MoveBookmark). */\nfunction buildMoveRangeStartAttrs(m: MoveRangeStartOptions): string {\n const a: string[] = [`w:id=\"${m.id}\"`];\n if (m.name) a.push(`w:name=\"${escapeXml(m.name)}\"`);\n if (m.author) a.push(`w:author=\"${escapeXml(m.author)}\"`);\n if (m.date) a.push(`w:date=\"${m.date}\"`);\n if (m.displacedByCustomXml) a.push(`w:displacedByCustomXml=\"${m.displacedByCustomXml}\"`);\n if (m.colFirst !== undefined) a.push(`w:colFirst=\"${m.colFirst}\"`);\n if (m.colLast !== undefined) a.push(`w:colLast=\"${m.colLast}\"`);\n return a.join(\" \");\n}\n\n/** Stringify inline run/text content — the `wrap` shared by every sugar child. */\nfunction stringifyInlineWrap(wrap: (string | RunOptions)[] | undefined, ctx: BodyContext): string {\n const parts: string[] = [];\n for (const item of wrap ?? []) {\n parts.push(\n typeof item === \"string\"\n ? stringifyRunInline({ text: item }, ctx)\n : stringifyRunInline(item, ctx),\n );\n }\n return parts.join(\"\");\n}\n\n/**\n * Expand a `{ comment }` sugar child: allocate the comment id, register the\n * comment entry (side effect, consumed when word/comments.xml is stringified),\n * and emit the range markers + anchored content + reference with one shared id.\n *\n * The caller never supplies an id — the library owns id allocation and pairing.\n */\nfunction stringifyCommentChild(c: CommentChildOptions, ctx: BodyContext): string {\n const id = ctx.file.comments.nextId++;\n ctx.file.comments.entries.push({\n id,\n author: c.author,\n initials: c.initials,\n date: c.date,\n children: c.children,\n });\n\n return (\n `<w:commentRangeStart w:id=\"${id}\"/>` +\n stringifyInlineWrap(c.wrap, ctx) +\n `<w:commentRangeEnd w:id=\"${id}\"/>` +\n `<w:r><w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr><w:commentReference w:id=\"${id}\"/></w:r>`\n );\n}\n\n/**\n * Expand a `{ bookmark }` sugar child: allocate the bookmark id and emit the\n * paired bookmarkStart/bookmarkEnd with the anchored content between them.\n * Bookmarks are pure markup — the only effect is the two markers.\n */\nfunction stringifyBookmarkChild(b: BookmarkOptions, ctx: BodyContext): string {\n const id = ctx.file.markupIds.rangeNext++;\n const startAttrs = buildBookmarkStartAttrs({\n id,\n name: b.name,\n displacedByCustomXml: b.displacedByCustomXml,\n colFirst: b.colFirst,\n colLast: b.colLast,\n });\n const endAttrs = buildMarkupRangeAttrs({ id, displacedByCustomXml: b.displacedByCustomXml });\n return `<w:bookmarkStart ${startAttrs}/>${stringifyInlineWrap(b.wrap, ctx)}<w:bookmarkEnd ${endAttrs}/>`;\n}\n\n/**\n * Expand a `{ moveFrom }` / `{ moveTo }` sugar child: allocate the range id and\n * the move-run id, then emit the paired range markers with the moved run between\n * them. The move run (CT_TrackChange) carries the moved content.\n */\nfunction stringifyMoveRangeChild(\n kind: \"moveFrom\" | \"moveTo\",\n opts: MoveRangeOptions,\n ctx: BodyContext,\n): string {\n const rangeId = ctx.file.markupIds.rangeNext++;\n const runId = ctx.file.markupIds.moveRunNext++;\n const isMoveFrom = kind === \"moveFrom\";\n const startTag = isMoveFrom ? \"w:moveFromRangeStart\" : \"w:moveToRangeStart\";\n const endTag = isMoveFrom ? \"w:moveFromRangeEnd\" : \"w:moveToRangeEnd\";\n const runTag = isMoveFrom ? \"w:moveFrom\" : \"w:moveTo\";\n const rangeStartAttrs = buildMoveRangeStartAttrs({\n id: rangeId,\n name: opts.name,\n author: opts.author,\n date: opts.date,\n displacedByCustomXml: opts.displacedByCustomXml,\n colFirst: opts.colFirst,\n colLast: opts.colLast,\n });\n const endAttrs = buildMarkupRangeAttrs({\n id: rangeId,\n displacedByCustomXml: opts.displacedByCustomXml,\n });\n return (\n `<${startTag} ${rangeStartAttrs}/>` +\n `<${runTag} w:id=\"${runId}\" w:author=\"${escapeXml(opts.author)}\" w:date=\"${opts.date}\">${stringifyInlineWrap(opts.wrap, ctx)}</${runTag}>` +\n `<${endTag} ${endAttrs}/>`\n );\n}\n\nfunction runPropertiesXml(child: ParagraphChild): string {\n return stringifyRunProperties(child as RunOptions) ?? \"\";\n}\n\nexport function stringifyChildDispatch(\n child: ParagraphChild,\n ctx: BodyContext,\n): string | string[] | undefined {\n // Simple break types — pure XML, no side effects. A break run may carry run\n // properties (round-tripped from <w:r><w:rPr>…</w:rPr><w:br…/></w:r>).\n if (\"pageBreak\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:br w:type=\"page\"/></w:r>`;\n }\n if (\"columnBreak\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:br w:type=\"column\"/></w:r>`;\n }\n if (\"tab\" in child) {\n return `<w:r>${runPropertiesXml(child)}<w:tab/></w:r>`;\n }\n\n // Reference types — pure XML, no side effects\n if (\"footnoteReference\" in child) {\n const ref = child.footnoteReference;\n const id = typeof ref === \"number\" ? ref : ref.id;\n const cmf =\n typeof ref === \"object\" && ref.customMarkFollows ? ' w:customMarkFollows=\"true\"' : \"\";\n return `<w:r><w:rPr><w:rStyle w:val=\"FootnoteReference\"/></w:rPr><w:footnoteReference w:id=\"${id}\"${cmf}/></w:r>`;\n }\n if (\"endnoteReference\" in child) {\n const ref = child.endnoteReference;\n const id = typeof ref === \"number\" ? ref : ref.id;\n const cmf =\n typeof ref === \"object\" && ref.customMarkFollows ? ' w:customMarkFollows=\"true\"' : \"\";\n return `<w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteReference w:id=\"${id}\"${cmf}/></w:r>`;\n }\n\n // Comment sugar — library allocates the id, emits the range markers +\n // reference, and registers the comment entry (see stringifyCommentChild).\n if (\"comment\" in child) return stringifyCommentChild(child.comment, ctx);\n\n // Comment markers — pure XML\n if (\"commentRangeStart\" in child)\n return `<w:commentRangeStart ${buildMarkupRangeAttrs(child.commentRangeStart)}/>`;\n if (\"commentRangeEnd\" in child)\n return `<w:commentRangeEnd ${buildMarkupRangeAttrs(child.commentRangeEnd)}/>`;\n if (\"commentReference\" in child)\n return `<w:r><w:rPr><w:rStyle w:val=\"CommentReference\"/></w:rPr><w:commentReference w:id=\"${child.commentReference}\"/></w:r>`;\n\n // Bookmark markers — pure XML\n if (\"bookmarkStart\" in child) {\n return `<w:bookmarkStart ${buildBookmarkStartAttrs(child.bookmarkStart)}/>`;\n }\n if (\"bookmarkEnd\" in child) {\n return `<w:bookmarkEnd ${buildMarkupRangeAttrs(child.bookmarkEnd)}/>`;\n }\n // Bookmark sugar — library allocates the id and pairs start/end.\n if (\"bookmark\" in child) return stringifyBookmarkChild(child.bookmark, ctx);\n\n // Symbol run — direct XML output.\n // <w:sym> is a self-closing element, not text: emit it directly so it is\n // not escaped into a <w:t> by the run children path.\n if (\"symbolRun\" in child) {\n const opts = child.symbolRun;\n const rPr = stringifyRunProperties(opts) ?? \"\";\n return `<w:r>${rPr}<w:sym w:char=\"${opts.char}\" w:font=\"${opts.symbolfont ?? \"Wingdings\"}\"/></w:r>`;\n }\n\n // Form field (checkbox / dropdown list / text input) — fldChar sequence.\n // Word needs the field code (instrText) between begin and separate to\n // recognize the field type and render its result.\n if (\"formField\" in child) {\n const ff = child.formField;\n let result = \"\";\n let instrCode = \"\";\n let symbolFont = false;\n if (ff.checkBox) {\n result = ff.checkBox.checked ? \"☒\" : \"☐\";\n instrCode = \"FORMCHECKBOX\";\n // U+2610/U+2612 are absent from common body fonts (Calibri/Times);\n // MS Gothic holds them and matches the SDT w14:checkbox default.\n symbolFont = true;\n } else if (ff.dropDownList) {\n const idx = ff.dropDownList.result ?? ff.dropDownList.default;\n result = idx !== undefined ? (ff.dropDownList.entries[idx] ?? \"\") : \"\";\n instrCode = \"FORMDROPDOWN\";\n } else if (ff.textInput) {\n // Prefer the user-entered value (result run) over the placeholder default.\n result = ff.textInput.value ?? ff.textInput.default ?? \"\";\n instrCode = \"FORMTEXT\";\n }\n const rPr = symbolFont\n ? '<w:rPr><w:rFonts w:ascii=\"MS Gothic\" w:hAnsi=\"MS Gothic\"/></w:rPr>'\n : \"\";\n return (\n `<w:r>${createBegin(false, ff)}</w:r>` +\n `<w:r><w:instrText xml:space=\"preserve\"> ${instrCode} </w:instrText></w:r>` +\n `<w:r>${createSeparate()}</w:r>` +\n `<w:r>${rPr}<w:t xml:space=\"preserve\">${escapeXml(result)}</w:t></w:r>` +\n `<w:r>${createEnd()}</w:r>`\n );\n }\n\n // Image — side effect: media registration (content-deduplicated via core Media)\n if (\"image\" in child) {\n const opts = child.image;\n const rawData = toUint8Array(opts.data, { encoding: \"base64\" }) as Uint8Array;\n\n let mediaData: MediaData;\n if (opts.type === \"svg\") {\n const fallbackData = toUint8Array(opts.fallback.data, { encoding: \"base64\" }) as Uint8Array;\n const fallbackType = opts.fallback.type;\n // Register the raster fallback first so its file name is allocated, then\n // build the svg entry referencing it. Dedup applies to both independently.\n const fallback = ctx.file.media.addMedia(\n fallbackData,\n fallbackType,\n (fileName) =>\n ({\n type: fallbackType,\n ...createImageData(fallbackData, opts.transformation, fileName),\n }) as MediaData,\n );\n mediaData = ctx.file.media.addMedia(\n rawData,\n \"svg\",\n (fileName) =>\n ({\n type: \"svg\" as const,\n ...createImageData(\n rawData,\n opts.transformation,\n fileName,\n opts.sourceRectangle,\n opts.nonVisualProperties,\n ),\n useLocalDpi: opts.useLocalDpi,\n fallback,\n }) as MediaData,\n );\n } else {\n const type = opts.type;\n mediaData = ctx.file.media.addMedia(\n rawData,\n type,\n (fileName) =>\n ({\n type,\n ...createImageData(\n rawData,\n opts.transformation,\n fileName,\n opts.sourceRectangle,\n opts.nonVisualProperties,\n ),\n useLocalDpi: opts.useLocalDpi,\n }) as MediaData,\n );\n }\n\n // Build drawing XML via descriptor (zero XmlComponent instances)\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n outline: opts.outline,\n fill: opts.fill,\n effects: opts.effects,\n blipEffects: opts.blipEffects,\n tile: opts.tile,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // Chart — side effect: chart registration\n if (\"chart\" in child) {\n const opts = child.chart;\n const chartKey = `chart_${nextChartId++}`;\n const mediaData: ChartMediaData = {\n chartKey,\n transformation: createTransformation(opts.transformation),\n type: \"chart\",\n };\n\n // Register chart — pass all ChartSpaceOptions fields through\n const chartXml = chartSpaceDesc.stringify(\n {\n categories: opts.categories,\n series: opts.series,\n showLegend: opts.showLegend,\n style: opts.style,\n title: opts.title,\n type: opts.type,\n threeD: opts.threeD,\n view3D: opts.view3D,\n },\n ctx.file,\n );\n ctx.file.charts.addChart(chartKey, {\n key: chartKey,\n chartSpaceXml: chartXml ?? \"\",\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // SmartArt — side effect: smartArt registration\n if (\"smartArt\" in child) {\n const opts = child.smartArt;\n const hash = hashSmartArtData(opts);\n const smartArtKey = `smartart_${hash}`;\n const mediaData: SmartArtMediaData = {\n smartArtKey,\n transformation: createTransformation(opts.transformation),\n type: \"smartart\",\n };\n\n // Register SmartArt\n const layoutId = opts.layout ?? \"default\";\n const styleId = opts.style ?? \"simple1\";\n const colorId = opts.color ?? \"accent1_2\";\n const dataModelXml = createDataModel(opts.data.nodes, layoutId, styleId, colorId);\n\n ctx.file.smartArts.addSmartArt(smartArtKey, {\n dataModelXml,\n key: smartArtKey,\n layout: layoutId,\n style: styleId,\n color: colorId,\n });\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n },\n ctx,\n );\n return `<w:r>${drawingXml}</w:r>`;\n }\n\n // WPS Shape (WordProcessing Shape) — side effect: blip fill media registration\n if (\"wpsShape\" in child) {\n const opts = child.wpsShape;\n const mediaData: WpsMediaData = {\n data: opts,\n transformation: createTransformation(opts.transformation),\n type: \"wps\",\n };\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n outline: opts.outline,\n fill: opts.fill,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n registerVmlFallbackMedia(opts, ctx);\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // WPG Group (WordProcessing Group) — group of shapes/pictures\n if (\"wpgGroup\" in child) {\n const opts = child.wpgGroup;\n const mediaData: WpgMediaData = {\n children: opts.children,\n transformation: createTransformation(opts.transformation),\n childOffset: opts.childOffset,\n childExtent: opts.childExtent,\n fill: opts.fill,\n effects: opts.effects,\n groupShapeLocks: opts.groupShapeLocks,\n type: \"wpg\",\n };\n\n // Register pic children media so {fileName} placeholders resolve, recursing\n // into nested wpg groups. wps children carry shape data, not media.\n const registerMedia = (children: readonly GroupChildMediaData[]): void => {\n for (const c of children) {\n if (c.type === \"wps\") continue;\n if (c.type === \"wpg\") {\n registerMedia(c.children);\n continue;\n }\n if (c.type === \"svg\") {\n // Register the raster fallback first so its file name is allocated,\n // then the SVG entry referencing it. Dedup applies to each independently.\n const fb = c.fallback;\n const fbEntry = ctx.file.media.addMedia(\n fb.data,\n fb.type,\n () => fb as MediaData,\n fb.fileName,\n );\n fb.fileName = fbEntry.fileName;\n const svgEntry = ctx.file.media.addMedia(c.data, \"svg\", () => c as MediaData, c.fileName);\n c.fileName = svgEntry.fileName;\n continue;\n }\n const entry = ctx.file.media.addMedia(c.data, c.type, () => c as MediaData, c.fileName);\n // Sync to the canonical entry: when these bytes dedupe against an earlier\n // image, addMedia returns that entry without invoking the build callback,\n // leaving c.fileName at the source basename — the {fileName} placeholder\n // then fails to resolve. entry.fileName is always the registered name.\n c.fileName = entry.fileName;\n }\n };\n registerMedia(opts.children);\n\n const drawingXml = drawingDesc.stringify(\n {\n mediaData,\n docProperties: opts.altText,\n floating: opts.floating,\n graphicFrameLocks: opts.graphicFrameLocks,\n },\n ctx,\n );\n registerVmlFallbackMedia(opts, ctx);\n return wrapDrawingRun(drawingXml, opts);\n }\n\n // Ruby annotation — pure string concatenation\n if (\"ruby\" in child && typeof child.ruby === \"object\" && child.ruby !== null) {\n const r = child.ruby as RubyOptions;\n const align = r.alignment ?? \"center\";\n const hps = (r.fontSize ?? 10) * 2;\n const hpsRaise = (r.raise ?? 10) * 2;\n const hpsBaseText = (r.baseFontSize ?? 20) * 2;\n const lid = r.languageId ?? \"ja-JP\";\n\n const prParts = [\n `<w:rubyAlign w:val=\"${align}\"/>`,\n `<w:hps w:val=\"${hps}\"/>`,\n `<w:hpsRaise w:val=\"${hpsRaise}\"/>`,\n `<w:hpsBaseText w:val=\"${hpsBaseText}\"/>`,\n `<w:lid w:val=\"${lid}\"/>`,\n ];\n if (r.dirty) prParts.push(\"<w:dirty/>\");\n\n const rt = `<w:rt><w:r><w:t xml:space=\"preserve\">${escapeXml(r.text)}</w:t></w:r></w:rt>`;\n const rubyBase = `<w:rubyBase><w:r><w:t xml:space=\"preserve\">${escapeXml(r.base)}</w:t></w:r></w:rubyBase>`;\n\n return `<w:ruby><w:rubyPr>${prParts.join(\"\")}</w:rubyPr>${rt}${rubyBase}</w:ruby>`;\n }\n\n // Math — pure string concatenation\n if (\"math\" in child && typeof child.math === \"object\" && child.math !== null) {\n const mathOpts = child.math;\n const children = mathOpts.children ?? [];\n return stringifyMath(children);\n }\n\n // Inserted text run(s) — w:ins wraps one or more runs (CT_RunTrackChange)\n if (\"insertion\" in child) {\n const { id, author, date, children } = child.insertion;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:ins w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:ins>`;\n }\n\n // Deleted text run(s) — w:del wraps one or more runs (delText content)\n if (\"deletion\" in child) {\n const { id, author, date, children } = child.deletion;\n const body = children.map((c) => stringifyDeletedRun(c)).join(\"\");\n return `<w:del w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:del>`;\n }\n\n // Hyperlink — side effect: relationship registration\n if (\"hyperlink\" in child) {\n const hl = child.hyperlink;\n\n // Serialize children using stringifyRunInline. A top-level `text` is a\n // shorthand for a single text run; without it `{ text, hyperlink }` would\n // emit an empty <w:hyperlink>.\n const childParts: string[] = [];\n if (child.text !== undefined) {\n childParts.push(stringifyRunInline({ text: child.text }, ctx));\n }\n if (hl.children) {\n for (const rc of hl.children) {\n if (typeof rc === \"string\") {\n childParts.push(stringifyRunInline({ text: rc }, ctx));\n } else {\n childParts.push(stringifyRunInline(rc, ctx));\n }\n }\n }\n const body = childParts.join(\"\");\n\n const pushHlAttrs = (attrs: string[]): void => {\n if (hl.history !== false) attrs.push('w:history=\"1\"');\n if (hl.tooltip) attrs.push(`w:tooltip=\"${escapeXml(hl.tooltip)}\"`);\n if (hl.tgtFrame) attrs.push(`w:tgtFrame=\"${escapeXml(hl.tgtFrame)}\"`);\n if (hl.docLocation) attrs.push(`w:docLocation=\"${escapeXml(hl.docLocation)}\"`);\n };\n if (hl.link) {\n const linkId = uniqueId();\n ctx.viewWrapper.relationships.addRelationship(\n linkId,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\",\n hl.link,\n TargetModeType.EXTERNAL,\n );\n const attrs = [`r:id=\"rId${linkId}\"`];\n pushHlAttrs(attrs);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n if (hl.anchor) {\n const attrs = [`w:anchor=\"${escapeXml(hl.anchor)}\"`];\n pushHlAttrs(attrs);\n return `<w:hyperlink ${attrs.join(\" \")}>${body}</w:hyperlink>`;\n }\n return \"\";\n }\n\n // ── Proof error markers ──\n if (\"proofErr\" in child) return `<w:proofErr w:type=\"${child.proofErr}\"/>`;\n\n // ── Positional tab ──\n if (\"positionalTab\" in child) {\n const pt = child.positionalTab;\n return `<w:ptab w:alignment=\"${pt.alignment}\" w:leader=\"${pt.leader}\" w:relativeTo=\"${pt.relativeTo}\"/>`;\n }\n\n // ── Permission range markers ──\n if (\"permStart\" in child) {\n const ps = child.permStart;\n const a: string[] = [`w:id=\"${ps.id}\"`];\n if (ps.ed !== undefined) a.push(`w:ed=\"${escapeXml(String(ps.ed))}\"`);\n if (ps.editGroup !== undefined) a.push(`w:edGrp=\"${ps.editGroup}\"`);\n if (ps.colFirst !== undefined) a.push(`w:colFirst=\"${ps.colFirst}\"`);\n if (ps.colLast !== undefined) a.push(`w:colLast=\"${ps.colLast}\"`);\n return `<w:permStart ${a.join(\" \")}/>`;\n }\n if (\"permEnd\" in child) return `<w:permEnd w:id=\"${child.permEnd}\"/>`;\n\n // ── Move revision range markers ──\n if (\"moveFromRangeStart\" in child) {\n return `<w:moveFromRangeStart ${buildMoveRangeStartAttrs(child.moveFromRangeStart)}/>`;\n }\n if (\"moveFromRangeEnd\" in child)\n return `<w:moveFromRangeEnd ${buildMarkupRangeAttrs(child.moveFromRangeEnd)}/>`;\n if (\"moveToRangeStart\" in child) {\n return `<w:moveToRangeStart ${buildMoveRangeStartAttrs(child.moveToRangeStart)}/>`;\n }\n if (\"moveToRangeEnd\" in child)\n return `<w:moveToRangeEnd ${buildMarkupRangeAttrs(child.moveToRangeEnd)}/>`;\n // Move revision sugar — library allocates range + run ids and pairs markers.\n if (\"moveFrom\" in child) return stringifyMoveRangeChild(\"moveFrom\", child.moveFrom, ctx);\n if (\"moveTo\" in child) return stringifyMoveRangeChild(\"moveTo\", child.moveTo, ctx);\n\n // ── Move revision text runs ──\n if (\"movedFrom\" in child) {\n const { id, author, date, children } = child.movedFrom;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:moveFrom w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:moveFrom>`;\n }\n if (\"movedTo\" in child) {\n const { id, author, date, children } = child.movedTo;\n const body = children\n .map((c) => stringifyRunInline(typeof c === \"string\" ? { text: c } : c, ctx))\n .join(\"\");\n return `<w:moveTo w:id=\"${id}\" w:author=\"${escapeXml(String(author))}\" w:date=\"${date}\">${body}</w:moveTo>`;\n }\n\n // ── Custom XML range markers (track changes) ──\n if (\"customXmlInsRangeStart\" in child) {\n const o = child.customXmlInsRangeStart;\n return `<w:customXmlInsRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlInsRangeEnd\" in child)\n return `<w:customXmlInsRangeEnd w:id=\"${child.customXmlInsRangeEnd}\"/>`;\n if (\"customXmlDelRangeStart\" in child) {\n const o = child.customXmlDelRangeStart;\n return `<w:customXmlDelRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlDelRangeEnd\" in child)\n return `<w:customXmlDelRangeEnd w:id=\"${child.customXmlDelRangeEnd}\"/>`;\n if (\"customXmlMoveFromRangeStart\" in child) {\n const o = child.customXmlMoveFromRangeStart;\n return `<w:customXmlMoveFromRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveFromRangeEnd\" in child)\n return `<w:customXmlMoveFromRangeEnd w:id=\"${child.customXmlMoveFromRangeEnd}\"/>`;\n if (\"customXmlMoveToRangeStart\" in child) {\n const o = child.customXmlMoveToRangeStart;\n return `<w:customXmlMoveToRangeStart w:id=\"${o.id}\"${o.author ? ` w:author=\"${escapeXml(o.author)}\"` : \"\"}${o.date ? ` w:date=\"${o.date}\"` : \"\"}/>`;\n }\n if (\"customXmlMoveToRangeEnd\" in child)\n return `<w:customXmlMoveToRangeEnd w:id=\"${child.customXmlMoveToRangeEnd}\"/>`;\n\n // ── Simple field ──\n if (\"simpleField\" in child) {\n const sf = child.simpleField;\n const sfAttrs = [`w:instr=\"${escapeXml(sf.instruction)}\"`];\n if (sf.fldLock !== undefined) sfAttrs.push(`w:fldLock=\"${sf.fldLock ? 1 : 0}\"`);\n if (sf.dirty !== undefined) sfAttrs.push(`w:dirty=\"${sf.dirty ? 1 : 0}\"`);\n if (sf.cachedValue !== undefined) {\n return `<w:fldSimple ${sfAttrs.join(\" \")}><w:r><w:t>${escapeXml(sf.cachedValue)}</w:t></w:r></w:fldSimple>`;\n }\n return `<w:fldSimple ${sfAttrs.join(\" \")}/>`;\n }\n\n // ── Complex field (PAGE/DATE/TOC/... — fldChar field without w:ffData) ──\n if (\"complexField\" in child) {\n const cf = child.complexField;\n // Run-properties: Word writes identical rPr across a field's runs. Apply\n // the captured control-run rPr to begin/instrText/separate/end and the\n // result-run rPr to the result (defaults to the control rPr when the\n // result had none, matching Word's uniform behavior).\n const ctrl = cf.rPrXml ?? \"\";\n const res = cf.resultRPrXml ?? ctrl;\n // `separate` + the result run are emitted only when there is a cached\n // result; a result-less field round-trips as begin/instrText/end.\n const resultXml =\n cf.result !== undefined\n ? `<w:r>${ctrl}<w:fldChar w:fldCharType=\"separate\"/></w:r>` +\n `<w:r>${res}<w:t xml:space=\"preserve\">${escapeXml(cf.result)}</w:t></w:r>`\n : \"\";\n return (\n `<w:r>${ctrl}<w:fldChar w:fldCharType=\"begin\"/></w:r>` +\n `<w:r>${ctrl}<w:instrText xml:space=\"preserve\">${escapeXml(\n cf.instruction,\n )}</w:instrText></w:r>` +\n resultXml +\n `<w:r>${ctrl}<w:fldChar w:fldCharType=\"end\"/></w:r>`\n );\n }\n\n // ── Sequential identifier (SEQ field) ──\n if (\"seqIdentifier\" in child) {\n const id = child.seqIdentifier;\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\"> SEQ ${escapeXml(id)} </w:instrText>` +\n '<w:fldChar w:fldCharType=\"separate\"/>' +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Page reference (PAGEREF field) ──\n if (\"pageReference\" in child) {\n const pr = child.pageReference;\n let instr = ` PAGEREF ${escapeXml(pr.bookmarkId)} `;\n if (pr.hyperlink) instr += \"\\\\h \";\n if (pr.useRelativePosition) instr += \"\\\\p \";\n return (\n \"<w:r>\" +\n '<w:fldChar w:fldCharType=\"begin\"/>' +\n `<w:instrText xml:space=\"preserve\">${instr}</w:instrText>` +\n '<w:fldChar w:fldCharType=\"end\"/>' +\n \"</w:r>\"\n );\n }\n\n // ── Bidirectional text containers ──\n if (\"dir\" in child) {\n const d = child.dir;\n const childXml = serializeDirChildren(d.children, ctx);\n return `<w:dir w:val=\"${d.val}\">${childXml}</w:dir>`;\n }\n if (\"bdo\" in child) {\n const b = child.bdo;\n const childXml = serializeDirChildren(b.children, ctx);\n return `<w:bdo w:val=\"${b.val}\">${childXml}</w:bdo>`;\n }\n\n // ── Smart tag ──\n if (\"smartTag\" in child) {\n const st = child.smartTag;\n const attrs: string[] = [];\n if (st.uri) attrs.push(`w:uri=\"${escapeXml(st.uri)}\"`);\n attrs.push(`w:element=\"${escapeXml(st.element)}\"`);\n\n const parts: string[] = [];\n if (st.properties?.length) {\n const propParts: string[] = [];\n for (const p of st.properties) {\n const pa: string[] = [];\n if (p.uri) pa.push(`w:uri=\"${escapeXml(p.uri)}\"`);\n pa.push(`w:name=\"${escapeXml(p.name)}\"`, `w:val=\"${escapeXml(p.val)}\"`);\n propParts.push(`<w:attr ${pa.join(\" \")}/>`);\n }\n parts.push(`<w:smartTagPr>${propParts.join(\"\")}</w:smartTagPr>`);\n }\n if (st.children) {\n for (const c of st.children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c, ctx);\n parts.push(\n jr !== undefined\n ? Array.isArray(jr)\n ? jr.join(\"\")\n : jr\n : stringifyRunInline(c as RunOptions, ctx),\n );\n }\n }\n }\n return `<w:smartTag ${attrs.join(\" \")}>${parts.join(\"\")}</w:smartTag>`;\n }\n\n // ── Custom XML run (CT_CustomXmlRun) ──\n if (\"customXml\" in child) {\n const cx = child.customXml;\n const contentParts: string[] = [];\n if (cx.children) {\n for (const c of cx.children) {\n if (typeof c === \"string\") {\n contentParts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c as ParagraphChild, ctx);\n if (jr !== undefined) {\n contentParts.push(Array.isArray(jr) ? jr.join(\"\") : jr);\n } else {\n contentParts.push(stringifyRunInline(c as RunOptions, ctx));\n }\n }\n }\n }\n return stringifyCustomXmlShell(cx, contentParts.join(\"\"));\n }\n\n // ── Inline structured document tag (CT_SdtRun) ──\n if (\"sdt\" in child) {\n const s = child.sdt;\n let contentXml = \"\";\n if (s.properties.checkbox) {\n // Inline checkbox: render the state symbol as a run (no <w:p> wrapper).\n contentXml = checkboxSymbolRunInner(s.properties.checkbox);\n } else if (s.children && s.children.length > 0) {\n const cparts: string[] = [];\n for (const c of s.children) {\n if (typeof c === \"string\") {\n cparts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c as ParagraphChild, ctx);\n if (jr !== undefined) {\n cparts.push(Array.isArray(jr) ? jr.join(\"\") : jr);\n } else if (\"text\" in c || \"children\" in c || \"break\" in c) {\n cparts.push(stringifyRunInline(c as RunOptions, ctx));\n }\n }\n }\n contentXml = cparts.join(\"\");\n }\n return stringifySdtShell(s.properties, s.endProperties, contentXml);\n }\n\n return undefined;\n}\n\n/** Serialize children of Dir/Bdo containers. */\nfunction serializeDirChildren(\n children: (ParagraphChild | string)[] | undefined,\n ctx: BodyContext,\n): string {\n if (!children) return \"\";\n const parts: string[] = [];\n for (const c of children) {\n if (typeof c === \"string\") {\n parts.push(stringifyRunInline({ text: c }, ctx));\n } else {\n const jr = stringifyChildDispatch(c, ctx);\n parts.push(\n jr !== undefined\n ? Array.isArray(jr)\n ? jr.join(\"\")\n : jr\n : stringifyRunInline(c as RunOptions, ctx),\n );\n }\n }\n return parts.join(\"\");\n}\n\n/** Hash SmartArt data for unique key generation (duplicated from SmartArtRun). */\nfunction hashSmartArtData(options: SmartArtOptions): number {\n const data = JSON.stringify(options.data);\n let hash = 0;\n for (let i = 0; i < data.length; i++) {\n const char = data.charCodeAt(i);\n hash = ((hash << 5) - hash + char) | 0;\n }\n return Math.abs(hash);\n}\n\n// ── Paragraph ──\n\nexport function stringifyParagraphInline(\n opts: string | ParagraphOptions,\n ctx: BodyContext,\n): string {\n const resolved: ParagraphOptions = typeof opts === \"string\" ? { text: opts } : opts;\n const parts: string[] = [];\n\n const props = stringifyParagraphProperties(resolved);\n if (props.xml) parts.push(props.xml);\n\n // Register numbering references from inline paragraphs (footnotes, endnotes, etc.)\n // so that concrete numbering instances are created and placeholders get resolved.\n if (props.numberingReferences.length > 0) {\n for (const ref of props.numberingReferences) {\n ctx.file.numbering.createConcreteNumberingInstance(ref.reference, ref.instance);\n }\n }\n\n if (resolved.text !== undefined) {\n parts.push(stringifyRunInline({ text: resolved.text }, ctx));\n }\n\n if (resolved.children) {\n for (const child of resolved.children) {\n if (typeof child === \"string\") {\n parts.push(stringifyRunInline({ text: child }, ctx));\n } else if (typeof child === \"object\" && child !== null) {\n // Try JSON child dispatch first (image, chart, hyperlink, etc.)\n const jsonResult = stringifyChildDispatch(child as ParagraphChild, ctx);\n if (jsonResult !== undefined) {\n if (Array.isArray(jsonResult)) {\n parts.push(...jsonResult);\n } else {\n parts.push(jsonResult);\n }\n } else if (\"text\" in child || \"children\" in child || \"break\" in child) {\n parts.push(stringifyRunInline(child as RunOptions, ctx));\n }\n }\n }\n }\n\n const body = parts.join(\"\");\n return body ? `<w:p>${body}</w:p>` : \"<w:p/>\";\n}\n","/**\n * Direct XML string builders for table properties.\n *\n * Replaces `buildTableProperties() + xml()`, `buildTableRowProperties() + xml()`,\n * `buildTableCellProperties() + xml()`, and `new TablePropertyExceptions().toXml()`\n * with direct string concatenation — no intermediate object tree.\n *\n * @module\n */\n\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport {\n measurementOrPercentValue,\n signedTwipsMeasureValue,\n twipsMeasureValue,\n} from \"@office-open/core\";\nimport type { AlignmentType } from \"@parts/paragraph\";\nimport type { TableCellSpacingProperties } from \"@parts/table/table-cell-spacing\";\nimport type {\n TableCellBordersOptions,\n TextDirection,\n} from \"@parts/table/table-cell/table-cell-components\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableCellMarginOptions } from \"@parts/table/table-properties/table-cell-margin\";\nimport type { TableFloatOptions } from \"@parts/table/table-properties/table-float-properties\";\nimport type { TableLayoutType } from \"@parts/table/table-properties/table-layout\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type { TablePropertyExOptions } from \"@parts/table/table-properties/table-property-exceptions\";\nimport type {\n CnfStyleOptions,\n TableRowPropertiesOptionsBase,\n} from \"@parts/table/table-row/table-row-properties\";\nimport type { TableWidthProperties } from \"@parts/table/table-width\";\nimport { WidthType, widthPctToFiftieths } from \"@parts/table/table-width\";\nimport type { ShadingProperties } from \"@shared/shading\";\nimport type { CellMergeAttributes } from \"@shared/track-revision\";\nimport type { ChangedProperties } from \"@shared/track-revision/track-revision\";\nimport type { TableVerticalAlign } from \"@shared/vertical-align\";\n\nimport { attrParts, borderStr, onOff, shadingStr } from \"../paragraph/stringify\";\n\n// ── Table width string ──\n\nfunction tableWidthStr(name: string, opts: TableWidthProperties): string {\n const type = opts.type ?? WidthType.AUTO;\n // pct: user-facing percentage (100 = 100%) → OOXML fiftieths (5000 = 100%); the\n // emitted @w is always a bare integer, never \"N%\" (a different XSD branch that\n // Word treats as auto on tblW).\n const w = type === WidthType.PERCENTAGE ? widthPctToFiftieths(opts.size) : opts.size;\n const a = attrParts({\n \"w:w\": w !== undefined ? measurementOrPercentValue(w) : undefined,\n \"w:type\": type,\n });\n return `<${name} ${a}/>`;\n}\n\n// ── Cell margin string ──\n\nfunction cellMarginChildrenStr(opts: TableCellMarginOptions): string {\n // CT_TblCellMar sequence order: top, start, left, bottom, end, right.\n // Each side is an independent CT_TblWidth; margins default to DXA.\n const parts: string[] = [];\n const side = (name: string, w: TableWidthProperties | undefined): void => {\n if (w === undefined) return;\n parts.push(tableWidthStr(name, { size: w.size, type: w.type ?? WidthType.DXA }));\n };\n side(\"w:top\", opts.top);\n side(\"w:start\", opts.start);\n side(\"w:left\", opts.left);\n side(\"w:bottom\", opts.bottom);\n side(\"w:end\", opts.end);\n side(\"w:right\", opts.right);\n return parts.join(\"\");\n}\n\nfunction cellMarginStr(tag: string, opts: TableCellMarginOptions): string | undefined {\n const inner = cellMarginChildrenStr(opts);\n return inner ? `<${tag}>${inner}</${tag}>` : undefined;\n}\n\n// ── Table borders string ──\n\n// CT_TblBorders — all 6 sides are optional (minOccurs=0); emit only those set.\nfunction tableBordersStr(opts: TableBordersOptions): string | undefined {\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.insideHorizontal) parts.push(borderStr(\"w:insideH\", opts.insideHorizontal));\n if (opts.insideVertical) parts.push(borderStr(\"w:insideV\", opts.insideVertical));\n return parts.length > 0 ? `<w:tblBorders>${parts.join(\"\")}</w:tblBorders>` : undefined;\n}\n\n// ── Cell borders string ──\n\nfunction cellBordersStr(opts: TableCellBordersOptions): string | undefined {\n // CT_TcBorders sequence: top, start, left, bottom, end, right, insideH, insideV, tl2br, tr2bl.\n const parts: string[] = [];\n if (opts.top) parts.push(borderStr(\"w:top\", opts.top));\n if (opts.start) parts.push(borderStr(\"w:start\", opts.start));\n if (opts.left) parts.push(borderStr(\"w:left\", opts.left));\n if (opts.bottom) parts.push(borderStr(\"w:bottom\", opts.bottom));\n if (opts.end) parts.push(borderStr(\"w:end\", opts.end));\n if (opts.right) parts.push(borderStr(\"w:right\", opts.right));\n if (opts.insideHorizontal) parts.push(borderStr(\"w:insideH\", opts.insideHorizontal));\n if (opts.insideVertical) parts.push(borderStr(\"w:insideV\", opts.insideVertical));\n if (opts.topLeftToBottomRight) parts.push(borderStr(\"w:tl2br\", opts.topLeftToBottomRight));\n if (opts.topRightToBottomLeft) parts.push(borderStr(\"w:tr2bl\", opts.topRightToBottomLeft));\n return parts.length > 0 ? `<w:tcBorders>${parts.join(\"\")}</w:tcBorders>` : undefined;\n}\n\n// ── Float properties string ──\n\nfunction floatPropertiesStr(opts: TableFloatOptions): string {\n const a = attrParts({\n \"w:horzAnchor\": opts.horizontalAnchor,\n \"w:vertAnchor\": opts.verticalAnchor,\n \"w:tblpX\":\n opts.absoluteHorizontalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteHorizontalPosition)\n : undefined,\n \"w:tblpXSpec\": opts.relativeHorizontalPosition,\n \"w:tblpY\":\n opts.absoluteVerticalPosition !== undefined\n ? signedTwipsMeasureValue(opts.absoluteVerticalPosition)\n : undefined,\n \"w:tblpYSpec\": opts.relativeVerticalPosition,\n \"w:bottomFromText\":\n opts.bottomFromText !== undefined ? twipsMeasureValue(opts.bottomFromText) : undefined,\n \"w:topFromText\":\n opts.topFromText !== undefined ? twipsMeasureValue(opts.topFromText) : undefined,\n \"w:leftFromText\":\n opts.leftFromText !== undefined ? twipsMeasureValue(opts.leftFromText) : undefined,\n \"w:rightFromText\":\n opts.rightFromText !== undefined ? twipsMeasureValue(opts.rightFromText) : undefined,\n });\n return `<w:tblpPr ${a}/>`;\n}\n\n// ── Table look string ──\n\nfunction tableLookStr(opts: TableLookOptions): string {\n const a = attrParts({\n \"w:firstRow\": opts.firstRow,\n \"w:lastRow\": opts.lastRow,\n \"w:firstColumn\": opts.firstColumn,\n \"w:lastColumn\": opts.lastColumn,\n \"w:noHBand\": opts.noHBand,\n \"w:noVBand\": opts.noVBand,\n });\n return `<w:tblLook ${a}/>`;\n}\n\n// ── Conditional format style string (CT_Cnf) ──\n\nfunction cnfStyleStr(opts: CnfStyleOptions): string {\n const a = attrParts({\n \"w:val\": opts.val,\n \"w:firstRow\": opts.firstRow,\n \"w:lastRow\": opts.lastRow,\n \"w:firstColumn\": opts.firstColumn,\n \"w:lastColumn\": opts.lastColumn,\n \"w:oddVBand\": opts.oddVBand,\n \"w:evenVBand\": opts.evenVBand,\n \"w:oddHBand\": opts.oddHBand,\n \"w:evenHBand\": opts.evenHBand,\n \"w:firstRowFirstColumn\": opts.firstRowFirstColumn,\n \"w:firstRowLastColumn\": opts.firstRowLastColumn,\n \"w:lastRowFirstColumn\": opts.lastRowFirstColumn,\n \"w:lastRowLastColumn\": opts.lastRowLastColumn,\n });\n return `<w:cnfStyle ${a}/>`;\n}\n\n// ── Change/revision attribute string ──\n\nfunction changeAttrStr(tag: string, opts: ChangedProperties): string {\n const a = attrParts({ \"w:author\": opts.author, \"w:date\": opts.date, \"w:id\": opts.id });\n return `<${tag} ${a}/>`;\n}\n\n// ── Cell merge revision string ──\n\nfunction cellMergeStr(opts: CellMergeAttributes): string {\n const attrs: Record<string, string | number | boolean | undefined> = {\n \"w:author\": opts.author,\n \"w:date\": opts.date,\n \"w:id\": opts.id,\n };\n if (opts.verticalMerge !== undefined) {\n attrs[\"w:vMerge\"] = xsdVerticalMergeRev.to(opts.verticalMerge);\n }\n if (opts.verticalMergeOriginal !== undefined) {\n attrs[\"w:vMergeOrig\"] = xsdVerticalMergeRev.to(opts.verticalMergeOriginal);\n }\n const a = attrParts(attrs);\n return `<w:cellMerge ${a}/>`;\n}\n\n// ── Cell spacing string ──\n\nfunction cellSpacingStr(opts: TableCellSpacingProperties): string {\n // CT_TblWidth: pct size is a user-facing percentage (100 = 100%); convert to\n // fiftieths, matching tableWidthStr. type stays optional (no AUTO default).\n const w = opts.type === WidthType.PERCENTAGE ? widthPctToFiftieths(opts.size) : opts.size;\n const a = attrParts({\n \"w:w\": w !== undefined ? measurementOrPercentValue(w) : undefined,\n \"w:type\": opts.type,\n });\n return `<w:tblCellSpacing ${a}/>`;\n}\n\n// ── Table properties types ──\n\nexport interface TablePropertiesOptionsBase {\n width?: TableWidthProperties;\n indent?: TableWidthProperties;\n layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType];\n borders?: TableBordersOptions;\n float?: TableFloatOptions;\n shading?: ShadingProperties;\n style?: string;\n alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];\n cellMargin?: TableCellMarginOptions;\n visuallyRightToLeft?: boolean;\n tableLook?: TableLookOptions;\n cellSpacing?: TableCellSpacingProperties;\n styleRowBandSize?: number;\n styleColBandSize?: number;\n caption?: string;\n description?: string;\n}\n\nexport type TablePropertiesChangeOptions = TablePropertiesOptions & ChangedProperties;\n\nexport type TablePropertiesOptions = {\n revision?: TablePropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TablePropertiesOptionsBase;\n\n// ── Table properties change (w:tblPrChange) ──\n\nfunction stringifyTablePropertiesChangeInner(options: TablePropertiesChangeOptions): string {\n const inner = stringifyTablePropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tblPrChange ${a}><w:tblPr>${inner}</w:tblPr></w:tblPrChange>`;\n}\n\n// ── Table properties (w:tblPr) ──\n\nfunction stringifyTablePropertiesInner(options: TablePropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.style) {\n parts.push(`<w:tblStyle w:val=\"${options.style}\"/>`);\n }\n\n if (options.float) {\n parts.push(floatPropertiesStr(options.float));\n if (options.float.overlap) {\n parts.push(`<w:tblOverlap w:val=\"${options.float.overlap}\"/>`);\n }\n }\n\n if (options.visuallyRightToLeft !== undefined) {\n parts.push(onOff(\"w:bidiVisual\", options.visuallyRightToLeft));\n }\n\n if (options.styleRowBandSize !== undefined) {\n parts.push(`<w:tblStyleRowBandSize w:val=\"${options.styleRowBandSize}\"/>`);\n }\n\n if (options.styleColBandSize !== undefined) {\n parts.push(`<w:tblStyleColBandSize w:val=\"${options.styleColBandSize}\"/>`);\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.caption !== undefined) {\n parts.push(`<w:tblCaption w:val=\"${options.caption}\"/>`);\n }\n\n if (options.description !== undefined) {\n parts.push(`<w:tblDescription w:val=\"${options.description}\"/>`);\n }\n\n if (options.revision) {\n parts.push(stringifyTablePropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableProperties(options: TablePropertiesOptions): string | undefined {\n const inner = stringifyTablePropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tblPr>${inner}</w:tblPr>`;\n }\n return undefined;\n}\n\n// ── Row properties types ──\n\nexport type TableRowPropertiesChangeOptions = TableRowPropertiesOptionsBase & ChangedProperties;\n\nexport type TableRowPropertiesOptions = TableRowPropertiesOptionsBase & {\n insertion?: ChangedProperties;\n deletion?: ChangedProperties;\n revision?: TableRowPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n};\n\n// ── Row properties change (w:trPrChange) ──\n\nfunction stringifyTableRowPropertiesChangeInner(options: TableRowPropertiesChangeOptions): string {\n const inner = stringifyTableRowPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:trPrChange ${a}><w:trPr>${inner}</w:trPr></w:trPrChange>`;\n}\n\n// ── Row properties (w:trPr) ──\n\nfunction stringifyTableRowPropertiesInner(options: TableRowPropertiesOptions): string {\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n parts.push(cnfStyleStr(options.cnfStyle));\n }\n\n if (options.divId !== undefined) {\n parts.push(`<w:divId w:val=\"${options.divId}\"/>`);\n }\n\n if (options.gridBefore !== undefined) {\n parts.push(`<w:gridBefore w:val=\"${options.gridBefore}\"/>`);\n }\n\n if (options.gridAfter !== undefined) {\n parts.push(`<w:gridAfter w:val=\"${options.gridAfter}\"/>`);\n }\n\n if (options.widthBefore) {\n parts.push(tableWidthStr(\"w:wBefore\", options.widthBefore));\n }\n\n if (options.widthAfter) {\n parts.push(tableWidthStr(\"w:wAfter\", options.widthAfter));\n }\n\n if (options.cantSplit !== undefined) {\n parts.push(onOff(\"w:cantSplit\", options.cantSplit));\n }\n\n if (options.tableHeader !== undefined) {\n parts.push(onOff(\"w:tblHeader\", options.tableHeader));\n }\n\n if (options.height) {\n const a = attrParts({\n \"w:val\": twipsMeasureValue(options.height.value),\n \"w:hRule\": options.height.rule,\n });\n parts.push(`<w:trHeight ${a}/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.rowAlignment) {\n parts.push(`<w:jc w:val=\"${options.rowAlignment}\"/>`);\n }\n\n if (options.hidden !== undefined) {\n parts.push(onOff(\"w:hidden\", options.hidden));\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:ins\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:del\", options.deletion));\n }\n\n if (options.revision) {\n parts.push(stringifyTableRowPropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableRowProperties(\n options: TableRowPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableRowPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:trPr>${inner}</w:trPr>`;\n }\n return undefined;\n}\n\n// ── Cell properties types ──\n\nexport interface TableCellPropertiesOptionsBase {\n cnfStyle?: CnfStyleOptions;\n shading?: ShadingProperties;\n margins?: TableCellMarginOptions;\n verticalAlign?: TableVerticalAlign;\n textDirection?: (typeof TextDirection)[keyof typeof TextDirection];\n verticalMerge?: (typeof VerticalMergeType)[keyof typeof VerticalMergeType];\n width?: TableWidthProperties;\n columnSpan?: number;\n rowSpan?: number;\n borders?: TableCellBordersOptions;\n horizontalMerge?: \"continue\" | \"restart\";\n noWrap?: boolean;\n fitText?: boolean;\n hideMark?: boolean;\n headers?: string[];\n insertion?: ChangedProperties;\n deletion?: ChangedProperties;\n cellMerge?: CellMergeAttributes;\n}\n\nexport type TableCellPropertiesChangeOptions = TableCellPropertiesOptionsBase & ChangedProperties;\n\nexport type TableCellPropertiesOptions = {\n revision?: TableCellPropertiesChangeOptions;\n includeIfEmpty?: boolean;\n} & TableCellPropertiesOptionsBase;\n\n// ── Cell properties change (w:tcPrChange) ──\n\nfunction stringifyTableCellPropertiesChangeInner(\n options: TableCellPropertiesChangeOptions,\n): string {\n const inner = stringifyTableCellPropertiesInner({ ...options, includeIfEmpty: true });\n const a = attrParts({ \"w:author\": options.author, \"w:date\": options.date, \"w:id\": options.id });\n return `<w:tcPrChange ${a}><w:tcPr>${inner}</w:tcPr></w:tcPrChange>`;\n}\n\n// ── Cell properties (w:tcPr) ──\n\nfunction stringifyTableCellPropertiesInner(options: TableCellPropertiesOptions): string {\n // CT_TcPrBase sequence: cnfStyle, tcW, gridSpan, hMerge, vMerge, tcBorders, shd,\n // noWrap, tcMar, textDirection, tcFitText, vAlign, hideMark, headers;\n // then EG_CellMarkupElements (cellIns/cellDel/cellMerge), then tcPrChange.\n const parts: string[] = [];\n\n if (options.cnfStyle !== undefined) {\n parts.push(cnfStyleStr(options.cnfStyle));\n }\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tcW\", options.width));\n }\n\n if (options.columnSpan) {\n parts.push(`<w:gridSpan w:val=\"${options.columnSpan}\"/>`);\n }\n\n if (options.horizontalMerge !== undefined) {\n if (options.horizontalMerge === \"restart\") {\n parts.push(`<w:hMerge w:val=\"restart\"/>`);\n } else {\n parts.push(`<w:hMerge/>`);\n }\n }\n\n if (options.verticalMerge) {\n parts.push(`<w:vMerge w:val=\"${options.verticalMerge}\"/>`);\n } else if (options.rowSpan && options.rowSpan > 1) {\n parts.push(`<w:vMerge w:val=\"${VerticalMergeType.RESTART}\"/>`);\n }\n\n if (options.borders) {\n const bs = cellBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.noWrap !== undefined) {\n parts.push(onOff(\"w:noWrap\", options.noWrap));\n }\n\n if (options.margins) {\n const cm = cellMarginStr(\"w:tcMar\", options.margins);\n if (cm) parts.push(cm);\n }\n\n if (options.textDirection) {\n parts.push(`<w:textDirection w:val=\"${options.textDirection}\"/>`);\n }\n\n if (options.fitText !== undefined) {\n parts.push(onOff(\"w:tcFitText\", options.fitText));\n }\n\n if (options.verticalAlign) {\n parts.push(`<w:vAlign w:val=\"${options.verticalAlign}\"/>`);\n }\n\n if (options.hideMark !== undefined) {\n parts.push(onOff(\"w:hideMark\", options.hideMark));\n }\n\n if (options.headers !== undefined) {\n const headerParts = options.headers.map((h) => `<w:header w:val=\"${h}\"/>`).join(\"\");\n parts.push(`<w:headers>${headerParts}</w:headers>`);\n }\n\n if (options.insertion) {\n parts.push(changeAttrStr(\"w:cellIns\", options.insertion));\n }\n\n if (options.deletion) {\n parts.push(changeAttrStr(\"w:cellDel\", options.deletion));\n }\n\n if (options.cellMerge) {\n parts.push(cellMergeStr(options.cellMerge));\n }\n\n if (options.revision) {\n parts.push(stringifyTableCellPropertiesChangeInner(options.revision));\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTableCellProperties(\n options: TableCellPropertiesOptions,\n): string | undefined {\n const inner = stringifyTableCellPropertiesInner(options);\n if (options.includeIfEmpty || inner) {\n return `<w:tcPr>${inner}</w:tcPr>`;\n }\n return undefined;\n}\n\n// ── Table property exceptions (w:tblPrEx) ──\n\nfunction stringifyTablePropertyExceptionsInner(options: TablePropertyExOptions): string {\n const parts: string[] = [];\n\n if (options.width) {\n parts.push(tableWidthStr(\"w:tblW\", options.width));\n }\n\n if (options.alignment) {\n parts.push(`<w:jc w:val=\"${options.alignment}\"/>`);\n }\n\n if (options.cellSpacing) {\n parts.push(cellSpacingStr(options.cellSpacing));\n }\n\n if (options.indent) {\n parts.push(tableWidthStr(\"w:tblInd\", options.indent));\n }\n\n if (options.borders) {\n const bs = tableBordersStr(options.borders);\n if (bs) parts.push(bs);\n }\n\n if (options.shading) {\n parts.push(shadingStr(options.shading));\n }\n\n if (options.layout) {\n parts.push(`<w:tblLayout w:type=\"${options.layout}\"/>`);\n }\n\n if (options.cellMargin) {\n const cm = cellMarginStr(\"w:tblCellMar\", options.cellMargin);\n if (cm) parts.push(cm);\n }\n\n if (options.tableLook) {\n parts.push(tableLookStr(options.tableLook));\n }\n\n if (options.tblPrExChange) {\n const change = options.tblPrExChange;\n const a = attrParts({ \"w:author\": change.author, \"w:date\": change.date, \"w:id\": change.id });\n // CT_TblPrExChange requires a tblPrEx child holding the previous (pre-change) values.\n const revInner = stringifyTablePropertyExceptionsInner(change);\n parts.push(`<w:tblPrExChange ${a}><w:tblPrEx>${revInner}</w:tblPrEx></w:tblPrExChange>`);\n }\n\n return parts.join(\"\");\n}\n\nexport function stringifyTablePropertyExceptions(options: TablePropertyExOptions): string {\n return `<w:tblPrEx>${stringifyTablePropertyExceptionsInner(options)}</w:tblPrEx>`;\n}\n","/**\n * Table (w:tbl) descriptor for DOCX.\n *\n * Stringifies pure JSON TableOptions into XML using direct string\n * concatenation — no intermediate object tree, no xml() pipeline.\n *\n * @module\n */\n\nimport { ThemeColor } from \"@office-open/core\";\nimport { xsdVerticalMergeRev } from \"@office-open/core\";\nimport type { PositiveUniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrBool, attrMeasure, attrNum, children, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport {\n parseCustomXmlProperties,\n stringifyCustomXmlShell,\n stringifySdtShell,\n} from \"@parts/bodychildren\";\nimport type { CustomXmlCellOptions, CustomXmlRowOptions } from \"@parts/custom-xml\";\nimport { stringifyParagraphInline } from \"@parts/inline\";\nimport { parseRunProperties } from \"@parts/paragraph/run/run-parse\";\nimport { parseSdtProperties } from \"@parts/sdt/sdt-parse\";\nimport type { TableGridChangeOptions } from \"@parts/table/grid\";\nimport type { TableOptions } from \"@parts/table/table\";\nimport type { TableCellSpacingProperties } from \"@parts/table/table-cell-spacing\";\nimport type { SdtCellOptions, TableCellOptions } from \"@parts/table/table-cell/table-cell\";\nimport type { TableCellBordersOptions } from \"@parts/table/table-cell/table-cell-components\";\nimport { VerticalMergeType } from \"@parts/table/table-cell/table-cell-components\";\nimport type { TableBordersOptions } from \"@parts/table/table-properties/table-borders\";\nimport type { TableCellMarginOptions } from \"@parts/table/table-properties/table-cell-margin\";\nimport type { TableFloatOptions } from \"@parts/table/table-properties/table-float-properties\";\nimport type { TableLookOptions } from \"@parts/table/table-properties/table-look\";\nimport type {\n TablePropertyExChangeOptions,\n TablePropertyExOptions,\n} from \"@parts/table/table-properties/table-property-exceptions\";\nimport type { SdtRowOptions, TableRowOptions } from \"@parts/table/table-row/table-row\";\nimport type { CnfStyleOptions } from \"@parts/table/table-row/table-row-properties\";\nimport type { TableWidthProperties } from \"@parts/table/table-width\";\nimport { widthFiftiethsToPct } from \"@parts/table/table-width\";\nimport { BorderStyle } from \"@shared/border\";\nimport type { BorderOptions } from \"@shared/border\";\nimport type { SectionChild } from \"@shared/section\";\nimport { parseShading, type ShadingProperties } from \"@shared/shading\";\nimport type { CellMergeAttributes } from \"@shared/track-revision\";\nimport type { ChangedProperties } from \"@shared/track-revision/track-revision\";\n\nimport type { BodyContext, DocxReadContext } from \"../../context\";\nimport {\n stringifyTableCellProperties,\n stringifyTableProperties,\n stringifyTablePropertyExceptions,\n stringifyTableRowProperties,\n type TableCellPropertiesChangeOptions,\n type TableCellPropertiesOptions,\n type TablePropertiesChangeOptions,\n type TablePropertiesOptions,\n type TableRowPropertiesChangeOptions,\n type TableRowPropertiesOptions,\n} from \"./stringify\";\n\n// Valid border @w:val (ST_Border / BorderStyle) and @w:themeColor (ST_ThemeColor) values.\nconst BORDER_STYLES = Object.values(BorderStyle) as readonly string[];\nconst THEME_COLORS = Object.values(ThemeColor) as readonly string[];\n\n/** Parse track-change attributes (id/author/date) from w:ins/w:del/w:cellIns/w:cellDel. */\nfunction parseChangeAttrs(el: Element): Partial<ChangedProperties> {\n const change: Partial<ChangedProperties> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) change.id = id;\n const author = attr(el, \"w:author\");\n if (author) change.author = author;\n const date = attr(el, \"w:date\");\n if (date) change.date = date;\n return change;\n}\n\n// ── Table grid ──\n\nfunction buildTableGridXml(\n widths: Array<number | string>,\n revision?: TableGridChangeOptions,\n): string {\n const cols = widths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n\n if (revision) {\n const revCols = revision.columnWidths.map((w) => `<w:gridCol w:w=\"${w}\"/>`).join(\"\");\n return `<w:tblGrid>${cols}<w:tblGridChange w:id=\"${revision.id}\"><w:tblGrid>${revCols}</w:tblGrid></w:tblGridChange></w:tblGrid>`;\n }\n\n return `<w:tblGrid>${cols}</w:tblGrid>`;\n}\n\n// ── Cell span extraction ──\n\n/** Extract column/row span from a plain-object cell. */\nfunction getCellSpans(cell: TableCellOptions): {\n columnSpan: number;\n rowSpan: number;\n} {\n return { columnSpan: cell.columnSpan ?? 1, rowSpan: cell.rowSpan ?? 1 };\n}\n\n// ── Cell children stringification ──\n\n/**\n * Stringify a cell child (SectionChild) inline.\n * Handles strings and plain objects (paragraph/table).\n */\nfunction stringifyCellChild(child: SectionChild, ctx: BodyContext): string {\n if (typeof child === \"string\") {\n return stringifyParagraphInline(child, ctx);\n }\n\n // Plain object dispatch\n if (\"paragraph\" in child) {\n return stringifyParagraphInline(child.paragraph, ctx);\n }\n if (\"table\" in child) {\n // Recursive: nested table via descriptor\n return tableDesc.stringify(child.table, ctx) ?? \"\";\n }\n\n // Fallback for other types — should not happen inside table cells\n return \"\";\n}\n\n// ── Cell stringification ──\n\nfunction stringifyTableCell(cell: TableCellOptions, ctx: BodyContext): string {\n const parts: string[] = [];\n\n const tcPr = stringifyTableCellProperties(cell);\n if (tcPr) parts.push(tcPr);\n\n const children = cell.children as SectionChild[] | undefined;\n if (children) {\n for (const child of children) {\n parts.push(stringifyCellChild(child, ctx));\n }\n }\n\n // Cells must end with a paragraph unless the last child is already one\n const last = children?.[children.length - 1];\n const endsWithParagraph =\n last && typeof last !== \"string\" && (\"paragraph\" in last || \"table\" in last);\n if (!endsWithParagraph) {\n parts.push(\"<w:p/>\");\n }\n\n return `<w:tc>${parts.join(\"\")}</w:tc>`;\n}\n\n// ── Row stringification ──\n\nfunction stringifyTableRow(\n row: TableRowOptions,\n ctx: BodyContext,\n extraCells?: { cell: TableCellOptions; columnIndex: number }[],\n): string {\n const parts: string[] = [];\n\n // Property exceptions (tblPrEx)\n if (row.propertyExceptions) {\n parts.push(stringifyTablePropertyExceptions(row.propertyExceptions));\n }\n\n // Row properties\n const trPr = stringifyTableRowProperties(row);\n if (trPr) parts.push(trPr);\n\n const prefixCount = parts.length;\n\n // Cells (a cell may be wrapped by a cell-level SDT or customXml)\n for (const cell of row.cells) {\n if (\"sdt\" in cell) {\n const s = cell.sdt;\n const contentXml = (s.cells ?? []).map((c) => stringifyTableCell(c, ctx)).join(\"\");\n parts.push(stringifySdtShell(s.properties, s.endProperties, contentXml));\n } else if (\"customXml\" in cell) {\n const cx = cell.customXml;\n const contentXml = (cx.children ?? []).map((c) => stringifyTableCell(c, ctx)).join(\"\");\n parts.push(stringifyCustomXmlShell(cx, contentXml));\n } else {\n parts.push(stringifyTableCell(cell, ctx));\n }\n }\n\n // Insert extra CONTINUE cells at correct positions\n if (extraCells && extraCells.length > 0) {\n for (const { cell, columnIndex } of extraCells) {\n const insertIdx = findInsertIndex(row.cells, columnIndex, prefixCount);\n parts.splice(insertIdx, 0, stringifyTableCell(cell, ctx));\n }\n }\n\n // rsid attributes\n const rsidAttrs: string[] = [];\n if (row.runPropertiesRsid) rsidAttrs.push(` w:rsidRPr=\"${row.runPropertiesRsid}\"`);\n if (row.rsid) rsidAttrs.push(` w:rsidR=\"${row.rsid}\"`);\n if (row.deletionRsid) rsidAttrs.push(` w:rsidDel=\"${row.deletionRsid}\"`);\n if (row.tableRowRsid) rsidAttrs.push(` w:rsidTr=\"${row.tableRowRsid}\"`);\n const attr = rsidAttrs.join(\"\");\n\n const body = parts.join(\"\");\n return body ? `<w:tr${attr}>${body}</w:tr>` : attr ? `<w:tr${attr}/>` : \"<w:tr/>\";\n}\n\n// ── Row options type ──\n\n/** Type guard: a plain row (not SDT/customXml-wrapped). */\nfunction isPlainRow(\n r: TableRowOptions | { sdt: SdtRowOptions } | { customXml: CustomXmlRowOptions },\n): r is TableRowOptions {\n return !(\"sdt\" in r) && !(\"customXml\" in r);\n}\n\n/** Type guard: a plain cell (not SDT/customXml-wrapped). */\nfunction isPlainCell(\n c: TableCellOptions | { sdt: SdtCellOptions } | { customXml: CustomXmlCellOptions },\n): c is TableCellOptions {\n return !(\"sdt\" in c) && !(\"customXml\" in c);\n}\n\nfunction findInsertIndex(\n cells: TableRowOptions[\"cells\"],\n columnIndex: number,\n prefixCount: number,\n): number {\n let colIdx = 0;\n for (const [i, c] of cells.entries()) {\n if (!isPlainCell(c)) continue; // SDT/customXml-wrapped cells don't occupy grid columns\n const { columnSpan } = getCellSpans(c);\n colIdx += columnSpan;\n if (colIdx > columnIndex) {\n return i + prefixCount;\n }\n }\n return cells.length + prefixCount;\n}\n\n// ── Vertical merge ──\n\n/**\n * Pre-process rows to compute CONTINUE cells for vertical merge.\n */\nfunction computeVerticalMergeCells(\n rows: TableOptions[\"rows\"],\n): Map<number, { cell: TableCellOptions; columnIndex: number }[]> {\n const extraMap = new Map<number, { cell: TableCellOptions; columnIndex: number }[]>();\n for (let ri = 0; ri < rows.length - 1; ri++) {\n const row = rows[ri];\n if (!row || !isPlainRow(row)) continue; // SDT/customXml-wrapped rows don't participate in merge\n const cells = row.cells;\n let colIdx = 0;\n\n for (const cell of cells) {\n if (!isPlainCell(cell)) continue; // SDT/customXml-wrapped cells don't participate in merge\n const typedCell = cell;\n const { columnSpan, rowSpan } = getCellSpans(typedCell);\n\n if (rowSpan > 1) {\n const continueCell: TableCellOptions = {\n borders: typedCell.borders,\n children: [],\n columnSpan,\n rowSpan: rowSpan - 1,\n verticalMerge: VerticalMergeType.CONTINUE,\n };\n\n if (!extraMap.has(ri + 1)) {\n extraMap.set(ri + 1, []);\n }\n extraMap.get(ri + 1)!.push({ cell: continueCell, columnIndex: colIdx });\n }\n\n colIdx += columnSpan;\n }\n }\n\n return extraMap;\n}\n\n/** Parse a w:tblCellMar / w:tcMar container into TableCellMarginOptions. */\nfunction parseCellMargins(marginEl: Element): TableCellMarginOptions | undefined {\n const margins: TableCellMarginOptions = {};\n // CT_TblCellMar sides: top, start, left, bottom, end, right — each an\n // independent CT_TblWidth ({ size, type }). Parse faithfully: omit type\n // when the XML has none (stringify defaults it to DXA on the way back).\n for (const side of [\"top\", \"start\", \"left\", \"bottom\", \"end\", \"right\"] as const) {\n const sideEl = findChild(marginEl, `w:${side}`);\n if (sideEl) {\n const type = attr(sideEl, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(sideEl, \"w:w\"), type);\n if (size !== undefined) {\n margins[side] = (\n type ? { size, type: type as TableWidthProperties[\"type\"] } : { size }\n ) as TableWidthProperties;\n }\n }\n }\n if (Object.keys(margins).length === 0) return undefined;\n return margins as TableCellMarginOptions;\n}\n\n/** Parse a w:cnfStyle (CT_Cnf) element into CnfStyleOptions. */\nfunction parseCnfStyle(cnfEl: Element): CnfStyleOptions | undefined {\n const cnf: CnfStyleOptions = {};\n const val = attr(cnfEl, \"w:val\");\n if (val) cnf.val = val;\n const firstRow = attrBool(cnfEl, \"w:firstRow\");\n if (firstRow !== undefined) cnf.firstRow = firstRow;\n const lastRow = attrBool(cnfEl, \"w:lastRow\");\n if (lastRow !== undefined) cnf.lastRow = lastRow;\n const firstColumn = attrBool(cnfEl, \"w:firstColumn\");\n if (firstColumn !== undefined) cnf.firstColumn = firstColumn;\n const lastColumn = attrBool(cnfEl, \"w:lastColumn\");\n if (lastColumn !== undefined) cnf.lastColumn = lastColumn;\n const oddVBand = attrBool(cnfEl, \"w:oddVBand\");\n if (oddVBand !== undefined) cnf.oddVBand = oddVBand;\n const evenVBand = attrBool(cnfEl, \"w:evenVBand\");\n if (evenVBand !== undefined) cnf.evenVBand = evenVBand;\n const oddHBand = attrBool(cnfEl, \"w:oddHBand\");\n if (oddHBand !== undefined) cnf.oddHBand = oddHBand;\n const evenHBand = attrBool(cnfEl, \"w:evenHBand\");\n if (evenHBand !== undefined) cnf.evenHBand = evenHBand;\n const firstRowFirstColumn = attrBool(cnfEl, \"w:firstRowFirstColumn\");\n if (firstRowFirstColumn !== undefined) cnf.firstRowFirstColumn = firstRowFirstColumn;\n const firstRowLastColumn = attrBool(cnfEl, \"w:firstRowLastColumn\");\n if (firstRowLastColumn !== undefined) cnf.firstRowLastColumn = firstRowLastColumn;\n const lastRowFirstColumn = attrBool(cnfEl, \"w:lastRowFirstColumn\");\n if (lastRowFirstColumn !== undefined) cnf.lastRowFirstColumn = lastRowFirstColumn;\n const lastRowLastColumn = attrBool(cnfEl, \"w:lastRowLastColumn\");\n if (lastRowLastColumn !== undefined) cnf.lastRowLastColumn = lastRowLastColumn;\n if (Object.keys(cnf).length === 0) return undefined;\n return cnf as CnfStyleOptions;\n}\n\n/**\n * Parse a w:tblPrEx (CT_TblPrEx) element into TablePropertyExOptions.\n * CT_TblPrExBase shares its child elements with CT_TblPrBase, so this reuses\n * parseTablePropertiesEl and maps the table-level margins field to cellMargin.\n */\nfunction parseTablePropertyExceptions(el: Element): TablePropertyExOptions {\n const base = parseTablePropertiesEl(el);\n const opts: TablePropertyExOptions = {};\n if (base.width !== undefined) opts.width = base.width as TableWidthProperties;\n if (base.indent !== undefined) opts.indent = base.indent as TableWidthProperties;\n if (base.layout !== undefined) opts.layout = base.layout as TablePropertyExOptions[\"layout\"];\n if (base.borders !== undefined) opts.borders = base.borders as TableBordersOptions;\n if (base.shading !== undefined) opts.shading = base.shading as ShadingProperties;\n if (base.alignment !== undefined) {\n opts.alignment = base.alignment as TablePropertyExOptions[\"alignment\"];\n }\n if (base.cellMargin !== undefined) opts.cellMargin = base.cellMargin;\n if (base.tableLook !== undefined) opts.tableLook = base.tableLook as TableLookOptions;\n if (base.cellSpacing !== undefined) {\n opts.cellSpacing = base.cellSpacing as TableCellSpacingProperties;\n }\n const tblPrExChange = findChild(el, \"w:tblPrExChange\");\n if (tblPrExChange) {\n const change = parseTablePropertyExChange(tblPrExChange);\n if (change) opts.tblPrExChange = change;\n }\n return opts as TablePropertyExOptions;\n}\n\n/** Parse a w:tblPrExChange (CT_TblPrExChange) — track-change wrapper around the previous tblPrEx. */\nfunction parseTablePropertyExChange(el: Element): TablePropertyExChangeOptions | undefined {\n const change: Partial<TablePropertyExChangeOptions> = {};\n const id = attrNum(el, \"w:id\");\n if (id !== undefined) change.id = id;\n const author = attr(el, \"w:author\");\n if (author) change.author = author;\n const date = attr(el, \"w:date\");\n if (date) change.date = date;\n const innerTblPrEx = findChild(el, \"w:tblPrEx\");\n if (innerTblPrEx) {\n const inner = parseTablePropertyExceptions(innerTblPrEx);\n if (inner.width !== undefined) change.width = inner.width;\n if (inner.indent !== undefined) change.indent = inner.indent;\n if (inner.layout !== undefined) change.layout = inner.layout;\n if (inner.borders !== undefined) change.borders = inner.borders;\n if (inner.shading !== undefined) change.shading = inner.shading;\n if (inner.alignment !== undefined) change.alignment = inner.alignment;\n if (inner.cellMargin !== undefined) change.cellMargin = inner.cellMargin;\n if (inner.tableLook !== undefined) change.tableLook = inner.tableLook;\n if (inner.cellSpacing !== undefined) change.cellSpacing = inner.cellSpacing;\n }\n if (change.id === undefined || change.author === undefined) return undefined;\n return change as TablePropertyExChangeOptions;\n}\n\n// ── Descriptor ──\n\nexport const tableDesc: CustomDescriptor<TableOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [];\n\n // Table properties\n // tblPr is required in CT_Tbl (minOccurs defaults to 1) — always emit it,\n // even when empty; do not inject optional defaults (width/borders are XSD-optional).\n const tblPrOpts: TablePropertiesOptions = {\n alignment: opts.alignment,\n borders: opts.borders,\n caption: opts.caption,\n cellMargin: opts.margins,\n cellSpacing: opts.cellSpacing,\n description: opts.description,\n float: opts.float,\n indent: opts.indent,\n layout: opts.layout,\n revision: opts.revision,\n shading: opts.shading,\n style: opts.style,\n styleColBandSize: opts.styleColBandSize,\n styleRowBandSize: opts.styleRowBandSize,\n tableLook: opts.tableLook,\n visuallyRightToLeft: opts.visuallyRightToLeft,\n width: opts.width,\n includeIfEmpty: true,\n };\n parts.push(stringifyTableProperties(tblPrOpts)!);\n\n // Table grid\n const columnWidths =\n opts.columnWidths ??\n Array(Math.max(1, ...opts.rows.map((r) => (isPlainRow(r) ? r.cells.length : 0)))).fill(100);\n parts.push(buildTableGridXml(columnWidths, opts.columnWidthsRevision));\n\n // Compute vertical merge CONTINUE cells\n const extraCells = computeVerticalMergeCells(opts.rows);\n\n // Rows (a row may be wrapped by a row-level SDT)\n for (const [ri, r] of opts.rows.entries()) {\n if (\"sdt\" in r) {\n const sdt = r.sdt;\n const contentXml = (sdt.rows ?? []).map((rr) => stringifyTableRow(rr, ctx)).join(\"\");\n parts.push(stringifySdtShell(sdt.properties, sdt.endProperties, contentXml));\n } else if (\"customXml\" in r) {\n const cx = r.customXml;\n const contentXml = (cx.children ?? []).map((rr) => stringifyTableRow(rr, ctx)).join(\"\");\n parts.push(stringifyCustomXmlShell(cx, contentXml));\n } else {\n const extras = extraCells.get(ri);\n parts.push(stringifyTableRow(r, ctx, extras));\n }\n }\n\n return `<w:tbl>${parts.join(\"\")}</w:tbl>`;\n },\n\n parse(el, ctx) {\n return parseTableEl(el, ctx as DocxReadContext);\n },\n};\n\n// ── Parse (Element → TableOptions) ──\n\ntype ParseChildFn = (el: Element, ctx: DocxReadContext) => SectionChild;\n\n/** Callback used by table parser to parse body children. */\nlet _parseChild: ParseChildFn | undefined;\n\n/** Set the child parser callback (called from parseBody). */\nexport function setTableParseChild(fn: ParseChildFn): void {\n _parseChild = fn;\n}\n\nexport function parseTablePropertiesEl(el: Element): TablePropertiesOptions {\n const opts: TablePropertiesOptions = {};\n\n const style = findChild(el, \"w:tblStyle\");\n if (style) {\n const val = attr(style, \"w:val\");\n if (val) opts.style = val;\n }\n\n const tblW = findChild(el, \"w:tblW\");\n if (tblW) {\n const type = attr(tblW, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(tblW, \"w:w\"), type);\n if (size !== undefined || type) {\n opts.width = { size: size ?? 0, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.alignment = val as TablePropertiesOptions[\"alignment\"];\n }\n\n const layout = findChild(el, \"w:tblLayout\");\n if (layout) {\n const val = attr(layout, \"w:type\");\n if (val === \"autofit\" || val === \"fixed\") opts.layout = val;\n }\n\n const tblBorders = findChild(el, \"w:tblBorders\");\n if (tblBorders) {\n // XML side names → TableBordersOptions keys (insideH/insideV map to\n // insideHorizontal/insideVertical); all 6 sides are CT_TblBorders-optional.\n const SIDE_KEYS: ReadonlyArray<[string, keyof TableBordersOptions]> = [\n [\"top\", \"top\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"right\", \"right\"],\n [\"insideH\", \"insideHorizontal\"],\n [\"insideV\", \"insideVertical\"],\n ];\n const borders: TableBordersOptions = {};\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tblBorders, `w:${xmlSide}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n borders[key] = sideOpts;\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const tblCellMar = findChild(el, \"w:tblCellMar\");\n if (tblCellMar) {\n const margins = parseCellMargins(tblCellMar);\n if (margins) opts.cellMargin = margins;\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading = parseShading(shd);\n if (shading) opts.shading = shading;\n }\n\n // description → w:tblDescription/@w:val\n const tblDesc = findChild(el, \"w:tblDescription\");\n if (tblDesc) {\n const val = attr(tblDesc, \"w:val\");\n if (val) opts.description = val;\n }\n\n // float → w:tblpPr attributes + w:tblOverlap (sibling element in CT_TblPrBase)\n const tblpPr = findChild(el, \"w:tblpPr\");\n const tblOverlap = findChild(el, \"w:tblOverlap\");\n if (tblpPr || tblOverlap) {\n const floatOpts: Partial<TableFloatOptions> = {};\n if (tblpPr) {\n const horzAnchor = attr(tblpPr, \"w:horzAnchor\");\n if (horzAnchor)\n floatOpts.horizontalAnchor = horzAnchor as TableFloatOptions[\"horizontalAnchor\"];\n const vertAnchor = attr(tblpPr, \"w:vertAnchor\");\n if (vertAnchor) floatOpts.verticalAnchor = vertAnchor as TableFloatOptions[\"verticalAnchor\"];\n const tblpX = attrNum(tblpPr, \"w:tblpX\");\n if (tblpX !== undefined) floatOpts.absoluteHorizontalPosition = tblpX;\n const tblpXSpec = attr(tblpPr, \"w:tblpXSpec\");\n if (tblpXSpec)\n floatOpts.relativeHorizontalPosition =\n tblpXSpec as TableFloatOptions[\"relativeHorizontalPosition\"];\n const tblpY = attrNum(tblpPr, \"w:tblpY\");\n if (tblpY !== undefined) floatOpts.absoluteVerticalPosition = tblpY;\n const tblpYSpec = attr(tblpPr, \"w:tblpYSpec\");\n if (tblpYSpec)\n floatOpts.relativeVerticalPosition =\n tblpYSpec as TableFloatOptions[\"relativeVerticalPosition\"];\n const bottomFromText = attrNum(tblpPr, \"w:bottomFromText\");\n if (bottomFromText !== undefined) floatOpts.bottomFromText = bottomFromText;\n const topFromText = attrNum(tblpPr, \"w:topFromText\");\n if (topFromText !== undefined) floatOpts.topFromText = topFromText;\n const leftFromText = attrNum(tblpPr, \"w:leftFromText\");\n if (leftFromText !== undefined) floatOpts.leftFromText = leftFromText;\n const rightFromText = attrNum(tblpPr, \"w:rightFromText\");\n if (rightFromText !== undefined) floatOpts.rightFromText = rightFromText;\n }\n if (tblOverlap) {\n const overlap = attr(tblOverlap, \"w:val\");\n if (overlap) floatOpts.overlap = overlap as TableFloatOptions[\"overlap\"];\n }\n if (Object.keys(floatOpts).length > 0) opts.float = floatOpts as TableFloatOptions;\n }\n\n // indent → w:tblInd/@w:w and @w:type\n const tblInd = findChild(el, \"w:tblInd\");\n if (tblInd) {\n const type = attr(tblInd, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(tblInd, \"w:w\"), type);\n if (size !== undefined) {\n opts.indent = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n // visuallyRightToLeft → w:bidiVisual\n const bidiVisual = findChild(el, \"w:bidiVisual\");\n if (bidiVisual) opts.visuallyRightToLeft = attrBool(bidiVisual, \"w:val\") ?? true;\n\n // styleRowBandSize / styleColBandSize\n const tblStyleRowBandSize = findChild(el, \"w:tblStyleRowBandSize\");\n if (tblStyleRowBandSize) {\n const val = attrNum(tblStyleRowBandSize, \"w:val\");\n if (val !== undefined) opts.styleRowBandSize = val;\n }\n const tblStyleColBandSize = findChild(el, \"w:tblStyleColBandSize\");\n if (tblStyleColBandSize) {\n const val = attrNum(tblStyleColBandSize, \"w:val\");\n if (val !== undefined) opts.styleColBandSize = val;\n }\n\n // caption → w:tblCaption/@w:val\n const tblCaption = findChild(el, \"w:tblCaption\");\n if (tblCaption) {\n const val = attr(tblCaption, \"w:val\");\n if (val) opts.caption = val;\n }\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = widthFiftiethsToPct(attrMeasure(tblCellSpacing, \"w:w\"), type);\n if (w !== undefined)\n opts.cellSpacing = { size: w, ...(type ? { type } : {}) } as TableCellSpacingProperties;\n }\n\n // Revision (w:tblPrChange)\n const tblPrChange = findChild(el, \"w:tblPrChange\");\n if (tblPrChange) {\n const rev: Partial<TablePropertiesChangeOptions> = {};\n const author = attr(tblPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tblPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tblPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTblPr = findChild(tblPrChange, \"w:tblPr\");\n if (innerTblPr) {\n Object.assign(rev, parseTablePropertiesEl(innerTblPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TablePropertiesChangeOptions;\n }\n\n // tblLook — conditional formatting flags (CT_TblLook)\n const tblLook = findChild(el, \"w:tblLook\");\n if (tblLook) {\n const look: TableLookOptions = {};\n const firstRow = attrBool(tblLook, \"w:firstRow\");\n if (firstRow !== undefined) look.firstRow = firstRow;\n const lastRow = attrBool(tblLook, \"w:lastRow\");\n if (lastRow !== undefined) look.lastRow = lastRow;\n const firstColumn = attrBool(tblLook, \"w:firstColumn\");\n if (firstColumn !== undefined) look.firstColumn = firstColumn;\n const lastColumn = attrBool(tblLook, \"w:lastColumn\");\n if (lastColumn !== undefined) look.lastColumn = lastColumn;\n const noHBand = attrBool(tblLook, \"w:noHBand\");\n if (noHBand !== undefined) look.noHBand = noHBand;\n const noVBand = attrBool(tblLook, \"w:noVBand\");\n if (noVBand !== undefined) look.noVBand = noVBand;\n if (Object.keys(look).length > 0) opts.tableLook = look;\n }\n\n return opts;\n}\n\nfunction parseColumnWidthsEl(el: Element): {\n widths: Array<number | string>;\n revision?: TableGridChangeOptions;\n} {\n const widths: Array<number | string> = [];\n const tblGrid = findChild(el, \"w:tblGrid\");\n if (!tblGrid) return { widths };\n\n for (const col of children(tblGrid, \"w:gridCol\")) {\n const w = attrMeasure(col, \"w:w\");\n widths.push(w ?? 100);\n }\n\n // CT_TblGrid may carry a tblGridChange (CT_TblGridChange = CT_Markup + tblGrid).\n const tblGridChange = findChild(tblGrid, \"w:tblGridChange\");\n if (tblGridChange) {\n const id = attrNum(tblGridChange, \"w:id\");\n const innerGrid = findChild(tblGridChange, \"w:tblGrid\");\n const revWidths: Array<number | string> = [];\n if (innerGrid) {\n for (const col of children(innerGrid, \"w:gridCol\")) {\n const w = attrMeasure(col, \"w:w\");\n revWidths.push(w ?? 100);\n }\n }\n if (id !== undefined) {\n return {\n widths,\n revision: { id, columnWidths: revWidths as number[] | PositiveUniversalMeasure[] },\n };\n }\n }\n\n return { widths };\n}\n\nexport function parseTableRowPropertiesEl(el: Element): TableRowPropertiesOptions {\n const opts: TableRowPropertiesOptions = {};\n\n const trHeight = findChild(el, \"w:trHeight\");\n if (trHeight) {\n const val = attrMeasure(trHeight, \"w:val\");\n const rule = attr(trHeight, \"w:hRule\");\n if (val !== undefined) {\n opts.height = { value: val, ...(rule ? { rule } : {}) } as NonNullable<\n TableRowPropertiesOptions[\"height\"]\n >;\n }\n }\n\n // cnfStyle → w:cnfStyle (CT_Cnf)\n const cnfStyle = findChild(el, \"w:cnfStyle\");\n if (cnfStyle) {\n const cnf = parseCnfStyle(cnfStyle);\n if (cnf) opts.cnfStyle = cnf;\n }\n\n // divId → w:divId/@w:val\n const divId = findChild(el, \"w:divId\");\n if (divId) {\n const val = attrNum(divId, \"w:val\");\n if (val !== undefined) opts.divId = val;\n }\n\n // gridBefore / gridAfter\n const gridBefore = findChild(el, \"w:gridBefore\");\n if (gridBefore) {\n const val = attrNum(gridBefore, \"w:val\");\n if (val !== undefined) opts.gridBefore = val;\n }\n const gridAfter = findChild(el, \"w:gridAfter\");\n if (gridAfter) {\n const val = attrNum(gridAfter, \"w:val\");\n if (val !== undefined) opts.gridAfter = val;\n }\n\n // wBefore / wAfter → widthBefore / widthAfter\n const wBefore = findChild(el, \"w:wBefore\");\n if (wBefore) {\n const type = attr(wBefore, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(wBefore, \"w:w\"), type);\n if (size !== undefined)\n opts.widthBefore = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n const wAfter = findChild(el, \"w:wAfter\");\n if (wAfter) {\n const type = attr(wAfter, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(wAfter, \"w:w\"), type);\n if (size !== undefined)\n opts.widthAfter = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n\n // rowAlignment → w:jc/@w:val\n const jc = findChild(el, \"w:jc\");\n if (jc) {\n const val = attr(jc, \"w:val\");\n if (val) opts.rowAlignment = val as TableRowPropertiesOptions[\"rowAlignment\"];\n }\n\n // hidden → w:hidden\n const hidden = findChild(el, \"w:hidden\");\n if (hidden) opts.hidden = attrBool(hidden, \"w:val\") ?? true;\n\n // cellSpacing → w:tblCellSpacing\n const tblCellSpacing = findChild(el, \"w:tblCellSpacing\");\n if (tblCellSpacing) {\n const type = attr(tblCellSpacing, \"w:type\");\n const w = widthFiftiethsToPct(attrMeasure(tblCellSpacing, \"w:w\"), type);\n if (w !== undefined)\n opts.cellSpacing = { size: w, ...(type ? { type } : {}) } as TableCellSpacingProperties;\n }\n\n // insertion / deletion (track changes)\n const ins = findChild(el, \"w:ins\");\n if (ins) opts.insertion = parseChangeAttrs(ins) as ChangedProperties;\n const del = findChild(el, \"w:del\");\n if (del) opts.deletion = parseChangeAttrs(del) as ChangedProperties;\n\n // Revision (w:trPrChange)\n const trPrChange = findChild(el, \"w:trPrChange\");\n if (trPrChange) {\n const rev: Partial<TableRowPropertiesChangeOptions> = {};\n const author = attr(trPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(trPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(trPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTrPr = findChild(trPrChange, \"w:trPr\");\n if (innerTrPr) {\n Object.assign(rev, parseTableRowPropertiesEl(innerTrPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TableRowPropertiesChangeOptions;\n }\n\n const tblHeader = findChild(el, \"w:tblHeader\");\n if (tblHeader) {\n opts.tableHeader = attrBool(tblHeader, \"w:val\") ?? true;\n }\n\n const cantSplit = findChild(el, \"w:cantSplit\");\n if (cantSplit) {\n opts.cantSplit = attrBool(cantSplit, \"w:val\") ?? true;\n }\n\n return opts;\n}\n\nexport function parseTableCellPropertiesEl(el: Element): TableCellPropertiesOptions {\n const opts: TableCellPropertiesOptions = {};\n\n const cnfStyle = findChild(el, \"w:cnfStyle\");\n if (cnfStyle) {\n const cnf = parseCnfStyle(cnfStyle);\n if (cnf) opts.cnfStyle = cnf;\n }\n\n const tcW = findChild(el, \"w:tcW\");\n if (tcW) {\n const type = attr(tcW, \"w:type\");\n const size = widthFiftiethsToPct(attrMeasure(tcW, \"w:w\"), type);\n if (size !== undefined) {\n opts.width = { size, ...(type ? { type } : {}) } as TableWidthProperties;\n }\n }\n\n const gridSpan = findChild(el, \"w:gridSpan\");\n if (gridSpan) {\n const val = attrNum(gridSpan, \"w:val\");\n if (val !== undefined) opts.columnSpan = val;\n }\n\n const vMerge = findChild(el, \"w:vMerge\");\n if (vMerge) {\n const val = attr(vMerge, \"w:val\");\n opts.verticalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n const vAlign = findChild(el, \"w:vAlign\");\n if (vAlign) {\n const val = attr(vAlign, \"w:val\");\n if (val) opts.verticalAlign = val as TableCellPropertiesOptions[\"verticalAlign\"];\n }\n\n const shd = findChild(el, \"w:shd\");\n if (shd) {\n const shading = parseShading(shd);\n if (shading) opts.shading = shading;\n }\n\n const tcBorders = findChild(el, \"w:tcBorders\");\n if (tcBorders) {\n // XML side name → TableCellBordersOptions key (incl. start/end + diagonals);\n // all sides are CT_TcBorders-optional. Mirrors table-level borders parse.\n const SIDE_KEYS: ReadonlyArray<[string, keyof TableCellBordersOptions]> = [\n [\"top\", \"top\"],\n [\"start\", \"start\"],\n [\"left\", \"left\"],\n [\"bottom\", \"bottom\"],\n [\"end\", \"end\"],\n [\"right\", \"right\"],\n [\"insideH\", \"insideHorizontal\"],\n [\"insideV\", \"insideVertical\"],\n [\"tl2br\", \"topLeftToBottomRight\"],\n [\"tr2bl\", \"topRightToBottomLeft\"],\n ];\n const borders: TableCellBordersOptions = {};\n for (const [xmlSide, key] of SIDE_KEYS) {\n const sideEl = findChild(tcBorders, `w:${xmlSide}`);\n if (!sideEl) continue;\n // CT_Border requires w:val (style); skip malformed sides\n const style = attr(sideEl, \"w:val\");\n if (!style || !BORDER_STYLES.includes(style)) continue;\n const sideOpts: BorderOptions = { style: style as BorderOptions[\"style\"] };\n const color = attr(sideEl, \"w:color\");\n if (color) sideOpts.color = color;\n const size = attrNum(sideEl, \"w:sz\");\n if (size !== undefined) sideOpts.size = size;\n const space = attrNum(sideEl, \"w:space\");\n if (space !== undefined) sideOpts.space = space;\n const themeColor = attr(sideEl, \"w:themeColor\");\n if (themeColor && THEME_COLORS.includes(themeColor)) {\n sideOpts.themeColor = themeColor as BorderOptions[\"themeColor\"];\n }\n const themeTint = attr(sideEl, \"w:themeTint\");\n if (themeTint) sideOpts.themeTint = themeTint;\n const themeShade = attr(sideEl, \"w:themeShade\");\n if (themeShade) sideOpts.themeShade = themeShade;\n const shadow = attrBool(sideEl, \"w:shadow\");\n if (shadow !== undefined) sideOpts.shadow = shadow;\n const frame = attrBool(sideEl, \"w:frame\");\n if (frame !== undefined) sideOpts.frame = frame;\n borders[key] = sideOpts;\n }\n if (Object.keys(borders).length > 0) opts.borders = borders;\n }\n\n const noWrap = findChild(el, \"w:noWrap\");\n if (noWrap) opts.noWrap = attrBool(noWrap, \"w:val\") ?? true;\n\n const tcMar = findChild(el, \"w:tcMar\");\n if (tcMar) {\n const margins = parseCellMargins(tcMar);\n if (margins) opts.margins = margins;\n }\n\n const textDirection = findChild(el, \"w:textDirection\");\n if (textDirection) {\n const val = attr(textDirection, \"w:val\");\n if (val) opts.textDirection = val as TableCellPropertiesOptions[\"textDirection\"];\n }\n\n // horizontalMerge → w:hMerge\n const hMerge = findChild(el, \"w:hMerge\");\n if (hMerge) {\n const val = attr(hMerge, \"w:val\");\n opts.horizontalMerge = val === \"restart\" ? \"restart\" : \"continue\";\n }\n\n // fitText → w:tcFitText\n const tcFitText = findChild(el, \"w:tcFitText\");\n if (tcFitText) opts.fitText = attrBool(tcFitText, \"w:val\") ?? true;\n\n // hideMark → w:hideMark\n const hideMark = findChild(el, \"w:hideMark\");\n if (hideMark) opts.hideMark = attrBool(hideMark, \"w:val\") ?? true;\n\n // headers → w:headers/w:header\n const headersEl = findChild(el, \"w:headers\");\n if (headersEl) {\n const headerVals: string[] = [];\n for (const h of headersEl.elements ?? []) {\n if (h.name !== \"w:header\") continue;\n const val = attr(h, \"w:val\");\n if (val) headerVals.push(val);\n }\n if (headerVals.length > 0) opts.headers = headerVals;\n }\n\n // insertion / deletion (track changes)\n const cellIns = findChild(el, \"w:cellIns\");\n if (cellIns) opts.insertion = parseChangeAttrs(cellIns) as ChangedProperties;\n const cellDel = findChild(el, \"w:cellDel\");\n if (cellDel) opts.deletion = parseChangeAttrs(cellDel) as ChangedProperties;\n\n // Revision (w:tcPrChange)\n const tcPrChange = findChild(el, \"w:tcPrChange\");\n if (tcPrChange) {\n const rev: Partial<TableCellPropertiesChangeOptions> = {};\n const author = attr(tcPrChange, \"w:author\");\n if (author) rev.author = author;\n const date = attr(tcPrChange, \"w:date\");\n if (date) rev.date = date;\n const id = attrNum(tcPrChange, \"w:id\");\n if (id !== undefined) rev.id = id;\n const innerTcPr = findChild(tcPrChange, \"w:tcPr\");\n if (innerTcPr) {\n Object.assign(rev, parseTableCellPropertiesEl(innerTcPr));\n }\n if (Object.keys(rev).length > 0) opts.revision = rev as TableCellPropertiesChangeOptions;\n }\n\n // cellMerge → w:cellMerge\n const cellMerge = findChild(el, \"w:cellMerge\");\n if (cellMerge) {\n const cm = parseChangeAttrs(cellMerge) as Partial<CellMergeAttributes>;\n const vMerge = attr(cellMerge, \"w:vMerge\");\n if (vMerge) cm.verticalMerge = xsdVerticalMergeRev.from(vMerge) as \"continue\" | \"restart\";\n const vMergeOrig = attr(cellMerge, \"w:vMergeOrig\");\n if (vMergeOrig) {\n cm.verticalMergeOriginal = xsdVerticalMergeRev.from(vMergeOrig) as \"continue\" | \"restart\";\n }\n if (Object.keys(cm).length > 0) opts.cellMerge = cm as CellMergeAttributes;\n }\n\n return opts;\n}\n\nfunction parseTableCellEl(el: Element, ctx: DocxReadContext): TableCellOptions {\n const opts: Partial<TableCellOptions> = {};\n\n const tcPr = findChild(el, \"w:tcPr\");\n if (tcPr) {\n Object.assign(opts, parseTableCellPropertiesEl(tcPr));\n }\n\n const childElements: SectionChild[] = [];\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"w:tcPr\":\n break;\n case \"w:p\":\n case \"w:tbl\":\n if (_parseChild) childElements.push(_parseChild(child, ctx));\n break;\n default:\n break;\n }\n }\n\n opts.children = childElements;\n return opts as TableCellOptions;\n}\n\nfunction parseTableRowEl(el: Element, ctx: DocxReadContext): TableRowOptions {\n const opts: Partial<TableRowOptions> = {};\n\n const trPr = findChild(el, \"w:trPr\");\n if (trPr) {\n Object.assign(opts, parseTableRowPropertiesEl(trPr));\n }\n\n // w:tblPrEx (CT_TblPrEx) — per-row table-property exceptions\n const tblPrEx = findChild(el, \"w:tblPrEx\");\n if (tblPrEx) {\n const exceptions = parseTablePropertyExceptions(tblPrEx);\n if (Object.keys(exceptions).length > 0) opts.propertyExceptions = exceptions;\n }\n\n // rsid attributes on w:tr element\n for (const [attrName, optKey] of [\n [\"w:rsidRPr\", \"runPropertiesRsid\"],\n [\"w:rsidR\", \"rsid\"],\n [\"w:rsidDel\", \"deletionRsid\"],\n [\"w:rsidTr\", \"tableRowRsid\"],\n ] as const) {\n const val = attr(el, attrName);\n if (val) opts[optKey] = val;\n }\n\n const childCells: (\n | TableCellOptions\n | { sdt: SdtCellOptions }\n | { customXml: CustomXmlCellOptions }\n )[] = [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tc\") {\n childCells.push(parseTableCellEl(child, ctx));\n } else if (child.name === \"w:sdt\") {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtCells: TableCellOptions[] = [];\n if (sdtContent) {\n for (const sub of sdtContent.elements ?? []) {\n if (sub.name === \"w:tc\") sdtCells.push(parseTableCellEl(sub, ctx));\n }\n }\n const sdt: SdtCellOptions = {\n properties,\n };\n if (sdtCells.length > 0) sdt.cells = sdtCells;\n if (endProperties) sdt.endProperties = endProperties;\n childCells.push({ sdt });\n } else if (child.name === \"w:customXml\") {\n const element = attr(child, \"w:element\") ?? \"\";\n const cx: CustomXmlCellOptions = { element };\n const cxUri = attr(child, \"w:uri\");\n if (cxUri) cx.uri = cxUri;\n const xmlPr = findChild(child, \"w:customXmlPr\");\n if (xmlPr) {\n const parsed = parseCustomXmlProperties(xmlPr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined)\n cx.customXmlPr = parsed;\n }\n const cxCells: TableCellOptions[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:tc\") cxCells.push(parseTableCellEl(sub, ctx));\n }\n if (cxCells.length > 0) cx.children = cxCells;\n childCells.push({ customXml: cx });\n }\n }\n\n opts.cells = childCells;\n return opts as TableRowOptions;\n}\n\nfunction parseTableEl(el: Element, ctx: DocxReadContext): TableOptions {\n const opts: Partial<TableOptions> = {};\n\n const tblPr = findChild(el, \"w:tblPr\");\n if (tblPr) {\n const tblPrParsed = parseTablePropertiesEl(tblPr);\n Object.assign(opts, tblPrParsed);\n // TableOptions exposes w:tblCellMar as `margins`; TablePropertiesOptions\n // uses `cellMargin`. Map back so round-trip keeps the public field name.\n if (tblPrParsed.cellMargin !== undefined) opts.margins = tblPrParsed.cellMargin;\n }\n\n const grid = parseColumnWidthsEl(el);\n if (grid.widths.length > 0) {\n opts.columnWidths = grid.widths as NonNullable<TableOptions[\"columnWidths\"]>;\n }\n if (grid.revision) {\n opts.columnWidthsRevision = grid.revision;\n }\n\n const rows: (TableRowOptions | { sdt: SdtRowOptions } | { customXml: CustomXmlRowOptions })[] =\n [];\n for (const child of el.elements ?? []) {\n if (child.name === \"w:tr\") {\n rows.push(parseTableRowEl(child, ctx));\n } else if (child.name === \"w:sdt\") {\n const sdtPr = findChild(child, \"w:sdtPr\");\n const properties = sdtPr ? parseSdtProperties(sdtPr) : {};\n const sdtEndPr = findChild(child, \"w:sdtEndPr\");\n const endProperties = sdtEndPr ? parseRunProperties(sdtEndPr) : undefined;\n const sdtContent = findChild(child, \"w:sdtContent\");\n const sdtRows: TableRowOptions[] = [];\n if (sdtContent) {\n for (const sub of sdtContent.elements ?? []) {\n if (sub.name === \"w:tr\") sdtRows.push(parseTableRowEl(sub, ctx));\n }\n }\n const sdt: SdtRowOptions = {\n properties,\n };\n if (sdtRows.length > 0) sdt.rows = sdtRows;\n if (endProperties) sdt.endProperties = endProperties;\n rows.push({ sdt });\n } else if (child.name === \"w:customXml\") {\n const element = attr(child, \"w:element\") ?? \"\";\n const cx: CustomXmlRowOptions = { element };\n const cxUri = attr(child, \"w:uri\");\n if (cxUri) cx.uri = cxUri;\n const xmlPr = findChild(child, \"w:customXmlPr\");\n if (xmlPr) {\n const parsed = parseCustomXmlProperties(xmlPr);\n if (parsed.placeholder !== undefined || parsed.attributes !== undefined)\n cx.customXmlPr = parsed;\n }\n const cxRows: TableRowOptions[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:tr\") cxRows.push(parseTableRowEl(sub, ctx));\n }\n if (cxRows.length > 0) cx.children = cxRows;\n rows.push({ customXml: cx });\n }\n }\n\n opts.rows = rows;\n return opts as TableOptions;\n}\n","/**\n * Comments descriptor — produces word/comments.xml.\n *\n * Stringifies pure JSON CommentsOptions into XML without creating\n * Comment/Comments class instances.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, escapeXml } from \"@office-open/xml\";\nimport type { ParagraphOptions } from \"@parts/paragraph/paragraph\";\nimport type { CommentsOptions, CommentOptions } from \"@parts/paragraph/run/comment-run\";\n\nimport { parseParagraph } from \"../body\";\nimport type { BodyContext } from \"../context\";\nimport type { DocxReadContext } from \"../context\";\nimport { stringifyParagraphInline } from \"./inline\";\n\nconst COMMENTS_NS =\n 'xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" ' +\n 'xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ' +\n 'xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" ' +\n 'xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" ' +\n 'xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" ' +\n 'xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ' +\n 'xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" ' +\n 'xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" ' +\n 'xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ' +\n 'xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" ' +\n 'xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ' +\n 'xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ' +\n 'xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ' +\n 'xmlns:o=\"urn:schemas-microsoft-com:office:office\" ' +\n 'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n 'xmlns:v=\"urn:schemas-microsoft-com:vml\" ' +\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ' +\n 'xmlns:w10=\"urn:schemas-microsoft-com:office:word\" ' +\n 'xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" ' +\n 'xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" ' +\n 'xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" ' +\n 'xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ' +\n 'xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" ' +\n 'xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ' +\n 'xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" ' +\n 'xmlns:wne=\"http://schemas.openxmlformats.org/office/word/2006/wordml\" ' +\n 'xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ' +\n 'xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" ' +\n 'xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ' +\n 'xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ' +\n 'xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"';\n\n// ── Comment stringification ──\n\nfunction stringifyComment(opts: CommentOptions, ctx: BodyContext): string {\n const dateStr =\n typeof opts.date === \"string\" ? opts.date : (opts.date ?? new Date()).toISOString();\n // w:author is XSD-required (CT_TrackChange); default to empty string when absent.\n const attrs: string[] = [\n `w:id=\"${opts.id}\"`,\n `w:author=\"${escapeXml(opts.author ?? \"\")}\"`,\n `w:date=\"${escapeXml(dateStr)}\"`,\n ];\n if (opts.initials !== undefined) attrs.push(`w:initials=\"${escapeXml(opts.initials)}\"`);\n\n const parts: string[] = [];\n for (const child of opts.children) {\n parts.push(stringifyParagraphInline(child, ctx));\n }\n\n return `<w:comment ${attrs.join(\" \")}>${parts.join(\"\")}</w:comment>`;\n}\n\n// ── Descriptor ──\n\nexport const commentsDesc: CustomDescriptor<CommentsOptions, BodyContext> = {\n kind: \"custom\",\n\n stringify(opts, ctx) {\n const parts: string[] = [`<w:comments ${COMMENTS_NS}>`];\n\n for (const child of opts.children) {\n parts.push(stringifyComment(child, ctx));\n }\n\n parts.push(\"</w:comments>\");\n return parts.join(\"\");\n },\n\n parse(el, ctx) {\n const comments: CommentOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"w:comment\") continue;\n const id = attrNum(child, \"w:id\");\n if (id === undefined) continue;\n const comment: Partial<CommentOptions> = { id };\n const date = attr(child, \"w:date\");\n if (date) comment.date = date;\n const author = attr(child, \"w:author\");\n if (author !== undefined) comment.author = author;\n const initials = attr(child, \"w:initials\");\n if (initials !== undefined) comment.initials = initials;\n\n const children: (string | ParagraphOptions)[] = [];\n for (const sub of child.elements ?? []) {\n if (sub.name === \"w:p\") {\n children.push(parseParagraph(sub, ctx as DocxReadContext));\n }\n }\n comment.children = children;\n comments.push(comment as CommentOptions);\n }\n return { children: comments };\n },\n};\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,eAAe;;CAE1B,UAAU;;CAEV,SAAS;;CAET,OAAO;;CAEP,MAAM;AACR;;;;;;;;;;;;;;;;;ACdA,MAAa,eAAe;;CAE1B,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,WAAW;;CAEX,OAAO;AACT;;;;;;;ACmBA,SAAgB,SAAS,UAAqD;CAC5E,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,QAAQ,OAAO,aAAa,WAAW,WAAY,SAAS,SAAS;CAC3E,IAAI,SAAS,GAAG,OAAO;CACvB,MAAM,QAAQ,OAAO,aAAa,WAAW,SAAS,QAAQ,KAAA;CAC9D,MAAM,MAAM,QAAQ,kBAAkB,MAAM,OAAO;CACnD,OAAO,UAAU,IAAI,MAAM,IAAI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