ooxml-core 1.27.1 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/{PptxHandler-OIR3ZY4Q.mjs → PptxHandler-AFVUHNJO.mjs} +3 -3
  2. package/dist/PptxHandler-EZW4YAWL.mjs +4 -0
  3. package/dist/{PptxHandler-NHOKKZ4S.cjs → PptxHandler-WI23AJHM.cjs} +3 -3
  4. package/dist/{PresentationBuilder-RFTSZUPR.mjs → PresentationBuilder-DYEHCRHX.mjs} +2 -2
  5. package/dist/{PresentationBuilder-EX6DAE5X.cjs → PresentationBuilder-KUNPJTRL.cjs} +5 -5
  6. package/dist/{PresentationBuilder-X5WFSHLB.mjs → PresentationBuilder-WGTZPVOG.mjs} +3 -3
  7. package/dist/automation/index.cjs +16 -7
  8. package/dist/automation/index.mjs +16 -7
  9. package/dist/chart/index.cjs +16 -7
  10. package/dist/chart/index.mjs +16 -7
  11. package/dist/{chunk-36TR3PER.cjs → chunk-A2PC3CBO.cjs} +28 -7
  12. package/dist/{chunk-ZWTXVWMY.mjs → chunk-D7CAHL6J.mjs} +1 -1
  13. package/dist/{chunk-JJ37PCNR.mjs → chunk-EYCM7RVL.mjs} +28 -7
  14. package/dist/{chunk-DMJIDRJE.cjs → chunk-IQ7CB7BJ.cjs} +1771 -1319
  15. package/dist/{chunk-5NJPYCGO.mjs → chunk-LGSBK3BV.mjs} +258 -258
  16. package/dist/{chunk-I57SMSU6.mjs → chunk-LNPVKKR5.mjs} +28 -7
  17. package/dist/{chunk-GZ4DIXZZ.mjs → chunk-N5ROEHEQ.mjs} +699 -247
  18. package/dist/{chunk-QIMNQDON.mjs → chunk-RCEHCVLC.mjs} +1 -1
  19. package/dist/{chunk-BXZF7H5G.mjs → chunk-V33RUK4D.mjs} +5 -5
  20. package/dist/{chunk-5KJAQKZG.mjs → chunk-YNGMSNF4.mjs} +718 -246
  21. package/dist/docx/embedded.cjs +16 -7
  22. package/dist/docx/embedded.mjs +16 -7
  23. package/dist/docx/index.cjs +16 -7
  24. package/dist/docx/index.mjs +16 -7
  25. package/dist/docx/load/index.cjs +16 -7
  26. package/dist/docx/load/index.mjs +16 -7
  27. package/dist/index.cjs +16 -7
  28. package/dist/index.mjs +16 -7
  29. package/dist/opc/index.cjs +16 -7
  30. package/dist/opc/index.mjs +16 -7
  31. package/dist/opc/zip-limits.d.ts +8 -1
  32. package/dist/opc/zip-limits.d.ts.map +1 -1
  33. package/dist/pptx/automation/index.cjs +1009 -505
  34. package/dist/pptx/automation/index.d.ts +4 -4
  35. package/dist/pptx/automation/index.mjs +6 -6
  36. package/dist/pptx/chunks/{index-D8DNpc1X.d.ts → index-0slnMhMO.d.ts} +161 -12
  37. package/dist/pptx/chunks/index-0slnMhMO.d.ts.map +1 -0
  38. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts → index-DP-R2qY1.d.ts} +3 -3
  39. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts.map → index-DP-R2qY1.d.ts.map} +1 -1
  40. package/dist/pptx/chunks/{index-GWpMAY-f.d.ts → index-OQwOyNYK.d.ts} +4 -4
  41. package/dist/pptx/chunks/{index-GWpMAY-f.d.ts.map → index-OQwOyNYK.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{text-operations-CNfUj45U.d.ts → text-operations-dyvh8gyE.d.ts} +23 -1
  43. package/dist/pptx/chunks/{text-operations-CNfUj45U.d.ts.map → text-operations-dyvh8gyE.d.ts.map} +1 -1
  44. package/dist/pptx/cli/index.cjs +834 -333
  45. package/dist/pptx/cli/index.d.ts +1 -1
  46. package/dist/pptx/cli/index.mjs +5 -5
  47. package/dist/pptx/converter/index.d.ts +1 -1
  48. package/dist/pptx/converter/index.mjs +3 -3
  49. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  50. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  51. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  52. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  53. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  54. package/dist/pptx/index.cjs +1249 -726
  55. package/dist/pptx/index.d.ts +5 -5
  56. package/dist/pptx/index.mjs +6 -6
  57. package/dist/pptx/node/index.d.ts +1 -1
  58. package/dist/pptx/signature-node/index.cjs +28 -7
  59. package/dist/pptx/signature-node/index.mjs +2 -2
  60. package/dist/visio/index.cjs +14 -6
  61. package/dist/visio/index.mjs +14 -6
  62. package/dist/visio/ui/index.cjs +14 -6
  63. package/dist/visio/ui/index.mjs +14 -6
  64. package/dist/xlsx/index.cjs +14 -6
  65. package/dist/xlsx/index.mjs +14 -6
  66. package/dist/xlsx/load/index.cjs +14 -6
  67. package/dist/xlsx/load/index.mjs +14 -6
  68. package/dist/xlsx/ui/index.cjs +14 -6
  69. package/dist/xlsx/ui/index.mjs +14 -6
  70. package/package.json +5 -5
  71. package/dist/PptxHandler-TZJNIXPX.mjs +0 -4
  72. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +0 -1
@@ -10496,7 +10496,7 @@ function ensureArrayLocal(value) {
10496
10496
  return Array.isArray(value) ? value : value === void 0 ? [] : [value];
10497
10497
  }
10498
10498
  function countsSignature(counts) {
10499
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
10499
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
10500
10500
  }
10501
10501
  function pathSignature(path4) {
10502
10502
  const counts = /* @__PURE__ */ new Map();
@@ -13722,9 +13722,9 @@ function decodeSlot(dir, id, majorVersion, warnings) {
13722
13722
  };
13723
13723
  }
13724
13724
  function readDirectory(dir, majorVersion, strict, warnings) {
13725
- const count = Math.floor(dir.length / DIR_ENTRY_SIZE);
13725
+ const count2 = Math.floor(dir.length / DIR_ENTRY_SIZE);
13726
13726
  const slots = [];
13727
- for (let id = 0; id < count; id++)
13727
+ for (let id = 0; id < count2; id++)
13728
13728
  slots.push(decodeSlot(dir, id, majorVersion, warnings));
13729
13729
  const roots = slots.filter((slot) => slot.type === ENTRY_TYPE_ROOT);
13730
13730
  if (roots.length !== 1 || !roots[0].nameValid)
@@ -14265,10 +14265,10 @@ function writeFatChain(fat, chain) {
14265
14265
  fat[chain.sectors[i2]] = i2 < chain.sectors.length - 1 ? chain.sectors[i2 + 1] : ENDOFCHAIN;
14266
14266
  }
14267
14267
  }
14268
- function writeFatRun(fat, firstSector, count) {
14269
- for (let i2 = 0; i2 < count; i2++) {
14268
+ function writeFatRun(fat, firstSector, count2) {
14269
+ for (let i2 = 0; i2 < count2; i2++) {
14270
14270
  const sector = firstSector + i2;
14271
- fat[sector] = i2 < count - 1 ? sector + 1 : ENDOFCHAIN;
14271
+ fat[sector] = i2 < count2 - 1 ? sector + 1 : ENDOFCHAIN;
14272
14272
  }
14273
14273
  }
14274
14274
  function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorSize) {
@@ -14695,7 +14695,7 @@ function resolveLimits(limits) {
14695
14695
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
14696
14696
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
14697
14697
  label: limits.label ?? "ZIP",
14698
- fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
14698
+ fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
14699
14699
  };
14700
14700
  }
14701
14701
  async function inflateEntryGuarded(entry2, alreadyRead, limits) {
@@ -14749,7 +14749,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
14749
14749
  r.fail(
14750
14750
  `${r.label} part ${entry2.name} inflates past its declared size`,
14751
14751
  r.maxEntryBytes,
14752
- size > declared ? "declaredSize" : "maxEntryBytes"
14752
+ size > declared ? "declaredSize" : "maxEntryBytes",
14753
+ size
14753
14754
  )
14754
14755
  );
14755
14756
  if (alreadyRead + size > r.maxTotalBytes)
@@ -14757,7 +14758,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
14757
14758
  r.fail(
14758
14759
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14759
14760
  r.maxTotalBytes,
14760
- "maxTotalBytes"
14761
+ "maxTotalBytes",
14762
+ alreadyRead + size
14761
14763
  )
14762
14764
  );
14763
14765
  queue.push(chunk2);
@@ -14804,7 +14806,8 @@ function guardZip(zip, limits = {}) {
14804
14806
  throw r.fail(
14805
14807
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
14806
14808
  r.maxEntries,
14807
- "maxEntries"
14809
+ "maxEntries",
14810
+ entries.length
14808
14811
  );
14809
14812
  let declared = 0;
14810
14813
  for (const entry2 of entries) {
@@ -14817,7 +14820,8 @@ function guardZip(zip, limits = {}) {
14817
14820
  throw r.fail(
14818
14821
  `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
14819
14822
  r.maxEntryBytes,
14820
- "maxEntryBytes"
14823
+ "maxEntryBytes",
14824
+ size
14821
14825
  );
14822
14826
  declared += size;
14823
14827
  }
@@ -14825,7 +14829,8 @@ function guardZip(zip, limits = {}) {
14825
14829
  throw r.fail(
14826
14830
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14827
14831
  r.maxTotalBytes,
14828
- "maxTotalBytes"
14832
+ "maxTotalBytes",
14833
+ declared
14829
14834
  );
14830
14835
  const produced = /* @__PURE__ */ new Map();
14831
14836
  let total = 0;
@@ -14864,7 +14869,8 @@ async function openZip(input, limits = {}) {
14864
14869
  throw r.fail(
14865
14870
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
14866
14871
  maxInput,
14867
- "maxInputBytes"
14872
+ "maxInputBytes",
14873
+ bytes.byteLength
14868
14874
  );
14869
14875
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
14870
14876
  }
@@ -14882,11 +14888,14 @@ var init_zip_limits = __esm({
14882
14888
  limit;
14883
14889
  /** The check that failed (absent when the error was built without one). */
14884
14890
  kind;
14891
+ /** The observed value, when known (a lower bound for a size found while inflating). */
14892
+ actual;
14885
14893
  constructor(message, details) {
14886
14894
  super(message);
14887
14895
  this.name = "ZipLimitError";
14888
14896
  this.limit = details.limit;
14889
14897
  this.kind = details.kind;
14898
+ this.actual = details.actual;
14890
14899
  }
14891
14900
  };
14892
14901
  mib = (bytes) => Math.round(bytes / 1048576);
@@ -14902,15 +14911,27 @@ var init_types2 = __esm({
14902
14911
  MAX_ZIP_ENTRY_COUNT = 65536;
14903
14912
  ZipBombError = class extends Error {
14904
14913
  code = "ZIP_BOMB";
14914
+ /** Inflated bytes declared or read when a size limit failed (a lower bound while streaming). */
14905
14915
  uncompressedBytes;
14916
+ /** The value of the limit that failed. */
14906
14917
  limit;
14918
+ /** Number of archive entries, when the entry-count limit failed. */
14907
14919
  entryCount;
14920
+ /**
14921
+ * The `PptxLoadLimits` field behind this error (`maxUncompressedBytes` or
14922
+ * `maxEntries`); `undefined` for a forged size or an unsafe part name.
14923
+ */
14924
+ loadLimit;
14925
+ /** The observed value for {@link loadLimit}, when known. */
14926
+ actual;
14908
14927
  constructor(message, details) {
14909
14928
  super(message);
14910
14929
  this.name = "ZipBombError";
14911
14930
  this.uncompressedBytes = details.uncompressedBytes;
14912
14931
  this.limit = details.limit;
14913
14932
  this.entryCount = details.entryCount;
14933
+ this.loadLimit = details.loadLimit;
14934
+ this.actual = details.actual;
14914
14935
  }
14915
14936
  };
14916
14937
  }
@@ -14992,21 +15013,21 @@ function parseChartFormulaRange(formula2) {
14992
15013
  }
14993
15014
  return { sheetName, start, end };
14994
15015
  }
14995
- function expandRangeAddresses(range, count) {
15016
+ function expandRangeAddresses(range, count2) {
14996
15017
  const { start, end } = range;
14997
- if (count <= 0) {
15018
+ if (count2 <= 0) {
14998
15019
  return void 0;
14999
15020
  }
15000
15021
  if (start.col === end.col && start.row === end.row) {
15001
- return count === 1 ? [formatCellAddress(start)] : void 0;
15022
+ return count2 === 1 ? [formatCellAddress(start)] : void 0;
15002
15023
  }
15003
15024
  if (start.col === end.col) {
15004
15025
  const length = end.row - start.row + 1;
15005
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
15026
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
15006
15027
  }
15007
15028
  if (start.row === end.row) {
15008
15029
  const length = end.col - start.col + 1;
15009
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
15030
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
15010
15031
  }
15011
15032
  return void 0;
15012
15033
  }
@@ -15801,9 +15822,9 @@ var init_deflate_encode = __esm({
15801
15822
  len = 0;
15802
15823
  acc = 0;
15803
15824
  nbits = 0;
15804
- bits(value, count) {
15825
+ bits(value, count2) {
15805
15826
  this.acc |= value << this.nbits;
15806
- this.nbits += count;
15827
+ this.nbits += count2;
15807
15828
  while (this.nbits >= 8) {
15808
15829
  this.push(this.acc & 255);
15809
15830
  this.acc >>>= 8;
@@ -15811,12 +15832,12 @@ var init_deflate_encode = __esm({
15811
15832
  }
15812
15833
  }
15813
15834
  /** Huffman codes are packed most-significant bit first. */
15814
- code(value, count) {
15835
+ code(value, count2) {
15815
15836
  let reversed = 0;
15816
- for (let i2 = 0; i2 < count; i2++) {
15837
+ for (let i2 = 0; i2 < count2; i2++) {
15817
15838
  reversed = reversed << 1 | value >>> i2 & 1;
15818
15839
  }
15819
- this.bits(reversed, count);
15840
+ this.bits(reversed, count2);
15820
15841
  }
15821
15842
  finish() {
15822
15843
  if (this.nbits > 0) {
@@ -19661,12 +19682,12 @@ function functionValue(condition, point2, lookup) {
19661
19682
  if (!target) {
19662
19683
  return void 0;
19663
19684
  }
19664
- const { pos: pos2, count } = siblingPosition(target, ptType);
19685
+ const { pos: pos2, count: count2 } = siblingPosition(target, ptType);
19665
19686
  if (condition.func === "pos") {
19666
19687
  return pos2;
19667
19688
  }
19668
19689
  if (condition.func === "revPos") {
19669
- return count - pos2 + 1;
19690
+ return count2 - pos2 + 1;
19670
19691
  }
19671
19692
  return condition.func === "posEven" ? pos2 % 2 === 0 ? 1 : 0 : pos2 % 2 === 1 ? 1 : 0;
19672
19693
  }
@@ -22752,19 +22773,19 @@ function pointTypeMatches(node, pointType2) {
22752
22773
  }
22753
22774
  return node.nodeType === pointType2;
22754
22775
  }
22755
- function selectRange(nodes, start, count) {
22756
- if (start === void 0 && count === void 0) {
22776
+ function selectRange(nodes, start, count2) {
22777
+ if (start === void 0 && count2 === void 0) {
22757
22778
  return nodes;
22758
22779
  }
22759
22780
  const zeroBasedStart = Math.max(0, (start ?? 1) - 1);
22760
- const take2 = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
22781
+ const take2 = count2 !== void 0 && count2 > 0 ? count2 : nodes.length - zeroBasedStart;
22761
22782
  return nodes.slice(zeroBasedStart, zeroBasedStart + take2);
22762
22783
  }
22763
- function applyPointTypeAndRange(nodes, pointType2, start, count) {
22784
+ function applyPointTypeAndRange(nodes, pointType2, start, count2) {
22764
22785
  const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
22765
- return selectRange(filtered, start, count);
22786
+ return selectRange(filtered, start, count2);
22766
22787
  }
22767
- function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22788
+ function resolveAxisNodes(nodes, axis, pointTypes, start, count2, context) {
22768
22789
  if (axis.length === 0) {
22769
22790
  return void 0;
22770
22791
  }
@@ -22794,21 +22815,21 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22794
22815
  let current;
22795
22816
  let nextHop;
22796
22817
  if (axis[0] === "root" && axis.length > 1) {
22797
- current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
22818
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count2?.[1]);
22798
22819
  nextHop = 2;
22799
22820
  } else if (axis[0] === "root") {
22800
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
22821
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
22801
22822
  nextHop = 1;
22802
22823
  } else if (context !== void 0) {
22803
22824
  current = applyPointTypeAndRange(
22804
22825
  navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
22805
22826
  pointTypes?.[0],
22806
22827
  start?.[0],
22807
- count?.[0]
22828
+ count2?.[0]
22808
22829
  );
22809
22830
  nextHop = 1;
22810
22831
  } else {
22811
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
22832
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
22812
22833
  nextHop = 1;
22813
22834
  }
22814
22835
  for (let hop = nextHop; hop < axis.length; hop += 1) {
@@ -22816,13 +22837,13 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
22816
22837
  navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
22817
22838
  pointTypes?.[hop],
22818
22839
  start?.[hop],
22819
- count?.[hop]
22840
+ count2?.[hop]
22820
22841
  );
22821
22842
  }
22822
22843
  return current;
22823
22844
  }
22824
- function resolveAxisCount(nodes, axis, pointTypes, start, count, context) {
22825
- return resolveAxisNodes(nodes, axis, pointTypes, start, count, context)?.length;
22845
+ function resolveAxisCount(nodes, axis, pointTypes, start, count2, context) {
22846
+ return resolveAxisNodes(nodes, axis, pointTypes, start, count2, context)?.length;
22826
22847
  }
22827
22848
  var init_smartart_layout_interpreter_axis_count = __esm({
22828
22849
  "diagram/layout/smartart-layout-interpreter-axis-count.ts"() {
@@ -22848,14 +22869,14 @@ function depthFromAnchor(node, anchorId, byId) {
22848
22869
  }
22849
22870
  return void 0;
22850
22871
  }
22851
- function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count, anchor) {
22872
+ function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count2, anchor) {
22852
22873
  if (anchor.length === 0) {
22853
22874
  return void 0;
22854
22875
  }
22855
22876
  const byId = new Map(nodes.map((n) => [n.id, n]));
22856
22877
  let max = 0;
22857
22878
  for (const anchorPoint of anchor) {
22858
- const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count, [anchorPoint]);
22879
+ const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count2, [anchorPoint]);
22859
22880
  if (resolved === void 0) {
22860
22881
  return void 0;
22861
22882
  }
@@ -23341,8 +23362,8 @@ function selectArrangedNodes(node, flat, roots) {
23341
23362
  const followSibCounts = collectFollowSibNodeCounts(node);
23342
23363
  if (followSibCounts.length > 0) {
23343
23364
  for (const i2 of [...indices]) {
23344
- for (const count of followSibCounts) {
23345
- for (let k = 1; k <= count; k++) {
23365
+ for (const count2 of followSibCounts) {
23366
+ for (let k = 1; k <= count2; k++) {
23346
23367
  const j = i2 + k;
23347
23368
  if (j < base.length) {
23348
23369
  indices.add(j);
@@ -24917,12 +24938,12 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path4) {
24917
24938
  const baseAngleRad = dist > 1e-6 ? Math.atan2(dy, dx) : 0;
24918
24939
  const halfExtent = Math.max(context.itemWidth, context.itemHeight) / 2;
24919
24940
  const radius = context.itemWidth / 2 + Math.max(0, context.gapPx) + halfExtent;
24920
- const count = children16.length;
24941
+ const count2 = children16.length;
24921
24942
  const spanRad = context.fanSpanDeg * DEG_TO_RAD2;
24922
24943
  const nodes = [];
24923
24944
  const connectors2 = [];
24924
24945
  children16.forEach((child31, i2) => {
24925
- const angle = count === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count - 1);
24946
+ const angle = count2 === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count2 - 1);
24926
24947
  const cx = parentCentre.x + Math.cos(angle) * radius;
24927
24948
  const cy = parentCentre.y + Math.sin(angle) * radius;
24928
24949
  const key2 = `${context.elementId}-cycle-ext-${path4}-${i2}`;
@@ -24935,7 +24956,7 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path4) {
24935
24956
  height: context.itemHeight,
24936
24957
  node: child31,
24937
24958
  index: i2,
24938
- total: count,
24959
+ total: count2,
24939
24960
  palette: context.palette,
24940
24961
  style: context.style,
24941
24962
  ctx: context.ctx,
@@ -26112,12 +26133,12 @@ var init_smartart_layout_interpreter_linear_content_size = __esm({
26112
26133
  });
26113
26134
 
26114
26135
  // diagram/layout/smartart-layout-interpreter-axis-range.ts
26115
- function positionRange(start, count, step, total) {
26136
+ function positionRange(start, count2, step, total) {
26116
26137
  const out = [];
26117
26138
  const s = step > 0 ? step : 1;
26118
26139
  for (let i2 = Math.max(0, start - 1); i2 < total; i2 += s) {
26119
26140
  out.push(i2 + 1);
26120
- if (count !== void 0 && count > 0 && out.length >= count) {
26141
+ if (count2 !== void 0 && count2 > 0 && out.length >= count2) {
26121
26142
  break;
26122
26143
  }
26123
26144
  }
@@ -26137,8 +26158,8 @@ function compoundChildIds(role, node, childrenOf) {
26137
26158
  }
26138
26159
  const children16 = childrenOf.get(node.id) ?? [];
26139
26160
  const start = role.presentationOf?.start?.[chIndex] ?? 1;
26140
- const count = role.presentationOf?.count?.[chIndex];
26141
- const positions = positionRange(start, count, 1, children16.length);
26161
+ const count2 = role.presentationOf?.count?.[chIndex];
26162
+ const positions = positionRange(start, count2, 1, children16.length);
26142
26163
  const ids = [];
26143
26164
  for (const position3 of positions) {
26144
26165
  const child31 = children16[position3 - 1];
@@ -26712,9 +26733,9 @@ function arrangeSnake2(plan, nodes, box, palette, style, elementId, index = EMPT
26712
26733
  let y = INSET + row * (cellH + gapY);
26713
26734
  if (centerIncompleteLines) {
26714
26735
  const key2 = flowDir === "row" ? row : col;
26715
- const count = lineCounts.get(key2) ?? fullLineCount;
26716
- if (count < fullLineCount) {
26717
- const shift = (fullLineCount - count) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
26736
+ const count2 = lineCounts.get(key2) ?? fullLineCount;
26737
+ if (count2 < fullLineCount) {
26738
+ const shift = (fullLineCount - count2) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
26718
26739
  if (flowDir === "row") {
26719
26740
  x += shift;
26720
26741
  } else {
@@ -27628,26 +27649,26 @@ var init_smartart_layout_interpreter_composite_foreach = __esm({
27628
27649
  });
27629
27650
 
27630
27651
  // diagram/hierarchy/smartart-hierarchy-pitch.ts
27631
- function computeAxisPitch(dimension, margin, itemSize, count, fixedGapRatio) {
27632
- const n = Math.max(1, count);
27652
+ function computeAxisPitch(dimension, margin, itemSize, count2, fixedGapRatio) {
27653
+ const n = Math.max(1, count2);
27633
27654
  const gap = n <= 1 ? 0 : fixedGapRatio !== void 0 ? itemSize * Math.max(0, fixedGapRatio) : Math.max(0, (dimension - margin - n * itemSize) / (n - 1));
27634
27655
  const pitch = itemSize + gap;
27635
27656
  const centeredShift = (dimension - n * pitch + margin) / 2;
27636
27657
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
27637
27658
  return { pitch, shift: Math.min(centeredShift, maxShift) };
27638
27659
  }
27639
- function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
27640
- const n = Math.max(1, count);
27660
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count2) {
27661
+ const n = Math.max(1, count2);
27641
27662
  const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
27642
27663
  const pitch = itemSize + gap;
27643
27664
  const span = n * itemSize + Math.max(0, n - 1) * gap;
27644
27665
  const shift = (dimension - span) / 2;
27645
27666
  return { pitch, shift };
27646
27667
  }
27647
- function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
27668
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count2) {
27648
27669
  const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
27649
27670
  const cardOffsetX = cardOffsetXRatio * compositeW;
27650
- const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
27671
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count2);
27651
27672
  const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
27652
27673
  return { pitch: centred.pitch, shift: centred.shift + correction };
27653
27674
  }
@@ -27748,16 +27769,16 @@ function childAxisSpec(template, childCount) {
27748
27769
  const ownIndex = axis.indexOf("ch");
27749
27770
  if (ownIndex >= 0) {
27750
27771
  const start = template.presentationOf?.start?.[ownIndex] ?? 1;
27751
- const count = template.presentationOf?.count?.[ownIndex];
27752
- return { positions: positionRange(start, count, 1, childCount), fold };
27772
+ const count2 = template.presentationOf?.count?.[ownIndex];
27773
+ return { positions: positionRange(start, count2, 1, childCount), fold };
27753
27774
  }
27754
27775
  const origin = template.forEachOrigin;
27755
27776
  const originIndex = origin?.axis?.indexOf("ch") ?? -1;
27756
27777
  if (origin && originIndex >= 0) {
27757
27778
  const start = origin.start?.[originIndex] ?? 1;
27758
- const count = origin.count?.[originIndex];
27779
+ const count2 = origin.count?.[originIndex];
27759
27780
  const step = origin.step?.[originIndex] ?? 1;
27760
- return { positions: positionRange(start, count, step, childCount), fold };
27781
+ return { positions: positionRange(start, count2, step, childCount), fold };
27761
27782
  }
27762
27783
  return void 0;
27763
27784
  }
@@ -27953,8 +27974,8 @@ function slotRect(slot, box, absX, absY) {
27953
27974
  }
27954
27975
  function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27955
27976
  const perPoint = representativeSlotsPerPoint(slotted, nodes.length);
27956
- const count = Math.min(perPoint.length, nodes.length);
27957
- const slots = perPoint.slice(0, count).map((entry2) => slotRect(entry2, box, absX, absY));
27977
+ const count2 = Math.min(perPoint.length, nodes.length);
27978
+ const slots = perPoint.slice(0, count2).map((entry2) => slotRect(entry2, box, absX, absY));
27958
27979
  const fontFit = fontCtx ? resolveSharedFontFit(
27959
27980
  fontCtx,
27960
27981
  perPoint[0]?.node,
@@ -27966,7 +27987,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27966
27987
  }))
27967
27988
  ) : void 0;
27968
27989
  const rendered = [];
27969
- for (let i2 = 0; i2 < count; i2++) {
27990
+ for (let i2 = 0; i2 < count2; i2++) {
27970
27991
  const slot = slots[i2];
27971
27992
  rendered.push(
27972
27993
  presetBoxNode({
@@ -27977,7 +27998,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
27977
27998
  height: slot.height,
27978
27999
  node: nodes[i2],
27979
28000
  index: i2,
27980
- total: count,
28001
+ total: count2,
27981
28002
  palette: ctx.palette,
27982
28003
  style: ctx.style,
27983
28004
  fontSizeOverride: fontFit?.rootSizePx,
@@ -28022,9 +28043,9 @@ var init_smartart_layout_interpreter_composite_ring = __esm({
28022
28043
  });
28023
28044
 
28024
28045
  // diagram/layout/smartart-layout-interpreter-composite-pairs.ts
28025
- function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count) {
28046
+ function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count2) {
28026
28047
  const pairs = [];
28027
- for (let i2 = 0; i2 < count; i2++) {
28048
+ for (let i2 = 0; i2 < count2; i2++) {
28028
28049
  const node = nodes[i2];
28029
28050
  const selfRect = resolveSlot(selfSlots[i2].dims, box, absX, absY);
28030
28051
  const desSlotted = desSlots[i2];
@@ -28117,7 +28138,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28117
28138
  }
28118
28139
  const desSlots = slotsWithAxis(slotted, "des");
28119
28140
  const childRepeaterSlots = slotted.filter((slot) => !slot.node.presentationOf);
28120
- const count = Math.min(selfSlots.length, nodes.length);
28141
+ const count2 = Math.min(selfSlots.length, nodes.length);
28121
28142
  const pairs = collectSelfDesPairs(
28122
28143
  selfSlots,
28123
28144
  desSlots,
@@ -28127,14 +28148,14 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28127
28148
  absX,
28128
28149
  absY,
28129
28150
  childrenOf,
28130
- count
28151
+ count2
28131
28152
  );
28132
28153
  const fontFit = resolveFontFitFromPairs(fontCtx, selfSlots[0]?.node, pairs);
28133
28154
  const rendered = [];
28134
- for (let i2 = 0; i2 < count; i2++) {
28155
+ for (let i2 = 0; i2 < count2; i2++) {
28135
28156
  const { node, selfRect, selfLayoutNode, desSlot } = pairs[i2];
28136
28157
  rendered.push(
28137
- ...renderAnchoredPair(node, i2, count, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
28158
+ ...renderAnchoredPair(node, i2, count2, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
28138
28159
  );
28139
28160
  for (const wrapperSlot of childRepeaterSlots) {
28140
28161
  rendered.push(
@@ -28167,7 +28188,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
28167
28188
  absY,
28168
28189
  childrenOf,
28169
28190
  ctx,
28170
- count
28191
+ count2
28171
28192
  )
28172
28193
  );
28173
28194
  return rendered;
@@ -28884,11 +28905,11 @@ var init_smartart_hierarchy_orgchart_tree = __esm({
28884
28905
  // diagram/hierarchy/smartart-hierarchy-hang-depth.ts
28885
28906
  function countDescendants(t, orgChart) {
28886
28907
  const { normal } = partitionChildren(t, orgChart);
28887
- let count = normal.length;
28908
+ let count2 = normal.length;
28888
28909
  for (const child31 of normal) {
28889
- count += countDescendants(child31, orgChart);
28910
+ count2 += countDescendants(child31, orgChart);
28890
28911
  }
28891
- return count;
28912
+ return count2;
28892
28913
  }
28893
28914
  function fanContinues(t, perRow, orgChart, siblingCount, normalCount) {
28894
28915
  const chPrefFanEligible = Number.isFinite(perRow) && siblingCount === perRow && normalCount >= perRow;
@@ -29025,7 +29046,7 @@ var init_smartart_hierarchy_fan_aware_width = __esm({
29025
29046
  });
29026
29047
 
29027
29048
  // diagram/hierarchy/smartart-hierarchy-fold-depth.ts
29028
- function endsInUnboundedDescendantHop(axis, count) {
29049
+ function endsInUnboundedDescendantHop(axis, count2) {
29029
29050
  if (!axis || axis.length === 0) {
29030
29051
  return false;
29031
29052
  }
@@ -29034,7 +29055,7 @@ function endsInUnboundedDescendantHop(axis, count) {
29034
29055
  if (lastAxis !== "des" && lastAxis !== "desOrSelf") {
29035
29056
  return false;
29036
29057
  }
29037
- const lastCount = count?.[lastIndex];
29058
+ const lastCount = count2?.[lastIndex];
29038
29059
  return lastCount === void 0 || lastCount === 0;
29039
29060
  }
29040
29061
  function hierarchyLeafFoldsDescendants(node) {
@@ -29366,17 +29387,17 @@ var init_smartart_hierarchy_hanging_box = __esm({
29366
29387
  // diagram/hierarchy/smartart-hierarchy-hanging-fold.ts
29367
29388
  function countRows(t, level2, orgChart, fold) {
29368
29389
  const { assistants, normal } = partitionChildren(t, orgChart);
29369
- let count = 1 + assistants.length;
29390
+ let count2 = 1 + assistants.length;
29370
29391
  if (normal.length === 0) {
29371
- return count;
29392
+ return count2;
29372
29393
  }
29373
29394
  if (fold && level2 >= 1) {
29374
- return count;
29395
+ return count2;
29375
29396
  }
29376
29397
  for (const child31 of normal) {
29377
- count += countRows(child31, level2 + 1, orgChart, fold);
29398
+ count2 += countRows(child31, level2 + 1, orgChart, fold);
29378
29399
  }
29379
- return count;
29400
+ return count2;
29380
29401
  }
29381
29402
  function countHangingRows(roots, orgChart, fold) {
29382
29403
  return roots.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
@@ -34079,8 +34100,8 @@ function readPairs(element, vt) {
34079
34100
  const out = [];
34080
34101
  for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
34081
34102
  const name = variants[i2]?.textContent ?? "";
34082
- const count = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
34083
- out.push({ name, count: Number.isFinite(count) ? count : 0 });
34103
+ const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
34104
+ out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
34084
34105
  }
34085
34106
  return out;
34086
34107
  }
@@ -34297,9 +34318,9 @@ var init_custom = __esm({
34297
34318
  function titleGroups(headingPairs, titlesOfParts) {
34298
34319
  let offset = 0;
34299
34320
  return headingPairs.map((pair) => {
34300
- const count = Math.max(0, pair.count);
34301
- const titles = titlesOfParts.slice(offset, offset + count);
34302
- offset += count;
34321
+ const count2 = Math.max(0, pair.count);
34322
+ const titles = titlesOfParts.slice(offset, offset + count2);
34323
+ offset += count2;
34303
34324
  return { name: pair.name, titles };
34304
34325
  });
34305
34326
  }
@@ -52925,9 +52946,6 @@ function pptxDataFromJsonDocument(document2) {
52925
52946
  data.slides = document2.slides.map((slide) => deserializeSlide(slide));
52926
52947
  return data;
52927
52948
  }
52928
- function deserializePptxFromJson(text2) {
52929
- return pptxDataFromJsonDocument(parsePptxJson(text2));
52930
- }
52931
52949
  function deserializeSlide(encoded) {
52932
52950
  const slide = {};
52933
52951
  for (const key2 of Object.keys(SLIDE_FIELD_KIND)) {
@@ -54938,6 +54956,188 @@ var init_PresentationBuilder = __esm({
54938
54956
  }
54939
54957
  });
54940
54958
 
54959
+ // pptx/core/core/load-limits.ts
54960
+ function resolvePptxLoadLimits(options = {}) {
54961
+ const resolved = { ...DEFAULT_PPTX_LOAD_LIMITS };
54962
+ const legacy = options.maxUncompressedBytes;
54963
+ if (typeof legacy === "number" && legacy > 0) {
54964
+ resolved.maxUncompressedBytes = legacy;
54965
+ }
54966
+ const limits = options.limits;
54967
+ if (limits === void 0 || limits === null) {
54968
+ return resolved;
54969
+ }
54970
+ for (const name of LIMIT_NAMES) {
54971
+ const value = limits[name];
54972
+ if (value === void 0) {
54973
+ continue;
54974
+ }
54975
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
54976
+ throw new RangeError(`limits.${name} must be a positive finite number`);
54977
+ }
54978
+ if (name === "maxEntries" && value > MAX_ZIP_ENTRY_COUNT) {
54979
+ throw new RangeError(`limits.maxEntries must not exceed ${MAX_ZIP_ENTRY_COUNT}`);
54980
+ }
54981
+ resolved[name] = value;
54982
+ }
54983
+ return resolved;
54984
+ }
54985
+ function createPptxZipBombError(message, details) {
54986
+ const { limit, kind, actual } = details;
54987
+ if (kind === "maxEntries") {
54988
+ return new ZipBombError(message, {
54989
+ limit,
54990
+ loadLimit: "maxEntries",
54991
+ ...actual === void 0 ? {} : { entryCount: actual, actual }
54992
+ });
54993
+ }
54994
+ if (kind === "maxEntryBytes" || kind === "maxTotalBytes") {
54995
+ return new ZipBombError(message, {
54996
+ limit,
54997
+ loadLimit: "maxUncompressedBytes",
54998
+ ...actual === void 0 ? {} : { uncompressedBytes: actual, actual }
54999
+ });
55000
+ }
55001
+ return new ZipBombError(message, { limit });
55002
+ }
55003
+ function assertPptxInputWithinLimits(byteLength, limits) {
55004
+ if (byteLength > limits.maxInputBytes) {
55005
+ throw new PptxLoadLimitError(
55006
+ `PPTX input is ${count(byteLength)} bytes, more than the maxInputBytes limit of ${count(limits.maxInputBytes)}`,
55007
+ "maxInputBytes",
55008
+ limits.maxInputBytes,
55009
+ byteLength
55010
+ );
55011
+ }
55012
+ }
55013
+ function assertPptxTextWithinLimits(text2, limits) {
55014
+ const maximum = limits.maxInputBytes;
55015
+ if (text2.length * 3 <= maximum) {
55016
+ return;
55017
+ }
55018
+ const bytes = text2.length > maximum ? text2.length : utf8ByteLengthPast(text2, maximum);
55019
+ if (bytes > maximum) {
55020
+ throw new PptxLoadLimitError(
55021
+ `PPTX input is at least ${count(bytes)} bytes, more than the maxInputBytes limit of ${count(maximum)}`,
55022
+ "maxInputBytes",
55023
+ maximum,
55024
+ bytes
55025
+ );
55026
+ }
55027
+ }
55028
+ function utf8ByteLengthPast(text2, maximum) {
55029
+ let bytes = 0;
55030
+ for (let index = 0; index < text2.length && bytes <= maximum; index++) {
55031
+ const unit = text2.charCodeAt(index);
55032
+ if (unit < 128) {
55033
+ bytes += 1;
55034
+ } else if (unit < 2048) {
55035
+ bytes += 2;
55036
+ } else if (unit >= 55296 && unit <= 56319 && isLowSurrogate(text2.charCodeAt(index + 1))) {
55037
+ bytes += 4;
55038
+ index++;
55039
+ } else {
55040
+ bytes += 3;
55041
+ }
55042
+ }
55043
+ return bytes;
55044
+ }
55045
+ function isLowSurrogate(unit) {
55046
+ return unit >= 56320 && unit <= 57343;
55047
+ }
55048
+ function assertPptxSlideCountWithinLimits(slideCount, limits) {
55049
+ if (slideCount > limits.maxSlides) {
55050
+ throw new PptxLoadLimitError(
55051
+ `PPTX presentation has ${count(slideCount)} slides, more than the maxSlides limit of ${count(limits.maxSlides)}`,
55052
+ "maxSlides",
55053
+ limits.maxSlides,
55054
+ slideCount
55055
+ );
55056
+ }
55057
+ }
55058
+ function countPptxShapesWithinLimits(counted, elements2, limits) {
55059
+ const maximum = limits.maxShapes;
55060
+ if (maximum === Number.POSITIVE_INFINITY) {
55061
+ return counted;
55062
+ }
55063
+ const total = counted + countAuthoredElements(elements2);
55064
+ if (total > maximum) {
55065
+ throw new PptxLoadLimitError(
55066
+ `PPTX presentation has at least ${count(total)} shapes, more than the maxShapes limit of ${count(maximum)}`,
55067
+ "maxShapes",
55068
+ maximum,
55069
+ total
55070
+ );
55071
+ }
55072
+ return total;
55073
+ }
55074
+ function countAuthoredElements(elements2) {
55075
+ let total = 0;
55076
+ const lists = [elements2];
55077
+ const positions = [0];
55078
+ while (lists.length > 0) {
55079
+ const top = lists.length - 1;
55080
+ const list3 = lists[top];
55081
+ const position3 = positions[top];
55082
+ if (position3 >= list3.length) {
55083
+ lists.pop();
55084
+ positions.pop();
55085
+ continue;
55086
+ }
55087
+ positions[top] = position3 + 1;
55088
+ const element = list3[position3];
55089
+ if (typeof element !== "object" || element === null) {
55090
+ continue;
55091
+ }
55092
+ const { id, type, children: children16 } = element;
55093
+ if (typeof id === "string" && isTemplateElementId(id)) {
55094
+ continue;
55095
+ }
55096
+ total++;
55097
+ if (type === "group" && Array.isArray(children16) && children16.length > 0) {
55098
+ lists.push(children16);
55099
+ positions.push(0);
55100
+ }
55101
+ }
55102
+ return total;
55103
+ }
55104
+ var DEFAULT_PPTX_LOAD_LIMITS, LIMIT_NAMES, PptxLoadLimitError, count;
55105
+ var init_load_limits = __esm({
55106
+ "pptx/core/core/load-limits.ts"() {
55107
+ init_group_ops();
55108
+ init_types2();
55109
+ DEFAULT_PPTX_LOAD_LIMITS = Object.freeze({
55110
+ maxInputBytes: Number.POSITIVE_INFINITY,
55111
+ maxUncompressedBytes: DEFAULT_MAX_UNCOMPRESSED_BYTES,
55112
+ maxEntries: MAX_ZIP_ENTRY_COUNT,
55113
+ maxSlides: Number.POSITIVE_INFINITY,
55114
+ maxShapes: Number.POSITIVE_INFINITY
55115
+ });
55116
+ LIMIT_NAMES = Object.keys(DEFAULT_PPTX_LOAD_LIMITS);
55117
+ PptxLoadLimitError = class extends Error {
55118
+ code = "PPTX_LOAD_LIMIT";
55119
+ /** The limit that was exceeded. */
55120
+ limit;
55121
+ /** The value of that limit. */
55122
+ maximum;
55123
+ /**
55124
+ * The observed value: exact for `maxSlides` and for `maxInputBytes` on
55125
+ * `load()`; for `maxShapes`, and for `maxInputBytes` on `loadFromJson()`
55126
+ * (which stops counting once past the limit), a lower bound.
55127
+ */
55128
+ actual;
55129
+ constructor(message, limit, maximum, actual) {
55130
+ super(message);
55131
+ this.name = "PptxLoadLimitError";
55132
+ this.limit = limit;
55133
+ this.maximum = maximum;
55134
+ this.actual = actual;
55135
+ }
55136
+ };
55137
+ count = (value) => value.toLocaleString("en-US");
55138
+ }
55139
+ });
55140
+
54941
55141
  // pptx/core/builders/factories/ConnectorXmlFactory.ts
54942
55142
  var ConnectorXmlFactory;
54943
55143
  var init_ConnectorXmlFactory = __esm({
@@ -61352,7 +61552,7 @@ function parsedParagraphSignature(paragraph2) {
61352
61552
  return signatureOf(counts);
61353
61553
  }
61354
61554
  function signatureOf(counts) {
61355
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
61555
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
61356
61556
  }
61357
61557
  function collectParsedParagraphs2(root) {
61358
61558
  const result = [];
@@ -64699,23 +64899,23 @@ function classify(chars, index) {
64699
64899
  }
64700
64900
  function countParagraphWords(text2) {
64701
64901
  const chars = Array.from(text2);
64702
- let count = 0;
64902
+ let count2 = 0;
64703
64903
  let previous = "none";
64704
64904
  for (let index = 0; index < chars.length; index++) {
64705
64905
  const kind = classify(chars, index);
64706
64906
  if (kind === "space") {
64707
64907
  if (previous === "none" || previous === "control") {
64708
- count++;
64908
+ count2++;
64709
64909
  }
64710
64910
  previous = "space";
64711
64911
  continue;
64712
64912
  }
64713
64913
  if (kind === "ideograph" || kind === "control" || kind !== previous) {
64714
- count++;
64914
+ count2++;
64715
64915
  }
64716
64916
  previous = kind;
64717
64917
  }
64718
- return count;
64918
+ return count2;
64719
64919
  }
64720
64920
  var LINE_BREAK_CHAR, WORD_CHAR, DIGIT_CHAR, IDEOGRAPH_CHAR, SPACE_CHAR, WORD_JOINERS, NUMBER_JOINERS;
64721
64921
  var init_app_properties_word_count = __esm({
@@ -65253,6 +65453,96 @@ var init_background_fill_shapes = __esm({
65253
65453
  }
65254
65454
  });
65255
65455
 
65456
+ // pptx/core/core/runtime/load-part-reader.ts
65457
+ function parseText2(parser, text2) {
65458
+ return text2 ? parser.parse(text2) : void 0;
65459
+ }
65460
+ function readPartText(zip, path4) {
65461
+ const reader2 = openReaders.get(zip);
65462
+ if (reader2) {
65463
+ return reader2.readText(path4);
65464
+ }
65465
+ return zip.file(path4)?.async("string") ?? Promise.resolve(void 0);
65466
+ }
65467
+ async function readPartXml(zip, parser, path4) {
65468
+ const reader2 = openReaders.get(zip);
65469
+ if (reader2) {
65470
+ return reader2.readXml(parser, path4);
65471
+ }
65472
+ const text2 = await zip.file(path4)?.async("string");
65473
+ return text2 ? parseText2(parser, text2) : void 0;
65474
+ }
65475
+ var openReaders, LoadPartReader;
65476
+ var init_load_part_reader = __esm({
65477
+ "pptx/core/core/runtime/load-part-reader.ts"() {
65478
+ openReaders = /* @__PURE__ */ new WeakMap();
65479
+ LoadPartReader = class {
65480
+ constructor(zip) {
65481
+ this.zip = zip;
65482
+ openReaders.set(zip, this);
65483
+ }
65484
+ zip;
65485
+ parts = /* @__PURE__ */ new Map();
65486
+ closed = false;
65487
+ entry(path4) {
65488
+ const file = this.zip.file(path4);
65489
+ if (!file) {
65490
+ this.parts.delete(path4);
65491
+ return void 0;
65492
+ }
65493
+ const previous = this.parts.get(path4);
65494
+ if (previous?.file === file) {
65495
+ return previous;
65496
+ }
65497
+ const entry2 = { file, text: file.async("string"), relationships: /* @__PURE__ */ new Map() };
65498
+ this.parts.set(path4, entry2);
65499
+ entry2.text.catch(() => {
65500
+ if (this.parts.get(path4) === entry2) {
65501
+ this.parts.delete(path4);
65502
+ }
65503
+ });
65504
+ return entry2;
65505
+ }
65506
+ readText(path4) {
65507
+ return this.entry(path4)?.text ?? Promise.resolve(void 0);
65508
+ }
65509
+ async readXml(parser, path4) {
65510
+ const entry2 = this.entry(path4);
65511
+ if (!entry2) {
65512
+ return void 0;
65513
+ }
65514
+ if (!path4.endsWith(".rels")) {
65515
+ return parseText2(parser, await entry2.text);
65516
+ }
65517
+ let parsed = entry2.relationships.get(parser);
65518
+ if (!parsed) {
65519
+ const pending = entry2.text.then((text2) => parseText2(parser, text2));
65520
+ entry2.relationships.set(parser, pending);
65521
+ pending.catch(() => {
65522
+ if (entry2.relationships.get(parser) === pending) {
65523
+ entry2.relationships.delete(parser);
65524
+ }
65525
+ });
65526
+ parsed = pending;
65527
+ }
65528
+ return structuredClone(await parsed);
65529
+ }
65530
+ /** Whether this reader still serves reads for its package. */
65531
+ get isOpen() {
65532
+ return !this.closed;
65533
+ }
65534
+ /** Drops every cached read; later reads of the package go to the archive. */
65535
+ close() {
65536
+ this.closed = true;
65537
+ if (openReaders.get(this.zip) === this) {
65538
+ openReaders.delete(this.zip);
65539
+ }
65540
+ this.parts.clear();
65541
+ }
65542
+ };
65543
+ }
65544
+ });
65545
+
65256
65546
  // pptx/core/core/builders/element-hidden-flag.ts
65257
65547
  function findCNvPr(shape) {
65258
65548
  if (!shape) {
@@ -65326,11 +65616,10 @@ var init_flatten_elements = __esm({
65326
65616
 
65327
65617
  // pptx/core/utils/slide-synchronization.ts
65328
65618
  async function loadSlideSynchronization(input) {
65329
- const relsXml = await input.zip.file(input.relsPath)?.async("string");
65330
- if (!relsXml) {
65619
+ const relsData = await readPartXml(input.zip, input.parser, input.relsPath);
65620
+ if (!relsData) {
65331
65621
  return void 0;
65332
65622
  }
65333
- const relsData = input.parser.parse(relsXml);
65334
65623
  const relationship2 = findSlideSyncRelationship(relsData);
65335
65624
  if (!relationship2) {
65336
65625
  return void 0;
@@ -65340,7 +65629,7 @@ async function loadSlideSynchronization(input) {
65340
65629
  return void 0;
65341
65630
  }
65342
65631
  const partPath = resolvePartPath2(input.slidePath, target);
65343
- const partXml = await input.zip.file(partPath)?.async("string");
65632
+ const partXml = await readPartText(input.zip, partPath);
65344
65633
  if (!partXml) {
65345
65634
  return void 0;
65346
65635
  }
@@ -65461,6 +65750,7 @@ function nextSlideSyncPath(files) {
65461
65750
  var SLIDE_SYNC_CONTENT_TYPE;
65462
65751
  var init_slide_synchronization = __esm({
65463
65752
  "pptx/core/utils/slide-synchronization.ts"() {
65753
+ init_load_part_reader();
65464
65754
  SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
65465
65755
  }
65466
65756
  });
@@ -65474,11 +65764,10 @@ function ensureArray8(value) {
65474
65764
  }
65475
65765
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65476
65766
  try {
65477
- const relsXml = await zip.file(relsPath2)?.async("string");
65478
- if (!relsXml) {
65767
+ const relsData = await readPartXml(zip, parser, relsPath2);
65768
+ if (!relsData) {
65479
65769
  return [];
65480
65770
  }
65481
- const relsData = parser.parse(relsXml);
65482
65771
  const relationships3 = ensureArray8(
65483
65772
  relsData["Relationships"]?.["Relationship"]
65484
65773
  );
@@ -65501,7 +65790,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65501
65790
  if (!resolved) {
65502
65791
  continue;
65503
65792
  }
65504
- const vmlXml = await zip.file(resolved)?.async("string");
65793
+ const vmlXml = await readPartText(zip, resolved);
65505
65794
  if (!vmlXml) {
65506
65795
  continue;
65507
65796
  }
@@ -65520,6 +65809,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
65520
65809
  var VML_DRAWING_REL_SUFFIX;
65521
65810
  var init_vml_drawing_loader = __esm({
65522
65811
  "pptx/core/utils/vml-drawing-loader.ts"() {
65812
+ init_load_part_reader();
65523
65813
  init_safe_path();
65524
65814
  init_vml_parser();
65525
65815
  VML_DRAWING_REL_SUFFIX = "/relationships/vmlDrawing";
@@ -67526,10 +67816,10 @@ function assertAfterAnimationClearSupported(effectCTn) {
67526
67816
  if (!isXmlObject5(sub)) return;
67527
67817
  const countAfterFlags = (value) => {
67528
67818
  if (Array.isArray(value))
67529
- return value.reduce((count, child31) => count + countAfterFlags(child31), 0);
67819
+ return value.reduce((count2, child31) => count2 + countAfterFlags(child31), 0);
67530
67820
  if (!isXmlObject5(value)) return 0;
67531
67821
  return Object.entries(value).reduce(
67532
- (count, [key2, child31]) => count + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child31)) ? 1 : countAfterFlags(child31)),
67822
+ (count2, [key2, child31]) => count2 + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child31)) ? 1 : countAfterFlags(child31)),
67533
67823
  0
67534
67824
  );
67535
67825
  };
@@ -68027,6 +68317,7 @@ var PptxSlideLoaderService;
68027
68317
  var init_PptxSlideLoaderService = __esm({
68028
68318
  "pptx/core/services/PptxSlideLoaderService.ts"() {
68029
68319
  init_background_fill_shapes();
68320
+ init_load_part_reader();
68030
68321
  init_element_hidden_flag();
68031
68322
  init_background_style_ref();
68032
68323
  init_flatten_elements();
@@ -68087,11 +68378,14 @@ var init_PptxSlideLoaderService = __esm({
68087
68378
  * @returns Map of relationship ID to target path string.
68088
68379
  */
68089
68380
  async loadPresentationSlideRels(params) {
68090
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
68091
- if (!relsXml) {
68381
+ const relsData = await readPartXml(
68382
+ params.zip,
68383
+ params.parser,
68384
+ "ppt/_rels/presentation.xml.rels"
68385
+ );
68386
+ if (!relsData) {
68092
68387
  return /* @__PURE__ */ new Map();
68093
68388
  }
68094
- const relsData = params.parser.parse(relsXml);
68095
68389
  const relationships3 = relsData["Relationships"]?.["Relationship"];
68096
68390
  const relNodes = this.toXmlObjectArray(relationships3);
68097
68391
  const relsMap = /* @__PURE__ */ new Map();
@@ -68131,7 +68425,7 @@ var init_PptxSlideLoaderService = __esm({
68131
68425
  if (!params.zip.file(path4)) {
68132
68426
  path4 = `ppt/${target}`;
68133
68427
  }
68134
- const slideXmlStr = await params.zip.file(path4)?.async("string");
68428
+ const slideXmlStr = await readPartText(params.zip, path4);
68135
68429
  if (!slideXmlStr) {
68136
68430
  return void 0;
68137
68431
  }
@@ -89369,8 +89663,8 @@ function reorderContainer(node, rawInner) {
89369
89663
  if (isGroupedByTag(children16.map((child31) => child31.tag))) {
89370
89664
  return;
89371
89665
  }
89372
- for (const [tag, count] of occurrence) {
89373
- if (ensureItems(node[tag]).length !== count) {
89666
+ for (const [tag, count2] of occurrence) {
89667
+ if (ensureItems(node[tag]).length !== count2) {
89374
89668
  return;
89375
89669
  }
89376
89670
  }
@@ -89392,8 +89686,8 @@ function annotateOmmlSiblingOrder(xml, parsed) {
89392
89686
  return;
89393
89687
  }
89394
89688
  const nodes = collectParsedOmathNodes(parsed);
89395
- const count = Math.min(fragments.length, nodes.length);
89396
- for (let index = 0; index < count; index++) {
89689
+ const count2 = Math.min(fragments.length, nodes.length);
89690
+ for (let index = 0; index < count2; index++) {
89397
89691
  if (fragments[index]) {
89398
89692
  reorderContainer(nodes[index], fragments[index]);
89399
89693
  }
@@ -90533,6 +90827,180 @@ var init_eot_parser = __esm({
90533
90827
  }
90534
90828
  });
90535
90829
 
90830
+ // pptx/core/utils/deferred-embedded-font.ts
90831
+ function resolveEmbeddedFontGuid(source) {
90832
+ if (isEotFormat(source.originalPartBytes)) {
90833
+ return void 0;
90834
+ }
90835
+ const { fontKey } = source;
90836
+ const fromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
90837
+ return fromKey || extractGuidFromPartName(source.partPath) || void 0;
90838
+ }
90839
+ function hasSfntSignature(bytes) {
90840
+ if (bytes.length < 4) {
90841
+ return false;
90842
+ }
90843
+ const [v0, v1, v2, v3] = bytes;
90844
+ return v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0 || v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79 || v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102 || v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
90845
+ }
90846
+ function warnInvalidSignature(name, bytes) {
90847
+ const hex3 = Array.from(bytes.subarray(0, 4), (b) => b.toString(16)).join(",");
90848
+ console.warn(
90849
+ `[pptx-viewer] Embedded font "${name}" has invalid sfnt header [${hex3}] after processing; skipping (web font fallback will be used)`
90850
+ );
90851
+ }
90852
+ function isEmbeddedFontPartPlausible(source) {
90853
+ const bytes = source.originalPartBytes;
90854
+ if (bytes.length === 0) {
90855
+ return false;
90856
+ }
90857
+ if (isEotFormat(bytes)) {
90858
+ return true;
90859
+ }
90860
+ const guid = resolveEmbeddedFontGuid(source);
90861
+ if (!guid) {
90862
+ console.warn(
90863
+ `[pptx-viewer] Embedded font "${source.name}" at "${source.partPath}" has no fontKey attribute and no GUID in filename; skipping`
90864
+ );
90865
+ return false;
90866
+ }
90867
+ const header = deobfuscateFont(bytes.subarray(0, Math.min(bytes.length, 32)), guid);
90868
+ if (header.length < 4) {
90869
+ return false;
90870
+ }
90871
+ if (!hasSfntSignature(header)) {
90872
+ warnInvalidSignature(source.name, header);
90873
+ return false;
90874
+ }
90875
+ return true;
90876
+ }
90877
+ function uint8ArrayToBase64(bytes) {
90878
+ let binary = "";
90879
+ const chunkSize = 8192;
90880
+ for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
90881
+ const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
90882
+ for (let j = 0; j < chunk2.length; j++) {
90883
+ binary += String.fromCharCode(chunk2[j]);
90884
+ }
90885
+ }
90886
+ return btoa(binary);
90887
+ }
90888
+ function decodeEmbeddedFontPart(source) {
90889
+ const { name, partPath, originalPartBytes } = source;
90890
+ try {
90891
+ let fontData;
90892
+ const fontGuid = resolveEmbeddedFontGuid(source);
90893
+ if (isEotFormat(originalPartBytes)) {
90894
+ const extracted = extractFontFromEot(originalPartBytes);
90895
+ if (!extracted) {
90896
+ const header = parseEotHeader(originalPartBytes);
90897
+ console.info(
90898
+ `[pptx-viewer] Embedded font "${name}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""}; extraction failed, will use web font fallback`
90899
+ );
90900
+ return null;
90901
+ }
90902
+ fontData = extracted.fontData;
90903
+ } else if (fontGuid) {
90904
+ fontData = deobfuscateFont(originalPartBytes, fontGuid);
90905
+ } else {
90906
+ console.warn(
90907
+ `[pptx-viewer] Embedded font "${name}" at "${partPath}" has no fontKey attribute and no GUID in filename; skipping`
90908
+ );
90909
+ return null;
90910
+ }
90911
+ if (fontData.length < 4) {
90912
+ return null;
90913
+ }
90914
+ if (!hasSfntSignature(fontData)) {
90915
+ warnInvalidSignature(name, fontData);
90916
+ return null;
90917
+ }
90918
+ const format = detectFontFormat(fontData);
90919
+ const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
90920
+ return {
90921
+ name,
90922
+ dataUrl: `data:${mimeType};base64,${uint8ArrayToBase64(fontData)}`,
90923
+ bold: source.bold,
90924
+ italic: source.italic,
90925
+ format,
90926
+ rawFontData: fontData,
90927
+ partPath,
90928
+ fontGuid,
90929
+ originalRId: source.originalRId,
90930
+ originalPartBytes
90931
+ };
90932
+ } catch {
90933
+ return null;
90934
+ }
90935
+ }
90936
+ function createDeferredEmbeddedFont(source) {
90937
+ const fontGuid = resolveEmbeddedFontGuid(source);
90938
+ let fields;
90939
+ let pending;
90940
+ const decode = () => {
90941
+ if (!fields) {
90942
+ const decoded = decodeEmbeddedFontPart(source);
90943
+ fields = {
90944
+ dataUrl: decoded?.dataUrl ?? "",
90945
+ format: decoded?.format,
90946
+ rawFontData: decoded?.rawFontData
90947
+ };
90948
+ }
90949
+ return fields;
90950
+ };
90951
+ const font = {
90952
+ name: source.name,
90953
+ get dataUrl() {
90954
+ return decode().dataUrl;
90955
+ },
90956
+ set dataUrl(value) {
90957
+ decode().dataUrl = value;
90958
+ },
90959
+ bold: source.bold,
90960
+ italic: source.italic,
90961
+ get format() {
90962
+ return decode().format;
90963
+ },
90964
+ set format(value) {
90965
+ decode().format = value;
90966
+ },
90967
+ get rawFontData() {
90968
+ return decode().rawFontData;
90969
+ },
90970
+ set rawFontData(value) {
90971
+ decode().rawFontData = value;
90972
+ },
90973
+ partPath: source.partPath,
90974
+ fontGuid,
90975
+ originalRId: source.originalRId,
90976
+ originalPartBytes: source.originalPartBytes
90977
+ };
90978
+ Object.defineProperties(font, {
90979
+ load: {
90980
+ value: () => pending ??= Promise.resolve().then(
90981
+ () => decode().rawFontData?.length || decode().dataUrl ? font : null
90982
+ )
90983
+ },
90984
+ isLoaded: { get: () => fields !== void 0 }
90985
+ });
90986
+ return font;
90987
+ }
90988
+ function shouldSaveEmbeddedFontVerbatim(font) {
90989
+ if (font.isLoaded === void 0 || !font.originalPartBytes?.length) {
90990
+ return false;
90991
+ }
90992
+ if (!font.originalRId || !font.partPath) {
90993
+ return false;
90994
+ }
90995
+ return font.isLoaded === false || !font.rawFontData?.length;
90996
+ }
90997
+ var init_deferred_embedded_font = __esm({
90998
+ "pptx/core/utils/deferred-embedded-font.ts"() {
90999
+ init_eot_parser();
91000
+ init_font_deobfuscation();
91001
+ }
91002
+ });
91003
+
90536
91004
  // pptx/core/core/runtime/header-footer-parts.ts
