ooxml-core 1.27.0 → 1.27.2

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 (41) hide show
  1. package/dist/{PptxHandler-6ZGALYYM.cjs → PptxHandler-FRQKHTCM.cjs} +3 -3
  2. package/dist/PptxHandler-RETSKQ5E.mjs +4 -0
  3. package/dist/{PptxHandler-HEPPGI32.mjs → PptxHandler-WRJXTPGV.mjs} +2 -2
  4. package/dist/{PresentationBuilder-BCDRASRT.mjs → PresentationBuilder-LWR5X3JA.mjs} +2 -2
  5. package/dist/{PresentationBuilder-OQOZE76H.mjs → PresentationBuilder-POXKHTV7.mjs} +2 -2
  6. package/dist/{PresentationBuilder-HFGK2BWN.cjs → PresentationBuilder-YO5YOTA3.cjs} +5 -5
  7. package/dist/{chunk-MU3XSASV.cjs → chunk-36TR3PER.cjs} +270 -13
  8. package/dist/{chunk-4SGBL2H4.mjs → chunk-3VIPI6IA.mjs} +4 -4
  9. package/dist/{chunk-KE2FUFIU.mjs → chunk-6LCBTFNL.mjs} +253 -380
  10. package/dist/{chunk-VRJOOHWV.mjs → chunk-G67MARDL.mjs} +271 -17
  11. package/dist/{chunk-2XMK5SXU.mjs → chunk-I57SMSU6.mjs} +268 -14
  12. package/dist/{chunk-HYCOBPCC.cjs → chunk-K6DNX3YC.cjs} +1330 -1457
  13. package/dist/{chunk-7E45SAZJ.mjs → chunk-RNUYMB73.mjs} +253 -380
  14. package/dist/{chunk-63GRFYAN.mjs → chunk-TIQWSSGI.mjs} +1 -1
  15. package/dist/{chunk-ANIFYTKH.mjs → chunk-XW4XB6P4.mjs} +1 -1
  16. package/dist/pptx/automation/index.cjs +555 -416
  17. package/dist/pptx/automation/index.d.ts +3 -3
  18. package/dist/pptx/automation/index.mjs +5 -5
  19. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts → index-CdRlUz-v.d.ts} +2 -2
  20. package/dist/pptx/chunks/{index-D4FnOx6x.d.ts.map → index-CdRlUz-v.d.ts.map} +1 -1
  21. package/dist/pptx/chunks/{index-D8DNpc1X.d.ts → index-D_d4NTVP.d.ts} +36 -3
  22. package/dist/pptx/chunks/index-D_d4NTVP.d.ts.map +1 -0
  23. package/dist/pptx/chunks/{index-CbFowkp4.d.ts → index-lwMA6pP5.d.ts} +18 -5
  24. package/dist/pptx/chunks/index-lwMA6pP5.d.ts.map +1 -0
  25. package/dist/pptx/cli/index.cjs +555 -416
  26. package/dist/pptx/cli/index.mjs +4 -4
  27. package/dist/pptx/converter/index.d.ts +1 -1
  28. package/dist/pptx/converter/index.mjs +2 -2
  29. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  30. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  31. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  32. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  33. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  34. package/dist/pptx/index.cjs +557 -416
  35. package/dist/pptx/index.d.ts +4 -4
  36. package/dist/pptx/index.mjs +5 -5
  37. package/dist/pptx/node/index.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/dist/PptxHandler-NO7MNGOW.mjs +0 -4
  40. package/dist/pptx/chunks/index-CbFowkp4.d.ts.map +0 -1
  41. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +0 -1
@@ -71221,6 +71221,272 @@ var init_chart_data_sheet = __esm({
71221
71221
  }
71222
71222
  });
71223
71223
 
71224
+ // pptx/core/utils/modern-comment-mention-read.ts
71225
+ function readCommentMentions(node, authorName) {
71226
+ if (!node) {
71227
+ return void 0;
71228
+ }
71229
+ const found = [];
71230
+ for (const list3 of mentionChildrenNamed(node, "mentionLst")) {
71231
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
71232
+ const mention = readMention(entry2, authorName);
71233
+ if (mention) {
71234
+ found.push(mention);
71235
+ }
71236
+ }
71237
+ }
71238
+ for (const extension of mentionChildrenNamed(mentionChildrenNamed(node, "extLst")[0], "ext")) {
71239
+ const uri = String(extension["@_uri"] || "");
71240
+ for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
71241
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
71242
+ const mention = readMention(entry2, authorName, uri);
71243
+ if (mention) {
71244
+ found.push(mention);
71245
+ }
71246
+ }
71247
+ }
71248
+ }
71249
+ found.sort((a, b) => a.startIndex - b.startIndex);
71250
+ return found.length > 0 ? found : void 0;
71251
+ }
71252
+ var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute5, integer2, readMention;
71253
+ var init_modern_comment_mention_read = __esm({
71254
+ "pptx/core/utils/modern-comment-mention-read.ts"() {
71255
+ mentionLocalName = (key2) => key2.split(":").pop() || key2;
71256
+ mentionNodesOf = (value) => {
71257
+ if (Array.isArray(value)) {
71258
+ return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
71259
+ }
71260
+ return value && typeof value === "object" ? [value] : [];
71261
+ };
71262
+ mentionChildrenNamed = (node, name) => {
71263
+ if (!node) {
71264
+ return [];
71265
+ }
71266
+ const result = [];
71267
+ for (const [key2, value] of Object.entries(node)) {
71268
+ if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
71269
+ result.push(...mentionNodesOf(value));
71270
+ }
71271
+ }
71272
+ return result;
71273
+ };
71274
+ MENTION_PERSON_KEYS = [
71275
+ "@_mentionpersonId",
71276
+ "@_mentionPersonId",
71277
+ "@_personId",
71278
+ "@_authorId"
71279
+ ];
71280
+ MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
71281
+ attribute5 = (node, keys) => {
71282
+ for (const key2 of keys) {
71283
+ const value = node[key2];
71284
+ if (value !== void 0 && value !== null && String(value).length > 0) {
71285
+ return String(value);
71286
+ }
71287
+ }
71288
+ return void 0;
71289
+ };
71290
+ integer2 = (value) => {
71291
+ if (value === void 0) {
71292
+ return void 0;
71293
+ }
71294
+ const parsed = Number.parseInt(value, 10);
71295
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
71296
+ };
71297
+ readMention = (node, authorName, containerUri) => {
71298
+ const personId = attribute5(node, MENTION_PERSON_KEYS);
71299
+ const startIndex = integer2(attribute5(node, ["@_startIndex"]));
71300
+ const length = integer2(attribute5(node, MENTION_LENGTH_KEYS));
71301
+ if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
71302
+ return void 0;
71303
+ }
71304
+ return {
71305
+ personId,
71306
+ startIndex,
71307
+ length,
71308
+ id: attribute5(node, ["@_mentionId", "@_id"]),
71309
+ authorName: authorName(personId),
71310
+ containerUri,
71311
+ rawXml: node
71312
+ };
71313
+ };
71314
+ }
71315
+ });
71316
+
71317
+ // pptx/core/utils/modern-comment-mentions.ts
71318
+ function rebaseCommentMentions(mentions, oldText, newText, loaded) {
71319
+ if (!mentions || mentions.length === 0) {
71320
+ return void 0;
71321
+ }
71322
+ if (oldText === newText) {
71323
+ return mentions;
71324
+ }
71325
+ const prefix = commonPrefixLength(oldText, newText);
71326
+ const suffix = commonSuffixLength(
71327
+ oldText,
71328
+ newText,
71329
+ Math.min(oldText.length, newText.length) - prefix
71330
+ );
71331
+ const changeEnd = oldText.length - suffix;
71332
+ const delta2 = newText.length - oldText.length;
71333
+ const result = [];
71334
+ for (const mention of mentions) {
71335
+ const start = mention.startIndex;
71336
+ const end = start + mention.length;
71337
+ const coverage = loaded ? loadedCoverage(mention, loaded, oldText) : [];
71338
+ if (coverage === void 0 || coverage.includes(newText.slice(start, end))) {
71339
+ if (start >= 0 && mention.length > 0 && end <= newText.length) {
71340
+ result.push(mention);
71341
+ }
71342
+ continue;
71343
+ }
71344
+ const span = oldText.slice(start, end);
71345
+ if (span.length !== mention.length) {
71346
+ continue;
71347
+ }
71348
+ let next = -1;
71349
+ if (end <= prefix) {
71350
+ next = start;
71351
+ } else if (start >= changeEnd) {
71352
+ next = start + delta2;
71353
+ }
71354
+ if (next >= 0 && newText.slice(next, next + mention.length) === span) {
71355
+ result.push(next === start ? mention : { ...mention, startIndex: next });
71356
+ continue;
71357
+ }
71358
+ const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
71359
+ if (relocated >= 0) {
71360
+ result.push({ ...mention, startIndex: relocated });
71361
+ }
71362
+ }
71363
+ return result.length > 0 ? result : void 0;
71364
+ }
71365
+ function buildMentionListNode(mentions) {
71366
+ if (!mentions || mentions.length === 0) {
71367
+ return void 0;
71368
+ }
71369
+ return { "p188:mention": mentions.map(buildMention) };
71370
+ }
71371
+ function applyCommentMentions(node, mentions, extension, replace) {
71372
+ if (!replace) {
71373
+ return extension;
71374
+ }
71375
+ const { direct, byUri } = groupByContainer(mentions);
71376
+ const directList = buildMentionListNode(direct);
71377
+ if (directList) {
71378
+ node["p188:mentionLst"] = directList;
71379
+ }
71380
+ if (!extension) {
71381
+ return void 0;
71382
+ }
71383
+ const rebuilt = stripMentionLists(extension);
71384
+ const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
71385
+ const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
71386
+ const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
71387
+ const next = stripMentionLists(entry2);
71388
+ if (list3) {
71389
+ next["p188:mentionLst"] = list3;
71390
+ }
71391
+ return next;
71392
+ });
71393
+ if (entries.length > 0) {
71394
+ rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
71395
+ }
71396
+ return rebuilt;
71397
+ }
71398
+ var commonPrefixLength, commonSuffixLength, nearestOccurrence, loadedCoverage, buildMention, stripMentionLists, groupByContainer;
71399
+ var init_modern_comment_mentions = __esm({
71400
+ "pptx/core/utils/modern-comment-mentions.ts"() {
71401
+ init_modern_comment_mention_read();
71402
+ init_modern_comment_mention_read();
71403
+ commonPrefixLength = (a, b) => {
71404
+ const max = Math.min(a.length, b.length);
71405
+ let index = 0;
71406
+ while (index < max && a[index] === b[index]) {
71407
+ index += 1;
71408
+ }
71409
+ return index;
71410
+ };
71411
+ commonSuffixLength = (a, b, limit) => {
71412
+ let index = 0;
71413
+ while (index < limit && a[a.length - 1 - index] === b[b.length - 1 - index]) {
71414
+ index += 1;
71415
+ }
71416
+ return index;
71417
+ };
71418
+ nearestOccurrence = (text2, span, hint) => {
71419
+ let best = -1;
71420
+ let bestDistance = Number.POSITIVE_INFINITY;
71421
+ let at2 = text2.indexOf(span);
71422
+ while (at2 !== -1) {
71423
+ const distance = Math.abs(at2 - hint);
71424
+ if (distance < bestDistance) {
71425
+ best = at2;
71426
+ bestDistance = distance;
71427
+ }
71428
+ at2 = text2.indexOf(span, at2 + 1);
71429
+ }
71430
+ return best;
71431
+ };
71432
+ loadedCoverage = (mention, loaded, oldText) => {
71433
+ const records = loaded.filter(
71434
+ (record2) => mention.id ? record2.id === mention.id : !record2.id && record2.personId === mention.personId && record2.length === mention.length
71435
+ );
71436
+ if (records.length === 0) {
71437
+ return void 0;
71438
+ }
71439
+ return records.map(
71440
+ (record2) => oldText.slice(record2.startIndex, record2.startIndex + record2.length)
71441
+ );
71442
+ };
71443
+ buildMention = (mention) => {
71444
+ const node = {};
71445
+ for (const [key2, value] of Object.entries(mention.rawXml || {})) {
71446
+ if (key2.startsWith("@_")) {
71447
+ node[key2] = value;
71448
+ }
71449
+ }
71450
+ const personKey = MENTION_PERSON_KEYS.find((key2) => node[key2] !== void 0) || "@_mentionpersonId";
71451
+ const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node[key2] !== void 0) || "@_length";
71452
+ node[personKey] = mention.personId;
71453
+ node[lengthKey] = String(mention.length);
71454
+ node["@_startIndex"] = String(mention.startIndex);
71455
+ if (mention.id) {
71456
+ const idKey = node["@_id"] !== void 0 && node["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
71457
+ node[idKey] = mention.id;
71458
+ }
71459
+ return node;
71460
+ };
71461
+ stripMentionLists = (node) => {
71462
+ const result = {};
71463
+ for (const [key2, value] of Object.entries(node)) {
71464
+ if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
71465
+ result[key2] = value;
71466
+ }
71467
+ }
71468
+ return result;
71469
+ };
71470
+ groupByContainer = (mentions) => {
71471
+ const direct = [];
71472
+ const byUri = /* @__PURE__ */ new Map();
71473
+ for (const mention of mentions || []) {
71474
+ if (!mention.containerUri) {
71475
+ direct.push(mention);
71476
+ continue;
71477
+ }
71478
+ const bucket = byUri.get(mention.containerUri);
71479
+ if (bucket) {
71480
+ bucket.push(mention);
71481
+ } else {
71482
+ byUri.set(mention.containerUri, [mention]);
71483
+ }
71484
+ }
71485
+ return { direct, byUri };
71486
+ };
71487
+ }
71488
+ });
71489
+
71224
71490
  // pptx/core/utils/index.ts
