{"version":3,"file":"index.mjs","names":["NS","SW_REF","sx","buildXml","stringifyXml","createEffectList","coreParse","imageTypeFromPath","coreImageTypeFromPath","parse","imageTypeFromPath","stringify","stringify","chartSpaceDesc","parse","stringify","imageTypeFromPath","pptxCtx","createDataModel","parse","stringify","Media","stringifyXml","NS","NS","encoder","Relationships","Relationships","NS","stringifyXml","parseXml","stringifyXml","stringifyXml","parsePresentation","themeDesc","themeOverrideDesc","encoder","Relationships","ChartCollection","SmartArtCollection","encoder"],"sources":["../src/shared/constants.ts","../src/parts/slide-layout.ts","../src/parts/notes-master.ts","../src/parts/handout-master.ts","../src/parts/notes-slide.ts","../src/parts/slide/c-sld.ts","../src/shared/shape/shape.ts","../src/shared/placeholder.ts","../src/shared/animation/timing.ts","../src/parts/descriptors/animation.ts","../src/parts/descriptors/background.ts","../src/parts/descriptors/graphic-frame.ts","../src/shared/media/image-type.ts","../src/parts/descriptors/shape.ts","../src/parts/descriptors/chart.ts","../src/parts/descriptors/group.ts","../src/parts/descriptors/line.ts","../src/parts/descriptors/locked-canvas.ts","../src/parts/descriptors/media.ts","../src/parts/descriptors/ole.ts","../src/parts/descriptors/smartart.ts","../src/parts/descriptors/table.ts","../src/parts/descriptors/bridge.ts","../src/parts/descriptors/color-map-override.ts","../src/shared/transition.ts","../src/shared/header-footer.ts","../src/context.ts","../src/parts/background.ts","../src/parts/slide-master.ts","../src/parts/descriptors/slide-master.ts","../src/parts/descriptors/handout-master.ts","../src/parts/descriptors/notes-master.ts","../src/compile/shared.ts","../src/compile/masters.ts","../src/compile/slides.ts","../src/parts/descriptors/slide.ts","../src/parts/descriptors/slide-layout.ts","../src/parts/descriptors/comments.ts","../src/parts/presentation-properties.ts","../src/parts/descriptors/presentation-properties.ts","../src/shared/media/media.ts","../src/parts/descriptors/notes-slide.ts","../src/parts/descriptors/presentation.ts","../src/parts/descriptors/table-styles.ts","../src/parts/view-properties.ts","../src/parts/descriptors/view-properties.ts","../src/parse.ts","../src/patch.ts","../src/parts/descriptors/slide-sync.ts","../src/compile/parts.ts","../src/compiler.ts","../src/generate.ts"],"sourcesContent":["/**\n * PPTX-specific OOXML constants.\n *\n * Text/outline/shadow/color-mapping defaults live in core DrawingML; this\n * module keeps only PPTX-specific shape-tree constants.\n *\n * @module\n */\n\n// ── Shape tree defaults (p:spTree) ──\n\n/** Empty shape tree header: nvGrpSpPr + grpSpPr with zero-offset transform */\nexport const SP_TREE_HEADER =\n  '<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>' +\n  '<p:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/>' +\n  '<a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"0\" cy=\"0\"/></a:xfrm></p:grpSpPr>';\n","import { convertToEmu } from \"@office-open/core\";\nimport type { MasterPlaceholderPosition } from \"@parts/slide-master\";\nimport type { LayoutDefinition } from \"@shared/file\";\n\n/** Slide layout family (ST_SlideLayoutType). */\nexport type SlideLayoutType =\n  | \"blank\"\n  | \"title\"\n  | \"text\"\n  | \"twoColumnText\"\n  | \"titleOnly\"\n  | \"object\"\n  | \"sectionHeader\"\n  | \"chart\"\n  | \"table\"\n  | \"clipArtAndText\"\n  | \"pictureText\"\n  | \"twoObjects\"\n  | \"twoTextAndTwoObjects\"\n  | \"objectAndText\"\n  | \"verticalText\"\n  | \"verticalTitleAndText\";\n\nexport const NS = `xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"`;\n\nimport { SP_TREE_HEADER } from \"@shared/constants\";\n\n// 16:9 reference slide width\nconst SW_REF = 12192000;\nconst sx = (refX: number, sw: number) => Math.round((refX * sw) / SW_REF);\n\n// Convert a placeholder position (number=EMU | UniversalMeasure) to EMU off/ext.\nconst toEmuPos = (pos: MasterPlaceholderPosition) => ({\n  x: convertToEmu(pos.x),\n  y: convertToEmu(pos.y),\n  cx: convertToEmu(pos.width),\n  cy: convertToEmu(pos.height),\n});\n\n// ── Placeholder XML builders ──\n\n// No xfrm — inherited from master\nfunction dtPlaceholder(id: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Date Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"dt\" sz=\"half\" idx=\"10\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:fld id=\"{5BCAD085-E8A6-8845-BD4E-CB4CCA059FC4}\" type=\"datetimeFigureOut\"><a:rPr lang=\"en-US\" smtClean=\"0\"/><a:t>1/27/13</a:t></a:fld><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction ftrPlaceholder(id: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Footer Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"ftr\" sz=\"quarter\" idx=\"11\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction sldNumPlaceholder(id: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Slide Number Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldNum\" sz=\"quarter\" idx=\"12\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:fld id=\"{C1FF6DA9-008F-8B48-92A6-B652298478BF}\" type=\"slidenum\"><a:rPr lang=\"en-US\" smtClean=\"0\"/><a:t>‹#›</a:t></a:fld><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// title — no idx, no xfrm (inherited)\nfunction titlePlaceholder(id: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Title 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"title\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Body (generic) idx, no xfrm (inherited)\nfunction bodyPlaceholder(id: number, idx: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Content Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Body with xfrm (positioned)\nfunction bodyPlaceholderAt(\n  id: number,\n  idx: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Content Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Body with explicit type=\"body\" and xfrm\nfunction typedBodyPlaceholder(\n  id: number,\n  idx: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n  sz?: \"half\" | \"quarter\",\n  orient?: \"vert\",\n): string {\n  const szAttr = sz ? ` sz=\"${sz}\"` : \"\";\n  const orientAttr = orient ? ` orient=\"${orient}\"` : \"\";\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Text Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"body\"${szAttr}${orientAttr} idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Title with xfrm\nfunction titlePlaceholderAt(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n  orient?: \"vert\",\n): string {\n  const orientAttr = orient ? ` orient=\"${orient}\"` : \"\";\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Title 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"title\"${orientAttr}/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// ctrTitle — centered title for title layout\nfunction ctrTitlePlaceholder(id: number, x: number, y: number, cx: number, cy: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Title 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"ctrTitle\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr anchor=\"b\"/><a:lstStyle><a:lvl1pPr algn=\"ctr\"><a:defRPr sz=\"6000\"/></a:lvl1pPr></a:lstStyle><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// subTitle for title layout\nfunction subTitlePlaceholder(id: number, x: number, y: number, cx: number, cy: number): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Subtitle 2\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"subTitle\" idx=\"1\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle><a:lvl1pPr marL=\"0\" indent=\"0\" algn=\"ctr\"><a:buNone/><a:defRPr sz=\"2400\"/></a:lvl1pPr></a:lstStyle><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Pic placeholder\nfunction picPlaceholder(\n  id: number,\n  idx: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Picture Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"pic\" idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// Typed content placeholder (clipArt/chart/tbl) with xfrm\nfunction typedContentPlaceholder(\n  id: number,\n  type: \"clipArt\" | \"chart\" | \"tbl\",\n  idx: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n  sz?: \"half\" | \"quarter\",\n): string {\n  const label = type === \"clipArt\" ? \"Clip Art\" : type === \"chart\" ? \"Chart\" : \"Table\";\n  const szAttr = sz ? ` sz=\"${sz}\"` : \"\";\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"${label} Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"${type}\"${szAttr} idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\n// ── Layout definitions (16:9 reference positions) ──\n\ninterface LayoutDef {\n  type: SlideLayoutType;\n  name: string;\n  buildShapes: (sw: number) => string;\n}\n\nconst LAYOUT_DEFS: Record<SlideLayoutType, LayoutDef> = {\n  // 1. title — ctrTitle + subTitle\n  title: {\n    type: \"title\",\n    name: \"Title Slide\",\n    buildShapes: (sw) =>\n      ctrTitlePlaceholder(2, sx(1524000, sw), 1122363, sx(9144000, sw), 2387600) +\n      subTitlePlaceholder(3, sx(1524000, sw), 3602038, sx(9144000, sw), 1655762),\n  },\n  // 2. obj — title + body (generic content)\n  object: {\n    type: \"object\",\n    name: \"Title and Content\",\n    buildShapes: () => titlePlaceholder(2) + bodyPlaceholder(3, 1),\n  },\n  // 3. secHead — title + body (both positioned)\n  sectionHeader: {\n    type: \"sectionHeader\",\n    name: \"Section Header\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(831850, sw), 1709738, sx(10515600, sw), 2852737) +\n      typedBodyPlaceholder(3, 1, sx(831850, sw), 4589463, sx(10515600, sw), 1500187),\n  },\n  // 4. twoObj — title + 2 body columns\n  twoObjects: {\n    type: \"twoObjects\",\n    name: \"Two Content\",\n    buildShapes: (sw) =>\n      titlePlaceholder(2) +\n      bodyPlaceholderAt(3, 1, sx(838200, sw), 1825625, sx(5181600, sw), 4351338) +\n      bodyPlaceholderAt(4, 2, sx(6172200, sw), 1825625, sx(5181600, sw), 4351338),\n  },\n  // 5. twoTxTwoObj — title + 4 quadrants (2 text, 2 content)\n  twoTextAndTwoObjects: {\n    type: \"twoTextAndTwoObjects\",\n    name: \"Comparison\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(839788, sw), 365125, sx(10515600, sw), 1325563) +\n      typedBodyPlaceholder(3, 1, sx(839788, sw), 1681163, sx(5157787, sw), 823912) +\n      bodyPlaceholderAt(4, 2, sx(839788, sw), 2505075, sx(5157787, sw), 3684588) +\n      typedBodyPlaceholder(5, 3, sx(6172200, sw), 1681163, sx(5183188, sw), 823912) +\n      bodyPlaceholderAt(6, 4, sx(6172200, sw), 2505075, sx(5183188, sw), 3684588),\n  },\n  // 6. titleOnly — title only\n  titleOnly: {\n    type: \"titleOnly\",\n    name: \"Title Only\",\n    buildShapes: () => titlePlaceholder(2),\n  },\n  // 7. blank — no content placeholders\n  blank: {\n    type: \"blank\",\n    name: \"Blank\",\n    buildShapes: () => \"\",\n  },\n  // 8. objTx — title + body + text (object and text)\n  objectAndText: {\n    type: \"objectAndText\",\n    name: \"Content with Caption\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(839788, sw), 457200, sx(3932237, sw), 1600200) +\n      bodyPlaceholderAt(3, 1, sx(5183188, sw), 987425, sx(6172200, sw), 4873625) +\n      typedBodyPlaceholder(4, 2, sx(839788, sw), 2057400, sx(3932237, sw), 3811588),\n  },\n  // 9. picTx — pic on top, title and text caption below\n  pictureText: {\n    type: \"pictureText\",\n    name: \"Picture with Caption\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(2389717, sw), 4800600, sx(7315200, sw), 566738) +\n      picPlaceholder(3, 1, sx(2389717, sw), 612775, sx(7315200, sw), 4114800) +\n      typedBodyPlaceholder(4, 2, sx(2389717, sw), 5367338, sx(7315200, sw), 804862, \"half\"),\n  },\n  // 10. clipArtAndTx — full-width title, clip art left, text right\n  clipArtAndText: {\n    type: \"clipArtAndText\",\n    name: \"Title, Clip Art and Text\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(1534584, sw), 617538, sx(10390716, sw), 1143000) +\n      typedContentPlaceholder(\n        3,\n        \"clipArt\",\n        1,\n        sx(1576917, sw),\n        2017713,\n        sx(5080000, sw),\n        4114800,\n        \"half\",\n      ) +\n      typedBodyPlaceholder(4, 2, sx(6860117, sw), 2017713, sx(5080000, sw), 4114800, \"half\"),\n  },\n  // 11. vertTx — title + body (vertical text)\n  verticalText: {\n    type: \"verticalText\",\n    name: \"Vertical Text\",\n    buildShapes: () =>\n      titlePlaceholder(2) +\n      `<p:sp><p:nvSpPr><p:cNvPr id=\"3\" name=\"Text Placeholder 2\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"body\" orient=\"vert\" idx=\"1\"/></p:nvPr></p:nvSpPr><p:spPr/><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`,\n  },\n  // 12. vertTitleAndTx — vertical title + body\n  verticalTitleAndText: {\n    type: \"verticalTitleAndText\",\n    name: \"Vertical Title and Text\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(8724900, sw), 365125, sx(2628900, sw), 5811838, \"vert\") +\n      typedBodyPlaceholder(\n        3,\n        1,\n        sx(838200, sw),\n        365125,\n        sx(7734300, sw),\n        5811838,\n        undefined,\n        \"vert\",\n      ),\n  },\n  // Aliases / simplified versions\n  text: {\n    type: \"text\",\n    name: \"Title and Text\",\n    buildShapes: () => titlePlaceholder(2) + bodyPlaceholder(3, 1),\n  },\n  chart: {\n    type: \"chart\",\n    name: \"Title and Chart\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(1534584, sw), 617538, sx(10390716, sw), 1143000) +\n      typedContentPlaceholder(3, \"chart\", 1, sx(1576917, sw), 2017713, sx(10363200, sw), 4114800),\n  },\n  table: {\n    type: \"table\",\n    name: \"Title and Table\",\n    buildShapes: (sw) =>\n      titlePlaceholderAt(2, sx(1534584, sw), 617538, sx(10390716, sw), 1143000) +\n      typedContentPlaceholder(3, \"tbl\", 1, sx(1576917, sw), 2017713, sx(10363200, sw), 4114800),\n  },\n  twoColumnText: {\n    type: \"twoColumnText\",\n    name: \"Two Content\",\n    buildShapes: (sw) =>\n      titlePlaceholder(2) +\n      bodyPlaceholderAt(3, 1, sx(838200, sw), 1825625, sx(5181600, sw), 4351338) +\n      bodyPlaceholderAt(4, 2, sx(6172200, sw), 1825625, sx(5181600, sw), 4351338),\n  },\n};\n\nexport function buildLayoutXml(layoutType: SlideLayoutType, slideWidth: number = SW_REF): string {\n  // LayoutDefinition.type accepts any ST_SlideLayoutType string, so a parsed\n  // layout may carry a type we model no shapes for — fall back to blank.\n  const def =\n    (LAYOUT_DEFS as Record<string, LayoutDef | undefined>)[layoutType] ?? LAYOUT_DEFS.blank;\n  const contentShapes = def.buildShapes(slideWidth);\n  // Count content shapes to determine starting ID for footer placeholders\n  const contentCount = contentShapes ? (contentShapes.match(/<p:sp>/g) || []).length : 0;\n  const footerStartId = 2 + contentCount;\n\n  const footerShapes =\n    dtPlaceholder(footerStartId) +\n    ftrPlaceholder(footerStartId + 1) +\n    sldNumPlaceholder(footerStartId + 2);\n\n  return `<p:sldLayout ${NS} type=\"${layoutType}\" preserve=\"1\"><p:cSld name=\"${def.name}\"><p:spTree>${SP_TREE_HEADER}${contentShapes}${footerShapes}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sldLayout>`;\n}\n\n// ── Custom layout builder ──\n\nfunction positionedTitlePlaceholder(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Title 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"title\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction positionedSubtitlePlaceholder(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Subtitle 2\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"subTitle\" idx=\"1\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction positionedBodyPlaceholder(\n  id: number,\n  idx: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Content Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph idx=\"${idx}\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction positionedDatePlaceholder(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Date Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"dt\" sz=\"half\" idx=\"10\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:fld id=\"{5BCAD085-E8A6-8845-BD4E-CB4CCA059FC4}\" type=\"datetimeFigureOut\"><a:rPr lang=\"en-US\" smtClean=\"0\"/><a:t>1/27/13</a:t></a:fld><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction positionedFooterPlaceholder(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Footer Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"ftr\" sz=\"quarter\" idx=\"11\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nfunction positionedSldNumPlaceholder(\n  id: number,\n  x: number,\n  y: number,\n  cx: number,\n  cy: number,\n): string {\n  return `<p:sp><p:nvSpPr><p:cNvPr id=\"${id}\" name=\"Slide Number Placeholder ${id - 1}\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldNum\" sz=\"quarter\" idx=\"12\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:fld id=\"{C1FF6DA9-008F-8B48-92A6-B652298478BF}\" type=\"slidenum\"><a:rPr lang=\"en-US\" smtClean=\"0\"/><a:t>‹#›</a:t></a:fld><a:endParaRPr lang=\"en-US\"/></a:p></p:txBody></p:sp>`;\n}\n\nexport function buildCustomLayoutXml(def: LayoutDefinition): string {\n  const ph = def.placeholders ?? {};\n  const displayName =\n    def.name ?? LAYOUT_DEFS[def.type as SlideLayoutType]?.name ?? def.type ?? \"Custom\";\n\n  const shapes: string[] = [];\n  let nextId = 2;\n\n  // Content placeholders\n  if (ph.title !== false) {\n    const titlePos = ph.title ? toEmuPos(ph.title) : null;\n    if (titlePos) {\n      shapes.push(\n        positionedTitlePlaceholder(nextId++, titlePos.x, titlePos.y, titlePos.cx, titlePos.cy),\n      );\n    } else {\n      shapes.push(titlePlaceholder(nextId++));\n    }\n  }\n\n  if (ph.subtitle !== false && ph.subtitle !== undefined) {\n    const subPos = toEmuPos(ph.subtitle);\n    shapes.push(positionedSubtitlePlaceholder(nextId++, subPos.x, subPos.y, subPos.cx, subPos.cy));\n  }\n\n  if (ph.body !== false && ph.body !== undefined) {\n    const bodyPos = ph.body ? toEmuPos(ph.body) : null;\n    if (bodyPos) {\n      shapes.push(\n        positionedBodyPlaceholder(nextId++, 1, bodyPos.x, bodyPos.y, bodyPos.cx, bodyPos.cy),\n      );\n    } else {\n      shapes.push(bodyPlaceholder(nextId++, 1));\n    }\n  }\n\n  // Footer placeholders\n  if (ph.date !== false && ph.date !== undefined) {\n    const datePos = ph.date ? toEmuPos(ph.date) : null;\n    if (datePos) {\n      shapes.push(\n        positionedDatePlaceholder(nextId++, datePos.x, datePos.y, datePos.cx, datePos.cy),\n      );\n    } else {\n      shapes.push(dtPlaceholder(nextId++));\n    }\n  }\n\n  if (ph.footer !== false && ph.footer !== undefined) {\n    const ftrPos = ph.footer ? toEmuPos(ph.footer) : null;\n    if (ftrPos) {\n      shapes.push(positionedFooterPlaceholder(nextId++, ftrPos.x, ftrPos.y, ftrPos.cx, ftrPos.cy));\n    } else {\n      shapes.push(ftrPlaceholder(nextId++));\n    }\n  }\n\n  if (ph.slideNumber !== false && ph.slideNumber !== undefined) {\n    const sldPos = ph.slideNumber ? toEmuPos(ph.slideNumber) : null;\n    if (sldPos) {\n      shapes.push(positionedSldNumPlaceholder(nextId++, sldPos.x, sldPos.y, sldPos.cx, sldPos.cy));\n    } else {\n      shapes.push(sldNumPlaceholder(nextId++));\n    }\n  }\n\n  // @type omitted when unset — the XSD default \"cust\" applies (ST_SlideLayoutType\n  // has no \"custom\" token); slideLayoutDesc preserves the absence on re-emit.\n  const typeAttr = def.type !== undefined ? ` type=\"${def.type}\"` : \"\";\n  const matchingAttr = def.matchingName !== undefined ? ` matchingName=\"${def.matchingName}\"` : \"\";\n  return `<p:sldLayout ${NS}${typeAttr} preserve=\"1\"${matchingAttr}><p:cSld name=\"${displayName}\"><p:spTree>${SP_TREE_HEADER}${shapes.join(\"\")}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sldLayout>`;\n}\n","import type { ColorMappingOptions } from \"@office-open/core\";\nimport type { TextListStyleOptions } from \"@office-open/core/drawing\";\nimport type { ThemeOptions } from \"@office-open/core/theme\";\nimport type { BackgroundOptions } from \"@parts/background\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\n\nimport type { HeaderFooterOptions } from \"./handout-master\";\n\nexport type { HeaderFooterOptions };\n\n/** Options for the notes master (p:notesMaster). */\nexport interface NotesMasterOptions {\n  /** Background (p:bg); defaults to the MS Office bgRef idx=\"1001\". */\n  background?: BackgroundOptions;\n  /** Custom spTree shapes (p:spTree children after the group header). */\n  children?: SlideChild[];\n  /** Color mapping overrides (p:clrMap). */\n  colorMapping?: Partial<ColorMappingOptions>;\n  /** Header/footer settings (p:hf). */\n  headerFooter?: HeaderFooterOptions;\n  /** Notes text style (p:notesStyle, CT_TextListStyle); defaults to the Office 9-level notes style. */\n  notesStyle?: TextListStyleOptions;\n  /** The notes master's own theme part (ppt/theme/themeN.xml); defaults to the Office theme. */\n  theme?: ThemeOptions;\n  /** Trailing p:extLst inner XML (e.g. p14:creationId) — verbatim round-trip. */\n  ext?: string;\n}\n\n/** MS Office default notes style — 9 levels, 12pt minor font, incremental margins. */\nexport const DEFAULT_NOTES_STYLE: TextListStyleOptions = {\n  levels: [0, 457200, 914400, 1371600, 1828800, 2286000, 2743200, 3200400, 3657600].map(\n    (marginIndent) => ({\n      alignment: \"left\",\n      marginIndent,\n      defTabSize: 914400,\n      rightToLeft: false,\n      eastAsianLineBreak: true,\n      latinLineBreak: false,\n      hangingPunctuation: true,\n      defaultRunProperties: {\n        size: 12,\n        kern: 12,\n        fill: { type: \"solid\", color: { value: \"tx1\" } },\n        font: { latin: \"+mn-lt\", eastAsia: \"+mn-ea\", complexScript: \"+mn-cs\" },\n      },\n    }),\n  ),\n};\n","import { parseOnOff, stringifyColorMapping } from \"@office-open/core\";\nimport type { ColorMappingOptions } from \"@office-open/core\";\nimport type { ThemeOptions } from \"@office-open/core/theme\";\nimport { attr, type Element } from \"@office-open/xml\";\nimport type { BackgroundOptions } from \"@parts/background\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\n\n/** Header/footer options for handout/notes master */\nexport interface HeaderFooterOptions {\n  /** Show date/time */\n  date?: boolean;\n  /** Show header */\n  header?: boolean;\n  /** Show footer */\n  footer?: boolean;\n  /** Show slide number */\n  slideNumber?: boolean;\n}\n\n/** Options for handout master parameterization */\nexport interface HandoutMasterOptions {\n  /** Background (p:bg); defaults to the Office bgRef idx=\"1001\". */\n  background?: BackgroundOptions;\n  /** Custom spTree shapes (p:spTree children after the group header). */\n  children?: SlideChild[];\n  /** Color mapping overrides */\n  colorMapping?: Partial<ColorMappingOptions>;\n  /** Header/footer settings */\n  headerFooter?: HeaderFooterOptions;\n  /** The handout master's own theme part; defaults to the Office theme. */\n  theme?: ThemeOptions;\n  /** Trailing p:extLst inner XML (e.g. p14:creationId) — verbatim round-trip. */\n  ext?: string;\n}\n\nexport function buildHfAttrs(opts?: HeaderFooterOptions): string {\n  if (!opts) return 'dt=\"0\" hdr=\"0\" ftr=\"0\" sldNum=\"0\"';\n  return `dt=\"${opts.date ? 1 : 0}\" hdr=\"${opts.header ? 1 : 0}\" ftr=\"${opts.footer ? 1 : 0}\" sldNum=\"${opts.slideNumber ? 1 : 0}\"`;\n}\n\n/** Parse a p:hf element into HeaderFooterOptions (undefined when empty/absent). */\nexport function parseHeaderFooter(el: Element | undefined): HeaderFooterOptions | undefined {\n  if (!el) return undefined;\n  const headerFooter: HeaderFooterOptions = {};\n  const dt = attr(el, \"dt\");\n  if (dt !== undefined) headerFooter.date = parseOnOff(dt) ?? false;\n  const hdr = attr(el, \"hdr\");\n  if (hdr !== undefined) headerFooter.header = parseOnOff(hdr) ?? false;\n  const ftr = attr(el, \"ftr\");\n  if (ftr !== undefined) headerFooter.footer = parseOnOff(ftr) ?? false;\n  const sldNum = attr(el, \"sldNum\");\n  if (sldNum !== undefined) headerFooter.slideNumber = parseOnOff(sldNum) ?? false;\n  return Object.keys(headerFooter).length > 0 ? headerFooter : undefined;\n}\n\n/**\n * Build the handout master XML (fresh generation only).\n *\n * The handout master stays a fixed template: its spTree holds only print-layout\n * placeholders that PowerPoint regenerates on demand, real files carry no\n * authorable content worth round-tripping, and nothing in the parse pipeline\n * consumes it — structuring it would add surface with no consumer.\n */\nexport function buildHandoutMasterXml(options?: HandoutMasterOptions): string {\n  const colorMapping = stringifyColorMapping(options?.colorMapping, \"p:clrMap\");\n  const hf = buildHfAttrs(options?.headerFooter);\n  return (\n    '<p:handoutMaster xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ' +\n    'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n    'xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">' +\n    '<p:cSld><p:bg><p:bgRef idx=\"1001\"><a:schemeClr val=\"bg1\"/></p:bgRef></p:bg>' +\n    `<p:spTree>${SP_TREE_HEADER}</p:spTree></p:cSld>` +\n    colorMapping +\n    `<p:hf ${hf}/>` +\n    \"</p:handoutMaster>\"\n  );\n}\n","/**\n * Notes Slide XML builder.\n *\n * Pure function — no XmlComponent inheritance.\n *\n * @module\n */\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type { NotesSlideOptions } from \"./descriptors/notes-slide\";\n\n/**\n * Build a complete p:notes XML string.\n *\n * Replaces the former NotesSlide XmlComponent class hierarchy\n * (NotesSlide → NotesCommonSlideData → NotesShapeTree → SlideImagePlaceholder / NotesBodyPlaceholder).\n */\nexport function buildNotesSlideXml(options: NotesSlideOptions = {}): string {\n  const escapedText = options.text ? escapeXml(options.text) : \"\";\n\n  return (\n    '<p:notes xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">' +\n    \"<p:cSld>\" +\n    \"<p:spTree>\" +\n    '<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>' +\n    '<p:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/><a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"0\" cy=\"0\"/></a:xfrm></p:grpSpPr>' +\n    // Slide Image Placeholder\n    \"<p:sp>\" +\n    '<p:nvSpPr><p:cNvPr id=\"2\" name=\"Slide Image Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\" noRot=\"1\" noChangeAspect=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldImg\"/></p:nvPr></p:nvSpPr>' +\n    '<p:spPr><a:xfrm><a:off x=\"685800\" y=\"1600200\"/><a:ext cx=\"5486400\" cy=\"3086100\"/></a:xfrm></p:spPr>' +\n    \"</p:sp>\" +\n    // Notes Body Placeholder\n    \"<p:sp>\" +\n    '<p:nvSpPr><p:cNvPr id=\"3\" name=\"Notes Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"body\" idx=\"1\"/></p:nvPr></p:nvSpPr>' +\n    '<p:spPr><a:xfrm><a:off x=\"685800\" y=\"4800600\"/><a:ext cx=\"5486400\" cy=\"3600450\"/></a:xfrm></p:spPr>' +\n    \"<p:txBody>\" +\n    \"<a:bodyPr/>\" +\n    \"<a:lstStyle/>\" +\n    (escapedText\n      ? `<a:p><a:r><a:rPr lang=\"en-US\" dirty=\"0\"/><a:t>${escapedText}</a:t></a:r></a:p>`\n      : '<a:p><a:endParaRPr lang=\"en-US\" dirty=\"0\"/></a:p>') +\n    \"</p:txBody>\" +\n    \"</p:sp>\" +\n    \"</p:spTree>\" +\n    \"</p:cSld>\" +\n    \"<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>\" +\n    \"</p:notes>\"\n  );\n}\n","/**\n * Shared cSld sub-block serializers/parsers (CT_CommonSlideData tail children)\n * used by the slide-family serializers — compiler.ts (slide), slide-master.ts,\n * slide-layout.ts, and the slide descriptor. p:hf is attribute-form per\n * CT_HeaderFooter (sldNum/hdr/ftr/dt boolean attributes, no element children);\n * parse additionally tolerates the legacy element-form emission.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport { attr, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { SlideHeaderFooterOptions } from \"@shared/header-footer\";\n\nimport type { ControlOptions } from \"./slide\";\n\n// ── p:custDataLst ──\n\n/** Serialize cSld customer-data references; empty string when there are none. */\nexport function stringifyCustDataLst(items: { rId: string }[] | undefined): string {\n  if (!items || items.length === 0) return \"\";\n  return `<p:custDataLst>${items.map((d) => `<p:custData r:id=\"${d.rId}\"/>`).join(\"\")}</p:custDataLst>`;\n}\n\n/** Parse a p:custDataLst element into customer-data references. */\nexport function parseCustDataLst(el: Element | undefined): { rId: string }[] | undefined {\n  if (!el) return undefined;\n  const items: { rId: string }[] = [];\n  for (const cd of el.elements ?? []) {\n    if (cd.name === \"p:custData\") {\n      const rId = attr(cd, \"r:id\");\n      if (rId) items.push({ rId });\n    }\n  }\n  return items.length > 0 ? items : undefined;\n}\n\n// ── p:controls ──\n\n/** Serialize cSld controls; empty string when there are none. */\nexport function stringifyControls(controls: ControlOptions[] | undefined): string {\n  if (!controls || controls.length === 0) return \"\";\n  const items = controls\n    .map((c) => {\n      const attrs: string[] = [];\n      if (c.shapeId !== undefined) attrs.push(`spid=\"${c.shapeId}\"`);\n      if (c.name) attrs.push(`name=\"${c.name}\"`);\n      if (c.showAsIcon) attrs.push('showAsIcon=\"1\"');\n      if (c.rId) attrs.push(`r:id=\"${c.rId}\"`);\n      if (c.imageWidth !== undefined) attrs.push(`imgW=\"${c.imageWidth}\"`);\n      if (c.imageHeight !== undefined) attrs.push(`imgH=\"${c.imageHeight}\"`);\n      return `<p:control ${attrs.join(\" \")}/>`;\n    })\n    .join(\"\");\n  return `<p:controls>${items}</p:controls>`;\n}\n\n/** Parse a p:controls element into control options. */\nexport function parseControls(el: Element | undefined): ControlOptions[] | undefined {\n  if (!el) return undefined;\n  const items: ControlOptions[] = [];\n  for (const ctrl of el.elements ?? []) {\n    if (ctrl.name !== \"p:control\") continue;\n    const item: ControlOptions = {};\n    // @spid is ST_ShapeID (a token like \"_x0000_s1026\"), never numeric.\n    const shapeId = attr(ctrl, \"spid\");\n    if (shapeId) item.shapeId = shapeId;\n    const name = attr(ctrl, \"name\");\n    if (name) item.name = name;\n    if (parseOnOff(attr(ctrl, \"showAsIcon\"))) item.showAsIcon = true;\n    const rId = attr(ctrl, \"r:id\");\n    if (rId) item.rId = rId;\n    const imageWidth = attrNum(ctrl, \"imgW\");\n    if (imageWidth !== undefined) item.imageWidth = imageWidth;\n    const imageHeight = attrNum(ctrl, \"imgH\");\n    if (imageHeight !== undefined) item.imageHeight = imageHeight;\n    items.push(item);\n  }\n  return items.length > 0 ? items : undefined;\n}\n\n// ── p:hf (CT_HeaderFooter, attribute form) ──\n\n/**\n * Serialize a layout-level p:hf in attribute form per CT_HeaderFooter;\n * undefined/empty options emit nothing (each attribute defaults to true in\n * the XSD, so an all-true header/footer is the absent element).\n */\nexport function stringifySlideHf(hf: SlideHeaderFooterOptions | undefined): string {\n  if (!hf) return \"\";\n  const attrs: string[] = [];\n  if (hf.slideNumber !== undefined) attrs.push(`sldNum=\"${hf.slideNumber ? 1 : 0}\"`);\n  if (hf.dateTime !== undefined) attrs.push(`dt=\"${hf.dateTime ? 1 : 0}\"`);\n  if (hf.footer !== undefined) attrs.push(`ftr=\"${hf.footer ? 1 : 0}\"`);\n  if (hf.header !== undefined) attrs.push(`hdr=\"${hf.header ? 1 : 0}\"`);\n  if (attrs.length === 0) return \"\";\n  return `<p:hf ${attrs.join(\" \")}/>`;\n}\n\n/**\n * Parse a layout-level p:hf. Reads CT_HeaderFooter attributes; tolerates the\n * legacy element-form children this library used to emit.\n */\nexport function parseSlideHf(el: Element | undefined): SlideHeaderFooterOptions | undefined {\n  if (!el) return undefined;\n  const hf: SlideHeaderFooterOptions = {};\n  const sldNum = attr(el, \"sldNum\");\n  if (sldNum !== undefined) hf.slideNumber = parseOnOff(sldNum) ?? false;\n  const dt = attr(el, \"dt\");\n  if (dt !== undefined) hf.dateTime = parseOnOff(dt) ?? false;\n  const ftr = attr(el, \"ftr\");\n  if (ftr !== undefined) hf.footer = parseOnOff(ftr) ?? false;\n  const hdr = attr(el, \"hdr\");\n  if (hdr !== undefined) hf.header = parseOnOff(hdr) ?? false;\n  if (Object.keys(hf).length > 0) return hf;\n\n  // Legacy element-form emission (<p:hf><p:sldNum/>…</p:hf>).\n  if (findChild(el, \"p:sldNum\")) hf.slideNumber = true;\n  if (findChild(el, \"p:dt\")) hf.dateTime = true;\n  if (findChild(el, \"p:ftr\")) hf.footer = true;\n  if (findChild(el, \"p:hdr\")) hf.header = true;\n  return Object.keys(hf).length > 0 ? hf : undefined;\n}\n","import type { NonVisualDrawingPropertiesOptions, ShapeLockingOptions } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport type {\n  ShapePropertiesOptions,\n  Transform2DOptions,\n  TextBodyOptions,\n  BlackWhiteMode,\n  TextHyperlinkOptions,\n} from \"@office-open/core/drawing\";\nimport { parseColorChoice, isPlainRgbColor } from \"@office-open/core/drawing\";\nimport type { SolidFillOptions } from \"@office-open/core/drawing\";\nimport { attr, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\n/**\n * Shape options type for PPTX.\n *\n * The single source of truth for both the public slide-child entry and the\n * descriptor. Shape-level animation is intentionally absent — CT_Shape has no\n * timing child in the XSD; animation lives at the slide level\n * (slide.animations / timing).\n *\n * @module\n */\n\n/** Style-matrix reference color: hex shorthand or a full color choice\n * (schemeClr with transforms, sysClr, hslClr, …). */\n/** CT_Placeholder `@type` — ST_PlaceholderType. */\nexport type PlaceholderType =\n  | \"title\"\n  | \"body\"\n  | \"centerTitle\"\n  | \"subTitle\"\n  | \"date\"\n  | \"slideNumber\"\n  | \"footer\"\n  | \"header\"\n  | \"object\"\n  | \"chart\"\n  | \"table\"\n  | \"clipArt\"\n  | \"diagram\"\n  | \"media\"\n  | \"slideImage\"\n  | \"picture\";\n\n/** CT_Placeholder `@sz` — sizing hint. */\nexport type PlaceholderSize = \"full\" | \"half\" | \"quarter\";\n\n/** CT_Placeholder `@orient` — orientation hint. */\nexport type PlaceholderOrientation = \"horz\" | \"vert\";\n\nexport type StyleReferenceColor = string | SolidFillOptions;\n\n/**\n * A style-matrix reference (CT_StyleMatrixReference): an index into the\n * theme's style matrix plus an optional color override.\n */\nexport interface ShapeStyleReferenceOptions {\n  index: number;\n  color?: StyleReferenceColor;\n}\n\nexport interface ShapeStyleOptions {\n  lineReference?: ShapeStyleReferenceOptions;\n  fillReference?: ShapeStyleReferenceOptions;\n  effectReference?: ShapeStyleReferenceOptions;\n  /**\n   * a:fontRef — @idx is ST_FontCollectionIndex (major/minor/none), not a\n   * number.\n   */\n  fontReference?: { collection: \"major\" | \"minor\" | \"none\"; color?: StyleReferenceColor };\n}\n\nexport interface ShapeOptions extends NonVisualDrawingPropertiesOptions, Transform2DOptions {\n  id?: number;\n  /**\n   * Shape properties (a:spPr children): geometry/fill/outline/effects/3D and\n   * the spPr extension list. Transform fields stay top-level on the shape.\n   * `fill: null` marks a source spPr with no fill child — absence is the\n   * fidelity (the shape inherits its fill), so stringify emits nothing instead\n   * of the fresh-authoring noFill default.\n   */\n  properties?: Omit<ShapePropertiesOptions, keyof Transform2DOptions>;\n  textBody?: TextBodyOptions;\n  locking?: ShapeLockingOptions;\n  /** CT_Placeholder `@type` — ST_PlaceholderType. */\n  placeholder?: PlaceholderType;\n  placeholderIndex?: number;\n  /** CT_Placeholder `@sz` — sizing hint (default \"full\"). */\n  placeholderSize?: \"full\" | \"half\" | \"quarter\";\n  /** CT_Placeholder `@orient` — orientation hint (default \"horz\"). */\n  placeholderOrientation?: \"horz\" | \"vert\";\n  useBackgroundFill?: boolean;\n  isPhoto?: boolean;\n  userDrawn?: boolean;\n  hasCustomPrompt?: boolean;\n  style?: ShapeStyleOptions;\n  /**\n   * `@bwMode` (ST_BlackWhiteMode) on `p:spPr` — how the shape renders in\n   * black-and-white view/print.\n   */\n  blackWhiteMode?: BlackWhiteMode;\n  /**\n   * Click hyperlink on the shape itself (a:hlinkClick inside p:cNvPr) —\n   * jump to a URL or another slide when the shape is clicked.\n   */\n  hyperlink?: TextHyperlinkOptions;\n}\n\n/**\n * Parse a p:style element (a:lnRef/a:fillRef/a:effectRef/a:fontRef) into\n * ShapeStyleOptions. Shared by the shape descriptor and placeholder\n * inheritance — idx is required per CT_StyleMatrixReference/CT_FontReference,\n * so refs without it are skipped. Each ref carries a bare EG_ColorChoice\n * child (any of the six color kinds).\n */\nexport function readShapeStyle(styleEl: XmlElement, ctx: ReadContext): ShapeStyleOptions {\n  const style: ShapeStyleOptions = {};\n  const lnRef = findChild(styleEl, \"a:lnRef\");\n  if (lnRef) {\n    const idx = attrNum(lnRef, \"idx\");\n    if (idx !== undefined) {\n      const color = readRefColor(lnRef, ctx);\n      style.lineReference = color !== undefined ? { index: idx, color } : { index: idx };\n    }\n  }\n  const fillRef = findChild(styleEl, \"a:fillRef\");\n  if (fillRef) {\n    const idx = attrNum(fillRef, \"idx\");\n    if (idx !== undefined) {\n      const color = readRefColor(fillRef, ctx);\n      style.fillReference = color !== undefined ? { index: idx, color } : { index: idx };\n    }\n  }\n  const effectRef = findChild(styleEl, \"a:effectRef\");\n  if (effectRef) {\n    const idx = attrNum(effectRef, \"idx\");\n    if (idx !== undefined) {\n      const color = readRefColor(effectRef, ctx);\n      style.effectReference = color !== undefined ? { index: idx, color } : { index: idx };\n    }\n  }\n  const fontRef = findChild(styleEl, \"a:fontRef\");\n  if (fontRef) {\n    // @idx is ST_FontCollectionIndex (major/minor/none) — passthrough keeps\n    // unknown tokens intact for round-trip fidelity.\n    const raw = attr(fontRef, \"idx\");\n    if (raw !== undefined) {\n      const color = readRefColor(fontRef, ctx);\n      const collection = raw as \"major\" | \"minor\" | \"none\";\n      style.fontReference = color !== undefined ? { collection, color } : { collection };\n    }\n  }\n  return style;\n}\n\n/** Read a ref's EG_ColorChoice; a bare srgbClr collapses to the hex shorthand,\n * scheme/sys/hsl colors keep their structured form. */\nfunction readRefColor(refEl: XmlElement, ctx: ReadContext): StyleReferenceColor | undefined {\n  const color = parseColorChoice(refEl, ctx);\n  if (!color || Object.keys(color).length === 0) return undefined;\n  if (isPlainRgbColor(color)) return (color as { value: string }).value;\n  return color;\n}\n","/**\n * Placeholder inheritance resolution.\n *\n * A slide placeholder omits geometry (xfrm) and other shape facets when it\n * inherits them from its layout, which in turn inherits from the slide master.\n * {@link resolvePlaceholder} walks that chain to recover the rendered position,\n * shape facets, text body and style.\n *\n * @module\n */\n\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { shapePropertiesDesc, textBodyDesc } from \"@office-open/core/drawing\";\nimport type {\n  NonVisualDrawingPropertiesOptions,\n  ShapePropertiesOptions,\n  TextBodyOptions,\n} from \"@office-open/core/drawing\";\nimport { parseNonVisualDrawingProperties } from \"@office-open/core/drawing\";\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\n\nimport type { LayoutDefinition, MasterDefinition } from \"./file\";\nimport { readShapeStyle, type ShapeStyleOptions } from \"./shape/shape\";\n\n/** Logical keys of the placeholder maps (LayoutPlaceholderOptions /\n *  MasterPlaceholderOptions fields). */\nexport type PlaceholderKey =\n  | \"title\"\n  | \"body\"\n  | \"subtitle\"\n  | \"date\"\n  | \"footer\"\n  | \"slideNumber\"\n  | \"header\"\n  | \"object\"\n  | \"chart\"\n  | \"table\"\n  | \"diagram\"\n  | \"media\"\n  | \"clipArt\"\n  | \"slideImage\"\n  | \"picture\";\n\n/**\n * Placeholder slot map keyed by `p:ph/@type` (ST_PlaceholderType): `false`\n * hides the slot, a definition overrides its position and facets, omitted\n * shows the default. Layouts and masters share the same key set — both public\n * maps are aliases of this type.\n */\nexport type PlaceholderMapOptions = { [K in PlaceholderKey]?: PlaceholderDefinition | false };\n\n/**\n * Maps a `p:ph/@type` token (ST_PlaceholderType, 16 tokens) to the matching\n * placeholder-map key. `ctrTitle` normalizes to `title`; every other token\n * keeps its full-word key.\n */\nexport const PLACEHOLDER_TYPE_TO_KEY: Readonly<Record<string, PlaceholderKey>> = {\n  title: \"title\",\n  ctrTitle: \"title\",\n  body: \"body\",\n  subTitle: \"subtitle\",\n  dt: \"date\",\n  sldNum: \"slideNumber\",\n  ftr: \"footer\",\n  hdr: \"header\",\n  obj: \"object\",\n  chart: \"chart\",\n  tbl: \"table\",\n  dgm: \"diagram\",\n  media: \"media\",\n  clipArt: \"clipArt\",\n  sldImg: \"slideImage\",\n  pic: \"picture\",\n};\n\n/** Placeholder slots the master fresh-emit re-generates from the map (the\n *  standard five with reference positions). Parse keeps every other\n *  placeholder type in the spTree children verbatim and records it on the map\n *  for inheritance only. */\nexport const STANDARD_EMIT_KEYS: ReadonlySet<PlaceholderKey> = new Set([\n  \"title\",\n  \"body\",\n  \"date\",\n  \"footer\",\n  \"slideNumber\",\n]);\n\n/** Position rect (a:xfrm off/ext). `number` is EMU on round-trip. */\nexport interface PlaceholderPosition {\n  x: number | UniversalMeasure;\n  y: number | UniversalMeasure;\n  width: number | UniversalMeasure;\n  height: number | UniversalMeasure;\n}\n\n/**\n * Inheritable facets of a placeholder beyond position: shape properties\n * (geometry/fill/outline/effects/3D), text body, and shape style. Each field is\n * optional — present only when the layout/master placeholder defined it. A\n * slide placeholder inherits whichever facets it omits.\n */\nexport interface PlaceholderFacets {\n  geometry?: ShapePropertiesOptions[\"geometry\"];\n  customGeometry?: ShapePropertiesOptions[\"customGeometry\"];\n  fill?: ShapePropertiesOptions[\"fill\"];\n  outline?: ShapePropertiesOptions[\"outline\"];\n  effects?: ShapePropertiesOptions[\"effects\"];\n  scene3d?: ShapePropertiesOptions[\"scene3d\"];\n  shape3d?: ShapePropertiesOptions[\"shape3d\"];\n  textBody?: TextBodyOptions;\n  style?: ShapeStyleOptions;\n}\n\n/**\n * Complete placeholder template on a master/layout: position, inheritable\n * facets, and cNvPr fields (a16:creationId) so a re-emitted placeholder keeps\n * its identity. Accepts the old flat x/y/width/height shape.\n */\nexport interface PlaceholderDefinition\n  extends PlaceholderPosition, PlaceholderFacets, NonVisualDrawingPropertiesOptions {}\n\n/** Result of resolving a placeholder against the layout/master chain. */\nexport interface ResolvedPlaceholder {\n  /**\n   * First defined position (layout takes precedence over master). Undefined\n   * when neither carries a transform for this placeholder type.\n   */\n  position?: PlaceholderPosition;\n  /**\n   * Inherited shape/text/style facets. Master is the base; layout overrides\n   * per-facet. Undefined when neither layer defines any facet.\n   */\n  facets?: PlaceholderFacets;\n  /** True when layout or master carries `sz=\"0\"` (hidden). */\n  hidden?: boolean;\n}\n\nfunction asDefinition(ph: unknown): PlaceholderDefinition | undefined {\n  return ph !== undefined && ph !== false && ph !== true && typeof ph === \"object\"\n    ? (ph as PlaceholderDefinition)\n    : undefined;\n}\n\nfunction pickPosition(def: PlaceholderDefinition | undefined): PlaceholderPosition | undefined {\n  if (!def) return undefined;\n  const { x, y, width, height } = def;\n  if (x === undefined || y === undefined || width === undefined || height === undefined) {\n    return undefined;\n  }\n  return { x, y, width, height };\n}\n\nfunction pickFacets(def: PlaceholderDefinition | undefined): PlaceholderFacets | undefined {\n  if (!def) return undefined;\n  const facets: PlaceholderFacets = {};\n  if (def.geometry !== undefined) facets.geometry = def.geometry;\n  if (def.customGeometry !== undefined) facets.customGeometry = def.customGeometry;\n  if (def.fill !== undefined) facets.fill = def.fill;\n  if (def.outline !== undefined) facets.outline = def.outline;\n  if (def.effects !== undefined) facets.effects = def.effects;\n  if (def.scene3d !== undefined) facets.scene3d = def.scene3d;\n  if (def.shape3d !== undefined) facets.shape3d = def.shape3d;\n  if (def.textBody !== undefined) facets.textBody = def.textBody;\n  if (def.style !== undefined) facets.style = def.style;\n  return Object.keys(facets).length > 0 ? facets : undefined;\n}\n\nfunction mergeFacets(\n  base: PlaceholderFacets | undefined,\n  override: PlaceholderFacets | undefined,\n): PlaceholderFacets | undefined {\n  if (!base && !override) return undefined;\n  if (!base) return override;\n  if (!override) return base;\n  return { ...base, ...override };\n}\n\n/**\n * Resolve a slide placeholder's inherited position and facets from the\n * layout → master chain.\n *\n * @param placeholderType The `p:ph/@type` token from the slide placeholder\n *   (e.g. `\"title\"`, `\"body\"`, `\"dt\"`).\n * @param layout The slide's layout definition (carries placeholder templates).\n * @param master The layout's slide master definition.\n * @returns The resolved position and facets (or `{ hidden: true }` when either\n *   layer suppresses the placeholder with `sz=\"0\"`).\n */\nexport function resolvePlaceholder(\n  placeholderType: string,\n  layout: LayoutDefinition | undefined,\n  master: MasterDefinition | undefined,\n): ResolvedPlaceholder {\n  const key = PLACEHOLDER_TYPE_TO_KEY[placeholderType];\n  if (!key) return {};\n\n  const layoutPh = layout?.placeholders?.[key as keyof typeof layout.placeholders];\n  const masterPh = master?.placeholders?.[key as keyof typeof master.placeholders];\n\n  // sz=\"0\" on either layer hides the placeholder downstream.\n  if (layoutPh === false || masterPh === false) return { hidden: true };\n\n  const layoutDef = asDefinition(layoutPh);\n  const masterDef = asDefinition(masterPh);\n\n  const result: ResolvedPlaceholder = {};\n\n  const position = pickPosition(layoutDef) ?? pickPosition(masterDef);\n  if (position) result.position = position;\n\n  // Master is the base; layout overrides each facet it defines.\n  const facets = mergeFacets(pickFacets(masterDef), pickFacets(layoutDef));\n  if (facets) result.facets = facets;\n\n  return result;\n}\n\n// ── Placeholder extraction (master/layout parse path) ──\n\n/**\n * Read a placeholder's logical key and full definition (position + inheritable\n * facets), or `false` when hidden (`sz=\"0\"`). Returns undefined for non-placeholder\n * shapes or ones without a transform. Shared by the slide-master and slide-layout\n * parse paths; the caller supplies its own `p:ph/@type` → key map.\n *\n * Facets beyond position are carried only when the source defined them: non-rect\n * geometry, fill/outline/effects/3D, custom text body (a run/break/field beyond\n * the default endParaRPr body), and shape style. This keeps default placeholders\n * position-only so the fresh emit path stays byte-equivalent with MS Office.\n */\nexport function extractPlaceholderDefinition(\n  spEl: XmlElement,\n  ctx: ReadContext,\n  phTypeToKey: Readonly<Record<string, PlaceholderKey>>,\n): { key: PlaceholderKey; def: PlaceholderDefinition | false } | undefined {\n  const nvSpPr = findChild(spEl, \"p:nvSpPr\");\n  const nvPr = nvSpPr ? findChild(nvSpPr, \"p:nvPr\") : undefined;\n  const ph = nvPr ? findChild(nvPr, \"p:ph\") : undefined;\n  if (!ph) return undefined;\n\n  const phType = attr(ph, \"type\");\n  const key = phType ? phTypeToKey[phType] : undefined;\n  if (!key) return undefined;\n\n  if (attr(ph, \"sz\") === \"0\") return { key, def: false };\n\n  const def: Partial<PlaceholderDefinition> = {};\n\n  // cNvPr fields (name/description/title/hidden + a16:creationId) so a\n  // re-emitted placeholder keeps its identity.\n  const cNvPr = nvSpPr ? findChild(nvSpPr, \"p:cNvPr\") : undefined;\n  Object.assign(def, parseNonVisualDrawingProperties(cNvPr));\n\n  // Position + spPr facets from shapePropertiesDesc.parse.\n  const spPr = findChild(spEl, \"p:spPr\");\n  if (spPr) {\n    const spPrOpts = shapePropertiesDesc.parse(spPr, ctx);\n    if (spPrOpts) {\n      if (spPrOpts.x !== undefined) def.x = spPrOpts.x;\n      if (spPrOpts.y !== undefined) def.y = spPrOpts.y;\n      if (spPrOpts.width !== undefined) def.width = spPrOpts.width;\n      if (spPrOpts.height !== undefined) def.height = spPrOpts.height;\n      // rect is the placeholder geometry default — carry only non-rect.\n      if (spPrOpts.customGeometry) {\n        def.customGeometry = spPrOpts.customGeometry;\n      } else if (spPrOpts.geometry !== undefined) {\n        const preset =\n          typeof spPrOpts.geometry === \"string\" ? spPrOpts.geometry : spPrOpts.geometry.preset;\n        if (preset !== \"rect\") def.geometry = spPrOpts.geometry;\n      }\n      if (spPrOpts.fill !== undefined) def.fill = spPrOpts.fill;\n      if (spPrOpts.outline !== undefined) def.outline = spPrOpts.outline;\n      if (spPrOpts.effects !== undefined) def.effects = spPrOpts.effects;\n      if (spPrOpts.scene3d !== undefined) def.scene3d = spPrOpts.scene3d;\n      if (spPrOpts.shape3d !== undefined) def.shape3d = spPrOpts.shape3d;\n    }\n  }\n\n  // textBody: always carried — source bodies (styled lstStyle, field runs)\n  // must round-trip exactly; fresh placeholders fall back to the emitter\n  // defaults when the definition carries none.\n  const txBody = findChild(spEl, \"p:txBody\");\n  if (txBody) {\n    def.textBody = textBodyDesc.parse(txBody, ctx);\n  }\n\n  // p:style — placeholders default to none; carry whenever present.\n  const styleEl = findChild(spEl, \"p:style\");\n  if (styleEl) def.style = readShapeStyle(styleEl, ctx);\n\n  // A placeholder definition requires a concrete position.\n  if (\n    def.x === undefined ||\n    def.y === undefined ||\n    def.width === undefined ||\n    def.height === undefined\n  ) {\n    return undefined;\n  }\n  return { key, def: def as PlaceholderDefinition };\n}\n","import {\n  xsdAnimCalcMode,\n  xsdAnimClass,\n  xsdAnimValueType,\n  xsdAnimationDgmBuild,\n  xsdChartBuild,\n  xsdDiagramBuild,\n  xsdIterateType,\n  xsdTextBuild,\n} from \"@office-open/core\";\nimport { element as buildXml } from \"@office-open/xml\";\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type {\n  AnimationBuildOptions,\n  AnimationClass,\n  AnimationOptions,\n  AnimationType,\n  AnimationVariantOptions,\n  EmphasisType,\n  EndConditionOptions,\n  PathAnimationType,\n} from \"./types\";\n\n// --- Preset ID mappings ---\n// Single source for both stringify (here) and parse (descriptors/animation.ts\n// builds reverse maps from these). Entrance zoom = 53: PowerPoint assigns 10\n// to fade, so the pre-unification value collided and round-tripped as fade;\n// 53 is the \"fade and zoom\" entrance preset in PowerPoint's ID space.\n\nexport const ENTR_PRESET_IDS: Record<AnimationType, number> = {\n  appear: 1,\n  fade: 10,\n  fly: 2,\n  wipe: 22,\n  dissolve: 34,\n  split: 21,\n  blinds: 25,\n  checker: 26,\n  randomBars: 24,\n  wheel: 27,\n  zoom: 53,\n  cover: 28,\n  push: 19,\n  strips: 23,\n};\n\nexport const EXIT_PRESET_IDS: Record<AnimationType, number> = {\n  appear: 53,\n  fade: 59,\n  fly: 51,\n  wipe: 72,\n  dissolve: 84,\n  split: 71,\n  blinds: 75,\n  checker: 76,\n  randomBars: 74,\n  wheel: 77,\n  zoom: 60,\n  cover: 78,\n  push: 69,\n  strips: 73,\n};\n\nexport const EMPH_PRESET_IDS: Record<EmphasisType, number> = {\n  growShrink: 53,\n  spin: 54,\n  growWithTurn: 56,\n  colorChange: 29,\n  transparency: 57,\n  boldFlash: 50,\n  wave: 55,\n  pulse: 58,\n};\n\nexport const PATH_PRESET_IDS: Record<PathAnimationType, number> = {\n  customPath: 200,\n  arc: 201,\n  bounce: 202,\n  circle: 203,\n  curve: 204,\n  figureEight: 205,\n  line: 206,\n  loop: 207,\n};\n\nexport const DIRECTION_SUBTYPES: Record<string, number> = {\n  left: 4,\n  right: 8,\n  up: 2,\n  down: 1,\n  horizontal: 16,\n  vertical: 32,\n};\n\nconst FILTER_MAP: Record<string, string> = {\n  fade: \"fade\",\n  fly: \"fly\",\n  wipe: \"wipe\",\n  dissolve: \"dissolve\",\n  split: \"split\",\n  blinds: \"blinds\",\n  checker: \"checkerboard\",\n  randomBars: \"randombars\",\n  wheel: \"wheel\",\n  zoom: \"zoom\",\n  cover: \"cover\",\n  push: \"push\",\n  strips: \"strips\",\n};\n\nconst DIRECTION_FILTER: Record<string, Record<string, string>> = {\n  fly: { left: \"fromLeft\", right: \"fromRight\", up: \"fromTop\", down: \"fromBottom\" },\n  wipe: { left: \"right\", right: \"left\", up: \"down\", down: \"up\" },\n  split: { horizontal: \"horizontal\", vertical: \"vertical\" },\n  blinds: { horizontal: \"horizontal\", vertical: \"vertical\" },\n  checker: { horizontal: \"horizontal\", vertical: \"vertical\" },\n  randomBars: { horizontal: \"horizontal\", vertical: \"vertical\" },\n  cover: { left: \"left\", right: \"right\", up: \"top\", down: \"bottom\" },\n  push: { left: \"left\", right: \"right\", up: \"top\", down: \"bottom\" },\n  strips: {\n    left: \"fromBottomLeft\",\n    right: \"fromTopRight\",\n    up: \"fromBottomRight\",\n    down: \"fromTopLeft\",\n  },\n  wheel: {},\n};\n\nconst PATH_STRINGS: Record<PathAnimationType, string> = {\n  customPath: \"\",\n  arc: \"M 0 0 C 50 -100 100 -100 150 0\",\n  bounce: \"M 0 0 L 50 0 C 50 -30 30 -50 0 -50 C -30 -50 -50 -30 -50 0 L 50 0\",\n  circle: \"M 0 0 C 50 -50 100 0 50 50 C 0 100 -50 50 0 0\",\n  curve: \"M 0 0 C 50 -80 100 -80 150 0 C 200 80 250 80 300 0\",\n  figureEight:\n    \"M 0 0 C 50 -50 100 0 50 50 C 0 100 -50 50 0 0 C -50 -50 -100 0 -50 50 C 0 100 50 50 0 0\",\n  line: \"M 0 0 L 200 0\",\n  loop: \"M 0 0 C 50 -80 100 0 50 80 C 0 160 -50 80 0 0\",\n};\n\n// --- Helper functions ---\n\nfunction resolvePresetId(options: AnimationOptions): number {\n  if (options.mediaType) return 1;\n  if (options.attributeName) return 0;\n  const cls: AnimationClass = options.class ?? \"entrance\";\n\n  if (cls === \"emphasis\" && options.emphasisType) {\n    return EMPH_PRESET_IDS[options.emphasisType] ?? 0;\n  }\n\n  if (options.pathType) {\n    return PATH_PRESET_IDS[options.pathType] ?? 200;\n  }\n\n  const type = options.type ?? \"appear\";\n  const map = cls === \"exit\" ? EXIT_PRESET_IDS : ENTR_PRESET_IDS;\n  return map[type] ?? 0;\n}\n\nfunction resolvePresetClass(options: AnimationOptions): AnimationClass {\n  if (options.mediaType) return \"mediaCall\";\n  if (options.attributeName) return \"entrance\";\n  if (options.pathType) return \"emphasis\";\n  return options.class ?? \"entrance\";\n}\n\nfunction resolvePresetSubtype(options: AnimationOptions): number {\n  if (options.direction) {\n    return DIRECTION_SUBTYPES[options.direction] ?? 0;\n  }\n  return 0;\n}\n\nfunction buildTargetElement(spid: number, options?: AnimationOptions): string {\n  // Target element type selection\n  if (options?.inkTargetShapeId !== undefined) {\n    return buildXml(\"p:tgtEl\", undefined, [`<p:inkTgt spid=\"${options.inkTargetShapeId}\"/>`]);\n  }\n\n  if (options?.soundTarget !== undefined) {\n    return buildXml(\"p:tgtEl\", undefined, [`<p:sndTgt r:id=\"${options.soundTarget}\"/>`]);\n  }\n\n  const spTgtChildren: string[] = [];\n  if (options?.charRange) {\n    spTgtChildren.push(\n      buildXml(\"p:txEl\", undefined, [\n        `<p:charRg st=\"${options.charRange[0]}\" end=\"${options.charRange[1]}\"/>`,\n      ]),\n    );\n  } else if (options?.paragraphRange) {\n    spTgtChildren.push(\n      buildXml(\"p:txEl\", undefined, [\n        `<p:pRg st=\"${options.paragraphRange[0]}\" end=\"${options.paragraphRange[1]}\"/>`,\n      ]),\n    );\n  } else if (options?.subShapeId !== undefined) {\n    spTgtChildren.push(`<p:subSp spid=\"${options.subShapeId}\"/>`);\n  } else if (options?.graphicElement !== undefined) {\n    const ge = options.graphicElement;\n    if (ge.diagram) {\n      const dgmAttrs: Record<string, string> = {};\n      if (ge.diagram.id) dgmAttrs.id = ge.diagram.id;\n      if (ge.diagram.buildStep) dgmAttrs.bldStep = ge.diagram.buildStep;\n      spTgtChildren.push(buildXml(\"p:graphicEl\", undefined, [buildXml(\"a:dgm\", dgmAttrs)]));\n    } else if (ge.chart) {\n      const chartAttrs: Record<string, string | number> = {\n        bldStep: ge.chart.buildStep,\n      };\n      if (ge.chart.seriesIndex !== undefined) chartAttrs.seriesIdx = ge.chart.seriesIndex;\n      if (ge.chart.categoryIndex !== undefined) chartAttrs.categoryIdx = ge.chart.categoryIndex;\n      spTgtChildren.push(buildXml(\"p:graphicEl\", undefined, [buildXml(\"a:chart\", chartAttrs)]));\n    }\n  } else if (options?.oleChartElementType !== undefined) {\n    const oleChartAttrs: Record<string, string | number> = {\n      type: options.oleChartElementType,\n    };\n    if (options.oleChartElementLevel !== undefined) {\n      oleChartAttrs.lvl = options.oleChartElementLevel;\n    }\n    spTgtChildren.push(buildXml(\"p:oleChartEl\", oleChartAttrs));\n  }\n\n  return buildXml(\"p:tgtEl\", undefined, [\n    buildXml(\"p:spTgt\", { spid }, spTgtChildren.length > 0 ? spTgtChildren : undefined),\n  ]);\n}\n\nfunction buildEntrOrExitEffects(\n  options: AnimationOptions,\n  spid: number,\n  ids: { set: number; effect: number },\n): string[] {\n  const children: string[] = [];\n\n  // p:set — make shape visible (entr) or hidden (exit)\n  const cls = options.class ?? \"entrance\";\n  const visibility = cls === \"exit\" ? \"hidden\" : \"visible\";\n  children.push(\n    buildXml(\"p:set\", undefined, [\n      buildXml(\"p:cBhvr\", undefined, [\n        buildXml(\"p:cTn\", { id: ids.set, dur: \"1\", fill: \"hold\" }, [\n          buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`]),\n        ]),\n        buildXml(\"p:tgtEl\", undefined, [buildXml(\"p:spTgt\", { spid })]),\n        buildXml(\"p:attrNameLst\", undefined, [`<p:attrName>style.visibility</p:attrName>`]),\n      ]),\n      buildXml(\"p:to\", undefined, [`<p:strVal val=\"${visibility}\"/>`]),\n    ]),\n  );\n\n  // p:animEffect for non-appear types\n  if (options.type !== \"appear\") {\n    const filterBase = FILTER_MAP[options.type ?? \"fade\"];\n    const dirMap = DIRECTION_FILTER[options.type ?? \"fade\"];\n    const dirFilter = options.direction && dirMap ? dirMap[options.direction] : undefined;\n\n    let filter = filterBase;\n    if (options.type === \"wheel\") {\n      filter = \"wheel(4)\";\n    } else if (options.type === \"split\") {\n      const dir = options.direction ?? \"horizontal\";\n      filter = `split(${dir})`;\n    } else if (dirFilter) {\n      filter = `${filterBase}(${dirFilter})`;\n    }\n\n    const transition = cls === \"exit\" ? \"out\" : \"in\";\n\n    const animEffectAttrs: Record<string, string | undefined> = {\n      transition,\n      filter,\n    };\n    if (options.propertyList) animEffectAttrs.prLst = options.propertyList;\n\n    const animEffectChildren: string[] = [\n      buildXml(\"p:cBhvr\", undefined, [\n        buildXml(\"p:cTn\", { id: ids.effect, dur: String(options.duration ?? 500), fill: \"hold\" }),\n        buildXml(\"p:tgtEl\", undefined, [buildXml(\"p:spTgt\", { spid })]),\n      ]),\n    ];\n\n    // Add progress if specified (CT_TLAnimateEffectBehavior progress)\n    if (options.effectProgress) {\n      animEffectChildren.push(\n        buildXml(\"p:progress\", undefined, [buildVariantValue(options.effectProgress)]),\n      );\n    }\n\n    children.push(buildXml(\"p:animEffect\", animEffectAttrs, animEffectChildren));\n  }\n\n  return children;\n}\n\nfunction buildEmphasisEffects(\n  options: AnimationOptions,\n  spid: number,\n  ids: { set: number; effect: number },\n): string[] {\n  const emphType = options.emphasisType ?? \"growShrink\";\n  const children: string[] = [];\n  const dur = String(options.duration ?? 500);\n\n  // Common target element\n  const tgtEl = buildXml(\"p:tgtEl\", undefined, [buildXml(\"p:spTgt\", { spid })]);\n\n  switch (emphType) {\n    case \"growShrink\": {\n      const animScaleAttrs: Record<string, string | number | undefined> = {};\n      if (options.zoomContents !== undefined)\n        animScaleAttrs.zoomContents = options.zoomContents ? 1 : 0;\n      children.push(\n        buildXml(\"p:animScale\", animScaleAttrs, [\n          buildXml(\"p:cBhvr\", undefined, [\n            buildXml(\n              \"p:cTn\",\n              {\n                id: ids.effect,\n                dur,\n                fill: \"hold\",\n                ...(options.autoReverse ? { autoRev: 1 } : {}),\n              },\n              [buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`])],\n            ),\n            tgtEl,\n          ]),\n          `<p:by x=\"150000\" y=\"150000\"/>`,\n        ]),\n      );\n      break;\n    }\n\n    case \"spin\":\n      children.push(\n        buildXml(\"p:animRot\", { by: \"3600000\" }, [\n          buildXml(\"p:cBhvr\", undefined, [\n            buildXml(\n              \"p:cTn\",\n              {\n                id: ids.effect,\n                dur,\n                fill: \"hold\",\n              },\n              [buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`])],\n            ),\n            tgtEl,\n          ]),\n        ]),\n      );\n      break;\n\n    case \"colorChange\": {\n      const color = options.color ?? \"FF0000\";\n      const animClrAttrs: Record<string, string | undefined> = {};\n      if (options.colorSpace !== undefined) animClrAttrs.clrSpc = options.colorSpace;\n      const animClrChildren: string[] = [\n        buildXml(\"p:cBhvr\", undefined, [\n          buildXml(\n            \"p:cTn\",\n            {\n              id: ids.effect,\n              dur,\n              fill: \"hold\",\n            },\n            [buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`])],\n          ),\n          tgtEl,\n        ]),\n      ];\n      // p:by (color animation by value — rgb or hsl). p:rgb/p:hsl channels are\n      // ST_Percentage: Office writes per-mille integers, and the SDK's schema\n      // only accepts that form — normalize \"N%\" strings to N×1000.\n      const pct = (s: string): string =>\n        s.endsWith(\"%\") ? String(Math.round(parseFloat(s) * 1000)) : s;\n      if (options.colorByRgb) {\n        animClrChildren.push(\n          buildXml(\"p:by\", undefined, [\n            `<p:rgb r=\"${pct(options.colorByRgb.r)}\" g=\"${pct(options.colorByRgb.g)}\" b=\"${pct(options.colorByRgb.b)}\"/>`,\n          ]),\n        );\n      } else if (options.colorByHsl) {\n        animClrChildren.push(\n          buildXml(\"p:by\", undefined, [\n            `<p:hsl h=\"${pct(options.colorByHsl.h)}\" s=\"${pct(options.colorByHsl.s)}\" l=\"${pct(options.colorByHsl.l)}\"/>`,\n          ]),\n        );\n      }\n      // p:from (color animation from value)\n      if (options.colorFrom) {\n        animClrChildren.push(\n          buildXml(\"p:from\", undefined, [`<a:srgbClr val=\"${options.colorFrom}\"/>`]),\n        );\n      }\n      // p:to (color animation to value)\n      animClrChildren.push(\n        buildXml(\"p:to\", undefined, [`<a:srgbClr val=\"${options.colorTo ?? color}\"/>`]),\n      );\n      children.push(buildXml(\"p:animClr\", animClrAttrs, animClrChildren));\n      break;\n    }\n\n    case \"transparency\":\n      children.push(\n        buildXml(\n          \"p:anim\",\n          {\n            calcmode: \"lin\",\n            valueType: \"num\",\n            from: \"0\",\n            to: \"1\",\n          },\n          [\n            buildXml(\"p:cBhvr\", undefined, [\n              buildXml(\"p:cTn\", {\n                id: ids.effect,\n                dur,\n                fill: \"hold\",\n              }),\n              tgtEl,\n              buildXml(\"p:attrNameLst\", undefined, [`<p:attrName>style.opacity</p:attrName>`]),\n            ]),\n          ],\n        ),\n      );\n      break;\n\n    default:\n      // boldFlash, wave, pulse, growWithTurn — use p:animEffect with emph filter\n      children.push(\n        buildXml(\n          \"p:animEffect\",\n          {\n            transition: \"in\",\n            filter: emphType,\n          },\n          [\n            buildXml(\"p:cBhvr\", undefined, [\n              buildXml(\"p:cTn\", {\n                id: ids.effect,\n                dur,\n                fill: \"hold\",\n              }),\n              tgtEl,\n            ]),\n          ],\n        ),\n      );\n      break;\n  }\n\n  return children;\n}\n\nfunction buildPathEffects(\n  options: AnimationOptions,\n  spid: number,\n  ids: { set: number; effect: number },\n): string[] {\n  const pathStr = options.path ?? PATH_STRINGS[options.pathType ?? \"customPath\"] ?? \"\";\n  const dur = String(options.duration ?? 1000);\n\n  const animMotionAttrs: Record<string, string | undefined> = {\n    origin: \"layout\",\n    path: pathStr,\n  };\n  if (options.pointsTypes) animMotionAttrs.ptsTypes = options.pointsTypes;\n  if (options.pathEditMode) animMotionAttrs.pathEditMode = options.pathEditMode;\n  // @rAng is ST_Angle (1/60000 degree); the API exposes degrees.\n  if (options.rotationAngle !== undefined)\n    animMotionAttrs.rAng = String(Math.round(options.rotationAngle * 60000));\n\n  const animMotionChildren: string[] = [\n    buildXml(\"p:cBhvr\", undefined, [\n      buildXml(\n        \"p:cTn\",\n        {\n          id: ids.effect,\n          dur,\n          fill: \"hold\",\n        },\n        [buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`])],\n      ),\n      buildTargetElement(spid, options),\n    ]),\n  ];\n\n  // Motion path from/rCtr (A5)\n  if (options.motionFrom) {\n    animMotionChildren.push(`<p:from x=\"${options.motionFrom.x}\" y=\"${options.motionFrom.y}\"/>`);\n  }\n  if (options.motionRotationCenter) {\n    animMotionChildren.push(\n      `<p:rCtr x=\"${options.motionRotationCenter.x}\" y=\"${options.motionRotationCenter.y}\"/>`,\n    );\n  }\n\n  return [buildXml(\"p:animMotion\", animMotionAttrs, animMotionChildren)];\n}\n\n/**\n * Build p:cmd for media play/pause/stop (goes inside the animation sequence).\n * PowerPoint uses p:cmd type=\"call\" cmd=\"playFrom(0.0)\" for video play.\n */\nfunction buildMediaPlayCommand(\n  options: AnimationOptions,\n  spid: number,\n  ids: { cmd: number },\n): string {\n  const cmdStr = options.fullScreen ? \"playFrom(0.0,1.0)\" : \"playFrom(0.0)\";\n\n  return buildXml(\"p:cmd\", { type: \"call\", cmd: cmdStr }, [\n    buildXml(\"p:cBhvr\", undefined, [\n      buildXml(\"p:cTn\", {\n        id: ids.cmd,\n        dur: String(options.duration ?? 10000),\n        fill: \"hold\",\n      }),\n      buildTargetElement(spid),\n    ]),\n  ]);\n}\n\n/**\n * Build generic p:cmd with configurable type (call/evt/verb).\n */\nfunction buildCommand(options: AnimationOptions, spid: number, ids: { cmd: number }): string {\n  const cmdType = options.commandType ?? \"call\";\n  const cmdStr = options.command ?? \"\";\n\n  return buildXml(\"p:cmd\", { type: cmdType, cmd: cmdStr }, [\n    buildXml(\"p:cBhvr\", undefined, [\n      buildXml(\"p:cTn\", {\n        id: ids.cmd,\n        dur: String(options.duration ?? 1000),\n        fill: \"hold\",\n      }),\n      buildTargetElement(spid),\n    ]),\n  ]);\n}\n\n/**\n * Build p:set for an instant property change (setBehavior).\n */\nfunction buildSetBehavior(\n  setOptions: NonNullable<AnimationOptions[\"setBehavior\"]>,\n  spid: number,\n  ids: { set: number },\n): string {\n  const toValName = setOptions.toType === \"number\" ? \"p:numVal\" : \"p:strVal\";\n\n  return buildXml(\"p:set\", undefined, [\n    buildXml(\"p:cBhvr\", undefined, [\n      buildXml(\"p:cTn\", { id: ids.set, dur: \"1\", fill: \"hold\" }, [\n        buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`]),\n      ]),\n      buildTargetElement(spid),\n      buildXml(\"p:attrNameLst\", undefined, [\n        `<p:attrName>${escapeXml(setOptions.attributeName)}</p:attrName>`,\n      ]),\n    ]),\n    buildXml(\"p:to\", undefined, [`<${toValName} val=\"${setOptions.toValue}\"/>`]),\n  ]);\n}\n\n/**\n * Build p:iterate for text-level animation iteration.\n */\nfunction buildIterate(iterate: NonNullable<AnimationOptions[\"iterate\"]>): string {\n  const attrs: Record<string, string | number | undefined> = {};\n  if (iterate.type) attrs.type = xsdIterateType.to(iterate.type);\n  if (iterate.backwards) attrs.backwards = 1;\n\n  const iterChildren: string[] = [];\n  if (iterate.iteratePercentage !== undefined) {\n    iterChildren.push(`<p:tmPct val=\"${iterate.iteratePercentage * 1000}\"/>`);\n  } else if (iterate.interval !== undefined) {\n    iterChildren.push(`<p:tmAbs val=\"${iterate.interval}\"/>`);\n  }\n\n  return buildXml(\"p:iterate\", attrs, iterChildren.length > 0 ? iterChildren : undefined);\n}\n\n/**\n * Build p:animVariant value child (boolVal|intVal|fltVal|strVal|clrVal).\n */\nfunction buildVariantValue(variant: AnimationVariantOptions): string {\n  if (variant.bool !== undefined) {\n    return `<p:boolVal val=\"${variant.bool ? 1 : 0}\"/>`;\n  }\n  if (variant.int !== undefined) {\n    return `<p:intVal val=\"${variant.int}\"/>`;\n  }\n  if (variant.float !== undefined) {\n    return `<p:fltVal val=\"${variant.float}\"/>`;\n  }\n  if (variant.color !== undefined) {\n    return buildXml(\"p:clrVal\", undefined, [`<a:srgbClr val=\"${variant.color}\"/>`]);\n  }\n  // string fallback\n  return `<p:strVal val=\"${variant.string ?? \"\"}\"/>`;\n}\n\n/**\n * Build a condition element (p:cond) from EndConditionOptions.\n */\nfunction buildCondition(cond: EndConditionOptions): string {\n  const attrs: Record<string, string | number | undefined> = {};\n  if (cond.delay !== undefined) attrs.delay = cond.delay;\n  if (cond.event !== undefined) attrs.evt = cond.event;\n\n  const children: string[] = [];\n  if (cond.timeNodeId !== undefined) {\n    children.push(`<p:tn val=\"${cond.timeNodeId}\"/>`);\n  } else if (cond.runtimeNode !== undefined) {\n    children.push(`<p:rtn val=\"${cond.runtimeNode}\"/>`);\n  }\n\n  return buildXml(\"p:cond\", attrs, children.length > 0 ? children : undefined);\n}\n\n/**\n * Build p:video/p:audio with p:cMediaNode (goes as sibling of p:seq).\n * This is the media state controller, separate from the play command.\n */\nfunction buildMediaStateNode(\n  options: AnimationOptions,\n  spid: number,\n  ids: { mediaCtn: number },\n): string {\n  const isVideo = options.mediaType === \"playVideo\";\n  const elementName = isVideo ? \"p:video\" : \"p:audio\";\n\n  const mediaAttrs: Record<string, string | number | boolean | undefined> = {};\n  if (!isVideo && options.isNarration) {\n    mediaAttrs.isNarration = true;\n  }\n  if (isVideo && options.fullScreen) {\n    mediaAttrs.fullScrn = true;\n  }\n\n  const cMediaNodeAttrs: Record<string, string | number | undefined> = {};\n  if (options.volume !== undefined) {\n    cMediaNodeAttrs.vol = options.volume * 1000;\n  } else {\n    cMediaNodeAttrs.vol = 80000;\n  }\n  if (options.mute) {\n    cMediaNodeAttrs.mute = 1;\n  }\n  if (options.numberOfSlides !== undefined) {\n    cMediaNodeAttrs.numSld = options.numberOfSlides;\n  }\n  if (options.showWhenStopped !== undefined) {\n    cMediaNodeAttrs.showWhenStopped = options.showWhenStopped ? 1 : 0;\n  }\n\n  return buildXml(elementName, mediaAttrs, [\n    buildXml(\"p:cMediaNode\", cMediaNodeAttrs, [\n      buildXml(\n        \"p:cTn\",\n        {\n          id: ids.mediaCtn,\n          fill: \"hold\",\n          display: \"0\",\n        },\n        [buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"indefinite\"/>`])],\n      ),\n      buildTargetElement(spid),\n    ]),\n  ]);\n}\n\nfunction buildPropertyAnimation(\n  options: AnimationOptions,\n  spid: number,\n  ids: { cBhvr: number },\n): string {\n  const attrs: Record<string, string | undefined> = {};\n  if (options.calcMode) attrs.calcmode = xsdAnimCalcMode.to(options.calcMode);\n  if (options.valueType) attrs.valueType = xsdAnimValueType.to(options.valueType);\n  if (options.from !== undefined) attrs.from = options.from;\n  if (options.to !== undefined) attrs.to = options.to;\n  if (options.animBy !== undefined) attrs.by = options.animBy;\n  if (options.formula !== undefined) attrs.fmla = options.formula;\n  if (options.colorSpace !== undefined) attrs.clrSpc = options.colorSpace;\n\n  const cBhvrChildren: string[] = [\n    buildXml(\"p:cTn\", {\n      id: ids.cBhvr,\n      dur: String(options.duration ?? 500),\n      fill: \"hold\",\n    }),\n    buildTargetElement(spid, options),\n  ];\n\n  if (options.attributeName) {\n    cBhvrChildren.push(\n      buildXml(\"p:attrNameLst\", undefined, [\n        `<p:attrName>${escapeXml(options.attributeName)}</p:attrName>`,\n      ]),\n    );\n  }\n\n  const cBhvrAttrs: Record<string, string | number | undefined> = {};\n  if (options.additive !== undefined) cBhvrAttrs.additive = options.additive;\n  if (options.accumulate !== undefined) cBhvrAttrs.accumulate = options.accumulate;\n  if (options.transformType !== undefined) cBhvrAttrs.xfrmType = options.transformType;\n  if (options.runtimeContext !== undefined) cBhvrAttrs.rctx = options.runtimeContext;\n  if (options.override !== undefined) cBhvrAttrs.override = options.override;\n\n  const animChildren: string[] = [buildXml(\"p:cBhvr\", cBhvrAttrs, cBhvrChildren)];\n\n  // Build tavLst if from/to are specified (support variant value types)\n  if (\n    options.from !== undefined ||\n    options.to !== undefined ||\n    options.colorFrom ||\n    options.colorTo\n  ) {\n    const tavList: string[] = [];\n\n    // Build variant child for p:val\n    const buildVariantChild = (val: string, isColor?: boolean): string => {\n      if (isColor) {\n        return `<p:clrVal><a:srgbClr val=\"${val}\"/></p:clrVal>`;\n      }\n      if (options.variantInt !== undefined) {\n        return `<p:intVal val=\"${Number(val)}\"/>`;\n      }\n      if (options.variantFloat !== undefined) {\n        return `<p:fltVal val=\"${Number(val)}\"/>`;\n      }\n      if (options.variantBool !== undefined) {\n        return `<p:boolVal val=\"${val === \"true\" ? 1 : 0}\"/>`;\n      }\n      return `<p:strVal val=\"${val}\"/>`;\n    };\n\n    if (options.colorFrom) {\n      tavList.push(\n        buildXml(\"p:tav\", { tm: \"0\" }, [\n          buildXml(\"p:val\", undefined, [buildVariantChild(options.colorFrom, true)]),\n        ]),\n      );\n    } else if (options.from !== undefined) {\n      tavList.push(\n        buildXml(\"p:tav\", { tm: \"0\" }, [\n          buildXml(\"p:val\", undefined, [buildVariantChild(options.from)]),\n        ]),\n      );\n    }\n    if (options.colorTo) {\n      tavList.push(\n        buildXml(\"p:tav\", { tm: \"100000\" }, [\n          buildXml(\"p:val\", undefined, [buildVariantChild(options.colorTo, true)]),\n        ]),\n      );\n    } else if (options.to !== undefined) {\n      tavList.push(\n        buildXml(\"p:tav\", { tm: \"100000\" }, [\n          buildXml(\"p:val\", undefined, [buildVariantChild(options.to)]),\n        ]),\n      );\n    }\n    if (tavList.length > 0) {\n      animChildren.push(buildXml(\"p:tavLst\", undefined, tavList));\n    }\n  }\n\n  return buildXml(\"p:anim\", attrs, animChildren);\n}\n\n// --- Build list (bldLst) ---\n\nfunction buildBuildList(builds: ResolvedAnimationBuildOptions[], nextId: () => number): string {\n  const bldChildren: string[] = [];\n\n  for (const bld of builds) {\n    const bldAttrs: Record<string, string | number | undefined> = {\n      spid: bld.shapeId,\n      grpId: bld.groupId,\n    };\n    if (bld.uiExpand) bldAttrs.uiExpand = 1;\n\n    let elementName: string;\n    const bldChildrenInner: string[] = [];\n\n    switch (bld.type) {\n      case \"paragraph\": {\n        elementName = \"p:bldP\";\n        if (bld.build) bldAttrs.build = xsdTextBuild.to(bld.build);\n        if (bld.buildLevel !== undefined) bldAttrs.bldLvl = bld.buildLevel;\n        if (bld.animateBackground !== undefined) bldAttrs.animBg = bld.animateBackground ? 1 : 0;\n        if (bld.autoUpdateAnimateBackground !== undefined)\n          bldAttrs.autoUpdateAnimBg = bld.autoUpdateAnimateBackground ? 1 : 0;\n        if (bld.rev) bldAttrs.rev = 1;\n        if (bld.advanceAuto !== undefined) bldAttrs.advAuto = bld.advanceAuto;\n        // Templates (tmplLst) — p:tnLst requires at least one p:par, so a\n        // template with no children is dropped rather than emitted empty\n        if (bld.templates && bld.templates.length > 0) {\n          const tmplChildren = bld.templates\n            .filter((tmpl) => tmpl.children.length > 0)\n            .map((tmpl) => {\n              const tmplAttrs: Record<string, string | number | undefined> = {};\n              if (tmpl.lvl !== undefined) tmplAttrs.lvl = tmpl.lvl;\n              const tnLstChildren = tmpl.children.map(() => {\n                const tid = nextId();\n                return buildXml(\"p:par\", undefined, [`<p:cTn id=\"${tid}\"/>`]);\n              });\n              return buildXml(\"p:tmpl\", tmplAttrs, [buildXml(\"p:tnLst\", undefined, tnLstChildren)]);\n            });\n          if (tmplChildren.length > 0)\n            bldChildrenInner.push(buildXml(\"p:tmplLst\", undefined, tmplChildren));\n        }\n        break;\n      }\n      case \"diagram\": {\n        elementName = \"p:bldDgm\";\n        if (bld.diagramBuild) bldAttrs.bld = xsdDiagramBuild.to(bld.diagramBuild);\n        break;\n      }\n      case \"oleChart\": {\n        elementName = \"p:bldOleChart\";\n        if (bld.oleChartBuild) bldAttrs.bld = xsdChartBuild.to(bld.oleChartBuild);\n        if (bld.oleChartAnimateBackground !== undefined)\n          bldAttrs.animBg = bld.oleChartAnimateBackground ? 1 : 0;\n        break;\n      }\n      case \"graphic\": {\n        elementName = \"p:bldGraphic\";\n        if (bld.graphicBuildAsOne) {\n          bldChildrenInner.push(`<p:bldAsOne/>`);\n        } else {\n          const sub = bld.graphicSubBuild;\n          if (sub?.diagram) {\n            const dgmAttrs: Record<string, string | number> = {};\n            if (sub.diagram.build) dgmAttrs.bld = xsdAnimationDgmBuild.to(sub.diagram.build);\n            if (sub.diagram.reverse) dgmAttrs.rev = 1;\n            bldChildrenInner.push(\n              buildXml(\"p:bldSub\", undefined, [buildXml(\"a:bldDgm\", dgmAttrs)]),\n            );\n          } else if (sub?.chart) {\n            const chartAttrs: Record<string, string | number> = {};\n            if (sub.chart.build) chartAttrs.bld = xsdChartBuild.to(sub.chart.build);\n            if (sub.chart.animateBackground !== undefined)\n              chartAttrs.animBg = sub.chart.animateBackground ? 1 : 0;\n            bldChildrenInner.push(\n              buildXml(\"p:bldSub\", undefined, [buildXml(\"a:bldChart\", chartAttrs)]),\n            );\n          } else {\n            bldChildrenInner.push(`<p:bldSub/>`);\n          }\n        }\n        break;\n      }\n    }\n\n    bldChildren.push(\n      buildXml(elementName, bldAttrs, bldChildrenInner.length > 0 ? bldChildrenInner : undefined),\n    );\n  }\n\n  return buildXml(\"p:bldLst\", undefined, bldChildren);\n}\n\n// --- Main class ---\n\n/** One animated shape: the animation settings plus the target shape reference. */\nexport interface AnimationEntry extends AnimationOptions {\n  /**\n   * Target shape's cNvPr id. Round-tripped sources keep the parsed value;\n   * fresh authoring prefers shapeName (an explicit id must not collide with\n   * the library's auto-assigned id stream).\n   */\n  shapeId?: number;\n  /**\n   * Target shape's cNvPr name — resolved to its id at compile time against the\n   * shapes of the same slide/layout/master. Unknown or duplicated names throw\n   * rather than emitting a dangling spTgt `@spid`.\n   */\n  shapeName?: string;\n}\n\n/** An AnimationBuildOptions with its shape reference resolved to a concrete id. */\nexport interface ResolvedAnimationBuildOptions extends AnimationBuildOptions {\n  shapeId: number;\n}\n\n/** An AnimationEntry with its shape reference resolved to a concrete id. */\nexport interface ResolvedAnimationEntry extends AnimationEntry {\n  shapeId: number;\n  builds?: ResolvedAnimationBuildOptions[];\n}\n\n/**\n * The slide timing tree: structured animation entries, or the verbatim inner\n * XML of p:timing when the source exceeds what the model rebuilds (so exotic\n * timing survives round-trip).\n */\nexport type AnimationsOptions = AnimationEntry[] | string;\n\n/**\n * p:timing — Slide timing for shape animations.\n *\n * Pure collector — no XmlComponent inheritance.\n * Collects string children and serializes via `toXml()`.\n */\nexport class SlideTiming {\n  private parts: string[] = [];\n\n  public constructor(entries: ResolvedAnimationEntry[]) {\n    if (entries.length === 0) return;\n\n    let id = 1;\n    const rootCtnId = id++;\n    const seqCtnId = id++;\n\n    // Check for builds from first entry\n    const builds = entries[0]?.builds;\n    const previousAction = entries[0]?.previousAction;\n\n    const animationNodes: string[] = [];\n    const mediaStateNodes: string[] = [];\n    let clickGroupDelay = 0;\n\n    for (const [i, entry] of entries.entries()) {\n      const { shapeId: spid, ...options } = entry;\n\n      const nodeType =\n        options.trigger === \"withPrevious\"\n          ? \"withEffect\"\n          : options.trigger === \"afterPrevious\"\n            ? \"afterEffect\"\n            : \"clickEffect\";\n\n      if (options.trigger === \"afterPrevious\" && i > 0) {\n        clickGroupDelay += (options.duration ?? 500) + (options.delay ?? 0);\n      }\n      if (options.trigger === \"onClick\" || options.trigger === undefined) {\n        clickGroupDelay = 0;\n      }\n\n      const groupCtnId = id++;\n      const effectCtnId = id++;\n      const setCtnId = id++;\n      const effectCtnId2 = id++;\n\n      const presetId = resolvePresetId(options);\n      const presetClass = resolvePresetClass(options);\n      const presetSubtype = resolvePresetSubtype(options);\n\n      // Build effect children based on animation class\n      let effectChildren: string[];\n\n      if (options.commandType) {\n        effectChildren = [buildCommand(options, spid, { cmd: effectCtnId2 })];\n      } else if (options.mediaType) {\n        effectChildren = [buildMediaPlayCommand(options, spid, { cmd: effectCtnId2 })];\n        // Generate media state node (p:video/p:audio) as sibling of p:seq\n        const mediaStateId = id++;\n        mediaStateNodes.push(buildMediaStateNode(options, spid, { mediaCtn: mediaStateId }));\n      } else if (options.attributeName) {\n        effectChildren = [buildPropertyAnimation(options, spid, { cBhvr: effectCtnId2 })];\n      } else if (options.pathType) {\n        effectChildren = buildPathEffects(options, spid, {\n          set: setCtnId,\n          effect: effectCtnId2,\n        });\n      } else if (presetClass === \"emphasis\") {\n        effectChildren = buildEmphasisEffects(options, spid, {\n          set: setCtnId,\n          effect: effectCtnId2,\n        });\n      } else {\n        effectChildren = buildEntrOrExitEffects(options, spid, {\n          set: setCtnId,\n          effect: effectCtnId2,\n        });\n      }\n\n      // Prepend a p:set for setBehavior (if specified)\n      if (options.setBehavior) {\n        const setBehId = id++;\n        effectChildren = [\n          buildSetBehavior(options.setBehavior, spid, { set: setBehId }),\n          ...effectChildren,\n        ];\n      }\n\n      // Build cTn attributes with optional speed/repeatCount/autoReverse\n      const cTnAttrs: Record<string, string | number | undefined> = {\n        id: effectCtnId,\n        fill: \"hold\",\n        nodeType,\n      };\n      if (!options.mediaType && !options.attributeName) {\n        cTnAttrs.presetID = presetId;\n        cTnAttrs.presetClass = xsdAnimClass.to(presetClass);\n        cTnAttrs.presetSubtype = presetSubtype;\n      }\n      if (options.mediaType) {\n        cTnAttrs.presetID = presetId;\n        cTnAttrs.presetClass = xsdAnimClass.to(presetClass);\n        cTnAttrs.presetSubtype = presetSubtype;\n      }\n      if (options.speed !== undefined) cTnAttrs.spd = String(options.speed * 1000);\n      if (options.repeatCount !== undefined) cTnAttrs.repeatCount = String(options.repeatCount);\n      if (options.autoReverse) cTnAttrs.autoRev = 1;\n      if (options.repeatDuration !== undefined) cTnAttrs.repeatDur = options.repeatDuration;\n      if (options.acceleration !== undefined) cTnAttrs.accel = options.acceleration * 1000;\n      if (options.deceleration !== undefined) cTnAttrs.decel = options.deceleration * 1000;\n      if (options.restart !== undefined) cTnAttrs.restart = options.restart;\n      if (options.syncBehavior !== undefined) cTnAttrs.syncBehavior = options.syncBehavior;\n      if (options.timeFilter !== undefined) cTnAttrs.tmFilter = options.timeFilter;\n      if (options.eventFilter !== undefined) cTnAttrs.evtFilter = options.eventFilter;\n      if (options.display !== undefined) cTnAttrs.display = options.display ? 1 : 0;\n      if (options.masterRelation !== undefined) cTnAttrs.masterRel = options.masterRelation;\n      if (options.buildLevel !== undefined) cTnAttrs.bldLvl = options.buildLevel;\n      if (options.groupId !== undefined) cTnAttrs.grpId = options.groupId;\n      if (options.afterEffect !== undefined) cTnAttrs.afterEffect = options.afterEffect ? 1 : 0;\n      if (options.nodePlaceholder !== undefined) cTnAttrs.nodePh = options.nodePlaceholder ? 1 : 0;\n      if (options.advanceAfterTime !== undefined) cTnAttrs.advAuto = options.advanceAfterTime;\n      if (options.animateBackground !== undefined)\n        cTnAttrs.animBg = options.animateBackground ? 1 : 0;\n      if (options.autoUpdateAnimationBackground !== undefined)\n        cTnAttrs.autoUpdateAnimBg = options.autoUpdateAnimationBackground ? 1 : 0;\n\n      // Build effect cTn\n      const effectCtnChildren: string[] = [\n        buildXml(\"p:stCondLst\", undefined, [\n          buildXml(\"p:cond\", { delay: String(options.delay ?? 0) }),\n        ]),\n      ];\n\n      // Add endCondLst (A2)\n      if (options.endConditions && options.endConditions.length > 0) {\n        effectCtnChildren.push(\n          buildXml(\"p:endCondLst\", undefined, options.endConditions.map(buildCondition)),\n        );\n      }\n\n      // Add endSync (A2) — directly CT_TLTimeCondition, no cond wrapper\n      if (options.endSyncCondition) {\n        const syncAttrs: Record<string, string | undefined> = {};\n        if (options.endSyncCondition.delay !== undefined)\n          syncAttrs.delay = options.endSyncCondition.delay;\n        if (options.endSyncCondition.event !== undefined)\n          syncAttrs.evt = options.endSyncCondition.event;\n\n        const syncChildren: string[] = [];\n        if (options.endSyncCondition.timeNodeId !== undefined) {\n          syncChildren.push(`<p:tn val=\"${options.endSyncCondition.timeNodeId}\"/>`);\n        } else if (options.endSyncCondition.runtimeNode !== undefined) {\n          syncChildren.push(`<p:rtn val=\"${options.endSyncCondition.runtimeNode}\"/>`);\n        }\n\n        effectCtnChildren.push(\n          buildXml(\"p:endSync\", syncAttrs, syncChildren.length > 0 ? syncChildren : undefined),\n        );\n      }\n\n      // Add iterate container if specified (CT_TLCommonTimeNodeData places\n      // iterate after endSync, before childTnLst)\n      if (options.iterate) {\n        effectCtnChildren.push(buildIterate(options.iterate));\n      }\n\n      // Add childTnLst with possible excl wrapper\n      const childTnListChildren = options.exclusiveMode\n        ? [\n            buildXml(\"p:excl\", undefined, [\n              buildXml(\"p:cTn\", { id: id++ }, [\n                buildXml(\"p:childTnLst\", undefined, effectChildren),\n              ]),\n            ]),\n          ]\n        : effectChildren;\n\n      effectCtnChildren.push(buildXml(\"p:childTnLst\", undefined, childTnListChildren));\n\n      // Add subTnLst (A2)\n      if (options.subTimeNodes && options.subTimeNodes.length > 0) {\n        effectCtnChildren.push(\n          buildXml(\n            \"p:subTnLst\",\n            undefined,\n            options.subTimeNodes.map((subOpts: AnimationOptions) => {\n              const subId = id++;\n              return buildXml(\"p:par\", undefined, [\n                buildXml(\n                  \"p:cTn\",\n                  {\n                    id: subId,\n                    dur: String(subOpts.duration ?? 0),\n                  },\n                  [\n                    buildXml(\"p:stCondLst\", undefined, [\n                      buildXml(\"p:cond\", { delay: String(subOpts.delay ?? 0) }),\n                    ]),\n                  ],\n                ),\n              ]);\n            }),\n          ),\n        );\n      }\n\n      const effectCtn = buildXml(\"p:cTn\", cTnAttrs, effectCtnChildren);\n\n      // Wrap in inner par\n      const innerPar = buildXml(\"p:par\", undefined, [effectCtn]);\n\n      // Wrap in outer par (click group)\n      const outerPar = buildXml(\"p:par\", undefined, [\n        buildXml(\n          \"p:cTn\",\n          {\n            id: groupCtnId,\n            fill: \"hold\",\n          },\n          [\n            buildXml(\"p:stCondLst\", undefined, [`<p:cond delay=\"0\"/>`]),\n            buildXml(\"p:childTnLst\", undefined, [innerPar]),\n          ],\n        ),\n      ]);\n\n      animationNodes.push(outerPar);\n    }\n\n    // Assemble the full timing tree\n    const seqAttrs: Record<string, string | number | undefined> = {\n      concurrent: 1,\n      nextAc: \"seek\",\n    };\n    if (previousAction !== undefined) seqAttrs.prevAc = previousAction;\n\n    this.parts.push(\n      buildXml(\"p:tnLst\", undefined, [\n        buildXml(\"p:par\", undefined, [\n          buildXml(\n            \"p:cTn\",\n            {\n              id: rootCtnId,\n              dur: \"indefinite\",\n              restart: \"never\",\n              nodeType: \"tmRoot\",\n            },\n            [\n              buildXml(\"p:childTnLst\", undefined, [\n                buildXml(\"p:seq\", seqAttrs, [\n                  buildXml(\n                    \"p:cTn\",\n                    {\n                      id: seqCtnId,\n                      dur: \"indefinite\",\n                      nodeType: \"mainSeq\",\n                    },\n                    [buildXml(\"p:childTnLst\", undefined, animationNodes)],\n                  ),\n                  buildXml(\"p:prevCondLst\", undefined, [\n                    buildXml(\"p:cond\", { evt: \"onPrev\", delay: \"0\" }, [\n                      buildXml(\"p:tgtEl\", undefined, [`<p:sldTgt/>`]),\n                    ]),\n                  ]),\n                  buildXml(\"p:nextCondLst\", undefined, [\n                    buildXml(\"p:cond\", { evt: \"onNext\", delay: \"0\" }, [\n                      buildXml(\"p:tgtEl\", undefined, [`<p:sldTgt/>`]),\n                    ]),\n                  ]),\n                ]),\n                ...mediaStateNodes,\n              ]),\n            ],\n          ),\n        ]),\n      ]),\n    );\n\n    // bldLst — sibling of tnLst in p:timing (CT_SlideTiming: tnLst → bldLst → extLst)\n    if (builds) {\n      this.parts.push(buildBuildList(builds, () => id++));\n    }\n  }\n\n  /** Serialize to p:timing XML string. */\n  public toXml(): string {\n    if (this.parts.length === 0) return \"\";\n    const body = this.parts.join(\"\");\n    return body ? `<p:timing>${body}</p:timing>` : \"\";\n  }\n}\n","/**\n * Animation timing (p:timing) descriptor for PPTX.\n *\n * @module\n */\n\nimport {\n  parseOnOff,\n  xsdAnimCalcMode,\n  xsdAnimClass,\n  xsdAnimValueType,\n  xsdIterateType,\n} from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, findChild, findFirst, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport type {\n  AnimationEntry,\n  AnimationsOptions,\n  ResolvedAnimationBuildOptions,\n  ResolvedAnimationEntry,\n} from \"@shared/animation/timing\";\nimport { SlideTiming } from \"@shared/animation/timing\";\nimport {\n  DIRECTION_SUBTYPES,\n  EMPH_PRESET_IDS,\n  ENTR_PRESET_IDS,\n  EXIT_PRESET_IDS,\n  PATH_PRESET_IDS,\n} from \"@shared/animation/timing\";\nimport type {\n  AnimationClass,\n  AnimationOptions,\n  AnimationType,\n  EmphasisType,\n  PathAnimationType,\n} from \"@shared/animation/types\";\n\nimport type { PptxWriteContext } from \"../../context\";\n\n// ── Reverse lookup maps: presetID → type name ──\n// Built from the single stringify-side tables in shared/animation/timing.ts.\n\nconst ENTR_PRESET_TO_TYPE = new Map<number, AnimationType>();\nconst EXIT_PRESET_TO_TYPE = new Map<number, AnimationType>();\nconst EMPH_PRESET_TO_ID = new Map<number, EmphasisType>();\nconst PATH_PRESET_TO_TYPE = new Map<number, PathAnimationType>();\n\nfor (const [k, v] of Object.entries(ENTR_PRESET_IDS))\n  ENTR_PRESET_TO_TYPE.set(v, k as AnimationType);\nfor (const [k, v] of Object.entries(EXIT_PRESET_IDS))\n  EXIT_PRESET_TO_TYPE.set(v, k as AnimationType);\nfor (const [k, v] of Object.entries(EMPH_PRESET_IDS)) EMPH_PRESET_TO_ID.set(v, k as EmphasisType);\nfor (const [k, v] of Object.entries(PATH_PRESET_IDS))\n  PATH_PRESET_TO_TYPE.set(v, k as PathAnimationType);\n\n// Direction subtype reverse map\nconst SUBTYPE_TO_DIRECTION = new Map<number, string>();\nfor (const [k, v] of Object.entries(DIRECTION_SUBTYPES)) SUBTYPE_TO_DIRECTION.set(v, k);\n\n// ── Parse helpers ──\n\n/**\n * Parse p:timing element and return animation entries grouped by shape ID.\n * A shape can carry several effects (e.g. entrance + emphasis), so each\n * parsed effect becomes its own entry instead of overwriting the previous one.\n */\nfunction parseTiming(el: XmlElement): Map<number, AnimationOptions[]> {\n  const result = new Map<number, AnimationOptions[]>();\n\n  const tnLst = findChild(el, \"p:tnLst\");\n  if (!tnLst) return result;\n\n  const mainPar = findChild(tnLst, \"p:par\");\n  if (!mainPar) return result;\n\n  const mainCTn = findChild(mainPar, \"p:cTn\");\n  if (!mainCTn) return result;\n\n  const childTnLst = findChild(mainCTn, \"p:childTnLst\");\n  if (!childTnLst) return result;\n\n  const seq = findChild(childTnLst, \"p:seq\");\n  if (!seq) return result;\n\n  const seqCTn = findChild(seq, \"p:cTn\");\n  const seqChildTnLst = seqCTn ? findChild(seqCTn, \"p:childTnLst\") : undefined;\n  if (!seqChildTnLst) return result;\n\n  for (const parEl of seqChildTnLst.elements ?? []) {\n    if (parEl.name !== \"p:par\") continue;\n\n    const parCTn = findChild(parEl, \"p:cTn\");\n    if (!parCTn) continue;\n\n    const parChildTnLst = findChild(parCTn, \"p:childTnLst\");\n    if (!parChildTnLst) continue;\n\n    for (const effectEl of parChildTnLst.elements ?? []) {\n      const anim = parseAnimationEffect(effectEl);\n      if (!anim) continue;\n\n      const shapeId = extractTargetShapeId(effectEl);\n      if (shapeId !== undefined) {\n        const list = result.get(shapeId);\n        if (list) list.push(anim);\n        else result.set(shapeId, [anim]);\n      }\n    }\n  }\n\n  return result;\n}\n\nfunction parseAnimationEffect(el: XmlElement): AnimationOptions | undefined {\n  const opts: Partial<AnimationOptions> = {};\n\n  const cTn = findChild(el, \"p:cTn\") ?? el;\n\n  const nodeType = attr(cTn, \"nodeType\");\n  if (nodeType === \"clickEffect\") opts.trigger = \"onClick\";\n  else if (nodeType === \"withEffect\") opts.trigger = \"withPrevious\";\n  else if (nodeType === \"afterEffect\") opts.trigger = \"afterPrevious\";\n\n  const presetClassAttr = attr(cTn, \"presetClass\");\n  const presetClass = presetClassAttr\n    ? (xsdAnimClass.from(presetClassAttr) as AnimationClass)\n    : undefined;\n  if (presetClass) opts.class = presetClass;\n\n  const presetID = attrNum(cTn, \"presetID\");\n\n  const dur = attr(cTn, \"dur\");\n  if (dur) {\n    const ms = parseDuration(dur);\n    if (ms !== undefined) opts.duration = ms;\n  }\n\n  const stCondLst = findChild(cTn, \"p:stCondLst\");\n  if (stCondLst) {\n    const cond = findChild(stCondLst, \"p:cond\");\n    if (cond) {\n      const delay = attr(cond, \"delay\");\n      if (delay) {\n        const ms = parseDuration(delay);\n        if (ms !== undefined) opts.delay = ms;\n      }\n    }\n  }\n\n  const presetSubtype = attrNum(cTn, \"presetSubtype\");\n  if (presetSubtype !== undefined) {\n    const dir = SUBTYPE_TO_DIRECTION.get(presetSubtype);\n    if (dir) opts.direction = dir as AnimationOptions[\"direction\"];\n  }\n\n  if (presetID !== undefined) {\n    const cls = presetClass ?? \"entrance\";\n    if (cls === \"entrance\") {\n      const type = ENTR_PRESET_TO_TYPE.get(presetID);\n      if (type) opts.type = type;\n    } else if (cls === \"exit\") {\n      const type = EXIT_PRESET_TO_TYPE.get(presetID);\n      if (type) opts.type = type;\n    } else if (cls === \"emphasis\") {\n      const emphType = EMPH_PRESET_TO_ID.get(presetID);\n      if (emphType) {\n        opts.emphasisType = emphType;\n        opts.type = \"appear\";\n      }\n    } else if (cls === \"mediaCall\") {\n      opts.mediaType = \"play\";\n      opts.type = \"appear\";\n    }\n  }\n\n  const childTnLst = findChild(cTn, \"p:childTnLst\");\n  if (childTnLst) {\n    for (const sub of childTnLst.elements ?? []) {\n      switch (sub.name) {\n        case \"p:animEffect\": {\n          if (opts.duration === undefined) {\n            const cBhvr = findChild(sub, \"p:cBhvr\");\n            const subCTn = cBhvr ? findChild(cBhvr, \"p:cTn\") : undefined;\n            if (subCTn) {\n              const subDur = attr(subCTn, \"dur\");\n              if (subDur) {\n                const ms = parseDuration(subDur);\n                if (ms !== undefined) opts.duration = ms;\n              }\n            }\n          }\n          break;\n        }\n        case \"p:anim\": {\n          // CT_TLAnimateBehavior attributes — from/to/by/calcmode/valueType\n          const calcMode = attr(sub, \"calcmode\");\n          if (calcMode)\n            opts.calcMode = xsdAnimCalcMode.from(calcMode) as AnimationOptions[\"calcMode\"];\n          const valueType = attr(sub, \"valueType\");\n          if (valueType)\n            opts.valueType = xsdAnimValueType.from(valueType) as AnimationOptions[\"valueType\"];\n          const fromAttr = attr(sub, \"from\");\n          if (fromAttr) opts.from = fromAttr;\n          const toAttr = attr(sub, \"to\");\n          if (toAttr) opts.to = toAttr;\n          const byAttr = attr(sub, \"by\");\n          if (byAttr) opts.animBy = byAttr;\n\n          const cBhvr = findChild(sub, \"p:cBhvr\");\n          if (cBhvr) {\n            const attrName = findChild(cBhvr, \"p:attrNameLst\");\n            if (attrName) {\n              const name = findChild(attrName, \"p:attrName\");\n              if (name) {\n                const text = name.elements?.[0]?.text;\n                if (text) opts.attributeName = text as string;\n              }\n            }\n          }\n          const from = findChild(sub, \"p:cb\");\n          if (from) {\n            const val = findChild(from, \"p:val\");\n            if (val) {\n              const v = attr(val, \"val\");\n              if (v) opts.from = v;\n            }\n          }\n          const toEl = findChild(sub, \"p:tavLst\");\n          if (toEl) {\n            const tav = findChild(toEl, \"p:tav\");\n            if (tav) {\n              const toVal = findChild(tav, \"p:val\");\n              if (toVal) {\n                const v = attr(toVal, \"val\");\n                if (v) opts.to = v;\n              }\n            }\n          }\n          break;\n        }\n        case \"p:animMotion\": {\n          opts.pathType = \"customPath\" as PathAnimationType;\n          const path = attr(sub, \"path\");\n          if (path) opts.path = path;\n          // @rAng is ST_Angle (1/60000 degree); the API exposes degrees.\n          const rAng = attrNum(sub, \"rAng\");\n          if (rAng !== undefined) opts.rotationAngle = rAng / 60000;\n          break;\n        }\n        case \"p:animScale\": {\n          opts.emphasisType = \"growShrink\" as EmphasisType;\n          readSubDuration(sub, opts);\n          break;\n        }\n        case \"p:animRot\": {\n          opts.emphasisType = \"spin\" as EmphasisType;\n          readSubDuration(sub, opts);\n          break;\n        }\n        case \"p:animClr\": {\n          opts.emphasisType = \"colorChange\" as EmphasisType;\n          const clrSpc = attr(sub, \"clrSpc\");\n          if (clrSpc) opts.colorSpace = clrSpc as AnimationOptions[\"colorSpace\"];\n          readSubDuration(sub, opts);\n          break;\n        }\n        case \"p:cmd\": {\n          // mediaType belongs to mediacall-preset effects (set via presetClass);\n          // a bare command must stay a command or the rebuild path would emit\n          // playFrom(0.0) instead of the authored cmd string.\n          const cmdType = attr(sub, \"type\");\n          if (cmdType) opts.commandType = cmdType as AnimationOptions[\"commandType\"];\n          const cmdStr = attr(sub, \"cmd\");\n          if (cmdStr) opts.command = cmdStr;\n          break;\n        }\n      }\n    }\n  }\n\n  // p:iterate — direct child of cTn (CT_TLCommonTimeNodeData sequence places\n  // it before childTnLst, not inside it). tmPct carries percent, tmAbs ms.\n  const iterateEl = findChild(cTn, \"p:iterate\");\n  if (iterateEl) {\n    const iterate: NonNullable<AnimationOptions[\"iterate\"]> = {};\n    const iterType = attr(iterateEl, \"type\");\n    if (iterType)\n      iterate.type = xsdIterateType.from(iterType) as NonNullable<\n        AnimationOptions[\"iterate\"]\n      >[\"type\"];\n    if (parseOnOff(attr(iterateEl, \"backwards\"))) iterate.backwards = true;\n    const tmPct = findChild(iterateEl, \"p:tmPct\");\n    if (tmPct) {\n      const v = attrNum(tmPct, \"val\");\n      if (v !== undefined) iterate.iteratePercentage = v / 1000;\n    } else {\n      const tmAbs = findChild(iterateEl, \"p:tmAbs\");\n      if (tmAbs) {\n        const v = attrNum(tmAbs, \"val\");\n        if (v !== undefined) iterate.interval = v;\n      }\n    }\n    opts.iterate = iterate;\n  }\n\n  return Object.keys(opts).length > 0 ? (opts as AnimationOptions) : undefined;\n}\n\nfunction extractTargetShapeId(el: XmlElement): number | undefined {\n  const cBhvr = findFirst(el, \"p:cBhvr\");\n  if (!cBhvr) return undefined;\n\n  const tgtEl = findChild(cBhvr, \"p:tgtEl\");\n  if (!tgtEl) return undefined;\n\n  const spTgt = findChild(tgtEl, \"p:spTgt\");\n  if (!spTgt) return undefined;\n\n  return attrNum(spTgt, \"spid\");\n}\n\nfunction readSubDuration(sub: XmlElement, opts: Record<string, unknown>): void {\n  if (opts.duration !== undefined) return;\n  const cBhvr = findChild(sub, \"p:cBhvr\");\n  const subCTn = cBhvr ? findChild(cBhvr, \"p:cTn\") : undefined;\n  if (subCTn) {\n    const subDur = attr(subCTn, \"dur\");\n    if (subDur) {\n      const ms = parseDuration(subDur);\n      if (ms !== undefined) opts.duration = ms;\n    }\n  }\n}\n\nfunction parseDuration(val: string): number | undefined {\n  if (val.startsWith(\"PT\")) {\n    let ms = 0;\n    const sMatch = val.match(/(\\d+\\.?\\d*)S/);\n    if (sMatch) ms += Math.round(parseFloat(sMatch[1] ?? \"\") * 1000);\n    const mMatch = val.match(/(\\d+\\.?\\d*)M/);\n    if (mMatch) ms += Math.round(parseFloat(mMatch[1] ?? \"\") * 60000);\n    const hMatch = val.match(/(\\d+\\.?\\d*)H/);\n    if (hMatch) ms += Math.round(parseFloat(hMatch[1] ?? \"\") * 3600000);\n    return ms;\n  }\n  if (val === \"indefinite\") return undefined;\n  const num = parseInt(val, 10);\n  return isNaN(num) ? undefined : num;\n}\n\n// ── Descriptor ──\n\n/**\n * Resolve shapeName references against the part's shape-name symbol table so\n * every entry and build carries a concrete cNvPr id before SlideTiming\n * serializes. shapeId wins when both are set; neither is an authoring error.\n */\nfunction resolveAnimationShapeIds(\n  entries: AnimationEntry[],\n  ctx: PptxWriteContext,\n): ResolvedAnimationEntry[] {\n  const resolveShape = (ref: { shapeId?: number; shapeName?: string }): number => {\n    if (ref.shapeId !== undefined) return ref.shapeId;\n    if (ref.shapeName !== undefined) return ctx.resolveShapeName(ref.shapeName);\n    throw new Error(\n      \"Animation entry needs a target: set shapeName (preferred) or shapeId on the shape it animates.\",\n    );\n  };\n  return entries.map((entry): ResolvedAnimationEntry => {\n    const { shapeId, shapeName, builds, ...rest } = entry;\n    const resolved: ResolvedAnimationEntry = {\n      ...rest,\n      shapeId: resolveShape({ shapeId, shapeName }),\n    };\n    if (builds) {\n      resolved.builds = builds.map((bld): ResolvedAnimationBuildOptions => ({\n        ...bld,\n        shapeId: resolveShape(bld),\n      }));\n    }\n    return resolved;\n  });\n}\n\nexport const timingDesc: CustomDescriptor<AnimationsOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    // Verbatim fallback — the source tree the structured model cannot rebuild.\n    if (typeof opts === \"string\") return `<p:timing>${opts}</p:timing>`;\n    if (opts.length === 0) return \"\";\n    const timing = new SlideTiming(resolveAnimationShapeIds(opts, ctx as PptxWriteContext));\n    return timing.toXml();\n  },\n\n  parse(el, _ctx) {\n    const animMap = parseTiming(el);\n    const entries: ResolvedAnimationEntry[] = [];\n    for (const [shapeId, optionsList] of animMap) {\n      for (const options of optionsList) {\n        // Parsed options never carry builds (bldLst parses verbatim-side), so\n        // the shapeId from the spTgt map key is the only reference to fill.\n        entries.push({ ...options, shapeId } as ResolvedAnimationEntry);\n      }\n    }\n    // Fidelity gate: rebuilding reorganizes the timing tree, so compare the\n    // rebuilt tag multiset against the source — any drift (including trees the\n    // model extracts no entries from, like tmRoot-only timing) falls back to\n    // the verbatim inner XML rather than silently losing or reshaping nodes.\n    const rebuilt = new SlideTiming(entries).toXml();\n    const source = `<p:timing>${stringifyXml(el)}</p:timing>`;\n    if (rebuilt && sameTagMultiset(rebuilt, source)) return entries;\n    return stringifyXml(el);\n  },\n};\n\n/** Tag multiset of an XML string, keyed `<prefix:name` open tags. */\nfunction tagMultiset(xml: string, into: Map<string, number>): void {\n  for (const m of xml.matchAll(/<([\\w-]+:[\\w-]+)[ >/]/g)) {\n    into.set(m[1]!, (into.get(m[1]!) ?? 0) + 1);\n  }\n}\n\nfunction sameTagMultiset(rebuiltXml: string, sourceXml: string): boolean {\n  const a = new Map<string, number>();\n  const b = new Map<string, number>();\n  tagMultiset(rebuiltXml, a);\n  tagMultiset(sourceXml, b);\n  if (a.size !== b.size) return false;\n  for (const [tag, n] of a) {\n    if (b.get(tag) !== n) return false;\n  }\n  return true;\n}\n","/**\n * Background (p:bg) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport { parse as coreParse } from \"@office-open/core/descriptor\";\nimport { createEffectList, effectListDesc, fillDesc } from \"@office-open/core/drawing\";\nimport { stringifyColorChoice, parseColorChoiceElement } from \"@office-open/core/drawing\";\nimport { attrNum, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { buildFill } from \"@shared/drawing/fill\";\n\nimport type { BackgroundOptions, StyleMatrixReferenceOptions } from \"../background\";\n\n// ── Descriptor ──\n\nexport const backgroundDesc: CustomDescriptor<BackgroundOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    return stringifyBackgroundInner(opts, ctx);\n  },\n\n  parse(el, ctx) {\n    return parseBackground(el, ctx);\n  },\n};\n\n// ── Stringify ──\n\nfunction stringifyBackgroundInner(opts: BackgroundOptions, ctx: WriteContext): string {\n  // CT_Background declares an unprefixed @bwMode (a:ST_BlackWhiteMode).\n  const bgAttrs: string[] = [];\n  if (opts.blackWhiteMode) bgAttrs.push(` bwMode=\"${opts.blackWhiteMode}\"`);\n\n  // CT_Background is a choice: p:bgRef (theme style index) or p:bgPr (explicit fill).\n  if (opts.reference) {\n    const colorXml =\n      opts.reference.color !== undefined ? stringifyColorChoice(opts.reference.color, ctx) : \"\";\n    return `<p:bg${bgAttrs.join(\"\")}><p:bgRef idx=\"${opts.reference.index}\">${colorXml}</p:bgRef></p:bg>`;\n  }\n\n  const bgPrAttrs: string[] = [];\n  if (opts.shadeToTitle) bgPrAttrs.push(' shadeToTitle=\"1\"');\n\n  // buildFill skips a one-stop gradient (illegal gsLst) — a skipped fill falls\n  // back to noFill so p:bgPr always carries exactly one fill element\n  const fillXml = buildFill(opts.fill ?? { type: \"none\" }) ?? \"<a:noFill/>\";\n\n  let effectsXml = \"\";\n  if (opts.effects) {\n    effectsXml = createEffectList(opts.effects);\n  }\n\n  return `<p:bg${bgAttrs.join(\"\")}><p:bgPr${bgPrAttrs.join(\"\")}>${fillXml}${effectsXml}</p:bgPr></p:bg>`;\n}\n\n// ── Parse ──\n\nfunction parseBackground(el: XmlElement, ctx: ReadContext): BackgroundOptions {\n  const result: Partial<BackgroundOptions> = {};\n\n  if (el.attributes?.[\"bwMode\"]) {\n    result.blackWhiteMode = String(el.attributes[\"bwMode\"]) as BackgroundOptions[\"blackWhiteMode\"];\n  }\n\n  const bgRef = findChild(el, \"p:bgRef\");\n  if (bgRef) {\n    const reference: StyleMatrixReferenceOptions = { index: attrNum(bgRef, \"idx\") ?? 0 };\n    for (const child of bgRef.elements ?? []) {\n      const color = parseColorChoiceElement(child, ctx);\n      if (color) {\n        reference.color = color;\n        break;\n      }\n    }\n    result.reference = reference;\n    return result as BackgroundOptions;\n  }\n\n  const bgPr = findChild(el, \"p:bgPr\");\n  if (bgPr) {\n    if (parseOnOff(bgPr.attributes?.[\"shadeToTitle\"])) {\n      result.shadeToTitle = true;\n    }\n\n    // Fill — CT_BackgroundProperties requires an EG_FillProperties child, so\n    // parse always yields one ({ type: \"none\" } for a:noFill).\n    result.fill = coreParse(fillDesc, bgPr, ctx);\n\n    // Effects (a:effectLst) — an empty element stays (bare <a:effectLst/>).\n    const effectLst = findChild(bgPr, \"a:effectLst\");\n    if (effectLst) {\n      result.effects = coreParse(effectListDesc, effectLst, ctx);\n    }\n  }\n\n  return result as BackgroundOptions;\n}\n","/**\n * GraphicFrame non-visual frame properties (p:cNvGraphicFramePr) — shared by\n * the five p:graphicFrame descriptors (table/chart/smartArt/ole/lockedCanvas).\n *\n * @module\n */\nimport type { GraphicFrameLockingOptions } from \"@office-open/core\";\nimport { extUriMatches, parseOnOff, xsdPlaceholderType } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { graphicFrameLockingDesc } from \"@office-open/core/drawing\";\nimport { attr, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport type { PlaceholderOrientation, PlaceholderSize, PlaceholderType } from \"@shared/shape/shape\";\n\n/**\n * Serialize p:cNvGraphicFramePr. Locking is tri-state:\n * undefined → the fresh default (MS Office's noGrp=\"1\" emission); null → an\n * empty frame-props element; an object → the explicit lock flags.\n */\nexport function stringifyCnvGraphicFramePr(locking?: GraphicFrameLockingOptions | null): string {\n  if (locking === null) return \"<p:cNvGraphicFramePr/>\";\n  if (locking === undefined)\n    return '<p:cNvGraphicFramePr><a:graphicFrameLocks noGrp=\"1\"/></p:cNvGraphicFramePr>';\n  // An explicit object always emits the locks element — empty flags keep the\n  // bare <a:graphicFrameLocks/> form the source may carry.\n  const locks = graphicFrameLockingDesc.stringify(locking, undefined as never) ?? \"\";\n  return `<p:cNvGraphicFramePr>${locks || \"<a:graphicFrameLocks/>\"}</p:cNvGraphicFramePr>`;\n}\n\n/**\n * Read the frame locking from a p:nvGraphicFramePr parent. Returns undefined\n * when the element is absent, null for an explicit empty cNvGraphicFramePr,\n * and the parsed flags otherwise.\n */\nexport function readGraphicFrameLocking(\n  nvGraphicFramePr: XmlElement | undefined,\n  ctx: ReadContext,\n): GraphicFrameLockingOptions | null | undefined {\n  const cNvGfp = nvGraphicFramePr ? findChild(nvGraphicFramePr, \"p:cNvGraphicFramePr\") : undefined;\n  if (!cNvGfp) return undefined;\n  const locks = findChild(cNvGfp, \"a:graphicFrameLocks\");\n  if (!locks) return null;\n  return graphicFrameLockingDesc.parse(locks, ctx);\n}\n\n/**\n * Placeholder reference carried in p:nvPr > p:ph — applies to every drawing\n * (shapes, pictures, and all five graphicFrame kinds).\n */\nexport interface NvPrPlaceholderOptions {\n  /** CT_Placeholder `@type` — ST_PlaceholderType. */\n  placeholder?: PlaceholderType;\n  /** CT_Placeholder `@idx`. */\n  placeholderIndex?: number;\n  /** CT_Placeholder `@sz` — sizing hint (default \"full\"). */\n  placeholderSize?: PlaceholderSize;\n  /** CT_Placeholder `@orient` — orientation hint (default \"horz\"). */\n  placeholderOrientation?: PlaceholderOrientation;\n  hasCustomPrompt?: boolean;\n  /** p:nvPr `@isPhoto`. */\n  isPhoto?: boolean;\n  /** p:nvPr `@userDrawn`. */\n  userDrawn?: boolean;\n  /**\n   * p14:modId `@val` from the nvPr extension list — Office's collaboration\n   * modification stamp, the sole known p:nvPr ext content.\n   */\n  modId?: string;\n}\n\n/** The p14:modId extension uri (CT_ApplicationNonVisualDrawingProps extLst). */\nconst MODID_EXT_URI = \"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}\";\n\n/** Serialize the p:nvPr content (placeholder reference, or photo/user-drawn attrs). */\nexport function stringifyNvPr(opts: NvPrPlaceholderOptions): string {\n  const modIdExt = opts.modId\n    ? `<p:extLst><p:ext uri=\"${MODID_EXT_URI}\"><p14:modId xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\" val=\"${opts.modId}\"/></p:ext></p:extLst>`\n    : \"\";\n  // isPhoto/userDrawn live on p:nvPr itself, orthogonal to the p:ph child\n  // (CT_ApplicationNonVisualDrawingProps) — a placeholder can carry both.\n  const nvPrAttrs: string[] = [];\n  if (opts.isPhoto) nvPrAttrs.push('isPhoto=\"1\"');\n  if (opts.userDrawn) nvPrAttrs.push('userDrawn=\"1\"');\n  const nvPrAttrsXml = nvPrAttrs.length ? ` ${nvPrAttrs.join(\" \")}` : \"\";\n  // p:ph @type is optional (XSD default \"obj\"), so a placeholder keyed only\n  // by idx must still emit <p:ph/> without a type attribute.\n  if (opts.placeholder || opts.placeholderIndex !== undefined) {\n    const phAttrs: string[] = [];\n    if (opts.placeholder) phAttrs.push(`type=\"${xsdPlaceholderType.to(opts.placeholder)}\"`);\n    if (opts.placeholderIndex !== undefined) phAttrs.push(`idx=\"${opts.placeholderIndex}\"`);\n    if (opts.placeholderSize !== undefined) phAttrs.push(`sz=\"${opts.placeholderSize}\"`);\n    if (opts.placeholderOrientation !== undefined)\n      phAttrs.push(`orient=\"${opts.placeholderOrientation}\"`);\n    if (opts.hasCustomPrompt) phAttrs.push('hasCustomPrompt=\"1\"');\n    return `<p:nvPr${nvPrAttrsXml}><p:ph ${phAttrs.join(\" \")}/>${modIdExt}</p:nvPr>`;\n  }\n  if (modIdExt) return `<p:nvPr${nvPrAttrsXml}>${modIdExt}</p:nvPr>`;\n  return nvPrAttrsXml ? `<p:nvPr${nvPrAttrsXml}/>` : \"<p:nvPr/>\";\n}\n\n/** Read the p:nvPr placeholder reference into a result object. */\nexport function readNvPrPlaceholder(\n  nvParent: XmlElement,\n  result: {\n    placeholder?: PlaceholderType;\n    placeholderIndex?: number;\n    placeholderSize?: PlaceholderSize;\n    placeholderOrientation?: PlaceholderOrientation;\n    hasCustomPrompt?: boolean;\n    isPhoto?: boolean;\n    userDrawn?: boolean;\n    modId?: string;\n  },\n): void {\n  const nvPr = findChild(nvParent, \"p:nvPr\");\n  if (!nvPr) return;\n  if (nvPr.attributes) {\n    if (nvPr.attributes[\"isPhoto\"] !== undefined)\n      result.isPhoto = parseOnOff(nvPr.attributes[\"isPhoto\"]) ?? false;\n    if (nvPr.attributes[\"userDrawn\"] !== undefined)\n      result.userDrawn = parseOnOff(nvPr.attributes[\"userDrawn\"]) ?? false;\n  }\n  const ph = findChild(nvPr, \"p:ph\");\n  if (ph?.attributes) {\n    if (ph.attributes[\"type\"] !== undefined)\n      result.placeholder = xsdPlaceholderType.from(\n        String(ph.attributes[\"type\"]),\n      ) as PlaceholderType;\n    if (ph.attributes[\"idx\"] !== undefined) result.placeholderIndex = Number(ph.attributes[\"idx\"]);\n    if (ph.attributes[\"sz\"] !== undefined)\n      result.placeholderSize = ph.attributes[\"sz\"] as PlaceholderSize;\n    if (ph.attributes[\"orient\"] !== undefined)\n      result.placeholderOrientation = ph.attributes[\"orient\"] as PlaceholderOrientation;\n    if (ph.attributes[\"hasCustomPrompt\"] !== undefined)\n      result.hasCustomPrompt = parseOnOff(ph.attributes[\"hasCustomPrompt\"]) ?? false;\n  }\n  const extLst = findChild(nvPr, \"p:extLst\");\n  if (extLst) {\n    for (const ext of extLst.elements ?? []) {\n      if (ext.name !== \"p:ext\" || !extUriMatches(attr(ext, \"uri\"), MODID_EXT_URI)) continue;\n      const modId = findChild(ext, \"p14:modId\");\n      const val = modId ? attr(modId, \"val\") : undefined;\n      if (val) result.modId = val;\n    }\n  }\n}\n","/**\n * Media path → picture type token.\n *\n * @module\n */\n\nimport { imageTypeFromPath as coreImageTypeFromPath } from \"@office-open/core\";\n\nimport type { PictureOptions } from \"../picture\";\n\n/**\n * Map a media path's file extension to a picture type token (unknown → png).\n * PPTX pictures have no tif/ico variant — those extensions fall back to png.\n */\nexport function imageTypeFromPath(path: string): PictureOptions[\"type\"] {\n  const type = coreImageTypeFromPath(path);\n  return type === \"tif\" || type === \"ico\" ? \"png\" : type;\n}\n","/**\n * Shape (p:sp) and Picture (p:pic) descriptors for PPTX slides.\n *\n * These CustomDescriptor implementations produce the same XML output as the\n * class-based Shape and Picture components, but through the descriptor pipeline.\n *\n * @module\n */\n\nimport { parseOnOff, toUint8Array, xsdPlaceholderType } from \"@office-open/core\";\nimport type { NonVisualDrawingPropertiesOptions, ShapeLockingOptions } from \"@office-open/core\";\nimport type { CustomDescriptor, WriteContext, ReadContext } from \"@office-open/core/descriptor\";\nimport { parse, stringify } from \"@office-open/core/descriptor\";\nimport {\n  shapeLockingDesc,\n  effectListDesc,\n  shapePropertiesDesc,\n  scene3DDesc,\n  shape3DDesc,\n  textBodyDesc,\n  stringifyNonVisualDrawingProperties,\n  parseNonVisualDrawingProperties,\n  pictureLockingDesc,\n  blipDesc,\n  createSourceRectangle,\n  fillDesc,\n  findFillChild,\n  outlineDesc,\n  stringifyColorChoice,\n  registerHyperlink,\n  buildHyperlinkElement,\n  readHyperlink,\n} from \"@office-open/core/drawing\";\nimport type {\n  BlipCompression,\n  SourceRectangleOptions,\n  Transform2DOptions,\n} from \"@office-open/core/drawing\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { findChild, findFirst, attrNum, attr } from \"@office-open/xml\";\nimport { imageTypeFromPath } from \"@shared/media/image-type\";\nimport type { PictureOptions } from \"@shared/picture\";\nimport {\n  readShapeStyle,\n  type ShapeOptions,\n  type ShapeStyleOptions,\n  type StyleReferenceColor,\n} from \"@shared/shape/shape\";\n\nimport type { PptxWriteContext, MediaEntry } from \"../../context\";\nimport { readNvPrPlaceholder, stringifyNvPr } from \"./graphic-frame\";\n\n// ── Auto-incrementing IDs ──\n\nlet _nextShapeId = 2;\nlet _nextPictureId = 100;\n\n/** Reset shape ID counter (useful for tests). */\nexport function resetShapeIdCounter(value = 2): void {\n  _nextShapeId = value;\n}\n\n// ── Shape (p:sp) descriptor ──\n\nexport const shapeDesc: CustomDescriptor<ShapeOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextShapeId++;\n    const name = opts.name ?? `Shape ${id}`;\n    (ctx as PptxWriteContext).registerShapeId(name, id);\n    const parts: string[] = [];\n\n    // ── p:nvSpPr ──\n    parts.push(stringifyNvSpPr(id, name, opts, ctx));\n\n    // ── p:spPr ──\n    const spPrXml = stringifySpPr(opts, ctx);\n    if (spPrXml) parts.push(spPrXml);\n\n    // ── p:style ──\n    if (opts.style) {\n      const styleXml = stringifyShapeStyle(opts.style, ctx);\n      if (styleXml) parts.push(styleXml);\n    }\n\n    // ── p:txBody (optional in CT_Shape; omitted when absent so txBody-less\n    // shapes like the notes sldImg placeholder round-trip without a spurious\n    // empty body. Parse only sets textBody when a p:txBody element exists.)\n    if (opts.textBody !== undefined) {\n      parts.push(`<p:txBody>${textBodyDesc.stringify(opts.textBody, ctx) ?? \"\"}</p:txBody>`);\n    }\n\n    // ── Root attributes ──\n    const spAttrs: string[] = [];\n    if (opts.useBackgroundFill) spAttrs.push(' useBgFill=\"1\"');\n\n    return `<p:sp${spAttrs.join(\"\")}>${parts.join(\"\")}</p:sp>`;\n  },\n\n  parse(el, ctx) {\n    const result: ShapeOptions = {};\n\n    // Root attributes\n    if (el.attributes) {\n      if (el.attributes[\"useBgFill\"] !== undefined)\n        result.useBackgroundFill = parseOnOff(el.attributes[\"useBgFill\"]) ?? false;\n    }\n\n    // p:nvSpPr — readNvSpPr returns the full ShapeOptions shape; assign whole\n    // so fields added later flow without touching this whitelist.\n    const nvSpPr = findChild(el, \"p:nvSpPr\");\n    if (nvSpPr) {\n      Object.assign(result, readNvSpPr(nvSpPr, ctx));\n    }\n\n    // p:spPr — transform goes top-level, paint fields land on `properties`;\n    // @bwMode is a container attribute so it stays top-level too.\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) {\n      const { properties, ...transform } = readSpPr(spPr, ctx);\n      Object.assign(result, transform);\n      result.properties = properties;\n      const bwMode = spPr.attributes?.[\"bwMode\"];\n      if (bwMode !== undefined) {\n        result.blackWhiteMode = String(bwMode) as ShapeOptions[\"blackWhiteMode\"];\n      }\n    }\n\n    // p:style\n    const style = findChild(el, \"p:style\");\n    if (style) result.style = readShapeStyle(style, ctx);\n\n    // p:txBody\n    const txBody = findChild(el, \"p:txBody\");\n    if (txBody) result.textBody = textBodyDesc.parse(txBody, ctx);\n\n    return result;\n  },\n};\n\n// ── Picture (p:pic) descriptor ──\n\nexport const pictureDesc: CustomDescriptor<PictureOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const pptx = ctx as PptxWriteContext;\n    const id = opts.id ?? _nextPictureId++;\n    const name = opts.name ?? `Picture ${id}`;\n    pptx.registerShapeId(name, id);\n\n    // A linked-only picture (external URL, no bytes) registers no media —\n    // its slide carries one External image relationship instead. A byteless\n    // picture with no link either (a broken source reference) registers none\n    // as well: there are no bytes to store, so the blip re-emits bare.\n    let mediaFileName: string | undefined;\n    if (opts.data !== undefined) {\n      const fileName = opts.fileName ?? `${name.replace(/\\s+/g, \"_\")}.${opts.type}`;\n      // Register media with the PPTX context (content-deduplicated). Identity\n      // fields only — the extent is emitted from opts per reference, never\n      // carried on the shared dedup entry.\n      const mediaEntry = pptx.addImage(fileName, {\n        key: fileName,\n        type: opts.type,\n        fileName,\n        data: toUint8Array(opts.data ?? new Uint8Array(0), { encoding: \"base64\" }),\n      });\n      mediaFileName = mediaEntry.fileName;\n    }\n\n    const parts: string[] = [];\n\n    // ── p:nvPicPr ──\n    parts.push(stringifyNvPicPr(id, name, opts, ctx));\n\n    // ── p:blipFill ──\n    parts.push(\n      stringifyPptxBlipFill(\n        { fileName: mediaFileName, sourceUrl: opts.sourceUrl, compression: opts.compression },\n        opts.sourceRectangle,\n        opts.blipEffects,\n        ctx,\n        opts.useLocalDpi,\n        opts.fillRectangle,\n      ),\n    );\n\n    // ── p:spPr ──\n    const spPrXml = stringifyPicSpPr(opts, ctx);\n    if (spPrXml) parts.push(spPrXml);\n\n    // ── p:style ──\n    if (opts.style) {\n      const styleXml = stringifyShapeStyle(opts.style, ctx);\n      if (styleXml) parts.push(styleXml);\n    }\n\n    return `<p:pic>${parts.join(\"\")}</p:pic>`;\n  },\n\n  parse(el, ctx) {\n    const result: Partial<PictureOptions> = {};\n\n    // p:nvPicPr\n    const nvPicPr = findChild(el, \"p:nvPicPr\");\n    if (nvPicPr) {\n      const cNvPr = findChild(nvPicPr, \"p:cNvPr\");\n      Object.assign(result, parseNonVisualDrawingProperties(cNvPr));\n      if (cNvPr?.attributes && cNvPr.attributes[\"id\"] !== undefined) {\n        result.id = Number(cNvPr.attributes[\"id\"]);\n      }\n      const hlinkClick = cNvPr ? findChild(cNvPr, \"a:hlinkClick\") : undefined;\n      if (hlinkClick) result.hyperlink = readHyperlink(hlinkClick, ctx);\n      const cNvPicPr = findChild(nvPicPr, \"p:cNvPicPr\");\n      const picLocks = cNvPicPr ? findChild(cNvPicPr, \"a:picLocks\") : undefined;\n      if (picLocks) {\n        // Element presence is the signal — a bare <a:picLocks/> round-trips\n        // as an empty locking object, not as a dropped element.\n        result.locking = parse(pictureLockingDesc, picLocks, ctx) ?? {};\n      }\n      readNvPrPlaceholder(nvPicPr, result);\n    }\n\n    // p:spPr (position/size/flip/rotation)\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) {\n      // A source picture may carry no geometry at all — keep it suppressed.\n      if (!findChild(spPr, \"a:prstGeom\") && !findChild(spPr, \"a:custGeom\")) {\n        result.geometry = null;\n      }\n      const xfrm = findChild(spPr, \"a:xfrm\");\n      if (xfrm) {\n        const off = findChild(xfrm, \"a:off\");\n        if (off?.attributes) {\n          result.x = Number(off.attributes[\"x\"] ?? 0);\n          result.y = Number(off.attributes[\"y\"] ?? 0);\n        }\n        const ext = findChild(xfrm, \"a:ext\");\n        if (ext?.attributes) {\n          result.width = Number(ext.attributes[\"cx\"] ?? 0);\n          result.height = Number(ext.attributes[\"cy\"] ?? 0);\n        }\n        if (xfrm.attributes) {\n          const flipH = parseOnOff(xfrm.attributes[\"flipH\"]);\n          if (flipH !== undefined && flipH) result.flipHorizontal = true;\n          const flipV = parseOnOff(xfrm.attributes[\"flipV\"]);\n          if (flipV !== undefined && flipV) result.flipVertical = true;\n          const rot = xfrm.attributes[\"rot\"];\n          if (rot !== undefined && rot !== \"\") result.rotation = Number(rot) / 60000;\n        }\n      }\n\n      // Fill (a:noFill on cropped/locked pictures is common)\n      const fillChild = findFillChild(spPr);\n      if (fillChild) result.fill = parse(fillDesc, fillChild, ctx);\n\n      // Outline (decorated pictures carry one)\n      const picLn = findChild(spPr, \"a:ln\");\n      if (picLn) result.outline = parse(outlineDesc, picLn, ctx);\n\n      // Effects (e.g. shadow/reflection on the picture)\n      const effectLst = findChild(spPr, \"a:effectLst\");\n      if (effectLst) {\n        const effects = parse(effectListDesc, effectLst, ctx);\n        if (effects) result.effects = effects;\n      }\n\n      // 3D scene / shape properties\n      const scene3d = findChild(spPr, \"a:scene3d\");\n      if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, ctx);\n      const sp3d = findChild(spPr, \"a:sp3d\");\n      if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, ctx);\n    }\n\n    // p:style\n    const picStyle = findChild(el, \"p:style\");\n    if (picStyle) result.style = readShapeStyle(picStyle, ctx);\n\n    // Crop rectangle from p:blipFill → a:srcRect (‰ → percent)\n    const blipFill = findChild(el, \"p:blipFill\");\n    const srcRectEl = blipFill ? findChild(blipFill, \"a:srcRect\") : undefined;\n    if (srcRectEl) {\n      const rect: SourceRectangleOptions = {};\n      const l = attrNum(srcRectEl, \"l\");\n      if (l !== undefined) rect.left = l / 1000;\n      const t = attrNum(srcRectEl, \"t\");\n      if (t !== undefined) rect.top = t / 1000;\n      const r = attrNum(srcRectEl, \"r\");\n      if (r !== undefined) rect.right = r / 1000;\n      const b = attrNum(srcRectEl, \"b\");\n      if (b !== undefined) rect.bottom = b / 1000;\n      result.sourceRectangle = rect;\n    }\n\n    // Stretch fill rectangle — a bare <a:stretch/> (no a:fillRect child) is a\n    // distinct emitted form some writers produce; keep it tri-state.\n    const stretch = blipFill ? findChild(blipFill, \"a:stretch\") : undefined;\n    if (stretch) {\n      const fillRectEl = findChild(stretch, \"a:fillRect\");\n      if (!fillRectEl) {\n        result.fillRectangle = false;\n      } else {\n        const rect: SourceRectangleOptions = {};\n        const l = attrNum(fillRectEl, \"l\");\n        if (l !== undefined) rect.left = l / 1000;\n        const t = attrNum(fillRectEl, \"t\");\n        if (t !== undefined) rect.top = t / 1000;\n        const r = attrNum(fillRectEl, \"r\");\n        if (r !== undefined) rect.right = r / 1000;\n        const b = attrNum(fillRectEl, \"b\");\n        if (b !== undefined) rect.bottom = b / 1000;\n        if (Object.keys(rect).length > 0) result.fillRectangle = rect;\n      }\n    }\n\n    // Image data from p:blipFill → a:blip → r:embed / r:link\n    const blip = findFirst(el, \"a:blip\");\n    if (blip) {\n      const parsedBlip = parse(blipDesc, blip, ctx);\n      if (parsedBlip.blipEffects) result.blipEffects = parsedBlip.blipEffects;\n      if (parsedBlip.useLocalDpi !== undefined) result.useLocalDpi = parsedBlip.useLocalDpi;\n      if (parsedBlip.compression !== undefined) result.compression = parsedBlip.compression;\n      const rEmbed = attr(blip, \"r:embed\");\n      if (rEmbed) {\n        const imagePath = ctx.resolveRelationship(rEmbed);\n        if (imagePath) {\n          const imageData = ctx.getRaw(imagePath);\n          if (imageData) {\n            result.data = imageData;\n            result.type = imageTypeFromPath(imagePath);\n          }\n          // Keep the source file name — re-deriving it from the shape name\n          // renames the media part and forks it from its passthrough copy.\n          result.fileName = imagePath.split(\"/\").pop();\n        }\n      }\n      const rLink = attr(blip, \"r:link\");\n      if (rLink) {\n        // External image source — the per-part rels keep External targets raw,\n        // so resolveRelationship returns the URL itself.\n        const url = ctx.resolveRelationship(rLink);\n        if (url) {\n          result.sourceUrl = url;\n          if (!result.type) result.type = imageTypeFromPath(url);\n        }\n      }\n    }\n\n    // A picture whose rel target resolves to no part (a broken reference)\n    // stays byteless: fabricating empty bytes would grow a 0-byte media part\n    // the source never had. A linked-only picture is byteless by design.\n    if (!result.type) result.type = \"png\";\n\n    return result as PictureOptions;\n  },\n};\n\n// ── Shape helper: p:nvSpPr ──\n\nfunction stringifyNvSpPr(id: number, name: string, opts: ShapeOptions, ctx: WriteContext): string {\n  // nvPr — @isPhoto/@userDrawn are the element's own attributes, orthogonal\n  // to the p:ph child (CT_ApplicationNonVisualDrawingProps), so both emit\n  // together. p:ph @type is optional (XSD default \"obj\"), so a placeholder\n  // keyed only by idx must still emit <p:ph/> without a type attribute.\n  const nvPrAttrs: string[] = [];\n  if (opts.isPhoto) nvPrAttrs.push('isPhoto=\"1\"');\n  if (opts.userDrawn) nvPrAttrs.push('userDrawn=\"1\"');\n  const nvPrAttrsXml = nvPrAttrs.length > 0 ? ` ${nvPrAttrs.join(\" \")}` : \"\";\n  let nvPrContent = nvPrAttrs.length > 0 ? `<p:nvPr${nvPrAttrsXml}/>` : \"<p:nvPr/>\";\n  if (opts.placeholder || opts.placeholderIndex !== undefined) {\n    const phAttrs: string[] = [];\n    if (opts.placeholder) phAttrs.push(`type=\"${xsdPlaceholderType.to(opts.placeholder)}\"`);\n    if (opts.placeholderIndex !== undefined) phAttrs.push(`idx=\"${opts.placeholderIndex}\"`);\n    if (opts.placeholderSize !== undefined) phAttrs.push(`sz=\"${opts.placeholderSize}\"`);\n    if (opts.placeholderOrientation !== undefined)\n      phAttrs.push(`orient=\"${opts.placeholderOrientation}\"`);\n    if (opts.hasCustomPrompt) phAttrs.push('hasCustomPrompt=\"1\"');\n    nvPrContent = `<p:nvPr${nvPrAttrsXml}><p:ph ${phAttrs.join(\" \")}/></p:nvPr>`;\n  }\n\n  // cNvSpPr (with optional locking)\n  let cNvSpPrContent = \"<p:cNvSpPr/>\";\n  if (opts.locking) {\n    const lockAttrs = buildLockAttrs(opts.locking);\n    if (lockAttrs.length > 0) {\n      cNvSpPrContent = `<p:cNvSpPr><a:spLocks ${lockAttrs.join(\" \")}/></p:cNvSpPr>`;\n    }\n  }\n\n  // Click hyperlink (a:hlinkClick) lives inside p:cNvPr.\n  let hlinkXml: string | undefined;\n  if (opts.hyperlink) {\n    const key = registerHyperlink(opts.hyperlink, ctx);\n    hlinkXml = buildHyperlinkElement(\"a:hlinkClick\", opts.hyperlink, key);\n  }\n\n  const cNvPrXml = stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name, hlinkXml);\n  return `<p:nvSpPr>${cNvPrXml}${cNvSpPrContent}${nvPrContent}</p:nvSpPr>`;\n}\n\nfunction buildLockAttrs(opts: ShapeLockingOptions): string[] {\n  const attrs: string[] = [];\n  const keys = [\n    \"noGrp\",\n    \"noSelect\",\n    \"noRot\",\n    \"noChangeAspect\",\n    \"noMove\",\n    \"noResize\",\n    \"noEditPoints\",\n    \"noAdjustHandles\",\n    \"noChangeArrowheads\",\n    \"noChangeShapeType\",\n    \"noTextEdit\",\n  ] as const;\n  for (const key of keys) {\n    const val = opts[key];\n    if (val !== undefined) attrs.push(`${key}=\"${val ? 1 : 0}\"`);\n  }\n  return attrs;\n}\n\n// ── Shape helper: p:spPr ──\n\nfunction stringifySpPr(opts: ShapeOptions, ctx: WriteContext): string {\n  const pptx = ctx as PptxWriteContext;\n  const sp = opts.properties ?? {};\n\n  // Blip fill: pre-register via addImage so the deduped canonical keeps the\n  // pinned source name on round-trip (imageType normalization like jpeg→jpg\n  // would otherwise fork a second media part); fresh fills get the\n  // pptx-local image_blip.<type>. shapePropertiesDesc's fillDesc re-registers\n  // via addMedia, deduped to the same canonical.\n  if (sp.fill && typeof sp.fill !== \"string\" && sp.fill.type === \"blip\" && sp.fill.data) {\n    const blipFill = sp.fill;\n    const raw = toUint8Array(blipFill.data!, { encoding: \"base64\" });\n    const fileName = blipFill.fileName ?? `image_blip.${blipFill.imageType ?? \"png\"}`;\n    pptx.addImage(fileName, {\n      key: fileName,\n      data: raw,\n      fileName,\n      type: (blipFill.imageType ?? \"png\") as MediaEntry[\"type\"],\n    });\n  }\n\n  // Placeholder shapes inherit geometry/fill from layout/master; only emit\n  // them when explicitly set. Non-placeholder shapes default to rect geometry\n  // and noFill. A p:ph with no @type (idx-only) is still a placeholder —\n  // placeholderIndex alone carries its identity.\n  const isPlaceholder = !!opts.placeholder || opts.placeholderIndex !== undefined;\n  const geometry = sp.customGeometry\n    ? undefined\n    : isPlaceholder\n      ? sp.geometry\n      : (sp.geometry ?? \"rect\");\n  // A shape whose p:style carries a fillRef inherits its fill from the style\n  // matrix — an explicit noFill would override that, so leave the spPr fill\n  // unset unless the source (or the fresh caller) says otherwise. `fill: null`\n  // marks a parsed source with no fill child — emit nothing there too.\n  const styleOwnsFill = opts.style?.fillReference !== undefined;\n  const fill =\n    sp.fill === null\n      ? undefined\n      : isPlaceholder || styleOwnsFill\n        ? sp.fill\n        : (sp.fill ?? ({ type: \"none\" } as const));\n\n  const spPrContent = shapePropertiesDesc.stringify(\n    {\n      x: opts.x,\n      y: opts.y,\n      width: opts.width,\n      height: opts.height,\n      flipHorizontal: opts.flipHorizontal,\n      flipVertical: opts.flipVertical,\n      rotation: opts.rotation,\n      ...sp,\n      geometry,\n      fill,\n    },\n    ctx,\n  );\n\n  // @bwMode is a CT_ShapeProperties container attribute (CT_Shape itself only\n  // has @useBgFill).\n  const bwAttr = opts.blackWhiteMode ? ` bwMode=\"${opts.blackWhiteMode}\"` : \"\";\n  if (!spPrContent) return bwAttr ? `<p:spPr${bwAttr}/>` : \"<p:spPr/>\";\n  return `<p:spPr${bwAttr}>${spPrContent}</p:spPr>`;\n}\n\n// ── Shape helper: p:style ──\n\n/**\n * Serialize p:style (CT_ShapeStyle). Every ref carries a bare EG_ColorChoice\n * child (any of the six color kinds; fontRef included — @idx is\n * ST_FontCollectionIndex, not numeric). Shared by the shape descriptor and\n * the master placeholder emitter.\n */\nexport function stringifyShapeStyle(style: ShapeStyleOptions, ctx: WriteContext): string {\n  const ref = (\n    name: string,\n    { index, color }: { index: number | string; color?: StyleReferenceColor },\n  ): string => {\n    if (color === undefined) return `<${name} idx=\"${index}\"/>`;\n    const choice = typeof color === \"string\" ? { value: color } : color;\n    return `<${name} idx=\"${index}\">${stringifyColorChoice(choice, ctx)}</${name}>`;\n  };\n\n  const parts: string[] = [];\n  if (style.lineReference) parts.push(ref(\"a:lnRef\", style.lineReference));\n  if (style.fillReference) parts.push(ref(\"a:fillRef\", style.fillReference));\n  if (style.effectReference) parts.push(ref(\"a:effectRef\", style.effectReference));\n  if (style.fontReference)\n    parts.push(\n      ref(\"a:fontRef\", {\n        index: style.fontReference.collection,\n        color: style.fontReference.color,\n      }),\n    );\n  return parts.length > 0 ? `<p:style>${parts.join(\"\")}</p:style>` : \"\";\n}\n\n// ── Picture helpers ──\n\nfunction stringifyNvPicPr(\n  id: number,\n  name: string,\n  opts: PictureOptions | undefined,\n  ctx: WriteContext,\n): string {\n  // Click hyperlink (a:hlinkClick) lives inside p:cNvPr.\n  let hlinkXml: string | undefined;\n  if (opts?.hyperlink) {\n    const key = registerHyperlink(opts.hyperlink, ctx);\n    hlinkXml = buildHyperlinkElement(\"a:hlinkClick\", opts.hyperlink, key);\n  }\n  const cNvPrXml = stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name, hlinkXml);\n  const locks = opts?.locking ? (pictureLockingDesc.stringify(opts.locking, ctx) ?? \"\") : \"\";\n  const cNvPicPr = locks ? `<p:cNvPicPr>${locks}</p:cNvPicPr>` : \"<p:cNvPicPr/>\";\n  return `<p:nvPicPr>${cNvPrXml}${cNvPicPr}${stringifyNvPr(opts ?? {})}</p:nvPicPr>`;\n}\n\n/** PPTX uses p:blipFill (not pic:blipFill). */\nfunction stringifyPptxBlipFill(\n  blip: {\n    /** Embedded media file name; undefined on a linked-only picture. */\n    fileName?: string;\n    /** External image source URL (a:blip @r:link). */\n    sourceUrl?: string;\n    /** Compression state (a:blip @cstate); absent = attribute omitted. */\n    compression?: BlipCompression;\n  },\n  sourceRectangle?: SourceRectangleOptions,\n  blipEffects?: PictureOptions[\"blipEffects\"],\n  ctx?: WriteContext,\n  useLocalDpi?: boolean,\n  fillRectangle?: SourceRectangleOptions | false,\n): string {\n  // The linked source registers an {img-link:key} placeholder the compiler\n  // rewrites per slide/layout while adding the External image relationship.\n  // The placeholder body carries the \"img-link:\" prefix (hlink convention).\n  const linkKey =\n    blip.sourceUrl !== undefined && ctx\n      ? `img-link:${(ctx as PptxWriteContext).addImageLink(blip.sourceUrl)}`\n      : undefined;\n  const blipXml = stringify(\n    blipDesc,\n    {\n      referenceId: blip.fileName,\n      linkReferenceId: linkKey,\n      compression: blip.compression,\n      blipEffects,\n      useLocalDpi,\n    },\n    ctx,\n  );\n  const srcRect = sourceRectangle ? createSourceRectangle(sourceRectangle) : \"\";\n  const fillRect =\n    fillRectangle === false\n      ? \"<a:stretch/>\"\n      : `<a:stretch>${createSourceRectangle(fillRectangle ?? {}, \"a:fillRect\")}</a:stretch>`;\n  return `<p:blipFill>${blipXml}${srcRect}${fillRect}</p:blipFill>`;\n}\n\nfunction stringifyPicSpPr(opts: PictureOptions, ctx: WriteContext): string {\n  const spPrContent = shapePropertiesDesc.stringify(\n    {\n      x: opts.x,\n      y: opts.y,\n      width: opts.width,\n      height: opts.height,\n      flipHorizontal: opts.flipHorizontal,\n      flipVertical: opts.flipVertical,\n      rotation: opts.rotation,\n      // Pictures always use a rect preset geometry unless the source omitted it.\n      geometry: opts.geometry === null ? undefined : \"rect\",\n      fill: opts.fill,\n      outline: opts.outline,\n      effects: opts.effects,\n      scene3d: opts.scene3d,\n      shape3d: opts.shape3d,\n    },\n    ctx,\n  );\n  if (!spPrContent) return \"<p:spPr/>\";\n  return `<p:spPr>${spPrContent}</p:spPr>`;\n}\n\n// ── Read helpers ──\n\n/**\n * Read the non-visual drawing properties (id/name/description/title/hidden…)\n * from the first parent tag that holds a p:cNvPr (a:cNvPr tolerated); with no\n * parent tags, el itself is the non-visual properties container. Shared\n * probe+parse by every slide-child descriptor.\n */\nexport function readCnvPr(\n  el: XmlElement,\n  ...parentTags: string[]\n): NonVisualDrawingPropertiesOptions & { id?: number } {\n  const parents = parentTags.length ? parentTags.map((tag) => findChild(el, tag)) : [el];\n  for (const parent of parents) {\n    if (!parent) continue;\n    const cNvPr = findChild(parent, \"p:cNvPr\") ?? findChild(parent, \"a:cNvPr\");\n    if (!cNvPr) continue;\n    const result: NonVisualDrawingPropertiesOptions & { id?: number } = {\n      ...parseNonVisualDrawingProperties(cNvPr),\n    };\n    const id = attrNum(cNvPr, \"id\");\n    if (id !== undefined) result.id = id;\n    return result;\n  }\n  return {};\n}\n\nexport function readNvSpPr(nvSpPr: XmlElement, ctx: ReadContext): ShapeOptions {\n  const result: ShapeOptions = {};\n\n  Object.assign(result, readCnvPr(nvSpPr));\n\n  // Click hyperlink inside p:cNvPr (a:hlinkClick)\n  const cNvPr = findChild(nvSpPr, \"p:cNvPr\") ?? findChild(nvSpPr, \"a:cNvPr\");\n  const hlinkClick = cNvPr ? findChild(cNvPr, \"a:hlinkClick\") : undefined;\n  if (hlinkClick) {\n    result.hyperlink = readHyperlink(hlinkClick, ctx);\n  }\n\n  const nvPr = findChild(nvSpPr, \"p:nvPr\");\n  if (nvPr) {\n    if (nvPr.attributes) {\n      if (nvPr.attributes[\"isPhoto\"] !== undefined)\n        result.isPhoto = parseOnOff(nvPr.attributes[\"isPhoto\"]) ?? false;\n      if (nvPr.attributes[\"userDrawn\"] !== undefined)\n        result.userDrawn = parseOnOff(nvPr.attributes[\"userDrawn\"]) ?? false;\n    }\n    const ph = findChild(nvPr, \"p:ph\");\n    if (ph?.attributes) {\n      if (ph.attributes[\"type\"] !== undefined)\n        result.placeholder = xsdPlaceholderType.from(\n          String(ph.attributes[\"type\"]),\n        ) as ShapeOptions[\"placeholder\"];\n      if (ph.attributes[\"idx\"] !== undefined)\n        result.placeholderIndex = Number(ph.attributes[\"idx\"]);\n      if (ph.attributes[\"sz\"] !== undefined)\n        result.placeholderSize = ph.attributes[\"sz\"] as ShapeOptions[\"placeholderSize\"];\n      if (ph.attributes[\"orient\"] !== undefined)\n        result.placeholderOrientation = ph.attributes[\n          \"orient\"\n        ] as ShapeOptions[\"placeholderOrientation\"];\n      if (ph.attributes[\"hasCustomPrompt\"] !== undefined)\n        result.hasCustomPrompt = parseOnOff(ph.attributes[\"hasCustomPrompt\"]) ?? false;\n    }\n  }\n\n  const cNvSpPr = findChild(nvSpPr, \"p:cNvSpPr\");\n  if (cNvSpPr) {\n    const spLocks = findChild(cNvSpPr, \"a:spLocks\");\n    if (spLocks) {\n      result.locking = shapeLockingDesc.parse(spLocks, {} as ReadContext) as ShapeLockingOptions;\n    }\n  }\n\n  return result;\n}\n\n/** Parse p:spPr via the shared core descriptor: transform top-level, paint into\n * `properties` (fill absence marked null so stringify skips the fresh default). */\nfunction readSpPr(\n  spPr: XmlElement,\n  ctx: ReadContext,\n): Transform2DOptions & { properties: NonNullable<ShapeOptions[\"properties\"]> } {\n  const parsed = parse(shapePropertiesDesc, spPr, ctx);\n  const { x, y, width, height, flipHorizontal, flipVertical, rotation, ...paint } = parsed;\n\n  // A source spPr with no fill child inherits its fill — mark the absence so\n  // stringify does not apply the fresh-authoring noFill default.\n  if (paint.fill === undefined) paint.fill = null;\n\n  // Collapse a preset geometry without adjustment values to the bare string\n  // shorthand the public options accept.\n  const geometry = paint.geometry;\n  if (\n    typeof geometry === \"object\" &&\n    (!geometry.adjustmentValues || geometry.adjustmentValues.length === 0) &&\n    geometry.preset\n  ) {\n    paint.geometry = geometry.preset;\n  }\n\n  return {\n    x,\n    y,\n    width,\n    height,\n    flipHorizontal,\n    flipVertical,\n    rotation,\n    properties: paint,\n  };\n}\n\n/** Read x/y/width/height (in EMU) from an a:xfrm element. */\nexport function readPositionFromXfrm(xfrm: XmlElement): Record<string, number> {\n  const result: Record<string, number> = {};\n  const off = findChild(xfrm, \"a:off\");\n  if (off) {\n    const x = attrNum(off, \"x\");\n    if (x !== undefined) result.x = x;\n    const y = attrNum(off, \"y\");\n    if (y !== undefined) result.y = y;\n  }\n  const ext = findChild(xfrm, \"a:ext\");\n  if (ext) {\n    const cx = attrNum(ext, \"cx\");\n    if (cx !== undefined) result.width = cx;\n    const cy = attrNum(ext, \"cy\");\n    if (cy !== undefined) result.height = cy;\n  }\n  return result;\n}\n\n// ── Image type helper ──\n","/**\n * Chart (p:graphicFrame) descriptor for PPTX.\n *\n * Produces a graphicFrame with a chart reference placeholder.\n * The actual chart data is registered in PptxWriteContext for\n * separate compilation by the compiler.\n *\n * @module\n */\n\nimport { partPathToRelsPath, resolveRelationshipTarget } from \"@office-open/core\";\nimport { convertToEmu } from \"@office-open/core\";\nimport { buildUserShapesData, chartSpaceDesc, userShapesDesc } from \"@office-open/core/chart\";\nimport type { ChartSpaceOptions } from \"@office-open/core/chart\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { stringify } from \"@office-open/core/descriptor\";\nimport { stringifyNonVisualDrawingProperties } from \"@office-open/core/drawing\";\nimport { attr, findChild, findFirst } from \"@office-open/xml\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport type { ChartOptions } from \"../chart-frame\";\nimport {\n  readGraphicFrameLocking,\n  readNvPrPlaceholder,\n  stringifyCnvGraphicFramePr,\n  stringifyNvPr,\n} from \"./graphic-frame\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\n\n// ── ID counter ──\n\nlet _nextChartId = 2048;\n\n// ── Chart descriptor ──\n\nexport const chartDesc: CustomDescriptor<ChartOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const pptxCtx = ctx as PptxWriteContext;\n    const id = opts.id ?? _nextChartId++;\n    const name = opts.name ?? `Chart ${id}`;\n    pptxCtx.registerShapeId(name, id);\n    const chartKey = opts.chartKey ?? pptxCtx.nextChartKey();\n\n    // Register chart data with context\n    const chartXml = stringify(chartSpaceDesc, opts as ChartSpaceOptions, ctx);\n    if (chartXml) {\n      pptxCtx.addChart(chartKey, {\n        key: chartKey,\n        chartSpaceXml: chartXml,\n        ...(opts.userShapes ? { userShapes: buildUserShapesData(opts.userShapes) } : {}),\n      });\n    }\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    const w = convertToEmu(opts.width ?? \"100px\");\n    const h = convertToEmu(opts.height ?? \"100px\");\n\n    const parts: string[] = [];\n\n    // p:nvGraphicFramePr — strip the chart title so it stays a c:title-only\n    // field and never leaks into the cNvPr @title attribute.\n    const { title: _chartTitle, ...cNvPrProps } = opts;\n    parts.push(\n      `<p:nvGraphicFramePr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, cNvPrProps, name)}` +\n        `${stringifyCnvGraphicFramePr(opts.locking)}` +\n        `${stringifyNvPr(opts)}</p:nvGraphicFramePr>`,\n    );\n\n    // p:xfrm\n    parts.push(`<p:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${w}\" cy=\"${h}\"/></p:xfrm>`);\n\n    // a:graphic > a:graphicData > c:chart (placeholder)\n    parts.push(\n      `<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\">` +\n        `<c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"{chart:${chartKey}}\"/>` +\n        `</a:graphicData></a:graphic>`,\n    );\n\n    return `<p:graphicFrame>${parts.join(\"\")}</p:graphicFrame>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<ChartOptions> = {};\n\n    // id + name from p:nvGraphicFramePr/p:cNvPr — drop the cNvPr @title so the\n    // chart title (parsed from the chart part below) stays the single source.\n    const { title: _cNvPrTitle, ...cNvPrProps } = readCnvPr(el, \"p:nvGraphicFramePr\");\n    const locking = readGraphicFrameLocking(findChild(el, \"p:nvGraphicFramePr\"), _ctx);\n    if (locking !== undefined) result.locking = locking;\n    readNvPrPlaceholder(findChild(el, \"p:nvGraphicFramePr\") ?? el, result);\n    Object.assign(result, cNvPrProps);\n\n    // Position from p:xfrm\n    const xfrm = findChild(el, \"p:xfrm\");\n    if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n\n    // Chart data via c:chart → r:id → resolve relationship; the c:chartSpace\n    // payload itself is parsed by the core chart descriptor (full type/series\n    // coverage — the same descriptor that stringifies it).\n    const chartRef = findFirst(el, \"c:chart\");\n    if (chartRef) {\n      const rId = attr(chartRef, \"r:id\");\n      if (rId) {\n        const chartPath = _ctx.resolveRelationship(rId);\n        if (chartPath) {\n          const chartXml = _ctx.getPart(chartPath);\n          if (chartXml) {\n            Object.assign(result, chartSpaceDesc.parse(chartXml, _ctx));\n            // c:userShapes body hangs off the chart part's own rels — the\n            // core descriptor reads the r:id only, fill the anchors here\n            const us = result.userShapes;\n            if (us && us.anchors.length === 0) {\n              const relsEl = _ctx.getPart(partPathToRelsPath(chartPath));\n              const rel = relsEl?.elements?.find(\n                (e) =>\n                  e.name === \"Relationship\" &&\n                  attr(e, \"Id\") === (us.relationshipId ?? \"\") &&\n                  (attr(e, \"Type\") ?? \"\").endsWith(\"/chartUserShapes\"),\n              );\n              const target = rel ? attr(rel, \"Target\") : undefined;\n              const bodyEl = target\n                ? _ctx.getPart(resolveRelationshipTarget(chartPath, target))\n                : undefined;\n              if (bodyEl) us.anchors = userShapesDesc.parse(bodyEl, _ctx).anchors;\n            }\n          }\n        }\n      }\n    }\n\n    return result as ChartOptions;\n  },\n};\n","/**\n * Group shape descriptor for PPTX.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport {\n  groupLockingDesc,\n  groupShapePropertiesDesc,\n  stringifyNonVisualDrawingProperties,\n} from \"@office-open/core/drawing\";\nimport type { BlackWhiteMode } from \"@office-open/core/drawing\";\nimport { findChild } from \"@office-open/xml\";\nimport type { SlideChild as LegacySlideChild } from \"@parts/slide/slide-child\";\nimport type { GroupOptions } from \"@shared/shape/group-shape\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { parseChild, stringifyChild } from \"./bridge\";\nimport { readCnvPr } from \"./shape\";\n\n// ── ID counter ──\n\nlet _nextGroupId = 200;\n\n// ── GroupShape (p:grpSp) descriptor ──\n\nexport const groupShapeDesc: CustomDescriptor<GroupOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const descCtx = ctx as PptxWriteContext;\n    const id = opts.id ?? _nextGroupId++;\n    const name = opts.name ?? \"Group\";\n    descCtx.registerShapeId(name, id);\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    const w = convertToEmu(opts.width ?? \"100px\");\n    const h = convertToEmu(opts.height ?? \"100px\");\n\n    const grpSpPrContent =\n      groupShapePropertiesDesc.stringify(\n        {\n          x,\n          y,\n          width: w,\n          height: h,\n          ...(opts.flipHorizontal !== undefined ? { flipHorizontal: opts.flipHorizontal } : {}),\n          ...(opts.flipVertical !== undefined ? { flipVertical: opts.flipVertical } : {}),\n          ...(opts.rotation !== undefined ? { rotation: opts.rotation } : {}),\n          // chOff/chExt default to off/ext when the child coordinate system is unchanged.\n          childOffsetX: opts.childOffsetX !== undefined ? convertToEmu(opts.childOffsetX) : x,\n          childOffsetY: opts.childOffsetY !== undefined ? convertToEmu(opts.childOffsetY) : y,\n          childExtentWidth:\n            opts.childExtentWidth !== undefined ? convertToEmu(opts.childExtentWidth) : w,\n          childExtentHeight:\n            opts.childExtentHeight !== undefined ? convertToEmu(opts.childExtentHeight) : h,\n          ...(opts.fill !== undefined ? { fill: opts.fill } : {}),\n          ...(opts.effects !== undefined ? { effects: opts.effects } : {}),\n        },\n        descCtx,\n      ) ?? \"\";\n\n    const grpSpPrAttrs = opts.blackWhiteMode ? ` bwMode=\"${opts.blackWhiteMode}\"` : \"\";\n\n    const parts: string[] = [];\n\n    // p:nvGrpSpPr\n    // null = explicit empty locks element; an object always emits the flags.\n    const grpLocks =\n      opts.locking === null\n        ? \"<a:grpSpLocks/>\"\n        : opts.locking\n          ? (groupLockingDesc.stringify(opts.locking, descCtx) ?? \"\")\n          : \"\";\n    const cNvGrpSpPr = grpLocks ? `<p:cNvGrpSpPr>${grpLocks}</p:cNvGrpSpPr>` : \"<p:cNvGrpSpPr/>\";\n    parts.push(\n      `<p:nvGrpSpPr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}${cNvGrpSpPr}<p:nvPr/></p:nvGrpSpPr>`,\n    );\n\n    // p:grpSpPr\n    parts.push(`<p:grpSpPr${grpSpPrAttrs}>${grpSpPrContent}</p:grpSpPr>`);\n\n    // Children\n    if (opts.children) {\n      for (const child of opts.children) {\n        const xml = stringifyChild(child, descCtx);\n        if (xml) parts.push(xml);\n      }\n    }\n\n    return `<p:grpSp>${parts.join(\"\")}</p:grpSp>`;\n  },\n\n  parse(el, ctx) {\n    const result: Partial<GroupOptions> = {};\n\n    // id + name from p:nvGrpSpPr/p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvGrpSpPr\"));\n    const nvGrpSpPr = findChild(el, \"p:nvGrpSpPr\");\n    const grpLocks = nvGrpSpPr ? findChild(nvGrpSpPr, \"p:cNvGrpSpPr\") : undefined;\n    const lockEl = grpLocks ? findChild(grpLocks, \"a:grpSpLocks\") : undefined;\n    if (lockEl) {\n      const locks = groupLockingDesc.parse(lockEl, ctx);\n      result.locking = locks && Object.keys(locks).length > 0 ? locks : null;\n    }\n\n    const grpSpPr = findChild(el, \"p:grpSpPr\");\n    if (grpSpPr) {\n      const props = groupShapePropertiesDesc.parse(grpSpPr, ctx);\n      if (props.x !== undefined) result.x = props.x;\n      if (props.y !== undefined) result.y = props.y;\n      if (props.width !== undefined) result.width = props.width;\n      if (props.height !== undefined) result.height = props.height;\n      if (props.rotation !== undefined) result.rotation = props.rotation;\n      if (props.flipHorizontal) result.flipHorizontal = true;\n      if (props.flipVertical) result.flipVertical = true;\n      if (props.childOffsetX !== undefined) result.childOffsetX = props.childOffsetX;\n      if (props.childOffsetY !== undefined) result.childOffsetY = props.childOffsetY;\n      if (props.childExtentWidth !== undefined) result.childExtentWidth = props.childExtentWidth;\n      if (props.childExtentHeight !== undefined) {\n        result.childExtentHeight = props.childExtentHeight;\n      }\n      if (props.fill !== undefined) result.fill = props.fill;\n      if (props.effects !== undefined) result.effects = props.effects;\n      const bwMode = grpSpPr.attributes?.[\"bwMode\"];\n      if (bwMode !== undefined) result.blackWhiteMode = bwMode as BlackWhiteMode;\n    }\n\n    // Children — recursive parse\n    const groupChildren: LegacySlideChild[] = [];\n    for (const child of el.elements ?? []) {\n      if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n      const parsed = parseChild(child, ctx);\n      if (parsed !== undefined) groupChildren.push(parsed);\n    }\n    if (groupChildren.length > 0) result.children = groupChildren;\n\n    return result as GroupOptions;\n  },\n};\n","/**\n * Line and Connector descriptors for PPTX.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { parse, stringify } from \"@office-open/core/descriptor\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport {\n  connectorLockingDesc,\n  effectListDesc,\n  fillDesc,\n  findFillChild,\n  outlineDesc,\n  parseEndpointConnection,\n  presetGeometryDesc,\n  scene3DDesc,\n  shape3DDesc,\n  shapeLockingDesc,\n  stringifyEndpointConnection,\n  stringifyNonVisualDrawingProperties,\n  textBodyDesc,\n} from \"@office-open/core/drawing\";\nimport { attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { ConnectorOptions, LineShapeOptions } from \"@shared/shape/line-shape\";\nimport { readShapeStyle } from \"@shared/shape/shape\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { readCnvPr } from \"./shape\";\nimport { stringifyShapeStyle } from \"./shape\";\n\n// ── ID counters ──\n\nlet _nextLineId = 2;\nlet _nextConnectorId = 2;\n\n// ── Shared endpoint-model spPr helpers (line + connector) ──\n\n/** a:xfrm + a:prstGeom for an endpoint-model line (flip encodes direction). */\nfunction stringifyLineXfrmGeometry(\n  x1: number,\n  y1: number,\n  x2: number,\n  y2: number,\n  geomXml = '<a:prstGeom prst=\"line\"><a:avLst/></a:prstGeom>',\n): string {\n  const attrs = [x1 > x2 ? ' flipH=\"1\"' : \"\", y1 > y2 ? ' flipV=\"1\"' : \"\"].join(\"\");\n  const offX = Math.min(x1, x2);\n  const offY = Math.min(y1, y2);\n  return (\n    `<a:xfrm${attrs}><a:off x=\"${offX}\" y=\"${offY}\"/>` +\n    `<a:ext cx=\"${Math.abs(x2 - x1)}\" cy=\"${Math.abs(y2 - y1)}\"/></a:xfrm>` +\n    geomXml\n  );\n}\n\n/** Parse endpoints (off/ext + flip) + paint from p:spPr of a line/connector. */\nfunction parseLineSpPr(\n  spPr: Element,\n  ctx: ReadContext,\n): Pick<LineShapeOptions, \"x1\" | \"y1\" | \"x2\" | \"y2\"> & {\n  properties: NonNullable<LineShapeOptions[\"properties\"]>;\n} {\n  const result: ReturnType<typeof parseLineSpPr> = { properties: {} };\n\n  const xfrm = findChild(spPr, \"a:xfrm\");\n  if (xfrm) {\n    const off = findChild(xfrm, \"a:off\");\n    const ext = findChild(xfrm, \"a:ext\");\n    const flipH = attrBool(xfrm, \"flipH\");\n    const flipV = attrBool(xfrm, \"flipV\");\n\n    if (off && ext) {\n      const offX = attrNum(off, \"x\") ?? 0;\n      const offY = attrNum(off, \"y\") ?? 0;\n      const cx = attrNum(ext, \"cx\") ?? 0;\n      const cy = attrNum(ext, \"cy\") ?? 0;\n\n      result.x1 = flipH ? offX + cx : offX;\n      result.y1 = flipV ? offY + cy : offY;\n      result.x2 = flipH ? offX : offX + cx;\n      result.y2 = flipV ? offY : offY + cy;\n    }\n  }\n\n  const paint = result.properties;\n\n  // Only parse fill when a fill child exists — fillDesc returns\n  // { type: \"none\" } for an empty spPr, which would spuriously emit <a:noFill/>.\n  const fillChild = findFillChild(spPr);\n  if (fillChild) paint.fill = parse(fillDesc, fillChild, ctx);\n  const ln = findChild(spPr, \"a:ln\");\n  if (ln) paint.outline = parse(outlineDesc, ln, ctx);\n  const effectLst = findChild(spPr, \"a:effectLst\");\n  if (effectLst) paint.effects = parse(effectListDesc, effectLst, ctx);\n  const scene3d = findChild(spPr, \"a:scene3d\");\n  if (scene3d) paint.scene3d = scene3DDesc.parse(scene3d, ctx);\n  const sp3d = findChild(spPr, \"a:sp3d\");\n  if (sp3d) paint.shape3d = shape3DDesc.parse(sp3d, ctx);\n\n  return result;\n}\n\n// ── LineShape (p:sp) descriptor ──\n\nexport const lineShapeDesc: CustomDescriptor<LineShapeOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextLineId++;\n    const name = opts.name ?? `Line ${id}`;\n    (ctx as PptxWriteContext).registerShapeId(name, id);\n\n    const x1 = convertToEmu(opts.x1 ?? 0);\n    const y1 = convertToEmu(opts.y1 ?? 0);\n    const x2 = convertToEmu(opts.x2 ?? \"100px\");\n    const y2 = convertToEmu(opts.y2 ?? \"100px\");\n\n    const parts: string[] = [];\n\n    // p:nvSpPr\n    const spLocks = opts.locking ? (shapeLockingDesc.stringify(opts.locking, ctx) ?? \"\") : \"\";\n    const cNvSpPr = spLocks ? `<p:cNvSpPr>${spLocks}</p:cNvSpPr>` : \"<p:cNvSpPr/>\";\n    parts.push(\n      `<p:nvSpPr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}${cNvSpPr}<p:nvPr/></p:nvSpPr>`,\n    );\n\n    // p:spPr\n    const sp = opts.properties ?? {};\n    const spPrParts: string[] = [];\n    spPrParts.push(stringifyLineXfrmGeometry(x1, y1, x2, y2));\n\n    // Fill\n    if (sp.fill !== undefined) {\n      const fillXml = stringify(fillDesc, sp.fill, ctx);\n      if (fillXml) spPrParts.push(fillXml);\n    }\n\n    // Outline\n    if (sp.outline) {\n      const outlineXml = stringify(outlineDesc, sp.outline, ctx);\n      if (outlineXml) spPrParts.push(outlineXml);\n    }\n\n    // Effects (a:effectLst after a:ln per CT_ShapeProperties)\n    if (sp.effects) spPrParts.push(stringify(effectListDesc, sp.effects, ctx) ?? \"\");\n    if (sp.scene3d) spPrParts.push(scene3DDesc.stringify(sp.scene3d, ctx) ?? \"\");\n    if (sp.shape3d) spPrParts.push(shape3DDesc.stringify(sp.shape3d, ctx) ?? \"\");\n\n    parts.push(`<p:spPr>${spPrParts.join(\"\")}</p:spPr>`);\n\n    // p:style\n    if (opts.style) {\n      const styleXml = stringifyShapeStyle(opts.style, ctx);\n      if (styleXml) parts.push(styleXml);\n    }\n\n    // p:txBody — source lines carry wrap/anchor hints; fresh ones keep the default.\n    const txBodyContent = opts.textBody\n      ? (textBodyDesc.stringify(opts.textBody, ctx) ?? \"\")\n      : '<a:bodyPr wrap=\"square\"/><a:lstStyle/><a:p/>';\n    parts.push(`<p:txBody>${txBodyContent}</p:txBody>`);\n\n    return `<p:sp>${parts.join(\"\")}</p:sp>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<LineShapeOptions> = {};\n\n    // p:nvSpPr → id, name\n    Object.assign(result, readCnvPr(el, \"p:nvSpPr\"));\n    const nvSpPr = findChild(el, \"p:nvSpPr\");\n    const cNvSpPr = nvSpPr ? findChild(nvSpPr, \"p:cNvSpPr\") : undefined;\n    const spLocks = cNvSpPr ? findChild(cNvSpPr, \"a:spLocks\") : undefined;\n    if (spLocks) {\n      const locks = shapeLockingDesc.parse(spLocks, _ctx);\n      if (locks && Object.keys(locks).length > 0) result.locking = locks;\n    }\n\n    // p:spPr → endpoints (off/ext + flip) + fill/outline/effects\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) Object.assign(result, parseLineSpPr(spPr, _ctx));\n\n    // p:style\n    const lineStyle = findChild(el, \"p:style\");\n    if (lineStyle) result.style = readShapeStyle(lineStyle, _ctx);\n\n    // p:txBody — keep the source's wrap/anchor hints and empty-paragraph rPr.\n    const txBody = findChild(el, \"p:txBody\");\n    if (txBody) result.textBody = textBodyDesc.parse(txBody, _ctx);\n\n    return result as LineShapeOptions;\n  },\n};\n\n// ── ConnectorShape (p:cxnSp) descriptor ──\n\nexport const connectorShapeDesc: CustomDescriptor<ConnectorOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextConnectorId++;\n    const name = opts.name ?? `Connector ${id}`;\n    (ctx as PptxWriteContext).registerShapeId(name, id);\n\n    const x1 = convertToEmu(opts.x1 ?? 0);\n    const y1 = convertToEmu(opts.y1 ?? 0);\n    const x2 = convertToEmu(opts.x2 ?? \"100px\");\n    const y2 = convertToEmu(opts.y2 ?? \"100px\");\n\n    // Preset geometry: bent/elbow connectors carry their own form + guides.\n    const geomXml =\n      opts.properties?.geometry !== undefined\n        ? (presetGeometryDesc.stringify(\n            typeof opts.properties.geometry === \"string\"\n              ? { preset: opts.properties.geometry }\n              : opts.properties.geometry,\n            ctx,\n          ) ?? \"\")\n        : undefined;\n\n    const parts: string[] = [];\n\n    // p:nvCxnSpPr — cNvCxnSpPr holds optional cxnSpLocks/stCxn/endCxn.\n    const cNvCxnSpPrInner: string[] = [];\n    if (opts.locking) {\n      const locks = stringify(connectorLockingDesc, opts.locking, ctx);\n      if (locks) cNvCxnSpPrInner.push(locks);\n    }\n    if (opts.startConnection) {\n      cNvCxnSpPrInner.push(stringifyEndpointConnection(\"stCxn\", opts.startConnection));\n    }\n    if (opts.endConnection) {\n      cNvCxnSpPrInner.push(stringifyEndpointConnection(\"endCxn\", opts.endConnection));\n    }\n    const cNvCxnSpPr = cNvCxnSpPrInner.length\n      ? `<p:cNvCxnSpPr>${cNvCxnSpPrInner.join(\"\")}</p:cNvCxnSpPr>`\n      : \"<p:cNvCxnSpPr/>\";\n    parts.push(\n      `<p:nvCxnSpPr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}${cNvCxnSpPr}<p:nvPr/></p:nvCxnSpPr>`,\n    );\n\n    // p:spPr\n    const sp = opts.properties ?? {};\n    const spPrParts: string[] = [];\n    spPrParts.push(stringifyLineXfrmGeometry(x1, y1, x2, y2, geomXml));\n\n    // Fill\n    if (sp.fill !== undefined) {\n      const fillXml = stringify(fillDesc, sp.fill, ctx);\n      if (fillXml) spPrParts.push(fillXml);\n    }\n\n    // Outline (arrowheads live inside the outline as headEnd/tailEnd)\n    if (sp.outline) {\n      const outlineXml = stringify(outlineDesc, sp.outline, ctx);\n      if (outlineXml) spPrParts.push(outlineXml);\n    }\n\n    // Effects (a:effectLst after a:ln per CT_ShapeProperties)\n    if (sp.effects) spPrParts.push(stringify(effectListDesc, sp.effects, ctx) ?? \"\");\n    if (sp.scene3d) spPrParts.push(scene3DDesc.stringify(sp.scene3d, ctx) ?? \"\");\n    if (sp.shape3d) spPrParts.push(shape3DDesc.stringify(sp.shape3d, ctx) ?? \"\");\n\n    parts.push(`<p:spPr>${spPrParts.join(\"\")}</p:spPr>`);\n\n    // p:style\n    if (opts.style) {\n      const styleXml = stringifyShapeStyle(opts.style, ctx);\n      if (styleXml) parts.push(styleXml);\n    }\n\n    return `<p:cxnSp>${parts.join(\"\")}</p:cxnSp>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<ConnectorOptions> = {};\n\n    // p:nvCxnSpPr → id, name, and optional cNvCxnSpPr (locks + connections)\n    const nvCxnSpPr = findChild(el, \"p:nvCxnSpPr\");\n    if (nvCxnSpPr) {\n      Object.assign(result, readCnvPr(nvCxnSpPr));\n      const cNvCxnSpPr = findChild(nvCxnSpPr, \"p:cNvCxnSpPr\");\n      if (cNvCxnSpPr) {\n        const cxnSpLocks = findChild(cNvCxnSpPr, \"a:cxnSpLocks\");\n        if (cxnSpLocks) {\n          const locks = parse(connectorLockingDesc, cxnSpLocks, _ctx);\n          if (locks && Object.keys(locks).length > 0) result.locking = locks;\n        }\n        const stCxn = findChild(cNvCxnSpPr, \"a:stCxn\");\n        if (stCxn) {\n          const conn = parseEndpointConnection(stCxn);\n          if (conn) result.startConnection = conn;\n        }\n        const endCxn = findChild(cNvCxnSpPr, \"a:endCxn\");\n        if (endCxn) {\n          const conn = parseEndpointConnection(endCxn);\n          if (conn) result.endConnection = conn;\n        }\n      }\n    }\n\n    // p:spPr → endpoints (off/ext + flip) + geometry/fill/outline/effects\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) {\n      const { properties, ...endpoints } = parseLineSpPr(spPr, _ctx);\n      Object.assign(result, endpoints);\n      result.properties = properties;\n      // Non-line presets or adjusted guides must survive the round-trip.\n      const prstGeom = findChild(spPr, \"a:prstGeom\");\n      if (prstGeom) {\n        const geom = presetGeometryDesc.parse(prstGeom, _ctx);\n        if (geom.preset !== undefined && (geom.preset !== \"line\" || geom.adjustmentValues)) {\n          result.properties.geometry = geom;\n        }\n      }\n    }\n\n    // p:style\n    const cxnStyle = findChild(el, \"p:style\");\n    if (cxnStyle) result.style = readShapeStyle(cxnStyle, _ctx);\n\n    return result as ConnectorOptions;\n  },\n};\n","/**\n * Locked Canvas descriptor for PPTX.\n *\n * Produces a p:graphicFrame with lc:lockedCanvas.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport {\n  stringifyNonVisualDrawingProperties,\n  shapePropertiesDesc,\n  textBodyDesc,\n} from \"@office-open/core/drawing\";\nimport { findChild } from \"@office-open/xml\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport type { LockedCanvasFrameOptions, LockedCanvasShapeOptions } from \"../locked-canvas-frame\";\nimport {\n  readGraphicFrameLocking,\n  readNvPrPlaceholder,\n  stringifyCnvGraphicFramePr,\n  stringifyNvPr,\n} from \"./graphic-frame\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\n\n// ── ID counters ──\n\nlet _nextLockedCanvasId = 2048;\nlet _nextCanvasShapeId = 2;\n\n// ── Locked Canvas descriptor ──\n\nexport const lockedCanvasDesc: CustomDescriptor<LockedCanvasFrameOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextLockedCanvasId++;\n    const name = opts.name ?? `Locked Canvas ${id}`;\n    (ctx as PptxWriteContext).registerShapeId(name, id);\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    const cx = convertToEmu(opts.width ?? 0);\n    const cy = convertToEmu(opts.height ?? 0);\n\n    const parts: string[] = [];\n\n    // p:nvGraphicFramePr\n    parts.push(\n      `<p:nvGraphicFramePr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}` +\n        `${stringifyCnvGraphicFramePr(opts.locking)}` +\n        `${stringifyNvPr(opts)}</p:nvGraphicFramePr>`,\n    );\n\n    // p:xfrm\n    parts.push(`<p:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/></p:xfrm>`);\n\n    // a:graphic > a:graphicData > lc:lockedCanvas\n    const grpSpPr =\n      `<a:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"${cx}\" cy=\"${cy}\"/>` +\n      `<a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"${cx}\" cy=\"${cy}\"/></a:xfrm></a:grpSpPr>`;\n    const canvasChildren = buildCanvasChildren(opts.children, ctx);\n\n    parts.push(\n      `<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas\">` +\n        `<lc:lockedCanvas xmlns:lc=\"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas\">` +\n        `<a:nvGrpSpPr><a:cNvPr id=\"0\" name=\"\"/><a:cNvGrpSpPr/></a:nvGrpSpPr>` +\n        `${grpSpPr}${canvasChildren}` +\n        `</lc:lockedCanvas></a:graphicData></a:graphic>`,\n    );\n\n    return `<p:graphicFrame>${parts.join(\"\")}</p:graphicFrame>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<LockedCanvasFrameOptions> = {};\n\n    // id, name from p:nvGraphicFramePr/p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvGraphicFramePr\"));\n    const locking = readGraphicFrameLocking(findChild(el, \"p:nvGraphicFramePr\"), _ctx);\n    readNvPrPlaceholder(findChild(el, \"p:nvGraphicFramePr\") ?? el, result);\n    if (locking !== undefined) result.locking = locking;\n\n    // x, y, width, height from p:xfrm\n    const xfrm = findChild(el, \"p:xfrm\");\n    if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n\n    // Navigate to a:graphic/a:graphicData/lc:lockedCanvas\n    const graphic = findChild(el, \"a:graphic\");\n    const graphicData = graphic ? findChild(graphic, \"a:graphicData\") : undefined;\n    const lockedCanvas = graphicData ? findChild(graphicData, \"lc:lockedCanvas\") : undefined;\n\n    if (lockedCanvas) {\n      const children: LockedCanvasShapeOptions[] = [];\n      for (const child of lockedCanvas.elements ?? []) {\n        if (child.name !== \"a:sp\") continue;\n        const shape: Partial<LockedCanvasShapeOptions> = {};\n\n        // Full CT_ShapeProperties round-trip (geometry/fill/outline/effects/…)\n        const spPr = findChild(child, \"a:spPr\");\n        if (spPr) {\n          Object.assign(shape, shapePropertiesDesc.parse(spPr, _ctx));\n        }\n\n        // textBody from a:txSp/a:txBody/a:p/a:r/a:t\n        const txSp = findChild(child, \"a:txSp\");\n        if (txSp) {\n          const txBody = findChild(txSp, \"a:txBody\");\n          if (txBody) {\n            const txt = collectRunText(txBody);\n            if (txt) shape.textBody = txt;\n          }\n        }\n\n        children.push(shape as LockedCanvasShapeOptions);\n      }\n      if (children.length > 0) result.children = children;\n    }\n\n    return result as LockedCanvasFrameOptions;\n  },\n};\n\nfunction buildCanvasChildren(\n  children: LockedCanvasShapeOptions[] | undefined,\n  ctx: Parameters<typeof shapePropertiesDesc.stringify>[1],\n): string {\n  if (!children || children.length === 0) return \"\";\n\n  const parts: string[] = [];\n  for (const { textBody, ...spPr } of children) {\n    const id = _nextCanvasShapeId++;\n    const spPrContent = shapePropertiesDesc.stringify(\n      { ...spPr, geometry: spPr.geometry ?? \"rect\" },\n      ctx,\n    );\n\n    const txBodyContent = textBodyDesc.stringify(\n      textBody !== undefined ? { text: textBody } : {},\n      ctx,\n    );\n\n    parts.push(\n      `<a:sp>` +\n        `<a:nvSpPr><a:cNvPr id=\"${id}\" name=\"Shape ${id}\"/><a:cNvSpPr/></a:nvSpPr>` +\n        `<a:spPr>${spPrContent ?? \"\"}</a:spPr>` +\n        `<a:txSp><a:txBody>${txBodyContent ?? \"\"}</a:txBody><a:useSpRect/></a:txSp>` +\n        `</a:sp>`,\n    );\n  }\n\n  return parts.join(\"\");\n}\n\n/** Collect text from a:r/a:t children within a txBody element. */\nfunction collectRunText(el: {\n  elements?: Array<{ name?: string; text?: string | number | boolean; elements?: Array<unknown> }>;\n}): string {\n  const parts: string[] = [];\n  for (const child of el.elements ?? []) {\n    if (child.name === \"a:r\") {\n      // Look for a:t child\n      for (const sub of (child.elements ?? []) as Array<{\n        name?: string;\n        text?: string | number | boolean;\n      }>) {\n        if (sub.name === \"a:t\" && sub.text !== undefined) {\n          parts.push(String(sub.text));\n        }\n      }\n    } else if (child.name === \"a:p\") {\n      parts.push(collectRunText(child as Parameters<typeof collectRunText>[0]));\n    }\n  }\n  return parts.join(\"\");\n}\n","/**\n * Video and Audio frame descriptors for PPTX.\n *\n * Both produce p:pic elements with media placeholders that are\n * resolved during compilation.\n *\n * Reference: OOXML transitional, dml-main.xsd EG_Media\n * (audioCd / wavAudioFile / audioFile / videoFile / quickTimeFile).\n *\n * @module\n */\n\nimport { toUint8Array } from \"@office-open/core\";\nimport type { DataType } from \"@office-open/core\";\nimport type { CustomDescriptor, ReadContext } from \"@office-open/core/descriptor\";\nimport {\n  shapePropertiesDesc,\n  stringifyNonVisualDrawingProperties,\n} from \"@office-open/core/drawing\";\nimport { attr, attrNum, escapeXml, findChild, findFirst, stringify } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AudioCdOptions, AudioFrameOptions, AudioType } from \"@shared/media/audio-frame\";\nimport { imageTypeFromPath } from \"@shared/media/image-type\";\nimport type { MediaFrameBaseOptions, MediaTrimOptions } from \"@shared/media/media-frame-base\";\nimport type { VideoFrameOptions, VideoType } from \"@shared/media/video-frame\";\n\nimport type { MediaEntry, PptxWriteContext } from \"../../context\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\n\n// ── ID counters ──\n\nlet _nextVideoId = 100;\nlet _nextAudioId = 200;\n\n// ── Extension URIs ──\n\n// The p14:media extension uri is shared by audio and video frames (the\n// documented media extension; PptxGenJS/python-pptx emit the same uri for both).\nexport const MEDIA_EXT_URI = \"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}\";\n\n// ── Shared media element builders (EG_Media) ──\n\n/** a:audioCd — CD track playback, no media file. */\nfunction stringifyAudioCd(cd: AudioCdOptions): string {\n  const ext = cd.ext !== undefined ? `<a:extLst>${cd.ext}</a:extLst>` : \"\";\n  return (\n    `<a:audioCd><a:st${stringifyAudioCdTime(cd.start)}/>` +\n    `<a:end${stringifyAudioCdTime(cd.end)}/>${ext}</a:audioCd>`\n  );\n}\n\nfunction stringifyAudioCdTime(t: AudioCdOptions[\"start\"]): string {\n  let s = ` track=\"${t.track}\"`;\n  if (t.time !== undefined) s += ` time=\"${t.time}\"`;\n  return s;\n}\n\n/** p14:media extension body — embed reference plus optional trim child. */\nfunction stringifyP14Media(mediaFileName: string, trim?: MediaTrimOptions): string {\n  const trimXml = trim\n    ? `<p14:trim${trim.start !== undefined ? ` st=\"${trim.start}\"` : \"\"}${trim.end !== undefined ? ` end=\"${trim.end}\"` : \"\"}/>`\n    : \"\";\n  return (\n    `<p:extLst><p:ext uri=\"${MEDIA_EXT_URI}\">` +\n    `<p14:media r:embed=\"{media:${mediaFileName}}\" xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\"` +\n    (trimXml ? `>${trimXml}</p14:media>` : \"/>\") +\n    `</p:ext></p:extLst>`\n  );\n}\n\n/** Read p14:trim (play window) off a p14:media element. */\nfunction readMediaTrim(p14media: Element): MediaTrimOptions | undefined {\n  const trimEl = (p14media.elements ?? []).find((c) => c.name === \"p14:trim\");\n  if (!trimEl) return undefined;\n  const trim: MediaTrimOptions = {};\n  const st = attrNum(trimEl, \"st\");\n  if (st !== undefined) trim.start = st;\n  const end = attrNum(trimEl, \"end\");\n  if (end !== undefined) trim.end = end;\n  return Object.keys(trim).length > 0 ? trim : {};\n}\n\n/** a:audioFile / a:wavAudioFile — linked/embedded audio file. */\nfunction stringifyAudioFile(\n  mediaFileName: string,\n  type: AudioType,\n  opts: AudioFrameOptions,\n): string {\n  const contentType = opts.contentType ? ` contentType=\"${escapeXml(opts.contentType)}\"` : \"\";\n  if (type === \"wav\") {\n    // Embedded WAV: r:embed + optional original file name.\n    const name = opts.audioFileName ? ` name=\"${escapeXml(opts.audioFileName)}\"` : \"\";\n    return `<a:wavAudioFile r:embed=\"{audio:${mediaFileName}}\"${name}/>`;\n  }\n  return `<a:audioFile r:link=\"{audio:${mediaFileName}}\"${contentType}/>`;\n}\n\n// ── Video descriptor ──\n\nexport const videoDesc: CustomDescriptor<VideoFrameOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextVideoId++;\n    const name = opts.name ?? `Video ${id}`;\n    const pptx = ctx as PptxWriteContext;\n    pptx.registerShapeId(name, id);\n    const mediaFileName = registerMediaFile(\n      pptx,\n      opts.data,\n      opts.type ?? \"mp4\",\n      opts.fileName ?? `${name.replace(/\\s+/g, \"_\")}.${opts.type ?? \"mp4\"}`,\n    );\n\n    const parts: string[] = [];\n\n    // p:nvPicPr\n    const contentType = opts.contentType ? ` contentType=\"${escapeXml(opts.contentType)}\"` : \"\";\n    const mediaEl = mediaFileName\n      ? `<a:videoFile r:link=\"{video:${mediaFileName}}\"${contentType}/>`\n      : \"\";\n    const hlinkXml = opts.mediaAction ? '<a:hlinkClick r:id=\"\" action=\"ppaction://media\"/>' : \"\";\n    parts.push(\n      `<p:nvPicPr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name, hlinkXml)}` +\n        `<p:cNvPicPr><a:picLocks noChangeAspect=\"1\"/></p:cNvPicPr>` +\n        `<p:nvPr>${mediaEl}` +\n        (mediaFileName ? stringifyP14Media(mediaFileName, opts.trim) : \"\") +\n        `</p:nvPr></p:nvPicPr>`,\n    );\n\n    // p:blipFill (poster image)\n    let posterAttr = \"\";\n    if (opts.poster) {\n      const posterFileName = registerMediaFile(\n        pptx,\n        opts.poster,\n        opts.posterType ?? \"png\",\n        `${name.replace(/\\s+/g, \"_\")}_poster.${opts.posterType ?? \"png\"}`,\n      );\n      if (posterFileName) posterAttr = `<a:blip r:embed=\"{${posterFileName}}\"/>`;\n    }\n    parts.push(`<p:blipFill>${posterAttr}<a:stretch><a:fillRect/></a:stretch></p:blipFill>`);\n\n    // p:spPr\n    parts.push(stringifyMediaSpPr(opts, ctx));\n\n    return `<p:pic>${parts.join(\"\")}</p:pic>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<VideoFrameOptions> = {};\n\n    // Position from p:spPr\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) {\n      const xfrm = findChild(spPr, \"a:xfrm\");\n      if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n    }\n\n    // id + name from p:nvPicPr → a:cNvPr or p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvPicPr\"));\n    readMediaAction(el, result);\n\n    // Media data from a:videoFile (r:link) or p14:media (r:embed)\n    const quickTimeEl = findFirst(el, \"a:quickTimeFile\");\n    const videoFileEl = findFirst(el, \"a:videoFile\") ?? quickTimeEl;\n    const rLink = videoFileEl ? attr(videoFileEl, \"r:link\") : undefined;\n    // The p14:media extension copy coexists with the EG_Media element — a\n    // source whose r:link is a broken external target still carries the real\n    // bytes under r:embed here, so it is always read.\n    const p14media = findFirst(el, \"p14:media\");\n    const rEmbed = p14media ? attr(p14media, \"r:embed\") : undefined;\n    if (p14media) {\n      const trim = readMediaTrim(p14media);\n      if (trim) result.trim = trim;\n    }\n    const mediaRef = rLink ?? rEmbed;\n    if (mediaRef) {\n      const mediaPath = _ctx.resolveRelationship(mediaRef);\n      let data: Uint8Array | undefined;\n      let resolvedPath = mediaPath;\n      if (mediaPath) data = _ctx.getRaw(mediaPath);\n      if (!data && rEmbed && rEmbed !== mediaRef) {\n        // The link target is unreadable (broken or external) — fall back to\n        // the embedded p14:media copy.\n        resolvedPath = _ctx.resolveRelationship(rEmbed);\n        data = resolvedPath ? _ctx.getRaw(resolvedPath) : undefined;\n      }\n      if (resolvedPath) {\n        if (data) result.data = data;\n        // Keep the source file name — re-deriving it from the frame name\n        // renames the media part (a name that already carries the extension\n        // would even double it).\n        result.fileName = resolvedPath.split(\"/\").pop();\n      }\n      // Fall back to the placeholder reference (e.g. \"{media:foo.mp4}\") when the\n      // relationship isn't registered, so the type survives a round-trip.\n      result.type = mediaTypeFromPath(resolvedPath ?? mediaRef, \"video\");\n    }\n    if (quickTimeEl) result.type = \"mov\";\n    if (videoFileEl) {\n      const contentType = attr(videoFileEl, \"contentType\");\n      if (contentType) result.contentType = contentType;\n    }\n\n    // Poster from blipFill\n    readPoster(el, result, _ctx);\n\n    return result as VideoFrameOptions;\n  },\n};\n\n// ── Audio descriptor ──\n\nexport const audioDesc: CustomDescriptor<AudioFrameOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextAudioId++;\n    const name = opts.name ?? `Audio ${id}`;\n    const pptx = ctx as PptxWriteContext;\n    pptx.registerShapeId(name, id);\n    const mediaFileName =\n      opts.data !== undefined\n        ? registerMediaFile(\n            pptx,\n            opts.data,\n            opts.type ?? \"mp3\",\n            opts.fileName ?? `${name.replace(/\\s+/g, \"_\")}.${opts.type ?? \"mp3\"}`,\n          )\n        : undefined;\n\n    const parts: string[] = [];\n\n    // p:nvPicPr — EG_Media choice, then the p14:media extension. Embedded WAV\n    // carries no media extension (pre-2010 form); linked audio does.\n    let mediaEl: string;\n    if (opts.audioCd) {\n      mediaEl = stringifyAudioCd(opts.audioCd);\n    } else if (mediaFileName) {\n      mediaEl = stringifyAudioFile(mediaFileName, opts.type ?? \"mp3\", opts);\n    } else {\n      mediaEl = \"\";\n    }\n    const emitExt = mediaFileName !== undefined && (opts.type ?? \"mp3\") !== \"wav\";\n    const hlinkXml = opts.mediaAction ? '<a:hlinkClick r:id=\"\" action=\"ppaction://media\"/>' : \"\";\n    parts.push(\n      `<p:nvPicPr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name, hlinkXml)}` +\n        `<p:cNvPicPr><a:picLocks noChangeAspect=\"1\"/></p:cNvPicPr>` +\n        `<p:nvPr>${mediaEl}` +\n        (emitExt ? stringifyP14Media(mediaFileName!, opts.trim) : \"\") +\n        `</p:nvPr></p:nvPicPr>`,\n    );\n\n    // p:blipFill (speaker art poster when present)\n    let posterAttr = \"\";\n    if (opts.poster) {\n      const posterFileName = registerMediaFile(\n        pptx,\n        opts.poster,\n        opts.posterType ?? \"png\",\n        `${name.replace(/\\s+/g, \"_\")}_poster.${opts.posterType ?? \"png\"}`,\n      );\n      if (posterFileName) posterAttr = `<a:blip r:embed=\"{${posterFileName}}\"/>`;\n    }\n    parts.push(`<p:blipFill>${posterAttr}<a:stretch><a:fillRect/></a:stretch></p:blipFill>`);\n\n    // p:spPr\n    parts.push(stringifyMediaSpPr(opts, ctx));\n\n    return `<p:pic>${parts.join(\"\")}</p:pic>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<AudioFrameOptions> = {};\n\n    // Position from p:spPr\n    const spPr = findChild(el, \"p:spPr\");\n    if (spPr) {\n      const xfrm = findChild(spPr, \"a:xfrm\");\n      if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n    }\n\n    // id + name from p:nvPicPr\n    Object.assign(result, readCnvPr(el, \"p:nvPicPr\"));\n    readMediaAction(el, result);\n\n    // CD audio (a:audioCd) — track/time, no media file\n    const audioCdEl = findFirst(el, \"a:audioCd\");\n    if (audioCdEl) {\n      const stEl = findChild(audioCdEl, \"a:st\");\n      const endEl = findChild(audioCdEl, \"a:end\");\n      if (stEl && endEl) {\n        const cd: AudioCdOptions = {\n          start: readAudioCdTime(stEl),\n          end: readAudioCdTime(endEl),\n        };\n        const extLst = findChild(audioCdEl, \"a:extLst\");\n        if (extLst) cd.ext = stringify(extLst);\n        result.audioCd = cd;\n      }\n      readPoster(el, result, _ctx);\n      return result as AudioFrameOptions;\n    }\n\n    // Media data from a:audioFile / a:wavAudioFile (r:link/r:embed) or p14:media\n    const wavFileEl = findFirst(el, \"a:wavAudioFile\");\n    const audioFileEl = findFirst(el, \"a:audioFile\") ?? wavFileEl;\n    const rLink = audioFileEl ? attr(audioFileEl, \"r:link\") : undefined;\n    const rEmbedAttr = audioFileEl ? attr(audioFileEl, \"r:embed\") : undefined;\n    // The p14:media extension copy coexists with the EG_Media element — a\n    // source whose r:link is a broken external target still carries the real\n    // bytes under r:embed here, so it is always read.\n    const p14media = findFirst(el, \"p14:media\");\n    const rEmbedExt = p14media ? attr(p14media, \"r:embed\") : undefined;\n    if (p14media) {\n      const trim = readMediaTrim(p14media);\n      if (trim) result.trim = trim;\n    }\n    const mediaRef = rLink ?? rEmbedAttr ?? rEmbedExt;\n    if (mediaRef) {\n      const mediaPath = _ctx.resolveRelationship(mediaRef);\n      let data: Uint8Array | undefined;\n      let resolvedPath = mediaPath;\n      if (mediaPath) data = _ctx.getRaw(mediaPath);\n      if (!data && rEmbedExt && rEmbedExt !== mediaRef) {\n        // The link target is unreadable (broken or external) — fall back to\n        // the embedded p14:media copy.\n        resolvedPath = _ctx.resolveRelationship(rEmbedExt);\n        data = resolvedPath ? _ctx.getRaw(resolvedPath) : undefined;\n      }\n      if (resolvedPath) {\n        if (data) result.data = data;\n        // Keep the source file name — re-deriving it from the frame name\n        // renames the media part.\n        result.fileName = resolvedPath.split(\"/\").pop();\n      }\n      // Fall back to the placeholder reference (e.g. \"{media:foo.wav}\") when the\n      // relationship isn't registered, so the type survives a round-trip.\n      result.type = mediaTypeFromPath(resolvedPath ?? mediaRef, \"audio\");\n    }\n    if (wavFileEl) result.type = \"wav\";\n    if (audioFileEl) {\n      const contentType = attr(audioFileEl, \"contentType\");\n      if (contentType) result.contentType = contentType;\n      const audioFileName = attr(audioFileEl, \"name\");\n      if (audioFileName) result.audioFileName = audioFileName;\n    }\n\n    readPoster(el, result, _ctx);\n\n    return result as AudioFrameOptions;\n  },\n};\n\n// ── Helpers ──\n\nfunction readAudioCdTime(el: Element): AudioCdOptions[\"start\"] {\n  const time = attrNum(el, \"time\");\n  return { track: attrNum(el, \"track\") ?? 0, ...(time !== undefined ? { time } : {}) };\n}\n\n/** Read the click-to-play hyperlink (a:hlinkClick action=\"ppaction://media\"). */\nfunction readMediaAction(el: Element, result: { mediaAction?: boolean }): void {\n  const hlinkClick = findFirst(el, \"a:hlinkClick\");\n  if (hlinkClick && attr(hlinkClick, \"action\") === \"ppaction://media\") {\n    result.mediaAction = true;\n  }\n}\n\n/** Read the poster image from p:blipFill → a:blip r:embed. */\nfunction readPoster(\n  el: Element,\n  result: { poster?: DataType; posterType?: \"png\" | \"jpg\" },\n  ctx: ReadContext,\n): void {\n  const blipFill = findChild(el, \"p:blipFill\");\n  if (!blipFill) return;\n  const blip = findChild(blipFill, \"a:blip\");\n  if (!blip) return;\n  const rEmbedPoster = attr(blip, \"r:embed\");\n  if (!rEmbedPoster) return;\n  const posterPath = ctx.resolveRelationship(rEmbedPoster);\n  if (posterPath) {\n    const data = ctx.getRaw(posterPath);\n    if (data) result.poster = data;\n    // PosterType only allows png/jpg — other extensions fall back to png.\n    const posterType = imageTypeFromPath(posterPath);\n    result.posterType = posterType === \"jpg\" ? \"jpg\" : \"png\";\n  }\n}\n\n/**\n * Register media bytes under a deterministic file name and return the canonical\n * name (which may differ when the requested name is taken by other bytes).\n * Returns undefined when data is undefined.\n */\nfunction registerMediaFile(\n  pptx: PptxWriteContext,\n  data: MediaFrameBaseOptions[\"data\"] | undefined,\n  type: string,\n  fileName: string,\n): string | undefined {\n  if (data === undefined) return undefined;\n  const raw = toUint8Array(data, { encoding: \"base64\" });\n  const entry: MediaEntry = {\n    key: fileName,\n    data: raw,\n    fileName,\n    type,\n  };\n  return pptx.addImage(fileName, entry).fileName;\n}\n\n/** p:spPr for a media frame: position/size + rect geometry (picture precedent). */\nfunction stringifyMediaSpPr(\n  opts: Pick<MediaFrameBaseOptions, \"x\" | \"y\" | \"width\" | \"height\">,\n  ctx: Parameters<typeof shapePropertiesDesc.stringify>[1],\n): string {\n  const content = shapePropertiesDesc.stringify(\n    {\n      x: opts.x ?? 0,\n      y: opts.y ?? 0,\n      width: opts.width ?? 0,\n      height: opts.height ?? 0,\n      geometry: \"rect\",\n    },\n    ctx,\n  );\n  return `<p:spPr>${content ?? \"\"}</p:spPr>`;\n}\n\nfunction mediaTypeFromPath(path: string, kind: \"video\"): VideoType;\nfunction mediaTypeFromPath(path: string, kind: \"audio\"): AudioType;\nfunction mediaTypeFromPath(path: string, kind: \"video\" | \"audio\"): VideoType | AudioType {\n  // Tolerate placeholder wrappers like \"{media:foo.wav}\" — extract the last\n  // alphanumeric extension token rather than a trailing fragment with \"}\".\n  const ext = path.match(/\\.([a-z0-9]+)\\b/i)?.[1]?.toLowerCase() ?? \"\";\n  if (kind === \"video\") {\n    if ([\"mp4\", \"mov\", \"wmv\", \"avi\"].includes(ext)) return ext as VideoType;\n    return \"mp4\";\n  }\n  if ([\"mp3\", \"wav\", \"wma\", \"aac\"].includes(ext)) return ext as AudioType;\n  return \"mp3\";\n}\n","/**\n * OLE Object descriptor for PPTX.\n *\n * Produces a p:graphicFrame with p:oleObj.\n *\n * @module\n */\n\nimport { convertToEmu, toUint8Array } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { stringifyNonVisualDrawingProperties } from \"@office-open/core/drawing\";\nimport { attr, attrBool, attrNum, escapeXml, findChild, findFirst } from \"@office-open/xml\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport type { OleOptions } from \"../ole-frame\";\nimport {\n  readGraphicFrameLocking,\n  readNvPrPlaceholder,\n  stringifyCnvGraphicFramePr,\n  stringifyNvPr,\n} from \"./graphic-frame\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\n\n// ── ID counter ──\n\nlet _nextOleId = 2048;\n\n// ── OLE descriptor ──\n\nexport const oleDesc: CustomDescriptor<OleOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const id = opts.id ?? _nextOleId++;\n    const name = opts.name ?? `Object ${id}`;\n    (ctx as PptxWriteContext).registerShapeId(name, id);\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    const w = convertToEmu(opts.width ?? \"100px\");\n    const h = convertToEmu(opts.height ?? \"100px\");\n\n    const parts: string[] = [];\n\n    // p:nvGraphicFramePr\n    parts.push(\n      `<p:nvGraphicFramePr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}` +\n        `${stringifyCnvGraphicFramePr(opts.locking)}` +\n        `${stringifyNvPr(opts)}</p:nvGraphicFramePr>`,\n    );\n\n    // p:xfrm\n    parts.push(`<p:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${w}\" cy=\"${h}\"/></p:xfrm>`);\n\n    // a:graphic > a:graphicData > p:oleObj\n    const oleAttrs: string[] = [];\n    oleAttrs.push(`name=\"${escapeXml(opts.name ?? \"OLE Object\")}\"`);\n    if (opts.shapeId) oleAttrs.push(`spid=\"${opts.shapeId}\"`);\n    if (opts.showAsIcon) oleAttrs.push(`showAsIcon=\"1\"`);\n    if (opts.imageWidth !== undefined) oleAttrs.push(`imgW=\"${opts.imageWidth}\"`);\n    if (opts.imageHeight !== undefined) oleAttrs.push(`imgH=\"${opts.imageHeight}\"`);\n    if (opts.progId) oleAttrs.push(`progId=\"${opts.progId}\"`);\n\n    // Embedded OLE: register the binary as ppt/embeddings/oleObjectN.bin and\n    // emit a {ole:…} placeholder — the compiler rewrites it to a real r:id and\n    // adds the oleObject relationship. Linked OLE emits an {ole-link:…}\n    // placeholder resolved to an External oleObject relationship the same way.\n    // followColorScheme is CT_OleObjectEmbed's attribute, not oleObj's.\n    const oleChildren: string[] = [];\n    if (opts.embed) {\n      const pptxCtx = ctx as PptxWriteContext;\n      const ref = pptxCtx.addOle(toUint8Array(opts.embed.data) as Uint8Array, opts.progId);\n      oleAttrs.push(`r:id=\"${ref}\"`);\n      const fcs = opts.embed.followColorScheme\n        ? ` followColorScheme=\"${opts.embed.followColorScheme}\"`\n        : \"\";\n      oleChildren.push(`<p:embed${fcs}/>`);\n    } else if (opts.link) {\n      const pptxCtx = ctx as PptxWriteContext;\n      const linkKey = pptxCtx.addOleLink(opts.link.url);\n      oleAttrs.push(`r:id=\"{ole-link:${linkKey}}\"`);\n      const linkAttrs = opts.link.autoUpdate ? ' updateAutomatic=\"1\"' : \"\";\n      oleChildren.push(`<p:link${linkAttrs}/>`);\n    } else {\n      // p:oleObj's content model is a required choice between p:embed and\n      // p:link — emitting neither produces schema-invalid XML.\n      throw new Error(\"OleOptions requires either embed or link\");\n    }\n\n    // Icon/preview picture — MS Office refuses to open the presentation when\n    // an oleObj carries no picture, so it is emitted whenever iconImage is\n    // supplied. Registered as media; the {fileName} placeholder is rewritten\n    // by the compiler's image pass.\n    if (opts.iconImage) {\n      const pptxCtx = ctx as PptxWriteContext;\n      const imageRef = pptxCtx.addMedia(\n        toUint8Array(opts.iconImage.data) as Uint8Array,\n        opts.iconImage.type,\n      );\n      oleChildren.push(\n        `<p:pic><p:nvPicPr><p:cNvPr id=\"0\" name=\"\"/><p:cNvPicPr/><p:nvPr/></p:nvPicPr>` +\n          `<p:blipFill><a:blip r:embed=\"${imageRef}\"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>` +\n          `<p:spPr><a:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${w}\" cy=\"${h}\"/></a:xfrm>` +\n          `<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></p:spPr></p:pic>`,\n      );\n    }\n\n    parts.push(\n      `<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/presentationml/2006/ole\">` +\n        `<p:oleObj ${oleAttrs.join(\" \")}>${oleChildren.join(\"\")}</p:oleObj>` +\n        `</a:graphicData></a:graphic>`,\n    );\n\n    return `<p:graphicFrame>${parts.join(\"\")}</p:graphicFrame>`;\n  },\n\n  parse(el, ctx) {\n    const result: Partial<OleOptions> = {};\n\n    // id, name from p:nvGraphicFramePr/p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvGraphicFramePr\"));\n    const locking = readGraphicFrameLocking(findChild(el, \"p:nvGraphicFramePr\"), ctx);\n    readNvPrPlaceholder(findChild(el, \"p:nvGraphicFramePr\") ?? el, result);\n    if (locking !== undefined) result.locking = locking;\n\n    // x, y, width, height from p:xfrm (in EMU)\n    const xfrm = findChild(el, \"p:xfrm\");\n    if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n\n    // Navigate to a:graphic/a:graphicData/p:oleObj\n    const graphic = findChild(el, \"a:graphic\");\n    const graphicData = graphic ? findChild(graphic, \"a:graphicData\") : undefined;\n    const oleObj = graphicData ? findChild(graphicData, \"p:oleObj\") : undefined;\n    if (oleObj) {\n      const progId = attr(oleObj, \"progId\");\n      if (progId !== undefined) result.progId = progId;\n      const shapeId = attr(oleObj, \"spid\");\n      if (shapeId !== undefined) result.shapeId = shapeId;\n      if (attrBool(oleObj, \"showAsIcon\")) result.showAsIcon = true;\n      const imgW = attrNum(oleObj, \"imgW\");\n      if (imgW !== undefined) result.imageWidth = imgW;\n      const imgH = attrNum(oleObj, \"imgH\");\n      if (imgH !== undefined) result.imageHeight = imgH;\n\n      // embed/link — embedded OLE reads the binary back through the\n      // relationship so generate re-registers it in a fresh package.\n      const embedEl = findChild(oleObj, \"p:embed\");\n      if (embedEl) {\n        const rId = attr(oleObj, \"r:id\");\n        const mediaPath = rId ? ctx.resolveRelationship(rId) : undefined;\n        const raw = mediaPath ? ctx.getRaw(mediaPath) : undefined;\n        const followCS = attr(embedEl, \"followColorScheme\") as\n          | \"none\"\n          | \"full\"\n          | \"textAndBackground\"\n          | undefined;\n        if (raw) {\n          result.embed = {\n            data: raw,\n            ...(followCS !== undefined ? { followColorScheme: followCS } : {}),\n          };\n        }\n      } else {\n        const linkEl = findChild(oleObj, \"p:link\");\n        if (linkEl) {\n          const rId = attr(oleObj, \"r:id\");\n          // The linked source resolves through the External oleObject\n          // relationship — the URL is the durable fact; the source rId itself\n          // does not survive renumbering.\n          const url = rId ? ctx.resolveRelationship(rId) : undefined;\n          const autoUpdate = attrBool(linkEl, \"updateAutomatic\") === true;\n          if (url) result.link = { url, ...(autoUpdate ? { autoUpdate: true } : {}) };\n        }\n      }\n\n      // iconImage: read the picture bytes back through the blip relationship\n      const pic = findChild(oleObj, \"p:pic\");\n      if (pic) {\n        const blip = findFirst(pic, \"a:blip\");\n        const blipRId = blip ? attr(blip, \"r:embed\") : undefined;\n        const imagePath = blipRId ? ctx.resolveRelationship(blipRId) : undefined;\n        const raw = imagePath ? ctx.getRaw(imagePath) : undefined;\n        const type = imagePath?.split(\".\").pop();\n        if (raw && type) result.iconImage = { data: raw, type };\n      }\n    }\n\n    return result as OleOptions;\n  },\n};\n","/**\n * SmartArt (p:graphicFrame with diagram) descriptor for PPTX.\n *\n * Produces a graphicFrame with SmartArt relationship placeholders.\n * The actual diagram data is registered in PptxWriteContext for\n * separate compilation by the compiler.\n *\n * @module\n */\n\nimport { convertToEmu } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { stringifyNonVisualDrawingProperties } from \"@office-open/core/drawing\";\nimport {\n  COLOR_CATEGORIES,\n  LAYOUT_CATEGORIES,\n  STYLE_CATEGORIES,\n  createDataModel,\n  definitionId,\n  parseColorDefinition,\n  parseLayoutDefinition,\n  parseStyleDefinition,\n  type TreeNode,\n} from \"@office-open/core/smartart\";\nimport { attr, findChild, findFirst } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport type { SmartArtOptions } from \"../smartart\";\nimport {\n  readGraphicFrameLocking,\n  readNvPrPlaceholder,\n  stringifyCnvGraphicFramePr,\n  stringifyNvPr,\n} from \"./graphic-frame\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\n\n// ── Types ──\n\n// ── ID counter ──\n\nlet _nextSmartArtId = 1024;\n\n// ── SmartArt descriptor ──\n\nexport const smartArtDesc: CustomDescriptor<SmartArtOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const pptxCtx = ctx as PptxWriteContext;\n    const id = opts.id ?? _nextSmartArtId++;\n    const name = opts.name ?? `Diagram ${id}`;\n    pptxCtx.registerShapeId(name, id);\n    const saKey = opts.smartArtKey ?? pptxCtx.nextSmartArtKey();\n\n    // Custom definitions embed their own id in the doc point's type ids.\n    const layoutId =\n      typeof opts.layout === \"object\" ? definitionId(opts.layout) : (opts.layout ?? \"default\");\n    const styleId =\n      typeof opts.style === \"object\" ? definitionId(opts.style) : (opts.style ?? \"simple1\");\n    const colorId =\n      typeof opts.color === \"object\" ? definitionId(opts.color) : (opts.color ?? \"accent1_2\");\n\n    // Register SmartArt data with context — an explicitly empty node tree\n    // still round-trips (the data part keeps its bare doc point); only an\n    // absent tree skips registration.\n    if (opts.nodes !== undefined) {\n      const body = createDataModel(opts.nodes, layoutId, styleId, colorId);\n      const dataModelXml = body\n        ? '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>' + body\n        : \"\";\n      pptxCtx.addSmartArt(saKey, {\n        key: saKey,\n        dataModelXml,\n        layout: opts.layout ?? \"default\",\n        style: opts.style ?? \"simple1\",\n        color: opts.color ?? \"accent1_2\",\n      });\n    }\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    const w = convertToEmu(opts.width ?? \"100px\");\n    const h = convertToEmu(opts.height ?? \"100px\");\n\n    const parts: string[] = [];\n\n    // p:nvGraphicFramePr\n    parts.push(\n      `<p:nvGraphicFramePr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}` +\n        `${stringifyCnvGraphicFramePr(opts.locking)}` +\n        `${stringifyNvPr(opts)}</p:nvGraphicFramePr>`,\n    );\n\n    // p:xfrm\n    parts.push(`<p:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${w}\" cy=\"${h}\"/></p:xfrm>`);\n\n    // a:graphic > a:graphicData > dgm:relIds (placeholders)\n    parts.push(\n      `<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\">` +\n        `<dgm:relIds xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ` +\n        `r:dm=\"{smartart:${saKey}}\" r:lo=\"{smartart-lo:${saKey}}\" r:qs=\"{smartart-qs:${saKey}}\" r:cs=\"{smartart-cs:${saKey}}\"/>` +\n        `</a:graphicData></a:graphic>`,\n    );\n\n    return `<p:graphicFrame>${parts.join(\"\")}</p:graphicFrame>`;\n  },\n\n  parse(el, _ctx) {\n    const result: Partial<SmartArtOptions> = {};\n\n    // Position from p:xfrm\n    const xfrm = findChild(el, \"p:xfrm\");\n    if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n\n    // Name from p:nvGraphicFramePr → p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvGraphicFramePr\"));\n    const locking = readGraphicFrameLocking(findChild(el, \"p:nvGraphicFramePr\"), _ctx);\n    readNvPrPlaceholder(findChild(el, \"p:nvGraphicFramePr\") ?? el, result);\n    if (locking !== undefined) result.locking = locking;\n\n    // SmartArt data via dgm:relIds → r:dm, plus the layout/style/colors parts\n    const relIds = findFirst(el, \"dgm:relIds\");\n    if (relIds) {\n      const rId = attr(relIds, \"r:dm\");\n      if (rId) {\n        const dataPath = _ctx.resolveRelationship(rId);\n        if (dataPath) {\n          const dataEl = _ctx.getPart(dataPath);\n          if (dataEl) {\n            parseSmartArtDataXml(dataEl, result);\n          }\n        }\n      }\n\n      // Custom definitions come back structured; built-in stubs fold to their\n      // id string so round-tripping a built-in diagram keeps the compact form.\n      const layoutEl = readRelatedPart(_ctx, relIds, \"r:lo\");\n      if (layoutEl) {\n        const layout = parseLayoutDefinition(layoutEl);\n        const id = layout.uniqueId?.split(\"/\").pop();\n        result.layout = id && id in LAYOUT_CATEGORIES ? id : layout;\n      }\n      const styleEl = readRelatedPart(_ctx, relIds, \"r:qs\");\n      if (styleEl) {\n        const style = parseStyleDefinition(styleEl);\n        const id = style.uniqueId?.split(\"/\").pop();\n        result.style = id && id in STYLE_CATEGORIES ? id : style;\n      }\n      const colorEl = readRelatedPart(_ctx, relIds, \"r:cs\");\n      if (colorEl) {\n        const color = parseColorDefinition(colorEl);\n        const id = color.uniqueId?.split(\"/\").pop();\n        result.color = id && id in COLOR_CATEGORIES ? id : color;\n      }\n    }\n\n    return result as SmartArtOptions;\n  },\n};\n\n/** Resolve a dgm:relIds relationship attribute to its parsed part element. */\nfunction readRelatedPart(\n  ctx: {\n    resolveRelationship(rId: string): string | undefined;\n    getPart(path: string): Element | undefined;\n  },\n  relIds: Element,\n  attrName: \"r:lo\" | \"r:qs\" | \"r:cs\",\n): Element | undefined {\n  const rId = attr(relIds, attrName);\n  if (!rId) return undefined;\n  const path = ctx.resolveRelationship(rId);\n  return path ? ctx.getPart(path) : undefined;\n}\n\n/** Parse SmartArt data XML into options. */\nfunction parseSmartArtDataXml(dataEl: Element, result: Partial<SmartArtOptions>): void {\n  // The data part's root element IS dgm:dataModel (CT_DataModel: ptLst + cxnLst).\n  const model = dataEl.name === \"dgm:dataModel\" ? dataEl : findChild(dataEl, \"dgm:dataModel\");\n  if (!model) return;\n\n  const pts = findChild(model, \"dgm:ptLst\");\n  if (!pts) return;\n\n  // Build node text map and extract layout/style/color from doc point\n  const nodeMap = new Map<string, string>();\n  let docModelId: string | undefined;\n\n  for (const pt of pts.elements ?? []) {\n    if (pt.name !== \"dgm:pt\") continue;\n    const ptType = attr(pt, \"type\"); // XSD default: \"node\"\n    const modelId = attr(pt, \"modelId\");\n\n    // Document root — extract layout/style/color\n    if (ptType === \"doc\") {\n      docModelId = modelId;\n      const prSet = findChild(pt, \"dgm:prSet\");\n      if (prSet) {\n        const loTypeId = attr(prSet, \"loTypeId\") ?? \"\";\n        const qsTypeId = attr(prSet, \"qsTypeId\") ?? \"\";\n        const csTypeId = attr(prSet, \"csTypeId\") ?? \"\";\n        const layout = loTypeId.split(\"/\").pop();\n        if (layout) result.layout = layout;\n        const style = qsTypeId.split(\"/\").pop();\n        if (style) result.style = style;\n        const color = csTypeId.split(\"/\").pop();\n        if (color) result.color = color;\n      }\n      continue;\n    }\n\n    // Nodes — the XSD default type. pres/asst/parTrans/sibTrans points carry\n    // no user text.\n    if ((ptType === undefined || ptType === \"node\") && modelId) {\n      const t = findFirst(pt, \"a:t\");\n      const text = t ? extractText(t) : \"\";\n      nodeMap.set(modelId, text);\n    }\n  }\n\n  // Build tree from data connections (XSD default cxn type: \"parOf\";\n  // presOf/presParOf are presentation-tree edges that would pollute it)\n  const cxnLst = findChild(model, \"dgm:cxnLst\");\n  if (!cxnLst) {\n    result.nodes = [];\n    return;\n  }\n\n  const childrenMap = new Map<string, string[]>();\n  for (const cxn of cxnLst.elements ?? []) {\n    if (cxn.name !== \"dgm:cxn\") continue;\n    const cxnType = attr(cxn, \"type\");\n    if (cxnType !== undefined && cxnType !== \"parOf\") continue;\n    const srcId = attr(cxn, \"srcId\");\n    const destId = attr(cxn, \"destId\");\n    if (!srcId || !destId || !nodeMap.has(destId)) continue;\n\n    let arr = childrenMap.get(srcId);\n    if (!arr) {\n      arr = [];\n      childrenMap.set(srcId, arr);\n    }\n    arr.push(destId);\n  }\n\n  // The doc point is the tree root — referenced either by its own modelId\n  // (2007-era files) or by the reserved id \"0\".\n  const topIds = childrenMap.get(docModelId ?? \"\") ?? childrenMap.get(\"0\") ?? [];\n  result.nodes = topIds.map((id) => buildSmartArtNode(id, nodeMap, childrenMap));\n}\n\nfunction extractText(t: Element): string {\n  return (t.elements ?? [])\n    .filter((e) => e.type === \"text\")\n    .map((e) => String(e.text ?? \"\"))\n    .join(\"\");\n}\n\nfunction buildSmartArtNode(\n  id: string,\n  nodeMap: Map<string, string>,\n  childrenMap: Map<string, string[]>,\n): TreeNode {\n  const text = nodeMap.get(id) ?? \"\";\n  const childIds = childrenMap.get(id) ?? [];\n  if (childIds.length === 0) return { text };\n  return { text, children: childIds.map((cid) => buildSmartArtNode(cid, nodeMap, childrenMap)) };\n}\n","/**\n * Table (p:graphicFrame with a:tbl) descriptor for PPTX.\n *\n * @module\n */\n\nimport {\n  convertToEmu,\n  extUriMatches,\n  parseOnOff,\n  stripColorHashPrefix,\n  xsdTextAnchor,\n  xsdTextVerticalType,\n} from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { parse, stringify } from \"@office-open/core/descriptor\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport {\n  cell3DDesc,\n  createBodyProperties,\n  createTableStyle,\n  fillDesc,\n  findFillChild,\n  parseTableStyle,\n  outlineDesc,\n  stringifyLineProperties,\n  stringifyNonVisualDrawingProperties,\n} from \"@office-open/core/drawing\";\nimport {\n  attr,\n  attrBool,\n  attrMeasure,\n  attrNum,\n  children,\n  escapeXml,\n  findChild,\n  textOf,\n} from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { TableCellOptions, TextVerticalType, VerticalAnchor } from \"@shared/table/table-cell\";\nimport type { CellBorderOptions } from \"@shared/table/table-cell-properties\";\nimport type { TableOptions } from \"@shared/table/table-frame\";\nimport type { TableRowOptions } from \"@shared/table/table-row\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport {\n  readGraphicFrameLocking,\n  stringifyCnvGraphicFramePr,\n  readNvPrPlaceholder,\n  stringifyNvPr,\n} from \"./graphic-frame\";\nimport { readCnvPr, readPositionFromXfrm } from \"./shape\";\nimport { paragraphDesc, type ParagraphDescriptorOptions } from \"./text\";\n\n// ── Internal aliases ──\n\n// The public types carry the canonical shapes; these name the inline\n// border/margin maps the descriptor reads and writes cell-by-cell.\ntype CellBorders = NonNullable<TableCellOptions[\"borders\"]>;\ntype CellMargins = NonNullable<TableCellOptions[\"margins\"]>;\ntype TableLevelBorders = NonNullable<TableOptions[\"borders\"]>;\n\n// ── ID counter ──\n\nlet _nextTableId = 1024;\n\n// ── Office 2014 table stamps (a16:colId on a:gridCol, a16:rowId on a:tr) ──\n\nconst A16_NS = \"http://schemas.microsoft.com/office/drawing/2014/main\";\nconst COL_ID_EXT_URI = \"{9D8B030D-6E8A-4147-A177-3AD203B41FA5}\";\nconst ROW_ID_EXT_URI = \"{0D108BD9-81ED-4DB2-BD59-A6C34878D82A}\";\n\ntype OfficeIdTag = \"a16:colId\" | \"a16:rowId\";\n\nfunction officeIdExtLst(uri: string, tag: OfficeIdTag, val: string): string {\n  return `<a:extLst><a:ext uri=\"${uri}\"><${tag} xmlns:a16=\"${A16_NS}\" val=\"${escapeXml(val)}\"/></a:ext></a:extLst>`;\n}\n\nfunction readOfficeIdExt(el: Element, uri: string, tag: OfficeIdTag): string | undefined {\n  const extLst = findChild(el, \"a:extLst\");\n  if (!extLst) return undefined;\n  for (const ext of extLst.elements ?? []) {\n    if (ext.name !== \"a:ext\" || !extUriMatches(attr(ext, \"uri\"), uri)) continue;\n    const idEl = findChild(ext, tag);\n    const val = idEl ? attr(idEl, \"val\") : undefined;\n    if (val) return val;\n  }\n  return undefined;\n}\n\n// ── Table (p:graphicFrame) descriptor ──\n\nexport const tableDesc: CustomDescriptor<TableOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const pptxCtx = ctx as PptxWriteContext;\n    const id = opts.id ?? _nextTableId++;\n    const name = opts.name ?? `Table ${id}`;\n    pptxCtx.registerShapeId(name, id);\n\n    const x = convertToEmu(opts.x ?? 0);\n    const y = convertToEmu(opts.y ?? 0);\n    // Default 100px when width/height unspecified\n    const w = convertToEmu(opts.width ?? \"100px\");\n    const h = convertToEmu(opts.height ?? \"100px\");\n\n    const parts: string[] = [];\n\n    // p:nvGraphicFramePr\n    parts.push(\n      `<p:nvGraphicFramePr>${stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, opts, name)}` +\n        `${stringifyCnvGraphicFramePr(opts.locking)}` +\n        `${stringifyNvPr(opts)}</p:nvGraphicFramePr>`,\n    );\n\n    // p:xfrm\n    parts.push(`<p:xfrm><a:off x=\"${x}\" y=\"${y}\"/><a:ext cx=\"${w}\" cy=\"${h}\"/></p:xfrm>`);\n\n    // a:graphic > a:graphicData > a:tbl\n    const tblParts: string[] = [];\n\n    // a:tblPr\n    tblParts.push(stringifyTblPr(opts));\n\n    // a:tblGrid — gridCol widths are EMU; numbers stay (already EMU), strings convert.\n    // Without explicit columnWidths the table fills its graphicFrame, so the\n    // frame width is split evenly (a 0-width gridCol collapses the column).\n    const colCount = opts.rows[0]?.cells.length ?? 1;\n    const colWidths =\n      opts.columnWidths && opts.columnWidths.length > 0\n        ? opts.columnWidths.map(convertToEmu)\n        : Array.from({ length: colCount }, () => Math.round(w / colCount));\n    const gridCols = colWidths\n      .map((cw, ci) => {\n        const colId = opts.columnIds?.[ci];\n        return colId\n          ? `<a:gridCol w=\"${cw}\">${officeIdExtLst(COL_ID_EXT_URI, \"a16:colId\", colId)}</a:gridCol>`\n          : `<a:gridCol w=\"${cw}\"/>`;\n      })\n      .join(\"\");\n    tblParts.push(`<a:tblGrid>${gridCols}</a:tblGrid>`);\n\n    // a:tr[] — with border distribution\n    const rowCount = opts.rows.length;\n    for (const [ri, row] of opts.rows.entries()) {\n      const cells = distributeBorders(row, ri, rowCount, opts.borders);\n      tblParts.push(stringifyRow({ ...row, cells }, pptxCtx));\n    }\n\n    const tblXml = `<a:tbl>${tblParts.join(\"\")}</a:tbl>`;\n    parts.push(\n      `<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/table\">${tblXml}</a:graphicData></a:graphic>`,\n    );\n\n    return `<p:graphicFrame>${parts.join(\"\")}</p:graphicFrame>`;\n  },\n\n  parse(el, ctx) {\n    const result: Partial<TableOptions> = {};\n\n    // Position from p:xfrm\n    const xfrm = findChild(el, \"p:xfrm\");\n    if (xfrm) Object.assign(result, readPositionFromXfrm(xfrm));\n\n    // Name from p:nvGraphicFramePr → p:cNvPr\n    Object.assign(result, readCnvPr(el, \"p:nvGraphicFramePr\"));\n    const locking = readGraphicFrameLocking(findChild(el, \"p:nvGraphicFramePr\"), ctx);\n    readNvPrPlaceholder(findChild(el, \"p:nvGraphicFramePr\") ?? el, result);\n    if (locking !== undefined) result.locking = locking;\n\n    // Find a:tbl inside a:graphicData\n    const graphicData = findChild(el, \"a:graphic\");\n    const gd = graphicData ? findChild(graphicData, \"a:graphicData\") : undefined;\n    const tbl = gd ? findChild(gd, \"a:tbl\") : undefined;\n    if (!tbl) return result as TableOptions;\n\n    // a:tblPr\n    const tblPr = findChild(tbl, \"a:tblPr\");\n    if (tblPr) {\n      if (attrBool(tblPr, \"firstRow\")) result.firstRow = true;\n      if (attrBool(tblPr, \"lastRow\")) result.lastRow = true;\n      if (attrBool(tblPr, \"bandRow\")) result.bandRow = true;\n      if (attrBool(tblPr, \"firstCol\")) result.firstCol = true;\n      if (attrBool(tblPr, \"lastCol\")) result.lastCol = true;\n      if (attrBool(tblPr, \"bandCol\")) result.bandCol = true;\n\n      const tableStyleIdEl = findChild(tblPr, \"a:tableStyleId\");\n      if (tableStyleIdEl) {\n        const styleId = textOf(tableStyleIdEl);\n        if (styleId) result.tableStyleId = styleId;\n      } else {\n        const tableStyleEl = findChild(tblPr, \"a:tableStyle\");\n        if (tableStyleEl) {\n          const style = parseTableStyle(tableStyleEl);\n          if (style) result.tableStyle = style;\n        }\n      }\n\n      // Table-level borders\n      const borders: TableLevelBorders = {};\n      for (const [elName, key] of [\n        [\"a:lnL\", \"left\"],\n        [\"a:lnR\", \"right\"],\n        [\"a:lnT\", \"top\"],\n        [\"a:lnB\", \"bottom\"],\n      ] as const) {\n        const borderEl = findChild(tblPr, elName);\n        if (borderEl) {\n          const borderOpts: Partial<CellBorderOptions> = {};\n          const w = attrNum(borderEl, \"w\");\n          if (w !== undefined) borderOpts.width = w;\n          const fillResult = parseBorderColor(borderEl, ctx);\n          if (fillResult !== undefined) borderOpts.color = fillResult;\n          const prstDash = findChild(borderEl, \"a:prstDash\");\n          if (prstDash) {\n            const val = attr(prstDash, \"val\");\n            // Identity read — dashStyle shares PresetDash's token value set.\n            if (val) borderOpts.dashStyle = val as CellBorderOptions[\"dashStyle\"];\n          }\n          borderOpts.outline = parse(outlineDesc, borderEl, ctx);\n          borders[key] = borderOpts as CellBorderOptions;\n        }\n      }\n      if (Object.keys(borders).length > 0) result.borders = borders;\n    }\n\n    // a:tblGrid → columnWidths (+ per-column a16:colId stamps)\n    const tblGrid = findChild(tbl, \"a:tblGrid\");\n    if (tblGrid) {\n      const colWidths: number[] = [];\n      const columnIds: string[] = [];\n      for (const gridCol of children(tblGrid, \"a:gridCol\")) {\n        const w = attrNum(gridCol, \"w\");\n        colWidths.push(w ?? 0);\n        const colId = readOfficeIdExt(gridCol, COL_ID_EXT_URI, \"a16:colId\");\n        columnIds.push(colId ?? \"\");\n      }\n      if (colWidths.length > 0) result.columnWidths = colWidths;\n      if (columnIds.some((id) => id !== \"\")) result.columnIds = columnIds;\n    }\n\n    // a:tr → rows\n    const rows: TableRowOptions[] = [];\n    for (const tr of children(tbl, \"a:tr\")) {\n      const h = attrNum(tr, \"h\");\n      const cells: TableCellOptions[] = [];\n      for (const tc of children(tr, \"a:tc\")) {\n        cells.push(parseTableCell(tc, ctx));\n      }\n      const row: TableRowOptions = { cells };\n      if (h !== undefined) row.height = h;\n      const rowId = readOfficeIdExt(tr, ROW_ID_EXT_URI, \"a16:rowId\");\n      if (rowId) row.rowId = rowId;\n      rows.push(row);\n    }\n    result.rows = rows;\n\n    return result as TableOptions;\n  },\n};\n\n// ── Helpers ──\n\nfunction stringifyTblPr(opts: TableOptions): string {\n  const attrs: string[] = [];\n  if (opts.firstRow !== undefined) attrs.push(`firstRow=\"${opts.firstRow ? 1 : 0}\"`);\n  if (opts.lastRow !== undefined) attrs.push(`lastRow=\"${opts.lastRow ? 1 : 0}\"`);\n  if (opts.bandRow !== undefined) attrs.push(`bandRow=\"${opts.bandRow ? 1 : 0}\"`);\n  if (opts.firstCol !== undefined) attrs.push(`firstCol=\"${opts.firstCol ? 1 : 0}\"`);\n  if (opts.lastCol !== undefined) attrs.push(`lastCol=\"${opts.lastCol ? 1 : 0}\"`);\n  if (opts.bandCol !== undefined) attrs.push(`bandCol=\"${opts.bandCol ? 1 : 0}\"`);\n  const styleId = opts.tableStyleId\n    ? `<a:tableStyleId>${escapeXml(opts.tableStyleId)}</a:tableStyleId>`\n    : \"\";\n  // Inline CT_TableStyle — alternative to referencing a tableStyles part entry.\n  const style = opts.tableStyle ? createTableStyle(opts.tableStyle, \"a:tableStyle\") : \"\";\n  if (attrs.length === 0 && !styleId && !style) return \"<a:tblPr/>\";\n  return `<a:tblPr ${attrs.join(\" \")}>${styleId}${style}</a:tblPr>`;\n}\n\nfunction stringifyRow(row: TableRowOptions, ctx: PptxWriteContext): string {\n  const h = convertToEmu(row.height ?? 0);\n  const cellParts: string[] = [];\n  for (const cell of row.cells) {\n    cellParts.push(stringifyCell(cell, ctx));\n  }\n  // CT_TableRow tail — verbatim row stamp (a16:rowId's home).\n  const ext = row.rowId ? officeIdExtLst(ROW_ID_EXT_URI, \"a16:rowId\", row.rowId) : \"\";\n  return `<a:tr h=\"${h}\">${cellParts.join(\"\")}${ext}</a:tr>`;\n}\n\nfunction stringifyCell(cell: TableCellOptions, ctx: PptxWriteContext): string {\n  const parts: string[] = [];\n\n  // Attributes\n  const tcAttrs: string[] = [];\n  if (cell.columnSpan !== undefined && cell.columnSpan > 1)\n    tcAttrs.push(`gridSpan=\"${cell.columnSpan}\"`);\n  if (cell.rowSpan !== undefined && cell.rowSpan > 1) tcAttrs.push(`rowSpan=\"${cell.rowSpan}\"`);\n  if (cell.horizontalMerge) tcAttrs.push(`hMerge=\"${cell.horizontalMerge === \"restart\" ? 1 : 0}\"`);\n  if (cell.verticalMerge) tcAttrs.push(`vMerge=\"${cell.verticalMerge === \"restart\" ? 1 : 0}\"`);\n  const tcAttrStr = tcAttrs.length > 0 ? ` ${tcAttrs.join(\" \")}` : \"\";\n\n  // a:txBody\n  parts.push(stringifyTxBody(cell, ctx));\n\n  // a:tcPr\n  parts.push(stringifyTcPr(cell, ctx));\n\n  return `<a:tc${tcAttrStr}>${parts.join(\"\")}</a:tc>`;\n}\n\nfunction stringifyTxBody(cell: TableCellOptions, ctx: PptxWriteContext): string {\n  const txParts: string[] = [];\n\n  txParts.push(createBodyProperties({}));\n  txParts.push(\"<a:lstStyle/>\");\n\n  // Paragraphs — a:txBody requires at least one a:p, so an empty children\n  // array (or paragraphs that stringify to nothing) falls back to a bare one\n  const paragraphs: string[] = [];\n  if (cell.children) {\n    for (const c of cell.children) {\n      const pXml =\n        typeof c === \"string\"\n          ? paragraphDesc.stringify({ children: [{ text: c }] }, ctx)\n          : paragraphDesc.stringify(c, ctx);\n      if (pXml) paragraphs.push(pXml);\n    }\n  } else if (cell.text !== undefined) {\n    const pXml = paragraphDesc.stringify({ children: [{ text: cell.text }] }, ctx);\n    if (pXml) paragraphs.push(pXml);\n  }\n  txParts.push(paragraphs.length > 0 ? paragraphs.join(\"\") : \"<a:p/>\");\n\n  return `<a:txBody>${txParts.join(\"\")}</a:txBody>`;\n}\n\nfunction stringifyTcPr(cell: TableCellOptions, ctx: PptxWriteContext): string {\n  const attrs: string[] = [];\n  const children: string[] = [];\n\n  if (cell.verticalAlign) attrs.push(`anchor=\"${xsdTextAnchor.to(cell.verticalAlign)}\"`);\n  if (cell.vertical) attrs.push(`vert=\"${xsdTextVerticalType.to(cell.vertical)}\"`);\n  if (cell.margins?.left !== undefined) attrs.push(`marL=\"${convertToEmu(cell.margins.left)}\"`);\n  if (cell.margins?.right !== undefined) attrs.push(`marR=\"${convertToEmu(cell.margins.right)}\"`);\n  if (cell.margins?.top !== undefined) attrs.push(`marT=\"${convertToEmu(cell.margins.top)}\"`);\n  if (cell.margins?.bottom !== undefined) attrs.push(`marB=\"${convertToEmu(cell.margins.bottom)}\"`);\n\n  if (cell.borders) {\n    if (cell.borders.left) children.push(buildBorderLine(\"a:lnL\", cell.borders.left, ctx));\n    if (cell.borders.right) children.push(buildBorderLine(\"a:lnR\", cell.borders.right, ctx));\n    if (cell.borders.top) children.push(buildBorderLine(\"a:lnT\", cell.borders.top, ctx));\n    if (cell.borders.bottom) children.push(buildBorderLine(\"a:lnB\", cell.borders.bottom, ctx));\n    if (cell.borders.diagonalTopLeftToBottomRight)\n      children.push(buildBorderLine(\"a:lnTlToBr\", cell.borders.diagonalTopLeftToBottomRight, ctx));\n    if (cell.borders.diagonalBottomLeftToTopRight)\n      children.push(buildBorderLine(\"a:lnBlToTr\", cell.borders.diagonalBottomLeftToTopRight, ctx));\n  }\n\n  if (cell.cell3D) {\n    const cell3DXml = stringify(cell3DDesc, cell.cell3D, ctx);\n    if (cell3DXml) children.push(cell3DXml);\n  }\n\n  if (cell.fill !== undefined) {\n    const fillXml = stringify(fillDesc, cell.fill, ctx);\n    if (fillXml) children.push(fillXml);\n  }\n\n  // A source cell may carry no a:tcPr at all (pandoc-style minimal output) —\n  // only the round-trip marker re-emits the bare element.\n  if (attrs.length === 0 && children.length === 0) return cell.cellProperties ? \"<a:tcPr/>\" : \"\";\n\n  const attrStr = attrs.length > 0 ? ` ${attrs.join(\" \")}` : \"\";\n  if (children.length === 0) return `<a:tcPr${attrStr}/>`;\n  return `<a:tcPr${attrStr}>${children.join(\"\")}</a:tcPr>`;\n}\n\nfunction buildBorderLine(name: string, options: CellBorderOptions, ctx: PptxWriteContext): string {\n  // Full line properties win when present (parsed sources keep every child).\n  if (options.outline) {\n    return stringifyLineProperties(name, options.outline, ctx) ?? `<${name}/>`;\n  }\n  const attrs: string[] = [];\n  if (options.width !== undefined) attrs.push(`w=\"${convertToEmu(options.width)}\"`);\n\n  const children: string[] = [];\n  if (options.color !== undefined) {\n    const fillXml =\n      typeof options.color === \"string\"\n        ? `<a:solidFill><a:srgbClr val=\"${stripColorHashPrefix(options.color)}\"/></a:solidFill>`\n        : stringify(fillDesc, options.color, ctx);\n    if (fillXml) children.push(fillXml);\n  }\n  if (options.dashStyle) {\n    children.push(`<a:prstDash val=\"${options.dashStyle}\"/>`);\n  }\n\n  const attrStr = attrs.length > 0 ? ` ${attrs.join(\" \")}` : \"\";\n  if (children.length === 0) return `<${name}${attrStr}/>`;\n  return `<${name}${attrStr}>${children.join(\"\")}</${name}>`;\n}\n\n/** Distribute table-level borders to edge cells. */\nfunction distributeBorders(\n  row: TableRowOptions,\n  ri: number,\n  rowCount: number,\n  tb: TableOptions[\"borders\"],\n): TableCellOptions[] {\n  if (!tb) return row.cells;\n  const colCount = row.cells.length;\n  return row.cells.map((cell, ci) => {\n    const needTop = ri === 0 && !!tb.top && !cell.borders?.top;\n    const needBottom = ri === rowCount - 1 && !!tb.bottom && !cell.borders?.bottom;\n    const needLeft = ci === 0 && !!tb.left && !cell.borders?.left;\n    const needRight = ci === colCount - 1 && !!tb.right && !cell.borders?.right;\n    if (!needTop && !needBottom && !needLeft && !needRight) return cell;\n    const borders = {\n      ...cell.borders,\n      ...(needTop && { top: tb.top }),\n      ...(needBottom && { bottom: tb.bottom }),\n      ...(needLeft && { left: tb.left }),\n      ...(needRight && { right: tb.right }),\n    };\n    return { ...cell, borders };\n  });\n}\n\n/** Parse a table cell (a:tc) into options. */\nfunction parseTableCell(tc: Element, readCtx?: ReadContext): TableCellOptions {\n  const result: TableCellOptions = {};\n  const ctx = readCtx ?? ({} as ReadContext);\n\n  const gridSpan = attrNum(tc, \"gridSpan\");\n  if (gridSpan !== undefined && gridSpan > 1) result.columnSpan = gridSpan;\n  const rowSpan = attrNum(tc, \"rowSpan\");\n  if (rowSpan !== undefined && rowSpan > 1) result.rowSpan = rowSpan;\n  const hMerge = parseOnOff(attr(tc, \"hMerge\"));\n  if (hMerge === true) result.horizontalMerge = \"restart\";\n  else if (hMerge === false) result.horizontalMerge = \"continue\";\n  const vMerge = parseOnOff(attr(tc, \"vMerge\"));\n  if (vMerge === true) result.verticalMerge = \"restart\";\n  else if (vMerge === false) result.verticalMerge = \"continue\";\n\n  // a:txBody → paragraph children\n  const txBody = findChild(tc, \"a:txBody\");\n  if (txBody) {\n    const paragraphs: ParagraphDescriptorOptions[] = [];\n    for (const pEl of txBody.elements ?? []) {\n      if (pEl.name !== \"a:p\") continue;\n      const para = paragraphDesc.parse(pEl, ctx);\n      paragraphs.push(para);\n    }\n\n    if (paragraphs.length === 1) {\n      const [p] = paragraphs;\n      if (p) {\n        if (p.text && !p.children) {\n          result.text = p.text;\n        } else {\n          result.children = [p];\n        }\n      }\n    } else if (paragraphs.length > 0) {\n      result.children = paragraphs;\n    }\n\n    // Extract margins from a:bodyPr\n    const bodyPr = findChild(txBody, \"a:bodyPr\");\n    if (bodyPr) {\n      const margins: CellMargins = {};\n      const tIns = attrMeasure(bodyPr, \"tIns\");\n      if (tIns !== undefined) margins.top = tIns as number | UniversalMeasure;\n      const bIns = attrMeasure(bodyPr, \"bIns\");\n      if (bIns !== undefined) margins.bottom = bIns as number | UniversalMeasure;\n      const lIns = attrMeasure(bodyPr, \"lIns\");\n      if (lIns !== undefined) margins.left = lIns as number | UniversalMeasure;\n      const rIns = attrMeasure(bodyPr, \"rIns\");\n      if (rIns !== undefined) margins.right = rIns as number | UniversalMeasure;\n      if (Object.keys(margins).length > 0) result.margins = margins;\n    }\n  }\n\n  // a:tcPr\n  const tcPr = findChild(tc, \"a:tcPr\");\n  if (tcPr) {\n    const keysBefore = Object.keys(result).length;\n    const anchor = attr(tcPr, \"anchor\");\n    if (anchor) result.verticalAlign = xsdTextAnchor.from(anchor) as VerticalAnchor;\n    const vert = attr(tcPr, \"vert\");\n    if (vert) result.vertical = xsdTextVerticalType.from(vert) as TextVerticalType;\n\n    // Margins from tcPr attributes\n    const margins: CellMargins = {};\n    const marL = attrMeasure(tcPr, \"marL\");\n    if (marL !== undefined) margins.left = marL as number | UniversalMeasure;\n    const marR = attrMeasure(tcPr, \"marR\");\n    if (marR !== undefined) margins.right = marR as number | UniversalMeasure;\n    const marT = attrMeasure(tcPr, \"marT\");\n    if (marT !== undefined) margins.top = marT as number | UniversalMeasure;\n    const marB = attrMeasure(tcPr, \"marB\");\n    if (marB !== undefined) margins.bottom = marB as number | UniversalMeasure;\n    if (Object.keys(margins).length > 0) result.margins = margins;\n\n    // Fill — guard against fillDesc returning { type: \"none\" } for a tcPr with\n    // no fill child, which would spuriously emit <a:noFill/> on re-stringify.\n    const fillChild = findFillChild(tcPr);\n    if (fillChild) result.fill = parse(fillDesc, fillChild, ctx);\n\n    const cell3DEl = findChild(tcPr, \"a:cell3D\");\n    if (cell3DEl) result.cell3D = parse(cell3DDesc, cell3DEl, ctx);\n\n    // Cell borders\n    const borders: CellBorders = {};\n    for (const [elName, key] of [\n      [\"a:lnL\", \"left\"],\n      [\"a:lnR\", \"right\"],\n      [\"a:lnT\", \"top\"],\n      [\"a:lnB\", \"bottom\"],\n      [\"a:lnTlToBr\", \"diagonalTopLeftToBottomRight\"],\n      [\"a:lnBlToTr\", \"diagonalBottomLeftToTopRight\"],\n    ] as const) {\n      const borderEl = findChild(tcPr, elName);\n      if (borderEl) {\n        const borderOpts: Partial<CellBorderOptions> = {};\n        const w = attrNum(borderEl, \"w\");\n        if (w !== undefined) borderOpts.width = w;\n        const fillResult = parseBorderColor(borderEl, ctx);\n        if (fillResult !== undefined) borderOpts.color = fillResult;\n        // Dash style\n        const prstDash = findChild(borderEl, \"a:prstDash\");\n        if (prstDash) {\n          const val = attr(prstDash, \"val\");\n          // Identity read — dashStyle shares PresetDash's token value set.\n          if (val) borderOpts.dashStyle = val as CellBorderOptions[\"dashStyle\"];\n        }\n        // Full line properties — keeps joins/line ends and bare <a:lnX><a:noFill/></a:lnX>.\n        borderOpts.outline = parse(outlineDesc, borderEl, ctx);\n        borders[key] = borderOpts as CellBorderOptions;\n      }\n    }\n    if (Object.keys(borders).length > 0) result.borders = borders;\n\n    // A bare <a:tcPr/> yields no fields — mark the presence so stringify\n    // re-emits the empty element.\n    if (Object.keys(result).length === keysBefore) result.cellProperties = true;\n  }\n\n  return result;\n}\n\n/**\n * Read a border line color from its a:lnL/a:lnR/… element. An srgb solid fill\n * stays the hex-string sugar; any other fill (scheme color, gradient) comes\n * back as the structured FillOptions so it round-trips.\n */\nfunction parseBorderColor(el: Element, ctx: ReadContext): CellBorderOptions[\"color\"] {\n  const solidFill = findChild(el, \"a:solidFill\");\n  if (!solidFill) return undefined;\n  const srgbClr = findChild(solidFill, \"a:srgbClr\");\n  if (srgbClr?.attributes?.[\"val\"] !== undefined) return String(srgbClr.attributes[\"val\"]);\n  const fill = parse(fillDesc, el, ctx);\n  return fill ?? undefined;\n}\n","/**\n * Bridge functions for serializing legacy SlideChild objects to XML.\n *\n * Shared between compiler.ts and descriptor modules (e.g. group.ts)\n * to avoid circular dependencies.\n *\n * @module\n */\n\nimport { extUriMatches } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { attr, findChild, findFirst, stringifyElement } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport type { SlideChild as LegacySlideChild } from \"@parts/slide/slide-child\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { chartDesc } from \"./chart\";\nimport { groupShapeDesc } from \"./group\";\nimport { connectorShapeDesc, lineShapeDesc } from \"./line\";\nimport { lockedCanvasDesc } from \"./locked-canvas\";\nimport { MEDIA_EXT_URI, audioDesc, videoDesc } from \"./media\";\nimport { oleDesc } from \"./ole\";\nimport { shapeDesc, pictureDesc } from \"./shape\";\nimport { smartArtDesc } from \"./smartart\";\nimport { tableDesc } from \"./table\";\n\n// ── Helpers ──\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Serialize a SlideChild to XML using descriptors.\n */\nexport function stringifyChild(child: LegacySlideChild, ctx: PptxWriteContext): string | undefined {\n  // JSON object — descriptor dispatch\n  if (\"shape\" in child && child.shape) {\n    return shapeDesc.stringify(child.shape, ctx);\n  }\n  if (\"picture\" in child && child.picture) {\n    return pictureDesc.stringify(child.picture, ctx);\n  }\n  if (\"table\" in child && child.table) {\n    return tableDesc.stringify(child.table, ctx);\n  }\n  if (\"line\" in child && child.line) {\n    return lineShapeDesc.stringify(child.line, ctx);\n  }\n  if (\"connector\" in child && child.connector) {\n    return connectorShapeDesc.stringify(child.connector, ctx);\n  }\n  if (\"group\" in child && child.group) {\n    return groupShapeDesc.stringify(child.group, ctx);\n  }\n  if (\"chart\" in child && child.chart) {\n    return chartDesc.stringify(child.chart, ctx);\n  }\n  if (\"smartart\" in child && child.smartart) {\n    return smartArtDesc.stringify(child.smartart, ctx);\n  }\n  if (\"video\" in child && child.video) {\n    return videoDesc.stringify(child.video, ctx);\n  }\n  if (\"audio\" in child && child.audio) {\n    return audioDesc.stringify(child.audio, ctx);\n  }\n  if (\"ole\" in child && child.ole) {\n    return oleDesc.stringify(child.ole, ctx);\n  }\n  if (\"lockedCanvas\" in child && child.lockedCanvas) {\n    return lockedCanvasDesc.stringify(child.lockedCanvas, ctx);\n  }\n  if (\"contentPart\" in child && child.contentPart) {\n    // r:id must name an external relationship the caller owns — without one\n    // there is nothing to reference, so the element is skipped\n    if (!child.contentPart.rId) return \"\";\n    return `<p:contentPart r:id=\"${child.contentPart.rId}\"/>`;\n  }\n  if (\"rawXml\" in child && child.rawXml) {\n    return child.rawXml;\n  }\n\n  return undefined;\n}\n\n// ── Parse path ──\n\n/**\n * Parse an XML child element into a SlideChild object using descriptors.\n *\n * Symmetric to {@link stringifyChild} — dispatches based on element tag name\n * to the appropriate descriptor's `parse()` method.\n */\nexport function parseChild(el: XmlElement, ctx: ReadContext): LegacySlideChild | undefined {\n  switch (el.name) {\n    case \"p:sp\": {\n      // Check if line shape (prstGeom prst=\"line\")\n      const spPr = findChild(el, \"p:spPr\");\n      const prstGeom = spPr ? findChild(spPr, \"a:prstGeom\") : undefined;\n      const prst = prstGeom ? attr(prstGeom, \"prst\") : undefined;\n      if (prst === \"line\") {\n        return { line: lineShapeDesc.parse(el, ctx) } as LegacySlideChild;\n      }\n      return { shape: shapeDesc.parse(el, ctx) } as LegacySlideChild;\n    }\n    case \"p:pic\": {\n      const mediaType = detectMediaType(el);\n      if (mediaType === \"video\") {\n        return { video: videoDesc.parse(el, ctx) } as LegacySlideChild;\n      }\n      if (mediaType === \"audio\") {\n        return { audio: audioDesc.parse(el, ctx) } as LegacySlideChild;\n      }\n      return { picture: pictureDesc.parse(el, ctx) } as LegacySlideChild;\n    }\n    case \"p:graphicFrame\":\n      return parseGraphicFrameChild(el, ctx);\n    case \"p:cxnSp\":\n      return { connector: connectorShapeDesc.parse(el, ctx) } as LegacySlideChild;\n    case \"p:grpSp\":\n      return { group: groupShapeDesc.parse(el, ctx) } as LegacySlideChild;\n    default:\n      // Unrecognized element — keep verbatim so round-trip never drops content\n      // (mc:AlternateContent, vendor extensions, future schema versions).\n      return { rawXml: stringifyElement(el) } as LegacySlideChild;\n  }\n}\n\n/** Detect whether a p:pic element is a video or audio frame. */\nfunction detectMediaType(el: XmlElement): \"video\" | \"audio\" | undefined {\n  const nvPicPr = findChild(el, \"p:nvPicPr\");\n  if (!nvPicPr) return undefined;\n\n  const nvPr = findChild(nvPicPr, \"p:nvPr\");\n  if (!nvPr) return undefined;\n\n  // EG_Media elements come first — plain a:videoFile/a:audioFile/etc. without\n  // the p14:media extension (pre-2010 files) still identify the frame kind.\n  for (const name of [\"a:audioCd\", \"a:wavAudioFile\", \"a:audioFile\"]) {\n    if (findChild(nvPr, name)) return \"audio\";\n  }\n  for (const name of [\"a:videoFile\", \"a:quickTimeFile\"]) {\n    if (findChild(nvPr, name)) return \"video\";\n  }\n\n  // Fallback: the p14:media extension. Audio and video frames share the same\n  // extension uri, so the frame kind is undecidable here — files without an\n  // EG_Media element are near-nonexistent (Office always emits one), and those\n  // rare ext-only frames are treated as video.\n  const extLst = findChild(nvPr, \"p:extLst\");\n  if (!extLst) return undefined;\n\n  for (const ext of extLst.elements ?? []) {\n    if (ext.name !== \"p:ext\") continue;\n    const uri = attr(ext, \"uri\");\n    if (extUriMatches(uri, MEDIA_EXT_URI)) return \"video\";\n  }\n\n  return undefined;\n}\n\n/** Dispatch p:graphicFrame to chart/smartart/table descriptor. */\nfunction parseGraphicFrameChild(el: XmlElement, ctx: ReadContext): LegacySlideChild | undefined {\n  const graphicData = findFirst(el, \"a:graphicData\");\n  if (!graphicData) return undefined;\n\n  const uri = attr(graphicData, \"uri\") ?? \"\";\n\n  if (uri.includes(\"/chart\")) {\n    return { chart: chartDesc.parse(el, ctx) } as LegacySlideChild;\n  }\n  if (uri.includes(\"/diagram\")) {\n    return { smartart: smartArtDesc.parse(el, ctx) } as LegacySlideChild;\n  }\n\n  const tbl = findChild(graphicData, \"a:tbl\");\n  if (tbl) {\n    return { table: tableDesc.parse(el, ctx) } as LegacySlideChild;\n  }\n\n  // Unknown graphicData URI (OLE objects, ink, future content) — keep verbatim.\n  return { rawXml: stringifyElement(el) } as LegacySlideChild;\n}\n","/**\n * Color mapping override (p:clrMapOvr) descriptor for PPTX.\n *\n * CT_ColorMappingOverride appears on child slides. It either inherits the\n * master mapping or contains a complete a:overrideClrMapping.\n *\n * @module\n */\nimport { parseColorMapping, stringifyColorMapping } from \"@office-open/core\";\nimport type { ColorMappingOptions } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild } from \"@office-open/xml\";\n\nexport type ColorMappingOverrideOptions =\n  | { kind: \"master\" }\n  | { kind: \"override\"; colorMapping: Partial<ColorMappingOptions> };\n\nexport const colorMappingOverrideDesc: CustomDescriptor<ColorMappingOverrideOptions | undefined> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    // undefined omits the element — CT_Slide makes it optional and writers\n    // that omit it (pandoc) must round-trip without one.\n    if (opts === undefined) return \"\";\n    if (opts.kind === \"override\") {\n      return `<p:clrMapOvr>${stringifyColorMapping(opts.colorMapping, \"a:overrideClrMapping\")}</p:clrMapOvr>`;\n    }\n    return \"<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>\";\n  },\n\n  parse(el, _ctx) {\n    if (findChild(el, \"a:masterClrMapping\")) return { kind: \"master\" };\n    const colorMapping = parseColorMapping(findChild(el, \"a:overrideClrMapping\"));\n    return colorMapping ? { kind: \"override\", colorMapping } : undefined;\n  },\n};\n","import type { DataType } from \"@office-open/core\";\nimport { xsdOrient } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport type { WriteContext } from \"@office-open/core/descriptor\";\n\nconst ORIENT_TYPES = new Set([\"blinds\", \"checker\", \"comb\", \"randomBar\"]);\n\nconst SIDE_DIR_TYPES = new Set([\"push\", \"wipe\"]);\n\nconst EIGHT_DIR_TYPES = new Set([\"cover\", \"pull\"]);\n\n/** Slide-change effect (ST_Transition): \"newsflash\" spinning blur, \"plus\" plus-shaped reveal, \"wedge\" wedge-shaped wipe, \"comb\" comb-tooth reveal, \"randomBar\" random bars. */\nexport type TransitionType =\n  | \"fade\"\n  | \"push\"\n  | \"wipe\"\n  | \"split\"\n  | \"blinds\"\n  | \"checker\"\n  | \"comb\"\n  | \"randomBar\"\n  | \"cover\"\n  | \"pull\"\n  | \"strips\"\n  | \"wheel\"\n  | \"zoom\"\n  | \"circle\"\n  | \"dissolve\"\n  | \"diamond\"\n  | \"newsflash\"\n  | \"plus\"\n  | \"wedge\"\n  | \"random\"\n  | \"cut\";\n\n/** Slide-transition motion direction; diagonal corners like \"leftUp\" apply to cover/pull, \"in\"/\"out\" to circle/plus/wedge/diamond. */\nexport type TransitionDirection =\n  | \"left\"\n  | \"up\"\n  | \"right\"\n  | \"down\"\n  | \"leftUp\"\n  | \"rightUp\"\n  | \"leftDown\"\n  | \"rightDown\"\n  | \"out\"\n  | \"in\";\n\nexport const DIRECTION_MAP: Record<TransitionDirection, string> = {\n  left: \"l\",\n  up: \"u\",\n  right: \"r\",\n  down: \"d\",\n  leftUp: \"lu\",\n  rightUp: \"ru\",\n  leftDown: \"ld\",\n  rightDown: \"rd\",\n  out: \"out\",\n  in: \"in\",\n};\n\nexport interface TransitionOptions {\n  /** Slide-change effect; see TransitionType. */\n  type?: TransitionType;\n  /** Transition playback speed. */\n  speed?: \"slow\" | \"medium\" | \"fast\";\n  advanceOnClick?: boolean;\n  advanceAfterTime?: number;\n  /** Motion direction; see TransitionDirection. */\n  direction?: TransitionDirection;\n  /** Split/wipe orientation. */\n  orient?: \"horizontal\" | \"vertical\";\n  thruBlk?: boolean;\n  spokes?: number;\n  startSound?: {\n    /** Audio content: base64 string, data URL, or raw bytes. */\n    data: DataType;\n    /** Audio container format — becomes the media part extension. */\n    type: \"mp3\" | \"wav\" | \"wma\" | \"aac\";\n    name?: string;\n    loop?: boolean;\n  };\n  stopPreviousSound?: boolean;\n}\n\nfunction buildTransitionElement(\n  type: TransitionType,\n  direction?: TransitionDirection,\n  orient?: string,\n  thruBlk?: boolean,\n  spokes?: number,\n): string {\n  const dir = direction ? DIRECTION_MAP[direction] : undefined;\n  const attrs: string[] = [];\n\n  if (\n    dir &&\n    (ORIENT_TYPES.has(type) ||\n      ((SIDE_DIR_TYPES.has(type) || EIGHT_DIR_TYPES.has(type)) && dir !== \"l\") ||\n      (type === \"strips\" && dir !== \"lu\"))\n  ) {\n    attrs.push(`dir=\"${dir}\"`);\n  } else if ((type === \"fade\" || type === \"cut\") && thruBlk !== undefined) {\n    attrs.push(`thruBlk=\"${thruBlk ? 1 : 0}\"`);\n  } else if (type === \"split\") {\n    if (orient && orient !== \"horizontal\") attrs.push(`orient=\"${xsdOrient.to(orient)}\"`);\n    if (dir && dir !== \"out\") attrs.push(`dir=\"${dir}\"`);\n  } else if (type === \"wheel\") {\n    if (spokes !== undefined && spokes !== 4) attrs.push(`spokes=\"${spokes}\"`);\n  } else if (type === \"zoom\" && dir && dir !== \"in\") {\n    attrs.push(`dir=\"${dir}\"`);\n  }\n\n  return attrs.length > 0 ? `<p:${type} ${attrs.join(\" \")}/>` : `<p:${type}/>`;\n}\n\nexport function buildTransition(options: TransitionOptions, ctx?: WriteContext): string {\n  const attrParts: string[] = [];\n  if (options.speed)\n    // OOXML ST_TransitionSpeed uses \"med\"; the friendly API token is \"medium\".\n    attrParts.push(`spd=\"${options.speed === \"medium\" ? \"med\" : options.speed}\"`);\n  if (options.advanceOnClick !== undefined)\n    attrParts.push(`advClick=\"${options.advanceOnClick ? 1 : 0}\"`);\n  if (options.advanceAfterTime !== undefined) attrParts.push(`advTm=\"${options.advanceAfterTime}\"`);\n\n  const children: string[] = [];\n  if (options.type) {\n    children.push(\n      buildTransitionElement(\n        options.type,\n        options.direction,\n        options.orient,\n        options.thruBlk,\n        options.spokes,\n      ),\n    );\n  }\n\n  // Sound action (sndAc: stSnd | endSnd). The sound bytes are registered as\n  // media through the write context; the {audio:…} placeholder is rewritten to\n  // a real relationship id (and the audio relationship added) by the compiler.\n  if (options.startSound && ctx) {\n    const ref = ctx.addMedia(toUint8Array(options.startSound.data), options.startSound.type);\n    const audioRef = `{audio:${ref.slice(1, -1)}}`;\n    const sndAttrs: string[] = [`r:embed=\"${audioRef}\"`];\n    if (options.startSound.name) sndAttrs.push(` name=\"${options.startSound.name}\"`);\n    const stSndAttrs: string[] = [];\n    if (options.startSound.loop) stSndAttrs.push(' loop=\"1\"');\n    children.push(\n      `<p:sndAc><p:stSnd${stSndAttrs.join(\"\")}>` +\n        `<p:snd ${sndAttrs.join(\" \")}/>` +\n        `</p:stSnd></p:sndAc>`,\n    );\n  } else if (options.stopPreviousSound) {\n    children.push(\"<p:sndAc><p:endSnd/></p:sndAc>\");\n  }\n\n  if (attrParts.length === 0 && children.length === 0) {\n    return \"<p:transition/>\";\n  }\n\n  const attrStr = attrParts.length > 0 ? ` ${attrParts.join(\" \")}` : \"\";\n  if (children.length === 0) {\n    return `<p:transition${attrStr}/>`;\n  }\n  return `<p:transition${attrStr}>${children.join(\"\")}</p:transition>`;\n}\n","/**\n * Slide header/footer: options plus the slide-level placeholder shapes that\n * realize them. CT_Slide has no p:hf child — PowerPoint controls per-slide\n * date/footer/slide-number visibility by instantiating dt/ftr/sldNum\n * placeholder shapes (inheriting position from layout/master) on the slide.\n *\n * @module\n */\n\nimport type { ShapeOptions } from \"@shared/shape/shape\";\n\nexport interface SlideHeaderFooterOptions {\n  slideNumber?: boolean;\n  dateTime?: boolean;\n  footer?: string | boolean;\n  header?: boolean;\n}\n\n// PowerPoint's canonical dt/ftr/sldNum idx triple (observed across its output).\nconst DT_IDX = 10;\nconst FTR_IDX = 11;\nconst SLD_NUM_IDX = 12;\n\n/**\n * Build the dt/ftr/sldNum placeholder shapes a headerFooter option enables.\n * The shapes carry no xfrm (position is inherited from layout/master); the\n * date and slide-number bodies are a:fld so PowerPoint recomputes them.\n */\nexport function buildHeaderFooterShapes(opts: SlideHeaderFooterOptions): ShapeOptions[] {\n  const shapes: ShapeOptions[] = [];\n\n  if (opts.dateTime) {\n    shapes.push({\n      placeholder: \"date\",\n      placeholderIndex: DT_IDX,\n      placeholderSize: \"half\",\n      textBody: { paragraphs: [{ children: [{ type: \"datetimeFigureOut\", text: \"1/1/1\" }] }] },\n    });\n  }\n\n  if (opts.footer) {\n    shapes.push({\n      placeholder: \"footer\",\n      placeholderIndex: FTR_IDX,\n      placeholderSize: \"quarter\",\n      // A false/absent footer stays inherited-hidden; a true footer with no\n      // text is still emitted as an empty body so the layout footer shows.\n      textBody: typeof opts.footer === \"string\" ? { text: opts.footer } : {},\n    });\n  }\n\n  if (opts.slideNumber) {\n    shapes.push({\n      placeholder: \"slideNumber\",\n      placeholderIndex: SLD_NUM_IDX,\n      placeholderSize: \"quarter\",\n      textBody: { paragraphs: [{ children: [{ type: \"slidenum\", text: \"1\" }] }] },\n    });\n  }\n\n  return shapes;\n}\n","/**\n * PPTX write context — collects resources during descriptor-driven serialization.\n *\n * @module\n */\n\nimport { EmbeddingCollection, Media } from \"@office-open/core\";\nimport type { BaseMediaEntry, EmbeddingData } from \"@office-open/core\";\nimport type { HyperlinkTarget, ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport type {\n  ColorDefinitionOptions,\n  LayoutDefinitionOptions,\n  StyleDefinitionOptions,\n} from \"@office-open/core/smartart\";\n\nimport type { PptxDocument } from \"./parse\";\n\n// ── Parse context (moved from parse/context.ts) ──\n\n/**\n * Parse context for PPTX documents.\n */\nexport class ParseContext {\n  constructor(\n    public pptx: PptxDocument,\n    /** Slide relationship ID → path, parsed from slide's _rels file */\n    public slideRels: Map<string, string>,\n  ) {}\n}\n\n// ── Resource entries ──\n\nexport interface MediaEntry extends BaseMediaEntry {\n  key: string;\n}\n\nexport interface ChartEntry {\n  key: string;\n  chartSpaceXml: string;\n  /** User-shapes part behind c:userShapes (body + the chart's own rels id). */\n  userShapes?: {\n    relationshipId: string;\n    xml: string;\n  };\n}\n\nexport interface SmartArtEntry {\n  key: string;\n  dataModelXml: string;\n  /** Built-in layout id or a full custom layout definition. */\n  layout: string | LayoutDefinitionOptions;\n  /** Built-in quick-style id or a full custom style definition. */\n  style: string | StyleDefinitionOptions;\n  /** Built-in color-transform id or a full custom color definition. */\n  color: string | ColorDefinitionOptions;\n}\n\nexport interface HyperlinkEntry {\n  key: string;\n  url?: string;\n  slide?: number;\n  tooltip?: string;\n}\n\n/** An externally linked image source (a:blip @r:link, TargetMode=\"External\"). */\nexport interface ImageLinkEntry {\n  key: string;\n  url: string;\n}\n\n/** An externally linked OLE object source (p:oleObj @r:id, TargetMode=\"External\"). */\nexport interface OleLinkEntry {\n  key: string;\n  url: string;\n}\n\n// ── Context ──\n\n/**\n * PPTX-specific write context.\n *\n * Extends the core {@link WriteContext} with media, chart, SmartArt,\n * and hyperlink registration methods. Custom descriptors cast the\n * generic `WriteContext` to this type to access PPTX-specific features.\n */\nexport class PptxWriteContext implements WriteContext {\n  private _media = new Media<MediaEntry>();\n  private _embeddings = new EmbeddingCollection();\n  private _charts = new Map<string, ChartEntry>();\n  private _smartArts = new Map<string, SmartArtEntry>();\n  private _hyperlinks = new Map<string, HyperlinkEntry>();\n  private _imageLinks = new Map<string, ImageLinkEntry>();\n  /** url → key side index so registration dedup is O(1), not a scan. */\n  private _imageLinkKeys = new Map<string, string>();\n  private _nextImageLinkId = 1;\n  private _oleLinks = new Map<string, OleLinkEntry>();\n  /** url → key side index for O(1) registration dedup. */\n  private _oleLinkKeys = new Map<string, string>();\n  private _nextOleLinkId = 1;\n  private _nextRelId = 1;\n  /** cNvPr name → id for the part being serialized (cleared per slide/layout/master). */\n  private _shapeIds = new Map<string, number>();\n  private _ambiguousShapeNames = new Set<string>();\n  private _nextChartId = 1;\n  private _nextSmartArtId = 1;\n\n  /**\n   * Slide width in EMU — the master's standard placeholder positions are scaled\n   * to this width. Set by the compiler from the presentation size; defaults to\n   * the 16:9 width (12192000 EMU) so patch/deserialize paths that never touch\n   * the master still have a sane value.\n   */\n  public slideWidth = 12192000;\n\n  // ── WriteContext stubs (core interface) ──\n\n  public addRelationship(_type: string, _target: string, _mode?: string): string {\n    const id = this._nextRelId++;\n    return `rId${id}`;\n  }\n\n  public addMedia(data: Uint8Array, type: string): string {\n    const entry = this._media.addMedia(data, type, (fileName) => ({\n      key: fileName,\n      fileName,\n      data,\n      type,\n    }));\n    return `{${entry.fileName}}`;\n  }\n\n  // ── PPTX-specific registration ──\n\n  /**\n   * Register an OLE embedding (ppt/embeddings/oleObjectN.bin) and return a\n   * `{ole:oleObjectN.bin}` placeholder. The compiler rewrites the placeholder\n   * to a real relationship id and adds the oleObject relationship per slide.\n   */\n  public addOle(data: Uint8Array, progId?: string): string {\n    const entry = this._embeddings.addEmbedding(data, undefined, progId);\n    return `{ole:${entry.fileName}}`;\n  }\n\n  public addImage(key: string, entry: MediaEntry): MediaEntry {\n    return this._media.addMedia(\n      entry.data,\n      entry.type,\n      (fileName) => ({ ...entry, fileName, key: fileName }),\n      key,\n    );\n  }\n\n  public addChart(key: string, entry: ChartEntry): void {\n    this._charts.set(key, entry);\n  }\n\n  public addSmartArt(key: string, entry: SmartArtEntry): void {\n    this._smartArts.set(key, entry);\n  }\n\n  public addHyperlink(key: string, target: HyperlinkTarget): void {\n    this._hyperlinks.set(key, {\n      key,\n      url: target.url,\n      slide: target.slide,\n      tooltip: target.tooltip,\n    });\n  }\n\n  /**\n   * Register an externally linked image source and return its `{img-link:key}`\n   * placeholder. The compiler rewrites the placeholder to a relationship id\n   * and adds the External image relationship per slide/layout.\n   */\n  public addImageLink(url: string): string {\n    const existingKey = this._imageLinkKeys.get(url);\n    if (existingKey !== undefined) return existingKey;\n    const key = `img-link_${this._nextImageLinkId++}`;\n    this._imageLinks.set(key, { key, url });\n    this._imageLinkKeys.set(url, key);\n    return key;\n  }\n\n  /**\n   * Register an externally linked OLE object source and return its\n   * `{ole-link:key}` placeholder. The compiler rewrites the placeholder to a\n   * relationship id and adds the External oleObject relationship per\n   * slide/layout.\n   */\n  public addOleLink(url: string): string {\n    const existingKey = this._oleLinkKeys.get(url);\n    if (existingKey !== undefined) return existingKey;\n    const key = `ole-link_${this._nextOleLinkId++}`;\n    this._oleLinks.set(key, { key, url });\n    this._oleLinkKeys.set(url, key);\n    return key;\n  }\n\n  public nextChartKey(): string {\n    return `chart_${this._nextChartId++}`;\n  }\n\n  // ── Shape-name symbol table ──\n\n  /**\n   * Clear the shape-name symbol table. spTgt @spid resolves within one part's\n   * spTree, so slide/layout/master serialization each starts a fresh scope.\n   */\n  public beginShapeScope(): void {\n    this._shapeIds.clear();\n    this._ambiguousShapeNames.clear();\n  }\n\n  /**\n   * Record a drawing's (cNvPr name, id) — the table animation `shapeName`\n   * references resolve against. A name carried by two different ids becomes\n   * ambiguous and stays unresolvable.\n   */\n  public registerShapeId(name: string, id: number): void {\n    const first = this._shapeIds.get(name);\n    if (first === undefined) this._shapeIds.set(name, id);\n    else if (first !== id) this._ambiguousShapeNames.add(name);\n  }\n\n  /**\n   * Resolve a shapeName reference to its cNvPr id. Throws when the name is\n   * unknown or ambiguous — a dangling spid would produce a file Office\n   * rejects, so the failure surfaces at compile time instead.\n   */\n  public resolveShapeName(name: string): number {\n    if (this._ambiguousShapeNames.has(name)) {\n      throw new Error(\n        `Shape name \"${name}\" is used by multiple shapes in this part — reference it by shapeId instead.`,\n      );\n    }\n    const id = this._shapeIds.get(name);\n    if (id === undefined) {\n      const names = [...this._shapeIds.keys()];\n      const available =\n        names.length === 0\n          ? \"this part has no shapes\"\n          : `shapes in this part are named: ${names\n              .slice(0, 8)\n              .map((n) => `\"${n}\"`)\n              .join(\", \")}${names.length > 8 ? `, … (${names.length} total)` : \"\"}`;\n      throw new Error(`No shape named \"${name}\" in this part — ${available}.`);\n    }\n    return id;\n  }\n\n  public nextSmartArtKey(): string {\n    return `smartart_${this._nextSmartArtId++}`;\n  }\n\n  // ── Getters ──\n\n  public get media(): MediaEntry[] {\n    return this._media.array;\n  }\n\n  /** Underlying deduplicated collection — used by the compiler for media output. */\n  public get mediaCollection(): Media<MediaEntry> {\n    return this._media;\n  }\n\n  /** Registered OLE embeddings — output as ppt/embeddings/*.bin by the compiler. */\n  public get embeddings(): EmbeddingData[] {\n    return this._embeddings.array;\n  }\n\n  public get charts(): ChartEntry[] {\n    return [...this._charts.values()];\n  }\n\n  public get smartArts(): SmartArtEntry[] {\n    return [...this._smartArts.values()];\n  }\n\n  public get hyperlinks(): HyperlinkEntry[] {\n    return [...this._hyperlinks.values()];\n  }\n\n  public get imageLinks(): ImageLinkEntry[] {\n    return [...this._imageLinks.values()];\n  }\n\n  public get oleLinks(): OleLinkEntry[] {\n    return [...this._oleLinks.values()];\n  }\n}\n\n// ── Read context ──\n\n/**\n * PPTX-specific read context.\n *\n * Adapts the existing {@link ParseContext} to the core {@link ReadContext}\n * interface used by the descriptor parse pipeline.\n */\nexport class PptxReadContext implements ReadContext {\n  constructor(private _parseCtx: ParseContext) {}\n\n  public resolveRelationship(rId: string): string | undefined {\n    return this._parseCtx.slideRels.get(rId);\n  }\n\n  public getPart(path: string) {\n    return this._parseCtx.pptx.doc.get(path);\n  }\n\n  public getRaw(path: string): Uint8Array | undefined {\n    return this._parseCtx.pptx.doc.getRaw(path);\n  }\n}\n","import type { BlackWhiteMode, EffectListOptions } from \"@office-open/core/drawing\";\nimport type { StyleMatrixReferenceOptions } from \"@office-open/core/drawing\";\nimport type { FillOptions } from \"@shared/drawing/fill\";\n\nexport type { StyleMatrixReferenceOptions };\n\nexport interface BackgroundOptions {\n  /** Style matrix reference (p:bgRef) — the common \"inherit theme background style\" form; mutually exclusive with fill. */\n  reference?: StyleMatrixReferenceOptions;\n  fill?: FillOptions;\n  effects?: EffectListOptions;\n  shadeToTitle?: boolean;\n  /** `@bwMode` (ST_BlackWhiteMode) — unprefixed attribute on `p:bg`. */\n  blackWhiteMode?: BlackWhiteMode;\n}\n\n/** MS Office default master/notes background — the first theme background style. */\nexport const DEFAULT_BACKGROUND_REFERENCE: StyleMatrixReferenceOptions = {\n  index: 1001,\n  color: { value: \"bg1\" },\n};\n","import { convertToEmu } from \"@office-open/core\";\nimport type { ColorMappingOptions, UniversalMeasure } from \"@office-open/core\";\nimport type { WriteContext } from \"@office-open/core/descriptor\";\nimport {\n  pickNonVisualDrawingProperties,\n  shapePropertiesDesc,\n  stringifyNonVisualDrawingProperties,\n  textBodyDesc,\n} from \"@office-open/core/drawing\";\nimport type { ShapePropertiesOptions } from \"@office-open/core/drawing\";\nimport type { BackgroundOptions } from \"@parts/background\";\nimport { DEFAULT_BACKGROUND_REFERENCE } from \"@parts/background\";\nimport { backgroundDesc } from \"@parts/descriptors/background\";\nimport { stringifyShapeStyle } from \"@parts/descriptors/shape\";\nimport type { TextStylesOptions } from \"@parts/descriptors/text-list-style\";\nimport type { ControlOptions } from \"@parts/slide/slide\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport type { AnimationsOptions } from \"@shared/animation/timing\";\nimport type { PlaceholderDefinition, PlaceholderMapOptions } from \"@shared/placeholder\";\nimport type { TransitionOptions } from \"@shared/transition\";\n\nimport type { PptxWriteContext } from \"../context\";\nimport type { HeaderFooterOptions } from \"./handout-master\";\n\nexport interface MasterPlaceholderPosition {\n  x: number | UniversalMeasure;\n  y: number | UniversalMeasure;\n  width: number | UniversalMeasure;\n  height: number | UniversalMeasure;\n}\n\nexport type MasterPlaceholderOptions = PlaceholderMapOptions;\n\nexport interface SlideMasterOptions {\n  background?: BackgroundOptions;\n  children?: SlideChild[];\n  placeholders?: MasterPlaceholderOptions;\n  /** Color mapping overrides (p:clrMap); defaults to the standard mapping. */\n  colorMapping?: Partial<ColorMappingOptions>;\n  /** Header/footer visibility on the master (p:hf). */\n  headerFooter?: HeaderFooterOptions;\n  /**\n   * Master text styles (p:txStyles — title/body/other, CT_SlideMasterTextStyles).\n   * Defaults to the MS Office standard block when omitted. Round-tripped masters\n   * carry their own so custom typography (fonts, indents, bullets) survives.\n   */\n  textStyles?: TextStylesOptions;\n  /** `@preserve` — keep this master even when no slide references it. */\n  preserve?: boolean;\n  /** p:transition — slide-transition defaults inherited by slides. */\n  transition?: TransitionOptions;\n  /** p:timing — animation timeline. */\n  animations?: AnimationsOptions;\n  /** cSld/custDataLst — relationship references to customer data parts. */\n  customerData?: { rId: string }[];\n  /** cSld/controls — embedded controls (ActiveX/legacy). */\n  controls?: ControlOptions[];\n  /**\n   * Raw inner XML of the p:extLst inside p:cSld (CT_CommonSlideData tail —\n   * where p14:creationId lives) — verbatim round-trip (captured from a\n   * parsed source; do not hand-author).\n   */\n  cSldExt?: string;\n  /** Raw extLst inner XML — verbatim round-trip for unmodeled extensions (captured from a parsed source; do not hand-author). */\n  ext?: string;\n}\n\n// ── Placeholder emit helpers (fresh-generate + round-trip path) ──\n//\n// The master carries up to five standard placeholders (title/body/date/footer/\n// slideNumber). Fresh generation scales their reference positions to the slide\n// width; round-trip supplies explicit EMU positions parsed from spTree. Both\n// paths now flow through shapePropertiesDesc/textBodyDesc so custom facets\n// (geometry/fill/outline/effects/textBody/style) round-trip losslessly while\n// the default layout stays byte-equivalent with MS Office's master output.\n\n// Reference positions (16:9 master, slideWidth = 12192000 EMU)\nexport const SW_REF = 12192000;\nconst sx = (refX: number, sw: number) => Math.round((refX * sw) / SW_REF);\n\nconst REF_TITLE = { x: 838200, y: 365125, cx: 10515600, cy: 1325563 };\nconst REF_BODY = { x: 838200, y: 1825625, cx: 10515600, cy: 4351338 };\nconst REF_DATE = { x: 838200, y: 6356350, cx: 2743200, cy: 365125 };\nconst REF_FOOTER = { x: 4038600, y: 6356350, cx: 4114800, cy: 365125 };\nconst REF_SLDNUM = { x: 8610600, y: 6356350, cx: 2743200, cy: 365125 };\n\n/**\n * Resolve a placeholder option into a concrete EMU position, or null when\n * hidden. Legacy helper kept for callers that only need the rect.\n */\nexport function resolvePos(\n  opt: boolean | MasterPlaceholderPosition | undefined,\n  ref: { x: number; y: number; cx: number; cy: number },\n  slideWidth: number,\n): { x: number; y: number; cx: number; cy: number } | null {\n  if (opt === false) return null;\n  if (opt === undefined || opt === true) {\n    return { x: sx(ref.x, slideWidth), y: ref.y, cx: sx(ref.cx, slideWidth), cy: ref.cy };\n  }\n  return {\n    x: convertToEmu(opt.x),\n    y: convertToEmu(opt.y),\n    cx: convertToEmu(opt.width),\n    cy: convertToEmu(opt.height),\n  };\n}\n\n/**\n * Resolve a placeholder option into a full definition (EMU position + carried\n * facets), or null when hidden. Fresh input (undefined/true) takes the\n * reference position; an explicit definition preserves its facets for emit.\n */\nfunction resolveDef(\n  opt: PlaceholderDefinition | false | undefined,\n  ref: { x: number; y: number; cx: number; cy: number },\n  slideWidth: number,\n): PlaceholderDefinition | null {\n  if (opt === false) return null;\n  const def: Partial<PlaceholderDefinition> = {};\n  if (opt === undefined) {\n    def.x = sx(ref.x, slideWidth);\n    def.y = ref.y;\n    def.width = sx(ref.cx, slideWidth);\n    def.height = ref.cy;\n  } else {\n    def.x = convertToEmu(opt.x);\n    def.y = convertToEmu(opt.y);\n    def.width = convertToEmu(opt.width);\n    def.height = convertToEmu(opt.height);\n    copyFacets(opt, def);\n    Object.assign(def, pickNonVisualDrawingProperties(opt));\n  }\n  return def as PlaceholderDefinition;\n}\n\nfunction copyFacets(src: PlaceholderDefinition, dst: Partial<PlaceholderDefinition>): void {\n  if (src.geometry !== undefined) dst.geometry = src.geometry;\n  if (src.customGeometry !== undefined) dst.customGeometry = src.customGeometry;\n  if (src.fill !== undefined) dst.fill = src.fill;\n  if (src.outline !== undefined) dst.outline = src.outline;\n  if (src.effects !== undefined) dst.effects = src.effects;\n  if (src.scene3d !== undefined) dst.scene3d = src.scene3d;\n  if (src.shape3d !== undefined) dst.shape3d = src.shape3d;\n  if (src.textBody !== undefined) dst.textBody = src.textBody;\n  if (src.style !== undefined) dst.style = src.style;\n}\n\n/** Emit one placeholder <p:sp> from a full definition (position + facets). */\nfunction phSp(\n  id: number,\n  name: string,\n  phAttrs: string,\n  def: PlaceholderDefinition,\n  defaultBody: string,\n  ctx: WriteContext,\n): string {\n  // p:spPr — xfrm + geometry (defaults to rect, the placeholder standard) +\n  // any inherited fill/outline/effects/3D facets.\n  const spPrContent = shapePropertiesDesc.stringify(\n    {\n      x: def.x,\n      y: def.y,\n      width: def.width,\n      height: def.height,\n      geometry: def.customGeometry ? undefined : (def.geometry ?? \"rect\"),\n      customGeometry: def.customGeometry,\n      fill: def.fill,\n      outline: def.outline,\n      effects: def.effects,\n      scene3d: def.scene3d,\n      shape3d: def.shape3d,\n    } as ShapePropertiesOptions,\n    ctx,\n  );\n  const spPr = spPrContent ? `<p:spPr>${spPrContent}</p:spPr>` : \"<p:spPr/>\";\n\n  const styleXml = def.style ? stringifyShapeStyle(def.style, ctx) : \"\";\n  const bodyContent = def.textBody ? textBodyDesc.stringify(def.textBody, ctx) : defaultBody;\n\n  // cNvPr via the shared serializer — carries description/title/hidden and the\n  // a16:creationId extension when the definition (round-trip) has them; fresh\n  // definitions emit the same plain `<p:cNvPr id name/>` as before.\n  const cNvPr = stringifyNonVisualDrawingProperties(\"p:cNvPr\", id, def, name);\n\n  return `<p:sp><p:nvSpPr>${cNvPr}<p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph ${phAttrs}/></p:nvPr></p:nvSpPr>${spPr}${styleXml}<p:txBody>${bodyContent}</p:txBody></p:sp>`;\n}\n\nexport const BODY_DEFAULT = `<a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\"/></a:p>`;\n\nexport function footerBody(algn: string, fldType: string, fldId: string, fldText: string): string {\n  const fld =\n    fldType && fldId\n      ? `<a:fld id=\"${fldId}\" type=\"${fldType}\"><a:rPr lang=\"en-US\" smtClean=\"0\"/><a:t>${fldText}</a:t></a:fld>`\n      : \"\";\n  return `<a:bodyPr/><a:lstStyle><a:lvl1pPr algn=\"${algn}\"><a:defRPr sz=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"><a:tint val=\"75000\"/></a:schemeClr></a:solidFill></a:defRPr></a:lvl1pPr></a:lstStyle><a:p>${fld}<a:endParaRPr lang=\"en-US\"/></a:p>`;\n}\n\nexport interface PlaceholderEmitResult {\n  /** Concatenated placeholder <p:sp> XML (empty when all hidden). */\n  xml: string;\n  /** Next free cNvPr id after the emitted placeholders (children start here). */\n  nextId: number;\n}\n\n/**\n * Emit the master's standard placeholders in XSD order (title → body → date →\n * footer → slideNumber). Returns the concatenated XML and the next free id.\n */\nexport function buildPlaceholderShapes(\n  placeholders: MasterPlaceholderOptions | undefined,\n  ctx: PptxWriteContext,\n): PlaceholderEmitResult {\n  const ph = placeholders ?? {};\n  const slideWidth = ctx.slideWidth;\n  const shapes: string[] = [];\n  let nextId = 2;\n\n  const titleDef = resolveDef(ph.title, REF_TITLE, slideWidth);\n  if (titleDef) {\n    shapes.push(phSp(nextId++, \"Title Placeholder 1\", 'type=\"title\"', titleDef, BODY_DEFAULT, ctx));\n  }\n\n  const bodyDef = resolveDef(ph.body, REF_BODY, slideWidth);\n  if (bodyDef) {\n    shapes.push(\n      phSp(nextId++, \"Text Placeholder 2\", 'type=\"body\" idx=\"1\"', bodyDef, BODY_DEFAULT, ctx),\n    );\n  }\n\n  const dateDef = resolveDef(ph.date, REF_DATE, slideWidth);\n  if (dateDef) {\n    shapes.push(\n      phSp(\n        nextId++,\n        \"Date Placeholder 3\",\n        'type=\"dt\" sz=\"half\" idx=\"2\"',\n        dateDef,\n        footerBody(\"l\", \"datetimeFigureOut\", \"{5BCAD085-E8A6-8845-BD4E-CB4CCA059FC4}\", \"1/27/13\"),\n        ctx,\n      ),\n    );\n  }\n\n  const footerDef = resolveDef(ph.footer, REF_FOOTER, slideWidth);\n  if (footerDef) {\n    shapes.push(\n      phSp(\n        nextId++,\n        \"Footer Placeholder 4\",\n        'type=\"ftr\" sz=\"quarter\" idx=\"3\"',\n        footerDef,\n        footerBody(\"ctr\", \"\", \"\", \"\"),\n        ctx,\n      ),\n    );\n  }\n\n  const sldNumDef = resolveDef(ph.slideNumber, REF_SLDNUM, slideWidth);\n  if (sldNumDef) {\n    shapes.push(\n      phSp(\n        nextId++,\n        \"Slide Number Placeholder 5\",\n        'type=\"sldNum\" sz=\"quarter\" idx=\"4\"',\n        sldNumDef,\n        footerBody(\"r\", \"slidenum\", \"{C1FF6DA9-008F-8B48-92A6-B652298478BF}\", \"‹#›\"),\n        ctx,\n      ),\n    );\n  }\n\n  return { xml: shapes.join(\"\"), nextId };\n}\n\n// ── Background ──\n\n/** Emit p:bg. Undefined background emits the MS Office default bgRef idx=\"1001\". */\nexport function buildBackgroundXml(bg?: BackgroundOptions): string {\n  return (\n    backgroundDesc.stringify(\n      bg ?? { reference: DEFAULT_BACKGROUND_REFERENCE },\n      undefined as never,\n    ) ?? \"\"\n  );\n}\n","/**\n * Slide Master (p:sldMaster) descriptor for PPTX.\n *\n * CT_SlideMaster — fully structured, mirroring {@link slideLayoutDesc}:\n * stringify builds cSld/bg/spTree(placeholders+children)/custDataLst/controls +\n * clrMap(EG_TopLevelSlide, required) + sldLayoutIdLst + transition + timing +\n * hf + txStyles with the `@preserve` attribute; parse extracts the same.\n *\n * Placeholder positions are scaled to the slide width on fresh generation and\n * re-derived from spTree on parse (round-trip). The master's standard text\n * styles (p:txStyles) default to the MS Office block when omitted.\n *\n * @module\n */\n\nimport { parseColorMapping, parseOnOff, stringifyColorMapping } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, findChild, stringify as stringifyXml } from \"@office-open/xml\";\nimport {\n  buildBackgroundXml,\n  buildPlaceholderShapes,\n  type MasterPlaceholderOptions,\n  type SlideMasterOptions,\n} from \"@parts/slide-master\";\nimport {\n  parseControls,\n  parseCustDataLst,\n  stringifyControls,\n  stringifyCustDataLst,\n} from \"@parts/slide/c-sld\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\nimport {\n  extractPlaceholderDefinition,\n  PLACEHOLDER_TYPE_TO_KEY,\n  STANDARD_EMIT_KEYS,\n} from \"@shared/placeholder\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { buildHfAttrs, parseHeaderFooter } from \"../handout-master\";\nimport { timingDesc } from \"./animation\";\nimport { backgroundDesc } from \"./background\";\nimport { parseChild, stringifyChild } from \"./bridge\";\nimport { readTransition, stringifyTransition } from \"./slide\";\nimport { DEFAULT_TEXT_STYLES, parseTextStyles, stringifyTextStyles } from \"./text-list-style\";\n\n// ── Types ──\n\n/** Slide master options — structured form (CT_SlideMaster). */\nexport type SlideMasterDescriptorOptions = SlideMasterOptions & {\n  /** cSld/`@name`. */\n  name?: string;\n  /** sldLayoutIdLst — layout ids + relationship ids owned by this master. */\n  slideLayoutIds?: { id: number; relationshipId: string }[];\n};\n\n/**\n * Assign an explicit cNvPr id to a single-key slide-child wrapper (master\n * children start after the placeholder ids so ids stay unique per part).\n * Verbatim/rawXml children have no id slot and pass through unchanged.\n */\nexport function withChildId(child: SlideChild, id: number): SlideChild {\n  const [key, value] = Object.entries(child)[0] as [string, { id?: number } | string];\n  if (typeof value !== \"object\") return child;\n  return { [key]: { ...value, id: value.id ?? id } } as SlideChild;\n}\n\nconst NS =\n  'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ' +\n  'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n  'xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"';\n\n// ── Descriptor ──\n\nexport const slideMasterDesc: CustomDescriptor<SlideMasterDescriptorOptions, PptxWriteContext> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const parts: string[] = [];\n    ctx.beginShapeScope();\n\n    // Root (CT_SlideMaster: @preserve).\n    const preserveAttr = opts.preserve ? ' preserve=\"1\"' : \"\";\n    parts.push(`<p:sldMaster ${NS}${preserveAttr}>`);\n\n    // p:cSld (CT_CommonSlideData) — optional name attribute.\n    parts.push(`<p:cSld${opts.name !== undefined ? ` name=\"${opts.name}\"` : \"\"}>`);\n\n    // p:bg — undefined background emits the MS Office default bgRef idx=\"1001\".\n    parts.push(buildBackgroundXml(opts.background));\n\n    // p:spTree — standard placeholders (scaled to slide width) + custom children.\n    parts.push(\"<p:spTree>\");\n    parts.push(SP_TREE_HEADER);\n    const { xml: placeholderXml, nextId } = buildPlaceholderShapes(opts.placeholders, ctx);\n    if (placeholderXml) parts.push(placeholderXml);\n    // Children carry explicit cNvPr ids (starting after the placeholders) so they\n    // never collide with the module-level shape id counter or the placeholders.\n    let childId = nextId;\n    for (const child of opts.children ?? []) {\n      const xml = stringifyChild(withChildId(child, childId++), ctx);\n      if (xml) parts.push(xml);\n    }\n    parts.push(\"</p:spTree>\");\n\n    // custDataLst + controls (inside cSld per CT_CommonSlideData).\n    parts.push(stringifyCustDataLst(opts.customerData));\n    parts.push(stringifyControls(opts.controls));\n\n    // cSld-tail extLst (p14:creationId's home) — verbatim.\n    if (opts.cSldExt) parts.push(`<p:extLst>${opts.cSldExt}</p:extLst>`);\n\n    parts.push(\"</p:cSld>\");\n\n    // EG_TopLevelSlide — p:clrMap (required; defaults to the standard mapping).\n    parts.push(stringifyColorMapping(opts.colorMapping, \"p:clrMap\"));\n\n    // p:sldLayoutIdLst (always emitted; empty when the master owns no layouts).\n    const layoutIds = (opts.slideLayoutIds ?? []).map(\n      (l) => `<p:sldLayoutId id=\"${l.id}\" r:id=\"${l.relationshipId}\"/>`,\n    );\n    parts.push(`<p:sldLayoutIdLst>${layoutIds.join(\"\")}</p:sldLayoutIdLst>`);\n\n    // p:transition (optional, after sldLayoutIdLst).\n    if (opts.transition) {\n      const transitionXml = stringifyTransition(opts.transition, ctx);\n      if (transitionXml) parts.push(transitionXml);\n    }\n\n    // p:timing (optional).\n    if (opts.animations?.length) {\n      parts.push(timingDesc.stringify(opts.animations, ctx) ?? \"\");\n    }\n\n    // p:hf (optional — MS Office masters carry none by default; emit only what\n    // the source defined).\n    if (opts.headerFooter !== undefined) {\n      parts.push(`<p:hf ${buildHfAttrs(opts.headerFooter)}/>`);\n    }\n\n    // p:txStyles (defaults to the MS Office standard title/body/other block).\n    parts.push(\n      `<p:txStyles>${stringifyTextStyles(opts.textStyles ?? DEFAULT_TEXT_STYLES, ctx)}</p:txStyles>`,\n    );\n\n    // p:extLst — verbatim round-trip (last child per CT_SlideMaster sequence).\n    if (opts.ext) parts.push(`<p:extLst>${opts.ext}</p:extLst>`);\n\n    parts.push(\"</p:sldMaster>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, ctx) {\n    const result: Partial<SlideMasterDescriptorOptions> = {};\n\n    // @preserve\n    if (parseOnOff(attr(el, \"preserve\"))) result.preserve = true;\n\n    // p:cSld (CT_CommonSlideData).\n    const cSld = findChild(el, \"p:cSld\");\n    if (cSld) {\n      const name = attr(cSld, \"name\");\n      if (name !== undefined) result.name = name;\n\n      const bg = findChild(cSld, \"p:bg\");\n      if (bg) {\n        const bgOpts = backgroundDesc.parse(bg, ctx);\n        if (bgOpts && Object.keys(bgOpts).length > 0) result.background = bgOpts;\n      }\n\n      // spTree — structured children + derived placeholder positions.\n      const spTree = findChild(cSld, \"p:spTree\");\n      if (spTree) {\n        const children: SlideChild[] = [];\n        const placeholders: MasterPlaceholderOptions = {};\n        for (const child of spTree.elements ?? []) {\n          if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n          if (child.name === \"p:sp\") {\n            const ph = extractPlaceholderDefinition(child, ctx, PLACEHOLDER_TYPE_TO_KEY);\n            if (ph) {\n              placeholders[ph.key] = ph.def;\n              // Standard five re-emit from the map (fresh reference\n              // positions); any other placeholder type stays in the spTree\n              // children verbatim — the emit helper has no branch for it.\n              if (STANDARD_EMIT_KEYS.has(ph.key)) continue;\n            }\n          }\n          const parsed = parseChild(child, ctx);\n          if (parsed !== undefined) children.push(parsed);\n        }\n        if (children.length > 0) result.children = children;\n        // Round-trip always declares the standard slots explicitly — absent\n        // ones become false so a source master with no (or partial) standard\n        // placeholders does not fall back to the fresh-file defaults. Other\n        // placeholder types are neither emitted fresh nor hidden by absence,\n        // so they stay unset.\n        for (const optKey of STANDARD_EMIT_KEYS) {\n          if (placeholders[optKey] === undefined) placeholders[optKey] = false;\n        }\n        result.placeholders = placeholders;\n      }\n\n      // custDataLst + controls (inside cSld).\n      result.customerData = parseCustDataLst(findChild(cSld, \"p:custDataLst\"));\n      result.controls = parseControls(findChild(cSld, \"p:controls\"));\n\n      // cSld-tail extLst (p14:creationId's home) — verbatim, distinct from\n      // the root-level extLst read below (two separate XSD slots).\n      const cSldExtLst = findChild(cSld, \"p:extLst\");\n      if (cSldExtLst) {\n        const inner = stringifyXml(cSldExtLst);\n        if (inner) result.cSldExt = inner;\n      }\n    }\n\n    // EG_TopLevelSlide — p:clrMap (required).\n    const colorMapping = parseColorMapping(findChild(el, \"p:clrMap\"));\n    if (colorMapping) result.colorMapping = colorMapping;\n\n    // p:sldLayoutIdLst.\n    const sldLayoutIdLst = findChild(el, \"p:sldLayoutIdLst\");\n    if (sldLayoutIdLst) {\n      const ids = (sldLayoutIdLst.elements ?? [])\n        .filter((e) => e.name === \"p:sldLayoutId\")\n        .map((e) => ({\n          id: Number(attr(e, \"id\")),\n          relationshipId: attr(e, \"r:id\") ?? \"\",\n        }));\n      if (ids.length > 0) result.slideLayoutIds = ids;\n    }\n\n    // p:transition.\n    const transition = findChild(el, \"p:transition\");\n    if (transition) result.transition = readTransition(transition, ctx);\n\n    // p:timing (structured entries, or verbatim inner XML fallback).\n    const timing = findChild(el, \"p:timing\");\n    if (timing) {\n      const animations = timingDesc.parse(timing, ctx);\n      if (!(Array.isArray(animations) && animations.length === 0)) result.animations = animations;\n    }\n\n    // p:hf.\n    const headerFooter = parseHeaderFooter(findChild(el, \"p:hf\"));\n    if (headerFooter) result.headerFooter = headerFooter;\n\n    // p:txStyles (CT_SlideMasterTextStyles — title/body/other).\n    const txStyles = findChild(el, \"p:txStyles\");\n    if (txStyles) result.textStyles = parseTextStyles(txStyles, ctx);\n\n    // p:extLst — verbatim inner XML for unmodeled extensions.\n    const extLst = findChild(el, \"p:extLst\");\n    if (extLst) {\n      const inner = stringifyXml(extLst);\n      if (inner) result.ext = inner;\n    }\n\n    return result as SlideMasterDescriptorOptions;\n  },\n};\n","/**\n * Handout Master (p:handoutMaster) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseColorMapping, stringifyColorMapping } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, stringify } from \"@office-open/xml\";\nimport { buildHfAttrs, buildHandoutMasterXml, parseHeaderFooter } from \"@parts/handout-master\";\nimport type { HandoutMasterOptions } from \"@parts/handout-master\";\nimport { NS } from \"@parts/slide-layout\";\nimport { buildBackgroundXml } from \"@parts/slide-master\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { backgroundDesc } from \"./background\";\nimport { parseChild, stringifyChild } from \"./bridge\";\nimport { withChildId } from \"./slide-master\";\n\n// ── Types ──\n\nexport interface HandoutMasterDescriptorOptions {\n  options?: HandoutMasterOptions;\n}\n\n// ── Descriptor ──\n\nexport const handoutMasterDesc: CustomDescriptor<HandoutMasterDescriptorOptions, PptxWriteContext> =\n  {\n    kind: \"custom\",\n\n    stringify(opts, ctx) {\n      // A parsed source carries its spTree shapes; a fresh one keeps the\n      // minimal Office default.\n      if (opts.options?.children?.length) {\n        const parts: string[] = [];\n        parts.push(`<p:handoutMaster ${NS}>`);\n        parts.push(\"<p:cSld>\");\n        parts.push(buildBackgroundXml(opts.options.background));\n        parts.push(\"<p:spTree>\");\n        parts.push(SP_TREE_HEADER);\n        let childId = 100;\n        for (const child of opts.options.children) {\n          const xml = stringifyChild(withChildId(child, childId++), ctx);\n          if (xml) parts.push(xml);\n        }\n        parts.push(\"</p:spTree>\");\n        if (opts.options.ext !== undefined) parts.push(`<p:extLst>${opts.options.ext}</p:extLst>`);\n        parts.push(\"</p:cSld>\");\n        parts.push(stringifyColorMapping(opts.options.colorMapping, \"p:clrMap\"));\n        if (opts.options.headerFooter !== undefined) {\n          parts.push(`<p:hf ${buildHfAttrs(opts.options.headerFooter)}/>`);\n        }\n        parts.push(\"</p:handoutMaster>\");\n        return parts.join(\"\");\n      }\n      return buildHandoutMasterXml(opts.options);\n    },\n\n    parse(el, ctx) {\n      const options: HandoutMasterOptions = {};\n\n      const cSld = findChild(el, \"p:cSld\");\n      if (cSld) {\n        const bg = findChild(cSld, \"p:bg\");\n        if (bg) {\n          const bgOpts = backgroundDesc.parse(bg, ctx);\n          if (bgOpts && Object.keys(bgOpts).length > 0) options.background = bgOpts;\n        }\n\n        const spTree = findChild(cSld, \"p:spTree\");\n        if (spTree) {\n          const children: SlideChild[] = [];\n          for (const child of spTree.elements ?? []) {\n            if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n            const parsed = parseChild(child, ctx);\n            if (parsed !== undefined) children.push(parsed);\n          }\n          if (children.length > 0) options.children = children;\n        }\n      }\n\n      const colorMapping = parseColorMapping(findChild(el, \"p:clrMap\"));\n      if (colorMapping) options.colorMapping = colorMapping;\n\n      const headerFooter = parseHeaderFooter(findChild(el, \"p:hf\"));\n      if (headerFooter) options.headerFooter = headerFooter;\n\n      const extLst = cSld && findChild(cSld, \"p:extLst\");\n      if (extLst) options.ext = stringify(extLst);\n\n      return Object.keys(options).length > 0 ? { options } : {};\n    },\n  };\n","/**\n * Notes Master (p:notesMaster) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseColorMapping, stringifyColorMapping } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { stringifyTextListStyleTag, textListStyleDesc } from \"@office-open/core/drawing\";\nimport { findChild, stringify } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { buildHfAttrs, parseHeaderFooter } from \"@parts/handout-master\";\nimport { DEFAULT_NOTES_STYLE } from \"@parts/notes-master\";\nimport type { NotesMasterOptions } from \"@parts/notes-master\";\nimport { NS } from \"@parts/slide-layout\";\nimport { buildBackgroundXml } from \"@parts/slide-master\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { backgroundDesc } from \"./background\";\nimport { parseChild, stringifyChild } from \"./bridge\";\nimport { withChildId } from \"./slide-master\";\n\n// ── Descriptor ──\n\nexport const notesMasterDesc: CustomDescriptor<NotesMasterOptions, PptxWriteContext> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const parts: string[] = [];\n\n    parts.push(`<p:notesMaster ${NS}>`);\n\n    // p:cSld — bg + spTree.\n    parts.push(\"<p:cSld>\");\n    parts.push(buildBackgroundXml(opts.background));\n    parts.push(\"<p:spTree>\");\n    parts.push(SP_TREE_HEADER);\n    // Children carry explicit cNvPr ids so they never collide with the group\n    // header (id 1) or ids kept from a parsed source.\n    let childId = 100;\n    for (const child of opts.children ?? []) {\n      const xml = stringifyChild(withChildId(child, childId++), ctx);\n      if (xml) parts.push(xml);\n    }\n    parts.push(\"</p:spTree>\");\n    if (opts.ext !== undefined) parts.push(`<p:extLst>${opts.ext}</p:extLst>`);\n    parts.push(\"</p:cSld>\");\n\n    parts.push(stringifyColorMapping(opts.colorMapping, \"p:clrMap\"));\n    // p:hf — optional; Office notes masters carry none by default.\n    if (opts.headerFooter !== undefined) {\n      parts.push(`<p:hf ${buildHfAttrs(opts.headerFooter)}/>`);\n    }\n    parts.push(\n      stringifyTextListStyleTag(\"p:notesStyle\", opts.notesStyle ?? DEFAULT_NOTES_STYLE, ctx),\n    );\n\n    parts.push(\"</p:notesMaster>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, ctx) {\n    const result: Partial<NotesMasterOptions> = {};\n\n    const cSld = findChild(el, \"p:cSld\");\n    if (cSld) {\n      const bg = findChild(cSld, \"p:bg\");\n      if (bg) {\n        const bgOpts = backgroundDesc.parse(bg, ctx);\n        if (bgOpts && Object.keys(bgOpts).length > 0) result.background = bgOpts;\n      }\n\n      const spTree = findChild(cSld, \"p:spTree\");\n      if (spTree) {\n        const children: SlideChild[] = [];\n        for (const child of spTree.elements ?? []) {\n          if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n          const parsed = parseChild(child, ctx);\n          if (parsed !== undefined) children.push(parsed);\n        }\n        if (children.length > 0) result.children = children;\n      }\n    }\n\n    const colorMapping = parseColorMapping(findChild(el, \"p:clrMap\"));\n    if (colorMapping) result.colorMapping = colorMapping;\n\n    const headerFooter = parseHeaderFooter(findChild(el, \"p:hf\"));\n    if (headerFooter) result.headerFooter = headerFooter;\n\n    const extLst = cSld && findChild(cSld, \"p:extLst\");\n    if (extLst) result.ext = stringify(extLst);\n\n    const notesStyleEl: XmlElement | undefined = findChild(el, \"p:notesStyle\");\n    if (notesStyleEl) {\n      const notesStyle = textListStyleDesc.parse(notesStyleEl, ctx);\n      // An empty p:notesStyle parses to an empty list; keep the Office default.\n      if (\n        notesStyle.defaultParagraph ||\n        notesStyle.ext !== undefined ||\n        (notesStyle.levels?.length ?? 0) > 0\n      ) {\n        result.notesStyle = notesStyle;\n      }\n    }\n\n    return result as NotesMasterOptions;\n  },\n};\n","/**\n * Cross-domain compile scaffolding shared by the pptx compile phases: the\n * XML declaration/encoder pair, the mapping shape, and the relationship\n * wiring helpers every part family (masters, layouts, slides, notes) reuses.\n *\n * @module\n */\n\nimport {\n  RELATIONSHIP_TYPES,\n  Relationships,\n  collectPlaceholderKeys,\n  replacePlaceholders,\n} from \"@office-open/core\";\nimport type { RelationshipType } from \"@office-open/core\";\nimport { OOXML_XML_DECLARATION } from \"@office-open/xml\";\nimport type { PresentationOptions } from \"@shared/file\";\n\nimport type { HyperlinkEntry } from \"../context\";\n\nexport const encoder = new TextEncoder();\nexport const XML_DECL = OOXML_XML_DECLARATION + \"\\n\";\n\nexport interface RelEntry {\n  id: number | string;\n  type: RelationshipType;\n  target: string;\n  mode?: string;\n}\n\nexport interface XmlifyedFileMapping {\n  [key: string]: { data: string; path: string };\n}\n\n/** Rel kinds whose targets are media files the model may rename on absorb. */\nexport const MEDIA_REL_KINDS = new Set([\"image\", \"media\", \"audio\", \"video\"]);\n\nexport function buildRels(entries: RelEntry[]): Relationships {\n  const rels = new Relationships();\n  for (const e of entries) {\n    rels.addRelationship(e.id, e.type, e.target, e.mode as \"External\" | undefined);\n  }\n  return rels;\n}\n\n/**\n * Replace `{hlink:key}` placeholders in a serialized part with real r:ids and\n * wire the matching hyperlink relationships. Every part that can host text\n * (master, layout, notes slide, notesMaster, handoutMaster) routes here —\n * without it, hyperlinks in those parts leak raw placeholders and dangle.\n * `slideTargetPrefix` differs per directory: slides reference each other\n * directly, every other part needs \"../slides/\". Slide-target relationships\n * dedup by target (a part may carry only one slide rel per target — several\n * hyperlinks jumping to the same slide share one rId).\n */\nexport function wirePartHyperlinks(\n  xml: string,\n  hyperlinks: HyperlinkEntry[],\n  nextId: number,\n  add: (id: number, type: RelationshipType, target: string, mode?: \"External\") => void,\n  slideTargetPrefix: string,\n  existingIdOf?: (target: string) => number | undefined,\n): string {\n  const keys = collectPlaceholderKeys(xml, \"hlink:\");\n  if (keys.length === 0) return xml;\n  const keySet = new Set(keys);\n  const matched = hyperlinks.filter((h) => keySet.has(h.key));\n  const SLIDE_REL = RELATIONSHIP_TYPES.slide;\n  // Parts that resolve an existing rel (slides, notes) are round-trip owners —\n  // each hyperlink keeps its own relationship there even when targets repeat\n  // (source files may legally carry several). Fresh parts (master, layout,\n  // notesMaster, handoutMaster) dedup by target so the SDK's one-slide-rel-\n  // per-target rule holds for generated packages. Resolve pre-existing rels\n  // once up front — a live re-query would see rels this helper just added and\n  // fold round-trip duplicates into one.\n  const dedup = existingIdOf === undefined;\n  const preExisting = new Map<string, number>();\n  if (existingIdOf) {\n    for (const hlink of matched) {\n      if (hlink.slide === undefined) continue;\n      const target = `${slideTargetPrefix}slide${hlink.slide}.xml`;\n      if (!preExisting.has(target)) {\n        const id = existingIdOf(target);\n        if (id !== undefined) preExisting.set(target, id);\n      }\n    }\n  }\n  const idBySlideTarget = new Map<string, number>();\n  let cursor = nextId;\n  const idByKey = new Map<string, number>();\n  for (const hlink of matched) {\n    if (hlink.slide === undefined) continue;\n    const target = `${slideTargetPrefix}slide${hlink.slide}.xml`;\n    let id = preExisting.get(target);\n    if (id === undefined) id = dedup ? idBySlideTarget.get(target) : undefined;\n    if (id === undefined) {\n      id = cursor++;\n      if (dedup) idBySlideTarget.set(target, id);\n      add(id, SLIDE_REL as RelationshipType, target);\n    }\n    idByKey.set(hlink.key, id);\n  }\n  for (const hlink of matched) {\n    if (hlink.slide !== undefined) continue;\n    const id = cursor++;\n    idByKey.set(hlink.key, id);\n    add(id, RELATIONSHIP_TYPES.hyperlink, hlink.url ?? \"\", \"External\");\n  }\n  const replacement = new Map<string, string>();\n  for (const [key, id] of idByKey) replacement.set(`hlink:${key}`, `rId${id}`);\n  return replacePlaceholders(xml, replacement);\n}\n\n/** Promote the slide layout rel to its source id when the source rId is free\n * — verbatim slide content references the source rId and dangling the layout\n * would dangle the rest of the slide's rels. */\nexport function promoteLayoutToSourceId(\n  rels: Relationships,\n  sourcePassthrough: { rId: string; target: string; relationshipType: string }[] | undefined,\n): void {\n  if (!sourcePassthrough) return;\n  const sourceLayout = sourcePassthrough.find(\n    (r) => r.relationshipType === RELATIONSHIP_TYPES.slideLayout,\n  );\n  if (!sourceLayout) return;\n  const numeric = /^rId(\\d+)$/.exec(sourceLayout.rId);\n  if (!numeric) return;\n  rels.renameEntryByType(RELATIONSHIP_TYPES.slideLayout, Number(numeric[1]));\n}\n\n/** Reserve the captured ids whose rels a claim will re-emit. A captured rel\n * whose kind the model registers for the part (layout, theme, media, …) is\n * absorbed — the claim skips it as owned, so reserving its id only opens a\n * hole the round-trip then reports as drift. Kinds outside `absorbedKinds`\n * have no model counterpart (a chart part carried as a raw island beside a\n * modeled picture, say): their claims keep the source ids verbatim content\n * references, so those ids must stay free above the batch allocations. */\nexport function reserveClaimedSourceRids(\n  rels: Relationships,\n  source: string,\n  passthroughRelationships: PresentationOptions[\"passthroughRelationships\"],\n  absorbedKinds: ReadonlySet<string>,\n): void {\n  for (const rel of passthroughRelationships ?? []) {\n    if (rel.source !== source) continue;\n    if (absorbedKinds.has(rel.relationshipType.split(\"/\").pop()!)) continue;\n    rels.reserveId(rel.rId);\n  }\n}\n","/**\n * Master/layout compile phase: builds the slide-master map (masters, their\n * layouts, deduped themes) and writes the master, layout, notesMaster, and\n * handoutMaster parts into the file mapping.\n *\n * @module\n */\n\nimport {\n  RELATIONSHIP_TYPES,\n  Relationships,\n  collectPlaceholderKeys,\n  convertToEmu,\n  getReferencedMedia,\n  replaceImageLinkPlaceholders,\n  replaceImagePlaceholders,\n  replaceOleLinkPlaceholders,\n  themeOverrideDesc,\n} from \"@office-open/core\";\nimport type { PresentationPartOptions } from \"@parts/presentation\";\nimport { buildCustomLayoutXml, buildLayoutXml, type SlideLayoutType } from \"@parts/slide-layout\";\nimport type {\n  LayoutDefinition,\n  MasterDefinition,\n  PresentationOptions,\n  SlideOptions,\n  SlideSize,\n} from \"@shared/file\";\nimport { createThemeXml } from \"@shared/theme\";\n\nimport type { PptxWriteContext } from \"../context\";\nimport { handoutMasterDesc } from \"../parts/descriptors/handout-master\";\nimport { notesMasterDesc } from \"../parts/descriptors/notes-master\";\nimport { parseLayoutDef, slideLayoutDesc } from \"../parts/descriptors/slide-layout\";\nimport { slideMasterDesc } from \"../parts/descriptors/slide-master\";\nimport {\n  MEDIA_REL_KINDS,\n  XML_DECL,\n  type RelEntry,\n  type XmlifyedFileMapping,\n  buildRels,\n  reserveClaimedSourceRids,\n  wirePartHyperlinks,\n} from \"./shared\";\n\nexport interface LayoutInfo {\n  key: string;\n  index: number;\n  masterIndex: number;\n  def: LayoutDefinition;\n  /** Serialized themeOverride part XML, when the layout deviates from its master's theme. */\n  themeOverride?: string;\n}\n\nexport interface MasterInfo {\n  name: string;\n  index: number;\n  master: string;\n  theme: string;\n  /** Emitted theme part index — shared when masters carry identical themes. */\n  themeIndex: number;\n  layouts: LayoutInfo[];\n  masterRels: Relationships;\n  layoutRels: Relationships[];\n}\n\n/**\n * Resolve a layout definition to its structured form for stringify.\n *\n * Structured defs (round-trip parse, or user-provided shapes/bg/transition/etc)\n * pass through unchanged. Fresh template / custom / deprecated-verbatim layouts\n * are built to XML then parsed back to structure, so every layout is emitted via\n * slideLayoutDesc.stringify uniformly.\n */\nfunction resolveLayoutDef(\n  layoutDef: LayoutDefinition | undefined,\n  slideLayoutType: SlideLayoutType,\n  slideWidth: number,\n): LayoutDefinition {\n  if (layoutDef && hasStructuredLayoutContent(layoutDef)) return layoutDef;\n  const xml = layoutDef?.layout\n    ? layoutDef.layout\n    : layoutDef\n      ? buildCustomLayoutXml(layoutDef)\n      : buildLayoutXml(slideLayoutType, slideWidth);\n  return parseLayoutDef(xml);\n}\n\n/** True when a def carries structured content that must drive stringify directly. */\nfunction hasStructuredLayoutContent(def: LayoutDefinition): boolean {\n  return (\n    (def.children !== undefined && def.children.length > 0) ||\n    def.background !== undefined ||\n    def.transition !== undefined ||\n    def.animations !== undefined ||\n    def.ext !== undefined ||\n    def.headerFooter !== undefined ||\n    def.colorMappingOverride !== undefined ||\n    (def.controls !== undefined && def.controls.length > 0) ||\n    (def.customerData !== undefined && def.customerData.length > 0)\n  );\n}\n\nexport function buildMasterMap(\n  masterDefs: MasterDefinition[],\n  slides: SlideOptions[],\n  slideWidth: number,\n  ctx: PptxWriteContext,\n  passthroughRelationships: PresentationOptions[\"passthroughRelationships\"],\n): MasterInfo[] {\n  // Master placeholder positions scale to the slide width — record it on the\n  // shared context so slideMasterDesc.stringify can read it.\n  ctx.slideWidth = slideWidth;\n  const defs = masterDefs.length > 0 ? masterDefs : [{} as MasterDefinition];\n  const slideMasterLookup = new Map<number, number>();\n\n  for (const [si, slide] of slides.entries()) {\n    const masterName = slide.master;\n    if (masterName === undefined) {\n      slideMasterLookup.set(si, 0);\n      continue;\n    }\n    const mi = defs.findIndex((d) => d.name === masterName);\n    slideMasterLookup.set(si, mi >= 0 ? mi : 0);\n  }\n\n  let globalLayoutIndex = 0;\n  const masters: MasterInfo[] = [];\n  // Identical master themes share one theme part (sources commonly point two\n  // masters at the same theme) — dedupe by serialized content, like media.\n  const themeIndexByXml = new Map<string, number>();\n  let themeCount = 0;\n\n  for (const [mi, def] of defs.entries()) {\n    const name = def.name ?? `master${mi + 1}`;\n\n    const layoutDefs = def.layouts;\n    let layoutKeys: string[];\n    if (layoutDefs && layoutDefs.length > 0) {\n      layoutKeys = layoutDefs.map(\n        (ld) => ld.type ?? ld.name ?? `layout${mi}_${layoutDefs.indexOf(ld)}`,\n      );\n    } else {\n      const seen = new Set<string>();\n      const keys: string[] = [];\n      for (const [si, slide] of slides.entries()) {\n        if (slideMasterLookup.get(si) === mi) {\n          const lt = slide.layout ?? \"blank\";\n          if (!seen.has(lt)) {\n            seen.add(lt);\n            keys.push(lt);\n          }\n        }\n      }\n      layoutKeys = keys.length > 0 ? keys : [\"blank\"];\n    }\n\n    // Layout id + rId pairs — rId order matches masterRels below. Source\n    // layout ids round-trip as-is; only fresh authoring renumbers.\n    const layoutIdBase = 2147483648 + mi * 12 + 1;\n    const layoutDefsById = def.layouts;\n    const slideLayoutIds = layoutKeys.map((_, li) => ({\n      id: layoutDefsById?.[li]?.layoutId ?? layoutIdBase + li,\n      relationshipId: `rId${li + 1}`,\n    }));\n    // Rest-spread so every SlideMasterOptions field flows to the descriptor —\n    // field-copy whitelists here have dropped newly added options before.\n    const { name: _masterName, theme: _theme, layouts: _layouts, ...masterOpts } = def;\n    const master = slideMasterDesc.stringify({ ...masterOpts, slideLayoutIds }, ctx) ?? \"\";\n    const theme = createThemeXml(def.theme, ctx);\n    let themeIndex = themeIndexByXml.get(theme);\n    if (themeIndex === undefined) {\n      themeIndex = themeCount++;\n      themeIndexByXml.set(theme, themeIndex);\n    }\n\n    const layouts: LayoutInfo[] = [];\n    const layoutRels: Relationships[] = [];\n\n    for (const [li, key] of layoutKeys.entries()) {\n      const layoutDef = layoutDefs?.[li];\n      const slideLayoutType = (layoutDef?.type ?? key) as SlideLayoutType;\n      const themeOverride = layoutDef?.themeOverride\n        ? (themeOverrideDesc.stringify(layoutDef.themeOverride, ctx) ?? undefined)\n        : undefined;\n      layouts.push({\n        key,\n        index: globalLayoutIndex,\n        masterIndex: mi,\n        def: resolveLayoutDef(layoutDef, slideLayoutType, slideWidth),\n        themeOverride,\n      });\n      const layoutRelEntries: RelEntry[] = [\n        {\n          id: 1,\n          type: RELATIONSHIP_TYPES.slideMaster,\n          target: `../slideMasters/slideMaster${mi + 1}.xml`,\n        },\n      ];\n      if (themeOverride) {\n        layoutRelEntries.push({\n          id: 2,\n          type: RELATIONSHIP_TYPES.themeOverride,\n          target: `../theme/themeOverride${globalLayoutIndex + 1}.xml`,\n        });\n      }\n      const layoutRel = buildRels(layoutRelEntries);\n      // The layout's captured rels are claimed in the mapping phase, after\n      // the layout's media/hyperlink batches have registered their kinds —\n      // claiming here would re-emit rels the batches then duplicate.\n      layoutRels.push(layoutRel);\n      globalLayoutIndex++;\n    }\n\n    // The master's rels go through the Relationships class like every other\n    // part: model registrations and the passthrough claim below share one id\n    // space, so a hand-written max-id fallback can't collide with a batch\n    // offset. Captured ids whose rels a claim will re-emit are reserved\n    // before the media batch snapshots nextRelationshipId; absorbed kinds\n    // (slideLayout, theme, images the media batch re-registers) are skipped —\n    // reserving them would only open holes their claims never fill.\n    const masterMediaData = getReferencedMedia(master, ctx.mediaCollection.array);\n    const masterAbsorbedKinds = new Set([\n      \"slideLayout\",\n      \"theme\",\n      ...(masterMediaData.length > 0 ? [\"image\"] : []),\n    ]);\n    const masterRels = new Relationships();\n    reserveClaimedSourceRids(\n      masterRels,\n      `ppt/slideMasters/slideMaster${mi + 1}.xml`,\n      passthroughRelationships,\n      masterAbsorbedKinds,\n    );\n    for (const [li, layout] of layouts.entries()) {\n      masterRels.addRelationship(\n        li + 1,\n        RELATIONSHIP_TYPES.slideLayout,\n        `../slideLayouts/slideLayout${layout.index + 1}.xml`,\n      );\n    }\n    masterRels.add(RELATIONSHIP_TYPES.theme, `../theme/theme${themeIndex + 1}.xml`);\n    // Media referenced by master shapes gets the same image-relationship\n    // wiring slides/layouts use (master pictures otherwise lose their rel).\n    // Registered before the passthrough loop so its kind ownership test sees\n    // the model registration and skips the source's stale image rels.\n    const masterImageOffset = masterRels.nextRelationshipId;\n    for (const [idx, mediaItem] of masterMediaData.entries()) {\n      masterRels.addRelationship(\n        masterImageOffset + idx,\n        RELATIONSHIP_TYPES.image,\n        `../media/${mediaItem.fileName}`,\n      );\n    }\n    let masterXml = replaceImagePlaceholders(master, masterMediaData, masterImageOffset);\n    // Linked image sources on master shapes get the same External wiring.\n    const masterImgLinkKeys = collectPlaceholderKeys(masterXml, \"img-link:\");\n    if (masterImgLinkKeys.length > 0) {\n      const masterImgLinkSet = new Set(masterImgLinkKeys);\n      const masterImgLinks = ctx.imageLinks.filter((l) => masterImgLinkSet.has(l.key));\n      const imgLinkOffset = masterRels.nextRelationshipId;\n      masterXml = replaceImageLinkPlaceholders(masterXml, masterImgLinks, imgLinkOffset);\n      for (const [ili, imgLink] of masterImgLinks.entries()) {\n        masterRels.addRelationship(\n          imgLinkOffset + ili,\n          RELATIONSHIP_TYPES.image,\n          imgLink.url,\n          \"External\",\n        );\n      }\n    }\n    // Hyperlinks on master shapes/text — same placeholder wiring slides get.\n    masterXml = wirePartHyperlinks(\n      masterXml,\n      ctx.hyperlinks,\n      masterRels.nextRelationshipId,\n      (id, type, target, mode) => masterRels.addRelationship(id, type, target, mode),\n      \"../slides/\",\n    );\n    // Master-level passthrough relationships (round-trip) — re-emitted as\n    // written unless the model already registered the same kind+target\n    // (ownership test: targets may be renamed and ISO-strict types differ in\n    // URI only). Media-targeted rels whose kind the model already owns mean\n    // the source rel was absorbed under a renamed target — skip on kind alone\n    // or the stale target would re-emit dangling (same rule as slides).\n    for (const rel of passthroughRelationships ?? []) {\n      if (rel.source !== `ppt/slideMasters/slideMaster${mi + 1}.xml`) continue;\n      const kind = rel.relationshipType.split(\"/\").pop()!;\n      if (MEDIA_REL_KINDS.has(kind) && masterRels.hasRelationshipKind(kind)) continue;\n      masterRels.claimSourceRel(rel);\n    }\n\n    masters.push({\n      name,\n      index: mi,\n      master: masterXml,\n      theme,\n      themeIndex,\n      layouts,\n      masterRels,\n      layoutRels,\n    });\n  }\n\n  return masters;\n}\n\nfunction findLayoutForSlide(\n  masters: MasterInfo[],\n  slides: SlideOptions[],\n  slideIndex: number,\n): LayoutInfo {\n  // slideIndex is caller-bounded by slides.length; masters is built by buildMasterMap\n  // with non-empty layouts — these indexed accesses are contract narrows, not runtime checks.\n  const opts = slides[slideIndex]!;\n  const mi =\n    opts.master !== undefined\n      ? Math.max(\n          0,\n          masters.findIndex((m) => m.name === opts.master),\n        )\n      : 0;\n  const master = masters[mi]!;\n  const layoutKey = opts.layout ?? \"blank\";\n  const li = master.layouts.find((l) => l.key === layoutKey);\n  return li ?? master.layouts[0]!;\n}\n\nexport function buildSlideRels(masters: MasterInfo[], slides: SlideOptions[]): Relationships[] {\n  const rels: Relationships[] = [];\n  for (let i = 0; i < slides.length; i++) {\n    const layout = findLayoutForSlide(masters, slides, i);\n    rels.push(\n      buildRels([\n        {\n          id: 1,\n          type: RELATIONSHIP_TYPES.slideLayout,\n          target: `../slideLayouts/slideLayout${layout.index + 1}.xml`,\n        },\n      ]),\n    );\n  }\n  return rels;\n}\n\nexport function initPresRels(masters: MasterInfo[], slideCount: number): Relationships {\n  // Only structure-owned slots are pre-allocated here: slideMaster + slide rels.\n  // presProps/viewProps/theme/tableStyles are added at the end of the\n  // compiler pass after passthrough id pre-claim, so they slot in *after* the\n  // source ids (notesMaster, handoutMaster, …) and the source ordering of\n  // presentation.xml.rels survives round-trip.\n  const rels = new Relationships();\n  for (let mi = 0; mi < masters.length; mi++) {\n    rels.addRelationship(\n      mi + 1,\n      RELATIONSHIP_TYPES.slideMaster,\n      `slideMasters/slideMaster${mi + 1}.xml`,\n    );\n  }\n  for (let i = 0; i < slideCount; i++) {\n    rels.addRelationship(\n      masters.length + i + 1,\n      RELATIONSHIP_TYPES.slide,\n      `slides/slide${i + 1}.xml`,\n    );\n  }\n  return rels;\n}\n\nexport function resolveSlideSize(size?: SlideSize): { width: number; height: number } {\n  if (!size || size === \"16:9\") return { width: 12192000, height: 6858000 };\n  if (size === \"4:3\") return { width: 9144000, height: 6858000 };\n  return { width: convertToEmu(size.width), height: convertToEmu(size.height) };\n}\n\nexport function deriveInitials(name: string): string {\n  const parts = name.trim().split(/\\s+/);\n  if (parts.length < 2) return name.slice(0, 2).toUpperCase();\n  const first = parts[0];\n  const last = parts[parts.length - 1];\n  if (!first || !last) return name.slice(0, 2).toUpperCase();\n  return (first.charAt(0) + last.charAt(0)).toUpperCase();\n}\n\n/** Map the slide-master parts and their layouts. Layout media/hyperlink\n * batches register their kinds before the layout's captured rels are claimed\n * (see buildMasterMap for the matching master-side reservation). */\nexport function mapMasterAndLayoutParts(\n  mapping: XmlifyedFileMapping,\n  masters: MasterInfo[],\n  descCtx: PptxWriteContext,\n  passthroughRelationships: PresentationOptions[\"passthroughRelationships\"],\n): void {\n  const media = descCtx.mediaCollection;\n  const masterRels = masters.map((m) => m.masterRels);\n  const allLayouts = masters.flatMap((m) => m.layouts);\n  const allLayoutRels = masters.flatMap((m) => m.layoutRels);\n\n  // Slide Masters\n  for (const [mi, masterInfo] of masters.entries()) {\n    mapping[`SlideMaster${mi}`] = {\n      data: XML_DECL + masterInfo.master,\n      path: `ppt/slideMasters/slideMaster${mi + 1}.xml`,\n    };\n    mapping[`SlideMasterRels${mi}`] = {\n      data: XML_DECL + masterRels[mi]!.serialize(),\n      path: `ppt/slideMasters/_rels/slideMaster${mi + 1}.xml.rels`,\n    };\n  }\n\n  // Slide Layouts\n  for (const [li, layoutInfo] of allLayouts.entries()) {\n    const layoutXml = slideLayoutDesc.stringify(layoutInfo.def, descCtx) ?? \"\";\n    // Media referenced by layout shapes gets the same image-relationship\n    // wiring slides use (layout pictures otherwise lose their rel).\n    const layoutRels = allLayoutRels[li]!;\n    const layoutMediaData = getReferencedMedia(layoutXml, media.array);\n    // Reserve captured ids whose rels a claim will re-emit before the media\n    // batch below snapshots nextRelationshipId. Absorbed kinds (the\n    // slideMaster rel, a present themeOverride, images the media batch\n    // re-registers) are skipped — reserving them would only open holes.\n    reserveClaimedSourceRids(\n      layoutRels,\n      `ppt/slideLayouts/slideLayout${li + 1}.xml`,\n      passthroughRelationships,\n      new Set([\n        \"slideMaster\",\n        ...(layoutInfo.themeOverride ? [\"themeOverride\"] : []),\n        ...(layoutMediaData.length > 0 ? [\"image\"] : []),\n      ]),\n    );\n    const layoutImageOffset = layoutRels.nextRelationshipId;\n    for (const [idx, mediaItem] of layoutMediaData.entries()) {\n      layoutRels.addRelationship(\n        layoutImageOffset + idx,\n        RELATIONSHIP_TYPES.image,\n        `../media/${mediaItem.fileName}`,\n      );\n    }\n    let replacedLayoutXml = replaceImagePlaceholders(layoutXml, layoutMediaData, layoutImageOffset);\n    // Linked image sources on layout shapes get the same External wiring.\n    const layoutImgLinkKeys = collectPlaceholderKeys(replacedLayoutXml, \"img-link:\");\n    if (layoutImgLinkKeys.length > 0) {\n      const layoutImgLinkSet = new Set(layoutImgLinkKeys);\n      const layoutImgLinks = descCtx.imageLinks.filter((l) => layoutImgLinkSet.has(l.key));\n      const imgLinkOffset = layoutRels.nextRelationshipId;\n      replacedLayoutXml = replaceImageLinkPlaceholders(\n        replacedLayoutXml,\n        layoutImgLinks,\n        imgLinkOffset,\n      );\n      for (const [ili, imgLink] of layoutImgLinks.entries()) {\n        layoutRels.addRelationship(\n          imgLinkOffset + ili,\n          RELATIONSHIP_TYPES.image,\n          imgLink.url,\n          \"External\",\n        );\n      }\n    }\n    // Linked OLE objects on layout shapes get the same External wiring.\n    const layoutOleLinkKeys = collectPlaceholderKeys(replacedLayoutXml, \"ole-link:\");\n    if (layoutOleLinkKeys.length > 0) {\n      const layoutOleLinkSet = new Set(layoutOleLinkKeys);\n      const layoutOleLinks = descCtx.oleLinks.filter((l) => layoutOleLinkSet.has(l.key));\n      const oleLinkOffset = layoutRels.nextRelationshipId;\n      replacedLayoutXml = replaceOleLinkPlaceholders(\n        replacedLayoutXml,\n        layoutOleLinks,\n        oleLinkOffset,\n      );\n      for (const [oli, oleLink] of layoutOleLinks.entries()) {\n        layoutRels.addRelationship(\n          oleLinkOffset + oli,\n          RELATIONSHIP_TYPES.oleObject,\n          oleLink.url,\n          \"External\",\n        );\n      }\n    }\n    // Hyperlinks on layout shapes/text — same placeholder wiring slides get.\n    replacedLayoutXml = wirePartHyperlinks(\n      replacedLayoutXml,\n      descCtx.hyperlinks,\n      layoutRels.nextRelationshipId,\n      (id, type, target, mode) => layoutRels.addRelationship(id, type, target, mode),\n      \"../slides/\",\n    );\n    // Layout-level passthrough relationships (round-trip) — appended after\n    // every model registration so the kind ownership test sees them all.\n    // claimSourceRel keeps the source ids when free (verbatim layout islands\n    // reference them).\n    for (const rel of passthroughRelationships ?? []) {\n      if (rel.source !== `ppt/slideLayouts/slideLayout${li + 1}.xml`) continue;\n      if (layoutRels.hasRelationshipKind(rel.relationshipType.split(\"/\").pop()!)) continue;\n      layoutRels.claimSourceRel(rel);\n    }\n    mapping[`SlideLayout${li}`] = {\n      data: XML_DECL + replacedLayoutXml,\n      path: `ppt/slideLayouts/slideLayout${li + 1}.xml`,\n    };\n    mapping[`SlideLayoutRels${li}`] = {\n      data: XML_DECL + layoutRels.serialize(),\n      path: `ppt/slideLayouts/_rels/slideLayout${li + 1}.xml.rels`,\n    };\n    if (layoutInfo.themeOverride) {\n      mapping[`SlideLayoutThemeOverride${li}`] = {\n        data: XML_DECL + layoutInfo.themeOverride,\n        path: `ppt/theme/themeOverride${li + 1}.xml`,\n      };\n    }\n  }\n}\n\n/** Map the notesMaster and handoutMaster parts. The presentation's captured\n * rel ids are pre-claimed first so the structured notesMaster/handoutMaster\n * additions slot in after them (preserving source rId ordering);\n * claimSourceRel skips entries the model already owns. */\nexport function mapNotesAndHandoutMasters(\n  mapping: XmlifyedFileMapping,\n  presRels: Relationships,\n  presOptions: PresentationPartOptions,\n  options: PresentationOptions,\n  slides: readonly SlideOptions[],\n  descCtx: PptxWriteContext,\n  themesCount: number,\n): void {\n  for (const rel of options.passthroughRelationships ?? []) {\n    if (rel.source !== \"ppt/presentation.xml\") continue;\n    presRels.claimSourceRel(rel);\n  }\n  // Notes Master — emitted when notes slides exist or the source carried one.\n  const includeNotesMasterPart =\n    slides.some((s) => Boolean(s.notes)) || options.notesMasterOptions !== undefined;\n  if (includeNotesMasterPart) {\n    let notesMasterRId: number;\n    if (presRels.hasRelationshipKind(\"notesMaster\")) {\n      // Already pre-claimed by the source passthrough rel (round-trip).\n      notesMasterRId = presRels.idByKind(\"notesMaster\")!;\n    } else {\n      notesMasterRId = presRels.add(\n        RELATIONSHIP_TYPES.notesMaster,\n        \"notesMasters/notesMaster1.xml\",\n      );\n    }\n    presOptions.notesMasterRId = notesMasterRId;\n    mapMasterLikePart(\n      mapping,\n      descCtx,\n      \"NotesMaster\",\n      \"notesMasters/notesMaster1\",\n      notesMasterDesc.stringify(options.notesMasterOptions ?? {}, descCtx) ?? \"\",\n      createThemeXml(options.notesMasterOptions?.theme, descCtx),\n      themesCount + 1,\n    );\n  }\n\n  // Handout Master\n  if (options.includeHandoutMaster ?? false) {\n    let handoutMasterRId: number;\n    if (presRels.hasRelationshipKind(\"handoutMaster\")) {\n      handoutMasterRId = presRels.idByKind(\"handoutMaster\")!;\n    } else {\n      handoutMasterRId = presRels.add(\n        RELATIONSHIP_TYPES.handoutMaster,\n        \"handoutMasters/handoutMaster1.xml\",\n      );\n    }\n    presOptions.handoutMasterRId = handoutMasterRId;\n    mapMasterLikePart(\n      mapping,\n      descCtx,\n      \"HandoutMaster\",\n      \"handoutMasters/handoutMaster1\",\n      handoutMasterDesc.stringify({ options: options.handoutMasterOptions }, descCtx) ?? \"\",\n      createThemeXml(options.handoutMasterOptions?.theme, descCtx),\n      themesCount + (includeNotesMasterPart ? 2 : 1),\n    );\n  }\n}\n\n/** Wire one master-like part (notesMaster/handoutMaster): theme part, its rel,\n * slide-style media image wiring, hyperlink placeholders, and the part +\n * rels mapping entries. */\nfunction mapMasterLikePart(\n  mapping: XmlifyedFileMapping,\n  descCtx: PptxWriteContext,\n  key: string,\n  partDir: string,\n  xml: string,\n  themeXml: string,\n  themeIndex: number,\n): void {\n  mapping[`${key}Theme`] = {\n    data: XML_DECL + themeXml,\n    path: `ppt/theme/theme${themeIndex}.xml`,\n  };\n  const rels = new Relationships();\n  rels.addRelationship(1, RELATIONSHIP_TYPES.theme, `../theme/theme${themeIndex}.xml`);\n  // Media referenced by master shapes gets slide-style image wiring.\n  const mediaData = getReferencedMedia(xml, descCtx.mediaCollection.array);\n  const imageOffset = rels.nextRelationshipId;\n  for (const [idx, mediaItem] of mediaData.entries()) {\n    rels.addRelationship(\n      imageOffset + idx,\n      RELATIONSHIP_TYPES.image,\n      `../media/${mediaItem.fileName}`,\n    );\n  }\n  let wiredXml = replaceImagePlaceholders(xml, mediaData, imageOffset);\n  // Hyperlinks on master shapes/text — same placeholder wiring slides get.\n  wiredXml = wirePartHyperlinks(\n    wiredXml,\n    descCtx.hyperlinks,\n    rels.nextRelationshipId,\n    (id, type, target, mode) => rels.addRelationship(id, type, target, mode),\n    \"../slides/\",\n  );\n  mapping[key] = {\n    data: XML_DECL + wiredXml,\n    path: `ppt/${partDir}.xml`,\n  };\n  const [partDirName, partBase] = partDir.split(\"/\");\n  mapping[`${key}Relationships`] = {\n    data: XML_DECL + rels.serialize(),\n    path: `ppt/${partDirName}/_rels/${partBase}.xml.rels`,\n  };\n}\n","/**\n * Slide compile phase: slide serialization (`stringifySlide`), comment data,\n * and the per-slide mapping/relationship batches (media, charts, SmartArt,\n * hyperlinks, OLE, notes, sync, comments).\n *\n * @module\n */\n\nimport {\n  RELATIONSHIP_TYPES,\n  Relationships,\n  addSmartArtRelationships,\n  collectPlaceholderKeys,\n  convertToEmu,\n  getAudioRefs,\n  getMediaRefs,\n  getOleRefs,\n  getReferencedMedia,\n  getVideoRefs,\n  hasPlaceholders,\n  replaceAudioPlaceholders,\n  replaceChartPlaceholders,\n  replaceImageLinkPlaceholders,\n  replaceImagePlaceholders,\n  replaceMediaPlaceholders,\n  replaceOleLinkPlaceholders,\n  replaceOlePlaceholders,\n  replaceSmartArtPlaceholders,\n  replaceVideoPlaceholders,\n} from \"@office-open/core\";\nimport { ChartCollection } from \"@office-open/core/chart\";\nimport { SmartArtCollection } from \"@office-open/core/smartart\";\nimport type { AuthorEntry, CommentEntry } from \"@parts/comment\";\nimport { stringifyControls, stringifyCustDataLst } from \"@parts/slide/c-sld\";\nimport type { SlideSyncOptions } from \"@parts/slide/slide-sync-properties\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\nimport type { PresentationOptions, SlideOptions } from \"@shared/file\";\nimport { buildHeaderFooterShapes } from \"@shared/header-footer\";\n\nimport { PptxWriteContext } from \"../context\";\nimport { timingDesc } from \"../parts/descriptors/animation\";\nimport { backgroundDesc } from \"../parts/descriptors/background\";\nimport { stringifyChild } from \"../parts/descriptors/bridge\";\nimport { colorMappingOverrideDesc } from \"../parts/descriptors/color-map-override\";\nimport type { NotesSlideOptions } from \"../parts/descriptors/notes-slide\";\nimport { stringifyTransition } from \"../parts/descriptors/slide\";\nimport { deriveInitials } from \"./masters\";\nimport {\n  MEDIA_REL_KINDS,\n  XML_DECL,\n  type XmlifyedFileMapping,\n  promoteLayoutToSourceId,\n  reserveClaimedSourceRids,\n  wirePartHyperlinks,\n} from \"./shared\";\n\n/**\n * Serialize a single slide to its `<p:sld>` XML (no XML declaration — matches\n * the generated slide parts). Exposed so patch can append/replace slides by\n * reusing the full slide vocabulary without re-running the compiler.\n */\nexport function stringifySlide(slideOpts: SlideOptions, ctx: PptxWriteContext): string {\n  const parts: string[] = [];\n  ctx.beginShapeScope();\n\n  const sldAttrs: string[] = [];\n  if (slideOpts.showMasterShapes === false) sldAttrs.push(' showMasterSp=\"0\"');\n  if (slideOpts.showMasterPlaceholderAnimations === false) sldAttrs.push(' showMasterPhAnim=\"0\"');\n  if (slideOpts.hidden) sldAttrs.push(' show=\"0\"');\n  parts.push(\n    `<p:sld xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"${sldAttrs.join(\"\")}>`,\n  );\n\n  parts.push(\"<p:cSld>\");\n\n  if (slideOpts.background) {\n    parts.push(backgroundDesc.stringify(slideOpts.background, ctx) ?? \"\");\n  }\n\n  parts.push(\"<p:spTree>\");\n  parts.push(SP_TREE_HEADER);\n\n  if (slideOpts.children) {\n    for (const child of slideOpts.children) {\n      const xml = stringifyChild(child, ctx);\n      if (xml) parts.push(xml);\n    }\n  }\n\n  // Per-slide header/footer: instantiate the dt/ftr/sldNum placeholder shapes\n  // after the children (spTree tail, ids continue the child sequence). A type\n  // the children already carry — a round-tripped placeholder shape — is left\n  // untouched so re-serialization never duplicates it.\n  if (slideOpts.headerFooter) {\n    const present = new Set(\n      (slideOpts.children ?? []).flatMap((c) =>\n        \"shape\" in c && c.shape?.placeholder ? [c.shape.placeholder] : [],\n      ),\n    );\n    for (const shape of buildHeaderFooterShapes(slideOpts.headerFooter)) {\n      if (present.has(shape.placeholder!)) continue;\n      const xml = stringifyChild({ shape }, ctx);\n      if (xml) parts.push(xml);\n    }\n  }\n\n  parts.push(\"</p:spTree>\");\n\n  parts.push(stringifyCustDataLst(slideOpts.customerData));\n  parts.push(stringifyControls(slideOpts.controls));\n\n  // cSld-tail extLst (p14:creationId's home) — verbatim, before the cSld close\n  // and distinct from the root-level extLst emitted after timing.\n  if (slideOpts.cSldExt) {\n    parts.push(`<p:extLst>${slideOpts.cSldExt}</p:extLst>`);\n  }\n\n  parts.push(\"</p:cSld>\");\n  // Optional per CT_Slide — undefined (a source without one) omits it.\n  parts.push(colorMappingOverrideDesc.stringify(slideOpts.colorMappingOverride, ctx) ?? \"\");\n\n  if (slideOpts.transition) {\n    parts.push(stringifyTransition(slideOpts.transition, ctx));\n  }\n\n  if (slideOpts.animations && slideOpts.animations.length > 0) {\n    parts.push(timingDesc.stringify(slideOpts.animations, ctx) ?? \"\");\n  }\n\n  // p:extLst — verbatim round-trip (last child per CT_Slide sequence)\n  if (slideOpts.ext) {\n    parts.push(`<p:extLst>${slideOpts.ext}</p:extLst>`);\n  }\n\n  parts.push(\"</p:sld>\");\n  return parts.join(\"\");\n}\n\nexport function buildCommentData(\n  slides: readonly SlideOptions[],\n  existingAuthors: AuthorEntry[] = [],\n): {\n  authors: AuthorEntry[] | undefined;\n  perSlide: (CommentEntry[] | undefined)[];\n} {\n  const authorMap = new Map<\n    string,\n    { id: number; name: string; initials: string; clrIdx: number; commentCount: number }\n  >();\n  let nextAuthorId = 0;\n  // Seed from existing authors so appended comments continue author ids and the\n  // per-author idx counter (commentCount resumes at lastIdx).\n  for (const a of existingAuthors) {\n    authorMap.set(a.name, {\n      id: a.id,\n      name: a.name,\n      initials: a.initials,\n      clrIdx: a.clrIdx,\n      commentCount: a.lastIdx,\n    });\n    if (a.id >= nextAuthorId) nextAuthorId = a.id + 1;\n  }\n\n  const perSlide: (CommentEntry[] | undefined)[] = Array.from({ length: slides.length });\n\n  for (const [i, slide] of slides.entries()) {\n    const slideComments = slide.comments;\n    if (!slideComments || slideComments.length === 0) continue;\n\n    const commentEntries: CommentEntry[] = [];\n\n    for (const c of slideComments) {\n      let author = authorMap.get(c.author);\n      if (!author) {\n        const id = nextAuthorId++;\n        author = {\n          id,\n          name: c.author,\n          initials: c.initials || deriveInitials(c.author),\n          clrIdx: id,\n          commentCount: 0,\n        };\n        authorMap.set(c.author, author);\n      }\n      author.commentCount++;\n\n      commentEntries.push({\n        authorId: author.id,\n        idx: author.commentCount,\n        date: c.date,\n        x: convertToEmu(c.x),\n        y: convertToEmu(c.y),\n        text: c.text,\n        modified: c.modified,\n      });\n    }\n\n    perSlide[i] = commentEntries;\n  }\n\n  const authors =\n    authorMap.size > 0\n      ? Array.from(authorMap.values(), (a) => ({\n          id: a.id,\n          name: a.name,\n          initials: a.initials,\n          clrIdx: a.clrIdx,\n          lastIdx: a.commentCount,\n        }))\n      : undefined;\n\n  return { authors, perSlide };\n}\n\nfunction getChartGlobalIndex(\n  key: string,\n  legacyCharts: { key: string }[],\n  descCharts: { key: string }[],\n): number {\n  const legacyIdx = legacyCharts.findIndex((c) => c.key === key);\n  if (legacyIdx >= 0) return legacyIdx;\n  return legacyCharts.length + descCharts.findIndex((c) => c.key === key);\n}\n\nfunction computeSmartArtGlobalStart(\n  firstKey: string,\n  legacySmartArts: { key: string }[],\n  descSmartArts: { key: string }[],\n): number {\n  const legacyIdx = legacySmartArts.findIndex((s) => s.key === firstKey);\n  if (legacyIdx >= 0) return legacyIdx;\n  return legacySmartArts.length + descSmartArts.findIndex((s) => s.key === firstKey);\n}\n\n/** Parts the slide loop emits besides the slide XML itself, needed by the\n * package tail (notes slides, sync properties, comment authors/comments). */\nexport interface SlideCompileArtifacts {\n  notesOptions: NotesSlideOptions[];\n  notesSlideIndexMap: Map<number, number>;\n  slideSyncOptionsList: SlideSyncOptions[];\n  slideSyncIndexMap: Map<number, number>;\n  commentAuthors: AuthorEntry[] | undefined;\n  slideComments: (CommentEntry[] | undefined)[];\n}\n\n/** Run the per-slide compile: map every slide's XML and relationships and\n * collect the per-slide attachments the package tail emits later. */\nexport function compileSlideParts(\n  mapping: XmlifyedFileMapping,\n  slides: readonly SlideOptions[],\n  slideRels: readonly Relationships[],\n  descCtx: PptxWriteContext,\n  charts: ChartCollection,\n  smartArts: SmartArtCollection,\n  passthroughRelationships: PresentationOptions[\"passthroughRelationships\"],\n): SlideCompileArtifacts {\n  const media = descCtx.mediaCollection;\n\n  const notesOptions: NotesSlideOptions[] = [];\n  const notesSlideIndexMap = new Map<number, number>();\n  let notesIdx = 0;\n  for (const [i, slide] of slides.entries()) {\n    if (slide.notes) {\n      notesOptions.push(typeof slide.notes === \"string\" ? { text: slide.notes } : slide.notes);\n      notesSlideIndexMap.set(i, notesIdx++);\n    }\n  }\n\n  const slideSyncOptionsList: SlideSyncOptions[] = [];\n  const slideSyncIndexMap = new Map<number, number>();\n  let syncIdx = 0;\n  for (const [i, slide] of slides.entries()) {\n    if (slide.slideSync) {\n      slideSyncOptionsList.push(slide.slideSync);\n      slideSyncIndexMap.set(i, syncIdx++);\n    }\n  }\n\n  const { authors: commentAuthorEntries, perSlide: slideCommentEntries } = buildCommentData(slides);\n\n  // Group passthrough rels by source part once — the per-slide loop below\n  // looks its own slice up instead of re-filtering the full list each time.\n  const slidePassthroughBySource = new Map<\n    string,\n    PresentationOptions[\"passthroughRelationships\"]\n  >();\n  for (const rel of passthroughRelationships ?? []) {\n    const group = slidePassthroughBySource.get(rel.source);\n    if (group) group.push(rel);\n    else slidePassthroughBySource.set(rel.source, [rel]);\n  }\n  for (const [i, slide] of slides.entries()) {\n    const slideXml = stringifySlide(slide, descCtx);\n\n    const slideMediaData = getReferencedMedia(slideXml, media.array);\n    const currentSlideRels = slideRels[i];\n    if (!currentSlideRels) continue; // slideRels is built one-per-slide in lockstep with slides\n    absorbSlideSourceKinds(\n      currentSlideRels,\n      slide,\n      slideXml,\n      slideMediaData,\n      `ppt/slides/slide${i + 1}.xml`,\n      passthroughRelationships,\n      descCtx,\n    );\n    // Promote the slide layout rel to its source id up front — the model's\n    // layout registration is rId1 by construction and the source id is free\n    // below it, so the rename never collides.\n    promoteLayoutToSourceId(\n      currentSlideRels,\n      slidePassthroughBySource.get(`ppt/slides/slide${i + 1}.xml`),\n    );\n    const slideImageOffset = currentSlideRels.nextRelationshipId;\n    for (const [idx, mediaItem] of slideMediaData.entries()) {\n      currentSlideRels.addRelationship(\n        slideImageOffset + idx,\n        RELATIONSHIP_TYPES.image,\n        `../media/${mediaItem.fileName}`,\n      );\n    }\n\n    const replacedSlideXml = wireSlidePlaceholderBatches(\n      replaceImagePlaceholders(slideXml, slideMediaData, slideImageOffset),\n      currentSlideRels,\n      descCtx,\n      charts,\n      smartArts,\n    );\n\n    mapping[`Slide${i}`] = {\n      data: replacedSlideXml,\n      path: `ppt/slides/slide${i + 1}.xml`,\n    };\n\n    if (\n      slideCommentEntries[i] &&\n      !currentSlideRels.hasRelationshipKind(\"comments\") &&\n      !currentSlideRels.hasRelationship(\n        RELATIONSHIP_TYPES.comments,\n        `../comments/comment${i + 1}.xml`,\n      )\n    ) {\n      currentSlideRels.add(RELATIONSHIP_TYPES.comments, `../comments/comment${i + 1}.xml`);\n    }\n\n    const notesSlideIndex = notesSlideIndexMap.get(i);\n    if (\n      notesSlideIndex !== undefined &&\n      !currentSlideRels.hasRelationshipKind(\"notesSlide\") &&\n      !currentSlideRels.hasRelationship(\n        RELATIONSHIP_TYPES.notesSlide,\n        `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`,\n      )\n    ) {\n      currentSlideRels.add(\n        RELATIONSHIP_TYPES.notesSlide,\n        `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`,\n      );\n    }\n\n    const slideSyncIndex = slideSyncIndexMap.get(i);\n    if (slideSyncIndex !== undefined) {\n      currentSlideRels.add(\n        RELATIONSHIP_TYPES.slideSyncProperties,\n        `../slideSyncPr/slideSyncPr${slideSyncIndex + 1}.xml`,\n      );\n    }\n\n    // Slide-level passthrough relationships, appended after every model\n    // registration so the ownership test sees them all. claimSourceRel keeps\n    // the source id when its slot is free — verbatim slide islands reference\n    // the source rIds and renumbering would dangle them. Media-targeted rels\n    // whose kind the model already owns mean the source rel was absorbed\n    // under a renamed target — skip on kind alone or the stale target would\n    // re-emit dangling.\n    for (const rel of passthroughRelationships ?? []) {\n      if (rel.source !== `ppt/slides/slide${i + 1}.xml`) continue;\n      const kind = rel.relationshipType.split(\"/\").pop()!;\n      if (MEDIA_REL_KINDS.has(kind) && currentSlideRels.hasRelationshipKind(kind)) continue;\n      currentSlideRels.claimSourceRel(rel);\n    }\n\n    mapping[`SlideRelationships${i}`] = {\n      data: XML_DECL + currentSlideRels.serialize(),\n      path: `ppt/slides/_rels/slide${i + 1}.xml.rels`,\n    };\n  }\n\n  return {\n    notesOptions,\n    notesSlideIndexMap,\n    slideSyncOptionsList,\n    slideSyncIndexMap,\n    commentAuthors: commentAuthorEntries,\n    slideComments: slideCommentEntries,\n  };\n}\n\n/** Register every placeholder batch a slide carries (charts, SmartArt,\n * hyperlinks, linked images/OLE, media, embeddings) onto its relationships\n * and return the XML with placeholders resolved. */\nfunction wireSlidePlaceholderBatches(\n  slideXml: string,\n  rels: Relationships,\n  descCtx: PptxWriteContext,\n  charts: ChartCollection,\n  smartArts: SmartArtCollection,\n): string {\n  let replacedSlideXml = slideXml;\n  const media = descCtx.mediaCollection;\n  if (!hasPlaceholders(replacedSlideXml)) return replacedSlideXml;\n\n  // Chart\n  const slideChartKeys = collectPlaceholderKeys(replacedSlideXml, \"chart:\");\n  if (slideChartKeys.length > 0) {\n    const slideChartOffset = rels.nextRelationshipId;\n    const slideChartKeySet = new Set(slideChartKeys);\n    const xmlCompCharts = charts.array.filter((c) => slideChartKeySet.has(c.key));\n    const descCharts = descCtx.charts.filter((c) => slideChartKeySet.has(c.key));\n    const allChartKeys = [...xmlCompCharts.map((c) => c.key), ...descCharts.map((c) => c.key)];\n    replacedSlideXml = replaceChartPlaceholders(replacedSlideXml, allChartKeys, slideChartOffset);\n    for (const [ci, chartKey] of allChartKeys.entries()) {\n      rels.addRelationship(\n        slideChartOffset + ci,\n        RELATIONSHIP_TYPES.chart,\n        `../charts/chart${getChartGlobalIndex(chartKey, charts.array, descCtx.charts) + 1}.xml`,\n      );\n    }\n  }\n\n  // SmartArt\n  const slideSmartArtKeys = collectPlaceholderKeys(replacedSlideXml, \"smartart:\");\n  if (slideSmartArtKeys.length > 0) {\n    const slideSmartArtKeySet = new Set(slideSmartArtKeys);\n    const xmlCompSmartArts = smartArts.array.filter((s) => slideSmartArtKeySet.has(s.key));\n    const descSmartArts = descCtx.smartArts.filter((s) => slideSmartArtKeySet.has(s.key));\n    const allSaKeys = [...xmlCompSmartArts.map((s) => s.key), ...descSmartArts.map((s) => s.key)];\n    const saOffset = rels.nextRelationshipId;\n    replacedSlideXml = replaceSmartArtPlaceholders(replacedSlideXml, allSaKeys, saOffset);\n    const firstSaKey = allSaKeys[0];\n    if (firstSaKey !== undefined) {\n      const saGlobalStart = computeSmartArtGlobalStart(\n        firstSaKey,\n        smartArts.array,\n        descCtx.smartArts,\n      );\n      addSmartArtRelationships(\n        allSaKeys,\n        (id, type, target) => {\n          rels.addRelationship(id, type, target);\n        },\n        saOffset,\n        saGlobalStart,\n        {\n          pathPrefix: \"../\",\n          styleRelType: RELATIONSHIP_TYPES.diagramQuickStyle,\n        },\n      );\n    }\n  }\n\n  // Hyperlinks — slides reference each other directly (no ../slides/).\n  replacedSlideXml = wirePartHyperlinks(\n    replacedSlideXml,\n    descCtx.hyperlinks,\n    rels.nextRelationshipId,\n    (id, type, target, mode) => rels.addRelationship(id, type, target, mode),\n    \"\",\n    (target) => {\n      const rid = rels.idOf(\"slide\", target);\n      return rid === undefined ? undefined : Number(rid.slice(3));\n    },\n  );\n\n  // Linked image sources (a:blip @r:link) — one External image relationship\n  // per referenced URL.\n  const slideImgLinkKeys = collectPlaceholderKeys(replacedSlideXml, \"img-link:\");\n  if (slideImgLinkKeys.length > 0) {\n    const slideImgLinkSet = new Set(slideImgLinkKeys);\n    const slideImgLinks = descCtx.imageLinks.filter((l) => slideImgLinkSet.has(l.key));\n    const imgLinkOffset = rels.nextRelationshipId;\n    replacedSlideXml = replaceImageLinkPlaceholders(replacedSlideXml, slideImgLinks, imgLinkOffset);\n    for (const [li, imgLink] of slideImgLinks.entries()) {\n      rels.addRelationship(imgLinkOffset + li, RELATIONSHIP_TYPES.image, imgLink.url, \"External\");\n    }\n  }\n\n  // Linked OLE objects (p:oleObj @r:id with p:link) — one External\n  // oleObject relationship per referenced URL.\n  const slideOleLinkKeys = collectPlaceholderKeys(replacedSlideXml, \"ole-link:\");\n  if (slideOleLinkKeys.length > 0) {\n    const slideOleLinkSet = new Set(slideOleLinkKeys);\n    const slideOleLinks = descCtx.oleLinks.filter((l) => slideOleLinkSet.has(l.key));\n    const oleLinkOffset = rels.nextRelationshipId;\n    replacedSlideXml = replaceOleLinkPlaceholders(replacedSlideXml, slideOleLinks, oleLinkOffset);\n    for (const [oli, oleLink] of slideOleLinks.entries()) {\n      rels.addRelationship(\n        oleLinkOffset + oli,\n        RELATIONSHIP_TYPES.oleObject,\n        oleLink.url,\n        \"External\",\n      );\n    }\n  }\n\n  // Media (video/audio)\n  const slideMediaRefs = getMediaRefs(replacedSlideXml, media.array);\n  const slideAudioRefs = getAudioRefs(replacedSlideXml, media.array);\n  const slideVideoRefs = getVideoRefs(replacedSlideXml, media.array);\n  if (slideMediaRefs.length > 0 || slideAudioRefs.length > 0 || slideVideoRefs.length > 0) {\n    const mediaOffset = rels.nextRelationshipId;\n    const audioOffset = mediaOffset + slideMediaRefs.length;\n    const videoOffset = audioOffset + slideAudioRefs.length;\n    replacedSlideXml = replaceMediaPlaceholders(replacedSlideXml, slideMediaRefs, mediaOffset);\n    replacedSlideXml = replaceAudioPlaceholders(replacedSlideXml, slideAudioRefs, audioOffset);\n    replacedSlideXml = replaceVideoPlaceholders(replacedSlideXml, slideVideoRefs, videoOffset);\n    for (const [mi, mediaRef] of slideMediaRefs.entries()) {\n      rels.addRelationship(\n        mediaOffset + mi,\n        RELATIONSHIP_TYPES.mediaMs,\n        `../media/${mediaRef.fileName}`,\n      );\n    }\n    for (const [ai, audioRef] of slideAudioRefs.entries()) {\n      rels.addRelationship(\n        audioOffset + ai,\n        RELATIONSHIP_TYPES.audio,\n        `../media/${audioRef.fileName}`,\n      );\n    }\n    for (const [vi, videoRef] of slideVideoRefs.entries()) {\n      rels.addRelationship(\n        videoOffset + vi,\n        RELATIONSHIP_TYPES.video,\n        `../media/${videoRef.fileName}`,\n      );\n    }\n  }\n\n  // OLE embeddings\n  const slideOleRefs = getOleRefs(replacedSlideXml, descCtx.embeddings);\n  if (slideOleRefs.length > 0) {\n    const oleOffset = rels.nextRelationshipId;\n    replacedSlideXml = replaceOlePlaceholders(replacedSlideXml, slideOleRefs, oleOffset);\n    for (const [oi, oleRef] of slideOleRefs.entries()) {\n      rels.addRelationship(\n        oleOffset + oi,\n        RELATIONSHIP_TYPES.oleObject,\n        `../embeddings/${oleRef.fileName}`,\n      );\n    }\n  }\n\n  return replacedSlideXml;\n}\n\n/** Reserve the slide's captured ids whose rels a claim will re-emit — the\n * media/chart/… batches snapshot nextRelationshipId, and a batch landing on\n * such an id would force the claim loop at the end to renumber a verbatim\n * reference into a dangle. Kinds the batches register (layout, images,\n * charts, media, notes, …) are absorbed by the model — the claim skips them\n * as owned, so reserving their ids would only open holes the round-trip then\n * reports as drift. */\nfunction absorbSlideSourceKinds(\n  rels: Relationships,\n  slide: SlideOptions,\n  slideXml: string,\n  slideMediaData: readonly { fileName: string }[],\n  source: string,\n  passthroughRelationships: PresentationOptions[\"passthroughRelationships\"],\n  descCtx: PptxWriteContext,\n): void {\n  const slideAbsorbedKinds = new Set<string>([\"slideLayout\"]);\n  if (slideMediaData.length > 0 || collectPlaceholderKeys(slideXml, \"img-link:\").length > 0)\n    slideAbsorbedKinds.add(\"image\");\n  if (collectPlaceholderKeys(slideXml, \"chart:\").length > 0) slideAbsorbedKinds.add(\"chart\");\n  if (collectPlaceholderKeys(slideXml, \"smartart:\").length > 0) {\n    slideAbsorbedKinds.add(\"diagramData\");\n    slideAbsorbedKinds.add(\"diagramColors\");\n    slideAbsorbedKinds.add(\"diagramQuickStyle\");\n  }\n  const media = descCtx.mediaCollection;\n  if (getMediaRefs(slideXml, media.array).length > 0) slideAbsorbedKinds.add(\"media\");\n  if (getAudioRefs(slideXml, media.array).length > 0) slideAbsorbedKinds.add(\"audio\");\n  if (getVideoRefs(slideXml, media.array).length > 0) slideAbsorbedKinds.add(\"video\");\n  if (\n    getOleRefs(slideXml, descCtx.embeddings).length > 0 ||\n    collectPlaceholderKeys(slideXml, \"ole-link:\").length > 0\n  )\n    slideAbsorbedKinds.add(\"oleObject\");\n  if (collectPlaceholderKeys(slideXml, \"hlink:\").length > 0) slideAbsorbedKinds.add(\"hyperlink\");\n  if (slide.notes) slideAbsorbedKinds.add(\"notesSlide\");\n  if (slide.comments) slideAbsorbedKinds.add(\"comments\");\n  reserveClaimedSourceRids(rels, source, passthroughRelationships, slideAbsorbedKinds);\n}\n","/**\n * Slide (p:sld) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport { xsdOrient } from \"@office-open/core\";\nimport type { CustomDescriptor, ReadContext, WriteContext } from \"@office-open/core/descriptor\";\nimport { attr, findChild, stringify } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport { parseControls, parseCustDataLst } from \"@parts/slide/c-sld\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport type { SlideOptions } from \"@shared/file\";\nimport type { TransitionDirection, TransitionOptions } from \"@shared/transition\";\nimport { buildTransition } from \"@shared/transition\";\n\nimport { stringifySlide } from \"../../compile/slides\";\nimport type { PptxWriteContext } from \"../../context\";\nimport { timingDesc } from \"./animation\";\nimport { backgroundDesc } from \"./background\";\nimport { parseChild } from \"./bridge\";\nimport { colorMappingOverrideDesc } from \"./color-map-override\";\n\n// ── Types ──\n\n// ── Slide (p:sld) descriptor ──\n\nexport const slideDesc: CustomDescriptor<SlideOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    // Single implementation lives in compiler.stringifySlide — the descriptor\n    // used to keep a near-copy that silently dropped p:timing (animations)\n    // and emitted a p:hf that CT_Slide's content model does not allow.\n    return stringifySlide(opts, ctx as unknown as PptxWriteContext);\n  },\n\n  parse(el, _ctx) {\n    const result: Record<string, unknown> = {};\n\n    // Root attributes\n    if (el.attributes) {\n      if (el.attributes[\"showMasterSp\"] !== undefined)\n        result.showMasterShapes = parseOnOff(el.attributes[\"showMasterSp\"]) ?? true;\n      if (el.attributes[\"showMasterPhAnim\"] !== undefined)\n        result.showMasterPlaceholderAnimations =\n          parseOnOff(el.attributes[\"showMasterPhAnim\"]) ?? true;\n      if (el.attributes[\"show\"] === \"0\") result.hidden = true;\n    }\n\n    // p:cSld\n    const cSld = findChild(el, \"p:cSld\");\n    if (cSld) {\n      // Background\n      const bg = findChild(cSld, \"p:bg\");\n      if (bg) result.background = backgroundDesc.parse(bg, _ctx);\n\n      // Shape tree\n      const spTree = findChild(cSld, \"p:spTree\");\n      if (spTree) {\n        const children: SlideChild[] = [];\n        if (spTree.elements) {\n          for (const child of spTree.elements) {\n            // Skip tree container structure\n            if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n            const parsed = parseChild(child, _ctx);\n            if (parsed !== undefined) children.push(parsed);\n          }\n        }\n        if (children.length > 0) result.children = children;\n      }\n\n      // p:hf is master/layout/notes-level (CT_Slide has no hf child) — nothing\n      // to read at slide level.\n\n      // custDataLst / controls — children of cSld per CT_CommonSlideData\n      // (its own stringify writes them there; read from the same place).\n      result.customerData = parseCustDataLst(findChild(cSld, \"p:custDataLst\"));\n      result.controls = parseControls(findChild(cSld, \"p:controls\"));\n\n      // cSld-tail extLst (p14:creationId's home) — verbatim, distinct from the\n      // root-level extLst read below (two separate XSD slots).\n      const cSldExtLst = findChild(cSld, \"p:extLst\");\n      if (cSldExtLst) {\n        const inner = stringify(cSldExtLst);\n        if (inner) result.cSldExt = inner;\n      }\n    }\n\n    // p:clrMapOvr (between cSld and transition per CT_Slide).\n    const clrMapOvr = findChild(el, \"p:clrMapOvr\");\n    if (clrMapOvr) result.colorMappingOverride = colorMappingOverrideDesc.parse(clrMapOvr, _ctx);\n\n    // p:transition — a plain child parses structured; one wrapped in a\n    // markup-compatibility block (mc:Choice p14:dur + mc:Fallback twin) is\n    // not a direct child at all, so the whole block rides verbatim.\n    const transition = findChild(el, \"p:transition\");\n    if (transition) {\n      result.transition = readTransition(transition, _ctx);\n    } else {\n      const mcBlock = (el.elements ?? []).find(\n        (c) => c.name === \"mc:AlternateContent\" && hasDescendant(c, \"p:transition\"),\n      );\n      // stringify treats its argument as a document root and serializes only\n      // its children — wrap the block to serialize the block itself.\n      if (mcBlock) result.transition = stringify({ elements: [mcBlock] });\n    }\n\n    // p:timing → animations (structured entries, or verbatim inner XML when\n    // the source tree exceeds the model)\n    const timing = findChild(el, \"p:timing\");\n    if (timing) {\n      const animations = timingDesc.parse(timing, _ctx);\n      if (!(Array.isArray(animations) && animations.length === 0)) result.animations = animations;\n    }\n\n    // extLst — verbatim inner XML for unmodeled extensions\n    const extLst = findChild(el, \"p:extLst\");\n    if (extLst) {\n      const inner = stringify(extLst);\n      if (inner) result.ext = inner;\n    }\n\n    return result as Partial<SlideOptions> as SlideOptions;\n  },\n};\n\n// ── Transition helpers ──\n\n/** True when a descendant of any depth carries the element name. */\nfunction hasDescendant(el: XmlElement, name: string): boolean {\n  for (const child of el.elements ?? []) {\n    if (child.name === name || hasDescendant(child, name)) return true;\n  }\n  return false;\n}\n\nexport function stringifyTransition(opts: TransitionOptions | string, ctx?: WriteContext): string {\n  // Verbatim markup-compatibility block (mc:Choice p14:dur + mc:Fallback).\n  if (typeof opts === \"string\") return opts;\n  // A typeless transition stays legal — buildTransition emits the bare\n  // <p:transition/> (attributes only) the CT_SlideTransition content model allows.\n  return buildTransition(opts, ctx);\n}\n\n// Reverse of DIRECTION_MAP in @shared/transition (dir attribute → semantic direction).\nconst XML_DIR_TO_DIRECTION: Record<string, TransitionDirection> = {\n  l: \"left\",\n  r: \"right\",\n  u: \"up\",\n  d: \"down\",\n  lu: \"leftUp\",\n  ru: \"rightUp\",\n  ld: \"leftDown\",\n  rd: \"rightDown\",\n  out: \"out\",\n  in: \"in\",\n};\n\n// All transitional transition element names (EG_SlideTransition). Used to\n// detect the type from the matching child and read its attributes generically,\n// so every supported transition round-trips without a per-type branch.\nconst TRANSITION_ELEMENT_TYPES = [\n  \"fade\",\n  \"push\",\n  \"wipe\",\n  \"split\",\n  \"blinds\",\n  \"checker\",\n  \"comb\",\n  \"randomBar\",\n  \"cover\",\n  \"pull\",\n  \"strips\",\n  \"wheel\",\n  \"zoom\",\n  \"circle\",\n  \"dissolve\",\n  \"diamond\",\n  \"newsflash\",\n  \"plus\",\n  \"wedge\",\n  \"random\",\n  \"cut\",\n] as const;\n\nexport function readTransition(el: XmlElement, ctx?: ReadContext): TransitionOptions {\n  const result: TransitionOptions = {};\n\n  if (el.attributes) {\n    if (el.attributes[\"spd\"] !== undefined)\n      result.speed =\n        el.attributes[\"spd\"] === \"med\" ? \"medium\" : (el.attributes[\"spd\"] as \"slow\" | \"fast\");\n    if (el.attributes[\"advClick\"] !== undefined)\n      result.advanceOnClick = parseOnOff(el.attributes[\"advClick\"]) ?? false;\n    if (el.attributes[\"advTm\"] !== undefined)\n      result.advanceAfterTime = Number(el.attributes[\"advTm\"]);\n  }\n\n  // Detect transition type from the first matching child, then read its\n  // attributes (dir/orient/spokes/thruBlk) in one pass.\n  for (const t of TRANSITION_ELEMENT_TYPES) {\n    const child = findChild(el, `p:${t}`);\n    if (!child) continue;\n    result.type = t;\n    const attrs = child.attributes ?? {};\n    const dir = attrs[\"dir\"];\n    if (dir !== undefined) {\n      const direction = XML_DIR_TO_DIRECTION[String(dir)];\n      if (direction) result.direction = direction;\n    }\n    if (attrs[\"orient\"] !== undefined)\n      result.orient = xsdOrient.from(String(attrs[\"orient\"])) as \"horizontal\" | \"vertical\";\n    if (attrs[\"spokes\"] !== undefined) result.spokes = Number(attrs[\"spokes\"]);\n    if (attrs[\"thruBlk\"] !== undefined) result.thruBlk = parseOnOff(attrs[\"thruBlk\"]) ?? false;\n    break;\n  }\n\n  // Sound action (p:sndAc: stSnd with embedded sound, or endSnd to stop previous).\n  // The audio part bytes are read back so generate re-registers the media —\n  // a bare rId would point at the wrong relationship in a fresh package.\n  const sndAc = findChild(el, \"p:sndAc\");\n  if (sndAc) {\n    const stSnd = findChild(sndAc, \"p:stSnd\");\n    if (stSnd) {\n      const snd = findChild(stSnd, \"p:snd\");\n      const rId = snd ? attr(snd, \"r:embed\") : undefined;\n      if (rId && ctx) {\n        const mediaPath = ctx.resolveRelationship(rId);\n        const raw = mediaPath ? ctx.getRaw(mediaPath) : undefined;\n        const type = mediaPath?.split(\".\").pop();\n        if (raw && (type === \"mp3\" || type === \"wav\" || type === \"wma\" || type === \"aac\")) {\n          const startSound: NonNullable<TransitionOptions[\"startSound\"]> = {\n            data: raw,\n            type,\n          };\n          const name = attr(snd, \"name\");\n          if (name) startSound.name = name;\n          if (parseOnOff(attr(stSnd, \"loop\"))) startSound.loop = true;\n          result.startSound = startSound;\n        }\n      }\n    } else if (findChild(sndAc, \"p:endSnd\")) {\n      result.stopPreviousSound = true;\n    }\n  }\n\n  return result;\n}\n","/**\n * Slide Layout (p:sldLayout) descriptor for PPTX.\n *\n * CT_SlideLayout — fully structured. Mirrors {@link slideDesc}: stringify builds\n * cSld/bg/spTree/custDataLst/controls + clrMapOvr/transition/timing/hf with all\n * CT_SlideLayout attributes; parse extracts the same. Placeholder positions are\n * derived from spTree on parse (read-only helper for the fresh/editor path).\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport { xsdSlideLayoutType } from \"@office-open/core\";\nimport type { CustomDescriptor, ReadContext } from \"@office-open/core/descriptor\";\nimport { attr, findChild, parse as parseXml, stringify as stringifyXml } from \"@office-open/xml\";\nimport { NS } from \"@parts/slide-layout\";\nimport {\n  parseControls,\n  parseCustDataLst,\n  parseSlideHf,\n  stringifyControls,\n  stringifyCustDataLst,\n  stringifySlideHf,\n} from \"@parts/slide/c-sld\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\nimport type { LayoutDefinition, LayoutPlaceholderOptions } from \"@shared/file\";\nimport { extractPlaceholderDefinition, PLACEHOLDER_TYPE_TO_KEY } from \"@shared/placeholder\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport { timingDesc } from \"./animation\";\nimport { backgroundDesc } from \"./background\";\nimport { parseChild, stringifyChild } from \"./bridge\";\nimport { colorMappingOverrideDesc } from \"./color-map-override\";\nimport { readTransition, stringifyTransition } from \"./slide\";\n\n// ── Display name → SlideLayoutType mapping (fallback when @type absent) ──\n\nconst NAME_TO_TYPE: Record<string, string> = {\n  \"Title Slide\": \"title\",\n  \"Title and Content\": \"object\",\n  \"Section Header\": \"sectionHeader\",\n  \"Two Content\": \"twoObjects\",\n  Comparison: \"twoTextAndTwoObjects\",\n  \"Title Only\": \"titleOnly\",\n  Blank: \"blank\",\n  \"Content with Caption\": \"objectAndText\",\n  \"Picture with Caption\": \"pictureText\",\n  \"Vertical Text\": \"verticalText\",\n  \"Vertical Title and Text\": \"verticalTitleAndText\",\n  \"Title and Text\": \"text\",\n};\n\n// ── Descriptor ──\n\nexport const slideLayoutDesc: CustomDescriptor<LayoutDefinition, PptxWriteContext> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    const parts: string[] = [];\n    ctx.beginShapeScope();\n\n    // Root attributes (CT_SlideLayout: type/matchingName/preserve/userDrawn + AG_ChildSlide).\n    // @type omitted when unset — the XSD default is \"cust\" (ST_SlideLayoutType has\n    // no \"custom\" token), matching python-pptx / Open XML SDK output.\n    const attrs: string[] = [];\n    if (opts.type !== undefined) attrs.push(`type=\"${xsdSlideLayoutType.to(opts.type)}\"`);\n    if (opts.matchingName !== undefined) attrs.push(`matchingName=\"${opts.matchingName}\"`);\n    attrs.push(`preserve=\"${opts.preserve ? 1 : 0}\"`);\n    if (opts.userDrawn) attrs.push('userDrawn=\"1\"');\n    if (opts.showMasterShapes === false) attrs.push('showMasterSp=\"0\"');\n    if (opts.showMasterPlaceholderAnimations === false) attrs.push('showMasterPhAnim=\"0\"');\n    parts.push(`<p:sldLayout ${NS} ${attrs.join(\" \")}>`);\n\n    // p:cSld (CT_CommonSlideData) — optional name attribute.\n    parts.push(`<p:cSld${opts.name !== undefined ? ` name=\"${opts.name}\"` : \"\"}>`);\n\n    if (opts.background) {\n      parts.push(backgroundDesc.stringify(opts.background, ctx) ?? \"\");\n    }\n\n    // p:spTree\n    parts.push(\"<p:spTree>\");\n    parts.push(SP_TREE_HEADER);\n    if (opts.children) {\n      for (const child of opts.children) {\n        const xml = stringifyChild(child, ctx);\n        if (xml) parts.push(xml);\n      }\n    }\n    parts.push(\"</p:spTree>\");\n\n    // custDataLst + controls (inside cSld per CT_CommonSlideData).\n    parts.push(stringifyCustDataLst(opts.customerData));\n    parts.push(stringifyControls(opts.controls));\n\n    // cSld-tail extLst (p14:creationId's home) — verbatim.\n    if (opts.cSldExt) parts.push(`<p:extLst>${opts.cSldExt}</p:extLst>`);\n\n    parts.push(\"</p:cSld>\");\n\n    // EG_ChildSlide — p:clrMapOvr (optional; undefined omits it, sources\n    // that carry one round-trip it).\n    parts.push(colorMappingOverrideDesc.stringify(opts.colorMappingOverride, ctx) ?? \"\");\n\n    // p:transition (optional, after clrMapOvr).\n    if (opts.transition) {\n      const transitionXml = stringifyTransition(opts.transition, ctx);\n      if (transitionXml) parts.push(transitionXml);\n    }\n\n    // p:timing (optional).\n    if (opts.animations?.length) {\n      parts.push(timingDesc.stringify(opts.animations, ctx) ?? \"\");\n    }\n\n    // p:hf (optional, sibling of cSld per CT_SlideLayout; attribute form per\n    // CT_HeaderFooter).\n    parts.push(stringifySlideHf(opts.headerFooter));\n\n    // p:extLst — verbatim round-trip (last child per CT_SlideLayout sequence).\n    if (opts.ext) parts.push(`<p:extLst>${opts.ext}</p:extLst>`);\n\n    parts.push(\"</p:sldLayout>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, ctx) {\n    const result: Partial<LayoutDefinition> = {};\n\n    // Root attributes (CT_SlideLayout).\n    const typeAttr = attr(el, \"type\");\n    if (typeAttr) result.type = xsdSlideLayoutType.from(typeAttr);\n    const matchingName = attr(el, \"matchingName\");\n    if (matchingName !== undefined) result.matchingName = matchingName;\n    const preserveAttr = attr(el, \"preserve\");\n    if (preserveAttr !== undefined) result.preserve = parseOnOff(preserveAttr) ?? false;\n    if (parseOnOff(attr(el, \"userDrawn\"))) result.userDrawn = true;\n    const showMasterShapes = attr(el, \"showMasterSp\");\n    if (showMasterShapes !== undefined)\n      result.showMasterShapes = parseOnOff(showMasterShapes) ?? true;\n    const showMasterPlaceholderAnimations = attr(el, \"showMasterPhAnim\");\n    if (showMasterPlaceholderAnimations !== undefined)\n      result.showMasterPlaceholderAnimations = parseOnOff(showMasterPlaceholderAnimations) ?? true;\n\n    // p:cSld (CT_CommonSlideData).\n    const cSld = findChild(el, \"p:cSld\");\n    if (cSld) {\n      const name = attr(cSld, \"name\");\n      if (name !== undefined) {\n        result.name = name;\n        // Only map display names that have a real ST_SlideLayoutType value —\n        // free-form names (\"True or False\") are not legal @type values and\n        // PowerPoint rejects the part on real-open.\n        if (!result.type) result.type = NAME_TO_TYPE[name];\n      }\n\n      const bg = findChild(cSld, \"p:bg\");\n      if (bg) result.background = backgroundDesc.parse(bg, ctx);\n\n      // spTree — structured children + derived placeholder positions.\n      const spTree = findChild(cSld, \"p:spTree\");\n      if (spTree) {\n        const children: SlideChild[] = [];\n        const placeholders: LayoutPlaceholderOptions = {};\n        for (const child of spTree.elements ?? []) {\n          if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n          const parsed = parseChild(child, ctx);\n          if (parsed !== undefined) children.push(parsed);\n          if (child.name === \"p:sp\") {\n            const ph = extractPlaceholderDefinition(child, ctx, PLACEHOLDER_TYPE_TO_KEY);\n            if (ph) placeholders[ph.key] = ph.def;\n          }\n        }\n        if (children.length > 0) result.children = children;\n        if (Object.keys(placeholders).length > 0) result.placeholders = placeholders;\n      }\n\n      // custDataLst + controls (inside cSld).\n      result.customerData = parseCustDataLst(findChild(cSld, \"p:custDataLst\"));\n      result.controls = parseControls(findChild(cSld, \"p:controls\"));\n\n      // cSld-tail extLst (p14:creationId's home) — verbatim, distinct from\n      // the root-level extLst read below (two separate XSD slots).\n      const cSldExtLst = findChild(cSld, \"p:extLst\");\n      if (cSldExtLst) {\n        const inner = stringifyXml(cSldExtLst);\n        if (inner) result.cSldExt = inner;\n      }\n    }\n\n    // EG_ChildSlide — p:clrMapOvr.\n    const clrMapOvr = findChild(el, \"p:clrMapOvr\");\n    if (clrMapOvr) result.colorMappingOverride = colorMappingOverrideDesc.parse(clrMapOvr, ctx);\n\n    // p:transition.\n    const transition = findChild(el, \"p:transition\");\n    if (transition) result.transition = readTransition(transition, ctx);\n\n    // p:timing (structured entries, or verbatim inner XML fallback).\n    const timing = findChild(el, \"p:timing\");\n    if (timing) {\n      const animations = timingDesc.parse(timing, ctx);\n      if (!(Array.isArray(animations) && animations.length === 0)) result.animations = animations;\n    }\n\n    // p:hf (sibling of cSld; attribute form per CT_HeaderFooter).\n    result.headerFooter = parseSlideHf(findChild(el, \"p:hf\"));\n\n    // p:extLst — verbatim inner XML for unmodeled extensions.\n    const extLst = findChild(el, \"p:extLst\");\n    if (extLst) {\n      const inner = stringifyXml(extLst);\n      if (inner) result.ext = inner;\n    }\n\n    return result as LayoutDefinition;\n  },\n};\n\n// ── Template parsing (compiler generate-path) ──\n\n// Stub ReadContext for parsing pre-built template/custom layout XML. Template\n// layouts carry no relatable media, so relationship resolution is unnecessary.\nconst STUB_READ_CONTEXT = {\n  resolveRelationship: () => undefined,\n  getPart: () => undefined,\n  getRaw: () => undefined,\n} as unknown as ReadContext;\n\n/**\n * Parse a pre-built slideLayout XML string into a structured LayoutDefinition.\n *\n * Used by the compiler to convert fresh template/custom layout XML (produced by\n * buildLayoutXml/buildCustomLayoutXml) into structured form, so every layout\n * flows through {@link slideLayoutDesc.stringify} uniformly.\n */\nexport function parseLayoutDef(xml: string): LayoutDefinition {\n  const doc = parseXml(xml);\n  const root = doc.elements?.[0];\n  if (!root) throw new Error(\"parsed slideLayout document has no root element\");\n  return slideLayoutDesc.parse(root, STUB_READ_CONTEXT);\n}\n","/**\n * Comment descriptors for PPTX.\n *\n * Handles both comment authors (p:cmAuthorLst) and\n * per-slide comment lists (p:cmLst).\n *\n * @module\n */\n\nimport { convertToEmu, parseOnOff } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { escapeXml } from \"@office-open/xml\";\nimport { attr, attrNum, findChild, textOf } from \"@office-open/xml\";\nimport type { AuthorEntry, CommentEntry } from \"@parts/comment\";\n\n// ── Comment Authors ──\n\nexport const commentAuthorsDesc: CustomDescriptor<AuthorEntry[]> = {\n  kind: \"custom\",\n\n  stringify(authors, _ctx) {\n    const parts: string[] = [\n      '<p:cmAuthorLst xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">',\n    ];\n    for (const a of authors) {\n      parts.push(\n        `<p:cmAuthor id=\"${a.id}\" name=\"${escapeXml(a.name)}\" initials=\"${escapeXml(a.initials)}\" clrIdx=\"${a.clrIdx}\" lastIdx=\"${a.lastIdx}\"/>`,\n      );\n    }\n    parts.push(\"</p:cmAuthorLst>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, _ctx) {\n    const authors: AuthorEntry[] = [];\n    for (const child of el.elements ?? []) {\n      if (child.name !== \"p:cmAuthor\") continue;\n      const id = attrNum(child, \"id\");\n      const name = attr(child, \"name\");\n      const initials = attr(child, \"initials\");\n      const clrIdx = attrNum(child, \"clrIdx\");\n      const lastIdx = attrNum(child, \"lastIdx\");\n      if (id !== undefined && name && initials && clrIdx !== undefined && lastIdx !== undefined) {\n        authors.push({ id, name, initials, clrIdx, lastIdx });\n      }\n    }\n    return authors as AuthorEntry[];\n  },\n};\n\n// ── Slide Comments ──\n\nexport const slideCommentsDesc: CustomDescriptor<CommentEntry[]> = {\n  kind: \"custom\",\n\n  stringify(comments, _ctx) {\n    const parts: string[] = [\n      '<p:cmLst xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">',\n    ];\n    for (const c of comments) {\n      const attrs: string[] = [`authorId=\"${c.authorId}\"`, `idx=\"${c.idx}\"`];\n      if (c.date != null) attrs.push(`dt=\"${escapeXml(c.date)}\"`);\n      parts.push(`<p:cm ${attrs.join(\" \")}>`);\n      parts.push(`<p:pos x=\"${convertToEmu(c.x)}\" y=\"${convertToEmu(c.y)}\"/>`);\n      parts.push(`<p:text>${escapeXml(c.text)}</p:text>`);\n      // CT_ExtensionListModify.mod lives on <p:extLst>, not <p:cm>.\n      if (c.modified !== undefined) {\n        parts.push(`<p:extLst mod=\"${c.modified ? 1 : 0}\"/>`);\n      }\n      parts.push(\"</p:cm>\");\n    }\n    parts.push(\"</p:cmLst>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, _ctx) {\n    const comments: CommentEntry[] = [];\n    for (const cm of el.elements ?? []) {\n      if (cm.name !== \"p:cm\") continue;\n      const authorId = attrNum(cm, \"authorId\") ?? 0;\n      const idx = attrNum(cm, \"idx\") ?? 0;\n      const date = attr(cm, \"dt\");\n      const pos = findChild(cm, \"p:pos\");\n      const x = pos ? (attrNum(pos, \"x\") ?? 0) : 0;\n      const y = pos ? (attrNum(pos, \"y\") ?? 0) : 0;\n      const textEl = findChild(cm, \"p:text\");\n      const text = textEl ? (textOf(textEl) ?? \"\") : \"\";\n      const entry: CommentEntry = { authorId, idx, x, y, text };\n      if (date !== undefined) entry.date = date;\n      // mod lives on <p:extLst> (CT_ExtensionListModify), not on <p:cm>.\n      const extLst = findChild(cm, \"p:extLst\");\n      if (extLst) {\n        const mod = attr(extLst, \"mod\");\n        if (mod !== undefined) entry.modified = parseOnOff(mod) ?? false;\n      }\n      comments.push(entry);\n    }\n    return comments as CommentEntry[];\n  },\n};\n","import type { ShowOptions } from \"@shared/file\";\n\n/** Web output options (p:webPr — HTML export behavior). */\nexport interface WebPropertiesOptions {\n  showAnimation?: boolean;\n  resizeGraphics?: boolean;\n  allowPng?: boolean;\n  relyOnVml?: boolean;\n  organizeInFolders?: boolean;\n  useLongFilenames?: boolean;\n  /** Monitor size for web output (p:webPr `@imgSz`, ST_WebScreenSize) */\n  imageSize?:\n    | \"544x376\"\n    | \"640x480\"\n    | \"720x512\"\n    | \"800x600\"\n    | \"1024x768\"\n    | \"1152x882\"\n    | \"1152x900\"\n    | \"1280x1024\"\n    | \"1600x1200\"\n    | \"1800x1400\"\n    | \"1920x1200\";\n  encoding?: string;\n  /** Color scheme for web output (p:webPr `@clr`, ST_WebColorType) */\n  color?:\n    | \"none\"\n    | \"browser\"\n    | \"presentationText\"\n    | \"presentationAccent\"\n    | \"whiteTextOnBlack\"\n    | \"blackTextOnWhite\";\n}\n\n/** Print options (p:prnPr — what each page holds and the color mode). */\nexport interface PrintPropertiesOptions {\n  /** What each printed page holds: slides, \"handoutsN\" N slides per page, notes pages, or the outline. */\n  printWhat?:\n    | \"slides\"\n    | \"handouts1\"\n    | \"handouts2\"\n    | \"handouts3\"\n    | \"handouts4\"\n    | \"handouts6\"\n    | \"handouts9\"\n    | \"notes\"\n    | \"outline\";\n  /** Print in pure black-and-white, grayscale, or color. */\n  colorMode?: \"blackWhite\" | \"gray\" | \"color\";\n  hiddenSlides?: boolean;\n  scaleToFitPaper?: boolean;\n  frameSlides?: boolean;\n}\n\n/** Web-publishing target (p:htmlPubPr — browser and title for HTML export). */\nexport interface HtmlPublishPropertiesOptions {\n  showSpeakerNotes?: boolean;\n  target?: string;\n  title?: string;\n  rId?: string;\n}\n\nexport interface PresentationPropertiesOptions {\n  show?: ShowOptions;\n  web?: WebPropertiesOptions;\n  print?: PrintPropertiesOptions;\n  htmlPublish?: HtmlPublishPropertiesOptions;\n  colorMru?: string[];\n  /** Verbatim inner XML of p:extLst (last child per CT_PresentationProperties). */\n  ext?: string;\n}\n\nconst COLOR_MODE_XSD: Record<string, string> = {\n  blackWhite: \"bw\",\n  gray: \"gray\",\n  color: \"clr\",\n};\n\nfunction buildWebPrXml(opts: WebPropertiesOptions): string {\n  const attrs: string[] = [];\n  if (opts.showAnimation) attrs.push(' showAnimation=\"1\"');\n  if (opts.resizeGraphics === false) attrs.push(' resizeGraphics=\"0\"');\n  if (opts.allowPng) attrs.push(' allowPng=\"1\"');\n  if (opts.relyOnVml) attrs.push(' relyOnVml=\"1\"');\n  if (opts.organizeInFolders === false) attrs.push(' organizeInFolders=\"0\"');\n  if (opts.useLongFilenames === false) attrs.push(' useLongFilenames=\"0\"');\n  if (opts.imageSize) attrs.push(` imgSz=\"${opts.imageSize}\"`);\n  if (opts.encoding) attrs.push(` encoding=\"${opts.encoding}\"`);\n  if (opts.color) attrs.push(` clr=\"${opts.color}\"`);\n  return `<p:webPr${attrs.join(\"\")}/>`;\n}\n\nfunction buildPrnPrXml(opts: PrintPropertiesOptions): string {\n  const attrs: string[] = [];\n  if (opts.printWhat) attrs.push(` prnWhat=\"${opts.printWhat}\"`);\n  if (opts.colorMode) attrs.push(` clrMode=\"${COLOR_MODE_XSD[opts.colorMode]}\"`);\n  if (opts.hiddenSlides) attrs.push(' hiddenSlides=\"1\"');\n  if (opts.scaleToFitPaper) attrs.push(' scaleToFitPaper=\"1\"');\n  if (opts.frameSlides) attrs.push(' frameSlides=\"1\"');\n  return `<p:prnPr${attrs.join(\"\")}/>`;\n}\n\nfunction buildHtmlPubPrXml(opts: HtmlPublishPropertiesOptions): string {\n  const attrs: string[] = [];\n  if (opts.showSpeakerNotes === false) attrs.push(' showSpeakerNotes=\"0\"');\n  if (opts.target) attrs.push(` target=\"${opts.target}\"`);\n  if (opts.title) attrs.push(` title=\"${opts.title}\"`);\n  if (opts.rId) attrs.push(` r:id=\"${opts.rId}\"`);\n  return `<p:htmlPubPr${attrs.join(\"\")}><p:sldAll/></p:htmlPubPr>`;\n}\n\nfunction buildShowPrXml(showOptions: ShowOptions): string {\n  const showPrAttrs: string[] = [];\n  if (showOptions.loop) showPrAttrs.push(' loop=\"1\"');\n  if (showOptions.showNarration !== undefined)\n    showPrAttrs.push(` showNarration=\"${showOptions.showNarration ? 1 : 0}\"`);\n  if (showOptions.showAnimation !== undefined)\n    showPrAttrs.push(` showAnimation=\"${showOptions.showAnimation ? 1 : 0}\"`);\n  if (showOptions.useTimings) showPrAttrs.push(' useTimings=\"1\"');\n\n  const showType = showOptions.type ?? \"present\";\n  let showTypeXml: string;\n  if (showType === \"kiosk\") {\n    const restartAttr =\n      showOptions.restart !== undefined ? ` restart=\"${showOptions.restart}\"` : \"\";\n    showTypeXml = `<p:kiosk${restartAttr}/>`;\n  } else if (showType === \"browse\") {\n    const scrollbarAttr = showOptions.showScrollbar === false ? ' showScrollbar=\"0\"' : \"\";\n    showTypeXml = `<p:browse${scrollbarAttr}/>`;\n  } else {\n    showTypeXml = \"<p:present/>\";\n  }\n\n  let slideListXml = \"<p:sldAll/>\";\n  if (showOptions.slideRange) {\n    slideListXml = `<p:sldRg st=\"${showOptions.slideRange.start}\" end=\"${showOptions.slideRange.end}\"/>`;\n  }\n\n  let penClrXml = \"\";\n  if (showOptions.penColor) {\n    penClrXml = `<p:penClr><a:srgbClr val=\"${showOptions.penColor}\"/></p:penClr>`;\n  }\n\n  const extXml = showOptions.ext !== undefined ? `<p:extLst>${showOptions.ext}</p:extLst>` : \"\";\n  return `<p:showPr${showPrAttrs.join(\"\")}>${showTypeXml}${slideListXml}${penClrXml}${extXml}</p:showPr>`;\n}\n\nexport function buildPresentationPropertiesXml(opts?: PresentationPropertiesOptions): string {\n  const ns =\n    'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ' +\n    'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n    'xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"';\n\n  if (!opts) {\n    return `<p:presentationPr ${ns}/>`;\n  }\n\n  const children: string[] = [];\n  if (opts.htmlPublish) children.push(buildHtmlPubPrXml(opts.htmlPublish));\n  if (opts.web) children.push(buildWebPrXml(opts.web));\n  if (opts.print) children.push(buildPrnPrXml(opts.print));\n  if (opts.show) children.push(buildShowPrXml(opts.show));\n  if (opts.colorMru && opts.colorMru.length > 0) {\n    children.push(\n      `<p:clrMru>${opts.colorMru.map((c) => `<a:srgbClr val=\"${c}\"/>`).join(\"\")}</p:clrMru>`,\n    );\n  }\n  if (opts.ext) children.push(`<p:extLst>${opts.ext}</p:extLst>`);\n\n  if (children.length === 0) {\n    return `<p:presentationPr ${ns}/>`;\n  }\n\n  return `<p:presentationPr ${ns}>${children.join(\"\")}</p:presentationPr>`;\n}\n","/**\n * Presentation Properties (p:presentationPr) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, findChild, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport {\n  buildPresentationPropertiesXml,\n  type PresentationPropertiesOptions,\n  type PrintPropertiesOptions,\n  type WebPropertiesOptions,\n} from \"@parts/presentation-properties\";\nimport type { ShowOptions } from \"@shared/file\";\n\n// ── Descriptor ──\n\nexport const presentationPropertiesDesc: CustomDescriptor<PresentationPropertiesOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    return buildPresentationPropertiesXml(opts);\n  },\n\n  parse(el, _ctx) {\n    return parsePresentationProperties(el);\n  },\n};\n\n// ── Parse ──\n\nconst COLOR_MODE_FROM_XSD: Record<string, PrintPropertiesOptions[\"colorMode\"]> = {\n  bw: \"blackWhite\",\n  gray: \"gray\",\n  clr: \"color\",\n};\n\nfunction parsePresentationProperties(el: XmlElement): PresentationPropertiesOptions {\n  const result: Partial<PresentationPropertiesOptions> = {};\n\n  // show (p:showPr in real PPTX files, or p:show for round-trip compat)\n  const showPr = findChild(el, \"p:showPr\") ?? findChild(el, \"p:show\");\n  if (showPr) {\n    const showOpts: Partial<ShowOptions> = {};\n    if (showPr.attributes?.[\"loop\"] !== undefined)\n      showOpts.loop = parseOnOff(showPr.attributes[\"loop\"]) ?? false;\n    if (showPr.attributes?.[\"showNarration\"] !== undefined)\n      showOpts.showNarration = parseOnOff(showPr.attributes[\"showNarration\"]) ?? false;\n    if (showPr.attributes?.[\"showAnimation\"] !== undefined)\n      showOpts.showAnimation = parseOnOff(showPr.attributes[\"showAnimation\"]) ?? false;\n    if (showPr.attributes?.[\"useTimings\"] !== undefined)\n      showOpts.useTimings = parseOnOff(showPr.attributes[\"useTimings\"]) ?? false;\n    // Show type from child elements (kiosk/browse/present)\n    if (findChild(showPr, \"p:kiosk\")) {\n      showOpts.type = \"kiosk\";\n      const restart = attrNum(findChild(showPr, \"p:kiosk\")!, \"restart\");\n      if (restart !== undefined) showOpts.restart = restart;\n    } else if (findChild(showPr, \"p:browse\")) {\n      showOpts.type = \"browse\";\n      if (String(attr(findChild(showPr, \"p:browse\")!, \"showScrollbar\")) === \"0\") {\n        showOpts.showScrollbar = false;\n      }\n    } else if (findChild(showPr, \"p:present\")) {\n      showOpts.type = \"present\";\n    }\n    const sldRg = findChild(showPr, \"p:sldRg\");\n    if (sldRg) {\n      const start = attrNum(sldRg, \"st\");\n      const end = attrNum(sldRg, \"end\");\n      if (start !== undefined && end !== undefined) showOpts.slideRange = { start, end };\n    }\n    const penClr = findChild(showPr, \"p:penClr\");\n    if (penClr) {\n      const srgb = findChild(penClr, \"a:srgbClr\");\n      const val = srgb ? attr(srgb, \"val\") : undefined;\n      if (val) showOpts.penColor = val;\n    }\n    const showPrExt = findChild(showPr, \"p:extLst\");\n    if (showPrExt) showOpts.ext = stringifyXml(showPrExt);\n    if (Object.keys(showOpts).length > 0) result.show = showOpts as ShowOptions;\n  }\n\n  // web (p:webPr) — default-true booleans only carry \"0\"\n  const webPr = findChild(el, \"p:webPr\");\n  if (webPr) {\n    const web: Partial<WebPropertiesOptions> = {};\n    if (parseOnOff(webPr.attributes?.[\"showAnimation\"])) web.showAnimation = true;\n    if (String(webPr.attributes?.[\"resizeGraphics\"]) === \"0\") web.resizeGraphics = false;\n    if (parseOnOff(webPr.attributes?.[\"allowPng\"])) web.allowPng = true;\n    if (parseOnOff(webPr.attributes?.[\"relyOnVml\"])) web.relyOnVml = true;\n    if (String(webPr.attributes?.[\"organizeInFolders\"]) === \"0\") web.organizeInFolders = false;\n    if (String(webPr.attributes?.[\"useLongFilenames\"]) === \"0\") web.useLongFilenames = false;\n    const imageSize = attr(webPr, \"imgSz\");\n    if (imageSize) web.imageSize = imageSize as WebPropertiesOptions[\"imageSize\"];\n    const encoding = attr(webPr, \"encoding\");\n    if (encoding) web.encoding = encoding;\n    const color = attr(webPr, \"clr\");\n    if (color) web.color = color as WebPropertiesOptions[\"color\"];\n    if (Object.keys(web).length > 0) result.web = web as WebPropertiesOptions;\n  }\n\n  // print (p:prnPr)\n  const prnPr = findChild(el, \"p:prnPr\");\n  if (prnPr) {\n    const print: Partial<PrintPropertiesOptions> = {};\n    const printWhat = attr(prnPr, \"prnWhat\");\n    if (printWhat) print.printWhat = printWhat as PrintPropertiesOptions[\"printWhat\"];\n    const clrMode = attr(prnPr, \"clrMode\");\n    if (clrMode && COLOR_MODE_FROM_XSD[clrMode]) print.colorMode = COLOR_MODE_FROM_XSD[clrMode];\n    if (parseOnOff(prnPr.attributes?.[\"hiddenSlides\"])) print.hiddenSlides = true;\n    if (parseOnOff(prnPr.attributes?.[\"scaleToFitPaper\"])) print.scaleToFitPaper = true;\n    if (parseOnOff(prnPr.attributes?.[\"frameSlides\"])) print.frameSlides = true;\n    if (Object.keys(print).length > 0) result.print = print as PrintPropertiesOptions;\n  }\n\n  // htmlPublish (p:htmlPubPr)\n  const htmlPubPr = findChild(el, \"p:htmlPubPr\");\n  if (htmlPubPr) {\n    const htmlPublish: NonNullable<PresentationPropertiesOptions[\"htmlPublish\"]> = {};\n    if (String(htmlPubPr.attributes?.[\"showSpeakerNotes\"]) === \"0\") {\n      htmlPublish.showSpeakerNotes = false;\n    }\n    const target = attr(htmlPubPr, \"target\");\n    if (target) htmlPublish.target = target;\n    const title = attr(htmlPubPr, \"title\");\n    if (title) htmlPublish.title = title;\n    const rId = attr(htmlPubPr, \"r:id\");\n    if (rId) htmlPublish.rId = rId;\n    if (Object.keys(htmlPublish).length > 0) result.htmlPublish = htmlPublish;\n  }\n\n  // colorMru (p:clrMru)\n  const clrMru = findChild(el, \"p:clrMru\");\n  if (clrMru) {\n    const colors: string[] = [];\n    for (const child of clrMru.elements ?? []) {\n      if (child.name !== \"a:srgbClr\") continue;\n      const val = attr(child, \"val\");\n      if (val) colors.push(val);\n    }\n    if (colors.length > 0) result.colorMru = colors;\n  }\n\n  // p:extLst — verbatim inner XML for unmodeled extensions (p14 discardImageDpi etc.).\n  const extLst = findChild(el, \"p:extLst\");\n  if (extLst) {\n    const inner = stringifyXml(extLst);\n    if (inner) result.ext = inner;\n  }\n\n  return result as PresentationPropertiesOptions;\n}\n","/**\n * Media module for PresentationML documents.\n *\n * Provides transformation helpers for embedded media. The deduplicated\n * {@link Media} collection lives in `@office`-open/core and is shared across all\n * format packages.\n *\n * @module\n */\nimport { convertEmuToPixels, convertToEmu } from \"@office-open/core\";\nimport type { UniversalMeasure } from \"@office-open/core\";\n\nimport type { MediaDataTransformation } from \"./data\";\n\nexport interface MediaTransformation {\n  width: number | UniversalMeasure;\n  height: number | UniversalMeasure;\n}\n\nexport const createTransformation = (options: MediaTransformation): MediaDataTransformation => {\n  const cx = convertToEmu(options.width);\n  const cy = convertToEmu(options.height);\n  return {\n    emus: { x: cx, y: cy },\n    pixels: { x: Math.round(convertEmuToPixels(cx)), y: Math.round(convertEmuToPixels(cy)) },\n  };\n};\n","/**\n * Notes Slide (p:notes) descriptor for PPTX.\n *\n * CT_NotesSlide is CT_Slide minus transition/timing: cSld (bg + spTree) +\n * clrMapOvr (EG_ChildSlide) + extLst. The shape tree holds the slide-image\n * placeholder (p:ph type=\"sldImg\", no txBody) and the notes body placeholder,\n * plus any extra shapes a user adds. Structured stringify mirrors slideDesc so\n * a parsed notes slide round-trips byte-exact; the simple `text` shorthand\n * keeps the fresh API (text-only notes) one line.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { findChild, stringify as stringifyXml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { buildNotesSlideXml } from \"@parts/notes-slide\";\nimport type { SlideChild } from \"@parts/slide/slide-child\";\nimport { SP_TREE_HEADER } from \"@shared/constants\";\n\nimport type { PptxWriteContext } from \"../../context\";\nimport type { BackgroundOptions } from \"../background\";\nimport { backgroundDesc } from \"./background\";\nimport { stringifyChild, parseChild } from \"./bridge\";\nimport { colorMappingOverrideDesc, type ColorMappingOverrideOptions } from \"./color-map-override\";\n\n// ── Types ──\n\nexport interface NotesSlideOptions {\n  /** Notes text — shorthand that builds a fresh sldImg + body placeholder slide. */\n  text?: string;\n  /** Shape-tree children (structured). When set, the structured path is used. */\n  children?: SlideChild[];\n  background?: BackgroundOptions;\n  colorMappingOverride?: ColorMappingOverrideOptions;\n  /**\n   * Raw inner XML of the p:extLst inside p:cSld (CT_CommonSlideData tail —\n   * where p14:creationId lives) — verbatim round-trip.\n   */\n  cSldExt?: string;\n  showMasterShapes?: boolean;\n  showMasterPlaceholderAnimations?: boolean;\n  /** Hidden notes slide (p:notes/`@show`=\"0\"). */\n  show?: boolean;\n}\n\n// ── Descriptor ──\n\nexport const notesSlideDesc: CustomDescriptor<NotesSlideOptions, PptxWriteContext> = {\n  kind: \"custom\",\n\n  stringify(opts, ctx) {\n    // Simple text path — fresh builder with sldImg + body placeholders.\n    const structured =\n      opts.children !== undefined ||\n      opts.background !== undefined ||\n      opts.colorMappingOverride !== undefined ||\n      opts.cSldExt !== undefined;\n    if (!structured) return buildNotesSlideXml({ text: opts.text });\n\n    // Structured path — mirror slideDesc (p:notes has no transition/timing).\n    const parts: string[] = [];\n    const attrs: string[] = [];\n    if (opts.showMasterShapes === false) attrs.push(' showMasterSp=\"0\"');\n    if (opts.showMasterPlaceholderAnimations === false) attrs.push(' showMasterPhAnim=\"0\"');\n    if (opts.show === false) attrs.push(' show=\"0\"');\n    parts.push(\n      '<p:notes xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"' +\n        attrs.join(\"\") +\n        \">\",\n    );\n\n    parts.push(\"<p:cSld>\");\n    if (opts.background) parts.push(backgroundDesc.stringify(opts.background, ctx) ?? \"\");\n    parts.push(\"<p:spTree>\");\n    parts.push(SP_TREE_HEADER);\n    if (opts.children) {\n      for (const child of opts.children) {\n        const xml = stringifyChild(child, ctx);\n        if (xml) parts.push(xml);\n      }\n    }\n    parts.push(\"</p:spTree>\");\n    // cSld-tail extLst (p14:creationId's home) — verbatim.\n    if (opts.cSldExt) parts.push(`<p:extLst>${opts.cSldExt}</p:extLst>`);\n    parts.push(\"</p:cSld>\");\n\n    parts.push(colorMappingOverrideDesc.stringify(opts.colorMappingOverride, ctx) ?? \"\");\n\n    parts.push(\"</p:notes>\");\n    return parts.join(\"\");\n  },\n\n  parse(el, ctx) {\n    const result: Partial<NotesSlideOptions> = {};\n\n    if (el.attributes) {\n      if (el.attributes[\"showMasterSp\"] !== undefined)\n        result.showMasterShapes = parseOnOff(String(el.attributes[\"showMasterSp\"])) ?? true;\n      if (el.attributes[\"showMasterPhAnim\"] !== undefined)\n        result.showMasterPlaceholderAnimations =\n          parseOnOff(String(el.attributes[\"showMasterPhAnim\"])) ?? true;\n      if (el.attributes[\"show\"] !== undefined)\n        result.show = parseOnOff(String(el.attributes[\"show\"])) ?? true;\n    }\n\n    const cSld = findChild(el, \"p:cSld\");\n    if (cSld) {\n      const bg = findChild(cSld, \"p:bg\");\n      if (bg) result.background = backgroundDesc.parse(bg, ctx);\n\n      const spTree = findChild(cSld, \"p:spTree\");\n      if (spTree) {\n        const children: SlideChild[] = [];\n        for (const child of spTree.elements ?? []) {\n          // Skip the tree container structure (nvGrpSpPr/grpSpPr).\n          if (child.name === \"p:nvGrpSpPr\" || child.name === \"p:grpSpPr\") continue;\n          const parsed = parseChild(child as Element, ctx);\n          if (parsed !== undefined) children.push(parsed as SlideChild);\n        }\n        if (children.length > 0) result.children = children;\n      }\n\n      // cSld-tail extLst (p14:creationId's home) — verbatim.\n      const cSldExtLst = findChild(cSld, \"p:extLst\");\n      if (cSldExtLst) {\n        const inner = stringifyXml(cSldExtLst);\n        if (inner) result.cSldExt = inner;\n      }\n    }\n\n    const clrMapOvr = findChild(el, \"p:clrMapOvr\");\n    if (clrMapOvr) result.colorMappingOverride = colorMappingOverrideDesc.parse(clrMapOvr, ctx);\n\n    return result as NotesSlideOptions;\n  },\n};\n","/**\n * Presentation (p:presentation) descriptor for PPTX.\n *\n * @module\n */\n\nimport {\n  derivePasswordHash,\n  emitPercent,\n  extUriMatches,\n  parseOnOff,\n  parsePercentAttr,\n  uniqueUuid,\n} from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, escapeXml, findChild, stringify, stringifyElement } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport type {\n  PresentationPartOptions,\n  PhotoAlbumOptions,\n  ModifyVerifierOptions,\n  EmbeddedFontOptions,\n  CustomShowOptions,\n  KinsokuOptions,\n  CustomerDataOptions,\n} from \"@parts/presentation\";\n\n// Re-export sub-types for convenience\nexport type {\n  PresentationPartOptions as PresentationDescriptorOptions,\n  PhotoAlbumOptions,\n  ModifyVerifierOptions,\n  EmbeddedFontOptions,\n  CustomShowOptions,\n  KinsokuOptions,\n  CustomerDataOptions,\n};\n\n// ── Default text style ──\n\nconst DEFAULT_TEXT_STYLE_XML = `<p:defaultTextStyle xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\n  <a:defPPr><a:defRPr/></a:defPPr>\n  <a:lvl1pPr marL=\"0\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl1pPr>\n  <a:lvl2pPr marL=\"457200\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl2pPr>\n  <a:lvl3pPr marL=\"914400\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl3pPr>\n  <a:lvl4pPr marL=\"1371600\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl4pPr>\n  <a:lvl5pPr marL=\"1828800\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl5pPr>\n  <a:lvl6pPr marL=\"2286000\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl6pPr>\n  <a:lvl7pPr marL=\"2743200\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl7pPr>\n  <a:lvl8pPr marL=\"3200400\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl8pPr>\n  <a:lvl9pPr marL=\"3657600\" algn=\"l\" defTabSz=\"914400\" rtl=\"0\" eaLnBrk=\"1\" latinLnBrk=\"0\" hangingPunct=\"1\">\n    <a:defRPr sz=\"1800\" kern=\"1200\"><a:solidFill><a:schemeClr val=\"tx1\"/></a:solidFill><a:latin typeface=\"+mn-lt\"/><a:ea typeface=\"+mn-ea\"/><a:cs typeface=\"+mn-cs\"/></a:defRPr>\n  </a:lvl9pPr>\n</p:defaultTextStyle>`;\n\n// ── Stringify (internal) ──\n\nfunction stringifyPresentation(opts: PresentationPartOptions): string {\n  const cx = opts.slideWidth ?? 12192000;\n  const cy = opts.slideHeight ?? 6858000;\n\n  const rootAttrs: string[] = [];\n  if (opts.serverZoom !== undefined)\n    rootAttrs.push(` serverZoom=\"${emitPercent(opts.serverZoom)}\"`);\n  if (opts.firstSlideNum !== undefined) rootAttrs.push(` firstSlideNum=\"${opts.firstSlideNum}\"`);\n  if (opts.showSpecialPlsOnTitleSld === false) rootAttrs.push(' showSpecialPlsOnTitleSld=\"0\"');\n  if (opts.rtl) rootAttrs.push(' rtl=\"1\"');\n  if (opts.removePersonalInfoOnSave) rootAttrs.push(' removePersonalInfoOnSave=\"1\"');\n  if (opts.compatMode) rootAttrs.push(' compatMode=\"1\"');\n  if (opts.strictFirstAndLastChars === false) rootAttrs.push(' strictFirstAndLastChars=\"0\"');\n  if (opts.embedTrueTypeFonts) rootAttrs.push(' embedTrueTypeFonts=\"1\"');\n  if (opts.saveSubsetFonts) rootAttrs.push(' saveSubsetFonts=\"1\"');\n  if (opts.autoCompressPictures === false) rootAttrs.push(' autoCompressPictures=\"0\"');\n  if (opts.bookmarkIdSeed !== undefined) rootAttrs.push(` bookmarkIdSeed=\"${opts.bookmarkIdSeed}\"`);\n  if (opts.conformance) rootAttrs.push(` conformance=\"${opts.conformance}\"`);\n\n  const parts: string[] = [];\n  parts.push(\n    `<p:presentation xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"${rootAttrs.join(\"\")}>`,\n  );\n\n  // sldMasterIdLst\n  parts.push(\"<p:sldMasterIdLst>\");\n  for (let mi = 0; mi < opts.masterCount; mi++) {\n    parts.push(`<p:sldMasterId id=\"${2147483648 + mi * 12}\" r:id=\"rId${mi + 1}\"/>`);\n  }\n  parts.push(\"</p:sldMasterIdLst>\");\n\n  if (opts.notesMasterRId) {\n    parts.push(\n      `<p:notesMasterIdLst><p:notesMasterId r:id=\"rId${opts.notesMasterRId}\"/></p:notesMasterIdLst>`,\n    );\n  }\n  if (opts.handoutMasterRId) {\n    parts.push(\n      `<p:handoutMasterIdLst><p:handoutMasterId r:id=\"rId${opts.handoutMasterRId}\"/></p:handoutMasterIdLst>`,\n    );\n  }\n\n  // sldIdLst — CT_Presentation optional; a source with no slides carries no\n  // element at all, so an empty list must not emit the wrapper.\n  if (opts.slideIds.length > 0) {\n    parts.push(\"<p:sldIdLst>\");\n    const sRidOff = opts.masterCount + 1;\n    for (let i = 0; i < opts.slideIds.length; i++) {\n      parts.push(`<p:sldId id=\"${opts.slideIds[i]}\" r:id=\"rId${sRidOff + i}\"/>`);\n    }\n    parts.push(\"</p:sldIdLst>\");\n  }\n\n  const typeAttr =\n    opts.slideSizeType && opts.slideSizeType !== \"custom\" ? ` type=\"${opts.slideSizeType}\"` : \"\";\n  parts.push(`<p:sldSz cx=\"${cx}\" cy=\"${cy}\"${typeAttr}/>`);\n  parts.push(`<p:notesSz cx=\"${opts.notesWidth ?? 6858000}\" cy=\"${opts.notesHeight ?? 9144000}\"/>`);\n\n  // smartTags (CT_SmartTags — r:id to the smart-tags part)\n  if (opts.smartTags) {\n    parts.push(`<p:smartTags r:id=\"${opts.smartTags.rId}\"/>`);\n  }\n\n  // embeddedFontLst\n  if (opts.embeddedFonts && opts.embeddedFonts.length > 0) {\n    parts.push(\"<p:embeddedFontLst>\");\n    for (const ef of opts.embeddedFonts) {\n      const fontAttrs: string[] = [`typeface=\"${ef.font.typeface}\"`];\n      if (ef.font.panose) fontAttrs.push(`panose=\"${ef.font.panose}\"`);\n      if (ef.font.pitchFamily !== undefined) fontAttrs.push(`pitchFamily=\"${ef.font.pitchFamily}\"`);\n      if (ef.font.charset !== undefined) fontAttrs.push(`charset=\"${ef.font.charset}\"`);\n      parts.push(\"<p:embeddedFont>\");\n      parts.push(`<p:font ${fontAttrs.join(\" \")}/>`);\n      if (ef.regular) parts.push(`<p:regular r:id=\"${ef.regular}\"/>`);\n      if (ef.bold) parts.push(`<p:bold r:id=\"${ef.bold}\"/>`);\n      if (ef.italic) parts.push(`<p:italic r:id=\"${ef.italic}\"/>`);\n      if (ef.boldItalic) parts.push(`<p:boldItalic r:id=\"${ef.boldItalic}\"/>`);\n      parts.push(\"</p:embeddedFont>\");\n    }\n    parts.push(\"</p:embeddedFontLst>\");\n  }\n\n  // custShowLst\n  if (opts.customShows && opts.customShows.length > 0) {\n    parts.push(\"<p:custShowLst>\");\n    // @id only needs to be unique within the list — assign max+1 for entries a\n    // fresh document didn't number (round-tripped sources keep theirs).\n    let maxShowId = 0;\n    for (const cs of opts.customShows)\n      if (cs.id !== undefined && cs.id > maxShowId) maxShowId = cs.id;\n    for (const cs of opts.customShows) {\n      parts.push(`<p:custShow name=\"${cs.name}\" id=\"${cs.id ?? ++maxShowId}\">`);\n      parts.push(\"<p:sldLst>\");\n      for (const sl of cs.slides) {\n        parts.push(`<p:sld r:id=\"${sl.rId}\"/>`);\n      }\n      parts.push(\"</p:sldLst>\");\n      parts.push(\"</p:custShow>\");\n    }\n    parts.push(\"</p:custShowLst>\");\n  }\n\n  // photoAlbum\n  if (opts.photoAlbum) {\n    const pa = opts.photoAlbum;\n    const paAttrs: string[] = [];\n    if (pa.blackWhite) paAttrs.push(' bw=\"1\"');\n    if (pa.showCaptions) paAttrs.push(' showCaptions=\"1\"');\n    if (pa.layout) paAttrs.push(` layout=\"${pa.layout}\"`);\n    if (pa.frame) paAttrs.push(` frame=\"${pa.frame}\"`);\n    parts.push(`<p:photoAlbum${paAttrs.join(\"\")}/>`);\n  }\n\n  // custDataLst\n  if (opts.customerData) {\n    const cdParts: string[] = [];\n    if (opts.customerData.data) {\n      for (const d of opts.customerData.data) {\n        cdParts.push(`<p:custData r:id=\"${d.rId}\"/>`);\n      }\n    }\n    if (opts.customerData.tags) {\n      cdParts.push(`<p:tags r:id=\"${opts.customerData.tags.rId}\"/>`);\n    }\n    if (cdParts.length > 0) {\n      parts.push(`<p:custDataLst>${cdParts.join(\"\")}</p:custDataLst>`);\n    }\n  }\n\n  // kinsoku\n  if (opts.kinsoku && opts.kinsoku.length > 0) {\n    for (const k of opts.kinsoku) {\n      const kAttrs: string[] = [];\n      if (k.lang) kAttrs.push(` lang=\"${k.lang}\"`);\n      kAttrs.push(` invalStChars=\"${k.invalStChars}\"`);\n      kAttrs.push(` invalEndChars=\"${k.invalEndChars}\"`);\n      parts.push(`<p:kinsoku${kAttrs.join(\"\")}/>`);\n    }\n  }\n\n  // Default text style — fresh emits PowerPoint's default 9-level style; a\n  // parsed source preserves its raw XML; false omits the element.\n  if (opts.defaultTextStyle === false) {\n    // omit\n  } else {\n    parts.push(opts.defaultTextStyle ?? DEFAULT_TEXT_STYLE_XML);\n  }\n\n  // modifyVerifier\n  if (opts.modifyVerifier) {\n    const mv = opts.modifyVerifier;\n    let derived: ReturnType<typeof derivePasswordHash> | undefined;\n    if (mv.password !== undefined && mv.hashValue === undefined && mv.hashData === undefined) {\n      derived = derivePasswordHash(mv.password);\n    }\n    const useTransitional =\n      mv.cryptoProviderType !== undefined || mv.cryptoAlgorithmSid !== undefined;\n    const mvAttrs: string[] = [];\n\n    if (useTransitional) {\n      const hashData = mv.hashData ?? derived?.hashValue;\n      const saltData = mv.saltData ?? derived?.saltValue;\n      const spinCount = mv.spinCount ?? derived?.spinCount;\n      if (mv.cryptoProviderType) mvAttrs.push(` cryptProviderType=\"${mv.cryptoProviderType}\"`);\n      if (mv.cryptoAlgorithmClass)\n        mvAttrs.push(` cryptAlgorithmClass=\"${mv.cryptoAlgorithmClass}\"`);\n      if (mv.cryptoAlgorithmType) mvAttrs.push(` cryptAlgorithmType=\"${mv.cryptoAlgorithmType}\"`);\n      if (mv.cryptoAlgorithmSid !== undefined)\n        mvAttrs.push(` cryptAlgorithmSid=\"${mv.cryptoAlgorithmSid}\"`);\n      if (spinCount !== undefined) mvAttrs.push(` spinCount=\"${spinCount}\"`);\n      if (saltData) mvAttrs.push(` saltData=\"${saltData}\"`);\n      if (hashData) mvAttrs.push(` hashData=\"${hashData}\"`);\n      if (mv.cryptoProvider) mvAttrs.push(` cryptProvider=\"${mv.cryptoProvider}\"`);\n      if (mv.algorithmExtensionId !== undefined)\n        mvAttrs.push(` algIdExt=\"${mv.algorithmExtensionId}\"`);\n      if (mv.algorithmExtensionSource)\n        mvAttrs.push(` algIdExtSource=\"${mv.algorithmExtensionSource}\"`);\n      if (mv.cryptoProviderTypeExtension !== undefined)\n        mvAttrs.push(` cryptProviderTypeExt=\"${mv.cryptoProviderTypeExtension}\"`);\n      if (mv.cryptoProviderTypeExtensionSource)\n        mvAttrs.push(` cryptProviderTypeExtSource=\"${mv.cryptoProviderTypeExtensionSource}\"`);\n    } else {\n      const hashValue = mv.hashValue ?? derived?.hashValue;\n      const saltValue = mv.saltValue ?? derived?.saltValue;\n      const algorithmName = mv.algorithmName ?? derived?.algorithmName;\n      if (algorithmName) mvAttrs.push(` algorithmName=\"${algorithmName}\"`);\n      if (hashValue) mvAttrs.push(` hashValue=\"${hashValue}\"`);\n      if (saltValue) mvAttrs.push(` saltValue=\"${saltValue}\"`);\n      if (mv.spinValue !== undefined) mvAttrs.push(` spinValue=\"${mv.spinValue}\"`);\n    }\n\n    parts.push(`<p:modifyVerifier${mvAttrs.join(\"\")}/>`);\n  }\n\n  // p14:sectionLst — slide sections (Microsoft PowerPoint 2010 extension).\n  // Only emitted when at least one slide carries a section name.\n  const extEntries: string[] = [];\n  if (opts.sections && opts.sections.length > 0) {\n    const sectionXml: string[] = [];\n    for (const sec of opts.sections) {\n      const ids = sec.slideIndices\n        .map((idx) => opts.slideIds[idx])\n        .filter((id): id is number => id !== undefined);\n      if (ids.length === 0) continue;\n      const sldIds = ids.map((id) => `<p14:sldId id=\"${id}\"/>`).join(\"\");\n      sectionXml.push(\n        `<p14:section name=\"${escapeXml(sec.name)}\" id=\"{${uniqueUuid().toUpperCase()}}\"><p14:sldIdLst>${sldIds}</p14:sldIdLst></p14:section>`,\n      );\n    }\n    if (sectionXml.length > 0) {\n      extEntries.push(\n        `<p:ext uri=\"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}\"><p14:sectionLst xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\">${sectionXml.join(\"\")}</p14:sectionLst></p:ext>`,\n      );\n    }\n  }\n\n  // Remaining extensions (verbatim) share the extLst with sections.\n  if (opts.ext) extEntries.push(opts.ext);\n  if (extEntries.length > 0) {\n    parts.push(`<p:extLst>${extEntries.join(\"\")}</p:extLst>`);\n  }\n\n  parts.push(\"</p:presentation>\");\n  return parts.join(\"\");\n}\n\n// ── Parse ──\n\nfunction parsePresentation(el: XmlElement): PresentationPartOptions {\n  const result: Partial<PresentationPartOptions> = {};\n\n  if (el.attributes) {\n    const a = el.attributes;\n    const serverZoom = parsePercentAttr(a[\"serverZoom\"]);\n    if (serverZoom !== undefined) result.serverZoom = serverZoom;\n    if (a[\"firstSlideNum\"] !== undefined) result.firstSlideNum = Number(a[\"firstSlideNum\"]);\n    if (a[\"showSpecialPlsOnTitleSld\"] !== undefined)\n      result.showSpecialPlsOnTitleSld = parseOnOff(a[\"showSpecialPlsOnTitleSld\"]) ?? true;\n    if (a[\"rtl\"] !== undefined) result.rtl = parseOnOff(a[\"rtl\"]) ?? false;\n    if (a[\"removePersonalInfoOnSave\"] !== undefined)\n      result.removePersonalInfoOnSave = parseOnOff(a[\"removePersonalInfoOnSave\"]) ?? false;\n    if (a[\"compatMode\"] !== undefined) result.compatMode = parseOnOff(a[\"compatMode\"]) ?? false;\n    if (a[\"strictFirstAndLastChars\"] !== undefined)\n      result.strictFirstAndLastChars = parseOnOff(a[\"strictFirstAndLastChars\"]) ?? true;\n    if (a[\"embedTrueTypeFonts\"] !== undefined)\n      result.embedTrueTypeFonts = parseOnOff(a[\"embedTrueTypeFonts\"]) ?? false;\n    if (a[\"saveSubsetFonts\"] !== undefined)\n      result.saveSubsetFonts = parseOnOff(a[\"saveSubsetFonts\"]) ?? false;\n    if (a[\"autoCompressPictures\"] !== undefined)\n      result.autoCompressPictures = parseOnOff(a[\"autoCompressPictures\"]) ?? true;\n    if (a[\"bookmarkIdSeed\"] !== undefined) result.bookmarkIdSeed = Number(a[\"bookmarkIdSeed\"]);\n    if (a[\"conformance\"])\n      result.conformance = a[\"conformance\"] as PresentationPartOptions[\"conformance\"];\n  }\n\n  // sldSz\n  const sldSz = findChild(el, \"p:sldSz\");\n  if (sldSz?.attributes) {\n    if (sldSz.attributes[\"cx\"] !== undefined) result.slideWidth = Number(sldSz.attributes[\"cx\"]);\n    if (sldSz.attributes[\"cy\"] !== undefined) result.slideHeight = Number(sldSz.attributes[\"cy\"]);\n    // XSD default \"custom\" — only a non-default class carries information back.\n    const type = sldSz.attributes[\"type\"] as string | undefined;\n    if (type && type !== \"custom\")\n      result.slideSizeType = type as PresentationPartOptions[\"slideSizeType\"];\n  }\n\n  // notesSz\n  const notesSz = findChild(el, \"p:notesSz\");\n  if (notesSz?.attributes) {\n    if (notesSz.attributes[\"cx\"] !== undefined)\n      result.notesWidth = Number(notesSz.attributes[\"cx\"]);\n    if (notesSz.attributes[\"cy\"] !== undefined)\n      result.notesHeight = Number(notesSz.attributes[\"cy\"]);\n  }\n\n  // smartTags — r:id to the smart-tags part\n  const smartTags = findChild(el, \"p:smartTags\");\n  if (smartTags) {\n    const rId = attr(smartTags, \"r:id\");\n    if (rId) result.smartTags = { rId };\n  }\n\n  // sldIdLst\n  const sldIdLst = findChild(el, \"p:sldIdLst\");\n  if (sldIdLst) {\n    const slideIds: number[] = [];\n    for (const child of sldIdLst.elements ?? []) {\n      if (child.name === \"p:sldId\") {\n        const id = attrNum(child, \"id\");\n        if (id !== undefined) slideIds.push(id);\n      }\n    }\n    if (slideIds.length > 0) result.slideIds = slideIds;\n  }\n\n  // sldMasterIdLst — count masters\n  const sldMasterIdLst = findChild(el, \"p:sldMasterIdLst\");\n  if (sldMasterIdLst) {\n    let masterCount = 0;\n    for (const child of sldMasterIdLst.elements ?? []) {\n      if (child.name === \"p:sldMasterId\") masterCount++;\n    }\n    result.masterCount = masterCount;\n  }\n\n  // notesMasterIdLst\n  const notesMasterIdLst = findChild(el, \"p:notesMasterIdLst\");\n  if (notesMasterIdLst) {\n    const nmId = findChild(notesMasterIdLst, \"p:notesMasterId\");\n    if (nmId) {\n      const rId = attr(nmId, \"r:id\");\n      if (rId) result.notesMasterRId = Number(rId.replace(\"rId\", \"\"));\n    }\n  }\n\n  // handoutMasterIdLst\n  const handoutMasterIdLst = findChild(el, \"p:handoutMasterIdLst\");\n  if (handoutMasterIdLst) {\n    const hmId = findChild(handoutMasterIdLst, \"p:handoutMasterId\");\n    if (hmId) {\n      const rId = attr(hmId, \"r:id\");\n      if (rId) result.handoutMasterRId = Number(rId.replace(\"rId\", \"\"));\n    }\n  }\n\n  // photoAlbum\n  const photoAlbum = findChild(el, \"p:photoAlbum\");\n  if (photoAlbum?.attributes) {\n    const pa: PhotoAlbumOptions = {};\n    if (parseOnOff(photoAlbum.attributes[\"bw\"])) pa.blackWhite = true;\n    if (parseOnOff(photoAlbum.attributes[\"showCaptions\"])) pa.showCaptions = true;\n    if (photoAlbum.attributes[\"layout\"])\n      pa.layout = photoAlbum.attributes[\"layout\"] as PhotoAlbumOptions[\"layout\"];\n    if (photoAlbum.attributes[\"frame\"])\n      pa.frame = photoAlbum.attributes[\"frame\"] as PhotoAlbumOptions[\"frame\"];\n    result.photoAlbum = pa;\n  }\n\n  // modifyVerifier\n  const mv = findChild(el, \"p:modifyVerifier\");\n  if (mv?.attributes) {\n    const mvOpts: ModifyVerifierOptions = {};\n    if (mv.attributes[\"algorithmName\"])\n      mvOpts.algorithmName = String(mv.attributes[\"algorithmName\"]);\n    if (mv.attributes[\"hashValue\"]) mvOpts.hashValue = String(mv.attributes[\"hashValue\"]);\n    if (mv.attributes[\"saltValue\"]) mvOpts.saltValue = String(mv.attributes[\"saltValue\"]);\n    if (mv.attributes[\"spinValue\"] !== undefined)\n      mvOpts.spinValue = Number(mv.attributes[\"spinValue\"]);\n    if (mv.attributes[\"cryptProviderType\"])\n      mvOpts.cryptoProviderType = String(\n        mv.attributes[\"cryptProviderType\"],\n      ) as ModifyVerifierOptions[\"cryptoProviderType\"];\n    if (mv.attributes[\"cryptAlgorithmClass\"])\n      mvOpts.cryptoAlgorithmClass = String(\n        mv.attributes[\"cryptAlgorithmClass\"],\n      ) as ModifyVerifierOptions[\"cryptoAlgorithmClass\"];\n    if (mv.attributes[\"cryptAlgorithmType\"])\n      mvOpts.cryptoAlgorithmType = String(\n        mv.attributes[\"cryptAlgorithmType\"],\n      ) as ModifyVerifierOptions[\"cryptoAlgorithmType\"];\n    if (mv.attributes[\"cryptAlgorithmSid\"] !== undefined)\n      mvOpts.cryptoAlgorithmSid = Number(mv.attributes[\"cryptAlgorithmSid\"]);\n    if (mv.attributes[\"spinCount\"] !== undefined)\n      mvOpts.spinCount = Number(mv.attributes[\"spinCount\"]);\n    if (mv.attributes[\"saltData\"]) mvOpts.saltData = String(mv.attributes[\"saltData\"]);\n    if (mv.attributes[\"hashData\"]) mvOpts.hashData = String(mv.attributes[\"hashData\"]);\n    if (mv.attributes[\"cryptProvider\"])\n      mvOpts.cryptoProvider = String(mv.attributes[\"cryptProvider\"]);\n    result.modifyVerifier = mvOpts;\n  }\n\n  // embeddedFontLst\n  const efl = findChild(el, \"p:embeddedFontLst\");\n  if (efl) {\n    const fonts: EmbeddedFontOptions[] = [];\n    for (const ef of efl.elements ?? []) {\n      if (ef.name !== \"p:embeddedFont\") continue;\n      const fontEl = findChild(ef, \"p:font\");\n      if (!fontEl) continue;\n      const font: EmbeddedFontOptions[\"font\"] = { typeface: attr(fontEl, \"typeface\") ?? \"\" };\n      if (fontEl.attributes?.[\"panose\"]) font.panose = String(fontEl.attributes[\"panose\"]);\n      const pp = attrNum(fontEl, \"pitchFamily\");\n      if (pp !== undefined) font.pitchFamily = pp;\n      const cs = attrNum(fontEl, \"charset\");\n      if (cs !== undefined) font.charset = cs;\n      const entry: EmbeddedFontOptions = { font };\n      const regular = findChild(ef, \"p:regular\");\n      if (regular) entry.regular = attr(regular, \"r:id\") ?? \"\";\n      const bold = findChild(ef, \"p:bold\");\n      if (bold) entry.bold = attr(bold, \"r:id\") ?? \"\";\n      const italic = findChild(ef, \"p:italic\");\n      if (italic) entry.italic = attr(italic, \"r:id\") ?? \"\";\n      const boldItalic = findChild(ef, \"p:boldItalic\");\n      if (boldItalic) entry.boldItalic = attr(boldItalic, \"r:id\") ?? \"\";\n      fonts.push(entry);\n    }\n    if (fonts.length > 0) result.embeddedFonts = fonts;\n  }\n\n  // customShows\n  const csl = findChild(el, \"p:custShowLst\");\n  if (csl) {\n    const shows: CustomShowOptions[] = [];\n    for (const cs of csl.elements ?? []) {\n      if (cs.name !== \"p:custShow\") continue;\n      const sldLst = findChild(cs, \"p:sldLst\");\n      const slides: { rId: string }[] = [];\n      if (sldLst) {\n        for (const s of sldLst.elements ?? []) {\n          const rId = attr(s, \"r:id\");\n          if (rId) slides.push({ rId });\n        }\n      }\n      shows.push({\n        name: attr(cs, \"name\") ?? \"\",\n        id: attrNum(cs, \"id\") ?? 0,\n        slides,\n      });\n    }\n    if (shows.length > 0) result.customShows = shows;\n  }\n\n  // kinsoku\n  const kinsokuEls = el.elements?.filter((e) => e.name === \"p:kinsoku\") ?? [];\n  if (kinsokuEls.length > 0) {\n    const kinsoku: KinsokuOptions[] = [];\n    for (const k of kinsokuEls) {\n      const entry: KinsokuOptions = {\n        invalStChars: attr(k, \"invalStChars\") ?? \"\",\n        invalEndChars: attr(k, \"invalEndChars\") ?? \"\",\n      };\n      if (k.attributes?.[\"lang\"]) entry.lang = String(k.attributes[\"lang\"]);\n      kinsoku.push(entry);\n    }\n    result.kinsoku = kinsoku;\n  }\n\n  // Default text style — preserve the source raw XML so it round-trips; a\n  // source with no p:defaultTextStyle marks false so stringify omits it.\n  const defaultTextStyle = findChild(el, \"p:defaultTextStyle\");\n  if (defaultTextStyle) {\n    result.defaultTextStyle = `<p:defaultTextStyle xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">${stringify(defaultTextStyle)}</p:defaultTextStyle>`;\n  } else {\n    result.defaultTextStyle = false;\n  }\n\n  // Trailing extLst — the sectionLst extension is modeled structurally\n  // (sections via slide.section); every other <p:ext> verbatim.\n  const extLst = findChild(el, \"p:extLst\");\n  if (extLst) {\n    const rest: string[] = [];\n    for (const ext of extLst.elements ?? []) {\n      if (ext.name !== \"p:ext\") continue;\n      if (extUriMatches(attr(ext, \"uri\"), \"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}\")) continue;\n      rest.push(stringifyElement(ext));\n    }\n    if (rest.length > 0) result.ext = rest.join(\"\");\n  }\n\n  return result as PresentationPartOptions;\n}\n\n// ── Descriptor ──\n\nexport const presentationDesc: CustomDescriptor<PresentationPartOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    return stringifyPresentation(opts);\n  },\n\n  parse(el, _ctx) {\n    return parsePresentation(el);\n  },\n};\n","/**\n * Table Styles (a:tblStyleLst) descriptor for PPTX.\n *\n * @module\n */\n\nimport {\n  createTableStyleList,\n  parseTableStyleList,\n  type TableStyleListOptions,\n} from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\n\n// ── Types ──\n\nexport interface TableStylesDescriptorOptions {\n  opts?: TableStyleListOptions;\n}\n\n// ── Descriptor ──\n\nconst DEFAULT_STYLE_ID = \"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}\";\n\nexport const tableStylesDesc: CustomDescriptor<TableStylesDescriptorOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    if (!opts.opts) {\n      return `<a:tblStyleLst xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" def=\"${DEFAULT_STYLE_ID}\"/>`;\n    }\n    return createTableStyleList(opts.opts);\n  },\n\n  parse(el, _ctx) {\n    return { opts: parseTableStyleList(el) };\n  },\n};\n","import { xsdOrient } from \"@office-open/core\";\n\ntype SplitterBarState = \"restored\" | \"maximized\" | \"minimized\";\n\n/**\n * CT_CommonViewProperties (`p:cViewPr`) — zoom scale and origin, the child\n * shared by the slide/outline/notes-text/sorter view property elements.\n */\nexport interface CommonViewPropertiesOptions {\n  /** Zoom scale as a fraction (CT_Scale2D `a:sx` n/d; `a:sy` mirrors sx). */\n  scale?: { numerator: number; denominator: number };\n  /** View origin coordinates (CT_Point2D). */\n  origin?: { x: number; y: number };\n  /** Variable scaling allowed (`@varScale`, default false). */\n  variableScale?: boolean;\n}\n\n/** CT_NormalViewPortion — one restored pane of the normal view. */\nexport interface NormalViewPortionOptions {\n  /** Restored pane size in thousandths of a percent (`@sz`, required). */\n  size: number;\n  /** Auto-adjust the pane when the window resizes (`@autoAdjust`, default true). */\n  autoAdjust?: boolean;\n}\n\nexport interface NormalViewOptions {\n  showOutlineIcons?: boolean;\n  snapVertSplitter?: boolean;\n  /** Vertical splitter-bar state: restored (pane visible at restored size), maximized, or minimized. */\n  vertBarState?: SplitterBarState;\n  /** Horizontal splitter-bar state, same states as vertBarState. */\n  horzBarState?: SplitterBarState;\n  preferSingleView?: boolean;\n  /** Restored left outline pane (`p:restoredLeft`). */\n  restoredLeft?: NormalViewPortionOptions;\n  /** Restored top notes pane (`p:restoredTop`). */\n  restoredTop?: NormalViewPortionOptions;\n}\n\nexport interface SlideViewOptions {\n  snapToGrid?: boolean;\n  snapToObjects?: boolean;\n  showGuides?: boolean;\n  /** Zoom/origin of the slide view (`p:cViewPr`). */\n  view?: CommonViewPropertiesOptions;\n}\n\nconst LAST_VIEW_XSD: Record<string, string> = {\n  slideView: \"sldView\",\n  slideMasterView: \"sldMasterView\",\n  notesView: \"notesView\",\n  handoutView: \"handoutView\",\n  outlineView: \"outlineView\",\n  slideSorterView: \"sldSorterView\",\n};\n\n/** Editing-view settings (p:viewPr — last active view, grid, guides, window panes). */\nexport interface ViewPropertiesOptions {\n  /** View active when the file was last saved; \"slideSorterView\" = the slide-overview grid. */\n  lastView?:\n    | \"slideView\"\n    | \"slideMasterView\"\n    | \"notesView\"\n    | \"handoutView\"\n    | \"outlineView\"\n    | \"slideSorterView\";\n  showComments?: boolean;\n  gridSpacing?: { cx: number; cy: number };\n  normalView?: NormalViewOptions;\n  slideView?: SlideViewOptions;\n  /** Slide-view guides (`p:guideLst`); each guide is a vertical or horizontal line at `pos` (EMU). */\n  guides?: {\n    orient?: \"vertical\" | \"horizontal\";\n    pos?: number;\n  }[];\n  /** Outline view (`p:outlineViewPr`) — view is its required `p:cViewPr`. */\n  outlineView?: {\n    view: CommonViewPropertiesOptions;\n    slides?: {\n      rId: string;\n      collapse?: boolean;\n    }[];\n  };\n  /** Notes text view (`p:notesTextViewPr`) — the `p:cViewPr` payload. */\n  notesTextView?: CommonViewPropertiesOptions;\n  sorterView?: {\n    showFormatting?: boolean;\n    view: CommonViewPropertiesOptions;\n  };\n  /**\n   * Notes view (`p:notesViewPr`) — true emits the default empty view; an\n   * object carries its zoom/origin and its own guide list.\n   */\n  notesView?: boolean | NotesViewOptions;\n}\n\n/** The `p:notesViewPr` payload — a CT_CommonSlideViewProperties (view + guides). */\nexport interface NotesViewOptions {\n  /** Zoom/origin of the notes view (`p:cViewPr`). */\n  view?: CommonViewPropertiesOptions;\n  /** Notes-view guides (`p:guideLst`); each guide is a vertical or horizontal line at `pos` (EMU). */\n  guides?: {\n    orient?: \"vertical\" | \"horizontal\";\n    pos?: number;\n  }[];\n}\n\nfunction portionXml(\n  name: string,\n  opts: NormalViewPortionOptions | undefined,\n  fallbackSize: number,\n): string {\n  const size = opts?.size ?? fallbackSize;\n  const attrs = [`sz=\"${size}\"`];\n  if (opts?.autoAdjust !== undefined) attrs.push(`autoAdjust=\"${opts.autoAdjust ? 1 : 0}\"`);\n  return `<p:${name} ${attrs.join(\" \")}/>`;\n}\n\nfunction commonViewPrXml(opts: CommonViewPropertiesOptions | undefined): string {\n  // scale and origin are required children; defaults match a fresh Office file.\n  const n = opts?.scale?.numerator ?? 90;\n  const d = opts?.scale?.denominator ?? 100;\n  const x = opts?.origin?.x ?? 1200;\n  const y = opts?.origin?.y ?? 72;\n  const varScale = opts?.variableScale ? ' varScale=\"1\"' : \"\";\n  return (\n    `<p:cViewPr${varScale}>` +\n    `<p:scale><a:sx n=\"${n}\" d=\"${d}\"/><a:sy n=\"${n}\" d=\"${d}\"/></p:scale>` +\n    `<p:origin x=\"${x}\" y=\"${y}\"/>` +\n    \"</p:cViewPr>\"\n  );\n}\n\nfunction buildNormalViewPrXml(opts?: NormalViewOptions): string {\n  const attrs: string[] = [];\n  if (opts?.showOutlineIcons === false) attrs.push(' showOutlineIcons=\"0\"');\n  if (opts?.snapVertSplitter) attrs.push(' snapVertSplitter=\"1\"');\n  if (opts?.vertBarState) attrs.push(` vertBarState=\"${opts.vertBarState}\"`);\n  if (opts?.horzBarState) attrs.push(` horzBarState=\"${opts.horzBarState}\"`);\n  if (opts?.preferSingleView) attrs.push(' preferSingleView=\"1\"');\n  return (\n    `<p:normalViewPr${attrs.join(\"\")}>` +\n    portionXml(\"restoredLeft\", opts?.restoredLeft, 15619) +\n    portionXml(\"restoredTop\", opts?.restoredTop, 94681) +\n    \"</p:normalViewPr>\"\n  );\n}\n\nfunction buildCSldViewPrXml(\n  opts?: SlideViewOptions,\n  guides?: ViewPropertiesOptions[\"guides\"],\n): string {\n  const attrs: string[] = [];\n  if (opts?.snapToGrid === false) attrs.push(' snapToGrid=\"0\"');\n  if (opts?.snapToObjects) attrs.push(' snapToObjects=\"1\"');\n  if (opts?.showGuides) attrs.push(' showGuides=\"1\"');\n\n  // Build guideLst with optional guides\n  let guideLstXml = \"<p:guideLst/>\";\n  if (guides && guides.length > 0) {\n    const guideXmls = guides.map((g) => {\n      const gAttrs: string[] = [];\n      if (g.orient) gAttrs.push(` orient=\"${xsdOrient.to(g.orient)}\"`);\n      if (g.pos !== undefined) gAttrs.push(` pos=\"${g.pos}\"`);\n      return `<p:guide${gAttrs.join(\"\")}/>`;\n    });\n    guideLstXml = `<p:guideLst>${guideXmls.join(\"\")}</p:guideLst>`;\n  }\n\n  return (\n    `<p:cSldViewPr${attrs.join(\"\")}>` +\n    commonViewPrXml(opts?.view) +\n    guideLstXml +\n    \"</p:cSldViewPr>\"\n  );\n}\n\nexport function buildViewPropsXml(opts?: ViewPropertiesOptions): string {\n  const ns =\n    'xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ' +\n    'xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ' +\n    'xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"';\n\n  const gridCx = opts?.gridSpacing?.cx ?? 72008;\n  const gridCy = opts?.gridSpacing?.cy ?? 72008;\n\n  const parts: string[] = [];\n\n  let rootAttrs = \"\";\n  if (opts?.lastView) rootAttrs += ` lastView=\"${LAST_VIEW_XSD[opts.lastView]}\"`;\n  if (opts?.showComments === false) rootAttrs += ' showComments=\"0\"';\n\n  parts.push(`<p:viewPr ${ns}${rootAttrs}>`);\n  parts.push(buildNormalViewPrXml(opts?.normalView));\n  parts.push(\"<p:slideViewPr>\");\n  parts.push(buildCSldViewPrXml(opts?.slideView, opts?.guides));\n  parts.push(\"</p:slideViewPr>\");\n\n  // outlineViewPr — sequence: cViewPr (required), sldLst\n  if (opts?.outlineView) {\n    let outlineXml = \"<p:outlineViewPr>\";\n    outlineXml += commonViewPrXml(opts.outlineView.view);\n    if (opts.outlineView.slides && opts.outlineView.slides.length > 0) {\n      outlineXml += \"<p:sldLst>\";\n      for (const sl of opts.outlineView.slides) {\n        const slAttrs: string[] = [`r:id=\"${sl.rId}\"`];\n        if (sl.collapse) slAttrs.push(' collapse=\"1\"');\n        outlineXml += `<p:sld ${slAttrs.join(\" \")}/>`;\n      }\n      outlineXml += \"</p:sldLst>\";\n    }\n    outlineXml += \"</p:outlineViewPr>\";\n    parts.push(outlineXml);\n  }\n\n  // notesTextViewPr — cViewPr only\n  if (opts?.notesTextView) {\n    parts.push(`<p:notesTextViewPr>${commonViewPrXml(opts.notesTextView)}</p:notesTextViewPr>`);\n  }\n\n  // sorterViewPr — sequence: cViewPr (not cSldViewPr!)\n  if (opts?.sorterView) {\n    const sorterAttrs: string[] = [];\n    if (opts.sorterView.showFormatting) sorterAttrs.push(' showFormatting=\"1\"');\n    parts.push(`<p:sorterViewPr${sorterAttrs.join(\" \")}>`);\n    parts.push(commonViewPrXml(opts.sorterView.view));\n    parts.push(\"</p:sorterViewPr>\");\n  }\n\n  // notesViewPr — sequence: cSldViewPr\n  if (opts?.notesView) {\n    parts.push(\"<p:notesViewPr>\");\n    parts.push(\n      typeof opts.notesView === \"boolean\"\n        ? buildCSldViewPrXml()\n        : buildCSldViewPrXml(\n            opts.notesView.view ? { view: opts.notesView.view } : undefined,\n            opts.notesView.guides,\n          ),\n    );\n    parts.push(\"</p:notesViewPr>\");\n  }\n\n  parts.push(`<p:gridSpacing cx=\"${gridCx}\" cy=\"${gridCy}\"/>`);\n  parts.push(\"</p:viewPr>\");\n  return parts.join(\"\");\n}\n","/**\n * View Properties (p:viewPr) descriptor for PPTX.\n *\n * @module\n */\n\nimport { parseOnOff } from \"@office-open/core\";\nimport { xsdOrient } from \"@office-open/core\";\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element as XmlElement } from \"@office-open/xml\";\nimport {\n  buildViewPropsXml,\n  type CommonViewPropertiesOptions,\n  type NormalViewOptions,\n  type NormalViewPortionOptions,\n  type NotesViewOptions,\n  type SlideViewOptions,\n  type ViewPropertiesOptions,\n} from \"@parts/view-properties\";\n\n// ── Descriptor ──\n\nexport const viewPropsDesc: CustomDescriptor<ViewPropertiesOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    return buildViewPropsXml(opts);\n  },\n\n  parse(el, _ctx) {\n    return parseViewProperties(el);\n  },\n};\n\n// ── Parse ──\n\n/** Parse p:cViewPr (CT_CommonViewProperties): scale + origin + varScale. */\nfunction parseCommonViewProperties(el: XmlElement): CommonViewPropertiesOptions {\n  const view: CommonViewPropertiesOptions = {};\n  if (parseOnOff(attr(el, \"varScale\"))) view.variableScale = true;\n  const scale = findChild(el, \"p:scale\");\n  if (scale) {\n    const sx = findChild(scale, \"a:sx\");\n    const n = sx ? attrNum(sx, \"n\") : undefined;\n    const d = sx ? attrNum(sx, \"d\") : undefined;\n    if (n !== undefined && d !== undefined) view.scale = { numerator: n, denominator: d };\n  }\n  const origin = findChild(el, \"p:origin\");\n  if (origin) {\n    const x = attrNum(origin, \"x\");\n    const y = attrNum(origin, \"y\");\n    if (x !== undefined || y !== undefined) view.origin = { x: x ?? 0, y: y ?? 0 };\n  }\n  return view;\n}\n\n/** Parse p:restoredLeft / p:restoredTop (CT_NormalViewPortion). */\nfunction parseNormalViewPortion(el: XmlElement): NormalViewPortionOptions {\n  const portion: NormalViewPortionOptions = { size: attrNum(el, \"sz\") ?? 0 };\n  const autoAdjust = attrNum(el, \"autoAdjust\");\n  if (autoAdjust !== undefined) portion.autoAdjust = autoAdjust === 1;\n  return portion;\n}\n\n/** Read a p:guideLst's entries (shared by slide-view and notes-view guides). */\nfunction parseGuideLst(\n  guideLst: XmlElement,\n): { orient?: \"vertical\" | \"horizontal\"; pos?: number }[] {\n  const guides: { orient?: \"vertical\" | \"horizontal\"; pos?: number }[] = [];\n  for (const guide of guideLst.elements ?? []) {\n    if (guide.name !== \"p:guide\") continue;\n    const entry: { orient?: \"vertical\" | \"horizontal\"; pos?: number } = {};\n    const orient = attr(guide, \"orient\");\n    if (orient) entry.orient = xsdOrient.from(orient) as \"vertical\" | \"horizontal\";\n    const pos = attrNum(guide, \"pos\");\n    if (pos !== undefined) entry.pos = pos;\n    guides.push(entry);\n  }\n  return guides;\n}\n\nfunction parseViewProperties(el: XmlElement): ViewPropertiesOptions {\n  const result: Partial<ViewPropertiesOptions> = {};\n\n  if (el.attributes) {\n    const a = el.attributes;\n    if (a[\"lastView\"]) {\n      const reverseMap: Record<string, string> = {\n        sldView: \"slideView\",\n        sldMasterView: \"slideMasterView\",\n        notesView: \"notesView\",\n        handoutView: \"handoutView\",\n        outlineView: \"outlineView\",\n        sldSorterView: \"slideSorterView\",\n      };\n      const mapped = reverseMap[a[\"lastView\"]];\n      if (mapped) result.lastView = mapped as ViewPropertiesOptions[\"lastView\"];\n    }\n    if (a[\"showComments\"] !== undefined)\n      result.showComments = parseOnOff(a[\"showComments\"]) ?? true;\n  }\n\n  // p:normalViewPr\n  const normalViewPr = findChild(el, \"p:normalViewPr\");\n  if (normalViewPr) {\n    const nv: Partial<NormalViewOptions> = {};\n    if (String(normalViewPr.attributes?.[\"showOutlineIcons\"]) === \"0\") nv.showOutlineIcons = false;\n    if (parseOnOff(normalViewPr.attributes?.[\"snapVertSplitter\"])) nv.snapVertSplitter = true;\n    const vertBarState = attr(normalViewPr, \"vertBarState\");\n    if (vertBarState) nv.vertBarState = vertBarState as NormalViewOptions[\"vertBarState\"];\n    const horzBarState = attr(normalViewPr, \"horzBarState\");\n    if (horzBarState) nv.horzBarState = horzBarState as NormalViewOptions[\"horzBarState\"];\n    if (parseOnOff(normalViewPr.attributes?.[\"preferSingleView\"])) nv.preferSingleView = true;\n    const restoredLeft = findChild(normalViewPr, \"p:restoredLeft\");\n    if (restoredLeft) nv.restoredLeft = parseNormalViewPortion(restoredLeft);\n    const restoredTop = findChild(normalViewPr, \"p:restoredTop\");\n    if (restoredTop) nv.restoredTop = parseNormalViewPortion(restoredTop);\n    if (Object.keys(nv).length > 0) result.normalView = nv as NormalViewOptions;\n  }\n\n  // p:slideViewPr > p:cSldViewPr (zoom, guides, slide-view toggles)\n  const slideViewPr = findChild(el, \"p:slideViewPr\");\n  if (slideViewPr) {\n    const cSldViewPr = findChild(slideViewPr, \"p:cSldViewPr\");\n    if (cSldViewPr) {\n      const sv: Partial<SlideViewOptions> = {};\n      if (String(cSldViewPr.attributes?.[\"snapToGrid\"]) === \"0\") sv.snapToGrid = false;\n      if (parseOnOff(cSldViewPr.attributes?.[\"snapToObjects\"])) sv.snapToObjects = true;\n      if (parseOnOff(cSldViewPr.attributes?.[\"showGuides\"])) sv.showGuides = true;\n\n      const cViewPr = findChild(cSldViewPr, \"p:cViewPr\");\n      if (cViewPr) sv.view = parseCommonViewProperties(cViewPr);\n\n      if (Object.keys(sv).length > 0) result.slideView = sv as SlideViewOptions;\n\n      const guideLst = findChild(cSldViewPr, \"p:guideLst\");\n      if (guideLst) {\n        const guides = parseGuideLst(guideLst);\n        if (guides.length > 0) result.guides = guides;\n      }\n    }\n  }\n\n  // p:outlineViewPr — cViewPr (required) + sldLst\n  const outlineViewPr = findChild(el, \"p:outlineViewPr\");\n  if (outlineViewPr) {\n    const cViewPr = findChild(outlineViewPr, \"p:cViewPr\");\n    if (cViewPr) {\n      const view = parseCommonViewProperties(cViewPr);\n      const sldLst = findChild(outlineViewPr, \"p:sldLst\");\n      const slides: NonNullable<NonNullable<ViewPropertiesOptions[\"outlineView\"]>[\"slides\"]> = [];\n      if (sldLst) {\n        for (const sld of sldLst.elements ?? []) {\n          if (sld.name !== \"p:sld\") continue;\n          const entry: { rId: string; collapse?: boolean } = { rId: attr(sld, \"r:id\") ?? \"\" };\n          if (parseOnOff(attr(sld, \"collapse\"))) entry.collapse = true;\n          slides.push(entry);\n        }\n      }\n      result.outlineView = slides.length > 0 ? { view, slides } : { view };\n    }\n  }\n\n  // p:notesTextViewPr — cViewPr only\n  const notesTextViewPr = findChild(el, \"p:notesTextViewPr\");\n  if (notesTextViewPr) {\n    const cViewPr = findChild(notesTextViewPr, \"p:cViewPr\");\n    if (cViewPr) result.notesTextView = parseCommonViewProperties(cViewPr);\n  }\n\n  // p:notesViewPr — cSldViewPr (view + guides)\n  const notesViewPr = findChild(el, \"p:notesViewPr\");\n  if (notesViewPr) {\n    const cSld = findChild(notesViewPr, \"p:cSldViewPr\");\n    const nv: NotesViewOptions = {};\n    const cViewPr = cSld ? findChild(cSld, \"p:cViewPr\") : undefined;\n    if (cViewPr) nv.view = parseCommonViewProperties(cViewPr);\n    const guideLst = cSld ? findChild(cSld, \"p:guideLst\") : undefined;\n    if (guideLst) {\n      const guides = parseGuideLst(guideLst);\n      if (guides.length > 0) nv.guides = guides;\n    }\n    result.notesView = Object.keys(nv).length > 0 ? nv : true;\n  }\n\n  // p:sorterViewPr — cViewPr + @showFormatting\n  const sorterViewPr = findChild(el, \"p:sorterViewPr\");\n  if (sorterViewPr) {\n    const cViewPr = findChild(sorterViewPr, \"p:cViewPr\");\n    if (cViewPr) {\n      const sorter: NonNullable<ViewPropertiesOptions[\"sorterView\"]> = {\n        view: parseCommonViewProperties(cViewPr),\n      };\n      if (String(sorterViewPr.attributes?.[\"showFormatting\"]) === \"0\") {\n        sorter.showFormatting = false;\n      }\n      result.sorterView = sorter;\n    }\n  }\n\n  const gridSpacing = findChild(el, \"p:gridSpacing\");\n  if (gridSpacing?.attributes) {\n    const cx = attrNum(gridSpacing, \"cx\");\n    const cy = attrNum(gridSpacing, \"cy\");\n    if (cx !== undefined || cy !== undefined) {\n      result.gridSpacing = { cx: cx ?? 72008, cy: cy ?? 72008 };\n    }\n  }\n\n  return result as ViewPropertiesOptions;\n}\n","import type { PassthroughRelationship } from \"@office-open/core\";\nimport {\n  RELATIONSHIP_TYPES,\n  appPropertiesDesc,\n  collectPassthroughParts,\n  contentTypesDesc,\n  customPropertiesDesc,\n  isEncryptedContainer,\n  parseArchive,\n  parseCorePropsElement,\n  partPathToRelsPath,\n  ParsedArchive,\n  resolveRelationshipTarget,\n} from \"@office-open/core\";\nimport type { DataType } from \"@office-open/core\";\nimport { extUriMatches, toUint8Array, toUint8ArrayAsync } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport { themeDesc, themeOverrideDesc } from \"@office-open/core/theme\";\nimport type { Element } from \"@office-open/xml\";\nimport { attr, attrNum, findChild } from \"@office-open/xml\";\n\nimport { PptxReadContext, ParseContext } from \"./context\";\nimport { commentAuthorsDesc, slideCommentsDesc } from \"./parts/descriptors/comments\";\nimport { handoutMasterDesc } from \"./parts/descriptors/handout-master\";\nimport { notesMasterDesc } from \"./parts/descriptors/notes-master\";\nimport { notesSlideDesc } from \"./parts/descriptors/notes-slide\";\nimport { presentationDesc } from \"./parts/descriptors/presentation\";\nimport { presentationPropertiesDesc } from \"./parts/descriptors/presentation-properties\";\nimport { slideDesc } from \"./parts/descriptors/slide\";\nimport { slideLayoutDesc } from \"./parts/descriptors/slide-layout\";\nimport { slideMasterDesc } from \"./parts/descriptors/slide-master\";\nimport { tableStylesDesc } from \"./parts/descriptors/table-styles\";\nimport { viewPropsDesc } from \"./parts/descriptors/view-properties\";\n\nexport { parseArchive };\n\nimport type { CustomerDataOptions } from \"./parts/presentation\";\nimport type { SlideLayoutType } from \"./parts/slide-layout\";\nimport type {\n  LayoutDefinition,\n  MasterDefinition,\n  SlideOptions,\n  SlideCommentOptions,\n  PresentationOptions,\n} from \"./shared/file\";\n\n/**\n * All part paths extracted from the PPTX package.\n * Field names correspond directly to the OOXML directory structure.\n */\nexport interface PptxPartRefs {\n  /** ppt/theme/themeN.xml */\n  themes: string[];\n  /** ppt/notesMasters/notesMasterN.xml */\n  notesMasters: string[];\n  /** ppt/handoutMasters/handoutMasterN.xml */\n  handoutMasters: string[];\n  /** ppt/handoutMasters/handoutMasterN.xml presence. */\n  handoutMaster: boolean;\n  /** ppt/commentAuthors.xml */\n  commentAuthors?: string;\n  /** ppt/comments/commentN.xml (from slide rels) */\n  comments: string[];\n  /** ppt/charts/chartN.xml (from slide rels) */\n  charts: string[];\n  /** ppt/diagrams/dataN.xml (from slide rels) */\n  diagramData: string[];\n  /** ppt/media/* (all media files) */\n  media: string[];\n}\n\nexport interface PptxDocument {\n  doc: ParsedArchive;\n  /** ppt/presentation.xml root element (p:presentation) */\n  presentation?: Element;\n  /** ppt/slides/slideN.xml */\n  slides: string[];\n  /** ppt/slideMasters/slideMasterN.xml */\n  slideMasters: string[];\n  /** ppt/slideLayouts/slideLayoutN.xml */\n  slideLayouts: string[];\n  /** ppt/notesSlides/notesSlideN.xml */\n  notesSlides: string[];\n  partRefs: PptxPartRefs;\n  /** ppt/presProps.xml */\n  presProps?: string;\n  /** ppt/viewProps.xml */\n  viewProps?: string;\n  /** ppt/tableStyles.xml */\n  tableStyles?: string;\n  /** docProps/core.xml */\n  coreProps?: string;\n  /** docProps/app.xml */\n  appProps?: string;\n  /** docProps/custom.xml */\n  customProps?: string;\n}\n\nfunction sortByNumber(paths: string[]): string[] {\n  return paths.sort((a, b) => {\n    const numA = parseInt(a.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n    const numB = parseInt(b.match(/(\\d+)/)?.[1] ?? \"0\", 10);\n    return numA - numB;\n  });\n}\n\nfunction xmlKeys(keys: string[]): string[] {\n  return keys.filter((k) => k.endsWith(\".xml\"));\n}\n\nfunction parseRootRels(doc: ParsedArchive): {\n  coreProps?: string;\n  appProps?: string;\n  customProps?: string;\n} {\n  const relsEl = doc.get(\"_rels/.rels\");\n  if (!relsEl) return {};\n\n  // Canonical OPC/docProps relationship types. Duplicate rels with variant\n  // URIs (camelCase …/extendedProperties, the …/officedocument/… core form)\n  // exist in the wild — the canonical spelling wins, the losing part flows\n  // through the passthrough pipeline untouched.\n  const canonicalCore = RELATIONSHIP_TYPES.metadataCoreProperties;\n  const canonicalApp = RELATIONSHIP_TYPES.extendedProperties;\n  const canonicalCustom = RELATIONSHIP_TYPES.customProperties;\n  let coreProps: string | undefined;\n  let appProps: string | undefined;\n  let customProps: string | undefined;\n\n  for (const child of relsEl.elements ?? []) {\n    if (child.name !== \"Relationship\") continue;\n    const type = attr(child, \"Type\") ?? \"\";\n    const target = attr(child, \"Target\") ?? \"\";\n    if (!target) continue;\n\n    const path = target.startsWith(\"/\") ? target.slice(1) : target;\n\n    // Transitional packages use the oclc URI form with camelCase segments\n    // (…/extendedProperties); normalize case and hyphens so both resolve.\n    const relType = type.toLowerCase().replaceAll(\"-\", \"\");\n    if (relType.includes(\"/coreproperties\")) {\n      if (type === canonicalCore || coreProps === undefined) coreProps = path;\n    } else if (relType.includes(\"/extendedproperties\")) {\n      if (type === canonicalApp || appProps === undefined) appProps = path;\n    } else if (relType.includes(\"/customproperties\")) {\n      if (type === canonicalCustom || customProps === undefined) customProps = path;\n    }\n  }\n\n  return { coreProps, appProps, customProps };\n}\n\nfunction parseSlideRels(doc: ParsedArchive, slidePaths: string[], refs: PptxPartRefs): void {\n  const commentsSet = new Set(refs.comments);\n  const chartsSet = new Set(refs.charts);\n  const diagramDataSet = new Set(refs.diagramData);\n  const mediaSet = new Set(refs.media);\n\n  for (const slidePath of slidePaths) {\n    const relsPath = partPathToRelsPath(slidePath);\n\n    const relsEl = doc.get(relsPath);\n    if (!relsEl) continue;\n\n    for (const child of relsEl.elements ?? []) {\n      if (child.name !== \"Relationship\") continue;\n      const type = attr(child, \"Type\") ?? \"\";\n      const target = attr(child, \"Target\") ?? \"\";\n      if (!target) continue;\n\n      const path = resolveRelationshipTarget(slidePath, target);\n\n      if (type.includes(\"/comments\") && !type.includes(\"commentAuthors\")) {\n        commentsSet.add(path);\n      } else if (type.includes(\"/chart\")) {\n        chartsSet.add(path);\n      } else if (type.includes(\"/diagramData\")) {\n        diagramDataSet.add(path);\n      } else if (\n        type.includes(\"/image\") ||\n        type.includes(\"/video\") ||\n        type.includes(\"/audio\") ||\n        type.includes(\"/media\")\n      ) {\n        mediaSet.add(path);\n      }\n    }\n  }\n\n  refs.comments = [...commentsSet];\n  refs.charts = [...chartsSet];\n  refs.diagramData = [...diagramDataSet];\n  refs.media = [...mediaSet];\n}\n\nexport function parsePptx(data: DataType): PptxDocument {\n  return parsePptxArchive(parseArchive(toUint8Array(data)));\n}\n\n/** Archive-backed core of {@link parsePptx} — shared with the Blob open path. */\nfunction parsePptxArchive(doc: ParsedArchive): PptxDocument {\n  const presentation = doc.get(\"ppt/presentation.xml\");\n\n  const relsXml = doc.get(\"ppt/_rels/presentation.xml.rels\");\n  const slides: string[] = [];\n  const slideMasters: string[] = [];\n  const themes: string[] = [];\n  const notesMasters: string[] = [];\n  const handoutMasters: string[] = [];\n  let presProps: string | undefined;\n  let viewProps: string | undefined;\n  let tableStyles: string | undefined;\n  let commentAuthors: string | undefined;\n\n  if (relsXml) {\n    for (const child of relsXml.elements ?? []) {\n      if (child.name !== \"Relationship\") continue;\n      const type = attr(child, \"Type\") ?? \"\";\n      const target = attr(child, \"Target\") ?? \"\";\n      if (!target) continue;\n\n      const path = resolveRelationshipTarget(\"ppt/presentation.xml\", target);\n\n      if (type.includes(\"/slideMaster\")) {\n        slideMasters.push(path);\n      } else if (\n        type.includes(\"/slide\") &&\n        !type.includes(\"slideLayout\") &&\n        !type.includes(\"slideMaster\")\n      ) {\n        slides.push(path);\n      } else if (type.includes(\"/theme\")) {\n        themes.push(path);\n      } else if (type.includes(\"/notesMaster\")) {\n        notesMasters.push(path);\n      } else if (type.includes(\"/handoutMaster\")) {\n        handoutMasters.push(path);\n      } else if (type.includes(\"/presProps\")) {\n        presProps = path;\n      } else if (type.includes(\"/viewProps\")) {\n        viewProps = path;\n      } else if (type.includes(\"/tableStyles\")) {\n        tableStyles = path;\n      } else if (type.includes(\"/commentAuthors\")) {\n        commentAuthors = path;\n      }\n    }\n  }\n\n  sortByNumber(slides);\n  sortByNumber(slideMasters);\n  sortByNumber(themes);\n  sortByNumber(notesMasters);\n  sortByNumber(handoutMasters);\n\n  const slideLayouts = sortByNumber(xmlKeys(doc.keys(\"ppt/slideLayouts/\")));\n  const notesSlides = sortByNumber(xmlKeys(doc.keys(\"ppt/notesSlides/\")));\n\n  const partRefs: PptxPartRefs = {\n    themes,\n    notesMasters,\n    handoutMasters,\n    handoutMaster: handoutMasters.length > 0,\n    commentAuthors,\n    comments: [],\n    charts: [],\n    diagramData: [],\n    media: doc.keys(\"ppt/media/\"),\n  };\n\n  parseSlideRels(doc, slides, partRefs);\n  sortByNumber(partRefs.comments);\n  sortByNumber(partRefs.charts);\n  sortByNumber(partRefs.diagramData);\n\n  const { coreProps, appProps, customProps } = parseRootRels(doc);\n\n  return {\n    doc,\n    presentation,\n    slides,\n    slideMasters,\n    slideLayouts,\n    notesSlides,\n    partRefs,\n    presProps,\n    viewProps,\n    tableStyles,\n    coreProps,\n    appProps,\n    customProps,\n  };\n}\n\n/**\n * Parse a single slide's relationship file into a Map<rId, path>.\n */\nfunction parseSlideRelMap(doc: ParsedArchive, slidePath: string): Map<string, string> {\n  const rels = new Map<string, string>();\n  const relsPath = partPathToRelsPath(slidePath);\n\n  const relsEl = doc.get(relsPath);\n  if (!relsEl) return rels;\n\n  for (const child of relsEl.elements ?? []) {\n    if (child.name !== \"Relationship\") continue;\n    const id = attr(child, \"Id\") ?? \"\";\n    const target = attr(child, \"Target\") ?? \"\";\n    if (!id || !target) continue;\n    // External links (hyperlinks) keep their original URL target\n    if (attr(child, \"TargetMode\") === \"External\") {\n      rels.set(id, target);\n    } else {\n      rels.set(id, resolveRelationshipTarget(slidePath, target));\n    }\n  }\n\n  return rels;\n}\n\n/**\n * External relationships of slide parts. The shared collector drops\n * part-level External entries because a rebuilt owner usually remaps its\n * rIds — but a slide re-emits unrecognized content verbatim (rawXml children,\n * e.g. a linked p:oleObj) whose source rIds never renumber, so each\n * relationship must survive with its source id for the reference to stay\n * resolvable.\n */\nfunction collectExternalPartRelationships(\n  doc: ParsedArchive,\n  partPaths: readonly string[],\n): PassthroughRelationship[] {\n  const out: PassthroughRelationship[] = [];\n  for (const partPath of partPaths) {\n    const relsEl = doc.get(partPathToRelsPath(partPath));\n    for (const rel of relsEl?.elements ?? []) {\n      if (rel.name !== \"Relationship\") continue;\n      if (attr(rel, \"TargetMode\") !== \"External\") continue;\n      const relationshipType = attr(rel, \"Type\");\n      const target = attr(rel, \"Target\");\n      const rId = attr(rel, \"Id\");\n      if (!relationshipType || !target || !rId) continue;\n      out.push({ source: partPath, relationshipType, target, rId, targetMode: \"External\" });\n    }\n  }\n  return out;\n}\n\n/**\n * Build a map from each path to the rel target matching a predicate.\n */\nfunction resolveRelTargets(\n  doc: ParsedArchive,\n  paths: string[],\n  predicate: (target: string) => boolean,\n): Map<string, string> {\n  const map = new Map<string, string>();\n  for (const path of paths) {\n    for (const target of parseSlideRelMap(doc, path).values()) {\n      if (predicate(target)) map.set(path, target);\n    }\n  }\n  return map;\n}\n\n/**\n * Parse p14:sectionLst from presentation.xml and map each slide path to its\n * section name. Bridges p14:sldId (by slide id) -> p:sldIdLst (slide id ->\n * rId) -> presentation rels (rId -> path).\n */\nfunction parseSlideSections(\n  presentation: Element | undefined,\n  doc: ParsedArchive,\n): Map<string, string> {\n  const pathToSection = new Map<string, string>();\n  if (!presentation) return pathToSection;\n\n  const extLst = findChild(presentation, \"p:extLst\");\n  if (!extLst) return pathToSection;\n\n  let sectionLst: Element | undefined;\n  for (const ext of extLst.elements ?? []) {\n    if (ext.name !== \"p:ext\") continue;\n    if (!extUriMatches(attr(ext, \"uri\"), \"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}\")) continue;\n    sectionLst = findChild(ext, \"p14:sectionLst\");\n    if (sectionLst) break;\n  }\n  if (!sectionLst) return pathToSection;\n\n  // slideId -> sectionName\n  const sectionBySlideId = new Map<number, string>();\n  for (const section of sectionLst.elements ?? []) {\n    if (section.name !== \"p14:section\") continue;\n    const name = attr(section, \"name\");\n    if (!name) continue;\n    const sldIdLst = findChild(section, \"p14:sldIdLst\");\n    for (const sldId of sldIdLst?.elements ?? []) {\n      if (sldId.name !== \"p14:sldId\") continue;\n      const id = attrNum(sldId, \"id\");\n      if (id !== undefined) sectionBySlideId.set(id, name);\n    }\n  }\n  if (sectionBySlideId.size === 0) return pathToSection;\n\n  // slideId -> rId (from p:sldIdLst)\n  const sldIdLst = findChild(presentation, \"p:sldIdLst\");\n  const rIdBySlideId = new Map<number, string>();\n  for (const sldId of sldIdLst?.elements ?? []) {\n    if (sldId.name !== \"p:sldId\") continue;\n    const id = attrNum(sldId, \"id\");\n    const rId = attr(sldId, \"r:id\");\n    if (id !== undefined && rId) rIdBySlideId.set(id, rId);\n  }\n\n  // rId -> path (from presentation.xml.rels)\n  const relsEl = doc.get(\"ppt/_rels/presentation.xml.rels\");\n  const pathByRId = new Map<string, string>();\n  for (const child of relsEl?.elements ?? []) {\n    if (child.name !== \"Relationship\") continue;\n    const id = attr(child, \"Id\");\n    const target = attr(child, \"Target\");\n    if (id && target) pathByRId.set(id, resolveRelationshipTarget(\"ppt/presentation.xml\", target));\n  }\n\n  for (const [slideId, name] of sectionBySlideId) {\n    const rId = rIdBySlideId.get(slideId);\n    if (!rId) continue;\n    const path = pathByRId.get(rId);\n    if (path) pathToSection.set(path, name);\n  }\n\n  return pathToSection;\n}\n\n/**\n * Parse a .pptx file and convert it into PresentationOptions.\n *\n * This is the main public API for parsing PPTX files. Async so that `Blob`\n * (including `File`) and `ReadableStream` inputs are accepted alongside raw\n * bytes — parts are indexed and decompressed on demand.\n * The returned options can be passed directly to `new Presentation(parsed)`\n * to recreate the presentation.\n *\n * @param data - .pptx file content — raw bytes, base64 string, Blob, or ReadableStream\n * @returns Parsed presentation options\n */\nexport async function parsePresentation(data: DataType): Promise<PresentationOptions> {\n  // Blob/File inputs bypass full materialization: the archive indexes and\n  // inflates through random-access windows, so a multi-GB package costs only\n  // the parts actually read.\n  if (data instanceof Blob) {\n    const head = new Uint8Array(await data.slice(0, 8).arrayBuffer());\n    if (isEncryptedContainer(head)) {\n      return { encrypted: { data: await toUint8ArrayAsync(data) } };\n    }\n    return parsePresentationFromPptx(parsePptxArchive(await ParsedArchive.open(data)));\n  }\n  return parsePresentationFromBytes(await toUint8ArrayAsync(data));\n}\n\n/**\n * Synchronous counterpart of {@link parsePresentation}: same result, but\n * `Blob` and `ReadableStream` inputs throw (normalize them to bytes first,\n * or use the async entry).\n */\nexport function parsePresentationSync(data: DataType): PresentationOptions {\n  return parsePresentationFromBytes(toUint8Array(data));\n}\n\nfunction parsePresentationFromBytes(uint8: Uint8Array): PresentationOptions {\n  // Encrypted package (OLE2/CFB container): the plaintext needs the password,\n  // so carry the source bytes verbatim for generate() to re-emit.\n  if (isEncryptedContainer(uint8)) {\n    return { encrypted: { data: uint8 } };\n  }\n\n  return parsePresentationFromPptx(parsePptx(uint8));\n}\n\nfunction parsePresentationFromPptx(pptx: PptxDocument): PresentationOptions {\n  const opts: Partial<PresentationOptions> = {};\n  if (pptx.partRefs.handoutMaster) opts.includeHandoutMaster = true;\n  const sectionBySlidePath = parseSlideSections(pptx.presentation, pptx.doc);\n  // Package-level fallback context — parts parsed with it carry no rel wiring\n  // (their relationship layer is resolved separately around the descriptor).\n  const bareReadCtx = new PptxReadContext(new ParseContext(pptx, new Map()));\n\n  // 1. Parse slide size from p:sldSz\n  if (pptx.presentation) {\n    const sldSz = findChild(pptx.presentation, \"p:sldSz\");\n    if (sldSz) {\n      const cx = attrNum(sldSz, \"cx\");\n      const cy = attrNum(sldSz, \"cy\");\n      if (cx === 12192000 && cy === 6858000) {\n        opts.size = \"16:9\";\n      } else if (cx === 9144000 && cy === 6858000) {\n        opts.size = \"4:3\";\n      } else if (cx && cy) {\n        opts.size = { width: cx, height: cy };\n      }\n    }\n\n    // p:custDataLst — customer data parts and the tags part reference.\n    const custDataLst = findChild(pptx.presentation, \"p:custDataLst\");\n    if (custDataLst) {\n      const customerData: CustomerDataOptions = {};\n      const data: { rId: string }[] = [];\n      for (const child of custDataLst.elements ?? []) {\n        if (child.name === \"p:custData\") {\n          const rId = attr(child, \"r:id\");\n          if (rId) data.push({ rId });\n        } else if (child.name === \"p:tags\") {\n          const rId = attr(child, \"r:id\");\n          if (rId) customerData.tags = { rId };\n        }\n      }\n      if (data.length > 0) customerData.data = data;\n      if (Object.keys(customerData).length > 0) opts.customerData = customerData;\n    }\n  }\n\n  // 1b. Presentation-level data fields — via the descriptor's own parse (the\n  // same contract stringify uses); id/count/rId wiring stays compiler-owned.\n  if (pptx.presentation) {\n    const presPart = presentationDesc.parse(pptx.presentation, bareReadCtx);\n    opts.photoAlbum = presPart.photoAlbum;\n    opts.defaultTextStyle = presPart.defaultTextStyle;\n    if (presPart.kinsoku) opts.kinsoku = presPart.kinsoku;\n    if (presPart.customShows) opts.customShows = presPart.customShows;\n    if (presPart.embeddedFonts) opts.embeddedFonts = presPart.embeddedFonts;\n    if (presPart.modifyVerifier) opts.modifyVerifier = presPart.modifyVerifier;\n    if (presPart.smartTags) opts.smartTags = presPart.smartTags;\n    if (presPart.ext) opts.ext = presPart.ext;\n  }\n\n  // 2. Parse core properties\n  if (pptx.coreProps) {\n    const corePropsEl = pptx.doc.get(pptx.coreProps);\n    if (corePropsEl) {\n      const cp = parseCorePropsElement(corePropsEl);\n      // Empty strings are meaningful (element present, text empty) — assign\n      // the whole shape so they survive round-trip.\n      Object.assign(opts, cp);\n    }\n  }\n\n  // 2b. Parse extended (app) properties\n  if (pptx.appProps) {\n    const appPropsEl = pptx.doc.get(pptx.appProps);\n    if (appPropsEl) {\n      const ap = appPropertiesDesc.parse(appPropsEl, {} as ReadContext);\n      if (ap && Object.keys(ap).length > 0) opts.appProperties = ap;\n    }\n  }\n\n  // 2c. Parse custom properties — presence-based: an empty docProps/custom.xml\n  // round-trips as an empty part, keeping part + rel + Override in sync.\n  if (pptx.customProps) {\n    const customPropsEl = pptx.doc.get(pptx.customProps);\n    if (customPropsEl) {\n      const cp = customPropertiesDesc.parse(customPropsEl, {} as ReadContext);\n      opts.customProperties = cp.properties ?? [];\n    }\n  }\n\n  // 3. Parse presentation properties (show/web/print/htmlPublish/colorMru)\n  if (pptx.presProps) {\n    const presPropsEl = pptx.doc.get(pptx.presProps);\n    if (presPropsEl) {\n      const presPropsOpts = presentationPropertiesDesc.parse(presPropsEl, {} as ReadContext);\n      if (presPropsOpts.show) opts.show = presPropsOpts.show;\n      if (presPropsOpts.web) opts.web = presPropsOpts.web;\n      if (presPropsOpts.print) opts.print = presPropsOpts.print;\n      if (presPropsOpts.htmlPublish) opts.htmlPublish = presPropsOpts.htmlPublish;\n      if (presPropsOpts.colorMru) opts.colorMru = presPropsOpts.colorMru;\n      if (presPropsOpts.ext) opts.presentationPropertiesExt = presPropsOpts.ext;\n    }\n  }\n\n  // 3b. Parse view properties\n  if (pptx.viewProps) {\n    const viewPropsEl = pptx.doc.get(pptx.viewProps);\n    if (viewPropsEl) {\n      const viewOpts = viewPropsDesc.parse(viewPropsEl, {} as ReadContext);\n      if (Object.keys(viewOpts).length > 0) opts.view = viewOpts;\n    }\n  }\n\n  // 3c. Parse table styles\n  if (pptx.tableStyles) {\n    const tableStylesEl = pptx.doc.get(pptx.tableStyles);\n    if (tableStylesEl) {\n      const tableStylesResult = tableStylesDesc.parse(tableStylesEl, {} as ReadContext);\n      if (tableStylesResult.opts) opts.tableStyles = tableStylesResult.opts;\n    }\n  }\n\n  // 4. Build relationship maps\n  const masterThemePaths = resolveRelTargets(\n    pptx.doc,\n    pptx.slideMasters,\n    (t) => t.includes(\"/theme\") && !t.includes(\"/themeOverride\") && !t.includes(\"/themeManager\"),\n  );\n  const layoutThemeOverridePaths = resolveRelTargets(pptx.doc, pptx.slideLayouts, (t) =>\n    t.includes(\"/themeOverride\"),\n  );\n  const layoutMasterPaths = resolveRelTargets(pptx.doc, pptx.slideLayouts, (t) =>\n    t.includes(\"/slideMaster\"),\n  );\n  const slideLayoutPaths = resolveRelTargets(pptx.doc, pptx.slides, (t) =>\n    t.includes(\"/slideLayout\"),\n  );\n\n  // 5. Parse masters\n\n  const masterDefs: MasterDefinition[] = [];\n\n  for (const [mi, masterPath] of pptx.slideMasters.entries()) {\n    const masterEl = pptx.doc.get(masterPath);\n    if (!masterEl) continue;\n\n    // Theme (resolved separately — the descriptor does not handle theme).\n    const themePath = masterThemePaths.get(masterPath);\n    const themeEl = themePath ? pptx.doc.get(themePath) : undefined;\n    const themeOptions = themeEl ? themeDesc.parse(themeEl, bareReadCtx) : undefined;\n\n    // Structured master (cSld/clrMap/sldLayoutIdLst/transition/timing/hf/txStyles).\n    // Placeholders are derived from spTree, so their positions survive round-trip.\n    // The master's own rels back r:embed resolution (a blip-filled master\n    // background references its image here).\n    const masterReadCtx = new PptxReadContext(\n      new ParseContext(pptx, parseSlideRelMap(pptx.doc, masterPath)),\n    );\n    const masterOpts = slideMasterDesc.parse(masterEl, masterReadCtx);\n\n    // Layouts belonging to this master (resolved separately — relationship layer).\n    // A layout with no .rels (sources ship such packages) still belongs when\n    // the master's sldLayoutIdLst names it — fall back to that membership.\n    const masterListedLayouts = new Set<string>();\n    const layoutIdsByPath = new Map<string, number>();\n    const sldLayoutIdLst = findChild(masterEl, \"p:sldLayoutIdLst\");\n    if (sldLayoutIdLst) {\n      const masterRelTargets = parseSlideRelMap(pptx.doc, masterPath);\n      for (const sldLayoutId of sldLayoutIdLst.elements ?? []) {\n        if (sldLayoutId.name !== \"p:sldLayoutId\") continue;\n        const rid = sldLayoutId.attributes?.[\"r:id\"];\n        const target = rid ? masterRelTargets.get(String(rid)) : undefined;\n        const idAttr = sldLayoutId.attributes?.[\"id\"];\n        if (target && pptx.slideLayouts.includes(target)) {\n          masterListedLayouts.add(target);\n          const idNum = Number(idAttr);\n          if (idAttr !== undefined && Number.isFinite(idNum)) {\n            layoutIdsByPath.set(target, idNum);\n          }\n        }\n      }\n    }\n    const masterLayouts: LayoutDefinition[] = [];\n    for (const layoutPath of pptx.slideLayouts) {\n      if (layoutMasterPaths.get(layoutPath) !== masterPath && !masterListedLayouts.has(layoutPath))\n        continue;\n      const layoutEl = pptx.doc.get(layoutPath);\n      if (layoutEl) {\n        // Fully structured def (children/background/clrMapOvr/transition/...).\n        // The compiler re-stringifies from structure, so edits survive round-trip.\n        // The layout's own rels back its r:embed resolution (background blips).\n        const layoutReadCtx = new PptxReadContext(\n          new ParseContext(pptx, parseSlideRelMap(pptx.doc, layoutPath)),\n        );\n        const layoutDef = slideLayoutDesc.parse(layoutEl, layoutReadCtx);\n        const sourceLayoutId = layoutIdsByPath.get(layoutPath);\n        if (sourceLayoutId !== undefined) layoutDef.layoutId = sourceLayoutId;\n        const themeOverridePath = layoutThemeOverridePaths.get(layoutPath);\n        const themeOverrideEl = themeOverridePath ? pptx.doc.get(themeOverridePath) : undefined;\n        if (themeOverrideEl) {\n          layoutDef.themeOverride = themeOverrideDesc.parse(themeOverrideEl, layoutReadCtx);\n        }\n        masterLayouts.push(layoutDef);\n      }\n    }\n\n    const masterName = themeOptions?.name ?? `master${mi + 1}`;\n    const masterDef: Partial<MasterDefinition> = {\n      name: masterName,\n      background: masterOpts.background,\n      children: masterOpts.children,\n      placeholders: masterOpts.placeholders,\n      colorMapping: masterOpts.colorMapping,\n      headerFooter: masterOpts.headerFooter,\n      textStyles: masterOpts.textStyles,\n      preserve: masterOpts.preserve,\n      transition: masterOpts.transition,\n      animations: masterOpts.animations,\n      customerData: masterOpts.customerData,\n      controls: masterOpts.controls,\n      cSldExt: masterOpts.cSldExt,\n      ext: masterOpts.ext,\n    };\n    if (themeOptions) masterDef.theme = themeOptions;\n    if (masterLayouts.length > 0) masterDef.layouts = masterLayouts;\n    masterDefs.push(masterDef as MasterDefinition);\n  }\n\n  // Carry every parsed master — a single source master must survive round-trip\n  // too (the compiler only synthesizes a default master when none is given).\n  if (masterDefs.length > 0) {\n    opts.masters = masterDefs;\n  }\n\n  // 5b. Parse notes masters\n  const notesMasterThemePaths = resolveRelTargets(\n    pptx.doc,\n    pptx.partRefs.notesMasters,\n    (t) => t.includes(\"/theme\") && !t.includes(\"/themeOverride\") && !t.includes(\"/themeManager\"),\n  );\n  for (const nmPath of pptx.partRefs.notesMasters) {\n    const nmEl = pptx.doc.get(nmPath);\n    if (nmEl) {\n      const nmOpts = notesMasterDesc.parse(nmEl, bareReadCtx);\n      const nmThemePath = notesMasterThemePaths.get(nmPath);\n      const nmThemeEl = nmThemePath ? pptx.doc.get(nmThemePath) : undefined;\n      if (nmThemeEl) nmOpts.theme = themeDesc.parse(nmThemeEl, bareReadCtx);\n      if (Object.keys(nmOpts).length > 0) {\n        opts.includeNotesMaster = true;\n        opts.notesMasterOptions = nmOpts;\n      }\n    }\n  }\n\n  // 5c. Parse handout masters — content plus their own theme part\n  const handoutMasterThemePaths = resolveRelTargets(\n    pptx.doc,\n    pptx.partRefs.handoutMasters,\n    (t) => t.includes(\"/theme\") && !t.includes(\"/themeOverride\") && !t.includes(\"/themeManager\"),\n  );\n  for (const hmPath of pptx.partRefs.handoutMasters) {\n    const hmEl = pptx.doc.get(hmPath);\n    if (!hmEl) continue;\n    const hmParsed = handoutMasterDesc.parse(hmEl, bareReadCtx);\n    if (hmParsed.options) {\n      const hmThemePath = handoutMasterThemePaths.get(hmPath);\n      const hmThemeEl = hmThemePath ? pptx.doc.get(hmThemePath) : undefined;\n      if (hmThemeEl) hmParsed.options.theme = themeDesc.parse(hmThemeEl, bareReadCtx);\n      opts.handoutMasterOptions = hmParsed.options;\n    }\n  }\n\n  // 6. Parse comment authors\n  const commentAuthors = new Map<number, { name: string; initials: string }>();\n  if (pptx.partRefs.commentAuthors) {\n    const authorsEl = pptx.doc.get(pptx.partRefs.commentAuthors);\n    if (authorsEl) {\n      const authors = commentAuthorsDesc.parse(authorsEl, bareReadCtx);\n      for (const a of authors) {\n        commentAuthors.set(a.id, { name: a.name, initials: a.initials });\n      }\n    }\n  }\n\n  // 7. Parse slides with layout and master references\n  const result: SlideOptions[] = [];\n  for (const slidePath of pptx.slides) {\n    const slideEl = pptx.doc.get(slidePath);\n    if (!slideEl) continue;\n\n    const slideRels = parseSlideRelMap(pptx.doc, slidePath);\n    const ctx = new ParseContext(pptx, slideRels);\n    const readCtx = new PptxReadContext(ctx);\n    // slideDesc.parse returns the slide-part fields of SlideOptions (children/\n    // background/transition/animations/…). The public-API-only fields (layout,\n    // master, comments, notes, section) are enriched below before the push.\n    const slideOpts = slideDesc.parse(slideEl, readCtx) as Record<string, unknown>;\n\n    // Resolve layout → master\n    const layoutPath = slideLayoutPaths.get(slidePath);\n    if (layoutPath) {\n      const layoutEl = pptx.doc.get(layoutPath);\n      if (layoutEl) {\n        // The layout's own rels back its r:embed resolution (background blips).\n        const layoutReadCtx = new PptxReadContext(\n          new ParseContext(pptx, parseSlideRelMap(pptx.doc, layoutPath)),\n        );\n        const layoutOpts = slideLayoutDesc.parse(layoutEl, layoutReadCtx);\n        slideOpts.layout = (layoutOpts.type ?? \"blank\") as SlideLayoutType;\n      }\n\n      const resolvedMasterPath = layoutMasterPaths.get(layoutPath);\n      if (resolvedMasterPath) {\n        const masterIdx = pptx.slideMasters.indexOf(resolvedMasterPath);\n        if (masterIdx >= 0 && masterDefs[masterIdx]) {\n          slideOpts.master = masterDefs[masterIdx].name;\n        }\n      }\n    }\n\n    // Comments via slide rels\n    for (const [, relPath] of slideRels) {\n      if (!relPath.includes(\"/comments/\")) continue;\n      const commentsEl = pptx.doc.get(relPath);\n      if (!commentsEl) continue;\n\n      const parsedComments = slideCommentsDesc.parse(commentsEl, readCtx);\n      if (parsedComments.length > 0) {\n        const comments: Partial<SlideCommentOptions>[] = [];\n        for (const cm of parsedComments) {\n          const entry: Partial<SlideCommentOptions> = { x: cm.x, y: cm.y };\n          if (cm.text) entry.text = cm.text;\n          if (cm.date) entry.date = cm.date;\n          if (cm.modified !== undefined) entry.modified = cm.modified;\n          const author = commentAuthors.get(cm.authorId);\n          if (author) {\n            entry.author = author.name;\n            if (author.initials) entry.initials = author.initials;\n          }\n          comments.push(entry);\n        }\n        if (comments.length > 0) slideOpts.comments = comments as SlideCommentOptions[];\n      }\n      break;\n    }\n\n    // Notes slide via slide rels\n    for (const [, relPath] of slideRels) {\n      if (!relPath.includes(\"/notesSlides/\")) continue;\n      const notesEl = pptx.doc.get(relPath);\n      if (!notesEl) continue;\n      const notesData = notesSlideDesc.parse(notesEl, readCtx);\n      if (\n        notesData.children ||\n        notesData.text ||\n        notesData.background ||\n        notesData.colorMappingOverride ||\n        notesData.cSldExt\n      ) {\n        slideOpts.notes = notesData;\n      }\n      break;\n    }\n\n    // Section (p14:sectionLst) — bridged via slide id -> rId -> path\n    const sectionName = sectionBySlidePath.get(slidePath);\n    if (sectionName) slideOpts.section = sectionName;\n\n    result.push(slideOpts as SlideOptions);\n  }\n\n  opts.slides = result;\n\n  // Package-wide passthrough (SDK ExtendedPart analogue): every part the model\n  // did NOT absorb is carried verbatim instead of dropped. Listed below are\n  // only parts the compiler ALWAYS re-emits — anything model-driven (layouts,\n  // themes beyond the first, charts, notes) may or may not be emitted, so it\n  // passes through and the compiler's own output at the same path wins by\n  // assembly order. Media is likewise not listed (pinned source paths).\n  const rebuilt: string[] = [\"ppt/presentation.xml\", \"ppt/_rels/presentation.xml.rels\"];\n  if (pptx.coreProps) rebuilt.push(pptx.coreProps);\n  if (pptx.appProps) rebuilt.push(pptx.appProps);\n  if (pptx.customProps) rebuilt.push(pptx.customProps);\n  for (const p of pptx.slides) {\n    rebuilt.push(p);\n    rebuilt.push(partPathToRelsPath(p));\n  }\n  for (const p of pptx.slideMasters) {\n    rebuilt.push(p);\n    rebuilt.push(partPathToRelsPath(p));\n  }\n  if (pptx.presProps) rebuilt.push(pptx.presProps);\n  if (pptx.viewProps) rebuilt.push(pptx.viewProps);\n  if (pptx.tableStyles) rebuilt.push(pptx.tableStyles);\n  const { parts: passthroughParts, relationships: passthroughRels } = collectPassthroughParts(\n    pptx.doc,\n    rebuilt,\n  );\n  passthroughRels.push(...collectExternalPartRelationships(pptx.doc, pptx.slides));\n  if (passthroughParts.length > 0) opts.rawParts = passthroughParts;\n  if (passthroughRels.length > 0) opts.passthroughRelationships = passthroughRels;\n\n  // Source content-type declarations — the compiler keeps them as the base\n  // table so round-trip preserves the Default/Override split (a .xlsx\n  // embedding stays Default-typed, a printer-settings .bin stays itself).\n  const sourceContentTypes = pptx.doc.get(\"[Content_Types].xml\");\n  if (sourceContentTypes) {\n    const ct = contentTypesDesc.parse(sourceContentTypes, {} as ReadContext);\n    if (ct) opts.contentTypes = ct;\n  }\n\n  return opts as PresentationOptions;\n}\n","import {\n  RELATIONSHIP_TYPES,\n  PPTX_NS,\n  OoxmlMimeType,\n  appendOverride,\n  appendRelationship,\n  applyCorePropertiesOverride,\n  collectPlaceholderKeys,\n  createReplacer,\n  getNextRelationshipIndex,\n  nextNumericId,\n  partPathToRelsPath,\n  removeOverride,\n  replaceHyperlinkPlaceholders,\n  strFromU8,\n  toJson,\n  unzipSync,\n  zipAndConvert,\n} from \"@office-open/core\";\nimport type { BasePatchOptions, OutputByType, OutputType } from \"@office-open/core\";\nimport { toUint8Array } from \"@office-open/core\";\nimport type { ReadContext } from \"@office-open/core/descriptor\";\nimport type { TextRunOptions } from \"@office-open/core/drawing\";\nimport { OOXML_XML_DECLARATION } from \"@office-open/xml\";\nimport { findChild, stringify, parse } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport type { AuthorEntry, CommentEntry } from \"@parts/comment\";\nimport { commentAuthorsDesc, slideCommentsDesc } from \"@parts/descriptors/comments\";\nimport { textRunDesc } from \"@parts/descriptors/text\";\nimport type { SlideCommentOptions, SlideOptions } from \"@shared/file\";\n\nimport { buildCommentData, stringifySlide } from \"./compile/slides\";\nimport { PptxWriteContext } from \"./context\";\n\n/** Reusable TextEncoder (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\n/**\n * Parts scanned for text replacement: slides, slide masters, slide layouts,\n * and notes slides. Replacing text in a master/layout propagates to every\n * dependent slide — intended for template branding.\n */\nconst TARGET_RE =\n  /^ppt\\/(?:slides\\/slide\\d+|slideMasters\\/slideMaster\\d+|slideLayouts\\/slideLayout\\d+|notesSlides\\/notesSlide\\d+)\\.xml$/;\nconst HYPERLINK_REL_TYPE = RELATIONSHIP_TYPES.hyperlink;\nconst SLIDE_PART_CONTENT_TYPE =\n  \"application/vnd.openxmlformats-officedocument.presentationml.slide+xml\";\nconst SLIDE_REL_TYPE = RELATIONSHIP_TYPES.slide;\nconst SLIDE_LAYOUT_REL_TYPE = RELATIONSHIP_TYPES.slideLayout;\nconst COMMENTS_REL_TYPE = RELATIONSHIP_TYPES.comments;\nconst COMMENT_AUTHORS_REL_TYPE = RELATIONSHIP_TYPES.commentAuthors;\nconst COMMENTS_CONTENT_TYPE =\n  \"application/vnd.openxmlformats-officedocument.presentationml.comments+xml\";\nconst COMMENT_AUTHORS_CONTENT_TYPE =\n  \"application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml\";\n\n/**\n * Inline run-level patch content. Reuses the generate vocabulary: a\n * {@link TextRunOptions} (or an array of them), or a plain string shorthand\n * for `{ text: \"…\" }`.\n */\nexport type Patch = TextRunOptions | TextRunOptions[] | string;\n\nexport interface PatchPresentationOptions<\n  T extends OutputType = OutputType,\n> extends BasePatchOptions<T, Patch> {\n  /**\n   * Slide collection edits. Appended slides inherit the template's first slide\n   * layout; replaced slides keep their existing identity (sldId/rId/rels).\n   */\n  slides?: {\n    /** Replace slides keyed by 0-based index in the slide list (sldIdLst order). */\n    replace?: Readonly<Record<number, SlideOptions>>;\n    /** Append slides after the last existing slide. */\n    append?: Readonly<SlideOptions[]>;\n    /** Remove slides by 0-based index in the slide list (sldIdLst order). */\n    remove?: readonly number[];\n  };\n  /**\n   * Comments to append per slide, keyed by 0-based slide index (sldIdLst order).\n   * Authors are merged into commentAuthors.xml (deduped by name, ids continued);\n   * per-slide comments are merged into ppt/comments/commentN.xml.\n   */\n  comments?: Readonly<Record<number, SlideCommentOptions[]>>;\n  keepOriginalStyles?: boolean;\n}\n\n/** Write context for the current patch operation — accumulates hyperlinks. */\nlet currentPatchCtx: PptxWriteContext;\n\n/**\n * Patch replacer. Serializes each run via {@link textRunDesc} so the full\n * RunProperties vocabulary (color, fill, outline, shadow, font, hyperlinks, …)\n * is supported — no hand-rolled `<a:r>` builder.\n */\nconst pptxReplacer = createReplacer({\n  ns: PPTX_NS,\n  formatChild: (child: unknown): Element[] => {\n    const runOpts = (typeof child === \"string\" ? { text: child } : child) as TextRunOptions;\n    const xmlStr = textRunDesc.stringify(runOpts, currentPatchCtx) ?? \"<a:r/>\";\n    const root = parse(xmlStr, { captureSpacesBetweenElements: true }).elements?.[0];\n    return root ? [root] : [];\n  },\n  preserveSpace: false,\n});\n\n/**\n * Normalize a user patch value into the replacer's `{ type, children }`\n * envelope. PPTX patches are always inline run-level (`type: \"paragraph\"`).\n */\nconst toReplacerPatch = (patch: Patch): { type: \"paragraph\"; children: TextRunOptions[] } =>\n  typeof patch === \"string\"\n    ? { type: \"paragraph\", children: [{ text: patch }] }\n    : { type: \"paragraph\", children: Array.isArray(patch) ? patch : [patch] };\n\nconst createRelationshipFile = (): Element => ({\n  declaration: {\n    attributes: { encoding: \"UTF-8\", standalone: \"yes\", version: \"1.0\" },\n  },\n  elements: [\n    {\n      attributes: { xmlns: \"http://schemas.openxmlformats.org/package/2006/relationships\" },\n      elements: [],\n      name: \"Relationships\",\n      type: \"element\",\n    },\n  ],\n});\n\n/** Build a bare OOXML element node. */\nconst makeElement = (name: string, attributes: Record<string, string> = {}): Element => ({\n  type: \"element\",\n  name,\n  attributes,\n  elements: [],\n});\n\n/**\n * Locate the document root element by tag. A parsed XML part is wrapped as\n * `{ declaration, elements: [<root>] }`, so named children live one level down.\n */\nconst rootElement = (doc: Element | undefined, name: string): Element | undefined =>\n  doc?.elements?.find((e) => e.name === name);\n\n/** Next 1-based slide file number given the existing slide parts. */\nconst nextSlideNumber = (xmlMap: Map<string, Element>): number => {\n  let maxN = 0;\n  for (const key of xmlMap.keys()) {\n    const m = key.match(/^ppt\\/slides\\/slide(\\d+)\\.xml$/);\n    if (m) maxN = Math.max(maxN, Number(m[1]));\n  }\n  return maxN + 1;\n};\n\n/** Next id for an appended `<p:sldId>` (255 floor → ≥256). */\nconst nextSldId = (sldIdLst: Element | undefined): number =>\n  nextNumericId(sldIdLst, \"p:sldId\", \"id\", 255);\n\n/** Resolve a relationship `r:id` to its Target via a rels part. */\nconst resolveRelTarget = (\n  rels: Element | undefined,\n  rId: string | number | undefined,\n): string | undefined => {\n  if (rId === undefined) return undefined;\n  const needle = String(rId);\n  const relationshipsRoot = rootElement(rels, \"Relationships\");\n  for (const child of relationshipsRoot?.elements ?? []) {\n    if (child.name === \"Relationship\" && String(child.attributes?.[\"Id\"]) === needle) {\n      const target = child.attributes?.[\"Target\"];\n      return target !== undefined ? String(target) : undefined;\n    }\n  }\n  return undefined;\n};\n\n/**\n * Append a slide: serialize it, then wire sldIdLst + presentation rels +\n * content types + a slide rels pointing at the first slide layout (which must\n * already exist in the template). The appended slide inherits the template's\n * layout/master; it cannot reference styles or media not already present.\n */\nconst appendSlideToMap = (\n  xmlMap: Map<string, Element>,\n  slideOpts: SlideOptions,\n  ctx: PptxWriteContext,\n): void => {\n  const newN = nextSlideNumber(xmlMap);\n  const slidePath = `ppt/slides/slide${newN}.xml`;\n\n  // Slide part — no XML declaration, matching generated slide parts.\n  xmlMap.set(slidePath, toJson(stringifySlide(slideOpts, ctx)));\n\n  // presentation.xml sldIdLst + presentation.xml.rels (the new rId ties them)\n  const presRoot = rootElement(xmlMap.get(\"ppt/presentation.xml\"), \"p:presentation\");\n  const presRels = xmlMap.get(\"ppt/_rels/presentation.xml.rels\") ?? createRelationshipFile();\n  xmlMap.set(\"ppt/_rels/presentation.xml.rels\", presRels);\n  const newRId = getNextRelationshipIndex(presRels);\n\n  const sldIdLst = findChild(presRoot, \"p:sldIdLst\");\n  if (sldIdLst) {\n    const els = sldIdLst.elements ?? (sldIdLst.elements = []);\n    els.push(makeElement(\"p:sldId\", { id: String(nextSldId(sldIdLst)), \"r:id\": `rId${newRId}` }));\n  }\n  appendRelationship(presRels, newRId, SLIDE_REL_TYPE, `slides/slide${newN}.xml`);\n\n  // [Content_Types].xml Override\n  const contentTypes = xmlMap.get(\"[Content_Types].xml\");\n  if (contentTypes) {\n    appendOverride(contentTypes, `/${slidePath}`, SLIDE_PART_CONTENT_TYPE);\n  }\n\n  // Slide rels → first slide layout (template must already provide it)\n  const slideRels = createRelationshipFile();\n  appendRelationship(slideRels, 1, SLIDE_LAYOUT_REL_TYPE, \"../slideLayouts/slideLayout1.xml\");\n  xmlMap.set(`ppt/slides/_rels/slide${newN}.xml.rels`, slideRels);\n};\n\n/** Resolve a 0-based sldIdLst index to its slide part path (ppt/slides/slideN.xml). */\nconst resolveSlidePath = (xmlMap: Map<string, Element>, index: number): string => {\n  const presRoot = rootElement(xmlMap.get(\"ppt/presentation.xml\"), \"p:presentation\");\n  const sldIdLst = findChild(presRoot, \"p:sldIdLst\");\n  const sldIds = (sldIdLst?.elements ?? []).filter((e) => e.name === \"p:sldId\");\n  const entry = sldIds[index];\n  if (!entry?.attributes?.[\"r:id\"]) {\n    throw new Error(`patchPresentation: no slide at index ${index}`);\n  }\n  const target = resolveRelTarget(\n    xmlMap.get(\"ppt/_rels/presentation.xml.rels\"),\n    entry.attributes[\"r:id\"],\n  );\n  if (!target) {\n    throw new Error(`patchPresentation: slide ${index} relationship target not found`);\n  }\n  return `ppt/${target}`;\n};\n\n/**\n * Replace a slide in place by sldIdLst index: resolve the index to its slide\n * path via presentation rels, then rewrite only that part's content. sldId,\n * rId, content types, and slide rels are left untouched.\n */\nconst replaceSlideInMap = (\n  xmlMap: Map<string, Element>,\n  index: number,\n  slideOpts: SlideOptions,\n  ctx: PptxWriteContext,\n): void => {\n  const slidePath = resolveSlidePath(xmlMap, index);\n  xmlMap.set(slidePath, toJson(stringifySlide(slideOpts, ctx)));\n};\n\n/** Resolve a relationship Target against the directory of its source part. */\nconst resolveTargetPath = (sourceDir: string, target: string): string => {\n  if (target.startsWith(\"/\")) return target.slice(1);\n  const base = sourceDir.split(\"/\").filter(Boolean);\n  for (const seg of target.split(\"/\")) {\n    if (seg === \"..\") base.pop();\n    else if (seg !== \".\") base.push(seg);\n  }\n  return base.join(\"/\");\n};\n\n/**\n * Remove a part from the package: the part itself, its rels, and its\n * `[Content_Types].xml` Override. Parts the rels point at are NOT touched —\n * layouts, media, and charts are shared across slides; they simply lose one\n * referencing slide, and unreferenced leftovers are inert in OPC packages.\n */\nconst removePart = (xmlMap: Map<string, Element>, partPath: string): void => {\n  xmlMap.delete(partPath);\n  xmlMap.delete(partPathToRelsPath(partPath));\n  const contentTypes = xmlMap.get(\"[Content_Types].xml\");\n  if (contentTypes) removeOverride(contentTypes, `/${partPath}`);\n};\n\nconst NOTES_SLIDE_REL_TYPE = RELATIONSHIP_TYPES.notesSlide;\n\n/**\n * Remove slides by 0-based index (positions in the deck as it entered the\n * patch). Drops each sldIdLst entry, the presentation relationship, and the\n * slide part with its rels. The slide's notesSlide — which no other slide\n * references — is removed with it; shared parts (layouts, media, …) stay.\n * Run after replace/append — those operate on the same original indices,\n * which the trailing slide removals do not disturb.\n */\nconst removeSlidesFromMap = (xmlMap: Map<string, Element>, indices: readonly number[]): void => {\n  // Resolve every index before touching sldIdLst — removing entries mid-loop\n  // would shift the positions of later ones.\n  const presRoot = rootElement(xmlMap.get(\"ppt/presentation.xml\"), \"p:presentation\");\n  const sldIdLst = findChild(presRoot, \"p:sldIdLst\");\n  const sldIds = (sldIdLst?.elements ?? []).filter((e) => e.name === \"p:sldId\");\n  const presRelsKey = \"ppt/_rels/presentation.xml.rels\";\n\n  const doomedEntries = new Set<Element>();\n  const doomedRIds = new Set<string>();\n  const slidePaths: string[] = [];\n  for (const index of indices) {\n    const entry = sldIds[index];\n    const rId = entry?.attributes?.[\"r:id\"];\n    if (!rId) {\n      throw new Error(`patchPresentation: no slide at index ${index}`);\n    }\n    const target = resolveRelTarget(xmlMap.get(presRelsKey), rId);\n    if (!target) {\n      throw new Error(`patchPresentation: slide ${index} relationship target not found`);\n    }\n    doomedEntries.add(entry);\n    doomedRIds.add(String(rId));\n    slidePaths.push(resolveTargetPath(\"ppt\", target));\n  }\n\n  if (sldIdLst?.elements) {\n    sldIdLst.elements = sldIdLst.elements.filter((e) => !doomedEntries.has(e));\n  }\n  const presRelsRoot = rootElement(xmlMap.get(presRelsKey), \"Relationships\");\n  if (presRelsRoot?.elements) {\n    presRelsRoot.elements = presRelsRoot.elements.filter(\n      (e) => !(e.name === \"Relationship\" && doomedRIds.has(String(e.attributes?.[\"Id\"]))),\n    );\n  }\n  for (const slidePath of slidePaths) {\n    // The notesSlide is owned by exactly this slide — take it with us.\n    const slideRelsRoot = rootElement(xmlMap.get(partPathToRelsPath(slidePath)), \"Relationships\");\n    const notesTarget = findRelByType(slideRelsRoot, NOTES_SLIDE_REL_TYPE)?.target;\n    if (notesTarget) {\n      removePart(xmlMap, resolveTargetPath(\"ppt/slides\", notesTarget));\n    }\n    removePart(xmlMap, slidePath);\n  }\n};\n\n/** Find an existing relationship of a type in a Relationships root. */\nconst findRelByType = (\n  rels: Element | undefined,\n  type: string,\n): { id: string; target: string } | undefined => {\n  const relationshipsRoot = rootElement(rels, \"Relationships\");\n  for (const child of relationshipsRoot?.elements ?? []) {\n    if (child.name === \"Relationship\" && String(child.attributes?.[\"Type\"]) === type) {\n      const target = child.attributes?.[\"Target\"];\n      if (target !== undefined) {\n        return { id: String(child.attributes?.[\"Id\"]), target: String(target) };\n      }\n    }\n  }\n  return undefined;\n};\n\n/** Noop ReadContext: comment-author/comment-list parse touches no relationships/parts/raw media. */\nconst STUB_READ_CTX: ReadContext = {\n  resolveRelationship: () => undefined,\n  getPart: () => undefined,\n  getRaw: () => undefined,\n};\n\n/**\n * Append comments to a slide, merging authors into commentAuthors.xml and the\n * per-slide list into ppt/comments/commentN.xml. Wires presentation rels\n * (commentAuthors) + slide rels (comments) + content types when newly introduced.\n */\nconst appendCommentsToMap = (\n  xmlMap: Map<string, Element>,\n  index: number,\n  slideComments: SlideCommentOptions[],\n  ctx: PptxWriteContext,\n): void => {\n  const slidePath = resolveSlidePath(xmlMap, index);\n  const slideNMatch = slidePath.match(/slide(\\d+)\\.xml$/);\n  const slideN = slideNMatch ? Number(slideNMatch[1]) : index + 1;\n  const commentPath = `ppt/comments/comment${slideN}.xml`;\n\n  // Parse existing authors + per-slide comments (merge targets).\n  const existingAuthorsRoot = rootElement(xmlMap.get(\"ppt/commentAuthors.xml\"), \"p:cmAuthorLst\");\n  const existingAuthors: AuthorEntry[] = existingAuthorsRoot\n    ? commentAuthorsDesc.parse(existingAuthorsRoot, STUB_READ_CTX)\n    : [];\n  const existingEntriesRoot = rootElement(xmlMap.get(commentPath), \"p:cmLst\");\n  const existingEntries: CommentEntry[] = existingEntriesRoot\n    ? slideCommentsDesc.parse(existingEntriesRoot, STUB_READ_CTX)\n    : [];\n\n  // buildCommentData continues author ids + per-author idx from existing authors.\n  const { authors, perSlide } = buildCommentData(\n    [{ comments: slideComments }] as unknown as SlideOptions[],\n    existingAuthors,\n  );\n  const mergedEntries = [...existingEntries, ...(perSlide[0] ?? [])];\n  const mergedAuthors = authors ?? existingAuthors;\n\n  // commentAuthors.xml (global) — written when any authors exist.\n  if (mergedAuthors.length > 0) {\n    xmlMap.set(\n      \"ppt/commentAuthors.xml\",\n      toJson(\n        `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>${commentAuthorsDesc.stringify(mergedAuthors, ctx)}`,\n      ),\n    );\n    const presRels = xmlMap.get(\"ppt/_rels/presentation.xml.rels\") ?? createRelationshipFile();\n    xmlMap.set(\"ppt/_rels/presentation.xml.rels\", presRels);\n    if (!findRelByType(presRels, COMMENT_AUTHORS_REL_TYPE)) {\n      const n = getNextRelationshipIndex(presRels);\n      appendRelationship(presRels, n, COMMENT_AUTHORS_REL_TYPE, \"commentAuthors.xml\");\n    }\n  }\n\n  // commentN.xml (per slide).\n  xmlMap.set(\n    commentPath,\n    toJson(\n      `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>${slideCommentsDesc.stringify(mergedEntries, ctx)}`,\n    ),\n  );\n  const slideRelsKey = partPathToRelsPath(slidePath);\n  const slideRels = xmlMap.get(slideRelsKey) ?? createRelationshipFile();\n  xmlMap.set(slideRelsKey, slideRels);\n  if (!findRelByType(slideRels, COMMENTS_REL_TYPE)) {\n    const n = getNextRelationshipIndex(slideRels);\n    appendRelationship(slideRels, n, COMMENTS_REL_TYPE, `../comments/comment${slideN}.xml`);\n  }\n\n  // Content types — commentAuthors + commentN Overrides (deduped).\n  const contentTypes = xmlMap.get(\"[Content_Types].xml\");\n  if (contentTypes) {\n    if (mergedAuthors.length > 0) {\n      appendOverride(contentTypes, \"/ppt/commentAuthors.xml\", COMMENT_AUTHORS_CONTENT_TYPE);\n    }\n    appendOverride(contentTypes, `/${commentPath}`, COMMENTS_CONTENT_TYPE);\n  }\n};\n\n/**\n * Patches an existing .pptx presentation by replacing placeholders with run content.\n *\n * Patch content reuses the generate {@link TextRunOptions} vocabulary (serialized\n * via the same descriptor), so color, fonts, fills, and hyperlinks are all\n * supported. Hyperlinks introduced by patch runs are registered into each\n * slide's relationship part.\n *\n * @publicApi\n */\nexport const patchPresentation = async <T extends OutputType = OutputType>({\n  outputType,\n  data,\n  placeholders,\n  findReplace,\n  coreProperties,\n  slides,\n  comments,\n  keepOriginalStyles = true,\n  placeholderDelimiters = { end: \"}}\", start: \"{{\" } as const,\n}: PatchPresentationOptions<T>): Promise<OutputByType[T]> => {\n  const { start, end } = placeholderDelimiters;\n  if (!start.trim() || !end.trim()) {\n    throw new Error(\"Both start and end delimiters must be non-empty strings.\");\n  }\n\n  const zipContent = unzipSync(toUint8Array(data));\n\n  const xmlMap = new Map<string, Element>();\n  const binaryMap = new Map<string, Uint8Array>();\n\n  // Separate XML files from binary files\n  for (const [key, value] of Object.entries(zipContent)) {\n    if (key.endsWith(\".xml\") || key.endsWith(\".rels\")) {\n      xmlMap.set(key, toJson(strFromU8(value)));\n    } else {\n      binaryMap.set(key, value);\n    }\n  }\n\n  // Build (find-text → patch envelope) entries. Placeholders wrap the key in\n  // delimiters; findReplace uses the literal key. Both share the same engine.\n  const entries: Array<{\n    find: string;\n    patch: { type: \"paragraph\"; children: TextRunOptions[] };\n  }> = [];\n  if (placeholders) {\n    for (const [key, value] of Object.entries(placeholders)) {\n      entries.push({ find: `${start}${key}${end}`, patch: toReplacerPatch(value) });\n    }\n  }\n  if (findReplace) {\n    for (const [key, value] of Object.entries(findReplace)) {\n      entries.push({ find: key, patch: toReplacerPatch(value) });\n    }\n  }\n\n  // Target parts: slides + masters + layouts + notes (deterministic order)\n  const targetPaths = Object.keys(zipContent)\n    .filter((k) => TARGET_RE.test(k))\n    .sort();\n\n  currentPatchCtx = new PptxWriteContext();\n  const context = {};\n\n  // Process text replacement on each target part\n  for (const targetPath of targetPaths) {\n    const json = xmlMap.get(targetPath);\n    if (!json) continue;\n\n    for (const { find, patch } of entries) {\n      // Replace every occurrence — loop until the replacer finds no more.\n      while (true) {\n        const { didFindOccurrence } = pptxReplacer({\n          context,\n          json,\n          keepOriginalStyles,\n          patch,\n          patchText: find,\n        });\n        if (!didFindOccurrence) break;\n      }\n    }\n  }\n\n  // Resolve hyperlink placeholders registered by patch runs into each part's rels\n  const hlinkByKey = new Map(currentPatchCtx.hyperlinks.map((h) => [h.key, h]));\n  for (const targetPath of targetPaths) {\n    const targetEl = xmlMap.get(targetPath);\n    if (!targetEl) continue;\n\n    const targetXml = stringify(targetEl);\n    const hlinkKeys = collectPlaceholderKeys(targetXml, \"hlink:\");\n    if (hlinkKeys.length === 0) continue;\n\n    const targetHlinks = hlinkKeys\n      .map((k) => hlinkByKey.get(k))\n      .filter((h): h is NonNullable<typeof h> => h !== undefined);\n    if (targetHlinks.length === 0) continue;\n\n    // Generalized rels path: ppt/<dir>/_rels/<file>.rels\n    const relsKey = partPathToRelsPath(targetPath);\n    const relsJson = xmlMap.get(relsKey) ?? createRelationshipFile();\n    xmlMap.set(relsKey, relsJson);\n    const offset = getNextRelationshipIndex(relsJson);\n\n    const resolved = replaceHyperlinkPlaceholders(targetXml, targetHlinks, offset);\n    xmlMap.set(targetPath, toJson(resolved));\n\n    for (const [i, hlink] of targetHlinks.entries()) {\n      // External URL hyperlinks only; internal slide jumps carry no url and are\n      // tokenized by the stringifier rather than registered as External rels.\n      if (hlink.url !== undefined) {\n        appendRelationship(relsJson, offset + i, HYPERLINK_REL_TYPE, hlink.url, \"External\");\n      }\n    }\n  }\n\n  // Slide collection edits — reuse the slide stringifier (no compiler re-run).\n  // Removal runs last: replace/append address the original slide indices,\n  // which the removals (dropping entries) would otherwise shift.\n  if (slides) {\n    if (slides.replace) {\n      for (const [index, slideOpts] of Object.entries(slides.replace)) {\n        replaceSlideInMap(xmlMap, Number(index), slideOpts, currentPatchCtx);\n      }\n    }\n    if (slides.append) {\n      for (const slideOpts of slides.append) {\n        appendSlideToMap(xmlMap, slideOpts, currentPatchCtx);\n      }\n    }\n    if (slides.remove) {\n      removeSlidesFromMap(xmlMap, slides.remove);\n    }\n  }\n\n  // Slide comments — append per slide, merging authors + per-slide comment lists.\n  if (comments) {\n    for (const [indexStr, slideComments] of Object.entries(comments)) {\n      appendCommentsToMap(xmlMap, Number(indexStr), slideComments, currentPatchCtx);\n    }\n  }\n\n  // Rebuild ZIP\n  const files: Record<string, Uint8Array> = {};\n\n  for (const [key, value] of xmlMap) {\n    files[key] =\n      key === \"docProps/core.xml\" && coreProperties\n        ? encoder.encode(OOXML_XML_DECLARATION + applyCorePropertiesOverride(value, coreProperties))\n        : encoder.encode(stringify(value));\n  }\n\n  for (const [key, value] of binaryMap) {\n    files[key] = value;\n  }\n\n  return await zipAndConvert(files, outputType, OoxmlMimeType.PPTX);\n};\n","/**\n * Slide Sync Properties (p:sldSyncPr) descriptor for PPTX.\n *\n * @module\n */\n\nimport type { CustomDescriptor } from \"@office-open/core/descriptor\";\nimport { attr } from \"@office-open/xml\";\nimport type { SlideSyncOptions } from \"@parts/slide/slide-sync-properties\";\n\n// ── Descriptor ──\n\nexport const slideSyncDesc: CustomDescriptor<SlideSyncOptions> = {\n  kind: \"custom\",\n\n  stringify(opts, _ctx) {\n    return (\n      `<p:sldSyncPr serverSldId=\"${opts.serverSldId}\" ` +\n      `serverSldModifiedTime=\"${opts.serverSldModifiedTime}\" ` +\n      `clientInsertedTime=\"${opts.clientInsertedTime}\"/>`\n    );\n  },\n\n  parse(el, _ctx) {\n    return {\n      serverSldId: attr(el, \"serverSldId\") ?? \"\",\n      serverSldModifiedTime: attr(el, \"serverSldModifiedTime\") ?? \"\",\n      clientInsertedTime: attr(el, \"clientInsertedTime\") ?? \"\",\n    };\n  },\n};\n","/**\n * Package-tail compile phase: writes the parts the slide/master mapping\n * doesn't cover — chart and SmartArt part families, viewProps/presProps\n * rels, notes slides, sync properties, and comment parts.\n *\n * @module\n */\n\nimport {\n  IMAGE_MEDIA_CONTENT_TYPES,\n  RELATIONSHIP_TYPES,\n  Relationships,\n  PPTX_PARTS,\n  getReferencedMedia,\n  replaceImagePlaceholders,\n  resolverFromRegistry,\n} from \"@office-open/core\";\nimport type { Zippable } from \"@office-open/core\";\nimport { ChartCollection } from \"@office-open/core/chart\";\nimport {\n  stringifyColorDefinitionPart,\n  stringifyLayoutDefinitionPart,\n  stringifyStyleDefinitionPart,\n} from \"@office-open/core/smartart\";\nimport { SmartArtCollection } from \"@office-open/core/smartart\";\nimport { escapeXml } from \"@office-open/xml\";\nimport { getColorXml, getLayoutXml, getStyleXml, DEFAULT_DRAWING_XML } from \"@parts/smartart\";\nimport type { PresentationOptions } from \"@shared/file\";\n\nimport type { PptxWriteContext } from \"../context\";\nimport { commentAuthorsDesc, slideCommentsDesc } from \"../parts/descriptors/comments\";\nimport { notesSlideDesc } from \"../parts/descriptors/notes-slide\";\nimport { slideSyncDesc } from \"../parts/descriptors/slide-sync\";\nimport { XML_DECL, encoder, wirePartHyperlinks } from \"./shared\";\nimport type { SlideCompileArtifacts } from \"./slides\";\n\n/** PPTX part path → content type, derived from the part registry. Matches\n * actual file paths, so dense (slides) and sparse (slide-indexed comments)\n * naming are both handled. */\nexport const PPTX_CONTENT_TYPE_RESOLVER = resolverFromRegistry(PPTX_PARTS);\n\n/** Chart part → user-shapes part relationship (c:userShapes bridge). */\nconst CHART_USER_SHAPES_REL = RELATIONSHIP_TYPES.chartUserShapes;\n\n/** Extension → MIME for media Default entries (image/video/audio). Declared\n * only for extensions actually present in the package. */\nexport const PPTX_MEDIA_CONTENT_TYPES: Record<string, string> = {\n  ...IMAGE_MEDIA_CONTENT_TYPES,\n  mp4: \"video/mp4\",\n  mov: \"video/quicktime\",\n  wmv: \"video/x-ms-wmv\",\n  avi: \"video/x-msvideo\",\n  mpg: \"video/mpeg\",\n  mpeg: \"video/mpeg\",\n  mp3: \"audio/mpeg\",\n  wav: \"audio/wav\",\n  wma: \"audio/x-ms-wma\",\n  aac: \"audio/aac\",\n  bin: \"application/vnd.openxmlformats-officedocument.oleObject\",\n};\n\n/** Write the parts that follow the mapping→Zippable conversion: chart and\n * SmartArt families, viewProps/presProps rels, notes slides, sync\n * properties, and comment parts. */\nexport function compileTailParts(\n  files: Zippable,\n  descCtx: PptxWriteContext,\n  charts: ChartCollection,\n  smartArts: SmartArtCollection,\n  artifacts: SlideCompileArtifacts,\n  slideCount: number,\n  options: PresentationOptions,\n): void {\n  // Chart parts\n  const allCharts = [\n    ...charts.array.map((c) => ({\n      key: c.key,\n      xml: XML_DECL + c.chartSpaceXml,\n      userShapes: c.userShapes,\n    })),\n    ...descCtx.charts.map((c) => ({\n      key: c.key,\n      xml: c.chartSpaceXml,\n      userShapes: c.userShapes,\n    })),\n  ];\n  for (const [i, chart] of allCharts.entries()) {\n    files[`ppt/charts/chart${i + 1}.xml`] = encoder.encode(chart.xml);\n    // User-shapes part behind c:userShapes: the chart's own rels entry plus\n    // the body part (chartUserShapes relationship, same directory).\n    if (chart.userShapes) {\n      files[`ppt/charts/userShapes${i + 1}.xml`] = encoder.encode(chart.userShapes.xml);\n      files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = encoder.encode(\n        XML_DECL +\n          `<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">` +\n          `<Relationship Id=\"${escapeXml(chart.userShapes.relationshipId)}\" Type=\"${CHART_USER_SHAPES_REL}\" Target=\"userShapes${i + 1}.xml\"/>` +\n          `</Relationships>`,\n      );\n    }\n  }\n\n  // SmartArt parts\n  const allSmartArts = [\n    ...smartArts.array.map((s) => ({\n      key: s.key,\n      dataModelXml: XML_DECL + s.dataModelXml,\n      layout: s.layout,\n      style: s.style,\n      color: s.color,\n    })),\n    ...descCtx.smartArts.map((s) => ({\n      key: s.key,\n      dataModelXml: s.dataModelXml,\n      layout: s.layout,\n      style: s.style,\n      color: s.color,\n    })),\n  ];\n  for (const [i, sa] of allSmartArts.entries()) {\n    files[`ppt/diagrams/data${i + 1}.xml`] = encoder.encode(sa.dataModelXml);\n    files[`ppt/diagrams/layout${i + 1}.xml`] = encoder.encode(\n      typeof sa.layout === \"string\"\n        ? getLayoutXml(sa.layout)\n        : stringifyLayoutDefinitionPart(sa.layout),\n    );\n    files[`ppt/diagrams/quickStyle${i + 1}.xml`] = encoder.encode(\n      typeof sa.style === \"string\" ? getStyleXml(sa.style) : stringifyStyleDefinitionPart(sa.style),\n    );\n    files[`ppt/diagrams/colors${i + 1}.xml`] = encoder.encode(\n      typeof sa.color === \"string\" ? getColorXml(sa.color) : stringifyColorDefinitionPart(sa.color),\n    );\n    files[`ppt/diagrams/drawing${i + 1}.xml`] = encoder.encode(DEFAULT_DRAWING_XML);\n  }\n\n  // ViewProps relationships\n  const hasOutlineViewSlides =\n    !!options.view?.outlineView?.slides && options.view.outlineView.slides.length > 0;\n  if (hasOutlineViewSlides) {\n    const vpRels = new Relationships();\n    for (let i = 0; i < slideCount; i++) {\n      vpRels.addRelationship(i + 1, RELATIONSHIP_TYPES.slide, `slides/slide${i + 1}.xml`);\n    }\n    files[\"ppt/_rels/viewProps.xml.rels\"] = encoder.encode(XML_DECL + vpRels.serialize());\n  }\n\n  // PresProps relationships\n  const htmlPublishInfo = options.htmlPublish?.rId\n    ? { rId: options.htmlPublish.rId, target: options.htmlPublish.target }\n    : undefined;\n  if (htmlPublishInfo) {\n    const presPropsRels = new Relationships();\n    presPropsRels.addRelationship(\n      htmlPublishInfo.rId,\n      RELATIONSHIP_TYPES.hyperlink,\n      htmlPublishInfo.target ?? \"presentation.htm\",\n      \"External\",\n    );\n    files[\"ppt/_rels/presProps.xml.rels\"] = encoder.encode(XML_DECL + presPropsRels.serialize());\n  }\n\n  // Notes slides\n  const notesSlideToSlide = new Map<number, number>();\n  for (const [slideIdx, notesIdx] of artifacts.notesSlideIndexMap) {\n    notesSlideToSlide.set(notesIdx, slideIdx);\n  }\n  for (let i = 0; i < artifacts.notesOptions.length; i++) {\n    const slideIdx = notesSlideToSlide.get(i) ?? 0;\n    const nsRels = new Relationships();\n    nsRels.addRelationship(1, RELATIONSHIP_TYPES.notesMaster, \"../notesMasters/notesMaster1.xml\");\n    nsRels.addRelationship(2, RELATIONSHIP_TYPES.slide, `../slides/slide${slideIdx + 1}.xml`);\n    // Media referenced by notes shapes gets slide-style image wiring (notes\n    // accept pictures just like slides do).\n    const notesRaw = notesSlideDesc.stringify(artifacts.notesOptions[i]!, descCtx) ?? \"\";\n    const notesMediaData = getReferencedMedia(notesRaw, descCtx.mediaCollection.array);\n    const notesImageOffset = nsRels.nextRelationshipId;\n    for (const [idx, mediaItem] of notesMediaData.entries()) {\n      nsRels.addRelationship(\n        notesImageOffset + idx,\n        RELATIONSHIP_TYPES.image,\n        `../media/${mediaItem.fileName}`,\n      );\n    }\n    let notesXml = replaceImagePlaceholders(notesRaw, notesMediaData, notesImageOffset);\n    // Hyperlinks in notes text get the same placeholder wiring slides get\n    // (a jump to the host slide reuses its existing slide rel).\n    notesXml = wirePartHyperlinks(\n      notesXml,\n      descCtx.hyperlinks,\n      nsRels.nextRelationshipId,\n      (id, type, target, mode) => nsRels.addRelationship(id, type, target, mode),\n      \"../slides/\",\n      (target) => {\n        const rid = nsRels.idOf(\"slide\", target);\n        return rid === undefined ? undefined : Number(rid.slice(3));\n      },\n    );\n    files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = encoder.encode(XML_DECL + notesXml);\n    files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = encoder.encode(\n      XML_DECL + nsRels.serialize(),\n    );\n  }\n\n  // Slide sync properties\n  for (const [i, syncOpts] of artifacts.slideSyncOptionsList.entries()) {\n    files[`ppt/slideSyncPr/slideSyncPr${i + 1}.xml`] = encoder.encode(\n      XML_DECL + (slideSyncDesc.stringify(syncOpts, descCtx) ?? \"\"),\n    );\n  }\n\n  // Comment authors\n  if (artifacts.commentAuthors) {\n    files[\"ppt/commentAuthors.xml\"] = encoder.encode(\n      XML_DECL + (commentAuthorsDesc.stringify(artifacts.commentAuthors, descCtx) ?? \"\"),\n    );\n  }\n\n  // Slide comments\n  for (let i = 0; i < artifacts.slideComments.length; i++) {\n    if (artifacts.slideComments[i]) {\n      files[`ppt/comments/comment${i + 1}.xml`] = encoder.encode(\n        XML_DECL + (slideCommentsDesc.stringify(artifacts.slideComments[i]!, descCtx) ?? \"\"),\n      );\n    }\n  }\n}\n","/**\n * Descriptor-based PPTX compiler.\n *\n * Produces a valid PPTX ZIP archive using the descriptor pipeline.\n * Accepts pure JSON PresentationOptions — no intermediate class needed.\n *\n * The compile runs in phases owned by the compile/ folder: masters/layouts\n * (compile/masters), the per-slide loop (compile/slides), the package tail\n * (compile/parts), and the relationship wiring scaffolding they share\n * (compile/shared). This module keeps the presentation-level orchestration.\n *\n * @module\n */\n\nimport {\n  RELATIONSHIP_TYPES,\n  addModelBinaries,\n  buildRootRelationships,\n  compileMapping,\n  dropDanglingPassthroughRels,\n  finalizeContentTypes,\n  getReferencedMedia,\n  replaceImagePlaceholders,\n} from \"@office-open/core\";\nimport type { XmlifyedFile, Zippable } from \"@office-open/core\";\nimport {\n  appPropertiesDesc,\n  buildCorePropertiesXmlString,\n  customPropertiesDesc,\n} from \"@office-open/core\";\nimport { ChartCollection } from \"@office-open/core/chart\";\nimport { SmartArtCollection } from \"@office-open/core/smartart\";\nimport type { PresentationPartOptions, PresentationSectionGroup } from \"@parts/presentation\";\nimport type { PresentationOptions } from \"@shared/file\";\n\nimport {\n  buildMasterMap,\n  buildSlideRels,\n  initPresRels,\n  mapMasterAndLayoutParts,\n  mapNotesAndHandoutMasters,\n  resolveSlideSize,\n} from \"./compile/masters\";\nimport {\n  PPTX_CONTENT_TYPE_RESOLVER,\n  PPTX_MEDIA_CONTENT_TYPES,\n  compileTailParts,\n} from \"./compile/parts\";\nimport {\n  XML_DECL,\n  type XmlifyedFileMapping,\n  encoder,\n  reserveClaimedSourceRids,\n} from \"./compile/shared\";\nimport { compileSlideParts } from \"./compile/slides\";\nimport { PptxWriteContext } from \"./context\";\nimport { presentationDesc } from \"./parts/descriptors/presentation\";\nimport { presentationPropertiesDesc } from \"./parts/descriptors/presentation-properties\";\nimport { tableStylesDesc } from \"./parts/descriptors/table-styles\";\nimport { viewPropsDesc } from \"./parts/descriptors/view-properties\";\n\nfunction buildPresAttrOpts(\n  options: PresentationOptions,\n): Partial<\n  Pick<\n    PresentationPartOptions,\n    | \"serverZoom\"\n    | \"firstSlideNum\"\n    | \"showSpecialPlsOnTitleSld\"\n    | \"rtl\"\n    | \"removePersonalInfoOnSave\"\n    | \"compatMode\"\n    | \"strictFirstAndLastChars\"\n    | \"embedTrueTypeFonts\"\n    | \"saveSubsetFonts\"\n    | \"autoCompressPictures\"\n    | \"bookmarkIdSeed\"\n    | \"conformance\"\n    | \"photoAlbum\"\n    | \"modifyVerifier\"\n    | \"embeddedFonts\"\n    | \"customShows\"\n    | \"kinsoku\"\n    | \"customerData\"\n    | \"smartTags\"\n    | \"defaultTextStyle\"\n  >\n> {\n  if (\n    !options.serverZoom &&\n    options.firstSlideNum === undefined &&\n    options.showSpecialPlsOnTitleSld === undefined &&\n    options.rtl === undefined &&\n    options.removePersonalInfoOnSave === undefined &&\n    options.compatMode === undefined &&\n    options.strictFirstAndLastChars === undefined &&\n    options.embedTrueTypeFonts === undefined &&\n    options.saveSubsetFonts === undefined &&\n    options.autoCompressPictures === undefined &&\n    options.bookmarkIdSeed === undefined &&\n    options.conformance === undefined &&\n    options.photoAlbum === undefined &&\n    options.modifyVerifier === undefined &&\n    options.embeddedFonts === undefined &&\n    options.customShows === undefined &&\n    options.kinsoku === undefined &&\n    options.customerData === undefined &&\n    options.smartTags === undefined &&\n    options.defaultTextStyle === undefined\n  ) {\n    return {};\n  }\n  return {\n    serverZoom: options.serverZoom,\n    firstSlideNum: options.firstSlideNum,\n    showSpecialPlsOnTitleSld: options.showSpecialPlsOnTitleSld,\n    rtl: options.rtl,\n    removePersonalInfoOnSave: options.removePersonalInfoOnSave,\n    compatMode: options.compatMode,\n    strictFirstAndLastChars: options.strictFirstAndLastChars,\n    embedTrueTypeFonts: options.embedTrueTypeFonts,\n    saveSubsetFonts: options.saveSubsetFonts,\n    autoCompressPictures: options.autoCompressPictures,\n    bookmarkIdSeed: options.bookmarkIdSeed,\n    conformance: options.conformance,\n    photoAlbum: options.photoAlbum,\n    modifyVerifier: options.modifyVerifier,\n    embeddedFonts: options.embeddedFonts,\n    customShows: options.customShows,\n    kinsoku: options.kinsoku,\n    customerData: options.customerData,\n    smartTags: options.smartTags,\n    defaultTextStyle: options.defaultTextStyle,\n  };\n}\n\n// ── Main compiler entry ──\n\nexport function compilePresentation(\n  options: PresentationOptions,\n  overrides: XmlifyedFile[] = [],\n  mediaLevel: number = 0,\n): Zippable {\n  const descCtx = new PptxWriteContext();\n  const slides = options.slides ?? [];\n  const masterDefs = options.masters ?? [];\n  const sz = resolveSlideSize(options.size);\n\n  // ── Pure structural computations ──\n\n  const masters = buildMasterMap(\n    masterDefs,\n    slides,\n    sz.width,\n    descCtx,\n    options.passthroughRelationships,\n  );\n  // Unique master themes in theme-index order (deduped in buildMasterMap) —\n  // notesMaster/handoutMaster themes append after these.\n  const uniqueMasterThemes: string[] = [];\n  for (const m of masters) uniqueMasterThemes[m.themeIndex] ??= m.theme;\n  const themes = uniqueMasterThemes;\n  const slideRels = buildSlideRels(masters, slides);\n\n  // ── Mutable state ──\n\n  // Presence-based: a parsed empty docProps/custom.xml round-trips as an\n  // empty part (undefined = fresh document, omit the part).\n  const hasCustomProperties = options.customProperties !== undefined;\n  const presRels = initPresRels(masters, slides.length);\n  // Reserve the presentation's captured ids whose rels a claim will re-emit —\n  // after the structured slide/master slots above (their r:ids are written\n  // verbatim into sldMasterIdLst/sldIdLst and take precedence), but before\n  // the claim loop, so anything allocated on the way there lands above those\n  // ids. Kinds the compiler always re-emits (slides, masters, the property\n  // parts) are absorbed and skipped: reserving them would only open holes.\n  reserveClaimedSourceRids(\n    presRels,\n    \"ppt/presentation.xml\",\n    options.passthroughRelationships,\n    new Set([\n      \"slide\",\n      \"slideMaster\",\n      \"theme\",\n      \"presProps\",\n      \"viewProps\",\n      \"tableStyles\",\n      \"notesMaster\",\n      \"handoutMaster\",\n    ]),\n  );\n  // Group slides into p14:sections by name (first-occurrence order); slides\n  // without a section name are left ungrouped (absent from p14:sectionLst).\n  const sectionOrder: string[] = [];\n  const sectionIndices = new Map<string, number[]>();\n  for (const [i, slide] of slides.entries()) {\n    const name = slide.section;\n    if (!name) continue;\n    let arr = sectionIndices.get(name);\n    if (!arr) {\n      arr = [];\n      sectionIndices.set(name, arr);\n      sectionOrder.push(name);\n    }\n    arr.push(i);\n  }\n  const sections: PresentationSectionGroup[] = sectionOrder.map((name) => ({\n    name,\n    slideIndices: sectionIndices.get(name)!,\n  }));\n\n  const presOptions: PresentationPartOptions = {\n    slideWidth: sz.width,\n    slideHeight: sz.height,\n    slideIds: slides.map((_, i) => 256 + i),\n    masterCount: masters.length,\n    sections,\n    ...buildPresAttrOpts(options),\n    ...(options.ext !== undefined ? { ext: options.ext } : {}),\n  };\n  const fileRels = buildRootRelationships(\n    \"ppt/presentation.xml\",\n    hasCustomProperties,\n    options.passthroughRelationships,\n  );\n  const media = descCtx.mediaCollection;\n  const charts = new ChartCollection();\n  const smartArts = new SmartArtCollection();\n\n  const presPropsFullOpts =\n    options.web ||\n    options.print ||\n    options.htmlPublish ||\n    options.colorMru ||\n    options.show ||\n    options.presentationPropertiesExt\n      ? {\n          web: options.web,\n          print: options.print,\n          htmlPublish: options.htmlPublish,\n          colorMru: options.colorMru,\n          show: options.show,\n          ext: options.presentationPropertiesExt,\n        }\n      : undefined;\n\n  // ── Build XML file mapping ──\n\n  const mapping: XmlifyedFileMapping = {\n    AppProperties: {\n      data: XML_DECL + (appPropertiesDesc.stringify(options.appProperties ?? {}, descCtx) ?? \"\"),\n      path: \"docProps/app.xml\",\n    },\n    Properties: {\n      data: XML_DECL + buildCorePropertiesXmlString(options),\n      path: \"docProps/core.xml\",\n    },\n    ...(hasCustomProperties\n      ? {\n          CustomProperties: {\n            data:\n              XML_DECL +\n              (customPropertiesDesc.stringify(\n                { properties: options.customProperties ?? [] },\n                descCtx,\n              ) ?? \"\"),\n            path: \"docProps/custom.xml\",\n          },\n        }\n      : {}),\n    FileRelationships: {\n      data: XML_DECL + fileRels.serialize(),\n      path: \"_rels/.rels\",\n    },\n  };\n\n  for (let ti = 0; ti < themes.length; ti++) {\n    mapping[`Theme${ti}`] = {\n      data: XML_DECL + themes[ti],\n      path: `ppt/theme/theme${ti + 1}.xml`,\n    };\n  }\n\n  mapping[\"TableStyles\"] = {\n    data: XML_DECL + (tableStylesDesc.stringify({ opts: options.tableStyles }, descCtx) ?? \"\"),\n    path: \"ppt/tableStyles.xml\",\n  };\n\n  mapping[\"PresProps\"] = {\n    data: XML_DECL + (presentationPropertiesDesc.stringify(presPropsFullOpts ?? {}, descCtx) ?? \"\"),\n    path: \"ppt/presProps.xml\",\n  };\n\n  mapping[\"ViewProps\"] = {\n    data: XML_DECL + (viewPropsDesc.stringify(options.view ?? {}, descCtx) ?? \"\"),\n    path: \"ppt/viewProps.xml\",\n  };\n\n  mapMasterAndLayoutParts(mapping, masters, descCtx, options.passthroughRelationships);\n  mapNotesAndHandoutMasters(\n    mapping,\n    presRels,\n    presOptions,\n    options,\n    slides,\n    descCtx,\n    themes.length,\n  );\n\n  // Comment Authors\n  if (\n    slides.some((s) => s.comments !== undefined && s.comments.length > 0) &&\n    !presRels.hasRelationshipKind(\"commentAuthors\")\n  ) {\n    presRels.add(RELATIONSHIP_TYPES.commentAuthors, \"commentAuthors.xml\");\n  }\n\n  // Structure-owned presentation rels not claimable by passthrough\n  // (presProps/viewProps/theme/tableStyles), slotted after the pre-claimed\n  // source ids so the source rId ordering is preserved.\n  // presentation.xml.rels carries exactly one theme rel (the presentation's\n  // default theme) regardless of how many masters or theme parts exist —\n  // extra masters reference their themes through their own rels.\n  if (!presRels.hasRelationshipKind(\"presProps\")) {\n    presRels.add(RELATIONSHIP_TYPES.presProps, \"presProps.xml\");\n  }\n  if (!presRels.hasRelationshipKind(\"viewProps\")) {\n    presRels.add(RELATIONSHIP_TYPES.viewProps, \"viewProps.xml\");\n  }\n  if (!presRels.hasRelationshipKind(\"theme\")) {\n    presRels.add(RELATIONSHIP_TYPES.theme, \"theme/theme1.xml\");\n  }\n  if (!presRels.hasRelationshipKind(\"tableStyles\")) {\n    presRels.add(RELATIONSHIP_TYPES.tableStyles, \"tableStyles.xml\");\n  }\n\n  // Presentation XML\n  const presBody = presentationDesc.stringify(presOptions, descCtx);\n  const presentationXml = presBody ? XML_DECL + presBody : \"\";\n  const mediaData = getReferencedMedia(presentationXml, media.array);\n  const presImageOffset = presRels.nextRelationshipId;\n  for (const [idx, mediaItem] of mediaData.entries()) {\n    presRels.addRelationship(\n      presImageOffset + idx,\n      RELATIONSHIP_TYPES.image,\n      `../media/${mediaItem.fileName}`,\n    );\n  }\n  const replacedPresentationXml = replaceImagePlaceholders(\n    presentationXml,\n    mediaData,\n    presImageOffset,\n  );\n\n  mapping[\"Presentation\"] = {\n    data: replacedPresentationXml,\n    path: \"ppt/presentation.xml\",\n  };\n  mapping[\"PresentationRelationships\"] = {\n    data: XML_DECL + presRels.serialize(),\n    path: \"ppt/_rels/presentation.xml.rels\",\n  };\n\n  // Slides\n  const artifacts = compileSlideParts(\n    mapping,\n    slides,\n    slideRels,\n    descCtx,\n    charts,\n    smartArts,\n    options.passthroughRelationships,\n  );\n\n  // Compile mapping to Zippable\n  const files = compileMapping(mapping, overrides);\n\n  compileTailParts(files, descCtx, charts, smartArts, artifacts, slides.length, options);\n\n  // Media + OLE embedding binaries (ppt/media/*, ppt/embeddings/*)\n  addModelBinaries(files, \"ppt\", media.array, descCtx.embeddings, mediaLevel);\n\n  // Derive [Content_Types].xml from the actual parts written — the file set is\n  // the single source of truth, so declarations cannot drift from what is on\n  // disk, and sparse/index-based names (slide-keyed comments) are handled\n  // naturally because emission follows the files. Raw passthrough parts\n  // (handout masters, customXml, unknown extensions, …) copy in first: the\n  // compiler output above wins at the same path, so only what the model missed\n  // actually passes through.\n  files[\"[Content_Types].xml\"] = encoder.encode(\n    finalizeContentTypes(\n      files,\n      {\n        resolve: PPTX_CONTENT_TYPE_RESOLVER,\n        mediaContentTypes: PPTX_MEDIA_CONTENT_TYPES,\n        // Round-trip: the source declaration table is the base; derived entries\n        // only fill what surviving source entries leave uncovered or mistyped.\n        source: options.contentTypes,\n        rawParts: options.rawParts,\n      },\n      descCtx,\n    ),\n  );\n\n  // Guard: drop passthrough rels whose target part never made it into the\n  // package (hand-authored input) — Office refuses to open dangling rels.\n  dropDanglingPassthroughRels(files, options.passthroughRelationships);\n\n  return files;\n}\n","/**\n * Pure function API for generating PPTX files.\n *\n * @module\n */\n\nimport { createPacker, OoxmlMimeType } from \"@office-open/core\";\nimport {\n  assertEncryptedExclusive,\n  encryptedContainerOutput,\n  encryptedContainerStream,\n} from \"@office-open/core\";\nimport type { OutputByType, OutputType, PackerOptions } from \"@office-open/core\";\nimport type { PresentationOptions } from \"@shared/file\";\n\nimport { compilePresentation } from \"./compiler\";\n\n/** `@internal` Packer instance for PPTX generation. */\nconst Packer = createPacker<PresentationOptions>({\n  compile: (options, overrides, mediaLevel) => compilePresentation(options, overrides, mediaLevel),\n  mimeType: OoxmlMimeType.PPTX,\n});\n\n/**\n * Re-emit the verbatim encrypted-container bytes, or `undefined` to compile.\n * Mixed content is rejected up front — compiling would silently drop it.\n */\nfunction encryptedPassthrough<T extends OutputType>(\n  options: PresentationOptions,\n  type: T,\n): OutputByType[T] | undefined {\n  assertEncryptedExclusive(options, (options.slides?.length ?? 0) > 0);\n  return encryptedContainerOutput(options, type, OoxmlMimeType.PPTX);\n}\n\n/**\n * Generate a PPTX file from pure JSON options.\n *\n * The output format is controlled by `packerOptions.type` (default: `\"nodebuffer\"` → Buffer).\n * For synchronous generation, use {@link generatePresentationSync}. For streaming, use {@link generatePresentationStream}.\n *\n * @param options - Presentation options (slides, masters, themes, etc.)\n * @param packerOptions - Optional packer configuration (type, compression, overrides, etc.)\n *\n * @example\n * ```typescript\n * import { generatePresentation } from \"`@office`-open/pptx\";\n *\n * const buffer = await generatePresentation({ slides: [...] });\n * const bytes = await generatePresentation({ slides: [...] }, { type: \"uint8array\" });\n * const blob = await generatePresentation({ slides: [...] }, { type: \"blob\" });\n * ```\n */\nexport function generatePresentation<T extends OutputType = \"nodebuffer\">(\n  options: PresentationOptions,\n  packerOptions?: PackerOptions<T>,\n): Promise<OutputByType[T]> {\n  const encrypted = encryptedPassthrough(options, packerOptions?.type ?? \"nodebuffer\");\n  if (encrypted) return Promise.resolve(encrypted as OutputByType[T]);\n  return Packer.pack(options, packerOptions) as Promise<OutputByType[T]>;\n}\n\n/**\n * Synchronously generate a PPTX file from pure JSON options.\n */\nexport function generatePresentationSync<T extends OutputType = \"nodebuffer\">(\n  options: PresentationOptions,\n  packerOptions?: PackerOptions<T>,\n): OutputByType[T] {\n  const encrypted = encryptedPassthrough(options, packerOptions?.type ?? \"nodebuffer\");\n  if (encrypted) return encrypted as OutputByType[T];\n  return Packer.packSync(options, packerOptions) as OutputByType[T];\n}\n\n/**\n * Generate a PPTX file as a `ReadableStream<Uint8Array>`.\n */\nexport function generatePresentationStream(\n  options: PresentationOptions,\n  packerOptions?: PackerOptions,\n): ReadableStream<Uint8Array> {\n  assertEncryptedExclusive(options, (options.slides?.length ?? 0) > 0);\n  const encrypted = encryptedContainerStream(options);\n  if (encrypted) return encrypted;\n  return Packer.toStream(options, packerOptions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAa,iBACX;;;ACUF,MAAaA,OAAK;AAKlB,MAAMC,WAAS;AACf,MAAMC,QAAM,MAAc,OAAe,KAAK,MAAO,OAAO,KAAMD,QAAM;AAGxE,MAAM,YAAY,SAAoC;CACpD,GAAG,aAAa,IAAI,CAAC;CACrB,GAAG,aAAa,IAAI,CAAC;CACrB,IAAI,aAAa,IAAI,KAAK;CAC1B,IAAI,aAAa,IAAI,MAAM;AAC7B;AA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