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
@@ -4504,57 +4504,98 @@ function resolveLimits(limits) {
4504
4504
  fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
4505
4505
  };
4506
4506
  }
4507
- function inflateEntryGuarded(entry2, alreadyRead, limits) {
4507
+ async function inflateEntryGuarded(entry2, alreadyRead, limits) {
4508
+ const chunks = [];
4509
+ let size = 0;
4510
+ for await (const chunk2 of streamEntryGuarded(entry2, alreadyRead, limits)) {
4511
+ chunks.push(chunk2);
4512
+ size += chunk2.byteLength;
4513
+ }
4514
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
4515
+ const out = new Uint8Array(size);
4516
+ let offset = 0;
4517
+ for (const chunk2 of chunks) {
4518
+ out.set(chunk2, offset);
4519
+ offset += chunk2.byteLength;
4520
+ }
4521
+ return out;
4522
+ }
4523
+ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
4508
4524
  const r = resolveLimits(limits);
4509
4525
  const declared = declaredEntrySize(entry2);
4510
- return new Promise((resolvePromise, reject) => {
4511
- const chunks = [];
4512
- let size = 0;
4513
- let done = false;
4514
- const stream = entry2.internalStream("uint8array");
4515
- const abort = (error62) => {
4516
- if (done) return;
4517
- done = true;
4518
- stream.pause();
4519
- chunks.length = 0;
4520
- reject(error62);
4521
- };
4522
- stream.on("data", (chunk2) => {
4523
- if (done) return;
4524
- size += chunk2.byteLength;
4525
- if (size > declared || size > r.maxEntryBytes)
4526
- return abort(
4527
- r.fail(
4528
- `${r.label} part ${entry2.name} inflates past its declared size`,
4529
- r.maxEntryBytes,
4530
- size > declared ? "declaredSize" : "maxEntryBytes"
4531
- )
4532
- );
4533
- if (alreadyRead + size > r.maxTotalBytes)
4534
- return abort(
4535
- r.fail(
4536
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
4537
- r.maxTotalBytes,
4538
- "maxTotalBytes"
4539
- )
4540
- );
4541
- chunks.push(chunk2);
4542
- });
4543
- stream.on("error", (error62) => abort(error62));
4544
- stream.on("end", () => {
4545
- if (done) return;
4546
- done = true;
4547
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
4548
- const out = new Uint8Array(size);
4549
- let offset = 0;
4550
- for (const chunk2 of chunks) {
4551
- out.set(chunk2, offset);
4552
- offset += chunk2.byteLength;
4553
- }
4554
- resolvePromise(out);
4555
- });
4526
+ const stream = entry2.internalStream("uint8array");
4527
+ const queue = [];
4528
+ let size = 0;
4529
+ let ended = false;
4530
+ let stopped = false;
4531
+ let failure2;
4532
+ let paused = false;
4533
+ let wake;
4534
+ const pause = () => {
4535
+ paused = true;
4536
+ stream.pause();
4537
+ };
4538
+ const resume = () => {
4539
+ if (!paused || stopped) return;
4540
+ paused = false;
4556
4541
  stream.resume();
4542
+ };
4543
+ const fail2 = (error62) => {
4544
+ failure2 ??= error62;
4545
+ stopped = true;
4546
+ queue.length = 0;
4547
+ pause();
4548
+ wake?.();
4549
+ };
4550
+ stream.on("data", (chunk2) => {
4551
+ if (stopped) return pause();
4552
+ size += chunk2.byteLength;
4553
+ if (size > declared || size > r.maxEntryBytes)
4554
+ return fail2(
4555
+ r.fail(
4556
+ `${r.label} part ${entry2.name} inflates past its declared size`,
4557
+ r.maxEntryBytes,
4558
+ size > declared ? "declaredSize" : "maxEntryBytes"
4559
+ )
4560
+ );
4561
+ if (alreadyRead + size > r.maxTotalBytes)
4562
+ return fail2(
4563
+ r.fail(
4564
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
4565
+ r.maxTotalBytes,
4566
+ "maxTotalBytes"
4567
+ )
4568
+ );
4569
+ queue.push(chunk2);
4570
+ if (queue.length >= AHEAD) pause();
4571
+ wake?.();
4572
+ });
4573
+ stream.on("error", (error62) => fail2(error62));
4574
+ stream.on("end", () => {
4575
+ ended = true;
4576
+ wake?.();
4557
4577
  });
4578
+ stream.resume();
4579
+ try {
4580
+ for (; ; ) {
4581
+ if (failure2) throw failure2;
4582
+ const chunk2 = queue.shift();
4583
+ if (chunk2) {
4584
+ if (queue.length < AHEAD / 2) resume();
4585
+ yield chunk2;
4586
+ continue;
4587
+ }
4588
+ if (ended) return;
4589
+ await new Promise((resolve) => {
4590
+ wake = resolve;
4591
+ resume();
4592
+ });
4593
+ wake = void 0;
4594
+ }
4595
+ } finally {
4596
+ stopped = true;
4597
+ if (!ended) pause();
4598
+ }
4558
4599
  }
4559
4600
  function toBase64(bytes) {
4560
4601
  let binary = "";
@@ -4633,7 +4674,7 @@ async function openZip(input2, limits = {}) {
4633
4674
  );
4634
4675
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
4635
4676
  }
4636
- var DEFAULT_ZIP_LIMITS, ZipLimitError, mib;
4677
+ var DEFAULT_ZIP_LIMITS, ZipLimitError, mib, AHEAD;
4637
4678
  var init_zip_limits = __esm({
4638
4679
  "opc/zip-limits.ts"() {
4639
4680
  DEFAULT_ZIP_LIMITS = {
@@ -4655,6 +4696,7 @@ var init_zip_limits = __esm({
4655
4696
  }
4656
4697
  };
4657
4698
  mib = (bytes) => Math.round(bytes / 1048576);
4699
+ AHEAD = 8;
4658
4700
  }
4659
4701
  });
4660
4702
 
@@ -54540,6 +54582,22 @@ var init_theme_effect_schemes_data = __esm({
54540
54582
  function findThemeEffectScheme(id) {
54541
54583
  return THEME_EFFECT_SCHEMES.find((scheme) => scheme.id === id);
54542
54584
  }
54585
+ function formatSchemeKey(scheme) {
54586
+ const raw2 = (styles) => (styles ?? []).map((style) => style.rawNode ?? null);
54587
+ const lists = [scheme.fillStyles, scheme.lineStyles, scheme.effectStyles];
54588
+ return JSON.stringify(
54589
+ [scheme.name ?? null, ...lists.map(raw2), raw2(scheme.backgroundFillStyles)],
54590
+ (_key, value) => {
54591
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
54592
+ return value;
54593
+ }
54594
+ const entries = Object.entries(value);
54595
+ const isAttribute = ([key2]) => key2.startsWith("@_");
54596
+ const attributes3 = entries.filter(isAttribute).sort(([x], [y]) => x < y ? -1 : 1);
54597
+ return Object.fromEntries([...attributes3, ...entries.filter((entry2) => !isAttribute(entry2))]);
54598
+ }
54599
+ );
54600
+ }
54543
54601
  function wrapFormatSchemeXml(fmtSchemeXml) {
54544
54602
  return fmtSchemeXml.replace(
54545
54603
  /^<a:fmtScheme/u,
@@ -94855,6 +94913,42 @@ var init_master_save_helpers = __esm({
94855
94913
  }
94856
94914
  });
94857
94915
 
94916
+ // pptx/core/core/runtime/held-format-schemes.ts
94917
+ function partsKey(deckScheme, themePaths) {
94918
+ return JSON.stringify([formatSchemeKey(deckScheme), [...new Set(themePaths)].sort()]);
94919
+ }
94920
+ var HeldFormatSchemes;
94921
+ var init_held_format_schemes = __esm({
94922
+ "pptx/core/core/runtime/held-format-schemes.ts"() {
94923
+ init_theme_effect_schemes();
94924
+ HeldFormatSchemes = class {
94925
+ elements = /* @__PURE__ */ new Map();
94926
+ partsByDeckScheme = /* @__PURE__ */ new Map();
94927
+ /** Keep `element`, which `scheme` was parsed from. */
94928
+ hold(scheme, element) {
94929
+ this.elements.set(formatSchemeKey(scheme), structuredClone(element));
94930
+ }
94931
+ /** The element `scheme` was parsed from, if one was held. */
94932
+ element(scheme) {
94933
+ return this.elements.get(formatSchemeKey(scheme));
94934
+ }
94935
+ /** What each part in `parts` held while the deck's scheme was `deckScheme`. */
94936
+ holdParts(deckScheme, parts) {
94937
+ if (parts.size > 0) {
94938
+ this.partsByDeckScheme.set(partsKey(deckScheme, [...parts.keys()]), new Map(parts));
94939
+ }
94940
+ }
94941
+ /**
94942
+ * The element each of `themePaths` held the last time the deck's scheme was `deckScheme` over
94943
+ * exactly those parts, if known.
94944
+ */
94945
+ parts(deckScheme, themePaths) {
94946
+ return this.partsByDeckScheme.get(partsKey(deckScheme, themePaths));
94947
+ }
94948
+ };
94949
+ }
94950
+ });
94951
+
94858
94952
  // pptx/core/builders/fluent/PptxXmlBuilder.ts
94859
94953
  var PptxXmlBuilder, PptxSlideBuilder, PptxSlideElementsBuilder, PptxSlideNotesBuilder;
94860
94954
  var init_PptxXmlBuilder = __esm({
@@ -121426,6 +121520,11 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121426
121520
  const upSegments = Array.from({ length: fromParts.length }).fill("..");
121427
121521
  return [...upSegments, ...toParts].join("/");
121428
121522
  }
121523
+ /**
121524
+ * Point a slide master's theme relationship at `themePath`.
121525
+ *
121526
+ * @returns whether the master had a theme relationship to rewrite
121527
+ */
121429
121528
  async setMasterThemeRelationship(masterPath, themePath) {
121430
121529
  const relsPath2 = masterPath.replace(
121431
121530
  /ppt\/slideMasters\/(slideMaster\d+)\.xml/,
@@ -121433,7 +121532,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121433
121532
  );
121434
121533
  const relsFile = this.zip.file(relsPath2);
121435
121534
  if (!relsFile) {
121436
- return;
121535
+ return false;
121437
121536
  }
121438
121537
  const relsXml = await relsFile.async("string");
121439
121538
  const relsData = this.parser.parse(relsXml);
@@ -121441,28 +121540,13 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
121441
121540
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
121442
121541
  const themeRel = relationships3.find((rel) => String(rel["@_Type"] || "").includes("/theme"));
121443
121542
  if (!themeRel) {
121444
- return;
121543
+ return false;
121445
121544
  }
121446
121545
  themeRel["@_Target"] = this.buildRelativeTargetPath(masterPath, themePath);
121447
121546
  relRoot["Relationship"] = relationships3;
121448
121547
  relsData["Relationships"] = relRoot;
121449
121548
  this.zip.file(relsPath2, this.builder.build(relsData));
121450
- }
121451
- async setPresentationTheme(themePath, applyToAllMasters = true) {
121452
- const normalizedThemePath = themePath.trim().replace(/\\/g, "/");
121453
- if (!normalizedThemePath.startsWith("ppt/theme/")) {
121454
- return;
121455
- }
121456
- const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
121457
- if (!masterFiles || masterFiles.length === 0) {
121458
- return;
121459
- }
121460
- const targetMasters = applyToAllMasters ? masterFiles : [masterFiles[0]];
121461
- await Promise.all(
121462
- targetMasters.map(async (masterFile) => {
121463
- await this.setMasterThemeRelationship(masterFile.name, normalizedThemePath);
121464
- })
121465
- );
121549
+ return true;
121466
121550
  }
121467
121551
  /** The text of a package part, or `undefined` when the package has no such part. */
121468
121552
  async readPartText(path4) {
@@ -121792,8 +121876,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121792
121876
  this.masterXmlMap.set(path4, data);
121793
121877
  }
121794
121878
  const masterCSldName = (xmlAttr(sldMaster["p:cSld"], "name") ?? "").trim();
121795
- const bg = sldMaster["p:cSld"]?.["p:bg"];
121796
- const backgroundColor = this.parseBackgroundColor(bg);
121797
121879
  const spTree = sldMaster["p:cSld"]?.["p:spTree"];
121798
121880
  const placeholders = this.extractPlaceholderList(spTree);
121799
121881
  let preserve;
@@ -121847,7 +121929,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121847
121929
  results.push({
121848
121930
  path: path4,
121849
121931
  name: masterCSldName.length > 0 ? masterCSldName : void 0,
121850
- backgroundColor,
121851
121932
  themePath,
121852
121933
  layoutPaths: layoutPaths.length > 0 ? layoutPaths : void 0,
121853
121934
  layouts: layouts.length > 0 ? layouts : void 0,
@@ -121985,11 +122066,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
121985
122066
  layout.clrMapOverride = overrideMap;
121986
122067
  }
121987
122068
  }
121988
- const bg = xmlPath(sldLayout, "p:cSld", "p:bg");
121989
- const bgColor = this.parseBackgroundColor(bg);
121990
- if (bgColor) {
121991
- layout.backgroundColor = bgColor;
121992
- }
121993
122069
  const spTree = xmlPath(sldLayout, "p:cSld", "p:spTree");
121994
122070
  const placeholders = this.extractPlaceholderList(spTree);
121995
122071
  if (placeholders.length > 0) {
@@ -137434,7 +137510,23 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
137434
137510
  }
137435
137511
  return this.isStrictOoxml ? "strict" : "transitional";
137436
137512
  }
137513
+ /** The save running now, or the last one: see {@link save}. */
137514
+ saveQueue = Promise.resolve();
137515
+ /**
137516
+ * Saves run one at a time. A save rewrites `this.zip` in place across many awaits and moves
137517
+ * per-part baselines (slide fingerprints, chart data, pending chart updates) while it runs, so
137518
+ * a second save that starts mid-way (a viewer's autosave snapshot firing during the user's own
137519
+ * save) read half-written state: it skipped the slide as unchanged and wrote the chart part's
137520
+ * original XML back over the edit, in both outputs. Each save now waits for the one before it;
137521
+ * one that fails does not hold up the next.
137522
+ */
137437
137523
  async save(slides, options) {
137524
+ const run2 = this.saveQueue.then(() => this.saveNow(slides, options));
137525
+ this.saveQueue = run2.catch(() => void 0);
137526
+ return run2;
137527
+ }
137528
+ /** One save, with the package to itself; callers go through {@link save}. */
137529
+ async saveNow(slides, options) {
137438
137530
  validateSlideGeometry(slides);
137439
137531
  const templates = [
137440
137532
  ...options?.slideMasters ?? [],
@@ -137452,7 +137544,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
137452
137544
  return this.saveAsLegacyPpt(
137453
137545
  slides,
137454
137546
  options,
137455
- () => this.save(slides, {
137547
+ () => this.saveNow(slides, {
137456
137548
  ...options,
137457
137549
  pptPassword: void 0,
137458
137550
  outputFormat: "pptx",
@@ -142439,6 +142531,25 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
142439
142531
  }
142440
142532
  return void 0;
142441
142533
  }
142534
+ /**
142535
+ * The colour a slide master or layout paints from its own `p:bg`, resolved exactly as a
142536
+ * slide's background is: through the active master's colour map and format scheme, with
142537
+ * `clrMapOverride` (a layout's `p:clrMapOvr`, or `null`) taking precedence. The caller makes
142538
+ * the part's master active first; a master's `bgRef` on `bg1` means `dk1` under a dark
142539
+ * `p:clrMap`, which no other state can tell.
142540
+ */
142541
+ extractTemplateBackgroundColor(partXml, rootTag2, clrMapOverride) {
142542
+ if (!partXml) {
142543
+ return void 0;
142544
+ }
142545
+ const previousOverride = this.currentSlideClrMapOverride;
142546
+ this.currentSlideClrMapOverride = clrMapOverride;
142547
+ try {
142548
+ return this.extractBackgroundColor(partXml, rootTag2);
142549
+ } finally {
142550
+ this.currentSlideClrMapOverride = previousOverride;
142551
+ }
142552
+ }
142442
142553
  /**
142443
142554
  * Composite a resolved background colour with its `a:alpha` (or
142444
142555
  * `a:alphaMod`/`a:alphaOff`) opacity onto opaque white.
@@ -143005,6 +143116,31 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
143005
143116
  const masterFormatScheme = this.masterThemeFormatSchemes.get(masterPath);
143006
143117
  this.themeFormatScheme = masterFormatScheme ?? this.globalThemeFormatSchemeSnapshot;
143007
143118
  }
143119
+ /**
143120
+ * Run `work` with one master's theme state active and no slide colour-map override, then
143121
+ * put back whatever state was active before, so a part parsed on request (a layout preview)
143122
+ * resolves through its own master without disturbing the caller's.
143123
+ */
143124
+ async withMasterThemeState(masterPath, work) {
143125
+ const saved = {
143126
+ colors: this.themeColorMap,
143127
+ fonts: this.themeFontMap,
143128
+ format: this.themeFormatScheme,
143129
+ clrMap: this.currentMasterClrMap,
143130
+ slideClrMap: this.currentSlideClrMapOverride
143131
+ };
143132
+ this.applyMasterThemeState(masterPath);
143133
+ this.currentSlideClrMapOverride = null;
143134
+ try {
143135
+ return await work();
143136
+ } finally {
143137
+ this.themeColorMap = saved.colors;
143138
+ this.themeFontMap = saved.fonts;
143139
+ this.themeFormatScheme = saved.format;
143140
+ this.currentMasterClrMap = saved.clrMap;
143141
+ this.currentSlideClrMapOverride = saved.slideClrMap;
143142
+ }
143143
+ }
143008
143144
  /**
143009
143145
  * Extract the `p:bg/@showAnimation` flag from a slide's XML.
143010
143146
  * Returns `true` when the background should animate, `false` when
@@ -143919,18 +144055,33 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
143919
144055
  this.rememberUnparsedMasterNodes(partPath, spTree, part.elements);
143920
144056
  }
143921
144057
  /**
143922
- * Populate `elements` on every slide master and on each of its layouts.
144058
+ * Resolve the background of every slide master and of each of its layouts,
144059
+ * and populate their `elements`.
143923
144060
  *
143924
- * Scheme colours on a master's own shapes must resolve through that
143925
- * master's colour map and theme, so the active master state is switched
143926
- * per part and reset to the deck-wide snapshot afterwards.
144061
+ * Scheme colours on a master, its own `p:bgRef` included, must resolve
144062
+ * through that master's colour map and theme, so the active master state is
144063
+ * switched per part and reset to the deck-wide snapshot afterwards.
143927
144064
  */
143928
144065
  async enrichSlideMasterElements(masters) {
143929
144066
  for (const master of masters) {
143930
144067
  try {
143931
144068
  this.applyMasterThemeState(master.path);
144069
+ master.backgroundColor = this.extractTemplateBackgroundColor(
144070
+ this.masterXmlMap.get(master.path),
144071
+ "p:sldMaster",
144072
+ null
144073
+ );
143932
144074
  await this.enrichMasterPartElements(master, "p:sldMaster");
143933
144075
  for (const layout of master.layouts ?? []) {
144076
+ const layoutXml3 = this.layoutXmlMap.get(layout.path);
144077
+ const backgroundColor = this.extractTemplateBackgroundColor(
144078
+ layoutXml3,
144079
+ "p:sldLayout",
144080
+ layoutXml3 ? this.parseLayoutClrMapOverride(layoutXml3) : null
144081
+ );
144082
+ if (backgroundColor) {
144083
+ layout.backgroundColor = backgroundColor;
144084
+ }
143934
144085
  await this.enrichMasterPartElements(layout, "p:sldLayout");
143935
144086
  }
143936
144087
  } catch (e) {
@@ -144201,20 +144352,23 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
144201
144352
  this.layoutCache.delete(layoutPath);
144202
144353
  this.eagerDecodeImages = true;
144203
144354
  }
144204
- let elements3;
144355
+ const masterPath = this.resolveMasterPathForLayout(layoutPath);
144356
+ let parsed;
144205
144357
  try {
144206
- elements3 = await this.getLayoutElementsByPath(layoutPath);
144358
+ parsed = await this.withMasterThemeState(masterPath, async () => ({
144359
+ elements: await this.getLayoutElementsByPath(layoutPath),
144360
+ background: this.resolveLayoutPreviewBackground(layoutXml3, masterPath)
144361
+ }));
144207
144362
  } finally {
144208
144363
  this.eagerDecodeImages = previousEagerDecode;
144209
144364
  }
144210
144365
  const cSld = xmlPath(layoutXml3, "p:sldLayout", "p:cSld");
144211
- const background = this.resolveLayoutPreviewBackground(layoutPath, cSld);
144212
144366
  const preview = {
144213
144367
  path: layoutPath,
144214
144368
  width: this.rawSlideWidthEmu / EMU_PER_PX,
144215
144369
  height: this.rawSlideHeightEmu / EMU_PER_PX,
144216
- ...background,
144217
- elements: elements3,
144370
+ ...parsed.background,
144371
+ elements: parsed.elements,
144218
144372
  placeholders: this.extractPlaceholderList(xmlChild(cSld, "p:spTree"))
144219
144373
  };
144220
144374
  this.layoutPreviewCache.set(layoutPath, preview);
@@ -144250,19 +144404,18 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
144250
144404
  }
144251
144405
  /**
144252
144406
  * Resolve the background a layout thumbnail should paint, falling back to
144253
- * the layout's master when the layout itself declares none.
144407
+ * the layout's master when the layout itself declares none. Runs with the
144408
+ * master active; the layout's own colour map override applies to an
144409
+ * inherited background too, as a slide's does.
144254
144410
  */
144255
- resolveLayoutPreviewBackground(layoutPath, cSld) {
144256
- const ownBackground = this.parseBackgroundColor(xmlChild(cSld, "p:bg"));
144257
- if (ownBackground) {
144258
- return { backgroundColor: ownBackground };
144259
- }
144260
- const masterPath = this.resolveMasterPathForLayout(layoutPath);
144261
- const masterXml = masterPath ? this.masterXmlMap.get(masterPath) : void 0;
144262
- const masterBackground = this.parseBackgroundColor(
144263
- xmlChild(xmlPath(masterXml, "p:sldMaster", "p:cSld"), "p:bg")
144411
+ resolveLayoutPreviewBackground(layoutXml3, masterPath) {
144412
+ const clrMapOverride = this.parseLayoutClrMapOverride(layoutXml3);
144413
+ const backgroundColor = this.extractTemplateBackgroundColor(layoutXml3, "p:sldLayout", clrMapOverride) ?? this.extractTemplateBackgroundColor(
144414
+ masterPath ? this.masterXmlMap.get(masterPath) : void 0,
144415
+ "p:sldMaster",
144416
+ clrMapOverride
144264
144417
  );
144265
- return masterBackground ? { backgroundColor: masterBackground } : {};
144418
+ return backgroundColor ? { backgroundColor } : {};
144266
144419
  }
144267
144420
  };
144268
144421
  }
@@ -145070,15 +145223,298 @@ var init_PptxHandlerRuntimeThemeRefResolution = __esm({
145070
145223
  }
145071
145224
  });
145072
145225
 
145226
+ // pptx/core/core/runtime/theme-scheme-edit.ts
145227
+ function normalizeHex6(hex5) {
145228
+ return hex5.replace(/^#/, "").toUpperCase();
145229
+ }
145230
+ function buildSrgbClrNode(hex5) {
145231
+ return { "a:srgbClr": { "@_val": normalizeHex6(hex5) } };
145232
+ }
145233
+ function themeElementsOf(data) {
145234
+ const root = data["a:theme"];
145235
+ return root?.["a:themeElements"];
145236
+ }
145237
+ function applyColorSchemeToThemeXml(data, colorScheme) {
145238
+ const themeElements = themeElementsOf(data);
145239
+ if (!themeElements) {
145240
+ return false;
145241
+ }
145242
+ const clrScheme = themeElements["a:clrScheme"] ?? {};
145243
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145244
+ clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
145245
+ }
145246
+ themeElements["a:clrScheme"] = clrScheme;
145247
+ return true;
145248
+ }
145249
+ function applyLatinTypeface(group, latin) {
145250
+ const font = group ?? {};
145251
+ font["a:latin"] = { "@_typeface": latin };
145252
+ if (!font["a:ea"]) {
145253
+ font["a:ea"] = { "@_typeface": "" };
145254
+ }
145255
+ if (!font["a:cs"]) {
145256
+ font["a:cs"] = { "@_typeface": "" };
145257
+ }
145258
+ return font;
145259
+ }
145260
+ function applyFontSchemeToThemeXml(data, fontScheme) {
145261
+ const themeElements = themeElementsOf(data);
145262
+ if (!themeElements) {
145263
+ return false;
145264
+ }
145265
+ const fntScheme = themeElements["a:fontScheme"] ?? {};
145266
+ if (fontScheme.majorFont?.latin) {
145267
+ fntScheme["a:majorFont"] = applyLatinTypeface(
145268
+ fntScheme["a:majorFont"],
145269
+ fontScheme.majorFont.latin
145270
+ );
145271
+ }
145272
+ if (fontScheme.minorFont?.latin) {
145273
+ fntScheme["a:minorFont"] = applyLatinTypeface(
145274
+ fntScheme["a:minorFont"],
145275
+ fontScheme.minorFont.latin
145276
+ );
145277
+ }
145278
+ themeElements["a:fontScheme"] = fntScheme;
145279
+ return true;
145280
+ }
145281
+ function applyColorSchemeToMap(map2, colorScheme, clrMap) {
145282
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145283
+ map2[key2] = normalizeHex6(colorScheme[key2]);
145284
+ }
145285
+ for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
145286
+ const target = clrMap?.[alias] ?? defaultTarget;
145287
+ const resolved = map2[target];
145288
+ if (resolved !== void 0) {
145289
+ map2[alias] = resolved;
145290
+ }
145291
+ }
145292
+ }
145293
+ function applyFontSchemeToMap(map2, fontScheme) {
145294
+ if (fontScheme.majorFont?.latin) {
145295
+ map2["mj-lt"] = fontScheme.majorFont.latin;
145296
+ map2["mj-ea"] = fontScheme.majorFont.latin;
145297
+ map2["mj-cs"] = fontScheme.majorFont.latin;
145298
+ }
145299
+ if (fontScheme.minorFont?.latin) {
145300
+ map2["mn-lt"] = fontScheme.minorFont.latin;
145301
+ map2["mn-ea"] = fontScheme.minorFont.latin;
145302
+ map2["mn-cs"] = fontScheme.minorFont.latin;
145303
+ }
145304
+ }
145305
+ var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
145306
+ var init_theme_scheme_edit = __esm({
145307
+ "pptx/core/core/runtime/theme-scheme-edit.ts"() {
145308
+ THEME_COLOR_SCHEME_KEYS2 = [
145309
+ "dk1",
145310
+ "lt1",
145311
+ "dk2",
145312
+ "lt2",
145313
+ "accent1",
145314
+ "accent2",
145315
+ "accent3",
145316
+ "accent4",
145317
+ "accent5",
145318
+ "accent6",
145319
+ "hlink",
145320
+ "folHlink"
145321
+ ];
145322
+ DEFAULT_CLR_MAP_ALIASES = {
145323
+ tx1: "dk1",
145324
+ bg1: "lt1",
145325
+ tx2: "dk2",
145326
+ bg2: "lt2"
145327
+ };
145328
+ }
145329
+ });
145330
+
145331
+ // pptx/core/core/runtime/theme-part-model.ts
145332
+ function colorSchemeFromMap(colorMap) {
145333
+ const scheme = {};
145334
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145335
+ scheme[key2] = colorMap[key2] || "";
145336
+ }
145337
+ return scheme;
145338
+ }
145339
+ function fontGroup(fontMap, prefix, byScript) {
145340
+ const latin = fontMap[`${prefix}-lt`];
145341
+ const eastAsia = fontMap[`${prefix}-ea`];
145342
+ const complexScript = fontMap[`${prefix}-cs`];
145343
+ return {
145344
+ ...latin ? { latin } : {},
145345
+ ...eastAsia ? { eastAsia } : {},
145346
+ ...complexScript ? { complexScript } : {},
145347
+ ...Object.keys(byScript).length > 0 ? { byScript: { ...byScript } } : {}
145348
+ };
145349
+ }
145350
+ function fontSchemeFromMap(fontMap, majorByScript, minorByScript) {
145351
+ return {
145352
+ majorFont: fontGroup(fontMap, "mj", majorByScript),
145353
+ minorFont: fontGroup(fontMap, "mn", minorByScript)
145354
+ };
145355
+ }
145356
+ var init_theme_part_model = __esm({
145357
+ "pptx/core/core/runtime/theme-part-model.ts"() {
145358
+ init_theme_scheme_edit();
145359
+ }
145360
+ });
145361
+
145362
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts
145363
+ var FONT_SLOTS, PptxHandlerRuntime84;
145364
+ var init_PptxHandlerRuntimeThemePartModel = __esm({
145365
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts"() {
145366
+ init_PptxHandlerRuntimeThemeRefResolution();
145367
+ init_theme_part_model();
145368
+ init_theme_scheme_edit();
145369
+ FONT_SLOTS = [
145370
+ ["mj", "a:majorFont"],
145371
+ ["mn", "a:minorFont"]
145372
+ ];
145373
+ PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
145374
+ /** Parse one theme part's XML. Side-effect free. */
145375
+ parseThemePartXml(themeXml3) {
145376
+ const themeData = this.parser.parse(themeXml3);
145377
+ const themeRoot = themeData["a:theme"];
145378
+ const themeElements = themeRoot?.["a:themeElements"];
145379
+ const colorScheme = themeElements?.["a:clrScheme"];
145380
+ const fontScheme = themeElements?.["a:fontScheme"];
145381
+ const fmtScheme = themeElements?.["a:fmtScheme"];
145382
+ const text2 = (value) => String(value || "").trim() || void 0;
145383
+ const colorMap = { ...this.getDefaultSchemeColorMap() };
145384
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145385
+ const parsed = this.parseColorChoice(colorScheme?.[`a:${key2}`]);
145386
+ if (parsed) {
145387
+ colorMap[key2] = parsed;
145388
+ }
145389
+ }
145390
+ const fontMap = {};
145391
+ const typeface = (node2) => this.normalizeTypefaceToken(String(node2?.["@_typeface"] || ""));
145392
+ for (const [prefix, tag] of FONT_SLOTS) {
145393
+ const group = fontScheme?.[tag];
145394
+ const latin = typeface(group?.["a:latin"]);
145395
+ if (latin) {
145396
+ fontMap[`${prefix}-lt`] = latin;
145397
+ fontMap[`${prefix}-ea`] = latin;
145398
+ fontMap[`${prefix}-cs`] = latin;
145399
+ }
145400
+ const eastAsia = typeface(group?.["a:ea"]);
145401
+ if (eastAsia) {
145402
+ fontMap[`${prefix}-ea`] = eastAsia;
145403
+ }
145404
+ const complexScript = typeface(group?.["a:cs"]);
145405
+ if (complexScript) {
145406
+ fontMap[`${prefix}-cs`] = complexScript;
145407
+ }
145408
+ }
145409
+ const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
145410
+ const objectDefaults = objectDefaultsNode && {
145411
+ spDef: objectDefaultsNode["a:spDef"],
145412
+ lnDef: objectDefaultsNode["a:lnDef"],
145413
+ txDef: objectDefaultsNode["a:txDef"]
145414
+ };
145415
+ const hasObjectDefaults = objectDefaults !== void 0 && (objectDefaults.spDef !== void 0 || objectDefaults.lnDef !== void 0 || objectDefaults.txDef !== void 0);
145416
+ return {
145417
+ name: text2(themeRoot?.["@_name"]),
145418
+ colorSchemeName: text2(colorScheme?.["@_name"]),
145419
+ fontSchemeName: text2(fontScheme?.["@_name"]),
145420
+ colorMap,
145421
+ fontMap,
145422
+ // Per-script fonts (`<a:font script="Hans|Hant|Arab|...">`): M4.
145423
+ majorFontScripts: this.collectFontScriptOverrides(
145424
+ fontScheme?.["a:majorFont"]
145425
+ ),
145426
+ minorFontScripts: this.collectFontScriptOverrides(
145427
+ fontScheme?.["a:minorFont"]
145428
+ ),
145429
+ // objectDefaults: M5.
145430
+ objectDefaults: hasObjectDefaults ? objectDefaults : void 0,
145431
+ extraClrSchemeLst: themeRoot?.["a:extraClrSchemeLst"],
145432
+ custClrLst: themeRoot?.["a:custClrLst"],
145433
+ extLst: themeRoot?.["a:extLst"],
145434
+ formatScheme: fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0
145435
+ };
145436
+ }
145437
+ /**
145438
+ * Record a parsed part under its path: its original XML (byte-stable passthrough on save,
145439
+ * C-H3), its names, per-script fonts and the raw subtrees the save re-emits.
145440
+ */
145441
+ cacheThemePartModel(themePath, themeXml3, model) {
145442
+ this.originalThemeXmlByPath.set(themePath, themeXml3);
145443
+ const keyed = [
145444
+ [this.masterThemeNames, model.name],
145445
+ [this.masterThemeColorSchemeNames, model.colorSchemeName],
145446
+ [this.masterThemeFontSchemeNames, model.fontSchemeName],
145447
+ [this.masterThemeObjectDefaults, model.objectDefaults],
145448
+ [this.masterThemeExtraClrSchemeLst, model.extraClrSchemeLst],
145449
+ [this.masterThemeCustClrLst, model.custClrLst],
145450
+ [this.masterThemeExtLst, model.extLst]
145451
+ ];
145452
+ for (const [map2, value] of keyed) {
145453
+ if (value !== void 0) {
145454
+ map2.set(themePath, value);
145455
+ }
145456
+ }
145457
+ if (Object.keys(model.majorFontScripts).length > 0) {
145458
+ this.masterThemeMajorFontScripts.set(themePath, model.majorFontScripts);
145459
+ }
145460
+ if (Object.keys(model.minorFontScripts).length > 0) {
145461
+ this.masterThemeMinorFontScripts.set(themePath, model.minorFontScripts);
145462
+ }
145463
+ }
145464
+ /**
145465
+ * Parse `<a:font script="..." typeface="..."/>` children of a major or minor font node into a
145466
+ * `script -> typeface` dictionary. fast-xml-parser collapses repeated tags into arrays, so the
145467
+ * array form is walked regardless of how many siblings are present. Phase 4 Stream A / M4.
145468
+ */
145469
+ collectFontScriptOverrides(fontNode) {
145470
+ const overrides = {};
145471
+ if (!fontNode) {
145472
+ return overrides;
145473
+ }
145474
+ const fontEntries = this.ensureArray(fontNode["a:font"]);
145475
+ for (const entry2 of fontEntries) {
145476
+ const script = String(entry2?.["@_script"] || "").trim();
145477
+ const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
145478
+ if (script && typeface) {
145479
+ overrides[script] = typeface;
145480
+ }
145481
+ }
145482
+ return overrides;
145483
+ }
145484
+ /**
145485
+ * The colour, font and format schemes and name of one theme part in the package, as the part holds
145486
+ * them now (a scheme edit already written to it included). Reads only: the loaded theme, the
145487
+ * masters and what a save writes are unchanged. `undefined` when the package has no such part.
145488
+ */
145489
+ async getThemePartSchemes(themePath) {
145490
+ const path4 = themePath.trim().replace(/\\/g, "/");
145491
+ const themeXml3 = await this.zip.file(path4)?.async("string");
145492
+ if (themeXml3 === void 0) {
145493
+ return void 0;
145494
+ }
145495
+ const model = this.parseThemePartXml(themeXml3);
145496
+ return {
145497
+ path: path4,
145498
+ ...model.name ? { name: model.name } : {},
145499
+ colorScheme: colorSchemeFromMap(model.colorMap),
145500
+ fontScheme: fontSchemeFromMap(model.fontMap, model.majorFontScripts, model.minorFontScripts),
145501
+ ...model.formatScheme ? { formatScheme: model.formatScheme } : {}
145502
+ };
145503
+ }
145504
+ };
145505
+ }
145506
+ });
145507
+
145073
145508
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts
145074
145509
  function isPresentationThemePartPath(path4) {
145075
145510
  return /^ppt\/theme\/(?!themeOverride)[^/]+\.xml$/iu.test(path4);
145076
145511
  }
145077
- var PptxHandlerRuntime84;
145512
+ var PptxHandlerRuntime85;
145078
145513
  var init_PptxHandlerRuntimeThemeLoading = __esm({
145079
145514
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts"() {
145080
- init_PptxHandlerRuntimeThemeRefResolution();
145081
- PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
145515
+ init_PptxHandlerRuntimeThemePartModel();
145516
+ init_theme_part_model();
145517
+ PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
145082
145518
  async resolvePrimaryThemePath() {
145083
145519
  const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
145084
145520
  if (!masterFiles || masterFiles.length === 0) {
@@ -145154,42 +145590,12 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145154
145590
  if (!hasColors && !hasFonts) {
145155
145591
  return void 0;
145156
145592
  }
145157
- let colorScheme;
145158
- if (hasColors) {
145159
- colorScheme = {
145160
- dk1: this.themeColorMap["dk1"] || "",
145161
- lt1: this.themeColorMap["lt1"] || "",
145162
- dk2: this.themeColorMap["dk2"] || "",
145163
- lt2: this.themeColorMap["lt2"] || "",
145164
- accent1: this.themeColorMap["accent1"] || "",
145165
- accent2: this.themeColorMap["accent2"] || "",
145166
- accent3: this.themeColorMap["accent3"] || "",
145167
- accent4: this.themeColorMap["accent4"] || "",
145168
- accent5: this.themeColorMap["accent5"] || "",
145169
- accent6: this.themeColorMap["accent6"] || "",
145170
- hlink: this.themeColorMap["hlink"] || "",
145171
- folHlink: this.themeColorMap["folHlink"] || ""
145172
- };
145173
- }
145174
- let fontScheme;
145175
- if (hasFonts) {
145176
- const majorByScript = this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts);
145177
- const minorByScript = this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts);
145178
- fontScheme = {
145179
- majorFont: {
145180
- latin: this.themeFontMap["mj-lt"],
145181
- eastAsia: this.themeFontMap["mj-ea"],
145182
- complexScript: this.themeFontMap["mj-cs"],
145183
- ...Object.keys(majorByScript).length > 0 ? { byScript: majorByScript } : {}
145184
- },
145185
- minorFont: {
145186
- latin: this.themeFontMap["mn-lt"],
145187
- eastAsia: this.themeFontMap["mn-ea"],
145188
- complexScript: this.themeFontMap["mn-cs"],
145189
- ...Object.keys(minorByScript).length > 0 ? { byScript: minorByScript } : {}
145190
- }
145191
- };
145192
- }
145593
+ const colorScheme = hasColors ? colorSchemeFromMap(this.themeColorMap) : void 0;
145594
+ const fontScheme = hasFonts ? fontSchemeFromMap(
145595
+ this.themeFontMap,
145596
+ this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts),
145597
+ this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts)
145598
+ ) : void 0;
145193
145599
  return {
145194
145600
  colorScheme,
145195
145601
  fontScheme,
@@ -145266,134 +145672,10 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145266
145672
  return null;
145267
145673
  }
145268
145674
  const themeXml3 = await themeFile.async("string");
145269
- this.originalThemeXmlByPath.set(themePath, themeXml3);
145270
- const themeData = this.parser.parse(themeXml3);
145271
- const themeRoot = themeData["a:theme"];
145272
- const themeElements = themeRoot?.["a:themeElements"];
145273
- const colorScheme = themeElements?.["a:clrScheme"];
145274
- const fontScheme = themeElements?.["a:fontScheme"];
145275
- const fmtScheme = themeElements?.["a:fmtScheme"];
145276
- const themeName = String(themeRoot?.["@_name"] || "").trim();
145277
- if (themeName) {
145278
- this.masterThemeNames.set(themePath, themeName);
145279
- }
145280
- const colorSchemeName = String(colorScheme?.["@_name"] || "").trim();
145281
- if (colorSchemeName) {
145282
- this.masterThemeColorSchemeNames.set(themePath, colorSchemeName);
145283
- }
145284
- const fontSchemeName = String(fontScheme?.["@_name"] || "").trim();
145285
- if (fontSchemeName) {
145286
- this.masterThemeFontSchemeNames.set(themePath, fontSchemeName);
145287
- }
145288
- const defaultMap = this.getDefaultSchemeColorMap();
145289
- const colorMap = { ...defaultMap };
145290
- if (colorScheme) {
145291
- const schemeKeys = [
145292
- "dk1",
145293
- "lt1",
145294
- "dk2",
145295
- "lt2",
145296
- "accent1",
145297
- "accent2",
145298
- "accent3",
145299
- "accent4",
145300
- "accent5",
145301
- "accent6",
145302
- "hlink",
145303
- "folHlink"
145304
- ];
145305
- for (const key2 of schemeKeys) {
145306
- const colorNode = colorScheme[`a:${key2}`];
145307
- const parsed = this.parseColorChoice(colorNode);
145308
- if (parsed) {
145309
- colorMap[key2] = parsed;
145310
- }
145311
- }
145312
- }
145313
- const majorFontNode = fontScheme?.["a:majorFont"];
145314
- const minorFontNode = fontScheme?.["a:minorFont"];
145315
- const majorLatin = majorFontNode?.["a:latin"];
145316
- const minorLatin = minorFontNode?.["a:latin"];
145317
- const majorFont = this.normalizeTypefaceToken(String(majorLatin?.["@_typeface"] || ""));
145318
- const minorFont = this.normalizeTypefaceToken(String(minorLatin?.["@_typeface"] || ""));
145319
- const fontMap = {};
145320
- if (majorFont) {
145321
- fontMap["mj-lt"] = majorFont;
145322
- fontMap["mj-ea"] = majorFont;
145323
- fontMap["mj-cs"] = majorFont;
145324
- }
145325
- if (minorFont) {
145326
- fontMap["mn-lt"] = minorFont;
145327
- fontMap["mn-ea"] = minorFont;
145328
- fontMap["mn-cs"] = minorFont;
145329
- }
145330
- const majorEa = this.normalizeTypefaceToken(
145331
- String(majorFontNode?.["a:ea"]?.["@_typeface"] || "")
145332
- );
145333
- if (majorEa) {
145334
- fontMap["mj-ea"] = majorEa;
145335
- }
145336
- const majorCs = this.normalizeTypefaceToken(
145337
- String(majorFontNode?.["a:cs"]?.["@_typeface"] || "")
145338
- );
145339
- if (majorCs) {
145340
- fontMap["mj-cs"] = majorCs;
145341
- }
145342
- const minorEa = this.normalizeTypefaceToken(
145343
- String(minorFontNode?.["a:ea"]?.["@_typeface"] || "")
145344
- );
145345
- if (minorEa) {
145346
- fontMap["mn-ea"] = minorEa;
145347
- }
145348
- const minorCs = this.normalizeTypefaceToken(
145349
- String(minorFontNode?.["a:cs"]?.["@_typeface"] || "")
145350
- );
145351
- if (minorCs) {
145352
- fontMap["mn-cs"] = minorCs;
145353
- }
145354
- const majorScripts = this.collectFontScriptOverrides(majorFontNode);
145355
- if (Object.keys(majorScripts).length > 0) {
145356
- this.masterThemeMajorFontScripts.set(themePath, majorScripts);
145357
- }
145358
- const minorScripts = this.collectFontScriptOverrides(minorFontNode);
145359
- if (Object.keys(minorScripts).length > 0) {
145360
- this.masterThemeMinorFontScripts.set(themePath, minorScripts);
145361
- }
145362
- const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
145363
- if (objectDefaultsNode) {
145364
- const od = {
145365
- spDef: objectDefaultsNode["a:spDef"],
145366
- lnDef: objectDefaultsNode["a:lnDef"],
145367
- txDef: objectDefaultsNode["a:txDef"]
145368
- };
145369
- if (od.spDef !== void 0 || od.lnDef !== void 0 || od.txDef !== void 0) {
145370
- this.masterThemeObjectDefaults.set(themePath, od);
145371
- }
145372
- }
145373
- const extraClrSchemeLst = themeRoot?.["a:extraClrSchemeLst"];
145374
- if (extraClrSchemeLst !== void 0) {
145375
- this.masterThemeExtraClrSchemeLst.set(themePath, extraClrSchemeLst);
145376
- }
145377
- const custClrLst = themeRoot?.["a:custClrLst"];
145378
- if (custClrLst !== void 0) {
145379
- this.masterThemeCustClrLst.set(themePath, custClrLst);
145380
- }
145381
- const themeExtLst = themeRoot?.["a:extLst"];
145382
- if (themeExtLst !== void 0) {
145383
- this.masterThemeExtLst.set(themePath, themeExtLst);
145384
- }
145385
- const formatScheme = fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0;
145386
- return { colorMap, fontMap, formatScheme };
145675
+ const model = this.parseThemePartXml(themeXml3);
145676
+ this.cacheThemePartModel(themePath, themeXml3, model);
145677
+ return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
145387
145678
  }
145388
- /**
145389
- * Parse `<a:font script="…" typeface="…"/>` children of a major or
145390
- * minor font node into a `script -> typeface` dictionary.
145391
- *
145392
- * fast-xml-parser collapses repeated tags into arrays, so iterate
145393
- * over the array form regardless of how many siblings are present.
145394
- *
145395
- * Phase 4 Stream A / M4.
145396
- */
145397
145679
  /**
145398
145680
  * Flatten a per-theme-path script-override map (`themePath -> {script ->
145399
145681
  * typeface}`) into a single `{script -> typeface}` lookup for
@@ -145411,21 +145693,6 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145411
145693
  }
145412
145694
  return aggregate;
145413
145695
  }
145414
- collectFontScriptOverrides(fontNode) {
145415
- const overrides = {};
145416
- if (!fontNode) {
145417
- return overrides;
145418
- }
145419
- const fontEntries = this.ensureArray(fontNode["a:font"]);
145420
- for (const entry2 of fontEntries) {
145421
- const script = String(entry2?.["@_script"] || "").trim();
145422
- const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
145423
- if (script && typeface) {
145424
- overrides[script] = typeface;
145425
- }
145426
- }
145427
- return overrides;
145428
- }
145429
145696
  /**
145430
145697
  * Resolve the theme file path referenced by a given master's `.rels`.
145431
145698
  * Returns `undefined` when the master has no theme relationship.
@@ -145511,119 +145778,14 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
145511
145778
  }
145512
145779
  });
145513
145780
 
145514
- // pptx/core/core/runtime/theme-scheme-edit.ts
145515
- function normalizeHex6(hex5) {
145516
- return hex5.replace(/^#/, "").toUpperCase();
145517
- }
145518
- function buildSrgbClrNode(hex5) {
145519
- return { "a:srgbClr": { "@_val": normalizeHex6(hex5) } };
145520
- }
145521
- function themeElementsOf(data) {
145522
- const root = data["a:theme"];
145523
- return root?.["a:themeElements"];
145524
- }
145525
- function applyColorSchemeToThemeXml(data, colorScheme) {
145526
- const themeElements = themeElementsOf(data);
145527
- if (!themeElements) {
145528
- return false;
145529
- }
145530
- const clrScheme = themeElements["a:clrScheme"] ?? {};
145531
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145532
- clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
145533
- }
145534
- themeElements["a:clrScheme"] = clrScheme;
145535
- return true;
145536
- }
145537
- function applyLatinTypeface(group, latin) {
145538
- const font = group ?? {};
145539
- font["a:latin"] = { "@_typeface": latin };
145540
- if (!font["a:ea"]) {
145541
- font["a:ea"] = { "@_typeface": "" };
145542
- }
145543
- if (!font["a:cs"]) {
145544
- font["a:cs"] = { "@_typeface": "" };
145545
- }
145546
- return font;
145547
- }
145548
- function applyFontSchemeToThemeXml(data, fontScheme) {
145549
- const themeElements = themeElementsOf(data);
145550
- if (!themeElements) {
145551
- return false;
145552
- }
145553
- const fntScheme = themeElements["a:fontScheme"] ?? {};
145554
- if (fontScheme.majorFont?.latin) {
145555
- fntScheme["a:majorFont"] = applyLatinTypeface(
145556
- fntScheme["a:majorFont"],
145557
- fontScheme.majorFont.latin
145558
- );
145559
- }
145560
- if (fontScheme.minorFont?.latin) {
145561
- fntScheme["a:minorFont"] = applyLatinTypeface(
145562
- fntScheme["a:minorFont"],
145563
- fontScheme.minorFont.latin
145564
- );
145565
- }
145566
- themeElements["a:fontScheme"] = fntScheme;
145567
- return true;
145568
- }
145569
- function applyColorSchemeToMap(map2, colorScheme, clrMap) {
145570
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
145571
- map2[key2] = normalizeHex6(colorScheme[key2]);
145572
- }
145573
- for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
145574
- const target = clrMap?.[alias] ?? defaultTarget;
145575
- const resolved = map2[target];
145576
- if (resolved !== void 0) {
145577
- map2[alias] = resolved;
145578
- }
145579
- }
145580
- }
145581
- function applyFontSchemeToMap(map2, fontScheme) {
145582
- if (fontScheme.majorFont?.latin) {
145583
- map2["mj-lt"] = fontScheme.majorFont.latin;
145584
- map2["mj-ea"] = fontScheme.majorFont.latin;
145585
- map2["mj-cs"] = fontScheme.majorFont.latin;
145586
- }
145587
- if (fontScheme.minorFont?.latin) {
145588
- map2["mn-lt"] = fontScheme.minorFont.latin;
145589
- map2["mn-ea"] = fontScheme.minorFont.latin;
145590
- map2["mn-cs"] = fontScheme.minorFont.latin;
145591
- }
145592
- }
145593
- var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
145594
- var init_theme_scheme_edit = __esm({
145595
- "pptx/core/core/runtime/theme-scheme-edit.ts"() {
145596
- THEME_COLOR_SCHEME_KEYS2 = [
145597
- "dk1",
145598
- "lt1",
145599
- "dk2",
145600
- "lt2",
145601
- "accent1",
145602
- "accent2",
145603
- "accent3",
145604
- "accent4",
145605
- "accent5",
145606
- "accent6",
145607
- "hlink",
145608
- "folHlink"
145609
- ];
145610
- DEFAULT_CLR_MAP_ALIASES = {
145611
- tx1: "dk1",
145612
- bg1: "lt1",
145613
- tx2: "dk2",
145614
- bg2: "lt2"
145615
- };
145616
- }
145617
- });
145618
-
145619
145781
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts
145620
- var THEME_PART_PATTERN, PptxHandlerRuntime85;
145782
+ var THEME_PART_PATTERN, PptxHandlerRuntime86;
145621
145783
  var init_PptxHandlerRuntimeThemeProcessing = __esm({
145622
145784
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts"() {
145623
145785
  init_PptxHandlerRuntimeThemeLoading();
145624
145786
  init_theme_scheme_edit();
145625
145787
  THEME_PART_PATTERN = /^ppt\/theme\/theme\d+\.xml$/;
145626
- PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
145788
+ PptxHandlerRuntime86 = class extends PptxHandlerRuntime85 {
145627
145789
  /**
145628
145790
  * The theme parts an edit should touch, primary theme first.
145629
145791
  *
@@ -145664,8 +145826,9 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145664
145826
  return this.parser.parse(xml);
145665
145827
  }
145666
145828
  /**
145667
- * Parse, edit, and write back every target theme part. Parts the edit
145668
- * cannot apply to (no `a:themeElements`) are left untouched.
145829
+ * Parse, edit, and write back every target theme part (`edit` gets the
145830
+ * part's path too). Parts the edit cannot apply to (no `a:themeElements`)
145831
+ * are left untouched.
145669
145832
  *
145670
145833
  * @returns the paths that were rewritten
145671
145834
  */
@@ -145673,7 +145836,7 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145673
145836
  const written = [];
145674
145837
  for (const path4 of await this.resolveThemeEditTargets(themePaths)) {
145675
145838
  const data = await this.readThemePart(path4);
145676
- if (!data || !edit(data)) {
145839
+ if (!data || !edit(data, path4)) {
145677
145840
  continue;
145678
145841
  }
145679
145842
  this.zip.file(path4, this.builder.build(data));
@@ -145777,15 +145940,90 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
145777
145940
  }
145778
145941
  });
145779
145942
 
145943
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts
145944
+ function themePartPath(themePath) {
145945
+ const path4 = themePath.trim().replace(/\\/g, "/");
145946
+ return path4.startsWith("ppt/theme/") ? path4 : void 0;
145947
+ }
145948
+ var SLIDE_MASTER_PART, PptxHandlerRuntime87;
145949
+ var init_PptxHandlerRuntimeThemeSwitching = __esm({
145950
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts"() {
145951
+ init_PptxHandlerRuntimeThemeProcessing();
145952
+ SLIDE_MASTER_PART = /^ppt\/slideMasters\/slideMaster\d+\.xml$/;
145953
+ PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
145954
+ /**
145955
+ * Point the first slide master, or every one, at a theme part already in the package. Does
145956
+ * nothing when the package has no such part.
145957
+ */
145958
+ async setPresentationTheme(themePath, applyToAllMasters = true) {
145959
+ const path4 = themePartPath(themePath);
145960
+ if (!path4 || !this.zip.file(path4)) {
145961
+ return;
145962
+ }
145963
+ const masters = this.zip.file(SLIDE_MASTER_PART);
145964
+ for (const master of applyToAllMasters ? masters : masters.slice(0, 1)) {
145965
+ await this.retargetMasterTheme(master.name, path4);
145966
+ }
145967
+ }
145968
+ /**
145969
+ * Point one slide master at a theme part already in the package (Undo of a theme switch puts
145970
+ * each master back on its own part). Does nothing when the package has no such master or part.
145971
+ */
145972
+ async setSlideMasterTheme(masterPath, themePath) {
145973
+ const path4 = themePartPath(themePath);
145974
+ if (!path4 || !this.zip.file(path4) || !SLIDE_MASTER_PART.test(masterPath)) {
145975
+ return;
145976
+ }
145977
+ if (this.zip.file(masterPath)) {
145978
+ await this.retargetMasterTheme(masterPath, path4);
145979
+ }
145980
+ }
145981
+ async retargetMasterTheme(masterPath, themePath) {
145982
+ if (await this.setMasterThemeRelationship(masterPath, themePath)) {
145983
+ await this.adoptMasterTheme(masterPath, themePath);
145984
+ }
145985
+ }
145986
+ /** Point the runtime's theme state for `masterPath` at the part it now uses. */
145987
+ async adoptMasterTheme(masterPath, themePath) {
145988
+ const themeXml3 = await this.zip.file(themePath)?.async("string");
145989
+ if (themeXml3 === void 0) {
145990
+ return;
145991
+ }
145992
+ const model = this.parseThemePartXml(themeXml3);
145993
+ if (!this.originalThemeXmlByPath.has(themePath)) {
145994
+ this.cacheThemePartModel(themePath, themeXml3, model);
145995
+ }
145996
+ this.masterThemePaths.set(masterPath, themePath);
145997
+ this.masterThemeColorMaps.set(masterPath, { ...model.colorMap });
145998
+ this.masterThemeFontMaps.set(masterPath, { ...model.fontMap });
145999
+ if (model.formatScheme) {
146000
+ this.masterThemeFormatSchemes.set(masterPath, model.formatScheme);
146001
+ } else {
146002
+ this.masterThemeFormatSchemes.delete(masterPath);
146003
+ }
146004
+ if (this.zip.file(SLIDE_MASTER_PART)[0]?.name !== masterPath) {
146005
+ return;
146006
+ }
146007
+ this.themeColorMap = { ...model.colorMap };
146008
+ this.themeFontMap = { ...model.fontMap };
146009
+ this.themeFormatScheme = model.formatScheme;
146010
+ this.globalThemeColorMapSnapshot = { ...model.colorMap };
146011
+ this.globalThemeFontMapSnapshot = { ...model.fontMap };
146012
+ this.globalThemeFormatSchemeSnapshot = model.formatScheme;
146013
+ }
146014
+ };
146015
+ }
146016
+ });
146017
+
145780
146018
  // pptx/core/core/runtime/PptxHandlerRuntimeComments.ts
