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
@@ -5020,57 +5020,98 @@ function resolveLimits(limits) {
5020
5020
  fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
5021
5021
  };
5022
5022
  }
5023
- function inflateEntryGuarded(entry2, alreadyRead, limits) {
5023
+ async function inflateEntryGuarded(entry2, alreadyRead, limits) {
5024
+ const chunks = [];
5025
+ let size = 0;
5026
+ for await (const chunk2 of streamEntryGuarded(entry2, alreadyRead, limits)) {
5027
+ chunks.push(chunk2);
5028
+ size += chunk2.byteLength;
5029
+ }
5030
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
5031
+ const out = new Uint8Array(size);
5032
+ let offset = 0;
5033
+ for (const chunk2 of chunks) {
5034
+ out.set(chunk2, offset);
5035
+ offset += chunk2.byteLength;
5036
+ }
5037
+ return out;
5038
+ }
5039
+ async function* streamEntryGuarded(entry2, alreadyRead, limits) {
5024
5040
  const r = resolveLimits(limits);
5025
5041
  const declared = declaredEntrySize(entry2);
5026
- return new Promise((resolvePromise, reject) => {
5027
- const chunks = [];
5028
- let size = 0;
5029
- let done = false;
5030
- const stream = entry2.internalStream("uint8array");
5031
- const abort = (error) => {
5032
- if (done) return;
5033
- done = true;
5034
- stream.pause();
5035
- chunks.length = 0;
5036
- reject(error);
5037
- };
5038
- stream.on("data", (chunk2) => {
5039
- if (done) return;
5040
- size += chunk2.byteLength;
5041
- if (size > declared || size > r.maxEntryBytes)
5042
- return abort(
5043
- r.fail(
5044
- `${r.label} part ${entry2.name} inflates past its declared size`,
5045
- r.maxEntryBytes,
5046
- size > declared ? "declaredSize" : "maxEntryBytes"
5047
- )
5048
- );
5049
- if (alreadyRead + size > r.maxTotalBytes)
5050
- return abort(
5051
- r.fail(
5052
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5053
- r.maxTotalBytes,
5054
- "maxTotalBytes"
5055
- )
5056
- );
5057
- chunks.push(chunk2);
5058
- });
5059
- stream.on("error", (error) => abort(error));
5060
- stream.on("end", () => {
5061
- if (done) return;
5062
- done = true;
5063
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
5064
- const out = new Uint8Array(size);
5065
- let offset = 0;
5066
- for (const chunk2 of chunks) {
5067
- out.set(chunk2, offset);
5068
- offset += chunk2.byteLength;
5069
- }
5070
- resolvePromise(out);
5071
- });
5042
+ const stream = entry2.internalStream("uint8array");
5043
+ const queue = [];
5044
+ let size = 0;
5045
+ let ended = false;
5046
+ let stopped = false;
5047
+ let failure;
5048
+ let paused = false;
5049
+ let wake;
5050
+ const pause = () => {
5051
+ paused = true;
5052
+ stream.pause();
5053
+ };
5054
+ const resume = () => {
5055
+ if (!paused || stopped) return;
5056
+ paused = false;
5072
5057
  stream.resume();
5058
+ };
5059
+ const fail2 = (error) => {
5060
+ failure ??= error;
5061
+ stopped = true;
5062
+ queue.length = 0;
5063
+ pause();
5064
+ wake?.();
5065
+ };
5066
+ stream.on("data", (chunk2) => {
5067
+ if (stopped) return pause();
5068
+ size += chunk2.byteLength;
5069
+ if (size > declared || size > r.maxEntryBytes)
5070
+ return fail2(
5071
+ r.fail(
5072
+ `${r.label} part ${entry2.name} inflates past its declared size`,
5073
+ r.maxEntryBytes,
5074
+ size > declared ? "declaredSize" : "maxEntryBytes"
5075
+ )
5076
+ );
5077
+ if (alreadyRead + size > r.maxTotalBytes)
5078
+ return fail2(
5079
+ r.fail(
5080
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
5081
+ r.maxTotalBytes,
5082
+ "maxTotalBytes"
5083
+ )
5084
+ );
5085
+ queue.push(chunk2);
5086
+ if (queue.length >= AHEAD) pause();
5087
+ wake?.();
5088
+ });
5089
+ stream.on("error", (error) => fail2(error));
5090
+ stream.on("end", () => {
5091
+ ended = true;
5092
+ wake?.();
5073
5093
  });
5094
+ stream.resume();
5095
+ try {
5096
+ for (; ; ) {
5097
+ if (failure) throw failure;
5098
+ const chunk2 = queue.shift();
5099
+ if (chunk2) {
5100
+ if (queue.length < AHEAD / 2) resume();
5101
+ yield chunk2;
5102
+ continue;
5103
+ }
5104
+ if (ended) return;
5105
+ await new Promise((resolve) => {
5106
+ wake = resolve;
5107
+ resume();
5108
+ });
5109
+ wake = void 0;
5110
+ }
5111
+ } finally {
5112
+ stopped = true;
5113
+ if (!ended) pause();
5114
+ }
5074
5115
  }
5075
5116
  function toBase64(bytes) {
5076
5117
  let binary = "";
@@ -5149,7 +5190,7 @@ async function openZip(input, limits = {}) {
5149
5190
  );
5150
5191
  return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
5151
5192
  }
5152
- var DEFAULT_ZIP_LIMITS, ZipLimitError, mib;
5193
+ var DEFAULT_ZIP_LIMITS, ZipLimitError, mib, AHEAD;
5153
5194
  var init_zip_limits = __esm({
5154
5195
  "opc/zip-limits.ts"() {
5155
5196
  DEFAULT_ZIP_LIMITS = {
@@ -5171,6 +5212,7 @@ var init_zip_limits = __esm({
5171
5212
  }
5172
5213
  };
5173
5214
  mib = (bytes) => Math.round(bytes / 1048576);
5215
+ AHEAD = 8;
5174
5216
  }
5175
5217
  });
5176
5218
 
@@ -62993,6 +63035,22 @@ function findThemeEffectSchemeByName(name) {
62993
63035
  const wanted = name.trim().toLowerCase();
62994
63036
  return exports.THEME_EFFECT_SCHEMES.find((scheme) => scheme.name.toLowerCase() === wanted);
62995
63037
  }
63038
+ function formatSchemeKey(scheme) {
63039
+ const raw2 = (styles) => (styles ?? []).map((style) => style.rawNode ?? null);
63040
+ const lists = [scheme.fillStyles, scheme.lineStyles, scheme.effectStyles];
63041
+ return JSON.stringify(
63042
+ [scheme.name ?? null, ...lists.map(raw2), raw2(scheme.backgroundFillStyles)],
63043
+ (_key, value) => {
63044
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
63045
+ return value;
63046
+ }
63047
+ const entries = Object.entries(value);
63048
+ const isAttribute = ([key2]) => key2.startsWith("@_");
63049
+ const attributes3 = entries.filter(isAttribute).sort(([x], [y]) => x < y ? -1 : 1);
63050
+ return Object.fromEntries([...attributes3, ...entries.filter((entry2) => !isAttribute(entry2))]);
63051
+ }
63052
+ );
63053
+ }
62996
63054
  function wrapFormatSchemeXml(fmtSchemeXml) {
62997
63055
  return fmtSchemeXml.replace(
62998
63056
  /^<a:fmtScheme/u,
@@ -108473,6 +108531,42 @@ var init_master_save_helpers = __esm({
108473
108531
  }
108474
108532
  });
108475
108533
 
108534
+ // pptx/core/core/runtime/held-format-schemes.ts
108535
+ function partsKey(deckScheme, themePaths) {
108536
+ return JSON.stringify([formatSchemeKey(deckScheme), [...new Set(themePaths)].sort()]);
108537
+ }
108538
+ var HeldFormatSchemes;
108539
+ var init_held_format_schemes = __esm({
108540
+ "pptx/core/core/runtime/held-format-schemes.ts"() {
108541
+ init_theme_effect_schemes();
108542
+ HeldFormatSchemes = class {
108543
+ elements = /* @__PURE__ */ new Map();
108544
+ partsByDeckScheme = /* @__PURE__ */ new Map();
108545
+ /** Keep `element`, which `scheme` was parsed from. */
108546
+ hold(scheme, element) {
108547
+ this.elements.set(formatSchemeKey(scheme), structuredClone(element));
108548
+ }
108549
+ /** The element `scheme` was parsed from, if one was held. */
108550
+ element(scheme) {
108551
+ return this.elements.get(formatSchemeKey(scheme));
108552
+ }
108553
+ /** What each part in `parts` held while the deck's scheme was `deckScheme`. */
108554
+ holdParts(deckScheme, parts) {
108555
+ if (parts.size > 0) {
108556
+ this.partsByDeckScheme.set(partsKey(deckScheme, [...parts.keys()]), new Map(parts));
108557
+ }
108558
+ }
108559
+ /**
108560
+ * The element each of `themePaths` held the last time the deck's scheme was `deckScheme` over
108561
+ * exactly those parts, if known.
108562
+ */
108563
+ parts(deckScheme, themePaths) {
108564
+ return this.partsByDeckScheme.get(partsKey(deckScheme, themePaths));
108565
+ }
108566
+ };
108567
+ }
108568
+ });
108569
+
108476
108570
  // pptx/core/builders/fluent/PptxXmlBuilder.ts
108477
108571
  exports.PptxXmlBuilder = void 0; exports.PptxSlideBuilder = void 0; exports.PptxSlideElementsBuilder = void 0; exports.PptxSlideNotesBuilder = void 0;
108478
108572
  var init_PptxXmlBuilder = __esm({
@@ -124972,6 +125066,157 @@ var init_pptx_view_props_helpers = __esm({
124972
125066
  }
124973
125067
  });
124974
125068
 
125069
+ // pptx/core/core/runtime/chart-part-registration.ts
125070
+ function asArray4(value) {
125071
+ if (value === void 0 || value === null) {
125072
+ return [];
125073
+ }
125074
+ return (Array.isArray(value) ? value : [value]).filter(
125075
+ (entry2) => Boolean(entry2) && typeof entry2 === "object"
125076
+ );
125077
+ }
125078
+ function nextFreeChartPartPath(zip, directory) {
125079
+ let n = 1;
125080
+ while (zip.file(`${directory}/chart${n}.xml`)) {
125081
+ n += 1;
125082
+ }
125083
+ return `${directory}/chart${n}.xml`;
125084
+ }
125085
+ function resolvePartTarget(fromPart, target) {
125086
+ if (target.startsWith("/")) {
125087
+ return target.slice(1);
125088
+ }
125089
+ const segments = fromPart.split("/").slice(0, -1);
125090
+ for (const segment of target.split("/")) {
125091
+ if (segment === "..") {
125092
+ segments.pop();
125093
+ } else if (segment !== "." && segment !== "") {
125094
+ segments.push(segment);
125095
+ }
125096
+ }
125097
+ return segments.join("/");
125098
+ }
125099
+ function relativePartTarget2(fromPart, toPart) {
125100
+ const from = fromPart.split("/").slice(0, -1);
125101
+ const to = toPart.split("/");
125102
+ let common = 0;
125103
+ while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
125104
+ common += 1;
125105
+ }
125106
+ return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
125107
+ }
125108
+ async function ensureContentTypeOverride2(deps, partPath, contentType) {
125109
+ const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
125110
+ if (!xml) {
125111
+ return;
125112
+ }
125113
+ const tree = deps.parser.parse(xml);
125114
+ const types = tree["Types"] ?? {};
125115
+ const overrides28 = asArray4(types["Override"]);
125116
+ const partName = `/${partPath}`;
125117
+ if (overrides28.some((entry2) => String(entry2["@_PartName"]) === partName)) {
125118
+ return;
125119
+ }
125120
+ overrides28.push({ "@_PartName": partName, "@_ContentType": contentType });
125121
+ types["Override"] = overrides28;
125122
+ tree["Types"] = types;
125123
+ deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
125124
+ }
125125
+ async function rewriteChartRelationship(deps, slidePath, rewrite) {
125126
+ const slash = slidePath.lastIndexOf("/");
125127
+ const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
125128
+ const xml = await deps.zip.file(relsPath2)?.async("string");
125129
+ if (!xml) {
125130
+ return void 0;
125131
+ }
125132
+ const tree = deps.parser.parse(xml);
125133
+ const root = tree["Relationships"];
125134
+ const relationships3 = asArray4(root?.["Relationship"]);
125135
+ const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
125136
+ (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
125137
+ );
125138
+ if (!match || !root) {
125139
+ return void 0;
125140
+ }
125141
+ match["@_Type"] = rewrite.relationshipType;
125142
+ match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
125143
+ delete match["@_TargetMode"];
125144
+ root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
125145
+ deps.zip.file(relsPath2, deps.builder.build(tree));
125146
+ return String(match["@_Id"]);
125147
+ }
125148
+ function rebindGraphicData(node, relationshipId2, extended) {
125149
+ for (const key2 of Object.keys(node)) {
125150
+ delete node[key2];
125151
+ }
125152
+ node["@_uri"] = extended ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
125153
+ if (extended) {
125154
+ node["cx:chart"] = {
125155
+ "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
125156
+ "@_xmlns:r": NS_R,
125157
+ "@_r:id": relationshipId2
125158
+ };
125159
+ } else {
125160
+ node["c:chart"] = {
125161
+ "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
125162
+ "@_xmlns:r": NS_R,
125163
+ "@_r:id": relationshipId2
125164
+ };
125165
+ }
125166
+ }
125167
+ function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
125168
+ if (!node || typeof node !== "object") {
125169
+ return 0;
125170
+ }
125171
+ if (Array.isArray(node)) {
125172
+ return node.reduce(
125173
+ (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
125174
+ 0
125175
+ );
125176
+ }
125177
+ const object = node;
125178
+ let count = 0;
125179
+ for (const key2 of Object.keys(object)) {
125180
+ if (key2.startsWith("@_")) {
125181
+ continue;
125182
+ }
125183
+ const value = object[key2];
125184
+ if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
125185
+ for (const candidate of asArray4(value)) {
125186
+ const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
125187
+ const chart = chartKey ? candidate[chartKey] : void 0;
125188
+ if (chart && String(chart["@_r:id"]) === relationshipId2) {
125189
+ rebindGraphicData(candidate, relationshipId2, extended);
125190
+ count += 1;
125191
+ }
125192
+ }
125193
+ continue;
125194
+ }
125195
+ count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
125196
+ }
125197
+ return count;
125198
+ }
125199
+ async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
125200
+ const xml = await deps.zip.file(slidePath)?.async("string");
125201
+ if (!xml) {
125202
+ return 0;
125203
+ }
125204
+ const tree = deps.parser.parse(xml);
125205
+ const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
125206
+ if (count > 0) {
125207
+ deps.zip.file(slidePath, deps.builder.build(tree));
125208
+ }
125209
+ return count;
125210
+ }
125211
+ var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R;
125212
+ var init_chart_part_registration = __esm({
125213
+ "pptx/core/core/runtime/chart-part-registration.ts"() {
125214
+ CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
125215
+ CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
125216
+ NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
125217
+ }
125218
+ });
125219
+
124975
125220
  // pptx/core/utils/chart-color-style-writer.ts
124976
125221
  function localName23(key2) {
124977
125222
  return key2.replace(/^.*:/u, "");
@@ -125241,7 +125486,7 @@ function buildChartExSpaceXml(chartData) {
125241
125486
  const chartSpace = {
125242
125487
  "@_xmlns:cx": NS_CX,
125243
125488
  "@_xmlns:a": NS_A,
125244
- "@_xmlns:r": NS_R,
125489
+ "@_xmlns:r": NS_R2,
125245
125490
  "cx:chartData": {
125246
125491
  "cx:data": chartData.series.map(
125247
125492
  (series, index) => buildChartExData(chartData, series, index)
@@ -125255,7 +125500,7 @@ function buildChartExSpaceXml(chartData) {
125255
125500
  }
125256
125501
  return { "cx:chartSpace": chartSpace };
125257
125502
  }
125258
- var NS_CX, NS_A, NS_R, NS_C;
125503
+ var NS_CX, NS_A, NS_R2, NS_C;
125259
125504
  var init_chart_cx_generator = __esm({
125260
125505
  "pptx/core/utils/chart-cx-generator.ts"() {
125261
125506
  init_chart_cx_legend();
@@ -125263,7 +125508,7 @@ var init_chart_cx_generator = __esm({
125263
125508
  init_chart_cx_legend();
125264
125509
  NS_CX = "http://schemas.microsoft.com/office/drawing/2014/chartex";
125265
125510
  NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main";
125266
- NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
125511
+ NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
125267
125512
  NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart";
125268
125513
  }
125269
125514
  });
@@ -126890,7 +127135,7 @@ function buildChartSpaceXml(chartData) {
126890
127135
  "c:chartSpace": {
126891
127136
  "@_xmlns:c": NS_C2,
126892
127137
  "@_xmlns:a": NS_A2,
126893
- "@_xmlns:r": NS_R2,
127138
+ "@_xmlns:r": NS_R3,
126894
127139
  "c:chart": chart
126895
127140
  }
126896
127141
  };
@@ -126898,7 +127143,7 @@ function buildChartSpaceXml(chartData) {
126898
127143
  applyGeneratedChartSpaceFormat(result, chartData);
126899
127144
  return result;
126900
127145
  }
126901
- var NS_C2, NS_A2, NS_R2, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
127146
+ var NS_C2, NS_A2, NS_R3, CAT_AX_ID, VAL_AX_ID, SER_AX_ID, SCATTER_LIKE;
126902
127147
  var init_chart_xml_generator = __esm({
126903
127148
  "pptx/core/utils/chart-xml-generator.ts"() {
126904
127149
  init_chart_bubble_options();
@@ -126919,7 +127164,7 @@ var init_chart_xml_generator = __esm({
126919
127164
  init_chart_xml_series_fill();
126920
127165
  NS_C2 = "http://schemas.openxmlformats.org/drawingml/2006/chart";
126921
127166
  NS_A2 = "http://schemas.openxmlformats.org/drawingml/2006/main";
126922
- NS_R2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
127167
+ NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
126923
127168
  CAT_AX_ID = 111111111;
126924
127169
  VAL_AX_ID = 222222222;
126925
127170
  SER_AX_ID = 333333333;
@@ -129071,7 +129316,7 @@ function buildTitleDefRPr(style, existing, resolveColor2) {
129071
129316
  }
129072
129317
  return rPr;
129073
129318
  }
129074
- function asArray4(value) {
129319
+ function asArray5(value) {
129075
129320
  if (Array.isArray(value)) {
129076
129321
  return value;
129077
129322
  }
@@ -129090,7 +129335,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
129090
129335
  return txKey;
129091
129336
  }
129092
129337
  const pKey = findKey30(rich, "p", getLocalName2) ?? "a:p";
129093
- const paragraphs = asArray4(rich[pKey]).map((para) => {
129338
+ const paragraphs = asArray5(rich[pKey]).map((para) => {
129094
129339
  const next = { ...para };
129095
129340
  const pPrKey = findKey30(next, "pPr", getLocalName2) ?? "a:pPr";
129096
129341
  const pPr = { ...ensureXmlChildOrCreate(next, pPrKey, "first") };
@@ -129103,7 +129348,7 @@ function applyRichTitleFont(title, style, getLocalName2, resolveColor2) {
129103
129348
  next[pPrKey] = pPr;
129104
129349
  const rKey = findKey30(next, "r", getLocalName2);
129105
129350
  if (rKey) {
129106
- const runs = asArray4(next[rKey]).map((run2) => {
129351
+ const runs = asArray5(next[rKey]).map((run2) => {
129107
129352
  const rPrKey = findKey30(run2, "rPr", getLocalName2) ?? "a:rPr";
129108
129353
  const existingRPr = run2[rPrKey] ?? {};
129109
129354
  const nextRun = { ...run2 };
@@ -129497,7 +129742,7 @@ var init_chart_neutral_save = __esm({
129497
129742
  function findKey31(node, localName29, getLocalName2) {
129498
129743
  return Object.keys(node).find((key2) => getLocalName2(key2) === localName29);
129499
129744
  }
129500
- function asArray5(value) {
129745
+ function asArray6(value) {
129501
129746
  if (value === void 0 || value === null) {
129502
129747
  return [];
129503
129748
  }
@@ -129511,8 +129756,8 @@ function dimensionType(node) {
129511
129756
  function replaceLevels(target, source, getLocalName2) {
129512
129757
  const targetKey = findKey31(target, "lvl", getLocalName2) ?? "cx:lvl";
129513
129758
  const sourceKey = findKey31(source, "lvl", getLocalName2);
129514
- const oldLevels = asArray5(target[targetKey]);
129515
- const newLevels = asArray5(sourceKey ? source[sourceKey] : void 0).map((level2, index) => {
129759
+ const oldLevels = asArray6(target[targetKey]);
129760
+ const newLevels = asArray6(sourceKey ? source[sourceKey] : void 0).map((level2, index) => {
129516
129761
  const old = oldLevels[index];
129517
129762
  if (!old) {
129518
129763
  return level2;
@@ -129531,8 +129776,8 @@ function replaceChartExDataDimensions(target, fresh, getLocalName2) {
129531
129776
  for (const kind of ["strDim", "numDim"]) {
129532
129777
  const targetKey = findKey31(target, kind, getLocalName2) ?? `cx:${kind}`;
129533
129778
  const freshKey = findKey31(fresh, kind, getLocalName2);
129534
- const existing = asArray5(target[targetKey]);
129535
- const incoming = asArray5(freshKey ? fresh[freshKey] : void 0);
129779
+ const existing = asArray6(target[targetKey]);
129780
+ const incoming = asArray6(freshKey ? fresh[freshKey] : void 0);
129536
129781
  for (const dimension of incoming) {
129537
129782
  const wantedType = dimensionType(dimension);
129538
129783
  let match = existing.find((candidate) => dimensionType(candidate) === wantedType);
@@ -129570,7 +129815,7 @@ function child29(node, localName29, getLocalName2) {
129570
129815
  const value = key2 ? node[key2] : void 0;
129571
129816
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
129572
129817
  }
129573
- function asArray6(value) {
129818
+ function asArray7(value) {
129574
129819
  if (value === void 0 || value === null) {
129575
129820
  return [];
129576
129821
  }
@@ -129759,7 +130004,7 @@ function chartExLayoutChanged(chartSpace, chartData, getLocalName2) {
129759
130004
  getLocalName2
129760
130005
  );
129761
130006
  const seriesKey = region ? findKey32(region, "series", getLocalName2) : void 0;
129762
- const first2 = region && seriesKey ? asArray6(region[seriesKey])[0] : void 0;
130007
+ const first2 = region && seriesKey ? asArray7(region[seriesKey])[0] : void 0;
129763
130008
  const existing = String(first2?.["@_layoutId"] ?? "").toLowerCase();
129764
130009
  const series = chartData.series[0];
129765
130010
  if (!existing || !series) {
@@ -129777,9 +130022,9 @@ function applyChartExUpdate(chartSpace, chartData, getLocalName2) {
129777
130022
  const chartDataKey = findKey32(chartSpace, "chartData", getLocalName2);
129778
130023
  const chartDataNode = (chartDataKey ? chartSpace[chartDataKey] : void 0) ?? {};
129779
130024
  const dataKey = findKey32(chartDataNode, "data", getLocalName2) ?? "cx:data";
129780
- const dataNodes = asArray6(chartDataNode[dataKey]);
130025
+ const dataNodes = asArray7(chartDataNode[dataKey]);
129781
130026
  const seriesKey = findKey32(region, "series", getLocalName2) ?? "cx:series";
129782
- const existing = asArray6(region[seriesKey]);
130027
+ const existing = asArray7(region[seriesKey]);
129783
130028
  const updated = [];
129784
130029
  chartData.series.forEach((series, index) => {
129785
130030
  const node = existing[index];
@@ -129861,157 +130106,6 @@ var init_chart_external_workbook_save = __esm({
129861
130106
  }
129862
130107
  });
129863
130108
 
129864
- // pptx/core/core/runtime/chart-part-registration.ts
129865
- function asArray7(value) {
129866
- if (value === void 0 || value === null) {
129867
- return [];
129868
- }
129869
- return (Array.isArray(value) ? value : [value]).filter(
129870
- (entry2) => Boolean(entry2) && typeof entry2 === "object"
129871
- );
129872
- }
129873
- function nextFreeChartPartPath(zip, directory) {
129874
- let n = 1;
129875
- while (zip.file(`${directory}/chart${n}.xml`)) {
129876
- n += 1;
129877
- }
129878
- return `${directory}/chart${n}.xml`;
129879
- }
129880
- function resolvePartTarget(fromPart, target) {
129881
- if (target.startsWith("/")) {
129882
- return target.slice(1);
129883
- }
129884
- const segments = fromPart.split("/").slice(0, -1);
129885
- for (const segment of target.split("/")) {
129886
- if (segment === "..") {
129887
- segments.pop();
129888
- } else if (segment !== "." && segment !== "") {
129889
- segments.push(segment);
129890
- }
129891
- }
129892
- return segments.join("/");
129893
- }
129894
- function relativePartTarget2(fromPart, toPart) {
129895
- const from = fromPart.split("/").slice(0, -1);
129896
- const to = toPart.split("/");
129897
- let common = 0;
129898
- while (common < from.length && common < to.length - 1 && from[common] === to[common]) {
129899
- common += 1;
129900
- }
129901
- return [...from.slice(common).map(() => ".."), ...to.slice(common)].join("/");
129902
- }
129903
- async function ensureContentTypeOverride2(deps, partPath, contentType) {
129904
- const xml = await deps.zip.file("[Content_Types].xml")?.async("string");
129905
- if (!xml) {
129906
- return;
129907
- }
129908
- const tree = deps.parser.parse(xml);
129909
- const types = tree["Types"] ?? {};
129910
- const overrides28 = asArray7(types["Override"]);
129911
- const partName = `/${partPath}`;
129912
- if (overrides28.some((entry2) => String(entry2["@_PartName"]) === partName)) {
129913
- return;
129914
- }
129915
- overrides28.push({ "@_PartName": partName, "@_ContentType": contentType });
129916
- types["Override"] = overrides28;
129917
- tree["Types"] = types;
129918
- deps.zip.file("[Content_Types].xml", deps.builder.build(tree));
129919
- }
129920
- async function rewriteChartRelationship(deps, slidePath, rewrite) {
129921
- const slash = slidePath.lastIndexOf("/");
129922
- const relsPath2 = `${slidePath.slice(0, slash + 1)}_rels/${slidePath.slice(slash + 1)}.rels`;
129923
- const xml = await deps.zip.file(relsPath2)?.async("string");
129924
- if (!xml) {
129925
- return void 0;
129926
- }
129927
- const tree = deps.parser.parse(xml);
129928
- const root = tree["Relationships"];
129929
- const relationships3 = asArray7(root?.["Relationship"]);
129930
- const match = relationships3.find((rel) => String(rel["@_Id"]) === rewrite.relationshipId) ?? relationships3.find(
129931
- (rel) => resolvePartTarget(slidePath, String(rel["@_Target"] ?? "")) === rewrite.oldPartPath
129932
- );
129933
- if (!match || !root) {
129934
- return void 0;
129935
- }
129936
- match["@_Type"] = rewrite.relationshipType;
129937
- match["@_Target"] = relativePartTarget2(slidePath, rewrite.newPartPath);
129938
- delete match["@_TargetMode"];
129939
- root["Relationship"] = relationships3.length === 1 ? relationships3[0] : relationships3;
129940
- deps.zip.file(relsPath2, deps.builder.build(tree));
129941
- return String(match["@_Id"]);
129942
- }
129943
- function rebindGraphicData(node, relationshipId2, extended) {
129944
- for (const key2 of Object.keys(node)) {
129945
- delete node[key2];
129946
- }
129947
- node["@_uri"] = extended ? CHART_EX_GRAPHIC_DATA_URI : CHART_GRAPHIC_DATA_URI;
129948
- if (extended) {
129949
- node["cx:chart"] = {
129950
- "@_xmlns:cx": CHART_EX_GRAPHIC_DATA_URI,
129951
- "@_xmlns:r": NS_R3,
129952
- "@_r:id": relationshipId2
129953
- };
129954
- } else {
129955
- node["c:chart"] = {
129956
- "@_xmlns:c": CHART_GRAPHIC_DATA_URI,
129957
- "@_xmlns:r": NS_R3,
129958
- "@_r:id": relationshipId2
129959
- };
129960
- }
129961
- }
129962
- function visitGraphicData(node, relationshipId2, extended, getLocalName2) {
129963
- if (!node || typeof node !== "object") {
129964
- return 0;
129965
- }
129966
- if (Array.isArray(node)) {
129967
- return node.reduce(
129968
- (count2, entry2) => count2 + visitGraphicData(entry2, relationshipId2, extended, getLocalName2),
129969
- 0
129970
- );
129971
- }
129972
- const object = node;
129973
- let count = 0;
129974
- for (const key2 of Object.keys(object)) {
129975
- if (key2.startsWith("@_")) {
129976
- continue;
129977
- }
129978
- const value = object[key2];
129979
- if (getLocalName2(key2) === "graphicData" && value && typeof value === "object") {
129980
- for (const candidate of asArray7(value)) {
129981
- const chartKey = Object.keys(candidate).find((k) => getLocalName2(k) === "chart");
129982
- const chart = chartKey ? candidate[chartKey] : void 0;
129983
- if (chart && String(chart["@_r:id"]) === relationshipId2) {
129984
- rebindGraphicData(candidate, relationshipId2, extended);
129985
- count += 1;
129986
- }
129987
- }
129988
- continue;
129989
- }
129990
- count += visitGraphicData(value, relationshipId2, extended, getLocalName2);
129991
- }
129992
- return count;
129993
- }
129994
- async function rewriteChartGraphicFrames(deps, slidePath, relationshipId2, extended) {
129995
- const xml = await deps.zip.file(slidePath)?.async("string");
129996
- if (!xml) {
129997
- return 0;
129998
- }
129999
- const tree = deps.parser.parse(xml);
130000
- const count = visitGraphicData(tree, relationshipId2, extended, deps.getLocalName);
130001
- if (count > 0) {
130002
- deps.zip.file(slidePath, deps.builder.build(tree));
130003
- }
130004
- return count;
130005
- }
130006
- var CHART_GRAPHIC_DATA_URI, CHART_EX_GRAPHIC_DATA_URI, NS_R3;
130007
- var init_chart_part_registration = __esm({
130008
- "pptx/core/core/runtime/chart-part-registration.ts"() {
130009
- CHART_GRAPHIC_DATA_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
130010
- CHART_EX_GRAPHIC_DATA_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
130011
- NS_R3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
130012
- }
130013
- });
130014
-
130015
130109
  // pptx/core/core/runtime/chart-part-family-switch.ts
130016
130110
  function detectChartPartFamily(chartSpace, getLocalName2) {
130017
130111
  const keys = Object.keys(chartSpace);
@@ -134058,18 +134152,22 @@ var init_PptxHandlerRuntimeElementActions = __esm({
134058
134152
  * Write or remove a single `a:hlinkClick` / `a:hlinkHover` node on
134059
134153
  * a `p:cNvPr` parent.
134060
134154
  */
134061
- serializeSingleAction(cNvPr, nodeName, action, resolveHyperlinkRelationshipId) {
134155
+ serializeSingleAction(cNvPr, nodeName, action, links) {
134062
134156
  if (!action) {
134063
134157
  delete cNvPr[nodeName];
134064
134158
  return;
134065
134159
  }
134066
134160
  const node = {};
134161
+ const url = action.url?.trim() || (/^ppaction:\/\/hlinksldjump\b/iu.test(action.action ?? "") && typeof action.targetSlideIndex === "number" ? links.slideTargetAt?.(action.targetSlideIndex) : void 0);
134067
134162
  let rId = action.rId;
134068
- if (!rId && action.url) {
134163
+ if (rId && url && links.getSlideRelationshipMap().get(rId) !== url) {
134164
+ rId = void 0;
134165
+ }
134166
+ if (!rId && url) {
134069
134167
  const forceExternal = /^ppaction:\/\/(program|hlinkfile|hlinkpres)\b/iu.test(
134070
134168
  action.action ?? ""
134071
134169
  );
134072
- rId = resolveHyperlinkRelationshipId(action.url, forceExternal) ?? void 0;
134170
+ rId = links.resolveHyperlinkRelationshipId(url, forceExternal) ?? void 0;
134073
134171
  }
134074
134172
  node["@_r:id"] = rId ?? "";
134075
134173
  if (action.action) {
@@ -134143,7 +134241,7 @@ var init_PptxHandlerRuntimeElementActions = __esm({
134143
134241
  * the `a:hlinkClick` and `a:hlinkHover` nodes on the element's
134144
134242
  * non-visual properties.
134145
134243
  */
134146
- serializeElementActions(shape, el, resolveHyperlinkRelationshipId) {
134244
+ serializeElementActions(shape, el, links) {
134147
134245
  const key2 = this.getTreeBucketKeyForElementType(el.type);
134148
134246
  const cNvPr = this.getCnvPrNode(shape, key2);
134149
134247
  if (!cNvPr) {
@@ -134151,8 +134249,8 @@ var init_PptxHandlerRuntimeElementActions = __esm({
134151
134249
  }
134152
134250
  const actionClick = "actionClick" in el ? el.actionClick : void 0;
134153
134251
  const actionHover = "actionHover" in el ? el.actionHover : void 0;
134154
- this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, resolveHyperlinkRelationshipId);
134155
- this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, resolveHyperlinkRelationshipId);
134252
+ this.serializeSingleAction(cNvPr, "a:hlinkClick", actionClick, links);
134253
+ this.serializeSingleAction(cNvPr, "a:hlinkHover", actionHover, links);
134156
134254
  const isDecorative = "isDecorative" in el ? el.isDecorative : void 0;
134157
134255
  serializeDecorativeExtension(cNvPr, isDecorative);
134158
134256
  }
@@ -135058,6 +135156,11 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135058
135156
  const upSegments = Array.from({ length: fromParts.length }).fill("..");
135059
135157
  return [...upSegments, ...toParts].join("/");
135060
135158
  }
135159
+ /**
135160
+ * Point a slide master's theme relationship at `themePath`.
135161
+ *
135162
+ * @returns whether the master had a theme relationship to rewrite
135163
+ */
135061
135164
  async setMasterThemeRelationship(masterPath, themePath) {
135062
135165
  const relsPath2 = masterPath.replace(
135063
135166
  /ppt\/slideMasters\/(slideMaster\d+)\.xml/,
@@ -135065,7 +135168,7 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135065
135168
  );
135066
135169
  const relsFile = this.zip.file(relsPath2);
135067
135170
  if (!relsFile) {
135068
- return;
135171
+ return false;
135069
135172
  }
135070
135173
  const relsXml = await relsFile.async("string");
135071
135174
  const relsData = this.parser.parse(relsXml);
@@ -135073,28 +135176,13 @@ var init_PptxHandlerRuntimeDocProperties = __esm({
135073
135176
  const relationships3 = this.ensureArray(relRoot["Relationship"]);
135074
135177
  const themeRel = relationships3.find((rel) => String(rel["@_Type"] || "").includes("/theme"));
135075
135178
  if (!themeRel) {
135076
- return;
135179
+ return false;
135077
135180
  }
135078
135181
  themeRel["@_Target"] = this.buildRelativeTargetPath(masterPath, themePath);
135079
135182
  relRoot["Relationship"] = relationships3;
135080
135183
  relsData["Relationships"] = relRoot;
135081
135184
  this.zip.file(relsPath2, this.builder.build(relsData));
135082
- }
135083
- async setPresentationTheme(themePath, applyToAllMasters = true) {
135084
- const normalizedThemePath = themePath.trim().replace(/\\/g, "/");
135085
- if (!normalizedThemePath.startsWith("ppt/theme/")) {
135086
- return;
135087
- }
135088
- const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
135089
- if (!masterFiles || masterFiles.length === 0) {
135090
- return;
135091
- }
135092
- const targetMasters = applyToAllMasters ? masterFiles : [masterFiles[0]];
135093
- await Promise.all(
135094
- targetMasters.map(async (masterFile) => {
135095
- await this.setMasterThemeRelationship(masterFile.name, normalizedThemePath);
135096
- })
135097
- );
135185
+ return true;
135098
135186
  }
135099
135187
  /** The text of a package part, or `undefined` when the package has no such part. */
135100
135188
  async readPartText(path3) {
@@ -135424,8 +135512,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135424
135512
  this.masterXmlMap.set(path3, data);
135425
135513
  }
135426
135514
  const masterCSldName = (xmlAttr(sldMaster["p:cSld"], "name") ?? "").trim();
135427
- const bg = sldMaster["p:cSld"]?.["p:bg"];
135428
- const backgroundColor = this.parseBackgroundColor(bg);
135429
135515
  const spTree = sldMaster["p:cSld"]?.["p:spTree"];
135430
135516
  const placeholders = this.extractPlaceholderList(spTree);
135431
135517
  let preserve;
@@ -135479,7 +135565,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135479
135565
  results.push({
135480
135566
  path: path3,
135481
135567
  name: masterCSldName.length > 0 ? masterCSldName : void 0,
135482
- backgroundColor,
135483
135568
  themePath,
135484
135569
  layoutPaths: layoutPaths.length > 0 ? layoutPaths : void 0,
135485
135570
  layouts: layouts.length > 0 ? layouts : void 0,
@@ -135617,11 +135702,6 @@ var init_PptxHandlerRuntimeSlideMasters = __esm({
135617
135702
  layout.clrMapOverride = overrideMap;
135618
135703
  }
135619
135704
  }
135620
- const bg = xmlPath(sldLayout, "p:cSld", "p:bg");
135621
- const bgColor = this.parseBackgroundColor(bg);
135622
- if (bgColor) {
135623
- layout.backgroundColor = bgColor;
135624
- }
135625
135705
  const spTree = xmlPath(sldLayout, "p:cSld", "p:spTree");
135626
135706
  const placeholders = this.extractPlaceholderList(spTree);
135627
135707
  if (placeholders.length > 0) {
@@ -147798,7 +147878,7 @@ var init_PptxHandlerRuntimeSaveElementWriter = __esm({
147798
147878
  if (ctx.connectorShapeIds) {
147799
147879
  applyConnectorShapeIds(shape, el, ctx.connectorShapeIds);
147800
147880
  }
147801
- this.serializeElementActions(shape, el, ctx.resolveHyperlinkRelationshipId);
147881
+ this.serializeElementActions(shape, el, ctx);
147802
147882
  this.serializeShapeLocks(shape, el);
147803
147883
  this.applyHiddenToCnvPr(shape, el);
147804
147884
  this.applyNameToCnvPr(shape, el);
@@ -148776,6 +148856,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
148776
148856
  init_theme_override_utils();
148777
148857
  init_builders();
148778
148858
  init_authored_slide_background();
148859
+ init_chart_part_registration();
148779
148860
  init_PptxHandlerRuntimeSaveElementWriter();
148780
148861
  init_save_structural_id_gate();
148781
148862
  init_slide_fingerprint();
@@ -148911,7 +148992,7 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
148911
148992
  * Process a single slide during save: update slide XML, process elements,
148912
148993
  * rebuild shape tree, and persist relationships.
148913
148994
  */
148914
- async processSlideForSave(slide, saveSession, constants) {
148995
+ async processSlideForSave(slide, saveSession, constants, slidePaths = []) {
148915
148996
  if (this.canSkipSlideSave(slide)) {
148916
148997
  return;
148917
148998
  }
@@ -149096,6 +149177,10 @@ var init_PptxHandlerRuntimeSaveSlideWriter = __esm({
149096
149177
  slideRelationshipRegistry,
149097
149178
  resolveHyperlinkRelationshipId: (target, forceExternal) => slideRelationshipRegistry.resolveHyperlinkRelationshipId(target, forceExternal),
149098
149179
  getSlideRelationshipMap: () => slideRelationshipRegistry.toRelationshipMap(),
149180
+ slideTargetAt: (index) => {
149181
+ const target = slidePaths[index];
149182
+ return target ? relativePartTarget2(slide.id, target) : void 0;
149183
+ },
149099
149184
  resolvedMediaBytes,
149100
149185
  saveSession,
149101
149186
  slideImageRelationshipType: constants.slideImageRelationshipType,
@@ -151405,7 +151490,23 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
151405
151490
  }
151406
151491
  return this.isStrictOoxml ? "strict" : "transitional";
151407
151492
  }
151493
+ /** The save running now, or the last one: see {@link save}. */
151494
+ saveQueue = Promise.resolve();
151495
+ /**
151496
+ * Saves run one at a time. A save rewrites `this.zip` in place across many awaits and moves
151497
+ * per-part baselines (slide fingerprints, chart data, pending chart updates) while it runs, so
151498
+ * a second save that starts mid-way (a viewer's autosave snapshot firing during the user's own
151499
+ * save) read half-written state: it skipped the slide as unchanged and wrote the chart part's
151500
+ * original XML back over the edit, in both outputs. Each save now waits for the one before it;
151501
+ * one that fails does not hold up the next.
151502
+ */
151408
151503
  async save(slides, options) {
151504
+ const run2 = this.saveQueue.then(() => this.saveNow(slides, options));
151505
+ this.saveQueue = run2.catch(() => void 0);
151506
+ return run2;
151507
+ }
151508
+ /** One save, with the package to itself; callers go through {@link save}. */
151509
+ async saveNow(slides, options) {
151409
151510
  validateSlideGeometry(slides);
151410
151511
  const templates = [
151411
151512
  ...options?.slideMasters ?? [],
@@ -151423,7 +151524,7 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
151423
151524
  return this.saveAsLegacyPpt(
151424
151525
  slides,
151425
151526
  options,
151426
- () => this.save(slides, {
151527
+ () => this.saveNow(slides, {
151427
151528
  ...options,
151428
151529
  pptPassword: void 0,
151429
151530
  outputFormat: "pptx",
@@ -151455,8 +151556,9 @@ var init_PptxHandlerRuntimeSavePipeline = __esm({
151455
151556
  await this.ensureNotesMasterForAuthoredNotes(slides, saveConstants);
151456
151557
  await this.ensureHandoutMasterInfrastructure(options?.handoutMaster, saveConstants);
151457
151558
  this.templateElementBaselines.beginSave();
151559
+ const slidePaths = slides.map((slide) => slide.id);
151458
151560
  for (const slide of slides) {
151459
- await this.processSlideForSave(slide, saveSession, saveConstants);
151561
+ await this.processSlideForSave(slide, saveSession, saveConstants, slidePaths);
151460
151562
  }
151461
151563
  this.templateElementBaselines.commitSave();
151462
151564
  const contentTypesXml3 = await this.zip.file("[Content_Types].xml")?.async("string");
@@ -156410,6 +156512,25 @@ var init_PptxHandlerRuntimeBackgroundParsing = __esm({
156410
156512
  }
156411
156513
  return void 0;
156412
156514
  }
156515
+ /**
156516
+ * The colour a slide master or layout paints from its own `p:bg`, resolved exactly as a
156517
+ * slide's background is: through the active master's colour map and format scheme, with
156518
+ * `clrMapOverride` (a layout's `p:clrMapOvr`, or `null`) taking precedence. The caller makes
156519
+ * the part's master active first; a master's `bgRef` on `bg1` means `dk1` under a dark
156520
+ * `p:clrMap`, which no other state can tell.
156521
+ */
156522
+ extractTemplateBackgroundColor(partXml, rootTag2, clrMapOverride) {
156523
+ if (!partXml) {
156524
+ return void 0;
156525
+ }
156526
+ const previousOverride = this.currentSlideClrMapOverride;
156527
+ this.currentSlideClrMapOverride = clrMapOverride;
156528
+ try {
156529
+ return this.extractBackgroundColor(partXml, rootTag2);
156530
+ } finally {
156531
+ this.currentSlideClrMapOverride = previousOverride;
156532
+ }
156533
+ }
156413
156534
  /**
156414
156535
  * Composite a resolved background colour with its `a:alpha` (or
156415
156536
  * `a:alphaMod`/`a:alphaOff`) opacity onto opaque white.
@@ -156976,6 +157097,31 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
156976
157097
  const masterFormatScheme = this.masterThemeFormatSchemes.get(masterPath);
156977
157098
  this.themeFormatScheme = masterFormatScheme ?? this.globalThemeFormatSchemeSnapshot;
156978
157099
  }
157100
+ /**
157101
+ * Run `work` with one master's theme state active and no slide colour-map override, then
157102
+ * put back whatever state was active before, so a part parsed on request (a layout preview)
157103
+ * resolves through its own master without disturbing the caller's.
157104
+ */
157105
+ async withMasterThemeState(masterPath, work) {
157106
+ const saved = {
157107
+ colors: this.themeColorMap,
157108
+ fonts: this.themeFontMap,
157109
+ format: this.themeFormatScheme,
157110
+ clrMap: this.currentMasterClrMap,
157111
+ slideClrMap: this.currentSlideClrMapOverride
157112
+ };
157113
+ this.applyMasterThemeState(masterPath);
157114
+ this.currentSlideClrMapOverride = null;
157115
+ try {
157116
+ return await work();
157117
+ } finally {
157118
+ this.themeColorMap = saved.colors;
157119
+ this.themeFontMap = saved.fonts;
157120
+ this.themeFormatScheme = saved.format;
157121
+ this.currentMasterClrMap = saved.clrMap;
157122
+ this.currentSlideClrMapOverride = saved.slideClrMap;
157123
+ }
157124
+ }
156979
157125
  /**
156980
157126
  * Extract the `p:bg/@showAnimation` flag from a slide's XML.
156981
157127
  * Returns `true` when the background should animate, `false` when
@@ -157890,18 +158036,33 @@ var init_PptxHandlerRuntimeAuxiliaryMasterElements = __esm({
157890
158036
  this.rememberUnparsedMasterNodes(partPath, spTree, part.elements);
157891
158037
  }
157892
158038
  /**
157893
- * Populate `elements` on every slide master and on each of its layouts.
158039
+ * Resolve the background of every slide master and of each of its layouts,
158040
+ * and populate their `elements`.
157894
158041
  *
157895
- * Scheme colours on a master's own shapes must resolve through that
157896
- * master's colour map and theme, so the active master state is switched
157897
- * per part and reset to the deck-wide snapshot afterwards.
158042
+ * Scheme colours on a master, its own `p:bgRef` included, must resolve
158043
+ * through that master's colour map and theme, so the active master state is
158044
+ * switched per part and reset to the deck-wide snapshot afterwards.
157898
158045
  */
157899
158046
  async enrichSlideMasterElements(masters) {
157900
158047
  for (const master of masters) {
157901
158048
  try {
157902
158049
  this.applyMasterThemeState(master.path);
158050
+ master.backgroundColor = this.extractTemplateBackgroundColor(
158051
+ this.masterXmlMap.get(master.path),
158052
+ "p:sldMaster",
158053
+ null
158054
+ );
157903
158055
  await this.enrichMasterPartElements(master, "p:sldMaster");
157904
158056
  for (const layout of master.layouts ?? []) {
158057
+ const layoutXml3 = this.layoutXmlMap.get(layout.path);
158058
+ const backgroundColor = this.extractTemplateBackgroundColor(
158059
+ layoutXml3,
158060
+ "p:sldLayout",
158061
+ layoutXml3 ? this.parseLayoutClrMapOverride(layoutXml3) : null
158062
+ );
158063
+ if (backgroundColor) {
158064
+ layout.backgroundColor = backgroundColor;
158065
+ }
157905
158066
  await this.enrichMasterPartElements(layout, "p:sldLayout");
157906
158067
  }
157907
158068
  } catch (e) {
@@ -158172,20 +158333,23 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
158172
158333
  this.layoutCache.delete(layoutPath);
158173
158334
  this.eagerDecodeImages = true;
158174
158335
  }
158175
- let elements3;
158336
+ const masterPath = this.resolveMasterPathForLayout(layoutPath);
158337
+ let parsed;
158176
158338
  try {
158177
- elements3 = await this.getLayoutElementsByPath(layoutPath);
158339
+ parsed = await this.withMasterThemeState(masterPath, async () => ({
158340
+ elements: await this.getLayoutElementsByPath(layoutPath),
158341
+ background: this.resolveLayoutPreviewBackground(layoutXml3, masterPath)
158342
+ }));
158178
158343
  } finally {
158179
158344
  this.eagerDecodeImages = previousEagerDecode;
158180
158345
  }
158181
158346
  const cSld = xmlPath(layoutXml3, "p:sldLayout", "p:cSld");
158182
- const background = this.resolveLayoutPreviewBackground(layoutPath, cSld);
158183
158347
  const preview = {
158184
158348
  path: layoutPath,
158185
158349
  width: this.rawSlideWidthEmu / exports.EMU_PER_PX,
158186
158350
  height: this.rawSlideHeightEmu / exports.EMU_PER_PX,
158187
- ...background,
158188
- elements: elements3,
158351
+ ...parsed.background,
158352
+ elements: parsed.elements,
158189
158353
  placeholders: this.extractPlaceholderList(xmlChild(cSld, "p:spTree"))
158190
158354
  };
158191
158355
  this.layoutPreviewCache.set(layoutPath, preview);
@@ -158221,19 +158385,18 @@ var init_PptxHandlerRuntimeLayoutPreviews = __esm({
158221
158385
  }
158222
158386
  /**
158223
158387
  * Resolve the background a layout thumbnail should paint, falling back to
158224
- * the layout's master when the layout itself declares none.
158388
+ * the layout's master when the layout itself declares none. Runs with the
158389
+ * master active; the layout's own colour map override applies to an
158390
+ * inherited background too, as a slide's does.
158225
158391
  */
158226
- resolveLayoutPreviewBackground(layoutPath, cSld) {
158227
- const ownBackground = this.parseBackgroundColor(xmlChild(cSld, "p:bg"));
158228
- if (ownBackground) {
158229
- return { backgroundColor: ownBackground };
158230
- }
158231
- const masterPath = this.resolveMasterPathForLayout(layoutPath);
158232
- const masterXml = masterPath ? this.masterXmlMap.get(masterPath) : void 0;
158233
- const masterBackground = this.parseBackgroundColor(
158234
- xmlChild(xmlPath(masterXml, "p:sldMaster", "p:cSld"), "p:bg")
158392
+ resolveLayoutPreviewBackground(layoutXml3, masterPath) {
158393
+ const clrMapOverride = this.parseLayoutClrMapOverride(layoutXml3);
158394
+ const backgroundColor = this.extractTemplateBackgroundColor(layoutXml3, "p:sldLayout", clrMapOverride) ?? this.extractTemplateBackgroundColor(
158395
+ masterPath ? this.masterXmlMap.get(masterPath) : void 0,
158396
+ "p:sldMaster",
158397
+ clrMapOverride
158235
158398
  );
158236
- return masterBackground ? { backgroundColor: masterBackground } : {};
158399
+ return backgroundColor ? { backgroundColor } : {};
158237
158400
  }
158238
158401
  };
158239
158402
  }
@@ -159041,15 +159204,298 @@ var init_PptxHandlerRuntimeThemeRefResolution = __esm({
159041
159204
  }
159042
159205
  });
159043
159206
 
159207
+ // pptx/core/core/runtime/theme-scheme-edit.ts
159208
+ function normalizeHex6(hex3) {
159209
+ return hex3.replace(/^#/, "").toUpperCase();
159210
+ }
159211
+ function buildSrgbClrNode(hex3) {
159212
+ return { "a:srgbClr": { "@_val": normalizeHex6(hex3) } };
159213
+ }
159214
+ function themeElementsOf(data) {
159215
+ const root = data["a:theme"];
159216
+ return root?.["a:themeElements"];
159217
+ }
159218
+ function applyColorSchemeToThemeXml(data, colorScheme) {
159219
+ const themeElements = themeElementsOf(data);
159220
+ if (!themeElements) {
159221
+ return false;
159222
+ }
159223
+ const clrScheme = themeElements["a:clrScheme"] ?? {};
159224
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159225
+ clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
159226
+ }
159227
+ themeElements["a:clrScheme"] = clrScheme;
159228
+ return true;
159229
+ }
159230
+ function applyLatinTypeface(group, latin) {
159231
+ const font = group ?? {};
159232
+ font["a:latin"] = { "@_typeface": latin };
159233
+ if (!font["a:ea"]) {
159234
+ font["a:ea"] = { "@_typeface": "" };
159235
+ }
159236
+ if (!font["a:cs"]) {
159237
+ font["a:cs"] = { "@_typeface": "" };
159238
+ }
159239
+ return font;
159240
+ }
159241
+ function applyFontSchemeToThemeXml(data, fontScheme) {
159242
+ const themeElements = themeElementsOf(data);
159243
+ if (!themeElements) {
159244
+ return false;
159245
+ }
159246
+ const fntScheme = themeElements["a:fontScheme"] ?? {};
159247
+ if (fontScheme.majorFont?.latin) {
159248
+ fntScheme["a:majorFont"] = applyLatinTypeface(
159249
+ fntScheme["a:majorFont"],
159250
+ fontScheme.majorFont.latin
159251
+ );
159252
+ }
159253
+ if (fontScheme.minorFont?.latin) {
159254
+ fntScheme["a:minorFont"] = applyLatinTypeface(
159255
+ fntScheme["a:minorFont"],
159256
+ fontScheme.minorFont.latin
159257
+ );
159258
+ }
159259
+ themeElements["a:fontScheme"] = fntScheme;
159260
+ return true;
159261
+ }
159262
+ function applyColorSchemeToMap(map, colorScheme, clrMap) {
159263
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159264
+ map[key2] = normalizeHex6(colorScheme[key2]);
159265
+ }
159266
+ for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
159267
+ const target = clrMap?.[alias] ?? defaultTarget;
159268
+ const resolved = map[target];
159269
+ if (resolved !== void 0) {
159270
+ map[alias] = resolved;
159271
+ }
159272
+ }
159273
+ }
159274
+ function applyFontSchemeToMap(map, fontScheme) {
159275
+ if (fontScheme.majorFont?.latin) {
159276
+ map["mj-lt"] = fontScheme.majorFont.latin;
159277
+ map["mj-ea"] = fontScheme.majorFont.latin;
159278
+ map["mj-cs"] = fontScheme.majorFont.latin;
159279
+ }
159280
+ if (fontScheme.minorFont?.latin) {
159281
+ map["mn-lt"] = fontScheme.minorFont.latin;
159282
+ map["mn-ea"] = fontScheme.minorFont.latin;
159283
+ map["mn-cs"] = fontScheme.minorFont.latin;
159284
+ }
159285
+ }
159286
+ var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
159287
+ var init_theme_scheme_edit = __esm({
159288
+ "pptx/core/core/runtime/theme-scheme-edit.ts"() {
159289
+ THEME_COLOR_SCHEME_KEYS2 = [
159290
+ "dk1",
159291
+ "lt1",
159292
+ "dk2",
159293
+ "lt2",
159294
+ "accent1",
159295
+ "accent2",
159296
+ "accent3",
159297
+ "accent4",
159298
+ "accent5",
159299
+ "accent6",
159300
+ "hlink",
159301
+ "folHlink"
159302
+ ];
159303
+ DEFAULT_CLR_MAP_ALIASES = {
159304
+ tx1: "dk1",
159305
+ bg1: "lt1",
159306
+ tx2: "dk2",
159307
+ bg2: "lt2"
159308
+ };
159309
+ }
159310
+ });
159311
+
159312
+ // pptx/core/core/runtime/theme-part-model.ts
159313
+ function colorSchemeFromMap(colorMap) {
159314
+ const scheme = {};
159315
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159316
+ scheme[key2] = colorMap[key2] || "";
159317
+ }
159318
+ return scheme;
159319
+ }
159320
+ function fontGroup(fontMap, prefix, byScript) {
159321
+ const latin = fontMap[`${prefix}-lt`];
159322
+ const eastAsia = fontMap[`${prefix}-ea`];
159323
+ const complexScript = fontMap[`${prefix}-cs`];
159324
+ return {
159325
+ ...latin ? { latin } : {},
159326
+ ...eastAsia ? { eastAsia } : {},
159327
+ ...complexScript ? { complexScript } : {},
159328
+ ...Object.keys(byScript).length > 0 ? { byScript: { ...byScript } } : {}
159329
+ };
159330
+ }
159331
+ function fontSchemeFromMap(fontMap, majorByScript, minorByScript) {
159332
+ return {
159333
+ majorFont: fontGroup(fontMap, "mj", majorByScript),
159334
+ minorFont: fontGroup(fontMap, "mn", minorByScript)
159335
+ };
159336
+ }
159337
+ var init_theme_part_model = __esm({
159338
+ "pptx/core/core/runtime/theme-part-model.ts"() {
159339
+ init_theme_scheme_edit();
159340
+ }
159341
+ });
159342
+
159343
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts
159344
+ var FONT_SLOTS, PptxHandlerRuntime84;
159345
+ var init_PptxHandlerRuntimeThemePartModel = __esm({
159346
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemePartModel.ts"() {
159347
+ init_PptxHandlerRuntimeThemeRefResolution();
159348
+ init_theme_part_model();
159349
+ init_theme_scheme_edit();
159350
+ FONT_SLOTS = [
159351
+ ["mj", "a:majorFont"],
159352
+ ["mn", "a:minorFont"]
159353
+ ];
159354
+ PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
159355
+ /** Parse one theme part's XML. Side-effect free. */
159356
+ parseThemePartXml(themeXml3) {
159357
+ const themeData = this.parser.parse(themeXml3);
159358
+ const themeRoot = themeData["a:theme"];
159359
+ const themeElements = themeRoot?.["a:themeElements"];
159360
+ const colorScheme = themeElements?.["a:clrScheme"];
159361
+ const fontScheme = themeElements?.["a:fontScheme"];
159362
+ const fmtScheme = themeElements?.["a:fmtScheme"];
159363
+ const text2 = (value) => String(value || "").trim() || void 0;
159364
+ const colorMap = { ...this.getDefaultSchemeColorMap() };
159365
+ for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159366
+ const parsed = this.parseColorChoice(colorScheme?.[`a:${key2}`]);
159367
+ if (parsed) {
159368
+ colorMap[key2] = parsed;
159369
+ }
159370
+ }
159371
+ const fontMap = {};
159372
+ const typeface = (node) => this.normalizeTypefaceToken(String(node?.["@_typeface"] || ""));
159373
+ for (const [prefix, tag] of FONT_SLOTS) {
159374
+ const group = fontScheme?.[tag];
159375
+ const latin = typeface(group?.["a:latin"]);
159376
+ if (latin) {
159377
+ fontMap[`${prefix}-lt`] = latin;
159378
+ fontMap[`${prefix}-ea`] = latin;
159379
+ fontMap[`${prefix}-cs`] = latin;
159380
+ }
159381
+ const eastAsia = typeface(group?.["a:ea"]);
159382
+ if (eastAsia) {
159383
+ fontMap[`${prefix}-ea`] = eastAsia;
159384
+ }
159385
+ const complexScript = typeface(group?.["a:cs"]);
159386
+ if (complexScript) {
159387
+ fontMap[`${prefix}-cs`] = complexScript;
159388
+ }
159389
+ }
159390
+ const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
159391
+ const objectDefaults = objectDefaultsNode && {
159392
+ spDef: objectDefaultsNode["a:spDef"],
159393
+ lnDef: objectDefaultsNode["a:lnDef"],
159394
+ txDef: objectDefaultsNode["a:txDef"]
159395
+ };
159396
+ const hasObjectDefaults = objectDefaults !== void 0 && (objectDefaults.spDef !== void 0 || objectDefaults.lnDef !== void 0 || objectDefaults.txDef !== void 0);
159397
+ return {
159398
+ name: text2(themeRoot?.["@_name"]),
159399
+ colorSchemeName: text2(colorScheme?.["@_name"]),
159400
+ fontSchemeName: text2(fontScheme?.["@_name"]),
159401
+ colorMap,
159402
+ fontMap,
159403
+ // Per-script fonts (`<a:font script="Hans|Hant|Arab|...">`): M4.
159404
+ majorFontScripts: this.collectFontScriptOverrides(
159405
+ fontScheme?.["a:majorFont"]
159406
+ ),
159407
+ minorFontScripts: this.collectFontScriptOverrides(
159408
+ fontScheme?.["a:minorFont"]
159409
+ ),
159410
+ // objectDefaults: M5.
159411
+ objectDefaults: hasObjectDefaults ? objectDefaults : void 0,
159412
+ extraClrSchemeLst: themeRoot?.["a:extraClrSchemeLst"],
159413
+ custClrLst: themeRoot?.["a:custClrLst"],
159414
+ extLst: themeRoot?.["a:extLst"],
159415
+ formatScheme: fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0
159416
+ };
159417
+ }
159418
+ /**
159419
+ * Record a parsed part under its path: its original XML (byte-stable passthrough on save,
159420
+ * C-H3), its names, per-script fonts and the raw subtrees the save re-emits.
159421
+ */
159422
+ cacheThemePartModel(themePath, themeXml3, model) {
159423
+ this.originalThemeXmlByPath.set(themePath, themeXml3);
159424
+ const keyed = [
159425
+ [this.masterThemeNames, model.name],
159426
+ [this.masterThemeColorSchemeNames, model.colorSchemeName],
159427
+ [this.masterThemeFontSchemeNames, model.fontSchemeName],
159428
+ [this.masterThemeObjectDefaults, model.objectDefaults],
159429
+ [this.masterThemeExtraClrSchemeLst, model.extraClrSchemeLst],
159430
+ [this.masterThemeCustClrLst, model.custClrLst],
159431
+ [this.masterThemeExtLst, model.extLst]
159432
+ ];
159433
+ for (const [map, value] of keyed) {
159434
+ if (value !== void 0) {
159435
+ map.set(themePath, value);
159436
+ }
159437
+ }
159438
+ if (Object.keys(model.majorFontScripts).length > 0) {
159439
+ this.masterThemeMajorFontScripts.set(themePath, model.majorFontScripts);
159440
+ }
159441
+ if (Object.keys(model.minorFontScripts).length > 0) {
159442
+ this.masterThemeMinorFontScripts.set(themePath, model.minorFontScripts);
159443
+ }
159444
+ }
159445
+ /**
159446
+ * Parse `<a:font script="..." typeface="..."/>` children of a major or minor font node into a
159447
+ * `script -> typeface` dictionary. fast-xml-parser collapses repeated tags into arrays, so the
159448
+ * array form is walked regardless of how many siblings are present. Phase 4 Stream A / M4.
159449
+ */
159450
+ collectFontScriptOverrides(fontNode) {
159451
+ const overrides28 = {};
159452
+ if (!fontNode) {
159453
+ return overrides28;
159454
+ }
159455
+ const fontEntries = this.ensureArray(fontNode["a:font"]);
159456
+ for (const entry2 of fontEntries) {
159457
+ const script = String(entry2?.["@_script"] || "").trim();
159458
+ const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
159459
+ if (script && typeface) {
159460
+ overrides28[script] = typeface;
159461
+ }
159462
+ }
159463
+ return overrides28;
159464
+ }
159465
+ /**
159466
+ * The colour, font and format schemes and name of one theme part in the package, as the part holds
159467
+ * them now (a scheme edit already written to it included). Reads only: the loaded theme, the
159468
+ * masters and what a save writes are unchanged. `undefined` when the package has no such part.
159469
+ */
159470
+ async getThemePartSchemes(themePath) {
159471
+ const path3 = themePath.trim().replace(/\\/g, "/");
159472
+ const themeXml3 = await this.zip.file(path3)?.async("string");
159473
+ if (themeXml3 === void 0) {
159474
+ return void 0;
159475
+ }
159476
+ const model = this.parseThemePartXml(themeXml3);
159477
+ return {
159478
+ path: path3,
159479
+ ...model.name ? { name: model.name } : {},
159480
+ colorScheme: colorSchemeFromMap(model.colorMap),
159481
+ fontScheme: fontSchemeFromMap(model.fontMap, model.majorFontScripts, model.minorFontScripts),
159482
+ ...model.formatScheme ? { formatScheme: model.formatScheme } : {}
159483
+ };
159484
+ }
159485
+ };
159486
+ }
159487
+ });
159488
+
159044
159489
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts
159045
159490
  function isPresentationThemePartPath(path3) {
159046
159491
  return /^ppt\/theme\/(?!themeOverride)[^/]+\.xml$/iu.test(path3);
159047
159492
  }
159048
- var PptxHandlerRuntime84;
159493
+ var PptxHandlerRuntime85;
159049
159494
  var init_PptxHandlerRuntimeThemeLoading = __esm({
159050
159495
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeLoading.ts"() {
159051
- init_PptxHandlerRuntimeThemeRefResolution();
159052
- PptxHandlerRuntime84 = class extends PptxHandlerRuntime83 {
159496
+ init_PptxHandlerRuntimeThemePartModel();
159497
+ init_theme_part_model();
159498
+ PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
159053
159499
  async resolvePrimaryThemePath() {
159054
159500
  const masterFiles = this.zip.file(/^ppt\/slideMasters\/slideMaster\d+\.xml$/);
159055
159501
  if (!masterFiles || masterFiles.length === 0) {
@@ -159125,42 +159571,12 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159125
159571
  if (!hasColors && !hasFonts) {
159126
159572
  return void 0;
159127
159573
  }
159128
- let colorScheme;
159129
- if (hasColors) {
159130
- colorScheme = {
159131
- dk1: this.themeColorMap["dk1"] || "",
159132
- lt1: this.themeColorMap["lt1"] || "",
159133
- dk2: this.themeColorMap["dk2"] || "",
159134
- lt2: this.themeColorMap["lt2"] || "",
159135
- accent1: this.themeColorMap["accent1"] || "",
159136
- accent2: this.themeColorMap["accent2"] || "",
159137
- accent3: this.themeColorMap["accent3"] || "",
159138
- accent4: this.themeColorMap["accent4"] || "",
159139
- accent5: this.themeColorMap["accent5"] || "",
159140
- accent6: this.themeColorMap["accent6"] || "",
159141
- hlink: this.themeColorMap["hlink"] || "",
159142
- folHlink: this.themeColorMap["folHlink"] || ""
159143
- };
159144
- }
159145
- let fontScheme;
159146
- if (hasFonts) {
159147
- const majorByScript = this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts);
159148
- const minorByScript = this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts);
159149
- fontScheme = {
159150
- majorFont: {
159151
- latin: this.themeFontMap["mj-lt"],
159152
- eastAsia: this.themeFontMap["mj-ea"],
159153
- complexScript: this.themeFontMap["mj-cs"],
159154
- ...Object.keys(majorByScript).length > 0 ? { byScript: majorByScript } : {}
159155
- },
159156
- minorFont: {
159157
- latin: this.themeFontMap["mn-lt"],
159158
- eastAsia: this.themeFontMap["mn-ea"],
159159
- complexScript: this.themeFontMap["mn-cs"],
159160
- ...Object.keys(minorByScript).length > 0 ? { byScript: minorByScript } : {}
159161
- }
159162
- };
159163
- }
159574
+ const colorScheme = hasColors ? colorSchemeFromMap(this.themeColorMap) : void 0;
159575
+ const fontScheme = hasFonts ? fontSchemeFromMap(
159576
+ this.themeFontMap,
159577
+ this.aggregateFontScriptOverrides(this.masterThemeMajorFontScripts),
159578
+ this.aggregateFontScriptOverrides(this.masterThemeMinorFontScripts)
159579
+ ) : void 0;
159164
159580
  return {
159165
159581
  colorScheme,
159166
159582
  fontScheme,
@@ -159237,134 +159653,10 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159237
159653
  return null;
159238
159654
  }
159239
159655
  const themeXml3 = await themeFile.async("string");
159240
- this.originalThemeXmlByPath.set(themePath, themeXml3);
159241
- const themeData = this.parser.parse(themeXml3);
159242
- const themeRoot = themeData["a:theme"];
159243
- const themeElements = themeRoot?.["a:themeElements"];
159244
- const colorScheme = themeElements?.["a:clrScheme"];
159245
- const fontScheme = themeElements?.["a:fontScheme"];
159246
- const fmtScheme = themeElements?.["a:fmtScheme"];
159247
- const themeName = String(themeRoot?.["@_name"] || "").trim();
159248
- if (themeName) {
159249
- this.masterThemeNames.set(themePath, themeName);
159250
- }
159251
- const colorSchemeName = String(colorScheme?.["@_name"] || "").trim();
159252
- if (colorSchemeName) {
159253
- this.masterThemeColorSchemeNames.set(themePath, colorSchemeName);
159254
- }
159255
- const fontSchemeName = String(fontScheme?.["@_name"] || "").trim();
159256
- if (fontSchemeName) {
159257
- this.masterThemeFontSchemeNames.set(themePath, fontSchemeName);
159258
- }
159259
- const defaultMap = this.getDefaultSchemeColorMap();
159260
- const colorMap = { ...defaultMap };
159261
- if (colorScheme) {
159262
- const schemeKeys = [
159263
- "dk1",
159264
- "lt1",
159265
- "dk2",
159266
- "lt2",
159267
- "accent1",
159268
- "accent2",
159269
- "accent3",
159270
- "accent4",
159271
- "accent5",
159272
- "accent6",
159273
- "hlink",
159274
- "folHlink"
159275
- ];
159276
- for (const key2 of schemeKeys) {
159277
- const colorNode = colorScheme[`a:${key2}`];
159278
- const parsed = this.parseColorChoice(colorNode);
159279
- if (parsed) {
159280
- colorMap[key2] = parsed;
159281
- }
159282
- }
159283
- }
159284
- const majorFontNode = fontScheme?.["a:majorFont"];
159285
- const minorFontNode = fontScheme?.["a:minorFont"];
159286
- const majorLatin = majorFontNode?.["a:latin"];
159287
- const minorLatin = minorFontNode?.["a:latin"];
159288
- const majorFont = this.normalizeTypefaceToken(String(majorLatin?.["@_typeface"] || ""));
159289
- const minorFont = this.normalizeTypefaceToken(String(minorLatin?.["@_typeface"] || ""));
159290
- const fontMap = {};
159291
- if (majorFont) {
159292
- fontMap["mj-lt"] = majorFont;
159293
- fontMap["mj-ea"] = majorFont;
159294
- fontMap["mj-cs"] = majorFont;
159295
- }
159296
- if (minorFont) {
159297
- fontMap["mn-lt"] = minorFont;
159298
- fontMap["mn-ea"] = minorFont;
159299
- fontMap["mn-cs"] = minorFont;
159300
- }
159301
- const majorEa = this.normalizeTypefaceToken(
159302
- String(majorFontNode?.["a:ea"]?.["@_typeface"] || "")
159303
- );
159304
- if (majorEa) {
159305
- fontMap["mj-ea"] = majorEa;
159306
- }
159307
- const majorCs = this.normalizeTypefaceToken(
159308
- String(majorFontNode?.["a:cs"]?.["@_typeface"] || "")
159309
- );
159310
- if (majorCs) {
159311
- fontMap["mj-cs"] = majorCs;
159312
- }
159313
- const minorEa = this.normalizeTypefaceToken(
159314
- String(minorFontNode?.["a:ea"]?.["@_typeface"] || "")
159315
- );
159316
- if (minorEa) {
159317
- fontMap["mn-ea"] = minorEa;
159318
- }
159319
- const minorCs = this.normalizeTypefaceToken(
159320
- String(minorFontNode?.["a:cs"]?.["@_typeface"] || "")
159321
- );
159322
- if (minorCs) {
159323
- fontMap["mn-cs"] = minorCs;
159324
- }
159325
- const majorScripts = this.collectFontScriptOverrides(majorFontNode);
159326
- if (Object.keys(majorScripts).length > 0) {
159327
- this.masterThemeMajorFontScripts.set(themePath, majorScripts);
159328
- }
159329
- const minorScripts = this.collectFontScriptOverrides(minorFontNode);
159330
- if (Object.keys(minorScripts).length > 0) {
159331
- this.masterThemeMinorFontScripts.set(themePath, minorScripts);
159332
- }
159333
- const objectDefaultsNode = themeRoot?.["a:objectDefaults"];
159334
- if (objectDefaultsNode) {
159335
- const od = {
159336
- spDef: objectDefaultsNode["a:spDef"],
159337
- lnDef: objectDefaultsNode["a:lnDef"],
159338
- txDef: objectDefaultsNode["a:txDef"]
159339
- };
159340
- if (od.spDef !== void 0 || od.lnDef !== void 0 || od.txDef !== void 0) {
159341
- this.masterThemeObjectDefaults.set(themePath, od);
159342
- }
159343
- }
159344
- const extraClrSchemeLst = themeRoot?.["a:extraClrSchemeLst"];
159345
- if (extraClrSchemeLst !== void 0) {
159346
- this.masterThemeExtraClrSchemeLst.set(themePath, extraClrSchemeLst);
159347
- }
159348
- const custClrLst = themeRoot?.["a:custClrLst"];
159349
- if (custClrLst !== void 0) {
159350
- this.masterThemeCustClrLst.set(themePath, custClrLst);
159351
- }
159352
- const themeExtLst = themeRoot?.["a:extLst"];
159353
- if (themeExtLst !== void 0) {
159354
- this.masterThemeExtLst.set(themePath, themeExtLst);
159355
- }
159356
- const formatScheme = fmtScheme ? this.parseFormatScheme(fmtScheme) : void 0;
159357
- return { colorMap, fontMap, formatScheme };
159656
+ const model = this.parseThemePartXml(themeXml3);
159657
+ this.cacheThemePartModel(themePath, themeXml3, model);
159658
+ return { colorMap: model.colorMap, fontMap: model.fontMap, formatScheme: model.formatScheme };
159358
159659
  }
159359
- /**
159360
- * Parse `<a:font script="…" typeface="…"/>` children of a major or
159361
- * minor font node into a `script -> typeface` dictionary.
159362
- *
159363
- * fast-xml-parser collapses repeated tags into arrays, so iterate
159364
- * over the array form regardless of how many siblings are present.
159365
- *
159366
- * Phase 4 Stream A / M4.
159367
- */
159368
159660
  /**
159369
159661
  * Flatten a per-theme-path script-override map (`themePath -> {script ->
159370
159662
  * typeface}`) into a single `{script -> typeface}` lookup for
@@ -159382,21 +159674,6 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159382
159674
  }
159383
159675
  return aggregate;
159384
159676
  }
159385
- collectFontScriptOverrides(fontNode) {
159386
- const overrides28 = {};
159387
- if (!fontNode) {
159388
- return overrides28;
159389
- }
159390
- const fontEntries = this.ensureArray(fontNode["a:font"]);
159391
- for (const entry2 of fontEntries) {
159392
- const script = String(entry2?.["@_script"] || "").trim();
159393
- const typeface = this.normalizeTypefaceToken(String(entry2?.["@_typeface"] || ""));
159394
- if (script && typeface) {
159395
- overrides28[script] = typeface;
159396
- }
159397
- }
159398
- return overrides28;
159399
- }
159400
159677
  /**
159401
159678
  * Resolve the theme file path referenced by a given master's `.rels`.
159402
159679
  * Returns `undefined` when the master has no theme relationship.
@@ -159482,119 +159759,14 @@ var init_PptxHandlerRuntimeThemeLoading = __esm({
159482
159759
  }
159483
159760
  });
159484
159761
 
159485
- // pptx/core/core/runtime/theme-scheme-edit.ts
159486
- function normalizeHex6(hex3) {
159487
- return hex3.replace(/^#/, "").toUpperCase();
159488
- }
159489
- function buildSrgbClrNode(hex3) {
159490
- return { "a:srgbClr": { "@_val": normalizeHex6(hex3) } };
159491
- }
159492
- function themeElementsOf(data) {
159493
- const root = data["a:theme"];
159494
- return root?.["a:themeElements"];
159495
- }
159496
- function applyColorSchemeToThemeXml(data, colorScheme) {
159497
- const themeElements = themeElementsOf(data);
159498
- if (!themeElements) {
159499
- return false;
159500
- }
159501
- const clrScheme = themeElements["a:clrScheme"] ?? {};
159502
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159503
- clrScheme[`a:${key2}`] = buildSrgbClrNode(colorScheme[key2]);
159504
- }
159505
- themeElements["a:clrScheme"] = clrScheme;
159506
- return true;
159507
- }
159508
- function applyLatinTypeface(group, latin) {
159509
- const font = group ?? {};
159510
- font["a:latin"] = { "@_typeface": latin };
159511
- if (!font["a:ea"]) {
159512
- font["a:ea"] = { "@_typeface": "" };
159513
- }
159514
- if (!font["a:cs"]) {
159515
- font["a:cs"] = { "@_typeface": "" };
159516
- }
159517
- return font;
159518
- }
159519
- function applyFontSchemeToThemeXml(data, fontScheme) {
159520
- const themeElements = themeElementsOf(data);
159521
- if (!themeElements) {
159522
- return false;
159523
- }
159524
- const fntScheme = themeElements["a:fontScheme"] ?? {};
159525
- if (fontScheme.majorFont?.latin) {
159526
- fntScheme["a:majorFont"] = applyLatinTypeface(
159527
- fntScheme["a:majorFont"],
159528
- fontScheme.majorFont.latin
159529
- );
159530
- }
159531
- if (fontScheme.minorFont?.latin) {
159532
- fntScheme["a:minorFont"] = applyLatinTypeface(
159533
- fntScheme["a:minorFont"],
159534
- fontScheme.minorFont.latin
159535
- );
159536
- }
159537
- themeElements["a:fontScheme"] = fntScheme;
159538
- return true;
159539
- }
159540
- function applyColorSchemeToMap(map, colorScheme, clrMap) {
159541
- for (const key2 of THEME_COLOR_SCHEME_KEYS2) {
159542
- map[key2] = normalizeHex6(colorScheme[key2]);
159543
- }
159544
- for (const [alias, defaultTarget] of Object.entries(DEFAULT_CLR_MAP_ALIASES)) {
159545
- const target = clrMap?.[alias] ?? defaultTarget;
159546
- const resolved = map[target];
159547
- if (resolved !== void 0) {
159548
- map[alias] = resolved;
159549
- }
159550
- }
159551
- }
159552
- function applyFontSchemeToMap(map, fontScheme) {
159553
- if (fontScheme.majorFont?.latin) {
159554
- map["mj-lt"] = fontScheme.majorFont.latin;
159555
- map["mj-ea"] = fontScheme.majorFont.latin;
159556
- map["mj-cs"] = fontScheme.majorFont.latin;
159557
- }
159558
- if (fontScheme.minorFont?.latin) {
159559
- map["mn-lt"] = fontScheme.minorFont.latin;
159560
- map["mn-ea"] = fontScheme.minorFont.latin;
159561
- map["mn-cs"] = fontScheme.minorFont.latin;
159562
- }
159563
- }
159564
- var THEME_COLOR_SCHEME_KEYS2, DEFAULT_CLR_MAP_ALIASES;
159565
- var init_theme_scheme_edit = __esm({
159566
- "pptx/core/core/runtime/theme-scheme-edit.ts"() {
159567
- THEME_COLOR_SCHEME_KEYS2 = [
159568
- "dk1",
159569
- "lt1",
159570
- "dk2",
159571
- "lt2",
159572
- "accent1",
159573
- "accent2",
159574
- "accent3",
159575
- "accent4",
159576
- "accent5",
159577
- "accent6",
159578
- "hlink",
159579
- "folHlink"
159580
- ];
159581
- DEFAULT_CLR_MAP_ALIASES = {
159582
- tx1: "dk1",
159583
- bg1: "lt1",
159584
- tx2: "dk2",
159585
- bg2: "lt2"
159586
- };
159587
- }
159588
- });
159589
-
159590
159762
  // pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts
159591
- var THEME_PART_PATTERN, PptxHandlerRuntime85;
159763
+ var THEME_PART_PATTERN, PptxHandlerRuntime86;
159592
159764
  var init_PptxHandlerRuntimeThemeProcessing = __esm({
159593
159765
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeProcessing.ts"() {
159594
159766
  init_PptxHandlerRuntimeThemeLoading();
159595
159767
  init_theme_scheme_edit();
159596
159768
  THEME_PART_PATTERN = /^ppt\/theme\/theme\d+\.xml$/;
159597
- PptxHandlerRuntime85 = class extends PptxHandlerRuntime84 {
159769
+ PptxHandlerRuntime86 = class extends PptxHandlerRuntime85 {
159598
159770
  /**
159599
159771
  * The theme parts an edit should touch, primary theme first.
159600
159772
  *
@@ -159635,8 +159807,9 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
159635
159807
  return this.parser.parse(xml);
159636
159808
  }
159637
159809
  /**
159638
- * Parse, edit, and write back every target theme part. Parts the edit
159639
- * cannot apply to (no `a:themeElements`) are left untouched.
159810
+ * Parse, edit, and write back every target theme part (`edit` gets the
159811
+ * part's path too). Parts the edit cannot apply to (no `a:themeElements`)
159812
+ * are left untouched.
159640
159813
  *
159641
159814
  * @returns the paths that were rewritten
159642
159815
  */
@@ -159644,7 +159817,7 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
159644
159817
  const written = [];
159645
159818
  for (const path3 of await this.resolveThemeEditTargets(themePaths)) {
159646
159819
  const data = await this.readThemePart(path3);
159647
- if (!data || !edit(data)) {
159820
+ if (!data || !edit(data, path3)) {
159648
159821
  continue;
159649
159822
  }
159650
159823
  this.zip.file(path3, this.builder.build(data));
@@ -159748,15 +159921,90 @@ var init_PptxHandlerRuntimeThemeProcessing = __esm({
159748
159921
  }
159749
159922
  });
159750
159923
 
159924
+ // pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts
159925
+ function themePartPath(themePath) {
159926
+ const path3 = themePath.trim().replace(/\\/g, "/");
159927
+ return path3.startsWith("ppt/theme/") ? path3 : void 0;
159928
+ }
159929
+ var SLIDE_MASTER_PART, PptxHandlerRuntime87;
159930
+ var init_PptxHandlerRuntimeThemeSwitching = __esm({
159931
+ "pptx/core/core/runtime/PptxHandlerRuntimeThemeSwitching.ts"() {
159932
+ init_PptxHandlerRuntimeThemeProcessing();
159933
+ SLIDE_MASTER_PART = /^ppt\/slideMasters\/slideMaster\d+\.xml$/;
159934
+ PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
159935
+ /**
159936
+ * Point the first slide master, or every one, at a theme part already in the package. Does
159937
+ * nothing when the package has no such part.
159938
+ */
159939
+ async setPresentationTheme(themePath, applyToAllMasters = true) {
159940
+ const path3 = themePartPath(themePath);
159941
+ if (!path3 || !this.zip.file(path3)) {
159942
+ return;
159943
+ }
159944
+ const masters = this.zip.file(SLIDE_MASTER_PART);
159945
+ for (const master of applyToAllMasters ? masters : masters.slice(0, 1)) {
159946
+ await this.retargetMasterTheme(master.name, path3);
159947
+ }
159948
+ }
159949
+ /**
159950
+ * Point one slide master at a theme part already in the package (Undo of a theme switch puts
159951
+ * each master back on its own part). Does nothing when the package has no such master or part.
159952
+ */
159953
+ async setSlideMasterTheme(masterPath, themePath) {
159954
+ const path3 = themePartPath(themePath);
159955
+ if (!path3 || !this.zip.file(path3) || !SLIDE_MASTER_PART.test(masterPath)) {
159956
+ return;
159957
+ }
159958
+ if (this.zip.file(masterPath)) {
159959
+ await this.retargetMasterTheme(masterPath, path3);
159960
+ }
159961
+ }
159962
+ async retargetMasterTheme(masterPath, themePath) {
159963
+ if (await this.setMasterThemeRelationship(masterPath, themePath)) {
159964
+ await this.adoptMasterTheme(masterPath, themePath);
159965
+ }
159966
+ }
159967
+ /** Point the runtime's theme state for `masterPath` at the part it now uses. */
159968
+ async adoptMasterTheme(masterPath, themePath) {
159969
+ const themeXml3 = await this.zip.file(themePath)?.async("string");
159970
+ if (themeXml3 === void 0) {
159971
+ return;
159972
+ }
159973
+ const model = this.parseThemePartXml(themeXml3);
159974
+ if (!this.originalThemeXmlByPath.has(themePath)) {
159975
+ this.cacheThemePartModel(themePath, themeXml3, model);
159976
+ }
159977
+ this.masterThemePaths.set(masterPath, themePath);
159978
+ this.masterThemeColorMaps.set(masterPath, { ...model.colorMap });
159979
+ this.masterThemeFontMaps.set(masterPath, { ...model.fontMap });
159980
+ if (model.formatScheme) {
159981
+ this.masterThemeFormatSchemes.set(masterPath, model.formatScheme);
159982
+ } else {
159983
+ this.masterThemeFormatSchemes.delete(masterPath);
159984
+ }
159985
+ if (this.zip.file(SLIDE_MASTER_PART)[0]?.name !== masterPath) {
159986
+ return;
159987
+ }
159988
+ this.themeColorMap = { ...model.colorMap };
159989
+ this.themeFontMap = { ...model.fontMap };
159990
+ this.themeFormatScheme = model.formatScheme;
159991
+ this.globalThemeColorMapSnapshot = { ...model.colorMap };
159992
+ this.globalThemeFontMapSnapshot = { ...model.fontMap };
159993
+ this.globalThemeFormatSchemeSnapshot = model.formatScheme;
159994
+ }
159995
+ };
159996
+ }
159997
+ });
159998
+
159751
159999
  // pptx/core/core/runtime/PptxHandlerRuntimeComments.ts
159752
- var PptxHandlerRuntime86;
160000
+ var PptxHandlerRuntime88;
159753
160001
  var init_PptxHandlerRuntimeComments = __esm({
159754
160002
  "pptx/core/core/runtime/PptxHandlerRuntimeComments.ts"() {
159755
160003
  init_legacy_comment_threading();
159756
160004
  init_modern_comment_xml();
159757
160005
  init_xml_access();
159758
- init_PptxHandlerRuntimeThemeProcessing();
159759
- PptxHandlerRuntime86 = class _PptxHandlerRuntime extends PptxHandlerRuntime85 {
160006
+ init_PptxHandlerRuntimeThemeSwitching();
160007
+ PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
159760
160008
  /**
159761
160009
  * Parse modern threaded comments (PowerPoint 2019+ / Office 365).
159762
160010
  * Modern comments use `p188:cmLst`/`p15:cmLst` roots within
@@ -159985,7 +160233,7 @@ var init_PptxHandlerRuntimeComments = __esm({
159985
160233
  });
159986
160234
 
159987
160235
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts
159988
- var PptxHandlerRuntime87;
160236
+ var PptxHandlerRuntime89;
159989
160237
  var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
159990
160238
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtXmlUtils.ts"() {
159991
160239
  init_smartart_color_lists();
@@ -159993,7 +160241,7 @@ var init_PptxHandlerRuntimeSmartArtXmlUtils = __esm({
159993
160241
  init_smart_art_text_helpers();
159994
160242
  init_PptxHandlerRuntimeComments();
159995
160243
  init_smartart_text_paragraphs();
159996
- PptxHandlerRuntime87 = class extends PptxHandlerRuntime86 {
160244
+ PptxHandlerRuntime89 = class extends PptxHandlerRuntime88 {
159997
160245
  async readXmlPartByRelationshipId(slidePath, relationshipId2) {
159998
160246
  const normalizedRelationshipId = String(relationshipId2 || "").trim();
159999
160247
  if (normalizedRelationshipId.length === 0) {
@@ -160597,7 +160845,7 @@ var init_smartart_text_style_resolution = __esm({
160597
160845
  });
160598
160846
 
160599
160847
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts
160600
- var PptxHandlerRuntime88;
160848
+ var PptxHandlerRuntime90;
160601
160849
  var init_PptxHandlerRuntimeSmartArtParsing = __esm({
160602
160850
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArtParsing.ts"() {
160603
160851
  init_diagram();
@@ -160611,7 +160859,7 @@ var init_PptxHandlerRuntimeSmartArtParsing = __esm({
160611
160859
  init_smartart_style_label_refs();
160612
160860
  init_smartart_text_paragraphs();
160613
160861
  init_smartart_text_style_resolution();
160614
- PptxHandlerRuntime88 = class _PptxHandlerRuntime extends PptxHandlerRuntime87 {
160862
+ PptxHandlerRuntime90 = class _PptxHandlerRuntime extends PptxHandlerRuntime89 {
160615
160863
  reportIncompleteSmartArtRelationships(graphicFrame, relationshipIds, slidePath) {
160616
160864
  const missing = [
160617
160865
  ["dm", relationshipIds?.dataRelId],
@@ -161006,7 +161254,7 @@ var init_smartart_layout_category = __esm({
161006
161254
  });
161007
161255
 
161008
161256
  // pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts
161009
- var PptxHandlerRuntime89;
161257
+ var PptxHandlerRuntime91;
161010
161258
  var init_PptxHandlerRuntimeSmartArt = __esm({
161011
161259
  "pptx/core/core/runtime/PptxHandlerRuntimeSmartArt.ts"() {
161012
161260
  init_utils();
@@ -161021,7 +161269,7 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
161021
161269
  init_smartart_text_paragraphs();
161022
161270
  init_smartart_text_style_resolution();
161023
161271
  init_smartart_xml_builders();
161024
- PptxHandlerRuntime89 = class _PptxHandlerRuntime extends PptxHandlerRuntime88 {
161272
+ PptxHandlerRuntime91 = class _PptxHandlerRuntime extends PptxHandlerRuntime90 {
161025
161273
  async getSmartArtDataForGraphicFrame(slidePath, graphicFrame) {
161026
161274
  const graphicData = this.xmlLookupService.getChildByLocalName(
161027
161275
  this.xmlLookupService.getChildByLocalName(graphicFrame, "graphic"),
@@ -161197,12 +161445,12 @@ var init_PptxHandlerRuntimeSmartArt = __esm({
161197
161445
  });
161198
161446
 
161199
161447
  // pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts
161200
- var PptxHandlerRuntime90;
161448
+ var PptxHandlerRuntime92;
161201
161449
  var init_PptxHandlerRuntimeChartDetection = __esm({
161202
161450
  "pptx/core/core/runtime/PptxHandlerRuntimeChartDetection.ts"() {
161203
161451
  init_chart_multi_level_category_parser();
161204
161452
  init_PptxHandlerRuntimeSmartArt();
161205
- PptxHandlerRuntime90 = class extends PptxHandlerRuntime89 {
161453
+ PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
161206
161454
  detectChartType(plotArea) {
161207
161455
  if (!plotArea) {
161208
161456
  return "unknown";
@@ -161413,14 +161661,14 @@ function parseNumberVal(node) {
161413
161661
  const num4 = Number.parseFloat(String(raw2));
161414
161662
  return Number.isFinite(num4) ? num4 : void 0;
161415
161663
  }
161416
- var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime91;
161664
+ var CHART_DATA_DISPLAY_OPTIONS_EXT_URI2, PptxHandlerRuntime93;
161417
161665
  var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
161418
161666
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsingHelpers.ts"() {
161419
161667
  init_chart_ext_lookup();
161420
161668
  init_chart_pivot_source2();
161421
161669
  init_PptxHandlerRuntimeChartDetection();
161422
161670
  CHART_DATA_DISPLAY_OPTIONS_EXT_URI2 = "{56B9EC1D-385E-4148-901F-78D8002777C0}";
161423
- PptxHandlerRuntime91 = class extends PptxHandlerRuntime90 {
161671
+ PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
161424
161672
  /**
161425
161673
  * Parse `c:plotVisOnly` from the chart root element.
161426
161674
  *
@@ -161680,14 +161928,14 @@ var init_PptxHandlerRuntimeChartParsingHelpers = __esm({
161680
161928
  });
161681
161929
 
161682
161930
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts
161683
- var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime92;
161931
+ var CHART_USER_SHAPES_REL_TYPE2, PptxHandlerRuntime94;
161684
161932
  var init_PptxHandlerRuntimeChartExternalData = __esm({
161685
161933
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExternalData.ts"() {
161686
161934
  init_chart_user_shapes_parser();
161687
161935
  init_chart_xlsx_parser();
161688
161936
  init_PptxHandlerRuntimeChartParsingHelpers();
161689
161937
  CHART_USER_SHAPES_REL_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes";
161690
- PptxHandlerRuntime92 = class extends PptxHandlerRuntime91 {
161938
+ PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
161691
161939
  /**
161692
161940
  * Parse `c:externalData` from the chart's `c:chartSpace` and resolve
161693
161941
  * the external relationship target from the chart part's .rels file.
@@ -161849,12 +162097,12 @@ var init_PptxHandlerRuntimeChartExternalData = __esm({
161849
162097
  });
161850
162098
 
161851
162099
  // pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts
161852
- var PptxHandlerRuntime93;
162100
+ var PptxHandlerRuntime95;
161853
162101
  var init_PptxHandlerRuntimeChartColorStyle = __esm({
161854
162102
  "pptx/core/core/runtime/PptxHandlerRuntimeChartColorStyle.ts"() {
161855
162103
  init_chart_style_definition_parser();
161856
162104
  init_PptxHandlerRuntimeChartExternalData();
161857
- PptxHandlerRuntime93 = class extends PptxHandlerRuntime92 {
162105
+ PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
161858
162106
  /**
161859
162107
  * Parse the Office 2013+ chart-style part (`ppt/charts/style#.xml`)
161860
162108
  * referenced from the chart's relationships, sibling to
@@ -162015,7 +162263,7 @@ var init_PptxHandlerRuntimeChartColorStyle = __esm({
162015
162263
  });
162016
162264
 
162017
162265
  // pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts
162018
- var PptxHandlerRuntime94;
162266
+ var PptxHandlerRuntime96;
162019
162267
  var init_PptxHandlerRuntimeChartExParsing = __esm({
162020
162268
  "pptx/core/core/runtime/PptxHandlerRuntimeChartExParsing.ts"() {
162021
162269
  init_chart_cx_parser();
@@ -162025,7 +162273,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
162025
162273
  init_chart_protection2();
162026
162274
  init_chart_space_flags();
162027
162275
  init_PptxHandlerRuntimeChartColorStyle();
162028
- PptxHandlerRuntime94 = class extends PptxHandlerRuntime93 {
162276
+ PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
162029
162277
  /**
162030
162278
  * The facts of a chart part that live outside the plot (or in other parts): the external data
162031
162279
  * reference and the embedded workbook's rows, pivot source and formats, the colour-style and
@@ -162145,7 +162393,7 @@ var init_PptxHandlerRuntimeChartExParsing = __esm({
162145
162393
  });
162146
162394
 
162147
162395
  // pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts
162148
- var PptxHandlerRuntime95;
162396
+ var PptxHandlerRuntime97;
162149
162397
  var init_PptxHandlerRuntimeChartParsing = __esm({
162150
162398
  "pptx/core/core/runtime/PptxHandlerRuntimeChartParsing.ts"() {
162151
162399
  init_chart_element_format_read_xml();
@@ -162167,7 +162415,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
162167
162415
  init_chart_element_pictures();
162168
162416
  init_chart_embedded_fallback();
162169
162417
  init_PptxHandlerRuntimeChartExParsing();
162170
- PptxHandlerRuntime95 = class extends PptxHandlerRuntime94 {
162418
+ PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
162171
162419
  /**
162172
162420
  * Parse chart data from a graphic frame element on a slide.
162173
162421
  *
@@ -162451,7 +162699,7 @@ var init_PptxHandlerRuntimeChartParsing = __esm({
162451
162699
  });
162452
162700
 
162453
162701
  // pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts
162454
- var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime96;
162702
+ var XSD_INT_MIN, XSD_INT_MAX, PptxHandlerRuntime98;
162455
162703
  var init_PptxHandlerRuntimePresentationStructure = __esm({
162456
162704
  "pptx/core/core/runtime/PptxHandlerRuntimePresentationStructure.ts"() {
162457
162705
  init_kinsoku_parser();
@@ -162460,7 +162708,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
162460
162708
  init_PptxHandlerRuntimeChartParsing();
162461
162709
  XSD_INT_MIN = -2147483648;
162462
162710
  XSD_INT_MAX = 2147483647;
162463
- PptxHandlerRuntime96 = class extends PptxHandlerRuntime95 {
162711
+ PptxHandlerRuntime98 = class extends PptxHandlerRuntime97 {
162464
162712
  parseEditorAnimations(slideXml3) {
162465
162713
  return this.editorAnimationService.parseEditorAnimations(slideXml3);
162466
162714
  }
@@ -162663,7 +162911,7 @@ var init_PptxHandlerRuntimePresentationStructure = __esm({
162663
162911
  });
162664
162912
 
162665
162913
  // pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts
162666
- var PptxHandlerRuntime97;
162914
+ var PptxHandlerRuntime99;
162667
162915
  var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
162668
162916
  "pptx/core/core/runtime/PptxHandlerRuntimeEmbeddedFonts.ts"() {
162669
162917
  init_eot_parser();
@@ -162672,7 +162920,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
162672
162920
  init_strip_parent_dir_segments();
162673
162921
  init_xml_access();
162674
162922
  init_PptxHandlerRuntimePresentationStructure();
162675
- PptxHandlerRuntime97 = class extends PptxHandlerRuntime96 {
162923
+ PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
162676
162924
  async getEmbeddedFonts(fontList) {
162677
162925
  if (!fontList || fontList.fonts.length === 0) {
162678
162926
  return [];
@@ -162874,7 +163122,7 @@ var init_PptxHandlerRuntimeEmbeddedFonts = __esm({
162874
163122
  };
162875
163123
  }
162876
163124
  });
162877
- var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime98;
163125
+ var MAX_OLE_EMBEDDING_BYTES, PptxHandlerRuntime100;
162878
163126
  var init_PptxHandlerRuntimeLoadSession = __esm({
162879
163127
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadSession.ts"() {
162880
163128
  init_zip_limits();
@@ -162886,7 +163134,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
162886
163134
  init_bullet_picture_image_enrichment();
162887
163135
  init_PptxHandlerRuntimeEmbeddedFonts();
162888
163136
  MAX_OLE_EMBEDDING_BYTES = 25 * 1024 * 1024;
162889
- PptxHandlerRuntime98 = class _PptxHandlerRuntime extends PptxHandlerRuntime97 {
163137
+ PptxHandlerRuntime100 = class _PptxHandlerRuntime extends PptxHandlerRuntime99 {
162890
163138
  isZipContainer(data) {
162891
163139
  const bytes = new Uint8Array(data);
162892
163140
  if (bytes.byteLength < 4) {
@@ -163254,7 +163502,7 @@ var init_PptxHandlerRuntimeLoadSession = __esm({
163254
163502
  });
163255
163503
 
163256
163504
  // pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts
163257
- var PptxHandlerRuntime99;
163505
+ var PptxHandlerRuntime101;
163258
163506
  var init_PptxHandlerRuntimeLoadPipeline = __esm({
163259
163507
  "pptx/core/core/runtime/PptxHandlerRuntimeLoadPipeline.ts"() {
163260
163508
  init_fluent();
@@ -163270,7 +163518,7 @@ var init_PptxHandlerRuntimeLoadPipeline = __esm({
163270
163518
  init_layout_switch_placeholder_prompts();
163271
163519
  init_PptxHandlerRuntimeLoadSession();
163272
163520
  init_slide_fingerprint();
163273
- PptxHandlerRuntime99 = class extends PptxHandlerRuntime98 {
163521
+ PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
163274
163522
  async buildLoadData(presentationState, slidesWithWarnings, slideMasters) {
163275
163523
  const headerFooter = this.extractHeaderFooter();
163276
163524
  const presentationProperties = await this.parsePresentationProperties();
@@ -163770,12 +164018,12 @@ function refIndex2(node) {
163770
164018
  const idx = Number.parseInt(String(node["@_idx"] ?? ""), 10);
163771
164019
  return Number.isFinite(idx) ? idx : void 0;
163772
164020
  }
163773
- var PptxHandlerRuntime100;
164021
+ var PptxHandlerRuntime102;
163774
164022
  var init_PptxHandlerRuntimeStyleMatrixResolve = __esm({
163775
164023
  "pptx/core/core/runtime/PptxHandlerRuntimeStyleMatrixResolve.ts"() {
163776
164024
  init_authored_shape_style();
163777
164025
  init_PptxHandlerRuntimeLoadPipeline();
163778
- PptxHandlerRuntime100 = class extends PptxHandlerRuntime99 {
164026
+ PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
163779
164027
  /**
163780
164028
  * Resolve a `<p:style>` node (`a:lnRef`, `a:fillRef`, `a:effectRef`,
163781
164029
  * `a:fontRef`) against the current theme's format scheme, with the same
@@ -163840,14 +164088,17 @@ function withKeys(style, from, keys) {
163840
164088
  function refNode(idx, colorXml2) {
163841
164089
  return { "@_idx": String(idx), ...colorXml2 ?? {} };
163842
164090
  }
163843
- var PptxHandlerRuntime101;
164091
+ var PptxHandlerRuntime103;
163844
164092
  var init_PptxHandlerRuntimeThemeEffects = __esm({
163845
164093
  "pptx/core/core/runtime/PptxHandlerRuntimeThemeEffects.ts"() {
163846
164094
  init_theme_effect_schemes();
163847
164095
  init_authored_shape_style();
164096
+ init_held_format_schemes();
163848
164097
  init_PptxHandlerRuntimeStyleMatrixResolve();
163849
- PptxHandlerRuntime101 = class extends PptxHandlerRuntime100 {
164098
+ PptxHandlerRuntime103 = class extends PptxHandlerRuntime102 {
163850
164099
  effectSchemeCache = /* @__PURE__ */ new Map();
164100
+ /** Every `a:fmtScheme` written into a theme part or over one ({@link restoreThemeFormatScheme}). */
164101
+ heldFormatSchemes = new HeldFormatSchemes();
163851
164102
  /**
163852
164103
  * Resolve a `<p:style>` node as the base class does, against built-in effect scheme
163853
164104
  * `effectSchemeId` instead of the deck's own (the Effects gallery draws each tile this way).
@@ -163900,32 +164151,79 @@ var init_PptxHandlerRuntimeThemeEffects = __esm({
163900
164151
  */
163901
164152
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
163902
164153
  const parsed = this.parseEffectScheme({ fmtSchemeXml });
163903
- if (!parsed) {
163904
- return void 0;
164154
+ return parsed ? this.writeFormatScheme(() => parsed.node) : void 0;
164155
+ }
164156
+ /**
164157
+ * Put back a format scheme the deck held before (Undo and Redo of an Effects pick), as the parts
164158
+ * held it: each theme part a master references gets back what it held the last time the deck's
164159
+ * scheme was `scheme` over those same parts, so a part with a scheme of its own gets its own back
164160
+ * (with no such time, `scheme`'s own element goes into every one). With `themePaths`, `scheme`'s
164161
+ * own element goes into those parts only.
164162
+ *
164163
+ * @returns the deck's format scheme now, or `undefined` (nothing written) for a scheme no part
164164
+ * held while this handler wrote into it
164165
+ */
164166
+ async restoreThemeFormatScheme(scheme, themePaths) {
164167
+ const parts = themePaths ? void 0 : this.heldFormatSchemes.parts(scheme, await this.resolveThemeEditTargets());
164168
+ if (parts) {
164169
+ return this.writeFormatScheme((path3) => parts.get(path3));
163905
164170
  }
163906
- const written = await this.rewriteThemeParts(void 0, (data) => {
164171
+ const element = this.heldFormatSchemes.element(scheme);
164172
+ return element ? this.writeFormatScheme(() => element, themePaths) : void 0;
164173
+ }
164174
+ /**
164175
+ * Write `elementFor(part)` into every theme part a master references (or only `themePaths`),
164176
+ * skipping a part it gives none, holding what each part held and now holds, and refresh the
164177
+ * in-memory format schemes of the masters on those parts and, when the deck's part is among
164178
+ * them, the deck's.
164179
+ */
164180
+ async writeFormatScheme(elementFor, themePaths) {
164181
+ const deckBefore = this.getThemeFormatScheme();
164182
+ const replaced = /* @__PURE__ */ new Map();
164183
+ const schemes = /* @__PURE__ */ new Map();
164184
+ const written = await this.rewriteThemeParts(themePaths, (data, path3) => {
164185
+ const element = elementFor(path3);
163907
164186
  const elements3 = data["a:theme"]?.["a:themeElements"];
163908
- if (!elements3) {
164187
+ if (!element || !elements3) {
163909
164188
  return false;
163910
164189
  }
163911
- elements3["a:fmtScheme"] = structuredClone(parsed.node);
164190
+ const previous = elements3["a:fmtScheme"];
164191
+ if (previous) {
164192
+ this.heldFormatSchemes.hold(this.parseFormatScheme(previous), previous);
164193
+ replaced.set(path3, structuredClone(previous));
164194
+ }
164195
+ const scheme = this.parseFormatScheme(element);
164196
+ this.heldFormatSchemes.hold(scheme, element);
164197
+ elements3["a:fmtScheme"] = structuredClone(element);
164198
+ schemes.set(path3, scheme);
163912
164199
  return true;
163913
164200
  });
163914
164201
  if (written.length === 0) {
163915
164202
  return void 0;
163916
164203
  }
164204
+ if (deckBefore) {
164205
+ this.heldFormatSchemes.holdParts(deckBefore, replaced);
164206
+ }
163917
164207
  for (const path3 of written) {
163918
164208
  const xml = await this.zip.file(path3)?.async("string");
163919
164209
  if (xml !== void 0) {
163920
164210
  this.originalThemeXmlByPath.set(path3, xml);
163921
164211
  }
164212
+ for (const masterPath of this.mastersUsingThemes([path3])) {
164213
+ this.masterThemeFormatSchemes.set(masterPath, schemes.get(path3));
164214
+ }
163922
164215
  }
163923
- for (const masterPath of this.mastersUsingThemes(written)) {
163924
- this.masterThemeFormatSchemes.set(masterPath, parsed.scheme);
164216
+ const primary = await this.resolvePrimaryThemePath();
164217
+ const deck = primary === void 0 ? void 0 : schemes.get(primary);
164218
+ if (deck) {
164219
+ this.globalThemeFormatSchemeSnapshot = deck;
164220
+ this.themeFormatScheme = deck;
164221
+ this.heldFormatSchemes.holdParts(
164222
+ deck,
164223
+ new Map(written.map((path3) => [path3, elementFor(path3)]))
164224
+ );
163925
164225
  }
163926
- this.globalThemeFormatSchemeSnapshot = parsed.scheme;
163927
- this.themeFormatScheme = parsed.scheme;
163928
- return parsed.scheme;
164226
+ return this.getThemeFormatScheme();
163929
164227
  }
163930
164228
  /** The real theme variants the loaded package carries, or none. */
163931
164229
  getThemeVariants() {
@@ -164051,7 +164349,7 @@ function schemeFromColorMap(map) {
164051
164349
  folHlink: pick("folHlink")
164052
164350
  };
164053
164351
  }
164054
- var PptxHandlerRuntime102;
164352
+ var PptxHandlerRuntime104;
164055
164353
  var init_PptxHandlerRuntimeBackgroundStyles = __esm({
164056
164354
  "pptx/core/core/runtime/PptxHandlerRuntimeBackgroundStyles.ts"() {
164057
164355
  init_background_style();
@@ -164059,7 +164357,7 @@ var init_PptxHandlerRuntimeBackgroundStyles = __esm({
164059
164357
  init_theme_switching();
164060
164358
  init_master_save_helpers();
164061
164359
  init_PptxHandlerRuntimeThemeEffects();
164062
- PptxHandlerRuntime102 = class extends PptxHandlerRuntime101 {
164360
+ PptxHandlerRuntime104 = class extends PptxHandlerRuntime103 {
164063
164361
  resolveBackgroundStyle(preset2) {
164064
164362
  const xml = {
164065
164363
  "p:sld": { "p:cSld": { "p:bg": backgroundRefNode(preset2.idx, preset2.scheme) } }
@@ -164319,14 +164617,14 @@ var init_sdk_placeholder = __esm({
164319
164617
  });
164320
164618
 
164321
164619
  // pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts
164322
- var PptxHandlerRuntime103;
164620
+ var PptxHandlerRuntime105;
164323
164621
  var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
164324
164622
  "pptx/core/core/runtime/PptxHandlerRuntimeSdkPlaceholders.ts"() {
164325
164623
  init_placeholder_remap();
164326
164624
  init_xml_access();
164327
164625
  init_PptxHandlerRuntimeBackgroundStyles();
164328
164626
  init_sdk_placeholder();
164329
- PptxHandlerRuntime103 = class _PptxHandlerRuntime extends PptxHandlerRuntime102 {
164627
+ PptxHandlerRuntime105 = class _PptxHandlerRuntime extends PptxHandlerRuntime104 {
164330
164628
  createPlaceholderElement(layoutPath, input, type, options) {
164331
164629
  if (input.type !== "text") throw new Error("Placeholder input must be text");
164332
164630
  const layout = this.layoutXmlMap.get(layoutPath);
@@ -164380,14 +164678,14 @@ var init_PptxHandlerRuntimeSdkPlaceholders = __esm({
164380
164678
  };
164381
164679
  }
164382
164680
  });
164383
- var PptxHandlerRuntime104;
164681
+ var PptxHandlerRuntime106;
164384
164682
  var init_PptxHandlerRuntimeImplementation = __esm({
164385
164683
  "pptx/core/core/runtime/PptxHandlerRuntimeImplementation.ts"() {
164386
164684
  init_PptxElementXmlBuilder();
164387
164685
  init_builders();
164388
164686
  init_factories();
164389
164687
  init_PptxHandlerRuntimeSdkPlaceholders();
164390
- PptxHandlerRuntime104 = class _PptxHandlerRuntime extends PptxHandlerRuntime103 {
164688
+ PptxHandlerRuntime106 = class _PptxHandlerRuntime extends PptxHandlerRuntime105 {
164391
164689
  constructor(dependencyFactory = new exports.PptxRuntimeDependencyFactory()) {
164392
164690
  super();
164393
164691
  this.dependencyFactory = dependencyFactory;
@@ -164531,7 +164829,7 @@ exports.PptxHandlerRuntime = void 0;
164531
164829
  var init_PptxHandlerRuntime = __esm({
164532
164830
  "pptx/core/core/PptxHandlerRuntime.ts"() {
164533
164831
  init_PptxHandlerRuntimeImplementation();
164534
- exports.PptxHandlerRuntime = class extends PptxHandlerRuntime104 {
164832
+ exports.PptxHandlerRuntime = class extends PptxHandlerRuntime106 {
164535
164833
  };
164536
164834
  }
164537
164835
  });
@@ -167918,10 +168216,32 @@ var init_PptxHandlerCore = __esm({
167918
168216
  async setPresentationTheme(themePath, applyToAllMasters = true) {
167919
168217
  await this.runtime.setPresentationTheme(themePath, applyToAllMasters);
167920
168218
  }
168219
+ /**
168220
+ * Point one slide master at a theme part already in the package; scheme edits and saves follow
168221
+ * it. Does nothing when the package has no such master or part.
168222
+ *
168223
+ * @param masterPath - The master's part path (e.g. `ppt/slideMasters/slideMaster2.xml`).
168224
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme1.xml`).
168225
+ */
168226
+ async setSlideMasterTheme(masterPath, themePath) {
168227
+ await this.runtime.setSlideMasterTheme(masterPath, themePath);
168228
+ }
168229
+ /**
168230
+ * Read one theme part's colour, font and format schemes and its name without changing the
168231
+ * loaded theme, for example to show what switching to it would apply.
168232
+ *
168233
+ * @param themePath - The theme part's path (e.g. `ppt/theme/theme2.xml`).
168234
+ * @returns The part's schemes, or `undefined` when the package has no such part.
168235
+ */
168236
+ async getThemePartSchemes(themePath) {
168237
+ return this.runtime.getThemePartSchemes(themePath);
168238
+ }
167921
168239
  /**
167922
168240
  * Modify the theme’s colour scheme (accent colours, background, text, etc.).
167923
168241
  *
167924
168242
  * @param colorScheme - A {@link PptxThemeColorScheme} with hex colour values.
168243
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
168244
+ * master uses when omitted.
167925
168245
  *
167926
168246
  * @example
167927
168247
  * ```ts
@@ -167934,13 +168254,15 @@ var init_PptxHandlerCore = __esm({
167934
168254
  * // => void — colour scheme updated in the in-memory theme XML
167935
168255
  * ```
167936
168256
  */
167937
- async updateThemeColorScheme(colorScheme) {
167938
- await this.runtime.updateThemeColorScheme(colorScheme);
168257
+ async updateThemeColorScheme(colorScheme, themePaths) {
168258
+ await this.runtime.updateThemeColorScheme(colorScheme, themePaths);
167939
168259
  }
167940
168260
  /**
167941
168261
  * Update the theme’s font scheme (heading + body typefaces).
167942
168262
  *
167943
168263
  * @param fontScheme - A {@link PptxThemeFontScheme} with font family names.
168264
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
168265
+ * master uses when omitted.
167944
168266
  *
167945
168267
  * @example
167946
168268
  * ```ts
@@ -167951,16 +168273,18 @@ var init_PptxHandlerCore = __esm({
167951
168273
  * // => void — font scheme updated in the in-memory theme XML
167952
168274
  * ```
167953
168275
  */
167954
- async updateThemeFontScheme(fontScheme) {
167955
- await this.runtime.updateThemeFontScheme(fontScheme);
168276
+ async updateThemeFontScheme(fontScheme, themePaths) {
168277
+ await this.runtime.updateThemeFontScheme(fontScheme, themePaths);
167956
168278
  }
167957
168279
  /**
167958
168280
  * Rename the presentation theme.
167959
168281
  *
167960
168282
  * @param name - New display name for the theme.
168283
+ * @param themePaths - Only these theme parts (e.g. `ppt/theme/theme2.xml`); every part a slide
168284
+ * master uses when omitted.
167961
168285
  */
167962
- async updateThemeName(name) {
167963
- await this.runtime.updateThemeName(name);
168286
+ async updateThemeName(name, themePaths) {
168287
+ await this.runtime.updateThemeName(name, themePaths);
167964
168288
  }
167965
168289
  /**
167966
168290
  * Resolve a `<p:style>` block (`a:lnRef` / `a:fillRef` / `a:effectRef` /
@@ -167983,6 +168307,14 @@ var init_PptxHandlerCore = __esm({
167983
168307
  async applyThemeFormatSchemeXml(fmtSchemeXml) {
167984
168308
  return this.runtime.applyThemeFormatSchemeXml(fmtSchemeXml);
167985
168309
  }
168310
+ /**
168311
+ * Put a format scheme a theme part held before back into the theme parts (or only `themePaths`),
168312
+ * as the part held it: Undo and Redo of an Effects pick. Only a scheme this handler wrote into a
168313
+ * part or over one can come back; for any other it writes nothing and returns `undefined`.
168314
+ */
168315
+ async restoreThemeFormatScheme(scheme, themePaths) {
168316
+ return this.runtime.restoreThemeFormatScheme(scheme, themePaths);
168317
+ }
167986
168318
  /** The real theme variants the loaded package carries (`themeVariants/` parts), or none. */
167987
168319
  getThemeVariants() {
167988
168320
  return this.runtime.getThemeVariants();
@@ -187154,6 +187486,7 @@ exports.flattenChartUserShapes = flattenChartUserShapes;
187154
187486
  exports.flattenNodes = flattenNodes;
187155
187487
  exports.formatAutoNumberMarker = formatAutoNumberMarker;
187156
187488
  exports.formatCommentTimestamp = formatCommentTimestamp;
187489
+ exports.formatSchemeKey = formatSchemeKey;
187157
187490
  exports.formatScriptAutoNumber = formatScriptAutoNumber;
187158
187491
  exports.fragmentShapes = fragmentShapes;
187159
187492
  exports.gearPoints = gearPoints;