90537
91005
  function asArray3(value) {
90538
91006
  if (Array.isArray(value)) {
@@ -92320,12 +92788,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
92320
92788
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
92321
92789
  const target = resolve2(chartPartPath, external.targetPath);
92322
92790
  let references = 0;
92323
- const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
92324
92791
  try {
92325
92792
  for (const path4 of Object.keys(zip.files)) {
92326
92793
  if (!path4.endsWith(".rels") || !path4.includes("/_rels/")) continue;
92327
92794
  const source = path4.replace("/_rels/", "/").slice(0, -5);
92328
- const tree = parser.parse(await zip.file(path4).async("string"));
92795
+ const tree = await readPartXml(zip, relationshipParser, path4);
92329
92796
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
92330
92797
  const relationshipTarget2 = xmlAttr(rel, "Target");
92331
92798
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve2(source, relationshipTarget2) === target)
@@ -92342,11 +92809,14 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
92342
92809
  return false;
92343
92810
  }
92344
92811
  }
92812
+ var relationshipParser;
92345
92813
  var init_chart_label_source = __esm({
92346
92814
  "pptx/core/utils/chart-label-source.ts"() {
92815
+ init_load_part_reader();
92347
92816
  init_chart_xlsx_writer();
92348
92817
  init_xml_access();
92349
92818
  init_chart_xlsx_cellref();
92819
+ relationshipParser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
92350
92820
  }
92351
92821
  });
92352
92822
 
@@ -92573,10 +93043,10 @@ function collectFilteredSeriesIndices(container2, xmlLookup) {
92573
93043
  }
92574
93044
  return reserved;
92575
93045
  }
