office-open 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/ai/index.mjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/convert/index.d.mts.map +1 -1
- package/dist/convert/index.mjs +67 -65
- package/dist/convert/index.mjs.map +1 -1
- package/dist/schemas/index.mjs +1 -1
- package/dist/{schemas-B400scMm.mjs → schemas-LxuRToZl.mjs} +535 -533
- package/dist/{schemas-B400scMm.mjs.map → schemas-LxuRToZl.mjs.map} +1 -1
- package/package.json +8 -7
- package/schemas/docx.schema.json +188 -174
- package/schemas/pptx.schema.json +524 -486
- package/schemas/xlsx.schema.json +146 -158
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["hasCnvPr","altTextFromCnvPr"],"sources":["../../src/convert/position.ts","../../src/convert/picture.ts","../../src/convert/text.ts","../../src/convert/shape.ts","../../src/convert/connector.ts","../../src/convert/group.ts","../../src/convert/table.ts","../../src/convert/smartart.ts"],"sourcesContent":["/**\n * Cross-format position helpers shared by the picture/shape/connector/group\n * converters. Each format uses a different coordinate model; this module\n * translates between them via an absolute EMU bounding box.\n *\n * - pptx: absolute EMU coordinates as top-level x/y/w/h.\n * - docx: {@link MediaTransformation} (offset left/top + width/height).\n * - xlsx: 1-based cell anchors. Column/row sizes are heuristic (8.43-char\n * column × 15pt row), so xlsx ↔ {pptx,docx} loses precise positioning — the\n * same loss MS Office paste incurs between apps.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { MediaTransformation } from \"@office-open/docx\";\nimport type { DrawingAnchorOptions } from \"@office-open/xlsx\";\n\n/** Heuristic default column width in EMU (8.43 chars ≈ 64 px at 96 DPI). */\nexport const DEFAULT_COL_EMU = 609600;\n/** Heuristic default row height in EMU (15 pt). */\nexport const DEFAULT_ROW_EMU = 190500;\n\n/** Coerce a coordinate (EMU number or universal measure) to raw EMU. */\nexport function toEmu(value: number | UniversalMeasure | undefined, fallback = 0): number {\n return value === undefined ? fallback : convertToEmu(value);\n}\n\n/** Convert a raw EMU offset to a 1-based cell index. */\nexport function emuToCell(emus: number, cellEmu: number): number {\n return Math.floor(emus / cellEmu) + 1;\n}\n\n/** Absolute EMU bounding box (top-left + size + optional rotation/flip). */\nexport interface AbsoluteBox {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n}\n\n// ── → box ──\n\n/** Build a box from pptx top-level position fields. */\nexport function boxFromPptx(\n x: number | UniversalMeasure | undefined,\n y: number | UniversalMeasure | undefined,\n width: number | UniversalMeasure | undefined,\n height: number | UniversalMeasure | undefined,\n rotation?: number,\n flipHorizontal?: boolean,\n): AbsoluteBox {\n return {\n x: toEmu(x),\n y: toEmu(y),\n width: toEmu(width),\n height: toEmu(height),\n ...(rotation !== undefined ? { rotation } : {}),\n ...(flipHorizontal ? { flipHorizontal: true } : {}),\n };\n}\n\n/**\n * Build a box from a core spPr transform (off/ext + rotation/flip). Used for\n * group children, which position via spPr.xfrm with no cell anchor.\n */\nexport function boxFromSpPr(spPr: {\n x?: number | UniversalMeasure;\n y?: number | UniversalMeasure;\n width?: number | UniversalMeasure;\n height?: number | UniversalMeasure;\n rotation?: number;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n}): AbsoluteBox {\n return {\n x: toEmu(spPr.x),\n y: toEmu(spPr.y),\n width: toEmu(spPr.width),\n height: toEmu(spPr.height),\n ...(spPr.rotation !== undefined ? { rotation: spPr.rotation } : {}),\n ...(spPr.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(spPr.flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n/**\n * Build a box from an xlsx cell anchor. The absolute top-left comes from the\n * from-marker (col/row + offsets); the size comes from the caller (spPr.xfrm\n * extent or the to-marker, depending on the source).\n */\nexport function boxFromXlsxAnchor(\n anchor: DrawingAnchorOptions,\n width: number | UniversalMeasure | undefined,\n height: number | UniversalMeasure | undefined,\n rotation?: number,\n flipHorizontal?: boolean,\n flipVertical?: boolean,\n): AbsoluteBox {\n const x = (anchor.col - 1) * DEFAULT_COL_EMU + toEmu(anchor.colOffset);\n const y = (anchor.row - 1) * DEFAULT_ROW_EMU + toEmu(anchor.rowOffset);\n return {\n x,\n y,\n width: toEmu(width),\n height: toEmu(height),\n ...(rotation !== undefined ? { rotation } : {}),\n ...(flipHorizontal ? { flipHorizontal: true } : {}),\n ...(flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n/** Build a box from a docx MediaTransformation. */\nexport function boxFromDocx(transformation: MediaTransformation): AbsoluteBox {\n return {\n x: toEmu(transformation.offset?.left),\n y: toEmu(transformation.offset?.top),\n width: toEmu(transformation.width),\n height: toEmu(transformation.height),\n ...(transformation.rotation !== undefined ? { rotation: transformation.rotation } : {}),\n ...(transformation.flip?.horizontal ? { flipHorizontal: true } : {}),\n ...(transformation.flip?.vertical ? { flipVertical: true } : {}),\n };\n}\n\n// ── box → ──\n\n/** Pptx top-level position fields derived from a box. */\nexport interface PptxPosition {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n flipHorizontal?: boolean;\n}\n\n/** Emit pptx top-level position fields from a box. */\nexport function boxToPptx(box: AbsoluteBox): PptxPosition {\n return {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n };\n}\n\n/** xlsx position: cell anchor plus the matching spPr.xfrm offset/extent. */\nexport interface XlsxPosition {\n anchor: DrawingAnchorOptions;\n /** spPr.xfrm.off.x — the in-cell horizontal offset (= anchor colOffset). */\n xfrmX: number;\n /** spPr.xfrm.off.y — the in-cell vertical offset (= anchor rowOffset). */\n xfrmY: number;\n}\n\n/**\n * Emit an xlsx position from a box. The from-marker locates the cell, the\n * to-marker carries the size (twoCellAnchor), and the xfrm offset mirrors the\n * from-marker offset so the anchor and spPr agree.\n */\nexport function boxToXlsx(box: AbsoluteBox): XlsxPosition {\n const col = emuToCell(box.x, DEFAULT_COL_EMU);\n const row = emuToCell(box.y, DEFAULT_ROW_EMU);\n const colOffset = box.x - (col - 1) * DEFAULT_COL_EMU;\n const rowOffset = box.y - (row - 1) * DEFAULT_ROW_EMU;\n return {\n anchor: {\n col,\n row,\n colOffset,\n rowOffset,\n toCol: emuToCell(box.x + box.width, DEFAULT_COL_EMU),\n toRow: emuToCell(box.y + box.height, DEFAULT_ROW_EMU),\n },\n xfrmX: colOffset,\n xfrmY: rowOffset,\n };\n}\n\n/** Emit a docx MediaTransformation from a box. */\nexport function boxToDocx(box: AbsoluteBox): MediaTransformation {\n return {\n offset: { left: box.x, top: box.y },\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal || box.flipVertical\n ? {\n flip: {\n ...(box.flipHorizontal ? { horizontal: true } : {}),\n ...(box.flipVertical ? { vertical: true } : {}),\n },\n }\n : {}),\n };\n}\n","/**\n * Cross-format picture conversion.\n *\n * Each package's PictureOptions extends (or, for docx, is bridged onto) the\n * core BasePictureOptions: the binary payload (data/type) plus the non-visual\n * drawing properties (name/description/title/hidden) that mirror\n * a:CT_NonVisualDrawingProps. Those cNvPr fields pass straight through every\n * conversion leg via pickNonVisualDrawingProperties, so alt text survives a\n * cross-format copy instead of being dropped.\n *\n * Position mapping is heuristic where the target has no matching coordinate\n * model: pptx/docx use absolute EMU coordinates; xlsx uses 1-based cell anchors\n * with no size on the public input. EMU↔cell converts via a default cell size\n * (8.43-char column × 15pt row); size is lost on the xlsx leg. This matches MS\n * Office paste behavior between apps.\n *\n * docx is the odd one out: its PictureOptions is a format discriminated union\n * (regular raster vs. SVG-with-fallback), so it does not extend BasePictureOptions.\n * The cNvPr fields live on its structured altText field instead, and SVG falls\n * back to its raster payload when targeting pptx/xlsx (no vector support).\n *\n * @module\n */\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { BasePictureOptions, NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { PictureOptions as DocxPictureOptions } from \"@office-open/docx\";\nimport type { PictureOptions as PptxPictureOptions } from \"@office-open/pptx\";\nimport type { PictureOptions as XlsxPictureOptions } from \"@office-open/xlsx\";\n\nimport { DEFAULT_COL_EMU, DEFAULT_ROW_EMU, emuToCell, toEmu } from \"./position\";\n\n// ── base readers: each package → shared BasePictureOptions ──\n\n/** Project a pptx picture onto the shared base (data/type + cNvPr). */\nconst baseFromPptx = (p: PptxPictureOptions): BasePictureOptions => ({\n data: p.data,\n type: p.type,\n ...(p.sourceUrl !== undefined ? { sourceUrl: p.sourceUrl } : {}),\n ...pickNonVisualDrawingProperties(p),\n});\n\n/** Project an xlsx picture onto the shared base. */\nconst baseFromXlsx = (x: XlsxPictureOptions): BasePictureOptions => ({\n data: x.data,\n type: x.type,\n ...(x.sourceUrl !== undefined ? { sourceUrl: x.sourceUrl } : {}),\n ...pickNonVisualDrawingProperties(x),\n});\n\n/**\n * Project a docx picture onto the shared base. docx does not extend\n * BasePictureOptions (its PictureOptions is a format discriminated union), so\n * the cNvPr fields are read from the structured altText. SVG falls back to its\n * raster payload since pptx/xlsx have no vector picture support.\n */\nconst baseFromDocx = (d: DocxPictureOptions): BasePictureOptions => {\n const cNvPr = pickNonVisualDrawingProperties(d.altText);\n if (d.type === \"svg\") {\n return { data: d.fallback.data, type: d.fallback.type, ...cNvPr };\n }\n return {\n data: d.data,\n type: d.type,\n ...(d.sourceUrl !== undefined ? { sourceUrl: d.sourceUrl } : {}),\n ...cNvPr,\n };\n};\n\n// ── type narrowing ──\n\ntype DocxRasterType = \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\nconst DOCX_RASTER_TYPES: readonly DocxRasterType[] = [\n \"jpg\",\n \"png\",\n \"gif\",\n \"bmp\",\n \"tif\",\n \"ico\",\n \"emf\",\n \"wmf\",\n];\n\n/** Narrow an image type to docx's raster set (pptx/xlsx sources are never svg). */\nconst docxType = (type: string): DocxRasterType =>\n (DOCX_RASTER_TYPES as readonly string[]).includes(type) ? (type as DocxRasterType) : \"png\";\n\nconst PPTX_TYPES = [\"png\", \"jpg\", \"gif\", \"bmp\", \"emf\", \"wmf\"] as const;\n/** Narrow an image type to pptx's supported set, falling back to png. */\nconst pptxType = (type: string): PptxPictureOptions[\"type\"] =>\n (PPTX_TYPES as readonly string[]).includes(type) ? (type as PptxPictureOptions[\"type\"]) : \"png\";\n\n/** Narrow an image type to xlsx's png/jpg set. */\nconst xlsxType = (type: string): \"png\" | \"jpg\" =>\n type === \"jpg\" || type === \"jpeg\" ? \"jpg\" : \"png\";\n\n/**\n * Build the docx altText (wp:docPr) from the shared base. Only emitted when at\n * least one cNvPr field is authored; name defaults to \"Picture\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions without\n * importing that internal type.\n */\nconst altTextFromBase = (\n base: BasePictureOptions,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n const picked = pickNonVisualDrawingProperties(base);\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"Picture\", ...picked } };\n};\n\n// ── → docx ──\n\n/** Convert a pptx picture to a docx inline image. */\nexport function toDocxPicture(source: PptxPictureOptions): DocxPictureOptions;\n/** Convert an xlsx image to a docx inline image (size defaults to 0; xlsx carries no size). */\nexport function toDocxPicture(source: XlsxPictureOptions): DocxPictureOptions;\nexport function toDocxPicture(source: PptxPictureOptions | XlsxPictureOptions): DocxPictureOptions {\n // pptx → docx: absolute x/y → offset, width/height → transformation.\n if (\"width\" in source || \"height\" in source) {\n const p = source as PptxPictureOptions;\n const base = baseFromPptx(p);\n return {\n type: docxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n transformation: {\n width: p.width ?? 0,\n height: p.height ?? 0,\n ...(p.x !== undefined || p.y !== undefined\n ? { offset: { left: p.x ?? 0, top: p.y ?? 0 } }\n : {}),\n },\n ...altTextFromBase(base),\n };\n }\n // xlsx → docx: cell anchor → offset EMU; size unknown.\n const x = source as XlsxPictureOptions;\n const base = baseFromXlsx(x);\n return {\n type: docxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n transformation: {\n width: 0,\n height: 0,\n offset: { left: (x.col - 1) * DEFAULT_COL_EMU, top: (x.row - 1) * DEFAULT_ROW_EMU },\n },\n ...altTextFromBase(base),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx image to a pptx picture. */\nexport function toPptxPicture(source: DocxPictureOptions): PptxPictureOptions;\n/** Convert an xlsx image to a pptx picture (size defaults to 0; xlsx carries no size). */\nexport function toPptxPicture(source: XlsxPictureOptions): PptxPictureOptions;\nexport function toPptxPicture(source: DocxPictureOptions | XlsxPictureOptions): PptxPictureOptions {\n // docx → pptx: transformation → absolute x/y + width/height.\n if (\"transformation\" in source) {\n const d = source as DocxPictureOptions;\n const base = baseFromDocx(d);\n const t = d.transformation;\n return {\n type: pptxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n width: t.width,\n height: t.height,\n ...(t.offset ? { x: t.offset.left, y: t.offset.top } : {}),\n ...pickNonVisualDrawingProperties(base),\n };\n }\n // xlsx → pptx: cell anchor → absolute EMU; size unknown.\n const x = source as XlsxPictureOptions;\n const base = baseFromXlsx(x);\n return {\n type: pptxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n x: (x.col - 1) * DEFAULT_COL_EMU,\n y: (x.row - 1) * DEFAULT_ROW_EMU,\n width: 0,\n height: 0,\n ...pickNonVisualDrawingProperties(base),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a docx image to an xlsx picture (position mapped to cell anchor; size lost). */\nexport function toXlsxPicture(source: DocxPictureOptions): XlsxPictureOptions;\n/** Convert a pptx picture to an xlsx picture (position mapped to cell anchor; size lost). */\nexport function toXlsxPicture(source: PptxPictureOptions): XlsxPictureOptions;\nexport function toXlsxPicture(source: DocxPictureOptions | PptxPictureOptions): XlsxPictureOptions {\n // docx → xlsx: offset EMU → cell anchor.\n if (\"transformation\" in source) {\n const d = source as DocxPictureOptions;\n const base = baseFromDocx(d);\n const left = toEmu(d.transformation.offset?.left);\n const top = toEmu(d.transformation.offset?.top);\n return {\n data: base.data,\n type: xlsxType(base.type),\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n col: emuToCell(left, DEFAULT_COL_EMU),\n row: emuToCell(top, DEFAULT_ROW_EMU),\n ...pickNonVisualDrawingProperties(base),\n };\n }\n // pptx → xlsx: absolute EMU → cell anchor.\n const p = source as PptxPictureOptions;\n const base = baseFromPptx(p);\n return {\n data: base.data,\n type: xlsxType(base.type),\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n col: emuToCell(toEmu(p.x), DEFAULT_COL_EMU),\n row: emuToCell(toEmu(p.y), DEFAULT_ROW_EMU),\n ...pickNonVisualDrawingProperties(base),\n };\n}\n","/**\n * Cross-format text adapter — DrawingML paragraph (a:p, the core text model\n * shared by pptx/xlsx) ↔ WordprocessingML paragraph (w:p, docx).\n *\n * pptx and xlsx already model text as the core `a:p` shape, so this adapter only\n * bridges docx's w:p to/from that shared model. It lives in the aggregate\n * office-open convert layer alongside the other cross-format converters\n * (picture/shape/...): cross-format code references multiple format packages,\n * and the aggregate package is the single place that already depends on all of\n * them, so converters stay dependency-cycle-free. Single-format users never need\n * cross-format conversion.\n *\n * Round-trip is lossy by design, mirroring MS Office paste between apps.\n *\n * docx → a:p drops docx-only fields with no DrawingML text equivalent:\n * paragraph: numbering, heading, borders, shading, keepNext/keepLines,\n * bidirectional, widowControl, rsid, frame, outlineLevel, ...\n * run: highlight, shading, border, kern, scale, position, effect,\n * emphasisMark, w14 effects, language.eastAsia/bidirectional, ...\n *\n * a:p → docx drops DrawingML-only fields with no WordprocessingML equivalent:\n * paragraph: defTabSize; bullet color/size/font/char/format (only the level\n * survives); text fields (a:fld) are dropped.\n * run: non-solid fill and non-sRGB color variants (gradient/pattern/blip/group\n * fill; scheme/system/HSL/scRgb/preset colors → no w:p color);\n * a:br run properties.\n *\n * Magnitude loss: a:p `baseline` is a signed percentage; docx has only\n * subscript/superscript on/off flags. Hyperlink round-trips url + tooltip only.\n *\n * Units (both APIs take plain numbers in their native unit):\n * font size points on both APIs (direct).\n * char spacing a:p spc (1/100 pt) ↔ w:p spacing (twips), ÷5 / ×5.\n * before/after a:p spcPts (1/100 pt) ↔ w:p spacing (twips), ÷5 / ×5.\n * line spacing a:p lineSpacingPercent (percent, 100 = single) ↔ w:p line +\n * lineRule \"auto\" (240 = single); a:p lineSpacingPoints (pt)\n * ↔ line + lineRule \"exact\" (×20).\n * indents/tabs a:p marL/marR/pos (EMU) ↔ w:p (twips), ÷635 / ×635.\n *\n * @module\n */\n\nimport { convertToTwip, stripColorHashPrefix } from \"@office-open/core\";\nimport type {\n FillOptions,\n ParagraphDescriptorOptions,\n TextParagraphPropertiesOptions as DrawingParagraphProperties,\n RunFont,\n TextRunOptions as DrawingRunOptions,\n TextCharacterPropertiesOptions as DrawingRunProperties,\n TextFont,\n} from \"@office-open/core\";\nimport type { ParagraphOptions, RunOptions } from \"@office-open/docx\";\n\n// ── unit factors ──\n\n/** 1 inch = 914400 EMU = 1440 twips → 1 twip = 635 EMU. */\nconst EMU_PER_TWIP = 635;\n/** 1 point = 100 hundredths = 20 twips → 1 hundredth = 0.2 twip. */\nconst TWIPS_PER_HUNDREDTH = 1 / 5;\nconst HUNDREDTHS_PER_TWIP = 5;\n/** w:p \"auto\" line: 240 = single (100%). */\nconst AUTO_LINE_SINGLE = 240;\nconst POINTS_PER_TWIP = 1 / 20;\n\nconst round = Math.round;\n\n/** Discriminant keys of ParagraphChild variants that are NOT a text run. */\nconst NON_RUN_KEYS = new Set([\n \"hyperlink\",\n \"pageBreak\",\n \"columnBreak\",\n \"commentRangeStart\",\n \"commentRangeEnd\",\n \"commentReference\",\n \"comment\",\n \"insertion\",\n \"deletion\",\n \"bookmarkStart\",\n \"bookmarkEnd\",\n \"bookmark\",\n \"wpsShape\",\n \"wpgGroup\",\n \"proofErr\",\n \"positionalTab\",\n \"permStart\",\n \"permEnd\",\n \"pageReference\",\n \"section\",\n \"symbol\",\n \"footnoteReference\",\n \"endnoteReference\",\n \"footnote\",\n \"endnote\",\n \"chart\",\n \"picture\",\n \"object\",\n \"sdt\",\n \"customXml\",\n \"pageNumber\",\n \"tableOfContents\",\n]);\n\n// ── a:p → w:p ──\n\n/**\n * Convert a DrawingML paragraph (core a:p) to a WordprocessingML paragraph (w:p).\n *\n * pptx/xlsx text is already a:p, so call this when pasting shape or cell text\n * into a docx. See module header for lossy fields.\n */\nexport function fromDrawingParagraph(drawing: ParagraphDescriptorOptions): ParagraphOptions {\n const docx: ParagraphOptions = {};\n\n const props = drawing.properties;\n if (props) {\n if (props.alignment) {\n const a = alignToDocx(props.alignment);\n if (a) docx.alignment = a;\n }\n\n const spacing = spacingToDocx(props);\n if (spacing) docx.spacing = spacing;\n\n const indent = indentToDocx(props);\n if (indent) docx.indent = indent;\n\n // Only fabricate a docx bullet when the source is actually bulleted; a bare\n // indentLevel (common in pptx placeholders) carries no bullet semantics.\n if (props.bullet && props.bullet.type !== \"none\") {\n docx.bullet = { level: props.indentLevel ?? 0 };\n }\n\n if (props.fontAlignment) {\n const t = fontAlignToDocx(props.fontAlignment);\n if (t) docx.textAlignment = t;\n }\n\n if (props.tabStops?.length) {\n const tabs = props.tabStops.map(tabToDocx);\n if (tabs.length) docx.tabStops = tabs;\n }\n }\n\n // Text shorthand takes priority when the source is a single text-only run.\n if (drawing.text !== undefined) {\n docx.text = drawing.text;\n } else if (drawing.children?.length) {\n const children = drawingToDocxChildren(drawing.children);\n if (children.length) docx.children = children;\n }\n\n return docx;\n}\n\nfunction drawingToDocxChildren(\n children: NonNullable<ParagraphDescriptorOptions[\"children\"]>,\n): NonNullable<ParagraphOptions[\"children\"]> {\n const out: NonNullable<ParagraphOptions[\"children\"]> = [];\n for (const child of children) {\n // String shorthand (core children allow bare strings) → one text run.\n if (typeof child === \"string\") {\n out.push({ text: child });\n continue;\n }\n // Soft break (a:br) → a run carrying w:br (count collapses to 1).\n if (typeof child === \"object\" && child !== null && \"break\" in child) {\n out.push({ break: 1 });\n continue;\n }\n // Text field (a:fld) — no w:p equivalent; dropped.\n if (typeof child === \"object\" && child !== null && \"type\" in child) {\n continue;\n }\n const run = child as DrawingRunOptions;\n // Run with an external hyperlink becomes a w:hyperlink child wrapping the\n // (de-hyperlinked) run so its run formatting survives.\n if (run.hyperlink?.url) {\n const { hyperlink, ...rest } = run;\n out.push({\n hyperlink: {\n url: hyperlink.url,\n ...(hyperlink.tooltip ? { tooltip: hyperlink.tooltip } : {}),\n children: [drawingRunToDocx(rest)],\n },\n });\n continue;\n }\n out.push(drawingRunToDocx(run));\n }\n return out;\n}\n\nfunction drawingRunToDocx(run: DrawingRunOptions): RunOptions {\n return {\n ...drawingRunPropertiesToDocx(run),\n ...(run.text !== undefined ? { text: run.text } : {}),\n };\n}\n\nfunction drawingRunPropertiesToDocx(run: DrawingRunProperties): Partial<RunOptions> {\n const out: Partial<RunOptions> = {};\n if (run.size !== undefined) out.size = run.size;\n if (run.bold !== undefined) out.bold = run.bold;\n if (run.italic !== undefined) out.italic = run.italic;\n if (run.underline && run.underline !== \"none\") out.underline = { type: run.underline };\n if (run.strike === \"singleStrike\") out.strike = true;\n else if (run.strike === \"doubleStrike\") out.doubleStrike = true;\n if (run.baseline !== undefined && run.baseline !== 0) {\n out.verticalAlign = run.baseline > 0 ? \"superscript\" : \"subscript\";\n }\n if (run.spacing !== undefined) out.characterSpacing = round(run.spacing * TWIPS_PER_HUNDREDTH);\n if (run.capitalization === \"all\") out.allCaps = true;\n else if (run.capitalization === \"small\") out.smallCaps = true;\n if (run.shadow) out.shadow = true;\n if (run.outline) out.outline = true;\n if (run.rightToLeft !== undefined) out.rightToLeft = run.rightToLeft;\n if (run.font !== undefined) out.font = drawingFontToDocx(run.font);\n if (run.fill !== undefined) {\n const hex = solidFillToHex(run.fill);\n if (hex) out.color = hex;\n }\n if (run.lang !== undefined) out.language = { value: run.lang };\n return out;\n}\n\n// ── w:p → a:p ──\n\n/**\n * Convert a WordprocessingML paragraph (w:p) to a DrawingML paragraph (core a:p).\n *\n * Use this when pasting docx text (body or textbox) into a pptx/xlsx shape.\n * See module header for lossy fields.\n */\nexport function toDrawingParagraph(docx: ParagraphOptions): ParagraphDescriptorOptions {\n const drawing: ParagraphDescriptorOptions = {};\n\n const props = paragraphPropertiesToDrawing(docx);\n if (props) drawing.properties = props;\n\n // Prefer structured children over the text shorthand when both exist.\n if (docx.children?.length) {\n const children = docxToDrawingChildren(docx.children);\n if (children.length) drawing.children = children;\n } else if (docx.text !== undefined) {\n drawing.text = docx.text;\n }\n\n return drawing;\n}\n\nfunction docxToDrawingChildren(\n children: NonNullable<ParagraphOptions[\"children\"]>,\n): NonNullable<ParagraphDescriptorOptions[\"children\"]> {\n const out: NonNullable<ParagraphDescriptorOptions[\"children\"]> = [];\n for (const child of children) {\n if (typeof child === \"string\") {\n out.push({ text: child });\n continue;\n }\n if (typeof child !== \"object\" || child === null) continue;\n\n // External hyperlink child → flatten: each inner run inherits the link.\n if (\"hyperlink\" in child) {\n const hl = child.hyperlink;\n const url = hl.url;\n if (url === undefined) continue; // anchor-only/internal link — no a:p equivalent\n const link = { url, ...(hl.tooltip ? { tooltip: hl.tooltip } : {}) };\n const subs =\n hl.children && hl.children.length\n ? hl.children\n : child.text !== undefined\n ? [child.text]\n : [];\n for (const sub of subs) {\n if (typeof sub !== \"string\" && !isRunChild(sub)) continue;\n const run: DrawingRunOptions =\n typeof sub === \"string\" ? { text: sub } : docxRunToDrawing(sub);\n out.push({ ...run, hyperlink: link });\n }\n continue;\n }\n\n if (!isRunChild(child)) continue; // docx-only child (pageBreak, bookmark, …) dropped\n const run = child as RunOptions;\n if (run.text !== undefined) out.push(docxRunToDrawing(run));\n // A run carrying w:br becomes a soft break (count collapses to one).\n if (run.break) out.push({ break: true });\n }\n return out;\n}\n\nfunction docxRunToDrawing(run: RunOptions): DrawingRunOptions {\n const out: DrawingRunOptions = docxRunPropertiesToDrawing(run);\n if (run.text !== undefined) out.text = run.text;\n return out;\n}\n\nfunction docxRunPropertiesToDrawing(run: RunOptions): DrawingRunProperties {\n const out: DrawingRunProperties = {};\n if (run.size !== undefined) out.size = run.size;\n if (run.bold !== undefined) out.bold = run.bold;\n if (run.italic !== undefined) out.italic = run.italic;\n if (run.underline?.type) {\n // a:p models only single/double; other Word underline styles collapse to single.\n out.underline = run.underline.type === \"double\" ? \"double\" : \"single\";\n }\n if (run.doubleStrike) out.strike = \"doubleStrike\";\n else if (run.strike) out.strike = \"singleStrike\";\n if (run.verticalAlign === \"superscript\") out.baseline = 30000;\n else if (run.verticalAlign === \"subscript\") out.baseline = -25000;\n if (run.characterSpacing !== undefined) {\n out.spacing = round(convertToTwip(run.characterSpacing) * HUNDREDTHS_PER_TWIP);\n }\n if (run.allCaps) out.capitalization = \"all\";\n else if (run.smallCaps) out.capitalization = \"small\";\n if (run.shadow) out.shadow = true;\n if (run.outline) out.outline = true;\n if (run.rightToLeft !== undefined) out.rightToLeft = run.rightToLeft;\n if (run.font !== undefined) {\n const typeface = fontToString(run.font);\n if (typeface) out.font = typeface;\n }\n if (run.color !== undefined) {\n const hex = colorToHex(run.color);\n if (hex) out.fill = hex;\n }\n if (run.language?.value) out.lang = run.language.value;\n return out;\n}\n\n// ── paragraph property helpers ──\n\nfunction paragraphPropertiesToDrawing(\n docx: ParagraphOptions,\n): DrawingParagraphProperties | undefined {\n const out: DrawingParagraphProperties = {};\n if (docx.alignment) {\n const a = alignToDrawing(docx.alignment);\n if (a) out.alignment = a;\n }\n if (docx.spacing) {\n const sp = docx.spacing;\n if (sp.before !== undefined)\n out.spaceBefore = round(convertToTwip(sp.before) * HUNDREDTHS_PER_TWIP);\n if (sp.after !== undefined)\n out.spaceAfter = round(convertToTwip(sp.after) * HUNDREDTHS_PER_TWIP);\n if (sp.line !== undefined) {\n const twips = convertToTwip(sp.line);\n if (sp.lineRule === \"auto\") out.lineSpacingPercent = round((twips / AUTO_LINE_SINGLE) * 100);\n else out.lineSpacingPoints = round(twips * POINTS_PER_TWIP);\n }\n }\n if (docx.indent) {\n const start = docx.indent.start ?? docx.indent.left;\n const end = docx.indent.end ?? docx.indent.right;\n if (start !== undefined) out.marginIndent = round(convertToTwip(start) * EMU_PER_TWIP);\n if (end !== undefined) out.marginRight = round(convertToTwip(end) * EMU_PER_TWIP);\n }\n if (docx.bullet) {\n out.indentLevel = docx.bullet.level;\n out.bullet = { type: \"char\", char: \"•\" };\n }\n if (docx.textAlignment) {\n const f = fontAlignToDrawing(docx.textAlignment);\n if (f) out.fontAlignment = f;\n }\n if (docx.tabStops?.length) {\n const tabs = docx.tabStops\n .map(tabToDrawing)\n .filter((t): t is NonNullable<typeof t> => t !== undefined);\n if (tabs.length) out.tabStops = tabs;\n }\n return Object.keys(out).length ? out : undefined;\n}\n\nfunction spacingToDocx(\n props: DrawingParagraphProperties,\n): NonNullable<ParagraphOptions[\"spacing\"]> | undefined {\n const sp: NonNullable<ParagraphOptions[\"spacing\"]> = {};\n if (props.spaceBefore !== undefined) sp.before = round(props.spaceBefore * TWIPS_PER_HUNDREDTH);\n if (props.spaceAfter !== undefined) sp.after = round(props.spaceAfter * TWIPS_PER_HUNDREDTH);\n // Percent line spacing (100 = single) takes precedence over the points form.\n if (props.lineSpacingPercent !== undefined) {\n sp.line = round((props.lineSpacingPercent / 100) * AUTO_LINE_SINGLE);\n sp.lineRule = \"auto\";\n } else if (props.lineSpacingPoints !== undefined) {\n sp.line = round(props.lineSpacingPoints / POINTS_PER_TWIP);\n sp.lineRule = \"exact\";\n }\n return Object.keys(sp).length ? sp : undefined;\n}\n\nfunction indentToDocx(\n props: DrawingParagraphProperties,\n): NonNullable<ParagraphOptions[\"indent\"]> | undefined {\n const ind: NonNullable<ParagraphOptions[\"indent\"]> = {};\n if (props.marginIndent !== undefined) ind.start = round(props.marginIndent / EMU_PER_TWIP);\n if (props.marginRight !== undefined) ind.end = round(props.marginRight / EMU_PER_TWIP);\n return Object.keys(ind).length ? ind : undefined;\n}\n\nfunction tabToDocx(\n tab: NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number],\n): NonNullable<ParagraphOptions[\"tabStops\"]>[number] {\n return {\n type: tabAlignToDocx(tab.alignment),\n position: tab.position !== undefined ? round(tab.position / EMU_PER_TWIP) : 0,\n };\n}\n\nfunction tabToDrawing(\n tab: NonNullable<ParagraphOptions[\"tabStops\"]>[number],\n): NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number] | undefined {\n const alignment = tabAlignToDrawing(tab.type);\n if (!alignment) return undefined;\n const out: NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number] = { alignment };\n if (typeof tab.position === \"number\") out.position = round(tab.position * EMU_PER_TWIP);\n return out;\n}\n\n// ── enum / value mappers ──\n\nfunction alignToDocx(a: DrawingParagraphProperties[\"alignment\"]): ParagraphOptions[\"alignment\"] {\n switch (a) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"justify\":\n return \"both\";\n default:\n return undefined;\n }\n}\n\nfunction alignToDrawing(a: ParagraphOptions[\"alignment\"]): DrawingParagraphProperties[\"alignment\"] {\n switch (a) {\n case \"left\":\n case \"start\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n case \"end\":\n return \"right\";\n case \"both\":\n return \"justify\";\n default:\n return undefined;\n }\n}\n\nfunction fontAlignToDocx(\n f: DrawingParagraphProperties[\"fontAlignment\"],\n): ParagraphOptions[\"textAlignment\"] {\n switch (f) {\n case \"top\":\n return \"top\";\n case \"center\":\n return \"center\";\n case \"bottom\":\n return \"bottom\";\n case \"base\":\n return \"baseline\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\nfunction fontAlignToDrawing(\n t: ParagraphOptions[\"textAlignment\"],\n): DrawingParagraphProperties[\"fontAlignment\"] {\n switch (t) {\n case \"top\":\n return \"top\";\n case \"center\":\n return \"center\";\n case \"bottom\":\n return \"bottom\";\n case \"baseline\":\n return \"base\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\ntype DrawingTabAlignment = NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number][\"alignment\"];\ntype DocxTabType = NonNullable<ParagraphOptions[\"tabStops\"]>[number][\"type\"];\n\nfunction tabAlignToDocx(a: DrawingTabAlignment): DocxTabType {\n switch (a) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"decimal\":\n return \"decimal\";\n default:\n return \"left\";\n }\n}\n\nfunction tabAlignToDrawing(t: DocxTabType): DrawingTabAlignment {\n switch (t) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"decimal\":\n return \"decimal\";\n default:\n return undefined;\n }\n}\n\n/** 6- or 8-digit sRGB hex; excludes scheme/system/preset color-name values. */\nconst SRGB_HEX = /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/;\n\n/**\n * Extract an sRGB hex string from a solid fill; undefined for non-solid fills\n * and for non-RGB color variants (scheme/system/HSL/scRgb/preset) that have no\n * w:p color equivalent.\n */\nfunction solidFillToHex(fill: FillOptions): string | undefined {\n if (typeof fill === \"string\") return stripColorHashPrefix(fill);\n if (fill.type === \"solid\") {\n const c = fill.color;\n if (typeof c === \"string\") return stripColorHashPrefix(c);\n if (\"value\" in c && typeof c.value === \"string\" && SRGB_HEX.test(c.value)) return c.value;\n }\n return undefined;\n}\n\nfunction colorToHex(color: NonNullable<RunOptions[\"color\"]>): string | undefined {\n return typeof color === \"string\" ? stripColorHashPrefix(color) : color.val;\n}\n\nfunction fontToString(font: NonNullable<RunOptions[\"font\"]>): string | undefined {\n if (typeof font === \"string\") return font;\n if (\"name\" in font) return font.name; // RunFontReference\n return font.ascii ?? font.hAnsi ?? font.eastAsia ?? font.complexScript; // FontProperties\n}\n\n/** Map a DrawingML RunFont to a docx run font: latin→ascii+hAnsi, eastAsia→eastAsia, complexScript→complexScript. symbol has no docx equivalent and is dropped. */\nfunction drawingFontToDocx(font: RunFont): NonNullable<RunOptions[\"font\"]> {\n if (typeof font === \"string\") return font;\n const typeface = (tf: TextFont | undefined): string | undefined =>\n tf === undefined ? undefined : typeof tf === \"string\" ? tf : tf.typeface;\n const latin = typeface(font.latin);\n const ea = typeface(font.eastAsia);\n const cs = typeface(font.complexScript);\n return {\n ...(latin ? { ascii: latin, hAnsi: latin } : {}),\n ...(ea ? { eastAsia: ea } : {}),\n ...(cs ? { complexScript: cs } : {}),\n };\n}\n\nfunction isRunChild(child: unknown): child is RunOptions {\n if (typeof child !== \"object\" || child === null) return false;\n for (const key of Object.keys(child)) {\n if (NON_RUN_KEYS.has(key)) return false;\n }\n return true;\n}\n","/**\n * Cross-format shape conversion.\n *\n * Shape options convert between docx (wps), pptx (p:sp), and xlsx (xdr:sp).\n * The shape body — geometry/fill/outline/effects/3D — is already core\n * DrawingML in all three packages, so it round-trips near-losslessly. The\n * lossy legs are positioning (pptx/docx absolute EMU ↔ xlsx heuristic cell\n * anchors — see ./position) and text (docx w:p ↔ DrawingML a:p — see ./text).\n *\n * docx shapes carry text as w:p paragraphs; pptx/xlsx carry it as a core\n * TextBody (a:p). bodyProperties (a:bodyPr) round-trips verbatim. Geometry\n * adapts to docx's stricter API (presetGeometry rejects the bare-string\n * shorthand pptx/xlsx accept).\n *\n * @module\n */\n\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type {\n FillOptions,\n OutlineOptions,\n EffectListOptions,\n EffectDagOptions,\n Scene3DOptions,\n Shape3DOptions,\n PresetGeometryOptions,\n ShapeType,\n ParagraphDescriptorOptions,\n TextBodyOptions,\n ShapePropertiesOptions,\n} from \"@office-open/core/drawing\";\nimport type {\n ShapeOptions as DocxShapeRunOptions,\n ShapeCoreOptions,\n MediaTransformation,\n ParagraphOptions as DocxParagraph,\n ShapeTextBoxChild,\n} from \"@office-open/docx\";\nimport type { ShapeOptions as PptxShapeOptions } from \"@office-open/pptx\";\nimport type { ShapeOptions as XlsxShapeOptions } from \"@office-open/xlsx\";\n\nimport {\n boxFromPptx,\n boxFromXlsxAnchor,\n boxFromDocx,\n boxToPptx,\n boxToXlsx,\n boxToDocx,\n} from \"./position\";\nimport { fromDrawingParagraph, toDrawingParagraph } from \"./text\";\n\n/** docx shape input = ShapeOptions (core fields + transformation). */\nexport type DocxShapeOptions = DocxShapeRunOptions;\n\n/** The five-plus shape-content fields shared verbatim across all three packages. */\nexport interface ShapeContent {\n /** pptx adds null (a source spPr with no fill child); pickContent drops it. */\n fill?: FillOptions | null;\n outline?: OutlineOptions;\n effects?: EffectListOptions;\n effectDag?: EffectDagOptions;\n scene3d?: Scene3DOptions;\n shape3d?: Shape3DOptions;\n}\n\n/** pickContent's result: the shared fields with pptx's null fill filtered out. */\ntype PickedContent = Omit<ShapeContent, \"fill\"> & { fill?: FillOptions };\n\n/** Copy the shared shape-content fields that are present on the source. */\nexport function pickContent<T extends ShapeContent>(source: T): PickedContent {\n const out: PickedContent = {};\n // pptx carries fill: null for a source spPr with no fill child; the target\n // packages express the same \"emit no fill\" as an absent field, so null maps\n // to skipped rather than copied.\n if (source.fill != null) out.fill = source.fill;\n if (source.outline !== undefined) out.outline = source.outline;\n if (source.effects !== undefined) out.effects = source.effects;\n if (source.effectDag !== undefined) out.effectDag = source.effectDag;\n if (source.scene3d !== undefined) out.scene3d = source.scene3d;\n if (source.shape3d !== undefined) out.shape3d = source.shape3d;\n return out;\n}\n\n/** pptx/xlsx geometry shorthand (ShapeType | PresetGeometryOptions) → docx preset. */\nexport function toPresetGeometry(\n g: ShapeType | PresetGeometryOptions | undefined,\n): PresetGeometryOptions | undefined {\n if (g === undefined) return undefined;\n return typeof g === \"string\" ? { preset: g } : g;\n}\n\n// ── text bridge ──\n\n/** DrawingML text body (a:p) → docx w:p children. */\nexport function textBodyToDocxChildren(textBody: TextBodyOptions): DocxParagraph[] | string[] {\n const paragraphs = textBody.paragraphs ?? (textBody.text !== undefined ? [textBody.text] : []);\n const out: (DocxParagraph | string)[] = [];\n for (const p of paragraphs) {\n if (typeof p === \"string\") out.push(p);\n else out.push(fromDrawingParagraph(p));\n }\n return out as DocxParagraph[] | string[];\n}\n\n/** docx w:p children + bodyProperties → DrawingML text body (a:p), or undefined when empty. */\nexport function docxToTextBody(\n children: ShapeTextBoxChild[] | undefined,\n bodyProperties: TextBodyOptions[\"bodyProperties\"],\n): TextBodyOptions | undefined {\n const paragraphs: (ParagraphDescriptorOptions | string)[] = [];\n for (const child of children ?? []) {\n if (typeof child === \"string\") {\n paragraphs.push(child);\n } else if (\"paragraph\" in child) {\n paragraphs.push(\n typeof child.paragraph === \"string\" ? child.paragraph : toDrawingParagraph(child.paragraph),\n );\n } else if (\n !(\n \"table\" in child ||\n \"toc\" in child ||\n \"textbox\" in child ||\n \"sdt\" in child ||\n \"altChunk\" in child ||\n \"subDoc\" in child ||\n \"customXml\" in child ||\n \"bookmarkStart\" in child ||\n \"bookmarkEnd\" in child ||\n \"rawXml\" in child\n )\n ) {\n paragraphs.push(toDrawingParagraph(child));\n }\n }\n if (paragraphs.length === 0 && bodyProperties === undefined) return undefined;\n const out: TextBodyOptions = {};\n if (paragraphs.length > 0) out.paragraphs = paragraphs;\n if (bodyProperties !== undefined) out.bodyProperties = bodyProperties;\n return out;\n}\n\n// ── → docx ──\n\n/** docx shape split: the wps core (data) + position (transformation). */\nexport interface DocxShapeParts {\n data: ShapeCoreOptions;\n transformation: MediaTransformation;\n}\n\n/**\n * Build docx nonVisualProperties from a source's cNvPr — all authored fields,\n * not just name. name defaults to \"Shape\" (docx requires it).\n */\nconst docxNonVisual = (\n source: NonVisualDrawingPropertiesOptions,\n): { nonVisualProperties: NonVisualDrawingPropertiesOptions } => {\n const picked = pickNonVisualDrawingProperties(source);\n return { nonVisualProperties: { name: picked.name ?? \"Shape\", ...picked } };\n};\n\n/** True when a source carries at least one authored cNvPr field. */\nconst hasCnvPr = (source: NonVisualDrawingPropertiesOptions): boolean => {\n const picked = pickNonVisualDrawingProperties(source);\n return (\n picked.name !== undefined ||\n picked.description !== undefined ||\n picked.title !== undefined ||\n picked.hidden !== undefined\n );\n};\n\n/**\n * Build the docx wps core + position from a pptx or xlsx shape. Group\n * conversion reuses this to embed shapes as wpg children (the child carries a\n * full MediaDataTransformation; the caller runs it through createTransformation).\n */\nexport function toDocxShapeParts(source: PptxShapeOptions | XlsxShapeOptions): DocxShapeParts {\n if (\"spPr\" in source) {\n // xlsx → docx\n const spPr = source.spPr;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const preset = toPresetGeometry(spPr.geometry);\n return {\n data: {\n children: source.textBody ? textBodyToDocxChildren(source.textBody) : [],\n ...pickContent(spPr),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...(preset !== undefined ? { presetGeometry: preset } : {}),\n ...(hasCnvPr(source) ? docxNonVisual(source) : {}),\n },\n transformation: boxToDocx(box),\n };\n }\n // pptx → docx\n const box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const preset = toPresetGeometry(source.geometry);\n return {\n data: {\n children: source.textBody ? textBodyToDocxChildren(source.textBody) : [],\n ...pickContent(source),\n ...(source.customGeometry !== undefined ? { customGeometry: source.customGeometry } : {}),\n ...(preset !== undefined ? { presetGeometry: preset } : {}),\n ...(hasCnvPr(source) ? docxNonVisual(source) : {}),\n },\n transformation: boxToDocx(box),\n };\n}\n\n/** Convert a pptx shape to a docx wps shape. */\nexport function toDocxShape(source: PptxShapeOptions): DocxShapeOptions;\n/** Convert an xlsx shape to a docx wps shape. */\nexport function toDocxShape(source: XlsxShapeOptions): DocxShapeOptions;\nexport function toDocxShape(source: PptxShapeOptions | XlsxShapeOptions): DocxShapeOptions {\n const { data, transformation } = toDocxShapeParts(source);\n return { ...data, transformation };\n}\n\n// ── → pptx ──\n\n/** Convert a docx wps shape to a pptx shape. */\nexport function toPptxShape(source: DocxShapeOptions): PptxShapeOptions;\n/** Convert an xlsx shape to a pptx shape. */\nexport function toPptxShape(source: XlsxShapeOptions): PptxShapeOptions;\nexport function toPptxShape(source: DocxShapeOptions | XlsxShapeOptions): PptxShapeOptions {\n if (\"spPr\" in source) {\n // xlsx → pptx\n const spPr = source.spPr;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const result: PptxShapeOptions = {\n ...boxToPptx(box),\n ...pickContent(spPr),\n ...(spPr.geometry !== undefined ? { geometry: spPr.geometry } : {}),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...(source.textBody ? { textBody: source.textBody } : {}),\n ...pickNonVisualDrawingProperties(source),\n };\n return result;\n }\n // docx → pptx\n const box = boxFromDocx(source.transformation);\n const textBody = docxToTextBody(source.children, source.bodyProperties);\n const result: PptxShapeOptions = {\n ...boxToPptx(box),\n ...pickContent(source),\n ...(source.presetGeometry !== undefined\n ? { geometry: source.presetGeometry }\n : source.customGeometry !== undefined\n ? { customGeometry: source.customGeometry }\n : {}),\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(source.nonVisualProperties),\n };\n return result;\n}\n\n// ── → xlsx ──\n\n/** Convert a docx wps shape to an xlsx shape. */\nexport function toXlsxShape(source: DocxShapeOptions): XlsxShapeOptions;\n/** Convert a pptx shape to an xlsx shape. */\nexport function toXlsxShape(source: PptxShapeOptions): XlsxShapeOptions;\nexport function toXlsxShape(source: DocxShapeOptions | PptxShapeOptions): XlsxShapeOptions {\n if (\"transformation\" in source) {\n // docx → xlsx\n const box = boxFromDocx(source.transformation);\n const pos = boxToXlsx(box);\n const textBody = docxToTextBody(source.children, source.bodyProperties);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...pickContent(source),\n ...(source.presetGeometry !== undefined\n ? { geometry: source.presetGeometry }\n : source.customGeometry !== undefined\n ? { customGeometry: source.customGeometry }\n : {}),\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n spPr,\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(source.nonVisualProperties),\n };\n }\n // pptx → xlsx\n const box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const pos = boxToXlsx(box);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...pickContent(source),\n ...(source.geometry !== undefined ? { geometry: source.geometry } : {}),\n ...(source.customGeometry !== undefined ? { customGeometry: source.customGeometry } : {}),\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n };\n return {\n ...pos.anchor,\n spPr,\n ...(source.textBody ? { textBody: source.textBody } : {}),\n ...pickNonVisualDrawingProperties(source),\n };\n}\n","/**\n * Cross-format connector conversion.\n *\n * Connectors convert between pptx (p:cxnSp) and xlsx (xdr:cxnSp), which both\n * model a connector as a line geometry (spPr) plus optional endpoint glue\n * (startConnection/endConnection), locks, and the shared cNvPr. The base\n * fields (cNvPr name/description/title/hidden + locking + endpoint connections)\n * pass straight through via pickConnectorBase; only positioning (pptx two\n * endpoints ↔ xlsx cell-anchor bounding box, with flip flags encoding draw\n * direction) and the line fill/outline (pptx top-level convenience ↔ xlsx\n * nested in spPr) are adapted per leg.\n *\n * docx has no standalone connector element (Word embeds connectors as wps\n * shapes flagged with a connector marker), so converting a connector to docx\n * is a no-op: the function warns and returns undefined so callers can skip it.\n *\n * @module\n */\n\nimport { pickConnectorBase, type UniversalMeasure } from \"@office-open/core\";\nimport type { ShapePropertiesOptions } from \"@office-open/core/drawing\";\nimport type { ConnectorOptions as PptxConnectorOptions } from \"@office-open/pptx\";\nimport type { ConnectorOptions as XlsxConnectorOptions } from \"@office-open/xlsx\";\n\nimport { boxFromXlsxAnchor, boxToXlsx, toEmu } from \"./position\";\nimport type { AbsoluteBox } from \"./position\";\n\n/** pptx two endpoints → absolute box; flip flags encode the draw direction. */\nexport function endpointsToBox(\n x1: number | UniversalMeasure | undefined,\n y1: number | UniversalMeasure | undefined,\n x2: number | UniversalMeasure | undefined,\n y2: number | UniversalMeasure | undefined,\n): AbsoluteBox {\n const ax1 = toEmu(x1);\n const ay1 = toEmu(y1);\n const ax2 = toEmu(x2);\n const ay2 = toEmu(y2);\n return {\n x: Math.min(ax1, ax2),\n y: Math.min(ay1, ay2),\n width: Math.abs(ax2 - ax1),\n height: Math.abs(ay2 - ay1),\n ...(ax2 < ax1 ? { flipHorizontal: true } : {}),\n ...(ay2 < ay1 ? { flipVertical: true } : {}),\n };\n}\n\n/** absolute box → pptx two endpoints (restores direction from flip flags). */\nexport function boxToEndpoints(box: AbsoluteBox): {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n} {\n return {\n x1: box.flipHorizontal ? box.x + box.width : box.x,\n x2: box.flipHorizontal ? box.x : box.x + box.width,\n y1: box.flipVertical ? box.y + box.height : box.y,\n y2: box.flipVertical ? box.y : box.y + box.height,\n };\n}\n\n// ── → docx (no-op) ──\n\n/**\n * docx has no standalone connector; warn and return undefined so callers skip\n * it. (Word embeds connectors as wps shapes; that path is not auto-derived\n * here.)\n */\nexport function toDocxConnector(_source: PptxConnectorOptions | XlsxConnectorOptions): undefined {\n console.warn(\"Connector conversion to docx is unsupported (docx has no standalone connector).\");\n return undefined;\n}\n\n// ── → pptx ──\n\n/** Convert an xlsx connector to a pptx connector. */\nexport function toPptxConnector(source: XlsxConnectorOptions): PptxConnectorOptions {\n const spPr = source.spPr;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const { x1, y1, x2, y2 } = boxToEndpoints(box);\n return {\n x1,\n y1,\n x2,\n y2,\n ...(spPr.outline !== undefined ? { outline: spPr.outline } : {}),\n ...(spPr.fill !== undefined ? { fill: spPr.fill } : {}),\n // cNvPr + locking + endpoint connections pass straight through.\n ...pickConnectorBase(source),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a pptx connector to an xlsx connector. */\nexport function toXlsxConnector(source: PptxConnectorOptions): XlsxConnectorOptions {\n const box = endpointsToBox(source.x1, source.y1, source.x2, source.y2);\n const pos = boxToXlsx(box);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n // A connector renders as a line; carry the preset so xlsx emits prstGeom=\"line\".\n geometry: \"line\",\n ...(source.outline !== undefined ? { outline: source.outline } : {}),\n ...(source.fill !== undefined ? { fill: source.fill } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n spPr,\n // cNvPr + locking + endpoint connections pass straight through.\n ...pickConnectorBase(source),\n };\n}\n","/**\n * Cross-format group conversion.\n *\n * Groups convert between pptx (p:grpSp), xlsx (xdr:grpSp), and docx (wpg). The\n * group container (bounding box + rotation/flip) round-trips near-losslessly\n * via the absolute-box model (./position); only the xlsx leg loses precise\n * positioning (heuristic cell anchors).\n *\n * The container cNvPr (name/description/title/hidden) passes straight through on\n * every leg — pptx/xlsx via pickGroupBase, docx via its altText bridge — so alt\n * text survives a cross-format copy. Child shapes/connectors carry their own\n * cNvPr through pickNonVisualDrawingProperties (all four fields, not just name).\n *\n * Children recurse through their own converters — shapes via ./shape,\n * connectors via ./connector. docx has no standalone connector and xlsx groups\n * hold only shapes/connectors, so picture/table/chart/... children are dropped\n * with a warning on the legs that cannot host them.\n *\n * @module\n */\n\nimport {\n convertPixelsToEmu,\n parseAngle,\n pickGroupBase,\n pickNonVisualDrawingProperties,\n} from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { ShapePropertiesOptions, GroupTransform2DOptions } from \"@office-open/core/drawing\";\nimport type {\n GroupOptions as DocxGroupOptions,\n GroupChildMediaData,\n MediaDataTransformation,\n ShapeCoreOptions,\n} from \"@office-open/docx\";\nimport { createTransformation } from \"@office-open/docx\";\nimport type {\n GroupOptions as PptxGroupOptions,\n SlideChild,\n ShapeOptions as PptxShapeOptions,\n ConnectorOptions as PptxConnectorOptions,\n} from \"@office-open/pptx\";\nimport type {\n GroupOptions as XlsxGroupOptions,\n GroupShapeChildOptions,\n GroupConnectorChildOptions,\n} from \"@office-open/xlsx\";\n\nimport { boxToEndpoints, endpointsToBox } from \"./connector\";\nimport {\n boxFromPptx,\n boxFromSpPr,\n boxFromXlsxAnchor,\n boxFromDocx,\n boxToPptx,\n boxToXlsx,\n boxToDocx,\n} from \"./position\";\nimport type { AbsoluteBox } from \"./position\";\nimport {\n docxToTextBody,\n pickContent,\n textBodyToDocxChildren,\n toDocxShapeParts,\n toPresetGeometry,\n} from \"./shape\";\n\n// ── container cNvPr bridge ──\n\n/**\n * Build the docx altText (wp:docPr) from the container cNvPr. Only emitted when\n * at least one cNvPr field is authored; name defaults to \"Group\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions without\n * importing that internal type.\n */\nconst altTextFromCnvPr = (\n picked: Partial<NonVisualDrawingPropertiesOptions>,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"Group\", ...picked } };\n};\n\n/**\n * Build a docx child nonVisualProperties object from a picked cNvPr. Only\n * emitted when at least one field is authored; name defaults to `fallbackName`.\n */\nconst docxNonVisualFromCnvPr = (\n picked: Partial<NonVisualDrawingPropertiesOptions>,\n fallbackName: string,\n): { nonVisualProperties: NonVisualDrawingPropertiesOptions } => {\n const name = picked.name ?? fallbackName;\n return { nonVisualProperties: { name, ...picked } };\n};\n\n/** True when a picked cNvPr carries at least one authored field. */\nconst hasCnvPr = (picked: Partial<NonVisualDrawingPropertiesOptions>): boolean =>\n picked.name !== undefined ||\n picked.description !== undefined ||\n picked.title !== undefined ||\n picked.hidden !== undefined;\n\n// ── container helpers ──\n\n/** docx child MediaDataTransformation → absolute box (reads EMUs; falls back to pixels). */\nfunction docxChildMediaToBox(t: MediaDataTransformation): AbsoluteBox {\n const x = t.offset?.emus?.x ?? convertPixelsToEmu(t.offset?.pixels.x ?? 0);\n const y = t.offset?.emus?.y ?? convertPixelsToEmu(t.offset?.pixels.y ?? 0);\n return {\n x,\n y,\n width: t.emus.x,\n height: t.emus.y,\n ...(t.rotation !== undefined ? { rotation: parseAngle(t.rotation) } : {}),\n ...(t.flip?.horizontal ? { flipHorizontal: true } : {}),\n ...(t.flip?.vertical ? { flipVertical: true } : {}),\n };\n}\n\n// ── shape-child spPr bridge ──\n\n/** pptx shape top-level → core spPr (group-child position is absolute). */\nfunction pptxShapeToSpPr(shape: PptxShapeOptions): ShapePropertiesOptions {\n return {\n x: shape.x,\n y: shape.y,\n width: shape.width,\n height: shape.height,\n ...(shape.rotation !== undefined ? { rotation: shape.rotation } : {}),\n ...(shape.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(shape.geometry !== undefined ? { geometry: shape.geometry } : {}),\n ...(shape.customGeometry !== undefined ? { customGeometry: shape.customGeometry } : {}),\n ...pickContent(shape),\n };\n}\n\n/** core spPr → pptx shape top-level fields. */\nfunction spPrToPptxShape(spPr: ShapePropertiesOptions): PptxShapeOptions {\n return {\n x: spPr.x,\n y: spPr.y,\n width: spPr.width,\n height: spPr.height,\n ...(spPr.rotation !== undefined ? { rotation: spPr.rotation } : {}),\n ...(spPr.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(spPr.flipVertical ? { flipVertical: true } : {}),\n ...(spPr.geometry !== undefined ? { geometry: spPr.geometry } : {}),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...pickContent(spPr),\n };\n}\n\n/** xlsx group child shape → docx wps core (position lives on the wpg child wrapper). */\nfunction xlsxShapeChildToDocxData(s: GroupShapeChildOptions): ShapeCoreOptions {\n const preset = toPresetGeometry(s.spPr.geometry);\n const cnvPr = pickNonVisualDrawingProperties(s);\n return {\n children: s.textBody ? textBodyToDocxChildren(s.textBody) : [],\n ...pickContent(s.spPr),\n ...(s.spPr.customGeometry !== undefined ? { customGeometry: s.spPr.customGeometry } : {}),\n ...(preset !== undefined ? { presetGeometry: preset } : {}),\n ...(hasCnvPr(cnvPr) ? docxNonVisualFromCnvPr(cnvPr, \"Shape\") : {}),\n };\n}\n\n/** docx wps child → core spPr (absolute position from the child transformation). */\nfunction docxChildToSpPr(data: ShapeCoreOptions, box: AbsoluteBox): ShapePropertiesOptions {\n const out: ShapePropertiesOptions = {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n ...pickContent(data),\n };\n if (data.presetGeometry !== undefined) out.geometry = data.presetGeometry;\n else if (data.customGeometry !== undefined) out.customGeometry = data.customGeometry;\n return out;\n}\n\n/** xlsx group connector child → pptx connector. */\nfunction xlsxConnectorChildToPptx(c: GroupConnectorChildOptions): PptxConnectorOptions {\n const { x1, y1, x2, y2 } = boxToEndpoints(boxFromSpPr(c.spPr));\n return {\n x1,\n y1,\n x2,\n y2,\n ...(c.spPr.outline !== undefined ? { outline: c.spPr.outline } : {}),\n ...(c.spPr.fill !== undefined ? { fill: c.spPr.fill } : {}),\n ...(c.locking ? { locking: c.locking } : {}),\n ...(c.startConnection ? { startConnection: c.startConnection } : {}),\n ...(c.endConnection ? { endConnection: c.endConnection } : {}),\n ...pickNonVisualDrawingProperties(c),\n };\n}\n\n// ── → docx ──\n\n/** Convert a pptx group to a docx wpg group. */\nexport function toDocxGroup(source: PptxGroupOptions): DocxGroupOptions;\n/** Convert an xlsx group to a docx wpg group. */\nexport function toDocxGroup(source: XlsxGroupOptions): DocxGroupOptions;\nexport function toDocxGroup(source: PptxGroupOptions | XlsxGroupOptions): DocxGroupOptions {\n let box: AbsoluteBox;\n let children: GroupChildMediaData[];\n if (\"grpSpPr\" in source) {\n const g = source.grpSpPr;\n box = boxFromXlsxAnchor(\n source,\n g.width,\n g.height,\n g.rotation,\n g.flipHorizontal,\n g.flipVertical,\n );\n children = xlsxGroupChildrenToDocx(source.shapes, source.connectors);\n } else {\n box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n children = pptxGroupChildrenToDocx(source.children);\n }\n // Container cNvPr → docx altText (wp:docPr).\n return { children, transformation: boxToDocx(box), ...altTextFromCnvPr(pickGroupBase(source)) };\n}\n\nfunction pptxGroupChildrenToDocx(children: SlideChild[] | undefined): GroupChildMediaData[] {\n const out: GroupChildMediaData[] = [];\n for (const child of children ?? []) {\n if (\"shape\" in child) {\n const parts = toDocxShapeParts(child.shape);\n out.push({\n type: \"wps\",\n transformation: createTransformation(parts.transformation),\n data: parts.data,\n });\n } else if (\"connector\" in child) {\n console.warn(\"Connector in group → docx is unsupported; skipped.\");\n } else {\n console.warn(`Unsupported group child → docx (${Object.keys(child)[0]}); skipped.`);\n }\n }\n return out;\n}\n\nfunction xlsxGroupChildrenToDocx(\n shapes: GroupShapeChildOptions[] | undefined,\n connectors: GroupConnectorChildOptions[] | undefined,\n): GroupChildMediaData[] {\n const out: GroupChildMediaData[] = [];\n for (const s of shapes ?? []) {\n out.push({\n type: \"wps\",\n transformation: createTransformation(boxToDocx(boxFromSpPr(s.spPr))),\n data: xlsxShapeChildToDocxData(s),\n });\n }\n if (connectors?.length) {\n console.warn(\"Connector in group → docx is unsupported; skipped.\");\n }\n return out;\n}\n\n// ── → pptx ──\n\n/** Convert a docx wpg group to a pptx group. */\nexport function toPptxGroup(source: DocxGroupOptions): PptxGroupOptions;\n/** Convert an xlsx group to a pptx group. */\nexport function toPptxGroup(source: XlsxGroupOptions): PptxGroupOptions;\nexport function toPptxGroup(source: DocxGroupOptions | XlsxGroupOptions): PptxGroupOptions {\n let box: AbsoluteBox;\n let children: SlideChild[];\n // Container cNvPr: docx bridges through altText; xlsx extends BaseGroupOptions.\n const cnvPr =\n \"transformation\" in source\n ? pickNonVisualDrawingProperties(source.altText)\n : pickGroupBase(source);\n if (\"grpSpPr\" in source) {\n const g = source.grpSpPr;\n box = boxFromXlsxAnchor(\n source,\n g.width,\n g.height,\n g.rotation,\n g.flipHorizontal,\n g.flipVertical,\n );\n children = xlsxGroupChildrenToPptx(source.shapes, source.connectors);\n } else {\n box = boxFromDocx(source.transformation);\n children = docxGroupChildrenToPptx(source.children);\n }\n return { ...boxToPptx(box), children, ...cnvPr };\n}\n\nfunction xlsxGroupChildrenToPptx(\n shapes: GroupShapeChildOptions[] | undefined,\n connectors: GroupConnectorChildOptions[] | undefined,\n): SlideChild[] {\n const out: SlideChild[] = [];\n for (const s of shapes ?? []) {\n const shape = spPrToPptxShape(s.spPr);\n if (s.textBody) shape.textBody = s.textBody;\n Object.assign(shape, pickNonVisualDrawingProperties(s));\n out.push({ shape });\n }\n for (const c of connectors ?? []) {\n out.push({ connector: xlsxConnectorChildToPptx(c) });\n }\n return out;\n}\n\nfunction docxGroupChildrenToPptx(children: GroupChildMediaData[] | undefined): SlideChild[] {\n const out: SlideChild[] = [];\n for (const child of children ?? []) {\n if (child.type === \"wps\") {\n const box = docxChildMediaToBox(child.transformation);\n const shape = spPrToPptxShape(docxChildToSpPr(child.data, box));\n const textBody = docxToTextBody(child.data.children, child.data.bodyProperties);\n if (textBody) shape.textBody = textBody;\n Object.assign(shape, pickNonVisualDrawingProperties(child.data.nonVisualProperties));\n out.push({ shape });\n } else {\n console.warn(`Unsupported docx group child → pptx (${child.type}); skipped.`);\n }\n }\n return out;\n}\n\n// ── → xlsx ──\n\n/** Convert a docx wpg group to an xlsx group. */\nexport function toXlsxGroup(source: DocxGroupOptions): XlsxGroupOptions;\n/** Convert a pptx group to an xlsx group. */\nexport function toXlsxGroup(source: PptxGroupOptions): XlsxGroupOptions;\nexport function toXlsxGroup(source: DocxGroupOptions | PptxGroupOptions): XlsxGroupOptions {\n let box: AbsoluteBox;\n let shapes: GroupShapeChildOptions[];\n let connectors: GroupConnectorChildOptions[];\n // Container cNvPr: docx bridges through altText; pptx extends BaseGroupOptions.\n const cnvPr =\n \"transformation\" in source\n ? pickNonVisualDrawingProperties(source.altText)\n : pickGroupBase(source);\n if (\"transformation\" in source) {\n box = boxFromDocx(source.transformation);\n const r = docxGroupChildrenToXlsx(source.children);\n shapes = r.shapes;\n connectors = r.connectors;\n } else {\n box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const r = pptxGroupChildrenToXlsx(source.children);\n shapes = r.shapes;\n connectors = r.connectors;\n }\n const pos = boxToXlsx(box);\n const grpSpPr: GroupTransform2DOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n grpSpPr,\n ...(shapes.length ? { shapes } : {}),\n ...(connectors.length ? { connectors } : {}),\n ...cnvPr,\n };\n}\n\nfunction pptxGroupChildrenToXlsx(children: SlideChild[] | undefined): {\n shapes: GroupShapeChildOptions[];\n connectors: GroupConnectorChildOptions[];\n} {\n const shapes: GroupShapeChildOptions[] = [];\n const connectors: GroupConnectorChildOptions[] = [];\n for (const child of children ?? []) {\n if (\"shape\" in child) {\n const s: GroupShapeChildOptions = {\n spPr: pptxShapeToSpPr(child.shape),\n ...(child.shape.textBody ? { textBody: child.shape.textBody } : {}),\n ...pickNonVisualDrawingProperties(child.shape),\n };\n shapes.push(s);\n } else if (\"connector\" in child) {\n connectors.push(pptxConnectorToXlsxChild(child.connector));\n } else {\n console.warn(`Unsupported group child → xlsx (${Object.keys(child)[0]}); skipped.`);\n }\n }\n return { shapes, connectors };\n}\n\nfunction pptxConnectorToXlsxChild(c: PptxConnectorOptions): GroupConnectorChildOptions {\n // Place the connector's endpoint box on spPr.xfrm (no anchor — group children\n // position via spPr). The shared helper encodes direction as flip flags.\n const box = endpointsToBox(c.x1, c.y1, c.x2, c.y2);\n const spPr: ShapePropertiesOptions = {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n geometry: \"line\",\n ...(c.outline !== undefined ? { outline: c.outline } : {}),\n ...(c.fill !== undefined ? { fill: c.fill } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n spPr,\n ...(c.locking ? { locking: c.locking } : {}),\n ...(c.startConnection ? { startConnection: c.startConnection } : {}),\n ...(c.endConnection ? { endConnection: c.endConnection } : {}),\n ...pickNonVisualDrawingProperties(c),\n };\n}\n\nfunction docxGroupChildrenToXlsx(children: GroupChildMediaData[] | undefined): {\n shapes: GroupShapeChildOptions[];\n connectors: GroupConnectorChildOptions[];\n} {\n const shapes: GroupShapeChildOptions[] = [];\n const connectors: GroupConnectorChildOptions[] = [];\n for (const child of children ?? []) {\n if (child.type === \"wps\") {\n const box = docxChildMediaToBox(child.transformation);\n const spPr = docxChildToSpPr(child.data, box);\n const textBody = docxToTextBody(child.data.children, child.data.bodyProperties);\n shapes.push({\n spPr,\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(child.data.nonVisualProperties),\n });\n } else {\n console.warn(`Unsupported docx group child → xlsx (${child.type}); skipped.`);\n }\n }\n return { shapes, connectors };\n}\n","/**\n * Cross-format table conversion.\n *\n * docx (w:tbl flow) and pptx (a:tbl graphic) share a structural core\n * (rows/cells/span/6-flags/columnWidths/vertical-align) defined in\n * `@office-open/core`'s BaseTableOptions; both packages extend it. The\n * structural fields pass through directly and only the per-package parts need\n * translation:\n * - cell content: docx w:p (SectionChild) ↔ pptx a:p (ParagraphDescriptor),\n * via ./text. docx cell non-paragraph children (nested table/toc/sdt/…)\n * drop (flatten not implemented).\n * - column widths: `number` is the native unit (docx twip, pptx EMU) so it is\n * converted (×635 / ÷635); UniversalMeasure strings pass through (each\n * package's descriptor resolves them).\n * - position: pptx absolute x/y; docx is flow (no position) — lost pptx→docx.\n * - styles (fill/borders/margins): w:/a: domain types differ; only solid fill\n * maps (pptx→docx), the rest is dropped (matches MS Office paste loss).\n * - row height: docx {value,rule} twip ↔ pptx number EMU.\n *\n * xlsx has no visual table object (its sml Table is a data range), so docx/pptx\n * tables restore to worksheet fragments: cell value = first-paragraph plain\n * text, mergeCells = columnSpan/rowSpan, column widths / row heights converted\n * to xlsx units (character width / points). Cell styles are dropped (dxf\n * synthesis is a follow-up). The reverse takes xlsx fragments back to a table.\n *\n * @module\n */\nimport {\n convertEmuToPoints,\n convertEmuToTwip,\n convertPointsToEmu,\n convertPointsToTwip,\n convertToEmu,\n convertToPt,\n convertToTwip,\n convertTwipToEmu,\n} from \"@office-open/core\";\nimport type { ThemeColor } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { ParagraphDescriptorOptions } from \"@office-open/core/drawing\";\nimport type {\n ParagraphOptions,\n SectionChild,\n TableOptions as DocxTableOptions,\n TableCellOptions as DocxTableCellOptions,\n TableRowOptions as DocxTableRowOptions,\n} from \"@office-open/docx\";\nimport type {\n TableOptions as PptxTableOptions,\n TableCellOptions as PptxTableCellOptions,\n TableRowOptions as PptxTableRowOptions,\n} from \"@office-open/pptx\";\nimport type {\n CellOptions as XlsxCellOptions,\n ColumnOptions,\n MergeCellOptions,\n RowOptions as XlsxRowOptions,\n} from \"@office-open/xlsx\";\nimport { columnToLetter, letterToColumn } from \"@office-open/xlsx\";\n\nimport { DEFAULT_COL_EMU } from \"./position\";\nimport { fromDrawingParagraph, toDrawingParagraph } from \"./text\";\n\n/** Heuristic EMU per character of column width (8.43 chars ≈ DEFAULT_COL_EMU). */\nconst EMU_PER_CHAR = DEFAULT_COL_EMU / 8.43;\n\n/** xlsx visual-table restoration: worksheet fragments (rows/merges/columns). */\nexport interface XlsxVisualTable {\n rows: XlsxRowOptions[];\n mergeCells?: MergeCellOptions[];\n columns?: ColumnOptions[];\n}\n\n/** Parse a merge ref (\"A1:D1\") into 0-based row/col corners. */\nfunction parseMergeRef(\n ref: string,\n): { row: number; col: number; rowEnd: number; colEnd: number } | undefined {\n const [from = \"\", to = from] = ref.split(\":\");\n const fa = from.match(/^([A-Z]+)(\\d+)$/);\n const fb = to.match(/^([A-Z]+)(\\d+)$/);\n if (!fa || !fb) return undefined;\n return {\n row: Number(fa[2]) - 1,\n col: letterToColumn(fa[1]) - 1,\n rowEnd: Number(fb[2]) - 1,\n colEnd: letterToColumn(fb[1]) - 1,\n };\n}\n\n// ── unit helpers ──\n// EMU↔twip↔points conversions live in @office-open/core; only the xlsx\n// character-width heuristic (EMU_PER_CHAR) is local to visual restoration.\n\nconst emuToCharWidth = (emu: number): number => emu / EMU_PER_CHAR;\nconst charWidthToEmu = (chars: number): number => chars * EMU_PER_CHAR;\n\n/** docx height value (twip number or UM) → EMU. */\nconst docxHeightToEmu = (v: number | UniversalMeasure): number =>\n typeof v === \"number\" ? convertTwipToEmu(v) : convertToEmu(v);\n/** pptx height value (EMU number or UM) → twip. */\nconst pptxHeightToTwip = (v: number | UniversalMeasure): number =>\n typeof v === \"number\" ? convertEmuToTwip(v) : convertToTwip(v);\n\n/** Convert numeric column widths via `convert`; UM strings pass through. */\nfunction convertColumnWidths(\n widths: (number | string)[] | undefined,\n convert: (n: number) => number,\n): (number | string)[] | undefined {\n if (!widths) return undefined;\n return widths.map((w) => (typeof w === \"number\" ? convert(w) : w));\n}\n\n// ── discriminant ──\n\n/** Structural test: an XlsxVisualTable's first cell lacks docx/pptx markers\n * (children/text/shading), or it carries xlsx-only columns/mergeCells. */\nfunction isXlsxVisual(src: unknown): src is XlsxVisualTable {\n if (typeof src !== \"object\" || src === null) return false;\n const s = src as Record<string, unknown>;\n if (Array.isArray(s.columns) || Array.isArray(s.mergeCells)) return true;\n const firstCell = (s.rows as { cells?: Array<Record<string, unknown>> }[] | undefined)?.[0]\n ?.cells?.[0];\n if (!firstCell) return false;\n return !(\"children\" in firstCell) && !(\"text\" in firstCell) && !(\"shading\" in firstCell);\n}\n\n/** Copy the 6 special-row flags (matching field names across docx/pptx). */\nfunction copyBaseTableFlags<S extends DocxTableOptions | PptxTableOptions>(\n src: S,\n): Pick<\n DocxTableOptions & PptxTableOptions,\n \"firstRow\" | \"lastRow\" | \"firstCol\" | \"lastCol\" | \"bandRow\" | \"bandCol\"\n> {\n return {\n ...(src.firstRow !== undefined ? { firstRow: src.firstRow } : {}),\n ...(src.lastRow !== undefined ? { lastRow: src.lastRow } : {}),\n ...(src.firstCol !== undefined ? { firstCol: src.firstCol } : {}),\n ...(src.lastCol !== undefined ? { lastCol: src.lastCol } : {}),\n ...(src.bandRow !== undefined ? { bandRow: src.bandRow } : {}),\n ...(src.bandCol !== undefined ? { bandCol: src.bandCol } : {}),\n };\n}\n\n// ── cell content bridges ──\n\n/** docx cell (SectionChild[], w:p) → pptx paragraphs (a:p). */\nfunction docxCellToPptxContent(\n cell: DocxTableCellOptions,\n): (ParagraphDescriptorOptions | string)[] {\n const out: (ParagraphDescriptorOptions | string)[] = [];\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") {\n out.push(child);\n } else if (\"paragraph\" in child) {\n const para: ParagraphOptions =\n typeof child.paragraph === \"string\"\n ? { children: [{ text: child.paragraph }] }\n : child.paragraph;\n out.push(toDrawingParagraph(para));\n }\n // nested table/toc/sdt/… → drop\n }\n return out;\n}\n\n/** pptx cell (a:p) → docx SectionChild[] (w:p). */\nfunction pptxCellToDocxChildren(cell: PptxTableCellOptions): SectionChild[] {\n const out: SectionChild[] = [];\n if (cell.text !== undefined) {\n out.push({ paragraph: { children: [{ text: cell.text }] } });\n }\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") {\n out.push({ paragraph: { children: [{ text: child }] } });\n } else {\n out.push({ paragraph: fromDrawingParagraph(child) });\n }\n }\n return out;\n}\n\n/** First-paragraph plain text from a docx cell. */\nfunction docxCellText(cell: DocxTableCellOptions): string | undefined {\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") return child;\n if (\"paragraph\" in child) {\n const para =\n typeof child.paragraph === \"string\"\n ? { children: [{ text: child.paragraph }] }\n : child.paragraph;\n const text = para.children\n ?.map((r) => (typeof r === \"string\" ? r : \"text\" in r ? (r.text ?? \"\") : \"\"))\n .join(\"\");\n if (text) return text;\n }\n }\n return undefined;\n}\n\n/** Plain text from a pptx cell. */\nfunction pptxCellText(cell: PptxTableCellOptions): string | undefined {\n if (cell.text !== undefined) return cell.text;\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") return child;\n const text = child.children\n ?.map((r) => (typeof r === \"string\" ? r : \"text\" in r ? (r.text ?? \"\") : \"\"))\n .join(\"\");\n if (text) return text;\n }\n return undefined;\n}\n\n/** Map a: scheme color token (ST_SchemeColorVal) → w: themeColor token\n * (ST_ThemeColor). accent1-6 pass through; bg/tx/dk/lt → background/text/\n * dark/light; hlink → hyperlink, folHlink → followedHyperlink. phClr has no\n * w: equivalent (dropped). */\nconst SCHEME_TO_THEME: Record<string, ThemeColor> = {\n bg1: \"background1\",\n tx1: \"text1\",\n bg2: \"background2\",\n tx2: \"text2\",\n dk1: \"dark1\",\n lt1: \"light1\",\n dk2: \"dark2\",\n lt2: \"light2\",\n accent1: \"accent1\",\n accent2: \"accent2\",\n accent3: \"accent3\",\n accent4: \"accent4\",\n accent5: \"accent5\",\n accent6: \"accent6\",\n hlink: \"hyperlink\",\n folHlink: \"followedHyperlink\",\n};\n\n/** pptx FillOptions (a:fill) → docx ShadingProperties (w:shd). RGB hex and\n * RgbColorOptions → `@fill`; SchemeColorOptions → `@themeColor` (token mapped);\n * hsl/system/preset/scRgb/phClr and color transforms → dropped (docx shading\n * is RGB-hex or theme-color only). */\nfunction pptxFillToDocxShading(\n fill: PptxTableCellOptions[\"fill\"],\n): DocxTableCellOptions[\"shading\"] | undefined {\n if (fill === undefined) return undefined;\n if (typeof fill === \"string\") return { fill };\n if (fill.type === \"solid\") {\n if (typeof fill.color === \"string\") return { fill: fill.color };\n if (typeof fill.color === \"object\" && \"value\" in fill.color) {\n const v = fill.color.value;\n if (typeof v === \"string\") {\n return v in SCHEME_TO_THEME ? { themeColor: SCHEME_TO_THEME[v] } : { fill: v };\n }\n }\n return undefined; // hsl/system/preset/scRgb → drop\n }\n return undefined; // gradient/pattern/blip → drop\n}\n\n/** xlsx cell value → plain text. Primitives stringify directly; Date → ISO;\n * RichTextOptions falls back to JSON (rich-text run extraction is a follow-up). */\nfunction cellValueToText(value: XlsxCellOptions[\"value\"]): string | undefined {\n if (value === null || value === undefined) return undefined;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n return JSON.stringify(value);\n}\n\n// ── → docx ──\n\n/** Convert a pptx table to a docx table. */\nexport function toDocxTable(source: PptxTableOptions): DocxTableOptions;\n/** Convert xlsx visual-table fragments back to a docx table. */\nexport function toDocxTable(source: XlsxVisualTable): DocxTableOptions;\nexport function toDocxTable(source: PptxTableOptions | XlsxVisualTable): DocxTableOptions {\n return isXlsxVisual(source) ? xlsxToDocx(source) : pptxToDocx(source);\n}\n\nfunction pptxToDocx(src: PptxTableOptions): DocxTableOptions {\n const rows: DocxTableRowOptions[] = src.rows.map((row) => ({\n ...(row.height !== undefined ? { height: { value: pptxHeightToTwip(row.height) } } : {}),\n cells: row.cells.map((cell): DocxTableCellOptions => {\n const shading = pptxFillToDocxShading(cell.fill);\n return {\n children: pptxCellToDocxChildren(cell),\n ...(cell.columnSpan !== undefined ? { columnSpan: cell.columnSpan } : {}),\n ...(cell.rowSpan !== undefined ? { rowSpan: cell.rowSpan } : {}),\n ...(cell.verticalAlign !== undefined\n ? {\n verticalAlign:\n cell.verticalAlign === \"justify\" || cell.verticalAlign === \"distribute\"\n ? \"center\"\n : cell.verticalAlign,\n }\n : {}),\n ...(shading ? { shading } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columnWidths\n ? { columnWidths: convertColumnWidths(src.columnWidths, convertEmuToTwip) as number[] }\n : {}),\n ...copyBaseTableFlags(src),\n };\n}\n\n/** Index parsed merges by anchor cell (\"row:col\") for O(1) lookup per cell. */\ntype ParsedMergeRef = NonNullable<ReturnType<typeof parseMergeRef>>;\n\nfunction mergeIndex(merges: ParsedMergeRef[]): Map<string, ParsedMergeRef> {\n const index = new Map<string, ParsedMergeRef>();\n for (const m of merges) index.set(`${m.row}:${m.col}`, m);\n return index;\n}\n\nfunction xlsxToDocx(src: XlsxVisualTable): DocxTableOptions {\n const merges = mergeIndex(\n (src.mergeCells ?? [])\n .map((m) => parseMergeRef(m.ref))\n .filter((m): m is NonNullable<typeof m> => m !== undefined),\n );\n const rows: DocxTableRowOptions[] = src.rows.map((row, ri) => ({\n ...(row.height !== undefined\n ? { height: { value: convertPointsToTwip(convertToPt(row.height)) } }\n : {}),\n cells: (row.cells ?? []).map((cell, ci): DocxTableCellOptions => {\n const merge = merges.get(`${ri}:${ci}`);\n const columnSpan = merge ? merge.colEnd - merge.col + 1 : undefined;\n const rowSpan = merge ? merge.rowEnd - merge.row + 1 : undefined;\n const text = cellValueToText(cell.value);\n return {\n children: text !== undefined ? [{ paragraph: { children: [{ text }] } }] : [],\n ...(columnSpan && columnSpan > 1 ? { columnSpan } : {}),\n ...(rowSpan && rowSpan > 1 ? { rowSpan } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columns\n ? {\n columnWidths: src.columns.map((c) => convertEmuToTwip(charWidthToEmu(c.width ?? 8.43))),\n }\n : {}),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx table to a pptx table. */\nexport function toPptxTable(source: DocxTableOptions): PptxTableOptions;\n/** Convert xlsx visual-table fragments back to a pptx table. */\nexport function toPptxTable(source: XlsxVisualTable): PptxTableOptions;\nexport function toPptxTable(source: DocxTableOptions | XlsxVisualTable): PptxTableOptions {\n return isXlsxVisual(source) ? xlsxToPptx(source) : docxToPptx(source);\n}\n\nfunction docxToPptx(src: DocxTableOptions): PptxTableOptions {\n const rows: PptxTableRowOptions[] = src.rows.map((row) => {\n if (!(\"cells\" in row)) return { cells: [] }; // sdt/customXml row → flatten\n return {\n ...(row.height ? { height: docxHeightToEmu(row.height.value) } : {}),\n cells: row.cells.map((cell): PptxTableCellOptions => {\n if (!(\"children\" in cell)) return { children: [] }; // sdt/customXml cell → flatten\n return {\n children: docxCellToPptxContent(cell),\n ...(cell.columnSpan !== undefined ? { columnSpan: cell.columnSpan } : {}),\n ...(cell.rowSpan !== undefined ? { rowSpan: cell.rowSpan } : {}),\n ...(cell.verticalAlign !== undefined ? { verticalAlign: cell.verticalAlign } : {}),\n };\n }),\n };\n });\n return {\n rows,\n ...(src.columnWidths\n ? { columnWidths: convertColumnWidths(src.columnWidths, convertTwipToEmu) as number[] }\n : {}),\n ...copyBaseTableFlags(src),\n };\n}\n\nfunction xlsxToPptx(src: XlsxVisualTable): PptxTableOptions {\n const merges = mergeIndex(\n (src.mergeCells ?? [])\n .map((m) => parseMergeRef(m.ref))\n .filter((m): m is NonNullable<typeof m> => m !== undefined),\n );\n const rows: PptxTableRowOptions[] = src.rows.map((row, ri) => ({\n ...(row.height !== undefined ? { height: convertPointsToEmu(convertToPt(row.height)) } : {}),\n cells: (row.cells ?? []).map((cell, ci): PptxTableCellOptions => {\n const merge = merges.get(`${ri}:${ci}`);\n const columnSpan = merge ? merge.colEnd - merge.col + 1 : undefined;\n const rowSpan = merge ? merge.rowEnd - merge.row + 1 : undefined;\n const text = cellValueToText(cell.value);\n return {\n ...(text !== undefined ? { text } : {}),\n ...(columnSpan && columnSpan > 1 ? { columnSpan } : {}),\n ...(rowSpan && rowSpan > 1 ? { rowSpan } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columns\n ? { columnWidths: src.columns.map((c) => Math.round(charWidthToEmu(c.width ?? 8.43))) }\n : {}),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a docx table to xlsx worksheet fragments (visual restoration). */\nexport function toXlsxTable(source: DocxTableOptions): XlsxVisualTable;\n/** Convert a pptx table to xlsx worksheet fragments (visual restoration). */\nexport function toXlsxTable(source: PptxTableOptions): XlsxVisualTable;\nexport function toXlsxTable(source: DocxTableOptions | PptxTableOptions): XlsxVisualTable {\n return isDocxTable(source) ? docxToXlsx(source) : pptxToXlsx(source);\n}\n\n/** docx vs pptx: both extend BaseTableOptions so top-level fields mostly overlap.\n * Decide by content shape — docx wraps cell content as SectionChild\n * ({ paragraph | table | toc | … }), pptx stores flat a:p paragraphs or a\n * `text` shorthand — and by domain-only keys (docx w:shd/float/style; pptx\n * a:fill/tableStyleId). `width` overlaps (docx TableWidthProperties vs pptx\n * number) so it is intentionally not used. */\nfunction isDocxTable(src: unknown): src is DocxTableOptions {\n if (typeof src !== \"object\" || src === null) return false;\n const s = src as Record<string, unknown>;\n if (\"tableStyleId\" in s) return false; // pptx-only\n if (\"style\" in s || \"float\" in s || \"visuallyRightToLeft\" in s || \"indent\" in s) return true; // docx-only\n const rows = s.rows as Array<Record<string, unknown>> | undefined;\n if (!Array.isArray(rows)) return false;\n for (const row of rows) {\n if (!(\"cells\" in row) || !Array.isArray(row.cells)) continue;\n for (const cell of row.cells as Array<Record<string, unknown>>) {\n if (\"shading\" in cell) return true; // docx w:shd\n if (\"text\" in cell || \"fill\" in cell) return false; // pptx a:fill / shorthand\n const child = (cell.children as Array<Record<string, unknown>> | undefined)?.[0];\n if (child && typeof child === \"object\") {\n return (\n \"paragraph\" in child ||\n \"table\" in child ||\n \"toc\" in child ||\n \"sdt\" in child ||\n \"customXml\" in child ||\n \"altChunk\" in child\n );\n }\n }\n }\n return false;\n}\n\nfunction docxToXlsx(src: DocxTableOptions): XlsxVisualTable {\n const mergeCells: MergeCellOptions[] = [];\n const rows: XlsxRowOptions[] = src.rows.map((row, ri) => {\n if (!(\"cells\" in row)) return { cells: [] };\n let ci = 0;\n const cells: XlsxCellOptions[] = row.cells.map((cell): XlsxCellOptions => {\n if (!(\"children\" in cell)) {\n ci += 1;\n return {};\n }\n const span = cell.columnSpan ?? 1;\n const rspan = cell.rowSpan ?? 1;\n if (span > 1 || rspan > 1) {\n mergeCells.push({\n ref: `${columnToLetter(ci + 1)}${ri + 1}:${columnToLetter(ci + span)}${ri + rspan}`,\n });\n }\n const value = docxCellText(cell);\n ci += span;\n return value !== undefined ? { value } : {};\n });\n const xrow: XlsxRowOptions = { cells };\n if (row.height) xrow.height = convertEmuToPoints(docxHeightToEmu(row.height.value));\n return xrow;\n });\n const columns: ColumnOptions[] | undefined = src.columnWidths\n ? src.columnWidths.map((w, i) => ({\n min: i + 1,\n max: i + 1,\n width: typeof w === \"number\" ? emuToCharWidth(convertTwipToEmu(w)) : undefined,\n }))\n : undefined;\n return { rows, ...(mergeCells.length ? { mergeCells } : {}), ...(columns ? { columns } : {}) };\n}\n\nfunction pptxToXlsx(src: PptxTableOptions): XlsxVisualTable {\n const mergeCells: MergeCellOptions[] = [];\n const rows: XlsxRowOptions[] = src.rows.map((row, ri) => {\n let ci = 0;\n const cells: XlsxCellOptions[] = row.cells.map((cell): XlsxCellOptions => {\n const span = cell.columnSpan ?? 1;\n const rspan = cell.rowSpan ?? 1;\n if (span > 1 || rspan > 1) {\n mergeCells.push({\n ref: `${columnToLetter(ci + 1)}${ri + 1}:${columnToLetter(ci + span)}${ri + rspan}`,\n });\n }\n const value = pptxCellText(cell);\n ci += span;\n return value !== undefined ? { value } : {};\n });\n const xrow: XlsxRowOptions = { cells };\n if (row.height !== undefined)\n xrow.height = convertEmuToPoints(\n typeof row.height === \"number\" ? row.height : convertToEmu(row.height),\n );\n return xrow;\n });\n const columns: ColumnOptions[] | undefined = src.columnWidths\n ? src.columnWidths.map((w, i) => ({\n min: i + 1,\n max: i + 1,\n width: typeof w === \"number\" ? emuToCharWidth(w) : undefined,\n }))\n : undefined;\n return { rows, ...(mergeCells.length ? { mergeCells } : {}), ...(columns ? { columns } : {}) };\n}\n","/**\n * Cross-format SmartArt conversion (docx ↔ pptx).\n *\n * SmartArt (diagrams) is isomorphic between docx and pptx: both store the data\n * as a core TreeNode tree (docx wraps it in data.nodes; pptx takes nodes\n * directly), reference the same built-in layout/style/color by ID, and anchor\n * via an absolute EMU bounding box (pptx top-level x/y/w/h ↔ docx\n * MediaTransformation). xlsx has no diagram part, so it does not participate.\n *\n * Position maps through the shared position helpers; docx floating positioning\n * is dropped on the pptx leg (no equivalent) and pptx produces an inline\n * transformation (like a picture) on the docx leg. The cNvPr fields\n * (name/description/title/hidden) pass straight through via\n * pickNonVisualDrawingProperties so alt text survives a cross-format copy,\n * mirroring the picture converter.\n *\n * @module\n */\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { TreeNode } from \"@office-open/core/smartart\";\nimport type { SmartArtOptions as DocxSmartArt } from \"@office-open/docx\";\nimport type { SmartArtOptions as PptxSmartArt } from \"@office-open/pptx\";\n\nimport { boxFromDocx, boxFromPptx, boxToPptx } from \"./position\";\n\n// SmartArtNode (docx) and TreeNode (core) are structurally identical trees.\n// Map recursively since docx children are mutable and core's are readonly.\nconst toTreeNodes = (nodes: DocxSmartArt[\"nodes\"]): TreeNode[] =>\n nodes.map((n) => ({\n text: n.text,\n ...(n.children ? { children: toTreeNodes(n.children) } : {}),\n }));\n\nconst toDocxNodes = (nodes: TreeNode[]): DocxSmartArt[\"nodes\"] =>\n nodes.map((n) => ({\n text: n.text,\n ...(n.children ? { children: toDocxNodes([...n.children]) } : {}),\n }));\n\n/**\n * Build the docx altText (wp:docPr) from the shared cNvPr. Only emitted when at\n * least one cNvPr field is authored; name defaults to \"SmartArt\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions.\n */\nconst altTextFromCnvPr = (\n cNvPr: NonVisualDrawingPropertiesOptions,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n const picked = pickNonVisualDrawingProperties(cNvPr);\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"SmartArt\", ...picked } };\n};\n\n// ── → docx ──\n\n/** Convert a pptx SmartArt to a docx inline diagram. */\nexport function toDocxSmartArt(source: PptxSmartArt): DocxSmartArt {\n const box = boxFromPptx(source.x, source.y, source.width, source.height);\n return {\n nodes: toDocxNodes(source.nodes),\n transformation: {\n width: box.width,\n height: box.height,\n ...(source.x !== undefined || source.y !== undefined\n ? { offset: { left: box.x, top: box.y } }\n : {}),\n },\n ...altTextFromCnvPr(source),\n ...(source.layout ? { layout: source.layout } : {}),\n ...(source.style ? { style: source.style } : {}),\n ...(source.color ? { color: source.color } : {}),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx SmartArt to a pptx diagram (floating positioning is dropped). */\nexport function toPptxSmartArt(source: DocxSmartArt): PptxSmartArt {\n const box = boxFromDocx(source.transformation);\n const pos = boxToPptx(box);\n return {\n nodes: toTreeNodes(source.nodes),\n x: pos.x,\n y: pos.y,\n width: pos.width,\n height: pos.height,\n ...pickNonVisualDrawingProperties(source.altText),\n ...(source.layout ? { layout: source.layout } : {}),\n ...(source.style ? { style: source.style } : {}),\n ...(source.color ? { color: source.color } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;;AAG/B,SAAgB,MAAM,OAA8C,WAAW,GAAW;CACxF,OAAO,UAAU,KAAA,IAAY,WAAW,aAAa,KAAK;AAC5D;;AAGA,SAAgB,UAAU,MAAc,SAAyB;CAC/D,OAAO,KAAK,MAAM,OAAO,OAAO,IAAI;AACtC;;AAgBA,SAAgB,YACd,GACA,GACA,OACA,QACA,UACA,gBACa;CACb,OAAO;EACL,GAAG,MAAM,CAAC;EACV,GAAG,MAAM,CAAC;EACV,OAAO,MAAM,KAAK;EAClB,QAAQ,MAAM,MAAM;EACpB,GAAI,aAAa,KAAA,IAAY,EAAE,SAAS,IAAI,CAAC;EAC7C,GAAI,iBAAiB,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACnD;AACF;;;;;AAMA,SAAgB,YAAY,MAQZ;CACd,OAAO;EACL,GAAG,MAAM,KAAK,CAAC;EACf,GAAG,MAAM,KAAK,CAAC;EACf,OAAO,MAAM,KAAK,KAAK;EACvB,QAAQ,MAAM,KAAK,MAAM;EACzB,GAAI,KAAK,aAAa,KAAA,IAAY,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;EACjE,GAAI,KAAK,iBAAiB,EAAE,gBAAgB,KAAK,IAAI,CAAC;EACtD,GAAI,KAAK,eAAe,EAAE,cAAc,KAAK,IAAI,CAAC;CACpD;AACF;;;;;;AAOA,SAAgB,kBACd,QACA,OACA,QACA,UACA,gBACA,cACa;CAGb,OAAO;EACL,IAHS,OAAO,MAAM,KAAK,kBAAkB,MAAM,OAAO,SAAS;EAInE,IAHS,OAAO,MAAM,KAAK,kBAAkB,MAAM,OAAO,SAAS;EAInE,OAAO,MAAM,KAAK;EAClB,QAAQ,MAAM,MAAM;EACpB,GAAI,aAAa,KAAA,IAAY,EAAE,SAA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EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EACjD,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;EAC9C,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD;AACF;;AAKA,SAAgB,eAAe,QAAoC;CAEjE,MAAM,MAAM,UADA,YAAY,OAAO,cACT,CAAG;CACzB,OAAO;EACL,OAAO,YAAY,OAAO,KAAK;EAC/B,GAAG,IAAI;EACP,GAAG,IAAI;EACP,OAAO,IAAI;EACX,QAAQ,IAAI;EACZ,GAAG,+BAA+B,OAAO,OAAO;EAChD,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EACjD,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;EAC9C,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["hasCnvPr","altTextFromCnvPr"],"sources":["../../src/convert/position.ts","../../src/convert/picture.ts","../../src/convert/text.ts","../../src/convert/shape.ts","../../src/convert/connector.ts","../../src/convert/group.ts","../../src/convert/table.ts","../../src/convert/smartart.ts"],"sourcesContent":["/**\n * Cross-format position helpers shared by the picture/shape/connector/group\n * converters. Each format uses a different coordinate model; this module\n * translates between them via an absolute EMU bounding box.\n *\n * - pptx: absolute EMU coordinates as top-level x/y/w/h.\n * - docx: {@link MediaTransformation} (offset left/top + width/height).\n * - xlsx: 1-based cell anchors. Column/row sizes are heuristic (8.43-char\n * column × 15pt row), so xlsx ↔ {pptx,docx} loses precise positioning — the\n * same loss MS Office paste incurs between apps.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { MediaTransformation } from \"@office-open/docx\";\nimport type { DrawingAnchorOptions } from \"@office-open/xlsx\";\n\n/** Heuristic default column width in EMU (8.43 chars ≈ 64 px at 96 DPI). */\nexport const DEFAULT_COL_EMU = 609600;\n/** Heuristic default row height in EMU (15 pt). */\nexport const DEFAULT_ROW_EMU = 190500;\n\n/** Coerce a coordinate (EMU number or universal measure) to raw EMU. */\nexport function toEmu(value: number | UniversalMeasure | undefined, fallback = 0): number {\n return value === undefined ? fallback : convertToEmu(value);\n}\n\n/** Convert a raw EMU offset to a 1-based cell index. */\nexport function emuToCell(emus: number, cellEmu: number): number {\n return Math.floor(emus / cellEmu) + 1;\n}\n\n/** Absolute EMU bounding box (top-left + size + optional rotation/flip). */\nexport interface AbsoluteBox {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n}\n\n// ── → box ──\n\n/** Build a box from pptx top-level position fields. */\nexport function boxFromPptx(\n x: number | UniversalMeasure | undefined,\n y: number | UniversalMeasure | undefined,\n width: number | UniversalMeasure | undefined,\n height: number | UniversalMeasure | undefined,\n rotation?: number,\n flipHorizontal?: boolean,\n): AbsoluteBox {\n return {\n x: toEmu(x),\n y: toEmu(y),\n width: toEmu(width),\n height: toEmu(height),\n ...(rotation !== undefined ? { rotation } : {}),\n ...(flipHorizontal ? { flipHorizontal: true } : {}),\n };\n}\n\n/**\n * Build a box from a core spPr transform (off/ext + rotation/flip). Used for\n * group children, which position via spPr.xfrm with no cell anchor.\n */\nexport function boxFromSpPr(spPr: {\n x?: number | UniversalMeasure;\n y?: number | UniversalMeasure;\n width?: number | UniversalMeasure;\n height?: number | UniversalMeasure;\n rotation?: number;\n flipHorizontal?: boolean;\n flipVertical?: boolean;\n}): AbsoluteBox {\n return {\n x: toEmu(spPr.x),\n y: toEmu(spPr.y),\n width: toEmu(spPr.width),\n height: toEmu(spPr.height),\n ...(spPr.rotation !== undefined ? { rotation: spPr.rotation } : {}),\n ...(spPr.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(spPr.flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n/**\n * Build a box from an xlsx cell anchor. The absolute top-left comes from the\n * from-marker (col/row + offsets); the size comes from the caller (spPr.xfrm\n * extent or the to-marker, depending on the source).\n */\nexport function boxFromXlsxAnchor(\n anchor: DrawingAnchorOptions,\n width: number | UniversalMeasure | undefined,\n height: number | UniversalMeasure | undefined,\n rotation?: number,\n flipHorizontal?: boolean,\n flipVertical?: boolean,\n): AbsoluteBox {\n const x = (anchor.col - 1) * DEFAULT_COL_EMU + toEmu(anchor.colOffset);\n const y = (anchor.row - 1) * DEFAULT_ROW_EMU + toEmu(anchor.rowOffset);\n return {\n x,\n y,\n width: toEmu(width),\n height: toEmu(height),\n ...(rotation !== undefined ? { rotation } : {}),\n ...(flipHorizontal ? { flipHorizontal: true } : {}),\n ...(flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n/** Build a box from a docx MediaTransformation. */\nexport function boxFromDocx(transformation: MediaTransformation): AbsoluteBox {\n return {\n x: toEmu(transformation.offset?.left),\n y: toEmu(transformation.offset?.top),\n width: toEmu(transformation.width),\n height: toEmu(transformation.height),\n ...(transformation.rotation !== undefined ? { rotation: transformation.rotation } : {}),\n ...(transformation.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(transformation.flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n// ── box → ──\n\n/** Pptx top-level position fields derived from a box. */\nexport interface PptxPosition {\n x: number;\n y: number;\n width: number;\n height: number;\n rotation?: number;\n flipHorizontal?: boolean;\n}\n\n/** Emit pptx top-level position fields from a box. */\nexport function boxToPptx(box: AbsoluteBox): PptxPosition {\n return {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n };\n}\n\n/** xlsx position: cell anchor plus the matching spPr.xfrm offset/extent. */\nexport interface XlsxPosition {\n anchor: DrawingAnchorOptions;\n /** spPr.xfrm.off.x — the in-cell horizontal offset (= anchor colOffset). */\n xfrmX: number;\n /** spPr.xfrm.off.y — the in-cell vertical offset (= anchor rowOffset). */\n xfrmY: number;\n}\n\n/**\n * Emit an xlsx position from a box. The from-marker locates the cell, the\n * to-marker carries the size (twoCellAnchor), and the xfrm offset mirrors the\n * from-marker offset so the anchor and spPr agree.\n */\nexport function boxToXlsx(box: AbsoluteBox): XlsxPosition {\n const col = emuToCell(box.x, DEFAULT_COL_EMU);\n const row = emuToCell(box.y, DEFAULT_ROW_EMU);\n const colOffset = box.x - (col - 1) * DEFAULT_COL_EMU;\n const rowOffset = box.y - (row - 1) * DEFAULT_ROW_EMU;\n return {\n anchor: {\n col,\n row,\n colOffset,\n rowOffset,\n toCol: emuToCell(box.x + box.width, DEFAULT_COL_EMU),\n toRow: emuToCell(box.y + box.height, DEFAULT_ROW_EMU),\n },\n xfrmX: colOffset,\n xfrmY: rowOffset,\n };\n}\n\n/** Emit a docx MediaTransformation from a box. */\nexport function boxToDocx(box: AbsoluteBox): MediaTransformation {\n return {\n offset: { left: box.x, top: box.y },\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n}\n","/**\n * Cross-format picture conversion.\n *\n * Each package's PictureOptions extends (or, for docx, is bridged onto) the\n * core BasePictureOptions: the binary payload (data/type) plus the non-visual\n * drawing properties (name/description/title/hidden) that mirror\n * a:CT_NonVisualDrawingProps. Those cNvPr fields pass straight through every\n * conversion leg via pickNonVisualDrawingProperties, so alt text survives a\n * cross-format copy instead of being dropped.\n *\n * Position mapping is heuristic where the target has no matching coordinate\n * model: pptx/docx use absolute EMU coordinates; xlsx uses 1-based cell anchors\n * with no size on the public input. EMU↔cell converts via a default cell size\n * (8.43-char column × 15pt row); size is lost on the xlsx leg. This matches MS\n * Office paste behavior between apps.\n *\n * docx is the odd one out: its PictureOptions is a format discriminated union\n * (regular raster vs. SVG-with-fallback), so it does not extend BasePictureOptions.\n * The cNvPr fields live on its structured altText field instead, and SVG falls\n * back to its raster payload when targeting pptx/xlsx (no vector support).\n *\n * @module\n */\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { BasePictureOptions, NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { PictureOptions as DocxPictureOptions } from \"@office-open/docx\";\nimport type { PictureOptions as PptxPictureOptions } from \"@office-open/pptx\";\nimport type { PictureOptions as XlsxPictureOptions } from \"@office-open/xlsx\";\n\nimport { DEFAULT_COL_EMU, DEFAULT_ROW_EMU, emuToCell, toEmu } from \"./position\";\n\n// ── base readers: each package → shared BasePictureOptions ──\n\n/** Project a pptx picture onto the shared base (data/type + cNvPr). */\nconst baseFromPptx = (p: PptxPictureOptions): BasePictureOptions => ({\n data: p.data,\n type: p.type,\n ...(p.sourceUrl !== undefined ? { sourceUrl: p.sourceUrl } : {}),\n ...pickNonVisualDrawingProperties(p),\n});\n\n/** Project an xlsx picture onto the shared base. */\nconst baseFromXlsx = (x: XlsxPictureOptions): BasePictureOptions => ({\n data: x.data,\n type: x.type,\n ...(x.sourceUrl !== undefined ? { sourceUrl: x.sourceUrl } : {}),\n ...pickNonVisualDrawingProperties(x),\n});\n\n/**\n * Project a docx picture onto the shared base. docx does not extend\n * BasePictureOptions (its PictureOptions is a format discriminated union), so\n * the cNvPr fields are read from the structured altText. SVG falls back to its\n * raster payload since pptx/xlsx have no vector picture support.\n */\nconst baseFromDocx = (d: DocxPictureOptions): BasePictureOptions => {\n const cNvPr = pickNonVisualDrawingProperties(d.altText);\n if (d.type === \"svg\") {\n return { data: d.fallback.data, type: d.fallback.type, ...cNvPr };\n }\n return {\n data: d.data,\n type: d.type,\n ...(d.sourceUrl !== undefined ? { sourceUrl: d.sourceUrl } : {}),\n ...cNvPr,\n };\n};\n\n// ── type narrowing ──\n\ntype DocxRasterType = \"jpg\" | \"png\" | \"gif\" | \"bmp\" | \"tif\" | \"ico\" | \"emf\" | \"wmf\";\nconst DOCX_RASTER_TYPES: readonly DocxRasterType[] = [\n \"jpg\",\n \"png\",\n \"gif\",\n \"bmp\",\n \"tif\",\n \"ico\",\n \"emf\",\n \"wmf\",\n];\n\n/** Narrow an image type to docx's raster set (pptx/xlsx sources are never svg). */\nconst docxType = (type: string): DocxRasterType =>\n (DOCX_RASTER_TYPES as readonly string[]).includes(type) ? (type as DocxRasterType) : \"png\";\n\nconst PPTX_TYPES = [\"png\", \"jpg\", \"gif\", \"bmp\", \"emf\", \"wmf\"] as const;\n/** Narrow an image type to pptx's supported set, falling back to png. */\nconst pptxType = (type: string): PptxPictureOptions[\"type\"] =>\n (PPTX_TYPES as readonly string[]).includes(type) ? (type as PptxPictureOptions[\"type\"]) : \"png\";\n\n/** Narrow an image type to xlsx's png/jpg set. */\nconst xlsxType = (type: string): \"png\" | \"jpg\" =>\n type === \"jpg\" || type === \"jpeg\" ? \"jpg\" : \"png\";\n\n/**\n * Build the docx altText (wp:docPr) from the shared base. Only emitted when at\n * least one cNvPr field is authored; name defaults to \"Picture\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions without\n * importing that internal type.\n */\nconst altTextFromBase = (\n base: BasePictureOptions,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n const picked = pickNonVisualDrawingProperties(base);\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"Picture\", ...picked } };\n};\n\n// ── → docx ──\n\n/** Convert a pptx picture to a docx inline image. */\nexport function toDocxPicture(source: PptxPictureOptions): DocxPictureOptions;\n/** Convert an xlsx image to a docx inline image (size defaults to 0; xlsx carries no size). */\nexport function toDocxPicture(source: XlsxPictureOptions): DocxPictureOptions;\nexport function toDocxPicture(source: PptxPictureOptions | XlsxPictureOptions): DocxPictureOptions {\n // pptx → docx: absolute x/y → offset, width/height → transformation.\n if (\"width\" in source || \"height\" in source) {\n const p = source as PptxPictureOptions;\n const base = baseFromPptx(p);\n return {\n type: docxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n transformation: {\n width: p.width ?? 0,\n height: p.height ?? 0,\n ...(p.x !== undefined || p.y !== undefined\n ? { offset: { left: p.x ?? 0, top: p.y ?? 0 } }\n : {}),\n },\n ...altTextFromBase(base),\n };\n }\n // xlsx → docx: cell anchor → offset EMU; size unknown.\n const x = source as XlsxPictureOptions;\n const base = baseFromXlsx(x);\n return {\n type: docxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n transformation: {\n width: 0,\n height: 0,\n offset: { left: (x.col - 1) * DEFAULT_COL_EMU, top: (x.row - 1) * DEFAULT_ROW_EMU },\n },\n ...altTextFromBase(base),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx image to a pptx picture. */\nexport function toPptxPicture(source: DocxPictureOptions): PptxPictureOptions;\n/** Convert an xlsx image to a pptx picture (size defaults to 0; xlsx carries no size). */\nexport function toPptxPicture(source: XlsxPictureOptions): PptxPictureOptions;\nexport function toPptxPicture(source: DocxPictureOptions | XlsxPictureOptions): PptxPictureOptions {\n // docx → pptx: transformation → absolute x/y + width/height.\n if (\"transformation\" in source) {\n const d = source as DocxPictureOptions;\n const base = baseFromDocx(d);\n const t = d.transformation;\n return {\n type: pptxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n width: t.width,\n height: t.height,\n ...(t.offset ? { x: t.offset.left, y: t.offset.top } : {}),\n ...pickNonVisualDrawingProperties(base),\n };\n }\n // xlsx → pptx: cell anchor → absolute EMU; size unknown.\n const x = source as XlsxPictureOptions;\n const base = baseFromXlsx(x);\n return {\n type: pptxType(base.type),\n data: base.data,\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n x: (x.col - 1) * DEFAULT_COL_EMU,\n y: (x.row - 1) * DEFAULT_ROW_EMU,\n width: 0,\n height: 0,\n ...pickNonVisualDrawingProperties(base),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a docx image to an xlsx picture (position mapped to cell anchor; size lost). */\nexport function toXlsxPicture(source: DocxPictureOptions): XlsxPictureOptions;\n/** Convert a pptx picture to an xlsx picture (position mapped to cell anchor; size lost). */\nexport function toXlsxPicture(source: PptxPictureOptions): XlsxPictureOptions;\nexport function toXlsxPicture(source: DocxPictureOptions | PptxPictureOptions): XlsxPictureOptions {\n // docx → xlsx: offset EMU → cell anchor.\n if (\"transformation\" in source) {\n const d = source as DocxPictureOptions;\n const base = baseFromDocx(d);\n const left = toEmu(d.transformation.offset?.left);\n const top = toEmu(d.transformation.offset?.top);\n return {\n data: base.data,\n type: xlsxType(base.type),\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n col: emuToCell(left, DEFAULT_COL_EMU),\n row: emuToCell(top, DEFAULT_ROW_EMU),\n ...pickNonVisualDrawingProperties(base),\n };\n }\n // pptx → xlsx: absolute EMU → cell anchor.\n const p = source as PptxPictureOptions;\n const base = baseFromPptx(p);\n return {\n data: base.data,\n type: xlsxType(base.type),\n ...(base.sourceUrl !== undefined ? { sourceUrl: base.sourceUrl } : {}),\n col: emuToCell(toEmu(p.x), DEFAULT_COL_EMU),\n row: emuToCell(toEmu(p.y), DEFAULT_ROW_EMU),\n ...pickNonVisualDrawingProperties(base),\n };\n}\n","/**\n * Cross-format text adapter — DrawingML paragraph (a:p, the core text model\n * shared by pptx/xlsx) ↔ WordprocessingML paragraph (w:p, docx).\n *\n * pptx and xlsx already model text as the core `a:p` shape, so this adapter only\n * bridges docx's w:p to/from that shared model. It lives in the aggregate\n * office-open convert layer alongside the other cross-format converters\n * (picture/shape/...): cross-format code references multiple format packages,\n * and the aggregate package is the single place that already depends on all of\n * them, so converters stay dependency-cycle-free. Single-format users never need\n * cross-format conversion.\n *\n * Round-trip is lossy by design, mirroring MS Office paste between apps.\n *\n * docx → a:p drops docx-only fields with no DrawingML text equivalent:\n * paragraph: numbering, heading, borders, shading, keepNext/keepLines,\n * bidirectional, widowControl, rsid, frame, outlineLevel, ...\n * run: highlight, shading, border, kern, scale, position, effect,\n * emphasisMark, w14 effects, language.eastAsia/bidirectional, ...\n *\n * a:p → docx drops DrawingML-only fields with no WordprocessingML equivalent:\n * paragraph: defTabSize; bullet color/size/font/char/format (only the level\n * survives); text fields (a:fld) are dropped.\n * run: non-solid fill and non-sRGB color variants (gradient/pattern/blip/group\n * fill; scheme/system/HSL/scRgb/preset colors → no w:p color);\n * a:br run properties.\n *\n * Magnitude loss: a:p `baseline` is a signed percentage; docx has only\n * subscript/superscript on/off flags. Hyperlink round-trips url + tooltip only.\n *\n * Units (both APIs take plain numbers in their native unit):\n * font size points on both APIs (direct).\n * char spacing a:p spc (1/100 pt) ↔ w:p spacing (twips), ÷5 / ×5.\n * before/after a:p spcPts (1/100 pt) ↔ w:p spacing (twips), ÷5 / ×5.\n * line spacing a:p lineSpacingPercent (percent, 100 = single) ↔ w:p line +\n * lineRule \"auto\" (240 = single); a:p lineSpacingPoints (pt)\n * ↔ line + lineRule \"exact\" (×20).\n * indents/tabs a:p marL/marR/pos (EMU) ↔ w:p (twips), ÷635 / ×635.\n *\n * @module\n */\n\nimport { convertToTwip, stripColorHashPrefix } from \"@office-open/core\";\nimport type {\n FillOptions,\n ParagraphDescriptorOptions,\n TextParagraphPropertiesOptions as DrawingParagraphProperties,\n RunFont,\n TextRunOptions as DrawingRunOptions,\n TextCharacterPropertiesOptions as DrawingRunProperties,\n TextFont,\n} from \"@office-open/core\";\nimport type { ParagraphOptions, RunOptions } from \"@office-open/docx\";\n\n// ── unit factors ──\n\n/** 1 inch = 914400 EMU = 1440 twips → 1 twip = 635 EMU. */\nconst EMU_PER_TWIP = 635;\n/** 1 point = 100 hundredths = 20 twips → 1 hundredth = 0.2 twip. */\nconst TWIPS_PER_HUNDREDTH = 1 / 5;\nconst HUNDREDTHS_PER_TWIP = 5;\n/** w:p \"auto\" line: 240 = single (100%). */\nconst AUTO_LINE_SINGLE = 240;\nconst POINTS_PER_TWIP = 1 / 20;\n\nconst round = Math.round;\n\n/** Discriminant keys of ParagraphChild variants that are NOT a text run. */\nconst NON_RUN_KEYS = new Set([\n \"hyperlink\",\n \"pageBreak\",\n \"columnBreak\",\n \"commentRangeStart\",\n \"commentRangeEnd\",\n \"commentReference\",\n \"comment\",\n \"insertion\",\n \"deletion\",\n \"bookmarkStart\",\n \"bookmarkEnd\",\n \"bookmark\",\n \"wpsShape\",\n \"wpgGroup\",\n \"proofErr\",\n \"positionalTab\",\n \"permStart\",\n \"permEnd\",\n \"pageReference\",\n \"section\",\n \"symbol\",\n \"footnoteReference\",\n \"endnoteReference\",\n \"footnote\",\n \"endnote\",\n \"chart\",\n \"picture\",\n \"object\",\n \"sdt\",\n \"customXml\",\n \"pageNumber\",\n \"tableOfContents\",\n]);\n\n// ── a:p → w:p ──\n\n/**\n * Convert a DrawingML paragraph (core a:p) to a WordprocessingML paragraph (w:p).\n *\n * pptx/xlsx text is already a:p, so call this when pasting shape or cell text\n * into a docx. See module header for lossy fields.\n */\nexport function fromDrawingParagraph(drawing: ParagraphDescriptorOptions): ParagraphOptions {\n const docx: ParagraphOptions = {};\n\n const props = drawing.properties;\n if (props) {\n if (props.alignment) {\n const a = alignToDocx(props.alignment);\n if (a) docx.alignment = a;\n }\n\n const spacing = spacingToDocx(props);\n if (spacing) docx.spacing = spacing;\n\n const indent = indentToDocx(props);\n if (indent) docx.indent = indent;\n\n // Only fabricate a docx bullet when the source is actually bulleted; a bare\n // indentLevel (common in pptx placeholders) carries no bullet semantics.\n if (props.bullet && props.bullet.type !== \"none\") {\n docx.bullet = { level: props.indentLevel ?? 0 };\n }\n\n if (props.fontAlignment) {\n const t = fontAlignToDocx(props.fontAlignment);\n if (t) docx.textAlignment = t;\n }\n\n if (props.tabStops?.length) {\n const tabs = props.tabStops.map(tabToDocx);\n if (tabs.length) docx.tabStops = tabs;\n }\n }\n\n // Text shorthand takes priority when the source is a single text-only run.\n if (drawing.text !== undefined) {\n docx.text = drawing.text;\n } else if (drawing.children?.length) {\n const children = drawingToDocxChildren(drawing.children);\n if (children.length) docx.children = children;\n }\n\n return docx;\n}\n\nfunction drawingToDocxChildren(\n children: NonNullable<ParagraphDescriptorOptions[\"children\"]>,\n): NonNullable<ParagraphOptions[\"children\"]> {\n const out: NonNullable<ParagraphOptions[\"children\"]> = [];\n for (const child of children) {\n // String shorthand (core children allow bare strings) → one text run.\n if (typeof child === \"string\") {\n out.push({ text: child });\n continue;\n }\n // Soft break (a:br) → a run carrying w:br (count collapses to 1).\n if (typeof child === \"object\" && child !== null && \"break\" in child) {\n out.push({ break: 1 });\n continue;\n }\n // Text field (a:fld) — no w:p equivalent; dropped.\n if (typeof child === \"object\" && child !== null && \"type\" in child) {\n continue;\n }\n const run = child as DrawingRunOptions;\n // Run with an external hyperlink becomes a w:hyperlink child wrapping the\n // (de-hyperlinked) run so its run formatting survives.\n if (run.hyperlink?.url) {\n const { hyperlink, ...rest } = run;\n out.push({\n hyperlink: {\n url: hyperlink.url,\n ...(hyperlink.tooltip ? { tooltip: hyperlink.tooltip } : {}),\n children: [drawingRunToDocx(rest)],\n },\n });\n continue;\n }\n out.push(drawingRunToDocx(run));\n }\n return out;\n}\n\nfunction drawingRunToDocx(run: DrawingRunOptions): RunOptions {\n return {\n ...drawingRunPropertiesToDocx(run),\n ...(run.text !== undefined ? { text: run.text } : {}),\n };\n}\n\nfunction drawingRunPropertiesToDocx(run: DrawingRunProperties): Partial<RunOptions> {\n const out: Partial<RunOptions> = {};\n if (run.size !== undefined) out.size = run.size;\n if (run.bold !== undefined) out.bold = run.bold;\n if (run.italic !== undefined) out.italic = run.italic;\n if (run.underline && run.underline !== \"none\") out.underline = { type: run.underline };\n if (run.strike === \"singleStrike\") out.strike = true;\n else if (run.strike === \"doubleStrike\") out.doubleStrike = true;\n if (run.baseline !== undefined && run.baseline !== 0) {\n out.verticalAlign = run.baseline > 0 ? \"superscript\" : \"subscript\";\n }\n if (run.spacing !== undefined) out.characterSpacing = round(run.spacing * TWIPS_PER_HUNDREDTH);\n if (run.capitalization === \"all\") out.allCaps = true;\n else if (run.capitalization === \"small\") out.smallCaps = true;\n if (run.shadow) out.shadow = true;\n if (run.outline) out.outline = true;\n if (run.rightToLeft !== undefined) out.rightToLeft = run.rightToLeft;\n if (run.font !== undefined) out.font = drawingFontToDocx(run.font);\n if (run.fill !== undefined) {\n const hex = solidFillToHex(run.fill);\n if (hex) out.color = hex;\n }\n if (run.lang !== undefined) out.language = { value: run.lang };\n return out;\n}\n\n// ── w:p → a:p ──\n\n/**\n * Convert a WordprocessingML paragraph (w:p) to a DrawingML paragraph (core a:p).\n *\n * Use this when pasting docx text (body or textbox) into a pptx/xlsx shape.\n * See module header for lossy fields.\n */\nexport function toDrawingParagraph(docx: ParagraphOptions): ParagraphDescriptorOptions {\n const drawing: ParagraphDescriptorOptions = {};\n\n const props = paragraphPropertiesToDrawing(docx);\n if (props) drawing.properties = props;\n\n // Prefer structured children over the text shorthand when both exist.\n if (docx.children?.length) {\n const children = docxToDrawingChildren(docx.children);\n if (children.length) drawing.children = children;\n } else if (docx.text !== undefined) {\n drawing.text = docx.text;\n }\n\n return drawing;\n}\n\nfunction docxToDrawingChildren(\n children: NonNullable<ParagraphOptions[\"children\"]>,\n): NonNullable<ParagraphDescriptorOptions[\"children\"]> {\n const out: NonNullable<ParagraphDescriptorOptions[\"children\"]> = [];\n for (const child of children) {\n if (typeof child === \"string\") {\n out.push({ text: child });\n continue;\n }\n if (typeof child !== \"object\" || child === null) continue;\n\n // External hyperlink child → flatten: each inner run inherits the link.\n if (\"hyperlink\" in child) {\n const hl = child.hyperlink;\n const url = hl.url;\n if (url === undefined) continue; // anchor-only/internal link — no a:p equivalent\n const link = { url, ...(hl.tooltip ? { tooltip: hl.tooltip } : {}) };\n const subs =\n hl.children && hl.children.length\n ? hl.children\n : child.text !== undefined\n ? [child.text]\n : [];\n for (const sub of subs) {\n if (typeof sub !== \"string\" && !isRunChild(sub)) continue;\n const run: DrawingRunOptions =\n typeof sub === \"string\" ? { text: sub } : docxRunToDrawing(sub);\n out.push({ ...run, hyperlink: link });\n }\n continue;\n }\n\n if (!isRunChild(child)) continue; // docx-only child (pageBreak, bookmark, …) dropped\n const run = child as RunOptions;\n if (run.text !== undefined) out.push(docxRunToDrawing(run));\n // A run carrying w:br becomes a soft break (count collapses to one).\n if (run.break) out.push({ break: true });\n }\n return out;\n}\n\nfunction docxRunToDrawing(run: RunOptions): DrawingRunOptions {\n const out: DrawingRunOptions = docxRunPropertiesToDrawing(run);\n if (run.text !== undefined) out.text = run.text;\n return out;\n}\n\nfunction docxRunPropertiesToDrawing(run: RunOptions): DrawingRunProperties {\n const out: DrawingRunProperties = {};\n if (run.size !== undefined) out.size = run.size;\n if (run.bold !== undefined) out.bold = run.bold;\n if (run.italic !== undefined) out.italic = run.italic;\n if (run.underline?.type) {\n // a:p models only single/double; other Word underline styles collapse to single.\n out.underline = run.underline.type === \"double\" ? \"double\" : \"single\";\n }\n if (run.doubleStrike) out.strike = \"doubleStrike\";\n else if (run.strike) out.strike = \"singleStrike\";\n if (run.verticalAlign === \"superscript\") out.baseline = 30000;\n else if (run.verticalAlign === \"subscript\") out.baseline = -25000;\n if (run.characterSpacing !== undefined) {\n out.spacing = round(convertToTwip(run.characterSpacing) * HUNDREDTHS_PER_TWIP);\n }\n if (run.allCaps) out.capitalization = \"all\";\n else if (run.smallCaps) out.capitalization = \"small\";\n if (run.shadow) out.shadow = true;\n if (run.outline) out.outline = true;\n if (run.rightToLeft !== undefined) out.rightToLeft = run.rightToLeft;\n if (run.font !== undefined) {\n const typeface = fontToString(run.font);\n if (typeface) out.font = typeface;\n }\n if (run.color !== undefined) {\n const hex = colorToHex(run.color);\n if (hex) out.fill = hex;\n }\n if (run.language?.value) out.lang = run.language.value;\n return out;\n}\n\n// ── paragraph property helpers ──\n\nfunction paragraphPropertiesToDrawing(\n docx: ParagraphOptions,\n): DrawingParagraphProperties | undefined {\n const out: DrawingParagraphProperties = {};\n if (docx.alignment) {\n const a = alignToDrawing(docx.alignment);\n if (a) out.alignment = a;\n }\n if (docx.spacing) {\n const sp = docx.spacing;\n if (sp.before !== undefined)\n out.spaceBefore = round(convertToTwip(sp.before) * HUNDREDTHS_PER_TWIP);\n if (sp.after !== undefined)\n out.spaceAfter = round(convertToTwip(sp.after) * HUNDREDTHS_PER_TWIP);\n if (sp.line !== undefined) {\n const twips = convertToTwip(sp.line);\n if (sp.lineRule === \"auto\") out.lineSpacingPercent = round((twips / AUTO_LINE_SINGLE) * 100);\n else out.lineSpacingPoints = round(twips * POINTS_PER_TWIP);\n }\n }\n if (docx.indent) {\n const start = docx.indent.start ?? docx.indent.left;\n const end = docx.indent.end ?? docx.indent.right;\n if (start !== undefined) out.marginIndent = round(convertToTwip(start) * EMU_PER_TWIP);\n if (end !== undefined) out.marginRight = round(convertToTwip(end) * EMU_PER_TWIP);\n }\n if (docx.bullet) {\n out.indentLevel = docx.bullet.level;\n out.bullet = { type: \"char\", char: \"•\" };\n }\n if (docx.textAlignment) {\n const f = fontAlignToDrawing(docx.textAlignment);\n if (f) out.fontAlignment = f;\n }\n if (docx.tabStops?.length) {\n const tabs = docx.tabStops\n .map(tabToDrawing)\n .filter((t): t is NonNullable<typeof t> => t !== undefined);\n if (tabs.length) out.tabStops = tabs;\n }\n return Object.keys(out).length ? out : undefined;\n}\n\nfunction spacingToDocx(\n props: DrawingParagraphProperties,\n): NonNullable<ParagraphOptions[\"spacing\"]> | undefined {\n const sp: NonNullable<ParagraphOptions[\"spacing\"]> = {};\n if (props.spaceBefore !== undefined) sp.before = round(props.spaceBefore * TWIPS_PER_HUNDREDTH);\n if (props.spaceAfter !== undefined) sp.after = round(props.spaceAfter * TWIPS_PER_HUNDREDTH);\n // Percent line spacing (100 = single) takes precedence over the points form.\n if (props.lineSpacingPercent !== undefined) {\n sp.line = round((props.lineSpacingPercent / 100) * AUTO_LINE_SINGLE);\n sp.lineRule = \"auto\";\n } else if (props.lineSpacingPoints !== undefined) {\n sp.line = round(props.lineSpacingPoints / POINTS_PER_TWIP);\n sp.lineRule = \"exact\";\n }\n return Object.keys(sp).length ? sp : undefined;\n}\n\nfunction indentToDocx(\n props: DrawingParagraphProperties,\n): NonNullable<ParagraphOptions[\"indent\"]> | undefined {\n const ind: NonNullable<ParagraphOptions[\"indent\"]> = {};\n if (props.marginIndent !== undefined) ind.start = round(props.marginIndent / EMU_PER_TWIP);\n if (props.marginRight !== undefined) ind.end = round(props.marginRight / EMU_PER_TWIP);\n return Object.keys(ind).length ? ind : undefined;\n}\n\nfunction tabToDocx(\n tab: NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number],\n): NonNullable<ParagraphOptions[\"tabStops\"]>[number] {\n return {\n type: tabAlignToDocx(tab.alignment),\n position: tab.position !== undefined ? round(tab.position / EMU_PER_TWIP) : 0,\n };\n}\n\nfunction tabToDrawing(\n tab: NonNullable<ParagraphOptions[\"tabStops\"]>[number],\n): NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number] | undefined {\n const alignment = tabAlignToDrawing(tab.type);\n if (!alignment) return undefined;\n const out: NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number] = { alignment };\n if (typeof tab.position === \"number\") out.position = round(tab.position * EMU_PER_TWIP);\n return out;\n}\n\n// ── enum / value mappers ──\n\nfunction alignToDocx(a: DrawingParagraphProperties[\"alignment\"]): ParagraphOptions[\"alignment\"] {\n switch (a) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"justify\":\n return \"both\";\n default:\n return undefined;\n }\n}\n\nfunction alignToDrawing(a: ParagraphOptions[\"alignment\"]): DrawingParagraphProperties[\"alignment\"] {\n switch (a) {\n case \"left\":\n case \"start\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n case \"end\":\n return \"right\";\n case \"both\":\n return \"justify\";\n default:\n return undefined;\n }\n}\n\nfunction fontAlignToDocx(\n f: DrawingParagraphProperties[\"fontAlignment\"],\n): ParagraphOptions[\"textAlignment\"] {\n switch (f) {\n case \"top\":\n return \"top\";\n case \"center\":\n return \"center\";\n case \"bottom\":\n return \"bottom\";\n case \"base\":\n return \"baseline\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\nfunction fontAlignToDrawing(\n t: ParagraphOptions[\"textAlignment\"],\n): DrawingParagraphProperties[\"fontAlignment\"] {\n switch (t) {\n case \"top\":\n return \"top\";\n case \"center\":\n return \"center\";\n case \"bottom\":\n return \"bottom\";\n case \"baseline\":\n return \"base\";\n case \"auto\":\n return \"auto\";\n default:\n return undefined;\n }\n}\n\ntype DrawingTabAlignment = NonNullable<DrawingParagraphProperties[\"tabStops\"]>[number][\"alignment\"];\ntype DocxTabType = NonNullable<ParagraphOptions[\"tabStops\"]>[number][\"type\"];\n\nfunction tabAlignToDocx(a: DrawingTabAlignment): DocxTabType {\n switch (a) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"decimal\":\n return \"decimal\";\n default:\n return \"left\";\n }\n}\n\nfunction tabAlignToDrawing(t: DocxTabType): DrawingTabAlignment {\n switch (t) {\n case \"left\":\n return \"left\";\n case \"center\":\n return \"center\";\n case \"right\":\n return \"right\";\n case \"decimal\":\n return \"decimal\";\n default:\n return undefined;\n }\n}\n\n/** 6- or 8-digit sRGB hex; excludes scheme/system/preset color-name values. */\nconst SRGB_HEX = /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/;\n\n/**\n * Extract an sRGB hex string from a solid fill; undefined for non-solid fills\n * and for non-RGB color variants (scheme/system/HSL/scRgb/preset) that have no\n * w:p color equivalent.\n */\nfunction solidFillToHex(fill: FillOptions): string | undefined {\n if (typeof fill === \"string\") return stripColorHashPrefix(fill);\n if (fill.type === \"solid\") {\n const c = fill.color;\n if (typeof c === \"string\") return stripColorHashPrefix(c);\n if (\"value\" in c && typeof c.value === \"string\" && SRGB_HEX.test(c.value)) return c.value;\n }\n return undefined;\n}\n\nfunction colorToHex(color: NonNullable<RunOptions[\"color\"]>): string | undefined {\n return typeof color === \"string\" ? stripColorHashPrefix(color) : color.val;\n}\n\nfunction fontToString(font: NonNullable<RunOptions[\"font\"]>): string | undefined {\n if (typeof font === \"string\") return font;\n if (\"name\" in font) return font.name; // RunFontReference\n return font.ascii ?? font.hAnsi ?? font.eastAsia ?? font.complexScript; // FontProperties\n}\n\n/** Map a DrawingML RunFont to a docx run font: latin→ascii+hAnsi, eastAsia→eastAsia, complexScript→complexScript. symbol has no docx equivalent and is dropped. */\nfunction drawingFontToDocx(font: RunFont): NonNullable<RunOptions[\"font\"]> {\n if (typeof font === \"string\") return font;\n const typeface = (tf: TextFont | undefined): string | undefined =>\n tf === undefined ? undefined : typeof tf === \"string\" ? tf : tf.typeface;\n const latin = typeface(font.latin);\n const ea = typeface(font.eastAsia);\n const cs = typeface(font.complexScript);\n return {\n ...(latin ? { ascii: latin, hAnsi: latin } : {}),\n ...(ea ? { eastAsia: ea } : {}),\n ...(cs ? { complexScript: cs } : {}),\n };\n}\n\nfunction isRunChild(child: unknown): child is RunOptions {\n if (typeof child !== \"object\" || child === null) return false;\n for (const key of Object.keys(child)) {\n if (NON_RUN_KEYS.has(key)) return false;\n }\n return true;\n}\n","/**\n * Cross-format shape conversion.\n *\n * Shape options convert between docx (wps), pptx (p:sp), and xlsx (xdr:sp).\n * The shape body — geometry/fill/outline/effects/3D — is already core\n * DrawingML in all three packages, so it round-trips near-losslessly. The\n * lossy legs are positioning (pptx/docx absolute EMU ↔ xlsx heuristic cell\n * anchors — see ./position) and text (docx w:p ↔ DrawingML a:p — see ./text).\n *\n * docx shapes carry text as w:p paragraphs; pptx/xlsx carry it as a core\n * TextBody (a:p). bodyProperties (a:bodyPr) round-trips verbatim. Geometry\n * adapts to docx's stricter API (geometry rejects the bare-string\n * shorthand pptx/xlsx accept).\n *\n * @module\n */\n\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type {\n FillOptions,\n OutlineOptions,\n EffectListOptions,\n EffectDagOptions,\n Scene3DOptions,\n Shape3DOptions,\n PresetGeometryOptions,\n ShapeType,\n ParagraphDescriptorOptions,\n TextBodyOptions,\n ShapePropertiesOptions,\n} from \"@office-open/core/drawing\";\nimport type {\n ShapeOptions as DocxShapeRunOptions,\n ShapeCoreOptions,\n MediaTransformation,\n ParagraphOptions as DocxParagraph,\n ShapeTextBoxChild,\n} from \"@office-open/docx\";\nimport type { ShapeOptions as PptxShapeOptions } from \"@office-open/pptx\";\nimport type { ShapeOptions as XlsxShapeOptions } from \"@office-open/xlsx\";\n\nimport {\n boxFromPptx,\n boxFromXlsxAnchor,\n boxFromDocx,\n boxToPptx,\n boxToXlsx,\n boxToDocx,\n} from \"./position\";\nimport { fromDrawingParagraph, toDrawingParagraph } from \"./text\";\n\n/** docx shape input = ShapeOptions (core fields + transformation). */\nexport type DocxShapeOptions = DocxShapeRunOptions;\n\n/** The five-plus shape-content fields shared verbatim across all three packages. */\nexport interface ShapeContent {\n /** pptx adds null (a source spPr with no fill child); pickContent drops it. */\n fill?: FillOptions | null;\n outline?: OutlineOptions;\n effects?: EffectListOptions;\n effectDag?: EffectDagOptions;\n scene3d?: Scene3DOptions;\n shape3d?: Shape3DOptions;\n}\n\n/** pickContent's result: the shared fields with pptx's null fill filtered out. */\ntype PickedContent = Omit<ShapeContent, \"fill\"> & { fill?: FillOptions };\n\n/** Copy the shared shape-content fields that are present on the source. */\nexport function pickContent<T extends ShapeContent>(source: T): PickedContent {\n const out: PickedContent = {};\n // pptx carries fill: null for a source spPr with no fill child; the target\n // packages express the same \"emit no fill\" as an absent field, so null maps\n // to skipped rather than copied.\n if (source.fill != null) out.fill = source.fill;\n if (source.outline !== undefined) out.outline = source.outline;\n if (source.effects !== undefined) out.effects = source.effects;\n if (source.effectDag !== undefined) out.effectDag = source.effectDag;\n if (source.scene3d !== undefined) out.scene3d = source.scene3d;\n if (source.shape3d !== undefined) out.shape3d = source.shape3d;\n return out;\n}\n\n/** pptx/xlsx geometry shorthand (ShapeType | PresetGeometryOptions) → docx preset. */\nexport function toPresetGeometry(\n g: ShapeType | PresetGeometryOptions | undefined,\n): PresetGeometryOptions | undefined {\n if (g === undefined) return undefined;\n return typeof g === \"string\" ? { preset: g } : g;\n}\n\n// ── text bridge ──\n\n/** DrawingML text body (a:p) → docx w:p children. */\nexport function textBodyToDocxChildren(textBody: TextBodyOptions): DocxParagraph[] | string[] {\n const paragraphs = textBody.paragraphs ?? (textBody.text !== undefined ? [textBody.text] : []);\n const out: (DocxParagraph | string)[] = [];\n for (const p of paragraphs) {\n if (typeof p === \"string\") out.push(p);\n else out.push(fromDrawingParagraph(p));\n }\n return out as DocxParagraph[] | string[];\n}\n\n/** docx w:p children + bodyProperties → DrawingML text body (a:p), or undefined when empty. */\nexport function docxToTextBody(\n children: ShapeTextBoxChild[] | undefined,\n bodyProperties: TextBodyOptions[\"bodyProperties\"],\n): TextBodyOptions | undefined {\n const paragraphs: (ParagraphDescriptorOptions | string)[] = [];\n for (const child of children ?? []) {\n if (typeof child === \"string\") {\n paragraphs.push(child);\n } else if (\"paragraph\" in child) {\n paragraphs.push(\n typeof child.paragraph === \"string\" ? child.paragraph : toDrawingParagraph(child.paragraph),\n );\n } else if (\n !(\n \"table\" in child ||\n \"toc\" in child ||\n \"textbox\" in child ||\n \"sdt\" in child ||\n \"altChunk\" in child ||\n \"subDoc\" in child ||\n \"customXml\" in child ||\n \"bookmarkStart\" in child ||\n \"bookmarkEnd\" in child ||\n \"rawXml\" in child\n )\n ) {\n paragraphs.push(toDrawingParagraph(child));\n }\n }\n if (paragraphs.length === 0 && bodyProperties === undefined) return undefined;\n const out: TextBodyOptions = {};\n if (paragraphs.length > 0) out.paragraphs = paragraphs;\n if (bodyProperties !== undefined) out.bodyProperties = bodyProperties;\n return out;\n}\n\n// ── → docx ──\n\n/** docx shape split: the wps core (data) + position (transformation). */\nexport interface DocxShapeParts {\n data: ShapeCoreOptions;\n transformation: MediaTransformation;\n}\n\n/**\n * Build docx nonVisualProperties from a source's cNvPr — all authored fields,\n * not just name. name defaults to \"Shape\" (docx requires it).\n */\nconst docxNonVisual = (\n source: NonVisualDrawingPropertiesOptions,\n): { nonVisualProperties: NonVisualDrawingPropertiesOptions } => {\n const picked = pickNonVisualDrawingProperties(source);\n return { nonVisualProperties: { name: picked.name ?? \"Shape\", ...picked } };\n};\n\n/** True when a source carries at least one authored cNvPr field. */\nconst hasCnvPr = (source: NonVisualDrawingPropertiesOptions): boolean => {\n const picked = pickNonVisualDrawingProperties(source);\n return (\n picked.name !== undefined ||\n picked.description !== undefined ||\n picked.title !== undefined ||\n picked.hidden !== undefined\n );\n};\n\n/**\n * Build the docx wps core + position from a pptx or xlsx shape. Group\n * conversion reuses this to embed shapes as wpg children (the child carries a\n * full MediaDataTransformation; the caller runs it through createTransformation).\n */\nexport function toDocxShapeParts(source: PptxShapeOptions | XlsxShapeOptions): DocxShapeParts {\n if (\"col\" in source) {\n // xlsx (cell-anchored: required col/row markers; pptx shapes have none) → docx\n const spPr = source.properties;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const preset = toPresetGeometry(spPr.geometry);\n return {\n data: {\n children: source.textBody ? textBodyToDocxChildren(source.textBody) : [],\n ...pickContent(spPr),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...(preset !== undefined ? { geometry: preset } : {}),\n ...(hasCnvPr(source) ? docxNonVisual(source) : {}),\n },\n transformation: boxToDocx(box),\n };\n }\n // pptx → docx\n const spPr = source.properties ?? {};\n const box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const preset = toPresetGeometry(spPr.geometry);\n return {\n data: {\n children: source.textBody ? textBodyToDocxChildren(source.textBody) : [],\n ...pickContent(spPr),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...(preset !== undefined ? { geometry: preset } : {}),\n ...(hasCnvPr(source) ? docxNonVisual(source) : {}),\n },\n transformation: boxToDocx(box),\n };\n}\n\n/** Convert a pptx shape to a docx wps shape. */\nexport function toDocxShape(source: PptxShapeOptions): DocxShapeOptions;\n/** Convert an xlsx shape to a docx wps shape. */\nexport function toDocxShape(source: XlsxShapeOptions): DocxShapeOptions;\nexport function toDocxShape(source: PptxShapeOptions | XlsxShapeOptions): DocxShapeOptions {\n const { data, transformation } = toDocxShapeParts(source);\n return { ...data, transformation };\n}\n\n// ── → pptx ──\n\n/** Convert a docx wps shape to a pptx shape. */\nexport function toPptxShape(source: DocxShapeOptions): PptxShapeOptions;\n/** Convert an xlsx shape to a pptx shape. */\nexport function toPptxShape(source: XlsxShapeOptions): PptxShapeOptions;\nexport function toPptxShape(source: DocxShapeOptions | XlsxShapeOptions): PptxShapeOptions {\n if (\"col\" in source) {\n // xlsx (cell-anchored: required col/row markers; pptx shapes have none) → pptx\n const spPr = source.properties;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const result: PptxShapeOptions = {\n ...boxToPptx(box),\n properties: {\n ...pickContent(spPr),\n ...(spPr.geometry !== undefined ? { geometry: spPr.geometry } : {}),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n },\n ...(source.textBody ? { textBody: source.textBody } : {}),\n ...pickNonVisualDrawingProperties(source),\n };\n return result;\n }\n // docx → pptx\n const box = boxFromDocx(source.transformation);\n const textBody = docxToTextBody(source.children, source.bodyProperties);\n const result: PptxShapeOptions = {\n ...boxToPptx(box),\n properties: {\n ...pickContent(source),\n ...(source.geometry !== undefined\n ? { geometry: source.geometry }\n : source.customGeometry !== undefined\n ? { customGeometry: source.customGeometry }\n : {}),\n },\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(source.nonVisualProperties),\n };\n return result;\n}\n\n// ── → xlsx ──\n\n/** Convert a docx wps shape to an xlsx shape. */\nexport function toXlsxShape(source: DocxShapeOptions): XlsxShapeOptions;\n/** Convert a pptx shape to an xlsx shape. */\nexport function toXlsxShape(source: PptxShapeOptions): XlsxShapeOptions;\nexport function toXlsxShape(source: DocxShapeOptions | PptxShapeOptions): XlsxShapeOptions {\n if (\"transformation\" in source) {\n // docx → xlsx\n const box = boxFromDocx(source.transformation);\n const pos = boxToXlsx(box);\n const textBody = docxToTextBody(source.children, source.bodyProperties);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...pickContent(source),\n ...(source.geometry !== undefined\n ? { geometry: source.geometry }\n : source.customGeometry !== undefined\n ? { customGeometry: source.customGeometry }\n : {}),\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n properties: spPr,\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(source.nonVisualProperties),\n };\n }\n // pptx → xlsx\n const paint = source.properties ?? {};\n const box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const pos = boxToXlsx(box);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...pickContent(paint),\n ...(paint.geometry !== undefined ? { geometry: paint.geometry } : {}),\n ...(paint.customGeometry !== undefined ? { customGeometry: paint.customGeometry } : {}),\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n };\n return {\n ...pos.anchor,\n properties: spPr,\n ...(source.textBody ? { textBody: source.textBody } : {}),\n ...pickNonVisualDrawingProperties(source),\n };\n}\n","/**\n * Cross-format connector conversion.\n *\n * Connectors convert between pptx (p:cxnSp) and xlsx (xdr:cxnSp), which both\n * model a connector as a line geometry (spPr) plus optional endpoint glue\n * (startConnection/endConnection), locks, and the shared cNvPr. The base\n * fields (cNvPr name/description/title/hidden + locking + endpoint connections)\n * pass straight through via pickConnectorBase; only positioning (pptx two\n * endpoints ↔ xlsx cell-anchor bounding box, with flip flags encoding draw\n * direction) is adapted per leg — paint travels in `properties` on both sides.\n *\n * docx has no standalone connector element (Word embeds connectors as wps\n * shapes flagged with a connector marker), so converting a connector to docx\n * is a no-op: the function warns and returns undefined so callers can skip it.\n *\n * @module\n */\n\nimport { pickConnectorBase, type UniversalMeasure } from \"@office-open/core\";\nimport type { ShapePropertiesOptions } from \"@office-open/core/drawing\";\nimport type { ConnectorOptions as PptxConnectorOptions } from \"@office-open/pptx\";\nimport type { ConnectorOptions as XlsxConnectorOptions } from \"@office-open/xlsx\";\n\nimport { boxFromXlsxAnchor, boxToXlsx, toEmu } from \"./position\";\nimport type { AbsoluteBox } from \"./position\";\nimport { pickContent } from \"./shape\";\n\n/** pptx two endpoints → absolute box; flip flags encode the draw direction. */\nexport function endpointsToBox(\n x1: number | UniversalMeasure | undefined,\n y1: number | UniversalMeasure | undefined,\n x2: number | UniversalMeasure | undefined,\n y2: number | UniversalMeasure | undefined,\n): AbsoluteBox {\n const ax1 = toEmu(x1);\n const ay1 = toEmu(y1);\n const ax2 = toEmu(x2);\n const ay2 = toEmu(y2);\n return {\n x: Math.min(ax1, ax2),\n y: Math.min(ay1, ay2),\n width: Math.abs(ax2 - ax1),\n height: Math.abs(ay2 - ay1),\n ...(ax2 < ax1 ? { flipHorizontal: true } : {}),\n ...(ay2 < ay1 ? { flipVertical: true } : {}),\n };\n}\n\n/** absolute box → pptx two endpoints (restores direction from flip flags). */\nexport function boxToEndpoints(box: AbsoluteBox): {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n} {\n return {\n x1: box.flipHorizontal ? box.x + box.width : box.x,\n x2: box.flipHorizontal ? box.x : box.x + box.width,\n y1: box.flipVertical ? box.y + box.height : box.y,\n y2: box.flipVertical ? box.y : box.y + box.height,\n };\n}\n\n// ── → docx (no-op) ──\n\n/**\n * docx has no standalone connector; warn and return undefined so callers skip\n * it. (Word embeds connectors as wps shapes; that path is not auto-derived\n * here.)\n */\nexport function toDocxConnector(_source: PptxConnectorOptions | XlsxConnectorOptions): undefined {\n console.warn(\"Connector conversion to docx is unsupported (docx has no standalone connector).\");\n return undefined;\n}\n\n// ── → pptx ──\n\n/** Convert an xlsx connector to a pptx connector. */\nexport function toPptxConnector(source: XlsxConnectorOptions): PptxConnectorOptions {\n const spPr = source.properties;\n const box = boxFromXlsxAnchor(\n source,\n spPr.width,\n spPr.height,\n spPr.rotation,\n spPr.flipHorizontal,\n spPr.flipVertical,\n );\n const { x1, y1, x2, y2 } = boxToEndpoints(box);\n return {\n x1,\n y1,\n x2,\n y2,\n properties: pickContent(spPr),\n // cNvPr + locking + endpoint connections pass straight through.\n ...pickConnectorBase(source),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a pptx connector to an xlsx connector. */\nexport function toXlsxConnector(source: PptxConnectorOptions): XlsxConnectorOptions {\n const box = endpointsToBox(source.x1, source.y1, source.x2, source.y2);\n const pos = boxToXlsx(box);\n const spPr: ShapePropertiesOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n // A connector renders as a line; carry the preset so xlsx emits prstGeom=\"line\".\n geometry: \"line\",\n ...pickContent(source.properties ?? {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n properties: spPr,\n // cNvPr + locking + endpoint connections pass straight through.\n ...pickConnectorBase(source),\n };\n}\n","/**\n * Cross-format group conversion.\n *\n * Groups convert between pptx (p:grpSp), xlsx (xdr:grpSp), and docx (wpg). The\n * group container (bounding box + rotation/flip) round-trips near-losslessly\n * via the absolute-box model (./position); only the xlsx leg loses precise\n * positioning (heuristic cell anchors).\n *\n * The container cNvPr (name/description/title/hidden) passes straight through on\n * every leg — pptx/xlsx via pickGroupBase, docx via its altText bridge — so alt\n * text survives a cross-format copy. Child shapes/connectors carry their own\n * cNvPr through pickNonVisualDrawingProperties (all four fields, not just name).\n *\n * Children recurse through their own converters — shapes via ./shape,\n * connectors via ./connector. docx has no standalone connector and xlsx groups\n * hold only shapes/connectors, so picture/table/chart/... children are dropped\n * with a warning on the legs that cannot host them.\n *\n * @module\n */\n\nimport {\n convertPixelsToEmu,\n parseAngle,\n pickGroupBase,\n pickNonVisualDrawingProperties,\n} from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { ShapePropertiesOptions, GroupTransform2DOptions } from \"@office-open/core/drawing\";\nimport type {\n GroupOptions as DocxGroupOptions,\n GroupChildMediaData,\n MediaDataTransformation,\n ShapeCoreOptions,\n} from \"@office-open/docx\";\nimport { createTransformation } from \"@office-open/docx\";\nimport type {\n GroupOptions as PptxGroupOptions,\n SlideChild,\n ShapeOptions as PptxShapeOptions,\n ConnectorOptions as PptxConnectorOptions,\n} from \"@office-open/pptx\";\nimport type {\n GroupOptions as XlsxGroupOptions,\n GroupShapeChildOptions,\n GroupConnectorChildOptions,\n} from \"@office-open/xlsx\";\n\nimport { boxToEndpoints, endpointsToBox } from \"./connector\";\nimport {\n boxFromPptx,\n boxFromSpPr,\n boxFromXlsxAnchor,\n boxFromDocx,\n boxToPptx,\n boxToXlsx,\n boxToDocx,\n} from \"./position\";\nimport type { AbsoluteBox } from \"./position\";\nimport {\n docxToTextBody,\n pickContent,\n textBodyToDocxChildren,\n toDocxShapeParts,\n toPresetGeometry,\n} from \"./shape\";\n\n// ── container cNvPr bridge ──\n\n/**\n * Build the docx altText (wp:docPr) from the container cNvPr. Only emitted when\n * at least one cNvPr field is authored; name defaults to \"Group\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions without\n * importing that internal type.\n */\nconst altTextFromCnvPr = (\n picked: Partial<NonVisualDrawingPropertiesOptions>,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"Group\", ...picked } };\n};\n\n/**\n * Build a docx child nonVisualProperties object from a picked cNvPr. Only\n * emitted when at least one field is authored; name defaults to `fallbackName`.\n */\nconst docxNonVisualFromCnvPr = (\n picked: Partial<NonVisualDrawingPropertiesOptions>,\n fallbackName: string,\n): { nonVisualProperties: NonVisualDrawingPropertiesOptions } => {\n const name = picked.name ?? fallbackName;\n return { nonVisualProperties: { name, ...picked } };\n};\n\n/** True when a picked cNvPr carries at least one authored field. */\nconst hasCnvPr = (picked: Partial<NonVisualDrawingPropertiesOptions>): boolean =>\n picked.name !== undefined ||\n picked.description !== undefined ||\n picked.title !== undefined ||\n picked.hidden !== undefined;\n\n// ── container helpers ──\n\n/** docx child MediaDataTransformation → absolute box (reads EMUs; falls back to pixels). */\nfunction docxChildMediaToBox(t: MediaDataTransformation): AbsoluteBox {\n const x = t.offset?.emus?.x ?? convertPixelsToEmu(t.offset?.pixels.x ?? 0);\n const y = t.offset?.emus?.y ?? convertPixelsToEmu(t.offset?.pixels.y ?? 0);\n return {\n x,\n y,\n width: t.emus.x,\n height: t.emus.y,\n ...(t.rotation !== undefined ? { rotation: parseAngle(t.rotation) } : {}),\n ...(t.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(t.flipVertical ? { flipVertical: true } : {}),\n };\n}\n\n// ── shape-child spPr bridge ──\n\n/** pptx shape → core spPr (group-child position is absolute). */\nfunction pptxShapeToSpPr(shape: PptxShapeOptions): ShapePropertiesOptions {\n const paint = shape.properties ?? {};\n return {\n x: shape.x,\n y: shape.y,\n width: shape.width,\n height: shape.height,\n ...(shape.rotation !== undefined ? { rotation: shape.rotation } : {}),\n ...(shape.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(paint.geometry !== undefined ? { geometry: paint.geometry } : {}),\n ...(paint.customGeometry !== undefined ? { customGeometry: paint.customGeometry } : {}),\n ...pickContent(paint),\n };\n}\n\n/** core spPr → pptx shape (transform top-level, paint nested in `properties`). */\nfunction spPrToPptxShape(spPr: ShapePropertiesOptions): PptxShapeOptions {\n return {\n x: spPr.x,\n y: spPr.y,\n width: spPr.width,\n height: spPr.height,\n ...(spPr.rotation !== undefined ? { rotation: spPr.rotation } : {}),\n ...(spPr.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(spPr.flipVertical ? { flipVertical: true } : {}),\n properties: {\n ...(spPr.geometry !== undefined ? { geometry: spPr.geometry } : {}),\n ...(spPr.customGeometry !== undefined ? { customGeometry: spPr.customGeometry } : {}),\n ...pickContent(spPr),\n },\n };\n}\n\n/** xlsx group child shape → docx wps core (position lives on the wpg child wrapper). */\nfunction xlsxShapeChildToDocxData(s: GroupShapeChildOptions): ShapeCoreOptions {\n const preset = toPresetGeometry(s.properties.geometry);\n const cnvPr = pickNonVisualDrawingProperties(s);\n return {\n children: s.textBody ? textBodyToDocxChildren(s.textBody) : [],\n ...pickContent(s.properties),\n ...(s.properties.customGeometry !== undefined\n ? { customGeometry: s.properties.customGeometry }\n : {}),\n ...(preset !== undefined ? { geometry: preset } : {}),\n ...(hasCnvPr(cnvPr) ? docxNonVisualFromCnvPr(cnvPr, \"Shape\") : {}),\n };\n}\n\n/** docx wps child → core spPr (absolute position from the child transformation). */\nfunction docxChildToSpPr(data: ShapeCoreOptions, box: AbsoluteBox): ShapePropertiesOptions {\n const out: ShapePropertiesOptions = {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n ...pickContent(data),\n };\n if (data.geometry !== undefined) out.geometry = data.geometry;\n else if (data.customGeometry !== undefined) out.customGeometry = data.customGeometry;\n return out;\n}\n\n/** xlsx group connector child → pptx connector. */\nfunction xlsxConnectorChildToPptx(c: GroupConnectorChildOptions): PptxConnectorOptions {\n const { x1, y1, x2, y2 } = boxToEndpoints(boxFromSpPr(c.properties));\n return {\n x1,\n y1,\n x2,\n y2,\n properties: pickContent(c.properties),\n ...(c.locking ? { locking: c.locking } : {}),\n ...(c.startConnection ? { startConnection: c.startConnection } : {}),\n ...(c.endConnection ? { endConnection: c.endConnection } : {}),\n ...pickNonVisualDrawingProperties(c),\n };\n}\n\n// ── → docx ──\n\n/** Convert a pptx group to a docx wpg group. */\nexport function toDocxGroup(source: PptxGroupOptions): DocxGroupOptions;\n/** Convert an xlsx group to a docx wpg group. */\nexport function toDocxGroup(source: XlsxGroupOptions): DocxGroupOptions;\nexport function toDocxGroup(source: PptxGroupOptions | XlsxGroupOptions): DocxGroupOptions {\n let box: AbsoluteBox;\n let children: GroupChildMediaData[];\n if (\"properties\" in source) {\n const g = source.properties;\n box = boxFromXlsxAnchor(\n source,\n g.width,\n g.height,\n g.rotation,\n g.flipHorizontal,\n g.flipVertical,\n );\n children = xlsxGroupChildrenToDocx(source.shapes, source.connectors);\n } else {\n box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n children = pptxGroupChildrenToDocx(source.children);\n }\n // Container cNvPr → docx altText (wp:docPr).\n return { children, transformation: boxToDocx(box), ...altTextFromCnvPr(pickGroupBase(source)) };\n}\n\nfunction pptxGroupChildrenToDocx(children: SlideChild[] | undefined): GroupChildMediaData[] {\n const out: GroupChildMediaData[] = [];\n for (const child of children ?? []) {\n if (\"shape\" in child) {\n const parts = toDocxShapeParts(child.shape);\n out.push({\n type: \"wps\",\n transformation: createTransformation(parts.transformation),\n data: parts.data,\n });\n } else if (\"connector\" in child) {\n console.warn(\"Connector in group → docx is unsupported; skipped.\");\n } else {\n console.warn(`Unsupported group child → docx (${Object.keys(child)[0]}); skipped.`);\n }\n }\n return out;\n}\n\nfunction xlsxGroupChildrenToDocx(\n shapes: GroupShapeChildOptions[] | undefined,\n connectors: GroupConnectorChildOptions[] | undefined,\n): GroupChildMediaData[] {\n const out: GroupChildMediaData[] = [];\n for (const s of shapes ?? []) {\n out.push({\n type: \"wps\",\n transformation: createTransformation(boxToDocx(boxFromSpPr(s.properties))),\n data: xlsxShapeChildToDocxData(s),\n });\n }\n if (connectors?.length) {\n console.warn(\"Connector in group → docx is unsupported; skipped.\");\n }\n return out;\n}\n\n// ── → pptx ──\n\n/** Convert a docx wpg group to a pptx group. */\nexport function toPptxGroup(source: DocxGroupOptions): PptxGroupOptions;\n/** Convert an xlsx group to a pptx group. */\nexport function toPptxGroup(source: XlsxGroupOptions): PptxGroupOptions;\nexport function toPptxGroup(source: DocxGroupOptions | XlsxGroupOptions): PptxGroupOptions {\n let box: AbsoluteBox;\n let children: SlideChild[];\n // Container cNvPr: docx bridges through altText; xlsx extends BaseGroupOptions.\n const cnvPr =\n \"transformation\" in source\n ? pickNonVisualDrawingProperties(source.altText)\n : pickGroupBase(source);\n if (\"properties\" in source) {\n const g = source.properties;\n box = boxFromXlsxAnchor(\n source,\n g.width,\n g.height,\n g.rotation,\n g.flipHorizontal,\n g.flipVertical,\n );\n children = xlsxGroupChildrenToPptx(source.shapes, source.connectors);\n } else {\n box = boxFromDocx(source.transformation);\n children = docxGroupChildrenToPptx(source.children);\n }\n return { ...boxToPptx(box), children, ...cnvPr };\n}\n\nfunction xlsxGroupChildrenToPptx(\n shapes: GroupShapeChildOptions[] | undefined,\n connectors: GroupConnectorChildOptions[] | undefined,\n): SlideChild[] {\n const out: SlideChild[] = [];\n for (const s of shapes ?? []) {\n const shape = spPrToPptxShape(s.properties);\n if (s.textBody) shape.textBody = s.textBody;\n Object.assign(shape, pickNonVisualDrawingProperties(s));\n out.push({ shape });\n }\n for (const c of connectors ?? []) {\n out.push({ connector: xlsxConnectorChildToPptx(c) });\n }\n return out;\n}\n\nfunction docxGroupChildrenToPptx(children: GroupChildMediaData[] | undefined): SlideChild[] {\n const out: SlideChild[] = [];\n for (const child of children ?? []) {\n if (child.type === \"wps\") {\n const box = docxChildMediaToBox(child.transformation);\n const shape = spPrToPptxShape(docxChildToSpPr(child.data, box));\n const textBody = docxToTextBody(child.data.children, child.data.bodyProperties);\n if (textBody) shape.textBody = textBody;\n Object.assign(shape, pickNonVisualDrawingProperties(child.data.nonVisualProperties));\n out.push({ shape });\n } else {\n console.warn(`Unsupported docx group child → pptx (${child.type}); skipped.`);\n }\n }\n return out;\n}\n\n// ── → xlsx ──\n\n/** Convert a docx wpg group to an xlsx group. */\nexport function toXlsxGroup(source: DocxGroupOptions): XlsxGroupOptions;\n/** Convert a pptx group to an xlsx group. */\nexport function toXlsxGroup(source: PptxGroupOptions): XlsxGroupOptions;\nexport function toXlsxGroup(source: DocxGroupOptions | PptxGroupOptions): XlsxGroupOptions {\n let box: AbsoluteBox;\n let shapes: GroupShapeChildOptions[];\n let connectors: GroupConnectorChildOptions[];\n // Container cNvPr: docx bridges through altText; pptx extends BaseGroupOptions.\n const cnvPr =\n \"transformation\" in source\n ? pickNonVisualDrawingProperties(source.altText)\n : pickGroupBase(source);\n if (\"transformation\" in source) {\n box = boxFromDocx(source.transformation);\n const r = docxGroupChildrenToXlsx(source.children);\n shapes = r.shapes;\n connectors = r.connectors;\n } else {\n box = boxFromPptx(\n source.x,\n source.y,\n source.width,\n source.height,\n source.rotation,\n source.flipHorizontal,\n );\n const r = pptxGroupChildrenToXlsx(source.children);\n shapes = r.shapes;\n connectors = r.connectors;\n }\n const pos = boxToXlsx(box);\n const grpSpPr: GroupTransform2DOptions = {\n x: pos.xfrmX,\n y: pos.xfrmY,\n width: box.width,\n height: box.height,\n ...(box.rotation !== undefined ? { rotation: box.rotation } : {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n ...pos.anchor,\n properties: grpSpPr,\n ...(shapes.length ? { shapes } : {}),\n ...(connectors.length ? { connectors } : {}),\n ...cnvPr,\n };\n}\n\nfunction pptxGroupChildrenToXlsx(children: SlideChild[] | undefined): {\n shapes: GroupShapeChildOptions[];\n connectors: GroupConnectorChildOptions[];\n} {\n const shapes: GroupShapeChildOptions[] = [];\n const connectors: GroupConnectorChildOptions[] = [];\n for (const child of children ?? []) {\n if (\"shape\" in child) {\n const s: GroupShapeChildOptions = {\n properties: pptxShapeToSpPr(child.shape),\n ...(child.shape.textBody ? { textBody: child.shape.textBody } : {}),\n ...pickNonVisualDrawingProperties(child.shape),\n };\n shapes.push(s);\n } else if (\"connector\" in child) {\n connectors.push(pptxConnectorToXlsxChild(child.connector));\n } else {\n console.warn(`Unsupported group child → xlsx (${Object.keys(child)[0]}); skipped.`);\n }\n }\n return { shapes, connectors };\n}\n\nfunction pptxConnectorToXlsxChild(c: PptxConnectorOptions): GroupConnectorChildOptions {\n // Place the connector's endpoint box on spPr.xfrm (no anchor — group children\n // position via spPr). The shared helper encodes direction as flip flags.\n const box = endpointsToBox(c.x1, c.y1, c.x2, c.y2);\n const spPr: ShapePropertiesOptions = {\n x: box.x,\n y: box.y,\n width: box.width,\n height: box.height,\n geometry: \"line\",\n ...pickContent(c.properties ?? {}),\n ...(box.flipHorizontal ? { flipHorizontal: true } : {}),\n ...(box.flipVertical ? { flipVertical: true } : {}),\n };\n return {\n properties: spPr,\n ...(c.locking ? { locking: c.locking } : {}),\n ...(c.startConnection ? { startConnection: c.startConnection } : {}),\n ...(c.endConnection ? { endConnection: c.endConnection } : {}),\n ...pickNonVisualDrawingProperties(c),\n };\n}\n\nfunction docxGroupChildrenToXlsx(children: GroupChildMediaData[] | undefined): {\n shapes: GroupShapeChildOptions[];\n connectors: GroupConnectorChildOptions[];\n} {\n const shapes: GroupShapeChildOptions[] = [];\n const connectors: GroupConnectorChildOptions[] = [];\n for (const child of children ?? []) {\n if (child.type === \"wps\") {\n const box = docxChildMediaToBox(child.transformation);\n const spPr = docxChildToSpPr(child.data, box);\n const textBody = docxToTextBody(child.data.children, child.data.bodyProperties);\n shapes.push({\n properties: spPr,\n ...(textBody ? { textBody } : {}),\n ...pickNonVisualDrawingProperties(child.data.nonVisualProperties),\n });\n } else {\n console.warn(`Unsupported docx group child → xlsx (${child.type}); skipped.`);\n }\n }\n return { shapes, connectors };\n}\n","/**\n * Cross-format table conversion.\n *\n * docx (w:tbl flow) and pptx (a:tbl graphic) share a structural core\n * (rows/cells/span/6-flags/columnWidths/vertical-align) defined in\n * `@office-open/core`'s BaseTableOptions; both packages extend it. The\n * structural fields pass through directly and only the per-package parts need\n * translation:\n * - cell content: docx w:p (SectionChild) ↔ pptx a:p (ParagraphDescriptor),\n * via ./text. docx cell non-paragraph children (nested table/toc/sdt/…)\n * drop (flatten not implemented).\n * - column widths: `number` is the native unit (docx twip, pptx EMU) so it is\n * converted (×635 / ÷635); UniversalMeasure strings pass through (each\n * package's descriptor resolves them).\n * - position: pptx absolute x/y; docx is flow (no position) — lost pptx→docx.\n * - styles (fill/borders/margins): w:/a: domain types differ; only solid fill\n * maps (pptx→docx), the rest is dropped (matches MS Office paste loss).\n * - row height: docx {value,rule} twip ↔ pptx number EMU.\n *\n * xlsx has no visual table object (its sml Table is a data range), so docx/pptx\n * tables restore to worksheet fragments: cell value = first-paragraph plain\n * text, mergeCells = columnSpan/rowSpan, column widths / row heights converted\n * to xlsx units (character width / points). Cell styles are dropped (dxf\n * synthesis is a follow-up). The reverse takes xlsx fragments back to a table.\n *\n * @module\n */\nimport {\n convertEmuToPoints,\n convertEmuToTwip,\n convertPointsToEmu,\n convertPointsToTwip,\n convertToEmu,\n convertToPt,\n convertToTwip,\n convertTwipToEmu,\n} from \"@office-open/core\";\nimport type { ThemeColor } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { ParagraphDescriptorOptions } from \"@office-open/core/drawing\";\nimport type {\n ParagraphOptions,\n SectionChild,\n TableOptions as DocxTableOptions,\n TableCellOptions as DocxTableCellOptions,\n TableRowOptions as DocxTableRowOptions,\n} from \"@office-open/docx\";\nimport type {\n TableOptions as PptxTableOptions,\n TableCellOptions as PptxTableCellOptions,\n TableRowOptions as PptxTableRowOptions,\n} from \"@office-open/pptx\";\nimport type {\n CellOptions as XlsxCellOptions,\n ColumnOptions,\n MergeCellOptions,\n RowOptions as XlsxRowOptions,\n} from \"@office-open/xlsx\";\nimport { columnToLetter, letterToColumn } from \"@office-open/xlsx\";\n\nimport { DEFAULT_COL_EMU } from \"./position\";\nimport { fromDrawingParagraph, toDrawingParagraph } from \"./text\";\n\n/** Heuristic EMU per character of column width (8.43 chars ≈ DEFAULT_COL_EMU). */\nconst EMU_PER_CHAR = DEFAULT_COL_EMU / 8.43;\n\n/** xlsx visual-table restoration: worksheet fragments (rows/merges/columns). */\nexport interface XlsxVisualTable {\n rows: XlsxRowOptions[];\n mergeCells?: MergeCellOptions[];\n columns?: ColumnOptions[];\n}\n\n/** Parse a merge ref (\"A1:D1\") into 0-based row/col corners. */\nfunction parseMergeRef(\n ref: string,\n): { row: number; col: number; rowEnd: number; colEnd: number } | undefined {\n const [from = \"\", to = from] = ref.split(\":\");\n const fa = from.match(/^([A-Z]+)(\\d+)$/);\n const fb = to.match(/^([A-Z]+)(\\d+)$/);\n if (!fa || !fb) return undefined;\n return {\n row: Number(fa[2]) - 1,\n col: letterToColumn(fa[1]) - 1,\n rowEnd: Number(fb[2]) - 1,\n colEnd: letterToColumn(fb[1]) - 1,\n };\n}\n\n// ── unit helpers ──\n// EMU↔twip↔points conversions live in @office-open/core; only the xlsx\n// character-width heuristic (EMU_PER_CHAR) is local to visual restoration.\n\nconst emuToCharWidth = (emu: number): number => emu / EMU_PER_CHAR;\nconst charWidthToEmu = (chars: number): number => chars * EMU_PER_CHAR;\n\n/** docx height value (twip number or UM) → EMU. */\nconst docxHeightToEmu = (v: number | UniversalMeasure): number =>\n typeof v === \"number\" ? convertTwipToEmu(v) : convertToEmu(v);\n/** pptx height value (EMU number or UM) → twip. */\nconst pptxHeightToTwip = (v: number | UniversalMeasure): number =>\n typeof v === \"number\" ? convertEmuToTwip(v) : convertToTwip(v);\n\n/** Convert numeric column widths via `convert`; UM strings pass through. */\nfunction convertColumnWidths(\n widths: (number | string)[] | undefined,\n convert: (n: number) => number,\n): (number | string)[] | undefined {\n if (!widths) return undefined;\n return widths.map((w) => (typeof w === \"number\" ? convert(w) : w));\n}\n\n// ── discriminant ──\n\n/** Structural test: an XlsxVisualTable's first cell lacks docx/pptx markers\n * (children/text/shading), or it carries xlsx-only columns/mergeCells. */\nfunction isXlsxVisual(src: unknown): src is XlsxVisualTable {\n if (typeof src !== \"object\" || src === null) return false;\n const s = src as Record<string, unknown>;\n if (Array.isArray(s.columns) || Array.isArray(s.mergeCells)) return true;\n const firstCell = (s.rows as { cells?: Array<Record<string, unknown>> }[] | undefined)?.[0]\n ?.cells?.[0];\n if (!firstCell) return false;\n return !(\"children\" in firstCell) && !(\"text\" in firstCell) && !(\"shading\" in firstCell);\n}\n\n/** Copy the 6 special-row flags (matching field names across docx/pptx). */\nfunction copyBaseTableFlags<S extends DocxTableOptions | PptxTableOptions>(\n src: S,\n): Pick<\n DocxTableOptions & PptxTableOptions,\n \"firstRow\" | \"lastRow\" | \"firstCol\" | \"lastCol\" | \"bandRow\" | \"bandCol\"\n> {\n return {\n ...(src.firstRow !== undefined ? { firstRow: src.firstRow } : {}),\n ...(src.lastRow !== undefined ? { lastRow: src.lastRow } : {}),\n ...(src.firstCol !== undefined ? { firstCol: src.firstCol } : {}),\n ...(src.lastCol !== undefined ? { lastCol: src.lastCol } : {}),\n ...(src.bandRow !== undefined ? { bandRow: src.bandRow } : {}),\n ...(src.bandCol !== undefined ? { bandCol: src.bandCol } : {}),\n };\n}\n\n// ── cell content bridges ──\n\n/** docx cell (SectionChild[], w:p) → pptx paragraphs (a:p). */\nfunction docxCellToPptxContent(\n cell: DocxTableCellOptions,\n): (ParagraphDescriptorOptions | string)[] {\n const out: (ParagraphDescriptorOptions | string)[] = [];\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") {\n out.push(child);\n } else if (\"paragraph\" in child) {\n const para: ParagraphOptions =\n typeof child.paragraph === \"string\"\n ? { children: [{ text: child.paragraph }] }\n : child.paragraph;\n out.push(toDrawingParagraph(para));\n }\n // nested table/toc/sdt/… → drop\n }\n return out;\n}\n\n/** pptx cell (a:p) → docx SectionChild[] (w:p). */\nfunction pptxCellToDocxChildren(cell: PptxTableCellOptions): SectionChild[] {\n const out: SectionChild[] = [];\n if (cell.text !== undefined) {\n out.push({ paragraph: { children: [{ text: cell.text }] } });\n }\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") {\n out.push({ paragraph: { children: [{ text: child }] } });\n } else {\n out.push({ paragraph: fromDrawingParagraph(child) });\n }\n }\n return out;\n}\n\n/** First-paragraph plain text from a docx cell. */\nfunction docxCellText(cell: DocxTableCellOptions): string | undefined {\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") return child;\n if (\"paragraph\" in child) {\n const para =\n typeof child.paragraph === \"string\"\n ? { children: [{ text: child.paragraph }] }\n : child.paragraph;\n const text = para.children\n ?.map((r) => (typeof r === \"string\" ? r : \"text\" in r ? (r.text ?? \"\") : \"\"))\n .join(\"\");\n if (text) return text;\n }\n }\n return undefined;\n}\n\n/** Plain text from a pptx cell. */\nfunction pptxCellText(cell: PptxTableCellOptions): string | undefined {\n if (cell.text !== undefined) return cell.text;\n for (const child of cell.children ?? []) {\n if (typeof child === \"string\") return child;\n const text = child.children\n ?.map((r) => (typeof r === \"string\" ? r : \"text\" in r ? (r.text ?? \"\") : \"\"))\n .join(\"\");\n if (text) return text;\n }\n return undefined;\n}\n\n/** Map a: scheme color token (ST_SchemeColorVal) → w: themeColor token\n * (ST_ThemeColor). accent1-6 pass through; bg/tx/dk/lt → background/text/\n * dark/light; hlink → hyperlink, folHlink → followedHyperlink. phClr has no\n * w: equivalent (dropped). */\nconst SCHEME_TO_THEME: Record<string, ThemeColor> = {\n bg1: \"background1\",\n tx1: \"text1\",\n bg2: \"background2\",\n tx2: \"text2\",\n dk1: \"dark1\",\n lt1: \"light1\",\n dk2: \"dark2\",\n lt2: \"light2\",\n accent1: \"accent1\",\n accent2: \"accent2\",\n accent3: \"accent3\",\n accent4: \"accent4\",\n accent5: \"accent5\",\n accent6: \"accent6\",\n hlink: \"hyperlink\",\n folHlink: \"followedHyperlink\",\n};\n\n/** pptx FillOptions (a:fill) → docx ShadingProperties (w:shd). RGB hex and\n * RgbColorOptions → `@fill`; SchemeColorOptions → `@themeColor` (token mapped);\n * hsl/system/preset/scRgb/phClr and color transforms → dropped (docx shading\n * is RGB-hex or theme-color only). */\nfunction pptxFillToDocxShading(\n fill: PptxTableCellOptions[\"fill\"],\n): DocxTableCellOptions[\"shading\"] | undefined {\n if (fill === undefined) return undefined;\n if (typeof fill === \"string\") return { fill };\n if (fill.type === \"solid\") {\n if (typeof fill.color === \"string\") return { fill: fill.color };\n if (typeof fill.color === \"object\" && \"value\" in fill.color) {\n const v = fill.color.value;\n if (typeof v === \"string\") {\n return v in SCHEME_TO_THEME ? { themeColor: SCHEME_TO_THEME[v] } : { fill: v };\n }\n }\n return undefined; // hsl/system/preset/scRgb → drop\n }\n return undefined; // gradient/pattern/blip → drop\n}\n\n/** xlsx cell value → plain text. Primitives stringify directly; Date → ISO;\n * RichTextOptions falls back to JSON (rich-text run extraction is a follow-up). */\nfunction cellValueToText(value: XlsxCellOptions[\"value\"]): string | undefined {\n if (value === null || value === undefined) return undefined;\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (value instanceof Date) return value.toISOString();\n return JSON.stringify(value);\n}\n\n// ── → docx ──\n\n/** Convert a pptx table to a docx table. */\nexport function toDocxTable(source: PptxTableOptions): DocxTableOptions;\n/** Convert xlsx visual-table fragments back to a docx table. */\nexport function toDocxTable(source: XlsxVisualTable): DocxTableOptions;\nexport function toDocxTable(source: PptxTableOptions | XlsxVisualTable): DocxTableOptions {\n return isXlsxVisual(source) ? xlsxToDocx(source) : pptxToDocx(source);\n}\n\nfunction pptxToDocx(src: PptxTableOptions): DocxTableOptions {\n const rows: DocxTableRowOptions[] = src.rows.map((row) => ({\n ...(row.height !== undefined ? { height: { value: pptxHeightToTwip(row.height) } } : {}),\n cells: row.cells.map((cell): DocxTableCellOptions => {\n const shading = pptxFillToDocxShading(cell.fill);\n return {\n children: pptxCellToDocxChildren(cell),\n ...(cell.columnSpan !== undefined ? { columnSpan: cell.columnSpan } : {}),\n ...(cell.rowSpan !== undefined ? { rowSpan: cell.rowSpan } : {}),\n ...(cell.verticalAlign !== undefined\n ? {\n verticalAlign:\n cell.verticalAlign === \"justify\" || cell.verticalAlign === \"distribute\"\n ? \"center\"\n : cell.verticalAlign,\n }\n : {}),\n ...(shading ? { shading } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columnWidths\n ? { columnWidths: convertColumnWidths(src.columnWidths, convertEmuToTwip) as number[] }\n : {}),\n ...copyBaseTableFlags(src),\n };\n}\n\n/** Index parsed merges by anchor cell (\"row:col\") for O(1) lookup per cell. */\ntype ParsedMergeRef = NonNullable<ReturnType<typeof parseMergeRef>>;\n\nfunction mergeIndex(merges: ParsedMergeRef[]): Map<string, ParsedMergeRef> {\n const index = new Map<string, ParsedMergeRef>();\n for (const m of merges) index.set(`${m.row}:${m.col}`, m);\n return index;\n}\n\nfunction xlsxToDocx(src: XlsxVisualTable): DocxTableOptions {\n const merges = mergeIndex(\n (src.mergeCells ?? [])\n .map((m) => parseMergeRef(m.ref))\n .filter((m): m is NonNullable<typeof m> => m !== undefined),\n );\n const rows: DocxTableRowOptions[] = src.rows.map((row, ri) => ({\n ...(row.height !== undefined\n ? { height: { value: convertPointsToTwip(convertToPt(row.height)) } }\n : {}),\n cells: (row.cells ?? []).map((cell, ci): DocxTableCellOptions => {\n const merge = merges.get(`${ri}:${ci}`);\n const columnSpan = merge ? merge.colEnd - merge.col + 1 : undefined;\n const rowSpan = merge ? merge.rowEnd - merge.row + 1 : undefined;\n const text = cellValueToText(cell.value);\n return {\n children: text !== undefined ? [{ paragraph: { children: [{ text }] } }] : [],\n ...(columnSpan && columnSpan > 1 ? { columnSpan } : {}),\n ...(rowSpan && rowSpan > 1 ? { rowSpan } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columns\n ? {\n columnWidths: src.columns.map((c) => convertEmuToTwip(charWidthToEmu(c.width ?? 8.43))),\n }\n : {}),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx table to a pptx table. */\nexport function toPptxTable(source: DocxTableOptions): PptxTableOptions;\n/** Convert xlsx visual-table fragments back to a pptx table. */\nexport function toPptxTable(source: XlsxVisualTable): PptxTableOptions;\nexport function toPptxTable(source: DocxTableOptions | XlsxVisualTable): PptxTableOptions {\n return isXlsxVisual(source) ? xlsxToPptx(source) : docxToPptx(source);\n}\n\nfunction docxToPptx(src: DocxTableOptions): PptxTableOptions {\n const rows: PptxTableRowOptions[] = src.rows.map((row) => {\n if (!(\"cells\" in row)) return { cells: [] }; // sdt/customXml row → flatten\n return {\n ...(row.height ? { height: docxHeightToEmu(row.height.value) } : {}),\n cells: row.cells.map((cell): PptxTableCellOptions => {\n if (!(\"children\" in cell)) return { children: [] }; // sdt/customXml cell → flatten\n return {\n children: docxCellToPptxContent(cell),\n ...(cell.columnSpan !== undefined ? { columnSpan: cell.columnSpan } : {}),\n ...(cell.rowSpan !== undefined ? { rowSpan: cell.rowSpan } : {}),\n ...(cell.verticalAlign !== undefined ? { verticalAlign: cell.verticalAlign } : {}),\n };\n }),\n };\n });\n return {\n rows,\n ...(src.columnWidths\n ? { columnWidths: convertColumnWidths(src.columnWidths, convertTwipToEmu) as number[] }\n : {}),\n ...copyBaseTableFlags(src),\n };\n}\n\nfunction xlsxToPptx(src: XlsxVisualTable): PptxTableOptions {\n const merges = mergeIndex(\n (src.mergeCells ?? [])\n .map((m) => parseMergeRef(m.ref))\n .filter((m): m is NonNullable<typeof m> => m !== undefined),\n );\n const rows: PptxTableRowOptions[] = src.rows.map((row, ri) => ({\n ...(row.height !== undefined ? { height: convertPointsToEmu(convertToPt(row.height)) } : {}),\n cells: (row.cells ?? []).map((cell, ci): PptxTableCellOptions => {\n const merge = merges.get(`${ri}:${ci}`);\n const columnSpan = merge ? merge.colEnd - merge.col + 1 : undefined;\n const rowSpan = merge ? merge.rowEnd - merge.row + 1 : undefined;\n const text = cellValueToText(cell.value);\n return {\n ...(text !== undefined ? { text } : {}),\n ...(columnSpan && columnSpan > 1 ? { columnSpan } : {}),\n ...(rowSpan && rowSpan > 1 ? { rowSpan } : {}),\n };\n }),\n }));\n return {\n rows,\n ...(src.columns\n ? { columnWidths: src.columns.map((c) => Math.round(charWidthToEmu(c.width ?? 8.43))) }\n : {}),\n };\n}\n\n// ── → xlsx ──\n\n/** Convert a docx table to xlsx worksheet fragments (visual restoration). */\nexport function toXlsxTable(source: DocxTableOptions): XlsxVisualTable;\n/** Convert a pptx table to xlsx worksheet fragments (visual restoration). */\nexport function toXlsxTable(source: PptxTableOptions): XlsxVisualTable;\nexport function toXlsxTable(source: DocxTableOptions | PptxTableOptions): XlsxVisualTable {\n return isDocxTable(source) ? docxToXlsx(source) : pptxToXlsx(source);\n}\n\n/** docx vs pptx: both extend BaseTableOptions so top-level fields mostly overlap.\n * Decide by content shape — docx wraps cell content as SectionChild\n * ({ paragraph | table | toc | … }), pptx stores flat a:p paragraphs or a\n * `text` shorthand — and by domain-only keys (docx w:shd/float/style; pptx\n * a:fill/tableStyleId). `width` overlaps (docx TableWidthProperties vs pptx\n * number) so it is intentionally not used. */\nfunction isDocxTable(src: unknown): src is DocxTableOptions {\n if (typeof src !== \"object\" || src === null) return false;\n const s = src as Record<string, unknown>;\n if (\"tableStyleId\" in s) return false; // pptx-only\n if (\"style\" in s || \"float\" in s || \"visuallyRightToLeft\" in s || \"indent\" in s) return true; // docx-only\n const rows = s.rows as Array<Record<string, unknown>> | undefined;\n if (!Array.isArray(rows)) return false;\n for (const row of rows) {\n if (!(\"cells\" in row) || !Array.isArray(row.cells)) continue;\n for (const cell of row.cells as Array<Record<string, unknown>>) {\n if (\"shading\" in cell) return true; // docx w:shd\n if (\"text\" in cell || \"fill\" in cell) return false; // pptx a:fill / shorthand\n const child = (cell.children as Array<Record<string, unknown>> | undefined)?.[0];\n if (child && typeof child === \"object\") {\n return (\n \"paragraph\" in child ||\n \"table\" in child ||\n \"toc\" in child ||\n \"sdt\" in child ||\n \"customXml\" in child ||\n \"altChunk\" in child\n );\n }\n }\n }\n return false;\n}\n\nfunction docxToXlsx(src: DocxTableOptions): XlsxVisualTable {\n const mergeCells: MergeCellOptions[] = [];\n const rows: XlsxRowOptions[] = src.rows.map((row, ri) => {\n if (!(\"cells\" in row)) return { cells: [] };\n let ci = 0;\n const cells: XlsxCellOptions[] = row.cells.map((cell): XlsxCellOptions => {\n if (!(\"children\" in cell)) {\n ci += 1;\n return {};\n }\n const span = cell.columnSpan ?? 1;\n const rspan = cell.rowSpan ?? 1;\n if (span > 1 || rspan > 1) {\n mergeCells.push({\n ref: `${columnToLetter(ci + 1)}${ri + 1}:${columnToLetter(ci + span)}${ri + rspan}`,\n });\n }\n const value = docxCellText(cell);\n ci += span;\n return value !== undefined ? { value } : {};\n });\n const xrow: XlsxRowOptions = { cells };\n if (row.height) xrow.height = convertEmuToPoints(docxHeightToEmu(row.height.value));\n return xrow;\n });\n const columns: ColumnOptions[] | undefined = src.columnWidths\n ? src.columnWidths.map((w, i) => ({\n min: i + 1,\n max: i + 1,\n width: typeof w === \"number\" ? emuToCharWidth(convertTwipToEmu(w)) : undefined,\n }))\n : undefined;\n return { rows, ...(mergeCells.length ? { mergeCells } : {}), ...(columns ? { columns } : {}) };\n}\n\nfunction pptxToXlsx(src: PptxTableOptions): XlsxVisualTable {\n const mergeCells: MergeCellOptions[] = [];\n const rows: XlsxRowOptions[] = src.rows.map((row, ri) => {\n let ci = 0;\n const cells: XlsxCellOptions[] = row.cells.map((cell): XlsxCellOptions => {\n const span = cell.columnSpan ?? 1;\n const rspan = cell.rowSpan ?? 1;\n if (span > 1 || rspan > 1) {\n mergeCells.push({\n ref: `${columnToLetter(ci + 1)}${ri + 1}:${columnToLetter(ci + span)}${ri + rspan}`,\n });\n }\n const value = pptxCellText(cell);\n ci += span;\n return value !== undefined ? { value } : {};\n });\n const xrow: XlsxRowOptions = { cells };\n if (row.height !== undefined)\n xrow.height = convertEmuToPoints(\n typeof row.height === \"number\" ? row.height : convertToEmu(row.height),\n );\n return xrow;\n });\n const columns: ColumnOptions[] | undefined = src.columnWidths\n ? src.columnWidths.map((w, i) => ({\n min: i + 1,\n max: i + 1,\n width: typeof w === \"number\" ? emuToCharWidth(w) : undefined,\n }))\n : undefined;\n return { rows, ...(mergeCells.length ? { mergeCells } : {}), ...(columns ? { columns } : {}) };\n}\n","/**\n * Cross-format SmartArt conversion (docx ↔ pptx).\n *\n * SmartArt (diagrams) is isomorphic between docx and pptx: both store the data\n * as a core TreeNode tree (docx wraps it in data.nodes; pptx takes nodes\n * directly), reference the same built-in layout/style/color by ID, and anchor\n * via an absolute EMU bounding box (pptx top-level x/y/w/h ↔ docx\n * MediaTransformation). xlsx has no diagram part, so it does not participate.\n *\n * Position maps through the shared position helpers; docx floating positioning\n * is dropped on the pptx leg (no equivalent) and pptx produces an inline\n * transformation (like a picture) on the docx leg. The cNvPr fields\n * (name/description/title/hidden) pass straight through via\n * pickNonVisualDrawingProperties so alt text survives a cross-format copy,\n * mirroring the picture converter.\n *\n * @module\n */\nimport { pickNonVisualDrawingProperties } from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions } from \"@office-open/core\";\nimport type { TreeNode } from \"@office-open/core/smartart\";\nimport type { SmartArtOptions as DocxSmartArt } from \"@office-open/docx\";\nimport type { SmartArtOptions as PptxSmartArt } from \"@office-open/pptx\";\n\nimport { boxFromDocx, boxFromPptx, boxToPptx } from \"./position\";\n\n// SmartArtNode (docx) and TreeNode (core) are structurally identical trees.\n// Map recursively since docx children are mutable and core's are readonly.\nconst toTreeNodes = (nodes: DocxSmartArt[\"nodes\"]): TreeNode[] =>\n nodes.map((n) => ({\n text: n.text,\n ...(n.children ? { children: toTreeNodes(n.children) } : {}),\n }));\n\nconst toDocxNodes = (nodes: TreeNode[]): DocxSmartArt[\"nodes\"] =>\n nodes.map((n) => ({\n text: n.text,\n ...(n.children ? { children: toDocxNodes([...n.children]) } : {}),\n }));\n\n/**\n * Build the docx altText (wp:docPr) from the shared cNvPr. Only emitted when at\n * least one cNvPr field is authored; name defaults to \"SmartArt\" since docx\n * requires it. Structurally compatible with docx's DocPropertiesOptions.\n */\nconst altTextFromCnvPr = (\n cNvPr: NonVisualDrawingPropertiesOptions,\n): { altText?: NonVisualDrawingPropertiesOptions & { name: string } } => {\n const picked = pickNonVisualDrawingProperties(cNvPr);\n if (\n picked.name === undefined &&\n picked.description === undefined &&\n picked.title === undefined &&\n picked.hidden === undefined\n ) {\n return {};\n }\n return { altText: { name: picked.name ?? \"SmartArt\", ...picked } };\n};\n\n// ── → docx ──\n\n/** Convert a pptx SmartArt to a docx inline diagram. */\nexport function toDocxSmartArt(source: PptxSmartArt): DocxSmartArt {\n const box = boxFromPptx(source.x, source.y, source.width, source.height);\n return {\n nodes: toDocxNodes(source.nodes),\n transformation: {\n width: box.width,\n height: box.height,\n ...(source.x !== undefined || source.y !== undefined\n ? { offset: { left: box.x, top: box.y } }\n : {}),\n },\n ...altTextFromCnvPr(source),\n ...(source.layout ? { layout: source.layout } : {}),\n ...(source.style ? { style: source.style } : {}),\n ...(source.color ? { color: source.color } : {}),\n };\n}\n\n// ── → pptx ──\n\n/** Convert a docx SmartArt to a pptx diagram (floating positioning is dropped). */\nexport function toPptxSmartArt(source: DocxSmartArt): PptxSmartArt {\n const box = boxFromDocx(source.transformation);\n const pos = boxToPptx(box);\n return {\n nodes: toTreeNodes(source.nodes),\n x: pos.x,\n y: pos.y,\n width: pos.width,\n height: pos.height,\n ...pickNonVisualDrawingProperties(source.altText),\n ...(source.layout ? { layout: source.layout } : {}),\n ...(source.style ? { style: source.style } : {}),\n ...(source.color ? { color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