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
@@ -1510,7 +1510,7 @@ function ensureArrayLocal(value) {
1510
1510
  return Array.isArray(value) ? value : value === void 0 ? [] : [value];
1511
1511
  }
1512
1512
  function countsSignature(counts) {
1513
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
1513
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
1514
1514
  }
1515
1515
  function pathSignature(path3) {
1516
1516
  const counts = /* @__PURE__ */ new Map();
@@ -5017,7 +5017,7 @@ function resolveLimits(limits) {
5017
5017
  maxEntryBytes: limits.maxEntryBytes ?? DEFAULT_ZIP_LIMITS.maxEntryBytes,
5018
5018
  maxTotalBytes: limits.maxTotalBytes ?? DEFAULT_ZIP_LIMITS.maxTotalBytes,
5019
5019
  label: limits.label ?? "ZIP",
5020
- fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
5020
+ fail: (message, limit, kind, actual) => create2 ? create2(message, { limit, kind, actual }) : new ZipLimitError(message, { limit, kind, actual })
5021
5021
  };
5022
5022
  }
5023
5023
  async function inflateEntryGuarded(entry2, alreadyRead, limits) {
@@ -5071,7 +5071,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
5071
5071
  r.fail(
5072
5072
  `${r.label} part ${entry2.name} inflates past its declared size`,
5073
5073
  r.maxEntryBytes,
5074
- size > declared ? "declaredSize" : "maxEntryBytes"
5074
+ size > declared ? "declaredSize" : "maxEntryBytes",
5075
+ size
5075
5076
  )
5076
5077
  );
5077
5078
  if (alreadyRead + size > r.maxTotalBytes)
@@ -5079,7 +5080,8 @@ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
5079
5080
  r.fail(
5080
5081
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5081
5082
  r.maxTotalBytes,
5082
- "maxTotalBytes"
5083
+ "maxTotalBytes",
5084
+ alreadyRead + size
5083
5085
  )
5084
5086
  );
5085
5087
  queue.push(chunk2);
