@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,685 @@
1
+ import { schemeColorNameSchema } from "../../../core/dist/theme.js";
2
+ import { slideFooterValueSchema, slideNumberValueSchema } from "../../../core/dist/author-schemas.js";
3
+ import { footerPlaceholdersSchema } from "../../../core/dist/masters.js";
4
+ import "../../../core/dist/index.js";
5
+ import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
6
+ import "../../../core/dist/capability.js";
7
+ import { A_NS, P_NS, XML_NS, emuToPx } from "../../../import/dist/namespaces.js";
8
+ import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema } from "../../../import/dist/xml-fragments.js";
9
+ import "../../../emit/dist/index.js";
10
+ import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
11
+ import "../../../import/dist/index.js";
12
+ import { emitTextBody, parseTextContent, renderTextOutlinesSvg, resolveTextBody } from "../shared/text-service.js";
13
+ import { footerPlaceholderCodegen } from "./masters-codegen.js";
14
+ import { z } from "zod";
15
+ // ../capabilities/dist/masters/footer-placeholder.js
16
+ const slotToOoxmlType = {
17
+ dateTime: "dt",
18
+ footer: "ftr",
19
+ slideNumber: "sldNum"
20
+ };
21
+ const ooxmlTypeToSlot = {
22
+ dt: "dateTime",
23
+ ftr: "footer",
24
+ sldNum: "slideNumber"
25
+ };
26
+ const slotDefaultMeta = {
27
+ dateTime: {
28
+ idx: 2,
29
+ size: "half",
30
+ namePrefix: "Date Placeholder"
31
+ },
32
+ footer: {
33
+ idx: 3,
34
+ size: "quarter",
35
+ namePrefix: "Footer Placeholder"
36
+ },
37
+ slideNumber: {
38
+ idx: 4,
39
+ size: "quarter",
40
+ namePrefix: "Slide Number Placeholder"
41
+ }
42
+ };
43
+ const slotOrder = [
44
+ "dateTime",
45
+ "footer",
46
+ "slideNumber"
47
+ ];
48
+ function defaultSlotBox(slot, dimensions) {
49
+ const y = Math.round(dimensions.height * .88);
50
+ const height = Math.max(18, Math.round(dimensions.height * .06));
51
+ switch (slot) {
52
+ case "dateTime": return {
53
+ x: Math.round(dimensions.width * .05),
54
+ y,
55
+ width: Math.round(dimensions.width * .25),
56
+ height
57
+ };
58
+ case "footer": return {
59
+ x: Math.round(dimensions.width * .32),
60
+ y,
61
+ width: Math.round(dimensions.width * .36),
62
+ height
63
+ };
64
+ case "slideNumber": return {
65
+ x: Math.round(dimensions.width * .72),
66
+ y,
67
+ width: Math.round(dimensions.width * .23),
68
+ height
69
+ };
70
+ }
71
+ }
72
+ function hasExplicitGeometry(spec) {
73
+ return spec !== void 0 && (spec.x !== void 0 || spec.y !== void 0 || spec.width !== void 0 || spec.height !== void 0);
74
+ }
75
+ function mergeFooterStyle(...styles) {
76
+ const merged = {};
77
+ for (const style of styles) {
78
+ if (style === void 0) continue;
79
+ for (const [key, value] of Object.entries(style)) if (value !== void 0) merged[key] = value;
80
+ }
81
+ return Object.keys(merged).length === 0 ? void 0 : merged;
82
+ }
83
+ function resolveBoxFromSpecs(slot, dimensions, ...specs) {
84
+ const fallback = defaultSlotBox(slot, dimensions);
85
+ let x = fallback.x;
86
+ let y = fallback.y;
87
+ let width = fallback.width;
88
+ let height = fallback.height;
89
+ for (const spec of specs) {
90
+ if (spec === void 0) continue;
91
+ if (spec.x !== void 0) x = spec.x;
92
+ if (spec.y !== void 0) y = spec.y;
93
+ if (spec.width !== void 0) width = spec.width;
94
+ if (spec.height !== void 0) height = spec.height;
95
+ }
96
+ return {
97
+ x,
98
+ y,
99
+ width,
100
+ height
101
+ };
102
+ }
103
+ function buildFooterTextBody(args) {
104
+ const { slot, content, style, box, theme, slideNumber } = args;
105
+ const parsed = parseTextContent(slot === "slideNumber" ? [{
106
+ type: "slide-number",
107
+ props: {},
108
+ children: []
109
+ }] : content === void 0 || content === "" ? [] : [{
110
+ type: "#text",
111
+ text: content
112
+ }], style, theme, { slideNumber }, `footerPlaceholders.${slot}.style`);
113
+ return resolveTextBody(parsed.paragraphs, parsed.style, theme, parsed.style.verticalAlign ?? "middle", {
114
+ width: box.width,
115
+ height: box.height,
116
+ insets: {
117
+ top: 0,
118
+ right: 0,
119
+ bottom: 0,
120
+ left: 0
121
+ }
122
+ }, "text-box");
123
+ }
124
+ function emitFooterPlaceholderItemXml(item, shapeId, emitContext) {
125
+ const spPrXml = item.emitGeometry ? `<p:spPr><a:xfrm><a:off x="${pxToEmu(item.box.x)}" y="${pxToEmu(item.box.y)}"/><a:ext cx="${pxToEmu(item.box.width)}" cy="${pxToEmu(item.box.height)}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr>` : "<p:spPr/>";
126
+ const embedFonts = emitContext.options.embedFonts;
127
+ const emittedBody = emitTextBody(item.text, emitContext.theme, {
128
+ createFieldId: emitContext.createTextFieldId,
129
+ ...embedFonts === void 0 ? {} : { embedFonts }
130
+ });
131
+ return {
132
+ xml: `<p:sp><p:nvSpPr><p:cNvPr id="${shapeId}" name="${xmlEscape(item.name)}"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="${item.phType}" sz="${item.size}" idx="${item.idx}"/></p:nvPr></p:nvSpPr>${spPrXml}${emittedBody.xml}</p:sp>`,
133
+ presentationContributions: emittedBody.presentationContributions
134
+ };
135
+ }
136
+ function emitFooterPlaceholderModel(model, emitContext) {
137
+ if (model.items.length === 0) return { xml: "" };
138
+ let fallbackShapeId = 2;
139
+ const nextId = () => emitContext.allocateObjectId?.() ?? fallbackShapeId++;
140
+ let xml = "";
141
+ const contributions = [];
142
+ for (const item of model.items) {
143
+ const out = emitFooterPlaceholderItemXml(item, nextId(), emitContext);
144
+ xml += out.xml;
145
+ contributions.push(...out.presentationContributions);
146
+ }
147
+ return {
148
+ xml,
149
+ ...contributions.length === 0 ? {} : { presentationContributions: contributions }
150
+ };
151
+ }
152
+ function paintFooterPlaceholderModel(model, paintContext) {
153
+ if (model.items.length === 0) return { svg: "" };
154
+ const svgParts = [];
155
+ for (const item of model.items) {
156
+ if (item.text.text === "") continue;
157
+ const glyphs = renderTextOutlinesSvg({
158
+ paragraphs: item.text.paragraphs,
159
+ box: item.box,
160
+ insets: {
161
+ top: 0,
162
+ right: 0,
163
+ bottom: 0,
164
+ left: 0
165
+ },
166
+ verticalAlign: item.text.verticalAlign,
167
+ theme: paintContext.theme,
168
+ measuredLayout: item.text.measuredLayout,
169
+ idPrefix: `ftr-s${paintContext.slideNumber}-${item.slot}`
170
+ });
171
+ if (glyphs !== "") svgParts.push(glyphs);
172
+ }
173
+ return { svg: svgParts.join("") };
174
+ }
175
+ function normalizeSlideSlotOverride(slot, value) {
176
+ if (value === void 0) return { explicit: false };
177
+ if (typeof value === "boolean") return {
178
+ explicit: true,
179
+ visible: value
180
+ };
181
+ if (typeof value === "string") return {
182
+ explicit: true,
183
+ visible: true,
184
+ text: value
185
+ };
186
+ return {
187
+ explicit: true,
188
+ visible: value.visible ?? true,
189
+ ...typeof value === "object" && "text" in value && value.text !== void 0 ? { text: value.text } : {},
190
+ ...value.style === void 0 ? {} : { style: value.style },
191
+ ...value.idx === void 0 ? {} : { idx: value.idx },
192
+ ...value.size === void 0 ? {} : { size: value.size }
193
+ };
194
+ }
195
+ function isHeaderFooterEnabled(slot, masterHf, layoutHf) {
196
+ const layoutFlag = layoutHf?.[slot];
197
+ if (layoutFlag !== void 0) return layoutFlag;
198
+ const masterFlag = masterHf?.[slot];
199
+ if (masterFlag !== void 0) return masterFlag;
200
+ return true;
201
+ }
202
+ function resolveSlideFooterModel(args) {
203
+ const { slideProps, inheritance, dimensions, theme, slideNumber } = args;
204
+ const masterPlaceholders = inheritance?.master?.footerPlaceholders;
205
+ const layoutPlaceholders = inheritance?.layout?.footerPlaceholders;
206
+ const masterHf = inheritance?.master?.headerFooter;
207
+ const layoutHf = inheritance?.layout?.headerFooter;
208
+ const parsedDateTime = slideProps["dateTime"] === void 0 ? void 0 : slideFooterValueSchema.parse(slideProps["dateTime"]);
209
+ const parsedFooter = slideProps["footer"] === void 0 ? void 0 : slideFooterValueSchema.parse(slideProps["footer"]);
210
+ const parsedSlideNumber = slideProps["slideNumber"] === void 0 ? void 0 : slideNumberValueSchema.parse(slideProps["slideNumber"]);
211
+ const items = [];
212
+ for (const slot of slotOrder) {
213
+ const slideOverride = normalizeSlideSlotOverride(slot, slot === "dateTime" ? parsedDateTime : slot === "footer" ? parsedFooter : parsedSlideNumber);
214
+ const masterSpec = masterPlaceholders?.[slot];
215
+ const layoutSpec = layoutPlaceholders?.[slot];
216
+ const hfEnabled = isHeaderFooterEnabled(slot, masterHf, layoutHf);
217
+ let active = false;
218
+ if (slideOverride.explicit) active = slideOverride.visible && hfEnabled;
219
+ else if (hfEnabled) {
220
+ if (layoutSpec?.visible !== void 0) active = layoutSpec.visible;
221
+ else if (layoutSpec !== void 0) active = masterSpec?.visible ?? true;
222
+ else if (masterSpec !== void 0) active = masterSpec.visible ?? true;
223
+ }
224
+ if (!active) continue;
225
+ const defaults = slotDefaultMeta[slot];
226
+ const box = resolveBoxFromSpecs(slot, dimensions, masterSpec, layoutSpec);
227
+ const style = mergeFooterStyle(masterSpec?.style, layoutSpec?.style, slideOverride.explicit ? slideOverride.style : void 0);
228
+ const content = slot === "slideNumber" ? void 0 : (slideOverride.explicit && slideOverride.text !== void 0 ? slideOverride.text : layoutSpec?.text ?? masterSpec?.text) ?? "";
229
+ const idx = (slideOverride.explicit ? slideOverride.idx : void 0) ?? layoutSpec?.idx ?? masterSpec?.idx ?? defaults.idx;
230
+ const size = (slideOverride.explicit ? slideOverride.size : void 0) ?? layoutSpec?.size ?? masterSpec?.size ?? defaults.size;
231
+ const text = buildFooterTextBody({
232
+ slot,
233
+ content,
234
+ style,
235
+ box,
236
+ theme,
237
+ slideNumber
238
+ });
239
+ items.push({
240
+ slot,
241
+ phType: slotToOoxmlType[slot],
242
+ idx,
243
+ size,
244
+ box,
245
+ emitGeometry: !hasExplicitGeometry(layoutSpec),
246
+ name: `${defaults.namePrefix} ${idx}`,
247
+ text
248
+ });
249
+ }
250
+ return { items };
251
+ }
252
+ function resolveContainerFooterModel(args) {
253
+ const { targetType, footerPlaceholders, dimensions, theme } = args;
254
+ const items = [];
255
+ for (const slot of slotOrder) {
256
+ const spec = footerPlaceholders[slot];
257
+ if (spec === void 0) continue;
258
+ const defaults = slotDefaultMeta[slot];
259
+ const box = resolveBoxFromSpecs(slot, dimensions, spec);
260
+ const idx = spec.idx ?? defaults.idx;
261
+ const size = spec.size ?? defaults.size;
262
+ const text = buildFooterTextBody({
263
+ slot,
264
+ content: spec.text,
265
+ style: spec.style,
266
+ box,
267
+ theme,
268
+ slideNumber: 1
269
+ });
270
+ items.push({
271
+ slot,
272
+ phType: slotToOoxmlType[slot],
273
+ idx,
274
+ size,
275
+ box,
276
+ emitGeometry: targetType === "slide-master" || hasExplicitGeometry(spec),
277
+ name: `${defaults.namePrefix} ${idx}`,
278
+ text
279
+ });
280
+ }
281
+ return { items };
282
+ }
283
+ const PlaceholderAttrSchema = z.object({
284
+ type: z.enum([
285
+ "dt",
286
+ "ftr",
287
+ "sldNum"
288
+ ]),
289
+ sz: z.enum([
290
+ "full",
291
+ "half",
292
+ "quarter"
293
+ ]).optional(),
294
+ idx: ooxmlNonNegativeIntSchema.optional()
295
+ });
296
+ const NonVisualIdAttrSchema = z.object({
297
+ id: ooxmlNonNegativeIntSchema,
298
+ name: z.string().optional()
299
+ });
300
+ const SpLocksAttrSchema = z.object({ noGrp: ooxmlBoolSchema.optional() });
301
+ const PrstGeomAttrSchema = z.object({ prst: z.string().min(1) });
302
+ const BodyPrAttrSchema = z.object({
303
+ vert: z.string().optional(),
304
+ wrap: z.enum(["square", "none"]).optional(),
305
+ rtlCol: ooxmlBoolSchema.optional(),
306
+ lIns: ooxmlNonNegativeIntSchema.optional(),
307
+ tIns: ooxmlNonNegativeIntSchema.optional(),
308
+ rIns: ooxmlNonNegativeIntSchema.optional(),
309
+ bIns: ooxmlNonNegativeIntSchema.optional(),
310
+ anchor: z.enum([
311
+ "t",
312
+ "ctr",
313
+ "b"
314
+ ]).optional()
315
+ });
316
+ const LvlPPrAttrSchema = z.object({ algn: z.enum([
317
+ "l",
318
+ "ctr",
319
+ "r",
320
+ "just"
321
+ ]).optional() });
322
+ const RunPrAttrSchema = z.object({
323
+ lang: z.string().min(1).optional(),
324
+ sz: ooxmlPositiveIntSchema.optional(),
325
+ b: ooxmlBoolSchema.optional(),
326
+ i: ooxmlBoolSchema.optional(),
327
+ dirty: ooxmlBoolSchema.optional(),
328
+ smtClean: ooxmlBoolSchema.optional(),
329
+ kern: ooxmlNonNegativeIntSchema.optional()
330
+ });
331
+ const FieldAttrSchema = z.object({
332
+ id: z.string().min(1),
333
+ type: z.string().min(1)
334
+ });
335
+ const percentValAttrSchema = z.object({ val: ooxmlNonNegativeIntSchema });
336
+ const SrgbAttrSchema = z.object({ val: hexRgb6Schema });
337
+ const SchemeClrAttrSchema = z.object({ val: schemeColorNameSchema });
338
+ const TypefaceAttrSchema = z.object({ typeface: z.string().min(1) });
339
+ const algnMap = {
340
+ l: "left",
341
+ ctr: "center",
342
+ r: "right",
343
+ just: "justify"
344
+ };
345
+ const anchorMap = {
346
+ t: "top",
347
+ ctr: "middle",
348
+ b: "bottom"
349
+ };
350
+ function directDomChild(parent, namespaceUri, localName) {
351
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
352
+ if (child.nodeType !== 1) continue;
353
+ const el = child;
354
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
355
+ }
356
+ }
357
+ function readFooterPlaceholderOoxmlType(cursor) {
358
+ const nvSpPr = directDomChild(cursor.element, P_NS, "nvSpPr");
359
+ if (nvSpPr === void 0) return void 0;
360
+ const nvPr = directDomChild(nvSpPr, P_NS, "nvPr");
361
+ if (nvPr === void 0) return void 0;
362
+ const ph = directDomChild(nvPr, P_NS, "ph");
363
+ if (ph === void 0) return void 0;
364
+ const rawType = ph.getAttribute("type");
365
+ if (rawType === "dt" || rawType === "ftr" || rawType === "sldNum") return rawType;
366
+ }
367
+ function readFooterXmlColor(fillCursor, location, diagnostics) {
368
+ const srgb = fillCursor.child(A_NS, "srgbClr");
369
+ const scheme = srgb === void 0 ? fillCursor.child(A_NS, "schemeClr") : void 0;
370
+ const colorCursor = srgb ?? scheme;
371
+ if (colorCursor === void 0) return void 0;
372
+ let slot;
373
+ let hex;
374
+ if (srgb !== void 0) {
375
+ const parsed = SrgbAttrSchema.safeParse(srgb.attrsObject(["val"]));
376
+ if (!parsed.success) return void 0;
377
+ hex = `#${parsed.data.val.toUpperCase()}`;
378
+ } else if (scheme !== void 0) {
379
+ const parsed = SchemeClrAttrSchema.safeParse(scheme.attrsObject(["val"]));
380
+ if (!parsed.success) return void 0;
381
+ slot = parsed.data.val;
382
+ }
383
+ let lumMod;
384
+ let lumOff;
385
+ let alpha;
386
+ for (const mod of colorCursor.remainingElementChildren()) {
387
+ if (mod.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") continue;
388
+ const parsed = percentValAttrSchema.safeParse(mod.attrsObject(["val"]));
389
+ if (!parsed.success) continue;
390
+ const fraction = Math.min(1, Math.max(0, parsed.data.val / 1e5));
391
+ if (mod.localName === "tint") {
392
+ lumMod = fraction;
393
+ lumOff = 1 - fraction;
394
+ } else if (mod.localName === "lumMod") lumMod = fraction;
395
+ else if (mod.localName === "lumOff") lumOff = fraction;
396
+ else if (mod.localName === "alpha") alpha = fraction;
397
+ else diagnostics.push({
398
+ code: "unsupported-mechanism",
399
+ category: "unsupported",
400
+ disposition: "omitted",
401
+ location: {
402
+ ...location,
403
+ xpath: mod.xpath
404
+ },
405
+ namespaceUri: mod.namespaceUri,
406
+ localName: mod.localName,
407
+ mechanismHint: `color-transform:${mod.localName}`
408
+ });
409
+ }
410
+ const baseColor = slot !== void 0 ? lumMod !== void 0 ? {
411
+ slot,
412
+ lumMod,
413
+ ...lumOff === void 0 ? {} : { lumOff }
414
+ } : slot : hex;
415
+ if (baseColor === void 0) return void 0;
416
+ return alpha !== void 0 && alpha < 1 ? {
417
+ color: baseColor,
418
+ alpha
419
+ } : baseColor;
420
+ }
421
+ function readFooterRunStyle(rPrCursor, location, diagnostics) {
422
+ const parsed = RunPrAttrSchema.safeParse(rPrCursor.attrsObject([
423
+ "lang",
424
+ "sz",
425
+ "b",
426
+ "i",
427
+ "dirty",
428
+ "smtClean",
429
+ "kern"
430
+ ]));
431
+ const style = {};
432
+ if (parsed.success) {
433
+ if (parsed.data.sz !== void 0) style["fontSize"] = `${parsed.data.sz / 100}pt`;
434
+ if (parsed.data.b !== void 0) style["fontWeight"] = parsed.data.b ? "bold" : "normal";
435
+ if (parsed.data.i !== void 0) style["fontStyle"] = parsed.data.i ? "italic" : "normal";
436
+ if (parsed.data.lang !== void 0) style["lang"] = parsed.data.lang;
437
+ }
438
+ const solidFill = rPrCursor.child(A_NS, "solidFill");
439
+ if (solidFill !== void 0) {
440
+ const color = readFooterXmlColor(solidFill, location, diagnostics);
441
+ if (color !== void 0) style["color"] = color;
442
+ }
443
+ const latin = rPrCursor.child(A_NS, "latin");
444
+ const ea = rPrCursor.child(A_NS, "ea");
445
+ const cs = rPrCursor.child(A_NS, "cs");
446
+ const fontCursor = latin ?? ea ?? cs;
447
+ if (fontCursor !== void 0) {
448
+ const parsedFont = TypefaceAttrSchema.safeParse(fontCursor.attrsObject([
449
+ "typeface",
450
+ "pitchFamily",
451
+ "charset",
452
+ "panose"
453
+ ]));
454
+ if (parsedFont.success) {
455
+ const tf = parsedFont.data.typeface;
456
+ style["fontFamily"] = tf === "+mj-lt" || tf === "+mj-ea" || tf === "+mj-cs" ? "major" : tf === "+mn-lt" || tf === "+mn-ea" || tf === "+mn-cs" ? "minor" : tf;
457
+ }
458
+ }
459
+ for (const extra of [ea, cs]) if (extra !== void 0 && extra !== fontCursor) extra.attrsObject([
460
+ "typeface",
461
+ "pitchFamily",
462
+ "charset",
463
+ "panose"
464
+ ]);
465
+ return style;
466
+ }
467
+ function readSpPrTransformBox(spPr, location, diagnostics) {
468
+ const prstGeom = spPr.child(A_NS, "prstGeom");
469
+ if (prstGeom !== void 0) {
470
+ PrstGeomAttrSchema.safeParse(prstGeom.attrsObject(["prst"]));
471
+ prstGeom.ignoreEmptyChild(A_NS, "avLst");
472
+ }
473
+ const xfrm = spPr.child(A_NS, "xfrm");
474
+ if (xfrm === void 0) return void 0;
475
+ const off = xfrm.child(A_NS, "off");
476
+ const ext = xfrm.child(A_NS, "ext");
477
+ if (off === void 0 || ext === void 0) return void 0;
478
+ const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
479
+ const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
480
+ if (!parsedOff.success || !parsedExt.success) {
481
+ diagnostics.push({
482
+ code: "invalid-xml-value",
483
+ category: "corrupt-input",
484
+ disposition: "omitted",
485
+ location: {
486
+ ...location,
487
+ xpath: xfrm.xpath
488
+ },
489
+ attributeOrElement: "a:xfrm"
490
+ });
491
+ return;
492
+ }
493
+ return {
494
+ x: emuToPx(parsedOff.data.x),
495
+ y: emuToPx(parsedOff.data.y),
496
+ width: Math.max(1, emuToPx(parsedExt.data.cx)),
497
+ height: Math.max(1, emuToPx(parsedExt.data.cy))
498
+ };
499
+ }
500
+ function readFooterPlaceholderImport(context) {
501
+ const { cursor, part, slideIndex, containerNode } = context;
502
+ const location = {
503
+ part,
504
+ xpath: cursor.xpath,
505
+ ...containerNode !== void 0 && (containerNode.kind === "slide-master" || containerNode.kind === "slide-layout") ? {} : { slideIndex }
506
+ };
507
+ const diagnostics = [];
508
+ const nvSpPr = cursor.child(P_NS, "nvSpPr");
509
+ if (nvSpPr === void 0) return {};
510
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
511
+ if (cNvPr !== void 0) NonVisualIdAttrSchema.safeParse(cNvPr.attrsObject(["id", "name"]));
512
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
513
+ if (cNvSpPr !== void 0) {
514
+ const spLocks = cNvSpPr.child(A_NS, "spLocks");
515
+ if (spLocks !== void 0) SpLocksAttrSchema.safeParse(spLocks.attrsObject(["noGrp"]));
516
+ }
517
+ const ph = nvSpPr.child(P_NS, "nvPr")?.child(P_NS, "ph");
518
+ if (ph === void 0) return {};
519
+ const parsedPh = PlaceholderAttrSchema.safeParse(ph.attrsObject([
520
+ "type",
521
+ "sz",
522
+ "idx"
523
+ ]));
524
+ if (!parsedPh.success) return {};
525
+ const slot = ooxmlTypeToSlot[parsedPh.data.type];
526
+ const spPr = cursor.child(P_NS, "spPr");
527
+ const box = spPr === void 0 ? void 0 : readSpPrTransformBox(spPr, location, diagnostics);
528
+ let style;
529
+ const textParts = [];
530
+ const txBody = cursor.child(P_NS, "txBody");
531
+ if (txBody !== void 0) {
532
+ const bodyPr = txBody.child(A_NS, "bodyPr");
533
+ if (bodyPr !== void 0) {
534
+ const parsedBody = BodyPrAttrSchema.safeParse(bodyPr.attrsObject([
535
+ "vert",
536
+ "wrap",
537
+ "rtlCol",
538
+ "lIns",
539
+ "tIns",
540
+ "rIns",
541
+ "bIns",
542
+ "anchor"
543
+ ]));
544
+ if (parsedBody.success && parsedBody.data.anchor !== void 0) style = mergeFooterStyle(style, { verticalAlign: anchorMap[parsedBody.data.anchor] });
545
+ bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
546
+ bodyPr.ignoreEmptyChild(A_NS, "normAutofit");
547
+ bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
548
+ }
549
+ const lstStyle = txBody.child(A_NS, "lstStyle");
550
+ if (lstStyle !== void 0) {
551
+ const lvl1 = lstStyle.child(A_NS, "lvl1pPr");
552
+ if (lvl1 !== void 0) {
553
+ const parsedLvl1 = LvlPPrAttrSchema.safeParse(lvl1.attrsObject(["algn"]));
554
+ if (parsedLvl1.success && parsedLvl1.data.algn !== void 0) style = mergeFooterStyle(style, { align: algnMap[parsedLvl1.data.algn] });
555
+ const defRPr = lvl1.child(A_NS, "defRPr");
556
+ if (defRPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(defRPr, location, diagnostics));
557
+ }
558
+ }
559
+ for (const pCursor of txBody.children(A_NS, "p")) {
560
+ const pPr = pCursor.child(A_NS, "pPr");
561
+ if (pPr !== void 0) {
562
+ const parsedPPr = LvlPPrAttrSchema.safeParse(pPr.attrsObject(["algn"]));
563
+ if (parsedPPr.success && parsedPPr.data.algn !== void 0) style = mergeFooterStyle(style, { align: algnMap[parsedPPr.data.algn] });
564
+ }
565
+ let paragraphText = "";
566
+ for (const child of pCursor.remainingElementChildren()) if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
567
+ const rPr = child.child(A_NS, "rPr");
568
+ if (rPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(rPr, location, diagnostics));
569
+ const t = child.child(A_NS, "t");
570
+ if (t !== void 0) {
571
+ t.consumeAttr("space", XML_NS);
572
+ paragraphText += t.textContent;
573
+ }
574
+ } else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
575
+ FieldAttrSchema.safeParse(child.attrsObject(["id", "type"]));
576
+ const rPr = child.child(A_NS, "rPr");
577
+ if (rPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(rPr, location, diagnostics));
578
+ child.ignoreEmptyChild(A_NS, "pPr");
579
+ const t = child.child(A_NS, "t");
580
+ if (t !== void 0) {
581
+ t.consumeAttr("space", XML_NS);
582
+ paragraphText += t.textContent;
583
+ }
584
+ } else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") readFooterRunStyle(child, location, diagnostics);
585
+ textParts.push(paragraphText);
586
+ }
587
+ }
588
+ const combinedText = textParts.join("\n");
589
+ if (containerNode !== void 0 && (containerNode.kind === "slide-master" || containerNode.kind === "slide-layout")) {
590
+ const existingRaw = containerNode.props["footerPlaceholders"];
591
+ const existingParsed = existingRaw === void 0 ? {} : footerPlaceholdersSchema.parse(existingRaw);
592
+ const spec = {
593
+ ...box === void 0 ? {} : {
594
+ x: box.x,
595
+ y: box.y,
596
+ width: box.width,
597
+ height: box.height
598
+ },
599
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
600
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz },
601
+ ...slot !== "slideNumber" && combinedText !== "" ? { text: combinedText } : {},
602
+ ...style === void 0 ? {} : { style },
603
+ visible: false
604
+ };
605
+ const nextFooterPlaceholders = {
606
+ ...existingParsed,
607
+ [slot]: spec
608
+ };
609
+ containerNode.set({ footerPlaceholders: nextFooterPlaceholders });
610
+ } else if (containerNode !== void 0 && containerNode.kind === "slide") {
611
+ if (slot === "slideNumber") {
612
+ const value = style === void 0 && parsedPh.data.idx === void 0 && parsedPh.data.sz === void 0 ? true : {
613
+ ...style === void 0 ? {} : { style },
614
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
615
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz }
616
+ };
617
+ containerNode.set({ slideNumber: value });
618
+ } else {
619
+ const value = style === void 0 && parsedPh.data.idx === void 0 && parsedPh.data.sz === void 0 ? combinedText : {
620
+ ...combinedText !== "" ? { text: combinedText } : {},
621
+ ...style === void 0 ? {} : { style },
622
+ ...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
623
+ ...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz }
624
+ };
625
+ containerNode.set({ [slot]: value });
626
+ }
627
+ }
628
+ return diagnostics.length === 0 ? {} : { diagnostics };
629
+ }
630
+ const footerPlaceholderShapeImportHandler = {
631
+ target: "shape-tree",
632
+ localName: "sp",
633
+ matches(cursor) {
634
+ return readFooterPlaceholderOoxmlType(cursor) !== void 0;
635
+ },
636
+ read: readFooterPlaceholderImport
637
+ };
638
+ /** Native canvas mechanism for `dt`, `ftr`, and `sldNum` metadata placeholders (`footer-placeholder`). */
639
+ const footerPlaceholderMechanism = defineCanvasMechanism({
640
+ key: "footer-placeholder",
641
+ role: "canvas",
642
+ emit: emitFooterPlaceholderModel,
643
+ paint: paintFooterPlaceholderModel,
644
+ import: footerPlaceholderShapeImportHandler
645
+ });
646
+ /** Slide capability resolving, painting, emitting, and importing `dateTime`, `footer`, `slideNumber`, and master/layout `footerPlaceholders`. */
647
+ const footerPlaceholderCapability = {
648
+ declaration: "footer-placeholder",
649
+ slideProp: "footer",
650
+ slideProps: [
651
+ "footer",
652
+ "dateTime",
653
+ "slideNumber"
654
+ ],
655
+ slot: "shape-tree",
656
+ always: true,
657
+ mechanisms: [footerPlaceholderMechanism],
658
+ codegen: footerPlaceholderCodegen,
659
+ bindSlide(input, context) {
660
+ const model = input.type === "slide-master" || input.type === "slide-layout" ? resolveContainerFooterModel({
661
+ targetType: input.type,
662
+ footerPlaceholders: footerPlaceholdersSchema.parse(input.props["footerPlaceholders"] ?? {}),
663
+ dimensions: context.dimensions,
664
+ theme: context.theme
665
+ }) : resolveSlideFooterModel({
666
+ slideProps: input.props,
667
+ ...context.inheritance === void 0 ? {} : { inheritance: context.inheritance },
668
+ dimensions: context.dimensions,
669
+ theme: context.theme,
670
+ slideNumber: context.slideNumber
671
+ });
672
+ return { resolveSlide() {
673
+ const claims = model.items.flatMap((item) => item.text.resourceClaims);
674
+ const warnings = model.items.flatMap((item) => item.text.warnings);
675
+ return {
676
+ extensions: [],
677
+ ...claims.length === 0 ? {} : { resourceClaims: claims },
678
+ ...warnings.length === 0 ? {} : { warnings },
679
+ emit: (emitContext) => footerPlaceholderMechanism.emit(model, emitContext),
680
+ ...model.items.length === 0 ? {} : { paint: (paintContext) => footerPlaceholderMechanism.paint(model, paintContext) }
681
+ };
682
+ } };
683
+ }
684
+ };
685
+ export { footerPlaceholderCapability, footerPlaceholderMechanism, footerPlaceholderShapeImportHandler };