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
@@ -59619,6 +59619,272 @@ var init_chart_data_sheet = __esm({
59619
59619
  }
59620
59620
  });
59621
59621
 
59622
+ // pptx/core/utils/modern-comment-mention-read.ts
59623
+ function readCommentMentions(node2, authorName) {
59624
+ if (!node2) {
59625
+ return void 0;
59626
+ }
59627
+ const found = [];
59628
+ for (const list3 of mentionChildrenNamed(node2, "mentionLst")) {
59629
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
59630
+ const mention = readMention(entry2, authorName);
59631
+ if (mention) {
59632
+ found.push(mention);
59633
+ }
59634
+ }
59635
+ }
59636
+ for (const extension of mentionChildrenNamed(mentionChildrenNamed(node2, "extLst")[0], "ext")) {
59637
+ const uri = String(extension["@_uri"] || "");
59638
+ for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
59639
+ for (const entry2 of mentionChildrenNamed(list3, "mention")) {
59640
+ const mention = readMention(entry2, authorName, uri);
59641
+ if (mention) {
59642
+ found.push(mention);
59643
+ }
59644
+ }
59645
+ }
59646
+ }
59647
+ found.sort((a, b) => a.startIndex - b.startIndex);
59648
+ return found.length > 0 ? found : void 0;
59649
+ }
59650
+ var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute5, integer2, readMention;
59651
+ var init_modern_comment_mention_read = __esm({
59652
+ "pptx/core/utils/modern-comment-mention-read.ts"() {
59653
+ mentionLocalName = (key2) => key2.split(":").pop() || key2;
59654
+ mentionNodesOf = (value) => {
59655
+ if (Array.isArray(value)) {
59656
+ return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
59657
+ }
59658
+ return value && typeof value === "object" ? [value] : [];
59659
+ };
59660
+ mentionChildrenNamed = (node2, name) => {
59661
+ if (!node2) {
59662
+ return [];
59663
+ }
59664
+ const result = [];
59665
+ for (const [key2, value] of Object.entries(node2)) {
59666
+ if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
59667
+ result.push(...mentionNodesOf(value));
59668
+ }
59669
+ }
59670
+ return result;
59671
+ };
59672
+ MENTION_PERSON_KEYS = [
59673
+ "@_mentionpersonId",
59674
+ "@_mentionPersonId",
59675
+ "@_personId",
59676
+ "@_authorId"
59677
+ ];
59678
+ MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
59679
+ attribute5 = (node2, keys) => {
59680
+ for (const key2 of keys) {
59681
+ const value = node2[key2];
59682
+ if (value !== void 0 && value !== null && String(value).length > 0) {
59683
+ return String(value);
59684
+ }
59685
+ }
59686
+ return void 0;
59687
+ };
59688
+ integer2 = (value) => {
59689
+ if (value === void 0) {
59690
+ return void 0;
59691
+ }
59692
+ const parsed = Number.parseInt(value, 10);
59693
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
59694
+ };
59695
+ readMention = (node2, authorName, containerUri) => {
59696
+ const personId = attribute5(node2, MENTION_PERSON_KEYS);
59697
+ const startIndex = integer2(attribute5(node2, ["@_startIndex"]));
59698
+ const length = integer2(attribute5(node2, MENTION_LENGTH_KEYS));
59699
+ if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
59700
+ return void 0;
59701
+ }
59702
+ return {
59703
+ personId,
59704
+ startIndex,
59705
+ length,
59706
+ id: attribute5(node2, ["@_mentionId", "@_id"]),
59707
+ authorName: authorName(personId),
59708
+ containerUri,
59709
+ rawXml: node2
59710
+ };
59711
+ };
59712
+ }
59713
+ });
59714
+
59715
+ // pptx/core/utils/modern-comment-mentions.ts
59716
+ function rebaseCommentMentions(mentions, oldText, newText, loaded) {
59717
+ if (!mentions || mentions.length === 0) {
59718
+ return void 0;
59719
+ }
59720
+ if (oldText === newText) {
59721
+ return mentions;
59722
+ }
59723
+ const prefix = commonPrefixLength(oldText, newText);
59724
+ const suffix = commonSuffixLength(
59725
+ oldText,
59726
+ newText,
59727
+ Math.min(oldText.length, newText.length) - prefix
59728
+ );
59729
+ const changeEnd = oldText.length - suffix;
59730
+ const delta2 = newText.length - oldText.length;
59731
+ const result = [];
59732
+ for (const mention of mentions) {
59733
+ const start = mention.startIndex;
59734
+ const end = start + mention.length;
59735
+ const coverage = loaded ? loadedCoverage(mention, loaded, oldText) : [];
59736
+ if (coverage === void 0 || coverage.includes(newText.slice(start, end))) {
59737
+ if (start >= 0 && mention.length > 0 && end <= newText.length) {
59738
+ result.push(mention);
59739
+ }
59740
+ continue;
59741
+ }
59742
+ const span = oldText.slice(start, end);
59743
+ if (span.length !== mention.length) {
59744
+ continue;
59745
+ }
59746
+ let next = -1;
59747
+ if (end <= prefix) {
59748
+ next = start;
59749
+ } else if (start >= changeEnd) {
59750
+ next = start + delta2;
59751
+ }
59752
+ if (next >= 0 && newText.slice(next, next + mention.length) === span) {
59753
+ result.push(next === start ? mention : { ...mention, startIndex: next });
59754
+ continue;
59755
+ }
59756
+ const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
59757
+ if (relocated >= 0) {
59758
+ result.push({ ...mention, startIndex: relocated });
59759
+ }
59760
+ }
59761
+ return result.length > 0 ? result : void 0;
59762
+ }
59763
+ function buildMentionListNode(mentions) {
59764
+ if (!mentions || mentions.length === 0) {
59765
+ return void 0;
59766
+ }
59767
+ return { "p188:mention": mentions.map(buildMention) };
59768
+ }
59769
+ function applyCommentMentions(node2, mentions, extension, replace) {
59770
+ if (!replace) {
59771
+ return extension;
59772
+ }
59773
+ const { direct, byUri } = groupByContainer(mentions);
59774
+ const directList = buildMentionListNode(direct);
59775
+ if (directList) {
59776
+ node2["p188:mentionLst"] = directList;
59777
+ }
59778
+ if (!extension) {
59779
+ return void 0;
59780
+ }
59781
+ const rebuilt = stripMentionLists(extension);
59782
+ const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
59783
+ const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
59784
+ const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
59785
+ const next = stripMentionLists(entry2);
59786
+ if (list3) {
59787
+ next["p188:mentionLst"] = list3;
59788
+ }
59789
+ return next;
59790
+ });
59791
+ if (entries.length > 0) {
59792
+ rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
59793
+ }
59794
+ return rebuilt;
59795
+ }
59796
+ var commonPrefixLength, commonSuffixLength, nearestOccurrence, loadedCoverage, buildMention, stripMentionLists, groupByContainer;
59797
+ var init_modern_comment_mentions = __esm({
59798
+ "pptx/core/utils/modern-comment-mentions.ts"() {
59799
+ init_modern_comment_mention_read();
59800
+ init_modern_comment_mention_read();
59801
+ commonPrefixLength = (a, b) => {
59802
+ const max = Math.min(a.length, b.length);
59803
+ let index2 = 0;
59804
+ while (index2 < max && a[index2] === b[index2]) {
59805
+ index2 += 1;
59806
+ }
59807
+ return index2;
59808
+ };
59809
+ commonSuffixLength = (a, b, limit) => {
59810
+ let index2 = 0;
59811
+ while (index2 < limit && a[a.length - 1 - index2] === b[b.length - 1 - index2]) {
59812
+ index2 += 1;
59813
+ }
59814
+ return index2;
59815
+ };
59816
+ nearestOccurrence = (text2, span, hint) => {
59817
+ let best = -1;
59818
+ let bestDistance = Number.POSITIVE_INFINITY;
59819
+ let at2 = text2.indexOf(span);
59820
+ while (at2 !== -1) {
59821
+ const distance = Math.abs(at2 - hint);
59822
+ if (distance < bestDistance) {
59823
+ best = at2;
59824
+ bestDistance = distance;
59825
+ }
59826
+ at2 = text2.indexOf(span, at2 + 1);
59827
+ }
59828
+ return best;
59829
+ };
59830
+ loadedCoverage = (mention, loaded, oldText) => {
59831
+ const records = loaded.filter(
59832
+ (record3) => mention.id ? record3.id === mention.id : !record3.id && record3.personId === mention.personId && record3.length === mention.length
59833
+ );
59834
+ if (records.length === 0) {
59835
+ return void 0;
59836
+ }
59837
+ return records.map(
59838
+ (record3) => oldText.slice(record3.startIndex, record3.startIndex + record3.length)
59839
+ );
59840
+ };
59841
+ buildMention = (mention) => {
59842
+ const node2 = {};
59843
+ for (const [key2, value] of Object.entries(mention.rawXml || {})) {
59844
+ if (key2.startsWith("@_")) {
59845
+ node2[key2] = value;
59846
+ }
59847
+ }
59848
+ const personKey = MENTION_PERSON_KEYS.find((key2) => node2[key2] !== void 0) || "@_mentionpersonId";
59849
+ const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node2[key2] !== void 0) || "@_length";
59850
+ node2[personKey] = mention.personId;
59851
+ node2[lengthKey] = String(mention.length);
59852
+ node2["@_startIndex"] = String(mention.startIndex);
59853
+ if (mention.id) {
59854
+ const idKey = node2["@_id"] !== void 0 && node2["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
59855
+ node2[idKey] = mention.id;
59856
+ }
59857
+ return node2;
59858
+ };
59859
+ stripMentionLists = (node2) => {
59860
+ const result = {};
59861
+ for (const [key2, value] of Object.entries(node2)) {
59862
+ if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
59863
+ result[key2] = value;
59864
+ }
59865
+ }
59866
+ return result;
59867
+ };
59868
+ groupByContainer = (mentions) => {
59869
+ const direct = [];
59870
+ const byUri = /* @__PURE__ */ new Map();
59871
+ for (const mention of mentions || []) {
59872
+ if (!mention.containerUri) {
59873
+ direct.push(mention);
59874
+ continue;
59875
+ }
59876
+ const bucket = byUri.get(mention.containerUri);
59877
+ if (bucket) {
59878
+ bucket.push(mention);
59879
+ } else {
59880
+ byUri.set(mention.containerUri, [mention]);
59881
+ }
59882
+ }
59883
+ return { direct, byUri };
59884
+ };
59885
+ }
59886
+ });
59887
+
59622
59888
  // pptx/core/utils/index.ts
