@officedk/pptxdk 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2272 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +48 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,5 @@
1
+ import "../../core/dist/stage-options.js";
2
+ import { emit, emittedBuildQuery, validateOptions } from "./emit.js";
3
+ import { assertXml10Characters, colorMapAttributesXml, colorMapOverrideXml, layoutXml, masterXml, placeholderRefXml, pxToEmu, resolvedColorXml, sectionListXml, themeOverrideXml, themeXml, xmlDocument, xmlEscape } from "./ooxml.js";
4
+ import "../../core/dist/build.js";
5
+ export { assertXml10Characters, colorMapAttributesXml, colorMapOverrideXml, emit, emittedBuildQuery, layoutXml, masterXml, placeholderRefXml, pxToEmu, resolvedColorXml, sectionListXml, themeOverrideXml, themeXml, validateOptions, xmlDocument, xmlEscape };
@@ -0,0 +1,606 @@
1
+ import { createThemeContext, defaultColorMap, defaultTheme, isFont, nativeColorSlots, schemeColorSlots } from "../../core/dist/theme.js";
2
+ import { shapeTreeXml } from "./shape-tree.js";
3
+ import { createHash } from "node:crypto";
4
+ // ../emit/dist/ooxml.js
5
+ function pxToEmu(value) {
6
+ return Math.round(value * 9525);
7
+ }
8
+ function assertXml10Characters(value) {
9
+ for (const character of value) {
10
+ const codePoint = character.codePointAt(0);
11
+ if (codePoint !== void 0 && codePoint !== 9 && codePoint !== 10 && codePoint !== 13 && (codePoint < 32 || codePoint >= 55296 && codePoint <= 57343 || codePoint === 65534 || codePoint === 65535)) throw new Error("String contains characters not allowed in XML 1.0");
12
+ }
13
+ }
14
+ function xmlEscape(value) {
15
+ assertXml10Characters(value);
16
+ return value.replace(/&/gu, "&amp;").replace(/</gu, "&lt;").replace(/>/gu, "&gt;").replace(/"/gu, "&quot;").replace(/'/gu, "&apos;").replace(/\r/gu, "&#xD;").replace(/\n/gu, "&#xA;").replace(/\t/gu, "&#x9;");
17
+ }
18
+ function xmlDocument(body) {
19
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n${body}`;
20
+ }
21
+ const nativeSchemeReference = {
22
+ dk1: "tx1",
23
+ lt1: "bg1",
24
+ dk2: "tx2",
25
+ lt2: "bg2",
26
+ accent1: "accent1",
27
+ accent2: "accent2",
28
+ accent3: "accent3",
29
+ accent4: "accent4",
30
+ accent5: "accent5",
31
+ accent6: "accent6",
32
+ hlink: "hlink",
33
+ folHlink: "folHlink"
34
+ };
35
+ /** Write native theme colors as schemeClr and literal colors as srgbClr. */
36
+ function resolvedColorXml(value) {
37
+ const children = [
38
+ value.lumMod === void 0 ? "" : `<a:lumMod val="${Math.round(value.lumMod * 1e5)}"/>`,
39
+ value.lumOff === void 0 ? "" : `<a:lumOff val="${Math.round(value.lumOff * 1e5)}"/>`,
40
+ value.alpha === void 0 ? "" : `<a:alpha val="${Math.round(value.alpha * 1e5)}"/>`
41
+ ].join("");
42
+ const schemeVal = value.scheme ?? (value.slot === void 0 ? void 0 : nativeSchemeReference[value.slot]);
43
+ const element = schemeVal === void 0 ? "srgbClr" : "schemeClr";
44
+ const color = schemeVal ?? value.hex;
45
+ return children === "" ? `<a:${element} val="${color}"/>` : `<a:${element} val="${color}">${children}</a:${element}>`;
46
+ }
47
+ const namespaces = {
48
+ a: "http://schemas.openxmlformats.org/drawingml/2006/main",
49
+ p: "http://schemas.openxmlformats.org/presentationml/2006/main",
50
+ r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
51
+ relationships: "http://schemas.openxmlformats.org/package/2006/relationships",
52
+ contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types"
53
+ };
54
+ const minimumSlideLayoutId = 2147483648;
55
+ function relationships(entries) {
56
+ return xmlDocument(`<Relationships xmlns="${namespaces.relationships}">${entries.map(({ id, type, target, targetMode }) => `<Relationship Id="${xmlEscape(id)}" Type="${xmlEscape(type)}" Target="${xmlEscape(target)}"${targetMode === void 0 ? "" : ` TargetMode="${xmlEscape(targetMode)}"`}/>`).join("")}</Relationships>`);
57
+ }
58
+ const defaultEmittedMasters = [{
59
+ key: "master-1",
60
+ name: "Office Theme",
61
+ layouts: [{
62
+ key: "layout-1",
63
+ name: "Blank",
64
+ type: "blank",
65
+ preserve: true
66
+ }]
67
+ }];
68
+ function contentTypes(masterCount, layoutCount, themeCount, themeOverrideCount, slideCount, resources, packageParts, hasCoreProperties) {
69
+ const overrides = [
70
+ ["/ppt/presentation.xml", "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"],
71
+ ...Array.from({ length: masterCount }, (_, index) => [`/ppt/slideMasters/slideMaster${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"]),
72
+ ...Array.from({ length: layoutCount }, (_, index) => [`/ppt/slideLayouts/slideLayout${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"]),
73
+ ...Array.from({ length: themeCount }, (_, index) => [`/ppt/theme/theme${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.theme+xml"]),
74
+ ...Array.from({ length: themeOverrideCount }, (_, index) => [`/ppt/theme/themeOverride${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.themeOverride+xml"]),
75
+ ...Array.from({ length: slideCount }, (_, index) => [`/ppt/slides/slide${index + 1}.xml`, "application/vnd.openxmlformats-officedocument.presentationml.slide+xml"]),
76
+ ...hasCoreProperties ? [["/docProps/core.xml", "application/vnd.openxmlformats-package.core-properties+xml"]] : [],
77
+ ...packageParts.map((part) => [`/${part.path}`, part.contentType])
78
+ ];
79
+ const defaults = /* @__PURE__ */ new Map([["rels", "application/vnd.openxmlformats-package.relationships+xml"], ["xml", "application/xml"]]);
80
+ for (const resource of resources) defaults.set(resource.extension, resource.contentType);
81
+ return xmlDocument(`<Types xmlns="${namespaces.contentTypes}">${[...defaults].map(([extension, contentType]) => `<Default Extension="${xmlEscape(extension)}" ContentType="${xmlEscape(contentType)}"/>`).join("")}${overrides.map(([partName, contentType]) => `<Override PartName="${xmlEscape(partName)}" ContentType="${xmlEscape(contentType)}"/>`).join("")}</Types>`);
82
+ }
83
+ function normalizedHex6(color, label) {
84
+ const trimmed = color.trim();
85
+ const six = /^#[0-9a-f]{3}$/iu.test(trimmed) ? trimmed.slice(1).split("").map((c) => c + c).join("") : /^#[0-9a-f]{6}$/iu.test(trimmed) ? trimmed.slice(1) : void 0;
86
+ if (six === void 0) throw new Error(`${label} must be a #RRGGBB color`);
87
+ return six.toUpperCase();
88
+ }
89
+ function colorSchemeXml(name, colors) {
90
+ return `<a:clrScheme name="${xmlEscape(name)}">${nativeColorSlots.map((slot) => {
91
+ return `<a:${slot}><a:srgbClr val="${normalizedHex6(colors[slot], `Theme.colors.${slot}`)}"/></a:${slot}>`;
92
+ }).join("")}</a:clrScheme>`;
93
+ }
94
+ function fontSchemeXml(name, majorValue, minorValue) {
95
+ const major = isFont(majorValue) ? majorValue.family : majorValue;
96
+ const minor = isFont(minorValue) ? minorValue.family : minorValue;
97
+ const majorEscaped = xmlEscape(major);
98
+ const minorEscaped = xmlEscape(minor);
99
+ return `<a:fontScheme name="${xmlEscape(name)}"><a:majorFont><a:latin typeface="${majorEscaped}"/><a:ea typeface="${majorEscaped}"/><a:cs typeface="${majorEscaped}"/></a:majorFont><a:minorFont><a:latin typeface="${minorEscaped}"/><a:ea typeface="${minorEscaped}"/><a:cs typeface="${minorEscaped}"/></a:minorFont></a:fontScheme>`;
100
+ }
101
+ function formatColorTransformXml(transform) {
102
+ const mods = [
103
+ transform.tint === void 0 ? "" : `<a:tint val="${Math.round(transform.tint * 1e5)}"/>`,
104
+ transform.shade === void 0 ? "" : `<a:shade val="${Math.round(transform.shade * 1e5)}"/>`,
105
+ transform.satMod === void 0 ? "" : `<a:satMod val="${Math.round(transform.satMod * 1e5)}"/>`,
106
+ transform.lumMod === void 0 ? "" : `<a:lumMod val="${Math.round(transform.lumMod * 1e5)}"/>`,
107
+ transform.lumOff === void 0 ? "" : `<a:lumOff val="${Math.round(transform.lumOff * 1e5)}"/>`,
108
+ transform.alpha === void 0 ? "" : `<a:alpha val="${Math.round(transform.alpha * 1e5)}"/>`
109
+ ].join("");
110
+ if (transform.color.startsWith("#")) {
111
+ const hex = normalizedHex6(transform.color, "FormatScheme color");
112
+ return mods === "" ? `<a:srgbClr val="${hex}"/>` : `<a:srgbClr val="${hex}">${mods}</a:srgbClr>`;
113
+ }
114
+ return mods === "" ? `<a:schemeClr val="${xmlEscape(transform.color)}"/>` : `<a:schemeClr val="${xmlEscape(transform.color)}">${mods}</a:schemeClr>`;
115
+ }
116
+ function formatFillStyleXml(fill) {
117
+ if (fill.kind === "none") return "<a:noFill/>";
118
+ if (fill.kind === "solid") return `<a:solidFill>${formatColorTransformXml(fill.color)}</a:solidFill>`;
119
+ return `<a:gradFill${fill.rotWithShape === void 0 ? "" : ` rotWithShape="${fill.rotWithShape ? "1" : "0"}"`}><a:gsLst>${fill.stops.map((stop) => `<a:gs pos="${Math.round(stop.position * 1e5)}">${formatColorTransformXml(stop.color)}</a:gs>`).join("")}</a:gsLst>${fill.linear === void 0 ? "" : `<a:lin ang="${Math.round(fill.linear.angle * 6e4)}"${fill.linear.scaled === void 0 ? "" : ` scaled="${fill.linear.scaled ? "1" : "0"}"`}/>`}${fill.path === void 0 ? "" : `<a:path path="${fill.path.shape}">${fill.path.fillToRect === void 0 ? "" : `<a:fillToRect l="${Math.round(fill.path.fillToRect.l * 1e5)}" t="${Math.round(fill.path.fillToRect.t * 1e5)}" r="${Math.round(fill.path.fillToRect.r * 1e5)}" b="${Math.round(fill.path.fillToRect.b * 1e5)}"/>`}</a:path>`}</a:gradFill>`;
120
+ }
121
+ function formatLineStyleXml(line) {
122
+ return `<a:ln${[
123
+ line.widthEmu === void 0 ? "" : ` w="${line.widthEmu}"`,
124
+ line.cap === void 0 ? "" : ` cap="${line.cap}"`,
125
+ line.compound === void 0 ? "" : ` cmpd="${line.compound}"`,
126
+ line.align === void 0 ? "" : ` algn="${line.align}"`
127
+ ].join("")}>${line.fill === void 0 ? `<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>` : formatFillStyleXml(line.fill)}${line.dash === void 0 ? "" : `<a:prstDash val="${xmlEscape(line.dash)}"/>`}</a:ln>`;
128
+ }
129
+ function formatEffectStyleXml(effect) {
130
+ if (effect.shadow === void 0) return "<a:effectStyle><a:effectLst/></a:effectStyle>";
131
+ return `<a:effectStyle><a:effectLst><a:outerShdw blurRad="${Math.round((effect.shadow.blur ?? 0) * 12700)}" dist="${Math.round((effect.shadow.distance ?? 0) * 12700)}" dir="${Math.round((effect.shadow.angle ?? 0) * 6e4)}" rotWithShape="0">${typeof effect.shadow.color === "string" && effect.shadow.color.startsWith("#") ? `<a:srgbClr val="${normalizedHex6(effect.shadow.color, "shadow.color")}"/>` : "<a:srgbClr val=\"000000\"><a:alpha val=\"38000\"/></a:srgbClr>"}</a:outerShdw></a:effectLst></a:effectStyle>`;
132
+ }
133
+ function formatSchemeXml(scheme) {
134
+ const fill = `<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>`;
135
+ const line = `<a:ln w="6350"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill></a:ln>`;
136
+ const effect = `<a:effectStyle><a:effectLst/></a:effectStyle>`;
137
+ if (scheme === void 0) return `<a:fmtScheme name="Office"><a:fillStyleLst>${fill}${fill}${fill}</a:fillStyleLst><a:lnStyleLst>${line}${line}${line}</a:lnStyleLst><a:effectStyleLst>${effect}${effect}${effect}</a:effectStyleLst><a:bgFillStyleLst>${fill}${fill}${fill}</a:bgFillStyleLst></a:fmtScheme>`;
138
+ const fillList = scheme.fillStyles !== void 0 && scheme.fillStyles.length > 0 ? scheme.fillStyles.map(formatFillStyleXml).join("") : `${fill}${fill}${fill}`;
139
+ const lnList = scheme.lineStyles !== void 0 && scheme.lineStyles.length > 0 ? scheme.lineStyles.map(formatLineStyleXml).join("") : `${line}${line}${line}`;
140
+ const effList = scheme.effectStyles !== void 0 && scheme.effectStyles.length > 0 ? scheme.effectStyles.map(formatEffectStyleXml).join("") : `${effect}${effect}${effect}`;
141
+ const bgList = scheme.bgFillStyles !== void 0 && scheme.bgFillStyles.length > 0 ? scheme.bgFillStyles.map(formatFillStyleXml).join("") : `${fill}${fill}${fill}`;
142
+ return `<a:fmtScheme name="${xmlEscape(scheme.name ?? "Office")}"><a:fillStyleLst>${fillList}</a:fillStyleLst><a:lnStyleLst>${lnList}</a:lnStyleLst><a:effectStyleLst>${effList}</a:effectStyleLst><a:bgFillStyleLst>${bgList}</a:bgFillStyleLst></a:fmtScheme>`;
143
+ }
144
+ /**
145
+ * Serializes a resolved deck or master theme as a native theme part.
146
+ */
147
+ function themeXml(value) {
148
+ const name = xmlEscape(value.name);
149
+ const colors = colorSchemeXml(value.name, value.colors);
150
+ const fonts = fontSchemeXml(value.name, value.fonts.major, value.fonts.minor);
151
+ const format = formatSchemeXml(value.formatScheme);
152
+ return xmlDocument(`<a:theme xmlns:a="${namespaces.a}" name="${name}"><a:themeElements>${colors}${fonts}${format}</a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>`);
153
+ }
154
+ function fontSizeCentipoints(value) {
155
+ if (typeof value === "string" && value.endsWith("pt")) return Math.round(Number(value.slice(0, -2)) * 100);
156
+ if (typeof value === "string" && value.endsWith("px")) return Math.round(Number(value.slice(0, -2)) * 75);
157
+ return Math.round(Number(value) * 75);
158
+ }
159
+ function lengthCentipoints(value) {
160
+ if (typeof value === "string" && value.endsWith("pt")) return Math.round(Number(value.slice(0, -2)) * 100);
161
+ if (typeof value === "string" && value.endsWith("px")) return Math.round(Number(value.slice(0, -2)) * 75);
162
+ return Math.round(Number(value) * 75);
163
+ }
164
+ function ooxmlAlign(value) {
165
+ switch (value) {
166
+ case "left": return "l";
167
+ case "center": return "ctr";
168
+ case "right": return "r";
169
+ case "justify": return "just";
170
+ }
171
+ }
172
+ function ooxmlAnchor(value) {
173
+ return value === "middle" ? "ctr" : value === "bottom" ? "b" : "t";
174
+ }
175
+ function placeholderRefXml(ref) {
176
+ const attrs = [];
177
+ if (ref.explicitType !== false) attrs.push(`type="${xmlEscape(ref.type)}"`);
178
+ if (ref.sz !== void 0) attrs.push(`sz="${xmlEscape(ref.sz)}"`);
179
+ if (ref.orient !== void 0) attrs.push(`orient="${xmlEscape(ref.orient)}"`);
180
+ if (ref.idx !== void 0) attrs.push(`idx="${ref.idx}"`);
181
+ if (ref.hasCustomPrompt === true) attrs.push("hasCustomPrompt=\"1\"");
182
+ return `<p:ph${attrs.length === 0 ? "" : ` ${attrs.join(" ")}`}/>`;
183
+ }
184
+ function levelDefRPrXml(style, themeContext) {
185
+ const attrs = [];
186
+ if (style.lang !== void 0) attrs.push(`lang="${xmlEscape(style.lang)}"`);
187
+ if (style.fontSize !== void 0) attrs.push(`sz="${fontSizeCentipoints(style.fontSize)}"`);
188
+ if (style.fontWeight !== void 0) {
189
+ const bold = style.fontWeight === "bold" || typeof style.fontWeight === "number" && style.fontWeight >= 600;
190
+ attrs.push(`b="${bold ? 1 : 0}"`);
191
+ }
192
+ if (style.fontStyle !== void 0) attrs.push(`i="${style.fontStyle === "italic" ? 1 : 0}"`);
193
+ if (style.textDecoration === "underline") attrs.push("u=\"sng\"");
194
+ else if (style.textDecoration === "line-through") attrs.push("strike=\"sngStrike\"");
195
+ if (style.textTransform === "uppercase") attrs.push("cap=\"all\"");
196
+ if (style.letterSpacing !== void 0) attrs.push(`spc="${Math.round(style.letterSpacing * 75)}"`);
197
+ let fillXml = "";
198
+ if (style.color !== void 0) fillXml = `<a:solidFill>${resolvedColorXml(themeContext.resolveColor(style.color))}</a:solidFill>`;
199
+ let fontXml = "";
200
+ if (style.fontFamily !== void 0) {
201
+ const resolved = themeContext.resolveFont(style.fontFamily);
202
+ const latin = resolved.themeFont === "major" ? "+mj-lt" : resolved.themeFont === "minor" ? "+mn-lt" : resolved.family;
203
+ const ea = resolved.themeFont === "major" ? "+mj-ea" : resolved.themeFont === "minor" ? "+mn-ea" : resolved.family;
204
+ const cs = resolved.themeFont === "major" ? "+mj-cs" : resolved.themeFont === "minor" ? "+mn-cs" : resolved.family;
205
+ fontXml = `<a:latin typeface="${xmlEscape(latin)}"/><a:ea typeface="${xmlEscape(ea)}"/><a:cs typeface="${xmlEscape(cs)}"/>`;
206
+ }
207
+ if (attrs.length === 0 && fillXml === "" && fontXml === "") return "";
208
+ const attrText = attrs.length === 0 ? "" : ` ${attrs.join(" ")}`;
209
+ const inner = `${fillXml}${fontXml}`;
210
+ return inner === "" ? `<a:defRPr${attrText}/>` : `<a:defRPr${attrText}>${inner}</a:defRPr>`;
211
+ }
212
+ function levelParagraphPropertiesXml(tagName, level, themeContext) {
213
+ const attrs = [];
214
+ if (level.marginLeft !== void 0) attrs.push(`marL="${pxToEmu(level.marginLeft)}"`);
215
+ if (level.indent !== void 0) attrs.push(`indent="${pxToEmu(level.indent)}"`);
216
+ if (level.align !== void 0) attrs.push(`algn="${ooxmlAlign(level.align)}"`);
217
+ const spcBef = level.spacingBefore === void 0 ? "" : `<a:spcBef><a:spcPts val="${Math.round(level.spacingBefore * 75)}"/></a:spcBef>`;
218
+ const lnSpc = level.lineHeight === void 0 ? "" : `<a:lnSpc><a:spcPts val="${lengthCentipoints(level.lineHeight)}"/></a:lnSpc>`;
219
+ const spcAft = level.spacingAfter === void 0 ? "" : `<a:spcAft><a:spcPts val="${Math.round(level.spacingAfter * 75)}"/></a:spcAft>`;
220
+ let listXml = "";
221
+ if (level.list !== void 0) {
222
+ if (level.list.type === "bullet") listXml = `<a:buChar char="${xmlEscape(level.list.character ?? "•")}"/>`;
223
+ else listXml = `<a:buAutoNum type="${level.list.style ?? "arabicPeriod"}"${level.list.startAt === void 0 ? "" : ` startAt="${level.list.startAt}"`}/>`;
224
+ }
225
+ const defRPr = levelDefRPrXml(level, themeContext);
226
+ const children = `${lnSpc}${spcBef}${spcAft}${listXml}${defRPr}`;
227
+ if (attrs.length === 0 && children === "") return "";
228
+ const attrText = attrs.length === 0 ? "" : ` ${attrs.join(" ")}`;
229
+ return children === "" ? `<${tagName}${attrText}/>` : `<${tagName}${attrText}>${children}</${tagName}>`;
230
+ }
231
+ function listStylesInnerXml(styles, themeContext) {
232
+ if (styles === void 0) return "";
233
+ const parts = [];
234
+ for (const levelNumber of [
235
+ 1,
236
+ 2,
237
+ 3,
238
+ 4,
239
+ 5,
240
+ 6,
241
+ 7,
242
+ 8,
243
+ 9
244
+ ]) {
245
+ const entry = styles[levelNumber];
246
+ if (entry === void 0) continue;
247
+ const xml = levelParagraphPropertiesXml(`a:lvl${levelNumber}pPr`, entry, themeContext);
248
+ if (xml !== "") parts.push(xml);
249
+ }
250
+ return parts.join("");
251
+ }
252
+ function styleAsLevel1(style) {
253
+ if (style === void 0) return void 0;
254
+ const lvl = {};
255
+ for (const key of [
256
+ "fontFamily",
257
+ "fontSize",
258
+ "fontWeight",
259
+ "fontStyle",
260
+ "color",
261
+ "letterSpacing",
262
+ "textTransform",
263
+ "textDecoration",
264
+ "textShadow",
265
+ "lang",
266
+ "lineHeight",
267
+ "align",
268
+ "spacingAfter"
269
+ ]) if (style[key] !== void 0) lvl[key] = style[key];
270
+ return Object.keys(lvl).length === 0 ? void 0 : lvl;
271
+ }
272
+ function placeholderBodyPrXml(style) {
273
+ if (style === void 0) return "<a:bodyPr/>";
274
+ const attrs = [];
275
+ if (style.textWrap !== void 0) attrs.push(`wrap="${style.textWrap === "nowrap" ? "none" : "square"}"`);
276
+ const rawPad = style.padding;
277
+ const padTop = style.paddingTop ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad[0] : void 0);
278
+ const padRight = style.paddingRight ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad[1] : void 0);
279
+ const padBottom = style.paddingBottom ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad.length === 2 ? rawPad[0] : rawPad[2] : void 0);
280
+ const padLeft = style.paddingLeft ?? (typeof rawPad === "number" ? rawPad : Array.isArray(rawPad) ? rawPad.length === 2 ? rawPad[1] : rawPad[3] : void 0);
281
+ if (padLeft !== void 0) attrs.push(`lIns="${pxToEmu(padLeft)}"`);
282
+ if (padTop !== void 0) attrs.push(`tIns="${pxToEmu(padTop)}"`);
283
+ if (padRight !== void 0) attrs.push(`rIns="${pxToEmu(padRight)}"`);
284
+ if (padBottom !== void 0) attrs.push(`bIns="${pxToEmu(padBottom)}"`);
285
+ if (style.verticalAlign !== void 0) attrs.push(`anchor="${ooxmlAnchor(style.verticalAlign)}"`);
286
+ return attrs.length === 0 ? "<a:bodyPr/>" : `<a:bodyPr ${attrs.join(" ")}/>`;
287
+ }
288
+ function placeholderShapesXml(placeholders, themeContext, placeholderSpPrByKey) {
289
+ if (placeholders === void 0) return "";
290
+ return Object.entries(placeholders).map(([key, spec], index) => {
291
+ const id = 2 + index;
292
+ const name = xmlEscape(spec.name ?? key);
293
+ const phXml = placeholderRefXml({
294
+ type: spec.type,
295
+ ...spec.explicitType === void 0 ? {} : { explicitType: spec.explicitType },
296
+ ...spec.idx === void 0 ? {} : { idx: spec.idx },
297
+ ...spec.sz === void 0 ? {} : { sz: spec.sz },
298
+ ...spec.orient === void 0 ? {} : { orient: spec.orient },
299
+ ...spec.hasCustomPrompt === void 0 ? {} : { hasCustomPrompt: spec.hasCustomPrompt }
300
+ });
301
+ const hasBox = spec.x !== void 0 && spec.y !== void 0 && spec.width !== void 0 && spec.height !== void 0;
302
+ const spPr = placeholderSpPrByKey?.[key] ?? (hasBox ? `<p:spPr><a:xfrm><a:off x="${pxToEmu(spec.x)}" y="${pxToEmu(spec.y)}"/><a:ext cx="${pxToEmu(spec.width)}" cy="${pxToEmu(spec.height)}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr>` : "<p:spPr/>");
303
+ const mergedLvl1 = styleAsLevel1(spec.style) === void 0 && spec.listStyles?.[1] === void 0 ? void 0 : {
304
+ ...styleAsLevel1(spec.style),
305
+ ...spec.listStyles?.[1]
306
+ };
307
+ const lstStyleInner = listStylesInnerXml(mergedLvl1 === void 0 && spec.listStyles === void 0 ? void 0 : {
308
+ ...spec.listStyles,
309
+ ...mergedLvl1 === void 0 ? {} : { 1: mergedLvl1 }
310
+ }, themeContext);
311
+ const lstStyle = lstStyleInner === "" ? "<a:lstStyle/>" : `<a:lstStyle>${lstStyleInner}</a:lstStyle>`;
312
+ return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${name}"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${phXml}</p:nvPr></p:nvSpPr>${spPr}<p:txBody>${placeholderBodyPrXml(spec.style)}${lstStyle}${spec.promptText === void 0 ? "<a:p><a:endParaRPr/></a:p>" : `<a:p><a:r><a:t xml:space="preserve">${xmlEscape(spec.promptText)}</a:t></a:r></a:p>`}</p:txBody></p:sp>`;
313
+ }).join("");
314
+ }
315
+ function masterTextStylesXml(textStyles, themeContext) {
316
+ if (textStyles === void 0) return "<p:txStyles><p:titleStyle/><p:bodyStyle/><p:otherStyle/></p:txStyles>";
317
+ const titleInner = listStylesInnerXml(textStyles.titleStyle, themeContext);
318
+ const bodyInner = listStylesInnerXml(textStyles.bodyStyle, themeContext);
319
+ const otherInner = listStylesInnerXml(textStyles.otherStyle, themeContext);
320
+ return `<p:txStyles>${titleInner === "" ? "<p:titleStyle/>" : `<p:titleStyle>${titleInner}</p:titleStyle>`}${bodyInner === "" ? "<p:bodyStyle/>" : `<p:bodyStyle>${bodyInner}</p:bodyStyle>`}${otherInner === "" ? "<p:otherStyle/>" : `<p:otherStyle>${otherInner}</p:otherStyle>`}</p:txStyles>`;
321
+ }
322
+ function effectiveThemeWithOverride(baseTheme, override) {
323
+ if (override === void 0) return baseTheme;
324
+ const mergedColors = { ...baseTheme.colors };
325
+ if (override.colors !== void 0) for (const slot of nativeColorSlots) {
326
+ const value = override.colors[slot];
327
+ if (value !== void 0) mergedColors[slot] = value;
328
+ }
329
+ const mergedFonts = {
330
+ ...baseTheme.fonts,
331
+ ...override.fonts?.major === void 0 ? {} : { major: override.fonts.major },
332
+ ...override.fonts?.minor === void 0 ? {} : { minor: override.fonts.minor }
333
+ };
334
+ return {
335
+ ...baseTheme,
336
+ colors: mergedColors,
337
+ fonts: mergedFonts,
338
+ ...override.formatScheme === void 0 ? baseTheme.formatScheme === void 0 ? {} : { formatScheme: baseTheme.formatScheme } : { formatScheme: override.formatScheme }
339
+ };
340
+ }
341
+ function hasThemeOverrideContent(override) {
342
+ if (override === void 0) return false;
343
+ return override.colors !== void 0 && Object.keys(override.colors).length > 0 || override.fonts !== void 0 && (override.fonts.major !== void 0 || override.fonts.minor !== void 0) || override.formatScheme !== void 0;
344
+ }
345
+ function themeOverrideXml(override, baseTheme) {
346
+ let colorsXml = "";
347
+ if (override.colors !== void 0) {
348
+ const merged = {};
349
+ for (const slot of nativeColorSlots) merged[slot] = override.colors[slot] ?? baseTheme.colors[slot];
350
+ colorsXml = colorSchemeXml(baseTheme.name, merged);
351
+ }
352
+ const fontsXml = override.fonts === void 0 ? "" : fontSchemeXml(baseTheme.name, override.fonts.major ?? baseTheme.fonts.major, override.fonts.minor ?? baseTheme.fonts.minor);
353
+ const formatXml = override.formatScheme === void 0 ? "" : formatSchemeXml(override.formatScheme);
354
+ return xmlDocument(`<a:themeOverride xmlns:a="${namespaces.a}">${colorsXml}${fontsXml}${formatXml}</a:themeOverride>`);
355
+ }
356
+ function colorMapAttributesXml(map) {
357
+ return schemeColorSlots.map((slot) => `${slot}="${map[slot]}"`).join(" ");
358
+ }
359
+ function colorMapOverrideXml(override) {
360
+ if (override === void 0 || override === "master") return "<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>";
361
+ return `<p:clrMapOvr><a:overrideClrMapping ${colorMapAttributesXml(override)}/></p:clrMapOvr>`;
362
+ }
363
+ function headerFooterXml(hf) {
364
+ if (hf === void 0) return "";
365
+ return `<p:hf${[
366
+ hf.slideNumber === void 0 ? "" : ` sldNum="${hf.slideNumber ? "1" : "0"}"`,
367
+ hf.header === void 0 ? "" : ` hdr="${hf.header ? "1" : "0"}"`,
368
+ hf.footer === void 0 ? "" : ` ftr="${hf.footer ? "1" : "0"}"`,
369
+ hf.dateTime === void 0 ? "" : ` dt="${hf.dateTime ? "1" : "0"}"`
370
+ ].join("")}/>`;
371
+ }
372
+ function masterXml(spec, layoutIds, themeContext, colorMapXml = `<p:clrMap ${colorMapAttributesXml(spec.colorMap ?? defaultColorMap)}/>`) {
373
+ const preserveAttr = spec.preserve === void 0 ? "" : ` preserve="${spec.preserve ? "1" : "0"}"`;
374
+ const nameAttr = spec.name === void 0 ? "" : ` name="${xmlEscape(spec.name)}"`;
375
+ const layoutIdList = layoutIds.map(({ id, rId }) => `<p:sldLayoutId id="${id}" r:id="${xmlEscape(rId)}"/>`).join("");
376
+ const shapes = `${placeholderShapesXml(spec.placeholders, themeContext, spec.placeholderSpPrByKey)}${spec.shapeXml ?? ""}`;
377
+ const txStyles = masterTextStylesXml(spec.textStyles, themeContext);
378
+ return xmlDocument(`<p:sldMaster xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${preserveAttr}><p:cSld${nameAttr}>${spec.backgroundXml ?? ""}${shapeTreeXml(shapes)}</p:cSld>${colorMapXml}<p:sldLayoutIdLst>${layoutIdList}</p:sldLayoutIdLst>${spec.transitionXml ?? ""}${spec.timingXml ?? ""}${headerFooterXml(spec.headerFooter)}${txStyles}</p:sldMaster>`);
379
+ }
380
+ function layoutXml(spec, themeContext, colorMapOvrXml = colorMapOverrideXml(spec.colorMapOverride)) {
381
+ const typeAttr = spec.type === void 0 ? "" : ` type="${xmlEscape(spec.type)}"`;
382
+ const preserveAttr = spec.preserve === void 0 ? "" : ` preserve="${spec.preserve ? "1" : "0"}"`;
383
+ const matchingNameAttr = spec.matchingName === void 0 ? "" : ` matchingName="${xmlEscape(spec.matchingName)}"`;
384
+ const userDrawnAttr = spec.userDrawn === void 0 ? "" : ` userDrawn="${spec.userDrawn ? "1" : "0"}"`;
385
+ const showMasterSpAttr = spec.showMasterShapes === false ? " showMasterSp=\"0\"" : "";
386
+ const showMasterPhAnimAttr = spec.showMasterPlaceholderAnimations === void 0 ? "" : ` showMasterPhAnim="${spec.showMasterPlaceholderAnimations ? "1" : "0"}"`;
387
+ const nameAttr = spec.name === void 0 ? "" : ` name="${xmlEscape(spec.name)}"`;
388
+ const shapes = `${placeholderShapesXml(spec.placeholders, themeContext, spec.placeholderSpPrByKey)}${spec.shapeXml ?? ""}`;
389
+ return xmlDocument(`<p:sldLayout xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${typeAttr}${preserveAttr}${matchingNameAttr}${userDrawnAttr}${showMasterSpAttr}${showMasterPhAnimAttr}><p:cSld${nameAttr}>${spec.backgroundXml ?? ""}${shapeTreeXml(shapes)}</p:cSld>${colorMapOvrXml}${spec.transitionXml ?? ""}${spec.timingXml ?? ""}${headerFooterXml(spec.headerFooter)}</p:sldLayout>`);
390
+ }
391
+ function slide(slideId, shapeXml, slideXml, backgroundXml, hidden, showMasterPlaceholderAnimations, colorMapOverride, showMasterShapes, name, colorMapOvrXml = colorMapOverrideXml(colorMapOverride)) {
392
+ const showMasterSpAttr = showMasterShapes === false ? " showMasterSp=\"0\"" : "";
393
+ const showMasterPhAnimAttr = showMasterPlaceholderAnimations === void 0 ? "" : ` showMasterPhAnim="${showMasterPlaceholderAnimations ? "1" : "0"}"`;
394
+ return xmlDocument(`<p:sld xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${showMasterSpAttr}${showMasterPhAnimAttr}${hidden ? " show=\"false\"" : ""}><p:cSld name="${xmlEscape(name ?? slideId)}">${backgroundXml}${shapeTreeXml(shapeXml)}</p:cSld>${colorMapOvrXml}${slideXml}</p:sld>`);
395
+ }
396
+ function sectionId(index, name) {
397
+ const hex = createHash("sha1").update(`section:${index}:${name}`).digest("hex").toUpperCase();
398
+ return `{${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}}`;
399
+ }
400
+ function sectionListXml(sections) {
401
+ if (sections.length === 0) return "";
402
+ return `<p:extLst><p:ext uri="{521415D9-36F7-43E2-AB2F-B90AF26B5E84}"><p14:sectionLst xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main">${sections.map(({ name, slideIndexes }, index) => `<p14:section name="${xmlEscape(name)}" id="${sectionId(index, name)}"><p14:sldIdLst>${slideIndexes.map((slideIndex) => `<p14:sldId id="${255 + slideIndex}"/>`).join("")}</p14:sldIdLst></p14:section>`).join("")}</p14:sectionLst></p:ext></p:extLst>`;
403
+ }
404
+ function coreProperties(title) {
405
+ return xmlDocument(`<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${xmlEscape(title)}</dc:title></cp:coreProperties>`);
406
+ }
407
+ function countAllocatedMasterThemeParts(mastersInput, fallbackTheme = defaultTheme) {
408
+ const masters = mastersInput !== void 0 && mastersInput.length > 0 ? mastersInput : defaultEmittedMasters;
409
+ const seen = /* @__PURE__ */ new Set();
410
+ let count = 0;
411
+ for (const spec of masters) {
412
+ const masterTheme = spec.theme ?? fallbackTheme;
413
+ if (masterTheme !== defaultTheme && seen.has(masterTheme)) continue;
414
+ if (masterTheme !== defaultTheme) seen.add(masterTheme);
415
+ count += 1;
416
+ }
417
+ return count;
418
+ }
419
+ function pptxParts(size, slides, resources = [], packageParts = [], packageRelationships = [], presentationContent = {}, presentationAttributes = [], themeValue = defaultTheme, title, sectionXml = "", mastersInput, mastersEmitDriver) {
420
+ const masters = mastersInput !== void 0 && mastersInput.length > 0 ? mastersInput : defaultEmittedMasters;
421
+ let nextMasterLayoutId = minimumSlideLayoutId;
422
+ let globalLayoutNumber = 0;
423
+ const allocatedThemePartByTheme = /* @__PURE__ */ new Map();
424
+ const emittedThemeParts = [];
425
+ const emittedThemeOverrideParts = [];
426
+ const allocateThemePart = (masterTheme) => {
427
+ if (masterTheme !== defaultTheme) {
428
+ const existing = allocatedThemePartByTheme.get(masterTheme);
429
+ if (existing !== void 0) return existing;
430
+ }
431
+ const themeNumber = emittedThemeParts.length + 1;
432
+ const partPath = `ppt/theme/theme${themeNumber}.xml`;
433
+ const allocation = {
434
+ partPath,
435
+ relTarget: `../theme/theme${themeNumber}.xml`
436
+ };
437
+ emittedThemeParts.push({
438
+ partPath,
439
+ xml: mastersEmitDriver !== void 0 ? mastersEmitDriver.emitTheme(masterTheme) : themeXml(masterTheme)
440
+ });
441
+ if (masterTheme !== defaultTheme) allocatedThemePartByTheme.set(masterTheme, allocation);
442
+ return allocation;
443
+ };
444
+ const allocateThemeOverridePart = (override, baseTheme) => {
445
+ const overrideNumber = emittedThemeOverrideParts.length + 1;
446
+ const partPath = `ppt/theme/themeOverride${overrideNumber}.xml`;
447
+ emittedThemeOverrideParts.push({
448
+ partPath,
449
+ xml: mastersEmitDriver !== void 0 ? mastersEmitDriver.emitThemeOverride(override, baseTheme) : themeOverrideXml(override, baseTheme)
450
+ });
451
+ return `../theme/themeOverride${overrideNumber}.xml`;
452
+ };
453
+ const allocatedMasters = masters.map((spec, masterIndex) => {
454
+ const masterNumber = masterIndex + 1;
455
+ const masterId = nextMasterLayoutId++;
456
+ const masterPart = `ppt/slideMasters/slideMaster${masterNumber}.xml`;
457
+ const masterTheme = spec.theme ?? themeValue;
458
+ const themeAllocation = allocateThemePart(masterTheme);
459
+ const layouts = spec.layouts.map((layoutSpec, layoutIndex) => {
460
+ const layoutNumber = ++globalLayoutNumber;
461
+ const layoutId = nextMasterLayoutId++;
462
+ const layoutPart = `ppt/slideLayouts/slideLayout${layoutNumber}.xml`;
463
+ const themeOverrideTarget = hasThemeOverrideContent(layoutSpec.themeOverride) ? allocateThemeOverridePart(layoutSpec.themeOverride, masterTheme) : void 0;
464
+ return {
465
+ spec: layoutSpec,
466
+ layoutNumber,
467
+ layoutId,
468
+ layoutPart,
469
+ masterRelId: `rId${layoutIndex + 1}`,
470
+ themeOverrideTarget
471
+ };
472
+ });
473
+ return {
474
+ spec,
475
+ masterNumber,
476
+ masterId,
477
+ masterPart,
478
+ masterTheme,
479
+ themeRelTarget: themeAllocation.relTarget,
480
+ presentationRelId: `rId${masterNumber}`,
481
+ layouts
482
+ };
483
+ });
484
+ const layoutPartByKey = /* @__PURE__ */ new Map();
485
+ const masterThemeByLayoutKey = /* @__PURE__ */ new Map();
486
+ for (const allocatedMaster of allocatedMasters) for (const allocatedLayout of allocatedMaster.layouts) {
487
+ layoutPartByKey.set(allocatedLayout.spec.key, allocatedLayout.layoutPart);
488
+ masterThemeByLayoutKey.set(allocatedLayout.spec.key, effectiveThemeWithOverride(allocatedMaster.masterTheme, allocatedLayout.spec.themeOverride));
489
+ }
490
+ const fallbackLayoutPart = allocatedMasters[0]?.layouts[0]?.layoutPart ?? "ppt/slideLayouts/slideLayout1.xml";
491
+ const fallbackMasterTheme = allocatedMasters[0]?.masterTheme ?? themeValue;
492
+ const slideThemeOverrideTargets = slides.map((slideSpec) => {
493
+ if (!hasThemeOverrideContent(slideSpec.themeOverride)) return void 0;
494
+ const baseTheme = (slideSpec.layoutKey === void 0 ? void 0 : masterThemeByLayoutKey.get(slideSpec.layoutKey)) ?? fallbackMasterTheme;
495
+ return allocateThemeOverridePart(slideSpec.themeOverride, baseTheme);
496
+ });
497
+ const masterRelationships = allocatedMasters.map(({ masterNumber, presentationRelId }) => ({
498
+ id: presentationRelId,
499
+ type: `${namespaces.r}/slideMaster`,
500
+ target: `slideMasters/slideMaster${masterNumber}.xml`
501
+ }));
502
+ const masterIdsXml = allocatedMasters.map(({ masterId, presentationRelId }) => `<p:sldMasterId id="${masterId}" r:id="${presentationRelId}"/>`).join("");
503
+ const slideRelStart = allocatedMasters.length + 1;
504
+ const slideRelationships = slides.map((_, index) => ({
505
+ id: `rId${slideRelStart + index}`,
506
+ type: `${namespaces.r}/slide`,
507
+ target: `slides/slide${index + 1}.xml`
508
+ }));
509
+ const slideIds = slides.map((_, index) => `<p:sldId id="${256 + index}" r:id="rId${slideRelStart + index}"/>`).join("");
510
+ const slideIdListXml = slides.length === 0 ? "" : `<p:sldIdLst>${slideIds}</p:sldIdLst>`;
511
+ const presentationAttributeXml = presentationAttributes.map(({ name, value }) => ` ${name}="${xmlEscape(value)}"`).join("");
512
+ const extraPresentationRelationships = packageRelationships.find(({ sourcePath }) => sourcePath === "ppt/presentation.xml")?.relationships ?? [];
513
+ const presentation = xmlDocument(`<p:presentation xmlns:a="${namespaces.a}" xmlns:r="${namespaces.r}" xmlns:p="${namespaces.p}"${presentationAttributeXml}><p:sldMasterIdLst>${masterIdsXml}</p:sldMasterIdLst>${presentationContent.beforeSlides ?? ""}${slideIdListXml}<p:sldSz cx="${pxToEmu(size.width)}" cy="${pxToEmu(size.height)}"/><p:notesSz cx="6858000" cy="9144000"/>${presentationContent.afterNotesSize ?? ""}${sectionXml}</p:presentation>`);
514
+ const parts = {
515
+ "[Content_Types].xml": contentTypes(allocatedMasters.length, globalLayoutNumber, emittedThemeParts.length, emittedThemeOverrideParts.length, slides.length, resources, packageParts, title !== void 0),
516
+ "_rels/.rels": relationships([{
517
+ id: "rId1",
518
+ type: `${namespaces.r}/officeDocument`,
519
+ target: "ppt/presentation.xml"
520
+ }, ...title === void 0 ? [] : [{
521
+ id: "rId2",
522
+ type: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
523
+ target: "docProps/core.xml"
524
+ }]]),
525
+ "ppt/presentation.xml": presentation,
526
+ "ppt/_rels/presentation.xml.rels": relationships([
527
+ ...masterRelationships,
528
+ ...slideRelationships,
529
+ ...extraPresentationRelationships
530
+ ])
531
+ };
532
+ const defaultThemeCtx = createThemeContext(themeValue);
533
+ for (const themePart of emittedThemeParts) parts[themePart.partPath] = themePart.xml;
534
+ for (const overridePart of emittedThemeOverrideParts) parts[overridePart.partPath] = overridePart.xml;
535
+ for (const allocatedMaster of allocatedMasters) {
536
+ const masterThemeCtx = allocatedMaster.spec.themeContext ?? (allocatedMaster.spec.theme === void 0 ? defaultThemeCtx : createThemeContext(allocatedMaster.spec.theme, void 0, allocatedMaster.spec.colorMap === void 0 ? {} : { colorMap: allocatedMaster.spec.colorMap }));
537
+ const masterLayoutIds = allocatedMaster.layouts.map((item) => ({
538
+ id: item.layoutId,
539
+ rId: item.masterRelId
540
+ }));
541
+ parts[allocatedMaster.masterPart] = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitMaster(allocatedMaster.spec, masterLayoutIds, masterThemeCtx) : masterXml(allocatedMaster.spec, masterLayoutIds, masterThemeCtx);
542
+ parts[`ppt/slideMasters/_rels/slideMaster${allocatedMaster.masterNumber}.xml.rels`] = relationships([
543
+ ...allocatedMaster.layouts.map((item) => ({
544
+ id: item.masterRelId,
545
+ type: `${namespaces.r}/slideLayout`,
546
+ target: `../slideLayouts/slideLayout${item.layoutNumber}.xml`
547
+ })),
548
+ {
549
+ id: `rId${allocatedMaster.layouts.length + 1}`,
550
+ type: `${namespaces.r}/theme`,
551
+ target: allocatedMaster.themeRelTarget
552
+ },
553
+ ...allocatedMaster.spec.extraRelationships ?? []
554
+ ]);
555
+ for (const allocatedLayout of allocatedMaster.layouts) {
556
+ const layoutThemeCtx = allocatedLayout.spec.themeOverride !== void 0 || allocatedLayout.spec.colorMapOverride !== void 0 ? masterThemeCtx.withNativeOverrides(allocatedLayout.spec.themeOverride, allocatedLayout.spec.colorMapOverride) : masterThemeCtx;
557
+ parts[allocatedLayout.layoutPart] = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitLayout(allocatedLayout.spec, layoutThemeCtx) : layoutXml(allocatedLayout.spec, layoutThemeCtx);
558
+ const layoutRels = [
559
+ {
560
+ id: "rId1",
561
+ type: `${namespaces.r}/slideMaster`,
562
+ target: `../slideMasters/slideMaster${allocatedMaster.masterNumber}.xml`
563
+ },
564
+ ...allocatedLayout.themeOverrideTarget === void 0 ? [] : [{
565
+ id: "rId2",
566
+ type: `${namespaces.r}/themeOverride`,
567
+ target: allocatedLayout.themeOverrideTarget
568
+ }],
569
+ ...allocatedLayout.spec.extraRelationships ?? []
570
+ ];
571
+ parts[`ppt/slideLayouts/_rels/slideLayout${allocatedLayout.layoutNumber}.xml.rels`] = relationships(layoutRels);
572
+ }
573
+ }
574
+ slides.forEach(({ shapeXml, slideXml, backgroundXml, hidden, showMasterPlaceholderAnimations, showMasterShapes, layoutKey, colorMapOverride }, index) => {
575
+ const targetLayoutRel = `../${((layoutKey === void 0 ? void 0 : layoutPartByKey.get(layoutKey)) ?? fallbackLayoutPart).slice(4)}`;
576
+ const colorMapOvrXml = mastersEmitDriver !== void 0 ? mastersEmitDriver.emitColorMap(colorMapOverride === void 0 ? {} : { colorMapOverride }) : colorMapOverrideXml(colorMapOverride);
577
+ parts[`ppt/slides/slide${index + 1}.xml`] = slide(slides[index].id, shapeXml, slideXml ?? "", backgroundXml ?? "", hidden ?? false, showMasterPlaceholderAnimations, colorMapOverride, showMasterShapes, slides[index].name, colorMapOvrXml);
578
+ const slideOverrideTarget = slideThemeOverrideTargets[index];
579
+ const slideRels = [
580
+ {
581
+ id: "rId1",
582
+ type: `${namespaces.r}/slideLayout`,
583
+ target: targetLayoutRel
584
+ },
585
+ ...slides[index].relationships,
586
+ ...slideOverrideTarget === void 0 ? [] : [{
587
+ id: `rId${slides[index].relationships.length + 2}`,
588
+ type: `${namespaces.r}/themeOverride`,
589
+ target: slideOverrideTarget
590
+ }]
591
+ ];
592
+ parts[`ppt/slides/_rels/slide${index + 1}.xml.rels`] = relationships(slideRels);
593
+ });
594
+ if (title !== void 0) parts["docProps/core.xml"] = coreProperties(title);
595
+ for (const resource of resources) parts[`ppt/media/${resource.name}`] = resource.bytes;
596
+ for (const part of packageParts) parts[part.path] = part.content;
597
+ for (const relationshipSet of packageRelationships) {
598
+ if (relationshipSet.sourcePath === "ppt/presentation.xml") continue;
599
+ const marker = relationshipSet.sourcePath.lastIndexOf("/");
600
+ const directory = marker === -1 ? "" : relationshipSet.sourcePath.slice(0, marker + 1);
601
+ const name = relationshipSet.sourcePath.slice(marker + 1);
602
+ parts[`${directory}_rels/${name}.rels`] = relationships(relationshipSet.relationships);
603
+ }
604
+ return parts;
605
+ }
606
+ export { assertXml10Characters, colorMapAttributesXml, colorMapOverrideXml, countAllocatedMasterThemeParts, hasThemeOverrideContent, layoutXml, masterXml, placeholderRefXml, pptxParts, pxToEmu, resolvedColorXml, sectionListXml, themeOverrideXml, themeXml, xmlDocument, xmlEscape };
@@ -0,0 +1,12 @@
1
+ // ../emit/dist/shape-tree.js
2
+ const emptyShapeTree = "<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/><a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"0\" cy=\"0\"/></a:xfrm></p:grpSpPr>";
3
+ /**
4
+ * Internal PresentationML shape tree wrapper shared by slides, masters, and layouts.
5
+ *
6
+ * Capability writers contribute complete native object XML; this module owns only the surrounding
7
+ * shape-tree envelope and its required non-visual group properties.
8
+ */
9
+ function shapeTreeXml(shapeXml = "") {
10
+ return `<p:spTree>${emptyShapeTree}${shapeXml}</p:spTree>`;
11
+ }
12
+ export { shapeTreeXml };