@office-open/pptx 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
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, 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";
1
+ import { i as __toCommonJS, n as __exportAll, r as __reExport, t as __esmMin } from "./chunk-DJOrGtkp.js";
2
+ import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, Formatter as Formatter$1, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PPTX_NS, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, buildCorePropertiesXml, collectPlaceholderKeys, compileMapping, 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, xsdLineEndSize, 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
+ import { attr, attrBool, attrNum, children, colorAttr, escapeXml, findChild, findDeep, js2xml, textOf, xml, xml2js } from "@office-open/xml";
5
6
  import { DEFAULT_DRAWING_XML, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml } from "@office-open/core/smartart";
6
- import { attr, attrBool, attrNum, children, colorAttr, findChild, findDeep, js2xml, textOf, xml } from "@office-open/xml";
7
- import { textToUint8Array, toUint8Array } from "undio";
7
+ import { 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. */
@@ -116,7 +116,7 @@ function createPptxEffectList(options) {
116
116
  return effectListOpts ? createEffectList$1(effectListOpts) : null;
117
117
  }
118
118
  var ReflectionAlignment;
119
- var init_effects = __esmMin((() => {
119
+ var init_effects = __esmMin(() => {
120
120
  ReflectionAlignment = {
121
121
  TOP_LEFT: "topLeft",
122
122
  TOP: "top",
@@ -128,23 +128,23 @@ var init_effects = __esmMin((() => {
128
128
  BOTTOM: "bottom",
129
129
  BOTTOM_RIGHT: "bottomRight"
130
130
  };
131
- }));
131
+ });
132
132
  //#endregion
133
133
  //#region src/file/drawingml/fill.ts
134
- var init_fill = __esmMin((() => {}));
134
+ var init_fill = __esmMin(() => {});
135
135
  //#endregion
136
136
  //#region src/file/xml-components/base.ts
137
- var init_base = __esmMin((() => {}));
137
+ var init_base = __esmMin(() => {});
138
138
  //#endregion
139
139
  //#region src/file/xml-components/index.ts
140
- var init_xml_components = __esmMin((() => {
140
+ var init_xml_components = __esmMin(() => {
141
141
  init_base();
142
- }));
142
+ });
143
143
  //#endregion
144
144
  //#region src/file/background/background.ts
145
145
  var background_exports = /* @__PURE__ */ __exportAll({ Background: () => Background });
146
146
  var Background, BackgroundProperties;
147
- var init_background = __esmMin((() => {
147
+ var init_background = __esmMin(() => {
148
148
  init_effects();
149
149
  init_fill();
150
150
  init_xml_components();
@@ -179,7 +179,7 @@ var init_background = __esmMin((() => {
179
179
  return obj;
180
180
  }
181
181
  };
182
- }));
182
+ });
183
183
  //#endregion
184
184
  //#region src/file/chart/chart-collection.ts
185
185
  init_background();
@@ -547,6 +547,9 @@ var GroupTransform2D = class extends XmlComponent {
547
547
  prepForXml(context) {
548
548
  return this.core["prepForXml"]?.(context);
549
549
  }
550
+ toXml(context) {
551
+ return this.core.toXml(context);
552
+ }
550
553
  };
551
554
  //#endregion
552
555
  //#region src/file/drawingml/group-shape-properties.ts
@@ -612,6 +615,9 @@ var EndParagraphRunProperties = class extends BuilderElement {
612
615
  prepForXml(_context) {
613
616
  return buildEndParagraphRunProperties(this.lang);
614
617
  }
618
+ toXml(_context) {
619
+ return `<a:endParaRPr lang="${this.lang}"/>`;
620
+ }
615
621
  };
616
622
  //#endregion
617
623
  //#region src/file/shape/paragraph/paragraph-properties.ts
@@ -679,6 +685,10 @@ var ParagraphProperties = class extends XmlComponent {
679
685
  prepForXml(_context) {
680
686
  return buildParagraphProperties(this.options);
681
687
  }
688
+ toXml(_context) {
689
+ const obj = buildParagraphProperties(this.options);
690
+ return obj ? xml(obj) : "";
691
+ }
682
692
  };
683
693
  //#endregion
684
694
  //#region src/file/shape/paragraph/run-properties.ts
@@ -776,6 +786,34 @@ var RunProperties = class extends XmlComponent {
776
786
  } }).prepForXml(context) ?? void 0;
777
787
  return buildRunProperties(opts, hyperlinkKey, fillObj, effectListObj, outlineObj);
778
788
  }
789
+ toXml(context) {
790
+ const opts = this.options;
791
+ let hyperlinkKey;
792
+ if (opts.hyperlink) {
793
+ hyperlinkKey = `hlink_${nextHyperlinkId++}`;
794
+ context.fileData?.hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
795
+ }
796
+ let fillObj;
797
+ if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
798
+ let outlineObj;
799
+ if (opts.outline) outlineObj = createOutline$1({
800
+ width: 12700,
801
+ type: "solidFill",
802
+ color: { value: "000000" }
803
+ }).prepForXml(context) ?? void 0;
804
+ let effectListObj;
805
+ if (opts.shadow) effectListObj = createEffectList$1({ outerShadow: {
806
+ blurRadius: 50800,
807
+ distance: 38100,
808
+ direction: 27e5,
809
+ color: {
810
+ value: "000000",
811
+ transforms: { alpha: 4e4 }
812
+ }
813
+ } }).prepForXml(context) ?? void 0;
814
+ const obj = buildRunProperties(opts, hyperlinkKey, fillObj, effectListObj, outlineObj);
815
+ return obj ? xml(obj) : "";
816
+ }
779
817
  };
780
818
  //#endregion
781
819
  //#region src/file/shape/paragraph/run.ts
@@ -799,6 +837,27 @@ var TextRun = class extends XmlComponent {
799
837
  if (this.options.text) children.push({ "a:t": [this.options.text] });
800
838
  return { "a:r": children.length === 0 ? {} : children.length === 1 && "_attr" in children[0] ? children[0] : children };
801
839
  }
840
+ /**
841
+ * Fast path: simple properties (no hyperlink/fill/shadow/outline) skip
842
+ * RunProperties side effects and serialize directly.
843
+ * Complex path uses RunProperties.toXml() + direct text serialization.
844
+ */
845
+ toXml(context) {
846
+ const opts = this.options;
847
+ const hasRPr = RunProperties.hasProperties(opts);
848
+ if (!hasRPr || !opts.hyperlink && !opts.fill && !opts.shadow && !opts.outline) {
849
+ let body = "";
850
+ if (hasRPr) {
851
+ const rPrObj = buildRunProperties(opts);
852
+ if (rPrObj) body += xml(rPrObj);
853
+ }
854
+ if (opts.text) body += `<a:t>${escapeXml(opts.text)}</a:t>`;
855
+ return body.length === 0 ? "<a:r/>" : `<a:r>${body}</a:r>`;
856
+ }
857
+ let body = new RunProperties(opts).toXml(context);
858
+ if (opts.text) body += `<a:t>${escapeXml(opts.text)}</a:t>`;
859
+ return body ? `<a:r>${body}</a:r>` : "<a:r/>";
860
+ }
802
861
  };