@@ -5126,7 +5128,8 @@ function guardZip(zip, limits = {}) {
5126
5128
  throw r.fail(
5127
5129
  `${r.label} package exceeds the ${r.maxEntries.toLocaleString("en-US")} part limit`,
5128
5130
  r.maxEntries,
5129
- "maxEntries"
5131
+ "maxEntries",
5132
+ entries.length
5130
5133
  );
5131
5134
  let declared = 0;
5132
5135
  for (const entry2 of entries) {
@@ -5139,7 +5142,8 @@ function guardZip(zip, limits = {}) {
5139
5142
  throw r.fail(
5140
5143
  `${r.label} part ${entry2.name} exceeds the uncompressed part size limit`,
5141
5144
  r.maxEntryBytes,
5142
- "maxEntryBytes"
5145
+ "maxEntryBytes",
5146
+ size
5143
5147
  );
5144
5148
  declared += size;
5145
5149
  }
@@ -5147,7 +5151,8 @@ function guardZip(zip, limits = {}) {
5147
5151
  throw r.fail(
5148
5152
  `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5149
5153
  r.maxTotalBytes,
5150
- "maxTotalBytes"
5154
+ "maxTotalBytes",
5155
+ declared
5151
5156
  );
5152
5157
  const produced = /* @__PURE__ */ new Map();
5153
5158
  let total = 0;
@@ -5186,7 +5191,8 @@ async function openZip(input, limits = {}) {
5186
5191
  throw r.fail(
5187
5192
  `${r.label} package exceeds the ${mib(maxInput)} MiB compressed input limit`,
5188
5193
  maxInput,
5189
- "maxInputBytes"
5194
+ "maxInputBytes",
5195
+ bytes.byteLength
5190
5196
  );
5191
5197
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
5192
5198
  }
@@ -5204,11 +5210,14 @@ var init_zip_limits = __esm({
5204
5210
  limit;
5205
5211
  /** The check that failed (absent when the error was built without one). */
5206
5212
  kind;
5213
+ /** The observed value, when known (a lower bound for a size found while inflating). */
5214
+ actual;
5207
5215
  constructor(message, details) {
5208
5216
  super(message);
5209
5217
  this.name = "ZipLimitError";
5210
5218
  this.limit = details.limit;
5211
5219
  this.kind = details.kind;
5220
+ this.actual = details.actual;
5212
5221
  }
5213
5222
  };
5214
5223
  mib = (bytes) => Math.round(bytes / 1048576);
@@ -5224,15 +5233,27 @@ var init_types2 = __esm({
5224
5233
  exports.MAX_ZIP_ENTRY_COUNT = 65536;
5225
5234
  exports.ZipBombError = class extends Error {
5226
5235
  code = "ZIP_BOMB";
5236
+ /** Inflated bytes declared or read when a size limit failed (a lower bound while streaming). */
5227
5237
  uncompressedBytes;
5238
+ /** The value of the limit that failed. */
5228
5239
  limit;
5240
+ /** Number of archive entries, when the entry-count limit failed. */
5229
5241
  entryCount;
5242
+ /**
5243
+ * The `PptxLoadLimits` field behind this error (`maxUncompressedBytes` or
5244
+ * `maxEntries`); `undefined` for a forged size or an unsafe part name.
5245
+ */
5246
+ loadLimit;
5247
+ /** The observed value for {@link loadLimit}, when known. */
5248
+ actual;
5230
5249
  constructor(message, details) {
5231
5250
  super(message);
5232
5251
  this.name = "ZipBombError";
5233
5252
  this.uncompressedBytes = details.uncompressedBytes;
5234
5253
  this.limit = details.limit;
5235
5254
  this.entryCount = details.entryCount;
5255
+ this.loadLimit = details.loadLimit;
5256
+ this.actual = details.actual;
5236
5257
  }
5237
5258
  };
5238
5259
  }
@@ -5333,13 +5354,13 @@ function layoutRelsXml(masterIndex = 1) {
5333
5354
  </Relationships>`;
5334
5355
  }
5335
5356
  function countExistingLayouts(zip) {
5336
- let count = 0;
5357
+ let count2 = 0;
5337
5358
  zip.forEach((relativePath) => {
5338
5359
  if (/^ppt\/slideLayouts\/slideLayout\d+\.xml$/.test(relativePath)) {
5339
- count++;
5360
+ count2++;
5340
5361
  }
5341
5362
  });
5342
- return count;
5363
+ return count2;
5343
5364
  }
5344
5365
  async function addLayoutToSlideMaster(zip, layoutIndex2, masterIndex = 1) {
5345
5366
  const masterRelsPath = `ppt/slideMasters/_rels/slideMaster${masterIndex}.xml.rels`;
@@ -5919,6 +5940,564 @@ var init_PresentationBuilder = __esm({
5919
5940
  }
5920
5941
  });
5921
5942
 
5943
+ // pptx/core/utils/clone-utils.ts
5944
+ function isPlainRecord(value) {
5945
+ if (typeof value !== "object" || value === null) {
5946
+ return false;
5947
+ }
5948
+ const prototype = Object.getPrototypeOf(value);
5949
+ return prototype === Object.prototype || prototype === null;
5950
+ }
5951
+ function cloneValue(value, seen) {
5952
+ if (Array.isArray(value)) {
5953
+ const cached2 = seen.get(value);
5954
+ if (cached2 !== void 0) {
5955
+ return cached2;
5956
+ }
5957
+ const copy3 = new Array(value.length);
5958
+ seen.set(value, copy3);
5959
+ for (let index = 0; index < value.length; index++) {
5960
+ copy3[index] = cloneValue(value[index], seen);
5961
+ }
5962
+ return copy3;
5963
+ }
5964
+ if (!isPlainRecord(value)) {
5965
+ return value;
5966
+ }
5967
+ const cached = seen.get(value);
5968
+ if (cached !== void 0) {
5969
+ return cached;
5970
+ }
5971
+ const copy2 = {};
5972
+ seen.set(value, copy2);
5973
+ for (const key2 of Object.keys(value)) {
5974
+ const child32 = value[key2];
5975
+ copy2[key2] = SHARED_RAW_XML_KEYS.has(key2) ? child32 : cloneValue(child32, seen);
5976
+ }
5977
+ return copy2;
5978
+ }
5979
+ function deepCloneData(value) {
5980
+ return cloneValue(value, /* @__PURE__ */ new WeakMap());
5981
+ }
5982
+ function cloneTextStyle(style) {
5983
+ if (!style) {
5984
+ return void 0;
5985
+ }
5986
+ return deepCloneData(style);
5987
+ }
5988
+ function cloneShapeStyle(style) {
5989
+ if (!style) {
5990
+ return void 0;
5991
+ }
5992
+ return deepCloneData(style);
5993
+ }
5994
+ function cloneElement(element) {
5995
+ return deepCloneData(element);
5996
+ }
5997
+ function cloneSlide(slide) {
5998
+ return deepCloneData(slide);
5999
+ }
6000
+ function cloneTemplateElementsBySlideId(templateElementsBySlideId) {
6001
+ const cloned = {};
6002
+ Object.entries(templateElementsBySlideId).forEach(([slideId, elements3]) => {
6003
+ cloned[slideId] = elements3.map(cloneElement);
6004
+ });
6005
+ return cloned;
6006
+ }
6007
+ function cloneXmlObject(value) {
6008
+ if (!value) {
6009
+ return void 0;
6010
+ }
6011
+ try {
6012
+ if (typeof structuredClone === "function") {
6013
+ return structuredClone(value);
6014
+ }
6015
+ return JSON.parse(JSON.stringify(value));
6016
+ } catch (error) {
6017
+ console.warn("Failed to clone XML object, returning undefined.", value, error);
6018
+ return void 0;
6019
+ }
6020
+ }
6021
+ var SHARED_RAW_XML_KEYS;
6022
+ var init_clone_utils = __esm({
6023
+ "pptx/core/utils/clone-utils.ts"() {
6024
+ SHARED_RAW_XML_KEYS = /* @__PURE__ */ new Set([
6025
+ "rawXml",
6026
+ "rawTiming",
6027
+ "inkPartRawXml",
6028
+ "rawMediaReferenceXml"
6029
+ ]);
6030
+ }
6031
+ });
6032
+
6033
+ // pptx/core/utils/element-utils.ts
6034
+ function isTemplateElement(element) {
6035
+ return element.id.startsWith("layout-") || element.id.startsWith("master-");
6036
+ }
6037
+ function isEditableTextElement(element) {
6038
+ if (element.type !== "text" && element.type !== "shape") {
6039
+ return false;
6040
+ }
6041
+ return element.type === "text" || typeof element.text === "string" || (element.textSegments?.length ?? 0) > 0;
6042
+ }
6043
+ function getElementLabel(element) {
6044
+ if (element.type === "text") {
6045
+ return "Text";
6046
+ }
6047
+ if (element.type === "connector") {
6048
+ return "Connector";
6049
+ }
6050
+ if (element.type === "image" || element.type === "picture") {
6051
+ return "Image";
6052
+ }
6053
+ if (element.type === "chart") {
6054
+ return "Chart";
6055
+ }
6056
+ if (element.type === "table") {
6057
+ return "Table";
6058
+ }
6059
+ if (element.type === "smartArt") {
6060
+ return "SmartArt";
6061
+ }
6062
+ if (element.type === "ole") {
6063
+ return "Embedded Object";
6064
+ }
6065
+ if (element.type === "media") {
6066
+ return "Media";
6067
+ }
6068
+ return "Shape";
6069
+ }
6070
+ function shouldRenderFallbackLabel(element, isTextElement2) {
6071
+ if (isTextElement2) {
6072
+ return false;
6073
+ }
6074
+ if (element.type === "shape" || element.type === "connector") {
6075
+ return false;
6076
+ }
6077
+ if (element.type === "picture" || element.type === "image") {
6078
+ return false;
6079
+ }
6080
+ if (element.type === "table") {
6081
+ return false;
6082
+ }
6083
+ return element.type === "chart" || element.type === "smartArt" || element.type === "ole" || element.type === "media" || element.type === "unknown";
6084
+ }
6085
+ function getElementTextContent(element) {
6086
+ if (!hasTextProperties(element)) {
6087
+ return "";
6088
+ }
6089
+ if (typeof element.text === "string") {
6090
+ return element.text;
6091
+ }
6092
+ if (!element.textSegments || element.textSegments.length === 0) {
6093
+ return "";
6094
+ }
6095
+ return element.textSegments.map((segment) => String(segment.text || "")).join("");
6096
+ }
6097
+ function createUniformTextSegments(text2, style) {
6098
+ return [
6099
+ {
6100
+ text: text2,
6101
+ style: cloneTextStyle(style) || {}
6102
+ }
6103
+ ];
6104
+ }
6105
+ function createEditorId(prefix) {
6106
+ const random = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
6107
+ const sequence = (nextEditorIdSequence++).toString(36);
6108
+ return `${prefix}-${Date.now()}-${random}${sequence}`;
6109
+ }
6110
+ function createDrawingObjectId() {
6111
+ nextDrawingObjectId += 1;
6112
+ return nextDrawingObjectId;
6113
+ }
6114
+ function createArrayBufferCopy(bytes) {
6115
+ const copy2 = new Uint8Array(bytes.byteLength);
6116
+ copy2.set(bytes);
6117
+ return copy2.buffer;
6118
+ }
6119
+ function ensureArrayValue(value) {
6120
+ if (!value) {
6121
+ return [];
6122
+ }
6123
+ return Array.isArray(value) ? value : [value];
6124
+ }
6125
+ function formatCommentTimestamp(value) {
6126
+ const normalized = String(value || "").trim();
6127
+ if (normalized.length === 0) {
6128
+ return "";
6129
+ }
6130
+ const parsed = new Date(normalized);
6131
+ if (Number.isNaN(parsed.getTime())) {
6132
+ return "";
6133
+ }
6134
+ return parsed.toLocaleString(void 0, {
6135
+ month: "short",
6136
+ day: "numeric",
6137
+ hour: "2-digit",
6138
+ minute: "2-digit"
6139
+ });
6140
+ }
6141
+ function getCommentMarkerPosition(comment, index, width, height) {
6142
+ const fallbackX = 18 + index % 4 * 14;
6143
+ const fallbackY = 18 + Math.floor(index / 4) * 14;
6144
+ const rawX = typeof comment.x === "number" && Number.isFinite(comment.x) ? comment.x : fallbackX;
6145
+ const rawY = typeof comment.y === "number" && Number.isFinite(comment.y) ? comment.y : fallbackY;
6146
+ return {
6147
+ x: Math.min(Math.max(rawX, 8), Math.max(width - 8, 8)),
6148
+ y: Math.min(Math.max(rawY, 8), Math.max(height - 8, 8))
6149
+ };
6150
+ }
6151
+ async function readFileAsDataUrl(file) {
6152
+ return await new Promise((resolve, reject) => {
6153
+ const reader2 = new FileReader();
6154
+ reader2.onload = () => {
6155
+ const result = reader2.result;
6156
+ if (typeof result !== "string") {
6157
+ reject(new Error("Failed to read image file."));
6158
+ return;
6159
+ }
6160
+ resolve(result);
6161
+ };
6162
+ reader2.onerror = () => {
6163
+ reject(new Error("Failed to read image file."));
6164
+ };
6165
+ reader2.readAsDataURL(file);
6166
+ });
6167
+ }
6168
+ var nextEditorIdSequence, DRAWING_OBJECT_ID_BASE, nextDrawingObjectId;
6169
+ var init_element_utils = __esm({
6170
+ "pptx/core/utils/element-utils.ts"() {
6171
+ init_types();
6172
+ init_clone_utils();
6173
+ nextEditorIdSequence = 0;
6174
+ DRAWING_OBJECT_ID_BASE = 1e5;
6175
+ nextDrawingObjectId = DRAWING_OBJECT_ID_BASE;
6176
+ }
6177
+ });
6178
+
6179
+ // pptx/core/utils/group-ops.ts
6180
+ function isTemplateElementId(elementId) {
6181
+ return elementId.startsWith("layout-") || elementId.startsWith("master-");
6182
+ }
6183
+ function makeStoreAwareId(intoTemplate, sourceId) {
6184
+ if (!intoTemplate) {
6185
+ return createEditorId("el");
6186
+ }
6187
+ return sourceId.startsWith("master-") ? `master-${createEditorId("el")}` : `layout-${createEditorId("el")}`;
6188
+ }
6189
+ function reassignDescendantIds(element, mintId) {
6190
+ if (element.type !== "group") {
6191
+ return;
6192
+ }
6193
+ for (const child32 of element.children) {
6194
+ const next = mintId(child32);
6195
+ if (next !== void 0) {
6196
+ child32.id = next;
6197
+ }
6198
+ reassignDescendantIds(child32, mintId);
6199
+ }
6200
+ }
6201
+ function groupElements(elements3, ids, groupId) {
6202
+ const idSet = new Set(ids);
6203
+ const gathered = [];
6204
+ let insertionIndex = -1;
6205
+ for (let i2 = 0; i2 < elements3.length; i2++) {
6206
+ const el = elements3[i2];
6207
+ if (idSet.has(el.id)) {
6208
+ gathered.push(el);
6209
+ if (insertionIndex === -1) {
6210
+ insertionIndex = i2;
6211
+ }
6212
+ }
6213
+ }
6214
+ if (gathered.length < 2) {
6215
+ return { elements: [...elements3], groupId: null };
6216
+ }
6217
+ let minX = gathered[0].x;
6218
+ let minY = gathered[0].y;
6219
+ let maxX = gathered[0].x + gathered[0].width;
6220
+ let maxY = gathered[0].y + gathered[0].height;
6221
+ for (let i2 = 1; i2 < gathered.length; i2++) {
6222
+ const el = gathered[i2];
6223
+ if (el.x < minX) {
6224
+ minX = el.x;
6225
+ }
6226
+ if (el.y < minY) {
6227
+ minY = el.y;
6228
+ }
6229
+ const rx = el.x + el.width;
6230
+ const ry = el.y + el.height;
6231
+ if (rx > maxX) {
6232
+ maxX = rx;
6233
+ }
6234
+ if (ry > maxY) {
6235
+ maxY = ry;
6236
+ }
6237
+ }
6238
+ const children17 = gathered.map((el) => {
6239
+ const child32 = cloneElement(el);
6240
+ child32.x = el.x - minX;
6241
+ child32.y = el.y - minY;
6242
+ return child32;
6243
+ });
6244
+ const group = {
6245
+ type: "group",
6246
+ id: groupId,
6247
+ name: "Group",
6248
+ x: minX,
6249
+ y: minY,
6250
+ width: maxX - minX,
6251
+ height: maxY - minY,
6252
+ children: children17
6253
+ };
6254
+ const remaining = elements3.filter((el) => !idSet.has(el.id));
6255
+ let adjustedIndex = 0;
6256
+ for (let i2 = 0; i2 < insertionIndex; i2++) {
6257
+ if (!idSet.has(elements3[i2].id)) {
6258
+ adjustedIndex++;
6259
+ }
6260
+ }
6261
+ return {
6262
+ elements: [...remaining.slice(0, adjustedIndex), group, ...remaining.slice(adjustedIndex)],
6263
+ groupId
6264
+ };
6265
+ }
6266
+ function ungroupElements(elements3, groupId, childIds, options = {}) {
6267
+ const groupIndex = elements3.findIndex((el) => el.id === groupId);
6268
+ if (groupIndex === -1) {
6269
+ return { elements: [...elements3], childIds: [] };
6270
+ }
6271
+ const group = elements3[groupIndex];
6272
+ if (group.type !== "group") {
6273
+ return { elements: [...elements3], childIds: [] };
6274
+ }
6275
+ const intoTemplate = options.intoTemplate ?? isTemplateElementId(group.id);
6276
+ const usedChildIds = [];
6277
+ const expanded = group.children.map((child32, index) => {
6278
+ const newChildId = childIds[index] ?? child32.id;
6279
+ usedChildIds.push(newChildId);
6280
+ const promoted = cloneElement(child32);
6281
+ promoted.id = newChildId;
6282
+ promoted.x = child32.x + group.x;
6283
+ promoted.y = child32.y + group.y;
6284
+ reassignDescendantIds(
6285
+ promoted,
6286
+ (descendant) => isTemplateElementId(descendant.id) === intoTemplate ? void 0 : makeStoreAwareId(intoTemplate, newChildId)
6287
+ );
6288
+ return promoted;
6289
+ });
6290
+ return {
6291
+ elements: [...elements3.slice(0, groupIndex), ...expanded, ...elements3.slice(groupIndex + 1)],
6292
+ childIds: usedChildIds
6293
+ };
6294
+ }
6295
+ var init_group_ops = __esm({
6296
+ "pptx/core/utils/group-ops.ts"() {
6297
+ init_clone_utils();
6298
+ init_element_utils();
6299
+ }
6300
+ });
6301
+
6302
+ // pptx/core/core/load-limits.ts
6303
+ function isLimitName(value) {
6304
+ return typeof value === "string" && LIMIT_NAMES.includes(value);
6305
+ }
6306
+ function getPptxLoadLimitViolation(error) {
6307
+ if (typeof error !== "object" || error === null) {
6308
+ return void 0;
6309
+ }
6310
+ const fields = error;
6311
+ const actual = typeof fields.actual === "number" ? fields.actual : void 0;
6312
+ if (fields.code === "PPTX_LOAD_LIMIT" && isLimitName(fields.limit) && typeof fields.maximum === "number") {
6313
+ return { limit: fields.limit, maximum: fields.maximum, actual };
6314
+ }
6315
+ if (fields.code === "ZIP_BOMB" && isLimitName(fields.loadLimit) && typeof fields.limit === "number") {
6316
+ return { limit: fields.loadLimit, maximum: fields.limit, actual };
6317
+ }
6318
+ return void 0;
6319
+ }
6320
+ function resolvePptxLoadLimits(options = {}) {
6321
+ const resolved = { ...exports.DEFAULT_PPTX_LOAD_LIMITS };
6322
+ const legacy = options.maxUncompressedBytes;
6323
+ if (typeof legacy === "number" && legacy > 0) {
6324
+ resolved.maxUncompressedBytes = legacy;
6325
+ }
6326
+ const limits = options.limits;
6327
+ if (limits === void 0 || limits === null) {
6328
+ return resolved;
6329
+ }
6330
+ for (const name of LIMIT_NAMES) {
6331
+ const value = limits[name];
6332
+ if (value === void 0) {
6333
+ continue;
6334
+ }
6335
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
6336
+ throw new RangeError(`limits.${name} must be a positive finite number`);
6337
+ }
6338
+ if (name === "maxEntries" && value > exports.MAX_ZIP_ENTRY_COUNT) {
6339
+ throw new RangeError(`limits.maxEntries must not exceed ${exports.MAX_ZIP_ENTRY_COUNT}`);
6340
+ }
6341
+ resolved[name] = value;
6342
+ }
6343
+ return resolved;
6344
+ }
6345
+ function createPptxZipBombError(message, details) {
6346
+ const { limit, kind, actual } = details;
6347
+ if (kind === "maxEntries") {
6348
+ return new exports.ZipBombError(message, {
6349
+ limit,
6350
+ loadLimit: "maxEntries",
6351
+ ...actual === void 0 ? {} : { entryCount: actual, actual }
6352
+ });
6353
+ }
6354
+ if (kind === "maxEntryBytes" || kind === "maxTotalBytes") {
6355
+ return new exports.ZipBombError(message, {
6356
+ limit,
6357
+ loadLimit: "maxUncompressedBytes",
6358
+ ...actual === void 0 ? {} : { uncompressedBytes: actual, actual }
6359
+ });
6360
+ }
6361
+ return new exports.ZipBombError(message, { limit });
6362
+ }
6363
+ function assertPptxInputWithinLimits(byteLength, limits) {
6364
+ if (byteLength > limits.maxInputBytes) {
6365
+ throw new exports.PptxLoadLimitError(
6366
+ `PPTX input is ${count(byteLength)} bytes, more than the maxInputBytes limit of ${count(limits.maxInputBytes)}`,
6367
+ "maxInputBytes",
6368
+ limits.maxInputBytes,
6369
+ byteLength
6370
+ );
6371
+ }
6372
+ }
6373
+ function assertPptxTextWithinLimits(text2, limits) {
6374
+ const maximum = limits.maxInputBytes;
6375
+ if (text2.length * 3 <= maximum) {
6376
+ return;
6377
+ }
6378
+ const bytes = text2.length > maximum ? text2.length : utf8ByteLengthPast(text2, maximum);
6379
+ if (bytes > maximum) {
6380
+ throw new exports.PptxLoadLimitError(
6381
+ `PPTX input is at least ${count(bytes)} bytes, more than the maxInputBytes limit of ${count(maximum)}`,
6382
+ "maxInputBytes",
6383
+ maximum,
6384
+ bytes
6385
+ );
6386
+ }
6387
+ }
6388
+ function utf8ByteLengthPast(text2, maximum) {
6389
+ let bytes = 0;
6390
+ for (let index = 0; index < text2.length && bytes <= maximum; index++) {
6391
+ const unit = text2.charCodeAt(index);
6392
+ if (unit < 128) {
6393
+ bytes += 1;
6394
+ } else if (unit < 2048) {
6395
+ bytes += 2;
6396
+ } else if (unit >= 55296 && unit <= 56319 && isLowSurrogate(text2.charCodeAt(index + 1))) {
6397
+ bytes += 4;
6398
+ index++;
6399
+ } else {
6400
+ bytes += 3;
6401
+ }
6402
+ }
6403
+ return bytes;
6404
+ }
6405
+ function isLowSurrogate(unit) {
6406
+ return unit >= 56320 && unit <= 57343;
6407
+ }
6408
+ function assertPptxSlideCountWithinLimits(slideCount, limits) {
6409
+ if (slideCount > limits.maxSlides) {
6410
+ throw new exports.PptxLoadLimitError(
6411
+ `PPTX presentation has ${count(slideCount)} slides, more than the maxSlides limit of ${count(limits.maxSlides)}`,
6412
+ "maxSlides",
6413
+ limits.maxSlides,
6414
+ slideCount
6415
+ );
6416
+ }
6417
+ }
6418
+ function countPptxShapesWithinLimits(counted, elements3, limits) {
6419
+ const maximum = limits.maxShapes;
6420
+ if (maximum === Number.POSITIVE_INFINITY) {
6421
+ return counted;
6422
+ }
6423
+ const total = counted + countAuthoredElements(elements3);
6424
+ if (total > maximum) {
6425
+ throw new exports.PptxLoadLimitError(
6426
+ `PPTX presentation has at least ${count(total)} shapes, more than the maxShapes limit of ${count(maximum)}`,
6427
+ "maxShapes",
6428
+ maximum,
6429
+ total
6430
+ );
6431
+ }
6432
+ return total;
6433
+ }
6434
+ function countAuthoredElements(elements3) {
6435
+ let total = 0;
6436
+ const lists = [elements3];
6437
+ const positions = [0];
6438
+ while (lists.length > 0) {
6439
+ const top = lists.length - 1;
6440
+ const list3 = lists[top];
6441
+ const position3 = positions[top];
6442
+ if (position3 >= list3.length) {
6443
+ lists.pop();
6444
+ positions.pop();
6445
+ continue;
6446
+ }
6447
+ positions[top] = position3 + 1;
6448
+ const element = list3[position3];
6449
+ if (typeof element !== "object" || element === null) {
6450
+ continue;
6451
+ }
6452
+ const { id, type, children: children17 } = element;
6453
+ if (typeof id === "string" && isTemplateElementId(id)) {
6454
+ continue;
6455
+ }
6456
+ total++;
6457
+ if (type === "group" && Array.isArray(children17) && children17.length > 0) {
6458
+ lists.push(children17);
6459
+ positions.push(0);
6460
+ }
6461
+ }
6462
+ return total;
6463
+ }
6464
+ exports.DEFAULT_PPTX_LOAD_LIMITS = void 0; var LIMIT_NAMES; exports.PptxLoadLimitError = void 0; var count;
6465
+ var init_load_limits = __esm({
6466
+ "pptx/core/core/load-limits.ts"() {
6467
+ init_group_ops();
6468
+ init_types2();
6469
+ exports.DEFAULT_PPTX_LOAD_LIMITS = Object.freeze({
6470
+ maxInputBytes: Number.POSITIVE_INFINITY,
6471
+ maxUncompressedBytes: exports.DEFAULT_MAX_UNCOMPRESSED_BYTES,
6472
+ maxEntries: exports.MAX_ZIP_ENTRY_COUNT,
6473
+ maxSlides: Number.POSITIVE_INFINITY,
6474
+ maxShapes: Number.POSITIVE_INFINITY
6475
+ });
6476
+ LIMIT_NAMES = Object.keys(exports.DEFAULT_PPTX_LOAD_LIMITS);
6477
+ exports.PptxLoadLimitError = class extends Error {
6478
+ code = "PPTX_LOAD_LIMIT";
6479
+ /** The limit that was exceeded. */
6480
+ limit;
6481
+ /** The value of that limit. */
6482
+ maximum;
6483
+ /**
6484
+ * The observed value: exact for `maxSlides` and for `maxInputBytes` on
6485
+ * `load()`; for `maxShapes`, and for `maxInputBytes` on `loadFromJson()`
6486
+ * (which stops counting once past the limit), a lower bound.
6487
+ */
6488
+ actual;
6489
+ constructor(message, limit, maximum, actual) {
6490
+ super(message);
6491
+ this.name = "PptxLoadLimitError";
6492
+ this.limit = limit;
6493
+ this.maximum = maximum;
6494
+ this.actual = actual;
6495
+ }
6496
+ };
6497
+ count = (value) => value.toLocaleString("en-US");
6498
+ }
6499
+ });
6500
+
5922
6501
  // geometry/indexed.ts
5923
6502
  function at(items, index) {
5924
6503
  const value = items[index];
@@ -20501,365 +21080,6 @@ var init_preset_connection_sites_table = __esm({
20501
21080
  }
20502
21081
  });
20503
21082
 
20504
- // pptx/core/utils/clone-utils.ts
20505
- function isPlainRecord(value) {
20506
- if (typeof value !== "object" || value === null) {
20507
- return false;
20508
- }
20509
- const prototype = Object.getPrototypeOf(value);
20510
- return prototype === Object.prototype || prototype === null;
20511
- }
20512
- function cloneValue(value, seen) {
20513
- if (Array.isArray(value)) {
20514
- const cached2 = seen.get(value);
20515
- if (cached2 !== void 0) {
20516
- return cached2;
20517
- }
20518
- const copy3 = new Array(value.length);
20519
- seen.set(value, copy3);
20520
- for (let index = 0; index < value.length; index++) {
20521
- copy3[index] = cloneValue(value[index], seen);
20522
- }
20523
- return copy3;
20524
- }
20525
- if (!isPlainRecord(value)) {
20526
- return value;
20527
- }
20528
- const cached = seen.get(value);
20529
- if (cached !== void 0) {
20530
- return cached;
20531
- }
20532
- const copy2 = {};
20533
- seen.set(value, copy2);
20534
- for (const key2 of Object.keys(value)) {
20535
- const child32 = value[key2];
20536
- copy2[key2] = SHARED_RAW_XML_KEYS.has(key2) ? child32 : cloneValue(child32, seen);
20537
- }
20538
- return copy2;
20539
- }
20540
- function deepCloneData(value) {
20541
- return cloneValue(value, /* @__PURE__ */ new WeakMap());
20542
- }
20543
- function cloneTextStyle(style) {
20544
- if (!style) {
20545
- return void 0;
20546
- }
20547
- return deepCloneData(style);
20548
- }
20549
- function cloneShapeStyle(style) {
20550
- if (!style) {
20551
- return void 0;
20552
- }
20553
- return deepCloneData(style);
20554
- }
20555
- function cloneElement(element) {
20556
- return deepCloneData(element);
20557
- }
20558
- function cloneSlide(slide) {
20559
- return deepCloneData(slide);
20560
- }
20561
- function cloneTemplateElementsBySlideId(templateElementsBySlideId) {
20562
- const cloned = {};
20563
- Object.entries(templateElementsBySlideId).forEach(([slideId, elements3]) => {
20564
- cloned[slideId] = elements3.map(cloneElement);
20565
- });
20566
- return cloned;
20567
- }
20568
- function cloneXmlObject(value) {
20569
- if (!value) {
20570
- return void 0;
20571
- }
20572
- try {
20573
- if (typeof structuredClone === "function") {
20574
- return structuredClone(value);
20575
- }
20576
- return JSON.parse(JSON.stringify(value));
20577
- } catch (error) {
20578
- console.warn("Failed to clone XML object, returning undefined.", value, error);
20579
- return void 0;
20580
- }
20581
- }
20582
- var SHARED_RAW_XML_KEYS;
20583
- var init_clone_utils = __esm({
20584
- "pptx/core/utils/clone-utils.ts"() {
20585
- SHARED_RAW_XML_KEYS = /* @__PURE__ */ new Set([
20586
- "rawXml",
20587
- "rawTiming",
20588
- "inkPartRawXml",
20589
- "rawMediaReferenceXml"
20590
- ]);
20591
- }
20592
- });
20593
-
20594
- // pptx/core/utils/element-utils.ts
20595
- function isTemplateElement(element) {
20596
- return element.id.startsWith("layout-") || element.id.startsWith("master-");
20597
- }
20598
- function isEditableTextElement(element) {
20599
- if (element.type !== "text" && element.type !== "shape") {
20600
- return false;
20601
- }
20602
- return element.type === "text" || typeof element.text === "string" || (element.textSegments?.length ?? 0) > 0;
20603
- }
20604
- function getElementLabel(element) {
20605
- if (element.type === "text") {
20606
- return "Text";
20607
- }
20608
- if (element.type === "connector") {
20609
- return "Connector";
20610
- }
20611
- if (element.type === "image" || element.type === "picture") {
20612
- return "Image";
20613
- }
20614
- if (element.type === "chart") {
20615
- return "Chart";
20616
- }
20617
- if (element.type === "table") {
20618
- return "Table";
20619
- }
20620
- if (element.type === "smartArt") {
20621
- return "SmartArt";
20622
- }
20623
- if (element.type === "ole") {
20624
- return "Embedded Object";
20625
- }
20626
- if (element.type === "media") {
20627
- return "Media";
20628
- }
20629
- return "Shape";
20630
- }
20631
- function shouldRenderFallbackLabel(element, isTextElement2) {
20632
- if (isTextElement2) {
20633
- return false;
20634
- }
20635
- if (element.type === "shape" || element.type === "connector") {
20636
- return false;
20637
- }
20638
- if (element.type === "picture" || element.type === "image") {
20639
- return false;
20640
- }
20641
- if (element.type === "table") {
20642
- return false;
20643
- }
20644
- return element.type === "chart" || element.type === "smartArt" || element.type === "ole" || element.type === "media" || element.type === "unknown";
20645
- }
20646
- function getElementTextContent(element) {
20647
- if (!hasTextProperties(element)) {
20648
- return "";
20649
- }
20650
- if (typeof element.text === "string") {
20651
- return element.text;
20652
- }
20653
- if (!element.textSegments || element.textSegments.length === 0) {
20654
- return "";
20655
- }
20656
- return element.textSegments.map((segment) => String(segment.text || "")).join("");
20657
- }
20658
- function createUniformTextSegments(text2, style) {
20659
- return [
20660
- {
20661
- text: text2,
20662
- style: cloneTextStyle(style) || {}
20663
- }
20664
- ];
20665
- }
20666
- function createEditorId(prefix) {
20667
- const random = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
20668
- const sequence = (nextEditorIdSequence++).toString(36);
20669
- return `${prefix}-${Date.now()}-${random}${sequence}`;
20670
- }
20671
- function createDrawingObjectId() {
20672
- nextDrawingObjectId += 1;
20673
- return nextDrawingObjectId;
20674
- }
20675
- function createArrayBufferCopy(bytes) {
20676
- const copy2 = new Uint8Array(bytes.byteLength);
20677
- copy2.set(bytes);
20678
- return copy2.buffer;
20679
- }
20680
- function ensureArrayValue(value) {
20681
- if (!value) {
20682
- return [];
20683
- }
20684
- return Array.isArray(value) ? value : [value];
20685
- }
20686
- function formatCommentTimestamp(value) {
20687
- const normalized = String(value || "").trim();
20688
- if (normalized.length === 0) {
20689
- return "";
20690
- }
20691
- const parsed = new Date(normalized);
20692
- if (Number.isNaN(parsed.getTime())) {
20693
- return "";
20694
- }
20695
- return parsed.toLocaleString(void 0, {
20696
- month: "short",
20697
- day: "numeric",
20698
- hour: "2-digit",
20699
- minute: "2-digit"
20700
- });
20701
- }
20702
- function getCommentMarkerPosition(comment, index, width, height) {
20703
- const fallbackX = 18 + index % 4 * 14;
20704
- const fallbackY = 18 + Math.floor(index / 4) * 14;
20705
- const rawX = typeof comment.x === "number" && Number.isFinite(comment.x) ? comment.x : fallbackX;
20706
- const rawY = typeof comment.y === "number" && Number.isFinite(comment.y) ? comment.y : fallbackY;
20707
- return {
20708
- x: Math.min(Math.max(rawX, 8), Math.max(width - 8, 8)),
20709
- y: Math.min(Math.max(rawY, 8), Math.max(height - 8, 8))
20710
- };
20711
- }
20712
- async function readFileAsDataUrl(file) {
20713
- return await new Promise((resolve, reject) => {
20714
- const reader2 = new FileReader();
20715
- reader2.onload = () => {
20716
- const result = reader2.result;
20717
- if (typeof result !== "string") {
20718
- reject(new Error("Failed to read image file."));
20719
- return;
20720
- }
20721
- resolve(result);
20722
- };
20723
- reader2.onerror = () => {
20724
- reject(new Error("Failed to read image file."));
20725
- };
20726
- reader2.readAsDataURL(file);
20727
- });
20728
- }
20729
- var nextEditorIdSequence, DRAWING_OBJECT_ID_BASE, nextDrawingObjectId;
20730
- var init_element_utils = __esm({
20731
- "pptx/core/utils/element-utils.ts"() {
20732
- init_types();
20733
- init_clone_utils();
20734
- nextEditorIdSequence = 0;
20735
- DRAWING_OBJECT_ID_BASE = 1e5;
20736
- nextDrawingObjectId = DRAWING_OBJECT_ID_BASE;
20737
- }
20738
- });
20739
-
20740
- // pptx/core/utils/group-ops.ts
20741
- function isTemplateElementId(elementId) {
20742
- return elementId.startsWith("layout-") || elementId.startsWith("master-");
20743
- }
20744
- function makeStoreAwareId(intoTemplate, sourceId) {
20745
- if (!intoTemplate) {
20746
- return createEditorId("el");
20747
- }
20748
- return sourceId.startsWith("master-") ? `master-${createEditorId("el")}` : `layout-${createEditorId("el")}`;
20749
- }
20750
- function reassignDescendantIds(element, mintId) {
20751
- if (element.type !== "group") {
20752
- return;
20753
- }
20754
- for (const child32 of element.children) {
20755
- const next = mintId(child32);
20756
- if (next !== void 0) {
20757
- child32.id = next;
20758
- }
20759
- reassignDescendantIds(child32, mintId);
20760
- }
20761
- }
20762
- function groupElements(elements3, ids, groupId) {
20763
- const idSet = new Set(ids);
20764
- const gathered = [];
20765
- let insertionIndex = -1;
20766
- for (let i2 = 0; i2 < elements3.length; i2++) {
20767
- const el = elements3[i2];
20768
- if (idSet.has(el.id)) {
20769
- gathered.push(el);
20770
- if (insertionIndex === -1) {
20771
- insertionIndex = i2;
20772
- }
20773
- }
20774
- }
20775
- if (gathered.length < 2) {
20776
- return { elements: [...elements3], groupId: null };
20777
- }
20778
- let minX = gathered[0].x;
20779
- let minY = gathered[0].y;
20780
- let maxX = gathered[0].x + gathered[0].width;
20781
- let maxY = gathered[0].y + gathered[0].height;
20782
- for (let i2 = 1; i2 < gathered.length; i2++) {
20783
- const el = gathered[i2];
20784
- if (el.x < minX) {
20785
- minX = el.x;
20786
- }
20787
- if (el.y < minY) {
20788
- minY = el.y;
20789
- }
20790
- const rx = el.x + el.width;
20791
- const ry = el.y + el.height;
20792
- if (rx > maxX) {
20793
- maxX = rx;
20794
- }
20795
- if (ry > maxY) {
20796
- maxY = ry;
20797
- }
20798
- }
20799
- const children17 = gathered.map((el) => {
20800
- const child32 = cloneElement(el);
20801
- child32.x = el.x - minX;
20802
- child32.y = el.y - minY;
20803
- return child32;
20804
- });
20805
- const group = {
20806
- type: "group",
20807
- id: groupId,
20808
- name: "Group",
20809
- x: minX,
20810
- y: minY,
20811
- width: maxX - minX,
20812
- height: maxY - minY,
20813
- children: children17
20814
- };
20815
- const remaining = elements3.filter((el) => !idSet.has(el.id));
20816
- let adjustedIndex = 0;
20817
- for (let i2 = 0; i2 < insertionIndex; i2++) {
20818
- if (!idSet.has(elements3[i2].id)) {
20819
- adjustedIndex++;
20820
- }
20821
- }
20822
- return {
20823
- elements: [...remaining.slice(0, adjustedIndex), group, ...remaining.slice(adjustedIndex)],
20824
- groupId
20825
- };
20826
- }
20827
- function ungroupElements(elements3, groupId, childIds, options = {}) {
20828
- const groupIndex = elements3.findIndex((el) => el.id === groupId);
20829
- if (groupIndex === -1) {
20830
- return { elements: [...elements3], childIds: [] };
20831
- }
20832
- const group = elements3[groupIndex];
20833
- if (group.type !== "group") {
20834
- return { elements: [...elements3], childIds: [] };
20835
- }
20836
- const intoTemplate = options.intoTemplate ?? isTemplateElementId(group.id);
20837
- const usedChildIds = [];
20838
- const expanded = group.children.map((child32, index) => {
20839
- const newChildId = childIds[index] ?? child32.id;
20840
- usedChildIds.push(newChildId);
20841
- const promoted = cloneElement(child32);
20842
- promoted.id = newChildId;
20843
- promoted.x = child32.x + group.x;
20844
- promoted.y = child32.y + group.y;
20845
- reassignDescendantIds(
20846
- promoted,
20847
- (descendant) => isTemplateElementId(descendant.id) === intoTemplate ? void 0 : makeStoreAwareId(intoTemplate, newChildId)
20848
- );
20849
- return promoted;
20850
- });
20851
- return {
20852
- elements: [...elements3.slice(0, groupIndex), ...expanded, ...elements3.slice(groupIndex + 1)],
20853
- childIds: usedChildIds
20854
- };
20855
- }
20856
- var init_group_ops = __esm({
20857
- "pptx/core/utils/group-ops.ts"() {
20858
- init_clone_utils();
20859
- init_element_utils();
20860
- }
20861
- });
20862
-
20863
21083
  // pptx/core/utils/presentation-collections.ts
20864
21084
  function remapReferenceList(references, mapping, removed) {
20865
21085
  const result = [];
@@ -22531,9 +22751,9 @@ function decodeSlot(dir, id, majorVersion, warnings) {
22531
22751
  };
22532
22752
  }
22533
22753
  function readDirectory(dir, majorVersion, strict, warnings) {
22534
- const count = Math.floor(dir.length / DIR_ENTRY_SIZE);
22754
+ const count2 = Math.floor(dir.length / DIR_ENTRY_SIZE);
22535
22755
  const slots = [];
22536
- for (let id = 0; id < count; id++)
22756
+ for (let id = 0; id < count2; id++)
22537
22757
  slots.push(decodeSlot(dir, id, majorVersion, warnings));
22538
22758
  const roots = slots.filter((slot) => slot.type === ENTRY_TYPE_ROOT);
22539
22759
  if (roots.length !== 1 || !roots[0].nameValid)
@@ -23074,10 +23294,10 @@ function writeFatChain(fat, chain2) {
23074
23294
  fat[chain2.sectors[i2]] = i2 < chain2.sectors.length - 1 ? chain2.sectors[i2 + 1] : ENDOFCHAIN;
23075
23295
  }
23076
23296
  }
23077
- function writeFatRun(fat, firstSector, count) {
23078
- for (let i2 = 0; i2 < count; i2++) {
23297
+ function writeFatRun(fat, firstSector, count2) {
23298
+ for (let i2 = 0; i2 < count2; i2++) {
23079
23299
  const sector = firstSector + i2;
23080
- fat[sector] = i2 < count - 1 ? sector + 1 : ENDOFCHAIN;
23300
+ fat[sector] = i2 < count2 - 1 ? sector + 1 : ENDOFCHAIN;
23081
23301
  }
23082
23302
  }
23083
23303
  function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorSize) {
@@ -23595,21 +23815,21 @@ function parseChartFormulaRange(formula2) {
23595
23815
  }
23596
23816
  return { sheetName, start, end };
23597
23817
  }
23598
- function expandRangeAddresses(range, count) {
23818
+ function expandRangeAddresses(range, count2) {
23599
23819
  const { start, end } = range;
23600
- if (count <= 0) {
23820
+ if (count2 <= 0) {
23601
23821
  return void 0;
23602
23822
  }
23603
23823
  if (start.col === end.col && start.row === end.row) {
23604
- return count === 1 ? [formatCellAddress(start)] : void 0;
23824
+ return count2 === 1 ? [formatCellAddress(start)] : void 0;
23605
23825
  }
23606
23826
  if (start.col === end.col) {
23607
23827
  const length = end.row - start.row + 1;
23608
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
23828
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col, row: start.row + i2 })) : void 0;
23609
23829
  }
23610
23830
  if (start.row === end.row) {
23611
23831
  const length = end.col - start.col + 1;
23612
- return length === count ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
23832
+ return length === count2 ? Array.from({ length }, (_, i2) => formatCellAddress({ col: start.col + i2, row: start.row })) : void 0;
23613
23833
  }
23614
23834
  return void 0;
23615
23835
  }
@@ -25539,8 +25759,8 @@ function fcLcbFieldOffset(fib, key2) {
25539
25759
  }
25540
25760
  function readFcLcbAt(wordDoc, fib, index) {
25541
25761
  const view = new DataView(wordDoc.buffer, wordDoc.byteOffset, wordDoc.byteLength);
25542
- const count = view.getUint16(fib.fibRgFcLcbOffset - 2, true);
25543
- if (!Number.isInteger(index) || index < 0 || index >= count || fib.fibRgFcLcbCount !== void 0 && fib.fibRgFcLcbCount !== count)
25762
+ const count2 = view.getUint16(fib.fibRgFcLcbOffset - 2, true);
25763
+ if (!Number.isInteger(index) || index < 0 || index >= count2 || fib.fibRgFcLcbCount !== void 0 && fib.fibRgFcLcbCount !== count2)
25544
25764
  throw new Error("FIB fc/lcb index outside declared array");
25545
25765
  const off = fib.fibRgFcLcbOffset + index * 8;
25546
25766
  return { fc: view.getUint32(off, true), lcb: view.getUint32(off + 4, true) };
@@ -25772,7 +25992,7 @@ function appendCompoundAllocations(input, existingFatIds, payloads, sectorSize =
25772
25992
  const sectorCount = input.length / sectorSize - 1;
25773
25993
  const entriesPerFat = sectorSize / 4;
25774
25994
  const counts = payloads.map((payload) => Math.ceil(payload.length / sectorSize));
25775
- const payloadSectors = counts.reduce((sum, count) => sum + count, 0);
25995
+ const payloadSectors = counts.reduce((sum, count2) => sum + count2, 0);
25776
25996
  let fatCount = existingFatIds.length;
25777
25997
  while (sectorCount + payloadSectors + fatCount - existingFatIds.length > fatCount * entriesPerFat)
25778
25998
  fatCount++;
@@ -25857,21 +26077,21 @@ function resizeMiniCompoundStream(input, fat, fatIds, root, target, replacement,
25857
26077
  output2.view.setUint32(target.offset + 120, replacement.length, true);
25858
26078
  return output2.bytes;
25859
26079
  }
25860
- const firstMini = Math.ceil(root.size / MINI), count = Math.ceil(replacement.length / MINI);
25861
- const newRootSize = count ? (firstMini + count) * MINI : root.size;
26080
+ const firstMini = Math.ceil(root.size / MINI), count2 = Math.ceil(replacement.length / MINI);
26081
+ const newRootSize = count2 ? (firstMini + count2) * MINI : root.size;
25862
26082
  const newRoot = new Uint8Array(newRootSize);
25863
26083
  rootSectors.forEach((id, i2) => newRoot.set(input.subarray((id + 1) * SECTOR, (id + 1) * SECTOR + Math.min(SECTOR, root.size - i2 * SECTOR)), i2 * SECTOR));
25864
- if (count)
26084
+ if (count2)
25865
26085
  newRoot.set(replacement, firstMini * MINI);
25866
- const newMiniFatCount = Math.max(miniFatCount, Math.ceil((firstMini + count) / 128));
26086
+ const newMiniFatCount = Math.max(miniFatCount, Math.ceil((firstMini + count2) / 128));
25867
26087
  const newMiniFat = new Uint8Array(newMiniFatCount * SECTOR).fill(255);
25868
26088
  miniFatSectors.forEach((id, i2) => newMiniFat.set(input.subarray((id + 1) * SECTOR, (id + 2) * SECTOR), i2 * SECTOR));
25869
26089
  const miniView = new DataView(newMiniFat.buffer);
25870
26090
  if (wasMini)
25871
26091
  for (const id of oldChain)
25872
26092
  miniView.setUint32(id * 4, FREE2, true);
25873
- for (let i2 = 0; i2 < count; i2++)
25874
- miniView.setUint32((firstMini + i2) * 4, i2 + 1 === count ? END3 : firstMini + i2 + 1, true);
26093
+ for (let i2 = 0; i2 < count2; i2++)
26094
+ miniView.setUint32((firstMini + i2) * 4, i2 + 1 === count2 ? END3 : firstMini + i2 + 1, true);
25875
26095
  const output = appendCompoundAllocations(input, fatIds, [newRoot, newMiniFat]);
25876
26096
  if (!output)
25877
26097
  return void 0;
@@ -25881,7 +26101,7 @@ function resizeMiniCompoundStream(input, fat, fatIds, root, target, replacement,
25881
26101
  output.view.setUint32(root.offset + 120, newRootSize, true);
25882
26102
  output.view.setUint32(60, output.chains[1][0] ?? END3, true);
25883
26103
  output.view.setUint32(64, newMiniFatCount, true);
25884
- output.view.setUint32(target.offset + 116, count ? firstMini : END3, true);
26104
+ output.view.setUint32(target.offset + 116, count2 ? firstMini : END3, true);
25885
26105
  output.view.setUint32(target.offset + 120, replacement.length, true);
25886
26106
  return output.bytes;
25887
26107
  }
@@ -27396,9 +27616,9 @@ var init_deflate_encode = __esm({
27396
27616
  len = 0;
27397
27617
  acc = 0;
27398
27618
  nbits = 0;
27399
- bits(value, count) {
27619
+ bits(value, count2) {
27400
27620
  this.acc |= value << this.nbits;
27401
- this.nbits += count;
27621
+ this.nbits += count2;
27402
27622
  while (this.nbits >= 8) {
27403
27623
  this.push(this.acc & 255);
27404
27624
  this.acc >>>= 8;
@@ -27406,12 +27626,12 @@ var init_deflate_encode = __esm({
27406
27626
  }
27407
27627
  }
27408
27628
  /** Huffman codes are packed most-significant bit first. */
27409
- code(value, count) {
27629
+ code(value, count2) {
27410
27630
  let reversed = 0;
27411
- for (let i2 = 0; i2 < count; i2++) {
27631
+ for (let i2 = 0; i2 < count2; i2++) {
27412
27632
  reversed = reversed << 1 | value >>> i2 & 1;
27413
27633
  }
27414
- this.bits(reversed, count);
27634
+ this.bits(reversed, count2);
27415
27635
  }
27416
27636
  finish() {
27417
27637
  if (this.nbits > 0) {
@@ -31797,12 +32017,12 @@ function functionValue(condition, point2, lookup) {
31797
32017
  if (!target) {
31798
32018
  return void 0;
31799
32019
  }
31800
- const { pos: pos2, count } = siblingPosition(target, ptType);
32020
+ const { pos: pos2, count: count2 } = siblingPosition(target, ptType);
31801
32021
  if (condition.func === "pos") {
31802
32022
  return pos2;
31803
32023
  }
31804
32024
  if (condition.func === "revPos") {
31805
- return count - pos2 + 1;
32025
+ return count2 - pos2 + 1;
31806
32026
  }
31807
32027
  return condition.func === "posEven" ? pos2 % 2 === 0 ? 1 : 0 : pos2 % 2 === 1 ? 1 : 0;
31808
32028
  }
@@ -35014,19 +35234,19 @@ function pointTypeMatches(node, pointType2) {
35014
35234
  }
35015
35235
  return node.nodeType === pointType2;
35016
35236
  }
35017
- function selectRange(nodes, start, count) {
35018
- if (start === void 0 && count === void 0) {
35237
+ function selectRange(nodes, start, count2) {
35238
+ if (start === void 0 && count2 === void 0) {
35019
35239
  return nodes;
35020
35240
  }
35021
35241
  const zeroBasedStart = Math.max(0, (start ?? 1) - 1);
35022
- const take2 = count !== void 0 && count > 0 ? count : nodes.length - zeroBasedStart;
35242
+ const take2 = count2 !== void 0 && count2 > 0 ? count2 : nodes.length - zeroBasedStart;
35023
35243
  return nodes.slice(zeroBasedStart, zeroBasedStart + take2);
35024
35244
  }
35025
- function applyPointTypeAndRange(nodes, pointType2, start, count) {
35245
+ function applyPointTypeAndRange(nodes, pointType2, start, count2) {
35026
35246
  const filtered = pointType2 ? nodes.filter((n) => pointTypeMatches(n, pointType2)) : nodes;
35027
- return selectRange(filtered, start, count);
35247
+ return selectRange(filtered, start, count2);
35028
35248
  }
35029
- function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35249
+ function resolveAxisNodes(nodes, axis, pointTypes, start, count2, context) {
35030
35250
  if (axis.length === 0) {
35031
35251
  return void 0;
35032
35252
  }
@@ -35056,21 +35276,21 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35056
35276
  let current;
35057
35277
  let nextHop;
35058
35278
  if (axis[0] === "root" && axis.length > 1) {
35059
- current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count?.[1]);
35279
+ current = applyPointTypeAndRange(roots, pointTypes?.[1], start?.[1], count2?.[1]);
35060
35280
  nextHop = 2;
35061
35281
  } else if (axis[0] === "root") {
35062
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
35282
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
35063
35283
  nextHop = 1;
35064
35284
  } else if (context !== void 0) {
35065
35285
  current = applyPointTypeAndRange(
35066
35286
  navigateAxisHop(context, axis[0], nodes, childrenOf, parentOf, roots),
35067
35287
  pointTypes?.[0],
35068
35288
  start?.[0],
35069
- count?.[0]
35289
+ count2?.[0]
35070
35290
  );
35071
35291
  nextHop = 1;
35072
35292
  } else {
35073
- current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count?.[0]);
35293
+ current = applyPointTypeAndRange(roots, pointTypes?.[0], start?.[0], count2?.[0]);
35074
35294
  nextHop = 1;
35075
35295
  }
35076
35296
  for (let hop = nextHop; hop < axis.length; hop += 1) {
@@ -35078,13 +35298,13 @@ function resolveAxisNodes(nodes, axis, pointTypes, start, count, context) {
35078
35298
  navigateAxisHop(current, axis[hop], nodes, childrenOf, parentOf, roots),
35079
35299
  pointTypes?.[hop],
35080
35300
  start?.[hop],
35081
- count?.[hop]
35301
+ count2?.[hop]
35082
35302
  );
35083
35303
  }
35084
35304
  return current;
35085
35305
  }
35086
- function resolveAxisCount(nodes, axis, pointTypes, start, count, context) {
35087
- return resolveAxisNodes(nodes, axis, pointTypes, start, count, context)?.length;
35306
+ function resolveAxisCount(nodes, axis, pointTypes, start, count2, context) {
35307
+ return resolveAxisNodes(nodes, axis, pointTypes, start, count2, context)?.length;
35088
35308
  }
35089
35309
  var init_smartart_layout_interpreter_axis_count = __esm({
35090
35310
  "diagram/layout/smartart-layout-interpreter-axis-count.ts"() {
@@ -35110,14 +35330,14 @@ function depthFromAnchor(node, anchorId, byId) {
35110
35330
  }
35111
35331
  return void 0;
35112
35332
  }
35113
- function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count, anchor) {
35333
+ function resolveAxisMaxDepth(nodes, axis, pointTypes, start, count2, anchor) {
35114
35334
  if (anchor.length === 0) {
35115
35335
  return void 0;
35116
35336
  }
35117
35337
  const byId = new Map(nodes.map((n) => [n.id, n]));
35118
35338
  let max = 0;
35119
35339
  for (const anchorPoint of anchor) {
35120
- const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count, [anchorPoint]);
35340
+ const resolved = resolveAxisNodes(nodes, axis, pointTypes, start, count2, [anchorPoint]);
35121
35341
  if (resolved === void 0) {
35122
35342
  return void 0;
35123
35343
  }
@@ -35603,8 +35823,8 @@ function selectArrangedNodes(node, flat, roots) {
35603
35823
  const followSibCounts = collectFollowSibNodeCounts(node);
35604
35824
  if (followSibCounts.length > 0) {
35605
35825
  for (const i2 of [...indices]) {
35606
- for (const count of followSibCounts) {
35607
- for (let k = 1; k <= count; k++) {
35826
+ for (const count2 of followSibCounts) {
35827
+ for (let k = 1; k <= count2; k++) {
35608
35828
  const j = i2 + k;
35609
35829
  if (j < base.length) {
35610
35830
  indices.add(j);
@@ -37179,12 +37399,12 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path3) {
37179
37399
  const baseAngleRad = dist > 1e-6 ? Math.atan2(dy, dx) : 0;
37180
37400
  const halfExtent = Math.max(context.itemWidth, context.itemHeight) / 2;
37181
37401
  const radius = context.itemWidth / 2 + Math.max(0, context.gapPx) + halfExtent;
37182
- const count = children17.length;
37402
+ const count2 = children17.length;
37183
37403
  const spanRad = context.fanSpanDeg * DEG_TO_RAD2;
37184
37404
  const nodes = [];
37185
37405
  const connectors2 = [];
37186
37406
  children17.forEach((child32, i2) => {
37187
- const angle = count === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count - 1);
37407
+ const angle = count2 === 1 ? baseAngleRad : baseAngleRad - spanRad / 2 + spanRad * i2 / (count2 - 1);
37188
37408
  const cx = parentCentre.x + Math.cos(angle) * radius;
37189
37409
  const cy = parentCentre.y + Math.sin(angle) * radius;
37190
37410
  const key2 = `${context.elementId}-cycle-ext-${path3}-${i2}`;
@@ -37197,7 +37417,7 @@ function buildCycleRingExtensions(parentCentre, parentNode, context, path3) {
37197
37417
  height: context.itemHeight,
37198
37418
  node: child32,
37199
37419
  index: i2,
37200
- total: count,
37420
+ total: count2,
37201
37421
  palette: context.palette,
37202
37422
  style: context.style,
37203
37423
  ctx: context.ctx,
@@ -38374,12 +38594,12 @@ var init_smartart_layout_interpreter_linear_content_size = __esm({
38374
38594
  });
38375
38595
 
38376
38596
  // diagram/layout/smartart-layout-interpreter-axis-range.ts
38377
- function positionRange(start, count, step, total) {
38597
+ function positionRange(start, count2, step, total) {
38378
38598
  const out = [];
38379
38599
  const s = step > 0 ? step : 1;
38380
38600
  for (let i2 = Math.max(0, start - 1); i2 < total; i2 += s) {
38381
38601
  out.push(i2 + 1);
38382
- if (count !== void 0 && count > 0 && out.length >= count) {
38602
+ if (count2 !== void 0 && count2 > 0 && out.length >= count2) {
38383
38603
  break;
38384
38604
  }
38385
38605
  }
@@ -38399,8 +38619,8 @@ function compoundChildIds(role, node, childrenOf) {
38399
38619
  }
38400
38620
  const children17 = childrenOf.get(node.id) ?? [];
38401
38621
  const start = role.presentationOf?.start?.[chIndex] ?? 1;
38402
- const count = role.presentationOf?.count?.[chIndex];
38403
- const positions = positionRange(start, count, 1, children17.length);
38622
+ const count2 = role.presentationOf?.count?.[chIndex];
38623
+ const positions = positionRange(start, count2, 1, children17.length);
38404
38624
  const ids = [];
38405
38625
  for (const position3 of positions) {
38406
38626
  const child32 = children17[position3 - 1];
@@ -38974,9 +39194,9 @@ function arrangeSnake2(plan, nodes, box, palette, style, elementId, index = expo
38974
39194
  let y = INSET + row * (cellH + gapY);
38975
39195
  if (centerIncompleteLines) {
38976
39196
  const key2 = flowDir === "row" ? row : col;
38977
- const count = lineCounts.get(key2) ?? fullLineCount;
38978
- if (count < fullLineCount) {
38979
- const shift = (fullLineCount - count) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
39197
+ const count2 = lineCounts.get(key2) ?? fullLineCount;
39198
+ if (count2 < fullLineCount) {
39199
+ const shift = (fullLineCount - count2) * (flowDir === "row" ? cellW + gapX : cellH + gapY) / 2;
38980
39200
  if (flowDir === "row") {
38981
39201
  x += shift;
38982
39202
  } else {
@@ -39890,26 +40110,26 @@ var init_smartart_layout_interpreter_composite_foreach = __esm({
39890
40110
  });
39891
40111
 
39892
40112
  // diagram/hierarchy/smartart-hierarchy-pitch.ts
39893
- function computeAxisPitch(dimension, margin, itemSize, count, fixedGapRatio) {
39894
- const n = Math.max(1, count);
40113
+ function computeAxisPitch(dimension, margin, itemSize, count2, fixedGapRatio) {
40114
+ const n = Math.max(1, count2);
39895
40115
  const gap = n <= 1 ? 0 : fixedGapRatio !== void 0 ? itemSize * Math.max(0, fixedGapRatio) : Math.max(0, (dimension - margin - n * itemSize) / (n - 1));
39896
40116
  const pitch = itemSize + gap;
39897
40117
  const centeredShift = (dimension - n * pitch + margin) / 2;
39898
40118
  const maxShift = dimension - n * itemSize - gap * (n - 0.5);
39899
40119
  return { pitch, shift: Math.min(centeredShift, maxShift) };
39900
40120
  }
39901
- function centeredAxisPitch(dimension, itemSize, gapRatio, count) {
39902
- const n = Math.max(1, count);
40121
+ function centeredAxisPitch(dimension, itemSize, gapRatio, count2) {
40122
+ const n = Math.max(1, count2);
39903
40123
  const gap = n > 1 ? itemSize * Math.max(0, gapRatio) : 0;
39904
40124
  const pitch = itemSize + gap;
39905
40125
  const span = n * itemSize + Math.max(0, n - 1) * gap;
39906
40126
  const shift = (dimension - span) / 2;
39907
40127
  return { pitch, shift };
39908
40128
  }
39909
- function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count) {
40129
+ function compositeFanPitch(dimension, boxW, compositeWidthFactor, cardOffsetXRatio, sibSpRatio, count2) {
39910
40130
  const compositeW = compositeWidthFactor ? boxW / compositeWidthFactor : boxW;
39911
40131
  const cardOffsetX = cardOffsetXRatio * compositeW;
39912
- const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count);
40132
+ const centred = centeredAxisPitch(dimension, compositeW, sibSpRatio, count2);
39913
40133
  const correction = cardOffsetX + boxW / 2 - centred.pitch / 2;
39914
40134
  return { pitch: centred.pitch, shift: centred.shift + correction };
39915
40135
  }
@@ -40010,16 +40230,16 @@ function childAxisSpec(template, childCount) {
40010
40230
  const ownIndex = axis.indexOf("ch");
40011
40231
  if (ownIndex >= 0) {
40012
40232
  const start = template.presentationOf?.start?.[ownIndex] ?? 1;
40013
- const count = template.presentationOf?.count?.[ownIndex];
40014
- return { positions: positionRange(start, count, 1, childCount), fold };
40233
+ const count2 = template.presentationOf?.count?.[ownIndex];
40234
+ return { positions: positionRange(start, count2, 1, childCount), fold };
40015
40235
  }
40016
40236
  const origin = template.forEachOrigin;
40017
40237
  const originIndex = origin?.axis?.indexOf("ch") ?? -1;
40018
40238
  if (origin && originIndex >= 0) {
40019
40239
  const start = origin.start?.[originIndex] ?? 1;
40020
- const count = origin.count?.[originIndex];
40240
+ const count2 = origin.count?.[originIndex];
40021
40241
  const step = origin.step?.[originIndex] ?? 1;
40022
- return { positions: positionRange(start, count, step, childCount), fold };
40242
+ return { positions: positionRange(start, count2, step, childCount), fold };
40023
40243
  }
40024
40244
  return void 0;
40025
40245
  }
@@ -40215,8 +40435,8 @@ function slotRect(slot, box, absX, absY) {
40215
40435
  }
40216
40436
  function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40217
40437
  const perPoint = representativeSlotsPerPoint(slotted, nodes.length);
40218
- const count = Math.min(perPoint.length, nodes.length);
40219
- const slots = perPoint.slice(0, count).map((entry2) => slotRect(entry2, box, absX, absY));
40438
+ const count2 = Math.min(perPoint.length, nodes.length);
40439
+ const slots = perPoint.slice(0, count2).map((entry2) => slotRect(entry2, box, absX, absY));
40220
40440
  const fontFit = fontCtx ? resolveSharedFontFit(
40221
40441
  fontCtx,
40222
40442
  perPoint[0]?.node,
@@ -40228,7 +40448,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40228
40448
  }))
40229
40449
  ) : void 0;
40230
40450
  const rendered = [];
40231
- for (let i2 = 0; i2 < count; i2++) {
40451
+ for (let i2 = 0; i2 < count2; i2++) {
40232
40452
  const slot = slots[i2];
40233
40453
  rendered.push(
40234
40454
  presetBoxNode({
@@ -40239,7 +40459,7 @@ function arrangeByOrder(slotted, nodes, box, absX, absY, ctx, fontCtx) {
40239
40459
  height: slot.height,
40240
40460
  node: nodes[i2],
40241
40461
  index: i2,
40242
- total: count,
40462
+ total: count2,
40243
40463
  palette: ctx.palette,
40244
40464
  style: ctx.style,
40245
40465
  fontSizeOverride: fontFit?.rootSizePx,
@@ -40284,9 +40504,9 @@ var init_smartart_layout_interpreter_composite_ring = __esm({
40284
40504
  });
40285
40505
 
40286
40506
  // diagram/layout/smartart-layout-interpreter-composite-pairs.ts
40287
- function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count) {
40507
+ function collectSelfDesPairs(selfSlots, desSlots, allChildren, nodes, box, absX, absY, childrenOf, count2) {
40288
40508
  const pairs = [];
40289
- for (let i2 = 0; i2 < count; i2++) {
40509
+ for (let i2 = 0; i2 < count2; i2++) {
40290
40510
  const node = nodes[i2];
40291
40511
  const selfRect = resolveSlot(selfSlots[i2].dims, box, absX, absY);
40292
40512
  const desSlotted = desSlots[i2];
@@ -40379,7 +40599,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40379
40599
  }
40380
40600
  const desSlots = slotsWithAxis(slotted, "des");
40381
40601
  const childRepeaterSlots = slotted.filter((slot) => !slot.node.presentationOf);
40382
- const count = Math.min(selfSlots.length, nodes.length);
40602
+ const count2 = Math.min(selfSlots.length, nodes.length);
40383
40603
  const pairs = collectSelfDesPairs(
40384
40604
  selfSlots,
40385
40605
  desSlots,
@@ -40389,14 +40609,14 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40389
40609
  absX,
40390
40610
  absY,
40391
40611
  childrenOf,
40392
- count
40612
+ count2
40393
40613
  );
40394
40614
  const fontFit = resolveFontFitFromPairs(fontCtx, selfSlots[0]?.node, pairs);
40395
40615
  const rendered = [];
40396
- for (let i2 = 0; i2 < count; i2++) {
40616
+ for (let i2 = 0; i2 < count2; i2++) {
40397
40617
  const { node, selfRect, selfLayoutNode, desSlot } = pairs[i2];
40398
40618
  rendered.push(
40399
- ...renderAnchoredPair(node, i2, count, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
40619
+ ...renderAnchoredPair(node, i2, count2, selfRect, selfLayoutNode, desSlot, ctx, fontFit)
40400
40620
  );
40401
40621
  for (const wrapperSlot of childRepeaterSlots) {
40402
40622
  rendered.push(
@@ -40429,7 +40649,7 @@ function arrangeByPresentationOf(view, slotted, allChildren, nodes, flat, box, a
40429
40649
  absY,
40430
40650
  childrenOf,
40431
40651
  ctx,
40432
- count
40652
+ count2
40433
40653
  )
40434
40654
  );
40435
40655
  return rendered;
@@ -41146,11 +41366,11 @@ var init_smartart_hierarchy_orgchart_tree = __esm({
41146
41366
  // diagram/hierarchy/smartart-hierarchy-hang-depth.ts
41147
41367
  function countDescendants(t, orgChart) {
41148
41368
  const { normal } = partitionChildren(t, orgChart);
41149
- let count = normal.length;
41369
+ let count2 = normal.length;
41150
41370
  for (const child32 of normal) {
41151
- count += countDescendants(child32, orgChart);
41371
+ count2 += countDescendants(child32, orgChart);
41152
41372
  }
41153
- return count;
41373
+ return count2;
41154
41374
  }
41155
41375
  function fanContinues(t, perRow, orgChart, siblingCount, normalCount) {
41156
41376
  const chPrefFanEligible = Number.isFinite(perRow) && siblingCount === perRow && normalCount >= perRow;
@@ -41287,7 +41507,7 @@ var init_smartart_hierarchy_fan_aware_width = __esm({
41287
41507
  });
41288
41508
 
41289
41509
  // diagram/hierarchy/smartart-hierarchy-fold-depth.ts
41290
- function endsInUnboundedDescendantHop(axis, count) {
41510
+ function endsInUnboundedDescendantHop(axis, count2) {
41291
41511
  if (!axis || axis.length === 0) {
41292
41512
  return false;
41293
41513
  }
@@ -41296,7 +41516,7 @@ function endsInUnboundedDescendantHop(axis, count) {
41296
41516
  if (lastAxis !== "des" && lastAxis !== "desOrSelf") {
41297
41517
  return false;
41298
41518
  }
41299
- const lastCount = count?.[lastIndex];
41519
+ const lastCount = count2?.[lastIndex];
41300
41520
  return lastCount === void 0 || lastCount === 0;
41301
41521
  }
41302
41522
  function hierarchyLeafFoldsDescendants(node) {
@@ -41628,17 +41848,17 @@ var init_smartart_hierarchy_hanging_box = __esm({
41628
41848
  // diagram/hierarchy/smartart-hierarchy-hanging-fold.ts
41629
41849
  function countRows(t, level2, orgChart, fold) {
41630
41850
  const { assistants, normal } = partitionChildren(t, orgChart);
41631
- let count = 1 + assistants.length;
41851
+ let count2 = 1 + assistants.length;
41632
41852
  if (normal.length === 0) {
41633
- return count;
41853
+ return count2;
41634
41854
  }
41635
41855
  if (fold && level2 >= 1) {
41636
- return count;
41856
+ return count2;
41637
41857
  }
41638
41858
  for (const child32 of normal) {
41639
- count += countRows(child32, level2 + 1, orgChart, fold);
41859
+ count2 += countRows(child32, level2 + 1, orgChart, fold);
41640
41860
  }
41641
- return count;
41861
+ return count2;
41642
41862
  }
41643
41863
  function countHangingRows(roots, orgChart, fold) {
41644
41864
  return roots.reduce((sum, root) => sum + countRows(root, 0, orgChart, fold), 0);
@@ -47286,8 +47506,8 @@ function readPairs(element, vt) {
47286
47506
  const out = [];
47287
47507
  for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
47288
47508
  const name = variants[i2]?.textContent ?? "";
47289
- const count = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
47290
- out.push({ name, count: Number.isFinite(count) ? count : 0 });
47509
+ const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
47510
+ out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
47291
47511
  }
47292
47512
  return out;
47293
47513
  }
@@ -47504,9 +47724,9 @@ var init_custom = __esm({
47504
47724
  function titleGroups(headingPairs, titlesOfParts) {
47505
47725
  let offset = 0;
47506
47726
  return headingPairs.map((pair) => {
47507
- const count = Math.max(0, pair.count);
47508
- const titles = titlesOfParts.slice(offset, offset + count);
47509
- offset += count;
47727
+ const count2 = Math.max(0, pair.count);
47728
+ const titles = titlesOfParts.slice(offset, offset + count2);
47729
+ offset += count2;
47510
47730
  return { name: pair.name, titles };
47511
47731
  });
47512
47732
  }
@@ -69071,8 +69291,8 @@ var init_image_first_pixel_gif = __esm({
69071
69291
  return this.blockBytes[this.blockPos++];
69072
69292
  }
69073
69293
  /** Read `count` bits, LSB-first. Returns `undefined` at end of data. */
69074
- bits(count) {
69075
- while (this.bitCount < count) {
69294
+ bits(count2) {
69295
+ while (this.bitCount < count2) {
69076
69296
  const byte = this.nextByte();
69077
69297
  if (byte === void 0) {
69078
69298
  return void 0;
@@ -69080,9 +69300,9 @@ var init_image_first_pixel_gif = __esm({
69080
69300
  this.bitBuf |= byte << this.bitCount;
69081
69301
  this.bitCount += 8;
69082
69302
  }
69083
- const value = this.bitBuf & (1 << count) - 1;
69084
- this.bitBuf >>>= count;
69085
- this.bitCount -= count;
69303
+ const value = this.bitBuf & (1 << count2) - 1;
69304
+ this.bitBuf >>>= count2;
69305
+ this.bitCount -= count2;
69086
69306
  return value;
69087
69307
  }
69088
69308
  };
@@ -69103,12 +69323,12 @@ function decodeJpegHuffmanSymbol(reader2, table) {
69103
69323
  let index = 0;
69104
69324
  for (let len = 1; len <= 16; len++) {
69105
69325
  code = code << 1 | reader2.bits(1);
69106
- const count = table.counts[len];
69107
- if (count > 0 && code - first2 < count) {
69326
+ const count2 = table.counts[len];
69327
+ if (count2 > 0 && code - first2 < count2) {
69108
69328
  return table.symbols[index + (code - first2)];
69109
69329
  }
69110
- index += count;
69111
- first2 += count;
69330
+ index += count2;
69331
+ first2 += count2;
69112
69332
  first2 <<= 1;
69113
69333
  }
69114
69334
  throw new Error("jpeg: invalid Huffman code");
@@ -69158,9 +69378,9 @@ var init_image_first_pixel_jpeg_bitstream = __esm({
69158
69378
  return this.currentByte >> this.bitsLeftInByte & 1;
69159
69379
  }
69160
69380
  /** Read `count` (0-16) bits MSB-first as an unsigned integer. */
69161
- bits(count) {
69381
+ bits(count2) {
69162
69382
  let value = 0;
69163
- for (let i2 = 0; i2 < count; i2++) {
69383
+ for (let i2 = 0; i2 < count2; i2++) {
69164
69384
  value = value << 1 | this.nextBit();
69165
69385
  }
69166
69386
  return value >>> 0;
@@ -69446,12 +69666,12 @@ function decodeSymbol(reader2, table) {
69446
69666
  let index = 0;
69447
69667
  for (let len = 1; len < table.counts.length; len++) {
69448
69668
  code |= reader2.bits(1);
69449
- const count = table.counts[len];
69450
- if (code - first2 < count) {
69669
+ const count2 = table.counts[len];
69670
+ if (code - first2 < count2) {
69451
69671
  return table.symbols[index + (code - first2)];
69452
69672
  }
69453
- index += count;
69454
- first2 += count;
69673
+ index += count2;
69674
+ first2 += count2;
69455
69675
  first2 <<= 1;
69456
69676
  code <<= 1;
69457
69677
  }
@@ -69705,8 +69925,8 @@ var init_inflate = __esm({
69705
69925
  get bytePos() {
69706
69926
  return this.pos;
69707
69927
  }
69708
- bits(count) {
69709
- while (this.bitCount < count) {
69928
+ bits(count2) {
69929
+ while (this.bitCount < count2) {
69710
69930
  if (this.pos >= this.data.length) {
69711
69931
  throw new Error("inflate: unexpected end of stream");
69712
69932
  }
@@ -69714,9 +69934,9 @@ var init_inflate = __esm({
69714
69934
  this.pos++;
69715
69935
  this.bitCount += 8;
69716
69936
  }
69717
- const value = this.bitBuf & (1 << count) - 1;
69718
- this.bitBuf >>>= count;
69719
- this.bitCount -= count;
69937
+ const value = this.bitBuf & (1 << count2) - 1;
69938
+ this.bitBuf >>>= count2;
69939
+ this.bitCount -= count2;
69720
69940
  return value;
69721
69941
  }
69722
69942
  alignToByte() {
@@ -71141,12 +71361,12 @@ var init_chart_grid_operations = __esm({
71141
71361
 
71142
71362
  // pptx/core/utils/chart-data-sheet.ts
71143
71363
  function chartDataToSheet(data) {
71144
- const count = data.categories.length;
71364
+ const count2 = data.categories.length;
71145
71365
  return {
71146
71366
  categories: [...data.categories],
71147
71367
  series: data.series.map((series) => ({
71148
71368
  name: series.name,
71149
- values: Array.from({ length: count }, (_, index) => {
71369
+ values: Array.from({ length: count2 }, (_, index) => {
71150
71370
  const value = series.values[index];
71151
71371
  return typeof value === "number" && Number.isFinite(value) ? value : null;
71152
71372
  })
@@ -79790,7 +80010,7 @@ function parsedParagraphSignature(paragraph2) {
79790
80010
  return signatureOf(counts);
79791
80011
  }
79792
80012
  function signatureOf(counts) {
79793
- return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count]) => `${name}:${count}`).join(",");
80013
+ return [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([name, count2]) => `${name}:${count2}`).join(",");
79794
80014
  }
79795
80015
  function collectParsedParagraphs2(root) {
79796
80016
  const result = [];
@@ -83141,23 +83361,23 @@ function classify(chars, index) {
83141
83361
  }
83142
83362
  function countParagraphWords(text2) {
83143
83363
  const chars = Array.from(text2);
83144
- let count = 0;
83364
+ let count2 = 0;
83145
83365
  let previous = "none";
83146
83366
  for (let index = 0; index < chars.length; index++) {
83147
83367
  const kind = classify(chars, index);
83148
83368
  if (kind === "space") {
83149
83369
  if (previous === "none" || previous === "control") {
83150
- count++;
83370
+ count2++;
83151
83371
  }
83152
83372
  previous = "space";
83153
83373
  continue;
83154
83374
  }
83155
83375
  if (kind === "ideograph" || kind === "control" || kind !== previous) {
83156
- count++;
83376
+ count2++;
83157
83377
  }
83158
83378
  previous = kind;
83159
83379
  }
83160
- return count;
83380
+ return count2;
83161
83381
  }
83162
83382
  var LINE_BREAK_CHAR, WORD_CHAR, DIGIT_CHAR, IDEOGRAPH_CHAR, SPACE_CHAR, WORD_JOINERS, NUMBER_JOINERS;
83163
83383
  var init_app_properties_word_count = __esm({
@@ -83695,6 +83915,96 @@ var init_background_fill_shapes = __esm({
83695
83915
  }
83696
83916
  });
83697
83917
 
83918
+ // pptx/core/core/runtime/load-part-reader.ts
83919
+ function parseText3(parser, text2) {
83920
+ return text2 ? parser.parse(text2) : void 0;
83921
+ }
83922
+ function readPartText(zip, path3) {
83923
+ const reader2 = openReaders.get(zip);
83924
+ if (reader2) {
83925
+ return reader2.readText(path3);
83926
+ }
83927
+ return zip.file(path3)?.async("string") ?? Promise.resolve(void 0);
83928
+ }
83929
+ async function readPartXml(zip, parser, path3) {
83930
+ const reader2 = openReaders.get(zip);
83931
+ if (reader2) {
83932
+ return reader2.readXml(parser, path3);
83933
+ }
83934
+ const text2 = await zip.file(path3)?.async("string");
83935
+ return text2 ? parseText3(parser, text2) : void 0;
83936
+ }
83937
+ var openReaders, LoadPartReader;
83938
+ var init_load_part_reader = __esm({
83939
+ "pptx/core/core/runtime/load-part-reader.ts"() {
83940
+ openReaders = /* @__PURE__ */ new WeakMap();
83941
+ LoadPartReader = class {
83942
+ constructor(zip) {
83943
+ this.zip = zip;
83944
+ openReaders.set(zip, this);
83945
+ }
83946
+ zip;
83947
+ parts = /* @__PURE__ */ new Map();
83948
+ closed = false;
83949
+ entry(path3) {
83950
+ const file = this.zip.file(path3);
83951
+ if (!file) {
83952
+ this.parts.delete(path3);
83953
+ return void 0;
83954
+ }
83955
+ const previous = this.parts.get(path3);
83956
+ if (previous?.file === file) {
83957
+ return previous;
83958
+ }
83959
+ const entry2 = { file, text: file.async("string"), relationships: /* @__PURE__ */ new Map() };
83960
+ this.parts.set(path3, entry2);
83961
+ entry2.text.catch(() => {
83962
+ if (this.parts.get(path3) === entry2) {
83963
+ this.parts.delete(path3);
83964
+ }
83965
+ });
83966
+ return entry2;
83967
+ }
83968
+ readText(path3) {
83969
+ return this.entry(path3)?.text ?? Promise.resolve(void 0);
83970
+ }
83971
+ async readXml(parser, path3) {
83972
+ const entry2 = this.entry(path3);
83973
+ if (!entry2) {
83974
+ return void 0;
83975
+ }
83976
+ if (!path3.endsWith(".rels")) {
83977
+ return parseText3(parser, await entry2.text);
83978
+ }
83979
+ let parsed = entry2.relationships.get(parser);
83980
+ if (!parsed) {
83981
+ const pending = entry2.text.then((text2) => parseText3(parser, text2));
83982
+ entry2.relationships.set(parser, pending);
83983
+ pending.catch(() => {
83984
+ if (entry2.relationships.get(parser) === pending) {
83985
+ entry2.relationships.delete(parser);
83986
+ }
83987
+ });
83988
+ parsed = pending;
83989
+ }
83990
+ return structuredClone(await parsed);
83991
+ }
83992
+ /** Whether this reader still serves reads for its package. */
83993
+ get isOpen() {
83994
+ return !this.closed;
83995
+ }
83996
+ /** Drops every cached read; later reads of the package go to the archive. */
83997
+ close() {
83998
+ this.closed = true;
83999
+ if (openReaders.get(this.zip) === this) {
84000
+ openReaders.delete(this.zip);
84001
+ }
84002
+ this.parts.clear();
84003
+ }
84004
+ };
84005
+ }
84006
+ });
84007
+
83698
84008
  // pptx/core/core/builders/element-hidden-flag.ts
83699
84009
  function findCNvPr(shape) {
83700
84010
  if (!shape) {
@@ -83768,11 +84078,10 @@ var init_flatten_elements = __esm({
83768
84078
 
83769
84079
  // pptx/core/utils/slide-synchronization.ts
83770
84080
  async function loadSlideSynchronization(input) {
83771
- const relsXml = await input.zip.file(input.relsPath)?.async("string");
83772
- if (!relsXml) {
84081
+ const relsData = await readPartXml(input.zip, input.parser, input.relsPath);
84082
+ if (!relsData) {
83773
84083
  return void 0;
83774
84084
  }
83775
- const relsData = input.parser.parse(relsXml);
83776
84085
  const relationship2 = findSlideSyncRelationship(relsData);
83777
84086
  if (!relationship2) {
83778
84087
  return void 0;
@@ -83782,7 +84091,7 @@ async function loadSlideSynchronization(input) {
83782
84091
  return void 0;
83783
84092
  }
83784
84093
  const partPath = resolvePartPath2(input.slidePath, target);
83785
- const partXml = await input.zip.file(partPath)?.async("string");
84094
+ const partXml = await readPartText(input.zip, partPath);
83786
84095
  if (!partXml) {
83787
84096
  return void 0;
83788
84097
  }
@@ -83903,6 +84212,7 @@ function nextSlideSyncPath(files) {
83903
84212
  var SLIDE_SYNC_CONTENT_TYPE;
83904
84213
  var init_slide_synchronization = __esm({
83905
84214
  "pptx/core/utils/slide-synchronization.ts"() {
84215
+ init_load_part_reader();
83906
84216
  SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
83907
84217
  }
83908
84218
  });
@@ -83916,11 +84226,10 @@ function ensureArray9(value) {
83916
84226
  }
83917
84227
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83918
84228
  try {
83919
- const relsXml = await zip.file(relsPath2)?.async("string");
83920
- if (!relsXml) {
84229
+ const relsData = await readPartXml(zip, parser, relsPath2);
84230
+ if (!relsData) {
83921
84231
  return [];
83922
84232
  }
83923
- const relsData = parser.parse(relsXml);
83924
84233
  const relationships3 = ensureArray9(
83925
84234
  relsData["Relationships"]?.["Relationship"]
83926
84235
  );
@@ -83943,7 +84252,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83943
84252
  if (!resolved) {
83944
84253
  continue;
83945
84254
  }
83946
- const vmlXml = await zip.file(resolved)?.async("string");
84255
+ const vmlXml = await readPartText(zip, resolved);
83947
84256
  if (!vmlXml) {
83948
84257
  continue;
83949
84258
  }
@@ -83962,6 +84271,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83962
84271
  var VML_DRAWING_REL_SUFFIX;
83963
84272
  var init_vml_drawing_loader = __esm({
83964
84273
  "pptx/core/utils/vml-drawing-loader.ts"() {
84274
+ init_load_part_reader();
83965
84275
  init_safe_path();
83966
84276
  init_vml_parser();
83967
84277
  VML_DRAWING_REL_SUFFIX = "/relationships/vmlDrawing";
@@ -86144,10 +86454,10 @@ function assertAfterAnimationClearSupported(effectCTn) {
86144
86454
  if (!isXmlObject5(sub)) return;
86145
86455
  const countAfterFlags = (value) => {
86146
86456
  if (Array.isArray(value))
86147
- return value.reduce((count, child32) => count + countAfterFlags(child32), 0);
86457
+ return value.reduce((count2, child32) => count2 + countAfterFlags(child32), 0);
86148
86458
  if (!isXmlObject5(value)) return 0;
86149
86459
  return Object.entries(value).reduce(
86150
- (count, [key2, child32]) => count + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child32)) ? 1 : countAfterFlags(child32)),
86460
+ (count2, [key2, child32]) => count2 + (key2 === "@_afterEffect" && ["1", "true"].includes(String(child32)) ? 1 : countAfterFlags(child32)),
86151
86461
  0
86152
86462
  );
86153
86463
  };
@@ -86691,6 +87001,7 @@ exports.PptxSlideLoaderService = void 0;
86691
87001
  var init_PptxSlideLoaderService = __esm({
86692
87002
  "pptx/core/services/PptxSlideLoaderService.ts"() {
86693
87003
  init_background_fill_shapes();
87004
+ init_load_part_reader();
86694
87005
  init_element_hidden_flag();
86695
87006
  init_background_style_ref();
86696
87007
  init_flatten_elements();
@@ -86751,11 +87062,14 @@ var init_PptxSlideLoaderService = __esm({
86751
87062
  * @returns Map of relationship ID to target path string.
86752
87063
  */
86753
87064
  async loadPresentationSlideRels(params) {
86754
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
86755
- if (!relsXml) {
87065
+ const relsData = await readPartXml(
87066
+ params.zip,
87067
+ params.parser,
87068
+ "ppt/_rels/presentation.xml.rels"
87069
+ );
87070
+ if (!relsData) {
86756
87071
  return /* @__PURE__ */ new Map();
86757
87072
  }
86758
- const relsData = params.parser.parse(relsXml);
86759
87073
  const relationships3 = relsData["Relationships"]?.["Relationship"];
86760
87074
  const relNodes = this.toXmlObjectArray(relationships3);
86761
87075
  const relsMap = /* @__PURE__ */ new Map();
@@ -86795,7 +87109,7 @@ var init_PptxSlideLoaderService = __esm({
86795
87109
  if (!params.zip.file(path3)) {
86796
87110
  path3 = `ppt/${target}`;
86797
87111
  }
86798
- const slideXmlStr = await params.zip.file(path3)?.async("string");
87112
+ const slideXmlStr = await readPartText(params.zip, path3);
86799
87113
  if (!slideXmlStr) {
86800
87114
  return void 0;
86801
87115
  }
@@ -108327,8 +108641,8 @@ function reorderContainer(node, rawInner) {
108327
108641
  if (isGroupedByTag(children17.map((child32) => child32.tag))) {
108328
108642
  return;
108329
108643
  }
108330
- for (const [tag, count] of occurrence) {
108331
- if (ensureItems(node[tag]).length !== count) {
108644
+ for (const [tag, count2] of occurrence) {
108645
+ if (ensureItems(node[tag]).length !== count2) {
108332
108646
  return;
108333
108647
  }
108334
108648
  }
@@ -108350,8 +108664,8 @@ function annotateOmmlSiblingOrder(xml, parsed) {
108350
108664
  return;
108351
108665
  }
108352
108666
  const nodes = collectParsedOmathNodes(parsed);
108353
- const count = Math.min(fragments.length, nodes.length);
108354
- for (let index = 0; index < count; index++) {
108667
+ const count2 = Math.min(fragments.length, nodes.length);
108668
+ for (let index = 0; index < count2; index++) {
108355
108669
  if (fragments[index]) {
108356
108670
  reorderContainer(nodes[index], fragments[index]);
108357
108671
  }
@@ -109491,6 +109805,180 @@ var init_eot_parser = __esm({
109491
109805
  }
109492
109806
  });
109493
109807
 
109808
+ // pptx/core/utils/deferred-embedded-font.ts
109809
+ function resolveEmbeddedFontGuid(source) {
109810
+ if (isEotFormat(source.originalPartBytes)) {
109811
+ return void 0;
109812
+ }
109813
+ const { fontKey } = source;
109814
+ const fromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
109815
+ return fromKey || extractGuidFromPartName(source.partPath) || void 0;
109816
+ }
109817
+ function hasSfntSignature(bytes) {
109818
+ if (bytes.length < 4) {
109819
+ return false;
109820
+ }
109821
+ const [v0, v1, v2, v3] = bytes;
109822
+ 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);
109823
+ }
109824
+ function warnInvalidSignature(name, bytes) {
109825
+ const hex3 = Array.from(bytes.subarray(0, 4), (b) => b.toString(16)).join(",");
109826
+ console.warn(
109827
+ `[pptx-viewer] Embedded font "${name}" has invalid sfnt header [${hex3}] after processing; skipping (web font fallback will be used)`
109828
+ );
109829
+ }
109830
+ function isEmbeddedFontPartPlausible(source) {
109831
+ const bytes = source.originalPartBytes;
109832
+ if (bytes.length === 0) {
109833
+ return false;
109834
+ }
109835
+ if (isEotFormat(bytes)) {
109836
+ return true;
109837
+ }
109838
+ const guid = resolveEmbeddedFontGuid(source);
109839
+ if (!guid) {
109840
+ console.warn(
109841
+ `[pptx-viewer] Embedded font "${source.name}" at "${source.partPath}" has no fontKey attribute and no GUID in filename; skipping`
109842
+ );
109843
+ return false;
109844
+ }
109845
+ const header = deobfuscateFont(bytes.subarray(0, Math.min(bytes.length, 32)), guid);
109846
+ if (header.length < 4) {
109847
+ return false;
109848
+ }
109849
+ if (!hasSfntSignature(header)) {
109850
+ warnInvalidSignature(source.name, header);
109851
+ return false;
109852
+ }
109853
+ return true;
109854
+ }
109855
+ function uint8ArrayToBase642(bytes) {
109856
+ let binary = "";
109857
+ const chunkSize = 8192;
109858
+ for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
109859
+ const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
109860
+ for (let j = 0; j < chunk2.length; j++) {
109861
+ binary += String.fromCharCode(chunk2[j]);
109862
+ }
109863
+ }
109864
+ return btoa(binary);
109865
+ }
109866
+ function decodeEmbeddedFontPart(source) {
109867
+ const { name, partPath, originalPartBytes } = source;
109868
+ try {
109869
+ let fontData;
109870
+ const fontGuid = resolveEmbeddedFontGuid(source);
109871
+ if (isEotFormat(originalPartBytes)) {
109872
+ const extracted = extractFontFromEot(originalPartBytes);
109873
+ if (!extracted) {
109874
+ const header = parseEotHeader(originalPartBytes);
109875
+ console.info(
109876
+ `[pptx-viewer] Embedded font "${name}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""}; extraction failed, will use web font fallback`
109877
+ );
109878
+ return null;
109879
+ }
109880
+ fontData = extracted.fontData;
109881
+ } else if (fontGuid) {
109882
+ fontData = deobfuscateFont(originalPartBytes, fontGuid);
109883
+ } else {
109884
+ console.warn(
109885
+ `[pptx-viewer] Embedded font "${name}" at "${partPath}" has no fontKey attribute and no GUID in filename; skipping`
109886
+ );
109887
+ return null;
109888
+ }
109889
+ if (fontData.length < 4) {
109890
+ return null;
109891
+ }
109892
+ if (!hasSfntSignature(fontData)) {
109893
+ warnInvalidSignature(name, fontData);
109894
+ return null;
109895
+ }
109896
+ const format = detectFontFormat(fontData);
109897
+ const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
109898
+ return {
109899
+ name,
109900
+ dataUrl: `data:${mimeType};base64,${uint8ArrayToBase642(fontData)}`,
109901
+ bold: source.bold,
109902
+ italic: source.italic,
109903
+ format,
109904
+ rawFontData: fontData,
109905
+ partPath,
109906
+ fontGuid,
109907
+ originalRId: source.originalRId,
109908
+ originalPartBytes
109909
+ };
109910
+ } catch {
109911
+ return null;
109912
+ }
109913
+ }
109914
+ function createDeferredEmbeddedFont(source) {
109915
+ const fontGuid = resolveEmbeddedFontGuid(source);
109916
+ let fields;
109917
+ let pending;
109918
+ const decode = () => {
109919
+ if (!fields) {
109920
+ const decoded = decodeEmbeddedFontPart(source);
109921
+ fields = {
109922
+ dataUrl: decoded?.dataUrl ?? "",
109923
+ format: decoded?.format,
109924
+ rawFontData: decoded?.rawFontData
109925
+ };
109926
+ }
109927
+ return fields;
109928
+ };
109929
+ const font = {
109930
+ name: source.name,
109931
+ get dataUrl() {
109932
+ return decode().dataUrl;
109933
+ },
109934
+ set dataUrl(value) {
109935
+ decode().dataUrl = value;
109936
+ },
109937
+ bold: source.bold,
109938
+ italic: source.italic,
109939
+ get format() {
109940
+ return decode().format;
109941
+ },
109942
+ set format(value) {
109943
+ decode().format = value;
109944
+ },
109945
+ get rawFontData() {
109946
+ return decode().rawFontData;
109947
+ },
109948
+ set rawFontData(value) {
109949
+ decode().rawFontData = value;
109950
+ },
109951
+ partPath: source.partPath,
109952
+ fontGuid,
109953
+ originalRId: source.originalRId,
109954
+ originalPartBytes: source.originalPartBytes
109955
+ };
109956
+ Object.defineProperties(font, {
109957
+ load: {
109958
+ value: () => pending ??= Promise.resolve().then(
109959
+ () => decode().rawFontData?.length || decode().dataUrl ? font : null
109960
+ )
109961
+ },
109962
+ isLoaded: { get: () => fields !== void 0 }
109963
+ });
109964
+ return font;
109965
+ }
109966
+ function shouldSaveEmbeddedFontVerbatim(font) {
109967
+ if (font.isLoaded === void 0 || !font.originalPartBytes?.length) {
109968
+ return false;
109969
+ }
109970
+ if (!font.originalRId || !font.partPath) {
109971
+ return false;
109972
+ }
109973
+ return font.isLoaded === false || !font.rawFontData?.length;
109974
+ }
109975
+ var init_deferred_embedded_font = __esm({
109976
+ "pptx/core/utils/deferred-embedded-font.ts"() {
109977
+ init_eot_parser();
109978
+ init_font_deobfuscation();
109979
+ }
109980
+ });
109981
+
109494
109982
  // pptx/core/core/runtime/header-footer-parts.ts
109495
109983
  function asArray3(value) {
109496
109984
  if (Array.isArray(value)) {
@@ -111292,12 +111780,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
111292
111780
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
111293
111781
  const target = resolve(chartPartPath, external.targetPath);
111294
111782
  let references = 0;
111295
- const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
111296
111783
  try {
111297
111784
  for (const path3 of Object.keys(zip.files)) {
111298
111785
  if (!path3.endsWith(".rels") || !path3.includes("/_rels/")) continue;
111299
111786
  const source = path3.replace("/_rels/", "/").slice(0, -5);
111300
- const tree = parser.parse(await zip.file(path3).async("string"));
111787
+ const tree = await readPartXml(zip, relationshipParser, path3);
111301
111788
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
111302
111789
  const relationshipTarget2 = xmlAttr(rel, "Target");
111303
111790
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve(source, relationshipTarget2) === target)
@@ -111314,11 +111801,14 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
111314
111801
  return false;
111315
111802
  }
111316
111803
  }
111804
+ var relationshipParser;
111317
111805
  var init_chart_label_source = __esm({
111318
111806
  "pptx/core/utils/chart-label-source.ts"() {
111807
+ init_load_part_reader();
111319
111808
  init_chart_xlsx_writer();
111320
111809
  init_xml_access();
111321
111810
  init_chart_xlsx_cellref();
111811
+ relationshipParser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
111322
111812
  }
111323
111813
  });
111324
111814
 
@@ -111545,10 +112035,10 @@ function collectFilteredSeriesIndices(container2, xmlLookup) {
111545
112035
  }
111546
112036
  return reserved;
111547
112037
  }
111548
- function assignSeriesIndices(count, reservedIndices) {
112038
+ function assignSeriesIndices(count2, reservedIndices) {
111549
112039
  const assigned = [];
111550
112040
  let cursor = 0;
111551
- for (let i2 = 0; i2 < count; i2++) {
112041
+ for (let i2 = 0; i2 < count2; i2++) {
111552
112042
  while (reservedIndices.has(cursor)) {
111553
112043
  cursor++;
111554
112044
  }
@@ -112237,8 +112727,8 @@ function parseCache(node) {
112237
112727
  return point2;
112238
112728
  })
112239
112729
  };
112240
- const count = Number(cVal(node, "ptCount") ?? Number.NaN);
112241
- if (Number.isInteger(count) && count >= 0) cache2.pointCount = count;
112730
+ const count2 = Number(cVal(node, "ptCount") ?? Number.NaN);
112731
+ if (Number.isInteger(count2) && count2 >= 0) cache2.pointCount = count2;
112242
112732
  const formatCode2 = cChild(node, "formatCode")?.textContent;
112243
112733
  if (formatCode2) cache2.formatCode = formatCode2;
112244
112734
  return cache2;
@@ -112256,8 +112746,8 @@ function parseDataSource(element) {
112256
112746
  const levels = cChild(ref, "multiLvlStrCache");
112257
112747
  if (levels) {
112258
112748
  source.levels = children2(levels, "lvl", NS.c).map(parseCache);
112259
- const count = Number(cVal(levels, "ptCount") ?? Number.NaN);
112260
- if (Number.isInteger(count) && count >= 0) source.levelPointCount = count;
112749
+ const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
112750
+ if (Number.isInteger(count2) && count2 >= 0) source.levelPointCount = count2;
112261
112751
  }
112262
112752
  return source;
112263
112753
  }
@@ -113824,7 +114314,7 @@ function parseChartData(context, element) {
113824
114314
  }
113825
114315
  return out;
113826
114316
  }
113827
- function parseText3(context, element) {
114317
+ function parseText4(context, element) {
113828
114318
  if (!element) return void 0;
113829
114319
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
113830
114320
  const data = cxChild(element, "txData");
@@ -113844,7 +114334,7 @@ function parseTitle2(context, element) {
113844
114334
  return assignDefined(
113845
114335
  {},
113846
114336
  {
113847
- tx: parseText3(context, cxChild(element, "tx")),
114337
+ tx: parseText4(context, cxChild(element, "tx")),
113848
114338
  spPr: shapeProperties2(element),
113849
114339
  txPr: textProperties2(element),
113850
114340
  position: attribute6(element, "pos"),
@@ -114089,7 +114579,7 @@ function parseSeries2(context, element) {
114089
114579
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
114090
114580
  uniqueId: attribute6(element, "uniqueId"),
114091
114581
  formatIndex: numberAttribute(context, element, "formatIdx"),
114092
- tx: parseText3(context, cxChild(element, "tx")),
114582
+ tx: parseText4(context, cxChild(element, "tx")),
114093
114583
  spPr: shapeProperties2(element),
114094
114584
  txPr: textProperties2(element),
114095
114585
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -121980,9 +122470,9 @@ function buildFopt(simple, complex = []) {
121980
122470
  payload.bytes(bytes);
121981
122471
  }
121982
122472
  }
121983
- const count = simple.length + complex.length;
122473
+ const count2 = simple.length + complex.length;
121984
122474
  const data = new ByteWriter().append(entries).append(payload).toBytes();
121985
- return record(OA.FOPT, data, count, false, 3);
122475
+ return record(OA.FOPT, data, count2, false, 3);
121986
122476
  }
121987
122477
  function buildMetroBlobTertiaryFopt(metroBlob) {
121988
122478
  const data = new ByteWriter().u16(METRO_BLOB_OPID | 32768 | FBID_FLAG).u32(metroBlob.length >>> 0).bytes(metroBlob).toBytes();
@@ -122046,9 +122536,9 @@ function buildDgg(shapesPerDrawing, totalShapes) {
122046
122536
  const cidcl = drawingCount + 1;
122047
122537
  const cspSaved = totalShapes - drawingCount;
122048
122538
  const w = new ByteWriter().u32(maxShapeId).u32(cidcl).u32(cspSaved).u32(drawingCount);
122049
- shapesPerDrawing.forEach((count, i2) => {
122539
+ shapesPerDrawing.forEach((count2, i2) => {
122050
122540
  const drawingId = i2 + 1;
122051
- w.u32(drawingId).u32(count);
122541
+ w.u32(drawingId).u32(count2);
122052
122542
  });
122053
122543
  return record(OA.Dgg, w.toBytes(), 0, false, 0);
122054
122544
  }
@@ -122876,8 +123366,8 @@ function atom(recType, data) {
122876
123366
  function textHeader(textType) {
122877
123367
  return atom(RT.TextHeaderAtom, new ByteWriter().u32(textType).toBytes());
122878
123368
  }
122879
- function textSpecInfo(count) {
122880
- return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count).u32(1).u16(0).toBytes());
123369
+ function textSpecInfo(count2) {
123370
+ return atom(RT.TextSpecInfoAtom, new ByteWriter().u32(count2).u32(1).u16(0).toBytes());
122881
123371
  }
122882
123372
  function promptText(textType, paragraphs) {
122883
123373
  const text2 = paragraphs.join("\r");
@@ -123688,17 +124178,17 @@ function slideMasterIndex(masterIndex, masterCount) {
123688
124178
  return masterIndex !== void 0 && Number.isInteger(masterIndex) && masterIndex >= 0 && masterIndex < masterCount ? masterIndex : 0;
123689
124179
  }
123690
124180
  function countDrawingShapes(shapes) {
123691
- let count = 1;
124181
+ let count2 = 1;
123692
124182
  const walk3 = (list3) => {
123693
124183
  for (const shape of list3) {
123694
- count++;
124184
+ count2++;
123695
124185
  if (shape.kind === "group") {
123696
124186
  walk3(shape.children);
123697
124187
  }
123698
124188
  }
123699
124189
  };
123700
124190
  walk3(shapes);
123701
- return count;
124191
+ return count2;
123702
124192
  }
123703
124193
  function collectFonts(deck, masters) {
123704
124194
  const collect = (shape) => {
@@ -124279,7 +124769,7 @@ function toLevel(style = {}, themeFonts = {}) {
124279
124769
  }
124280
124770
  };
124281
124771
  }
124282
- function toLevels(levels, count, themeFonts) {
124772
+ function toLevels(levels, count2, themeFonts) {
124283
124773
  if (!levels) {
124284
124774
  return void 0;
124285
124775
  }
@@ -124289,7 +124779,7 @@ function toLevels(levels, count, themeFonts) {
124289
124779
  }
124290
124780
  const base = levels[-1];
124291
124781
  return Array.from(
124292
- { length: count },
124782
+ { length: count2 },
124293
124783
  (_, i2) => toLevel(base || levels[i2] ? { ...base, ...levels[i2] } : void 0, themeFonts)
124294
124784
  );
124295
124785
  }
@@ -125198,12 +125688,12 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
125198
125688
  }
125199
125689
  if (Array.isArray(node)) {
125200
125690
  return node.reduce(
125201
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
125691
+ (count3, entry2) => count3 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
125202
125692
  0
125203
125693
  );
125204
125694
  }
125205
125695
  const object = node;
125206
- let count = 0;
125696
+ let count2 = 0;
125207
125697
  for (const key2 of Object.keys(object)) {
125208
125698
  if (key2.startsWith("@_")) {
125209
125699
  continue;
@@ -125215,14 +125705,14 @@ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
125215
125705
  const chart = chartKey ? candidate[chartKey] : void 0;
125216
125706
  if (chart && String(chart["@_r:id"]) === relationshipId2) {
125217
125707
  rebindGraphicData(candidate, relationshipId2, extended);
125218
- count += 1;
125708
+ count2 += 1;
125219
125709
  }
125220
125710
  }
125221
125711
  continue;
125222
125712
  }
125223
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
125713
+ count2 += visitGraphicData(value, relationshipId2, extended, getLocalName2);
125224
125714
  }
125225
- return count;
125715
+ return count2;
125226
125716
  }
125227
125717
  async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
125228
125718
  const xml = await deps.zip.file(slidePath)?.async("string");
@@ -125230,11 +125720,11 @@ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, exten
125230
125720
  return 0;
125231
125721
  }
125232
125722
  const tree = deps.parser.parse(xml);
125233
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
125234
- if (count > 0) {
125723
+ const count2 = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
125724
+ if (count2 > 0) {
125235
125725
  deps.zip.file(slidePath, deps.builder.build(tree));
125236
125726
  }
125237
- return count;
125727
+ return count2;
125238
125728
  }
125239
125729
  var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
125240
125730
  var init_chart_part_registration = __esm({
@@ -127709,8 +128199,8 @@ async function discoverTagCollections(zip, codec) {
127709
128199
  if (!sourcePartPath) {
127710
128200
  continue;
127711
128201
  }
127712
- const data = codec.parse(await relFile.async("string"));
127713
- const root = data["Relationships"];
128202
+ const data = await readPartXml(zip, codec, relFile.name);
128203
+ const root = data?.["Relationships"];
127714
128204
  for (const relationship2 of ensureArray17(root?.["Relationship"])) {
127715
128205
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
127716
128206
  continue;
@@ -127815,7 +128305,7 @@ async function removeTagContentTypeOverride(zip, codec, path3) {
127815
128305
  zip.file("[Content_Types].xml", codec.build(data));
127816
128306
  }
127817
128307
  async function readTagCollection(zip, codec, path3) {
127818
- const xml = await zip.file(path3)?.async("string");
128308
+ const xml = await readPartText(zip, path3);
127819
128309
  if (!xml) {
127820
128310
  return void 0;
127821
128311
  }
@@ -127924,6 +128414,7 @@ function ensureArray17(value) {
127924
128414
  var TAG_RELATIONSHIP_TYPE, TAG_CONTENT_TYPE;
127925
128415
  var init_tag_package = __esm({
127926
128416
  "pptx/core/utils/tag-package.ts"() {
128417
+ init_load_part_reader();
127927
128418
  init_safe_path();
127928
128419
  init_tag_package_owning_element();
127929
128420
  TAG_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags";
@@ -133257,10 +133748,35 @@ var init_PptxHandlerRuntimeState = __esm({
133257
133748
  "pptx/core/core/runtime/PptxHandlerRuntimeState.ts"() {
133258
133749
  init_utils();
133259
133750
  init_part_rels_path();
133751
+ init_load_part_reader();
133260
133752
  init_template_element_baselines();
133261
133753
  PptxHandlerRuntime = class {
133262
133754
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
133263
133755
  zip;
133756
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
133757
+ loadPartReader;
133758
+ /** Opens a part reader for the current package, closing any earlier one. */
133759
+ beginPartReads() {
133760
+ this.endPartReads();
133761
+ const reader2 = new LoadPartReader(this.zip);
133762
+ this.loadPartReader = reader2;
133763
+ return reader2;
133764
+ }
133765
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
133766
+ endPartReads(reader2 = this.loadPartReader) {
133767
+ reader2?.close();
133768
+ if (reader2 && this.loadPartReader === reader2) {
133769
+ this.loadPartReader = void 0;
133770
+ }
133771
+ }
133772
+ /** The text of a package part, shared within a load. */
133773
+ readPartText(path3) {
133774
+ return readPartText(this.zip, path3);
133775
+ }
133776
+ /** A parsed package part; relationship parts are parsed once per load. */
133777
+ readPartXml(path3) {
133778
+ return readPartXml(this.zip, this.parser, path3);
133779
+ }
133264
133780
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
133265
133781
  parser;
133266
133782
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -133524,6 +134040,8 @@ var init_PptxHandlerRuntimeState = __esm({
133524
134040
  alternateContentBlockByRawXml = /* @__PURE__ */ new WeakMap();
133525
134041
  /** Embedded fonts extracted during load, preserved for automatic re-embedding on save. */
133526
134042
  loadedEmbeddedFonts = [];
134043
+ /** Decode every embedded font variant during load (see `PptxHandlerLoadOptions`). */
134044
+ eagerDecodeEmbeddedFonts = false;
133527
134045
  /** Typed source metadata for lossless embedded-font list round trips. */
133528
134046
  loadedEmbeddedFontList;
133529
134047
  /**
@@ -133679,11 +134197,11 @@ var init_PptxHandlerRuntimeState = __esm({
133679
134197
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
133680
134198
  */
133681
134199
  async loadPartRelationships(partPath, relsPath2) {
133682
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
133683
- if (!relsXml) {
134200
+ const path3 = relsPath2 ?? partRelsPath(partPath);
134201
+ const relsData = await this.readPartXml(path3);
134202
+ if (!relsData) {
133684
134203
  return;
133685
134204
  }
133686
- const relsData = this.parser.parse(relsXml);
133687
134205
  const relationships3 = relsData?.["Relationships"];
133688
134206
  const raw2 = relationships3?.["Relationship"];
133689
134207
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -135212,10 +135730,6 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135212
135730
  this.zip.file(relsPath2, this.builder.build(relsData));
135213
135731
  return true;
135214
135732
  }
135215
- /** The text of a package part, or `undefined` when the package has no such part. */
135216
- async readPartText(path3) {
135217
- return this.zip.file(path3)?.async("string");
135218
- }
135219
135733
  /**
135220
135734
  * Parse extended (application) properties from `docProps/app.xml`.
135221
135735
  */
@@ -135276,8 +135790,10 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135276
135790
  if (!relsFile) {
135277
135791
  return [];
135278
135792
  }
135279
- const relsXml = await relsFile.async("string");
135280
- const relsData = this.parser.parse(relsXml);
135793
+ const relsData = await this.readPartXml(relsPath2);
135794
+ if (!relsData) {
135795
+ return [];
135796
+ }
135281
135797
  const relRoot = relsData["Relationships"] || {};
135282
135798
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
135283
135799
  const relMap = /* @__PURE__ */ new Map();
@@ -135308,7 +135824,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135308
135824
  try {
135309
135825
  const file = this.zip.file(resolvedPath);
135310
135826
  if (file) {
135311
- data = await file.async("string");
135827
+ data = await this.readPartText(resolvedPath);
135312
135828
  }
135313
135829
  } catch {
135314
135830
  }
@@ -135388,9 +135904,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135388
135904
  */
135389
135905
  async parseTags() {
135390
135906
  try {
135391
- return await discoverTagCollections(this.zip, {
135392
- parse: (xml) => this.parser.parse(xml)
135393
- });
135907
+ return await discoverTagCollections(this.zip, this.parser);
135394
135908
  } catch (e) {
135395
135909
  console.warn("Failed to parse tags:", e);
135396
135910
  return [];
@@ -135530,7 +136044,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135530
136044
  }
135531
136045
  for (const file of masterFiles) {
135532
136046
  const path3 = file.name;
135533
- const xml = await file.async("string");
136047
+ const xml = await this.readPartText(path3) ?? "";
135534
136048
  const data = this.parser.parse(xml);
135535
136049
  const sldMaster = data?.["p:sldMaster"];
135536
136050
  if (!sldMaster) {
@@ -135555,8 +136069,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135555
136069
  );
135556
136070
  const relsFile = this.zip.file(relsPath2);
135557
136071
  if (relsFile) {
135558
- const relsXml = await relsFile.async("string");
135559
- const relsData = this.parser.parse(relsXml);
136072
+ const relsData = await this.readPartXml(relsPath2);
135560
136073
  const rels = this.ensureArray(
135561
136074
  xmlChild(relsData, "Relationships")?.["Relationship"]
135562
136075
  );
@@ -135570,8 +136083,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135570
136083
  }
135571
136084
  const layoutPaths = [];
135572
136085
  if (relsFile) {
135573
- const relsXml = await relsFile.async("string");
135574
- const relsData = this.parser.parse(relsXml);
136086
+ const relsData = await this.readPartXml(relsPath2);
135575
136087
  const rels = this.ensureArray(
135576
136088
  xmlChild(relsData, "Relationships")?.["Relationship"]
135577
136089
  );
@@ -135615,7 +136127,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135615
136127
  return void 0;
135616
136128
  }
135617
136129
  const path3 = files[0].name;
135618
- const xml = await files[0].async("string");
136130
+ const xml = await this.readPartText(path3) ?? "";
135619
136131
  const data = this.parser.parse(xml);
135620
136132
  const master = data?.["p:handoutMaster"];
135621
136133
  if (!master) {
@@ -135647,7 +136159,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135647
136159
  return void 0;
135648
136160
  }
135649
136161
  const path3 = files[0].name;
135650
- const xml = await files[0].async("string");
136162
+ const xml = await this.readPartText(path3) ?? "";
135651
136163
  const data = this.parser.parse(xml);
135652
136164
  const master = data?.["p:notesMaster"];
135653
136165
  if (!master) {
@@ -135678,7 +136190,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135678
136190
  if (!layoutFile) {
135679
136191
  return void 0;
135680
136192
  }
135681
- const xml = await layoutFile.async("string");
136193
+ const xml = await this.readPartText(layoutPath) ?? "";
135682
136194
  const data = this.parser.parse(xml);
135683
136195
  const sldLayout = data?.["p:sldLayout"];
135684
136196
  if (!sldLayout) {
@@ -135786,18 +136298,19 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
135786
136298
  */
135787
136299
  async parsePresentationProperties() {
135788
136300
  try {
135789
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
135790
- if (!relsXml) {
136301
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
136302
+ if (!relsData) {
135791
136303
  return void 0;
135792
136304
  }
135793
- const relsData = this.parser.parse(relsXml);
135794
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
136305
+ const rels = this.ensureArray(
136306
+ relsData.Relationships?.Relationship
136307
+ );
135795
136308
  const prRel = rels.find(
135796
136309
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
135797
136310
  );
135798
136311
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
135799
136312
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
135800
- const prXmlStr = await this.zip.file(prPath)?.async("string");
136313
+ const prXmlStr = await this.readPartText(prPath);
135801
136314
  if (!prXmlStr) {
135802
136315
  return void 0;
135803
136316
  }
@@ -135843,7 +136356,7 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
135843
136356
  */
135844
136357
  async parseViewProperties() {
135845
136358
  try {
135846
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
136359
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
135847
136360
  if (!viewPropsXml2) {
135848
136361
  return void 0;
135849
136362
  }
@@ -138348,10 +138861,10 @@ function detectDominantScript(text2) {
138348
138861
  }
138349
138862
  let best;
138350
138863
  let bestCount = 0;
138351
- for (const [cat, count] of Object.entries(counts)) {
138352
- if (count > bestCount) {
138864
+ for (const [cat, count2] of Object.entries(counts)) {
138865
+ if (count2 > bestCount) {
138353
138866
  best = cat;
138354
- bestCount = count;
138867
+ bestCount = count2;
138355
138868
  }
138356
138869
  }
138357
138870
  return best;
@@ -140345,7 +140858,7 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
140345
140858
  if (existingRel?.target) {
140346
140859
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
140347
140860
  try {
140348
- const xml = await this.zip.file(drawingPath)?.async("string");
140861
+ const xml = await this.readPartText(drawingPath);
140349
140862
  if (xml) {
140350
140863
  const root = this.parser.parse(xml);
140351
140864
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -140396,11 +140909,10 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
140396
140909
  const slash = chartPartPath.lastIndexOf("/");
140397
140910
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
140398
140911
  try {
140399
- const xml = await this.zip.file(relsPath2)?.async("string");
140400
- if (!xml) {
140912
+ const tree = await this.readPartXml(relsPath2);
140913
+ if (!tree) {
140401
140914
  return void 0;
140402
140915
  }
140403
- const tree = this.parser.parse(xml);
140404
140916
  const root = tree["Relationships"];
140405
140917
  const rels = root?.["Relationship"];
140406
140918
  const list3 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -141218,9 +141730,9 @@ function applyTableStructureEditXml(table, source, next, edit) {
141218
141730
  if (axis !== "row" && axis !== "column" || action !== "insert" && action !== "delete") {
141219
141731
  return false;
141220
141732
  }
141221
- const count = axis === "row" ? rows.length : columns.length;
141733
+ const count2 = axis === "row" ? rows.length : columns.length;
141222
141734
  const delta2 = action === "insert" ? 1 : -1;
141223
- if (!grid || !Number.isInteger(index) || index < 0 || index > count - (action === "delete" ? 1 : 0) || action === "delete" && count <= 1 || next.rows.length !== rows.length + (axis === "row" ? delta2 : 0) || next.columnWidths.length !== columns.length + (axis === "column" ? delta2 : 0)) {
141735
+ if (!grid || !Number.isInteger(index) || index < 0 || index > count2 - (action === "delete" ? 1 : 0) || action === "delete" && count2 <= 1 || next.rows.length !== rows.length + (axis === "row" ? delta2 : 0) || next.columnWidths.length !== columns.length + (axis === "column" ? delta2 : 0)) {
141224
141736
  return false;
141225
141737
  }
141226
141738
  if (axis === "row") {
@@ -143867,6 +144379,7 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
143867
144379
  "pptx/core/core/runtime/PptxHandlerRuntimeSaveDocumentParts.ts"() {
143868
144380
  init_utils();
143869
144381
  init_customer_data_package();
144382
+ init_deferred_embedded_font();
143870
144383
  init_embedded_font_list();
143871
144384
  init_font_deobfuscation();
143872
144385
  init_safe_path();
@@ -144328,7 +144841,9 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
144328
144841
  return;
144329
144842
  }
144330
144843
  const fonts = explicitFonts ?? this.loadedEmbeddedFonts;
144331
- const fontsWithData = fonts.filter((f6) => f6.rawFontData && f6.rawFontData.length > 0);
144844
+ const fontsWithData = fonts.filter(
144845
+ (f6) => shouldSaveEmbeddedFontVerbatim(f6) || f6.rawFontData && f6.rawFontData.length > 0
144846
+ );
144332
144847
  if (fontsWithData.length === 0) {
144333
144848
  const metadata = explicitFontList ?? this.loadedEmbeddedFontList;
144334
144849
  if (metadata && this.presentationData) {
@@ -144371,10 +144886,11 @@ var init_PptxHandlerRuntimeSaveDocumentParts = __esm({
144371
144886
  "p:font": { "@_typeface": typeface }
144372
144887
  };
144373
144888
  for (const variant of variants) {
144374
- const fontData = variant.rawFontData;
144889
+ const verbatim = shouldSaveEmbeddedFontVerbatim(variant);
144890
+ const fontData = verbatim ? void 0 : variant.rawFontData;
144375
144891
  const hasOriginal = Boolean(variant.originalRId && variant.partPath);
144376
- const reuseObfuscation = hasOriginal && Boolean(variant.fontGuid);
144377
- const reuseVerbatim = hasOriginal && !variant.fontGuid && Boolean(variant.originalPartBytes);
144892
+ const reuseObfuscation = hasOriginal && !verbatim && Boolean(variant.fontGuid);
144893
+ const reuseVerbatim = hasOriginal && (verbatim || !variant.fontGuid) && Boolean(variant.originalPartBytes);
144378
144894
  let guid;
144379
144895
  let fontPartPath;
144380
144896
  let relativeTarget4;
@@ -147990,13 +148506,13 @@ function countDeclaredIds(node, counts, ensureArray20) {
147990
148506
  if (!countDeclaredIds(branch, branchCounts, ensureArray20)) {
147991
148507
  return false;
147992
148508
  }
147993
- for (const [id, count] of branchCounts) {
147994
- merged.set(id, Math.max(merged.get(id) ?? 0, count));
148509
+ for (const [id, count2] of branchCounts) {
148510
+ merged.set(id, Math.max(merged.get(id) ?? 0, count2));
147995
148511
  }
147996
148512
  }
147997
148513
  }
147998
- for (const [id, count] of merged) {
147999
- counts.set(id, (counts.get(id) ?? 0) + count);
148514
+ for (const [id, count2] of merged) {
148515
+ counts.set(id, (counts.get(id) ?? 0) + count2);
148000
148516
  }
148001
148517
  }
148002
148518
  return true;
@@ -148006,8 +148522,8 @@ function hasStructuralIdDefects(spTree, ensureArray20) {
148006
148522
  if (!countDeclaredIds(spTree, counts, ensureArray20)) {
148007
148523
  return true;
148008
148524
  }
148009
- for (const count of counts.values()) {
148010
- if (count > 1) {
148525
+ for (const count2 of counts.values()) {
148526
+ if (count2 > 1) {
148011
148527
  return true;
148012
148528
  }
148013
148529
  }
@@ -156251,7 +156767,7 @@ var init_PptxHandlerRuntimeSlideParsing = __esm({
156251
156767
  this.unwrapAlternateContent(spTree);
156252
156768
  let rawXmlStr;
156253
156769
  try {
156254
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
156770
+ rawXmlStr = await this.readPartText(slidePath);
156255
156771
  } catch {
156256
156772
  }
156257
156773
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -156820,7 +157336,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
156820
157336
  if (cached) {
156821
157337
  return cached;
156822
157338
  }
156823
- const xml = await this.zip.file(layoutPath)?.async("string");
157339
+ const xml = await this.readPartText(layoutPath);
156824
157340
  if (!xml) {
156825
157341
  return void 0;
156826
157342
  }
@@ -156834,7 +157350,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
156834
157350
  if (cached) {
156835
157351
  return cached;
156836
157352
  }
156837
- const xml = await this.zip.file(masterPath)?.async("string");
157353
+ const xml = await this.readPartText(masterPath);
156838
157354
  if (!xml) {
156839
157355
  return void 0;
156840
157356
  }
@@ -157294,7 +157810,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
157294
157810
  if (!notesPath) {
157295
157811
  return {};
157296
157812
  }
157297
- const notesXml = await this.zip.file(notesPath)?.async("string");
157813
+ const notesXml = await this.readPartText(notesPath);
157298
157814
  if (!notesXml) {
157299
157815
  return {};
157300
157816
  }
@@ -157793,7 +158309,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
157793
158309
  try {
157794
158310
  let masterXmlObj = this.masterXmlMap.get(master.path);
157795
158311
  if (!masterXmlObj) {
157796
- const xmlStr = await this.zip.file(master.path)?.async("string");
158312
+ const xmlStr = await this.readPartText(master.path);
157797
158313
  if (!xmlStr) {
157798
158314
  continue;
157799
158315
  }
@@ -157866,7 +158382,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
157866
158382
  }
157867
158383
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
157868
158384
  try {
157869
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
158385
+ const masterXmlStr = await this.readPartText(masterPath);
157870
158386
  if (!masterXmlStr) {
157871
158387
  return [];
157872
158388
  }
@@ -158028,7 +158544,7 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
158028
158544
  }
158029
158545
  const partPath = part.path;
158030
158546
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
158031
- const xml = await this.zip.file(partPath)?.async("string");
158547
+ const xml = await this.readPartText(partPath);
158032
158548
  if (!xml) {
158033
158549
  return;
158034
158550
  }
@@ -158188,7 +158704,7 @@ var init_PptxHandlerRuntimeLayoutElements = __esm({
158188
158704
  }
158189
158705
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
158190
158706
  try {
158191
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
158707
+ const layoutXmlStr = await this.readPartText(layoutPath);
158192
158708
  if (!layoutXmlStr) {
158193
158709
  return [];
158194
158710
  }
@@ -158922,7 +159438,7 @@ var init_PptxHandlerRuntimeThemeOverrides = __esm({
158922
159438
  return cached;
158923
159439
  }
158924
159440
  try {
158925
- const overrideXml = await this.zip.file(overridePath)?.async("string");
159441
+ const overrideXml = await this.readPartText(overridePath);
158926
159442
  if (!overrideXml) {
158927
159443
  return null;
158928
159444
  }
@@ -159551,10 +160067,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159551
160067
  if (!relsXml) {
159552
160068
  return void 0;
159553
160069
  }
159554
- const relsData = this.parser.parse(
159555
- // eslint-disable-next-line no-await-in-loop
159556
- await relsXml.async("string")
159557
- );
160070
+ const relsData = await this.readPartXml(relsPath2);
159558
160071
  const relNodes = this.ensureArray(
159559
160072
  relsData?.Relationships?.Relationship
159560
160073
  );
@@ -159580,7 +160093,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159580
160093
  const options = [];
159581
160094
  for (const file of themeFiles) {
159582
160095
  try {
159583
- const xml = await file.async("string");
160096
+ const xml = await this.readPartText(file.name) ?? "";
159584
160097
  const data = this.parser.parse(xml);
159585
160098
  const root = data["a:theme"];
159586
160099
  const name = String(root?.["@_name"] || "").trim();
@@ -159660,7 +160173,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159660
160173
  ];
159661
160174
  for (const file of masterFiles) {
159662
160175
  try {
159663
- const masterXml = await file.async("string");
160176
+ const masterXml = await this.readPartText(file.name) ?? "";
159664
160177
  const masterData = this.parser.parse(masterXml);
159665
160178
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
159666
160179
  if (!clrMap) {
@@ -159693,7 +160206,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159693
160206
  if (!themeFile) {
159694
160207
  return null;
159695
160208
  }
159696
- const themeXml3 = await themeFile.async("string");
160209
+ const themeXml3 = await this.readPartText(themePath) ?? "";
159697
160210
  const model = this.parseThemePartXml(themeXml3);
159698
160211
  this.cacheThemePartModel(themePath, themeXml3, model);
159699
160212
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -159728,7 +160241,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159728
160241
  if (!relsXml) {
159729
160242
  return void 0;
159730
160243
  }
159731
- const relsData = this.parser.parse(await relsXml.async("string"));
160244
+ const relsData = await this.readPartXml(relsPath2);
159732
160245
  const relNodes = this.ensureArray(
159733
160246
  relsData?.Relationships?.Relationship
159734
160247
  );
@@ -160057,11 +160570,10 @@ var init_PptxHandlerRuntimeComments = __esm({
160057
160570
  async extractModernSlideComments(slidePath) {
160058
160571
  try {
160059
160572
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
160060
- const relsXml = await this.zip.file(relsPath2)?.async("string");
160061
- if (!relsXml) {
160573
+ const relsData = await this.readPartXml(relsPath2);
160574
+ if (!relsData) {
160062
160575
  return [];
160063
160576
  }
160064
- const relsData = this.parser.parse(relsXml);
160065
160577
  const rels = this.ensureArray(
160066
160578
  xmlChild(relsData, "Relationships")?.Relationship
160067
160579
  );
@@ -160078,7 +160590,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160078
160590
  continue;
160079
160591
  }
160080
160592
  const filePath = this.resolvePath(slidePath, target);
160081
- const xml = await this.zip.file(filePath)?.async("string");
160593
+ const xml = await this.readPartText(filePath);
160082
160594
  if (!xml) {
160083
160595
  continue;
160084
160596
  }
@@ -160101,11 +160613,10 @@ var init_PptxHandlerRuntimeComments = __esm({
160101
160613
  return [];
160102
160614
  }
160103
160615
  async loadModernCommentAuthors() {
160104
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
160105
- if (!relsXml) {
160616
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
160617
+ if (!relsData) {
160106
160618
  return;
160107
160619
  }
160108
- const relsData = this.parser.parse(relsXml);
160109
160620
  const relationships3 = this.ensureArray(
160110
160621
  xmlChild(relsData, "Relationships")?.Relationship
160111
160622
  );
@@ -160117,7 +160628,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160117
160628
  return;
160118
160629
  }
160119
160630
  const partPath = this.resolvePath("ppt/presentation.xml", target);
160120
- const xml = await this.zip.file(partPath)?.async("string");
160631
+ const xml = await this.readPartText(partPath);
160121
160632
  if (!xml) {
160122
160633
  return;
160123
160634
  }
@@ -160143,12 +160654,12 @@ var init_PptxHandlerRuntimeComments = __esm({
160143
160654
  }
160144
160655
  }
160145
160656
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
160146
- const relsXml = await this.zip.file(relsPath2)?.async("string");
160657
+ const relsXml = await this.readPartText(relsPath2);
160147
160658
  if (!relsXml) {
160148
160659
  return void 0;
160149
160660
  }
160150
160661
  try {
160151
- const relsData = this.parser.parse(relsXml);
160662
+ const relsData = await this.readPartXml(relsPath2);
160152
160663
  const rels = this.ensureArray(
160153
160664
  xmlChild(relsData, "Relationships")?.Relationship
160154
160665
  );
@@ -160187,7 +160698,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160187
160698
  return [];
160188
160699
  }
160189
160700
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
160190
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
160701
+ const commentsXml = await this.readPartText(commentsPath);
160191
160702
  if (!commentsXml) {
160192
160703
  return [];
160193
160704
  }
@@ -160222,7 +160733,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160222
160733
  }
160223
160734
  }
160224
160735
  async loadCommentAuthors() {
160225
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
160736
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
160226
160737
  if (!commentAuthorsXml) {
160227
160738
  return;
160228
160739
  }
@@ -160294,7 +160805,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
160294
160805
  return void 0;
160295
160806
  }
160296
160807
  const partPath = this.resolveImagePath(slidePath, target);
160297
- const xmlString = await this.zip.file(partPath)?.async("string");
160808
+ const xmlString = await this.readPartText(partPath);
160298
160809
  if (!xmlString) {
160299
160810
  return void 0;
160300
160811
  }
@@ -162009,9 +162520,8 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
162009
162520
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
162010
162521
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
162011
162522
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
162012
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
162013
- if (chartRelsXml) {
162014
- const chartRelsData = this.parser.parse(chartRelsXml);
162523
+ const chartRelsData = await this.readPartXml(chartRelsPath);
162524
+ if (chartRelsData) {
162015
162525
  const relsContainer = chartRelsData?.Relationships;
162016
162526
  if (relsContainer?.Relationship) {
162017
162527
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -162093,7 +162603,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
162093
162603
  if (drawingPath.length === 0) {
162094
162604
  return void 0;
162095
162605
  }
162096
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
162606
+ const drawingXml = await this.readPartText(drawingPath);
162097
162607
  if (!drawingXml) {
162098
162608
  return void 0;
162099
162609
  }
@@ -162114,11 +162624,10 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
162114
162624
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
162115
162625
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
162116
162626
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
162117
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
162118
- if (!chartRelsXml) {
162627
+ const chartRelsData = await this.readPartXml(chartRelsPath);
162628
+ if (!chartRelsData) {
162119
162629
  return [];
162120
162630
  }
162121
- const chartRelsData = this.parser.parse(chartRelsXml);
162122
162631
  const relsContainer = chartRelsData?.Relationships;
162123
162632
  if (!relsContainer?.Relationship) {
162124
162633
  return [];
@@ -162955,8 +163464,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
162955
163464
  var PptxHandlerRuntime99;
162956
163465
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
162957
163466
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
162958
- init_eot_parser();
162959
- init_font_deobfuscation();
163467
+ init_deferred_embedded_font();
162960
163468
  init_layout_display_name();
162961
163469
  init_strip_parent_dir_segments();
162962
163470
  init_xml_access();
@@ -163010,11 +163518,10 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163010
163518
  async loadPresentationFontRels() {
163011
163519
  const map = /* @__PURE__ */ new Map();
163012
163520
  try {
163013
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
163014
- if (!relsXml) {
163521
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
163522
+ if (!relsData) {
163015
163523
  return map;
163016
163524
  }
163017
- const relsData = this.parser.parse(relsXml);
163018
163525
  const rels = this.ensureArray(
163019
163526
  xmlChild(relsData, "Relationships")?.Relationship
163020
163527
  );
@@ -163033,7 +163540,13 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163033
163540
  }
163034
163541
  return map;
163035
163542
  }
163036
- /** Extract, de-obfuscate, and encode a single font variant. */
163543
+ /**
163544
+ * Read one variant's part. By default the result is a deferred descriptor
163545
+ * that decodes on first use (see `createDeferredEmbeddedFont`); parts that
163546
+ * fail the checks possible without decoding are skipped, as before. With
163547
+ * `eagerDecodeEmbeddedFonts` the variant is decoded now and skipped when
163548
+ * decoding fails.
163549
+ */
163037
163550
  async extractEmbeddedFontVariant(typeface, rId, bold, italic, relsMap, fontKey) {
163038
163551
  const fontPath = relsMap.get(rId);
163039
163552
  if (!fontPath) {
@@ -163044,80 +163557,25 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
163044
163557
  if (!fontBinary || fontBinary.length === 0) {
163045
163558
  return null;
163046
163559
  }
163047
- const originalPartBytes = new Uint8Array(fontBinary);
163048
- let fontData;
163049
- let resolvedGuid;
163050
- if (isEotFormat(fontBinary)) {
163051
- const extracted = extractFontFromEot(fontBinary);
163052
- if (extracted) {
163053
- fontData = extracted.fontData;
163054
- } else {
163055
- const header = parseEotHeader(fontBinary);
163056
- console.info(
163057
- `[pptx-viewer] Embedded font "${typeface}" uses EOT format${header?.isCompressed ? " with MTX compression" : ""} \u2014 extraction failed, will use web font fallback`
163058
- );
163059
- return null;
163060
- }
163061
- } else {
163062
- const guidFromKey = fontKey ? extractGuidFromPartName(fontKey) ?? fontKey.replace(/[{}]/g, "").trim() : null;
163063
- const guidFromPath = extractGuidFromPartName(fontPath);
163064
- const guid = guidFromKey || guidFromPath;
163065
- if (guid) {
163066
- fontData = deobfuscateFont(fontBinary, guid);
163067
- resolvedGuid = guid;
163068
- } else {
163069
- console.warn(
163070
- `[pptx-viewer] Embedded font "${typeface}" at "${fontPath}" has no fontKey attribute and no GUID in filename \u2014 skipping`
163071
- );
163072
- return null;
163073
- }
163074
- }
163075
- if (fontData.length < 4) {
163076
- return null;
163077
- }
163078
- const v0 = fontData[0], v1 = fontData[1], v2 = fontData[2], v3 = fontData[3];
163079
- const isTrueType = v0 === 0 && v1 === 1 && v2 === 0 && v3 === 0;
163080
- const isOTTO = v0 === 79 && v1 === 84 && v2 === 84 && v3 === 79;
163081
- const isTTC = v0 === 116 && v1 === 116 && v2 === 99 && v3 === 102;
163082
- const isWOFF = v0 === 119 && v1 === 79 && v2 === 70 && (v3 === 70 || v3 === 50);
163083
- if (!(isTrueType || isOTTO || isTTC || isWOFF)) {
163084
- console.warn(
163085
- `[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)`
163086
- );
163087
- return null;
163088
- }
163089
- const format = detectFontFormat(fontData);
163090
- const mimeType = format === "woff2" ? "font/woff2" : format === "woff" ? "font/woff" : format === "opentype" ? "font/otf" : "font/ttf";
163091
- const base64 = this.uint8ArrayToBase64(fontData);
163092
- const dataUrl = `data:${mimeType};base64,${base64}`;
163093
- return {
163560
+ const source = {
163094
163561
  name: typeface,
163095
- dataUrl,
163096
163562
  bold,
163097
163563
  italic,
163098
- format,
163099
- rawFontData: fontData,
163100
- partPath: fontPath,
163101
- fontGuid: resolvedGuid,
163102
163564
  originalRId: rId,
163103
- originalPartBytes
163565
+ partPath: fontPath,
163566
+ // The descriptor owns a copy, so it outlives this handler's ZIP and
163567
+ // the save pipeline can write it back verbatim.
163568
+ originalPartBytes: new Uint8Array(fontBinary),
163569
+ fontKey
163104
163570
  };
163571
+ if (this.eagerDecodeEmbeddedFonts) {
163572
+ return decodeEmbeddedFontPart(source);
163573
+ }
163574
+ return isEmbeddedFontPartPlausible(source) ? createDeferredEmbeddedFont(source) : null;
163105
163575
  } catch {
163106
163576
  return null;
163107
163577
  }
163108
163578
  }
163109
- /** Convert Uint8Array to base64 string. */
163110
- uint8ArrayToBase64(bytes) {
163111
- let binary = "";
163112
- const chunkSize = 8192;
163113
- for (let i2 = 0; i2 < bytes.length; i2 += chunkSize) {
163114
- const chunk2 = bytes.subarray(i2, Math.min(i2 + chunkSize, bytes.length));
163115
- for (let j = 0; j < chunk2.length; j++) {
163116
- binary += String.fromCharCode(chunk2[j]);
163117
- }
163118
- }
163119
- return btoa(binary);
163120
- }
163121
163579
  getLayoutOptions() {
163122
163580
  const options = [];
163123
163581
  for (const [path3, xmlObj] of this.layoutXmlMap.entries()) {
@@ -163170,12 +163628,16 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163170
163628
  init_ole_embedded_extract();
163171
163629
  init_ole_utils();
163172
163630
  init_signature_detection();
163173
- init_types2();
163631
+ init_load_limits();
163174
163632
  init_authored_slide_background();
163175
163633
  init_bullet_picture_image_enrichment();
163176
163634
  init_PptxHandlerRuntimeEmbeddedFonts();
163177
163635
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
163178
163636
  PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
163637
+ /** The limits of the load in progress (see `PptxHandlerLoadOptions.limits`). */
163638
+ loadLimits = { ...exports.DEFAULT_PPTX_LOAD_LIMITS };
163639
+ /** Slide elements parsed so far by the load in progress, for `maxShapes`. */
163640
+ loadedShapeCount = 0;
163179
163641
  isZipContainer(data) {
163180
163642
  const bytes = new Uint8Array(data);
163181
163643
  if (bytes.byteLength < 4) {
@@ -163184,7 +163646,9 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163184
163646
  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);
163185
163647
  }
163186
163648
  async initializeLoadSession(data, options) {
163649
+ const limits = resolvePptxLoadLimits(options);
163187
163650
  this.eagerDecodeImages = options.eagerDecodeImages ?? false;
163651
+ this.eagerDecodeEmbeddedFonts = options.eagerDecodeEmbeddedFonts === true;
163188
163652
  this.allowExternalImages = options.allowExternalImages === true;
163189
163653
  if (data.byteLength < 4) {
163190
163654
  throw new Error("Invalid PPTX binary: file is empty or truncated.");
@@ -163194,7 +163658,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163194
163658
  "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."
163195
163659
  );
163196
163660
  }
163197
- const maxBytes = typeof options.maxUncompressedBytes === "number" && options.maxUncompressedBytes > 0 ? options.maxUncompressedBytes : exports.DEFAULT_MAX_UNCOMPRESSED_BYTES;
163661
+ const maxBytes = limits.maxUncompressedBytes;
163198
163662
  let loaded;
163199
163663
  try {
163200
163664
  loaded = await JSZip__default.default.loadAsync(data);
@@ -163204,11 +163668,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163204
163668
  }
163205
163669
  this.zip = guardZip(loaded, {
163206
163670
  label: "PPTX",
163207
- maxEntries: exports.MAX_ZIP_ENTRY_COUNT,
163671
+ maxEntries: limits.maxEntries,
163208
163672
  maxEntryBytes: maxBytes,
163209
163673
  maxTotalBytes: maxBytes,
163210
- createError: (message, details) => new exports.ZipBombError(message, details)
163674
+ createError: createPptxZipBombError
163211
163675
  });
163676
+ this.loadLimits = limits;
163677
+ this.loadedShapeCount = 0;
163212
163678
  try {
163213
163679
  this.documentPropertiesUpdater = this.dependencyFactory.createDocumentPropertiesUpdater(
163214
163680
  this.zip,
@@ -163335,13 +163801,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163335
163801
  if (!file) {
163336
163802
  continue;
163337
163803
  }
163338
- const data = await file.async("string");
163804
+ const data = await this.readPartText(entry2) ?? "";
163339
163805
  const propsPath = `customXml/itemProps${itemId}.xml`;
163340
163806
  const propsFile = this.zip.file(propsPath);
163341
163807
  let properties;
163342
163808
  let schemaUri;
163343
163809
  if (propsFile) {
163344
- properties = await propsFile.async("string");
163810
+ properties = await this.readPartText(propsPath) ?? "";
163345
163811
  try {
163346
163812
  const propsData = this.parser.parse(properties);
163347
163813
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -163361,19 +163827,24 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163361
163827
  const relsFile = this.zip.file(relsPath2);
163362
163828
  let rels;
163363
163829
  if (relsFile) {
163364
- rels = await relsFile.async("string");
163830
+ rels = await this.readPartText(relsPath2);
163365
163831
  }
163366
163832
  parts.push({ id: itemId, data, schemaUri, properties, rels });
163367
163833
  }
163368
163834
  this.customXmlParts = parts;
163369
163835
  }
163370
163836
  async loadPresentationState() {
163371
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
163837
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
163372
163838
  if (!presentationXml3) {
163373
163839
  throw new Error("Invalid PPTX: presentation.xml not found");
163374
163840
  }
163375
163841
  this.presentationData = this.parser.parse(presentationXml3);
163376
163842
  this.detectAndSetStrictConformance(this.presentationData);
163843
+ const slideIds = this.presentationData?.["p:presentation"]?.["p:sldIdLst"]?.["p:sldId"];
163844
+ assertPptxSlideCountWithinLimits(
163845
+ Array.isArray(slideIds) ? slideIds.length : slideIds ? 1 : 0,
163846
+ this.loadLimits
163847
+ );
163377
163848
  await this.loadThemeData();
163378
163849
  this.parsePresentationDefaultTextStyle();
163379
163850
  await this.loadCommentAuthors();
@@ -163503,7 +163974,17 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163503
163974
  loadThemeOverride: (partBasePath) => this.loadThemeOverride(partBasePath),
163504
163975
  applyThemeOverrideState: (override) => this.applyThemeOverrideState(override),
163505
163976
  getLayoutElements: (slidePath) => this.getLayoutElements(slidePath),
163506
- parseSlide: (slideXml3, slidePath) => this.parseSlide(slideXml3, slidePath),
163977
+ // `maxShapes`: each slide's own elements are counted as soon as they are
163978
+ // parsed, before that slide's media is resolved and before the next slide.
163979
+ parseSlide: async (slideXml3, slidePath) => {
163980
+ const elements3 = await this.parseSlide(slideXml3, slidePath);
163981
+ this.loadedShapeCount = countPptxShapesWithinLimits(
163982
+ this.loadedShapeCount,
163983
+ elements3,
163984
+ this.loadLimits
163985
+ );
163986
+ return elements3;
163987
+ },
163507
163988
  extractMediaTimingMap: (slideXml3, slidePath) => this.extractMediaTimingMap(slideXml3, slidePath),
163508
163989
  enrichMediaElementsWithTiming: (elements3, timingMap) => this.enrichMediaElementsWithTiming(elements3, timingMap),
163509
163990
  enrichOleElementsWithEmbeddedData: (elements3, slidePath) => this.enrichOleElementsWithEmbeddedData(elements3, slidePath),
@@ -163556,6 +164037,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163556
164037
  init_smart_tags_parser();
163557
164038
  init_strip_parent_dir_segments();
163558
164039
  init_builders();
164040
+ init_load_limits();
163559
164041
  init_authored_slide_background();
163560
164042
  init_layout_switch_placeholder_prompts();
163561
164043
  init_PptxHandlerRuntimeLoadSession();
@@ -163720,6 +164202,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163720
164202
  * or resolve images. Create a new `PptxHandler` instance instead.
163721
164203
  */
163722
164204
  dispose() {
164205
+ this.endPartReads();
163723
164206
  this.revokeBlobUrls();
163724
164207
  this.imageDataCache.clear();
163725
164208
  this.slideMap.clear();
@@ -163753,7 +164236,23 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163753
164236
  this.zip = null;
163754
164237
  }
163755
164238
  async load(data, options = {}) {
163756
- await this.initializeLoadSession(data, options);
164239
+ let reader2;
164240
+ try {
164241
+ await this.initializeLoadSession(data, options);
164242
+ reader2 = this.beginPartReads();
164243
+ try {
164244
+ return await this.loadInitializedSession();
164245
+ } catch (error) {
164246
+ if (error instanceof exports.PptxLoadLimitError) {
164247
+ this.dispose();
164248
+ }
164249
+ throw error;
164250
+ }
164251
+ } finally {
164252
+ this.endPartReads(reader2);
164253
+ }
164254
+ }
164255
+ async loadInitializedSession() {
163757
164256
  await this.detectAndPreserveVbaProject();
163758
164257
  this.detectDigitalSignatureParts();
163759
164258
  await this.parseCustomXmlParts();
@@ -163903,7 +164402,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163903
164402
  options.push(this.buildLayoutOption(lp, xmlObj));
163904
164403
  } else {
163905
164404
  try {
163906
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
164405
+ const layoutXmlStr = await this.readPartText(lp);
163907
164406
  if (layoutXmlStr) {
163908
164407
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
163909
164408
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -163946,7 +164445,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163946
164445
  }
163947
164446
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
163948
164447
  if (!layoutXml3) {
163949
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
164448
+ const layoutXmlStr = await this.readPartText(layoutPath);
163950
164449
  if (!layoutXmlStr) {
163951
164450
  throw new Error(`Layout not found: ${layoutPath}`);
163952
164451
  }
@@ -165055,6 +165554,7 @@ var init_core2 = __esm({
165055
165554
  init_builders();
165056
165555
  init_factories();
165057
165556
  init_types2();
165557
+ init_load_limits();
165058
165558
  init_table_structural_ops();
165059
165559
  init_table_style_defaults();
165060
165560
  init_auto_number_sequence();
@@ -165319,24 +165819,24 @@ function parseStyleTextPropAtom(view, dataOffset, dataLen, textLength, scheme) {
165319
165819
  const charRuns = [];
165320
165820
  let covered = 0;
165321
165821
  while (covered < total && c.canRead(6)) {
165322
- const count = c.u32();
165822
+ const count2 = c.u32();
165323
165823
  const indentLevel = c.u16();
165324
- const props = { count, indentLevel };
165824
+ const props = { count: count2, indentLevel };
165325
165825
  if (!parsePfException(c, scheme, props)) {
165326
165826
  break;
165327
165827
  }
165328
165828
  paragraphRuns.push(props);
165329
- covered += count;
165829
+ covered += count2;
165330
165830
  }
165331
165831
  covered = 0;
165332
165832
  while (covered < total && c.canRead(8)) {
165333
- const count = c.u32();
165334
- const props = { count };
165833
+ const count2 = c.u32();
165834
+ const props = { count: count2 };
165335
165835
  if (!parseCfException(c, scheme, props)) {
165336
165836
  break;
165337
165837
  }
165338
165838
  charRuns.push(props);
165339
- covered += count;
165839
+ covered += count2;
165340
165840
  }
165341
165841
  return { paragraphRuns, charRuns };
165342
165842
  }
@@ -166398,13 +166898,13 @@ var init_geometry_map = __esm({
166398
166898
  function parseProperties2(view, data, rec) {
166399
166899
  const values = /* @__PURE__ */ new Map();
166400
166900
  const complex = /* @__PURE__ */ new Map();
166401
- const count = rec.recInstance;
166402
- const entriesEnd = rec.dataOffset + count * 6;
166901
+ const count2 = rec.recInstance;
166902
+ const entriesEnd = rec.dataOffset + count2 * 6;
166403
166903
  if (entriesEnd > rec.dataOffset + rec.recLen) {
166404
166904
  return { values, complex };
166405
166905
  }
166406
166906
  const complexRefs = [];
166407
- for (let i2 = 0; i2 < count; i2++) {
166907
+ for (let i2 = 0; i2 < count2; i2++) {
166408
166908
  const at2 = rec.dataOffset + i2 * 6;
166409
166909
  const opid = view.getUint16(at2, true);
166410
166910
  const value = view.getUint32(at2 + 2, true);
@@ -167605,8 +168105,8 @@ function levelXml(tag, level2, fallbackSizePt) {
167605
168105
  }
167606
168106
  function styleLevels(levels, fallbackSizePt) {
167607
168107
  const result = [];
167608
- const count = Math.max(1, Math.min(levels.length, 9));
167609
- for (let i2 = 0; i2 < count; i2++) {
168108
+ const count2 = Math.max(1, Math.min(levels.length, 9));
168109
+ for (let i2 = 0; i2 < count2; i2++) {
167610
168110
  result.push(levelXml(`lvl${i2 + 1}pPr`, levels[i2] ?? {}, fallbackSizePt));
167611
168111
  }
167612
168112
  return result.join("");
@@ -168103,6 +168603,7 @@ var PptxHandlerCore;
168103
168603
  var init_PptxHandlerCore = __esm({
168104
168604
  "pptx/core/PptxHandlerCore.ts"() {
168105
168605
  init_core2();
168606
+ init_load_limits();
168106
168607
  init_ppt();
168107
168608
  init_encryption_detection();
168108
168609
  init_ole2_parser();
@@ -168492,6 +168993,7 @@ var init_PptxHandlerCore = __esm({
168492
168993
  * ```
168493
168994
  */
168494
168995
  async load(data, options = {}) {
168996
+ assertPptxInputWithinLimits(data.byteLength, resolvePptxLoadLimits(options));
168495
168997
  const detection = detectFileFormat(data);
168496
168998
  if (detection.format === "ole") {
168497
168999
  let ole;
@@ -168744,6 +169246,7 @@ var init_PptxHandler = __esm({
168744
169246
  "pptx/core/PptxHandler.ts"() {
168745
169247
  init_json();
168746
169248
  init_PresentationBuilder();
169249
+ init_load_limits();
168747
169250
  init_PptxHandlerCore();
168748
169251
  exports.PptxHandler = class extends PptxHandlerCore {
168749
169252
  /**
@@ -168815,13 +169318,15 @@ var init_PptxHandler = __esm({
168815
169318
  * archives and portable `pptx-viewer-json` documents.
168816
169319
  *
168817
169320
  * The buffer is sniffed first: JSON documents (leading `{` plus the
168818
- * `"pptx-viewer-json"` format marker) are routed to {@link loadFromJson};
168819
- * everything else goes through the regular ZIP/OLE2 pipeline.
169321
+ * `"pptx-viewer-json"` format marker) are imported as {@link loadFromJson}
169322
+ * does; everything else goes through the regular ZIP/OLE2 pipeline.
168820
169323
  */
168821
169324
  async load(data, options = {}) {
169325
+ const limits = resolvePptxLoadLimits(options);
169326
+ assertPptxInputWithinLimits(data.byteLength, limits);
168822
169327
  const jsonText = decodePptxJsonText(data);
168823
169328
  if (jsonText !== null) {
168824
- return this.loadFromJson(jsonText, options);
169329
+ return this.importJson(jsonText, options, limits);
168825
169330
  }
168826
169331
  return super.load(data, options);
168827
169332
  }
@@ -168832,9 +169337,26 @@ var init_PptxHandler = __esm({
168832
169337
  * handler keeps a valid in-memory archive (editing and {@link save} keep
168833
169338
  * working), then the imported model is overlaid on top: imported
168834
169339
  * presentation fields win, and the slide array is replaced wholesale.
169340
+ *
169341
+ * `options.limits` applies as it does for {@link load}: `maxInputBytes` to
169342
+ * the UTF-8 size of `text` (checked before it is parsed), and `maxSlides`
169343
+ * and `maxShapes` to the document's slides with the same counting rule as
169344
+ * a `.pptx` package (layout and master elements are not counted).
168835
169345
  */
168836
169346
  async loadFromJson(text2, options = {}) {
168837
- const imported = deserializePptxFromJson(text2);
169347
+ const limits = resolvePptxLoadLimits(options);
169348
+ assertPptxTextWithinLimits(text2, limits);
169349
+ return this.importJson(text2, options, limits);
169350
+ }
169351
+ async importJson(text2, options, limits) {
169352
+ const document2 = parsePptxJson(text2);
169353
+ assertPptxSlideCountWithinLimits(document2.slides.length, limits);
169354
+ let shapes = 0;
169355
+ for (const slide of document2.slides) {
169356
+ const elements3 = Array.isArray(slide.elements) ? slide.elements : [];
169357
+ shapes = countPptxShapesWithinLimits(shapes, elements3, limits);
169358
+ }
169359
+ const imported = pptxDataFromJsonDocument(document2);
168838
169360
  const blankBytes = await buildBlankPresentationArchive({
168839
169361
  width: imported.widthEmu,
168840
169362
  height: imported.heightEmu,
@@ -168842,7 +169364,7 @@ var init_PptxHandler = __esm({
168842
169364
  // the overlaid model, so the archive must carry the value itself.
168843
169365
  firstSlideNumber: imported.firstSlideNumber
168844
169366
  });
168845
- const base = await super.load(blankBytes, options);
169367
+ const base = await super.load(blankBytes, { ...options, limits: void 0 });
168846
169368
  return applyImportedPptxData(base, imported);
168847
169369
  }
168848
169370
  };
@@ -171373,10 +171895,10 @@ function resolveNodeAtPath(nodes, path3) {
171373
171895
  }
171374
171896
  function validateShapeIndex(element, index) {
171375
171897
  ensureChartData2(element);
171376
- const count = element.chartData.userShapes?.length ?? 0;
171377
- if (index < 0 || index >= count) {
171898
+ const count2 = element.chartData.userShapes?.length ?? 0;
171899
+ if (index < 0 || index >= count2) {
171378
171900
  throw new RangeError(
171379
- `Overlay-shape index ${index} is out of range. Chart has ${count} overlay shape(s) (indices 0-${count - 1}).`
171901
+ `Overlay-shape index ${index} is out of range. Chart has ${count2} overlay shape(s) (indices 0-${count2 - 1}).`
171380
171902
  );
171381
171903
  }
171382
171904
  }
@@ -171516,13 +172038,13 @@ function masterIndexFromPath(masterPath) {
171516
172038
  return match ? parseInt(match[1], 10) : void 0;
171517
172039
  }
171518
172040
  function countExistingMasters(zip) {
171519
- let count = 0;
172041
+ let count2 = 0;
171520
172042
  zip.forEach((relativePath) => {
171521
172043
  if (/^ppt\/slideMasters\/slideMaster\d+\.xml$/.test(relativePath)) {
171522
- count++;
172044
+ count2++;
171523
172045
  }
171524
172046
  });
171525
- return count;
172047
+ return count2;
171526
172048
  }
171527
172049
  function escapeRegex2(value) {
171528
172050
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -187570,6 +188092,7 @@ exports.getOleNestedDeckDetail = getOleNestedDeckDetail;
187570
188092
  exports.getOleObjectTypeLabel = getOleObjectTypeLabel;
187571
188093
  exports.getOleSheetGrid = getOleSheetGrid;
187572
188094
  exports.getPanoseWeight = getPanoseWeight;
188095
+ exports.getPptxLoadLimitViolation = getPptxLoadLimitViolation;
187573
188096
  exports.getPresetConnectionSites = getPresetConnectionSites;
187574
188097
  exports.getPresetShapeClipPath = getPresetShapeClipPath;
187575
188098
  exports.getPresetTextRect = getPresetTextRect;