145781
- var PptxHandlerRuntime86;
146019
+ var PptxHandlerRuntime88;
145782
146020
  var init_PptxHandlerRuntimeComments = __esm({
145783
146021
  "pptx/core/core/runtime/PptxHandlerRuntimeComments.ts"() {
145784
146022
  init_legacy_comment_threading();
145785
146023
  init_modern_comment_xml();
145786
146024
  init_xml_access();
145787
- init_PptxHandlerRuntimeThemeProcessing();
145788
- PptxHandlerRuntime86 = class _PptxHandlerRuntime extends PptxHandlerRuntime85 {
146025
+ init_PptxHandlerRuntimeThemeSwitching();
146026
+ PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
145789
146027
  /**
145790
146028
  * Parse modern threaded comments (PowerPoint 2019+ / Office 365).
145791
146029
  * Modern comments use `p188:cmLst`/`p15:cmLst` roots within
@@ -146014,7 +146252,7 @@ var init_PptxHandlerRuntimeComments = __esm({
146014
146252
  });
146015
146253
 
146016
146254
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts
146017
- var PptxHandlerRuntime87;
146255
+ var PptxHandlerRuntime89;
146018
146256
  var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
146019
146257
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts"() {
146020
146258
  init_smartart_color_lists();
@@ -146022,7 +146260,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
146022
146260
  init_smart_art_text_helpers();
146023
146261
  init_PptxHandlerRuntimeComments();
146024
146262
  init_smartart_text_paragraphs();
146025
- PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
146263
+ PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
146026
146264
  async readXmlPartByRelationshipId(slidePath, relationshipId2) {
146027
146265
  const normalizedRelationshipId = String(relationshipId2 || "").trim();
146028
146266
  if (normalizedRelationshipId.length === 0) {
@@ -146626,7 +146864,7 @@ var init_smartart_text_style_resolution = __esm({
146626
146864
  });
146627
146865
 
146628
146866
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts
146629
- var PptxHandlerRuntime88;
146867
+ var PptxHandlerRuntime90;
146630
146868
  var init_PptxHandlerRuntimeSmartArtParsing = __esm({
146631
146869
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts"() {
146632
146870
  init_diagram();
@@ -146640,7 +146878,7 @@ var init_PptxHandlerRuntimeSmartArtParsing = __esm({
146640
146878
  init_smartart_style_label_refs();
146641
146879
  init_smartart_text_paragraphs();
146642
146880
  init_smartart_text_style_resolution();
146643
- PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
146881
+ PptxHandlerRuntime90 = class _PptxHandlerRuntime extends PptxHandlerRuntime89 {
146644
146882
  reportIncompleteSmartArtRelationships(graphicFrame, relationshipIds, slidePath) {
146645
146883
  const missing = [
146646
146884
  ["dm", relationshipIds?.dataRelId],
@@ -147035,7 +147273,7 @@ var init_smartart_layout_category = __esm({
147035
147273
  });
147036
147274
 
147037
147275
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts
147038
- var PptxHandlerRuntime89;
147276
+ var PptxHandlerRuntime91;
147039
147277
  var init_PptxHandlerRuntimeSmartArt = __esm({
147040
147278
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts"() {
147041
147279
  init_utils();
@@ -147050,7 +147288,7 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
147050
147288
  init_smartart_text_paragraphs();
147051
147289
  init_smartart_text_style_resolution();
147052
147290
  init_smartart_xml_builders();
147053
- PptxHandlerRuntime89 = class _PptxHandlerRuntime extends PptxHandlerRuntime88 {
147291
+ PptxHandlerRuntime91 = class _PptxHandlerRuntime extends PptxHandlerRuntime90 {
147054
147292
  async getSmartArtDataForGraphicFrame(slidePath, graphicFrame) {
147055
147293
  const graphicData = this.xmlLookupService.getChildByLocalName(
147056
147294
  this.xmlLookupService.getChildByLocalName(graphicFrame, "graphic"),
@@ -147226,12 +147464,12 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
147226
147464
  });
147227
147465
 
147228
147466
  // pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts
147229
- var PptxHandlerRuntime90;
147467
+ var PptxHandlerRuntime92;
147230
147468
  var init_PptxHandlerRuntimeChartDetection = __esm({
147231
147469
  "pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts"() {
147232
147470
  init_chart_multi_level_category_parser();
147233
147471
  init_PptxHandlerRuntimeSmartArt();
147234
- PptxHandlerRuntime90 = class extends PptxHandlerRuntime89 {
147472
+ PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
147235
147473
  detectChartType(plotArea) {
147236
147474
  if (!plotArea) {
147237
147475
  return "unknown";
@@ -147442,14 +147680,14 @@ function parseNumberVal(node2) {
147442
147680
  const num4 = Number.parseFloat(String(raw2));
147443
147681
  return Number.isFinite(num4) ? num4 : void 0;
147444
147682
  }
147445
- var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime91;
147683
+ var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime93;
147446
147684
  var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
147447
147685
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsingHelpers.ts"() {
147448
147686
  init_chart_ext_lookup();
147449
147687
  init_chart_pivot_source2();
147450
147688
  init_PptxHandlerRuntimeChartDetection();
147451
147689
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI2 = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
147452
- PptxHandlerRuntime91 = class extends PptxHandlerRuntime90 {
147690
+ PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
147453
147691
  /**
147454
147692
  * Parse `c:plotVisOnly` from the chart root element.
147455
147693
  *
@@ -147709,14 +147947,14 @@ var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
147709
147947
  });
147710
147948
 
147711
147949
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts
147712
- var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime92;
147950
+ var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime94;
147713
147951
  var init_PptxHandlerRuntimeChartExternalData = __esm({
147714
147952
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts"() {
147715
147953
  init_chart_user_shapes_parser();
147716
147954
  init_chart_xlsx_parser();
147717
147955
  init_PptxHandlerRuntimeChartParsingHelpers();
147718
147956
  CHART_USER_SHAPES_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
147719
- PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
147957
+ PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
147720
147958
  /**
147721
147959
  * Parse `c:externalData` from the chart's `c:chartSpace` and resolve
147722
147960
  * the external relationship target from the chart part's .rels file.
@@ -147878,12 +148116,12 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
147878
148116
  });
147879
148117
 
147880
148118
  // pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts
147881
- var PptxHandlerRuntime93;
148119
+ var PptxHandlerRuntime95;
147882
148120
  var init_PptxHandlerRuntimeChartColorStyle = __esm({
147883
148121
  "pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts"() {
147884
148122
  init_chart_style_definition_parser();
147885
148123
  init_PptxHandlerRuntimeChartExternalData();
147886
- PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
148124
+ PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
147887
148125
  /**
147888
148126
  * Parse the Office 2013+ chart-style part (`ppt/charts/style#.xml`)
147889
148127
  * referenced from the chart's relationships, sibling to
@@ -148044,7 +148282,7 @@ var init_PptxHandlerRuntimeChartColorStyle = __esm({
148044
148282
  });
148045
148283
 
148046
148284
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts
148047
- var PptxHandlerRuntime94;
148285
+ var PptxHandlerRuntime96;
148048
148286
  var init_PptxHandlerRuntimeChartExParsing = __esm({
148049
148287
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts"() {
148050
148288
  init_chart_cx_parser();
@@ -148054,7 +148292,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
148054
148292
  init_chart_protection2();
148055
148293
  init_chart_space_flags();
148056
148294
  init_PptxHandlerRuntimeChartColorStyle();
148057
- PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
148295
+ PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
148058
148296
  /**
148059
148297
  * The facts of a chart part that live outside the plot (or in other parts): the external data
148060
148298
  * reference and the embedded workbook's rows, pivot source and formats, the colour-style and
@@ -148174,7 +148412,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
148174
148412
  });
148175
148413
 
148176
148414
  // pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts
148177
- var PptxHandlerRuntime95;
148415
+ var PptxHandlerRuntime97;
148178
148416
  var init_PptxHandlerRuntimeChartParsing = __esm({
148179
148417
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
148180
148418
  init_chart_element_format_read_xml();
@@ -148196,7 +148434,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
148196
148434
  init_chart_element_pictures();
148197
148435
  init_chart_embedded_fallback();
148198
148436
  init_PptxHandlerRuntimeChartExParsing();
148199
- PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
148437
+ PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
148200
148438
  /**
148201
148439
  * Parse chart data from a graphic frame element on a slide.
148202
148440
  *
@@ -148480,7 +148718,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
148480
148718
  });
148481
148719
 
148482
148720
  // pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts
148483
- var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime96;
148721
+ var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime98;
148484
148722
  var init_PptxHandlerRuntimePresentationStructure = __esm({
148485
148723
  "pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts"() {
148486
148724
  init_kinsoku_parser();
@@ -148489,7 +148727,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
148489
148727
  init_PptxHandlerRuntimeChartParsing();
148490
148728
  XSD_INT_MIN = -2147483648;
148491
148729
  XSD_INT_MAX = 2147483647;
148492
- PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
148730
+ PptxHandlerRuntime98 = class extends PptxHandlerRuntime97 {
148493
148731
  parseEditorAnimations(slideXml3) {
148494
148732
  return this.editorAnimationService.parseEditorAnimations(slideXml3);
148495
148733
  }
@@ -148692,7 +148930,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
148692
148930
  });
148693
148931
 
148694
148932
  // pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts
148695
- var PptxHandlerRuntime97;
148933
+ var PptxHandlerRuntime99;
148696
148934
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148697
148935
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
148698
148936
  init_eot_parser();
@@ -148701,7 +148939,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148701
148939
  init_strip_parent_dir_segments();
148702
148940
  init_xml_access();
148703
148941
  init_PptxHandlerRuntimePresentationStructure();
148704
- PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
148942
+ PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
148705
148943
  async getEmbeddedFonts(fontList) {
148706
148944
  if (!fontList || fontList.fonts.length === 0) {
148707
148945
  return [];
@@ -148903,7 +149141,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
148903
149141
  };
148904
149142
  }
148905
149143
  });
148906
- var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime98;
149144
+ var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime100;
148907
149145
  var init_PptxHandlerRuntimeLoadSession = __esm({
148908
149146
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts"() {
148909
149147
  init_zip_limits();
@@ -148915,7 +149153,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
148915
149153
  init_bullet_picture_image_enrichment();
148916
149154
  init_PptxHandlerRuntimeEmbeddedFonts();
148917
149155
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
148918
- PptxHandlerRuntime98 = class _PptxHandlerRuntime extends PptxHandlerRuntime97 {
149156
+ PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
148919
149157
  isZipContainer(data) {
148920
149158
  const bytes = new Uint8Array(data);
148921
149159
  if (bytes.byteLength < 4) {
@@ -149283,7 +149521,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
149283
149521
  });
149284
149522
 
149285
149523
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts
149286
- var PptxHandlerRuntime99;
149524
+ var PptxHandlerRuntime101;
149287
149525
  var init_PptxHandlerRuntimeLoadPipeline = __esm({
149288
149526
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts"() {
149289
149527
  init_fluent();
@@ -149299,7 +149537,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
149299
149537
  init_layout_switch_placeholder_prompts();
149300
149538
  init_PptxHandlerRuntimeLoadSession();
149301
149539
  init_slide_fingerprint();
149302
- PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
149540
+ PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
149303
149541
  async buildLoadData(presentationState, slidesWithWarnings, slideMasters) {
149304
149542
  const headerFooter = this.extractHeaderFooter();
149305
149543
  const presentationProperties = await this.parsePresentationProperties();
@@ -149799,12 +150037,12 @@ function refIndex2(node2) {
149799
150037
  const idx = Number.parseInt(String(node2["@_idx"] ?? ""), 10);
149800
150038
  return Number.isFinite(idx) ? idx : void 0;
149801
150039
  }
149802
- var PptxHandlerRuntime100;
150040
+ var PptxHandlerRuntime102;
149803
150041
  var init_PptxHandlerRuntimeStyleMatrixResolve = __esm({
149804
150042
  "pptx/core/core/runtime/PptxHandlerRuntimeStyleMatrixResolve.ts"() {
149805
150043
  init_authored_shape_style();
149806
150044
  init_PptxHandlerRuntimeLoadPipeline();
149807
- PptxHandlerRuntime100 = class extends PptxHandlerRuntime99 {
150045
+ PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
149808
150046
  /**
149809
150047
  * Resolve a `<p:style>` node (`a:lnRef`, `a:fillRef`, `a:effectRef`,
149810
150048
  * `a:fontRef`) against the current theme's format scheme, with the same
@@ -149869,14 +150107,17 @@ function withKeys(style, from, keys) {
149869
150107
  function refNode(idx, colorXml2) {
149870
150108
  return { "@_idx": String(idx), ...colorXml2 ?? {} };
149871
150109
  }
149872
- var PptxHandlerRuntime101;
150110
+ var PptxHandlerRuntime103;
149873
150111
  var init_PptxHandlerRuntimeThemeEffects = __esm({
149874
150112
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeEffects.ts"() {
149875
150113
  init_theme_effect_schemes();
149876
150114
  init_authored_shape_style();
150115
+ init_held_format_schemes();
149877
150116
  init_PptxHandlerRuntimeStyleMatrixResolve();
149878
- PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
150117
+ PptxHandlerRuntime103 = class extends PptxHandlerRuntime102 {
149879
150118
  effectSchemeCache = /* @__PURE__ */ new Map();
150119
+ /** Every `a:fmtScheme` written into a theme part or over one ({@link restoreThemeFormatScheme}). */
150120
+ heldFormatSchemes = new HeldFormatSchemes();
149880
150121
  /**
149881
150122
  * Resolve a `<p:style>` node as the base class does, against built-in effect scheme
149882
150123
  * `effectSchemeId` instead of the deck's own (the Effects gallery draws each tile this way).
@@ -149929,32 +150170,79 @@ var init_PptxHandlerRuntimeThemeEffects = __esm({
149929
150170
  */
149930
150171
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
149931
150172
  const parsed = this.parseEffectScheme({ fmtSchemeXml });
149932
- if (!parsed) {
149933
- return void 0;
150173
+ return parsed ? this.writeFormatScheme(() => parsed.node) : void 0;
150174
+ }
150175
+ /**
150176
+ * Put back a format scheme the deck held before (Undo and Redo of an Effects pick), as the parts
150177
+ * held it: each theme part a master references gets back what it held the last time the deck's
150178
+ * scheme was `scheme` over those same parts, so a part with a scheme of its own gets its own back
150179
+ * (with no such time, `scheme`'s own element goes into every one). With `themePaths`, `scheme`'s
150180
+ * own element goes into those parts only.
150181
+ *
150182
+ * @returns the deck's format scheme now, or `undefined` (nothing written) for a scheme no part
150183
+ * held while this handler wrote into it
150184
+ */
150185
+ async restoreThemeFormatScheme(scheme, themePaths) {
150186
+ const parts = themePaths ? void 0 : this.heldFormatSchemes.parts(scheme, await this.resolveThemeEditTargets());
150187
+ if (parts) {
150188
+ return this.writeFormatScheme((path4) => parts.get(path4));
149934
150189
  }
149935
- const written = await this.rewriteThemeParts(void 0, (data) => {
150190
+ const element = this.heldFormatSchemes.element(scheme);
150191
+ return element ? this.writeFormatScheme(() => element, themePaths) : void 0;
150192
+ }
150193
+ /**
150194
+ * Write `elementFor(part)` into every theme part a master references (or only `themePaths`),
150195
+ * skipping a part it gives none, holding what each part held and now holds, and refresh the
150196
+ * in-memory format schemes of the masters on those parts and, when the deck's part is among
150197
+ * them, the deck's.
150198
+ */
150199
+ async writeFormatScheme(elementFor, themePaths) {
150200
+ const deckBefore = this.getThemeFormatScheme();
150201
+ const replaced = /* @__PURE__ */ new Map();
150202
+ const schemes = /* @__PURE__ */ new Map();
150203
+ const written = await this.rewriteThemeParts(themePaths, (data, path4) => {
150204
+ const element = elementFor(path4);
149936
150205
  const elements3 = data["a:theme"]?.["a:themeElements"];
149937
- if (!elements3) {
150206
+ if (!element || !elements3) {
149938
150207
  return false;
149939
150208
  }
149940
- elements3["a:fmtScheme"] = structuredClone(parsed.node);
150209
+ const previous = elements3["a:fmtScheme"];
150210
+ if (previous) {
150211
+ this.heldFormatSchemes.hold(this.parseFormatScheme(previous), previous);
150212
+ replaced.set(path4, structuredClone(previous));
150213
+ }
150214
+ const scheme = this.parseFormatScheme(element);
150215
+ this.heldFormatSchemes.hold(scheme, element);
150216
+ elements3["a:fmtScheme"] = structuredClone(element);
150217
+ schemes.set(path4, scheme);
149941
150218
  return true;
149942
150219
  });
149943
150220
  if (written.length === 0) {
149944
150221
  return void 0;
149945
150222
  }
150223
+ if (deckBefore) {
150224
+ this.heldFormatSchemes.holdParts(deckBefore, replaced);
150225
+ }
149946
150226
  for (const path4 of written) {
149947
150227
  const xml = await this.zip.file(path4)?.async("string");
149948
150228
  if (xml !== void 0) {
149949
150229
  this.originalThemeXmlByPath.set(path4, xml);
149950
150230
  }
150231
+ for (const masterPath of this.mastersUsingThemes([path4])) {
150232
+ this.masterThemeFormatSchemes.set(masterPath, schemes.get(path4));
150233
+ }
149951
150234
  }
149952
- for (const masterPath of this.mastersUsingThemes(written)) {
149953
- this.masterThemeFormatSchemes.set(masterPath, parsed.scheme);
150235
+ const primary = await this.resolvePrimaryThemePath();
150236
+ const deck = primary === void 0 ? void 0 : schemes.get(primary);
150237
+ if (deck) {
150238
+ this.globalThemeFormatSchemeSnapshot = deck;
150239
+ this.themeFormatScheme = deck;
150240
+ this.heldFormatSchemes.holdParts(
150241
+ deck,
150242
+ new Map(written.map((path4) => [path4, elementFor(path4)]))
150243
+ );
149954
150244
  }
149955
- this.globalThemeFormatSchemeSnapshot = parsed.scheme;
149956
- this.themeFormatScheme = parsed.scheme;
149957
- return parsed.scheme;
150245
+ return this.getThemeFormatScheme();
149958
150246
  }
149959
150247
  /** The real theme variants the loaded package carries, or none. */
149960
150248
  getThemeVariants() {
@@ -150080,7 +150368,7 @@ function schemeFromColorMap(map2) {
150080
150368
  folHlink: pick2("folHlink")
150081
150369
  };
150082
150370
  }
150083
- var PptxHandlerRuntime102;
150371
+ var PptxHandlerRuntime104;
150084
150372
  var init_PptxHandlerRuntimeBackgroundStyles = __esm({
150085
150373
  "pptx/core/core/runtime/PptxHandlerRuntimeBackgroundStyles.ts"() {
150086
150374
  init_background_style();
@@ -150088,7 +150376,7 @@ var init_PptxHandlerRuntimeBackgroundStyles = __esm({
150088
150376
  init_theme_switching();
150089
150377
  init_master_save_helpers();
150090
150378
  init_PptxHandlerRuntimeThemeEffects();
150091
- PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
150379
+ PptxHandlerRuntime104 = class extends PptxHandlerRuntime103 {
150092
150380
  resolveBackgroundStyle(preset) {
150093
150381
  const xml = {
150094
150382
  "p:sld": { "p:cSld": { "p:bg": backgroundRefNode(preset.idx, preset.scheme) } }
@@ -150348,14 +150636,14 @@ var init_sdk_placeholder = __esm({
150348
150636
  });
150349
150637
 
150350
150638
  // pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts
150351
- var PptxHandlerRuntime103;
150639
+ var PptxHandlerRuntime105;
150352
150640
  var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
150353
150641
  "pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts"() {
150354
150642
  init_placeholder_remap();
150355
150643
  init_xml_access();
150356
150644
  init_PptxHandlerRuntimeBackgroundStyles();
150357
150645
  init_sdk_placeholder();
150358
- PptxHandlerRuntime103 = class _PptxHandlerRuntime extends PptxHandlerRuntime102 {
150646
+ PptxHandlerRuntime105 = class _PptxHandlerRuntime extends PptxHandlerRuntime104 {
150359
150647
  createPlaceholderElement(layoutPath, input2, type, options) {
150360
150648
  if (input2.type !== "text") throw new Error("Placeholder input must be text");
150361
150649
  const layout = this.layoutXmlMap.get(layoutPath);
@@ -150409,14 +150697,14 @@ var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
150409
150697
  };
150410
150698
  }
150411
150699
  });
150412
- var PptxHandlerRuntime104;
150700
+ var PptxHandlerRuntime106;
150413
150701
  var init_PptxHandlerRuntimeImplementation = __esm({
150414
150702
  "pptx/core/core/runtime/PptxHandlerRuntimeImplementation.ts"() {
150415
150703
  init_PptxElementXmlBuilder();
150416
150704
  init_builders();
150417
150705
  init_factories();
150418
150706
  init_PptxHandlerRuntimeSdkPlaceholders();
150419
- PptxHandlerRuntime104 = class _PptxHandlerRuntime extends PptxHandlerRuntime103 {
150707
+ PptxHandlerRuntime106 = class _PptxHandlerRuntime extends PptxHandlerRuntime105 {
150420
150708
  constructor(dependencyFactory = new PptxRuntimeDependencyFactory()) {
150421
150709
  super();
150422
150710
  this.dependencyFactory = dependencyFactory;
@@ -150556,11 +150844,11 @@ var init_PptxHandlerRuntimeImplementation = __esm({
150556
150844
  });
150557
150845
 
150558
150846
  // pptx/core/core/PptxHandlerRuntime.ts
150559
- var PptxHandlerRuntime105;
150847
+ var PptxHandlerRuntime107;
150560
150848
  var init_PptxHandlerRuntime = __esm({
150561
150849
  "pptx/core/core/PptxHandlerRuntime.ts"() {
150562
150850
  init_PptxHandlerRuntimeImplementation();
150563
- PptxHandlerRuntime105 = class extends PptxHandlerRuntime104 {
150851
+ PptxHandlerRuntime107 = class extends PptxHandlerRuntime106 {
150564
150852
  };
150565
150853
  }
150566
150854
  });
@@ -150570,7 +150858,7 @@ var createDefaultPptxHandlerRuntime;
150570
150858
  var init_PptxHandlerRuntimeFactory = __esm({
150571
150859
  "pptx/core/core/PptxHandlerRuntimeFactory.ts"() {
150572
150860
  init_PptxHandlerRuntime();
150573
- createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime105();
150861
+ createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime107();
150574
150862
  }
150575
150863
  });
150576
150864
 
@@ -153829,10 +154117,32 @@ var init_PptxHandlerCore = __esm({
153829
154117
  async setPresentationTheme(themePath, applyToAllMasters = true) {
153830
154118
  await this.runtime.setPresentationTheme(themePath, applyToAllMasters);
153831
154119
  }
154120
+ /**
154121
+ * Point one slide master at a theme part already in the package; scheme edits and saves follow
154122
+ * it. Does nothing when the package has no such master or part.
154123
+ *
154124
+ * @param masterPath - The master's part path (e.g. `ppt/slideMasters/slideMaster2.xml`).
154125
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme1.xml`).
154126
+ */
154127
+ async setSlideMasterTheme(masterPath, themePath) {
154128
+ await this.runtime.setSlideMasterTheme(masterPath, themePath);
154129
+ }
154130
+ /**
154131
+ * Read one theme part's colour, font and format schemes and its name without changing the
154132
+ * loaded theme, for example to show what switching to it would apply.
154133
+ *
154134
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme2.xml`).
154135
+ * @returns The part's schemes, or `undefined` when the package has no such part.
154136
+ */
154137
+ async getThemePartSchemes(themePath) {
154138
+ return this.runtime.getThemePartSchemes(themePath);
154139
+ }
153832
154140
  /**
153833
154141
  * Modify the theme’s colour scheme (accent colours, background, text, etc.).
153834
154142
  *
153835
154143
  * @param colorScheme - A {@link PptxThemeColorScheme} with hex colour values.
154144
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154145
+ * master uses when omitted.
153836
154146
  *
153837
154147
  * @example
153838
154148
  * ```ts
@@ -153845,13 +154155,15 @@ var init_PptxHandlerCore = __esm({
153845
154155
  * // => void — colour scheme updated in the in-memory theme XML
153846
154156
  * ```
153847
154157
  */
153848
- async updateThemeColorScheme(colorScheme) {
153849
- await this.runtime.updateThemeColorScheme(colorScheme);
154158
+ async updateThemeColorScheme(colorScheme, themePaths) {
154159
+ await this.runtime.updateThemeColorScheme(colorScheme, themePaths);
153850
154160
  }
153851
154161
  /**
153852
154162
  * Update the theme’s font scheme (heading + body typefaces).
153853
154163
  *
153854
154164
  * @param fontScheme - A {@link PptxThemeFontScheme} with font family names.
154165
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154166
+ * master uses when omitted.
153855
154167
  *
153856
154168
  * @example
153857
154169
  * ```ts
@@ -153862,16 +154174,18 @@ var init_PptxHandlerCore = __esm({
153862
154174
  * // => void — font scheme updated in the in-memory theme XML
153863
154175
  * ```
153864
154176
  */
153865
- async updateThemeFontScheme(fontScheme) {
153866
- await this.runtime.updateThemeFontScheme(fontScheme);
154177
+ async updateThemeFontScheme(fontScheme, themePaths) {
154178
+ await this.runtime.updateThemeFontScheme(fontScheme, themePaths);
153867
154179
  }
153868
154180
  /**
153869
154181
  * Rename the presentation theme.
153870
154182
  *
153871
154183
  * @param name - New display name for the theme.
154184
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
154185
+ * master uses when omitted.
153872
154186
  */
153873
- async updateThemeName(name) {
153874
- await this.runtime.updateThemeName(name);
154187
+ async updateThemeName(name, themePaths) {
154188
+ await this.runtime.updateThemeName(name, themePaths);
153875
154189
  }
153876
154190
  /**
153877
154191
  * Resolve a `<p:style>` block (`a:lnRef` / `a:fillRef` / `a:effectRef` /
@@ -153894,6 +154208,14 @@ var init_PptxHandlerCore = __esm({
153894
154208
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
153895
154209
  return this.runtime.applyThemeFormatSchemeXml(fmtSchemeXml);
153896
154210
  }
154211
+ /**
154212
+ * Put a format scheme a theme part held before back into the theme parts (or only `themePaths`),
154213
+ * as the part held it: Undo and Redo of an Effects pick. Only a scheme this handler wrote into a
154214
+ * part or over one can come back; for any other it writes nothing and returns `undefined`.
154215
+ */
154216
+ async restoreThemeFormatScheme(scheme, themePaths) {
154217
+ return this.runtime.restoreThemeFormatScheme(scheme, themePaths);
154218
+ }
153897
154219
  /** The real theme variants the loaded package carries (`themeVariants/` parts), or none. */
153898
154220
  getThemeVariants() {
153899
154221
  return this.runtime.getThemeVariants();