803
862
  //#endregion
804
863
  //#region src/file/shape/paragraph/paragraph.ts
@@ -828,6 +887,19 @@ var Paragraph = class extends XmlComponent {
828
887
  children.push(buildEndParagraphRunProperties());
829
888
  return { "a:p": children };
830
889
  }
890
+ toXml(context) {
891
+ const parts = [];
892
+ const pPr = buildParagraphProperties(this.options.properties ?? {});
893
+ if (pPr) parts.push(xml(pPr));
894
+ if (this.options.text) parts.push(new TextRun(this.options.text).toXml(context));
895
+ if (this.options.children) for (const rawChild of this.options.children) {
896
+ const child = rawChild instanceof TextRun || rawChild instanceof XmlComponent ? rawChild : new TextRun(rawChild);
897
+ parts.push(child.toXml(context));
898
+ }
899
+ parts.push("<a:endParaRPr lang=\"en-US\"/>");
900
+ const body = parts.join("");
901
+ return body ? `<a:p>${body}</a:p>` : "<a:p/>";
902
+ }
831
903
  };
832
904
  //#endregion
833
905
  //#region src/file/table/table-cell-properties.ts
@@ -867,6 +939,10 @@ var TableCellProperties = class extends BaseXmlComponent {
867
939
  }
868
940
  return { "a:tcPr": children.length === 0 ? {} : children.length === 1 && "_attr" in children[0] ? children[0] : children };
869
941
  }
942
+ toXml(context) {
943
+ const obj = this.prepForXml(context);
944
+ return obj ? xml(obj) : "<a:tcPr/>";
945
+ }
870
946
  };
871
947
  //#endregion
872
948
  //#region src/file/table/table-cell.ts
@@ -921,6 +997,34 @@ var TableCell = class extends BaseXmlComponent {
921
997
  if (tcPrObj) children.push(tcPrObj);
922
998
  return { "a:tc": children };
923
999
  }
1000
+ toXml(context) {
1001
+ const opts = this.options;
1002
+ const parts = [];
1003
+ const tcAttrs = [];
1004
+ if (opts.columnSpan !== void 0 && opts.columnSpan > 1) tcAttrs.push(`gridSpan="${opts.columnSpan}"`);
1005
+ if (opts.rowSpan !== void 0 && opts.rowSpan > 1) tcAttrs.push(`rowSpan="${opts.rowSpan}"`);
1006
+ const tcAttrStr = tcAttrs.length > 0 ? ` ${tcAttrs.join(" ")}` : "";
1007
+ const txParts = [];
1008
+ const margins = opts.margins;
1009
+ const bodyPrAttrs = [];
1010
+ if (margins?.top !== void 0) bodyPrAttrs.push(`tIns="${margins.top}"`);
1011
+ if (margins?.bottom !== void 0) bodyPrAttrs.push(`bIns="${margins.bottom}"`);
1012
+ if (margins?.left !== void 0) bodyPrAttrs.push(`lIns="${margins.left}"`);
1013
+ if (margins?.right !== void 0) bodyPrAttrs.push(`rIns="${margins.right}"`);
1014
+ const bodyPrStr = bodyPrAttrs.length > 0 ? ` ${bodyPrAttrs.join(" ")}` : "";
1015
+ txParts.push(`<a:bodyPr${bodyPrStr}/>`);
1016
+ txParts.push("<a:lstStyle/>");
1017
+ if (this.paragraphs) for (const p of this.paragraphs) txParts.push(p.toXml(context));
1018
+ else txParts.push("<a:p/>");
1019
+ parts.push(`<a:txBody>${txParts.join("")}</a:txBody>`);
1020
+ const tcPr = new TableCellProperties({
1021
+ fill: opts.fill,
1022
+ borders: opts.borders,
1023
+ verticalAlign: opts.verticalAlign ? xsdTextAnchor.to(opts.verticalAlign) : void 0
1024
+ });
1025
+ parts.push(tcPr.toXml(context));
1026
+ return `<a:tc${tcAttrStr}>${parts.join("")}</a:tc>`;
1027
+ }
924
1028
  };
925
1029
  //#endregion
926
1030
  //#region src/file/shape/text-body.ts
@@ -975,6 +1079,18 @@ var TextBody = class extends XmlComponent {
975
1079
  }
976
1080
  return { "p:txBody": children };
977
1081
  }
1082
+ toXml(context) {
1083
+ const parts = [];
1084
+ parts.push(xml(buildBodyPr(this.options)));
1085
+ parts.push("<a:lstStyle/>");
1086
+ if (this.options.children) for (const p of this.options.children) {
1087
+ const para = typeof p === "string" ? new Paragraph({ children: [new TextRun({ text: p })] }) : p instanceof Paragraph ? p : new Paragraph(p);
1088
+ parts.push(para.toXml(context));
1089
+ }
1090
+ else if (this.options.text !== void 0) parts.push(new Paragraph({ children: [new TextRun({ text: this.options.text })] }).toXml(context));
1091
+ else parts.push(new Paragraph().toXml(context));
1092
+ return `<p:txBody>${parts.join("")}</p:txBody>`;
1093
+ }
978
1094
  };
979
1095
  //#endregion
980
1096
  //#region src/file/notes/notes-slide.ts
@@ -1178,13 +1294,16 @@ var PresentationProperties = class PresentationProperties extends ImportedXmlCom
1178
1294
  key;
1179
1295
  constructor(showOptions) {
1180
1296
  super("p:presentationPr");
1181
- this.key = showOptions ? JSON.stringify(showOptions) : "";
1297
+ this.key = showOptions ? presPropsKey(showOptions) : "";
1182
1298
  if (!PresentationProperties.cache.has(this.key)) PresentationProperties.cache.set(this.key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
1183
1299
  }
1184
1300
  prepForXml() {
1185
1301
  return PresentationProperties.cache.get(this.key).prepForXml({ stack: [] });
1186
1302
  }
1187
1303
  };
