ooxml-core 1.25.1 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +16 -0
  2. package/dist/{PptxHandler-AUK27AQD.mjs → PptxHandler-5QBRBXRX.mjs} +3 -3
  3. package/dist/{PptxHandler-QBGEZDCO.cjs → PptxHandler-CVYP5PAN.cjs} +3 -3
  4. package/dist/PptxHandler-TOAD6P7N.mjs +4 -0
  5. package/dist/{PresentationBuilder-RX7D75GZ.mjs → PresentationBuilder-EBVNYMLE.mjs} +2 -2
  6. package/dist/{PresentationBuilder-MEETJGEA.mjs → PresentationBuilder-M5UXW4AF.mjs} +3 -3
  7. package/dist/{PresentationBuilder-CI45KEHL.cjs → PresentationBuilder-RVQZCTIO.cjs} +5 -5
  8. package/dist/automation/index.cjs +273 -156
  9. package/dist/automation/index.mjs +273 -156
  10. package/dist/automation/xlsx-read.d.ts +2 -8
  11. package/dist/automation/xlsx-read.d.ts.map +1 -1
  12. package/dist/automation/xlsx.d.ts +2 -2
  13. package/dist/chart/index.cjs +89 -47
  14. package/dist/chart/index.mjs +89 -47
  15. package/dist/{chunk-6DHZZD5R.mjs → chunk-2XMK5SXU.mjs} +106 -48
  16. package/dist/{chunk-TX2QFS3J.mjs → chunk-4IIR2QEH.mjs} +608 -371
  17. package/dist/{chunk-635WPRNJ.mjs → chunk-DNYZX6YG.mjs} +19 -3
  18. package/dist/{chunk-VGDHSED6.mjs → chunk-EBJ724RB.mjs} +1 -1
  19. package/dist/{chunk-GMETZZ3V.cjs → chunk-EEHK52XB.cjs} +1677 -1440
  20. package/dist/{chunk-E2PYQQQV.mjs → chunk-JJ37PCNR.mjs} +89 -47
  21. package/dist/{chunk-5F7OB7PA.mjs → chunk-K6OFJ5GJ.mjs} +605 -368
  22. package/dist/{chunk-HVRFRYYS.mjs → chunk-KONCS53X.mjs} +5 -5
  23. package/dist/{chunk-S5TGOEQX.cjs → chunk-MU3XSASV.cjs} +106 -47
  24. package/dist/{chunk-E3PRAHL6.mjs → chunk-ZXPPM63Y.mjs} +1 -1
  25. package/dist/docx/embedded.cjs +89 -47
  26. package/dist/docx/embedded.mjs +89 -47
  27. package/dist/docx/index.cjs +89 -47
  28. package/dist/docx/index.mjs +89 -47
  29. package/dist/docx/layout/index.cjs +2 -2
  30. package/dist/docx/layout/index.mjs +2 -2
  31. package/dist/docx/layout/input.d.ts +6 -1
  32. package/dist/docx/layout/input.d.ts.map +1 -1
  33. package/dist/docx/layout/result.d.ts +1 -0
  34. package/dist/docx/layout/result.d.ts.map +1 -1
  35. package/dist/docx/load/index.cjs +89 -47
  36. package/dist/docx/load/index.mjs +89 -47
  37. package/dist/index.cjs +128 -53
  38. package/dist/index.mjs +128 -53
  39. package/dist/opc/index.cjs +90 -47
  40. package/dist/opc/index.mjs +90 -48
  41. package/dist/opc/zip-limits.d.ts +6 -0
  42. package/dist/opc/zip-limits.d.ts.map +1 -1
  43. package/dist/pptx/automation/index.cjs +766 -444
  44. package/dist/pptx/automation/index.d.ts +4 -4
  45. package/dist/pptx/automation/index.mjs +6 -6
  46. package/dist/pptx/chunks/{index-CgjEEpfK.d.ts → index-B94RKk84.d.ts} +276 -115
  47. package/dist/pptx/chunks/index-B94RKk84.d.ts.map +1 -0
  48. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts → index-BOpULlxB.d.ts} +3 -3
  49. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts.map → index-BOpULlxB.d.ts.map} +1 -1
  50. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts → index-D3gKRIAi.d.ts} +12 -5
  51. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts.map → index-D3gKRIAi.d.ts.map} +1 -1
  52. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts → text-operations-CNfUj45U.d.ts} +16 -2
  53. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts.map → text-operations-CNfUj45U.d.ts.map} +1 -1
  54. package/dist/pptx/cli/index.cjs +766 -444
  55. package/dist/pptx/cli/index.d.ts +1 -1
  56. package/dist/pptx/cli/index.mjs +5 -5
  57. package/dist/pptx/converter/index.d.ts +1 -1
  58. package/dist/pptx/converter/index.mjs +3 -3
  59. package/dist/pptx/editor/render/editor-history.cjs +21 -0
  60. package/dist/pptx/editor/render/editor-history.d.ts +9 -0
  61. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  62. package/dist/pptx/editor/render/editor-history.mjs +21 -0
  63. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  64. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  65. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  66. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  67. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  68. package/dist/pptx/index.cjs +765 -442
  69. package/dist/pptx/index.d.ts +5 -5
  70. package/dist/pptx/index.mjs +6 -6
  71. package/dist/pptx/node/index.d.ts +1 -1
  72. package/dist/pptx/signature-node/index.cjs +89 -47
  73. package/dist/pptx/signature-node/index.mjs +2 -2
  74. package/dist/visio/index.cjs +266 -150
  75. package/dist/visio/index.mjs +266 -150
  76. package/dist/visio/ui/index.cjs +266 -150
  77. package/dist/visio/ui/index.mjs +266 -150
  78. package/dist/xlsx/index.cjs +518 -153
  79. package/dist/xlsx/index.mjs +518 -154
  80. package/dist/xlsx/load/index.cjs +266 -150
  81. package/dist/xlsx/load/index.mjs +266 -150
  82. package/dist/xlsx/numfmt/view.d.ts +13 -0
  83. package/dist/xlsx/numfmt/view.d.ts.map +1 -0
  84. package/dist/xlsx/read/index.d.ts +1 -0
  85. package/dist/xlsx/read/index.d.ts.map +1 -1
  86. package/dist/xlsx/read/limits.d.ts +5 -0
  87. package/dist/xlsx/read/limits.d.ts.map +1 -1
  88. package/dist/xlsx/read/package.d.ts +6 -0
  89. package/dist/xlsx/read/package.d.ts.map +1 -1
  90. package/dist/xlsx/read/rows-stream.d.ts +12 -0
  91. package/dist/xlsx/read/rows-stream.d.ts.map +1 -0
  92. package/dist/xlsx/read/rows.d.ts +37 -0
  93. package/dist/xlsx/read/rows.d.ts.map +1 -0
  94. package/dist/xlsx/read/shared-strings.d.ts +6 -1
  95. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  96. package/dist/xlsx/read/sheet-data-source.d.ts +30 -3
  97. package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
  98. package/dist/xlsx/read/sheet-data.d.ts +13 -2
  99. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  100. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  101. package/dist/xlsx/ui/index.cjs +266 -150
  102. package/dist/xlsx/ui/index.mjs +266 -150
  103. package/dist/xml/index.cjs +38 -6
  104. package/dist/xml/index.mjs +37 -7
  105. package/dist/xml/lite.d.ts +15 -0
  106. package/dist/xml/lite.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/dist/PptxHandler-5UO5DD5K.mjs +0 -4
  109. package/dist/pptx/chunks/index-CgjEEpfK.d.ts.map +0 -1
@@ -14698,57 +14698,98 @@ function resolveLimits(limits) {
14698
14698
  fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
14699
14699
  };
14700
14700
  }