92576
- function assignSeriesIndices(count, reservedIndices) {
93046
+ function assignSeriesIndices(count2, reservedIndices) {
92577
93047
  const assigned = [];
92578
93048
  let cursor = 0;
92579
- for (let i2 = 0; i2 < count; i2++) {
93049
+ for (let i2 = 0; i2 < count2; i2++) {
92580
93050
  while (reservedIndices.has(cursor)) {
92581
93051
  cursor++;
92582
93052
  }
@@ -93265,8 +93735,8 @@ function parseCache(node) {
93265
93735
  return point2;
93266
93736
  })
93267
93737
  };
93268
- const count = Number(cVal(node, "ptCount") ?? Number.NaN);
93269
- if (Number.isInteger(count) && count >= 0) cache.pointCount = count;
93738
+ const count2 = Number(cVal(node, "ptCount") ?? Number.NaN);
93739
+ if (Number.isInteger(count2) && count2 >= 0) cache.pointCount = count2;
93270
93740
  const formatCode2 = cChild(node, "formatCode")?.textContent;
93271
93741
  if (formatCode2) cache.formatCode = formatCode2;
93272
93742
  return cache;
@@ -93284,8 +93754,8 @@ function parseDataSource(element) {
93284
93754
  const levels = cChild(ref, "multiLvlStrCache");
93285
93755
  if (levels) {
93286
93756
  source.levels = children2(levels, "lvl", NS.c).map(parseCache);
93287
- const count = Number(cVal(levels, "ptCount") ?? Number.NaN);
93288
- if (Number.isInteger(count) && count >= 0) source.levelPointCount = count;
93757
+ const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
93758
+ if (Number.isInteger(count2) && count2 >= 0) source.levelPointCount = count2;
93289
93759
  }
93290
93760
  return source;
93291
93761
  }
@@ -94852,7 +95322,7 @@ function parseChartData(context, element) {
94852
95322
  }
94853
95323
  return out;
94854
95324
  }
94855
- function parseText2(context, element) {
95325
+ function parseText3(context, element) {
94856
95326
  if (!element) return void 0;
94857
95327
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
94858
95328
  const data = cxChild(element, "txData");
@@ -94872,7 +95342,7 @@ function parseTitle2(context, element) {
94872
95342
  return assignDefined(
94873
95343
  {},
94874
95344
  {
94875
- tx: parseText2(context, cxChild(element, "tx")),
95345
+ tx: parseText3(context, cxChild(element, "tx")),
94876
95346
  spPr: shapeProperties2(element),
94877
95347
  txPr: textProperties2(element),
94878
95348
  position: attribute4(element, "pos"),
@@ -95117,7 +95587,7 @@ function parseSeries2(context, element) {
95117
95587
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
95118
95588
  uniqueId: attribute4(element, "uniqueId"),
95119
95589
  formatIndex: numberAttribute(context, element, "formatIdx"),
95120
- tx: parseText2(context, cxChild(element, "tx")),
95590
+ tx: parseText3(context, cxChild(element, "tx")),
95121
95591
  spPr: shapeProperties2(element),
95122
95592
  txPr: textProperties2(element),
95123
95593
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -102939,9 +103409,9 @@ function buildFopt(simple, complex = []) {
102939
103409
  payload.bytes(bytes);
102940
103410
  }
102941
103411
  }
102942
- const count = simple.length + complex.length;
103412
+ const count2 = simple.length + complex.length;
102943
103413
  const data = new ByteWriter().append(entries).append(payload).toBytes();
102944
- return record(OA.FOPT, data, count, false, 3);
103414
+ return record(OA.FOPT, data, count2, false, 3);
102945
103415
  }
102946
103416
  function buildMetroBlobTertiaryFopt(metroBlob) {
102947
103417
  const data = new ByteWriter().u16(METRO_BLOB_OPID | 32768 | FBID_FLAG).u32(metroBlob.length >>> 0).bytes(metroBlob).toBytes();
@@ -103005,9 +103475,9 @@ function buildDgg(shapesPerDrawing, totalShapes) {
103005
103475
  const cidcl = drawingCount + 1;
103006
103476
  const cspSaved = totalShapes - drawingCount;
103007
103477
  const w = new ByteWriter().u32(maxShapeId).u32(cidcl).u32(cspSaved).u32(drawingCount);
103008
- shapesPerDrawing.forEach((count, i2) => {
103478
+ shapesPerDrawing.forEach((count2, i2) => {
103009
103479
  const drawingId = i2 + 1;
103010
- w.u32(drawingId).u32(count);
103480
+ w.u32(drawingId).u32(count2);
103011
103481
  });
103012
103482
  return record(OA.Dgg, w.toBytes(), 0, false, 0);
103013
103483
  }
@@ -103835,8 +104305,8 @@ function atom(recType, data) {
103835
104305
  function textHeader(textType) {
103836
104306
  return atom(RT.TextHeaderAtom, new ByteWriter().u32(textType).toBytes());
103837
104307
  }
103838
- function textSpecInfo(count) {
103839
- return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count).u32(1).u16(0).toBytes());
104308
+ function textSpecInfo(count2) {
104309
+ return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count2).u32(1).u16(0).toBytes());
103840
104310
  }
103841
104311
  function promptText(textType, paragraphs) {
103842
104312
  const text2 = paragraphs.join("\r");
@@ -104647,17 +105117,17 @@ function slideMasterIndex(masterIndex, masterCount) {
104647
105117
  return masterIndex !== void 0 && Number.isInteger(masterIndex) && masterIndex >= 0 && masterIndex < masterCount ? masterIndex : 0;
104648
105118
  }
104649
105119
  function countDrawingShapes(shapes) {
104650
- let count = 1;
105120
+ let count2 = 1;
104651
105121
  const walk3 = (list3) => {
104652
105122
  for (const shape of list3) {
104653
- count++;
105123
+ count2++;
104654
105124
  if (shape.kind === "group") {
104655
105125
  walk3(shape.children);
104656
105126
  }
104657
105127
  }
104658
105128
  };
104659
105129
  walk3(shapes);
104660
- return count;
105130
+ return count2;
104661
105131
  }
104662
105132
  function collectFonts(deck, masters) {
104663
105133
  const collect = (shape) => {
@@ -105238,7 +105708,7 @@ function toLevel(style = {}, themeFonts = {}) {
105238
105708
  }
105239
105709
  };
105240
105710
  }
105241
- function toLevels(levels, count, themeFonts) {
105711
+ function toLevels(levels, count2, themeFonts) {
105242
105712
  if (!levels) {
105243
105713
  return void 0;
105244
105714
  }
@@ -105248,7 +105718,7 @@ function toLevels(levels, count, themeFonts) {
105248
105718
  }
105249
105719
  const base = levels[-1];
105250
105720
  return Array.from(
105251
- { length: count },
105721
+ { length: count2 },
105252
105722
  (_, i2) => toLevel(base || levels[i2] ? { ...base, ...levels[i2] } : void 0, themeFonts)
105253
105723
  );
105254
105724
  }
@@ -106157,12 +106627,12 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
106157
106627
  }
106158
106628
  if (Array.isArray(node)) {
106159
106629
  return node.reduce(
106160
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
106630
+ (count3, entry2) => count3 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
106161
106631
  0
106162
106632
  );
106163
106633
  }
106164
106634
  const object = node;
106165
- let count = 0;
106635
+ let count2 = 0;
106166
106636
  for (const key2 of Object.keys(object)) {
106167
106637
  if (key2.startsWith("@_")) {
106168
106638
  continue;
@@ -106174,14 +106644,14 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
106174
106644
  const chart = chartKey ? candidate[chartKey] : void 0;
106175
106645
  if (chart && String(chart["@_r:id"]) === relationshipId2) {
106176
106646
  rebindGraphicData(candidate, relationshipId2, extended);
106177
- count += 1;
106647
+ count2 += 1;
106178
106648
  }
106179
106649
  }
106180
106650
  continue;
106181
106651
  }
106182
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
106652
+ count2 += visitGraphicData(value, relationshipId2, extended, getLocalName2);
106183
106653
  }
106184
- return count;
106654
+ return count2;
106185
106655
  }
106186
106656
  async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
106187
106657
  const xml = await deps.zip.file(slidePath)?.async("string");
@@ -106189,11 +106659,11 @@ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, exten
106189
106659
  return 0;
106190
106660
  }
106191
106661
  const tree = deps.parser.parse(xml);
106192
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
106193
- if (count > 0) {
106662
+ const count2 = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
106663
+ if (count2 > 0) {
106194
106664
  deps.zip.file(slidePath, deps.builder.build(tree));
106195
106665
  }
106196
- return count;
106666
+ return count2;
106197
106667
  }
106198
106668
  var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
106199
106669
  var init_chart_part_registration = __esm({
@@ -108668,8 +109138,8 @@ async function discoverTagCollections(zip, codec) {
108668
109138
  if (!sourcePartPath) {
108669
109139
  continue;
108670
109140
  }
108671
- const data = codec.parse(await relFile.async("string"));
108672
- const root = data["Relationships"];
109141
+ const data = await readPartXml(zip, codec, relFile.name);
109142
+ const root = data?.["Relationships"];
108673
109143
  for (const relationship2 of ensureArray16(root?.["Relationship"])) {
108674
109144
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
108675
109145
  continue;
@@ -108774,7 +109244,7 @@ async function removeTagContentTypeOverride(zip, codec, path4) {
108774
109244
  zip.file("[Content_Types].xml", codec.build(data));
108775
109245
  }
108776
109246
  async function readTagCollection(zip, codec, path4) {
108777
- const xml = await zip.file(path4)?.async("string");
109247
+ const xml = await readPartText(zip, path4);
108778
109248
  if (!xml) {
108779
109249
  return void 0;
108780
109250
  }
@@ -108883,6 +109353,7 @@ function ensureArray16(value) {
108883
109353
  var TAG_RELATIONSHIP_TYPE, TAG_CONTENT_TYPE;
108884
109354
  var init_tag_package = __esm({
108885
109355
  "pptx/core/utils/tag-package.ts"() {
109356
+ init_load_part_reader();
108886
109357
  init_safe_path();
108887
109358
  init_tag_package_owning_element();
108888
109359
  TAG_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags";
@@ -113249,10 +113720,35 @@ var init_PptxHandlerRuntimeState = __esm({
113249
113720
  "pptx/core/core/runtime/PptxHandlerRuntimeState.ts"() {
113250
113721
  init_utils();
113251
113722
  init_part_rels_path();
113723
+ init_load_part_reader();
113252
113724
  init_template_element_baselines();
113253
113725
  PptxHandlerRuntime = class {
113254
113726
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
113255
113727
  zip;
113728
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
113729
+ loadPartReader;
113730
+ /** Opens a part reader for the current package, closing any earlier one. */
113731
+ beginPartReads() {
113732
+ this.endPartReads();
113733
+ const reader2 = new LoadPartReader(this.zip);
113734
+ this.loadPartReader = reader2;
113735
+ return reader2;
113736
+ }
113737
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
113738
+ endPartReads(reader2 = this.loadPartReader) {
113739
+ reader2?.close();
113740
+ if (reader2 && this.loadPartReader === reader2) {
113741
+ this.loadPartReader = void 0;
113742
+ }
113743
+ }
113744
+ /** The text of a package part, shared within a load. */
113745
+ readPartText(path4) {
113746
+ return readPartText(this.zip, path4);
113747
+ }
113748
+ /** A parsed package part; relationship parts are parsed once per load. */
113749
+ readPartXml(path4) {
113750
+ return readPartXml(this.zip, this.parser, path4);
113751
+ }
113256
113752
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
113257
113753
  parser;
113258
113754
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -113516,6 +114012,8 @@ var init_PptxHandlerRuntimeState = __esm({
113516
114012
  alternateContentBlockByRawXml = /* @__PURE__ */ new WeakMap();
113517
114013
  /** Embedded fonts extracted during load, preserved for automatic re-embedding on save. */
113518
114014
  loadedEmbeddedFonts = [];
114015
+ /** Decode every embedded font variant during load (see `PptxHandlerLoadOptions`). */
114016
+ eagerDecodeEmbeddedFonts = false;
113519
114017
  /** Typed source metadata for lossless embedded-font list round trips. */
113520
114018
  loadedEmbeddedFontList;
113521
114019
  /**
@@ -113671,11 +114169,11 @@ var init_PptxHandlerRuntimeState = __esm({
113671
114169
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
113672
114170
  */
113673
114171
  async loadPartRelationships(partPath, relsPath2) {
113674
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
113675
- if (!relsXml) {
114172
+ const path4 = relsPath2 ?? partRelsPath(partPath);
114173
+ const relsData = await this.readPartXml(path4);
114174
+ if (!relsData) {
113676
114175
  return;
113677
114176
  }
113678
- const relsData = this.parser.parse(relsXml);
113679
114177
  const relationships3 = relsData?.["Relationships"];
113680
114178
  const raw2 = relationships3?.["Relationship"];
113681
114179
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -115204,10 +115702,6 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115204
115702
  this.zip.file(relsPath2, this.builder.build(relsData));
115205
115703
  return true;
115206
115704
  }
115207
- /** The text of a package part, or `undefined` when the package has no such part. */
115208
- async readPartText(path4) {
115209
- return this.zip.file(path4)?.async("string");
115210
- }
115211
115705
  /**
115212
115706
  * Parse extended (application) properties from `docProps/app.xml`.
115213
115707
  */
@@ -115268,8 +115762,10 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115268
115762
  if (!relsFile) {
115269
115763
  return [];
115270
115764
  }
115271
- const relsXml = await relsFile.async("string");
115272
- const relsData = this.parser.parse(relsXml);
115765
+ const relsData = await this.readPartXml(relsPath2);
115766
+ if (!relsData) {
115767
+ return [];
115768
+ }
115273
115769
  const relRoot = relsData["Relationships"] || {};
115274
115770
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
115275
115771
  const relMap = /* @__PURE__ */ new Map();
@@ -115300,7 +115796,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115300
115796
  try {
115301
115797
  const file = this.zip.file(resolvedPath);
115302
115798
  if (file) {
115303
- data = await file.async("string");
115799
+ data = await this.readPartText(resolvedPath);
115304
115800
  }
115305
115801
  } catch {
115306
115802
  }
@@ -115380,9 +115876,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115380
115876
  */
115381
115877
  async parseTags() {
115382
115878
  try {
115383
- return await discoverTagCollections(this.zip, {
115384
- parse: (xml) => this.parser.parse(xml)
115385
- });
115879
+ return await discoverTagCollections(this.zip, this.parser);
115386
115880
  } catch (e) {
115387
115881
  console.warn("Failed to parse tags:", e);
115388
115882
  return [];
@@ -115522,7 +116016,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115522
116016
  }
115523
116017
  for (const file of masterFiles) {
115524
116018
  const path4 = file.name;
115525
- const xml = await file.async("string");
116019
+ const xml = await this.readPartText(path4) ?? "";
115526
116020
  const data = this.parser.parse(xml);
115527
116021
  const sldMaster = data?.["p:sldMaster"];
115528
116022
  if (!sldMaster) {
@@ -115547,8 +116041,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115547
116041
  );
115548
116042
  const relsFile = this.zip.file(relsPath2);
115549
116043
  if (relsFile) {
115550
- const relsXml = await relsFile.async("string");
115551
- const relsData = this.parser.parse(relsXml);
116044
+ const relsData = await this.readPartXml(relsPath2);
115552
116045
  const rels = this.ensureArray(
115553
116046
  xmlChild(relsData, "Relationships")?.["Relationship"]
115554
116047
  );
@@ -115562,8 +116055,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115562
116055
  }
115563
116056
  const layoutPaths = [];
115564
116057
  if (relsFile) {
115565
- const relsXml = await relsFile.async("string");
115566
- const relsData = this.parser.parse(relsXml);
116058
+ const relsData = await this.readPartXml(relsPath2);
115567
116059
  const rels = this.ensureArray(
115568
116060
  xmlChild(relsData, "Relationships")?.["Relationship"]
115569
116061
  );
@@ -115607,7 +116099,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115607
116099
  return void 0;
115608
116100
  }
115609
116101
  const path4 = files[0].name;
115610
- const xml = await files[0].async("string");
116102
+ const xml = await this.readPartText(path4) ?? "";
115611
116103
  const data = this.parser.parse(xml);
115612
116104
  const master = data?.["p:handoutMaster"];
115613
116105
  if (!master) {
@@ -115639,7 +116131,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115639
116131
  return void 0;
115640
116132
  }
115641
116133
  const path4 = files[0].name;
115642
- const xml = await files[0].async("string");
116134
+ const xml = await this.readPartText(path4) ?? "";
115643
116135
  const data = this.parser.parse(xml);
115644
116136
  const master = data?.["p:notesMaster"];
115645
116137
  if (!master) {
@@ -115670,7 +116162,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115670
116162
  if (!layoutFile) {
115671
116163
  return void 0;
115672
116164
  }
115673
- const xml = await layoutFile.async("string");
116165
+ const xml = await this.readPartText(layoutPath) ?? "";
115674
116166
  const data = this.parser.parse(xml);
115675
116167
  const sldLayout = data?.["p:sldLayout"];
115676
116168
  if (!sldLayout) {
@@ -115778,18 +116270,19 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
115778
116270
  */
115779
116271
  async parsePresentationProperties() {
115780
116272
  try {
115781
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
115782
- if (!relsXml) {
116273
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
116274
+ if (!relsData) {
115783
116275
  return void 0;
115784
116276
  }
115785
- const relsData = this.parser.parse(relsXml);
115786
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
116277
+ const rels = this.ensureArray(
116278
+ relsData.Relationships?.Relationship
116279
+ );
115787
116280
  const prRel = rels.find(
115788
116281
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
115789
116282
  );
115790
116283
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
115791
116284
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
115792
- const prXmlStr = await this.zip.file(prPath)?.async("string");
116285
+ const prXmlStr = await this.readPartText(prPath);
115793
116286
  if (!prXmlStr) {
115794
116287
  return void 0;
115795
116288
  }
@@ -115835,7 +116328,7 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
115835
116328
  */
115836
116329
  async parseViewProperties() {
115837
116330
  try {
115838
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
116331
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
115839
116332
  if (!viewPropsXml2) {
115840
116333
  return void 0;
115841
116334
  }
@@ -118340,10 +118833,10 @@ function detectDominantScript(text2) {
118340
118833
  }
118341
118834
  let best;
118342
118835
  let bestCount = 0;
118343
- for (const [cat, count] of Object.entries(counts)) {
118344
- if (count > bestCount) {
118836
+ for (const [cat, count2] of Object.entries(counts)) {
118837
+ if (count2 > bestCount) {
118345
118838
  best = cat;
118346
- bestCount = count;
118839
+ bestCount = count2;
118347
118840
  }
118348
118841
  }
118349
118842
  return best;
@@ -120299,7 +120792,7 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
120299
120792
  if (existingRel?.target) {
120300
120793
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
120301
120794
  try {
120302
- const xml = await this.zip.file(drawingPath)?.async("string");
120795
+ const xml = await this.readPartText(drawingPath);
120303
120796
  if (xml) {
120304
120797
  const root = this.parser.parse(xml);
120305
120798
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -120350,11 +120843,10 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
120350
120843
  const slash = chartPartPath.lastIndexOf("/");
120351
120844
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
120352
120845
  try {
120353
- const xml = await this.zip.file(relsPath2)?.async("string");
120354
- if (!xml) {
120846
+ const tree = await this.readPartXml(relsPath2);
120847
+ if (!tree) {
120355
120848
  return void 0;
120356
120849
  }
120357
- const tree = this.parser.parse(xml);
120358
120850
  const root = tree["Relationships"];
120359
120851
  const rels = root?.["Relationship"];
120360
120852
  const list3 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -123346,6 +123838,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123346
123838
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveDocumentParts.ts"() {
123347
123839
  init_utils();
123348
123840
  init_customer_data_package();
123841
+ init_deferred_embedded_font();
123349
123842
  init_embedded_font_list();
123350
123843
  init_font_deobfuscation();
123351
123844
  init_safe_path();
@@ -123807,7 +124300,9 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123807
124300
  return;
123808
124301
  }
123809
124302
  const fonts = explicitFonts ?? this.loadedEmbeddedFonts;
123810
- const fontsWithData = fonts.filter((f6) => f6.rawFontData && f6.rawFontData.length > 0);
124303
+ const fontsWithData = fonts.filter(
124304
+ (f6) => shouldSaveEmbeddedFontVerbatim(f6) || f6.rawFontData && f6.rawFontData.length > 0
124305
+ );
123811
124306
  if (fontsWithData.length === 0) {
123812
124307
  const metadata = explicitFontList ?? this.loadedEmbeddedFontList;
123813
124308
  if (metadata && this.presentationData) {
@@ -123850,10 +124345,11 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
123850
124345
  "p:font": { "@_typeface": typeface }
123851
124346
  };
123852
124347
  for (const variant of variants) {
123853
- const fontData = variant.rawFontData;
124348
+ const verbatim = shouldSaveEmbeddedFontVerbatim(variant);
124349
+ const fontData = verbatim ? void 0 : variant.rawFontData;
123854
124350
  const hasOriginal = Boolean(variant.originalRId && variant.partPath);
123855
- const reuseObfuscation = hasOriginal && Boolean(variant.fontGuid);
123856
- const reuseVerbatim = hasOriginal && !variant.fontGuid && Boolean(variant.originalPartBytes);
124351
+ const reuseObfuscation = hasOriginal && !verbatim && Boolean(variant.fontGuid);
124352
+ const reuseVerbatim = hasOriginal && (verbatim || !variant.fontGuid) && Boolean(variant.originalPartBytes);
123857
124353
  let guid;
123858
124354
  let fontPartPath;
123859
124355
  let relativeTarget4;
@@ -127469,13 +127965,13 @@ function countDeclaredIds(node, counts, ensureArray19) {
127469
127965
  if (!countDeclaredIds(branch, branchCounts, ensureArray19)) {
127470
127966
  return false;
127471
127967
  }
127472
- for (const [id, count] of branchCounts) {
127473
- merged.set(id, Math.max(merged.get(id) ?? 0, count));
127968
+ for (const [id, count2] of branchCounts) {
127969
+ merged.set(id, Math.max(merged.get(id) ?? 0, count2));
127474
127970
  }
127475
127971
  }
127476
127972
  }
127477
- for (const [id, count] of merged) {
127478
- counts.set(id, (counts.get(id) ?? 0) + count);
127973
+ for (const [id, count2] of merged) {
127974
+ counts.set(id, (counts.get(id) ?? 0) + count2);
127479
127975
  }
127480
127976
  }
127481
127977
  return true;
@@ -127485,8 +127981,8 @@ function hasStructuralIdDefects(spTree, ensureArray19) {
127485
127981
  if (!countDeclaredIds(spTree, counts, ensureArray19)) {
127486
127982
  return true;
127487
127983
  }
127488
- for (const count of counts.values()) {
127489
- if (count > 1) {
127984
+ for (const count2 of counts.values()) {
127985
+ if (count2 > 1) {
127490
127986
  return true;
127491
127987
  }
127492
127988
  }
@@ -135730,7 +136226,7 @@ var init_PptxHandlerRuntimeSlideParsing = __esm({
135730
136226
  this.unwrapAlternateContent(spTree);
135731
136227
  let rawXmlStr;
135732
136228
  try {
135733
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
136229
+ rawXmlStr = await this.readPartText(slidePath);
135734
136230
  } catch {
135735
136231
  }
135736
136232
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -136299,7 +136795,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
136299
136795
  if (cached) {
136300
136796
  return cached;
136301
136797
  }
136302
- const xml = await this.zip.file(layoutPath)?.async("string");
136798
+ const xml = await this.readPartText(layoutPath);
136303
136799
  if (!xml) {
136304
136800
  return void 0;
136305
136801
  }
@@ -136313,7 +136809,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
136313
136809
  if (cached) {
136314
136810
  return cached;
136315
136811
  }
136316
- const xml = await this.zip.file(masterPath)?.async("string");
136812
+ const xml = await this.readPartText(masterPath);
136317
136813
  if (!xml) {
136318
136814
  return void 0;
136319
136815
  }
@@ -136773,7 +137269,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
136773
137269
  if (!notesPath) {
136774
137270
  return {};
136775
137271
  }
136776
- const notesXml = await this.zip.file(notesPath)?.async("string");
137272
+ const notesXml = await this.readPartText(notesPath);
136777
137273
  if (!notesXml) {
136778
137274
  return {};
136779
137275
  }
@@ -137272,7 +137768,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
137272
137768
  try {
137273
137769
  let masterXmlObj = this.masterXmlMap.get(master.path);
137274
137770
  if (!masterXmlObj) {
137275
- const xmlStr = await this.zip.file(master.path)?.async("string");
137771
+ const xmlStr = await this.readPartText(master.path);
137276
137772
  if (!xmlStr) {
137277
137773
  continue;
137278
137774
  }
@@ -137345,7 +137841,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
137345
137841
  }
137346
137842
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
137347
137843
  try {
137348
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
137844
+ const masterXmlStr = await this.readPartText(masterPath);
137349
137845
  if (!masterXmlStr) {
137350
137846
  return [];
137351
137847
  }
@@ -137507,7 +138003,7 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
137507
138003
  }
137508
138004
  const partPath = part.path;
137509
138005
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
137510
- const xml = await this.zip.file(partPath)?.async("string");
138006
+ const xml = await this.readPartText(partPath);
137511
138007
  if (!xml) {
137512
138008
  return;
137513
138009
  }
@@ -137667,7 +138163,7 @@ var init_PptxHandlerRuntimeLayoutElements = __esm({
137667
138163
  }
137668
138164
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
137669
138165
  try {
137670
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
138166
+ const layoutXmlStr = await this.readPartText(layoutPath);
137671
138167
  if (!layoutXmlStr) {
137672
138168
  return [];
137673
138169
  }
@@ -138401,7 +138897,7 @@ var init_PptxHandlerRuntimeThemeOverrides = __esm({
138401
138897
  return cached;
138402
138898
  }
138403
138899
  try {
138404
- const overrideXml = await this.zip.file(overridePath)?.async("string");
138900
+ const overrideXml = await this.readPartText(overridePath);
138405
138901
  if (!overrideXml) {
138406
138902
  return null;
138407
138903
  }
@@ -139030,10 +139526,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139030
139526
  if (!relsXml) {
139031
139527
  return void 0;
139032
139528
  }
139033
- const relsData = this.parser.parse(
139034
- // eslint-disable-next-line no-await-in-loop
139035
- await relsXml.async("string")
139036
- );
139529
+ const relsData = await this.readPartXml(relsPath2);
139037
139530
  const relNodes = this.ensureArray(
139038
139531
  relsData?.Relationships?.Relationship
139039
139532
  );
@@ -139059,7 +139552,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139059
139552
  const options = [];
139060
139553
  for (const file of themeFiles) {
139061
139554
  try {
139062
- const xml = await file.async("string");
139555
+ const xml = await this.readPartText(file.name) ?? "";
139063
139556
  const data = this.parser.parse(xml);
139064
139557
  const root = data["a:theme"];
139065
139558
  const name = String(root?.["@_name"] || "").trim();
@@ -139139,7 +139632,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139139
139632
  ];
139140
139633
  for (const file of masterFiles) {
139141
139634
  try {
139142
- const masterXml = await file.async("string");
139635
+ const masterXml = await this.readPartText(file.name) ?? "";
139143
139636
  const masterData = this.parser.parse(masterXml);
139144
139637
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
139145
139638
  if (!clrMap) {
@@ -139172,7 +139665,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139172
139665
  if (!themeFile) {
139173
139666
  return null;
139174
139667
  }
139175
- const themeXml3 = await themeFile.async("string");
139668
+ const themeXml3 = await this.readPartText(themePath) ?? "";
139176
139669
  const model = this.parseThemePartXml(themeXml3);
139177
139670
  this.cacheThemePartModel(themePath, themeXml3, model);
139178
139671
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -139207,7 +139700,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
139207
139700
  if (!relsXml) {
139208
139701
  return void 0;
139209
139702
  }
139210
- const relsData = this.parser.parse(await relsXml.async("string"));
139703
+ const relsData = await this.readPartXml(relsPath2);
139211
139704
  const relNodes = this.ensureArray(
139212
139705
  relsData?.Relationships?.Relationship
139213
139706
  );
@@ -139536,11 +140029,10 @@ var init_PptxHandlerRuntimeComments = __esm({
139536
140029
  async extractModernSlideComments(slidePath) {
139537
140030
  try {
139538
140031
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
139539
- const relsXml = await this.zip.file(relsPath2)?.async("string");
139540
- if (!relsXml) {
140032
+ const relsData = await this.readPartXml(relsPath2);
140033
+ if (!relsData) {
139541
140034
  return [];
139542
140035
  }
139543
- const relsData = this.parser.parse(relsXml);
139544
140036
  const rels = this.ensureArray(
139545
140037
  xmlChild(relsData, "Relationships")?.Relationship
139546
140038
  );
@@ -139557,7 +140049,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139557
140049
  continue;
139558
140050
  }
139559
140051
  const filePath = this.resolvePath(slidePath, target);
139560
- const xml = await this.zip.file(filePath)?.async("string");
140052
+ const xml = await this.readPartText(filePath);
139561
140053
  if (!xml) {
139562
140054
  continue;
139563
140055
  }
@@ -139580,11 +140072,10 @@ var init_PptxHandlerRuntimeComments = __esm({
139580
140072
  return [];
139581
140073
  }
139582
140074
  async loadModernCommentAuthors() {
139583
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
139584
- if (!relsXml) {
140075
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
140076
+ if (!relsData) {
139585
140077
  return;
139586
140078
  }
139587
- const relsData = this.parser.parse(relsXml);
139588
140079
  const relationships3 = this.ensureArray(
139589
140080
  xmlChild(relsData, "Relationships")?.Relationship
139590
140081
  );
@@ -139596,7 +140087,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139596
140087
  return;
139597
140088
  }
139598
140089
  const partPath = this.resolvePath("ppt/presentation.xml", target);
139599
- const xml = await this.zip.file(partPath)?.async("string");
140090
+ const xml = await this.readPartText(partPath);
139600
140091
  if (!xml) {
139601
140092
  return;
139602
140093
  }
@@ -139622,12 +140113,12 @@ var init_PptxHandlerRuntimeComments = __esm({
139622
140113
  }
139623
140114
  }
139624
140115
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
139625
- const relsXml = await this.zip.file(relsPath2)?.async("string");
140116
+ const relsXml = await this.readPartText(relsPath2);
139626
140117
  if (!relsXml) {
139627
140118
  return void 0;
139628
140119
  }
139629
140120
  try {
139630
- const relsData = this.parser.parse(relsXml);
140121
+ const relsData = await this.readPartXml(relsPath2);
139631
140122
  const rels = this.ensureArray(
139632
140123
  xmlChild(relsData, "Relationships")?.Relationship
139633
140124
  );
@@ -139666,7 +140157,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139666
140157
  return [];
139667
140158
  }
139668
140159
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
139669
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
140160
+ const commentsXml = await this.readPartText(commentsPath);
139670
140161
  if (!commentsXml) {
139671
140162
  return [];
139672
140163
  }
@@ -139701,7 +140192,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139701
140192
  }
139702
140193
  }
139703
140194
  async loadCommentAuthors() {
139704
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
140195
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
139705
140196
  if (!commentAuthorsXml) {
139706
140197
  return;
139707
140198
  }
@@ -139773,7 +140264,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139773
140264
  return void 0;
139774
140265
  }
139775
140266
  const partPath = this.resolveImagePath(slidePath, target);
139776
- const xmlString = await this.zip.file(partPath)?.async("string");
140267
+ const xmlString = await this.readPartText(partPath);
139777
140268
  if (!xmlString) {
139778
140269
  return void 0;
139779
140270
  }
@@ -141488,9 +141979,8 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141488
141979
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
141489
141980
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
141490
141981
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
141491
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
141492
- if (chartRelsXml) {
141493
- const chartRelsData = this.parser.parse(chartRelsXml);
141982
+ const chartRelsData = await this.readPartXml(chartRelsPath);
141983
+ if (chartRelsData) {
141494
141984
  const relsContainer = chartRelsData?.Relationships;
141495
141985
  if (relsContainer?.Relationship) {
141496
141986
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -141572,7 +142062,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141572
142062
  if (drawingPath.length === 0) {
141573
142063
  return void 0;
141574
142064
  }
141575
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
142065
+ const drawingXml = await this.readPartText(drawingPath);
141576
142066
  if (!drawingXml) {
141577
142067
  return void 0;
141578
142068
  }
@@ -141593,11 +142083,10 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141593
142083
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
141594
142084
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
141595
142085
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
141596
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
141597
- if (!chartRelsXml) {
142086
+ const chartRelsData = await this.readPartXml(chartRelsPath);
142087
+ if (!chartRelsData) {
141598
142088
  return [];
141599
142089
  }
141600
- const chartRelsData = this.parser.parse(chartRelsXml);
141601
142090
  const relsContainer = chartRelsData?.Relationships;
141602
142091
  if (!relsContainer?.Relationship) {
141603
142092
  return [];
@@ -142434,8 +142923,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
142434
142923
  var PptxHandlerRuntime99;
142435
142924
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142436
142925
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
142437
- init_eot_parser();
142438
- init_font_deobfuscation();
142926
+ init_deferred_embedded_font();
142439
142927
  init_layout_display_name();
142440
142928
  init_strip_parent_dir_segments();
142441
142929
  init_xml_access();
@@ -142489,11 +142977,10 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142489
142977
  async loadPresentationFontRels() {
142490
142978
  const map = /* @__PURE__ */ new Map();
142491
142979
  try {
142492
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
142493
- if (!relsXml) {
142980
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
142981
+ if (!relsData) {
142494
142982
  return map;
142495
142983
  }
142496
- const relsData = this.parser.parse(relsXml);
142497
142984
  const rels = this.ensureArray(
142498
142985
  xmlChild(relsData, "Relationships")?.Relationship
142499
142986
  );
@@ -142512,7 +142999,13 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142512
142999
  }
142513
143000
  return map;
142514
143001
  }
142515
- /** Extract, de-obfuscate, and encode a single font variant. */
143002
+ /**
143003
+ * Read one variant's part. By default the result is a deferred descriptor
143004
+ * that decodes on first use (see `createDeferredEmbeddedFont`); parts that
143005
+ * fail the checks possible without decoding are skipped, as before. With
143006
+ * `eagerDecodeEmbeddedFonts` the variant is decoded now and skipped when
143007
+ * decoding fails.
143008
+ */
142516
143009
  async extractEmbeddedFontVariant(typeface, rId, bold, italic, relsMap, fontKey) {
142517
143010
  const fontPath = relsMap.get(rId);
142518
143011
  if (!fontPath) {
@@ -142523,80 +143016,25 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142523
143016
  if (!fontBinary || fontBinary.length === 0) {
142524
143017
  return null;
142525
143018
  }
142526
- const originalPartBytes = new Uint8Array(fontBinary);
142527
- let fontData;
142528
- let resolvedGuid;
142529
- if (isEotFormat(fontBinary)) {
142530
- const extracted = extractFontFromEot(fontBinary);
142531
- if (extracted) {
142532
- fontData = extracted.fontData;
142533
- } else {
142534
- const header = parseEotHeader(fontBinary);
142535
- console.info(
142536
- `[pptx-viewer] Embedded font "${typeface}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""} \u2014 extraction failed, will use web font fallback`
142537
- );
142538
- return null;
142539
- }
142540
- } else {
142541
- const guidFromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
142542
- const guidFromPath = extractGuidFromPartName(fontPath);
142543
- const guid = guidFromKey || guidFromPath;
142544
- if (guid) {
142545
- fontData = deobfuscateFont(fontBinary, guid);
142546
- resolvedGuid = guid;
142547
- } else {
142548
- console.warn(
142549
- `[pptx-viewer] Embedded font "${typeface}" at "${fontPath}" has no fontKey attribute and no GUID in filename \u2014 skipping`
142550
- );
142551
- return null;
142552
- }
142553
- }
142554
- if (fontData.length < 4) {
142555
- return null;
142556
- }
142557
- const v0 = fontData[0], v1 = fontData[1], v2 = fontData[2], v3 = fontData[3];
142558
- const isTrueType = v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0;
142559
- const isOTTO = v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79;
142560
- const isTTC = v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102;
142561
- const isWOFF = v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
142562
- if (!(isTrueType || isOTTO || isTTC || isWOFF)) {
142563
- console.warn(
142564
- `[pptx-viewer] Embedded font "${typeface}" has invalid sfnt header [${v0.toString(16)},${v1.toString(16)},${v2.toString(16)},${v3.toString(16)}] after processing \u2014 skipping (web font fallback will be used)`
142565
- );
142566
- return null;
142567
- }
142568
- const format = detectFontFormat(fontData);
142569
- const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
142570
- const base64 = this.uint8ArrayToBase64(fontData);
142571
- const dataUrl = `data:${mimeType};base64,${base64}`;
142572
- return {
143019
+ const source = {
142573
143020
  name: typeface,
142574
- dataUrl,
142575
143021
  bold,
142576
143022
  italic,
142577
- format,
142578
- rawFontData: fontData,
142579
- partPath: fontPath,
142580
- fontGuid: resolvedGuid,
142581
143023
  originalRId: rId,
142582
- originalPartBytes
143024
+ partPath: fontPath,
143025
+ // The descriptor owns a copy, so it outlives this handler's ZIP and
143026
+ // the save pipeline can write it back verbatim.
143027
+ originalPartBytes: new Uint8Array(fontBinary),
143028
+ fontKey
142583
143029
  };
143030
+ if (this.eagerDecodeEmbeddedFonts) {
143031
+ return decodeEmbeddedFontPart(source);
143032
+ }
143033
+ return isEmbeddedFontPartPlausible(source) ? createDeferredEmbeddedFont(source) : null;
142584
143034
  } catch {
142585
143035
  return null;
142586
143036
  }
142587
143037
  }
142588
- /** Convert Uint8Array to base64 string. */
142589
- uint8ArrayToBase64(bytes) {
142590
- let binary = "";
142591
- const chunkSize = 8192;
142592
- for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
142593
- const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
142594
- for (let j = 0; j < chunk2.length; j++) {
142595
- binary += String.fromCharCode(chunk2[j]);
142596
- }
142597
- }
142598
- return btoa(binary);
142599
- }
142600
143038
  getLayoutOptions() {
142601
143039
  const options = [];
142602
143040
  for (const [path4, xmlObj] of this.layoutXmlMap.entries()) {
@@ -142649,12 +143087,16 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142649
143087
  init_ole_embedded_extract();
142650
143088
  init_ole_utils();
142651
143089
  init_signature_detection();
142652
- init_types2();
143090
+ init_load_limits();
142653
143091
  init_authored_slide_background();
142654
143092
  init_bullet_picture_image_enrichment();
142655
143093
  init_PptxHandlerRuntimeEmbeddedFonts();
142656
143094
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
142657
143095
  PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
143096
+ /** The limits of the load in progress (see `PptxHandlerLoadOptions.limits`). */
143097
+ loadLimits = { ...DEFAULT_PPTX_LOAD_LIMITS };
143098
+ /** Slide elements parsed so far by the load in progress, for `maxShapes`. */
143099
+ loadedShapeCount = 0;
142658
143100
  isZipContainer(data) {
142659
143101
  const bytes = new Uint8Array(data);
142660
143102
  if (bytes.byteLength < 4) {
@@ -142663,7 +143105,9 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142663
143105
  return bytes[0] === 80 && bytes[1] === 75 && (bytes[2] === 3 && bytes[3] === 4 || bytes[2] === 5 && bytes[3] === 6 || bytes[2] === 7 && bytes[3] === 8);
142664
143106
  }
142665
143107
  async initializeLoadSession(data, options) {
143108
+ const limits = resolvePptxLoadLimits(options);
142666
143109
  this.eagerDecodeImages = options.eagerDecodeImages ?? false;
143110
+ this.eagerDecodeEmbeddedFonts = options.eagerDecodeEmbeddedFonts === true;
142667
143111
  this.allowExternalImages = options.allowExternalImages === true;
142668
143112
  if (data.byteLength < 4) {
142669
143113
  throw new Error("Invalid PPTX binary: file is empty or truncated.");
@@ -142673,7 +143117,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142673
143117
  "Invalid PPTX binary: not a ZIP/OpenXML package. The file is neither an OpenXML archive nor an OLE compound file (which is how legacy .ppt and encrypted presentations arrive), so it is most likely corrupt, truncated, or not a presentation at all."
142674
143118
  );
142675
143119
  }
142676
- const maxBytes = typeof options.maxUncompressedBytes === "number" && options.maxUncompressedBytes > 0 ? options.maxUncompressedBytes : DEFAULT_MAX_UNCOMPRESSED_BYTES;
143120
+ const maxBytes = limits.maxUncompressedBytes;
142677
143121
  let loaded;
142678
143122
  try {
142679
143123
  loaded = await JSZip__default.default.loadAsync(data);
@@ -142683,11 +143127,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142683
143127
  }
142684
143128
  this.zip = guardZip(loaded, {
142685
143129
  label: "PPTX",
142686
- maxEntries: MAX_ZIP_ENTRY_COUNT,
143130
+ maxEntries: limits.maxEntries,
142687
143131
  maxEntryBytes: maxBytes,
142688
143132
  maxTotalBytes: maxBytes,
142689
- createError: (message, details) => new ZipBombError(message, details)
143133
+ createError: createPptxZipBombError
142690
143134
  });
143135
+ this.loadLimits = limits;
143136
+ this.loadedShapeCount = 0;
142691
143137
  try {
142692
143138
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
142693
143139
  this.zip,
@@ -142814,13 +143260,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142814
143260
  if (!file) {
142815
143261
  continue;
142816
143262
  }
142817
- const data = await file.async("string");
143263
+ const data = await this.readPartText(entry2) ?? "";
142818
143264
  const propsPath = `customXml/itemProps${itemId}.xml`;
142819
143265
  const propsFile = this.zip.file(propsPath);
142820
143266
  let properties;
142821
143267
  let schemaUri;
142822
143268
  if (propsFile) {
142823
- properties = await propsFile.async("string");
143269
+ properties = await this.readPartText(propsPath) ?? "";
142824
143270
  try {
142825
143271
  const propsData = this.parser.parse(properties);
142826
143272
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -142840,19 +143286,24 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142840
143286
  const relsFile = this.zip.file(relsPath2);
142841
143287
  let rels;
142842
143288
  if (relsFile) {
142843
- rels = await relsFile.async("string");
143289
+ rels = await this.readPartText(relsPath2);
142844
143290
  }
142845
143291
  parts.push({ id: itemId, data, schemaUri, properties, rels });
142846
143292
  }
142847
143293
  this.customXmlParts = parts;
142848
143294
  }
142849
143295
  async loadPresentationState() {
142850
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
143296
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
142851
143297
  if (!presentationXml3) {
142852
143298
  throw new Error("Invalid PPTX: presentation.xml not found");
142853
143299
  }
142854
143300
  this.presentationData = this.parser.parse(presentationXml3);
142855
143301
  this.detectAndSetStrictConformance(this.presentationData);
143302
+ const slideIds = this.presentationData?.["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
143303
+ assertPptxSlideCountWithinLimits(
143304
+ Array.isArray(slideIds) ? slideIds.length : slideIds ? 1 : 0,
143305
+ this.loadLimits
143306
+ );
142856
143307
  await this.loadThemeData();
142857
143308
  this.parsePresentationDefaultTextStyle();
142858
143309
  await this.loadCommentAuthors();
@@ -142982,7 +143433,17 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142982
143433
  loadThemeOverride: (partBasePath) => this.loadThemeOverride(partBasePath),
142983
143434
  applyThemeOverrideState: (override) => this.applyThemeOverrideState(override),
142984
143435
  getLayoutElements: (slidePath) => this.getLayoutElements(slidePath),
142985
- parseSlide: (slideXml3, slidePath) => this.parseSlide(slideXml3, slidePath),
143436
+ // `maxShapes`: each slide's own elements are counted as soon as they are
143437
+ // parsed, before that slide's media is resolved and before the next slide.
143438
+ parseSlide: async (slideXml3, slidePath) => {
143439
+ const elements2 = await this.parseSlide(slideXml3, slidePath);
143440
+ this.loadedShapeCount = countPptxShapesWithinLimits(
143441
+ this.loadedShapeCount,
143442
+ elements2,
143443
+ this.loadLimits
143444
+ );
143445
+ return elements2;
143446
+ },
142986
143447
  extractMediaTimingMap: (slideXml3, slidePath) => this.extractMediaTimingMap(slideXml3, slidePath),
142987
143448
  enrichMediaElementsWithTiming: (elements2, timingMap) => this.enrichMediaElementsWithTiming(elements2, timingMap),
142988
143449
  enrichOleElementsWithEmbeddedData: (elements2, slidePath) => this.enrichOleElementsWithEmbeddedData(elements2, slidePath),
@@ -143035,6 +143496,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143035
143496
  init_smart_tags_parser();
143036
143497
  init_strip_parent_dir_segments();
143037
143498
  init_builders();
143499
+ init_load_limits();
143038
143500
  init_authored_slide_background();
143039
143501
  init_layout_switch_placeholder_prompts();
143040
143502
  init_PptxHandlerRuntimeLoadSession();
@@ -143199,6 +143661,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143199
143661
  * or resolve images. Create a new `PptxHandler` instance instead.
143200
143662
  */
143201
143663
  dispose() {
143664
+ this.endPartReads();
143202
143665
  this.revokeBlobUrls();
143203
143666
  this.imageDataCache.clear();
143204
143667
  this.slideMap.clear();
@@ -143232,7 +143695,23 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143232
143695
  this.zip = null;
143233
143696
  }
143234
143697
  async load(data, options = {}) {
143235
- await this.initializeLoadSession(data, options);
143698
+ let reader2;
143699
+ try {
143700
+ await this.initializeLoadSession(data, options);
143701
+ reader2 = this.beginPartReads();
143702
+ try {
143703
+ return await this.loadInitializedSession();
143704
+ } catch (error) {
143705
+ if (error instanceof PptxLoadLimitError) {
143706
+ this.dispose();
143707
+ }
143708
+ throw error;
143709
+ }
143710
+ } finally {
143711
+ this.endPartReads(reader2);
143712
+ }
143713
+ }
143714
+ async loadInitializedSession() {
143236
143715
  await this.detectAndPreserveVbaProject();
143237
143716
  this.detectDigitalSignatureParts();
143238
143717
  await this.parseCustomXmlParts();
@@ -143382,7 +143861,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143382
143861
  options.push(this.buildLayoutOption(lp, xmlObj));
143383
143862
  } else {
143384
143863
  try {
143385
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
143864
+ const layoutXmlStr = await this.readPartText(lp);
143386
143865
  if (layoutXmlStr) {
143387
143866
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
143388
143867
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -143425,7 +143904,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
143425
143904
  }
143426
143905
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
143427
143906
  if (!layoutXml3) {
143428
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
143907
+ const layoutXmlStr = await this.readPartText(layoutPath);
143429
143908
  if (!layoutXmlStr) {
143430
143909
  throw new Error(`Layout not found: ${layoutPath}`);
143431
143910
  }
@@ -144628,24 +145107,24 @@ function parseStyleTextPropAtom(view, dataOffset, dataLen, textLength, scheme) {
144628
145107
  const charRuns = [];
144629
145108
  let covered = 0;
144630
145109
  while (covered < total && c.canRead(6)) {
144631
- const count = c.u32();
145110
+ const count2 = c.u32();
144632
145111
  const indentLevel = c.u16();
144633
- const props = { count, indentLevel };
145112
+ const props = { count: count2, indentLevel };
144634
145113
  if (!parsePfException(c, scheme, props)) {
144635
145114
  break;
144636
145115
  }
144637
145116
  paragraphRuns.push(props);
144638
- covered += count;
145117
+ covered += count2;
144639
145118
  }
144640
145119
  covered = 0;
144641
145120
  while (covered < total && c.canRead(8)) {
144642
- const count = c.u32();
144643
- const props = { count };
145121
+ const count2 = c.u32();
145122
+ const props = { count: count2 };
144644
145123
  if (!parseCfException(c, scheme, props)) {
144645
145124
  break;
144646
145125
  }
144647
145126
  charRuns.push(props);
144648
- covered += count;
145127
+ covered += count2;
144649
145128
  }
144650
145129
  return { paragraphRuns, charRuns };
144651
145130
  }
@@ -145707,13 +146186,13 @@ var init_geometry_map = __esm({
145707
146186
  function parseProperties2(view, data, rec) {
145708
146187
  const values = /* @__PURE__ */ new Map();
145709
146188
  const complex = /* @__PURE__ */ new Map();
145710
- const count = rec.recInstance;
145711
- const entriesEnd = rec.dataOffset + count * 6;
146189
+ const count2 = rec.recInstance;
146190
+ const entriesEnd = rec.dataOffset + count2 * 6;
145712
146191
  if (entriesEnd > rec.dataOffset + rec.recLen) {
145713
146192
  return { values, complex };
145714
146193
  }
145715
146194
  const complexRefs = [];
145716
- for (let i2 = 0; i2 < count; i2++) {
146195
+ for (let i2 = 0; i2 < count2; i2++) {
145717
146196
  const at2 = rec.dataOffset + i2 * 6;
145718
146197
  const opid = view.getUint16(at2, true);
145719
146198
  const value = view.getUint32(at2 + 2, true);
@@ -146914,8 +147393,8 @@ function levelXml(tag, level2, fallbackSizePt) {
146914
147393
  }
146915
147394
  function styleLevels(levels, fallbackSizePt) {
146916
147395
  const result = [];
146917
- const count = Math.max(1, Math.min(levels.length, 9));
146918
- for (let i2 = 0; i2 < count; i2++) {
147396
+ const count2 = Math.max(1, Math.min(levels.length, 9));
147397
+ for (let i2 = 0; i2 < count2; i2++) {
146919
147398
  result.push(levelXml(`lvl${i2 + 1}pPr`, levels[i2] ?? {}, fallbackSizePt));
146920
147399
  }
146921
147400
  return result.join("");
@@ -147411,6 +147890,7 @@ var PptxHandlerCore;
147411
147890
  var init_PptxHandlerCore = __esm({
147412
147891
  "pptx/core/PptxHandlerCore.ts"() {
147413
147892
  init_core2();
147893
+ init_load_limits();
147414
147894
  init_ppt();
147415
147895
  init_encryption_detection();
147416
147896
  init_ole2_parser();
@@ -147800,6 +148280,7 @@ var init_PptxHandlerCore = __esm({
147800
148280
  * ```
147801
148281
  */
147802
148282
  async load(data, options = {}) {
148283
+ assertPptxInputWithinLimits(data.byteLength, resolvePptxLoadLimits(options));
147803
148284
  const detection = detectFileFormat(data);
147804
148285
  if (detection.format === "ole") {
147805
148286
  let ole;
@@ -148048,6 +148529,7 @@ var init_PptxHandler = __esm({
148048
148529
  "pptx/core/PptxHandler.ts"() {
148049
148530
  init_json();
148050
148531
  init_PresentationBuilder();
148532
+ init_load_limits();
148051
148533
  init_PptxHandlerCore();
148052
148534
  PptxHandler = class extends PptxHandlerCore {
148053
148535
  /**
@@ -148119,13 +148601,15 @@ var init_PptxHandler = __esm({
148119
148601
  * archives and portable `pptx-viewer-json` documents.
148120
148602
  *
148121
148603
  * The buffer is sniffed first: JSON documents (leading `{` plus the
148122
- * `"pptx-viewer-json"` format marker) are routed to {@link loadFromJson};
148123
- * everything else goes through the regular ZIP/OLE2 pipeline.
148604
+ * `"pptx-viewer-json"` format marker) are imported as {@link loadFromJson}
148605
+ * does; everything else goes through the regular ZIP/OLE2 pipeline.
148124
148606
  */
148125
148607
  async load(data, options = {}) {
148608
+ const limits = resolvePptxLoadLimits(options);
148609
+ assertPptxInputWithinLimits(data.byteLength, limits);
148126
148610
  const jsonText = decodePptxJsonText(data);
148127
148611
  if (jsonText !== null) {
148128
- return this.loadFromJson(jsonText, options);
148612
+ return this.importJson(jsonText, options, limits);
148129
148613
  }
148130
148614
  return super.load(data, options);
148131
148615
  }
@@ -148136,9 +148620,26 @@ var init_PptxHandler = __esm({
148136
148620
  * handler keeps a valid in-memory archive (editing and {@link save} keep
148137
148621
  * working), then the imported model is overlaid on top: imported
148138
148622
  * presentation fields win, and the slide array is replaced wholesale.
148623
+ *
148624
+ * `options.limits` applies as it does for {@link load}: `maxInputBytes` to
148625
+ * the UTF-8 size of `text` (checked before it is parsed), and `maxSlides`
148626
+ * and `maxShapes` to the document's slides with the same counting rule as
148627
+ * a `.pptx` package (layout and master elements are not counted).
148139
148628
  */
148140
148629
  async loadFromJson(text2, options = {}) {
148141
- const imported = deserializePptxFromJson(text2);
148630
+ const limits = resolvePptxLoadLimits(options);
148631
+ assertPptxTextWithinLimits(text2, limits);
148632
+ return this.importJson(text2, options, limits);
148633
+ }
148634
+ async importJson(text2, options, limits) {
148635
+ const document2 = parsePptxJson(text2);
148636
+ assertPptxSlideCountWithinLimits(document2.slides.length, limits);
148637
+ let shapes = 0;
148638
+ for (const slide of document2.slides) {
148639
+ const elements2 = Array.isArray(slide.elements) ? slide.elements : [];
148640
+ shapes = countPptxShapesWithinLimits(shapes, elements2, limits);
148641
+ }
148642
+ const imported = pptxDataFromJsonDocument(document2);
148142
148643
  const blankBytes = await buildBlankPresentationArchive({
148143
148644
  width: imported.widthEmu,
148144
148645
  height: imported.heightEmu,
@@ -148146,7 +148647,7 @@ var init_PptxHandler = __esm({
148146
148647
  // the overlaid model, so the archive must carry the value itself.
148147
148648
  firstSlideNumber: imported.firstSlideNumber
148148
148649
  });
148149
- const base = await super.load(blankBytes, options);
148650
+ const base = await super.load(blankBytes, { ...options, limits: void 0 });
148150
148651
  return applyImportedPptxData(base, imported);
148151
148652
  }
148152
148653
  };
@@ -151830,14 +152331,14 @@ async function resolveBlobImageUrls(elements2) {
151830
152331
  }
151831
152332
  }
151832
152333
  function countElements(elements2) {
151833
- let count = 0;
152334
+ let count2 = 0;
151834
152335
  for (const el of elements2) {
151835
- count++;
152336
+ count2++;
151836
152337
  if (el.type === "group" && "children" in el) {
151837
- count += countElements(el.children);
152338
+ count2 += countElements(el.children);
151838
152339
  }
151839
152340
  }
151840
- return count;
152341
+ return count2;
151841
152342
  }
151842
152343
  function extractSlideText(elements2) {
151843
152344
  const texts = [];
@@ -151952,10 +152453,10 @@ async function handleFind(bytes, search, options) {
151952
152453
  async function handleReplace(bytes, search, replacement, options) {
151953
152454
  const { handler, data } = await loadPptx(bytes);
151954
152455
  const pattern = options?.caseSensitive === false ? new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi") : search;
151955
- const count = replaceText(data.slides, pattern, replacement);
152456
+ const count2 = replaceText(data.slides, pattern, replacement);
151956
152457
  const outputBytes = await handler.save(data.slides);
151957
152458
  return {
151958
- replacementCount: count,
152459
+ replacementCount: count2,
151959
152460
  outputBytes
151960
152461
  };
151961
152462
  }