1304
+ function presPropsKey(o) {
1305
+ return `l${o.loop ? 1 : 0}k${o.kiosk ? 1 : 0}n${o.showNarration ? 1 : 0}t${o.useTimings ? 1 : 0}`;
1306
+ }
1188
1307
  //#endregion
1189
1308
  //#region src/file/presentation/presentation.ts
1190
1309
  init_xml_components();
@@ -1309,6 +1428,9 @@ var Transform2D = class extends XmlComponent {
1309
1428
  prepForXml(context) {
1310
1429
  return this.core["prepForXml"]?.(context);
1311
1430
  }
1431
+ toXml(context) {
1432
+ return this.core.toXml(context);
1433
+ }
1312
1434
  };
1313
1435
  //#endregion
1314
1436
  //#region src/util/position.ts
@@ -1319,8 +1441,8 @@ var Transform2D = class extends XmlComponent {
1319
1441
  /**
1320
1442
  * Converts pixel position/size values to EMU, defaulting missing values to 0.
1321
1443
  *
1322
- * Used by components that always need a transform (ChartFrame, Picture,
1323
- * TableFrame, SmartArtFrame, MediaFrameBase, etc.).
1444
+ * Used by components that always need a transform (Chart, Picture,
1445
+ * Table, SmartArt, MediaFrameBase, etc.).
1324
1446
  */
1325
1447
  function emuPosition(opts) {
1326
1448
  return {
@@ -1346,33 +1468,41 @@ function emuPositionOptional(opts) {
1346
1468
  //#endregion
1347
1469
  //#region src/file/chart/chart-frame.ts
1348
1470
  init_xml_components();
1349
- let nextChartFrameId = 2048;
1471
+ let nextChartId = 2048;
1350
1472
  /**
1351
1473
  * p:graphicFrame — Slide-level graphic frame wrapping a chart.
1352
1474
  *
1353
1475
  * The chart is stored as a separate part (ppt/charts/chart{n}.xml)
1354
1476
  * and referenced via a relationship ID placeholder {chart:key}.
1355
1477
  */
1356
- var ChartFrame = class extends XmlComponent {
1478
+ var Chart = class extends XmlComponent {
1357
1479
  chartOptions;
1358
1480
  chartKey;
1359
1481
  constructor(options) {
1360
1482
  super("p:graphicFrame");
1361
1483
  this.chartOptions = options;
1362
- this.chartKey = `chart_${nextChartFrameId++}`;
1363
- const id = nextChartFrameId++;
1484
+ this.chartKey = `chart_${nextChartId++}`;
1485
+ const id = nextChartId++;
1364
1486
  this.root.push(new GraphicFrameNonVisual$2(id));
1365
1487
  this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
1366
1488
  this.root.push(new ChartGraphic(this.chartKey));
1367
1489
  }
1368
- prepForXml(context) {
1490
+ /** Register chart data with the File's Chart collection. */
1491
+ registerChart(context) {
1369
1492
  const file = context.fileData;
1370
1493
  if (file?.charts) file.charts.addChart(this.chartKey, {
1371
1494
  chartSpace: new ChartSpace(this.chartOptions),
1372
1495
  key: this.chartKey
1373
1496
  });
1497
+ }
1498
+ prepForXml(context) {
1499
+ this.registerChart(context);
1374
1500
  return super.prepForXml(context);
1375
1501
  }
1502
+ toXml(context) {
1503
+ this.registerChart(context);
1504
+ return super.toXml(context);
1505
+ }
1376
1506
  };
1377
1507
  var GraphicFrameNonVisual$2 = class extends XmlComponent {
1378
1508
  constructor(id) {
@@ -1572,12 +1702,20 @@ var MediaFrameBase = class extends XmlComponent {
1572
1702
  children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
1573
1703
  }));
1574
1704
  }
1575
- prepForXml(context) {
1705
+ /** Register media data with the File's Media collection. */
1706
+ registerMedia(context) {
1576
1707
  const file = context.fileData;
1577
1708
  if (this.posterData) file?.media.addImage(this.posterData.fileName, this.posterData);
1578
1709
  file?.media.addMedia(this.mediaData.fileName, this.mediaData);
1710
+ }
1711
+ prepForXml(context) {
1712
+ this.registerMedia(context);
1579
1713
  return super.prepForXml(context);
1580
1714
  }
1715
+ toXml(context) {
1716
+ this.registerMedia(context);
1717
+ return super.toXml(context);
1718
+ }
1581
1719
  };
1582
1720
  //#endregion
1583
1721
  //#region src/file/media/audio-frame.ts
@@ -1768,7 +1906,7 @@ init_xml_components();
1768
1906
  /**
1769
1907
  * p:pic — A picture on a slide.
1770
1908
  *
1771
- * Registers image with Media collection via prepForXml.
1909
+ * Registers image with Media collection via prepForXml/toXml.
1772
1910
  * The ImageReplacer replaces `{fileName}` placeholder with actual rId.
1773
1911
  */
1774
1912
  var Picture = class Picture extends XmlComponent {
@@ -1801,10 +1939,18 @@ var Picture = class Picture extends XmlComponent {
1801
1939
  children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
1802
1940
  }));
1803
1941
  }
1804
- prepForXml(context) {
1942
+ /** Register image with the File's Media collection. */
1943
+ registerMedia(context) {
1805
1944
  context.fileData?.media.addImage(this.imageData.fileName, this.imageData);
1945
+ }
1946
+ prepForXml(context) {
1947
+ this.registerMedia(context);
1806
1948
  return super.prepForXml(context);
1807
1949
  }
1950
+ toXml(context) {
1951
+ this.registerMedia(context);
1952
+ return super.toXml(context);
1953
+ }
1808
1954
  };
1809
1955
  //#endregion
1810
1956
  //#region src/file/shape/group-shape.ts
@@ -1863,6 +2009,22 @@ var GroupShape = class GroupShape extends BaseXmlComponent {
1863
2009
  }
1864
2010
  return { "p:grpSp": children };
1865
2011
  }
2012
+ toXml(context) {
2013
+ const opts = this.options;
2014
+ const id = this.id;
2015
+ const parts = [];
2016
+ parts.push(`<p:nvGrpSpPr><p:cNvPr id="${id}" name="Group ${id}"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>`);
2017
+ const xfrmAttrs = [];
2018
+ if (opts.flipHorizontal !== void 0) xfrmAttrs.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
2019
+ if (opts.rotation !== void 0) xfrmAttrs.push(`rot="${opts.rotation}"`);
2020
+ const xfrmAttrStr = xfrmAttrs.length > 0 ? ` ${xfrmAttrs.join(" ")}` : "";
2021
+ parts.push(`<p:grpSpPr><a:xfrm${xfrmAttrStr}><a:off x="${convertPixelsToEmu$1(opts.x ?? 0)}" y="${convertPixelsToEmu$1(opts.y ?? 0)}"/><a:ext cx="${convertPixelsToEmu$1(opts.width ?? 0)}" cy="${convertPixelsToEmu$1(opts.height ?? 0)}"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>`);
2022
+ for (const rawChild of opts.children) {
2023
+ const s = coerceChild(rawChild).toXml(context);
2024
+ if (s) parts.push(s);
2025
+ }
2026
+ return `<p:grpSp>${parts.join("")}</p:grpSp>`;
2027
+ }
1866
2028
  };
1867
2029
  //#endregion
1868
2030
  //#region src/file/drawingml/non-visual-shape-props.ts
@@ -1893,16 +2055,11 @@ const ARROWHEAD_MAP = {
1893
2055
  oval: "oval",
1894
2056
  open: "arrow"
1895
2057
  };
1896
- const ARROWHEAD_SIZE_MAP = {
1897
- sm: "small",
1898
- med: "medium",
1899
- lg: "large"
1900
- };
1901
2058
  function toCoreLineEnd(type, width, length) {
1902
2059
  return {
1903
2060
  type: ARROWHEAD_MAP[type] ?? "triangle",
1904
- ...width ? { width: ARROWHEAD_SIZE_MAP[width] } : {},
1905
- ...length ? { length: ARROWHEAD_SIZE_MAP[length] } : {}
2061
+ ...width ? { width } : {},
2062
+ ...length ? { length } : {}
1906
2063
  };
1907
2064
  }
1908
2065
  /**
@@ -2188,6 +2345,10 @@ var ShapeProperties = class extends BaseXmlComponent {
2188
2345
  }
2189
2346
  return { "p:spPr": children };
2190
2347
  }
2348
+ toXml(context) {
2349
+ const obj = this.prepForXml(context);
2350
+ return obj ? xml(obj) : "";
2351
+ }
2191
2352
  };
2192
2353
  //#endregion
2193
2354
  //#region src/file/shape/shape.ts
@@ -2250,15 +2411,41 @@ var Shape = class Shape extends XmlComponent {
2250
2411
  if (txBodyObj) children.push(txBodyObj);
2251
2412
  return { "p:sp": children };
2252
2413
  }
2414
+ toXml(context) {
2415
+ const opts = this.options;
2416
+ const id = this.shapeId;
2417
+ const name = opts.name ?? `Shape ${id}`;
2418
+ const parts = [];
2419
+ let nvPrContent = "<p:nvPr/>";
2420
+ if (opts.placeholder) {
2421
+ const phAttrs = [`type="${opts.placeholder}"`];
2422
+ if (opts.placeholderIndex !== void 0) phAttrs.push(`idx="${opts.placeholderIndex}"`);
2423
+ nvPrContent = `<p:nvPr><p:ph ${phAttrs.join(" ")}/></p:nvPr>`;
2424
+ }
2425
+ parts.push(`<p:nvSpPr><p:cNvPr id="${id}" name="${escapeXml(name)}"/><p:cNvSpPr/>${nvPrContent}</p:nvSpPr>`);
2426
+ const spPrXml = new ShapeProperties({
2427
+ ...emuPositionOptional(opts),
2428
+ geometry: opts.geometry,
2429
+ fill: opts.fill,
2430
+ outline: opts.outline,
2431
+ effects: opts.effects,
2432
+ flipHorizontal: opts.flipHorizontal,
2433
+ rotation: opts.rotation
2434
+ }).toXml(context);
2435
+ if (spPrXml) parts.push(spPrXml);
2436
+ const txBody = new TextBody(opts.textBody ?? {});
2437
+ parts.push(txBody.toXml(context));
2438
+ return `<p:sp>${parts.join("")}</p:sp>`;
2439
+ }
2253
2440
  };
2254
2441
  //#endregion
2255
2442
  //#region src/file/smartart/smartart-frame.ts
2256
2443
  init_xml_components();
2257
- let nextSmartArtFrameId = 1024;
2444
+ let nextSmartArtId = 1024;
2258
2445
  /**
2259
2446
  * p:graphicFrame — Slide-level graphic frame wrapping a SmartArt diagram.
2260
2447
  */
2261
- var SmartArtFrame = class extends XmlComponent {
2448
+ var SmartArt = class extends XmlComponent {
2262
2449
  smartArtKey;
2263
2450
  dataModel;
2264
2451
  layoutId;
@@ -2266,18 +2453,19 @@ var SmartArtFrame = class extends XmlComponent {
2266
2453
  colorId;
2267
2454
  constructor(options) {
2268
2455
  super("p:graphicFrame");
2269
- this.smartArtKey = `smartart_${nextSmartArtFrameId++}`;
2456
+ this.smartArtKey = `smartart_${nextSmartArtId++}`;
2270
2457
  this.layoutId = options.layout ?? "default";
2271
2458
  this.styleId = options.style ?? "simple1";
2272
2459
  this.colorId = options.color ?? "accent1_2";
2273
2460
  this.dataModel = createDataModel(options.nodes, this.layoutId, this.styleId, this.colorId);
2274
- const id = nextSmartArtFrameId++;
2461
+ const id = nextSmartArtId++;
2275
2462
  const name = options.name ?? `Diagram ${id}`;
2276
2463
  this.root.push(new GraphicFrameNonVisual$1(id, name));
2277
2464
  this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
2278
2465
  this.root.push(new SmartArtGraphic(this.smartArtKey));
2279
2466
  }
2280
- prepForXml(context) {
2467
+ /** Register SmartArt data with the File's SmartArt collection. */
2468
+ registerSmartArt(context) {
2281
2469
  const file = context.fileData;
2282
2470
  if (file?.smartArts) file.smartArts.addSmartArt(this.smartArtKey, {
2283
2471
  key: this.smartArtKey,
@@ -2286,8 +2474,15 @@ var SmartArtFrame = class extends XmlComponent {
2286
2474
  style: this.styleId,
2287
2475
  color: this.colorId
2288
2476
  });
2477
+ }
2478
+ prepForXml(context) {
2479
+ this.registerSmartArt(context);
2289
2480
  return super.prepForXml(context);
2290
2481
  }
2482
+ toXml(context) {
2483
+ this.registerSmartArt(context);
2484
+ return super.toXml(context);
2485
+ }
2291
2486
  };
2292
2487
  var GraphicFrameNonVisual$1 = class extends XmlComponent {
2293
2488
  constructor(id, name) {
@@ -2384,6 +2579,9 @@ var Graphic = class extends BaseXmlComponent {
2384
2579
  if (tableObj) graphicDataChildren.push(tableObj);
2385
2580
  return { "a:graphic": [{ "a:graphicData": graphicDataChildren }] };
2386
2581
  }
2582
+ toXml(context) {
2583
+ return `<a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">${this.table.toXml(context)}</a:graphicData></a:graphic>`;
2584
+ }
2387
2585
  };
2388
2586
  //#endregion
2389
2587
  //#region src/file/table/graphic-frame-non-visual.ts
@@ -2438,6 +2636,9 @@ var TableGrid = class extends BaseXmlComponent {
2438
2636
  prepForXml(_context) {
2439
2637
  return { "a:tblGrid": this.columnWidths.map((w) => ({ "a:gridCol": { _attr: { w } } })) };
2440
2638
  }
2639
+ toXml(_context) {
2640
+ return `<a:tblGrid>${this.columnWidths.map((w) => `<a:gridCol w="${w}"/>`).join("")}</a:tblGrid>`;
2641
+ }
2441
2642
  };
2442
2643
  //#endregion
2443
2644
  //#region src/file/table/table-properties.ts
@@ -2464,6 +2665,18 @@ var TableProperties = class extends BaseXmlComponent {
2464
2665
  if (opts.bandCol !== void 0) attrs.bandCol = opts.bandCol ? 1 : 0;
2465
2666
  return { "a:tblPr": Object.keys(attrs).length > 0 ? { _attr: attrs } : {} };
2466
2667
  }
2668
+ toXml(_context) {
2669
+ if (!this.options) return "<a:tblPr/>";
2670
+ const opts = this.options;
2671
+ const attrs = [];
2672
+ if (opts.firstRow !== void 0) attrs.push(`firstRow="${opts.firstRow ? 1 : 0}"`);
2673
+ if (opts.lastRow !== void 0) attrs.push(`lastRow="${opts.lastRow ? 1 : 0}"`);
2674
+ if (opts.bandRow !== void 0) attrs.push(`bandRow="${opts.bandRow ? 1 : 0}"`);
2675
+ if (opts.firstCol !== void 0) attrs.push(`firstCol="${opts.firstCol ? 1 : 0}"`);
2676
+ if (opts.lastCol !== void 0) attrs.push(`lastCol="${opts.lastCol ? 1 : 0}"`);
2677
+ if (opts.bandCol !== void 0) attrs.push(`bandCol="${opts.bandCol ? 1 : 0}"`);
2678
+ return attrs.length === 0 ? "<a:tblPr/>" : `<a:tblPr ${attrs.join(" ")}/>`;
2679
+ }
2467
2680
  };
2468
2681
  //#endregion
2469
2682
  //#region src/file/table/table-row.ts
@@ -2487,6 +2700,12 @@ var TableRow = class extends BaseXmlComponent {
2487
2700
  }
2488
2701
  return { "a:tr": children };
2489
2702
  }
2703
+ toXml(context) {
2704
+ const h = this.options.height ?? 0;
2705
+ const parts = [];
2706
+ for (const cell of this.options.cells) parts.push(new TableCell(cell).toXml(context));
2707
+ return `<a:tr h="${h}">${parts.join("")}</a:tr>`;
2708
+ }
2490
2709
  };
2491
2710
  //#endregion
2492
2711
  //#region src/file/table/table.ts
@@ -2495,7 +2714,7 @@ init_xml_components();
2495
2714
  * a:tbl — DrawingML table element.
2496
2715
  * Lazy: stores options, builds IXmlableObject in prepForXml.
2497
2716
  */
2498
- var Table = class extends BaseXmlComponent {
2717
+ var DrawingTable = class extends BaseXmlComponent {
2499
2718
  options;
2500
2719
  constructor(options) {
2501
2720
  super("a:tbl");
@@ -2539,6 +2758,43 @@ var Table = class extends BaseXmlComponent {
2539
2758
  }
2540
2759
  return { "a:tbl": children };
2541
2760
  }
2761
+ toXml(context) {
2762
+ const opts = this.options;
2763
+ const parts = [];
2764
+ const tblPr = new TableProperties({
2765
+ firstRow: opts.firstRow,
2766
+ lastRow: opts.lastRow,
2767
+ bandRow: opts.bandRow,
2768
+ firstCol: opts.firstCol,
2769
+ lastCol: opts.lastCol,
2770
+ bandCol: opts.bandCol
2771
+ });
2772
+ parts.push(tblPr.toXml(context));
2773
+ const colWidths = opts.columnWidths && opts.columnWidths.length > 0 ? [...opts.columnWidths] : Array.from({ length: opts.rows[0]?.cells.length ?? 1 }, () => 0);
2774
+ parts.push(new TableGrid(colWidths).toXml(context));
2775
+ const tb = opts.borders;
2776
+ const rowCount = opts.rows.length;
2777
+ for (let ri = 0; ri < rowCount; ri++) {
2778
+ const row = opts.rows[ri];
2779
+ const colCount = row.cells.length;
2780
+ const cells = tb ? row.cells.map((cell, ci) => {
2781
+ const b = { ...cell.borders };
2782
+ if (ri === 0 && tb.top && !b.top) b.top = tb.top;
2783
+ if (ri === rowCount - 1 && tb.bottom && !b.bottom) b.bottom = tb.bottom;
2784
+ if (ci === 0 && tb.left && !b.left) b.left = tb.left;
2785
+ if (ci === colCount - 1 && tb.right && !b.right) b.right = tb.right;
2786
+ return Object.keys(b).length === 0 ? cell : {
2787
+ ...cell,
2788
+ borders: b
2789
+ };
2790
+ }) : row.cells;
2791
+ parts.push(new TableRow({
2792
+ ...row,
2793
+ cells
2794
+ }).toXml(context));
2795
+ }
2796
+ return `<a:tbl>${parts.join("")}</a:tbl>`;
2797
+ }
2542
2798
  };
2543
2799
  //#endregion
2544
2800
  //#region src/file/table/table-frame.ts
@@ -2548,12 +2804,12 @@ init_xml_components();
2548
2804
  *
2549
2805
  * x/y/width/height accept pixel values, converted to EMUs internally.
2550
2806
  */
2551
- var TableFrame = class extends XmlComponent {
2807
+ var Table = class extends XmlComponent {
2552
2808
  constructor(options) {
2553
2809
  super("p:graphicFrame");
2554
2810
  this.root.push(new GraphicFrameNonVisual());
2555
2811
  this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
2556
- const table = new Table(options);
2812
+ const table = new DrawingTable(options);
2557
2813
  this.root.push(new Graphic(table));
2558
2814
  }
2559
2815
  };
@@ -2564,14 +2820,14 @@ function coerceChild(child) {
2564
2820
  if (child instanceof BaseXmlComponent) return child;
2565
2821
  if ("shape" in child) return new Shape(child.shape);
2566
2822
  if ("picture" in child) return new Picture(child.picture);
2567
- if ("table" in child) return new TableFrame(child.table);
2568
- if ("chart" in child) return new ChartFrame(child.chart);
2823
+ if ("table" in child) return new Table(child.table);
2824
+ if ("chart" in child) return new Chart(child.chart);
2569
2825
  if ("line" in child) return new LineShape(child.line);
2570
2826
  if ("connector" in child) return new ConnectorShape(child.connector);
2571
2827
  if ("video" in child) return new VideoFrame(child.video);
2572
2828
  if ("audio" in child) return new AudioFrame(child.audio);
2573
2829
  if ("group" in child) return new GroupShape(child.group);
2574
- if ("smartart" in child) return new SmartArtFrame(child.smartart);
2830
+ if ("smartart" in child) return new SmartArt(child.smartart);
2575
2831
  throw new Error("Unknown slide child type");
2576
2832
  }
2577
2833
  function coerceMasterChild(child) {
@@ -4129,6 +4385,37 @@ var Slide = class extends XmlComponent {
4129
4385
  }
4130
4386
  return { "p:sld": children };
4131
4387
  }
4388
+ toXml(context) {
4389
+ const parts = [];
4390
+ parts.push("<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\">");
4391
+ parts.push("<p:cSld>");
4392
+ if (this.background) {
4393
+ const bgObj = this.background.prepForXml(context);
4394
+ if (bgObj) parts.push(xml(bgObj));
4395
+ }
4396
+ parts.push("<p:spTree>");
4397
+ parts.push("<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>");
4398
+ parts.push("<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>");
4399
+ const coercedChildren = this.children.map(coerceChild);
4400
+ for (const child of coercedChildren) {
4401
+ const s = child.toXml(context);
4402
+ if (s) parts.push(s);
4403
+ }
4404
+ parts.push("</p:spTree>");
4405
+ parts.push("</p:cSld>");
4406
+ parts.push("<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>");
4407
+ if (this.transition) {
4408
+ const transObj = buildTransition(this.transition);
4409
+ if (transObj) parts.push(xml(transObj));
4410
+ }
4411
+ const animations = collectAnimations(coercedChildren);
4412
+ if (animations.length > 0) {
4413
+ const timingObj = new SlideTiming(animations).prepForXml(context);
4414
+ if (timingObj) parts.push(xml(timingObj));
4415
+ }
4416
+ parts.push("</p:sld>");
4417
+ return parts.join("");
4418
+ }
4132
4419
  };
4133
4420
  //#endregion
4134
4421
  //#region src/file/table-styles.ts
@@ -4231,13 +4518,21 @@ var DefaultTheme = class DefaultTheme extends ImportedXmlComponent {
4231
4518
  cacheKey;
4232
4519
  constructor(options) {
4233
4520
  super("a:theme");
4234
- this.cacheKey = options ? JSON.stringify(options) : "";
4521
+ this.cacheKey = options ? themeKey(options) : "";
4235
4522
  if (!DefaultTheme.cache.has(this.cacheKey)) DefaultTheme.cache.set(this.cacheKey, ImportedXmlComponent.fromXmlString(buildThemeXml(options)));
4236
4523
  }
4237
4524
  prepForXml() {
4238
4525
  return DefaultTheme.cache.get(this.cacheKey).prepForXml({ stack: [] });
4239
4526
  }
4527
+ toXml(context) {
4528
+ return DefaultTheme.cache.get(this.cacheKey).toXml(context);
4529
+ }
4240
4530
  };
4531
+ function themeKey(o) {
4532
+ const c = o.colors;
4533
+ const f = o.fonts;
4534
+ return `n${o.name ?? ""}c${c?.dark1 ?? ""}${c?.light1 ?? ""}${c?.dark2 ?? ""}${c?.light2 ?? ""}${c?.accent1 ?? ""}${c?.accent2 ?? ""}${c?.accent3 ?? ""}${c?.accent4 ?? ""}${c?.accent5 ?? ""}${c?.accent6 ?? ""}${c?.hyperlink ?? ""}${c?.followedHyperlink ?? ""}f${f?.majorFont ?? ""}${f?.minorFont ?? ""}${f?.majorFontAsian ?? ""}${f?.minorFontAsian ?? ""}`;
4535
+ }
4241
4536
  //#endregion
4242
4537
  //#region src/file/view-properties.ts
4243
4538
  init_xml_components();
@@ -4855,29 +5150,27 @@ function collectRefs(xml, prefix, mediaArray) {
4855
5150
  }
4856
5151
  //#endregion
4857
5152
  //#region src/export/packer/next-compiler.ts
5153
+ /** Reusable TextEncoder (stateless, safe to share). */
5154
+ const encoder$1 = new TextEncoder();
4858
5155
  var Compiler = class {
4859
5156
  formatter = new Formatter$1();
4860
- compile(file, prettifyXml, overrides = []) {
5157
+ compile(file, overrides = []) {
4861
5158
  const declaration = true;
4862
- const indent = prettifyXml;
4863
5159
  const context = {
4864
5160
  fileData: file,
4865
5161
  stack: []
4866
5162
  };
4867
5163
  const mapping = {
4868
5164
  AppProperties: {
4869
- data: xml(this.formatter.format(file.appProperties, context), { declaration }),
5165
+ data: this.formatter.formatToXml(file.appProperties, context, declaration),
4870
5166
  path: "docProps/app.xml"
4871
5167
  },
4872
5168
  Properties: {
4873
- data: xml(this.formatter.format(file.coreProperties, context), {
4874
- declaration,
4875
- indent
4876
- }),
5169
+ data: this.formatter.formatToXml(file.coreProperties, context, declaration),
4877
5170
  path: "docProps/core.xml"
4878
5171
  },
4879
5172
  FileRelationships: {
4880
- data: xml(this.formatter.format(file.fileRelationships, context), { declaration: false }),
5173
+ data: this.formatter.formatToXml(file.fileRelationships, context),
4881
5174
  path: "_rels/.rels"
4882
5175
  }
4883
5176
  };
@@ -4906,7 +5199,7 @@ var Compiler = class {
4906
5199
  path: `ppt/slideMasters/slideMaster${mi + 1}.xml`
4907
5200
  };
4908
5201
  mapping[`SlideMasterRels${mi}`] = {
4909
- data: xml(this.formatter.format(masterRels[mi], context), { declaration: false }),
5202
+ data: this.formatter.formatToXml(masterRels[mi], context),
4910
5203
  path: `ppt/slideMasters/_rels/slideMaster${mi + 1}.xml.rels`
4911
5204
  };
4912
5205
  }
@@ -4918,7 +5211,7 @@ var Compiler = class {
4918
5211
  path: `ppt/slideLayouts/slideLayout${li + 1}.xml`
4919
5212
  };
4920
5213
  mapping[`SlideLayoutRels${li}`] = {
4921
- data: xml(this.formatter.format(layoutRels[li], context), { declaration: false }),
5214
+ data: this.formatter.formatToXml(layoutRels[li], context),
4922
5215
  path: `ppt/slideLayouts/_rels/slideLayout${li + 1}.xml.rels`
4923
5216
  };
4924
5217
  }
@@ -4930,14 +5223,11 @@ var Compiler = class {
4930
5223
  if (file.notesSlides.length > 0) {
4931
5224
  file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", "notesMasters/notesMaster1.xml");
4932
5225
  mapping["NotesMaster"] = {
4933
- data: xml(this.formatter.format(new DefaultNotesMaster(), context), {
4934
- declaration,
4935
- indent
4936
- }),
5226
+ data: this.formatter.formatToXml(new DefaultNotesMaster(), context, declaration),
4937
5227
  path: "ppt/notesMasters/notesMaster1.xml"
4938
5228
  };
4939
5229
  mapping["NotesMasterRelationships"] = {
4940
- data: xml(this.formatter.format(file.notesMasterRelationships, context), { declaration: false }),
5230
+ data: this.formatter.formatToXml(file.notesMasterRelationships, context),
4941
5231
  path: "ppt/notesMasters/_rels/notesMaster1.xml.rels"
4942
5232
  };
4943
5233
  }
@@ -4956,7 +5246,7 @@ var Compiler = class {
4956
5246
  path: "ppt/presentation.xml"
4957
5247
  };
4958
5248
  mapping["PresentationRelationships"] = {
4959
- data: xml(this.formatter.format(file.presentationWrapper.relationships, context), { declaration: false }),
5249
+ data: this.formatter.formatToXml(file.presentationWrapper.relationships, context),
4960
5250
  path: "ppt/_rels/presentation.xml.rels"
4961
5251
  };
4962
5252
  for (let i = 0; i < file.slides.length; i++) {
@@ -5025,7 +5315,7 @@ var Compiler = class {
5025
5315
  const notesSlideIndex = file.notesSlideIndexMap.get(i);
5026
5316
  if (notesSlideIndex !== void 0) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`);
5027
5317
  mapping[`SlideRelationships${i}`] = {
5028
- data: xml(this.formatter.format(slideWrapper.relationships, context), { declaration: false }),
5318
+ data: this.formatter.formatToXml(slideWrapper.relationships, context),
5029
5319
  path: `ppt/slides/_rels/slide${i + 1}.xml.rels`
5030
5320
  };
5031
5321
  }
@@ -5040,57 +5330,37 @@ var Compiler = class {
5040
5330
  file.contentTypes.addDiagramDrawing(i + 1);
5041
5331
  });
5042
5332
  mapping["ContentTypes"] = {
5043
- data: xml(this.formatter.format(file.contentTypes, context), { declaration: false }),
5333
+ data: this.formatter.formatToXml(file.contentTypes, context),
5044
5334
  path: "[Content_Types].xml"
5045
5335
  };
5046
- const files = {};
5047
- for (const key of Object.keys(mapping)) {
5048
- const entry = mapping[key];
5049
- files[entry.path] = textToUint8Array$1(entry.data);
5050
- }
5051
- for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array$1(override.data);
5336
+ const files = compileMapping(mapping, overrides);
5052
5337
  for (let i = 0; i < file.charts.array.length; i++) {
5053
5338
  const chartData = file.charts.array[i];
5054
- files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(chartData.chartSpace, context), {
5055
- declaration,
5056
- indent
5057
- }));
5058
- files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5339
+ files[`ppt/charts/chart${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(chartData.chartSpace, context, declaration));
5340
+ files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = encoder$1.encode(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5059
5341
  encoding: "UTF-8",
5060
5342
  standalone: "yes"
5061
5343
  } }));
5062
5344
  }
5063
5345
  for (let i = 0; i < file.smartArts.array.length; i++) {
5064
5346
  const smartArtData = file.smartArts.array[i];
5065
- files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(smartArtData.dataModel, context), {
5066
- declaration,
5067
- indent
5068
- }));
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);
5347
+ files[`ppt/diagrams/data${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(smartArtData.dataModel, context, declaration));
5348
+ files[`ppt/diagrams/layout${i + 1}.xml`] = encoder$1.encode(getLayoutXml(smartArtData.layout));
5349
+ files[`ppt/diagrams/quickStyle${i + 1}.xml`] = encoder$1.encode(getStyleXml(smartArtData.style));
5350
+ files[`ppt/diagrams/colors${i + 1}.xml`] = encoder$1.encode(getColorXml(smartArtData.color));
5351
+ files[`ppt/diagrams/drawing${i + 1}.xml`] = encoder$1.encode(DEFAULT_DRAWING_XML);
5073
5352
  }
5074
5353
  for (let i = 0; i < file.notesSlides.length; i++) {
5075
5354
  const notesSlide = file.notesSlides[i];
5076
- files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array$1(xml(this.formatter.format(notesSlide, context), {
5077
- declaration,
5078
- indent
5079
- }));
5080
- files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5355
+ files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(notesSlide, context, declaration));
5356
+ files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = encoder$1.encode(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
5081
5357
  encoding: "UTF-8",
5082
5358
  standalone: "yes"
5083
5359
  } }));
5084
5360
  }
5085
- if (file.commentAuthorList) files["ppt/commentAuthors.xml"] = textToUint8Array$1(xml(this.formatter.format(file.commentAuthorList, context), {
5086
- declaration,
5087
- indent
5088
- }));
5361
+ if (file.commentAuthorList) files["ppt/commentAuthors.xml"] = encoder$1.encode(this.formatter.formatToXml(file.commentAuthorList, context, declaration));
5089
5362
  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), {
5091
- declaration,
5092
- indent
5093
- }));
5363
+ for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(commentLists[i], context, declaration));
5094
5364
  for (const image of file.media.array) {
5095
5365
  files[`ppt/media/${image.fileName}`] = [image.data, { level: ZIP_STORED_LEVEL }];
5096
5366
  if (image.type === "svg" && "fallback" in image) {
@@ -5101,15 +5371,11 @@ var Compiler = class {
5101
5371
  return files;
5102
5372
  }
5103
5373
  };
5104
- function textToUint8Array$1(data) {
5105
- if (data instanceof Uint8Array) return data;
5106
- return new TextEncoder().encode(data);
5107
- }
5108
5374
  //#endregion
5109
5375
  //#region src/export/packer/packer.ts
5110
5376
  const compiler = new Compiler();
5111
5377
  const Packer = createPacker({
5112
- compile: (file, prettify, overrides) => compiler.compile(file, prettify, overrides),
5378
+ compile: (file, overrides) => compiler.compile(file, overrides),
5113
5379
  mimeType: OoxmlMimeType.PPTX
5114
5380
  });
5115
5381
  //#endregion
@@ -6091,9 +6357,9 @@ function parseConnector(el) {
6091
6357
  const type = attr(headEnd, "type");
6092
6358
  if (type) opts.endArrowhead = type;
6093
6359
  const len = attr(headEnd, "len");
6094
- if (len) opts.arrowheadLength = len;
6360
+ if (len) opts.arrowheadLength = xsdLineEndSize.from(len);
6095
6361
  const w = attr(headEnd, "w");
6096
- if (w) opts.arrowheadWidth = w;
6362
+ if (w) opts.arrowheadWidth = xsdLineEndSize.from(w);
6097
6363
  }
6098
6364
  const tailEnd = findChild(ln, "a:tailEnd");
6099
6365
  if (tailEnd) {
@@ -7209,12 +7475,14 @@ function extractCommentText(txBody) {
7209
7475
  }
7210
7476
  //#endregion
7211
7477
  //#region src/patcher/from-pptx.ts
7478
+ /** Reusable TextEncoder (stateless, safe to share). */
7479
+ const encoder = new TextEncoder();
7212
7480
  const PatchType = { PARAGRAPH: "paragraph" };
7213
7481
  const formatter = new Formatter();
7214
7482
  const pptxReplacer = createReplacer({
7215
7483
  ns: PPTX_NS,
7216
7484
  formatChild: (child, context) => {
7217
- return [toJson(xml(formatter.format(child, context))).elements[0]];
7485
+ return [xml2js(formatter.formatToXml(child, context), { captureSpacesBetweenElements: true }).elements[0]];
7218
7486
  },
7219
7487
  preserveSpace: false
7220
7488
  });
@@ -7275,7 +7543,7 @@ const patchPresentation = async ({ outputType, data, patches, keepOriginalStyles
7275
7543
  if (contentTypes) for (const [contentType, extension] of IMAGE_CONTENT_TYPES) appendContentType(contentTypes, contentType, extension);
7276
7544
  }
7277
7545
  const files = {};
7278
- for (const [key, value] of xmlMap) files[key] = textToUint8Array(js2xml(value));
7546
+ for (const [key, value] of xmlMap) files[key] = encoder.encode(js2xml(value));
7279
7547
  for (const [key, value] of binaryMap) files[key] = value;
7280
7548
  return await zipAndConvert(files, outputType, OoxmlMimeType.PPTX);
7281
7549
  };
@@ -7285,8 +7553,8 @@ __reExport(/* @__PURE__ */ __exportAll({
7285
7553
  Background: () => Background,
7286
7554
  BevelPresetType: () => BevelPresetType,
7287
7555
  BlipFill: () => BlipFill,
7556
+ Chart: () => Chart,
7288
7557
  ChartCollection: () => ChartCollection,
7289
- ChartFrame: () => ChartFrame,
7290
7558
  ChartSpace: () => ChartSpace,
7291
7559
  CompoundLine: () => CompoundLine,
7292
7560
  ConnectorShape: () => ConnectorShape,
@@ -7297,6 +7565,7 @@ __reExport(/* @__PURE__ */ __exportAll({
7297
7565
  DefaultSlideLayout: () => DefaultSlideLayout,
7298
7566
  DefaultSlideMaster: () => DefaultSlideMaster,
7299
7567
  DefaultTheme: () => DefaultTheme,
7568
+ DrawingTable: () => DrawingTable,
7300
7569
  EndParagraphRunProperties: () => EndParagraphRunProperties,
7301
7570
  Field: () => Field,
7302
7571
  File: () => File,
@@ -7324,7 +7593,6 @@ __reExport(/* @__PURE__ */ __exportAll({
7324
7593
  PresetDash: () => PresetDash,
7325
7594
  PresetGeometry: () => PresetGeometry,
7326
7595
  PresetMaterialType: () => PresetMaterialType,
7327
- PrettifyType: () => PrettifyType,
7328
7596
  ReflectionAlignment: () => ReflectionAlignment,
7329
7597
  Relationships: () => Relationships,
7330
7598
  RunProperties: () => RunProperties,
@@ -7335,12 +7603,11 @@ __reExport(/* @__PURE__ */ __exportAll({
7335
7603
  SlideLayout: () => SlideLayout,
7336
7604
  SlideNumberField: () => SlideNumberField,
7337
7605
  SlideSizePreset: () => SlideSizePreset,
7338
- SmartArtFrame: () => SmartArtFrame,
7606
+ SmartArt: () => SmartArt,
7339
7607
  StrikeStyle: () => StrikeStyle,
7340
7608
  Table: () => Table,
7341
7609
  TableCell: () => TableCell,
7342
7610
  TableCellProperties: () => TableCellProperties,
7343
- TableFrame: () => TableFrame,
7344
7611
  TableProperties: () => TableProperties,
7345
7612
  TableRow: () => TableRow,
7346
7613
  Text: () => Text,
@@ -7387,6 +7654,6 @@ __reExport(/* @__PURE__ */ __exportAll({
7387
7654
  uniqueUuid: () => uniqueUuid
7388
7655
  }), util_exports);
7389
7656
  //#endregion
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 };
7657
+ export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, Chart, ChartCollection, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, DrawingTable, 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, ReflectionAlignment, Relationships, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideLayout, SlideNumberField, SlideSizePreset, SmartArt, StrikeStyle, Table, TableCell, TableCellProperties, 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 };
7391
7658
 
7392
- //# sourceMappingURL=index.mjs.map
7659
+ //# sourceMappingURL=index.js.map