@office-open/pptx 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { i as __toCommonJS, n as __exportAll, r as __reExport, t as __esmMin } from "./chunk-090QGkrx.mjs";
2
- import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, stringContainerObj, uniqueId, uniqueNumericIdCreator, uniqueUuid } from "@office-open/core";
2
+ import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, Formatter as Formatter$1, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PPTX_NS, PrettifyType, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, createReplacer, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, strFromU8, stringContainerObj, toJson, uniqueId, uniqueNumericIdCreator, uniqueUuid, unzipSync, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, zipAndConvert } from "@office-open/core";
3
3
  import { BevelPresetType, CompoundLine, LineCap, LineJoin, PathShadeType, PenAlignment, PresetDash, PresetGeometry, PresetMaterialType, Stretch, TileFlipMode, buildFill, createBevel, createBlip, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createEffectList as createEffectList$1, createGradientFill, createGradientStop, createGroupTransform2D, createOutline, createOutline as createOutline$1, createScene3D, createScene3D as createScene3D$1, createShape3D, createShape3D as createShape3D$1, createTransform2D, extractBlipFillMedia } from "@office-open/core/drawingml";
4
4
  import { ChartCollection, ChartSpace } from "@office-open/core/chart";
5
5
  import { DEFAULT_DRAWING_XML, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml } from "@office-open/core/smartart";
6
- import { attr, attrBool, attrNum, children, findChild, findDeep, textOf, xml } from "@office-open/xml";
7
- import { toUint8Array } from "undio";
6
+ import { attr, attrBool, attrNum, children, colorAttr, findChild, findDeep, js2xml, textOf, xml } from "@office-open/xml";
7
+ import { textToUint8Array, toUint8Array } from "undio";
8
8
  export * from "@office-open/core/values";
9
9
  //#region src/file/drawingml/effects.ts
10
10
  /** Convert PPTX simple color to core SolidFillOptions. */
@@ -59,7 +59,7 @@ function toReflection(opts) {
59
59
  if (opts.scaleY !== void 0) result.scaleY = opts.scaleY * 1e3;
60
60
  if (opts.skewX !== void 0) result.skewX = opts.skewX * 6e4;
61
61
  if (opts.skewY !== void 0) result.skewY = opts.skewY * 6e4;
62
- if (opts.alignment !== void 0) result.alignment = ReflectionAlignment[opts.alignment];
62
+ if (opts.alignment !== void 0) result.alignment = xsdRectAlignment.to(opts.alignment);
63
63
  if (opts.rotateWithShape === false) result.rotWithShape = 0;
64
64
  return result;
65
65
  }
@@ -118,15 +118,15 @@ function createPptxEffectList(options) {
118
118
  var ReflectionAlignment;
119
119
  var init_effects = __esmMin((() => {
120
120
  ReflectionAlignment = {
121
- TOP_LEFT: "tl",
122
- TOP: "t",
123
- TOP_RIGHT: "tr",
124
- LEFT: "l",
125
- CENTER: "ctr",
126
- RIGHT: "r",
127
- BOTTOM_LEFT: "bl",
128
- BOTTOM: "b",
129
- BOTTOM_RIGHT: "br"
121
+ TOP_LEFT: "topLeft",
122
+ TOP: "top",
123
+ TOP_RIGHT: "topRight",
124
+ LEFT: "left",
125
+ CENTER: "center",
126
+ RIGHT: "right",
127
+ BOTTOM_LEFT: "bottomLeft",
128
+ BOTTOM: "bottom",
129
+ BOTTOM_RIGHT: "bottomRight"
130
130
  };
131
131
  }));
132
132
  //#endregion
@@ -492,7 +492,7 @@ var HyperlinkCollection = class {
492
492
  tooltip
493
493
  });
494
494
  }
495
- get Array() {
495
+ get array() {
496
496
  return [...this.map.values()];
497
497
  }
498
498
  };