71225
71491
  var init_utils = __esm({
71226
71492
  "pptx/core/utils/index.ts"() {
@@ -71357,6 +71623,7 @@ var init_utils = __esm({
71357
71623
  init_auto_number_scripts();
71358
71624
  init_chart_grid_operations();
71359
71625
  init_chart_data_sheet();
71626
+ init_modern_comment_mentions();
71360
71627
  }
71361
71628
  });
71362
71629
 
@@ -77195,7 +77462,7 @@ var init_effect_style_extractor_fill_overlay = __esm({
77195
77462
  });
77196
77463
 
77197
77464
  // pptx/core/core/builders/effect-style-extractor-reflection.ts
77198
- function integer2(value) {
77465
+ function integer3(value) {
77199
77466
  if (value === void 0 || value === null || value === "") {
77200
77467
  return void 0;
77201
77468
  }
@@ -77212,19 +77479,19 @@ function boolean2(value) {
77212
77479
  return void 0;
77213
77480
  }
77214
77481
  function fixedFraction(value) {
77215
- const parsed = integer2(value);
77482
+ const parsed = integer3(value);
77216
77483
  return parsed !== void 0 && parsed >= 0 && parsed <= 1e5 ? parsed / 1e5 : void 0;
77217
77484
  }
77218
77485
  function extractReflectionAttributes(node, emuPerPx) {
77219
- const blur = integer2(node["@_blurRad"]);
77220
- const distance = integer2(node["@_dist"]);
77221
- const startOpacity = integer2(node["@_stA"]);
77222
- const endOpacity = integer2(node["@_endA"]);
77223
- const startPosition = integer2(node["@_stPos"]);
77224
- const endPosition = integer2(node["@_endPos"]);
77225
- const direction = integer2(node["@_dir"]);
77226
- const rotation = integer2(node["@_rot"]);
77227
- const fadeDirection = integer2(node["@_fadeDir"]);
77486
+ const blur = integer3(node["@_blurRad"]);
77487
+ const distance = integer3(node["@_dist"]);
77488
+ const startOpacity = integer3(node["@_stA"]);
77489
+ const endOpacity = integer3(node["@_endA"]);
77490
+ const startPosition = integer3(node["@_stPos"]);
77491
+ const endPosition = integer3(node["@_endPos"]);
77492
+ const direction = integer3(node["@_dir"]);
77493
+ const rotation = integer3(node["@_rot"]);
77494
+ const fadeDirection = integer3(node["@_fadeDir"]);
77228
77495
  const alignment = String(node["@_algn"] ?? "").trim();
77229
77496
  return {
77230
77497
  reflectionBlurRadius: blur !== void 0 && blur >= 0 ? blur / emuPerPx : void 0,
@@ -77236,10 +77503,10 @@ function extractReflectionAttributes(node, emuPerPx) {
77236
77503
  reflectionRotation: rotation !== void 0 ? rotation / 6e4 : void 0,
77237
77504
  reflectionDistance: distance !== void 0 && distance >= 0 ? distance / emuPerPx : void 0,
77238
77505
  reflectionFadeDirection: fadeDirection !== void 0 ? fadeDirection / 6e4 : void 0,
77239
- reflectionScaleX: integer2(node["@_sx"]),
77240
- reflectionScaleY: integer2(node["@_sy"]),
77241
- reflectionSkewX: integer2(node["@_kx"]),
77242
- reflectionSkewY: integer2(node["@_ky"]),
77506
+ reflectionScaleX: integer3(node["@_sx"]),
77507
+ reflectionScaleY: integer3(node["@_sy"]),
77508
+ reflectionSkewX: integer3(node["@_kx"]),
77509
+ reflectionSkewY: integer3(node["@_ky"]),
77243
77510
  reflectionAlignment: VALID_ALIGNMENTS.has(alignment) ? alignment : void 0,
77244
77511
  reflectionRotateWithShape: boolean2(node["@_rotWithShape"])
77245
77512
  };
@@ -83428,6 +83695,96 @@ var init_background_fill_shapes = __esm({
83428
83695
  }
83429
83696
  });
83430
83697
 
83698
+ // pptx/core/core/runtime/load-part-reader.ts
83699
+ function parseText3(parser, text2) {
83700
+ return text2 ? parser.parse(text2) : void 0;
83701
+ }
83702
+ function readPartText(zip, path3) {
83703
+ const reader2 = openReaders.get(zip);
83704
+ if (reader2) {
83705
+ return reader2.readText(path3);
83706
+ }
83707
+ return zip.file(path3)?.async("string") ?? Promise.resolve(void 0);
83708
+ }
83709
+ async function readPartXml(zip, parser, path3) {
83710
+ const reader2 = openReaders.get(zip);
83711
+ if (reader2) {
83712
+ return reader2.readXml(parser, path3);
83713
+ }
83714
+ const text2 = await zip.file(path3)?.async("string");
83715
+ return text2 ? parseText3(parser, text2) : void 0;
83716
+ }
83717
+ var openReaders, LoadPartReader;
83718
+ var init_load_part_reader = __esm({
83719
+ "pptx/core/core/runtime/load-part-reader.ts"() {
83720
+ openReaders = /* @__PURE__ */ new WeakMap();
83721
+ LoadPartReader = class {
83722
+ constructor(zip) {
83723
+ this.zip = zip;
83724
+ openReaders.set(zip, this);
83725
+ }
83726
+ zip;
83727
+ parts = /* @__PURE__ */ new Map();
83728
+ closed = false;
83729
+ entry(path3) {
83730
+ const file = this.zip.file(path3);
83731
+ if (!file) {
83732
+ this.parts.delete(path3);
83733
+ return void 0;
83734
+ }
83735
+ const previous = this.parts.get(path3);
83736
+ if (previous?.file === file) {
83737
+ return previous;
83738
+ }
83739
+ const entry2 = { file, text: file.async("string"), relationships: /* @__PURE__ */ new Map() };
83740
+ this.parts.set(path3, entry2);
83741
+ entry2.text.catch(() => {
83742
+ if (this.parts.get(path3) === entry2) {
83743
+ this.parts.delete(path3);
83744
+ }
83745
+ });
83746
+ return entry2;
83747
+ }
83748
+ readText(path3) {
83749
+ return this.entry(path3)?.text ?? Promise.resolve(void 0);
83750
+ }
83751
+ async readXml(parser, path3) {
83752
+ const entry2 = this.entry(path3);
83753
+ if (!entry2) {
83754
+ return void 0;
83755
+ }
83756
+ if (!path3.endsWith(".rels")) {
83757
+ return parseText3(parser, await entry2.text);
83758
+ }
83759
+ let parsed = entry2.relationships.get(parser);
83760
+ if (!parsed) {
83761
+ const pending = entry2.text.then((text2) => parseText3(parser, text2));
83762
+ entry2.relationships.set(parser, pending);
83763
+ pending.catch(() => {
83764
+ if (entry2.relationships.get(parser) === pending) {
83765
+ entry2.relationships.delete(parser);
83766
+ }
83767
+ });
83768
+ parsed = pending;
83769
+ }
83770
+ return structuredClone(await parsed);
83771
+ }
83772
+ /** Whether this reader still serves reads for its package. */
83773
+ get isOpen() {
83774
+ return !this.closed;
83775
+ }
83776
+ /** Drops every cached read; later reads of the package go to the archive. */
83777
+ close() {
83778
+ this.closed = true;
83779
+ if (openReaders.get(this.zip) === this) {
83780
+ openReaders.delete(this.zip);
83781
+ }
83782
+ this.parts.clear();
83783
+ }
83784
+ };
83785
+ }
83786
+ });
83787
+
83431
83788
  // pptx/core/core/builders/element-hidden-flag.ts
83432
83789
  function findCNvPr(shape) {
83433
83790
  if (!shape) {
@@ -83501,11 +83858,10 @@ var init_flatten_elements = __esm({
83501
83858
 
83502
83859
  // pptx/core/utils/slide-synchronization.ts
83503
83860
  async function loadSlideSynchronization(input) {
83504
- const relsXml = await input.zip.file(input.relsPath)?.async("string");
83505
- if (!relsXml) {
83861
+ const relsData = await readPartXml(input.zip, input.parser, input.relsPath);
83862
+ if (!relsData) {
83506
83863
  return void 0;
83507
83864
  }
83508
- const relsData = input.parser.parse(relsXml);
83509
83865
  const relationship2 = findSlideSyncRelationship(relsData);
83510
83866
  if (!relationship2) {
83511
83867
  return void 0;
@@ -83515,7 +83871,7 @@ async function loadSlideSynchronization(input) {
83515
83871
  return void 0;
83516
83872
  }
83517
83873
  const partPath = resolvePartPath2(input.slidePath, target);
83518
- const partXml = await input.zip.file(partPath)?.async("string");
83874
+ const partXml = await readPartText(input.zip, partPath);
83519
83875
  if (!partXml) {
83520
83876
  return void 0;
83521
83877
  }
@@ -83636,6 +83992,7 @@ function nextSlideSyncPath(files) {
83636
83992
  var SLIDE_SYNC_CONTENT_TYPE;
83637
83993
  var init_slide_synchronization = __esm({
83638
83994
  "pptx/core/utils/slide-synchronization.ts"() {
83995
+ init_load_part_reader();
83639
83996
  SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
83640
83997
  }
83641
83998
  });
@@ -83649,11 +84006,10 @@ function ensureArray9(value) {
83649
84006
  }
83650
84007
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83651
84008
  try {
83652
- const relsXml = await zip.file(relsPath2)?.async("string");
83653
- if (!relsXml) {
84009
+ const relsData = await readPartXml(zip, parser, relsPath2);
84010
+ if (!relsData) {
83654
84011
  return [];
83655
84012
  }
83656
- const relsData = parser.parse(relsXml);
83657
84013
  const relationships3 = ensureArray9(
83658
84014
  relsData["Relationships"]?.["Relationship"]
83659
84015
  );
@@ -83676,7 +84032,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83676
84032
  if (!resolved) {
83677
84033
  continue;
83678
84034
  }
83679
- const vmlXml = await zip.file(resolved)?.async("string");
84035
+ const vmlXml = await readPartText(zip, resolved);
83680
84036
  if (!vmlXml) {
83681
84037
  continue;
83682
84038
  }
@@ -83695,6 +84051,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
83695
84051
  var VML_DRAWING_REL_SUFFIX;
83696
84052
  var init_vml_drawing_loader = __esm({
83697
84053
  "pptx/core/utils/vml-drawing-loader.ts"() {
84054
+ init_load_part_reader();
83698
84055
  init_safe_path();
83699
84056
  init_vml_parser();
83700
84057
  VML_DRAWING_REL_SUFFIX = "/relationships/vmlDrawing";
@@ -86424,6 +86781,7 @@ exports.PptxSlideLoaderService = void 0;
86424
86781
  var init_PptxSlideLoaderService = __esm({
86425
86782
  "pptx/core/services/PptxSlideLoaderService.ts"() {
86426
86783
  init_background_fill_shapes();
86784
+ init_load_part_reader();
86427
86785
  init_element_hidden_flag();
86428
86786
  init_background_style_ref();
86429
86787
  init_flatten_elements();
@@ -86484,11 +86842,14 @@ var init_PptxSlideLoaderService = __esm({
86484
86842
  * @returns Map of relationship ID to target path string.
86485
86843
  */
86486
86844
  async loadPresentationSlideRels(params) {
86487
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
86488
- if (!relsXml) {
86845
+ const relsData = await readPartXml(
86846
+ params.zip,
86847
+ params.parser,
86848
+ "ppt/_rels/presentation.xml.rels"
86849
+ );
86850
+ if (!relsData) {
86489
86851
  return /* @__PURE__ */ new Map();
86490
86852
  }
86491
- const relsData = params.parser.parse(relsXml);
86492
86853
  const relationships3 = relsData["Relationships"]?.["Relationship"];
86493
86854
  const relNodes = this.toXmlObjectArray(relationships3);
86494
86855
  const relsMap = /* @__PURE__ */ new Map();
@@ -86528,7 +86889,7 @@ var init_PptxSlideLoaderService = __esm({
86528
86889
  if (!params.zip.file(path3)) {
86529
86890
  path3 = `ppt/${target}`;
86530
86891
  }
86531
- const slideXmlStr = await params.zip.file(path3)?.async("string");
86892
+ const slideXmlStr = await readPartText(params.zip, path3);
86532
86893
  if (!slideXmlStr) {
86533
86894
  return void 0;
86534
86895
  }
@@ -111025,12 +111386,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
111025
111386
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
111026
111387
  const target = resolve(chartPartPath, external.targetPath);
111027
111388
  let references = 0;
111028
- const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
111029
111389
  try {
111030
111390
  for (const path3 of Object.keys(zip.files)) {
111031
111391
  if (!path3.endsWith(".rels") || !path3.includes("/_rels/")) continue;
111032
111392
  const source = path3.replace("/_rels/", "/").slice(0, -5);
111033
- const tree = parser.parse(await zip.file(path3).async("string"));
111393
+ const tree = await readPartXml(zip, relationshipParser, path3);
111034
111394
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
111035
111395
  const relationshipTarget2 = xmlAttr(rel, "Target");
111036
111396
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve(source, relationshipTarget2) === target)
@@ -111047,11 +111407,14 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
111047
111407
  return false;
111048
111408
  }
111049
111409
  }
111410
+ var relationshipParser;
111050
111411
  var init_chart_label_source = __esm({
111051
111412
  "pptx/core/utils/chart-label-source.ts"() {
111413
+ init_load_part_reader();
111052
111414
  init_chart_xlsx_writer();
111053
111415
  init_xml_access();
111054
111416
  init_chart_xlsx_cellref();
111417
+ relationshipParser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
111055
111418
  }
111056
111419
  });
111057
111420
 
@@ -111839,7 +112202,7 @@ function malformed(context, element, value) {
111839
112202
  function cBool(context, parent, local) {
111840
112203
  const element = cChild(parent, local);
111841
112204
  if (!element) return void 0;
111842
- const raw2 = attribute5(element, "val");
112205
+ const raw2 = attribute6(element, "val");
111843
112206
  if (raw2 === void 0) return true;
111844
112207
  const value = raw2.trim().toLowerCase();
111845
112208
  if (value === "1" || value === "true") return true;
@@ -111849,7 +112212,7 @@ function cBool(context, parent, local) {
111849
112212
  }
111850
112213
  function cNumber(context, parent, local) {
111851
112214
  const element = cChild(parent, local);
111852
- const raw2 = attribute5(element, "val");
112215
+ const raw2 = attribute6(element, "val");
111853
112216
  if (!element || raw2 === void 0) return void 0;
111854
112217
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
111855
112218
  if (Number.isFinite(value)) return value;
@@ -111858,7 +112221,7 @@ function cNumber(context, parent, local) {
111858
112221
  }
111859
112222
  function cEnum(context, parent, local, allowed) {
111860
112223
  const element = cChild(parent, local);
111861
- const raw2 = attribute5(element, "val");
112224
+ const raw2 = attribute6(element, "val");
111862
112225
  if (!element || raw2 === void 0) return void 0;
111863
112226
  if (allowed.includes(raw2)) return raw2;
111864
112227
  malformed(context, element, raw2);
@@ -111915,9 +112278,9 @@ function chartLines(parent, local) {
111915
112278
  }
111916
112279
  function numberFormat(parent) {
111917
112280
  const element = cChild(parent, "numFmt");
111918
- const formatCode2 = attribute5(element, "formatCode");
112281
+ const formatCode2 = attribute6(element, "formatCode");
111919
112282
  if (formatCode2 === void 0) return void 0;
111920
- const linked = attribute5(element, "sourceLinked");
112283
+ const linked = attribute6(element, "sourceLinked");
111921
112284
  return {
111922
112285
  formatCode: formatCode2,
111923
112286
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -111941,7 +112304,7 @@ function assignDefined(target, values) {
111941
112304
  if (value !== void 0) target[key2] = value;
111942
112305
  return target;
111943
112306
  }
111944
- var cChild, attribute5, cVal, path, textProperties;
112307
+ var cChild, attribute6, cVal, path, textProperties;
111945
112308
  var init_parse_util = __esm({
111946
112309
  "chart/parse-util.ts"() {
111947
112310
  init_xml2();
@@ -111950,8 +112313,8 @@ var init_parse_util = __esm({
111950
112313
  init_manual_layout();
111951
112314
  init_xml_fragment();
111952
112315
  cChild = (parent, local) => first(parent, local, NS.c);
111953
- attribute5 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
111954
- cVal = (parent, local) => attribute5(cChild(parent, local), "val");
112316
+ attribute6 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
112317
+ cVal = (parent, local) => attribute6(cChild(parent, local), "val");
111955
112318
  path = (element) => `c:${element.parentNode?.localName ?? ""}/c:${element.localName}`;
111956
112319
  textProperties = (parent) => chartTextBody(cChild(parent, "txPr"));
111957
112320
  }
@@ -111963,9 +112326,9 @@ function parseCache(node) {
111963
112326
  type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
111964
112327
  points: children2(node, "pt", NS.c).map((pt3) => {
111965
112328
  const point2 = { value: cChild(pt3, "v")?.textContent ?? "" };
111966
- const index = Number(attribute5(pt3, "idx") ?? Number.NaN);
112329
+ const index = Number(attribute6(pt3, "idx") ?? Number.NaN);
111967
112330
  if (Number.isInteger(index) && index >= 0) point2.index = index;
111968
- const formatCode3 = attribute5(pt3, "formatCode");
112331
+ const formatCode3 = attribute6(pt3, "formatCode");
111969
112332
  if (formatCode3 !== void 0) point2.formatCode = formatCode3;
111970
112333
  return point2;
111971
112334
  })
@@ -112168,10 +112531,10 @@ function readDisplayNaAsBlank(chartExtLst) {
112168
112531
  return void 0;
112169
112532
  }
112170
112533
  for (const ext of elements(root)) {
112171
- if (ext.localName !== "ext" || attribute5(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
112534
+ if (ext.localName !== "ext" || attribute6(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
112172
112535
  const flag2 = first(first(ext, "dataDisplayOptions16", C16R3), "dispNaAsBlank", C16R3);
112173
112536
  if (!flag2) continue;
112174
- const raw2 = attribute5(flag2, "val")?.trim().toLowerCase();
112537
+ const raw2 = attribute6(flag2, "val")?.trim().toLowerCase();
112175
112538
  return raw2 === void 0 || raw2 === "1" || raw2 === "true";
112176
112539
  }
112177
112540
  return void 0;
@@ -112416,7 +112779,7 @@ function customSplit(context, element) {
112416
112779
  if (!element) return void 0;
112417
112780
  reportUnmodelled(context, element, /* @__PURE__ */ new Set(["secondPiePt"]));
112418
112781
  return children2(element, "secondPiePt", NS.c).flatMap((point2) => {
112419
- const raw2 = attribute5(point2, "val")?.trim();
112782
+ const raw2 = attribute6(point2, "val")?.trim();
112420
112783
  const index = raw2 ? Number(raw2) : Number.NaN;
112421
112784
  return Number.isInteger(index) && index >= 0 ? [index] : [];
112422
112785
  });
@@ -112437,7 +112800,7 @@ function parseGroup(context, element) {
112437
112800
  is3D,
112438
112801
  series: children2(element, "ser", NS.c).map((ser) => parseSeries(context, ser)),
112439
112802
  axisIds: children2(element, "axId", NS.c).flatMap((axis) => {
112440
- const raw2 = attribute5(axis, "val")?.trim();
112803
+ const raw2 = attribute6(axis, "val")?.trim();
112441
112804
  const id = raw2 ? Number(raw2) : Number.NaN;
112442
112805
  return Number.isFinite(id) ? [id] : [];
112443
112806
  })
@@ -112719,7 +113082,7 @@ function chartStyle(context, space) {
112719
113082
  }
112720
113083
  function c14Style(space) {
112721
113084
  for (const alternate of children2(space, "AlternateContent", NS.mc)) {
112722
- const raw2 = attribute5(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
113085
+ const raw2 = attribute6(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
112723
113086
  const value = raw2?.trim() ? Number(raw2) : Number.NaN;
112724
113087
  if (Number.isFinite(value)) return value;
112725
113088
  }
@@ -113408,7 +113771,7 @@ function malformed2(context, where, value) {
113408
113771
  });
113409
113772
  }
113410
113773
  function boolAttribute(context, element, name) {
113411
- const raw2 = attribute5(element, name);
113774
+ const raw2 = attribute6(element, name);
113412
113775
  if (!element || raw2 === void 0) return void 0;
113413
113776
  const value = raw2.trim().toLowerCase();
113414
113777
  if (value === "1" || value === "true") return true;
@@ -113417,7 +113780,7 @@ function boolAttribute(context, element, name) {
113417
113780
  return void 0;
113418
113781
  }
113419
113782
  function numberAttribute(context, element, name) {
113420
- const raw2 = attribute5(element, name);
113783
+ const raw2 = attribute6(element, name);
113421
113784
  if (!element || raw2 === void 0) return void 0;
113422
113785
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
113423
113786
  if (Number.isFinite(value)) return value;
@@ -113427,11 +113790,11 @@ function numberAttribute(context, element, name) {
113427
113790
  function indexAttribute(context, element, name) {
113428
113791
  const value = numberAttribute(context, element, name);
113429
113792
  if (value === void 0 || Number.isInteger(value) && value >= 0) return value;
113430
- malformed2(context, path2(element, name), attribute5(element, name) ?? "");
113793
+ malformed2(context, path2(element, name), attribute6(element, name) ?? "");
113431
113794
  return void 0;
113432
113795
  }
113433
113796
  function autoNumberAttribute(context, element, name) {
113434
- return attribute5(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
113797
+ return attribute6(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
113435
113798
  }
113436
113799
  function reportUnmodelled2(context, element, handled) {
113437
113800
  for (const child32 of elements(element)) {
@@ -113462,9 +113825,9 @@ function lines(parent, local) {
113462
113825
  }
113463
113826
  function numberFormat2(parent) {
113464
113827
  const element = cxChild(parent, "numFmt");
113465
- const formatCode2 = attribute5(element, "formatCode");
113828
+ const formatCode2 = attribute6(element, "formatCode");
113466
113829
  if (formatCode2 === void 0) return void 0;
113467
- const linked = attribute5(element, "sourceLinked");
113830
+ const linked = attribute6(element, "sourceLinked");
113468
113831
  return {
113469
113832
  formatCode: formatCode2,
113470
113833
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -113475,7 +113838,7 @@ function formula(parent, local) {
113475
113838
  const element = cxChild(parent, local);
113476
113839
  if (!element) return void 0;
113477
113840
  const out = { formula: element.textContent ?? "" };
113478
- const direction = attribute5(element, "dir");
113841
+ const direction = attribute6(element, "dir");
113479
113842
  if (direction !== void 0) out.direction = direction;
113480
113843
  return out;
113481
113844
  }
@@ -113509,8 +113872,8 @@ function parseLevel(context, element) {
113509
113872
  { points: points7 },
113510
113873
  {
113511
113874
  pointCount: indexAttribute(context, element, "ptCount"),
113512
- formatCode: attribute5(element, "formatCode"),
113513
- name: attribute5(element, "name"),
113875
+ formatCode: attribute6(element, "formatCode"),
113876
+ name: attribute6(element, "name"),
113514
113877
  extLst: extensionList2(element)
113515
113878
  }
113516
113879
  );
@@ -113523,7 +113886,7 @@ function parseDimension(context, element) {
113523
113886
  levels: cxChildren(element, "lvl").map((level2) => parseLevel(context, level2))
113524
113887
  },
113525
113888
  {
113526
- type: attribute5(element, "type"),
113889
+ type: attribute6(element, "type"),
113527
113890
  formula: formula(element, "f"),
113528
113891
  nameFormula: formula(element, "nf"),
113529
113892
  extLst: extensionList2(element)
@@ -113557,7 +113920,7 @@ function parseChartData(context, element) {
113557
113920
  }
113558
113921
  return out;
113559
113922
  }
113560
- function parseText3(context, element) {
113923
+ function parseText4(context, element) {
113561
113924
  if (!element) return void 0;
113562
113925
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
113563
113926
  const data = cxChild(element, "txData");
@@ -113577,11 +113940,11 @@ function parseTitle2(context, element) {
113577
113940
  return assignDefined(
113578
113941
  {},
113579
113942
  {
113580
- tx: parseText3(context, cxChild(element, "tx")),
113943
+ tx: parseText4(context, cxChild(element, "tx")),
113581
113944
  spPr: shapeProperties2(element),
113582
113945
  txPr: textProperties2(element),
113583
- position: attribute5(element, "pos"),
113584
- align: attribute5(element, "align"),
113946
+ position: attribute6(element, "pos"),
113947
+ align: attribute6(element, "align"),
113585
113948
  overlay: boolAttribute(context, element, "overlay"),
113586
113949
  extLst: extensionList2(element)
113587
113950
  }
@@ -113592,8 +113955,8 @@ function parseLegend2(context, element) {
113592
113955
  return assignDefined(
113593
113956
  {},
113594
113957
  {
113595
- position: attribute5(element, "pos"),
113596
- align: attribute5(element, "align"),
113958
+ position: attribute6(element, "pos"),
113959
+ align: attribute6(element, "align"),
113597
113960
  overlay: boolAttribute(context, element, "overlay"),
113598
113961
  spPr: shapeProperties2(element),
113599
113962
  txPr: textProperties2(element),
@@ -113642,7 +114005,7 @@ function parseUnits(context, element) {
113642
114005
  return assignDefined(
113643
114006
  {},
113644
114007
  {
113645
- unit: attribute5(element, "unit"),
114008
+ unit: attribute6(element, "unit"),
113646
114009
  label: label ? parseTitle2(context, label) : void 0,
113647
114010
  extLst: extensionList2(element)
113648
114011
  }
@@ -113693,7 +114056,7 @@ var init_parse_axis = __esm({
113693
114056
  "txPr",
113694
114057
  "extLst"
113695
114058
  ]);
113696
- tickMarks = (element) => element ? assignDefined({}, { type: attribute5(element, "type") }) : void 0;
114059
+ tickMarks = (element) => element ? assignDefined({}, { type: attribute6(element, "type") }) : void 0;
113697
114060
  }
113698
114061
  });
113699
114062
 
@@ -113712,7 +114075,7 @@ function labelVisibility(context, element) {
113712
114075
  function labelOptions2(context, element) {
113713
114076
  const separator = cxChild(element, "separator");
113714
114077
  return {
113715
- position: attribute5(element, "pos"),
114078
+ position: attribute6(element, "pos"),
113716
114079
  numberFormat: numberFormat2(element),
113717
114080
  spPr: shapeProperties2(element),
113718
114081
  txPr: textProperties2(element),
@@ -113745,7 +114108,7 @@ function parseBinning(context, element) {
113745
114108
  return assignDefined(
113746
114109
  {},
113747
114110
  {
113748
- intervalClosed: attribute5(element, "intervalClosed"),
114111
+ intervalClosed: attribute6(element, "intervalClosed"),
113749
114112
  underflow: autoNumberAttribute(context, element, "underflow"),
113750
114113
  overflow: autoNumberAttribute(context, element, "overflow"),
113751
114114
  binSize: scalar4("binSize"),
@@ -113758,11 +114121,11 @@ function parseGeography(context, element) {
113758
114121
  return assignDefined(
113759
114122
  {},
113760
114123
  {
113761
- projectionType: attribute5(element, "projectionType"),
113762
- viewedRegionType: attribute5(element, "viewedRegionType"),
113763
- cultureLanguage: attribute5(element, "cultureLanguage"),
113764
- cultureRegion: attribute5(element, "cultureRegion"),
113765
- attribution: attribute5(element, "attribution"),
114124
+ projectionType: attribute6(element, "projectionType"),
114125
+ viewedRegionType: attribute6(element, "viewedRegionType"),
114126
+ cultureLanguage: attribute6(element, "cultureLanguage"),
114127
+ cultureRegion: attribute6(element, "cultureRegion"),
114128
+ attribution: attribute6(element, "attribution"),
113766
114129
  geoCacheXml: rawChild2(element, "geoCache"),
113767
114130
  extLst: extensionList2(element)
113768
114131
  }
@@ -113778,8 +114141,8 @@ function parseLayout(context, element) {
113778
114141
  return assignDefined(
113779
114142
  {},
113780
114143
  {
113781
- parentLabelLayout: attribute5(cxChild(element, "parentLabelLayout"), "val"),
113782
- regionLabelLayout: attribute5(cxChild(element, "regionLabelLayout"), "val"),
114144
+ parentLabelLayout: attribute6(cxChild(element, "parentLabelLayout"), "val"),
114145
+ regionLabelLayout: attribute6(cxChild(element, "regionLabelLayout"), "val"),
113783
114146
  visibility: visibility ? assignDefined(
113784
114147
  {},
113785
114148
  Object.fromEntries(
@@ -113791,7 +114154,7 @@ function parseLayout(context, element) {
113791
114154
  geography: geography ? parseGeography(context, geography) : void 0,
113792
114155
  statistics: statistics ? assignDefined(
113793
114156
  {},
113794
- { quartileMethod: attribute5(statistics, "quartileMethod") }
114157
+ { quartileMethod: attribute6(statistics, "quartileMethod") }
113795
114158
  ) : void 0,
113796
114159
  subtotals: subtotals ? cxChildren(subtotals, "idx").map((idx) => indexAttribute(context, idx, "val")).filter((index) => index !== void 0) : void 0,
113797
114160
  extLst: extensionList2(element)
@@ -113816,13 +114179,13 @@ function parseSeries2(context, element) {
113816
114179
  const layout = cxChild(element, "layoutPr");
113817
114180
  const axisIds = cxChildren(element, "axisId").map((axis) => indexAttribute(context, axis, "val")).filter((id) => id !== void 0);
113818
114181
  return assignDefined(
113819
- { layoutId: attribute5(element, "layoutId") ?? "", dataPoints, axisIds },
114182
+ { layoutId: attribute6(element, "layoutId") ?? "", dataPoints, axisIds },
113820
114183
  {
113821
114184
  hidden: boolAttribute(context, element, "hidden"),
113822
114185
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
113823
- uniqueId: attribute5(element, "uniqueId"),
114186
+ uniqueId: attribute6(element, "uniqueId"),
113824
114187
  formatIndex: numberAttribute(context, element, "formatIdx"),
113825
- tx: parseText3(context, cxChild(element, "tx")),
114188
+ tx: parseText4(context, cxChild(element, "tx")),
113826
114189
  spPr: shapeProperties2(element),
113827
114190
  txPr: textProperties2(element),
113828
114191
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -117550,254 +117913,6 @@ var init_modern_comment_fields = __esm({
117550
117913
  }
117551
117914
  });
117552
117915
 
117553
- // pptx/core/utils/modern-comment-mention-read.ts
117554
- function readCommentMentions(node, authorName) {
117555
- if (!node) {
117556
- return void 0;
117557
- }
117558
- const found = [];
117559
- for (const list3 of mentionChildrenNamed(node, "mentionLst")) {
117560
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
117561
- const mention = readMention(entry2, authorName);
117562
- if (mention) {
117563
- found.push(mention);
117564
- }
117565
- }
117566
- }
117567
- for (const extension of mentionChildrenNamed(mentionChildrenNamed(node, "extLst")[0], "ext")) {
117568
- const uri = String(extension["@_uri"] || "");
117569
- for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
117570
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
117571
- const mention = readMention(entry2, authorName, uri);
117572
- if (mention) {
117573
- found.push(mention);
117574
- }
117575
- }
117576
- }
117577
- }
117578
- found.sort((a, b) => a.startIndex - b.startIndex);
117579
- return found.length > 0 ? found : void 0;
117580
- }
117581
- var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute6, integer3, readMention;
117582
- var init_modern_comment_mention_read = __esm({
117583
- "pptx/core/utils/modern-comment-mention-read.ts"() {
117584
- mentionLocalName = (key2) => key2.split(":").pop() || key2;
117585
- mentionNodesOf = (value) => {
117586
- if (Array.isArray(value)) {
117587
- return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
117588
- }
117589
- return value && typeof value === "object" ? [value] : [];
117590
- };
117591
- mentionChildrenNamed = (node, name) => {
117592
- if (!node) {
117593
- return [];
117594
- }
117595
- const result = [];
117596
- for (const [key2, value] of Object.entries(node)) {
117597
- if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
117598
- result.push(...mentionNodesOf(value));
117599
- }
117600
- }
117601
- return result;
117602
- };
117603
- MENTION_PERSON_KEYS = [
117604
- "@_mentionpersonId",
117605
- "@_mentionPersonId",
117606
- "@_personId",
117607
- "@_authorId"
117608
- ];
117609
- MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
117610
- attribute6 = (node, keys) => {
117611
- for (const key2 of keys) {
117612
- const value = node[key2];
117613
- if (value !== void 0 && value !== null && String(value).length > 0) {
117614
- return String(value);
117615
- }
117616
- }
117617
- return void 0;
117618
- };
117619
- integer3 = (value) => {
117620
- if (value === void 0) {
117621
- return void 0;
117622
- }
117623
- const parsed = Number.parseInt(value, 10);
117624
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
117625
- };
117626
- readMention = (node, authorName, containerUri) => {
117627
- const personId = attribute6(node, MENTION_PERSON_KEYS);
117628
- const startIndex = integer3(attribute6(node, ["@_startIndex"]));
117629
- const length = integer3(attribute6(node, MENTION_LENGTH_KEYS));
117630
- if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
117631
- return void 0;
117632
- }
117633
- return {
117634
- personId,
117635
- startIndex,
117636
- length,
117637
- id: attribute6(node, ["@_mentionId", "@_id"]),
117638
- authorName: authorName(personId),
117639
- containerUri,
117640
- rawXml: node
117641
- };
117642
- };
117643
- }
117644
- });
117645
-
117646
- // pptx/core/utils/modern-comment-mentions.ts
117647
- function rebaseCommentMentions(mentions, oldText, newText) {
117648
- if (!mentions || mentions.length === 0) {
117649
- return void 0;
117650
- }
117651
- if (oldText === newText) {
117652
- return mentions;
117653
- }
117654
- const prefix = commonPrefixLength(oldText, newText);
117655
- const suffix = commonSuffixLength(
117656
- oldText,
117657
- newText,
117658
- Math.min(oldText.length, newText.length) - prefix
117659
- );
117660
- const changeEnd = oldText.length - suffix;
117661
- const delta2 = newText.length - oldText.length;
117662
- const result = [];
117663
- for (const mention of mentions) {
117664
- const start = mention.startIndex;
117665
- const end = start + mention.length;
117666
- const span = oldText.slice(start, end);
117667
- if (span.length !== mention.length) {
117668
- continue;
117669
- }
117670
- let next = -1;
117671
- if (end <= prefix) {
117672
- next = start;
117673
- } else if (start >= changeEnd) {
117674
- next = start + delta2;
117675
- }
117676
- if (next >= 0 && newText.slice(next, next + mention.length) === span) {
117677
- result.push(next === start ? mention : { ...mention, startIndex: next });
117678
- continue;
117679
- }
117680
- const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
117681
- if (relocated >= 0) {
117682
- result.push({ ...mention, startIndex: relocated });
117683
- }
117684
- }
117685
- return result.length > 0 ? result : void 0;
117686
- }
117687
- function buildMentionListNode(mentions) {
117688
- if (!mentions || mentions.length === 0) {
117689
- return void 0;
117690
- }
117691
- return { "p188:mention": mentions.map(buildMention) };
117692
- }
117693
- function applyCommentMentions(node, mentions, extension, replace) {
117694
- if (!replace) {
117695
- return extension;
117696
- }
117697
- const { direct, byUri } = groupByContainer(mentions);
117698
- const directList = buildMentionListNode(direct);
117699
- if (directList) {
117700
- node["p188:mentionLst"] = directList;
117701
- }
117702
- if (!extension) {
117703
- return void 0;
117704
- }
117705
- const rebuilt = stripMentionLists(extension);
117706
- const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
117707
- const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
117708
- const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
117709
- const next = stripMentionLists(entry2);
117710
- if (list3) {
117711
- next["p188:mentionLst"] = list3;
117712
- }
117713
- return next;
117714
- });
117715
- if (entries.length > 0) {
117716
- rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
117717
- }
117718
- return rebuilt;
117719
- }
117720
- var commonPrefixLength, commonSuffixLength, nearestOccurrence, buildMention, stripMentionLists, groupByContainer;
117721
- var init_modern_comment_mentions = __esm({
117722
- "pptx/core/utils/modern-comment-mentions.ts"() {
117723
- init_modern_comment_mention_read();
117724
- init_modern_comment_mention_read();
117725
- commonPrefixLength = (a, b) => {
117726
- const max = Math.min(a.length, b.length);
117727
- let index = 0;
117728
- while (index < max && a[index] === b[index]) {
117729
- index += 1;
117730
- }
117731
- return index;
117732
- };
117733
- commonSuffixLength = (a, b, limit) => {
117734
- let index = 0;
117735
- while (index < limit && a[a.length - 1 - index] === b[b.length - 1 - index]) {
117736
- index += 1;
117737
- }
117738
- return index;
117739
- };
117740
- nearestOccurrence = (text2, span, hint) => {
117741
- let best = -1;
117742
- let bestDistance = Number.POSITIVE_INFINITY;
117743
- let at2 = text2.indexOf(span);
117744
- while (at2 !== -1) {
117745
- const distance = Math.abs(at2 - hint);
117746
- if (distance < bestDistance) {
117747
- best = at2;
117748
- bestDistance = distance;
117749
- }
117750
- at2 = text2.indexOf(span, at2 + 1);
117751
- }
117752
- return best;
117753
- };
117754
- buildMention = (mention) => {
117755
- const node = {};
117756
- for (const [key2, value] of Object.entries(mention.rawXml || {})) {
117757
- if (key2.startsWith("@_")) {
117758
- node[key2] = value;
117759
- }
117760
- }
117761
- const personKey = MENTION_PERSON_KEYS.find((key2) => node[key2] !== void 0) || "@_mentionpersonId";
117762
- const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node[key2] !== void 0) || "@_length";
117763
- node[personKey] = mention.personId;
117764
- node[lengthKey] = String(mention.length);
117765
- node["@_startIndex"] = String(mention.startIndex);
117766
- if (mention.id) {
117767
- const idKey = node["@_id"] !== void 0 && node["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
117768
- node[idKey] = mention.id;
117769
- }
117770
- return node;
117771
- };
117772
- stripMentionLists = (node) => {
117773
- const result = {};
117774
- for (const [key2, value] of Object.entries(node)) {
117775
- if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
117776
- result[key2] = value;
117777
- }
117778
- }
117779
- return result;
117780
- };
117781
- groupByContainer = (mentions) => {
117782
- const direct = [];
117783
- const byUri = /* @__PURE__ */ new Map();
117784
- for (const mention of mentions || []) {
117785
- if (!mention.containerUri) {
117786
- direct.push(mention);
117787
- continue;
117788
- }
117789
- const bucket = byUri.get(mention.containerUri);
117790
- if (bucket) {
117791
- bucket.push(mention);
117792
- } else {
117793
- byUri.set(mention.containerUri, [mention]);
117794
- }
117795
- }
117796
- return { direct, byUri };
117797
- };
117798
- }
117799
- });
117800
-
117801
117916
  // pptx/core/utils/modern-comment-text-body.ts
117802
117917
  function flattenBodyText(node) {
117803
117918
  if (!node) {
@@ -118191,7 +118306,13 @@ var init_modern_comment_xml = __esm({
118191
118306
  const originalBody = child24(raw2, "txBody");
118192
118307
  node["p188:txBody"] = applyModernCommentText(originalBody, comment.text);
118193
118308
  const originalText = originalBody ? flattenBodyText(originalBody).join("\n") : comment.text;
118194
- const mentions = rebaseCommentMentions(comment.mentions, originalText, comment.text);
118309
+ const loadedMentions = raw2 ? readCommentMentions(raw2, () => void 0) : void 0;
118310
+ const mentions = rebaseCommentMentions(
118311
+ comment.mentions,
118312
+ originalText,
118313
+ comment.text,
118314
+ loadedMentions ?? []
118315
+ );
118195
118316
  const extension = applyCommentMentions(node, mentions, child24(raw2, "extLst"), ownsMentions);
118196
118317
  if (extension) {
118197
118318
  node["p188:extLst"] = extension;
@@ -127684,8 +127805,8 @@ async function discoverTagCollections(zip, codec) {
127684
127805
  if (!sourcePartPath) {
127685
127806
  continue;
127686
127807
  }
127687
- const data = codec.parse(await relFile.async("string"));
127688
- const root = data["Relationships"];
127808
+ const data = await readPartXml(zip, codec, relFile.name);
127809
+ const root = data?.["Relationships"];
127689
127810
  for (const relationship2 of ensureArray17(root?.["Relationship"])) {
127690
127811
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
127691
127812
  continue;
@@ -127790,7 +127911,7 @@ async function removeTagContentTypeOverride(zip, codec, path3) {
127790
127911
  zip.file("[Content_Types].xml", codec.build(data));
127791
127912
  }
127792
127913
  async function readTagCollection(zip, codec, path3) {
127793
- const xml = await zip.file(path3)?.async("string");
127914
+ const xml = await readPartText(zip, path3);
127794
127915
  if (!xml) {
127795
127916
  return void 0;
127796
127917
  }
@@ -127899,6 +128020,7 @@ function ensureArray17(value) {
127899
128020
  var TAG_RELATIONSHIP_TYPE, TAG_CONTENT_TYPE;
127900
128021
  var init_tag_package = __esm({
127901
128022
  "pptx/core/utils/tag-package.ts"() {
128023
+ init_load_part_reader();
127902
128024
  init_safe_path();
127903
128025
  init_tag_package_owning_element();
127904
128026
  TAG_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags";
@@ -133232,10 +133354,35 @@ var init_PptxHandlerRuntimeState = __esm({
133232
133354
  "pptx/core/core/runtime/PptxHandlerRuntimeState.ts"() {
133233
133355
  init_utils();
133234
133356
  init_part_rels_path();
133357
+ init_load_part_reader();
133235
133358
  init_template_element_baselines();
133236
133359
  PptxHandlerRuntime = class {
133237
133360
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
133238
133361
  zip;
133362
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
133363
+ loadPartReader;
133364
+ /** Opens a part reader for the current package, closing any earlier one. */
133365
+ beginPartReads() {
133366
+ this.endPartReads();
133367
+ const reader2 = new LoadPartReader(this.zip);
133368
+ this.loadPartReader = reader2;
133369
+ return reader2;
133370
+ }
133371
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
133372
+ endPartReads(reader2 = this.loadPartReader) {
133373
+ reader2?.close();
133374
+ if (reader2 && this.loadPartReader === reader2) {
133375
+ this.loadPartReader = void 0;
133376
+ }
133377
+ }
133378
+ /** The text of a package part, shared within a load. */
133379
+ readPartText(path3) {
133380
+ return readPartText(this.zip, path3);
133381
+ }
133382
+ /** A parsed package part; relationship parts are parsed once per load. */
133383
+ readPartXml(path3) {
133384
+ return readPartXml(this.zip, this.parser, path3);
133385
+ }
133239
133386
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
133240
133387
  parser;
133241
133388
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -133654,11 +133801,11 @@ var init_PptxHandlerRuntimeState = __esm({
133654
133801
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
133655
133802
  */
133656
133803
  async loadPartRelationships(partPath, relsPath2) {
133657
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
133658
- if (!relsXml) {
133804
+ const path3 = relsPath2 ?? partRelsPath(partPath);
133805
+ const relsData = await this.readPartXml(path3);
133806
+ if (!relsData) {
133659
133807
  return;
133660
133808
  }
133661
- const relsData = this.parser.parse(relsXml);
133662
133809
  const relationships3 = relsData?.["Relationships"];
133663
133810
  const raw2 = relationships3?.["Relationship"];
133664
133811
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -135187,10 +135334,6 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135187
135334
  this.zip.file(relsPath2, this.builder.build(relsData));
135188
135335
  return true;
135189
135336
  }
135190
- /** The text of a package part, or `undefined` when the package has no such part. */
135191
- async readPartText(path3) {
135192
- return this.zip.file(path3)?.async("string");
135193
- }
135194
135337
  /**
135195
135338
  * Parse extended (application) properties from `docProps/app.xml`.
135196
135339
  */
@@ -135251,8 +135394,10 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135251
135394
  if (!relsFile) {
135252
135395
  return [];
135253
135396
  }
135254
- const relsXml = await relsFile.async("string");
135255
- const relsData = this.parser.parse(relsXml);
135397
+ const relsData = await this.readPartXml(relsPath2);
135398
+ if (!relsData) {
135399
+ return [];
135400
+ }
135256
135401
  const relRoot = relsData["Relationships"] || {};
135257
135402
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
135258
135403
  const relMap = /* @__PURE__ */ new Map();
@@ -135283,7 +135428,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135283
135428
  try {
135284
135429
  const file = this.zip.file(resolvedPath);
135285
135430
  if (file) {
135286
- data = await file.async("string");
135431
+ data = await this.readPartText(resolvedPath);
135287
135432
  }
135288
135433
  } catch {
135289
135434
  }
@@ -135363,9 +135508,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135363
135508
  */
135364
135509
  async parseTags() {
135365
135510
  try {
135366
- return await discoverTagCollections(this.zip, {
135367
- parse: (xml) => this.parser.parse(xml)
135368
- });
135511
+ return await discoverTagCollections(this.zip, this.parser);
135369
135512
  } catch (e) {
135370
135513
  console.warn("Failed to parse tags:", e);
135371
135514
  return [];
@@ -135505,7 +135648,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135505
135648
  }
135506
135649
  for (const file of masterFiles) {
135507
135650
  const path3 = file.name;
135508
- const xml = await file.async("string");
135651
+ const xml = await this.readPartText(path3) ?? "";
135509
135652
  const data = this.parser.parse(xml);
135510
135653
  const sldMaster = data?.["p:sldMaster"];
135511
135654
  if (!sldMaster) {
@@ -135530,8 +135673,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135530
135673
  );
135531
135674
  const relsFile = this.zip.file(relsPath2);
135532
135675
  if (relsFile) {
135533
- const relsXml = await relsFile.async("string");
135534
- const relsData = this.parser.parse(relsXml);
135676
+ const relsData = await this.readPartXml(relsPath2);
135535
135677
  const rels = this.ensureArray(
135536
135678
  xmlChild(relsData, "Relationships")?.["Relationship"]
135537
135679
  );
@@ -135545,8 +135687,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135545
135687
  }
135546
135688
  const layoutPaths = [];
135547
135689
  if (relsFile) {
135548
- const relsXml = await relsFile.async("string");
135549
- const relsData = this.parser.parse(relsXml);
135690
+ const relsData = await this.readPartXml(relsPath2);
135550
135691
  const rels = this.ensureArray(
135551
135692
  xmlChild(relsData, "Relationships")?.["Relationship"]
135552
135693
  );
@@ -135590,7 +135731,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135590
135731
  return void 0;
135591
135732
  }
135592
135733
  const path3 = files[0].name;
135593
- const xml = await files[0].async("string");
135734
+ const xml = await this.readPartText(path3) ?? "";
135594
135735
  const data = this.parser.parse(xml);
135595
135736
  const master = data?.["p:handoutMaster"];
135596
135737
  if (!master) {
@@ -135622,7 +135763,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135622
135763
  return void 0;
135623
135764
  }
135624
135765
  const path3 = files[0].name;
135625
- const xml = await files[0].async("string");
135766
+ const xml = await this.readPartText(path3) ?? "";
135626
135767
  const data = this.parser.parse(xml);
135627
135768
  const master = data?.["p:notesMaster"];
135628
135769
  if (!master) {
@@ -135653,7 +135794,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135653
135794
  if (!layoutFile) {
135654
135795
  return void 0;
135655
135796
  }
135656
- const xml = await layoutFile.async("string");
135797
+ const xml = await this.readPartText(layoutPath) ?? "";
135657
135798
  const data = this.parser.parse(xml);
135658
135799
  const sldLayout = data?.["p:sldLayout"];
135659
135800
  if (!sldLayout) {
@@ -135761,18 +135902,19 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
135761
135902
  */
135762
135903
  async parsePresentationProperties() {
135763
135904
  try {
135764
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
135765
- if (!relsXml) {
135905
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
135906
+ if (!relsData) {
135766
135907
  return void 0;
135767
135908
  }
135768
- const relsData = this.parser.parse(relsXml);
135769
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
135909
+ const rels = this.ensureArray(
135910
+ relsData.Relationships?.Relationship
135911
+ );
135770
135912
  const prRel = rels.find(
135771
135913
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
135772
135914
  );
135773
135915
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
135774
135916
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
135775
- const prXmlStr = await this.zip.file(prPath)?.async("string");
135917
+ const prXmlStr = await this.readPartText(prPath);
135776
135918
  if (!prXmlStr) {
135777
135919
  return void 0;
135778
135920
  }
@@ -135818,7 +135960,7 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
135818
135960
  */
135819
135961
  async parseViewProperties() {
135820
135962
  try {
135821
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
135963
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
135822
135964
  if (!viewPropsXml2) {
135823
135965
  return void 0;
135824
135966
  }
@@ -140320,7 +140462,7 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
140320
140462
  if (existingRel?.target) {
140321
140463
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
140322
140464
  try {
140323
- const xml = await this.zip.file(drawingPath)?.async("string");
140465
+ const xml = await this.readPartText(drawingPath);
140324
140466
  if (xml) {
140325
140467
  const root = this.parser.parse(xml);
140326
140468
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -140371,11 +140513,10 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
140371
140513
  const slash = chartPartPath.lastIndexOf("/");
140372
140514
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
140373
140515
  try {
140374
- const xml = await this.zip.file(relsPath2)?.async("string");
140375
- if (!xml) {
140516
+ const tree = await this.readPartXml(relsPath2);
140517
+ if (!tree) {
140376
140518
  return void 0;
140377
140519
  }
140378
- const tree = this.parser.parse(xml);
140379
140520
  const root = tree["Relationships"];
140380
140521
  const rels = root?.["Relationship"];
140381
140522
  const list3 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -156226,7 +156367,7 @@ var init_PptxHandlerRuntimeSlideParsing = __esm({
156226
156367
  this.unwrapAlternateContent(spTree);
156227
156368
  let rawXmlStr;
156228
156369
  try {
156229
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
156370
+ rawXmlStr = await this.readPartText(slidePath);
156230
156371
  } catch {
156231
156372
  }
156232
156373
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -156795,7 +156936,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
156795
156936
  if (cached) {
156796
156937
  return cached;
156797
156938
  }
156798
- const xml = await this.zip.file(layoutPath)?.async("string");
156939
+ const xml = await this.readPartText(layoutPath);
156799
156940
  if (!xml) {
156800
156941
  return void 0;
156801
156942
  }
@@ -156809,7 +156950,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
156809
156950
  if (cached) {
156810
156951
  return cached;
156811
156952
  }
156812
- const xml = await this.zip.file(masterPath)?.async("string");
156953
+ const xml = await this.readPartText(masterPath);
156813
156954
  if (!xml) {
156814
156955
  return void 0;
156815
156956
  }
@@ -157269,7 +157410,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
157269
157410
  if (!notesPath) {
157270
157411
  return {};
157271
157412
  }
157272
- const notesXml = await this.zip.file(notesPath)?.async("string");
157413
+ const notesXml = await this.readPartText(notesPath);
157273
157414
  if (!notesXml) {
157274
157415
  return {};
157275
157416
  }
@@ -157768,7 +157909,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
157768
157909
  try {
157769
157910
  let masterXmlObj = this.masterXmlMap.get(master.path);
157770
157911
  if (!masterXmlObj) {
157771
- const xmlStr = await this.zip.file(master.path)?.async("string");
157912
+ const xmlStr = await this.readPartText(master.path);
157772
157913
  if (!xmlStr) {
157773
157914
  continue;
157774
157915
  }
@@ -157841,7 +157982,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
157841
157982
  }
157842
157983
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
157843
157984
  try {
157844
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
157985
+ const masterXmlStr = await this.readPartText(masterPath);
157845
157986
  if (!masterXmlStr) {
157846
157987
  return [];
157847
157988
  }
@@ -158003,7 +158144,7 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
158003
158144
  }
158004
158145
  const partPath = part.path;
158005
158146
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
158006
- const xml = await this.zip.file(partPath)?.async("string");
158147
+ const xml = await this.readPartText(partPath);
158007
158148
  if (!xml) {
158008
158149
  return;
158009
158150
  }
@@ -158163,7 +158304,7 @@ var init_PptxHandlerRuntimeLayoutElements = __esm({
158163
158304
  }
158164
158305
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
158165
158306
  try {
158166
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
158307
+ const layoutXmlStr = await this.readPartText(layoutPath);
158167
158308
  if (!layoutXmlStr) {
158168
158309
  return [];
158169
158310
  }
@@ -158897,7 +159038,7 @@ var init_PptxHandlerRuntimeThemeOverrides = __esm({
158897
159038
  return cached;
158898
159039
  }
158899
159040
  try {
158900
- const overrideXml = await this.zip.file(overridePath)?.async("string");
159041
+ const overrideXml = await this.readPartText(overridePath);
158901
159042
  if (!overrideXml) {
158902
159043
  return null;
158903
159044
  }
@@ -159526,10 +159667,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159526
159667
  if (!relsXml) {
159527
159668
  return void 0;
159528
159669
  }
159529
- const relsData = this.parser.parse(
159530
- // eslint-disable-next-line no-await-in-loop
159531
- await relsXml.async("string")
159532
- );
159670
+ const relsData = await this.readPartXml(relsPath2);
159533
159671
  const relNodes = this.ensureArray(
159534
159672
  relsData?.Relationships?.Relationship
159535
159673
  );
@@ -159555,7 +159693,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159555
159693
  const options = [];
159556
159694
  for (const file of themeFiles) {
159557
159695
  try {
159558
- const xml = await file.async("string");
159696
+ const xml = await this.readPartText(file.name) ?? "";
159559
159697
  const data = this.parser.parse(xml);
159560
159698
  const root = data["a:theme"];
159561
159699
  const name = String(root?.["@_name"] || "").trim();
@@ -159635,7 +159773,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159635
159773
  ];
159636
159774
  for (const file of masterFiles) {
159637
159775
  try {
159638
- const masterXml = await file.async("string");
159776
+ const masterXml = await this.readPartText(file.name) ?? "";
159639
159777
  const masterData = this.parser.parse(masterXml);
159640
159778
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
159641
159779
  if (!clrMap) {
@@ -159668,7 +159806,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159668
159806
  if (!themeFile) {
159669
159807
  return null;
159670
159808
  }
159671
- const themeXml3 = await themeFile.async("string");
159809
+ const themeXml3 = await this.readPartText(themePath) ?? "";
159672
159810
  const model = this.parseThemePartXml(themeXml3);
159673
159811
  this.cacheThemePartModel(themePath, themeXml3, model);
159674
159812
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -159703,7 +159841,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159703
159841
  if (!relsXml) {
159704
159842
  return void 0;
159705
159843
  }
159706
- const relsData = this.parser.parse(await relsXml.async("string"));
159844
+ const relsData = await this.readPartXml(relsPath2);
159707
159845
  const relNodes = this.ensureArray(
159708
159846
  relsData?.Relationships?.Relationship
159709
159847
  );
@@ -160032,11 +160170,10 @@ var init_PptxHandlerRuntimeComments = __esm({
160032
160170
  async extractModernSlideComments(slidePath) {
160033
160171
  try {
160034
160172
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
160035
- const relsXml = await this.zip.file(relsPath2)?.async("string");
160036
- if (!relsXml) {
160173
+ const relsData = await this.readPartXml(relsPath2);
160174
+ if (!relsData) {
160037
160175
  return [];
160038
160176
  }
160039
- const relsData = this.parser.parse(relsXml);
160040
160177
  const rels = this.ensureArray(
160041
160178
  xmlChild(relsData, "Relationships")?.Relationship
160042
160179
  );
@@ -160053,7 +160190,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160053
160190
  continue;
160054
160191
  }
160055
160192
  const filePath = this.resolvePath(slidePath, target);
160056
- const xml = await this.zip.file(filePath)?.async("string");
160193
+ const xml = await this.readPartText(filePath);
160057
160194
  if (!xml) {
160058
160195
  continue;
160059
160196
  }
@@ -160076,11 +160213,10 @@ var init_PptxHandlerRuntimeComments = __esm({
160076
160213
  return [];
160077
160214
  }
160078
160215
  async loadModernCommentAuthors() {
160079
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
160080
- if (!relsXml) {
160216
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
160217
+ if (!relsData) {
160081
160218
  return;
160082
160219
  }
160083
- const relsData = this.parser.parse(relsXml);
160084
160220
  const relationships3 = this.ensureArray(
160085
160221
  xmlChild(relsData, "Relationships")?.Relationship
160086
160222
  );
@@ -160092,7 +160228,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160092
160228
  return;
160093
160229
  }
160094
160230
  const partPath = this.resolvePath("ppt/presentation.xml", target);
160095
- const xml = await this.zip.file(partPath)?.async("string");
160231
+ const xml = await this.readPartText(partPath);
160096
160232
  if (!xml) {
160097
160233
  return;
160098
160234
  }
@@ -160118,12 +160254,12 @@ var init_PptxHandlerRuntimeComments = __esm({
160118
160254
  }
160119
160255
  }
160120
160256
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
160121
- const relsXml = await this.zip.file(relsPath2)?.async("string");
160257
+ const relsXml = await this.readPartText(relsPath2);
160122
160258
  if (!relsXml) {
160123
160259
  return void 0;
160124
160260
  }
160125
160261
  try {
160126
- const relsData = this.parser.parse(relsXml);
160262
+ const relsData = await this.readPartXml(relsPath2);
160127
160263
  const rels = this.ensureArray(
160128
160264
  xmlChild(relsData, "Relationships")?.Relationship
160129
160265
  );
@@ -160162,7 +160298,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160162
160298
  return [];
160163
160299
  }
160164
160300
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
160165
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
160301
+ const commentsXml = await this.readPartText(commentsPath);
160166
160302
  if (!commentsXml) {
160167
160303
  return [];
160168
160304
  }
@@ -160197,7 +160333,7 @@ var init_PptxHandlerRuntimeComments = __esm({
160197
160333
  }
160198
160334
  }
160199
160335
  async loadCommentAuthors() {
160200
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
160336
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
160201
160337
  if (!commentAuthorsXml) {
160202
160338
  return;
160203
160339
  }
@@ -160269,7 +160405,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
160269
160405
  return void 0;
160270
160406
  }
160271
160407
  const partPath = this.resolveImagePath(slidePath, target);
160272
- const xmlString = await this.zip.file(partPath)?.async("string");
160408
+ const xmlString = await this.readPartText(partPath);
160273
160409
  if (!xmlString) {
160274
160410
  return void 0;
160275
160411
  }
@@ -161984,9 +162120,8 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
161984
162120
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
161985
162121
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
161986
162122
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
161987
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
161988
- if (chartRelsXml) {
161989
- const chartRelsData = this.parser.parse(chartRelsXml);
162123
+ const chartRelsData = await this.readPartXml(chartRelsPath);
162124
+ if (chartRelsData) {
161990
162125
  const relsContainer = chartRelsData?.Relationships;
161991
162126
  if (relsContainer?.Relationship) {
161992
162127
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -162068,7 +162203,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
162068
162203
  if (drawingPath.length === 0) {
162069
162204
  return void 0;
162070
162205
  }
162071
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
162206
+ const drawingXml = await this.readPartText(drawingPath);
162072
162207
  if (!drawingXml) {
162073
162208
  return void 0;
162074
162209
  }
@@ -162089,11 +162224,10 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
162089
162224
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
162090
162225
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
162091
162226
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
162092
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
162093
- if (!chartRelsXml) {
162227
+ const chartRelsData = await this.readPartXml(chartRelsPath);
162228
+ if (!chartRelsData) {
162094
162229
  return [];
162095
162230
  }
162096
- const chartRelsData = this.parser.parse(chartRelsXml);
162097
162231
  const relsContainer = chartRelsData?.Relationships;
162098
162232
  if (!relsContainer?.Relationship) {
162099
162233
  return [];
@@ -162985,11 +163119,10 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
162985
163119
  async loadPresentationFontRels() {
162986
163120
  const map = /* @__PURE__ */ new Map();
162987
163121
  try {
162988
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
162989
- if (!relsXml) {
163122
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
163123
+ if (!relsData) {
162990
163124
  return map;
162991
163125
  }
162992
- const relsData = this.parser.parse(relsXml);
162993
163126
  const rels = this.ensureArray(
162994
163127
  xmlChild(relsData, "Relationships")?.Relationship
162995
163128
  );
@@ -163310,13 +163443,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163310
163443
  if (!file) {
163311
163444
  continue;
163312
163445
  }
163313
- const data = await file.async("string");
163446
+ const data = await this.readPartText(entry2) ?? "";
163314
163447
  const propsPath = `customXml/itemProps${itemId}.xml`;
163315
163448
  const propsFile = this.zip.file(propsPath);
163316
163449
  let properties;
163317
163450
  let schemaUri;
163318
163451
  if (propsFile) {
163319
- properties = await propsFile.async("string");
163452
+ properties = await this.readPartText(propsPath) ?? "";
163320
163453
  try {
163321
163454
  const propsData = this.parser.parse(properties);
163322
163455
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -163336,14 +163469,14 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163336
163469
  const relsFile = this.zip.file(relsPath2);
163337
163470
  let rels;
163338
163471
  if (relsFile) {
163339
- rels = await relsFile.async("string");
163472
+ rels = await this.readPartText(relsPath2);
163340
163473
  }
163341
163474
  parts.push({ id: itemId, data, schemaUri, properties, rels });
163342
163475
  }
163343
163476
  this.customXmlParts = parts;
163344
163477
  }
163345
163478
  async loadPresentationState() {
163346
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
163479
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
163347
163480
  if (!presentationXml3) {
163348
163481
  throw new Error("Invalid PPTX: presentation.xml not found");
163349
163482
  }
@@ -163695,6 +163828,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163695
163828
  * or resolve images. Create a new `PptxHandler` instance instead.
163696
163829
  */
163697
163830
  dispose() {
163831
+ this.endPartReads();
163698
163832
  this.revokeBlobUrls();
163699
163833
  this.imageDataCache.clear();
163700
163834
  this.slideMap.clear();
@@ -163728,18 +163862,24 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163728
163862
  this.zip = null;
163729
163863
  }
163730
163864
  async load(data, options = {}) {
163731
- await this.initializeLoadSession(data, options);
163732
- await this.detectAndPreserveVbaProject();
163733
- this.detectDigitalSignatureParts();
163734
- await this.parseCustomXmlParts();
163735
- const presentationState = await this.loadPresentationState();
163736
- const slideMasters = await this.parseSlideMasters();
163737
- await this.enrichSlideMastersWithTxStyles(slideMasters);
163738
- const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
163739
- const slidesWithWarnings = this.attachSlideWarnings(slides);
163740
- this.resetElementIdCounter(slides);
163741
- recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
163742
- return this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
163865
+ let reader2;
163866
+ try {
163867
+ await this.initializeLoadSession(data, options);
163868
+ reader2 = this.beginPartReads();
163869
+ await this.detectAndPreserveVbaProject();
163870
+ this.detectDigitalSignatureParts();
163871
+ await this.parseCustomXmlParts();
163872
+ const presentationState = await this.loadPresentationState();
163873
+ const slideMasters = await this.parseSlideMasters();
163874
+ await this.enrichSlideMastersWithTxStyles(slideMasters);
163875
+ const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
163876
+ const slidesWithWarnings = this.attachSlideWarnings(slides);
163877
+ this.resetElementIdCounter(slides);
163878
+ recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
163879
+ return await this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
163880
+ } finally {
163881
+ this.endPartReads(reader2);
163882
+ }
163743
163883
  }
163744
163884
  /**
163745
163885
  * Retrieve the current background colour for a layout or master.
@@ -163878,7 +164018,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163878
164018
  options.push(this.buildLayoutOption(lp, xmlObj));
163879
164019
  } else {
163880
164020
  try {
163881
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
164021
+ const layoutXmlStr = await this.readPartText(lp);
163882
164022
  if (layoutXmlStr) {
163883
164023
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
163884
164024
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -163921,7 +164061,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163921
164061
  }
163922
164062
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
163923
164063
  if (!layoutXml3) {
163924
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
164064
+ const layoutXmlStr = await this.readPartText(layoutPath);
163925
164065
  if (!layoutXmlStr) {
163926
164066
  throw new Error(`Layout not found: ${layoutPath}`);
163927
164067
  }
@@ -187764,6 +187904,7 @@ exports.readOleSheetGrid = readOleSheetGrid;
187764
187904
  exports.readOleXlsGrid = readOleXlsGrid;
187765
187905
  exports.reapplyAlternateContentToTree = reapplyAlternateContentToTree;
187766
187906
  exports.reassignDescendantIds = reassignDescendantIds;
187907
+ exports.rebaseCommentMentions = rebaseCommentMentions;
187767
187908
  exports.rebuildTableStructureInRawXml = rebuildTableStructureInRawXml;
187768
187909
  exports.reconcileAnimationTargets = reconcileAnimationTargets;
187769
187910
  exports.rectNode = rectNode;