ooxml-core 1.25.2 → 1.26.1

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 (103) hide show
  1. package/README.md +16 -0
  2. package/dist/{PptxHandler-AUK27AQD.mjs → PptxHandler-64BZOBWX.mjs} +3 -3
  3. package/dist/{PptxHandler-QBGEZDCO.cjs → PptxHandler-AILFLRH7.cjs} +3 -3
  4. package/dist/PptxHandler-PMLQGMFQ.mjs +4 -0
  5. package/dist/{PresentationBuilder-RX7D75GZ.mjs → PresentationBuilder-EJY2TYWL.mjs} +2 -2
  6. package/dist/{PresentationBuilder-MEETJGEA.mjs → PresentationBuilder-HBCCO2CF.mjs} +3 -3
  7. package/dist/{PresentationBuilder-CI45KEHL.cjs → PresentationBuilder-RBQP6A37.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-VGDHSED6.mjs → chunk-DHAZSMC7.mjs} +1 -1
  17. package/dist/{chunk-TX2QFS3J.mjs → chunk-FZBAMWCJ.mjs} +788 -542
  18. package/dist/{chunk-E2PYQQQV.mjs → chunk-JJ37PCNR.mjs} +89 -47
  19. package/dist/{chunk-S5TGOEQX.cjs → chunk-MU3XSASV.cjs} +106 -47
  20. package/dist/{chunk-GMETZZ3V.cjs → chunk-NXTHB2M3.cjs} +1857 -1611
  21. package/dist/{chunk-HVRFRYYS.mjs → chunk-OQPT5IC3.mjs} +5 -5
  22. package/dist/{chunk-5F7OB7PA.mjs → chunk-OTXJVFMY.mjs} +785 -539
  23. package/dist/{chunk-635WPRNJ.mjs → chunk-R7RL7W43.mjs} +19 -3
  24. package/dist/{chunk-E3PRAHL6.mjs → chunk-WRFMS5CL.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/load/index.cjs +89 -47
  30. package/dist/docx/load/index.mjs +89 -47
  31. package/dist/index.cjs +128 -53
  32. package/dist/index.mjs +128 -53
  33. package/dist/opc/index.cjs +90 -47
  34. package/dist/opc/index.mjs +90 -48
  35. package/dist/opc/zip-limits.d.ts +6 -0
  36. package/dist/opc/zip-limits.d.ts.map +1 -1
  37. package/dist/pptx/automation/index.cjs +954 -622
  38. package/dist/pptx/automation/index.d.ts +4 -4
  39. package/dist/pptx/automation/index.mjs +6 -6
  40. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts → index-CbFowkp4.d.ts} +12 -5
  41. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts.map → index-CbFowkp4.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts → index-D4FnOx6x.d.ts} +3 -3
  43. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts.map → index-D4FnOx6x.d.ts.map} +1 -1
  44. package/dist/pptx/chunks/{index-CgjEEpfK.d.ts → index-D8DNpc1X.d.ts} +289 -118
  45. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +1 -0
  46. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts → text-operations-CNfUj45U.d.ts} +16 -2
  47. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts.map → text-operations-CNfUj45U.d.ts.map} +1 -1
  48. package/dist/pptx/cli/index.cjs +954 -622
  49. package/dist/pptx/cli/index.d.ts +1 -1
  50. package/dist/pptx/cli/index.mjs +5 -5
  51. package/dist/pptx/converter/index.d.ts +1 -1
  52. package/dist/pptx/converter/index.mjs +3 -3
  53. package/dist/pptx/editor/render/editor-history.cjs +21 -0
  54. package/dist/pptx/editor/render/editor-history.d.ts +9 -0
  55. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  56. package/dist/pptx/editor/render/editor-history.mjs +21 -0
  57. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  58. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  59. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  60. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  61. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  62. package/dist/pptx/index.cjs +953 -620
  63. package/dist/pptx/index.d.ts +5 -5
  64. package/dist/pptx/index.mjs +6 -6
  65. package/dist/pptx/node/index.d.ts +1 -1
  66. package/dist/pptx/signature-node/index.cjs +89 -47
  67. package/dist/pptx/signature-node/index.mjs +2 -2
  68. package/dist/visio/index.cjs +266 -150
  69. package/dist/visio/index.mjs +266 -150
  70. package/dist/visio/ui/index.cjs +266 -150
  71. package/dist/visio/ui/index.mjs +266 -150
  72. package/dist/xlsx/index.cjs +518 -153
  73. package/dist/xlsx/index.mjs +518 -154
  74. package/dist/xlsx/load/index.cjs +266 -150
  75. package/dist/xlsx/load/index.mjs +266 -150
  76. package/dist/xlsx/numfmt/view.d.ts +13 -0
  77. package/dist/xlsx/numfmt/view.d.ts.map +1 -0
  78. package/dist/xlsx/read/index.d.ts +1 -0
  79. package/dist/xlsx/read/index.d.ts.map +1 -1
  80. package/dist/xlsx/read/limits.d.ts +5 -0
  81. package/dist/xlsx/read/limits.d.ts.map +1 -1
  82. package/dist/xlsx/read/package.d.ts +6 -0
  83. package/dist/xlsx/read/package.d.ts.map +1 -1
  84. package/dist/xlsx/read/rows-stream.d.ts +12 -0
  85. package/dist/xlsx/read/rows-stream.d.ts.map +1 -0
  86. package/dist/xlsx/read/rows.d.ts +37 -0
  87. package/dist/xlsx/read/rows.d.ts.map +1 -0
  88. package/dist/xlsx/read/shared-strings.d.ts +6 -1
  89. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  90. package/dist/xlsx/read/sheet-data-source.d.ts +30 -3
  91. package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
  92. package/dist/xlsx/read/sheet-data.d.ts +13 -2
  93. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  94. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  95. package/dist/xlsx/ui/index.cjs +266 -150
  96. package/dist/xlsx/ui/index.mjs +266 -150
  97. package/dist/xml/index.cjs +38 -6
  98. package/dist/xml/index.mjs +37 -7
  99. package/dist/xml/lite.d.ts +15 -0
  100. package/dist/xml/lite.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/PptxHandler-5UO5DD5K.mjs +0 -4
  103. 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?.();
14751
14766
  });
14767
+ stream.on("error", (error) => fail2(error));
14768
+ stream.on("end", () => {
14769
+ ended = true;
14770
+ wake?.();
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({
@@ -105932,6 +106026,157 @@ var init_pptx_view_props_helpers = __esm({
105932
106026
  }
105933
106027
  });
105934
106028
 
106029
+ // pptx/core/core/runtime/chart-part-registration.ts
106030
+ function asArray4(value) {
106031
+ if (value === void 0 || value === null) {
106032
+ return [];
106033
+ }
106034
+ return (Array.isArray(value) ? value : [value]).filter(
106035
+ (entry2) => Boolean(entry2) && typeof entry2 === "object"
106036
+ );
106037
+ }
106038
+ function nextFreeChartPartPath(zip, directory) {
106039
+ let n = 1;
106040
+ while (zip.file(`${directory}/chart${n}.xml`)) {
106041
+ n += 1;
106042
+ }
106043
+ return `${directory}/chart${n}.xml`;
106044
+ }
106045
+ function resolvePartTarget(fromPart, target) {
106046
+ if (target.startsWith("/")) {
106047
+ return target.slice(1);
106048
+ }
106049
+ const segments = fromPart.split("/").slice(0, -1);
106050
+ for (const segment of target.split("/")) {
106051
+ if (segment === "..") {
106052
+ segments.pop();
106053
+ } else if (segment !== "." && segment !== "") {
106054
+ segments.push(segment);
106055
+ }
106056
+ }
106057
+ return segments.join("/");
106058
+ }
106059
+ function relativePartTarget2(fromPart, toPart) {
106060
+ const from = fromPart.split("/").slice(0, -1);
106061
+ const to = toPart.split("/");
106062
+ let common = 0;
106063
+ while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
106064
+ common += 1;
106065
+ }
106066
+ return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
106067
+ }
106068
+ async function ensureContentTypeOverride2(deps, partPath, contentType) {
106069
+ const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
106070
+ if (!xml) {
106071
+ return;
106072
+ }
106073
+ const tree = deps.parser.parse(xml);
106074
+ const types = tree["Types"] ?? {};
106075
+ const overrides = asArray4(types["Override"]);
106076
+ const partName = `/${partPath}`;
106077
+ if (overrides.some((entry2) => String(entry2["@_PartName"]) === partName)) {
106078
+ return;
106079
+ }
106080
+ overrides.push({ "@_PartName": partName, "@_ContentType": contentType });
106081
+ types["Override"] = overrides;
106082
+ tree["Types"] = types;
106083
+ deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
106084
+ }
106085
+ async function rewriteChartRelationship(deps, slidePath, rewrite) {
106086
+ const slash = slidePath.lastIndexOf("/");
106087
+ const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
106088
+ const xml = await deps.zip.file(relsPath2)?.async("string");
106089
+ if (!xml) {
106090
+ return void 0;
106091
+ }
106092
+ const tree = deps.parser.parse(xml);
106093
+ const root = tree["Relationships"];
106094
+ const relationships3 = asArray4(root?.["Relationship"]);
106095
+ const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
106096
+ (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
106097
+ );
106098
+ if (!match || !root) {
106099
+ return void 0;
106100
+ }
106101
+ match["@_Type"] = rewrite.relationshipType;
106102
+ match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
106103
+ delete match["@_TargetMode"];
106104
+ root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
106105
+ deps.zip.file(relsPath2, deps.builder.build(tree));
106106
+ return String(match["@_Id"]);
106107
+ }
106108
+ function rebindGraphicData(node, relationshipId2, extended) {
106109
+ for (const key2 of Object.keys(node)) {
106110
+ delete node[key2];
106111
+ }
106112
+ node["@_uri"] = extended ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
106113
+ if (extended) {
106114
+ node["cx:chart"] = {
106115
+ "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
106116
+ "@_xmlns:r": NS_R,
106117
+ "@_r:id": relationshipId2
106118
+ };
106119
+ } else {
106120
+ node["c:chart"] = {
106121
+ "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
106122
+ "@_xmlns:r": NS_R,
106123
+ "@_r:id": relationshipId2
106124
+ };
106125
+ }
106126
+ }
106127
+ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
106128
+ if (!node || typeof node !== "object") {
106129
+ return 0;
106130
+ }
106131
+ if (Array.isArray(node)) {
106132
+ return node.reduce(
106133
+ (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
106134
+ 0
106135
+ );
106136
+ }
106137
+ const object = node;
106138
+ let count = 0;
106139
+ for (const key2 of Object.keys(object)) {
106140
+ if (key2.startsWith("@_")) {
106141
+ continue;
106142
+ }
106143
+ const value = object[key2];
106144
+ if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
106145
+ for (const candidate of asArray4(value)) {
106146
+ const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
106147
+ const chart = chartKey ? candidate[chartKey] : void 0;
106148
+ if (chart && String(chart["@_r:id"]) === relationshipId2) {
106149
+ rebindGraphicData(candidate, relationshipId2, extended);
106150
+ count += 1;
106151
+ }
106152
+ }
106153
+ continue;
106154
+ }
106155
+ count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
106156
+ }
106157
+ return count;
106158
+ }
106159
+ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
106160
+ const xml = await deps.zip.file(slidePath)?.async("string");
106161
+ if (!xml) {
106162
+ return 0;
106163
+ }
106164
+ const tree = deps.parser.parse(xml);
106165
+ const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
106166
+ if (count > 0) {
106167
+ deps.zip.file(slidePath, deps.builder.build(tree));
106168
+ }
106169
+ return count;
106170
+ }
106171
+ var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
106172
+ var init_chart_part_registration = __esm({
106173
+ "pptx/core/core/runtime/chart-part-registration.ts"() {
106174
+ CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
106175
+ CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
106176
+ NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
106177
+ }
106178
+ });
106179
+
105935
106180
  // pptx/core/utils/chart-color-style-writer.ts