59623
59889
  var init_utils = __esm({
59624
59890
  "pptx/core/utils/index.ts"() {
@@ -64097,7 +64363,7 @@ var init_effect_style_extractor_fill_overlay = __esm({
64097
64363
  });
64098
64364
 
64099
64365
  // pptx/core/core/builders/effect-style-extractor-reflection.ts
64100
- function integer2(value) {
64366
+ function integer3(value) {
64101
64367
  if (value === void 0 || value === null || value === "") {
64102
64368
  return void 0;
64103
64369
  }
@@ -64114,19 +64380,19 @@ function boolean2(value) {
64114
64380
  return void 0;
64115
64381
  }
64116
64382
  function fixedFraction(value) {
64117
- const parsed = integer2(value);
64383
+ const parsed = integer3(value);
64118
64384
  return parsed !== void 0 && parsed >= 0 && parsed <= 1e5 ? parsed / 1e5 : void 0;
64119
64385
  }
64120
64386
  function extractReflectionAttributes(node2, emuPerPx) {
64121
- const blur = integer2(node2["@_blurRad"]);
64122
- const distance = integer2(node2["@_dist"]);
64123
- const startOpacity = integer2(node2["@_stA"]);
64124
- const endOpacity = integer2(node2["@_endA"]);
64125
- const startPosition = integer2(node2["@_stPos"]);
64126
- const endPosition = integer2(node2["@_endPos"]);
64127
- const direction = integer2(node2["@_dir"]);
64128
- const rotation = integer2(node2["@_rot"]);
64129
- const fadeDirection = integer2(node2["@_fadeDir"]);
64387
+ const blur = integer3(node2["@_blurRad"]);
64388
+ const distance = integer3(node2["@_dist"]);
64389
+ const startOpacity = integer3(node2["@_stA"]);
64390
+ const endOpacity = integer3(node2["@_endA"]);
64391
+ const startPosition = integer3(node2["@_stPos"]);
64392
+ const endPosition = integer3(node2["@_endPos"]);
64393
+ const direction = integer3(node2["@_dir"]);
64394
+ const rotation = integer3(node2["@_rot"]);
64395
+ const fadeDirection = integer3(node2["@_fadeDir"]);
64130
64396
  const alignment = String(node2["@_algn"] ?? "").trim();
64131
64397
  return {
64132
64398
  reflectionBlurRadius: blur !== void 0 && blur >= 0 ? blur / emuPerPx : void 0,
@@ -64138,10 +64404,10 @@ function extractReflectionAttributes(node2, emuPerPx) {
64138
64404
  reflectionRotation: rotation !== void 0 ? rotation / 6e4 : void 0,
64139
64405
  reflectionDistance: distance !== void 0 && distance >= 0 ? distance / emuPerPx : void 0,
64140
64406
  reflectionFadeDirection: fadeDirection !== void 0 ? fadeDirection / 6e4 : void 0,
64141
- reflectionScaleX: integer2(node2["@_sx"]),
64142
- reflectionScaleY: integer2(node2["@_sy"]),
64143
- reflectionSkewX: integer2(node2["@_kx"]),
64144
- reflectionSkewY: integer2(node2["@_ky"]),
64407
+ reflectionScaleX: integer3(node2["@_sx"]),
64408
+ reflectionScaleY: integer3(node2["@_sy"]),
64409
+ reflectionSkewX: integer3(node2["@_kx"]),
64410
+ reflectionSkewY: integer3(node2["@_ky"]),
64145
64411
  reflectionAlignment: VALID_ALIGNMENTS.has(alignment) ? alignment : void 0,
64146
64412
  reflectionRotateWithShape: boolean2(node2["@_rotWithShape"])
64147
64413
  };
@@ -70326,6 +70592,96 @@ var init_background_fill_shapes = __esm({
70326
70592
  }
70327
70593
  });
70328
70594
 
70595
+ // pptx/core/core/runtime/load-part-reader.ts
70596
+ function parseText2(parser, text2) {
70597
+ return text2 ? parser.parse(text2) : void 0;
70598
+ }
70599
+ function readPartText(zip, path4) {
70600
+ const reader2 = openReaders.get(zip);
70601
+ if (reader2) {
70602
+ return reader2.readText(path4);
70603
+ }
70604
+ return zip.file(path4)?.async("string") ?? Promise.resolve(void 0);
70605
+ }
70606
+ async function readPartXml(zip, parser, path4) {
70607
+ const reader2 = openReaders.get(zip);
70608
+ if (reader2) {
70609
+ return reader2.readXml(parser, path4);
70610
+ }
70611
+ const text2 = await zip.file(path4)?.async("string");
70612
+ return text2 ? parseText2(parser, text2) : void 0;
70613
+ }
70614
+ var openReaders, LoadPartReader;
70615
+ var init_load_part_reader = __esm({
70616
+ "pptx/core/core/runtime/load-part-reader.ts"() {
70617
+ openReaders = /* @__PURE__ */ new WeakMap();
70618
+ LoadPartReader = class {
70619
+ constructor(zip) {
70620
+ this.zip = zip;
70621
+ openReaders.set(zip, this);
70622
+ }
70623
+ zip;
70624
+ parts = /* @__PURE__ */ new Map();
70625
+ closed = false;
70626
+ entry(path4) {
70627
+ const file2 = this.zip.file(path4);
70628
+ if (!file2) {
70629
+ this.parts.delete(path4);
70630
+ return void 0;
70631
+ }
70632
+ const previous = this.parts.get(path4);
70633
+ if (previous?.file === file2) {
70634
+ return previous;
70635
+ }
70636
+ const entry2 = { file: file2, text: file2.async("string"), relationships: /* @__PURE__ */ new Map() };
70637
+ this.parts.set(path4, entry2);
70638
+ entry2.text.catch(() => {
70639
+ if (this.parts.get(path4) === entry2) {
70640
+ this.parts.delete(path4);
70641
+ }
70642
+ });
70643
+ return entry2;
70644
+ }
70645
+ readText(path4) {
70646
+ return this.entry(path4)?.text ?? Promise.resolve(void 0);
70647
+ }
70648
+ async readXml(parser, path4) {
70649
+ const entry2 = this.entry(path4);
70650
+ if (!entry2) {
70651
+ return void 0;
70652
+ }
70653
+ if (!path4.endsWith(".rels")) {
70654
+ return parseText2(parser, await entry2.text);
70655
+ }
70656
+ let parsed = entry2.relationships.get(parser);
70657
+ if (!parsed) {
70658
+ const pending = entry2.text.then((text2) => parseText2(parser, text2));
70659
+ entry2.relationships.set(parser, pending);
70660
+ pending.catch(() => {
70661
+ if (entry2.relationships.get(parser) === pending) {
70662
+ entry2.relationships.delete(parser);
70663
+ }
70664
+ });
70665
+ parsed = pending;
70666
+ }
70667
+ return structuredClone(await parsed);
70668
+ }
70669
+ /** Whether this reader still serves reads for its package. */
70670
+ get isOpen() {
70671
+ return !this.closed;
70672
+ }
70673
+ /** Drops every cached read; later reads of the package go to the archive. */
70674
+ close() {
70675
+ this.closed = true;
70676
+ if (openReaders.get(this.zip) === this) {
70677
+ openReaders.delete(this.zip);
70678
+ }
70679
+ this.parts.clear();
70680
+ }
70681
+ };
70682
+ }
70683
+ });
70684
+
70329
70685
  // pptx/core/core/builders/element-hidden-flag.ts
70330
70686
  function findCNvPr(shape) {
70331
70687
  if (!shape) {
@@ -70399,11 +70755,10 @@ var init_flatten_elements = __esm({
70399
70755
 
70400
70756
  // pptx/core/utils/slide-synchronization.ts
70401
70757
  async function loadSlideSynchronization(input2) {
70402
- const relsXml = await input2.zip.file(input2.relsPath)?.async("string");
70403
- if (!relsXml) {
70758
+ const relsData = await readPartXml(input2.zip, input2.parser, input2.relsPath);
70759
+ if (!relsData) {
70404
70760
  return void 0;
70405
70761
  }
70406
- const relsData = input2.parser.parse(relsXml);
70407
70762
  const relationship2 = findSlideSyncRelationship(relsData);
70408
70763
  if (!relationship2) {
70409
70764
  return void 0;
@@ -70413,7 +70768,7 @@ async function loadSlideSynchronization(input2) {
70413
70768
  return void 0;
70414
70769
  }
70415
70770
  const partPath = resolvePartPath2(input2.slidePath, target);
70416
- const partXml = await input2.zip.file(partPath)?.async("string");
70771
+ const partXml = await readPartText(input2.zip, partPath);
70417
70772
  if (!partXml) {
70418
70773
  return void 0;
70419
70774
  }
@@ -70534,6 +70889,7 @@ function nextSlideSyncPath(files) {
70534
70889
  var SLIDE_SYNC_CONTENT_TYPE;
70535
70890
  var init_slide_synchronization = __esm({
70536
70891
  "pptx/core/utils/slide-synchronization.ts"() {
70892
+ init_load_part_reader();
70537
70893
  SLIDE_SYNC_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideSyncData+xml";
70538
70894
  }
70539
70895
  });
@@ -70547,11 +70903,10 @@ function ensureArray9(value) {
70547
70903
  }
70548
70904
  async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
70549
70905
  try {
70550
- const relsXml = await zip.file(relsPath2)?.async("string");
70551
- if (!relsXml) {
70906
+ const relsData = await readPartXml(zip, parser, relsPath2);
70907
+ if (!relsData) {
70552
70908
  return [];
70553
70909
  }
70554
- const relsData = parser.parse(relsXml);
70555
70910
  const relationships3 = ensureArray9(
70556
70911
  relsData["Relationships"]?.["Relationship"]
70557
70912
  );
@@ -70574,7 +70929,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
70574
70929
  if (!resolved) {
70575
70930
  continue;
70576
70931
  }
70577
- const vmlXml = await zip.file(resolved)?.async("string");
70932
+ const vmlXml = await readPartText(zip, resolved);
70578
70933
  if (!vmlXml) {
70579
70934
  continue;
70580
70935
  }
@@ -70593,6 +70948,7 @@ async function loadLegacyVmlDrawings(zip, parser, slidePath, relsPath2) {
70593
70948
  var VML_DRAWING_REL_SUFFIX;
70594
70949
  var init_vml_drawing_loader = __esm({
70595
70950
  "pptx/core/utils/vml-drawing-loader.ts"() {
70951
+ init_load_part_reader();
70596
70952
  init_safe_path();
70597
70953
  init_vml_parser();
70598
70954
  VML_DRAWING_REL_SUFFIX = "/relationships/vmlDrawing";
@@ -73100,6 +73456,7 @@ var PptxSlideLoaderService;
73100
73456
  var init_PptxSlideLoaderService = __esm({
73101
73457
  "pptx/core/services/PptxSlideLoaderService.ts"() {
73102
73458
  init_background_fill_shapes();
73459
+ init_load_part_reader();
73103
73460
  init_element_hidden_flag();
73104
73461
  init_background_style_ref();
73105
73462
  init_flatten_elements();
@@ -73160,11 +73517,14 @@ var init_PptxSlideLoaderService = __esm({
73160
73517
  * @returns Map of relationship ID to target path string.
73161
73518
  */
73162
73519
  async loadPresentationSlideRels(params) {
73163
- const relsXml = await params.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
73164
- if (!relsXml) {
73520
+ const relsData = await readPartXml(
73521
+ params.zip,
73522
+ params.parser,
73523
+ "ppt/_rels/presentation.xml.rels"
73524
+ );
73525
+ if (!relsData) {
73165
73526
  return /* @__PURE__ */ new Map();
73166
73527
  }
73167
- const relsData = params.parser.parse(relsXml);
73168
73528
  const relationships3 = relsData["Relationships"]?.["Relationship"];
73169
73529
  const relNodes = this.toXmlObjectArray(relationships3);
73170
73530
  const relsMap = /* @__PURE__ */ new Map();
@@ -73204,7 +73564,7 @@ var init_PptxSlideLoaderService = __esm({
73204
73564
  if (!params.zip.file(path4)) {
73205
73565
  path4 = `ppt/${target}`;
73206
73566
  }
73207
- const slideXmlStr = await params.zip.file(path4)?.async("string");
73567
+ const slideXmlStr = await readPartText(params.zip, path4);
73208
73568
  if (!slideXmlStr) {
73209
73569
  return void 0;
73210
73570
  }
@@ -97393,12 +97753,11 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
97393
97753
  if (!external.targetPath || !external.embeddedWorkbookData) return false;
97394
97754
  const target = resolve(chartPartPath, external.targetPath);
97395
97755
  let references = 0;
97396
- const parser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
97397
97756
  try {
97398
97757
  for (const path4 of Object.keys(zip.files)) {
97399
97758
  if (!path4.endsWith(".rels") || !path4.includes("/_rels/")) continue;
97400
97759
  const source = path4.replace("/_rels/", "/").slice(0, -5);
97401
- const tree = parser.parse(await zip.file(path4).async("string"));
97760
+ const tree = await readPartXml(zip, relationshipParser, path4);
97402
97761
  for (const rel of xmlChildren(xmlChild(tree, "Relationships"), "Relationship")) {
97403
97762
  const relationshipTarget2 = xmlAttr(rel, "Target");
97404
97763
  if (relationshipTarget2 && xmlAttr(rel, "TargetMode") !== "External" && resolve(source, relationshipTarget2) === target)
@@ -97415,11 +97774,14 @@ async function chartLabelsHaveEditableSources(xml, zip, chartSpace, seriesNodes,
97415
97774
  return false;
97416
97775
  }
97417
97776
  }
97777
+ var relationshipParser;
97418
97778
  var init_chart_label_source = __esm({
97419
97779
  "pptx/core/utils/chart-label-source.ts"() {
97780
+ init_load_part_reader();
97420
97781
  init_chart_xlsx_writer();
97421
97782
  init_xml_access();
97422
97783
  init_chart_xlsx_cellref();
97784
+ relationshipParser = new fastXmlParser.XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
97423
97785
  }
97424
97786
  });
97425
97787
 
@@ -98207,7 +98569,7 @@ function malformed(context, element, value) {
98207
98569
  function cBool(context, parent, local) {
98208
98570
  const element = cChild(parent, local);
98209
98571
  if (!element) return void 0;
98210
- const raw2 = attribute5(element, "val");
98572
+ const raw2 = attribute6(element, "val");
98211
98573
  if (raw2 === void 0) return true;
98212
98574
  const value = raw2.trim().toLowerCase();
98213
98575
  if (value === "1" || value === "true") return true;
@@ -98217,7 +98579,7 @@ function cBool(context, parent, local) {
98217
98579
  }
98218
98580
  function cNumber(context, parent, local) {
98219
98581
  const element = cChild(parent, local);
98220
- const raw2 = attribute5(element, "val");
98582
+ const raw2 = attribute6(element, "val");
98221
98583
  if (!element || raw2 === void 0) return void 0;
98222
98584
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
98223
98585
  if (Number.isFinite(value)) return value;
@@ -98226,7 +98588,7 @@ function cNumber(context, parent, local) {
98226
98588
  }
98227
98589
  function cEnum(context, parent, local, allowed) {
98228
98590
  const element = cChild(parent, local);
98229
- const raw2 = attribute5(element, "val");
98591
+ const raw2 = attribute6(element, "val");
98230
98592
  if (!element || raw2 === void 0) return void 0;
98231
98593
  if (allowed.includes(raw2)) return raw2;
98232
98594
  malformed(context, element, raw2);
@@ -98283,9 +98645,9 @@ function chartLines(parent, local) {
98283
98645
  }
98284
98646
  function numberFormat(parent) {
98285
98647
  const element = cChild(parent, "numFmt");
98286
- const formatCode2 = attribute5(element, "formatCode");
98648
+ const formatCode2 = attribute6(element, "formatCode");
98287
98649
  if (formatCode2 === void 0) return void 0;
98288
- const linked = attribute5(element, "sourceLinked");
98650
+ const linked = attribute6(element, "sourceLinked");
98289
98651
  return {
98290
98652
  formatCode: formatCode2,
98291
98653
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -98309,7 +98671,7 @@ function assignDefined(target, values) {
98309
98671
  if (value !== void 0) target[key2] = value;
98310
98672
  return target;
98311
98673
  }
98312
- var cChild, attribute5, cVal, path, textProperties;
98674
+ var cChild, attribute6, cVal, path, textProperties;
98313
98675
  var init_parse_util = __esm({
98314
98676
  "chart/parse-util.ts"() {
98315
98677
  init_xml2();
@@ -98318,8 +98680,8 @@ var init_parse_util = __esm({
98318
98680
  init_manual_layout();
98319
98681
  init_xml_fragment();
98320
98682
  cChild = (parent, local) => first(parent, local, NS.c);
98321
- attribute5 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
98322
- cVal = (parent, local) => attribute5(cChild(parent, local), "val");
98683
+ attribute6 = (element, name) => element?.hasAttribute(name) ? element.getAttribute(name) ?? void 0 : void 0;
98684
+ cVal = (parent, local) => attribute6(cChild(parent, local), "val");
98323
98685
  path = (element) => `c:${element.parentNode?.localName ?? ""}/c:${element.localName}`;
98324
98686
  textProperties = (parent) => chartTextBody(cChild(parent, "txPr"));
98325
98687
  }
@@ -98331,9 +98693,9 @@ function parseCache(node2) {
98331
98693
  type: node2.localName === "numCache" || node2.localName === "numLit" ? "number" : "string",
98332
98694
  points: children2(node2, "pt", NS.c).map((pt2) => {
98333
98695
  const point2 = { value: cChild(pt2, "v")?.textContent ?? "" };
98334
- const index2 = Number(attribute5(pt2, "idx") ?? Number.NaN);
98696
+ const index2 = Number(attribute6(pt2, "idx") ?? Number.NaN);
98335
98697
  if (Number.isInteger(index2) && index2 >= 0) point2.index = index2;
98336
- const formatCode3 = attribute5(pt2, "formatCode");
98698
+ const formatCode3 = attribute6(pt2, "formatCode");
98337
98699
  if (formatCode3 !== void 0) point2.formatCode = formatCode3;
98338
98700
  return point2;
98339
98701
  })
@@ -98536,10 +98898,10 @@ function readDisplayNaAsBlank(chartExtLst) {
98536
98898
  return void 0;
98537
98899
  }
98538
98900
  for (const ext of elements(root)) {
98539
- if (ext.localName !== "ext" || attribute5(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
98901
+ if (ext.localName !== "ext" || attribute6(ext, "uri") !== DATA_DISPLAY_OPTIONS_URI) continue;
98540
98902
  const flag2 = first(first(ext, "dataDisplayOptions16", C16R3), "dispNaAsBlank", C16R3);
98541
98903
  if (!flag2) continue;
98542
- const raw2 = attribute5(flag2, "val")?.trim().toLowerCase();
98904
+ const raw2 = attribute6(flag2, "val")?.trim().toLowerCase();
98543
98905
  return raw2 === void 0 || raw2 === "1" || raw2 === "true";
98544
98906
  }
98545
98907
  return void 0;
@@ -98784,7 +99146,7 @@ function customSplit(context, element) {
98784
99146
  if (!element) return void 0;
98785
99147
  reportUnmodelled(context, element, /* @__PURE__ */ new Set(["secondPiePt"]));
98786
99148
  return children2(element, "secondPiePt", NS.c).flatMap((point2) => {
98787
- const raw2 = attribute5(point2, "val")?.trim();
99149
+ const raw2 = attribute6(point2, "val")?.trim();
98788
99150
  const index2 = raw2 ? Number(raw2) : Number.NaN;
98789
99151
  return Number.isInteger(index2) && index2 >= 0 ? [index2] : [];
98790
99152
  });
@@ -98805,7 +99167,7 @@ function parseGroup(context, element) {
98805
99167
  is3D,
98806
99168
  series: children2(element, "ser", NS.c).map((ser) => parseSeries(context, ser)),
98807
99169
  axisIds: children2(element, "axId", NS.c).flatMap((axis) => {
98808
- const raw2 = attribute5(axis, "val")?.trim();
99170
+ const raw2 = attribute6(axis, "val")?.trim();
98809
99171
  const id = raw2 ? Number(raw2) : Number.NaN;
98810
99172
  return Number.isFinite(id) ? [id] : [];
98811
99173
  })
@@ -99087,7 +99449,7 @@ function chartStyle(context, space) {
99087
99449
  }
99088
99450
  function c14Style(space) {
99089
99451
  for (const alternate of children2(space, "AlternateContent", NS.mc)) {
99090
- const raw2 = attribute5(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
99452
+ const raw2 = attribute6(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
99091
99453
  const value = raw2?.trim() ? Number(raw2) : Number.NaN;
99092
99454
  if (Number.isFinite(value)) return value;
99093
99455
  }
@@ -99776,7 +100138,7 @@ function malformed2(context, where, value) {
99776
100138
  });
99777
100139
  }
99778
100140
  function boolAttribute(context, element, name) {
99779
- const raw2 = attribute5(element, name);
100141
+ const raw2 = attribute6(element, name);
99780
100142
  if (!element || raw2 === void 0) return void 0;
99781
100143
  const value = raw2.trim().toLowerCase();
99782
100144
  if (value === "1" || value === "true") return true;
@@ -99785,7 +100147,7 @@ function boolAttribute(context, element, name) {
99785
100147
  return void 0;
99786
100148
  }
99787
100149
  function numberAttribute(context, element, name) {
99788
- const raw2 = attribute5(element, name);
100150
+ const raw2 = attribute6(element, name);
99789
100151
  if (!element || raw2 === void 0) return void 0;
99790
100152
  const value = raw2.trim() ? Number(raw2) : Number.NaN;
99791
100153
  if (Number.isFinite(value)) return value;
@@ -99795,11 +100157,11 @@ function numberAttribute(context, element, name) {
99795
100157
  function indexAttribute(context, element, name) {
99796
100158
  const value = numberAttribute(context, element, name);
99797
100159
  if (value === void 0 || Number.isInteger(value) && value >= 0) return value;
99798
- malformed2(context, path2(element, name), attribute5(element, name) ?? "");
100160
+ malformed2(context, path2(element, name), attribute6(element, name) ?? "");
99799
100161
  return void 0;
99800
100162
  }
99801
100163
  function autoNumberAttribute(context, element, name) {
99802
- return attribute5(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
100164
+ return attribute6(element, name)?.trim() === "auto" ? "auto" : numberAttribute(context, element, name);
99803
100165
  }
99804
100166
  function reportUnmodelled2(context, element, handled) {
99805
100167
  for (const child31 of elements(element)) {
@@ -99830,9 +100192,9 @@ function lines(parent, local) {
99830
100192
  }
99831
100193
  function numberFormat2(parent) {
99832
100194
  const element = cxChild(parent, "numFmt");
99833
- const formatCode2 = attribute5(element, "formatCode");
100195
+ const formatCode2 = attribute6(element, "formatCode");
99834
100196
  if (formatCode2 === void 0) return void 0;
99835
- const linked = attribute5(element, "sourceLinked");
100197
+ const linked = attribute6(element, "sourceLinked");
99836
100198
  return {
99837
100199
  formatCode: formatCode2,
99838
100200
  ...linked === "1" || linked === "true" ? { sourceLinked: true } : {},
@@ -99843,7 +100205,7 @@ function formula(parent, local) {
99843
100205
  const element = cxChild(parent, local);
99844
100206
  if (!element) return void 0;
99845
100207
  const out = { formula: element.textContent ?? "" };
99846
- const direction = attribute5(element, "dir");
100208
+ const direction = attribute6(element, "dir");
99847
100209
  if (direction !== void 0) out.direction = direction;
99848
100210
  return out;
99849
100211
  }
@@ -99877,8 +100239,8 @@ function parseLevel(context, element) {
99877
100239
  { points: points7 },
99878
100240
  {
99879
100241
  pointCount: indexAttribute(context, element, "ptCount"),
99880
- formatCode: attribute5(element, "formatCode"),
99881
- name: attribute5(element, "name"),
100242
+ formatCode: attribute6(element, "formatCode"),
100243
+ name: attribute6(element, "name"),
99882
100244
  extLst: extensionList2(element)
99883
100245
  }
99884
100246
  );
@@ -99891,7 +100253,7 @@ function parseDimension(context, element) {
99891
100253
  levels: cxChildren(element, "lvl").map((level2) => parseLevel(context, level2))
99892
100254
  },
99893
100255
  {
99894
- type: attribute5(element, "type"),
100256
+ type: attribute6(element, "type"),
99895
100257
  formula: formula(element, "f"),
99896
100258
  nameFormula: formula(element, "nf"),
99897
100259
  extLst: extensionList2(element)
@@ -99925,7 +100287,7 @@ function parseChartData(context, element) {
99925
100287
  }
99926
100288
  return out;
99927
100289
  }
99928
- function parseText2(context, element) {
100290
+ function parseText3(context, element) {
99929
100291
  if (!element) return void 0;
99930
100292
  reportUnmodelled2(context, element, /* @__PURE__ */ new Set(["txData", "rich"]));
99931
100293
  const data = cxChild(element, "txData");
@@ -99945,11 +100307,11 @@ function parseTitle2(context, element) {
99945
100307
  return assignDefined(
99946
100308
  {},
99947
100309
  {
99948
- tx: parseText2(context, cxChild(element, "tx")),
100310
+ tx: parseText3(context, cxChild(element, "tx")),
99949
100311
  spPr: shapeProperties2(element),
99950
100312
  txPr: textProperties2(element),
99951
- position: attribute5(element, "pos"),
99952
- align: attribute5(element, "align"),
100313
+ position: attribute6(element, "pos"),
100314
+ align: attribute6(element, "align"),
99953
100315
  overlay: boolAttribute(context, element, "overlay"),
99954
100316
  extLst: extensionList2(element)
99955
100317
  }
@@ -99960,8 +100322,8 @@ function parseLegend2(context, element) {
99960
100322
  return assignDefined(
99961
100323
  {},
99962
100324
  {
99963
- position: attribute5(element, "pos"),
99964
- align: attribute5(element, "align"),
100325
+ position: attribute6(element, "pos"),
100326
+ align: attribute6(element, "align"),
99965
100327
  overlay: boolAttribute(context, element, "overlay"),
99966
100328
  spPr: shapeProperties2(element),
99967
100329
  txPr: textProperties2(element),
@@ -100010,7 +100372,7 @@ function parseUnits(context, element) {
100010
100372
  return assignDefined(
100011
100373
  {},
100012
100374
  {
100013
- unit: attribute5(element, "unit"),
100375
+ unit: attribute6(element, "unit"),
100014
100376
  label: label ? parseTitle2(context, label) : void 0,
100015
100377
  extLst: extensionList2(element)
100016
100378
  }
@@ -100061,7 +100423,7 @@ var init_parse_axis = __esm({
100061
100423
  "txPr",
100062
100424
  "extLst"
100063
100425
  ]);
100064
- tickMarks = (element) => element ? assignDefined({}, { type: attribute5(element, "type") }) : void 0;
100426
+ tickMarks = (element) => element ? assignDefined({}, { type: attribute6(element, "type") }) : void 0;
100065
100427
  }
100066
100428
  });
100067
100429
 
@@ -100080,7 +100442,7 @@ function labelVisibility(context, element) {
100080
100442
  function labelOptions2(context, element) {
100081
100443
  const separator = cxChild(element, "separator");
100082
100444
  return {
100083
- position: attribute5(element, "pos"),
100445
+ position: attribute6(element, "pos"),
100084
100446
  numberFormat: numberFormat2(element),
100085
100447
  spPr: shapeProperties2(element),
100086
100448
  txPr: textProperties2(element),
@@ -100113,7 +100475,7 @@ function parseBinning(context, element) {
100113
100475
  return assignDefined(
100114
100476
  {},
100115
100477
  {
100116
- intervalClosed: attribute5(element, "intervalClosed"),
100478
+ intervalClosed: attribute6(element, "intervalClosed"),
100117
100479
  underflow: autoNumberAttribute(context, element, "underflow"),
100118
100480
  overflow: autoNumberAttribute(context, element, "overflow"),
100119
100481
  binSize: scalar4("binSize"),
@@ -100126,11 +100488,11 @@ function parseGeography(context, element) {
100126
100488
  return assignDefined(
100127
100489
  {},
100128
100490
  {
100129
- projectionType: attribute5(element, "projectionType"),
100130
- viewedRegionType: attribute5(element, "viewedRegionType"),
100131
- cultureLanguage: attribute5(element, "cultureLanguage"),
100132
- cultureRegion: attribute5(element, "cultureRegion"),
100133
- attribution: attribute5(element, "attribution"),
100491
+ projectionType: attribute6(element, "projectionType"),
100492
+ viewedRegionType: attribute6(element, "viewedRegionType"),
100493
+ cultureLanguage: attribute6(element, "cultureLanguage"),
100494
+ cultureRegion: attribute6(element, "cultureRegion"),
100495
+ attribution: attribute6(element, "attribution"),
100134
100496
  geoCacheXml: rawChild2(element, "geoCache"),
100135
100497
  extLst: extensionList2(element)
100136
100498
  }
@@ -100146,8 +100508,8 @@ function parseLayout(context, element) {
100146
100508
  return assignDefined(
100147
100509
  {},
100148
100510
  {
100149
- parentLabelLayout: attribute5(cxChild(element, "parentLabelLayout"), "val"),
100150
- regionLabelLayout: attribute5(cxChild(element, "regionLabelLayout"), "val"),
100511
+ parentLabelLayout: attribute6(cxChild(element, "parentLabelLayout"), "val"),
100512
+ regionLabelLayout: attribute6(cxChild(element, "regionLabelLayout"), "val"),
100151
100513
  visibility: visibility ? assignDefined(
100152
100514
  {},
100153
100515
  Object.fromEntries(
@@ -100159,7 +100521,7 @@ function parseLayout(context, element) {
100159
100521
  geography: geography ? parseGeography(context, geography) : void 0,
100160
100522
  statistics: statistics ? assignDefined(
100161
100523
  {},
100162
- { quartileMethod: attribute5(statistics, "quartileMethod") }
100524
+ { quartileMethod: attribute6(statistics, "quartileMethod") }
100163
100525
  ) : void 0,
100164
100526
  subtotals: subtotals ? cxChildren(subtotals, "idx").map((idx) => indexAttribute(context, idx, "val")).filter((index2) => index2 !== void 0) : void 0,
100165
100527
  extLst: extensionList2(element)
@@ -100184,13 +100546,13 @@ function parseSeries2(context, element) {
100184
100546
  const layout = cxChild(element, "layoutPr");
100185
100547
  const axisIds = cxChildren(element, "axisId").map((axis) => indexAttribute(context, axis, "val")).filter((id) => id !== void 0);
100186
100548
  return assignDefined(
100187
- { layoutId: attribute5(element, "layoutId") ?? "", dataPoints, axisIds },
100549
+ { layoutId: attribute6(element, "layoutId") ?? "", dataPoints, axisIds },
100188
100550
  {
100189
100551
  hidden: boolAttribute(context, element, "hidden"),
100190
100552
  ownerIndex: numberAttribute(context, element, "ownerIdx"),
100191
- uniqueId: attribute5(element, "uniqueId"),
100553
+ uniqueId: attribute6(element, "uniqueId"),
100192
100554
  formatIndex: numberAttribute(context, element, "formatIdx"),
100193
- tx: parseText2(context, cxChild(element, "tx")),
100555
+ tx: parseText3(context, cxChild(element, "tx")),
100194
100556
  spPr: shapeProperties2(element),
100195
100557
  txPr: textProperties2(element),
100196
100558
  valueColorsXml: rawChild2(element, "valueColors"),
@@ -103918,254 +104280,6 @@ var init_modern_comment_fields = __esm({
103918
104280
  }
103919
104281
  });
103920
104282
 
103921
- // pptx/core/utils/modern-comment-mention-read.ts
103922
- function readCommentMentions(node2, authorName) {
103923
- if (!node2) {
103924
- return void 0;
103925
- }
103926
- const found = [];
103927
- for (const list3 of mentionChildrenNamed(node2, "mentionLst")) {
103928
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
103929
- const mention = readMention(entry2, authorName);
103930
- if (mention) {
103931
- found.push(mention);
103932
- }
103933
- }
103934
- }
103935
- for (const extension of mentionChildrenNamed(mentionChildrenNamed(node2, "extLst")[0], "ext")) {
103936
- const uri = String(extension["@_uri"] || "");
103937
- for (const list3 of mentionChildrenNamed(extension, "mentionLst")) {
103938
- for (const entry2 of mentionChildrenNamed(list3, "mention")) {
103939
- const mention = readMention(entry2, authorName, uri);
103940
- if (mention) {
103941
- found.push(mention);
103942
- }
103943
- }
103944
- }
103945
- }
103946
- found.sort((a, b) => a.startIndex - b.startIndex);
103947
- return found.length > 0 ? found : void 0;
103948
- }
103949
- var mentionLocalName, mentionNodesOf, mentionChildrenNamed, MENTION_PERSON_KEYS, MENTION_LENGTH_KEYS, attribute6, integer3, readMention;
103950
- var init_modern_comment_mention_read = __esm({
103951
- "pptx/core/utils/modern-comment-mention-read.ts"() {
103952
- mentionLocalName = (key2) => key2.split(":").pop() || key2;
103953
- mentionNodesOf = (value) => {
103954
- if (Array.isArray(value)) {
103955
- return value.filter((entry2) => Boolean(entry2) && typeof entry2 === "object");
103956
- }
103957
- return value && typeof value === "object" ? [value] : [];
103958
- };
103959
- mentionChildrenNamed = (node2, name) => {
103960
- if (!node2) {
103961
- return [];
103962
- }
103963
- const result = [];
103964
- for (const [key2, value] of Object.entries(node2)) {
103965
- if (!key2.startsWith("@_") && mentionLocalName(key2) === name) {
103966
- result.push(...mentionNodesOf(value));
103967
- }
103968
- }
103969
- return result;
103970
- };
103971
- MENTION_PERSON_KEYS = [
103972
- "@_mentionpersonId",
103973
- "@_mentionPersonId",
103974
- "@_personId",
103975
- "@_authorId"
103976
- ];
103977
- MENTION_LENGTH_KEYS = ["@_length", "@_mentionCharCount", "@_len"];
103978
- attribute6 = (node2, keys) => {
103979
- for (const key2 of keys) {
103980
- const value = node2[key2];
103981
- if (value !== void 0 && value !== null && String(value).length > 0) {
103982
- return String(value);
103983
- }
103984
- }
103985
- return void 0;
103986
- };
103987
- integer3 = (value) => {
103988
- if (value === void 0) {
103989
- return void 0;
103990
- }
103991
- const parsed = Number.parseInt(value, 10);
103992
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : void 0;
103993
- };
103994
- readMention = (node2, authorName, containerUri) => {
103995
- const personId = attribute6(node2, MENTION_PERSON_KEYS);
103996
- const startIndex = integer3(attribute6(node2, ["@_startIndex"]));
103997
- const length = integer3(attribute6(node2, MENTION_LENGTH_KEYS));
103998
- if (!personId || startIndex === void 0 || length === void 0 || length === 0) {
103999
- return void 0;
104000
- }
104001
- return {
104002
- personId,
104003
- startIndex,
104004
- length,
104005
- id: attribute6(node2, ["@_mentionId", "@_id"]),
104006
- authorName: authorName(personId),
104007
- containerUri,
104008
- rawXml: node2
104009
- };
104010
- };
104011
- }
104012
- });
104013
-
104014
- // pptx/core/utils/modern-comment-mentions.ts
104015
- function rebaseCommentMentions(mentions, oldText, newText) {
104016
- if (!mentions || mentions.length === 0) {
104017
- return void 0;
104018
- }
104019
- if (oldText === newText) {
104020
- return mentions;
104021
- }
104022
- const prefix = commonPrefixLength(oldText, newText);
104023
- const suffix = commonSuffixLength(
104024
- oldText,
104025
- newText,
104026
- Math.min(oldText.length, newText.length) - prefix
104027
- );
104028
- const changeEnd = oldText.length - suffix;
104029
- const delta2 = newText.length - oldText.length;
104030
- const result = [];
104031
- for (const mention of mentions) {
104032
- const start = mention.startIndex;
104033
- const end = start + mention.length;
104034
- const span = oldText.slice(start, end);
104035
- if (span.length !== mention.length) {
104036
- continue;
104037
- }
104038
- let next = -1;
104039
- if (end <= prefix) {
104040
- next = start;
104041
- } else if (start >= changeEnd) {
104042
- next = start + delta2;
104043
- }
104044
- if (next >= 0 && newText.slice(next, next + mention.length) === span) {
104045
- result.push(next === start ? mention : { ...mention, startIndex: next });
104046
- continue;
104047
- }
104048
- const relocated = nearestOccurrence(newText, span, next >= 0 ? next : start);
104049
- if (relocated >= 0) {
104050
- result.push({ ...mention, startIndex: relocated });
104051
- }
104052
- }
104053
- return result.length > 0 ? result : void 0;
104054
- }
104055
- function buildMentionListNode(mentions) {
104056
- if (!mentions || mentions.length === 0) {
104057
- return void 0;
104058
- }
104059
- return { "p188:mention": mentions.map(buildMention) };
104060
- }
104061
- function applyCommentMentions(node2, mentions, extension, replace) {
104062
- if (!replace) {
104063
- return extension;
104064
- }
104065
- const { direct, byUri } = groupByContainer(mentions);
104066
- const directList = buildMentionListNode(direct);
104067
- if (directList) {
104068
- node2["p188:mentionLst"] = directList;
104069
- }
104070
- if (!extension) {
104071
- return void 0;
104072
- }
104073
- const rebuilt = stripMentionLists(extension);
104074
- const extensionKey = Object.keys(rebuilt).find((key2) => mentionLocalName(key2) === "ext") || "p188:ext";
104075
- const entries = mentionNodesOf(rebuilt[extensionKey]).map((entry2) => {
104076
- const list3 = buildMentionListNode(byUri.get(String(entry2["@_uri"] || "")));
104077
- const next = stripMentionLists(entry2);
104078
- if (list3) {
104079
- next["p188:mentionLst"] = list3;
104080
- }
104081
- return next;
104082
- });
104083
- if (entries.length > 0) {
104084
- rebuilt[extensionKey] = entries.length === 1 ? entries[0] : entries;
104085
- }
104086
- return rebuilt;
104087
- }
104088
- var commonPrefixLength, commonSuffixLength, nearestOccurrence, buildMention, stripMentionLists, groupByContainer;
104089
- var init_modern_comment_mentions = __esm({
104090
- "pptx/core/utils/modern-comment-mentions.ts"() {
104091
- init_modern_comment_mention_read();
104092
- init_modern_comment_mention_read();
104093
- commonPrefixLength = (a, b) => {
104094
- const max = Math.min(a.length, b.length);
104095
- let index2 = 0;
104096
- while (index2 < max && a[index2] === b[index2]) {
104097
- index2 += 1;
104098
- }
104099
- return index2;
104100
- };
104101
- commonSuffixLength = (a, b, limit) => {
104102
- let index2 = 0;
104103
- while (index2 < limit && a[a.length - 1 - index2] === b[b.length - 1 - index2]) {
104104
- index2 += 1;
104105
- }
104106
- return index2;
104107
- };
104108
- nearestOccurrence = (text2, span, hint) => {
104109
- let best = -1;
104110
- let bestDistance = Number.POSITIVE_INFINITY;
104111
- let at2 = text2.indexOf(span);
104112
- while (at2 !== -1) {
104113
- const distance = Math.abs(at2 - hint);
104114
- if (distance < bestDistance) {
104115
- best = at2;
104116
- bestDistance = distance;
104117
- }
104118
- at2 = text2.indexOf(span, at2 + 1);
104119
- }
104120
- return best;
104121
- };
104122
- buildMention = (mention) => {
104123
- const node2 = {};
104124
- for (const [key2, value] of Object.entries(mention.rawXml || {})) {
104125
- if (key2.startsWith("@_")) {
104126
- node2[key2] = value;
104127
- }
104128
- }
104129
- const personKey = MENTION_PERSON_KEYS.find((key2) => node2[key2] !== void 0) || "@_mentionpersonId";
104130
- const lengthKey = MENTION_LENGTH_KEYS.find((key2) => node2[key2] !== void 0) || "@_length";
104131
- node2[personKey] = mention.personId;
104132
- node2[lengthKey] = String(mention.length);
104133
- node2["@_startIndex"] = String(mention.startIndex);
104134
- if (mention.id) {
104135
- const idKey = node2["@_id"] !== void 0 && node2["@_mentionId"] === void 0 ? "@_id" : "@_mentionId";
104136
- node2[idKey] = mention.id;
104137
- }
104138
- return node2;
104139
- };
104140
- stripMentionLists = (node2) => {
104141
- const result = {};
104142
- for (const [key2, value] of Object.entries(node2)) {
104143
- if (key2.startsWith("@_") || mentionLocalName(key2) !== "mentionLst") {
104144
- result[key2] = value;
104145
- }
104146
- }
104147
- return result;
104148
- };
104149
- groupByContainer = (mentions) => {
104150
- const direct = [];
104151
- const byUri = /* @__PURE__ */ new Map();
104152
- for (const mention of mentions || []) {
104153
- if (!mention.containerUri) {
104154
- direct.push(mention);
104155
- continue;
104156
- }
104157
- const bucket = byUri.get(mention.containerUri);
104158
- if (bucket) {
104159
- bucket.push(mention);
104160
- } else {
104161
- byUri.set(mention.containerUri, [mention]);
104162
- }
104163
- }
104164
- return { direct, byUri };
104165
- };
104166
- }
104167
- });
104168
-
104169
104283
  // pptx/core/utils/modern-comment-text-body.ts
104170
104284
  function flattenBodyText(node2) {
104171
104285
  if (!node2) {
@@ -104559,7 +104673,13 @@ var init_modern_comment_xml = __esm({
104559
104673
  const originalBody = child23(raw2, "txBody");
104560
104674
  node2["p188:txBody"] = applyModernCommentText(originalBody, comment.text);
104561
104675
  const originalText = originalBody ? flattenBodyText(originalBody).join("\n") : comment.text;
104562
- const mentions = rebaseCommentMentions(comment.mentions, originalText, comment.text);
104676
+ const loadedMentions = raw2 ? readCommentMentions(raw2, () => void 0) : void 0;
104677
+ const mentions = rebaseCommentMentions(
104678
+ comment.mentions,
104679
+ originalText,
104680
+ comment.text,
104681
+ loadedMentions ?? []
104682
+ );
104563
104683
  const extension = applyCommentMentions(node2, mentions, child23(raw2, "extLst"), ownsMentions);
104564
104684
  if (extension) {
104565
104685
  node2["p188:extLst"] = extension;
@@ -114052,8 +114172,8 @@ async function discoverTagCollections(zip, codec2) {
114052
114172
  if (!sourcePartPath) {
114053
114173
  continue;
114054
114174
  }
114055
- const data = codec2.parse(await relFile.async("string"));
114056
- const root = data["Relationships"];
114175
+ const data = await readPartXml(zip, codec2, relFile.name);
114176
+ const root = data?.["Relationships"];
114057
114177
  for (const relationship2 of ensureArray17(root?.["Relationship"])) {
114058
114178
  if (String(relationship2["@_Type"] ?? "") !== TAG_RELATIONSHIP_TYPE) {
114059
114179
  continue;
@@ -114158,7 +114278,7 @@ async function removeTagContentTypeOverride(zip, codec2, path4) {
114158
114278
  zip.file("[Content_Types].xml", codec2.build(data));
114159
114279
  }
114160
114280
  async function readTagCollection(zip, codec2, path4) {
114161
- const xml = await zip.file(path4)?.async("string");
114281
+ const xml = await readPartText(zip, path4);
114162
114282
  if (!xml) {
114163
114283
  return void 0;
114164
114284
  }
@@ -114267,6 +114387,7 @@ function ensureArray17(value) {
114267
114387
  var TAG_RELATIONSHIP_TYPE, TAG_CONTENT_TYPE;
114268
114388
  var init_tag_package = __esm({
114269
114389
  "pptx/core/utils/tag-package.ts"() {
114390
+ init_load_part_reader();
114270
114391
  init_safe_path();
114271
114392
  init_tag_package_owning_element();
114272
114393
  TAG_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags";
@@ -119600,10 +119721,35 @@ var init_PptxHandlerRuntimeState = __esm({
119600
119721
  "pptx/core/core/runtime/PptxHandlerRuntimeState.ts"() {
119601
119722
  init_utils();
119602
119723
  init_part_rels_path();
119724
+ init_load_part_reader();
119603
119725
  init_template_element_baselines();
119604
119726
  PptxHandlerRuntime = class {
119605
119727
  /** The in-memory ZIP archive representing the OPC (.pptx) package. */
119606
119728
  zip;
119729
+ /** Shares part reads within the load in progress; see {@link LoadPartReader}. */
119730
+ loadPartReader;
119731
+ /** Opens a part reader for the current package, closing any earlier one. */
119732
+ beginPartReads() {
119733
+ this.endPartReads();
119734
+ const reader2 = new LoadPartReader(this.zip);
119735
+ this.loadPartReader = reader2;
119736
+ return reader2;
119737
+ }
119738
+ /** Closes `reader` (by default the open one) and releases its cached reads. */
119739
+ endPartReads(reader2 = this.loadPartReader) {
119740
+ reader2?.close();
119741
+ if (reader2 && this.loadPartReader === reader2) {
119742
+ this.loadPartReader = void 0;
119743
+ }
119744
+ }
119745
+ /** The text of a package part, shared within a load. */
119746
+ readPartText(path4) {
119747
+ return readPartText(this.zip, path4);
119748
+ }
119749
+ /** A parsed package part; relationship parts are parsed once per load. */
119750
+ readPartXml(path4) {
119751
+ return readPartXml(this.zip, this.parser, path4);
119752
+ }
119607
119753
  /** fast-xml-parser instance used to parse XML strings into JS objects. */
119608
119754
  parser;
119609
119755
  /** fast-xml-parser builder used to serialize JS objects back to XML strings. */
@@ -120022,11 +120168,11 @@ var init_PptxHandlerRuntimeState = __esm({
120022
120168
  * @param relsPath - Path of the `.rels` part; derived from `partPath` when omitted.
120023
120169
  */
120024
120170
  async loadPartRelationships(partPath, relsPath2) {
120025
- const relsXml = await this.zip.file(relsPath2 ?? partRelsPath(partPath))?.async("string");
120026
- if (!relsXml) {
120171
+ const path4 = relsPath2 ?? partRelsPath(partPath);
120172
+ const relsData = await this.readPartXml(path4);
120173
+ if (!relsData) {
120027
120174
  return;
120028
120175
  }
120029
- const relsData = this.parser.parse(relsXml);
120030
120176
  const relationships3 = relsData?.["Relationships"];
120031
120177
  const raw2 = relationships3?.["Relationship"];
120032
120178
  const entries = Array.isArray(raw2) ? raw2 : raw2 ? [raw2] : [];
@@ -121555,10 +121701,6 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121555
121701
  this.zip.file(relsPath2, this.builder.build(relsData));
121556
121702
  return true;
121557
121703
  }
121558
- /** The text of a package part, or `undefined` when the package has no such part. */
121559
- async readPartText(path4) {
121560
- return this.zip.file(path4)?.async("string");
121561
- }
121562
121704
  /**
121563
121705
  * Parse extended (application) properties from `docProps/app.xml`.
121564
121706
  */
@@ -121619,8 +121761,10 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121619
121761
  if (!relsFile) {
121620
121762
  return [];
121621
121763
  }
121622
- const relsXml = await relsFile.async("string");
121623
- const relsData = this.parser.parse(relsXml);
121764
+ const relsData = await this.readPartXml(relsPath2);
121765
+ if (!relsData) {
121766
+ return [];
121767
+ }
121624
121768
  const relRoot = relsData["Relationships"] || {};
121625
121769
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
121626
121770
  const relMap = /* @__PURE__ */ new Map();
@@ -121651,7 +121795,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121651
121795
  try {
121652
121796
  const file2 = this.zip.file(resolvedPath);
121653
121797
  if (file2) {
121654
- data = await file2.async("string");
121798
+ data = await this.readPartText(resolvedPath);
121655
121799
  }
121656
121800
  } catch {
121657
121801
  }
@@ -121731,9 +121875,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121731
121875
  */
121732
121876
  async parseTags() {
121733
121877
  try {
121734
- return await discoverTagCollections(this.zip, {
121735
- parse: (xml) => this.parser.parse(xml)
121736
- });
121878
+ return await discoverTagCollections(this.zip, this.parser);
121737
121879
  } catch (e) {
121738
121880
  console.warn("Failed to parse tags:", e);
121739
121881
  return [];
@@ -121873,7 +122015,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121873
122015
  }
121874
122016
  for (const file2 of masterFiles) {
121875
122017
  const path4 = file2.name;
121876
- const xml = await file2.async("string");
122018
+ const xml = await this.readPartText(path4) ?? "";
121877
122019
  const data = this.parser.parse(xml);
121878
122020
  const sldMaster = data?.["p:sldMaster"];
121879
122021
  if (!sldMaster) {
@@ -121898,8 +122040,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121898
122040
  );
121899
122041
  const relsFile = this.zip.file(relsPath2);
121900
122042
  if (relsFile) {
121901
- const relsXml = await relsFile.async("string");
121902
- const relsData = this.parser.parse(relsXml);
122043
+ const relsData = await this.readPartXml(relsPath2);
121903
122044
  const rels = this.ensureArray(
121904
122045
  xmlChild(relsData, "Relationships")?.["Relationship"]
121905
122046
  );
@@ -121913,8 +122054,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121913
122054
  }
121914
122055
  const layoutPaths = [];
121915
122056
  if (relsFile) {
121916
- const relsXml = await relsFile.async("string");
121917
- const relsData = this.parser.parse(relsXml);
122057
+ const relsData = await this.readPartXml(relsPath2);
121918
122058
  const rels = this.ensureArray(
121919
122059
  xmlChild(relsData, "Relationships")?.["Relationship"]
121920
122060
  );
@@ -121958,7 +122098,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121958
122098
  return void 0;
121959
122099
  }
121960
122100
  const path4 = files[0].name;
121961
- const xml = await files[0].async("string");
122101
+ const xml = await this.readPartText(path4) ?? "";
121962
122102
  const data = this.parser.parse(xml);
121963
122103
  const master = data?.["p:handoutMaster"];
121964
122104
  if (!master) {
@@ -121990,7 +122130,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121990
122130
  return void 0;
121991
122131
  }
121992
122132
  const path4 = files[0].name;
121993
- const xml = await files[0].async("string");
122133
+ const xml = await this.readPartText(path4) ?? "";
121994
122134
  const data = this.parser.parse(xml);
121995
122135
  const master = data?.["p:notesMaster"];
121996
122136
  if (!master) {
@@ -122021,7 +122161,7 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
122021
122161
  if (!layoutFile) {
122022
122162
  return void 0;
122023
122163
  }
122024
- const xml = await layoutFile.async("string");
122164
+ const xml = await this.readPartText(layoutPath) ?? "";
122025
122165
  const data = this.parser.parse(xml);
122026
122166
  const sldLayout = data?.["p:sldLayout"];
122027
122167
  if (!sldLayout) {
@@ -122129,18 +122269,19 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
122129
122269
  */
122130
122270
  async parsePresentationProperties() {
122131
122271
  try {
122132
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
122133
- if (!relsXml) {
122272
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
122273
+ if (!relsData) {
122134
122274
  return void 0;
122135
122275
  }
122136
- const relsData = this.parser.parse(relsXml);
122137
- const rels = this.ensureArray(relsData?.Relationships?.Relationship);
122276
+ const rels = this.ensureArray(
122277
+ relsData.Relationships?.Relationship
122278
+ );
122138
122279
  const prRel = rels.find(
122139
122280
  (r) => String(r?.["@_Type"] || "").includes("presProps") || String(r?.["@_Target"] || "").includes("presProps")
122140
122281
  );
122141
122282
  const prTarget = prRel ? String(prRel["@_Target"] || "") : "presProps.xml";
122142
122283
  const prPath = prTarget.startsWith("/") ? prTarget.substring(1) : `ppt/${prTarget}`;
122143
- const prXmlStr = await this.zip.file(prPath)?.async("string");
122284
+ const prXmlStr = await this.readPartText(prPath);
122144
122285
  if (!prXmlStr) {
122145
122286
  return void 0;
122146
122287
  }
@@ -122186,7 +122327,7 @@ var init_PptxHandlerRuntimePresentationProps = __esm({
122186
122327
  */
122187
122328
  async parseViewProperties() {
122188
122329
  try {
122189
- const viewPropsXml2 = await this.zip.file("ppt/viewProps.xml")?.async("string");
122330
+ const viewPropsXml2 = await this.readPartText("ppt/viewProps.xml");
122190
122331
  if (!viewPropsXml2) {
122191
122332
  return void 0;
122192
122333
  }
@@ -126661,7 +126802,7 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
126661
126802
  if (existingRel?.target) {
126662
126803
  drawingPath = this.resolveImagePath(chartPartPath, existingRel.target);
126663
126804
  try {
126664
- const xml = await this.zip.file(drawingPath)?.async("string");
126805
+ const xml = await this.readPartText(drawingPath);
126665
126806
  if (xml) {
126666
126807
  const root = this.parser.parse(xml);
126667
126808
  onDisk = parseChartUserShapesDrawing(root, this.xmlLookupService, {
@@ -126712,11 +126853,10 @@ var init_PptxHandlerRuntimeChartUserShapes = __esm({
126712
126853
  const slash = chartPartPath.lastIndexOf("/");
126713
126854
  const relsPath2 = `${chartPartPath.slice(0, slash + 1)}_rels/${chartPartPath.slice(slash + 1)}.rels`;
126714
126855
  try {
126715
- const xml = await this.zip.file(relsPath2)?.async("string");
126716
- if (!xml) {
126856
+ const tree = await this.readPartXml(relsPath2);
126857
+ if (!tree) {
126717
126858
  return void 0;
126718
126859
  }
126719
- const tree = this.parser.parse(xml);
126720
126860
  const root = tree["Relationships"];
126721
126861
  const rels = root?.["Relationship"];
126722
126862
  const list3 = rels === void 0 ? [] : Array.isArray(rels) ? rels : [rels];
@@ -142255,7 +142395,7 @@ var init_PptxHandlerRuntimeSlideParsing = __esm({
142255
142395
  this.unwrapAlternateContent(spTree);
142256
142396
  let rawXmlStr;
142257
142397
  try {
142258
- rawXmlStr = await this.zip.file(slidePath)?.async("string") ?? void 0;
142398
+ rawXmlStr = await this.readPartText(slidePath);
142259
142399
  } catch {
142260
142400
  }
142261
142401
  const slidePrefix = slidePath ? `${slidePath}-` : "";
@@ -142824,7 +142964,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
142824
142964
  if (cached2) {
142825
142965
  return cached2;
142826
142966
  }
142827
- const xml = await this.zip.file(layoutPath)?.async("string");
142967
+ const xml = await this.readPartText(layoutPath);
142828
142968
  if (!xml) {
142829
142969
  return void 0;
142830
142970
  }
@@ -142838,7 +142978,7 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
142838
142978
  if (cached2) {
142839
142979
  return cached2;
142840
142980
  }
142841
- const xml = await this.zip.file(masterPath)?.async("string");
142981
+ const xml = await this.readPartText(masterPath);
142842
142982
  if (!xml) {
142843
142983
  return void 0;
142844
142984
  }
@@ -143298,7 +143438,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
143298
143438
  if (!notesPath) {
143299
143439
  return {};
143300
143440
  }
143301
- const notesXml = await this.zip.file(notesPath)?.async("string");
143441
+ const notesXml = await this.readPartText(notesPath);
143302
143442
  if (!notesXml) {
143303
143443
  return {};
143304
143444
  }
@@ -143797,7 +143937,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
143797
143937
  try {
143798
143938
  let masterXmlObj = this.masterXmlMap.get(master.path);
143799
143939
  if (!masterXmlObj) {
143800
- const xmlStr = await this.zip.file(master.path)?.async("string");
143940
+ const xmlStr = await this.readPartText(master.path);
143801
143941
  if (!xmlStr) {
143802
143942
  continue;
143803
143943
  }
@@ -143870,7 +144010,7 @@ var init_PptxHandlerRuntimeMasterElements = __esm({
143870
144010
  }
143871
144011
  const masterToken = masterPath.split("/").pop()?.replace(/\.xml$/u, "") ?? masterPath;
143872
144012
  try {
143873
- const masterXmlStr = await this.zip.file(masterPath)?.async("string");
144013
+ const masterXmlStr = await this.readPartText(masterPath);
143874
144014
  if (!masterXmlStr) {
143875
144015
  return [];
143876
144016
  }
@@ -144032,7 +144172,7 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
144032
144172
  }
144033
144173
  const partPath = part.path;
144034
144174
  rememberMasterPartBackground(this, partPath, part.backgroundColor);
144035
- const xml = await this.zip.file(partPath)?.async("string");
144175
+ const xml = await this.readPartText(partPath);
144036
144176
  if (!xml) {
144037
144177
  return;
144038
144178
  }
@@ -144192,7 +144332,7 @@ var init_PptxHandlerRuntimeLayoutElements = __esm({
144192
144332
  }
144193
144333
  const layoutToken = layoutPath.split("/").pop()?.replace(/\.xml$/u, "") ?? layoutPath;
144194
144334
  try {
144195
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
144335
+ const layoutXmlStr = await this.readPartText(layoutPath);
144196
144336
  if (!layoutXmlStr) {
144197
144337
  return [];
144198
144338
  }
@@ -144926,7 +145066,7 @@ var init_PptxHandlerRuntimeThemeOverrides = __esm({
144926
145066
  return cached2;
144927
145067
  }
144928
145068
  try {
144929
- const overrideXml = await this.zip.file(overridePath)?.async("string");
145069
+ const overrideXml = await this.readPartText(overridePath);
144930
145070
  if (!overrideXml) {
144931
145071
  return null;
144932
145072
  }
@@ -145555,10 +145695,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145555
145695
  if (!relsXml) {
145556
145696
  return void 0;
145557
145697
  }
145558
- const relsData = this.parser.parse(
145559
- // eslint-disable-next-line no-await-in-loop
145560
- await relsXml.async("string")
145561
- );
145698
+ const relsData = await this.readPartXml(relsPath2);
145562
145699
  const relNodes = this.ensureArray(
145563
145700
  relsData?.Relationships?.Relationship
145564
145701
  );
@@ -145584,7 +145721,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145584
145721
  const options = [];
145585
145722
  for (const file2 of themeFiles) {
145586
145723
  try {
145587
- const xml = await file2.async("string");
145724
+ const xml = await this.readPartText(file2.name) ?? "";
145588
145725
  const data = this.parser.parse(xml);
145589
145726
  const root = data["a:theme"];
145590
145727
  const name = String(root?.["@_name"] || "").trim();
@@ -145664,7 +145801,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145664
145801
  ];
145665
145802
  for (const file2 of masterFiles) {
145666
145803
  try {
145667
- const masterXml = await file2.async("string");
145804
+ const masterXml = await this.readPartText(file2.name) ?? "";
145668
145805
  const masterData = this.parser.parse(masterXml);
145669
145806
  const clrMap = masterData?.["p:sldMaster"]?.["p:clrMap"];
145670
145807
  if (!clrMap) {
@@ -145697,7 +145834,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145697
145834
  if (!themeFile) {
145698
145835
  return null;
145699
145836
  }
145700
- const themeXml3 = await themeFile.async("string");
145837
+ const themeXml3 = await this.readPartText(themePath) ?? "";
145701
145838
  const model = this.parseThemePartXml(themeXml3);
145702
145839
  this.cacheThemePartModel(themePath, themeXml3, model);
145703
145840
  return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
@@ -145732,7 +145869,7 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145732
145869
  if (!relsXml) {
145733
145870
  return void 0;
145734
145871
  }
145735
- const relsData = this.parser.parse(await relsXml.async("string"));
145872
+ const relsData = await this.readPartXml(relsPath2);
145736
145873
  const relNodes = this.ensureArray(
145737
145874
  relsData?.Relationships?.Relationship
145738
145875
  );
@@ -146061,11 +146198,10 @@ var init_PptxHandlerRuntimeComments = __esm({
146061
146198
  async extractModernSlideComments(slidePath) {
146062
146199
  try {
146063
146200
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
146064
- const relsXml = await this.zip.file(relsPath2)?.async("string");
146065
- if (!relsXml) {
146201
+ const relsData = await this.readPartXml(relsPath2);
146202
+ if (!relsData) {
146066
146203
  return [];
146067
146204
  }
146068
- const relsData = this.parser.parse(relsXml);
146069
146205
  const rels = this.ensureArray(
146070
146206
  xmlChild(relsData, "Relationships")?.Relationship
146071
146207
  );
@@ -146082,7 +146218,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146082
146218
  continue;
146083
146219
  }
146084
146220
  const filePath = this.resolvePath(slidePath, target);
146085
- const xml = await this.zip.file(filePath)?.async("string");
146221
+ const xml = await this.readPartText(filePath);
146086
146222
  if (!xml) {
146087
146223
  continue;
146088
146224
  }
@@ -146105,11 +146241,10 @@ var init_PptxHandlerRuntimeComments = __esm({
146105
146241
  return [];
146106
146242
  }
146107
146243
  async loadModernCommentAuthors() {
146108
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
146109
- if (!relsXml) {
146244
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
146245
+ if (!relsData) {
146110
146246
  return;
146111
146247
  }
146112
- const relsData = this.parser.parse(relsXml);
146113
146248
  const relationships3 = this.ensureArray(
146114
146249
  xmlChild(relsData, "Relationships")?.Relationship
146115
146250
  );
@@ -146121,7 +146256,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146121
146256
  return;
146122
146257
  }
146123
146258
  const partPath = this.resolvePath("ppt/presentation.xml", target);
146124
- const xml = await this.zip.file(partPath)?.async("string");
146259
+ const xml = await this.readPartText(partPath);
146125
146260
  if (!xml) {
146126
146261
  return;
146127
146262
  }
@@ -146147,12 +146282,12 @@ var init_PptxHandlerRuntimeComments = __esm({
146147
146282
  }
146148
146283
  }
146149
146284
  const relsPath2 = `${slidePath.replace("slides/", "slides/_rels/")}.rels`;
146150
- const relsXml = await this.zip.file(relsPath2)?.async("string");
146285
+ const relsXml = await this.readPartText(relsPath2);
146151
146286
  if (!relsXml) {
146152
146287
  return void 0;
146153
146288
  }
146154
146289
  try {
146155
- const relsData = this.parser.parse(relsXml);
146290
+ const relsData = await this.readPartXml(relsPath2);
146156
146291
  const rels = this.ensureArray(
146157
146292
  xmlChild(relsData, "Relationships")?.Relationship
146158
146293
  );
@@ -146191,7 +146326,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146191
146326
  return [];
146192
146327
  }
146193
146328
  const commentsPath = this.resolveImagePath(slidePath, commentTarget);
146194
- const commentsXml = await this.zip.file(commentsPath)?.async("string");
146329
+ const commentsXml = await this.readPartText(commentsPath);
146195
146330
  if (!commentsXml) {
146196
146331
  return [];
146197
146332
  }
@@ -146226,7 +146361,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146226
146361
  }
146227
146362
  }
146228
146363
  async loadCommentAuthors() {
146229
- const commentAuthorsXml = await this.zip.file("ppt/commentAuthors.xml")?.async("string");
146364
+ const commentAuthorsXml = await this.readPartText("ppt/commentAuthors.xml");
146230
146365
  if (!commentAuthorsXml) {
146231
146366
  return;
146232
146367
  }
@@ -146298,7 +146433,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
146298
146433
  return void 0;
146299
146434
  }
146300
146435
  const partPath = this.resolveImagePath(slidePath, target);
146301
- const xmlString = await this.zip.file(partPath)?.async("string");
146436
+ const xmlString = await this.readPartText(partPath);
146302
146437
  if (!xmlString) {
146303
146438
  return void 0;
146304
146439
  }
@@ -148013,9 +148148,8 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
148013
148148
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
148014
148149
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
148015
148150
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
148016
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
148017
- if (chartRelsXml) {
148018
- const chartRelsData = this.parser.parse(chartRelsXml);
148151
+ const chartRelsData = await this.readPartXml(chartRelsPath);
148152
+ if (chartRelsData) {
148019
148153
  const relsContainer = chartRelsData?.Relationships;
148020
148154
  if (relsContainer?.Relationship) {
148021
148155
  const rels = Array.isArray(relsContainer.Relationship) ? relsContainer.Relationship : [relsContainer.Relationship];
@@ -148097,7 +148231,7 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
148097
148231
  if (drawingPath.length === 0) {
148098
148232
  return void 0;
148099
148233
  }
148100
- const drawingXml = await this.zip.file(drawingPath)?.async("string");
148234
+ const drawingXml = await this.readPartText(drawingPath);
148101
148235
  if (!drawingXml) {
148102
148236
  return void 0;
148103
148237
  }
@@ -148118,11 +148252,10 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
148118
148252
  const chartDir = chartPartPath.substring(0, chartPartPath.lastIndexOf("/") + 1);
148119
148253
  const chartFileName = chartPartPath.substring(chartPartPath.lastIndexOf("/") + 1);
148120
148254
  const chartRelsPath = `${chartDir}_rels/${chartFileName}.rels`;
148121
- const chartRelsXml = await this.zip.file(chartRelsPath)?.async("string");
148122
- if (!chartRelsXml) {
148255
+ const chartRelsData = await this.readPartXml(chartRelsPath);
148256
+ if (!chartRelsData) {
148123
148257
  return [];
148124
148258
  }
148125
- const chartRelsData = this.parser.parse(chartRelsXml);
148126
148259
  const relsContainer = chartRelsData?.Relationships;
148127
148260
  if (!relsContainer?.Relationship) {
148128
148261
  return [];
@@ -149014,11 +149147,10 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
149014
149147
  async loadPresentationFontRels() {
149015
149148
  const map2 = /* @__PURE__ */ new Map();
149016
149149
  try {
149017
- const relsXml = await this.zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
149018
- if (!relsXml) {
149150
+ const relsData = await this.readPartXml("ppt/_rels/presentation.xml.rels");
149151
+ if (!relsData) {
149019
149152
  return map2;
149020
149153
  }
149021
- const relsData = this.parser.parse(relsXml);
149022
149154
  const rels = this.ensureArray(
149023
149155
  xmlChild(relsData, "Relationships")?.Relationship
149024
149156
  );
@@ -149339,13 +149471,13 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
149339
149471
  if (!file2) {
149340
149472
  continue;
149341
149473
  }
149342
- const data = await file2.async("string");
149474
+ const data = await this.readPartText(entry2) ?? "";
149343
149475
  const propsPath = `customXml/itemProps${itemId}.xml`;
149344
149476
  const propsFile = this.zip.file(propsPath);
149345
149477
  let properties;
149346
149478
  let schemaUri;
149347
149479
  if (propsFile) {
149348
- properties = await propsFile.async("string");
149480
+ properties = await this.readPartText(propsPath) ?? "";
149349
149481
  try {
149350
149482
  const propsData = this.parser.parse(properties);
149351
149483
  const schemaRefs = propsData?.["ds:datastoreItem"]?.["ds:schemaRefs"]?.["ds:schemaRef"];
@@ -149365,14 +149497,14 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
149365
149497
  const relsFile = this.zip.file(relsPath2);
149366
149498
  let rels;
149367
149499
  if (relsFile) {
149368
- rels = await relsFile.async("string");
149500
+ rels = await this.readPartText(relsPath2);
149369
149501
  }
149370
149502
  parts.push({ id: itemId, data, schemaUri, properties, rels });
149371
149503
  }
149372
149504
  this.customXmlParts = parts;
149373
149505
  }
149374
149506
  async loadPresentationState() {
149375
- const presentationXml3 = await this.zip.file("ppt/presentation.xml")?.async("string");
149507
+ const presentationXml3 = await this.readPartText("ppt/presentation.xml");
149376
149508
  if (!presentationXml3) {
149377
149509
  throw new Error("Invalid PPTX: presentation.xml not found");
149378
149510
  }
@@ -149724,6 +149856,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149724
149856
  * or resolve images. Create a new `PptxHandler` instance instead.
149725
149857
  */
149726
149858
  dispose() {
149859
+ this.endPartReads();
149727
149860
  this.revokeBlobUrls();
149728
149861
  this.imageDataCache.clear();
149729
149862
  this.slideMap.clear();
@@ -149757,18 +149890,24 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149757
149890
  this.zip = null;
149758
149891
  }
149759
149892
  async load(data, options = {}) {
149760
- await this.initializeLoadSession(data, options);
149761
- await this.detectAndPreserveVbaProject();
149762
- this.detectDigitalSignatureParts();
149763
- await this.parseCustomXmlParts();
149764
- const presentationState = await this.loadPresentationState();
149765
- const slideMasters = await this.parseSlideMasters();
149766
- await this.enrichSlideMastersWithTxStyles(slideMasters);
149767
- const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
149768
- const slidesWithWarnings = this.attachSlideWarnings(slides);
149769
- this.resetElementIdCounter(slides);
149770
- recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
149771
- return this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
149893
+ let reader2;
149894
+ try {
149895
+ await this.initializeLoadSession(data, options);
149896
+ reader2 = this.beginPartReads();
149897
+ await this.detectAndPreserveVbaProject();
149898
+ this.detectDigitalSignatureParts();
149899
+ await this.parseCustomXmlParts();
149900
+ const presentationState = await this.loadPresentationState();
149901
+ const slideMasters = await this.parseSlideMasters();
149902
+ await this.enrichSlideMastersWithTxStyles(slideMasters);
149903
+ const slides = await this.loadSlidesForPresentation(presentationState.sectionBySlideId);
149904
+ const slidesWithWarnings = this.attachSlideWarnings(slides);
149905
+ this.resetElementIdCounter(slides);
149906
+ recordSlideFingerprints(this.savedSlideFingerprints, slidesWithWarnings);
149907
+ return await this.buildLoadData(presentationState, slidesWithWarnings, slideMasters);
149908
+ } finally {
149909
+ this.endPartReads(reader2);
149910
+ }
149772
149911
  }
149773
149912
  /**
149774
149913
  * Retrieve the current background colour for a layout or master.
@@ -149907,7 +150046,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149907
150046
  options.push(this.buildLayoutOption(lp, xmlObj));
149908
150047
  } else {
149909
150048
  try {
149910
- const layoutXmlStr = await this.zip.file(lp)?.async("string");
150049
+ const layoutXmlStr = await this.readPartText(lp);
149911
150050
  if (layoutXmlStr) {
149912
150051
  const layoutXmlObj = this.parser.parse(layoutXmlStr);
149913
150052
  this.layoutXmlMap.set(lp, layoutXmlObj);
@@ -149950,7 +150089,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149950
150089
  }
149951
150090
  let layoutXml3 = this.layoutXmlMap.get(layoutPath);
149952
150091
  if (!layoutXml3) {
149953
- const layoutXmlStr = await this.zip.file(layoutPath)?.async("string");
150092
+ const layoutXmlStr = await this.readPartText(layoutPath);
149954
150093
  if (!layoutXmlStr) {
149955
150094
  throw new Error(`Layout not found: ${layoutPath}`);
149956
150095
  }