14701
- function inflateEntryGuarded(entry2, alreadyRead, limits) {
14701
+ async function inflateEntryGuarded(entry2, alreadyRead, limits) {
14702
+ const chunks = [];
14703
+ let size = 0;
14704
+ for await (const chunk2 of streamEntryGuarded(entry2, alreadyRead, limits)) {
14705
+ chunks.push(chunk2);
14706
+ size += chunk2.byteLength;
14707
+ }
14708
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
14709
+ const out = new Uint8Array(size);
14710
+ let offset = 0;
14711
+ for (const chunk2 of chunks) {
14712
+ out.set(chunk2, offset);
14713
+ offset += chunk2.byteLength;
14714
+ }
14715
+ return out;
14716
+ }
14717
+ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
14702
14718
  const r = resolveLimits(limits);
14703
14719
  const declared = declaredEntrySize(entry2);
14704
- return new Promise((resolvePromise, reject) => {
14705
- const chunks = [];
14706
- let size = 0;
14707
- let done = false;
14708
- const stream = entry2.internalStream("uint8array");
14709
- const abort = (error) => {
14710
- if (done) return;
14711
- done = true;
14712
- stream.pause();
14713
- chunks.length = 0;
14714
- reject(error);
14715
- };
14716
- stream.on("data", (chunk2) => {
14717
- if (done) return;
14718
- size += chunk2.byteLength;
14719
- if (size > declared || size > r.maxEntryBytes)
14720
- return abort(
14721
- r.fail(
14722
- `${r.label} part ${entry2.name} inflates past its declared size`,
14723
- r.maxEntryBytes,
14724
- size > declared ? "declaredSize" : "maxEntryBytes"
14725
- )
14726
- );
14727
- if (alreadyRead + size > r.maxTotalBytes)
14728
- return abort(
14729
- r.fail(
14730
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14731
- r.maxTotalBytes,
14732
- "maxTotalBytes"
14733
- )
14734
- );
14735
- chunks.push(chunk2);
14736
- });
14737
- stream.on("error", (error) => abort(error));
14738
- stream.on("end", () => {
14739
- if (done) return;
14740
- done = true;
14741
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
14742
- const out = new Uint8Array(size);
14743
- let offset = 0;
14744
- for (const chunk2 of chunks) {
14745
- out.set(chunk2, offset);
14746
- offset += chunk2.byteLength;
14747
- }
14748
- resolvePromise(out);
14749
- });
14720
+ const stream = entry2.internalStream("uint8array");
14721
+ const queue = [];
14722
+ let size = 0;
14723
+ let ended = false;
14724
+ let stopped = false;
14725
+ let failure;
14726
+ let paused = false;
14727
+ let wake;
14728
+ const pause = () => {
14729
+ paused = true;
14730
+ stream.pause();
14731
+ };
14732
+ const resume = () => {
14733
+ if (!paused || stopped) return;
14734
+ paused = false;
14750
14735
  stream.resume();
14736
+ };
14737
+ const fail2 = (error) => {
14738
+ failure ??= error;
14739
+ stopped = true;
14740
+ queue.length = 0;
14741
+ pause();
14742
+ wake?.();
14743
+ };
14744
+ stream.on("data", (chunk2) => {
14745
+ if (stopped) return pause();
14746
+ size += chunk2.byteLength;
14747
+ if (size > declared || size > r.maxEntryBytes)
14748
+ return fail2(
14749
+ r.fail(
14750
+ `${r.label} part ${entry2.name} inflates past its declared size`,
14751
+ r.maxEntryBytes,
14752
+ size > declared ? "declaredSize" : "maxEntryBytes"
14753
+ )
14754
+ );
14755
+ if (alreadyRead + size > r.maxTotalBytes)
14756
+ return fail2(
14757
+ r.fail(
14758
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
14759
+ r.maxTotalBytes,
14760
+ "maxTotalBytes"
14761
+ )
14762
+ );
14763
+ queue.push(chunk2);
14764
+ if (queue.length >= AHEAD) pause();
14765
+ wake?.();
14766
+ });
14767
+ stream.on("error", (error) => fail2(error));
14768
+ stream.on("end", () => {
14769
+ ended = true;
14770
+ wake?.();
14751
14771
  });
14772
+ stream.resume();
14773
+ try {
14774
+ for (; ; ) {
14775
+ if (failure) throw failure;
14776
+ const chunk2 = queue.shift();
14777
+ if (chunk2) {
14778
+ if (queue.length < AHEAD / 2) resume();
14779
+ yield chunk2;
14780
+ continue;
14781
+ }
14782
+ if (ended) return;
14783
+ await new Promise((resolve2) => {
14784
+ wake = resolve2;
14785
+ resume();
14786
+ });
14787
+ wake = void 0;
14788
+ }
14789
+ } finally {
14790
+ stopped = true;
14791
+ if (!ended) pause();
14792
+ }
14752
14793
  }
14753
14794
  function toBase64(bytes) {
14754
14795
  let binary = "";
@@ -14827,7 +14868,7 @@ async function openZip(input, limits = {}) {
14827
14868
  );
14828
14869
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
14829
14870
  }
14830
- var DEFAULT_ZIP_LIMITS, ZipLimitError, mib;
14871
+ var DEFAULT_ZIP_LIMITS, ZipLimitError, mib, AHEAD;
14831
14872
  var init_zip_limits = __esm({
14832
14873
  "opc/zip-limits.ts"() {
14833
14874
  DEFAULT_ZIP_LIMITS = {
@@ -14849,6 +14890,7 @@ var init_zip_limits = __esm({
14849
14890
  }
14850
14891
  };
14851
14892
  mib = (bytes) => Math.round(bytes / 1048576);
14893
+ AHEAD = 8;
14852
14894
  }
14853
14895
  });
14854
14896
 
@@ -45950,6 +45992,22 @@ var init_theme_effect_schemes_data = __esm({
45950
45992
  function findThemeEffectScheme(id) {
45951
45993
  return THEME_EFFECT_SCHEMES.find((scheme) => scheme.id === id);
45952
45994
  }
45995
+ function formatSchemeKey(scheme) {
45996
+ const raw2 = (styles) => (styles ?? []).map((style) => style.rawNode ?? null);
45997
+ const lists = [scheme.fillStyles, scheme.lineStyles, scheme.effectStyles];
45998
+ return JSON.stringify(
45999
+ [scheme.name ?? null, ...lists.map(raw2), raw2(scheme.backgroundFillStyles)],
46000
+ (_key, value) => {
46001
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
46002
+ return value;
46003
+ }
46004
+ const entries = Object.entries(value);
46005
+ const isAttribute = ([key2]) => key2.startsWith("@_");
46006
+ const attributes3 = entries.filter(isAttribute).sort(([x], [y]) => x < y ? -1 : 1);
46007
+ return Object.fromEntries([...attributes3, ...entries.filter((entry2) => !isAttribute(entry2))]);
46008
+ }
46009
+ );
46010
+ }
45953
46011
  function wrapFormatSchemeXml(fmtSchemeXml) {
45954
46012
  return fmtSchemeXml.replace(
45955
46013
  /^<a:fmtScheme/u,
@@ -89516,6 +89574,42 @@ var init_master_save_helpers = __esm({
89516
89574
  }
89517
89575
  });
89518
89576
 
89577
+ // pptx/core/core/runtime/held-format-schemes.ts
89578
+ function partsKey(deckScheme, themePaths) {
89579
+ return JSON.stringify([formatSchemeKey(deckScheme), [...new Set(themePaths)].sort()]);
89580
+ }
89581
+ var HeldFormatSchemes;
89582
+ var init_held_format_schemes = __esm({
89583
+ "pptx/core/core/runtime/held-format-schemes.ts"() {
89584
+ init_theme_effect_schemes();
89585
+ HeldFormatSchemes = class {
89586
+ elements = /* @__PURE__ */ new Map();
89587
+ partsByDeckScheme = /* @__PURE__ */ new Map();
89588
+ /** Keep `element`, which `scheme` was parsed from. */
89589
+ hold(scheme, element) {
89590
+ this.elements.set(formatSchemeKey(scheme), structuredClone(element));
89591
+ }
89592
+ /** The element `scheme` was parsed from, if one was held. */
89593
+ element(scheme) {
89594
+ return this.elements.get(formatSchemeKey(scheme));
89595
+ }
89596
+ /** What each part in `parts` held while the deck's scheme was `deckScheme`. */
89597
+ holdParts(deckScheme, parts) {
89598
+ if (parts.size > 0) {
89599
+ this.partsByDeckScheme.set(partsKey(deckScheme, [...parts.keys()]), new Map(parts));
89600
+ }
89601
+ }
89602
+ /**
89603
+ * The element each of `themePaths` held the last time the deck's scheme was `deckScheme` over
89604
+ * exactly those parts, if known.
89605
+ */
89606
+ parts(deckScheme, themePaths) {
89607
+ return this.partsByDeckScheme.get(partsKey(deckScheme, themePaths));
89608
+ }
89609
+ };
89610
+ }
89611
+ });
89612
+
89519
89613
  // pptx/core/builders/fluent/PptxXmlBuilder.ts
89520
89614
  var PptxXmlBuilder, PptxSlideBuilder, PptxSlideElementsBuilder, PptxSlideNotesBuilder;
89521
89615
  var init_PptxXmlBuilder = __esm({
@@ -115051,6 +115145,11 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115051
115145
  const upSegments = Array.from({ length: fromParts.length }).fill("..");
115052
115146
  return [...upSegments, ...toParts].join("/");
115053
115147
  }
115148
+ /**
115149
+ * Point a slide master's theme relationship at `themePath`.
115150
+ *
115151
+ * @returns whether the master had a theme relationship to rewrite
115152
+ */
115054
115153
  async setMasterThemeRelationship(masterPath, themePath) {
115055
115154
  const relsPath2 = masterPath.replace(
115056
115155
  /ppt\/slideMasters\/(slideMaster\d+)\.xml/,
@@ -115058,7 +115157,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115058
115157
  );
115059
115158
  const relsFile = this.zip.file(relsPath2);
115060
115159
  if (!relsFile) {
115061
- return;
115160
+ return false;
115062
115161
  }
115063
115162
  const relsXml = await relsFile.async("string");
115064
115163
  const relsData = this.parser.parse(relsXml);
@@ -115066,28 +115165,13 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115066
115165
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
115067
115166
  const themeRel = relationships3.find((rel) => String(rel["@_Type"] || "").includes("/theme"));
115068
115167
  if (!themeRel) {
115069
- return;
115168
+ return false;
115070
115169
  }
115071
115170
  themeRel["@_Target"] = this.buildRelativeTargetPath(masterPath, themePath);
115072
115171
  relRoot["Relationship"] = relationships3;
115073
115172
  relsData["Relationships"] = relRoot;
115074
115173
  this.zip.file(relsPath2, this.builder.build(relsData));
115075
- }
115076
- async setPresentationTheme(themePath, applyToAllMasters = true) {
115077
- const normalizedThemePath = themePath.trim().replace(/\\/g, "/");
115078
- if (!normalizedThemePath.startsWith("ppt/theme/")) {
115079
- return;
115080
- }
115081
- const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
115082
- if (!masterFiles || masterFiles.length === 0) {
115083
- return;
115084
- }
115085
- const targetMasters = applyToAllMasters ? masterFiles : [masterFiles[0]];
115086
- await Promise.all(
115087
- targetMasters.map(async (masterFile) => {
115088
- await this.setMasterThemeRelationship(masterFile.name, normalizedThemePath);
115089
- })
115090
- );
115174
+ return true;
115091
115175
  }
115092
115176
  /** The text of a package part, or `undefined` when the package has no such part. */
115093
115177
  async readPartText(path4) {
@@ -115417,8 +115501,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115417
115501
  this.masterXmlMap.set(path4, data);
115418
115502
  }
115419
115503
  const masterCSldName = (xmlAttr(sldMaster["p:cSld"], "name") ?? "").trim();
115420
- const bg = sldMaster["p:cSld"]?.["p:bg"];
115421
- const backgroundColor = this.parseBackgroundColor(bg);
115422
115504
  const spTree = sldMaster["p:cSld"]?.["p:spTree"];
115423
115505
  const placeholders = this.extractPlaceholderList(spTree);
115424
115506
  let preserve;
@@ -115472,7 +115554,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115472
115554
  results.push({
115473
115555
  path: path4,
115474
115556
  name: masterCSldName.length > 0 ? masterCSldName : void 0,
115475
- backgroundColor,
115476
115557
  themePath,
115477
115558
  layoutPaths: layoutPaths.length > 0 ? layoutPaths : void 0,
115478
115559
  layouts: layouts.length > 0 ? layouts : void 0,
@@ -115610,11 +115691,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115610
115691
  layout.clrMapOverride = overrideMap;
115611
115692
  }
115612
115693
  }
115613
- const bg = xmlPath(sldLayout, "p:cSld", "p:bg");
115614
- const bgColor = this.parseBackgroundColor(bg);
115615
- if (bgColor) {
115616
- layout.backgroundColor = bgColor;
115617
- }
115618
115694
  const spTree = xmlPath(sldLayout, "p:cSld", "p:spTree");
115619
115695
  const placeholders = this.extractPlaceholderList(spTree);
115620
115696
  if (placeholders.length > 0) {
@@ -130885,7 +130961,23 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
130885
130961
  }
130886
130962
  return this.isStrictOoxml ? "strict" : "transitional";
130887
130963
  }
130964
+ /** The save running now, or the last one: see {@link save}. */
130965
+ saveQueue = Promise.resolve();
130966
+ /**
130967
+ * Saves run one at a time. A save rewrites `this.zip` in place across many awaits and moves
130968
+ * per-part baselines (slide fingerprints, chart data, pending chart updates) while it runs, so
130969
+ * a second save that starts mid-way (a viewer's autosave snapshot firing during the user's own
130970
+ * save) read half-written state: it skipped the slide as unchanged and wrote the chart part's
130971
+ * original XML back over the edit, in both outputs. Each save now waits for the one before it;
130972
+ * one that fails does not hold up the next.
130973
+ */
130888
130974
  async save(slides, options) {
130975
+ const run2 = this.saveQueue.then(() => this.saveNow(slides, options));
130976
+ this.saveQueue = run2.catch(() => void 0);
130977
+ return run2;
130978
+ }
130979
+ /** One save, with the package to itself; callers go through {@link save}. */
130980
+ async saveNow(slides, options) {
130889
130981
  validateSlideGeometry(slides);
130890
130982
  const templates = [
130891
130983
  ...options?.slideMasters ?? [],
@@ -130903,7 +130995,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
130903
130995
  return this.saveAsLegacyPpt(
130904
130996
  slides,
130905
130997
  options,
130906
- () => this.save(slides, {
130998
+ () => this.saveNow(slides, {
130907
130999
  ...options,
130908
131000
  pptPassword: void 0,
130909
131001
  outputFormat: "pptx",
@@ -135890,6 +135982,25 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
135890
135982
  }
135891
135983
  return void 0;
135892
135984
  }
135985
+ /**
135986
+ * The colour a slide master or layout paints from its own `p:bg`, resolved exactly as a
135987
+ * slide's background is: through the active master's colour map and format scheme, with
135988
+ * `clrMapOverride` (a layout's `p:clrMapOvr`, or `null`) taking precedence. The caller makes
135989
+ * the part's master active first; a master's `bgRef` on `bg1` means `dk1` under a dark
135990
+ * `p:clrMap`, which no other state can tell.
135991
+ */
135992
+ extractTemplateBackgroundColor(partXml, rootTag, clrMapOverride) {
135993
+ if (!partXml) {
135994
+ return void 0;
135995
+ }
135996
+ const previousOverride = this.currentSlideClrMapOverride;
135997
+ this.currentSlideClrMapOverride = clrMapOverride;
135998
+ try {
135999
+ return this.extractBackgroundColor(partXml, rootTag);
136000
+ } finally {
136001
+ this.currentSlideClrMapOverride = previousOverride;
136002
+ }
136003
+ }
135893
136004
  /**
135894
136005
  * Composite a resolved background colour with its `a:alpha` (or
135895
136006
  * `a:alphaMod`/`a:alphaOff`) opacity onto opaque white.
@@ -136456,6 +136567,31 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
136456
136567
  const masterFormatScheme = this.masterThemeFormatSchemes.get(masterPath);
136457
136568
  this.themeFormatScheme = masterFormatScheme ?? this.globalThemeFormatSchemeSnapshot;
136458
136569
  }
136570
+ /**
136571
+ * Run `work` with one master's theme state active and no slide colour-map override, then
136572
+ * put back whatever state was active before, so a part parsed on request (a layout preview)
136573
+ * resolves through its own master without disturbing the caller's.
136574
+ */
136575
+ async withMasterThemeState(masterPath, work) {
136576
+ const saved = {
136577
+ colors: this.themeColorMap,
136578
+ fonts: this.themeFontMap,
136579
+ format: this.themeFormatScheme,
136580
+ clrMap: this.currentMasterClrMap,
136581
+ slideClrMap: this.currentSlideClrMapOverride
136582
+ };
136583
+ this.applyMasterThemeState(masterPath);
136584
+ this.currentSlideClrMapOverride = null;
136585
+ try {
136586
+ return await work();
136587
+ } finally {
136588
+ this.themeColorMap = saved.colors;
136589
+ this.themeFontMap = saved.fonts;
136590
+ this.themeFormatScheme = saved.format;
136591
+ this.currentMasterClrMap = saved.clrMap;
136592
+ this.currentSlideClrMapOverride = saved.slideClrMap;
136593
+ }
136594
+ }
136459
136595
  /**
136460
136596
  * Extract the `p:bg/@showAnimation` flag from a slide's XML.
136461
136597
  * Returns `true` when the background should animate, `false` when
@@ -137370,18 +137506,33 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
137370
137506
  this.rememberUnparsedMasterNodes(partPath, spTree, part.elements);
137371
137507
  }
137372
137508
  /**
137373
- * Populate `elements` on every slide master and on each of its layouts.
137509
+ * Resolve the background of every slide master and of each of its layouts,
137510
+ * and populate their `elements`.
137374
137511
  *
137375
- * Scheme colours on a master's own shapes must resolve through that
137376
- * master's colour map and theme, so the active master state is switched
137377
- * per part and reset to the deck-wide snapshot afterwards.
137512
+ * Scheme colours on a master, its own `p:bgRef` included, must resolve
137513
+ * through that master's colour map and theme, so the active master state is
137514
+ * switched per part and reset to the deck-wide snapshot afterwards.
137378
137515
  */
137379
137516
  async enrichSlideMasterElements(masters) {
137380
137517
  for (const master of masters) {
137381
137518
  try {
137382
137519
  this.applyMasterThemeState(master.path);
137520
+ master.backgroundColor = this.extractTemplateBackgroundColor(
137521
+ this.masterXmlMap.get(master.path),
137522
+ "p:sldMaster",
137523
+ null
137524
+ );
137383
137525
  await this.enrichMasterPartElements(master, "p:sldMaster");
137384
137526
  for (const layout of master.layouts ?? []) {
137527
+ const layoutXml3 = this.layoutXmlMap.get(layout.path);
137528
+ const backgroundColor = this.extractTemplateBackgroundColor(
137529
+ layoutXml3,
137530
+ "p:sldLayout",
137531
+ layoutXml3 ? this.parseLayoutClrMapOverride(layoutXml3) : null
137532
+ );
137533
+ if (backgroundColor) {
137534
+ layout.backgroundColor = backgroundColor;
137535
+ }
137385
137536
  await this.enrichMasterPartElements(layout, "p:sldLayout");
137386
137537
  }
137387
137538
  } catch (e) {
@@ -137652,20 +137803,23 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
137652
137803
  this.layoutCache.delete(layoutPath);
137653
137804
  this.eagerDecodeImages = true;
137654
137805
  }
137655
- let elements2;
137806
+ const masterPath = this.resolveMasterPathForLayout(layoutPath);
137807
+ let parsed;
137656
137808
  try {
137657
- elements2 = await this.getLayoutElementsByPath(layoutPath);
137809
+ parsed = await this.withMasterThemeState(masterPath, async () => ({
137810
+ elements: await this.getLayoutElementsByPath(layoutPath),
137811
+ background: this.resolveLayoutPreviewBackground(layoutXml3, masterPath)
137812
+ }));
137658
137813
  } finally {
137659
137814
  this.eagerDecodeImages = previousEagerDecode;
137660
137815
  }
137661
137816
  const cSld = xmlPath(layoutXml3, "p:sldLayout", "p:cSld");
137662
- const background = this.resolveLayoutPreviewBackground(layoutPath, cSld);
137663
137817
  const preview = {
137664
137818
  path: layoutPath,
137665
137819
  width: this.rawSlideWidthEmu / EMU_PER_PX,
137666
137820
  height: this.rawSlideHeightEmu / EMU_PER_PX,
137667
- ...background,
137668
- elements: elements2,
137821
+ ...parsed.background,
137822
+ elements: parsed.elements,
137669
137823
  placeholders: this.extractPlaceholderList(xmlChild(cSld, "p:spTree"))
137670
137824
  };
137671
137825
  this.layoutPreviewCache.set(layoutPath, preview);
@@ -137701,19 +137855,18 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
137701
137855
  }
137702
137856
  /**
137703
137857
  * Resolve the background a layout thumbnail should paint, falling back to
137704
- * the layout's master when the layout itself declares none.
137858
+ * the layout's master when the layout itself declares none. Runs with the
137859
+ * master active; the layout's own colour map override applies to an
137860
+ * inherited background too, as a slide's does.
137705
137861
  */
137706
- resolveLayoutPreviewBackground(layoutPath, cSld) {
137707
- const ownBackground = this.parseBackgroundColor(xmlChild(cSld, "p:bg"));
137708
- if (ownBackground) {
137709
- return { backgroundColor: ownBackground };
137710
- }
137711
- const masterPath = this.resolveMasterPathForLayout(layoutPath);
137712
- const masterXml = masterPath ? this.masterXmlMap.get(masterPath) : void 0;
137713
- const masterBackground = this.parseBackgroundColor(
137714
- xmlChild(xmlPath(masterXml, "p:sldMaster", "p:cSld"), "p:bg")
137862
+ resolveLayoutPreviewBackground(layoutXml3, masterPath) {
137863
+ const clrMapOverride = this.parseLayoutClrMapOverride(layoutXml3);
137864
+ const backgroundColor = this.extractTemplateBackgroundColor(layoutXml3, "p:sldLayout", clrMapOverride) ?? this.extractTemplateBackgroundColor(
137865
+ masterPath ? this.masterXmlMap.get(masterPath) : void 0,
137866
+ "p:sldMaster",
137867
+ clrMapOverride
137715
137868
  );
137716
- return masterBackground ? { backgroundColor: masterBackground } : {};
137869
+ return backgroundColor ? { backgroundColor } : {};
137717
137870
  }
137718
137871
  };
137719
137872
  }
@@ -138521,15 +138674,298 @@ var init_PptxHandlerRuntimeThemeRefResolution = __esm({
138521
138674
  }
138522
138675
  });
138523
138676
 
138677
+ // pptx/core/core/runtime/theme-scheme-edit.ts
138678
+ function normalizeHex6(hex3) {
138679
+ return hex3.replace(/^#/, "").toUpperCase();
138680
+ }
138681
+ function buildSrgbClrNode(hex3) {
138682
+ return { "a:srgbClr": { "@_val": normalizeHex6(hex3) } };
138683
+ }
138684
+ function themeElementsOf(data) {
138685
+ const root = data["a:theme"];
138686
+ return root?.["a:themeElements"];
138687
+ }
138688
+ function applyColorSchemeToThemeXml(data, colorScheme) {
138689
+ const themeElements = themeElementsOf(data);
138690
+ if (!themeElements) {
138691
+ return false;
138692
+ }
138693
+ const clrScheme = themeElements["a:clrScheme"] ?? {};
138694
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138695
+ clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
138696
+ }
138697
+ themeElements["a:clrScheme"] = clrScheme;
138698
+ return true;
138699
+ }
138700
+ function applyLatinTypeface(group, latin) {
138701
+ const font = group ?? {};
138702
+ font["a:latin"] = { "@_typeface": latin };
138703
+ if (!font["a:ea"]) {
138704
+ font["a:ea"] = { "@_typeface": "" };
138705
+ }
138706
+ if (!font["a:cs"]) {
138707
+ font["a:cs"] = { "@_typeface": "" };
138708
+ }
138709
+ return font;
138710
+ }
138711
+ function applyFontSchemeToThemeXml(data, fontScheme) {
138712
+ const themeElements = themeElementsOf(data);
138713
+ if (!themeElements) {
138714
+ return false;
138715
+ }
138716
+ const fntScheme = themeElements["a:fontScheme"] ?? {};
138717
+ if (fontScheme.majorFont?.latin) {
138718
+ fntScheme["a:majorFont"] = applyLatinTypeface(
138719
+ fntScheme["a:majorFont"],
138720
+ fontScheme.majorFont.latin
138721
+ );
138722
+ }
138723
+ if (fontScheme.minorFont?.latin) {
138724
+ fntScheme["a:minorFont"] = applyLatinTypeface(
138725
+ fntScheme["a:minorFont"],
138726
+ fontScheme.minorFont.latin
138727
+ );
138728
+ }
138729
+ themeElements["a:fontScheme"] = fntScheme;
138730
+ return true;
138731
+ }
138732
+ function applyColorSchemeToMap(map, colorScheme, clrMap) {
138733
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138734
+ map[key2] = normalizeHex6(colorScheme[key2]);
138735
+ }
138736
+ for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
138737
+ const target = clrMap?.[alias] ?? defaultTarget;
138738
+ const resolved = map[target];
138739
+ if (resolved !== void 0) {
138740
+ map[alias] = resolved;
138741
+ }
138742
+ }
138743
+ }
138744
+ function applyFontSchemeToMap(map, fontScheme) {
138745
+ if (fontScheme.majorFont?.latin) {
138746
+ map["mj-lt"] = fontScheme.majorFont.latin;
138747
+ map["mj-ea"] = fontScheme.majorFont.latin;
138748
+ map["mj-cs"] = fontScheme.majorFont.latin;
138749
+ }
138750
+ if (fontScheme.minorFont?.latin) {
138751
+ map["mn-lt"] = fontScheme.minorFont.latin;
138752
+ map["mn-ea"] = fontScheme.minorFont.latin;
138753
+ map["mn-cs"] = fontScheme.minorFont.latin;
138754
+ }
138755
+ }
138756
+ var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
138757
+ var init_theme_scheme_edit = __esm({
138758
+ "pptx/core/core/runtime/theme-scheme-edit.ts"() {
138759
+ THEME_COLOR_SCHEME_KEYS2 = [
138760
+ "dk1",
138761
+ "lt1",
138762
+ "dk2",
138763
+ "lt2",
138764
+ "accent1",
138765
+ "accent2",
138766
+ "accent3",
138767
+ "accent4",
138768
+ "accent5",
138769
+ "accent6",
138770
+ "hlink",
138771
+ "folHlink"
138772
+ ];
138773
+ DEFAULT_CLR_MAP_ALIASES = {
138774
+ tx1: "dk1",
138775
+ bg1: "lt1",
138776
+ tx2: "dk2",
138777
+ bg2: "lt2"
138778
+ };
138779
+ }
138780
+ });
138781
+
138782
+ // pptx/core/core/runtime/theme-part-model.ts
138783
+ function colorSchemeFromMap(colorMap) {
138784
+ const scheme = {};
138785
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138786
+ scheme[key2] = colorMap[key2] || "";
138787
+ }
138788
+ return scheme;
138789
+ }
138790
+ function fontGroup(fontMap, prefix, byScript) {
138791
+ const latin = fontMap[`${prefix}-lt`];
138792
+ const eastAsia = fontMap[`${prefix}-ea`];
138793
+ const complexScript = fontMap[`${prefix}-cs`];
138794
+ return {
138795
+ ...latin ? { latin } : {},
138796
+ ...eastAsia ? { eastAsia } : {},
138797
+ ...complexScript ? { complexScript } : {},
138798
+ ...Object.keys(byScript).length > 0 ? { byScript: { ...byScript } } : {}
138799
+ };
138800
+ }
138801
+ function fontSchemeFromMap(fontMap, majorByScript, minorByScript) {
138802
+ return {
138803
+ majorFont: fontGroup(fontMap, "mj", majorByScript),
138804
+ minorFont: fontGroup(fontMap, "mn", minorByScript)
138805
+ };
138806
+ }
138807
+ var init_theme_part_model = __esm({
138808
+ "pptx/core/core/runtime/theme-part-model.ts"() {
138809
+ init_theme_scheme_edit();
138810
+ }
138811
+ });
138812
+
138813
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts
138814
+ var FONT_SLOTS, PptxHandlerRuntime84;
138815
+ var init_PptxHandlerRuntimeThemePartModel = __esm({
138816
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts"() {
138817
+ init_PptxHandlerRuntimeThemeRefResolution();
138818
+ init_theme_part_model();
138819
+ init_theme_scheme_edit();
138820
+ FONT_SLOTS = [
138821
+ ["mj", "a:majorFont"],
138822
+ ["mn", "a:minorFont"]
138823
+ ];
138824
+ PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
138825
+ /** Parse one theme part's XML. Side-effect free. */
138826
+ parseThemePartXml(themeXml3) {
138827
+ const themeData = this.parser.parse(themeXml3);
138828
+ const themeRoot = themeData["a:theme"];
138829
+ const themeElements = themeRoot?.["a:themeElements"];
138830
+ const colorScheme = themeElements?.["a:clrScheme"];
138831
+ const fontScheme = themeElements?.["a:fontScheme"];
138832
+ const fmtScheme = themeElements?.["a:fmtScheme"];
138833
+ const text2 = (value) => String(value || "").trim() || void 0;
138834
+ const colorMap = { ...this.getDefaultSchemeColorMap() };
138835
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138836
+ const parsed = this.parseColorChoice(colorScheme?.[`a:${key2}`]);
138837
+ if (parsed) {
138838
+ colorMap[key2] = parsed;
138839
+ }
138840
+ }
138841
+ const fontMap = {};
138842
+ const typeface = (node) => this.normalizeTypefaceToken(String(node?.["@_typeface"] || ""));
138843
+ for (const [prefix, tag] of FONT_SLOTS) {
138844
+ const group = fontScheme?.[tag];
138845
+ const latin = typeface(group?.["a:latin"]);
138846
+ if (latin) {
138847
+ fontMap[`${prefix}-lt`] = latin;
138848
+ fontMap[`${prefix}-ea`] = latin;
138849
+ fontMap[`${prefix}-cs`] = latin;
138850
+ }
138851
+ const eastAsia = typeface(group?.["a:ea"]);
138852
+ if (eastAsia) {
138853
+ fontMap[`${prefix}-ea`] = eastAsia;
138854
+ }
138855
+ const complexScript = typeface(group?.["a:cs"]);
138856
+ if (complexScript) {
138857
+ fontMap[`${prefix}-cs`] = complexScript;
138858
+ }
138859
+ }
138860
+ const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
138861
+ const objectDefaults = objectDefaultsNode && {
138862
+ spDef: objectDefaultsNode["a:spDef"],
138863
+ lnDef: objectDefaultsNode["a:lnDef"],
138864
+ txDef: objectDefaultsNode["a:txDef"]
138865
+ };
138866
+ const hasObjectDefaults = objectDefaults !== void 0 && (objectDefaults.spDef !== void 0 || objectDefaults.lnDef !== void 0 || objectDefaults.txDef !== void 0);
138867
+ return {
138868
+ name: text2(themeRoot?.["@_name"]),
138869
+ colorSchemeName: text2(colorScheme?.["@_name"]),
138870
+ fontSchemeName: text2(fontScheme?.["@_name"]),
138871
+ colorMap,
138872
+ fontMap,
138873
+ // Per-script fonts (`<a:font script="Hans|Hant|Arab|...">`): M4.
138874
+ majorFontScripts: this.collectFontScriptOverrides(
138875
+ fontScheme?.["a:majorFont"]
138876
+ ),
138877
+ minorFontScripts: this.collectFontScriptOverrides(
138878
+ fontScheme?.["a:minorFont"]
138879
+ ),
138880
+ // objectDefaults: M5.
138881
+ objectDefaults: hasObjectDefaults ? objectDefaults : void 0,
138882
+ extraClrSchemeLst: themeRoot?.["a:extraClrSchemeLst"],
138883
+ custClrLst: themeRoot?.["a:custClrLst"],
138884
+ extLst: themeRoot?.["a:extLst"],
138885
+ formatScheme: fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0
138886
+ };
138887
+ }
138888
+ /**
138889
+ * Record a parsed part under its path: its original XML (byte-stable passthrough on save,
138890
+ * C-H3), its names, per-script fonts and the raw subtrees the save re-emits.
138891
+ */
138892
+ cacheThemePartModel(themePath, themeXml3, model) {
138893
+ this.originalThemeXmlByPath.set(themePath, themeXml3);
138894
+ const keyed = [
138895
+ [this.masterThemeNames, model.name],
138896
+ [this.masterThemeColorSchemeNames, model.colorSchemeName],
138897
+ [this.masterThemeFontSchemeNames, model.fontSchemeName],
138898
+ [this.masterThemeObjectDefaults, model.objectDefaults],
138899
+ [this.masterThemeExtraClrSchemeLst, model.extraClrSchemeLst],
138900
+ [this.masterThemeCustClrLst, model.custClrLst],
138901
+ [this.masterThemeExtLst, model.extLst]
138902
+ ];
138903
+ for (const [map, value] of keyed) {
138904
+ if (value !== void 0) {
138905
+ map.set(themePath, value);
138906
+ }
138907
+ }
138908
+ if (Object.keys(model.majorFontScripts).length > 0) {
138909
+ this.masterThemeMajorFontScripts.set(themePath, model.majorFontScripts);
138910
+ }
138911
+ if (Object.keys(model.minorFontScripts).length > 0) {
138912
+ this.masterThemeMinorFontScripts.set(themePath, model.minorFontScripts);
138913
+ }
138914
+ }
138915
+ /**
138916
+ * Parse `<a:font script="..." typeface="..."/>` children of a major or minor font node into a
138917
+ * `script -> typeface` dictionary. fast-xml-parser collapses repeated tags into arrays, so the
138918
+ * array form is walked regardless of how many siblings are present. Phase 4 Stream A / M4.
138919
+ */
138920
+ collectFontScriptOverrides(fontNode) {
138921
+ const overrides = {};
138922
+ if (!fontNode) {
138923
+ return overrides;
138924
+ }
138925
+ const fontEntries = this.ensureArray(fontNode["a:font"]);
138926
+ for (const entry2 of fontEntries) {
138927
+ const script = String(entry2?.["@_script"] || "").trim();
138928
+ const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
138929
+ if (script && typeface) {
138930
+ overrides[script] = typeface;
138931
+ }
138932
+ }
138933
+ return overrides;
138934
+ }
138935
+ /**
138936
+ * The colour, font and format schemes and name of one theme part in the package, as the part holds
138937
+ * them now (a scheme edit already written to it included). Reads only: the loaded theme, the
138938
+ * masters and what a save writes are unchanged. `undefined` when the package has no such part.
138939
+ */
138940
+ async getThemePartSchemes(themePath) {
138941
+ const path4 = themePath.trim().replace(/\\/g, "/");
138942
+ const themeXml3 = await this.zip.file(path4)?.async("string");
138943
+ if (themeXml3 === void 0) {
138944
+ return void 0;
138945
+ }
138946
+ const model = this.parseThemePartXml(themeXml3);
138947
+ return {
138948
+ path: path4,
138949
+ ...model.name ? { name: model.name } : {},
138950
+ colorScheme: colorSchemeFromMap(model.colorMap),
138951
+ fontScheme: fontSchemeFromMap(model.fontMap, model.majorFontScripts, model.minorFontScripts),
138952
+ ...model.formatScheme ? { formatScheme: model.formatScheme } : {}
138953
+ };
138954
+ }
138955
+ };
138956
+ }
138957
+ });
138958
+
138524
138959
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts
138525
138960
  function isPresentationThemePartPath(path4) {
138526
138961
  return /^ppt\/theme\/(?!themeOverride)[^/]+\.xml$/iu.test(path4);
138527
138962
  }
138528
- var PptxHandlerRuntime84;
138963
+ var PptxHandlerRuntime85;
138529
138964
  var init_PptxHandlerRuntimeThemeLoading = __esm({
138530
138965
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts"() {
138531
- init_PptxHandlerRuntimeThemeRefResolution();
138532
- PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
138966
+ init_PptxHandlerRuntimeThemePartModel();
138967
+ init_theme_part_model();
138968
+ PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
138533
138969
  async resolvePrimaryThemePath() {
138534
138970
  const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
138535
138971
  if (!masterFiles || masterFiles.length === 0) {
@@ -138605,42 +139041,12 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138605
139041
  if (!hasColors && !hasFonts) {
138606
139042
  return void 0;
138607
139043
  }
138608
- let colorScheme;
138609
- if (hasColors) {
138610
- colorScheme = {
138611
- dk1: this.themeColorMap["dk1"] || "",
138612
- lt1: this.themeColorMap["lt1"] || "",
138613
- dk2: this.themeColorMap["dk2"] || "",
138614
- lt2: this.themeColorMap["lt2"] || "",
138615
- accent1: this.themeColorMap["accent1"] || "",
138616
- accent2: this.themeColorMap["accent2"] || "",
138617
- accent3: this.themeColorMap["accent3"] || "",
138618
- accent4: this.themeColorMap["accent4"] || "",
138619
- accent5: this.themeColorMap["accent5"] || "",
138620
- accent6: this.themeColorMap["accent6"] || "",
138621
- hlink: this.themeColorMap["hlink"] || "",
138622
- folHlink: this.themeColorMap["folHlink"] || ""
138623
- };
138624
- }
138625
- let fontScheme;
138626
- if (hasFonts) {
138627
- const majorByScript = this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts);
138628
- const minorByScript = this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts);
138629
- fontScheme = {
138630
- majorFont: {
138631
- latin: this.themeFontMap["mj-lt"],
138632
- eastAsia: this.themeFontMap["mj-ea"],
138633
- complexScript: this.themeFontMap["mj-cs"],
138634
- ...Object.keys(majorByScript).length > 0 ? { byScript: majorByScript } : {}
138635
- },
138636
- minorFont: {
138637
- latin: this.themeFontMap["mn-lt"],
138638
- eastAsia: this.themeFontMap["mn-ea"],
138639
- complexScript: this.themeFontMap["mn-cs"],
138640
- ...Object.keys(minorByScript).length > 0 ? { byScript: minorByScript } : {}
138641
- }
138642
- };
138643
- }
139044
+ const colorScheme = hasColors ? colorSchemeFromMap(this.themeColorMap) : void 0;
139045
+ const fontScheme = hasFonts ? fontSchemeFromMap(
139046
+ this.themeFontMap,
139047
+ this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts),
139048
+ this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts)
139049
+ ) : void 0;
138644
139050
  return {
138645
139051
  colorScheme,
138646
139052
  fontScheme,
@@ -138717,134 +139123,10 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138717
139123
  return null;
138718
139124
  }
138719
139125
  const themeXml3 = await themeFile.async("string");
138720
- this.originalThemeXmlByPath.set(themePath, themeXml3);
138721
- const themeData = this.parser.parse(themeXml3);
138722
- const themeRoot = themeData["a:theme"];
138723
- const themeElements = themeRoot?.["a:themeElements"];
138724
- const colorScheme = themeElements?.["a:clrScheme"];
138725
- const fontScheme = themeElements?.["a:fontScheme"];
138726
- const fmtScheme = themeElements?.["a:fmtScheme"];
138727
- const themeName = String(themeRoot?.["@_name"] || "").trim();
138728
- if (themeName) {
138729
- this.masterThemeNames.set(themePath, themeName);
138730
- }
138731
- const colorSchemeName = String(colorScheme?.["@_name"] || "").trim();
138732
- if (colorSchemeName) {
138733
- this.masterThemeColorSchemeNames.set(themePath, colorSchemeName);
138734
- }
138735
- const fontSchemeName = String(fontScheme?.["@_name"] || "").trim();
138736
- if (fontSchemeName) {
138737
- this.masterThemeFontSchemeNames.set(themePath, fontSchemeName);
138738
- }
138739
- const defaultMap = this.getDefaultSchemeColorMap();
138740
- const colorMap = { ...defaultMap };
138741
- if (colorScheme) {
138742
- const schemeKeys = [
138743
- "dk1",
138744
- "lt1",
138745
- "dk2",
138746
- "lt2",
138747
- "accent1",
138748
- "accent2",
138749
- "accent3",
138750
- "accent4",
138751
- "accent5",
138752
- "accent6",
138753
- "hlink",
138754
- "folHlink"
138755
- ];
138756
- for (const key2 of schemeKeys) {
138757
- const colorNode = colorScheme[`a:${key2}`];
138758
- const parsed = this.parseColorChoice(colorNode);
138759
- if (parsed) {
138760
- colorMap[key2] = parsed;
138761
- }
138762
- }
138763
- }
138764
- const majorFontNode = fontScheme?.["a:majorFont"];
138765
- const minorFontNode = fontScheme?.["a:minorFont"];
138766
- const majorLatin = majorFontNode?.["a:latin"];
138767
- const minorLatin = minorFontNode?.["a:latin"];
138768
- const majorFont = this.normalizeTypefaceToken(String(majorLatin?.["@_typeface"] || ""));
138769
- const minorFont = this.normalizeTypefaceToken(String(minorLatin?.["@_typeface"] || ""));
138770
- const fontMap = {};
138771
- if (majorFont) {
138772
- fontMap["mj-lt"] = majorFont;
138773
- fontMap["mj-ea"] = majorFont;
138774
- fontMap["mj-cs"] = majorFont;
138775
- }
138776
- if (minorFont) {
138777
- fontMap["mn-lt"] = minorFont;
138778
- fontMap["mn-ea"] = minorFont;
138779
- fontMap["mn-cs"] = minorFont;
138780
- }
138781
- const majorEa = this.normalizeTypefaceToken(
138782
- String(majorFontNode?.["a:ea"]?.["@_typeface"] || "")
138783
- );
138784
- if (majorEa) {
138785
- fontMap["mj-ea"] = majorEa;
138786
- }
138787
- const majorCs = this.normalizeTypefaceToken(
138788
- String(majorFontNode?.["a:cs"]?.["@_typeface"] || "")
138789
- );
138790
- if (majorCs) {
138791
- fontMap["mj-cs"] = majorCs;
138792
- }
138793
- const minorEa = this.normalizeTypefaceToken(
138794
- String(minorFontNode?.["a:ea"]?.["@_typeface"] || "")
138795
- );
138796
- if (minorEa) {
138797
- fontMap["mn-ea"] = minorEa;
138798
- }
138799
- const minorCs = this.normalizeTypefaceToken(
138800
- String(minorFontNode?.["a:cs"]?.["@_typeface"] || "")
138801
- );
138802
- if (minorCs) {
138803
- fontMap["mn-cs"] = minorCs;
138804
- }
138805
- const majorScripts = this.collectFontScriptOverrides(majorFontNode);
138806
- if (Object.keys(majorScripts).length > 0) {
138807
- this.masterThemeMajorFontScripts.set(themePath, majorScripts);
138808
- }
138809
- const minorScripts = this.collectFontScriptOverrides(minorFontNode);
138810
- if (Object.keys(minorScripts).length > 0) {
138811
- this.masterThemeMinorFontScripts.set(themePath, minorScripts);
138812
- }
138813
- const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
138814
- if (objectDefaultsNode) {
138815
- const od = {
138816
- spDef: objectDefaultsNode["a:spDef"],
138817
- lnDef: objectDefaultsNode["a:lnDef"],
138818
- txDef: objectDefaultsNode["a:txDef"]
138819
- };
138820
- if (od.spDef !== void 0 || od.lnDef !== void 0 || od.txDef !== void 0) {
138821
- this.masterThemeObjectDefaults.set(themePath, od);
138822
- }
138823
- }
138824
- const extraClrSchemeLst = themeRoot?.["a:extraClrSchemeLst"];
138825
- if (extraClrSchemeLst !== void 0) {
138826
- this.masterThemeExtraClrSchemeLst.set(themePath, extraClrSchemeLst);
138827
- }
138828
- const custClrLst = themeRoot?.["a:custClrLst"];
138829
- if (custClrLst !== void 0) {
138830
- this.masterThemeCustClrLst.set(themePath, custClrLst);
138831
- }
138832
- const themeExtLst = themeRoot?.["a:extLst"];
138833
- if (themeExtLst !== void 0) {
138834
- this.masterThemeExtLst.set(themePath, themeExtLst);
138835
- }
138836
- const formatScheme = fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0;
138837
- return { colorMap, fontMap, formatScheme };
139126
+ const model = this.parseThemePartXml(themeXml3);
139127
+ this.cacheThemePartModel(themePath, themeXml3, model);
139128
+ return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
138838
139129
  }
138839
- /**
138840
- * Parse `<a:font script="…" typeface="…"/>` children of a major or
138841
- * minor font node into a `script -> typeface` dictionary.
138842
- *
138843
- * fast-xml-parser collapses repeated tags into arrays, so iterate
138844
- * over the array form regardless of how many siblings are present.
138845
- *
138846
- * Phase 4 Stream A / M4.
138847
- */
138848
139130
  /**
138849
139131
  * Flatten a per-theme-path script-override map (`themePath -> {script ->
138850
139132
  * typeface}`) into a single `{script -> typeface}` lookup for
@@ -138862,21 +139144,6 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138862
139144
  }
138863
139145
  return aggregate;
138864
139146
  }
138865
- collectFontScriptOverrides(fontNode) {
138866
- const overrides = {};
138867
- if (!fontNode) {
138868
- return overrides;
138869
- }
138870
- const fontEntries = this.ensureArray(fontNode["a:font"]);
138871
- for (const entry2 of fontEntries) {
138872
- const script = String(entry2?.["@_script"] || "").trim();
138873
- const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
138874
- if (script && typeface) {
138875
- overrides[script] = typeface;
138876
- }
138877
- }
138878
- return overrides;
138879
- }
138880
139147
  /**
138881
139148
  * Resolve the theme file path referenced by a given master's `.rels`.
138882
139149
  * Returns `undefined` when the master has no theme relationship.
@@ -138962,119 +139229,14 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138962
139229
  }
138963
139230
  });
138964
139231
 
138965
- // pptx/core/core/runtime/theme-scheme-edit.ts
138966
- function normalizeHex6(hex3) {
138967
- return hex3.replace(/^#/, "").toUpperCase();
138968
- }
138969
- function buildSrgbClrNode(hex3) {
138970
- return { "a:srgbClr": { "@_val": normalizeHex6(hex3) } };
138971
- }
138972
- function themeElementsOf(data) {
138973
- const root = data["a:theme"];
138974
- return root?.["a:themeElements"];
138975
- }
138976
- function applyColorSchemeToThemeXml(data, colorScheme) {
138977
- const themeElements = themeElementsOf(data);
138978
- if (!themeElements) {
138979
- return false;
138980
- }
138981
- const clrScheme = themeElements["a:clrScheme"] ?? {};
138982
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138983
- clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
138984
- }
138985
- themeElements["a:clrScheme"] = clrScheme;
138986
- return true;
138987
- }
138988
- function applyLatinTypeface(group, latin) {
138989
- const font = group ?? {};
138990
- font["a:latin"] = { "@_typeface": latin };
138991
- if (!font["a:ea"]) {
138992
- font["a:ea"] = { "@_typeface": "" };
138993
- }
138994
- if (!font["a:cs"]) {
138995
- font["a:cs"] = { "@_typeface": "" };
138996
- }
138997
- return font;
138998
- }
138999
- function applyFontSchemeToThemeXml(data, fontScheme) {
139000
- const themeElements = themeElementsOf(data);
139001
- if (!themeElements) {
139002
- return false;
139003
- }
139004
- const fntScheme = themeElements["a:fontScheme"] ?? {};
139005
- if (fontScheme.majorFont?.latin) {
139006
- fntScheme["a:majorFont"] = applyLatinTypeface(
139007
- fntScheme["a:majorFont"],
139008
- fontScheme.majorFont.latin
139009
- );
139010
- }
139011
- if (fontScheme.minorFont?.latin) {
139012
- fntScheme["a:minorFont"] = applyLatinTypeface(
139013
- fntScheme["a:minorFont"],
139014
- fontScheme.minorFont.latin
139015
- );
139016
- }
139017
- themeElements["a:fontScheme"] = fntScheme;
139018
- return true;
139019
- }
139020
- function applyColorSchemeToMap(map, colorScheme, clrMap) {
139021
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
139022
- map[key2] = normalizeHex6(colorScheme[key2]);
139023
- }
139024
- for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
139025
- const target = clrMap?.[alias] ?? defaultTarget;
139026
- const resolved = map[target];
139027
- if (resolved !== void 0) {
139028
- map[alias] = resolved;
139029
- }
139030
- }
139031
- }
139032
- function applyFontSchemeToMap(map, fontScheme) {
139033
- if (fontScheme.majorFont?.latin) {
139034
- map["mj-lt"] = fontScheme.majorFont.latin;
139035
- map["mj-ea"] = fontScheme.majorFont.latin;
139036
- map["mj-cs"] = fontScheme.majorFont.latin;
139037
- }
139038
- if (fontScheme.minorFont?.latin) {
139039
- map["mn-lt"] = fontScheme.minorFont.latin;
139040
- map["mn-ea"] = fontScheme.minorFont.latin;
139041
- map["mn-cs"] = fontScheme.minorFont.latin;
139042
- }
139043
- }
139044
- var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
139045
- var init_theme_scheme_edit = __esm({
139046
- "pptx/core/core/runtime/theme-scheme-edit.ts"() {
139047
- THEME_COLOR_SCHEME_KEYS2 = [
139048
- "dk1",
139049
- "lt1",
139050
- "dk2",
139051
- "lt2",
139052
- "accent1",
139053
- "accent2",
139054
- "accent3",
139055
- "accent4",
139056
- "accent5",
139057
- "accent6",
139058
- "hlink",
139059
- "folHlink"
139060
- ];
139061
- DEFAULT_CLR_MAP_ALIASES = {
139062
- tx1: "dk1",
139063
- bg1: "lt1",
139064
- tx2: "dk2",
139065
- bg2: "lt2"
139066
- };
139067
- }
139068
- });
139069
-
139070
139232
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts
139071
- var THEME_PART_PATTERN, PptxHandlerRuntime85;
139233
+ var THEME_PART_PATTERN, PptxHandlerRuntime86;
139072
139234
  var init_PptxHandlerRuntimeThemeProcessing = __esm({
139073
139235
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts"() {
139074
139236
  init_PptxHandlerRuntimeThemeLoading();
139075
139237
  init_theme_scheme_edit();
139076
139238
  THEME_PART_PATTERN = /^ppt\/theme\/theme\d+\.xml$/;
139077
- PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
139239
+ PptxHandlerRuntime86 = class extends PptxHandlerRuntime85 {
139078
139240
  /**
139079
139241
  * The theme parts an edit should touch, primary theme first.
139080
139242
  *
@@ -139115,8 +139277,9 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139115
139277
  return this.parser.parse(xml);
139116
139278
  }
139117
139279
  /**
139118
- * Parse, edit, and write back every target theme part. Parts the edit
139119
- * cannot apply to (no `a:themeElements`) are left untouched.
139280
+ * Parse, edit, and write back every target theme part (`edit` gets the
139281
+ * part's path too). Parts the edit cannot apply to (no `a:themeElements`)
139282
+ * are left untouched.
139120
139283
  *
139121
139284
  * @returns the paths that were rewritten
139122
139285
  */
@@ -139124,7 +139287,7 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139124
139287
  const written = [];
139125
139288
  for (const path4 of await this.resolveThemeEditTargets(themePaths)) {
139126
139289
  const data = await this.readThemePart(path4);
139127
- if (!data || !edit(data)) {
139290
+ if (!data || !edit(data, path4)) {
139128
139291
  continue;
139129
139292
  }
139130
139293
  this.zip.file(path4, this.builder.build(data));
@@ -139228,15 +139391,90 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139228
139391
  }
139229
139392
  });
139230
139393
 
139394
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts
139395
+ function themePartPath(themePath) {
139396
+ const path4 = themePath.trim().replace(/\\/g, "/");
139397
+ return path4.startsWith("ppt/theme/") ? path4 : void 0;
139398
+ }
139399
+ var SLIDE_MASTER_PART, PptxHandlerRuntime87;
139400
+ var init_PptxHandlerRuntimeThemeSwitching = __esm({
139401
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts"() {
139402
+ init_PptxHandlerRuntimeThemeProcessing();
139403
+ SLIDE_MASTER_PART = /^ppt\/slideMasters\/slideMaster\d+\.xml$/;
139404
+ PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
139405
+ /**
139406
+ * Point the first slide master, or every one, at a theme part already in the package. Does
139407
+ * nothing when the package has no such part.
139408
+ */
139409
+ async setPresentationTheme(themePath, applyToAllMasters = true) {
139410
+ const path4 = themePartPath(themePath);
139411
+ if (!path4 || !this.zip.file(path4)) {
139412
+ return;
139413
+ }
139414
+ const masters = this.zip.file(SLIDE_MASTER_PART);
139415
+ for (const master of applyToAllMasters ? masters : masters.slice(0, 1)) {
139416
+ await this.retargetMasterTheme(master.name, path4);
139417
+ }
139418
+ }
139419
+ /**
139420
+ * Point one slide master at a theme part already in the package (Undo of a theme switch puts
139421
+ * each master back on its own part). Does nothing when the package has no such master or part.
139422
+ */
139423
+ async setSlideMasterTheme(masterPath, themePath) {
139424
+ const path4 = themePartPath(themePath);
139425
+ if (!path4 || !this.zip.file(path4) || !SLIDE_MASTER_PART.test(masterPath)) {
139426
+ return;
139427
+ }
139428
+ if (this.zip.file(masterPath)) {
139429
+ await this.retargetMasterTheme(masterPath, path4);
139430
+ }
139431
+ }
139432
+ async retargetMasterTheme(masterPath, themePath) {
139433
+ if (await this.setMasterThemeRelationship(masterPath, themePath)) {
139434
+ await this.adoptMasterTheme(masterPath, themePath);
139435
+ }
139436
+ }
139437
+ /** Point the runtime's theme state for `masterPath` at the part it now uses. */
139438
+ async adoptMasterTheme(masterPath, themePath) {
139439
+ const themeXml3 = await this.zip.file(themePath)?.async("string");
139440
+ if (themeXml3 === void 0) {
139441
+ return;
139442
+ }
139443
+ const model = this.parseThemePartXml(themeXml3);
139444
+ if (!this.originalThemeXmlByPath.has(themePath)) {
139445
+ this.cacheThemePartModel(themePath, themeXml3, model);
139446
+ }
139447
+ this.masterThemePaths.set(masterPath, themePath);
139448
+ this.masterThemeColorMaps.set(masterPath, { ...model.colorMap });
139449
+ this.masterThemeFontMaps.set(masterPath, { ...model.fontMap });
139450
+ if (model.formatScheme) {
139451
+ this.masterThemeFormatSchemes.set(masterPath, model.formatScheme);
139452
+ } else {
139453
+ this.masterThemeFormatSchemes.delete(masterPath);
139454
+ }
139455
+ if (this.zip.file(SLIDE_MASTER_PART)[0]?.name !== masterPath) {
139456
+ return;
139457
+ }
139458
+ this.themeColorMap = { ...model.colorMap };
139459
+ this.themeFontMap = { ...model.fontMap };
139460
+ this.themeFormatScheme = model.formatScheme;
139461
+ this.globalThemeColorMapSnapshot = { ...model.colorMap };
139462
+ this.globalThemeFontMapSnapshot = { ...model.fontMap };
139463
+ this.globalThemeFormatSchemeSnapshot = model.formatScheme;
139464
+ }
139465
+ };
139466
+ }
139467
+ });
139468
+
139231
139469
  // pptx/core/core/runtime/PptxHandlerRuntimeComments.ts