105936
106181
  function localName22(key2) {
105937
106182
  return key2.replace(/^.*:/u, "");
@@ -106201,7 +106446,7 @@ function buildChartExSpaceXml(chartData) {
106201
106446
  const chartSpace = {
106202
106447
  "@_xmlns:cx": NS_CX,
106203
106448
  "@_xmlns:a": NS_A,
106204
- "@_xmlns:r": NS_R,
106449
+ "@_xmlns:r": NS_R2,
106205
106450
  "cx:chartData": {
106206
106451
  "cx:data": chartData.series.map(
106207
106452
  (series, index) => buildChartExData(chartData, series, index)
@@ -106215,7 +106460,7 @@ function buildChartExSpaceXml(chartData) {
106215
106460
  }
106216
106461
  return { "cx:chartSpace": chartSpace };
106217
106462
  }
106218
- var NS_CX, NS_A, NS_R, NS_C;
106463
+ var NS_CX, NS_A, NS_R2, NS_C;
106219
106464
  var init_chart_cx_generator = __esm({
106220
106465
  "pptx/core/utils/chart-cx-generator.ts"() {
106221
106466
  init_chart_cx_legend();
@@ -106223,7 +106468,7 @@ var init_chart_cx_generator = __esm({
106223
106468
  init_chart_cx_legend();
106224
106469
  NS_CX = "http://schemas.microsoft.com/office/drawing/2014/chartex";
106225
106470
  NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main";
106226
- NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
106471
+ NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
106227
106472
  NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart";
106228
106473
  }
106229
106474
  });
@@ -107850,7 +108095,7 @@ function buildChartSpaceXml(chartData) {
107850
108095
  "c:chartSpace": {
107851
108096
  "@_xmlns:c": NS_C2,
107852
108097
  "@_xmlns:a": NS_A2,
107853
- "@_xmlns:r": NS_R2,
108098
+ "@_xmlns:r": NS_R3,
107854
108099
  "c:chart": chart
107855
108100
  }
107856
108101
  };
@@ -107858,7 +108103,7 @@ function buildChartSpaceXml(chartData) {
107858
108103
  applyGeneratedChartSpaceFormat(result, chartData);
107859
108104
  return result;
107860
108105
  }
107861
- var NS_C2, NS_A2, NS_R2, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
108106
+ var NS_C2, NS_A2, NS_R3, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
107862
108107
  var init_chart_xml_generator = __esm({
107863
108108
  "pptx/core/utils/chart-xml-generator.ts"() {
107864
108109
  init_chart_bubble_options();
@@ -107879,7 +108124,7 @@ var init_chart_xml_generator = __esm({
107879
108124
  init_chart_xml_series_fill();
107880
108125
  NS_C2 = "http://schemas.openxmlformats.org/drawingml/2006/chart";
107881
108126
  NS_A2 = "http://schemas.openxmlformats.org/drawingml/2006/main";
107882
- NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
108127
+ NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
107883
108128
  CAT_AX_ID = 111111111;
107884
108129
  VAL_AX_ID = 222222222;
107885
108130
  SER_AX_ID = 333333333;
@@ -110031,7 +110276,7 @@ function buildTitleDefRPr(style, existing, resolveColor2) {
110031
110276
  }
110032
110277
  return rPr;
110033
110278
  }
110034
- function asArray4(value) {
110279
+ function asArray5(value) {
110035
110280
  if (Array.isArray(value)) {
110036
110281
  return value;
110037
110282
  }
@@ -110050,7 +110295,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
110050
110295
  return txKey;
110051
110296
  }
110052
110297
  const pKey = findKey30(rich, "p", getLocalName2) ?? "a:p";
110053
- const paragraphs = asArray4(rich[pKey]).map((para) => {
110298
+ const paragraphs = asArray5(rich[pKey]).map((para) => {
110054
110299
  const next = { ...para };
110055
110300
  const pPrKey = findKey30(next, "pPr", getLocalName2) ?? "a:pPr";
110056
110301
  const pPr = { ...ensureXmlChildOrCreate(next, pPrKey, "first") };
@@ -110063,7 +110308,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
110063
110308
  next[pPrKey] = pPr;
110064
110309
  const rKey = findKey30(next, "r", getLocalName2);
110065
110310
  if (rKey) {
110066
- const runs = asArray4(next[rKey]).map((run2) => {
110311
+ const runs = asArray5(next[rKey]).map((run2) => {
110067
110312
  const rPrKey = findKey30(run2, "rPr", getLocalName2) ?? "a:rPr";
110068
110313
  const existingRPr = run2[rPrKey] ?? {};
110069
110314
  const nextRun = { ...run2 };
@@ -110457,7 +110702,7 @@ var init_chart_neutral_save = __esm({
110457
110702
  function findKey31(node, localName28, getLocalName2) {
110458
110703
  return Object.keys(node).find((key2) => getLocalName2(key2) === localName28);
110459
110704
  }
110460
- function asArray5(value) {
110705
+ function asArray6(value) {
110461
110706
  if (value === void 0 || value === null) {
110462
110707
  return [];
110463
110708
  }
@@ -110471,8 +110716,8 @@ function dimensionType(node) {
110471
110716
  function replaceLevels(target, source, getLocalName2) {
110472
110717
  const targetKey = findKey31(target, "lvl", getLocalName2) ?? "cx:lvl";
110473
110718
  const sourceKey = findKey31(source, "lvl", getLocalName2);
110474
- const oldLevels = asArray5(target[targetKey]);
110475
- const newLevels = asArray5(sourceKey ? source[sourceKey] : void 0).map((level2, index) => {
110719
+ const oldLevels = asArray6(target[targetKey]);
110720
+ const newLevels = asArray6(sourceKey ? source[sourceKey] : void 0).map((level2, index) => {
110476
110721
  const old = oldLevels[index];
110477
110722
  if (!old) {
110478
110723
  return level2;
@@ -110491,8 +110736,8 @@ function replaceChartExDataDimensions(target, fresh, getLocalName2) {
110491
110736
  for (const kind of ["strDim", "numDim"]) {
110492
110737
  const targetKey = findKey31(target, kind, getLocalName2) ?? `cx:${kind}`;
110493
110738
  const freshKey = findKey31(fresh, kind, getLocalName2);
110494
- const existing = asArray5(target[targetKey]);
110495
- const incoming = asArray5(freshKey ? fresh[freshKey] : void 0);
110739
+ const existing = asArray6(target[targetKey]);
110740
+ const incoming = asArray6(freshKey ? fresh[freshKey] : void 0);
110496
110741
  for (const dimension of incoming) {
110497
110742
  const wantedType = dimensionType(dimension);
110498
110743
  let match = existing.find((candidate) => dimensionType(candidate) === wantedType);
@@ -110530,7 +110775,7 @@ function child28(node, localName28, getLocalName2) {
110530
110775
  const value = key2 ? node[key2] : void 0;
110531
110776
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
110532
110777
  }
110533
- function asArray6(value) {
110778
+ function asArray7(value) {
110534
110779
  if (value === void 0 || value === null) {
110535
110780
  return [];
110536
110781
  }
@@ -110719,7 +110964,7 @@ function chartExLayoutChanged(chartSpace, chartData, getLocalName2) {
110719
110964
  getLocalName2
110720
110965
  );
110721
110966
  const seriesKey = region ? findKey32(region, "series", getLocalName2) : void 0;
110722
- const first2 = region && seriesKey ? asArray6(region[seriesKey])[0] : void 0;
110967
+ const first2 = region && seriesKey ? asArray7(region[seriesKey])[0] : void 0;
110723
110968
  const existing = String(first2?.["@_layoutId"] ?? "").toLowerCase();
110724
110969
  const series = chartData.series[0];
110725
110970
  if (!existing || !series) {
@@ -110737,9 +110982,9 @@ function applyChartExUpdate(chartSpace, chartData, getLocalName2) {
110737
110982
  const chartDataKey = findKey32(chartSpace, "chartData", getLocalName2);
110738
110983
  const chartDataNode = (chartDataKey ? chartSpace[chartDataKey] : void 0) ?? {};
110739
110984
  const dataKey = findKey32(chartDataNode, "data", getLocalName2) ?? "cx:data";
110740
- const dataNodes = asArray6(chartDataNode[dataKey]);
110985
+ const dataNodes = asArray7(chartDataNode[dataKey]);
110741
110986
  const seriesKey = findKey32(region, "series", getLocalName2) ?? "cx:series";
110742
- const existing = asArray6(region[seriesKey]);
110987
+ const existing = asArray7(region[seriesKey]);
110743
110988
  const updated = [];
110744
110989
  chartData.series.forEach((series, index) => {
110745
110990
  const node = existing[index];
@@ -110821,157 +111066,6 @@ var init_chart_external_workbook_save = __esm({
110821
111066
  }
110822
111067
  });
110823
111068
 
110824
- // pptx/core/core/runtime/chart-part-registration.ts
110825
- function asArray7(value) {
110826
- if (value === void 0 || value === null) {
110827
- return [];
110828
- }
110829
- return (Array.isArray(value) ? value : [value]).filter(
110830
- (entry2) => Boolean(entry2) && typeof entry2 === "object"
110831
- );
110832
- }
110833
- function nextFreeChartPartPath(zip, directory) {
110834
- let n = 1;
110835
- while (zip.file(`${directory}/chart${n}.xml`)) {
110836
- n += 1;
110837
- }
110838
- return `${directory}/chart${n}.xml`;
110839
- }
110840
- function resolvePartTarget(fromPart, target) {
110841
- if (target.startsWith("/")) {
110842
- return target.slice(1);
110843
- }
110844
- const segments = fromPart.split("/").slice(0, -1);
110845
- for (const segment of target.split("/")) {
110846
- if (segment === "..") {
110847
- segments.pop();
110848
- } else if (segment !== "." && segment !== "") {
110849
- segments.push(segment);
110850
- }
110851
- }
110852
- return segments.join("/");
110853
- }
110854
- function relativePartTarget2(fromPart, toPart) {
110855
- const from = fromPart.split("/").slice(0, -1);
110856
- const to = toPart.split("/");
110857
- let common = 0;
110858
- while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
110859
- common += 1;
110860
- }
110861
- return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
110862
- }
110863
- async function ensureContentTypeOverride2(deps, partPath, contentType) {
110864
- const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
110865
- if (!xml) {
110866
- return;
110867
- }
110868
- const tree = deps.parser.parse(xml);
110869
- const types = tree["Types"] ?? {};
110870
- const overrides = asArray7(types["Override"]);
110871
- const partName = `/${partPath}`;
110872
- if (overrides.some((entry2) => String(entry2["@_PartName"]) === partName)) {
110873
- return;
110874
- }
110875
- overrides.push({ "@_PartName": partName, "@_ContentType": contentType });
110876
- types["Override"] = overrides;
110877
- tree["Types"] = types;
110878
- deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
110879
- }
110880
- async function rewriteChartRelationship(deps, slidePath, rewrite) {
110881
- const slash = slidePath.lastIndexOf("/");
110882
- const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
110883
- const xml = await deps.zip.file(relsPath2)?.async("string");
110884
- if (!xml) {
110885
- return void 0;
110886
- }
110887
- const tree = deps.parser.parse(xml);
110888
- const root = tree["Relationships"];
110889
- const relationships3 = asArray7(root?.["Relationship"]);
110890
- const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
110891
- (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
110892
- );
110893
- if (!match || !root) {
110894
- return void 0;
110895
- }
110896
- match["@_Type"] = rewrite.relationshipType;
110897
- match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
110898
- delete match["@_TargetMode"];
110899
- root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
110900
- deps.zip.file(relsPath2, deps.builder.build(tree));
110901
- return String(match["@_Id"]);
110902
- }
110903
- function rebindGraphicData(node, relationshipId2, extended) {
110904
- for (const key2 of Object.keys(node)) {
110905
- delete node[key2];
110906
- }
110907
- node["@_uri"] = extended ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
110908
- if (extended) {
110909
- node["cx:chart"] = {
110910
- "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
110911
- "@_xmlns:r": NS_R3,
110912
- "@_r:id": relationshipId2
110913
- };
110914
- } else {
110915
- node["c:chart"] = {
110916
- "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
110917
- "@_xmlns:r": NS_R3,
110918
- "@_r:id": relationshipId2
110919
- };
110920
- }
110921
- }
110922
- function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
110923
- if (!node || typeof node !== "object") {
110924
- return 0;
110925
- }
110926
- if (Array.isArray(node)) {
110927
- return node.reduce(
110928
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
110929
- 0
110930
- );
110931
- }
110932
- const object = node;
110933
- let count = 0;
110934
- for (const key2 of Object.keys(object)) {
110935
- if (key2.startsWith("@_")) {
110936
- continue;
110937
- }
110938
- const value = object[key2];
110939
- if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
110940
- for (const candidate of asArray7(value)) {
110941
- const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
110942
- const chart = chartKey ? candidate[chartKey] : void 0;
110943
- if (chart && String(chart["@_r:id"]) === relationshipId2) {
110944
- rebindGraphicData(candidate, relationshipId2, extended);
110945
- count += 1;
110946
- }
110947
- }
110948
- continue;
110949
- }
110950
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
110951
- }
110952
- return count;
110953
- }
110954
- async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
110955
- const xml = await deps.zip.file(slidePath)?.async("string");
110956
- if (!xml) {
110957
- return 0;
110958
- }
110959
- const tree = deps.parser.parse(xml);
110960
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
110961
- if (count > 0) {
110962
- deps.zip.file(slidePath, deps.builder.build(tree));
110963
- }
110964
- return count;
110965
- }
110966
- var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R3;
110967
- var init_chart_part_registration = __esm({
110968
- "pptx/core/core/runtime/chart-part-registration.ts"() {
110969
- CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
110970
- CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
110971
- NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
110972
- }
110973
- });
110974
-
110975
111069
  // pptx/core/core/runtime/chart-part-family-switch.ts
110976
111070
  function detectChartPartFamily(chartSpace, getLocalName2) {
110977
111071
  const keys = Object.keys(chartSpace);
@@ -114051,18 +114145,22 @@ var init_PptxHandlerRuntimeElementActions = __esm({
114051
114145
  * Write or remove a single `a:hlinkClick` / `a:hlinkHover` node on
114052
114146
  * a `p:cNvPr` parent.
114053
114147
  */
114054
- serializeSingleAction(cNvPr, nodeName, action, resolveHyperlinkRelationshipId) {
114148
+ serializeSingleAction(cNvPr, nodeName, action, links) {
114055
114149
  if (!action) {
114056
114150
  delete cNvPr[nodeName];
114057
114151
  return;
114058
114152
  }
114059
114153
  const node = {};
114154
+ const url = action.url?.trim() || (/^ppaction:\/\/hlinksldjump\b/iu.test(action.action ?? "") && typeof action.targetSlideIndex === "number" ? links.slideTargetAt?.(action.targetSlideIndex) : void 0);
114060
114155
  let rId = action.rId;
114061
- if (!rId && action.url) {
114156
+ if (rId && url && links.getSlideRelationshipMap().get(rId) !== url) {
114157
+ rId = void 0;
114158
+ }
114159
+ if (!rId && url) {
114062
114160
  const forceExternal = /^ppaction:\/\/(program|hlinkfile|hlinkpres)\b/iu.test(
114063
114161
  action.action ?? ""
114064
114162
  );
114065
- rId = resolveHyperlinkRelationshipId(action.url, forceExternal) ?? void 0;
114163
+ rId = links.resolveHyperlinkRelationshipId(url, forceExternal) ?? void 0;
114066
114164
  }
114067
114165
  node["@_r:id"] = rId ?? "";
114068
114166
  if (action.action) {
@@ -114136,7 +114234,7 @@ var init_PptxHandlerRuntimeElementActions = __esm({
114136
114234
  * the `a:hlinkClick` and `a:hlinkHover` nodes on the element's
114137
114235
  * non-visual properties.
114138
114236
  */
114139
- serializeElementActions(shape, el, resolveHyperlinkRelationshipId) {
114237
+ serializeElementActions(shape, el, links) {
114140
114238
  const key2 = this.getTreeBucketKeyForElementType(el.type);
114141
114239
  const cNvPr = this.getCnvPrNode(shape, key2);
114142
114240
  if (!cNvPr) {
@@ -114144,8 +114242,8 @@ var init_PptxHandlerRuntimeElementActions = __esm({
114144
114242
  }
114145
114243
  const actionClick = "actionClick" in el ? el.actionClick : void 0;
114146
114244
  const actionHover = "actionHover" in el ? el.actionHover : void 0;
114147
- this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, resolveHyperlinkRelationshipId);
114148
- this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, resolveHyperlinkRelationshipId);
114245
+ this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, links);
114246
+ this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, links);
114149
114247
  const isDecorative = "isDecorative" in el ? el.isDecorative : void 0;
114150
114248
  serializeDecorativeExtension(cNvPr, isDecorative);
114151
114249
  }
@@ -115051,6 +115149,11 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115051
115149
  const upSegments = Array.from({ length: fromParts.length }).fill("..");
115052
115150
  return [...upSegments, ...toParts].join("/");
115053
115151
  }
115152
+ /**
115153
+ * Point a slide master's theme relationship at `themePath`.
115154
+ *
115155
+ * @returns whether the master had a theme relationship to rewrite
115156
+ */
115054
115157
  async setMasterThemeRelationship(masterPath, themePath) {
115055
115158
  const relsPath2 = masterPath.replace(
115056
115159
  /ppt\/slideMasters\/(slideMaster\d+)\.xml/,
@@ -115058,7 +115161,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115058
115161
  );
115059
115162
  const relsFile = this.zip.file(relsPath2);
115060
115163
  if (!relsFile) {
115061
- return;
115164
+ return false;
115062
115165
  }
115063
115166
  const relsXml = await relsFile.async("string");
115064
115167
  const relsData = this.parser.parse(relsXml);
@@ -115066,28 +115169,13 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
115066
115169
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
115067
115170
  const themeRel = relationships3.find((rel) => String(rel["@_Type"] || "").includes("/theme"));
115068
115171
  if (!themeRel) {
115069
- return;
115172
+ return false;
115070
115173
  }
115071
115174
  themeRel["@_Target"] = this.buildRelativeTargetPath(masterPath, themePath);
115072
115175
  relRoot["Relationship"] = relationships3;
115073
115176
  relsData["Relationships"] = relRoot;
115074
115177
  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
- );
115178
+ return true;
115091
115179
  }
115092
115180
  /** The text of a package part, or `undefined` when the package has no such part. */
115093
115181
  async readPartText(path4) {
@@ -115417,8 +115505,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115417
115505
  this.masterXmlMap.set(path4, data);
115418
115506
  }
115419
115507
  const masterCSldName = (xmlAttr(sldMaster["p:cSld"], "name") ?? "").trim();
115420
- const bg = sldMaster["p:cSld"]?.["p:bg"];
115421
- const backgroundColor = this.parseBackgroundColor(bg);
115422
115508
  const spTree = sldMaster["p:cSld"]?.["p:spTree"];
115423
115509
  const placeholders = this.extractPlaceholderList(spTree);
115424
115510
  let preserve;
@@ -115472,7 +115558,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115472
115558
  results.push({
115473
115559
  path: path4,
115474
115560
  name: masterCSldName.length > 0 ? masterCSldName : void 0,
115475
- backgroundColor,
115476
115561
  themePath,
115477
115562
  layoutPaths: layoutPaths.length > 0 ? layoutPaths : void 0,
115478
115563
  layouts: layouts.length > 0 ? layouts : void 0,
@@ -115610,11 +115695,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
115610
115695
  layout.clrMapOverride = overrideMap;
115611
115696
  }
115612
115697
  }
115613
- const bg = xmlPath(sldLayout, "p:cSld", "p:bg");
115614
- const bgColor = this.parseBackgroundColor(bg);
115615
- if (bgColor) {
115616
- layout.backgroundColor = bgColor;
115617
- }
115618
115698
  const spTree = xmlPath(sldLayout, "p:cSld", "p:spTree");
115619
115699
  const placeholders = this.extractPlaceholderList(spTree);
115620
115700
  if (placeholders.length > 0) {
@@ -127278,7 +127358,7 @@ var init_PptxHandlerRuntimeSaveElementWriter = __esm({
127278
127358
  if (ctx.connectorShapeIds) {
127279
127359
  applyConnectorShapeIds(shape, el, ctx.connectorShapeIds);
127280
127360
  }
127281
- this.serializeElementActions(shape, el, ctx.resolveHyperlinkRelationshipId);
127361
+ this.serializeElementActions(shape, el, ctx);
127282
127362
  this.serializeShapeLocks(shape, el);
127283
127363
  this.applyHiddenToCnvPr(shape, el);
127284
127364
  this.applyNameToCnvPr(shape, el);
@@ -128256,6 +128336,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
128256
128336
  init_theme_override_utils();
128257
128337
  init_builders();
128258
128338
  init_authored_slide_background();
128339
+ init_chart_part_registration();
128259
128340
  init_PptxHandlerRuntimeSaveElementWriter();
128260
128341
  init_save_structural_id_gate();
128261
128342
  init_slide_fingerprint();
@@ -128391,7 +128472,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
128391
128472
  * Process a single slide during save: update slide XML, process elements,
128392
128473
  * rebuild shape tree, and persist relationships.
128393
128474
  */
128394
- async processSlideForSave(slide, saveSession, constants) {
128475
+ async processSlideForSave(slide, saveSession, constants, slidePaths = []) {
128395
128476
  if (this.canSkipSlideSave(slide)) {
128396
128477
  return;
128397
128478
  }
@@ -128576,6 +128657,10 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
128576
128657
  slideRelationshipRegistry,
128577
128658
  resolveHyperlinkRelationshipId: (target, forceExternal) => slideRelationshipRegistry.resolveHyperlinkRelationshipId(target, forceExternal),
128578
128659
  getSlideRelationshipMap: () => slideRelationshipRegistry.toRelationshipMap(),
128660
+ slideTargetAt: (index) => {
128661
+ const target = slidePaths[index];
128662
+ return target ? relativePartTarget2(slide.id, target) : void 0;
128663
+ },
128579
128664
  resolvedMediaBytes,
128580
128665
  saveSession,
128581
128666
  slideImageRelationshipType: constants.slideImageRelationshipType,
@@ -130885,7 +130970,23 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
130885
130970
  }
130886
130971
  return this.isStrictOoxml ? "strict" : "transitional";
130887
130972
  }
130973
+ /** The save running now, or the last one: see {@link save}. */
130974
+ saveQueue = Promise.resolve();
130975
+ /**
130976
+ * Saves run one at a time. A save rewrites `this.zip` in place across many awaits and moves
130977
+ * per-part baselines (slide fingerprints, chart data, pending chart updates) while it runs, so
130978
+ * a second save that starts mid-way (a viewer's autosave snapshot firing during the user's own
130979
+ * save) read half-written state: it skipped the slide as unchanged and wrote the chart part's
130980
+ * original XML back over the edit, in both outputs. Each save now waits for the one before it;
130981
+ * one that fails does not hold up the next.
130982
+ */
130888
130983
  async save(slides, options) {
130984
+ const run2 = this.saveQueue.then(() => this.saveNow(slides, options));
130985
+ this.saveQueue = run2.catch(() => void 0);
130986
+ return run2;
130987
+ }
130988
+ /** One save, with the package to itself; callers go through {@link save}. */
130989
+ async saveNow(slides, options) {
130889
130990
  validateSlideGeometry(slides);
130890
130991
  const templates = [
130891
130992
  ...options?.slideMasters ?? [],
@@ -130903,7 +131004,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
130903
131004
  return this.saveAsLegacyPpt(
130904
131005
  slides,
130905
131006
  options,
130906
- () => this.save(slides, {
131007
+ () => this.saveNow(slides, {
130907
131008
  ...options,
130908
131009
  pptPassword: void 0,
130909
131010
  outputFormat: "pptx",
@@ -130935,8 +131036,9 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
130935
131036
  await this.ensureNotesMasterForAuthoredNotes(slides, saveConstants);
130936
131037
  await this.ensureHandoutMasterInfrastructure(options?.handoutMaster, saveConstants);
130937
131038
  this.templateElementBaselines.beginSave();
131039
+ const slidePaths = slides.map((slide) => slide.id);
130938
131040
  for (const slide of slides) {
130939
- await this.processSlideForSave(slide, saveSession, saveConstants);
131041
+ await this.processSlideForSave(slide, saveSession, saveConstants, slidePaths);
130940
131042
  }
130941
131043
  this.templateElementBaselines.commitSave();
130942
131044
  const contentTypesXml3 = await this.zip.file("[Content_Types].xml")?.async("string");
@@ -135890,6 +135992,25 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
135890
135992
  }
135891
135993
  return void 0;
135892
135994
  }
135995
+ /**
135996
+ * The colour a slide master or layout paints from its own `p:bg`, resolved exactly as a
135997
+ * slide's background is: through the active master's colour map and format scheme, with
135998
+ * `clrMapOverride` (a layout's `p:clrMapOvr`, or `null`) taking precedence. The caller makes
135999
+ * the part's master active first; a master's `bgRef` on `bg1` means `dk1` under a dark
136000
+ * `p:clrMap`, which no other state can tell.
136001
+ */
136002
+ extractTemplateBackgroundColor(partXml, rootTag, clrMapOverride) {
136003
+ if (!partXml) {
136004
+ return void 0;
136005
+ }
136006
+ const previousOverride = this.currentSlideClrMapOverride;
136007
+ this.currentSlideClrMapOverride = clrMapOverride;
136008
+ try {
136009
+ return this.extractBackgroundColor(partXml, rootTag);
136010
+ } finally {
136011
+ this.currentSlideClrMapOverride = previousOverride;
136012
+ }
136013
+ }
135893
136014
  /**
135894
136015
  * Composite a resolved background colour with its `a:alpha` (or
135895
136016
  * `a:alphaMod`/`a:alphaOff`) opacity onto opaque white.
@@ -136456,6 +136577,31 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
136456
136577
  const masterFormatScheme = this.masterThemeFormatSchemes.get(masterPath);
136457
136578
  this.themeFormatScheme = masterFormatScheme ?? this.globalThemeFormatSchemeSnapshot;
136458
136579
  }
136580
+ /**
136581
+ * Run `work` with one master's theme state active and no slide colour-map override, then
136582
+ * put back whatever state was active before, so a part parsed on request (a layout preview)
136583
+ * resolves through its own master without disturbing the caller's.
136584
+ */
136585
+ async withMasterThemeState(masterPath, work) {
136586
+ const saved = {
136587
+ colors: this.themeColorMap,
136588
+ fonts: this.themeFontMap,
136589
+ format: this.themeFormatScheme,
136590
+ clrMap: this.currentMasterClrMap,
136591
+ slideClrMap: this.currentSlideClrMapOverride
136592
+ };
136593
+ this.applyMasterThemeState(masterPath);
136594
+ this.currentSlideClrMapOverride = null;
136595
+ try {
136596
+ return await work();
136597
+ } finally {
136598
+ this.themeColorMap = saved.colors;
136599
+ this.themeFontMap = saved.fonts;
136600
+ this.themeFormatScheme = saved.format;
136601
+ this.currentMasterClrMap = saved.clrMap;
136602
+ this.currentSlideClrMapOverride = saved.slideClrMap;
136603
+ }
136604
+ }
136459
136605
  /**
136460
136606
  * Extract the `p:bg/@showAnimation` flag from a slide's XML.
136461
136607
  * Returns `true` when the background should animate, `false` when
@@ -137370,18 +137516,33 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
137370
137516
  this.rememberUnparsedMasterNodes(partPath, spTree, part.elements);
137371
137517
  }
137372
137518
  /**
137373
- * Populate `elements` on every slide master and on each of its layouts.
137519
+ * Resolve the background of every slide master and of each of its layouts,
137520
+ * and populate their `elements`.
137374
137521
  *
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.
137522
+ * Scheme colours on a master, its own `p:bgRef` included, must resolve
137523
+ * through that master's colour map and theme, so the active master state is
137524
+ * switched per part and reset to the deck-wide snapshot afterwards.
137378
137525
  */
137379
137526
  async enrichSlideMasterElements(masters) {
137380
137527
  for (const master of masters) {
137381
137528
  try {
137382
137529
  this.applyMasterThemeState(master.path);
137530
+ master.backgroundColor = this.extractTemplateBackgroundColor(
137531
+ this.masterXmlMap.get(master.path),
137532
+ "p:sldMaster",
137533
+ null
137534
+ );
137383
137535
  await this.enrichMasterPartElements(master, "p:sldMaster");
137384
137536
  for (const layout of master.layouts ?? []) {
137537
+ const layoutXml3 = this.layoutXmlMap.get(layout.path);
137538
+ const backgroundColor = this.extractTemplateBackgroundColor(
137539
+ layoutXml3,
137540
+ "p:sldLayout",
137541
+ layoutXml3 ? this.parseLayoutClrMapOverride(layoutXml3) : null
137542
+ );
137543
+ if (backgroundColor) {
137544
+ layout.backgroundColor = backgroundColor;
137545
+ }
137385
137546
  await this.enrichMasterPartElements(layout, "p:sldLayout");
137386
137547
  }
137387
137548
  } catch (e) {
@@ -137652,20 +137813,23 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
137652
137813
  this.layoutCache.delete(layoutPath);
137653
137814
  this.eagerDecodeImages = true;
137654
137815
  }
137655
- let elements2;
137816
+ const masterPath = this.resolveMasterPathForLayout(layoutPath);
137817
+ let parsed;
137656
137818
  try {
137657
- elements2 = await this.getLayoutElementsByPath(layoutPath);
137819
+ parsed = await this.withMasterThemeState(masterPath, async () => ({
137820
+ elements: await this.getLayoutElementsByPath(layoutPath),
137821
+ background: this.resolveLayoutPreviewBackground(layoutXml3, masterPath)
137822
+ }));
137658
137823
  } finally {
137659
137824
  this.eagerDecodeImages = previousEagerDecode;
137660
137825
  }
137661
137826
  const cSld = xmlPath(layoutXml3, "p:sldLayout", "p:cSld");
137662
- const background = this.resolveLayoutPreviewBackground(layoutPath, cSld);
137663
137827
  const preview = {
137664
137828
  path: layoutPath,
137665
137829
  width: this.rawSlideWidthEmu / EMU_PER_PX,
137666
137830
  height: this.rawSlideHeightEmu / EMU_PER_PX,
137667
- ...background,
137668
- elements: elements2,
137831
+ ...parsed.background,
137832
+ elements: parsed.elements,
137669
137833
  placeholders: this.extractPlaceholderList(xmlChild(cSld, "p:spTree"))
137670
137834
  };
137671
137835
  this.layoutPreviewCache.set(layoutPath, preview);
@@ -137701,19 +137865,18 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
137701
137865
  }
137702
137866
  /**
137703
137867
  * Resolve the background a layout thumbnail should paint, falling back to
137704
- * the layout's master when the layout itself declares none.
137868
+ * the layout's master when the layout itself declares none. Runs with the
137869
+ * master active; the layout's own colour map override applies to an
137870
+ * inherited background too, as a slide's does.
137705
137871
  */
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")
137872
+ resolveLayoutPreviewBackground(layoutXml3, masterPath) {
137873
+ const clrMapOverride = this.parseLayoutClrMapOverride(layoutXml3);
137874
+ const backgroundColor = this.extractTemplateBackgroundColor(layoutXml3, "p:sldLayout", clrMapOverride) ?? this.extractTemplateBackgroundColor(
137875
+ masterPath ? this.masterXmlMap.get(masterPath) : void 0,
137876
+ "p:sldMaster",
137877
+ clrMapOverride
137715
137878
  );
137716
- return masterBackground ? { backgroundColor: masterBackground } : {};
137879
+ return backgroundColor ? { backgroundColor } : {};
137717
137880
  }
137718
137881
  };
137719
137882
  }
@@ -138521,15 +138684,298 @@ var init_PptxHandlerRuntimeThemeRefResolution = __esm({
138521
138684
  }
138522
138685
  });
138523
138686
 
138687
+ // pptx/core/core/runtime/theme-scheme-edit.ts
138688
+ function normalizeHex6(hex3) {
138689
+ return hex3.replace(/^#/, "").toUpperCase();
138690
+ }
138691
+ function buildSrgbClrNode(hex3) {
138692
+ return { "a:srgbClr": { "@_val": normalizeHex6(hex3) } };
138693
+ }
138694
+ function themeElementsOf(data) {
138695
+ const root = data["a:theme"];
138696
+ return root?.["a:themeElements"];
138697
+ }
138698
+ function applyColorSchemeToThemeXml(data, colorScheme) {
138699
+ const themeElements = themeElementsOf(data);
138700
+ if (!themeElements) {
138701
+ return false;
138702
+ }
138703
+ const clrScheme = themeElements["a:clrScheme"] ?? {};
138704
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138705
+ clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
138706
+ }
138707
+ themeElements["a:clrScheme"] = clrScheme;
138708
+ return true;
138709
+ }
138710
+ function applyLatinTypeface(group, latin) {
138711
+ const font = group ?? {};
138712
+ font["a:latin"] = { "@_typeface": latin };
138713
+ if (!font["a:ea"]) {
138714
+ font["a:ea"] = { "@_typeface": "" };
138715
+ }
138716
+ if (!font["a:cs"]) {
138717
+ font["a:cs"] = { "@_typeface": "" };
138718
+ }
138719
+ return font;
138720
+ }
138721
+ function applyFontSchemeToThemeXml(data, fontScheme) {
138722
+ const themeElements = themeElementsOf(data);
138723
+ if (!themeElements) {
138724
+ return false;
138725
+ }
138726
+ const fntScheme = themeElements["a:fontScheme"] ?? {};
138727
+ if (fontScheme.majorFont?.latin) {
138728
+ fntScheme["a:majorFont"] = applyLatinTypeface(
138729
+ fntScheme["a:majorFont"],
138730
+ fontScheme.majorFont.latin
138731
+ );
138732
+ }
138733
+ if (fontScheme.minorFont?.latin) {
138734
+ fntScheme["a:minorFont"] = applyLatinTypeface(
138735
+ fntScheme["a:minorFont"],
138736
+ fontScheme.minorFont.latin
138737
+ );
138738
+ }
138739
+ themeElements["a:fontScheme"] = fntScheme;
138740
+ return true;
138741
+ }
138742
+ function applyColorSchemeToMap(map, colorScheme, clrMap) {
138743
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138744
+ map[key2] = normalizeHex6(colorScheme[key2]);
138745
+ }
138746
+ for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
138747
+ const target = clrMap?.[alias] ?? defaultTarget;
138748
+ const resolved = map[target];
138749
+ if (resolved !== void 0) {
138750
+ map[alias] = resolved;
138751
+ }
138752
+ }
138753
+ }
138754
+ function applyFontSchemeToMap(map, fontScheme) {
138755
+ if (fontScheme.majorFont?.latin) {
138756
+ map["mj-lt"] = fontScheme.majorFont.latin;
138757
+ map["mj-ea"] = fontScheme.majorFont.latin;
138758
+ map["mj-cs"] = fontScheme.majorFont.latin;
138759
+ }
138760
+ if (fontScheme.minorFont?.latin) {
138761
+ map["mn-lt"] = fontScheme.minorFont.latin;
138762
+ map["mn-ea"] = fontScheme.minorFont.latin;
138763
+ map["mn-cs"] = fontScheme.minorFont.latin;
138764
+ }
138765
+ }
138766
+ var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
138767
+ var init_theme_scheme_edit = __esm({
138768
+ "pptx/core/core/runtime/theme-scheme-edit.ts"() {
138769
+ THEME_COLOR_SCHEME_KEYS2 = [
138770
+ "dk1",
138771
+ "lt1",
138772
+ "dk2",
138773
+ "lt2",
138774
+ "accent1",
138775
+ "accent2",
138776
+ "accent3",
138777
+ "accent4",
138778
+ "accent5",
138779
+ "accent6",
138780
+ "hlink",
138781
+ "folHlink"
138782
+ ];
138783
+ DEFAULT_CLR_MAP_ALIASES = {
138784
+ tx1: "dk1",
138785
+ bg1: "lt1",
138786
+ tx2: "dk2",
138787
+ bg2: "lt2"
138788
+ };
138789
+ }
138790
+ });
138791
+
138792
+ // pptx/core/core/runtime/theme-part-model.ts
138793
+ function colorSchemeFromMap(colorMap) {
138794
+ const scheme = {};
138795
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138796
+ scheme[key2] = colorMap[key2] || "";
138797
+ }
138798
+ return scheme;
138799
+ }
138800
+ function fontGroup(fontMap, prefix, byScript) {
138801
+ const latin = fontMap[`${prefix}-lt`];
138802
+ const eastAsia = fontMap[`${prefix}-ea`];
138803
+ const complexScript = fontMap[`${prefix}-cs`];
138804
+ return {
138805
+ ...latin ? { latin } : {},
138806
+ ...eastAsia ? { eastAsia } : {},
138807
+ ...complexScript ? { complexScript } : {},
138808
+ ...Object.keys(byScript).length > 0 ? { byScript: { ...byScript } } : {}
138809
+ };
138810
+ }
138811
+ function fontSchemeFromMap(fontMap, majorByScript, minorByScript) {
138812
+ return {
138813
+ majorFont: fontGroup(fontMap, "mj", majorByScript),
138814
+ minorFont: fontGroup(fontMap, "mn", minorByScript)
138815
+ };
138816
+ }
138817
+ var init_theme_part_model = __esm({
138818
+ "pptx/core/core/runtime/theme-part-model.ts"() {
138819
+ init_theme_scheme_edit();
138820
+ }
138821
+ });
138822
+
138823
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts
138824
+ var FONT_SLOTS, PptxHandlerRuntime84;
138825
+ var init_PptxHandlerRuntimeThemePartModel = __esm({
138826
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts"() {
138827
+ init_PptxHandlerRuntimeThemeRefResolution();
138828
+ init_theme_part_model();
138829
+ init_theme_scheme_edit();
138830
+ FONT_SLOTS = [
138831
+ ["mj", "a:majorFont"],
138832
+ ["mn", "a:minorFont"]
138833
+ ];
138834
+ PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
138835
+ /** Parse one theme part's XML. Side-effect free. */
138836
+ parseThemePartXml(themeXml3) {
138837
+ const themeData = this.parser.parse(themeXml3);
138838
+ const themeRoot = themeData["a:theme"];
138839
+ const themeElements = themeRoot?.["a:themeElements"];
138840
+ const colorScheme = themeElements?.["a:clrScheme"];
138841
+ const fontScheme = themeElements?.["a:fontScheme"];
138842
+ const fmtScheme = themeElements?.["a:fmtScheme"];
138843
+ const text2 = (value) => String(value || "").trim() || void 0;
138844
+ const colorMap = { ...this.getDefaultSchemeColorMap() };
138845
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
138846
+ const parsed = this.parseColorChoice(colorScheme?.[`a:${key2}`]);
138847
+ if (parsed) {
138848
+ colorMap[key2] = parsed;
138849
+ }
138850
+ }
138851
+ const fontMap = {};
138852
+ const typeface = (node) => this.normalizeTypefaceToken(String(node?.["@_typeface"] || ""));
138853
+ for (const [prefix, tag] of FONT_SLOTS) {
138854
+ const group = fontScheme?.[tag];
138855
+ const latin = typeface(group?.["a:latin"]);
138856
+ if (latin) {
138857
+ fontMap[`${prefix}-lt`] = latin;
138858
+ fontMap[`${prefix}-ea`] = latin;
138859
+ fontMap[`${prefix}-cs`] = latin;
138860
+ }
138861
+ const eastAsia = typeface(group?.["a:ea"]);
138862
+ if (eastAsia) {
138863
+ fontMap[`${prefix}-ea`] = eastAsia;
138864
+ }
138865
+ const complexScript = typeface(group?.["a:cs"]);
138866
+ if (complexScript) {
138867
+ fontMap[`${prefix}-cs`] = complexScript;
138868
+ }
138869
+ }
138870
+ const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
138871
+ const objectDefaults = objectDefaultsNode && {
138872
+ spDef: objectDefaultsNode["a:spDef"],
138873
+ lnDef: objectDefaultsNode["a:lnDef"],
138874
+ txDef: objectDefaultsNode["a:txDef"]
138875
+ };
138876
+ const hasObjectDefaults = objectDefaults !== void 0 && (objectDefaults.spDef !== void 0 || objectDefaults.lnDef !== void 0 || objectDefaults.txDef !== void 0);
138877
+ return {
138878
+ name: text2(themeRoot?.["@_name"]),
138879
+ colorSchemeName: text2(colorScheme?.["@_name"]),
138880
+ fontSchemeName: text2(fontScheme?.["@_name"]),
138881
+ colorMap,
138882
+ fontMap,
138883
+ // Per-script fonts (`<a:font script="Hans|Hant|Arab|...">`): M4.
138884
+ majorFontScripts: this.collectFontScriptOverrides(
138885
+ fontScheme?.["a:majorFont"]
138886
+ ),
138887
+ minorFontScripts: this.collectFontScriptOverrides(
138888
+ fontScheme?.["a:minorFont"]
138889
+ ),
138890
+ // objectDefaults: M5.
138891
+ objectDefaults: hasObjectDefaults ? objectDefaults : void 0,
138892
+ extraClrSchemeLst: themeRoot?.["a:extraClrSchemeLst"],
138893
+ custClrLst: themeRoot?.["a:custClrLst"],
138894
+ extLst: themeRoot?.["a:extLst"],
138895
+ formatScheme: fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0
138896
+ };
138897
+ }
138898
+ /**
138899
+ * Record a parsed part under its path: its original XML (byte-stable passthrough on save,
138900
+ * C-H3), its names, per-script fonts and the raw subtrees the save re-emits.
138901
+ */
138902
+ cacheThemePartModel(themePath, themeXml3, model) {
138903
+ this.originalThemeXmlByPath.set(themePath, themeXml3);
138904
+ const keyed = [
138905
+ [this.masterThemeNames, model.name],
138906
+ [this.masterThemeColorSchemeNames, model.colorSchemeName],
138907
+ [this.masterThemeFontSchemeNames, model.fontSchemeName],
138908
+ [this.masterThemeObjectDefaults, model.objectDefaults],
138909
+ [this.masterThemeExtraClrSchemeLst, model.extraClrSchemeLst],
138910
+ [this.masterThemeCustClrLst, model.custClrLst],
138911
+ [this.masterThemeExtLst, model.extLst]
138912
+ ];
138913
+ for (const [map, value] of keyed) {
138914
+ if (value !== void 0) {
138915
+ map.set(themePath, value);
138916
+ }
138917
+ }
138918
+ if (Object.keys(model.majorFontScripts).length > 0) {
138919
+ this.masterThemeMajorFontScripts.set(themePath, model.majorFontScripts);
138920
+ }
138921
+ if (Object.keys(model.minorFontScripts).length > 0) {
138922
+ this.masterThemeMinorFontScripts.set(themePath, model.minorFontScripts);
138923
+ }
138924
+ }
138925
+ /**
138926
+ * Parse `<a:font script="..." typeface="..."/>` children of a major or minor font node into a
138927
+ * `script -> typeface` dictionary. fast-xml-parser collapses repeated tags into arrays, so the
138928
+ * array form is walked regardless of how many siblings are present. Phase 4 Stream A / M4.
138929
+ */
138930
+ collectFontScriptOverrides(fontNode) {
138931
+ const overrides = {};
138932
+ if (!fontNode) {
138933
+ return overrides;
138934
+ }
138935
+ const fontEntries = this.ensureArray(fontNode["a:font"]);
138936
+ for (const entry2 of fontEntries) {
138937
+ const script = String(entry2?.["@_script"] || "").trim();
138938
+ const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
138939
+ if (script && typeface) {
138940
+ overrides[script] = typeface;
138941
+ }
138942
+ }
138943
+ return overrides;
138944
+ }
138945
+ /**
138946
+ * The colour, font and format schemes and name of one theme part in the package, as the part holds
138947
+ * them now (a scheme edit already written to it included). Reads only: the loaded theme, the
138948
+ * masters and what a save writes are unchanged. `undefined` when the package has no such part.
138949
+ */
138950
+ async getThemePartSchemes(themePath) {
138951
+ const path4 = themePath.trim().replace(/\\/g, "/");
138952
+ const themeXml3 = await this.zip.file(path4)?.async("string");
138953
+ if (themeXml3 === void 0) {
138954
+ return void 0;
138955
+ }
138956
+ const model = this.parseThemePartXml(themeXml3);
138957
+ return {
138958
+ path: path4,
138959
+ ...model.name ? { name: model.name } : {},
138960
+ colorScheme: colorSchemeFromMap(model.colorMap),
138961
+ fontScheme: fontSchemeFromMap(model.fontMap, model.majorFontScripts, model.minorFontScripts),
138962
+ ...model.formatScheme ? { formatScheme: model.formatScheme } : {}
138963
+ };
138964
+ }
138965
+ };
138966
+ }
138967
+ });
138968
+
138524
138969
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts
138525
138970
  function isPresentationThemePartPath(path4) {
138526
138971
  return /^ppt\/theme\/(?!themeOverride)[^/]+\.xml$/iu.test(path4);
138527
138972
  }
138528
- var PptxHandlerRuntime84;
138973
+ var PptxHandlerRuntime85;
138529
138974
  var init_PptxHandlerRuntimeThemeLoading = __esm({
138530
138975
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts"() {
138531
- init_PptxHandlerRuntimeThemeRefResolution();
138532
- PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
138976
+ init_PptxHandlerRuntimeThemePartModel();
138977
+ init_theme_part_model();
138978
+ PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
138533
138979
  async resolvePrimaryThemePath() {
138534
138980
  const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
138535
138981
  if (!masterFiles || masterFiles.length === 0) {
@@ -138605,42 +139051,12 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138605
139051
  if (!hasColors && !hasFonts) {
138606
139052
  return void 0;
138607
139053
  }
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
- }
139054
+ const colorScheme = hasColors ? colorSchemeFromMap(this.themeColorMap) : void 0;
139055
+ const fontScheme = hasFonts ? fontSchemeFromMap(
139056
+ this.themeFontMap,
139057
+ this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts),
139058
+ this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts)
139059
+ ) : void 0;
138644
139060
  return {
138645
139061
  colorScheme,
138646
139062
  fontScheme,
@@ -138717,134 +139133,10 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138717
139133
  return null;
138718
139134
  }
138719
139135
  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 };
139136
+ const model = this.parseThemePartXml(themeXml3);
139137
+ this.cacheThemePartModel(themePath, themeXml3, model);
139138
+ return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
138838
139139
  }
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
139140
  /**
138849
139141
  * Flatten a per-theme-path script-override map (`themePath -> {script ->
138850
139142
  * typeface}`) into a single `{script -> typeface}` lookup for
@@ -138862,21 +139154,6 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138862
139154
  }
138863
139155
  return aggregate;
138864
139156
  }
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
139157
  /**
138881
139158
  * Resolve the theme file path referenced by a given master's `.rels`.
138882
139159
  * Returns `undefined` when the master has no theme relationship.
@@ -138962,119 +139239,14 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
138962
139239
  }
138963
139240
  });
138964
139241
 
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
139242
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts
139071
- var THEME_PART_PATTERN, PptxHandlerRuntime85;
139243
+ var THEME_PART_PATTERN, PptxHandlerRuntime86;
139072
139244
  var init_PptxHandlerRuntimeThemeProcessing = __esm({
139073
139245
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts"() {
139074
139246
  init_PptxHandlerRuntimeThemeLoading();
139075
139247
  init_theme_scheme_edit();
139076
139248
  THEME_PART_PATTERN = /^ppt\/theme\/theme\d+\.xml$/;
139077
- PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
139249
+ PptxHandlerRuntime86 = class extends PptxHandlerRuntime85 {
139078
139250
  /**
139079
139251
  * The theme parts an edit should touch, primary theme first.
139080
139252
  *
@@ -139115,8 +139287,9 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139115
139287
  return this.parser.parse(xml);
139116
139288
  }
139117
139289
  /**
139118
- * Parse, edit, and write back every target theme part. Parts the edit
139119
- * cannot apply to (no `a:themeElements`) are left untouched.
139290
+ * Parse, edit, and write back every target theme part (`edit` gets the
139291
+ * part's path too). Parts the edit cannot apply to (no `a:themeElements`)
139292
+ * are left untouched.
139120
139293
  *
139121
139294
  * @returns the paths that were rewritten
139122
139295
  */
@@ -139124,7 +139297,7 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139124
139297
  const written = [];
139125
139298
  for (const path4 of await this.resolveThemeEditTargets(themePaths)) {
139126
139299
  const data = await this.readThemePart(path4);
139127
- if (!data || !edit(data)) {
139300
+ if (!data || !edit(data, path4)) {
139128
139301
  continue;
139129
139302
  }
139130
139303
  this.zip.file(path4, this.builder.build(data));
@@ -139228,15 +139401,90 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
139228
139401
  }
139229
139402
  });
139230
139403
 
139404
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts
139405
+ function themePartPath(themePath) {
139406
+ const path4 = themePath.trim().replace(/\\/g, "/");
139407
+ return path4.startsWith("ppt/theme/") ? path4 : void 0;
139408
+ }
139409
+ var SLIDE_MASTER_PART, PptxHandlerRuntime87;
139410
+ var init_PptxHandlerRuntimeThemeSwitching = __esm({
139411
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts"() {
139412
+ init_PptxHandlerRuntimeThemeProcessing();
139413
+ SLIDE_MASTER_PART = /^ppt\/slideMasters\/slideMaster\d+\.xml$/;
139414
+ PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
139415
+ /**
139416
+ * Point the first slide master, or every one, at a theme part already in the package. Does
139417
+ * nothing when the package has no such part.
139418
+ */
139419
+ async setPresentationTheme(themePath, applyToAllMasters = true) {
139420
+ const path4 = themePartPath(themePath);
139421
+ if (!path4 || !this.zip.file(path4)) {
139422
+ return;
139423
+ }
139424
+ const masters = this.zip.file(SLIDE_MASTER_PART);
139425
+ for (const master of applyToAllMasters ? masters : masters.slice(0, 1)) {
139426
+ await this.retargetMasterTheme(master.name, path4);
139427
+ }
139428
+ }
139429
+ /**
139430
+ * Point one slide master at a theme part already in the package (Undo of a theme switch puts
139431
+ * each master back on its own part). Does nothing when the package has no such master or part.
139432
+ */
139433
+ async setSlideMasterTheme(masterPath, themePath) {
139434
+ const path4 = themePartPath(themePath);
139435
+ if (!path4 || !this.zip.file(path4) || !SLIDE_MASTER_PART.test(masterPath)) {
139436
+ return;
139437
+ }
139438
+ if (this.zip.file(masterPath)) {
139439
+ await this.retargetMasterTheme(masterPath, path4);
139440
+ }
139441
+ }
139442
+ async retargetMasterTheme(masterPath, themePath) {
139443
+ if (await this.setMasterThemeRelationship(masterPath, themePath)) {
139444
+ await this.adoptMasterTheme(masterPath, themePath);
139445
+ }
139446
+ }
139447
+ /** Point the runtime's theme state for `masterPath` at the part it now uses. */
139448
+ async adoptMasterTheme(masterPath, themePath) {
139449
+ const themeXml3 = await this.zip.file(themePath)?.async("string");
139450
+ if (themeXml3 === void 0) {
139451
+ return;
139452
+ }
139453
+ const model = this.parseThemePartXml(themeXml3);
139454
+ if (!this.originalThemeXmlByPath.has(themePath)) {
139455
+ this.cacheThemePartModel(themePath, themeXml3, model);
139456
+ }
139457
+ this.masterThemePaths.set(masterPath, themePath);
139458
+ this.masterThemeColorMaps.set(masterPath, { ...model.colorMap });
139459
+ this.masterThemeFontMaps.set(masterPath, { ...model.fontMap });
139460
+ if (model.formatScheme) {
139461
+ this.masterThemeFormatSchemes.set(masterPath, model.formatScheme);
139462
+ } else {
139463
+ this.masterThemeFormatSchemes.delete(masterPath);
139464
+ }
139465
+ if (this.zip.file(SLIDE_MASTER_PART)[0]?.name !== masterPath) {
139466
+ return;
139467
+ }
139468
+ this.themeColorMap = { ...model.colorMap };
139469
+ this.themeFontMap = { ...model.fontMap };
139470
+ this.themeFormatScheme = model.formatScheme;
139471
+ this.globalThemeColorMapSnapshot = { ...model.colorMap };
139472
+ this.globalThemeFontMapSnapshot = { ...model.fontMap };
139473
+ this.globalThemeFormatSchemeSnapshot = model.formatScheme;
139474
+ }
139475
+ };
139476
+ }
139477
+ });
139478
+
139231
139479
  // pptx/core/core/runtime/PptxHandlerRuntimeComments.ts
139232
- var PptxHandlerRuntime86;
139480
+ var PptxHandlerRuntime88;
139233
139481
  var init_PptxHandlerRuntimeComments = __esm({
139234
139482
  "pptx/core/core/runtime/PptxHandlerRuntimeComments.ts"() {
139235
139483
  init_legacy_comment_threading();
139236
139484
  init_modern_comment_xml();
139237
139485
  init_xml_access();
139238
- init_PptxHandlerRuntimeThemeProcessing();
139239
- PptxHandlerRuntime86 = class _PptxHandlerRuntime extends PptxHandlerRuntime85 {
139486
+ init_PptxHandlerRuntimeThemeSwitching();
139487
+ PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
139240
139488
  /**
139241
139489
  * Parse modern threaded comments (PowerPoint 2019+ / Office 365).
139242
139490
  * Modern comments use `p188:cmLst`/`p15:cmLst` roots within
@@ -139465,7 +139713,7 @@ var init_PptxHandlerRuntimeComments = __esm({
139465
139713
  });
139466
139714
 
139467
139715
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts
139468
- var PptxHandlerRuntime87;
139716
+ var PptxHandlerRuntime89;
139469
139717
  var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139470
139718
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts"() {
139471
139719
  init_smartart_color_lists();
@@ -139473,7 +139721,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
139473
139721
  init_smart_art_text_helpers();
139474
139722
  init_PptxHandlerRuntimeComments();
139475
139723
  init_smartart_text_paragraphs();
139476
- PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
139724
+ PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
139477
139725
  async readXmlPartByRelationshipId(slidePath, relationshipId2) {
139478
139726
  const normalizedRelationshipId = String(relationshipId2 || "").trim();
139479
139727
  if (normalizedRelationshipId.length === 0) {
@@ -140077,7 +140325,7 @@ var init_smartart_text_style_resolution = __esm({
140077
140325
  });
140078
140326
 
140079
140327
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts
140080
- var PptxHandlerRuntime88;
140328
+ var PptxHandlerRuntime90;
140081
140329
  var init_PptxHandlerRuntimeSmartArtParsing = __esm({
140082
140330
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts"() {
140083
140331
  init_diagram();
@@ -140091,7 +140339,7 @@ var init_PptxHandlerRuntimeSmartArtParsing = __esm({
140091
140339
  init_smartart_style_label_refs();
140092
140340
  init_smartart_text_paragraphs();
140093
140341
  init_smartart_text_style_resolution();
140094
- PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
140342
+ PptxHandlerRuntime90 = class _PptxHandlerRuntime extends PptxHandlerRuntime89 {
140095
140343
  reportIncompleteSmartArtRelationships(graphicFrame, relationshipIds, slidePath) {
140096
140344
  const missing = [
140097
140345
  ["dm", relationshipIds?.dataRelId],
@@ -140486,7 +140734,7 @@ var init_smartart_layout_category = __esm({
140486
140734
  });
140487
140735
 
140488
140736
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts
140489
- var PptxHandlerRuntime89;
140737
+ var PptxHandlerRuntime91;
140490
140738
  var init_PptxHandlerRuntimeSmartArt = __esm({
140491
140739
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts"() {
140492
140740
  init_utils();
@@ -140501,7 +140749,7 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
140501
140749
  init_smartart_text_paragraphs();
140502
140750
  init_smartart_text_style_resolution();
140503
140751
  init_smartart_xml_builders();
140504
- PptxHandlerRuntime89 = class _PptxHandlerRuntime extends PptxHandlerRuntime88 {
140752
+ PptxHandlerRuntime91 = class _PptxHandlerRuntime extends PptxHandlerRuntime90 {
140505
140753
  async getSmartArtDataForGraphicFrame(slidePath, graphicFrame) {
140506
140754
  const graphicData = this.xmlLookupService.getChildByLocalName(
140507
140755
  this.xmlLookupService.getChildByLocalName(graphicFrame, "graphic"),
@@ -140677,12 +140925,12 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
140677
140925
  });
140678
140926
 
140679
140927
  // pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts
140680
- var PptxHandlerRuntime90;
140928
+ var PptxHandlerRuntime92;
140681
140929
  var init_PptxHandlerRuntimeChartDetection = __esm({
140682
140930
  "pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts"() {
140683
140931
  init_chart_multi_level_category_parser();
140684
140932
  init_PptxHandlerRuntimeSmartArt();
140685
- PptxHandlerRuntime90 = class extends PptxHandlerRuntime89 {
140933
+ PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
140686
140934
  detectChartType(plotArea) {
140687
140935
  if (!plotArea) {
140688
140936
  return "unknown";
@@ -140893,14 +141141,14 @@ function parseNumberVal(node) {
140893
141141
  const num4 = Number.parseFloat(String(raw2));
140894
141142
  return Number.isFinite(num4) ? num4 : void 0;
140895
141143
  }
140896
- var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime91;
141144
+ var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime93;
140897
141145
  var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
140898
141146
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsingHelpers.ts"() {
140899
141147
  init_chart_ext_lookup();
140900
141148
  init_chart_pivot_source2();
140901
141149
  init_PptxHandlerRuntimeChartDetection();
140902
141150
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI2 = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
140903
- PptxHandlerRuntime91 = class extends PptxHandlerRuntime90 {
141151
+ PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
140904
141152
  /**
140905
141153
  * Parse `c:plotVisOnly` from the chart root element.
140906
141154
  *
@@ -141160,14 +141408,14 @@ var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
141160
141408
  });
141161
141409
 
141162
141410
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts
141163
- var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime92;
141411
+ var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime94;
141164
141412
  var init_PptxHandlerRuntimeChartExternalData = __esm({
141165
141413
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts"() {
141166
141414
  init_chart_user_shapes_parser();
141167
141415
  init_chart_xlsx_parser();
141168
141416
  init_PptxHandlerRuntimeChartParsingHelpers();
141169
141417
  CHART_USER_SHAPES_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
141170
- PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
141418
+ PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
141171
141419
  /**
141172
141420
  * Parse `c:externalData` from the chart's `c:chartSpace` and resolve
141173
141421
  * the external relationship target from the chart part's .rels file.
@@ -141329,12 +141577,12 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
141329
141577
  });
141330
141578
 
141331
141579
  // pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts
141332
- var PptxHandlerRuntime93;
141580
+ var PptxHandlerRuntime95;
141333
141581
  var init_PptxHandlerRuntimeChartColorStyle = __esm({
141334
141582
  "pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts"() {
141335
141583
  init_chart_style_definition_parser();
141336
141584
  init_PptxHandlerRuntimeChartExternalData();
141337
- PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
141585
+ PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
141338
141586
  /**
141339
141587
  * Parse the Office 2013+ chart-style part (`ppt/charts/style#.xml`)
141340
141588
  * referenced from the chart's relationships, sibling to
@@ -141495,7 +141743,7 @@ var init_PptxHandlerRuntimeChartColorStyle = __esm({
141495
141743
  });
141496
141744
 
141497
141745
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts
141498
- var PptxHandlerRuntime94;
141746
+ var PptxHandlerRuntime96;
141499
141747
  var init_PptxHandlerRuntimeChartExParsing = __esm({
141500
141748
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts"() {
141501
141749
  init_chart_cx_parser();
@@ -141505,7 +141753,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
141505
141753
  init_chart_protection2();
141506
141754
  init_chart_space_flags();
141507
141755
  init_PptxHandlerRuntimeChartColorStyle();
141508
- PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
141756
+ PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
141509
141757
  /**
141510
141758
  * The facts of a chart part that live outside the plot (or in other parts): the external data
141511
141759
  * reference and the embedded workbook's rows, pivot source and formats, the colour-style and
@@ -141625,7 +141873,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
141625
141873
  });
141626
141874
 
141627
141875
  // pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts
141628
- var PptxHandlerRuntime95;
141876
+ var PptxHandlerRuntime97;
141629
141877
  var init_PptxHandlerRuntimeChartParsing = __esm({
141630
141878
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
141631
141879
  init_chart_element_format_read_xml();
@@ -141647,7 +141895,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
141647
141895
  init_chart_element_pictures();
141648
141896
  init_chart_embedded_fallback();
141649
141897
  init_PptxHandlerRuntimeChartExParsing();
141650
- PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
141898
+ PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
141651
141899
  /**
141652
141900
  * Parse chart data from a graphic frame element on a slide.
141653
141901
  *
@@ -141931,7 +142179,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
141931
142179
  });
141932
142180
 
141933
142181
  // pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts
141934
- var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime96;
142182
+ var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime98;
141935
142183
  var init_PptxHandlerRuntimePresentationStructure = __esm({
141936
142184
  "pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts"() {
141937
142185
  init_kinsoku_parser();
@@ -141940,7 +142188,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
141940
142188
  init_PptxHandlerRuntimeChartParsing();
141941
142189
  XSD_INT_MIN = -2147483648;
141942
142190
  XSD_INT_MAX = 2147483647;
141943
- PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
142191
+ PptxHandlerRuntime98 = class extends PptxHandlerRuntime97 {
141944
142192
  parseEditorAnimations(slideXml3) {
141945
142193
  return this.editorAnimationService.parseEditorAnimations(slideXml3);
141946
142194
  }
@@ -142143,7 +142391,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
142143
142391
  });
142144
142392
 
142145
142393
  // pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts
142146
- var PptxHandlerRuntime97;
142394
+ var PptxHandlerRuntime99;
142147
142395
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142148
142396
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
142149
142397
  init_eot_parser();
@@ -142152,7 +142400,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142152
142400
  init_strip_parent_dir_segments();
142153
142401
  init_xml_access();
142154
142402
  init_PptxHandlerRuntimePresentationStructure();
142155
- PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
142403
+ PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
142156
142404
  async getEmbeddedFonts(fontList) {
142157
142405
  if (!fontList || fontList.fonts.length === 0) {
142158
142406
  return [];
@@ -142354,7 +142602,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
142354
142602
  };
142355
142603
  }
142356
142604
  });
142357
- var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime98;
142605
+ var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime100;
142358
142606
  var init_PptxHandlerRuntimeLoadSession = __esm({
142359
142607
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts"() {
142360
142608
  init_zip_limits();
@@ -142366,7 +142614,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142366
142614
  init_bullet_picture_image_enrichment();
142367
142615
  init_PptxHandlerRuntimeEmbeddedFonts();
142368
142616
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
142369
- PptxHandlerRuntime98 = class _PptxHandlerRuntime extends PptxHandlerRuntime97 {
142617
+ PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
142370
142618
  isZipContainer(data) {
142371
142619
  const bytes = new Uint8Array(data);
142372
142620
  if (bytes.byteLength < 4) {
@@ -142734,7 +142982,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
142734
142982
  });
142735
142983
 
142736
142984
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts
142737
- var PptxHandlerRuntime99;
142985
+ var PptxHandlerRuntime101;
142738
142986
  var init_PptxHandlerRuntimeLoadPipeline = __esm({
142739
142987
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts"() {
142740
142988
  init_fluent();
@@ -142750,7 +142998,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
142750
142998
  init_layout_switch_placeholder_prompts();
142751
142999
  init_PptxHandlerRuntimeLoadSession();
142752
143000
  init_slide_fingerprint();
142753
- PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
143001
+ PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
142754
143002
  async buildLoadData(presentationState, slidesWithWarnings, slideMasters) {
142755
143003
  const headerFooter = this.extractHeaderFooter();
142756
143004
  const presentationProperties = await this.parsePresentationProperties();
@@ -143250,12 +143498,12 @@ function refIndex2(node) {
143250
143498
  const idx = Number.parseInt(String(node["@_idx"] ?? ""), 10);
143251
143499
  return Number.isFinite(idx) ? idx : void 0;
143252
143500
  }
143253
- var PptxHandlerRuntime100;
143501
+ var PptxHandlerRuntime102;
143254
143502
  var init_PptxHandlerRuntimeStyleMatrixResolve = __esm({
143255
143503
  "pptx/core/core/runtime/PptxHandlerRuntimeStyleMatrixResolve.ts"() {
143256
143504
  init_authored_shape_style();
143257
143505
  init_PptxHandlerRuntimeLoadPipeline();
143258
- PptxHandlerRuntime100 = class extends PptxHandlerRuntime99 {
143506
+ PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
143259
143507
  /**
143260
143508
  * Resolve a `<p:style>` node (`a:lnRef`, `a:fillRef`, `a:effectRef`,
143261
143509
  * `a:fontRef`) against the current theme's format scheme, with the same
@@ -143320,14 +143568,17 @@ function withKeys(style, from, keys) {
143320
143568
  function refNode(idx, colorXml2) {
143321
143569
  return { "@_idx": String(idx), ...colorXml2 ?? {} };
143322
143570
  }
143323
- var PptxHandlerRuntime101;
143571
+ var PptxHandlerRuntime103;
143324
143572
  var init_PptxHandlerRuntimeThemeEffects = __esm({
143325
143573
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeEffects.ts"() {
143326
143574
  init_theme_effect_schemes();
143327
143575
  init_authored_shape_style();
143576
+ init_held_format_schemes();
143328
143577
  init_PptxHandlerRuntimeStyleMatrixResolve();
143329
- PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
143578
+ PptxHandlerRuntime103 = class extends PptxHandlerRuntime102 {
143330
143579
  effectSchemeCache = /* @__PURE__ */ new Map();
143580
+ /** Every `a:fmtScheme` written into a theme part or over one ({@link restoreThemeFormatScheme}). */
143581
+ heldFormatSchemes = new HeldFormatSchemes();
143331
143582
  /**
143332
143583
  * Resolve a `<p:style>` node as the base class does, against built-in effect scheme
143333
143584
  * `effectSchemeId` instead of the deck's own (the Effects gallery draws each tile this way).
@@ -143380,32 +143631,79 @@ var init_PptxHandlerRuntimeThemeEffects = __esm({
143380
143631
  */
143381
143632
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
143382
143633
  const parsed = this.parseEffectScheme({ fmtSchemeXml });
143383
- if (!parsed) {
143384
- return void 0;
143634
+ return parsed ? this.writeFormatScheme(() => parsed.node) : void 0;
143635
+ }
143636
+ /**
143637
+ * Put back a format scheme the deck held before (Undo and Redo of an Effects pick), as the parts
143638
+ * held it: each theme part a master references gets back what it held the last time the deck's
143639
+ * scheme was `scheme` over those same parts, so a part with a scheme of its own gets its own back
143640
+ * (with no such time, `scheme`'s own element goes into every one). With `themePaths`, `scheme`'s
143641
+ * own element goes into those parts only.
143642
+ *
143643
+ * @returns the deck's format scheme now, or `undefined` (nothing written) for a scheme no part
143644
+ * held while this handler wrote into it
143645
+ */
143646
+ async restoreThemeFormatScheme(scheme, themePaths) {
143647
+ const parts = themePaths ? void 0 : this.heldFormatSchemes.parts(scheme, await this.resolveThemeEditTargets());
143648
+ if (parts) {
143649
+ return this.writeFormatScheme((path4) => parts.get(path4));
143385
143650
  }
143386
- const written = await this.rewriteThemeParts(void 0, (data) => {
143651
+ const element = this.heldFormatSchemes.element(scheme);
143652
+ return element ? this.writeFormatScheme(() => element, themePaths) : void 0;
143653
+ }
143654
+ /**
143655
+ * Write `elementFor(part)` into every theme part a master references (or only `themePaths`),
143656
+ * skipping a part it gives none, holding what each part held and now holds, and refresh the
143657
+ * in-memory format schemes of the masters on those parts and, when the deck's part is among
143658
+ * them, the deck's.
143659
+ */
143660
+ async writeFormatScheme(elementFor, themePaths) {
143661
+ const deckBefore = this.getThemeFormatScheme();
143662
+ const replaced = /* @__PURE__ */ new Map();
143663
+ const schemes = /* @__PURE__ */ new Map();
143664
+ const written = await this.rewriteThemeParts(themePaths, (data, path4) => {
143665
+ const element = elementFor(path4);
143387
143666
  const elements2 = data["a:theme"]?.["a:themeElements"];
143388
- if (!elements2) {
143667
+ if (!element || !elements2) {
143389
143668
  return false;
143390
143669
  }
143391
- elements2["a:fmtScheme"] = structuredClone(parsed.node);
143670
+ const previous = elements2["a:fmtScheme"];
143671
+ if (previous) {
143672
+ this.heldFormatSchemes.hold(this.parseFormatScheme(previous), previous);
143673
+ replaced.set(path4, structuredClone(previous));
143674
+ }
143675
+ const scheme = this.parseFormatScheme(element);
143676
+ this.heldFormatSchemes.hold(scheme, element);
143677
+ elements2["a:fmtScheme"] = structuredClone(element);
143678
+ schemes.set(path4, scheme);
143392
143679
  return true;
143393
143680
  });
143394
143681
  if (written.length === 0) {
143395
143682
  return void 0;
143396
143683
  }
143684
+ if (deckBefore) {
143685
+ this.heldFormatSchemes.holdParts(deckBefore, replaced);
143686
+ }
143397
143687
  for (const path4 of written) {
143398
143688
  const xml = await this.zip.file(path4)?.async("string");
143399
143689
  if (xml !== void 0) {
143400
143690
  this.originalThemeXmlByPath.set(path4, xml);
143401
143691
  }
143692
+ for (const masterPath of this.mastersUsingThemes([path4])) {
143693
+ this.masterThemeFormatSchemes.set(masterPath, schemes.get(path4));
143694
+ }
143402
143695
  }
143403
- for (const masterPath of this.mastersUsingThemes(written)) {
143404
- this.masterThemeFormatSchemes.set(masterPath, parsed.scheme);
143696
+ const primary = await this.resolvePrimaryThemePath();
143697
+ const deck = primary === void 0 ? void 0 : schemes.get(primary);
143698
+ if (deck) {
143699
+ this.globalThemeFormatSchemeSnapshot = deck;
143700
+ this.themeFormatScheme = deck;
143701
+ this.heldFormatSchemes.holdParts(
143702
+ deck,
143703
+ new Map(written.map((path4) => [path4, elementFor(path4)]))
143704
+ );
143405
143705
  }
143406
- this.globalThemeFormatSchemeSnapshot = parsed.scheme;
143407
- this.themeFormatScheme = parsed.scheme;
143408
- return parsed.scheme;
143706
+ return this.getThemeFormatScheme();
143409
143707
  }
143410
143708
  /** The real theme variants the loaded package carries, or none. */
143411
143709
  getThemeVariants() {
@@ -143531,7 +143829,7 @@ function schemeFromColorMap(map) {
143531
143829
  folHlink: pick("folHlink")
143532
143830
  };
143533
143831
  }
143534
- var PptxHandlerRuntime102;
143832
+ var PptxHandlerRuntime104;
143535
143833
  var init_PptxHandlerRuntimeBackgroundStyles = __esm({
143536
143834
  "pptx/core/core/runtime/PptxHandlerRuntimeBackgroundStyles.ts"() {
143537
143835
  init_background_style();
@@ -143539,7 +143837,7 @@ var init_PptxHandlerRuntimeBackgroundStyles = __esm({
143539
143837
  init_theme_switching();
143540
143838
  init_master_save_helpers();
143541
143839
  init_PptxHandlerRuntimeThemeEffects();
143542
- PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
143840
+ PptxHandlerRuntime104 = class extends PptxHandlerRuntime103 {
143543
143841
  resolveBackgroundStyle(preset) {
143544
143842
  const xml = {
143545
143843
  "p:sld": { "p:cSld": { "p:bg": backgroundRefNode(preset.idx, preset.scheme) } }
@@ -143799,14 +144097,14 @@ var init_sdk_placeholder = __esm({
143799
144097
  });
143800
144098
 
143801
144099
  // pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts
143802
- var PptxHandlerRuntime103;
144100
+ var PptxHandlerRuntime105;
143803
144101
  var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
143804
144102
  "pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts"() {
143805
144103
  init_placeholder_remap();
143806
144104
  init_xml_access();
143807
144105
  init_PptxHandlerRuntimeBackgroundStyles();
143808
144106
  init_sdk_placeholder();
143809
- PptxHandlerRuntime103 = class _PptxHandlerRuntime extends PptxHandlerRuntime102 {
144107
+ PptxHandlerRuntime105 = class _PptxHandlerRuntime extends PptxHandlerRuntime104 {
143810
144108
  createPlaceholderElement(layoutPath, input, type, options) {
143811
144109
  if (input.type !== "text") throw new Error("Placeholder input must be text");
143812
144110
  const layout = this.layoutXmlMap.get(layoutPath);
@@ -143860,14 +144158,14 @@ var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
143860
144158
  };
143861
144159
  }
143862
144160
  });
143863
- var PptxHandlerRuntime104;
144161
+ var PptxHandlerRuntime106;
143864
144162
  var init_PptxHandlerRuntimeImplementation = __esm({
143865
144163
  "pptx/core/core/runtime/PptxHandlerRuntimeImplementation.ts"() {
143866
144164
  init_PptxElementXmlBuilder();
143867
144165
  init_builders();
143868
144166
  init_factories();
143869
144167
  init_PptxHandlerRuntimeSdkPlaceholders();
143870
- PptxHandlerRuntime104 = class _PptxHandlerRuntime extends PptxHandlerRuntime103 {
144168
+ PptxHandlerRuntime106 = class _PptxHandlerRuntime extends PptxHandlerRuntime105 {
143871
144169
  constructor(dependencyFactory = new PptxRuntimeDependencyFactory()) {
143872
144170
  super();
143873
144171
  this.dependencyFactory = dependencyFactory;
@@ -144007,11 +144305,11 @@ var init_PptxHandlerRuntimeImplementation = __esm({
144007
144305
  });
144008
144306
 
144009
144307
  // pptx/core/core/PptxHandlerRuntime.ts
144010
- var PptxHandlerRuntime105;
144308
+ var PptxHandlerRuntime107;
144011
144309
  var init_PptxHandlerRuntime = __esm({
144012
144310
  "pptx/core/core/PptxHandlerRuntime.ts"() {
144013
144311
  init_PptxHandlerRuntimeImplementation();
144014
- PptxHandlerRuntime105 = class extends PptxHandlerRuntime104 {
144312
+ PptxHandlerRuntime107 = class extends PptxHandlerRuntime106 {
144015
144313
  };
144016
144314
  }
144017
144315
  });
@@ -144021,7 +144319,7 @@ var createDefaultPptxHandlerRuntime;
144021
144319
  var init_PptxHandlerRuntimeFactory = __esm({
144022
144320
  "pptx/core/core/PptxHandlerRuntimeFactory.ts"() {
144023
144321
  init_PptxHandlerRuntime();
144024
- createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime105();
144322
+ createDefaultPptxHandlerRuntime = () => new PptxHandlerRuntime107();
144025
144323
  }
144026
144324
  });
144027
144325
 
@@ -147227,10 +147525,32 @@ var init_PptxHandlerCore = __esm({
147227
147525
  async setPresentationTheme(themePath, applyToAllMasters = true) {
147228
147526
  await this.runtime.setPresentationTheme(themePath, applyToAllMasters);
147229
147527
  }
147528
+ /**
147529
+ * Point one slide master at a theme part already in the package; scheme edits and saves follow
147530
+ * it. Does nothing when the package has no such master or part.
147531
+ *
147532
+ * @param masterPath - The master's part path (e.g. `ppt/slideMasters/slideMaster2.xml`).
147533
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme1.xml`).
147534
+ */
147535
+ async setSlideMasterTheme(masterPath, themePath) {
147536
+ await this.runtime.setSlideMasterTheme(masterPath, themePath);
147537
+ }
147538
+ /**
147539
+ * Read one theme part's colour, font and format schemes and its name without changing the
147540
+ * loaded theme, for example to show what switching to it would apply.
147541
+ *
147542
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme2.xml`).
147543
+ * @returns The part's schemes, or `undefined` when the package has no such part.
147544
+ */
147545
+ async getThemePartSchemes(themePath) {
147546
+ return this.runtime.getThemePartSchemes(themePath);
147547
+ }
147230
147548
  /**
147231
147549
  * Modify the theme’s colour scheme (accent colours, background, text, etc.).
147232
147550
  *
147233
147551
  * @param colorScheme - A {@link PptxThemeColorScheme} with hex colour values.
147552
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147553
+ * master uses when omitted.
147234
147554
  *
147235
147555
  * @example
147236
147556
  * ```ts
@@ -147243,13 +147563,15 @@ var init_PptxHandlerCore = __esm({
147243
147563
  * // => void — colour scheme updated in the in-memory theme XML
147244
147564
  * ```
147245
147565
  */
147246
- async updateThemeColorScheme(colorScheme) {
147247
- await this.runtime.updateThemeColorScheme(colorScheme);
147566
+ async updateThemeColorScheme(colorScheme, themePaths) {
147567
+ await this.runtime.updateThemeColorScheme(colorScheme, themePaths);
147248
147568
  }
147249
147569
  /**
147250
147570
  * Update the theme’s font scheme (heading + body typefaces).
147251
147571
  *
147252
147572
  * @param fontScheme - A {@link PptxThemeFontScheme} with font family names.
147573
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147574
+ * master uses when omitted.
147253
147575
  *
147254
147576
  * @example
147255
147577
  * ```ts
@@ -147260,16 +147582,18 @@ var init_PptxHandlerCore = __esm({
147260
147582
  * // => void — font scheme updated in the in-memory theme XML
147261
147583
  * ```
147262
147584
  */
147263
- async updateThemeFontScheme(fontScheme) {
147264
- await this.runtime.updateThemeFontScheme(fontScheme);
147585
+ async updateThemeFontScheme(fontScheme, themePaths) {
147586
+ await this.runtime.updateThemeFontScheme(fontScheme, themePaths);
147265
147587
  }
147266
147588
  /**
147267
147589
  * Rename the presentation theme.
147268
147590
  *
147269
147591
  * @param name - New display name for the theme.
147592
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
147593
+ * master uses when omitted.
147270
147594
  */
147271
- async updateThemeName(name) {
147272
- await this.runtime.updateThemeName(name);
147595
+ async updateThemeName(name, themePaths) {
147596
+ await this.runtime.updateThemeName(name, themePaths);
147273
147597
  }
147274
147598
  /**
147275
147599
  * Resolve a `<p:style>` block (`a:lnRef` / `a:fillRef` / `a:effectRef` /
@@ -147292,6 +147616,14 @@ var init_PptxHandlerCore = __esm({
147292
147616
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
147293
147617
  return this.runtime.applyThemeFormatSchemeXml(fmtSchemeXml);
147294
147618
  }
147619
+ /**
147620
+ * Put a format scheme a theme part held before back into the theme parts (or only `themePaths`),
147621
+ * as the part held it: Undo and Redo of an Effects pick. Only a scheme this handler wrote into a
147622
+ * part or over one can come back; for any other it writes nothing and returns `undefined`.
147623
+ */
147624
+ async restoreThemeFormatScheme(scheme, themePaths) {
147625
+ return this.runtime.restoreThemeFormatScheme(scheme, themePaths);
147626
+ }
147295
147627
  /** The real theme variants the loaded package carries (`themeVariants/` parts), or none. */
147296
147628
  getThemeVariants() {
147297
147629
  return this.runtime.getThemeVariants();