@@ -526,7 +526,7 @@ var Media = class {
526
526
  addMedia(key, mediaData) {
527
527
  this.map.set(key, mediaData);
528
528
  }
529
- get Array() {
529
+ get array() {
530
530
  return [...this.map.values()];
531
531
  }
532
532
  };
@@ -617,10 +617,10 @@ var EndParagraphRunProperties = class extends BuilderElement {
617
617
  //#region src/file/shape/paragraph/paragraph-properties.ts
618
618
  init_xml_components();
619
619
  const TextAlignment = {
620
- LEFT: "l",
621
- CENTER: "ctr",
622
- RIGHT: "r",
623
- JUSTIFY: "just"
620
+ LEFT: "left",
621
+ CENTER: "center",
622
+ RIGHT: "right",
623
+ JUSTIFY: "justify"
624
624
  };
625
625
  function buildBulletChildren(options) {
626
626
  const children = [];
@@ -651,7 +651,7 @@ function buildBulletChildren(options) {
651
651
  function buildParagraphProperties(options) {
652
652
  const children = [];
653
653
  const attrs = {};
654
- if (options.alignment) attrs.algn = TextAlignment[options.alignment];
654
+ if (options.alignment) attrs.algn = xsdTextAlign.to(options.alignment);
655
655
  if (options.indentLevel !== void 0) attrs.lvl = options.indentLevel;
656
656
  if (options.marginIndent !== void 0) attrs.marL = options.marginIndent;
657
657
  if (options.marginRight !== void 0) attrs.marR = options.marginRight;
@@ -686,8 +686,8 @@ init_fill();
686
686
  init_xml_components();
687
687
  let nextHyperlinkId = 1;
688
688
  const UnderlineStyle = {
689
- SINGLE: "sng",
690
- DOUBLE: "dbl",
689
+ SINGLE: "single",
690
+ DOUBLE: "double",
691
691
  NONE: "none"
692
692
  };
693
693
  const StrikeStyle = {
@@ -711,11 +711,11 @@ function buildRunProperties(options, hyperlinkKey, fillObject, effectListObject,
711
711
  if (options.fontSize) attrs.sz = options.fontSize * 100;
712
712
  if (options.bold !== void 0) attrs.b = options.bold;
713
713
  if (options.italic !== void 0) attrs.i = options.italic;
714
- if (options.underline) attrs.u = UnderlineStyle[options.underline];
714
+ if (options.underline) attrs.u = xsdUnderlineStyle.to(options.underline);
715
715
  if (options.lang) attrs.lang = options.lang;
716
- if (options.strike) attrs.strike = StrikeStyle[options.strike];
716
+ if (options.strike) attrs.strike = xsdStrikeStyle.to(options.strike);
717
717
  if (options.baseline !== void 0) attrs.baseline = options.baseline;
718
- if (options.capitalization) attrs.cap = TextCapitalization[options.capitalization] ?? options.capitalization;
718
+ if (options.capitalization) attrs.cap = xsdTextCaps.to(options.capitalization);
719
719
  if (options.spacing !== void 0) attrs.spc = options.spacing;
720
720
  if (options.noProof !== void 0) attrs.noProof = options.noProof;
721
721
  if (options.dirty !== void 0) attrs.dirty = options.dirty;
@@ -754,7 +754,7 @@ var RunProperties = class extends XmlComponent {
754
754
  let hyperlinkKey;
755
755
  if (opts.hyperlink) {
756
756
  hyperlinkKey = `hlink_${nextHyperlinkId++}`;
757
- context.fileData?.Hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
757
+ context.fileData?.hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
758
758
  }
759
759
  let fillObj;
760
760
  if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
@@ -872,9 +872,9 @@ var TableCellProperties = class extends BaseXmlComponent {
872
872
  //#region src/file/table/table-cell.ts
873
873
  init_xml_components();
874
874
  const VerticalAlignment = {
875
- TOP: "t",
876
- CENTER: "ctr",
877
- BOTTOM: "b"
875
+ TOP: "top",
876
+ CENTER: "center",
877
+ BOTTOM: "bottom"
878
878
  };
879
879
  /**
880
880
  * a:tc — Table cell with text body and properties.
@@ -916,7 +916,7 @@ var TableCell = class extends BaseXmlComponent {
916
916
  const tcPrObj = new TableCellProperties({
917
917
  fill: opts.fill,
918
918
  borders: opts.borders,
919
- verticalAlign: opts.verticalAlign ? VerticalAlignment[opts.verticalAlign] : void 0
919
+ verticalAlign: opts.verticalAlign ? xsdTextAnchor.to(opts.verticalAlign) : void 0
920
920
  }).prepForXml(context);
921
921
  if (tcPrObj) children.push(tcPrObj);
922
922
  return { "a:tc": children };
@@ -936,7 +936,7 @@ function buildBodyPr(options) {
936
936
  const bodyPrContent = [];
937
937
  const attrs = {};
938
938
  if (options.vertical) attrs.vert = options.vertical;
939
- if (options.anchor) attrs.anchor = VerticalAlignment[options.anchor];
939
+ if (options.anchor) attrs.anchor = xsdTextAnchor.to(options.anchor);
940
940
  if (options.wrap) attrs.wrap = options.wrap;
941
941
  if (options.margins?.top !== void 0) attrs.tIns = options.margins.top;
942
942
  if (options.margins?.bottom !== void 0) attrs.bIns = options.margins.bottom;
@@ -962,11 +962,14 @@ var TextBody = class extends XmlComponent {
962
962
  const children = [];
963
963
  children.push(buildBodyPr(this.options));
964
964
  children.push({ "a:lstStyle": {} });
965
- if (this.options.paragraphs) for (const p of this.options.paragraphs) {
965
+ if (this.options.children) for (const p of this.options.children) {
966
966
  const obj = (typeof p === "string" ? new Paragraph({ children: [new TextRun({ text: p })] }) : p instanceof Paragraph ? p : new Paragraph(p)).prepForXml(context);
967
967
  if (obj) children.push(obj);
968
968
  }
969
- else {
969
+ else if (this.options.text !== void 0) {
970
+ const obj = new Paragraph({ children: [new TextRun({ text: this.options.text })] }).prepForXml(context);
971
+ if (obj) children.push(obj);
972
+ } else {
970
973
  const obj = new Paragraph().prepForXml(context);
971
974
  if (obj) children.push(obj);
972
975
  }
@@ -1154,7 +1157,7 @@ var NotesBodyPlaceholder = class extends XmlComponent {
1154
1157
  })]
1155
1158
  })]
1156
1159
  }));
1157
- const textBodyOptions = text ? { paragraphs: [new Paragraph({ children: [new TextRun({ text })] })] } : void 0;
1160
+ const textBodyOptions = text ? { children: [new Paragraph({ children: [new TextRun({ text })] })] } : void 0;
1158
1161
  this.root.push(new TextBody(textBodyOptions));
1159
1162
  }
1160
1163
  };
@@ -1172,16 +1175,15 @@ function buildPresPropsXml(showOptions) {
1172
1175
  }
1173
1176
  var PresentationProperties = class PresentationProperties extends ImportedXmlComponent {
1174
1177
  static cache = /* @__PURE__ */ new Map();
1178
+ key;
1175
1179
  constructor(showOptions) {
1176
1180
  super("p:presentationPr");
1177
- const key = showOptions ? JSON.stringify(showOptions) : "";
1178
- if (!PresentationProperties.cache.has(key)) PresentationProperties.cache.set(key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
1181
+ this.key = showOptions ? JSON.stringify(showOptions) : "";
1182
+ if (!PresentationProperties.cache.has(this.key)) PresentationProperties.cache.set(this.key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
1179
1183
  }
1180
1184
  prepForXml() {
1181
- const key = this.showOptions ? JSON.stringify(this.showOptions) : "";
1182
- return PresentationProperties.cache.get(key).prepForXml({ stack: [] });
1185
+ return PresentationProperties.cache.get(this.key).prepForXml({ stack: [] });
1183
1186
  }
1184
- showOptions;
1185
1187
  };
1186
1188
  //#endregion
1187
1189
  //#region src/file/presentation/presentation.ts
@@ -1287,12 +1289,9 @@ var PresentationWrapper = class {
1287
1289
  this.presentation = new Presentation(options);
1288
1290
  this.relationships = new Relationships();
1289
1291
  }
1290
- get View() {
1292
+ get view() {
1291
1293
  return this.presentation;
1292
1294
  }
1293
- get Relationships() {
1294
- return this.relationships;
1295
- }
1296
1295
  };
1297
1296
  //#endregion
1298
1297
  //#region src/file/drawingml/transform-2d.ts
@@ -1368,15 +1367,12 @@ var ChartFrame = class extends XmlComponent {
1368
1367
  }
1369
1368
  prepForXml(context) {
1370
1369
  const file = context.fileData;
1371
- if (file?.Charts) file.Charts.addChart(this.chartKey, {
1370
+ if (file?.charts) file.charts.addChart(this.chartKey, {
1372
1371
  chartSpace: new ChartSpace(this.chartOptions),
1373
1372
  key: this.chartKey
1374
1373
  });
1375
1374
  return super.prepForXml(context);
1376
1375
  }
1377
- get ChartKey() {
1378
- return this.chartKey;
1379
- }
1380
1376
  };
1381
1377
  var GraphicFrameNonVisual$2 = class extends XmlComponent {
1382
1378
  constructor(id) {
@@ -1479,13 +1475,13 @@ function buildMediaData(type, fileName, width, height, data) {
1479
1475
  */
1480
1476
  var MediaFrameBase = class extends XmlComponent {
1481
1477
  shapeId;
1482
- animationOptions;
1478
+ animation;
1483
1479
  mediaData;
1484
1480
  posterData;
1485
1481
  constructor(options, id, mediaFileName, params) {
1486
1482
  super("p:pic");
1487
1483
  this.shapeId = id;
1488
- this.animationOptions = options.animation;
1484
+ this.animation = options.animation;
1489
1485
  const name = options.name ?? `Media ${id}`;
1490
1486
  const w = options.width ?? 0;
1491
1487
  const h = options.height ?? 0;
@@ -1576,16 +1572,10 @@ var MediaFrameBase = class extends XmlComponent {
1576
1572
  children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
1577
1573
  }));
1578
1574
  }
1579
- get ShapeId() {
1580
- return this.shapeId;
1581
- }
1582
- get Animation() {
1583
- return this.animationOptions;
1584
- }
1585
1575
  prepForXml(context) {
1586
1576
  const file = context.fileData;
1587
- if (this.posterData) file?.Media.addImage(this.posterData.fileName, this.posterData);
1588
- file?.Media.addMedia(this.mediaData.fileName, this.mediaData);
1577
+ if (this.posterData) file?.media.addImage(this.posterData.fileName, this.posterData);
1578
+ file?.media.addMedia(this.mediaData.fileName, this.mediaData);
1589
1579
  return super.prepForXml(context);
1590
1580
  }
1591
1581
  };
@@ -1604,7 +1594,7 @@ var AudioFrame = class AudioFrame extends MediaFrameBase {
1604
1594
  const mediaFileName = `${(options.name ?? `Audio ${id}`).replace(/\s+/g, "_")}.${options.type}`;
1605
1595
  super(options, id, mediaFileName, {
1606
1596
  extUri: MEDIA_EXT_URI$1,
1607
- cNvPrPrefix: "a"
1597
+ cNvPrPrefix: "p"
1608
1598
  });
1609
1599
  }
1610
1600
  };
@@ -1721,12 +1711,12 @@ var VideoFrame = class VideoFrame extends MediaFrameBase {
1721
1711
  //#region src/file/drawingml/blip-fill.ts
1722
1712
  init_xml_components();
1723
1713
  /**
1724
- * a:blipFill — Image fill with stretch mode.
1714
+ * p:blipFill — Image fill with stretch mode (within p:pic context).
1725
1715
  * Uses core createBlip for the blip element.
1726
1716
  */
1727
1717
  var BlipFill = class extends XmlComponent {
1728
1718
  constructor(fileName) {
1729
- super("a:blipFill");
1719
+ super("p:blipFill");
1730
1720
  this.root.push(createBlip({ referenceId: fileName }));
1731
1721
  this.root.push(new Stretch());
1732
1722
  }
@@ -1735,12 +1725,11 @@ var BlipFill = class extends XmlComponent {
1735
1725
  //#region src/file/drawingml/non-visual-picture-props.ts
1736
1726
  init_xml_components();
1737
1727
  /**
1738
- * a:cNvPicPr — Non-visual picture drawing properties.
1739
- * Uses a: prefix (DrawingML type) but referenced via p:cNvPicPr in PML context.
1728
+ * p:cNvPicPr — Non-visual picture drawing properties (within p:pic context).
1740
1729
  */
1741
1730
  var NonVisualPictureProperties = class extends EmptyElement {
1742
1731
  constructor() {
1743
- super("a:cNvPicPr");
1732
+ super("p:cNvPicPr");
1744
1733
  }
1745
1734
  };
1746
1735
  //#endregion
@@ -1753,7 +1742,7 @@ var PictureNonVisual = class extends XmlComponent {
1753
1742
  constructor(id, name) {
1754
1743
  super("p:nvPicPr");
1755
1744
  this.root.push(new BuilderElement({
1756
- name: "a:cNvPr",
1745
+ name: "p:cNvPr",
1757
1746
  attributes: {
1758
1747
  id: {
1759
1748
  key: "id",
@@ -1813,7 +1802,7 @@ var Picture = class Picture extends XmlComponent {
1813
1802
  }));
1814
1803
  }
1815
1804
  prepForXml(context) {
1816
- context.fileData?.Media.addImage(this.imageData.fileName, this.imageData);
1805
+ context.fileData?.media.addImage(this.imageData.fileName, this.imageData);
1817
1806
  return super.prepForXml(context);
1818
1807
  }
1819
1808
  };
@@ -1890,28 +1879,28 @@ var NonVisualShapeProperties = class extends EmptyElement {
1890
1879
  //#endregion
1891
1880
  //#region src/file/drawingml/outline.ts
1892
1881
  const DASH_STYLE_MAP = {
1893
- solid: "SOLID",
1894
- dash: "DASH",
1895
- dashDot: "DASH_DOT",
1896
- lgDash: "LG_DASH",
1897
- sysDot: "SYS_DOT",
1898
- sysDash: "SYS_DASH"
1882
+ solid: "solid",
1883
+ dash: "dash",
1884
+ dashDot: "dashDot",
1885
+ lgDash: "lgDash",
1886
+ sysDot: "sysDot",
1887
+ sysDash: "sysDash"
1899
1888
  };
1900
1889
  const ARROWHEAD_MAP = {
1901
- triangle: "TRIANGLE",
1902
- stealth: "STEALTH",
1903
- diamond: "DIAMOND",
1904
- oval: "OVAL",
1905
- open: "ARROW"
1890
+ triangle: "triangle",
1891
+ stealth: "stealth",
1892
+ diamond: "diamond",
1893
+ oval: "oval",
1894
+ open: "arrow"
1906
1895
  };
1907
1896
  const ARROWHEAD_SIZE_MAP = {
1908
- sm: "SMALL",
1909
- med: "MEDIUM",
1910
- lg: "LARGE"
1897
+ sm: "small",
1898
+ med: "medium",
1899
+ lg: "large"
1911
1900
  };
1912
1901
  function toCoreLineEnd(type, width, length) {
1913
1902
  return {
1914
- type: ARROWHEAD_MAP[type] ?? "TRIANGLE",
1903
+ type: ARROWHEAD_MAP[type] ?? "triangle",
1915
1904
  ...width ? { width: ARROWHEAD_SIZE_MAP[width] } : {},
1916
1905
  ...length ? { length: ARROWHEAD_SIZE_MAP[length] } : {}
1917
1906
  };
@@ -1925,7 +1914,7 @@ const createOutlineCompat = (options = {}, arrowheads) => createOutline$1({
1925
1914
  type: "solidFill",
1926
1915
  color: { value: options.color.replace("#", "") }
1927
1916
  } : { type: "noFill" },
1928
- ...options.dashStyle && { dash: DASH_STYLE_MAP[options.dashStyle] ?? "SOLID" },
1917
+ ...options.dashStyle && { dash: DASH_STYLE_MAP[options.dashStyle] ?? "solid" },
1929
1918
  ...arrowheads?.endType ? { headEnd: toCoreLineEnd(arrowheads.endType, arrowheads.width, arrowheads.length) } : {},
1930
1919
  ...arrowheads?.beginType ? { tailEnd: toCoreLineEnd(arrowheads.beginType, arrowheads.width, arrowheads.length) } : {}
1931
1920
  });
@@ -2032,9 +2021,6 @@ var LineShape = class LineShape extends XmlComponent {
2032
2021
  ]
2033
2022
  }));
2034
2023
  }
2035
- get ShapeId() {
2036
- return this.shapeId;
2037
- }
2038
2024
  };
2039
2025
  /**
2040
2026
  * p:cxnSp — A connector shape on a slide (line with optional arrowheads).
@@ -2127,9 +2113,6 @@ var ConnectorShape = class ConnectorShape extends XmlComponent {
2127
2113
  children: spPrChildren
2128
2114
  }));
2129
2115
  }
2130
- get ShapeId() {
2131
- return this.shapeId;
2132
- }
2133
2116
  };
2134
2117
  //#endregion
2135
2118
  //#region src/file/drawingml/shape-properties.ts
@@ -2156,7 +2139,7 @@ var ShapeProperties = class extends BaseXmlComponent {
2156
2139
  const geomObj = new PresetGeometry({ preset: opts.geometry ?? "rect" }).prepForXml(context);
2157
2140
  if (geomObj) children.push(geomObj);
2158
2141
  const media = opts.fill ? extractBlipFillMedia(opts.fill) : void 0;
2159
- if (media) context.fileData?.Media.addImage(media.fileName, {
2142
+ if (media) context.fileData?.media.addImage(media.fileName, {
2160
2143
  data: media.data,
2161
2144
  fileName: media.fileName,
2162
2145
  type: media.type,
@@ -2226,24 +2209,18 @@ function buildPlaceholder(type, index) {
2226
2209
  var Shape = class Shape extends XmlComponent {
2227
2210
  static nextId = 2;
2228
2211
  shapeId;
2229
- animationOptions;
2212
+ animation;
2230
2213
  options;
2231
2214
  constructor(options = {}) {
2232
2215
  super("p:sp");
2233
2216
  const id = options.id ?? Shape.nextId++;
2234
2217
  this.shapeId = id;
2235
- this.animationOptions = options.animation;
2218
+ this.animation = options.animation;
2236
2219
  this.options = {
2237
2220
  ...options,
2238
2221
  id
2239
2222
  };
2240
2223
  }
2241
- get ShapeId() {
2242
- return this.shapeId;
2243
- }
2244
- get Animation() {
2245
- return this.animationOptions;
2246
- }
2247
2224
  prepForXml(context) {
2248
2225
  const opts = this.options;
2249
2226
  const id = this.shapeId;
@@ -2269,16 +2246,7 @@ var Shape = class Shape extends XmlComponent {
2269
2246
  rotation: opts.rotation
2270
2247
  }).prepForXml(context);
2271
2248
  if (spPrObj) children.push(spPrObj);
2272
- const txBodyObj = new TextBody({
2273
- paragraphs: opts.paragraphs ?? (opts.text ? [new Paragraph({ text: opts.text })] : void 0),
2274
- vertical: opts.textVertical,
2275
- anchor: opts.textAnchor,
2276
- autoFit: opts.textAutoFit,
2277
- wrap: opts.textWrap,
2278
- margins: opts.textMargins,
2279
- columns: opts.textColumns,
2280
- columnSpacing: opts.textColumnSpacing
2281
- }).prepForXml(context);
2249
+ const txBodyObj = new TextBody(opts.textBody ?? {}).prepForXml(context);
2282
2250
  if (txBodyObj) children.push(txBodyObj);
2283
2251
  return { "p:sp": children };
2284
2252
  }
@@ -2311,7 +2279,7 @@ var SmartArtFrame = class extends XmlComponent {
2311
2279
  }
2312
2280
  prepForXml(context) {
2313
2281
  const file = context.fileData;
2314
- if (file?.SmartArts) file.SmartArts.addSmartArt(this.smartArtKey, {
2282
+ if (file?.smartArts) file.smartArts.addSmartArt(this.smartArtKey, {
2315
2283
  key: this.smartArtKey,
2316
2284
  dataModel: this.dataModel,
2317
2285
  layout: this.layoutId,
@@ -2909,8 +2877,8 @@ function buildChildrenXml(children) {
2909
2877
  }
2910
2878
  return result;
2911
2879
  }
2912
- function buildSlideMasterXml(layoutCount, headerFooter, masterOptions, slideWidth = SW_REF, masterIndex = 0) {
2913
- const hfXml = headerFooter ? `<p:hf dt="0" hdr="0" ftr="0" sldNum="0"/>` : "";
2880
+ function buildSlideMasterXml(layoutCount, _headerFooter, masterOptions, slideWidth = SW_REF, masterIndex = 0) {
2881
+ const hfXml = `<p:hf dt="0" hdr="0" ftr="0" sldNum="0"/>`;
2914
2882
  const ph = masterOptions?.placeholders ?? {};
2915
2883
  const layoutIdBase = 2147483648 + masterIndex * 12 + 1;
2916
2884
  const layoutIdEntries = [];
@@ -2945,7 +2913,7 @@ var DefaultSlideMaster = class DefaultSlideMaster extends ImportedXmlComponent {
2945
2913
  cacheKey;
2946
2914
  constructor(layoutCount = 1, headerFooter, masterOptions, slideWidth = SW_REF, masterIndex = 0) {
2947
2915
  super("p:sldMaster");
2948
- this.cacheKey = `${layoutCount}:${headerFooter ? JSON.stringify(headerFooter) : ""}:${masterOptions ? JSON.stringify(masterOptions) : ""}:${slideWidth}:${masterIndex}`;
2916
+ this.cacheKey = `${layoutCount}:${masterOptions ? JSON.stringify(masterOptions) : ""}:${slideWidth}:${masterIndex}`;
2949
2917
  if (!DefaultSlideMaster.cache.has(this.cacheKey)) DefaultSlideMaster.cache.set(this.cacheKey, ImportedXmlComponent.fromXmlString(buildSlideMasterXml(layoutCount, headerFooter, masterOptions, slideWidth, masterIndex)));
2950
2918
  }
2951
2919
  prepForXml() {
@@ -4076,14 +4044,14 @@ var Transition = class extends BaseXmlComponent {
4076
4044
  //#region src/file/slide/slide.ts
4077
4045
  init_xml_components();
4078
4046
  function isAnimatable(child) {
4079
- return "ShapeId" in child && "Animation" in child;
4047
+ return "shapeId" in child && "animation" in child;
4080
4048
  }
4081
4049
  function collectAnimations(children) {
4082
4050
  const entries = [];
4083
4051
  for (const child of children) if (isAnimatable(child)) {
4084
- const anim = child.Animation;
4052
+ const anim = child.animation;
4085
4053
  if (anim) entries.push({
4086
- spid: child.ShapeId,
4054
+ spid: child.shapeId,
4087
4055
  options: anim
4088
4056
  });
4089
4057
  }
@@ -4336,27 +4304,27 @@ var File = class {
4336
4304
  slideWidthEmus;
4337
4305
  slideHeightEmus;
4338
4306
  masterDefs;
4339
- coreProperties;
4340
- appProperties;
4341
- contentTypes;
4342
- media;
4343
- charts;
4344
- smartArts;
4345
- hyperlinks;
4346
- presentationWrapper;
4347
- tableStyles;
4348
- presProps;
4349
- viewProps;
4350
- notesMasterRels;
4307
+ _coreProperties;
4308
+ _appProperties;
4309
+ _contentTypes;
4310
+ _media;
4311
+ _charts;
4312
+ _smartArts;
4313
+ _hyperlinks;
4314
+ _presentationWrapper;
4315
+ _tableStyles;
4316
+ _presProps;
4317
+ _viewProps;
4318
+ _notesMasterRels;
4351
4319
  masterMap;
4352
- allLayouts;
4353
- allLayoutRels;
4354
- slides;
4355
- slideWrappers;
4356
- notesSlides;
4357
- commentAuthorList;
4358
- slideCommentLists;
4359
- fileRels;
4320
+ _allLayouts;
4321
+ _allLayoutRels;
4322
+ _slides;
4323
+ _slideWrappers;
4324
+ _notesSlides;
4325
+ _commentAuthorList;
4326
+ _slideCommentLists;
4327
+ _fileRels;
4360
4328
  constructor(options) {
4361
4329
  this.slideOptions = options.slides ?? [];
4362
4330
  this.corePropsOptions = options;
@@ -4444,8 +4412,8 @@ var File = class {
4444
4412
  });
4445
4413
  }
4446
4414
  this.masterMap = masters;
4447
- this.allLayouts = masters.flatMap((m) => m.layouts);
4448
- this.allLayoutRels = masters.flatMap((m) => m.layoutRels);
4415
+ this._allLayouts = masters.flatMap((m) => m.layouts);
4416
+ this._allLayoutRels = masters.flatMap((m) => m.layoutRels);
4449
4417
  return this.masterMap;
4450
4418
  }
4451
4419
  findLayoutForSlide(slideIndex) {
@@ -4455,30 +4423,30 @@ var File = class {
4455
4423
  const layoutKey = opts.layout ?? "blank";
4456
4424
  return master.layouts.find((l) => l.key === layoutKey) ?? master.layouts[0];
4457
4425
  }
4458
- get CoreProperties() {
4459
- return this.coreProperties ??= new CoreProperties(this.corePropsOptions);
4426
+ get coreProperties() {
4427
+ return this._coreProperties ??= new CoreProperties(this.corePropsOptions);
4460
4428
  }
4461
- get AppProperties() {
4462
- return this.appProperties ??= new AppProperties();
4429
+ get appProperties() {
4430
+ return this._appProperties ??= new AppProperties();
4463
4431
  }
4464
- get ContentTypes() {
4465
- if (!this.contentTypes) {
4466
- this.contentTypes = new ContentTypes();
4432
+ get contentTypes() {
4433
+ if (!this._contentTypes) {
4434
+ this._contentTypes = new ContentTypes();
4467
4435
  let hasComments = false;
4468
4436
  for (let i = 0; i < this.slideOptions.length; i++) {
4469
- this.contentTypes.addSlide(i + 1);
4470
- if (this.slideOptions[i].notes) this.contentTypes.addNotesSlide(i + 1);
4437
+ this._contentTypes.addSlide(i + 1);
4438
+ if (this.slideOptions[i].notes) this._contentTypes.addNotesSlide(i + 1);
4471
4439
  if (this.slideOptions[i].comments && this.slideOptions[i].comments.length > 0) {
4472
- this.contentTypes.addComments(i + 1);
4440
+ this._contentTypes.addComments(i + 1);
4473
4441
  hasComments = true;
4474
4442
  }
4475
4443
  }
4476
- if (hasComments) this.contentTypes.addCommentAuthors();
4444
+ if (hasComments) this._contentTypes.addCommentAuthors();
4477
4445
  }
4478
- return this.contentTypes;
4446
+ return this._contentTypes;
4479
4447
  }
4480
- get FileRelationships() {
4481
- if (!this.fileRels) this.fileRels = buildRelationships([
4448
+ get fileRelationships() {
4449
+ if (!this._fileRels) this._fileRels = buildRelationships([
4482
4450
  {
4483
4451
  id: 1,
4484
4452
  type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
@@ -4495,30 +4463,30 @@ var File = class {
4495
4463
  target: "docProps/app.xml"
4496
4464
  }
4497
4465
  ]);
4498
- return this.fileRels;
4466
+ return this._fileRels;
4499
4467
  }
4500
- get Media() {
4501
- return this.media ??= new Media();
4468
+ get media() {
4469
+ return this._media ??= new Media();
4502
4470
  }
4503
- get Charts() {
4504
- return this.charts ??= new ChartCollection();
4471
+ get charts() {
4472
+ return this._charts ??= new ChartCollection();
4505
4473
  }
4506
- get SmartArts() {
4507
- return this.smartArts ??= new SmartArtCollection();
4474
+ get smartArts() {
4475
+ return this._smartArts ??= new SmartArtCollection();
4508
4476
  }
4509
- get Hyperlinks() {
4510
- return this.hyperlinks ??= new HyperlinkCollection();
4477
+ get hyperlinks() {
4478
+ return this._hyperlinks ??= new HyperlinkCollection();
4511
4479
  }
4512
- get PresentationWrapper() {
4513
- if (!this.presentationWrapper) {
4480
+ get presentationWrapper() {
4481
+ if (!this._presentationWrapper) {
4514
4482
  const masters = this.getMasterMap();
4515
- this.presentationWrapper = new PresentationWrapper({
4483
+ this._presentationWrapper = new PresentationWrapper({
4516
4484
  slideWidth: this.slideWidthEmus,
4517
4485
  slideHeight: this.slideHeightEmus,
4518
4486
  slideIds: this.slideOptions.map((_, i) => 256 + i),
4519
4487
  masterCount: masters.length
4520
4488
  });
4521
- const presRels = this.PresentationWrapper.Relationships;
4489
+ const presRels = this._presentationWrapper.relationships;
4522
4490
  let rid = 1;
4523
4491
  for (let mi = 0; mi < masters.length; mi++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster", `slideMasters/slideMaster${mi + 1}.xml`);
4524
4492
  for (let i = 0; i < this.slideOptions.length; i++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide", `slides/slide${i + 1}.xml`);
@@ -4527,49 +4495,49 @@ var File = class {
4527
4495
  for (let mi = 0; mi < masters.length; mi++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", `theme/theme${mi + 1}.xml`);
4528
4496
  presRels.addRelationship(rid, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles", "tableStyles.xml");
4529
4497
  }
4530
- return this.presentationWrapper;
4498
+ return this._presentationWrapper;
4531
4499
  }
4532
- get Themes() {
4500
+ get themes() {
4533
4501
  return this.getMasterMap().map((m) => m.theme);
4534
4502
  }
4535
- get TableStyles() {
4536
- return this.tableStyles ??= new TableStyles();
4503
+ get tableStyles() {
4504
+ return this._tableStyles ??= new TableStyles();
4537
4505
  }
4538
- get PresProps() {
4539
- return this.presProps ??= new PresentationProperties(this.showOptions);
4506
+ get presProps() {
4507
+ return this._presProps ??= new PresentationProperties(this.showOptions);
4540
4508
  }
4541
- get ViewProps() {
4542
- return this.viewProps ??= new ViewProperties();
4509
+ get viewProps() {
4510
+ return this._viewProps ??= new ViewProperties();
4543
4511
  }
4544
- get SlideMasters() {
4512
+ get slideMasters() {
4545
4513
  return this.getMasterMap().map((m) => m.master);
4546
4514
  }
4547
- get SlideMasterRelsArray() {
4515
+ get slideMasterRelsArray() {
4548
4516
  return this.getMasterMap().map((m) => m.masterRels);
4549
4517
  }
4550
- get AllLayouts() {
4518
+ get allLayouts() {
4551
4519
  this.getMasterMap();
4552
- return this.allLayouts;
4520
+ return this._allLayouts;
4553
4521
  }
4554
- get AllLayoutRelsArray() {
4522
+ get allLayoutRelsArray() {
4555
4523
  this.getMasterMap();
4556
- return this.allLayoutRels;
4524
+ return this._allLayoutRels;
4557
4525
  }
4558
- get Slides() {
4559
- if (!this.slides) {
4560
- this.slides = [];
4561
- for (const s of this.slideOptions) this.slides.push(new Slide(s.children ?? [], s.background ? new Background(s.background) : void 0, s.transition, s.headerFooter));
4526
+ get slides() {
4527
+ if (!this._slides) {
4528
+ this._slides = [];
4529
+ for (const s of this.slideOptions) this._slides.push(new Slide(s.children ?? [], s.background ? new Background(s.background) : void 0, s.transition, s.headerFooter));
4562
4530
  }
4563
- return this.slides;
4531
+ return this._slides;
4564
4532
  }
4565
- get SlideWrappers() {
4566
- if (!this.slideWrappers) {
4567
- this.slideWrappers = [];
4533
+ get slideWrappers() {
4534
+ if (!this._slideWrappers) {
4535
+ this._slideWrappers = [];
4568
4536
  for (let i = 0; i < this.slideOptions.length; i++) {
4569
4537
  const layout = this.findLayoutForSlide(i);
4570
- this.slideWrappers.push({
4571
- View: this.Slides[i],
4572
- Relationships: buildRelationships([{
4538
+ this._slideWrappers.push({
4539
+ view: this.slides[i],
4540
+ relationships: buildRelationships([{
4573
4541
  id: 1,
4574
4542
  type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
4575
4543
  target: `../slideLayouts/slideLayout${layout.index + 1}.xml`
@@ -4577,37 +4545,37 @@ var File = class {
4577
4545
  });
4578
4546
  }
4579
4547
  }
4580
- return this.slideWrappers;
4548
+ return this._slideWrappers;
4581
4549
  }
4582
- get NotesSlides() {
4583
- if (!this.notesSlides) {
4584
- this.notesSlides = [];
4585
- for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) this.notesSlides.push(new NotesSlide({ text: this.slideOptions[i].notes }));
4550
+ get notesSlides() {
4551
+ if (!this._notesSlides) {
4552
+ this._notesSlides = [];
4553
+ for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) this._notesSlides.push(new NotesSlide({ text: this.slideOptions[i].notes }));
4586
4554
  }
4587
- return this.notesSlides;
4555
+ return this._notesSlides;
4588
4556
  }
4589
4557
  /** Map from slide index → notesSlide index (0-based) for slides that have notes. */
4590
- get NotesSlideIndexMap() {
4558
+ get notesSlideIndexMap() {
4591
4559
  const map = /* @__PURE__ */ new Map();
4592
4560
  let notesIdx = 0;
4593
4561
  for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) map.set(i, notesIdx++);
4594
4562
  return map;
4595
4563
  }
4596
- get NotesMasterRelationships() {
4597
- return this.notesMasterRels ??= new Relationships();
4564
+ get notesMasterRelationships() {
4565
+ return this._notesMasterRels ??= new Relationships();
4598
4566
  }
4599
- get CommentAuthorList() {
4600
- if (!this.commentAuthorList && !this.slideCommentLists) this.buildComments();
4601
- return this.commentAuthorList;
4567
+ get commentAuthorList() {
4568
+ if (!this._commentAuthorList && !this._slideCommentLists) this.buildComments();
4569
+ return this._commentAuthorList;
4602
4570
  }
4603
- get SlideCommentLists() {
4604
- if (!this.slideCommentLists) this.buildComments();
4605
- return this.slideCommentLists;
4571
+ get slideCommentLists() {
4572
+ if (!this._slideCommentLists) this.buildComments();
4573
+ return this._slideCommentLists;
4606
4574
  }
4607
4575
  buildComments() {
4608
4576
  const authorMap = /* @__PURE__ */ new Map();
4609
4577
  let nextAuthorId = 0;
4610
- this.slideCommentLists = Array.from({ length: this.slideOptions.length });
4578
+ this._slideCommentLists = Array.from({ length: this.slideOptions.length });
4611
4579
  for (let i = 0; i < this.slideOptions.length; i++) {
4612
4580
  const slideComments = this.slideOptions[i].comments;
4613
4581
  if (!slideComments || slideComments.length === 0) continue;
@@ -4635,7 +4603,7 @@ var File = class {
4635
4603
  text: c.text
4636
4604
  });
4637
4605
  }
4638
- this.slideCommentLists[i] = new SlideCommentList(commentEntries);
4606
+ this._slideCommentLists[i] = new SlideCommentList(commentEntries);
4639
4607
  }
4640
4608
  if (authorMap.size > 0) {
4641
4609
  const authors = [...authorMap.values()].map((a) => ({
@@ -4645,7 +4613,7 @@ var File = class {
4645
4613
  clrIdx: a.clrIdx,
4646
4614
  lastIdx: a.commentCount
4647
4615
  }));
4648
- this.commentAuthorList = new CommentAuthorList(authors);
4616
+ this._commentAuthorList = new CommentAuthorList(authors);
4649
4617
  }
4650
4618
  }
4651
4619
  };
@@ -4888,7 +4856,7 @@ function collectRefs(xml, prefix, mediaArray) {
4888
4856
  //#endregion
4889
4857
  //#region src/export/packer/next-compiler.ts
4890
4858
  var Compiler = class {
4891
- formatter = new Formatter();
4859
+ formatter = new Formatter$1();
4892
4860
  compile(file, prettifyXml, overrides = []) {
4893
4861
  const declaration = true;
4894
4862
  const indent = prettifyXml;
@@ -4898,40 +4866,40 @@ var Compiler = class {
4898
4866
  };
4899
4867
  const mapping = {
4900
4868
  AppProperties: {
4901
- data: xml(this.formatter.format(file.AppProperties, context), { declaration }),
4869
+ data: xml(this.formatter.format(file.appProperties, context), { declaration }),
4902
4870
  path: "docProps/app.xml"
4903
4871
  },
4904
4872
  Properties: {
4905
- data: xml(this.formatter.format(file.CoreProperties, context), {
4873
+ data: xml(this.formatter.format(file.coreProperties, context), {
4906
4874
  declaration,
4907
4875
  indent
4908
4876
  }),
4909
4877
  path: "docProps/core.xml"
4910
4878
  },
4911
4879
  FileRelationships: {
4912
- data: xml(this.formatter.format(file.FileRelationships, context), { declaration: false }),
4880
+ data: xml(this.formatter.format(file.fileRelationships, context), { declaration: false }),
4913
4881
  path: "_rels/.rels"
4914
4882
  }
4915
4883
  };
4916
- const themes = file.Themes;
4884
+ const themes = file.themes;
4917
4885
  for (let ti = 0; ti < themes.length; ti++) mapping[`Theme${ti}`] = {
4918
4886
  data: this.formatter.formatToXml(themes[ti], context, declaration),
4919
4887
  path: `ppt/theme/theme${ti + 1}.xml`
4920
4888
  };
4921
4889
  mapping["TableStyles"] = {
4922
- data: this.formatter.formatToXml(file.TableStyles, context, declaration),
4890
+ data: this.formatter.formatToXml(file.tableStyles, context, declaration),
4923
4891
  path: "ppt/tableStyles.xml"
4924
4892
  };
4925
4893
  mapping["PresProps"] = {
4926
- data: this.formatter.formatToXml(file.PresProps, context, declaration),
4894
+ data: this.formatter.formatToXml(file.presProps, context, declaration),
4927
4895
  path: "ppt/presProps.xml"
4928
4896
  };
4929
4897
  mapping["ViewProps"] = {
4930
- data: this.formatter.formatToXml(file.ViewProps, context, declaration),
4898
+ data: this.formatter.formatToXml(file.viewProps, context, declaration),
4931
4899
  path: "ppt/viewProps.xml"
4932
4900
  };
4933
- const masters = file.SlideMasters;
4934
- const masterRels = file.SlideMasterRelsArray;
4901
+ const masters = file.slideMasters;
4902
+ const masterRels = file.slideMasterRelsArray;
4935
4903
  for (let mi = 0; mi < masters.length; mi++) {
4936
4904
  mapping[`SlideMaster${mi}`] = {
4937
4905
  data: this.formatter.formatToXml(masters[mi], context, declaration),
@@ -4942,8 +4910,8 @@ var Compiler = class {
4942
4910
  path: `ppt/slideMasters/_rels/slideMaster${mi + 1}.xml.rels`
4943
4911
  };
4944
4912
  }
4945
- const layouts = file.AllLayouts;
4946
- const layoutRels = file.AllLayoutRelsArray;
4913
+ const layouts = file.allLayouts;
4914
+ const layoutRels = file.allLayoutRelsArray;
4947
4915
  for (let li = 0; li < layouts.length; li++) {
4948
4916
  mapping[`SlideLayout${li}`] = {
4949
4917
  data: this.formatter.formatToXml(layouts[li].layout, context, declaration),
@@ -4954,13 +4922,13 @@ var Compiler = class {
4954
4922
  path: `ppt/slideLayouts/_rels/slideLayout${li + 1}.xml.rels`
4955
4923
  };
4956
4924
  }
4957
- for (let i = 0; i < layouts.length; i++) file.ContentTypes.addSlideLayout(i + 1);
4925
+ for (let i = 0; i < layouts.length; i++) file.contentTypes.addSlideLayout(i + 1);
4958
4926
  for (let mi = 0; mi < masters.length; mi++) {
4959
- file.ContentTypes.addSlideMaster(mi + 1);
4960
- file.ContentTypes.addTheme(mi + 1);
4927
+ file.contentTypes.addSlideMaster(mi + 1);
4928
+ file.contentTypes.addTheme(mi + 1);
4961
4929
  }
4962
- if (file.NotesSlides.length > 0) {
4963
- file.PresentationWrapper.Relationships.addRelationship(file.PresentationWrapper.Relationships.RelationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", "notesMasters/notesMaster1.xml");
4930
+ if (file.notesSlides.length > 0) {
4931
+ file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", "notesMasters/notesMaster1.xml");
4964
4932
  mapping["NotesMaster"] = {
4965
4933
  data: xml(this.formatter.format(new DefaultNotesMaster(), context), {
4966
4934
  declaration,
@@ -4969,17 +4937,17 @@ var Compiler = class {
4969
4937
  path: "ppt/notesMasters/notesMaster1.xml"
4970
4938
  };
4971
4939
  mapping["NotesMasterRelationships"] = {
4972
- data: xml(this.formatter.format(file.NotesMasterRelationships, context), { declaration: false }),
4940
+ data: xml(this.formatter.format(file.notesMasterRelationships, context), { declaration: false }),
4973
4941
  path: "ppt/notesMasters/_rels/notesMaster1.xml.rels"
4974
4942
  };
4975
4943
  }
4976
- if (file.CommentAuthorList) file.PresentationWrapper.Relationships.addRelationship(file.PresentationWrapper.Relationships.RelationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors", "commentAuthors.xml");
4977
- const presentationXml = this.formatter.formatToXml(file.PresentationWrapper.View, context, declaration);
4944
+ if (file.commentAuthorList) file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors", "commentAuthors.xml");
4945
+ const presentationXml = this.formatter.formatToXml(file.presentationWrapper.view, context, declaration);
4978
4946
  let currentImageCount = 0;
4979
- const mediaData = getReferencedMedia(presentationXml, file.Media.Array);
4980
- const presImageOffset = file.PresentationWrapper.Relationships.RelationshipCount + 1;
4947
+ const mediaData = getReferencedMedia(presentationXml, file.media.array);
4948
+ const presImageOffset = file.presentationWrapper.relationships.relationshipCount + 1;
4981
4949
  mediaData.forEach((image, idx) => {
4982
- file.PresentationWrapper.Relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
4950
+ file.presentationWrapper.relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
4983
4951
  });
4984
4952
  const replacedPresentationXml = replaceImagePlaceholders(presentationXml, mediaData, presImageOffset);
4985
4953
  currentImageCount += mediaData.length;
@@ -4988,38 +4956,38 @@ var Compiler = class {
4988
4956
  path: "ppt/presentation.xml"
4989
4957
  };
4990
4958
  mapping["PresentationRelationships"] = {
4991
- data: xml(this.formatter.format(file.PresentationWrapper.Relationships, context), { declaration: false }),
4959
+ data: xml(this.formatter.format(file.presentationWrapper.relationships, context), { declaration: false }),
4992
4960
  path: "ppt/_rels/presentation.xml.rels"
4993
4961
  };
4994
- for (let i = 0; i < file.Slides.length; i++) {
4995
- const slideWrapper = file.SlideWrappers[i];
4996
- const slideXml = this.formatter.formatToXml(slideWrapper.View, context, declaration);
4997
- const slideMediaData = getReferencedMedia(slideXml, file.Media.Array);
4998
- const slideImageOffset = slideWrapper.Relationships.RelationshipCount + 1;
4962
+ for (let i = 0; i < file.slides.length; i++) {
4963
+ const slideWrapper = file.slideWrappers[i];
4964
+ const slideXml = this.formatter.formatToXml(slideWrapper.view, context, declaration);
4965
+ const slideMediaData = getReferencedMedia(slideXml, file.media.array);
4966
+ const slideImageOffset = slideWrapper.relationships.relationshipCount + 1;
4999
4967
  slideMediaData.forEach((image, idx) => {
5000
- slideWrapper.Relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
4968
+ slideWrapper.relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
5001
4969
  });
5002
4970
  let replacedSlideXml = replaceImagePlaceholders(slideXml, slideMediaData, slideImageOffset);
5003
4971
  currentImageCount += slideMediaData.length;
5004
4972
  if (hasPlaceholders(replacedSlideXml)) {
5005
4973
  const slideChartKeys = collectPlaceholderKeys(replacedSlideXml, "chart:");
5006
4974
  if (slideChartKeys.length > 0) {
5007
- const slideChartOffset = slideWrapper.Relationships.RelationshipCount + 1;
5008
- const slideCharts = file.Charts.Array.filter((c) => slideChartKeys.includes(c.key));
4975
+ const slideChartOffset = slideWrapper.relationships.relationshipCount + 1;
4976
+ const slideCharts = file.charts.array.filter((c) => slideChartKeys.includes(c.key));
5009
4977
  replacedSlideXml = replaceChartPlaceholders(replacedSlideXml, slideCharts.map((c) => c.key), slideChartOffset);
5010
4978
  slideCharts.forEach((chartData, ci) => {
5011
- const globalIndex = file.Charts.Array.indexOf(chartData);
5012
- slideWrapper.Relationships.addRelationship(slideChartOffset + ci, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `../charts/chart${globalIndex + 1}.xml`);
4979
+ const globalIndex = file.charts.array.indexOf(chartData);
4980
+ slideWrapper.relationships.addRelationship(slideChartOffset + ci, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `../charts/chart${globalIndex + 1}.xml`);
5013
4981
  });
5014
4982
  }
5015
4983
  const slideSmartArtKeys = collectPlaceholderKeys(replacedSlideXml, "smartart:");
5016
4984
  if (slideSmartArtKeys.length > 0) {
5017
- const slideSmartArts = file.SmartArts.Array.filter((s) => slideSmartArtKeys.includes(s.key));
5018
- const saOffset = slideWrapper.Relationships.RelationshipCount + 1;
4985
+ const slideSmartArts = file.smartArts.array.filter((s) => slideSmartArtKeys.includes(s.key));
4986
+ const saOffset = slideWrapper.relationships.relationshipCount + 1;
5019
4987
  replacedSlideXml = replaceSmartArtPlaceholders(replacedSlideXml, slideSmartArts.map((s) => s.key), saOffset);
5020
- const saGlobalStart = file.SmartArts.Array.indexOf(slideSmartArts[0]);
4988
+ const saGlobalStart = file.smartArts.array.indexOf(slideSmartArts[0]);
5021
4989
  addSmartArtRelationships(slideSmartArts.map((s) => s.key), (id, type, target) => {
5022
- slideWrapper.Relationships.addRelationship(id, type, target);
4990
+ slideWrapper.relationships.addRelationship(id, type, target);
5023
4991
  }, saOffset, saGlobalStart, {
5024
4992
  pathPrefix: "../",
5025
4993
  styleRelType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"
@@ -5027,25 +4995,25 @@ var Compiler = class {
5027
4995
  }
5028
4996
  const slideHlinkKeys = collectPlaceholderKeys(replacedSlideXml, "hlink:");
5029
4997
  if (slideHlinkKeys.length > 0) {
5030
- const slideHlinks = file.Hyperlinks.Array.filter((h) => slideHlinkKeys.includes(h.key));
5031
- const hlinkOffset = slideWrapper.Relationships.RelationshipCount + 1;
4998
+ const slideHlinks = file.hyperlinks.array.filter((h) => slideHlinkKeys.includes(h.key));
4999
+ const hlinkOffset = slideWrapper.relationships.relationshipCount + 1;
5032
5000
  replacedSlideXml = replaceHyperlinkPlaceholders(replacedSlideXml, slideHlinks, hlinkOffset);
5033
5001
  slideHlinks.forEach((hlink, hi) => {
5034
- slideWrapper.Relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hlink.url, "External");
5002
+ slideWrapper.relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hlink.url, "External");
5035
5003
  });
5036
5004
  }
5037
- const slideMediaRefs = getMediaRefs(replacedSlideXml, file.Media.Array);
5038
- const slideVideoRefs = getVideoRefs(replacedSlideXml, file.Media.Array);
5005
+ const slideMediaRefs = getMediaRefs(replacedSlideXml, file.media.array);
5006
+ const slideVideoRefs = getVideoRefs(replacedSlideXml, file.media.array);
5039
5007
  if (slideMediaRefs.length > 0 || slideVideoRefs.length > 0) {
5040
- const mediaOffset = slideWrapper.Relationships.RelationshipCount + 1;
5008
+ const mediaOffset = slideWrapper.relationships.relationshipCount + 1;
5041
5009
  const videoOffset = mediaOffset + slideMediaRefs.length;
5042
5010
  replacedSlideXml = replaceMediaPlaceholders(replacedSlideXml, slideMediaRefs, mediaOffset);
5043
5011
  replacedSlideXml = replaceVideoPlaceholders(replacedSlideXml, slideVideoRefs, videoOffset);
5044
5012
  slideMediaRefs.forEach((media, mi) => {
5045
- slideWrapper.Relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${media.fileName}`);
5013
+ slideWrapper.relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${media.fileName}`);
5046
5014
  });
5047
5015
  slideVideoRefs.forEach((video, vi) => {
5048
- slideWrapper.Relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
5016
+ slideWrapper.relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
5049
5017
  });
5050
5018
  }
5051
5019
  }
@@ -5053,77 +5021,77 @@ var Compiler = class {
5053
5021
  data: replacedSlideXml,
5054
5022
  path: `ppt/slides/slide${i + 1}.xml`
5055
5023
  };
5056
- if (file.SlideCommentLists[i]) slideWrapper.Relationships.addRelationship(slideWrapper.Relationships.RelationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", `../comments/comment${i + 1}.xml`);
5057
- const notesSlideIndex = file.NotesSlideIndexMap.get(i);
5058
- if (notesSlideIndex !== void 0) slideWrapper.Relationships.addRelationship(slideWrapper.Relationships.RelationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`);
5024
+ if (file.slideCommentLists[i]) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", `../comments/comment${i + 1}.xml`);
5025
+ const notesSlideIndex = file.notesSlideIndexMap.get(i);
5026
+ if (notesSlideIndex !== void 0) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`);
5059
5027
  mapping[`SlideRelationships${i}`] = {
5060
- data: xml(this.formatter.format(slideWrapper.Relationships, context), { declaration: false }),
5028
+ data: xml(this.formatter.format(slideWrapper.relationships, context), { declaration: false }),
5061
5029
  path: `ppt/slides/_rels/slide${i + 1}.xml.rels`
5062
5030
  };
5063
5031
  }
5064
- file.Charts.Array.forEach((_, i) => {
5065
- file.ContentTypes.addChart(i + 1);
5032
+ file.charts.array.forEach((_, i) => {
5033
+ file.contentTypes.addChart(i + 1);
5066
5034
  });
5067
- file.SmartArts.Array.forEach((_, i) => {
5068
- file.ContentTypes.addDiagramData(i + 1);
5069
- file.ContentTypes.addDiagramLayout(i + 1);
5070
- file.ContentTypes.addDiagramStyle(i + 1);
5071
- file.ContentTypes.addDiagramColors(i + 1);
5072
- file.ContentTypes.addDiagramDrawing(i + 1);
5035
+ file.smartArts.array.forEach((_, i) => {
5036
+ file.contentTypes.addDiagramData(i + 1);
5037
+ file.contentTypes.addDiagramLayout(i + 1);
5038
+ file.contentTypes.addDiagramStyle(i + 1);
5039
+ file.contentTypes.addDiagramColors(i + 1);
5040
+ file.contentTypes.addDiagramDrawing(i + 1);
5073
5041
  });
5074
5042
  mapping["ContentTypes"] = {
5075
- data: xml(this.formatter.format(file.ContentTypes, context), { declaration: false }),
5043
+ data: xml(this.formatter.format(file.contentTypes, context), { declaration: false }),
5076
5044
  path: "[Content_Types].xml"
5077
5045
  };
5078
5046
  const files = {};
5079
5047
  for (const key of Object.keys(mapping)) {
5080
5048
  const entry = mapping[key];
5081
- files[entry.path] = textToUint8Array(entry.data);
5049
+ files[entry.path] = textToUint8Array$1(entry.data);
5082
5050
  }
5083
- for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array(override.data);
5084
- for (let i = 0; i < file.Charts.Array.length; i++) {
5085
- const chartData = file.Charts.Array[i];
5086
- files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
5051
+ for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array$1(override.data);
5052
+ for (let i = 0; i < file.charts.array.length; i++) {
5053
+ const chartData = file.charts.array[i];
5054
+ files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(chartData.chartSpace, context), {
5087
5055
  declaration,
5088
5056
  indent
5089
5057
  }));
5090
- files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5058
+ files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5091
5059
  encoding: "UTF-8",
5092
5060
  standalone: "yes"
5093
5061
  } }));
5094
5062
  }
5095
- for (let i = 0; i < file.SmartArts.Array.length; i++) {
5096
- const smartArtData = file.SmartArts.Array[i];
5097
- files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
5063
+ for (let i = 0; i < file.smartArts.array.length; i++) {
5064
+ const smartArtData = file.smartArts.array[i];
5065
+ files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(smartArtData.dataModel, context), {
5098
5066
  declaration,
5099
5067
  indent
5100
5068
  }));
5101
- files[`ppt/diagrams/layout${i + 1}.xml`] = textToUint8Array(getLayoutXml(smartArtData.layout));
5102
- files[`ppt/diagrams/quickStyle${i + 1}.xml`] = textToUint8Array(getStyleXml(smartArtData.style));
5103
- files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array(getColorXml(smartArtData.color));
5104
- files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array(DEFAULT_DRAWING_XML);
5069
+ files[`ppt/diagrams/layout${i + 1}.xml`] = textToUint8Array$1(getLayoutXml(smartArtData.layout));
5070
+ files[`ppt/diagrams/quickStyle${i + 1}.xml`] = textToUint8Array$1(getStyleXml(smartArtData.style));
5071
+ files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array$1(getColorXml(smartArtData.color));
5072
+ files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array$1(DEFAULT_DRAWING_XML);
5105
5073
  }
5106
- for (let i = 0; i < file.NotesSlides.length; i++) {
5107
- const notesSlide = file.NotesSlides[i];
5108
- files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(notesSlide, context), {
5074
+ for (let i = 0; i < file.notesSlides.length; i++) {
5075
+ const notesSlide = file.notesSlides[i];
5076
+ files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(notesSlide, context), {
5109
5077
  declaration,
5110
5078
  indent
5111
5079
  }));
5112
- files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5080
+ files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5113
5081
  encoding: "UTF-8",
5114
5082
  standalone: "yes"
5115
5083
  } }));
5116
5084
  }
5117
- if (file.CommentAuthorList) files["ppt/commentAuthors.xml"] = textToUint8Array(xml(this.formatter.format(file.CommentAuthorList, context), {
5085
+ if (file.commentAuthorList) files["ppt/commentAuthors.xml"] = textToUint8Array$1(xml(this.formatter.format(file.commentAuthorList, context), {
5118
5086
  declaration,
5119
5087
  indent
5120
5088
  }));
5121
- const commentLists = file.SlideCommentLists;
5122
- for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(commentLists[i], context), {
5089
+ const commentLists = file.slideCommentLists;
5090
+ for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(commentLists[i], context), {
5123
5091
  declaration,
5124
5092
  indent
5125
5093
  }));
5126
- for (const image of file.Media.Array) {
5094
+ for (const image of file.media.array) {
5127
5095
  files[`ppt/media/${image.fileName}`] = [image.data, { level: ZIP_STORED_LEVEL }];
5128
5096
  if (image.type === "svg" && "fallback" in image) {
5129
5097
  const fallback = image.fallback;
@@ -5133,7 +5101,7 @@ var Compiler = class {
5133
5101
  return files;
5134
5102
  }
5135
5103
  };
5136
- function textToUint8Array(data) {
5104
+ function textToUint8Array$1(data) {
5137
5105
  if (data instanceof Uint8Array) return data;
5138
5106
  return new TextEncoder().encode(data);
5139
5107
  }
@@ -5354,17 +5322,19 @@ function parseAnimationEffect(el) {
5354
5322
  }
5355
5323
  const childTnLst = findChild(cTn, "p:childTnLst");
5356
5324
  if (childTnLst) for (const sub of childTnLst.elements ?? []) switch (sub.name) {
5357
- case "p:animEffect": {
5358
- const subCTn = findChild(sub, "p:cTn");
5359
- if (subCTn) {
5360
- const subDur = attr(subCTn, "dur");
5361
- if (subDur) {
5362
- const ms = parseDuration(subDur);
5363
- if (ms !== void 0) opts.duration = ms;
5325
+ case "p:animEffect":
5326
+ if (opts.duration === void 0) {
5327
+ const cBhvr = findChild(sub, "p:cBhvr");
5328
+ const subCTn = cBhvr ? findChild(cBhvr, "p:cTn") : void 0;
5329
+ if (subCTn) {
5330
+ const subDur = attr(subCTn, "dur");
5331
+ if (subDur) {
5332
+ const ms = parseDuration(subDur);
5333
+ if (ms !== void 0) opts.duration = ms;
5334
+ }
5364
5335
  }
5365
5336
  }
5366
5337
  break;
5367
- }
5368
5338
  case "p:anim": {
5369
5339
  const subCTn = findChild(sub, "p:cTn");
5370
5340
  if (subCTn) {
@@ -5406,12 +5376,15 @@ function parseAnimationEffect(el) {
5406
5376
  }
5407
5377
  case "p:animScale":
5408
5378
  opts.emphasisType = "growShrink";
5379
+ readSubDuration(sub, opts);
5409
5380
  break;
5410
5381
  case "p:animRot":
5411
5382
  opts.emphasisType = "spin";
5383
+ readSubDuration(sub, opts);
5412
5384
  break;
5413
5385
  case "p:animClr":
5414
5386
  opts.emphasisType = "colorChange";
5387
+ readSubDuration(sub, opts);
5415
5388
  break;
5416
5389
  case "p:cmd":
5417
5390
  if (attr(sub, "type") === "call") opts.mediaType = "play";
@@ -5441,6 +5414,21 @@ function findDeep$1(parent, name) {
5441
5414
  return results;
5442
5415
  }
5443
5416
  /**
5417
+ * Read duration from p:cBhvr > p:cTn inside a sub-effect element.
5418
+ */
5419
+ function readSubDuration(sub, opts) {
5420
+ if (opts.duration !== void 0) return;
5421
+ const cBhvr = findChild(sub, "p:cBhvr");
5422
+ const subCTn = cBhvr ? findChild(cBhvr, "p:cTn") : void 0;
5423
+ if (subCTn) {
5424
+ const subDur = attr(subCTn, "dur");
5425
+ if (subDur) {
5426
+ const ms = parseDuration(subDur);
5427
+ if (ms !== void 0) opts.duration = ms;
5428
+ }
5429
+ }
5430
+ }
5431
+ /**
5444
5432
  * Parse OOXML duration string to milliseconds.
5445
5433
  * Format: "PT#H#M#S" or "###ms" or just a number string
5446
5434
  */
@@ -5616,7 +5604,7 @@ function parseTransition(el) {
5616
5604
  }
5617
5605
  return opts;
5618
5606
  }
5619
- function parseShape(el, _ctx) {
5607
+ function parseShape(el, ctx) {
5620
5608
  const opts = {};
5621
5609
  const nvSpPr = findChild(el, "p:nvSpPr");
5622
5610
  if (nvSpPr) {
@@ -5650,7 +5638,7 @@ function parseShape(el, _ctx) {
5650
5638
  if (effects) opts.effects = effects;
5651
5639
  }
5652
5640
  const txBody = findChild(el, "p:txBody");
5653
- if (txBody) parseTextBody(txBody, opts);
5641
+ if (txBody) parseTextBody(txBody, opts, ctx.slideRels);
5654
5642
  return opts;
5655
5643
  }
5656
5644
  function parseLineShape(el) {
@@ -5715,7 +5703,7 @@ function parsePicture(el, ctx) {
5715
5703
  }
5716
5704
  const nvPicPr = findChild(el, "p:nvPicPr");
5717
5705
  if (nvPicPr) {
5718
- const cNvPr = findChild(nvPicPr, "p:cNvPr");
5706
+ const cNvPr = findChild(nvPicPr, "a:cNvPr") ?? findChild(nvPicPr, "p:cNvPr");
5719
5707
  if (cNvPr) {
5720
5708
  const name = attr(cNvPr, "name");
5721
5709
  if (name) opts.name = name;
@@ -5998,6 +5986,20 @@ function parseTableCell(tc) {
5998
5986
  if (txBody) {
5999
5987
  const paragraphs = parseParagraphsFromTxBody(txBody);
6000
5988
  if (paragraphs.length > 0) opts.children = paragraphs;
5989
+ const bodyPr = findChild(txBody, "a:bodyPr");
5990
+ if (bodyPr) {
5991
+ const margins = {};
5992
+ for (const [attrName, key] of [
5993
+ ["tIns", "top"],
5994
+ ["bIns", "bottom"],
5995
+ ["lIns", "left"],
5996
+ ["rIns", "right"]
5997
+ ]) {
5998
+ const val = attrNum(bodyPr, attrName);
5999
+ if (val !== void 0) margins[key] = val;
6000
+ }
6001
+ if (Object.keys(margins).length > 0) opts.margins = margins;
6002
+ }
6001
6003
  }
6002
6004
  const tcPr = findChild(tc, "a:tcPr");
6003
6005
  if (tcPr) {
@@ -6006,9 +6008,9 @@ function parseTableCell(tc) {
6006
6008
  const anchor = attr(tcPr, "anchor");
6007
6009
  if (anchor) {
6008
6010
  const anchorMap = {
6009
- t: "TOP",
6010
- ctr: "CENTER",
6011
- b: "BOTTOM"
6011
+ t: "top",
6012
+ ctr: "center",
6013
+ b: "bottom"
6012
6014
  };
6013
6015
  if (anchor in anchorMap) opts.verticalAlign = anchorMap[anchor];
6014
6016
  }
@@ -6035,7 +6037,7 @@ function parseTableCell(tc) {
6035
6037
  const borderOpts = {};
6036
6038
  if (w !== void 0) borderOpts.width = w;
6037
6039
  const fill = parseFillFromElement(borderEl);
6038
- if (fill) borderOpts.fill = fill;
6040
+ if (typeof fill === "string") borderOpts.color = fill;
6039
6041
  if (Object.keys(borderOpts).length > 0) borders[key] = borderOpts;
6040
6042
  }
6041
6043
  }
@@ -6136,22 +6138,23 @@ function parseGroup(el, ctx) {
6136
6138
  opts.children = groupChildren;
6137
6139
  return opts;
6138
6140
  }
6139
- function parseTextBody(txBody, opts) {
6141
+ function parseTextBody(txBody, opts, rels) {
6142
+ const textBody = {};
6140
6143
  const bodyPr = findChild(txBody, "a:bodyPr");
6141
6144
  if (bodyPr) {
6142
6145
  const vert = attr(bodyPr, "vert");
6143
- if (vert) opts.textVertical = vert;
6146
+ if (vert) textBody.vertical = vert;
6144
6147
  const anchor = attr(bodyPr, "anchor");
6145
6148
  if (anchor) {
6146
6149
  const anchorMap = {
6147
- t: "TOP",
6148
- ctr: "CENTER",
6149
- b: "BOTTOM"
6150
+ t: "top",
6151
+ ctr: "center",
6152
+ b: "bottom"
6150
6153
  };
6151
- if (anchor in anchorMap) opts.textAnchor = anchorMap[anchor];
6154
+ if (anchor in anchorMap) textBody.anchor = anchorMap[anchor];
6152
6155
  }
6153
6156
  const wrap = attr(bodyPr, "wrap");
6154
- if (wrap) opts.textWrap = wrap;
6157
+ if (wrap) textBody.wrap = wrap;
6155
6158
  const tIns = attrNum(bodyPr, "tIns");
6156
6159
  const bIns = attrNum(bodyPr, "bIns");
6157
6160
  const lIns = attrNum(bodyPr, "lIns");
@@ -6161,34 +6164,36 @@ function parseTextBody(txBody, opts) {
6161
6164
  if (bIns !== void 0) margins.bottom = bIns;
6162
6165
  if (lIns !== void 0) margins.left = lIns;
6163
6166
  if (rIns !== void 0) margins.right = rIns;
6164
- if (Object.keys(margins).length > 0) opts.textMargins = margins;
6167
+ if (Object.keys(margins).length > 0) textBody.margins = margins;
6165
6168
  const numCol = attrNum(bodyPr, "numCol");
6166
- if (numCol !== void 0) opts.textColumns = numCol;
6169
+ if (numCol !== void 0) textBody.columns = numCol;
6167
6170
  const spcCol = attrNum(bodyPr, "spcCol");
6168
- if (spcCol !== void 0) opts.textColumnSpacing = spcCol / 100;
6169
- if (findChild(bodyPr, "a:normAutofit")) opts.textAutoFit = "normal";
6170
- else if (findChild(bodyPr, "a:spAutoFit")) opts.textAutoFit = "shape";
6171
- else if (findChild(bodyPr, "a:noAutofit")) opts.textAutoFit = "none";
6171
+ if (spcCol !== void 0) textBody.columnSpacing = spcCol / 100;
6172
+ if (findChild(bodyPr, "a:normAutofit")) textBody.autoFit = "normal";
6173
+ else if (findChild(bodyPr, "a:spAutoFit")) textBody.autoFit = "shape";
6174
+ else if (findChild(bodyPr, "a:noAutofit")) textBody.autoFit = "none";
6172
6175
  }
6173
- const paragraphs = parseParagraphsFromTxBody(txBody);
6176
+ const paragraphs = parseParagraphsFromTxBody(txBody, rels);
6174
6177
  if (paragraphs.length === 1) {
6175
6178
  const p = paragraphs[0];
6176
6179
  if (p.text && !p.children) {
6177
6180
  const props = p.properties;
6178
6181
  if (!(props && Object.keys(props).some((k) => k !== "bullet" || props[k]?.type !== "none"))) {
6179
- opts.text = p.text;
6182
+ textBody.text = p.text;
6183
+ opts.textBody = textBody;
6180
6184
  return;
6181
6185
  }
6182
6186
  }
6183
6187
  }
6184
- if (paragraphs.length > 0) opts.paragraphs = paragraphs;
6188
+ if (paragraphs.length > 0) textBody.children = paragraphs;
6189
+ if (Object.keys(textBody).length > 0) opts.textBody = textBody;
6185
6190
  }
6186
- function parseParagraphsFromTxBody(txBody) {
6191
+ function parseParagraphsFromTxBody(txBody, rels) {
6187
6192
  const paragraphs = [];
6188
- for (const pEl of children(txBody, "a:p")) paragraphs.push(parseParagraph(pEl));
6193
+ for (const pEl of children(txBody, "a:p")) paragraphs.push(parseParagraph(pEl, rels));
6189
6194
  return paragraphs;
6190
6195
  }
6191
- function parseParagraph(el) {
6196
+ function parseParagraph(el, rels) {
6192
6197
  const opts = {};
6193
6198
  const pPr = findChild(el, "a:pPr");
6194
6199
  if (pPr) {
@@ -6196,10 +6201,10 @@ function parseParagraph(el) {
6196
6201
  const algn = attr(pPr, "algn");
6197
6202
  if (algn) {
6198
6203
  const alignMap = {
6199
- l: "LEFT",
6200
- ctr: "CENTER",
6201
- r: "RIGHT",
6202
- just: "JUSTIFY"
6204
+ l: "left",
6205
+ ctr: "center",
6206
+ r: "right",
6207
+ just: "justify"
6203
6208
  };
6204
6209
  if (algn in alignMap) props.alignment = alignMap[algn];
6205
6210
  }
@@ -6219,7 +6224,7 @@ function parseParagraph(el) {
6219
6224
  if (buClr) {
6220
6225
  const srgbClr = findChild(buClr, "a:srgbClr");
6221
6226
  if (srgbClr) {
6222
- const val = attr(srgbClr, "val");
6227
+ const val = colorAttr(srgbClr, "val");
6223
6228
  if (val) bulletOpts.color = val;
6224
6229
  }
6225
6230
  }
@@ -6270,12 +6275,12 @@ function parseParagraph(el) {
6270
6275
  if (Object.keys(props).length > 0) opts.properties = props;
6271
6276
  }
6272
6277
  const runs = [];
6273
- for (const rEl of children(el, "a:r")) runs.push(parseRun(rEl));
6278
+ for (const rEl of children(el, "a:r")) runs.push(parseRun(rEl, rels));
6274
6279
  if (runs.length === 1 && Object.keys(runs[0]).length === 1 && runs[0].text) opts.text = runs[0].text;
6275
6280
  else if (runs.length > 0) opts.children = runs;
6276
6281
  return opts;
6277
6282
  }
6278
- function parseRun(el) {
6283
+ function parseRun(el, rels) {
6279
6284
  const opts = {};
6280
6285
  const rPr = findChild(el, "a:rPr");
6281
6286
  if (rPr) {
@@ -6288,9 +6293,9 @@ function parseRun(el) {
6288
6293
  const u = attr(rPr, "u");
6289
6294
  if (u) {
6290
6295
  const underlineMap = {
6291
- sng: "SINGLE",
6292
- dbl: "DOUBLE",
6293
- none: "NONE"
6296
+ sng: "single",
6297
+ dbl: "double",
6298
+ none: "none"
6294
6299
  };
6295
6300
  if (u in underlineMap) opts.underline = underlineMap[u];
6296
6301
  }
@@ -6299,9 +6304,9 @@ function parseRun(el) {
6299
6304
  const strike = attr(rPr, "strike");
6300
6305
  if (strike) {
6301
6306
  const strikeMap = {
6302
- sngStrike: "SINGLE",
6303
- dblStrike: "DOUBLE",
6304
- noStrike: "NONE"
6307
+ sngStrike: "sngStrike",
6308
+ dblStrike: "dblStrike",
6309
+ noStrike: "noStrike"
6305
6310
  };
6306
6311
  if (strike in strikeMap) opts.strike = strikeMap[strike];
6307
6312
  }
@@ -6310,9 +6315,9 @@ function parseRun(el) {
6310
6315
  const cap = attr(rPr, "cap");
6311
6316
  if (cap) {
6312
6317
  const capMap = {
6313
- none: "NONE",
6314
- all: "ALL",
6315
- small: "SMALL"
6318
+ none: "none",
6319
+ all: "all",
6320
+ small: "small"
6316
6321
  };
6317
6322
  if (cap in capMap) opts.capitalization = capMap[cap];
6318
6323
  }
@@ -6325,6 +6330,19 @@ function parseRun(el) {
6325
6330
  }
6326
6331
  const fill = parseFillFromElement(rPr);
6327
6332
  if (fill) opts.fill = fill;
6333
+ const hlinkClick = findChild(rPr, "a:hlinkClick");
6334
+ if (hlinkClick && rels) {
6335
+ const rId = attr(hlinkClick, "r:id");
6336
+ if (rId) {
6337
+ const url = rels.get(rId);
6338
+ if (url) {
6339
+ const hyperlink = { url };
6340
+ const tooltip = attr(hlinkClick, "tooltip");
6341
+ if (tooltip) hyperlink.tooltip = tooltip;
6342
+ opts.hyperlink = hyperlink;
6343
+ }
6344
+ }
6345
+ }
6328
6346
  }
6329
6347
  const t = findChild(el, "a:t");
6330
6348
  if (t) opts.text = textOf(t) ?? "";
@@ -6380,7 +6398,7 @@ function parseFillFromElement(parent) {
6380
6398
  const solidFill = findChild(parent, "a:solidFill");
6381
6399
  if (solidFill) {
6382
6400
  const srgbClr = findChild(solidFill, "a:srgbClr");
6383
- if (srgbClr) return attr(srgbClr, "val");
6401
+ if (srgbClr) return colorAttr(srgbClr, "val");
6384
6402
  const schemeClr = findChild(solidFill, "a:schemeClr");
6385
6403
  if (schemeClr) return {
6386
6404
  type: "scheme",
@@ -6398,7 +6416,7 @@ function parseFillFromElement(parent) {
6398
6416
  if (fgClr) {
6399
6417
  const srgbClr = findChild(fgClr, "a:srgbClr");
6400
6418
  if (srgbClr) {
6401
- const val = attr(srgbClr, "val");
6419
+ const val = colorAttr(srgbClr, "val");
6402
6420
  if (val) result.foregroundColor = val;
6403
6421
  }
6404
6422
  }
@@ -6406,7 +6424,7 @@ function parseFillFromElement(parent) {
6406
6424
  if (bgClr) {
6407
6425
  const srgbClr = findChild(bgClr, "a:srgbClr");
6408
6426
  if (srgbClr) {
6409
- const val = attr(srgbClr, "val");
6427
+ const val = colorAttr(srgbClr, "val");
6410
6428
  if (val) result.backgroundColor = val;
6411
6429
  }
6412
6430
  }
@@ -6425,8 +6443,8 @@ function parseFillFromElement(parent) {
6425
6443
  const pos = attrNum(gs, "pos");
6426
6444
  const srgbClr = findChild(gs, "a:srgbClr");
6427
6445
  if (pos !== void 0 && srgbClr) stops.push({
6428
- position: pos / 1e5,
6429
- color: attr(srgbClr, "val") ?? ""
6446
+ position: pos / 1e3,
6447
+ color: colorAttr(srgbClr, "val") ?? ""
6430
6448
  });
6431
6449
  }
6432
6450
  if (stops.length > 0) {
@@ -6439,6 +6457,11 @@ function parseFillFromElement(parent) {
6439
6457
  const ang = attrNum(lin, "ang");
6440
6458
  if (ang !== void 0) result.angle = Math.round(ang / 6e4);
6441
6459
  }
6460
+ const pathEl = findChild(gradFill, "a:path");
6461
+ if (pathEl) {
6462
+ const pathType = attr(pathEl, "path");
6463
+ if (pathType) result.path = pathType;
6464
+ }
6442
6465
  return result;
6443
6466
  }
6444
6467
  }
@@ -6453,7 +6476,7 @@ function parseOutlineFromElement(parent) {
6453
6476
  if (solidFill) {
6454
6477
  const srgbClr = findChild(solidFill, "a:srgbClr");
6455
6478
  if (srgbClr) {
6456
- const val = attr(srgbClr, "val");
6479
+ const val = colorAttr(srgbClr, "val");
6457
6480
  if (val) opts.color = val;
6458
6481
  }
6459
6482
  }
@@ -6465,10 +6488,10 @@ function parseOutlineFromElement(parent) {
6465
6488
  return Object.keys(opts).length > 0 ? opts : void 0;
6466
6489
  }
6467
6490
  function parseEffectsFromElement(parent) {
6468
- const effectLst = findChild(findChild(parent, "p:spPr") ?? parent, "a:effectLst");
6469
- if (!effectLst) return void 0;
6491
+ const spPr = findChild(parent, "p:spPr") ?? parent;
6470
6492
  const opts = {};
6471
- for (const child of effectLst.elements ?? []) {
6493
+ const effectLst = findChild(spPr, "a:effectLst");
6494
+ if (effectLst) for (const child of effectLst.elements ?? []) {
6472
6495
  if (!child.name) continue;
6473
6496
  switch (child.name) {
6474
6497
  case "a:outerShdw": {
@@ -6523,6 +6546,10 @@ function parseEffectsFromElement(parent) {
6523
6546
  if (dist !== void 0) reflection.distance = dist;
6524
6547
  const dir = attrNum(child, "dir");
6525
6548
  if (dir !== void 0) reflection.direction = dir;
6549
+ const stA = attrNum(child, "stA");
6550
+ if (stA !== void 0) reflection.startAlpha = stA / 1e3;
6551
+ const endA = attrNum(child, "endA");
6552
+ if (endA !== void 0) reflection.endAlpha = endA / 1e3;
6526
6553
  opts.reflection = reflection;
6527
6554
  break;
6528
6555
  }
@@ -6533,6 +6560,63 @@ function parseEffectsFromElement(parent) {
6533
6560
  }
6534
6561
  }
6535
6562
  }
6563
+ const scene3d = findChild(spPr, "a:scene3d");
6564
+ if (scene3d) {
6565
+ const camera = findChild(scene3d, "a:camera");
6566
+ if (camera) {
6567
+ const rot = findChild(camera, "a:rot");
6568
+ if (rot) {
6569
+ const rotation3d = {};
6570
+ const lat = attrNum(rot, "lat");
6571
+ const lon = attrNum(rot, "lon");
6572
+ const rev = attrNum(rot, "rev");
6573
+ if (lat !== void 0) rotation3d.x = Math.round(lat / 6e4);
6574
+ if (lon !== void 0) rotation3d.y = Math.round(lon / 6e4);
6575
+ if (rev !== void 0) rotation3d.z = Math.round(rev / 6e4);
6576
+ const fov = attrNum(camera, "fov");
6577
+ if (fov !== void 0) rotation3d.perspective = fov;
6578
+ if (Object.keys(rotation3d).length > 0) opts.rotation3D = rotation3d;
6579
+ }
6580
+ }
6581
+ const lightRig = findChild(scene3d, "a:lightRig");
6582
+ if (lightRig) {
6583
+ const rig = attr(lightRig, "rig");
6584
+ if (rig) opts.lighting = rig;
6585
+ }
6586
+ }
6587
+ const sp3d = findChild(spPr, "a:sp3d");
6588
+ if (sp3d) {
6589
+ const bevelT = findChild(sp3d, "a:bevelT");
6590
+ if (bevelT) {
6591
+ const bevel = {};
6592
+ const w = attrNum(bevelT, "w");
6593
+ const h = attrNum(bevelT, "h");
6594
+ if (w !== void 0) bevel.width = Math.round(w / 12700);
6595
+ if (h !== void 0) bevel.height = Math.round(h / 12700);
6596
+ const prst = attr(bevelT, "prst");
6597
+ if (prst) bevel.preset = prst;
6598
+ if (Object.keys(bevel).length > 0) opts.bevelTop = bevel;
6599
+ }
6600
+ const bevelB = findChild(sp3d, "a:bevelB");
6601
+ if (bevelB) {
6602
+ const bevel = {};
6603
+ const w = attrNum(bevelB, "w");
6604
+ const h = attrNum(bevelB, "h");
6605
+ if (w !== void 0) bevel.width = Math.round(w / 12700);
6606
+ if (h !== void 0) bevel.height = Math.round(h / 12700);
6607
+ const prst = attr(bevelB, "prst");
6608
+ if (prst) bevel.preset = prst;
6609
+ if (Object.keys(bevel).length > 0) opts.bevelBottom = bevel;
6610
+ }
6611
+ const z = attrNum(sp3d, "z");
6612
+ if (z !== void 0) opts.depth = z;
6613
+ const contourW = attrNum(sp3d, "contourW");
6614
+ if (contourW !== void 0) opts.contourWidth = contourW;
6615
+ const extrusionH = attrNum(sp3d, "extrusionH");
6616
+ if (extrusionH !== void 0) opts.extrusionH = extrusionH;
6617
+ const prstMaterial = attr(sp3d, "prstMaterial");
6618
+ if (prstMaterial) opts.material = prstMaterial;
6619
+ }
6536
6620
  return Object.keys(opts).length > 0 ? opts : void 0;
6537
6621
  }
6538
6622
  /**
@@ -6541,7 +6625,7 @@ function parseEffectsFromElement(parent) {
6541
6625
  */
6542
6626
  function extractColorFromElement(el) {
6543
6627
  for (const child of el.elements ?? []) if (child.name === "a:srgbClr") {
6544
- const color = attr(child, "val");
6628
+ const color = colorAttr(child, "val");
6545
6629
  let alpha;
6546
6630
  for (const transform of child.elements ?? []) if (transform.name === "a:alpha") {
6547
6631
  const val = attrNum(transform, "val");
@@ -6629,23 +6713,24 @@ function parseMediaFrame(el, ctx, mediaKind) {
6629
6713
  if (spPr) parseTransformFromSpPr(spPr, opts);
6630
6714
  const nvPicPr = findChild(el, "p:nvPicPr");
6631
6715
  if (nvPicPr) {
6632
- const cNvPr = findChild(nvPicPr, "p:cNvPr");
6716
+ const cNvPr = findChild(nvPicPr, "a:cNvPr") ?? findChild(nvPicPr, "p:cNvPr");
6633
6717
  if (cNvPr) {
6634
6718
  const name = attr(cNvPr, "name");
6635
6719
  if (name) opts.name = name;
6636
6720
  }
6637
6721
  }
6638
- const blip = findDeep(el, "a:blip")[0];
6639
- if (blip) {
6640
- const rEmbed = attr(blip, "r:embed");
6641
- if (rEmbed) {
6642
- const mediaPath = ctx.slideRels.get(rEmbed);
6643
- if (mediaPath) {
6644
- const data = ctx.pptx.doc.getRaw(mediaPath);
6645
- if (data) {
6646
- opts.data = data;
6647
- opts.type = mediaTypeFromPath(mediaPath, mediaKind);
6648
- }
6722
+ const mediaFileEl = findDeep(el, "a:videoFile")[0] ?? findDeep(el, "a:audioFile")[0];
6723
+ const rLink = mediaFileEl ? attr(mediaFileEl, "r:link") : void 0;
6724
+ const p14media = !mediaFileEl ? findDeep(el, "p14:media")[0] : void 0;
6725
+ const rEmbed = p14media ? attr(p14media, "r:embed") : void 0;
6726
+ const mediaRef = rLink ?? rEmbed;
6727
+ if (mediaRef) {
6728
+ const mediaPath = ctx.slideRels.get(mediaRef);
6729
+ if (mediaPath) {
6730
+ const data = ctx.pptx.doc.getRaw(mediaPath);
6731
+ if (data) {
6732
+ opts.data = data;
6733
+ opts.type = mediaTypeFromPath(mediaPath, mediaKind);
6649
6734
  }
6650
6735
  }
6651
6736
  }
@@ -6739,7 +6824,7 @@ const COLOR_MAP = {
6739
6824
  };
6740
6825
  function extractColor(el) {
6741
6826
  const srgb = findChild(el, "a:srgbClr");
6742
- if (srgb) return attr(srgb, "val") ?? void 0;
6827
+ if (srgb) return colorAttr(srgb, "val") ?? void 0;
6743
6828
  const sysClr = findChild(el, "a:sysClr");
6744
6829
  if (sysClr) return attr(sysClr, "lastClr") ?? void 0;
6745
6830
  }
@@ -6921,7 +7006,8 @@ function parseSlideRelMap(doc, slidePath) {
6921
7006
  const id = attr(child, "Id") ?? "";
6922
7007
  const target = attr(child, "Target") ?? "";
6923
7008
  if (!id || !target) continue;
6924
- rels.set(id, resolveRelsPath(target));
7009
+ if (attr(child, "TargetMode") === "External") rels.set(id, target);
7010
+ else rels.set(id, resolveRelsPath(target));
6925
7011
  }
6926
7012
  return rels;
6927
7013
  }
@@ -7004,6 +7090,24 @@ function parsePresentation(data) {
7004
7090
  const bg = cSld ? findChild(cSld, "p:bg") : void 0;
7005
7091
  const masterBackground = bg ? parseBackground(bg) : void 0;
7006
7092
  const hasBackground = masterBackground && Object.keys(masterBackground).length > 0;
7093
+ const spTree = cSld ? findChild(cSld, "p:spTree") : void 0;
7094
+ const masterChildren = [];
7095
+ if (spTree) {
7096
+ const emptyCtx = {
7097
+ pptx,
7098
+ slideRels: /* @__PURE__ */ new Map()
7099
+ };
7100
+ for (const child of spTree.elements ?? []) {
7101
+ if (child.name === "p:nvGrpSpPr" || child.name === "p:grpSpPr") continue;
7102
+ if (child.name === "p:sp") {
7103
+ const nvSpPr = findChild(child, "p:nvSpPr");
7104
+ const nvPr = nvSpPr ? findChild(nvSpPr, "p:nvPr") : void 0;
7105
+ if (nvPr && findChild(nvPr, "p:ph")) continue;
7106
+ }
7107
+ const parsed = parseSlideChild(child, emptyCtx);
7108
+ if (parsed !== void 0) masterChildren.push(parsed);
7109
+ }
7110
+ }
7007
7111
  const masterLayouts = [];
7008
7112
  for (const layoutPath of pptx.slideLayouts) {
7009
7113
  if (layoutMasterPaths.get(layoutPath) !== masterPath) continue;
@@ -7015,6 +7119,7 @@ function parsePresentation(data) {
7015
7119
  masterDef.name = masterName;
7016
7120
  if (themeOptions) masterDef.theme = themeOptions;
7017
7121
  if (hasBackground) masterDef.background = masterBackground;
7122
+ if (masterChildren.length > 0) masterDef.children = masterChildren;
7018
7123
  if (masterLayouts.length > 0) masterDef.layouts = masterLayouts;
7019
7124
  masterDefs.push(masterDef);
7020
7125
  }
@@ -7064,8 +7169,9 @@ function parsePresentation(data) {
7064
7169
  const pos = findChild(cm, "p:pos");
7065
7170
  const x = pos ? attrNum(pos, "x") : void 0;
7066
7171
  const y = pos ? attrNum(pos, "y") : void 0;
7172
+ const textEl = findChild(cm, "p:text");
7067
7173
  const txBody = findChild(cm, "p:txBody");
7068
- const text = txBody ? extractCommentText(txBody) : "";
7174
+ const text = textEl ? textOf(textEl) ?? "" : txBody ? extractCommentText(txBody) : "";
7069
7175
  const commentEntry = {};
7070
7176
  if (authorId !== void 0) commentEntry.authorId = authorId;
7071
7177
  if (author) commentEntry.author = author.name;
@@ -7101,6 +7207,78 @@ function extractCommentText(txBody) {
7101
7207
  }
7102
7208
  return parts.join("");
7103
7209
  }
7210
+ //#endregion
7211
+ //#region src/patcher/from-pptx.ts
7212
+ const PatchType = { PARAGRAPH: "paragraph" };
7213
+ const formatter = new Formatter();
7214
+ const pptxReplacer = createReplacer({
7215
+ ns: PPTX_NS,
7216
+ formatChild: (child, context) => {
7217
+ return [toJson(xml(formatter.format(child, context))).elements[0]];
7218
+ },
7219
+ preserveSpace: false
7220
+ });
7221
+ const IMAGE_CONTENT_TYPES = [
7222
+ ["image/png", "png"],
7223
+ ["image/jpeg", "jpeg"],
7224
+ ["image/jpeg", "jpg"],
7225
+ ["image/bmp", "bmp"],
7226
+ ["image/gif", "gif"],
7227
+ ["image/svg+xml", "svg"],
7228
+ ["image/tiff", "tif"],
7229
+ ["image/tiff", "tiff"],
7230
+ ["image/x-emf", "emf"],
7231
+ ["image/x-wmf", "wmf"]
7232
+ ];
7233
+ const SLIDE_RE = /^ppt\/slides\/slide(\d+)\.xml$/;
7234
+ /**
7235
+ * Patches an existing .pptx presentation by replacing placeholders with new content.
7236
+ *
7237
+ * @publicApi
7238
+ */
7239
+ const patchPresentation = async ({ outputType, data, patches, keepOriginalStyles = true, placeholderDelimiters = {
7240
+ end: "}}",
7241
+ start: "{{"
7242
+ } }) => {
7243
+ const zipContent = unzipSync(toUint8Array(data));
7244
+ const xmlMap = /* @__PURE__ */ new Map();
7245
+ const binaryMap = /* @__PURE__ */ new Map();
7246
+ let hasMedia = false;
7247
+ for (const [key, value] of Object.entries(zipContent)) if (key.endsWith(".xml") || key.endsWith(".rels")) xmlMap.set(key, toJson(strFromU8(value)));
7248
+ else binaryMap.set(key, value);
7249
+ const slidePaths = Object.keys(zipContent).filter((k) => SLIDE_RE.test(k)).sort((a, b) => {
7250
+ return parseInt(a.match(SLIDE_RE)[1], 10) - parseInt(b.match(SLIDE_RE)[1], 10);
7251
+ });
7252
+ const { start, end } = placeholderDelimiters;
7253
+ if (!start.trim() || !end.trim()) throw new Error("Both start and end delimiters must be non-empty strings.");
7254
+ const context = { stack: [] };
7255
+ for (const slidePath of slidePaths) {
7256
+ const json = xmlMap.get(slidePath);
7257
+ if (!json) continue;
7258
+ for (const [patchKey, patchValue] of Object.entries(patches)) pptxReplacer({
7259
+ context,
7260
+ json,
7261
+ keepOriginalStyles,
7262
+ patch: patchValue,
7263
+ patchText: `${start}${patchKey}${end}`
7264
+ });
7265
+ }
7266
+ for (const [key, patch] of Object.entries(patches)) if ("data" in patch && patch.data instanceof Uint8Array) {
7267
+ const mediaPath = `ppt/media/${key}`;
7268
+ if (binaryMap.has(mediaPath)) {
7269
+ binaryMap.set(mediaPath, patch.data);
7270
+ hasMedia = true;
7271
+ }
7272
+ }
7273
+ if (hasMedia) {
7274
+ const contentTypes = xmlMap.get("[Content_Types].xml");
7275
+ if (contentTypes) for (const [contentType, extension] of IMAGE_CONTENT_TYPES) appendContentType(contentTypes, contentType, extension);
7276
+ }
7277
+ const files = {};
7278
+ for (const [key, value] of xmlMap) files[key] = textToUint8Array(js2xml(value));
7279
+ for (const [key, value] of binaryMap) files[key] = value;
7280
+ return await zipAndConvert(files, outputType, OoxmlMimeType.PPTX);
7281
+ };
7104
7282
  __reExport(/* @__PURE__ */ __exportAll({
7105
7283
  AppProperties: () => AppProperties,
7106
7284
  AudioFrame: () => AudioFrame,
@@ -7137,6 +7315,7 @@ __reExport(/* @__PURE__ */ __exportAll({
7137
7315
  Packer: () => Packer,
7138
7316
  Paragraph: () => Paragraph,
7139
7317
  ParagraphProperties: () => ParagraphProperties,
7318
+ PatchType: () => PatchType,
7140
7319
  PathShadeType: () => PathShadeType,
7141
7320
  PenAlignment: () => PenAlignment,
7142
7321
  Picture: () => Picture,
@@ -7201,12 +7380,13 @@ __reExport(/* @__PURE__ */ __exportAll({
7201
7380
  parseArchive: () => parseArchive,
7202
7381
  parsePptx: () => parsePptx,
7203
7382
  parsePresentation: () => parsePresentation,
7383
+ patchPresentation: () => patchPresentation,
7204
7384
  percentToTHousandths: () => percentToTHousandths,
7205
7385
  uniqueId: () => uniqueId,
7206
7386
  uniqueNumericIdCreator: () => uniqueNumericIdCreator,
7207
7387
  uniqueUuid: () => uniqueUuid
7208
7388
  }), util_exports);
7209
7389
  //#endregion
7210
- export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, ChartCollection, ChartFrame, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, EndParagraphRunProperties, Field, File, File as Presentation, GroupShape, GroupShapeProperties, GroupTransform2D, HeaderFooter, LineCap, LineJoin, LineShape, Media, NonVisualDrawingProperties, NonVisualPictureProperties, NonVisualShapeProperties, NotesSlide, Packer, Paragraph, ParagraphProperties, PathShadeType, PenAlignment, Picture, PresentationWrapper, PresetDash, PresetGeometry, PresetMaterialType, PrettifyType, ReflectionAlignment, Relationships, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideLayout, SlideNumberField, SlideSizePreset, SmartArtFrame, StrikeStyle, Table, TableCell, TableCellProperties, TableFrame, TableProperties, TableRow, Text, TextAlignment, TextBody, TextCapitalization, TextRun, TileFlipMode, Transform2D, Transition, UnderlineStyle, VerticalAlignment, VideoFrame, buildFill, coerceChild, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPointsToEmu, createBevel, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createGradientFill, createGradientStop, createOutline, createOutlineCompat, createPptxEffectList, createScene3D, createShape3D, createTransformation, extractBlipFillMedia, hashedId, parseArchive, parsePptx, parsePresentation, percentToTHousandths, uniqueId, uniqueNumericIdCreator, uniqueUuid };
7390
+ export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, ChartCollection, ChartFrame, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, EndParagraphRunProperties, Field, File, File as Presentation, GroupShape, GroupShapeProperties, GroupTransform2D, HeaderFooter, LineCap, LineJoin, LineShape, Media, NonVisualDrawingProperties, NonVisualPictureProperties, NonVisualShapeProperties, NotesSlide, Packer, Paragraph, ParagraphProperties, PatchType, PathShadeType, PenAlignment, Picture, PresentationWrapper, PresetDash, PresetGeometry, PresetMaterialType, PrettifyType, ReflectionAlignment, Relationships, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideLayout, SlideNumberField, SlideSizePreset, SmartArtFrame, StrikeStyle, Table, TableCell, TableCellProperties, TableFrame, TableProperties, TableRow, Text, TextAlignment, TextBody, TextCapitalization, TextRun, TileFlipMode, Transform2D, Transition, UnderlineStyle, VerticalAlignment, VideoFrame, buildFill, coerceChild, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPointsToEmu, createBevel, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createGradientFill, createGradientStop, createOutline, createOutlineCompat, createPptxEffectList, createScene3D, createShape3D, createTransformation, extractBlipFillMedia, hashedId, parseArchive, parsePptx, parsePresentation, patchPresentation, percentToTHousandths, uniqueId, uniqueNumericIdCreator, uniqueUuid };
7211
7391
 
7212
7392
  //# sourceMappingURL=index.mjs.map