139232
- var PptxHandlerRuntime86;
139470
+ var PptxHandlerRuntime88;
139233
139471
  var init_PptxHandlerRuntimeComments = __esm({
139234
139472
  "pptx/core/core/runtime/PptxHandlerRuntimeComments.ts"() {
139235
139473
  init_legacy_comment_threading();
139236
139474
  init_modern_comment_xml();
139237
139475
  init_xml_access();
139238
- init_PptxHandlerRuntimeThemeProcessing();
139239
- PptxHandlerRuntime86 = class _PptxHandlerRuntime extends PptxHandlerRuntime85 {
139476
+ init_PptxHandlerRuntimeThemeSwitching();
139477
+ PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
139240
139478
  /**
139241
139479
  * Parse modern threaded comments (PowerPoint 2019+ / Office 365).
139242
139480
  * Modern comments use `p188:cmLst`/`p15:cmLst` roots within
@@ -139465,7 +139703,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139465
139703
  });
139466
139704
 
139467
139705
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts
139468
- var PptxHandlerRuntime87;
139706
+ var PptxHandlerRuntime89;
139469
139707
  var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139470
139708
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts"() {
139471
139709
  init_smartart_color_lists();
@@ -139473,7 +139711,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139473
139711
  init_smart_art_text_helpers();
139474
139712
  init_PptxHandlerRuntimeComments();
139475
139713
  init_smartart_text_paragraphs();
139476
- PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
139714
+ PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
139477
139715
  async readXmlPartByRelationshipId(slidePath, relationshipId2) {
139478
139716
  const normalizedRelationshipId = String(relationshipId2 || "").trim();
139479
139717
  if (normalizedRelationshipId.length === 0) {
@@ -140077,7 +140315,7 @@ var init_smartart_text_style_resolution = __esm({
140077
140315
  });
140078
140316
 
140079
140317
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts
140080
- var PptxHandlerRuntime88;
140318
+ var PptxHandlerRuntime90;
140081
140319
  var init_PptxHandlerRuntimeSmartArtParsing = __esm({
140082
140320
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts"() {
140083
140321
  init_diagram();
@@ -140091,7 +140329,7 @@ var init_PptxHandlerRuntimeSmartArtParsing = __esm({
140091
140329
  init_smartart_style_label_refs();
140092
140330
  init_smartart_text_paragraphs();
140093
140331
  init_smartart_text_style_resolution();
140094
- PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
140332
+ PptxHandlerRuntime90 = class _PptxHandlerRuntime extends PptxHandlerRuntime89 {
140095
140333
  reportIncompleteSmartArtRelationships(graphicFrame, relationshipIds, slidePath) {
140096
140334
  const missing = [
140097
140335
  ["dm", relationshipIds?.dataRelId],
@@ -140486,7 +140724,7 @@ var init_smartart_layout_category = __esm({
140486
140724
  });
140487
140725
 
140488
140726
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts
140489
- var PptxHandlerRuntime89;
140727
+ var PptxHandlerRuntime91;
140490
140728
  var init_PptxHandlerRuntimeSmartArt = __esm({
140491
140729
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts"() {
140492
140730
  init_utils();
@@ -140501,7 +140739,7 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
140501
140739
  init_smartart_text_paragraphs();
140502
140740
  init_smartart_text_style_resolution();
140503
140741
  init_smartart_xml_builders();
140504
- PptxHandlerRuntime89 = class _PptxHandlerRuntime extends PptxHandlerRuntime88 {
140742
+ PptxHandlerRuntime91 = class _PptxHandlerRuntime extends PptxHandlerRuntime90 {
140505
140743
  async getSmartArtDataForGraphicFrame(slidePath, graphicFrame) {
140506
140744
  const graphicData = this.xmlLookupService.getChildByLocalName(
140507
140745
  this.xmlLookupService.getChildByLocalName(graphicFrame, "graphic"),
@@ -140677,12 +140915,12 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
140677
140915
  });
140678
140916
 
140679
140917
  // pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts
140680
- var PptxHandlerRuntime90;
140918
+ var PptxHandlerRuntime92;
140681
140919
  var init_PptxHandlerRuntimeChartDetection = __esm({
140682
140920
  "pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts"() {
140683
140921
  init_chart_multi_level_category_parser();
140684
140922
  init_PptxHandlerRuntimeSmartArt();
140685
- PptxHandlerRuntime90 = class extends PptxHandlerRuntime89 {
140923
+ PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
140686
140924
  detectChartType(plotArea) {
140687
140925
  if (!plotArea) {
140688
140926
  return "unknown";
@@ -140893,14 +141131,14 @@ function parseNumberVal(node) {
140893
141131
  const num4 = Number.parseFloat(String(raw2));
140894
141132
  return Number.isFinite(num4) ? num4 : void 0;
140895
141133
  }
140896
- var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime91;
141134
+ var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime93;
140897
141135
  var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
140898
141136
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsingHelpers.ts"() {
140899
141137
  init_chart_ext_lookup();
140900
141138
  init_chart_pivot_source2();
140901
141139
  init_PptxHandlerRuntimeChartDetection();
140902
141140
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI2 = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
140903
- PptxHandlerRuntime91 = class extends PptxHandlerRuntime90 {
141141
+ PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
140904
141142
  /**
140905
141143
  * Parse `c:plotVisOnly` from the chart root element.
140906
141144
  *
@@ -141160,14 +141398,14 @@ var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
141160
141398
  });
141161
141399
 
141162
141400
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts
141163
- var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime92;
141401
+ var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime94;
141164
141402
  var init_PptxHandlerRuntimeChartExternalData = __esm({
141165
141403
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts"() {
141166
141404
  init_chart_user_shapes_parser();
141167
141405
  init_chart_xlsx_parser();
141168
141406
  init_PptxHandlerRuntimeChartParsingHelpers();
141169
141407
  CHART_USER_SHAPES_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
141170
- PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
141408
+ PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
141171
141409
  /**
141172
141410
  * Parse `c:externalData` from the chart's `c:chartSpace` and resolve
141173
141411
  * the external relationship target from the chart part's .rels file.
@@ -141329,12 +141567,12 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141329
141567
  });
141330
141568
 
141331
141569
  // pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts
141332
- var PptxHandlerRuntime93;
141570
+ var PptxHandlerRuntime95;
141333
141571
  var init_PptxHandlerRuntimeChartColorStyle = __esm({
141334
141572
  "pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts"() {
141335
141573
  init_chart_style_definition_parser();
141336
141574
  init_PptxHandlerRuntimeChartExternalData();
141337
- PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
141575
+ PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
141338
141576
  /**
141339
141577
  * Parse the Office 2013+ chart-style part (`ppt/charts/style#.xml`)
141340
141578
  * referenced from the chart's relationships, sibling to
@@ -141495,7 +141733,7 @@ var init_PptxHandlerRuntimeChartColorStyle = __esm({
141495
141733
  });
141496
141734
 
141497
141735
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts
141498
- var PptxHandlerRuntime94;
141736
+ var PptxHandlerRuntime96;
141499
141737
  var init_PptxHandlerRuntimeChartExParsing = __esm({
141500
141738
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts"() {
141501
141739
  init_chart_cx_parser();
@@ -141505,7 +141743,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
141505
141743
  init_chart_protection2();
141506
141744
  init_chart_space_flags();
141507
141745
  init_PptxHandlerRuntimeChartColorStyle();
141508
- PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
141746
+ PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
141509
141747
  /**
141510
141748
  * The facts of a chart part that live outside the plot (or in other parts): the external data
141511
141749
  * reference and the embedded workbook's rows, pivot source and formats, the colour-style and
@@ -141625,7 +141863,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
141625
141863
  });
141626
141864
 
141627
141865
  // pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts
141628
- var PptxHandlerRuntime95;
141866
+ var PptxHandlerRuntime97;
141629
141867
  var init_PptxHandlerRuntimeChartParsing = __esm({
141630
141868
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
141631
141869
  init_chart_element_format_read_xml();
@@ -141647,7 +141885,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
141647
141885
  init_chart_element_pictures();
141648
141886
  init_chart_embedded_fallback();
141649
141887
  init_PptxHandlerRuntimeChartExParsing();
141650
- PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
141888
+ PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
141651
141889
  /**
141652
141890
  * Parse chart data from a graphic frame element on a slide.
141653
141891
  *
@@ -141931,7 +142169,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
141931
142169
  });
141932
142170
 
141933
142171
  // pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts
141934
- var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime96;
142172
+ var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime98;
141935
142173
  var init_PptxHandlerRuntimePresentationStructure = __esm({
141936
142174
  "pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts"() {
141937
142175
  init_kinsoku_parser();
@@ -141940,7 +142178,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
141940
142178
  init_PptxHandlerRuntimeChartParsing();
141941
142179
  XSD_INT_MIN = -2147483648;
141942
142180
  XSD_INT_MAX = 2147483647;
141943
- PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
142181
+ PptxHandlerRuntime98 = class extends PptxHandlerRuntime97 {
141944
142182
  parseEditorAnimations(slideXml3) {
141945
142183
  return this.editorAnimationService.parseEditorAnimations(slideXml3);
141946
142184
  }
@@ -142143,7 +142381,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
142143
142381
  });
142144
142382
 
142145
142383
  // pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts
142146
- var PptxHandlerRuntime97;
142384
+ var PptxHandlerRuntime99;
142147
142385
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142148
142386
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
142149
142387
  init_eot_parser();
@@ -142152,7 +142390,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142152
142390
  init_strip_parent_dir_segments();
142153
142391
  init_xml_access();
142154
142392
  init_PptxHandlerRuntimePresentationStructure();
142155
- PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
142393
+ PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
142156
142394
  async getEmbeddedFonts(fontList) {
142157
142395
  if (!fontList || fontList.fonts.length === 0) {
142158
142396
  return [];
@@ -142354,7 +142592,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142354
142592
  };
142355
142593
  }
142356
142594
  });
142357
- var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime98;
142595
+ var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime100;
142358
142596
  var init_PptxHandlerRuntimeLoadSession = __esm({
142359
142597
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts"() {
142360
142598
  init_zip_limits();
@@ -142366,7 +142604,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142366
142604
  init_bullet_picture_image_enrichment();
142367
142605
  init_PptxHandlerRuntimeEmbeddedFonts();
142368
142606
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
142369
- PptxHandlerRuntime98 = class _PptxHandlerRuntime extends PptxHandlerRuntime97 {
142607
+ PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
142370
142608
  isZipContainer(data) {
142371
142609
  const bytes = new Uint8Array(data);
142372
142610
  if (bytes.byteLength < 4) {
@@ -142734,7 +142972,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142734
142972
  });
142735
142973
 
142736
142974
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts
142737
- var PptxHandlerRuntime99;
142975
+ var PptxHandlerRuntime101;
142738
142976
  var init_PptxHandlerRuntimeLoadPipeline = __esm({
142739
142977
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts"() {
142740
142978
  init_fluent();
@@ -142750,7 +142988,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
142750
142988
  init_layout_switch_placeholder_prompts();
142751
142989
  init_PptxHandlerRuntimeLoadSession();
142752
142990
  init_slide_fingerprint();
142753
- PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
142991
+ PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
142754
142992
  async buildLoadData(presentationState, slidesWithWarnings, slideMasters) {
142755
142993
  const headerFooter = this.extractHeaderFooter();
142756
142994
  const presentationProperties = await this.parsePresentationProperties();
@@ -143250,12 +143488,12 @@ function refIndex2(node) {
143250
143488
  const idx = Number.parseInt(String(node["@_idx"] ?? ""), 10);
143251
143489
  return Number.isFinite(idx) ? idx : void 0;
143252
143490
  }
143253
- var PptxHandlerRuntime100;
143491
+ var PptxHandlerRuntime102;
143254
143492
  var init_PptxHandlerRuntimeStyleMatrixResolve = __esm({
143255
143493
  "pptx/core/core/runtime/PptxHandlerRuntimeStyleMatrixResolve.ts"() {
143256
143494
  init_authored_shape_style();
143257
143495
  init_PptxHandlerRuntimeLoadPipeline();
143258
- PptxHandlerRuntime100 = class extends PptxHandlerRuntime99 {
143496
+ PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
143259
143497
  /**
143260
143498
  * Resolve a `<p:style>` node (`a:lnRef`, `a:fillRef`, `a:effectRef`,
143261
143499
  * `a:fontRef`) against the current theme's format scheme, with the same
@@ -143320,14 +143558,17 @@ function withKeys(style, from, keys) {
143320
143558
  function refNode(idx, colorXml2) {
143321
143559
  return { "@_idx": String(idx), ...colorXml2 ?? {} };
143322
143560
  }
143323
- var PptxHandlerRuntime101;
143561
+ var PptxHandlerRuntime103;
143324
143562
  var init_PptxHandlerRuntimeThemeEffects = __esm({
143325
143563
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeEffects.ts"() {
143326
143564
  init_theme_effect_schemes();
143327
143565
  init_authored_shape_style();
143566
+ init_held_format_schemes();
143328
143567
  init_PptxHandlerRuntimeStyleMatrixResolve();
143329
- PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
143568
+ PptxHandlerRuntime103 = class extends PptxHandlerRuntime102 {
143330
143569
  effectSchemeCache = /* @__PURE__ */ new Map();
143570
+ /** Every `a:fmtScheme` written into a theme part or over one ({@link restoreThemeFormatScheme}). */
143571
+ heldFormatSchemes = new HeldFormatSchemes();
143331
143572
  /**
143332
143573
  * Resolve a `<p:style>` node as the base class does, against built-in effect scheme
143333
143574
  * `effectSchemeId` instead of the deck's own (the Effects gallery draws each tile this way).
@@ -143380,32 +143621,79 @@ var init_PptxHandlerRuntimeThemeEffects = __esm({
143380
143621
  */
143381
143622
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
143382
143623
  const parsed = this.parseEffectScheme({ fmtSchemeXml });
143383
- if (!parsed) {
143384
- return void 0;
143624
+ return parsed ? this.writeFormatScheme(() => parsed.node) : void 0;
143625
+ }
143626
+ /**
143627
+ * Put back a format scheme the deck held before (Undo and Redo of an Effects pick), as the parts
143628
+ * held it: each theme part a master references gets back what it held the last time the deck's
143629
+ * scheme was `scheme` over those same parts, so a part with a scheme of its own gets its own back
143630
+ * (with no such time, `scheme`'s own element goes into every one). With `themePaths`, `scheme`'s
143631
+ * own element goes into those parts only.
143632
+ *
143633
+ * @returns the deck's format scheme now, or `undefined` (nothing written) for a scheme no part
143634
+ * held while this handler wrote into it
143635
+ */
143636
+ async restoreThemeFormatScheme(scheme, themePaths) {
143637
+ const parts = themePaths ? void 0 : this.heldFormatSchemes.parts(scheme, await this.resolveThemeEditTargets());
143638
+ if (parts) {
143639
+ return this.writeFormatScheme((path4) => parts.get(path4));
143385
143640
  }
143386
- const written = await this.rewriteThemeParts(void 0, (data) => {
143641
+ const element = this.heldFormatSchemes.element(scheme);
143642
+ return element ? this.writeFormatScheme(() => element, themePaths) : void 0;
143643
+ }
143644
+ /**
143645
+ * Write `elementFor(part)` into every theme part a master references (or only `themePaths`),
143646
+ * skipping a part it gives none, holding what each part held and now holds, and refresh the
143647
+ * in-memory format schemes of the masters on those parts and, when the deck's part is among
143648
+ * them, the deck's.
143649
+ */
143650
+ async writeFormatScheme(elementFor, themePaths) {
143651
+ const deckBefore = this.getThemeFormatScheme();
143652
+ const replaced = /* @__PURE__ */ new Map();
143653
+ const schemes = /* @__PURE__ */ new Map();
143654
+ const written = await this.rewriteThemeParts(themePaths, (data, path4) => {
143655
+ const element = elementFor(path4);
143387
143656
  const elements2 = data["a:theme"]?.["a:themeElements"];
143388
- if (!elements2) {
143657
+ if (!element || !elements2) {
143389
143658
  return false;
143390
143659
  }
143391
- elements2["a:fmtScheme"] = structuredClone(parsed.node);
143660
+ const previous = elements2["a:fmtScheme"];
143661
+ if (previous) {
143662
+ this.heldFormatSchemes.hold(this.parseFormatScheme(previous), previous);
143663
+ replaced.set(path4, structuredClone(previous));
143664
+ }
143665
+ const scheme = this.parseFormatScheme(element);
143666
+ this.heldFormatSchemes.hold(scheme, element);
143667
+ elements2["a:fmtScheme"] = structuredClone(element);
143668
+ schemes.set(path4, scheme);
143392
143669
  return true;
143393
143670
  });
143394
143671
  if (written.length === 0) {
143395
143672
  return void 0;
143396
143673
  }
143674
+ if (deckBefore) {
143675
+ this.heldFormatSchemes.holdParts(deckBefore, replaced);
143676
+ }
143397
143677
  for (const path4 of written) {
143398
143678
  const xml = await this.zip.file(path4)?.async("string");
143399
143679
  if (xml !== void 0) {
143400
143680
  this.originalThemeXmlByPath.set(path4, xml);
143401
143681
  }
143682
+ for (const masterPath of this.mastersUsingThemes([path4])) {
143683
+ this.masterThemeFormatSchemes.set(masterPath, schemes.get(path4));
143684
+ }
143402
143685
  }
143403
- for (const masterPath of this.mastersUsingThemes(written)) {
143404
- this.masterThemeFormatSchemes.set(masterPath, parsed.scheme);
143686
+ const primary = await this.resolvePrimaryThemePath();
143687
+ const deck = primary === void 0 ? void 0 : schemes.get(primary);
143688
+ if (deck) {
143689
+ this.globalThemeFormatSchemeSnapshot = deck;
143690
+ this.themeFormatScheme = deck;
143691
+ this.heldFormatSchemes.holdParts(
143692
+ deck,
143693
+ new Map(written.map((path4) => [path4, elementFor(path4)]))
143694
+ );
143405
143695
  }
143406
- this.globalThemeFormatSchemeSnapshot = parsed.scheme;
143407
- this.themeFormatScheme = parsed.scheme;
143408
- return parsed.scheme;
143696
+ return this.getThemeFormatScheme();
143409
143697
  }
143410
143698
  /** The real theme variants the loaded package carries, or none. */
143411
143699
  getThemeVariants() {
@@ -143531,7 +143819,7 @@ function schemeFromColorMap(map) {
143531
143819
  folHlink: pick("folHlink")
143532
143820
  };
143533
143821
  }
143534
- var PptxHandlerRuntime102;
143822
+ var PptxHandlerRuntime104;
143535
143823
  var init_PptxHandlerRuntimeBackgroundStyles = __esm({
143536
143824
  "pptx/core/core/runtime/PptxHandlerRuntimeBackgroundStyles.ts"() {
143537
143825
  init_background_style();
@@ -143539,7 +143827,7 @@ var init_PptxHandlerRuntimeBackgroundStyles = __esm({
143539
143827
  init_theme_switching();
143540
143828
  init_master_save_helpers();
143541
143829
  init_PptxHandlerRuntimeThemeEffects();
143542
- PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
143830
+ PptxHandlerRuntime104 = class extends PptxHandlerRuntime103 {
143543
143831
  resolveBackgroundStyle(preset) {
143544
143832
  const xml = {
143545
143833
  "p:sld": { "p:cSld": { "p:bg": backgroundRefNode(preset.idx, preset.scheme) } }
@@ -143799,14 +144087,14 @@ var init_sdk_placeholder = __esm({
143799
144087
  });
143800
144088
 
143801
144089
  // pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts
143802
- var PptxHandlerRuntime103;
144090
+ var PptxHandlerRuntime105;
143803
144091
  var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
143804
144092
  "pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts"() {
143805
144093
  init_placeholder_remap();
143806
144094
  init_xml_access();
143807
144095
  init_PptxHandlerRuntimeBackgroundStyles();
143808
144096
  init_sdk_placeholder();
143809
- PptxHandlerRuntime103 = class _PptxHandlerRuntime extends PptxHandlerRuntime102 {
144097
+ PptxHandlerRuntime105 = class _PptxHandlerRuntime extends PptxHandlerRuntime104 {
143810
144098
  createPlaceholderElement(layoutPath, input, type, options) {
143811
144099
  if (input.type !== "text") throw new Error("Placeholder input must be text");
143812
144100
  const layout = this.layoutXmlMap.get(layoutPath);
@@ -143860,14 +144148,14 @@ var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
143860
144148
  };
143861
144149
  }
143862
144150
  });
143863
- var PptxHandlerRuntime104;
144151
+ var PptxHandlerRuntime106;
143864
144152
  var init_PptxHandlerRuntimeImplementation = __esm({
143865
144153
  "pptx/core/core/runtime/PptxHandlerRuntimeImplementation.ts"() {
143866
144154
  init_PptxElementXmlBuilder();
143867
144155
  init_builders();
143868
144156
  init_factories();
143869
144157
  init_PptxHandlerRuntimeSdkPlaceholders();
143870
- PptxHandlerRuntime104 = class _PptxHandlerRuntime extends PptxHandlerRuntime103 {
144158
+ PptxHandlerRuntime106 = class _PptxHandlerRuntime extends PptxHandlerRuntime105 {
143871
144159
  constructor(dependencyFactory = new PptxRuntimeDependencyFactory()) {
143872
144160
  super();
143873
144161
  this.dependencyFactory = dependencyFactory;
@@ -144007,11 +144295,11 @@ var init_PptxHandlerRuntimeImplementation = __esm({
144007
144295
  });
144008
144296
 
144009
144297
  // pptx/core/core/PptxHandlerRuntime.ts
144010
- var PptxHandlerRuntime105;
144298
+ var PptxHandlerRuntime107;
144011
144299
  var init_PptxHandlerRuntime = __esm({
144012
144300
  "pptx/core/core/PptxHandlerRuntime.ts"() {
144013
144301
  init_PptxHandlerRuntimeImplementation();
144014
- PptxHandlerRuntime105 = class extends PptxHandlerRuntime104 {
144302
+ PptxHandlerRuntime107 = class extends PptxHandlerRuntime106 {
144015
144303
  };
144016
144304
  }
144017
144305
  });
@@ -144021,7 +144309,7 @@ var createDefaultPptxHandlerRuntime;
144021
144309
  var init_PptxHandlerRuntimeFactory = __esm({
144022
144310
  "pptx/core/core/PptxHandlerRuntimeFactory.ts"() {
144023
144311
  init_PptxHandlerRuntime();
144024
- createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime105();
144312
+ createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime107();
144025
144313
  }
144026
144314
  });
144027
144315
 
@@ -147227,10 +147515,32 @@ var init_PptxHandlerCore = __esm({
147227
147515
  async setPresentationTheme(themePath, applyToAllMasters = true) {
147228
147516
  await this.runtime.setPresentationTheme(themePath, applyToAllMasters);
147229
147517
  }
147518
+ /**
147519
+ * Point one slide master at a theme part already in the package; scheme edits and saves follow
147520
+ * it. Does nothing when the package has no such master or part.
147521
+ *
147522
+ * @param masterPath - The master's part path (e.g. `ppt/slideMasters/slideMaster2.xml`).
147523
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme1.xml`).
147524
+ */
147525
+ async setSlideMasterTheme(masterPath, themePath) {
147526
+ await this.runtime.setSlideMasterTheme(masterPath, themePath);
147527
+ }
147528
+ /**
147529
+ * Read one theme part's colour, font and format schemes and its name without changing the
147530
+ * loaded theme, for example to show what switching to it would apply.
147531
+ *
147532
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme2.xml`).
147533
+ * @returns The part's schemes, or `undefined` when the package has no such part.
147534
+ */
147535
+ async getThemePartSchemes(themePath) {
147536
+ return this.runtime.getThemePartSchemes(themePath);
147537
+ }
147230
147538
  /**
147231
147539
  * Modify the theme’s colour scheme (accent colours, background, text, etc.).
147232
147540
  *
147233
147541
  * @param colorScheme - A {@link PptxThemeColorScheme} with hex colour values.
147542
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147543
+ * master uses when omitted.
147234
147544
  *
147235
147545
  * @example
147236
147546
  * ```ts
@@ -147243,13 +147553,15 @@ var init_PptxHandlerCore = __esm({
147243
147553
  * // => void — colour scheme updated in the in-memory theme XML
147244
147554
  * ```
147245
147555
  */
147246
- async updateThemeColorScheme(colorScheme) {
147247
- await this.runtime.updateThemeColorScheme(colorScheme);
147556
+ async updateThemeColorScheme(colorScheme, themePaths) {
147557
+ await this.runtime.updateThemeColorScheme(colorScheme, themePaths);
147248
147558
  }
147249
147559
  /**
147250
147560
  * Update the theme’s font scheme (heading + body typefaces).
147251
147561
  *
147252
147562
  * @param fontScheme - A {@link PptxThemeFontScheme} with font family names.
147563
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147564
+ * master uses when omitted.
147253
147565
  *
147254
147566
  * @example
147255
147567
  * ```ts
@@ -147260,16 +147572,18 @@ var init_PptxHandlerCore = __esm({
147260
147572
  * // => void — font scheme updated in the in-memory theme XML
147261
147573
  * ```
147262
147574
  */
147263
- async updateThemeFontScheme(fontScheme) {
147264
- await this.runtime.updateThemeFontScheme(fontScheme);
147575
+ async updateThemeFontScheme(fontScheme, themePaths) {
147576
+ await this.runtime.updateThemeFontScheme(fontScheme, themePaths);
147265
147577
  }
147266
147578
  /**
147267
147579
  * Rename the presentation theme.
147268
147580
  *
147269
147581
  * @param name - New display name for the theme.
147582
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147583
+ * master uses when omitted.
147270
147584
  */
147271
- async updateThemeName(name) {
147272
- await this.runtime.updateThemeName(name);
147585
+ async updateThemeName(name, themePaths) {
147586
+ await this.runtime.updateThemeName(name, themePaths);
147273
147587
  }
147274
147588
  /**
147275
147589
  * Resolve a `<p:style>` block (`a:lnRef` / `a:fillRef` / `a:effectRef` /
@@ -147292,6 +147606,14 @@ var init_PptxHandlerCore = __esm({
147292
147606
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
147293
147607
  return this.runtime.applyThemeFormatSchemeXml(fmtSchemeXml);
147294
147608
  }
147609
+ /**
147610
+ * Put a format scheme a theme part held before back into the theme parts (or only `themePaths`),
147611
+ * as the part held it: Undo and Redo of an Effects pick. Only a scheme this handler wrote into a
147612
+ * part or over one can come back; for any other it writes nothing and returns `undefined`.
147613
+ */
147614
+ async restoreThemeFormatScheme(scheme, themePaths) {
147615
+ return this.runtime.restoreThemeFormatScheme(scheme, themePaths);
147616
+ }
147295
147617
  /** The real theme variants the loaded package carries (`themeVariants/` parts), or none. */
147296
147618
  getThemeVariants() {
147297
147619
  return this.runtime.getThemeVariants();