@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,778 @@
1
+ import { schemeColorNameSchema } from "../../../core/dist/theme.js";
2
+ import { matchLayoutPlaceholderKey } from "../../../core/dist/placeholders.js";
3
+ import "../../../core/dist/capability.js";
4
+ import { A_NS, P_NS, REL_IMAGE, R_NS, emuToPx } from "../../../import/dist/namespaces.js";
5
+ import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
6
+ import { resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "../../../import/dist/resources.js";
7
+ import "../../../import/dist/index.js";
8
+ import { preset, presetGeometryNames } from "../shared/geometry.js";
9
+ import { readClickLink } from "../shared/identity.js";
10
+ import { isPlaceholderPicElement, readNvPrPlaceholder } from "../shared/placeholder-import.js";
11
+ import { createImageNode } from "./image-declaration.js";
12
+ import { readImage } from "./image-decode.js";
13
+ import { alphaModFixFragmentSchema, customPathAttributesSchema, customPathPointSchema, geomGuideFragmentSchema, lineAttributesFragmentSchema, nonVisualPicIdSchema, outerShadowFragmentSchema, presetDashFragmentSchema, presetGeomFragmentSchema, softEdgeFragmentSchema, srcRectFragmentSchema } from "./image-schemas.js";
14
+ import { z } from "zod";
15
+ // ../capabilities/dist/image/image-import.js
16
+ const SchemeColorSchema = z.object({ val: schemeColorNameSchema });
17
+ const SrgbColorSchema = z.object({ val: hexRgb6Schema });
18
+ const AlphaModifierSchema = z.object({ val: ooxmlNonNegativeIntSchema });
19
+ function readColorElement(containerCursor, part, slideIndex, diagnostics) {
20
+ const srgb = containerCursor.child(A_NS, "srgbClr");
21
+ const scheme = srgb === void 0 ? containerCursor.child(A_NS, "schemeClr") : void 0;
22
+ const colorCursor = srgb ?? scheme;
23
+ if (colorCursor === void 0) return void 0;
24
+ let baseColor;
25
+ if (srgb !== void 0) {
26
+ const raw = srgb.attrsObject(["val"]);
27
+ const parsed = SrgbColorSchema.safeParse(raw);
28
+ if (!parsed.success) {
29
+ diagnostics.push({
30
+ code: "invalid-xml-value",
31
+ category: "corrupt-input",
32
+ disposition: "omitted",
33
+ location: {
34
+ part,
35
+ xpath: srgb.xpath,
36
+ slideIndex
37
+ },
38
+ attributeOrElement: "a:srgbClr/@val",
39
+ rawValue: raw["val"] ?? ""
40
+ });
41
+ return;
42
+ }
43
+ baseColor = `#${parsed.data.val.toUpperCase()}`;
44
+ } else if (scheme !== void 0) {
45
+ const raw = scheme.attrsObject(["val"]);
46
+ const parsed = SchemeColorSchema.safeParse(raw);
47
+ if (!parsed.success) {
48
+ diagnostics.push({
49
+ code: "invalid-xml-value",
50
+ category: "corrupt-input",
51
+ disposition: "omitted",
52
+ location: {
53
+ part,
54
+ xpath: scheme.xpath,
55
+ slideIndex
56
+ },
57
+ attributeOrElement: "a:schemeClr/@val",
58
+ rawValue: raw["val"] ?? ""
59
+ });
60
+ return;
61
+ }
62
+ baseColor = parsed.data.val;
63
+ }
64
+ if (baseColor === void 0) return void 0;
65
+ const alphaCursor = colorCursor.child(A_NS, "alpha");
66
+ if (alphaCursor !== void 0) {
67
+ const rawAlpha = alphaCursor.attrsObject(["val"]);
68
+ const parsedAlpha = AlphaModifierSchema.safeParse(rawAlpha);
69
+ if (parsedAlpha.success) return {
70
+ color: baseColor,
71
+ alpha: parsedAlpha.data.val / 1e5
72
+ };
73
+ }
74
+ return baseColor;
75
+ }
76
+ function readCustomPathPoint(ptCursor, part, slideIndex, diagnostics) {
77
+ const raw = ptCursor.attrsObject(["x", "y"]);
78
+ const parsed = customPathPointSchema.safeParse(raw);
79
+ if (!parsed.success) {
80
+ diagnostics.push({
81
+ code: "invalid-xml-value",
82
+ category: "corrupt-input",
83
+ disposition: "omitted",
84
+ location: {
85
+ part,
86
+ xpath: ptCursor.xpath,
87
+ slideIndex
88
+ },
89
+ attributeOrElement: "a:pt",
90
+ rawValue: JSON.stringify(raw)
91
+ });
92
+ return;
93
+ }
94
+ return {
95
+ x: parsed.data.x / 1e3,
96
+ y: parsed.data.y / 1e3
97
+ };
98
+ }
99
+ function readCustomGeometry(custGeom, part, slideIndex, fallbackSizePx, diagnostics) {
100
+ custGeom.ignoreEmptyChild(A_NS, "avLst");
101
+ const gdLst = custGeom.child(A_NS, "gdLst");
102
+ if (gdLst !== void 0 && gdLst.remainingElementChildren().length > 0) {
103
+ diagnostics.push({
104
+ code: "unsupported-mechanism",
105
+ category: "unsupported",
106
+ disposition: "omitted",
107
+ location: {
108
+ part,
109
+ xpath: gdLst.xpath,
110
+ slideIndex
111
+ },
112
+ namespaceUri: A_NS,
113
+ localName: "gdLst"
114
+ });
115
+ custGeom.suppressUnconsumed();
116
+ return;
117
+ }
118
+ custGeom.ignoreEmptyChild(A_NS, "ahLst");
119
+ custGeom.ignoreEmptyChild(A_NS, "cxnLst");
120
+ const rect = custGeom.child(A_NS, "rect");
121
+ if (rect !== void 0) {
122
+ rect.consumeAttr("l");
123
+ rect.consumeAttr("t");
124
+ rect.consumeAttr("r");
125
+ rect.consumeAttr("b");
126
+ }
127
+ const pathLst = custGeom.child(A_NS, "pathLst");
128
+ if (pathLst === void 0) return void 0;
129
+ const paths = [];
130
+ let viewWidth;
131
+ let viewHeight;
132
+ for (const pathCursor of pathLst.children(A_NS, "path")) {
133
+ const rawPath = pathCursor.attrsObject([
134
+ "w",
135
+ "h",
136
+ "fill",
137
+ "stroke"
138
+ ]);
139
+ const parsedPath = customPathAttributesSchema.safeParse(rawPath);
140
+ if (!parsedPath.success) {
141
+ diagnostics.push({
142
+ code: "invalid-xml-value",
143
+ category: "corrupt-input",
144
+ disposition: "omitted",
145
+ location: {
146
+ part,
147
+ xpath: pathCursor.xpath,
148
+ slideIndex
149
+ },
150
+ attributeOrElement: "a:path",
151
+ rawValue: JSON.stringify(rawPath)
152
+ });
153
+ pathCursor.suppressUnconsumed();
154
+ return;
155
+ }
156
+ const pathW = parsedPath.data.w !== void 0 ? parsedPath.data.w / 1e3 : fallbackSizePx.width;
157
+ const pathH = parsedPath.data.h !== void 0 ? parsedPath.data.h / 1e3 : fallbackSizePx.height;
158
+ viewWidth ??= pathW;
159
+ viewHeight ??= pathH;
160
+ const commands = [];
161
+ for (const cmdCursor of pathCursor.remainingElementChildren()) {
162
+ if (cmdCursor.namespaceUri !== "http://schemas.openxmlformats.org/drawingml/2006/main") {
163
+ diagnostics.push({
164
+ code: "unconsumed-xml",
165
+ category: "unsupported",
166
+ disposition: "omitted",
167
+ kind: "element",
168
+ location: {
169
+ part,
170
+ xpath: cmdCursor.xpath,
171
+ slideIndex
172
+ },
173
+ namespaceUri: cmdCursor.namespaceUri,
174
+ localName: cmdCursor.localName
175
+ });
176
+ continue;
177
+ }
178
+ switch (cmdCursor.localName) {
179
+ case "moveTo": {
180
+ const pt = cmdCursor.child(A_NS, "pt");
181
+ const coords = pt === void 0 ? void 0 : readCustomPathPoint(pt, part, slideIndex, diagnostics);
182
+ if (coords === void 0) return void 0;
183
+ commands.push({
184
+ op: "M",
185
+ x: coords.x,
186
+ y: coords.y
187
+ });
188
+ break;
189
+ }
190
+ case "lnTo": {
191
+ const pt = cmdCursor.child(A_NS, "pt");
192
+ const coords = pt === void 0 ? void 0 : readCustomPathPoint(pt, part, slideIndex, diagnostics);
193
+ if (coords === void 0) return void 0;
194
+ commands.push({
195
+ op: "L",
196
+ x: coords.x,
197
+ y: coords.y
198
+ });
199
+ break;
200
+ }
201
+ case "quadBezTo": {
202
+ const pts = cmdCursor.children(A_NS, "pt");
203
+ if (pts.length !== 2) return void 0;
204
+ const p1 = readCustomPathPoint(pts[0], part, slideIndex, diagnostics);
205
+ const p2 = readCustomPathPoint(pts[1], part, slideIndex, diagnostics);
206
+ if (p1 === void 0 || p2 === void 0) return void 0;
207
+ commands.push({
208
+ op: "Q",
209
+ x1: p1.x,
210
+ y1: p1.y,
211
+ x: p2.x,
212
+ y: p2.y
213
+ });
214
+ break;
215
+ }
216
+ case "cubicBezTo": {
217
+ const pts = cmdCursor.children(A_NS, "pt");
218
+ if (pts.length !== 3) return void 0;
219
+ const p1 = readCustomPathPoint(pts[0], part, slideIndex, diagnostics);
220
+ const p2 = readCustomPathPoint(pts[1], part, slideIndex, diagnostics);
221
+ const p3 = readCustomPathPoint(pts[2], part, slideIndex, diagnostics);
222
+ if (p1 === void 0 || p2 === void 0 || p3 === void 0) return;
223
+ commands.push({
224
+ op: "C",
225
+ x1: p1.x,
226
+ y1: p1.y,
227
+ x2: p2.x,
228
+ y2: p2.y,
229
+ x: p3.x,
230
+ y: p3.y
231
+ });
232
+ break;
233
+ }
234
+ case "close":
235
+ commands.push({ op: "Z" });
236
+ break;
237
+ default:
238
+ diagnostics.push({
239
+ code: "unsupported-mechanism",
240
+ category: "unsupported",
241
+ disposition: "omitted",
242
+ location: {
243
+ part,
244
+ xpath: cmdCursor.xpath,
245
+ slideIndex
246
+ },
247
+ namespaceUri: cmdCursor.namespaceUri,
248
+ localName: cmdCursor.localName
249
+ });
250
+ return;
251
+ }
252
+ }
253
+ if (commands.length === 0) continue;
254
+ const fill = parsedPath.data.fill === "none" ? false : true;
255
+ const stroke = parsedPath.data.stroke === "0" || parsedPath.data.stroke === "false" ? false : true;
256
+ paths.push({
257
+ commands,
258
+ ...fill ? {} : { fill: false },
259
+ ...stroke ? {} : { stroke: false }
260
+ });
261
+ }
262
+ if (paths.length === 0 || viewWidth === void 0 || viewHeight === void 0) return;
263
+ return {
264
+ type: "custom",
265
+ width: viewWidth,
266
+ height: viewHeight,
267
+ paths
268
+ };
269
+ }
270
+ function readPictureGeometry(spPr, part, slideIndex, sizePx, diagnostics) {
271
+ const prstGeom = spPr.child(A_NS, "prstGeom");
272
+ if (prstGeom !== void 0) {
273
+ const rawGeom = prstGeom.attrsObject(["prst"]);
274
+ const parsedGeom = presetGeomFragmentSchema.safeParse(rawGeom);
275
+ const avLst = prstGeom.child(A_NS, "avLst");
276
+ const adjust = {};
277
+ if (avLst !== void 0) for (const gd of avLst.children(A_NS, "gd")) {
278
+ const rawGd = gd.attrsObject(["name", "fmla"]);
279
+ const parsedGd = geomGuideFragmentSchema.safeParse(rawGd);
280
+ if (!parsedGd.success) {
281
+ diagnostics.push({
282
+ code: "invalid-xml-value",
283
+ category: "corrupt-input",
284
+ disposition: "recovered",
285
+ location: {
286
+ part,
287
+ xpath: gd.xpath,
288
+ slideIndex
289
+ },
290
+ attributeOrElement: "a:gd",
291
+ rawValue: JSON.stringify(rawGd)
292
+ });
293
+ continue;
294
+ }
295
+ const match = /^val (-?\d+)$/u.exec(parsedGd.data.fmla);
296
+ if (match !== null) adjust[parsedGd.data.name] = Number(match[1]);
297
+ }
298
+ if (!parsedGeom.success || !presetGeometryNames.has(parsedGeom.data.prst)) {
299
+ diagnostics.push({
300
+ code: "invalid-xml-value",
301
+ category: "corrupt-input",
302
+ disposition: "recovered",
303
+ location: {
304
+ part,
305
+ xpath: prstGeom.xpath,
306
+ slideIndex
307
+ },
308
+ attributeOrElement: "a:prstGeom/@prst",
309
+ rawValue: rawGeom["prst"] ?? ""
310
+ });
311
+ return;
312
+ }
313
+ const prstName = parsedGeom.data.prst;
314
+ if (Object.keys(adjust).length > 0) return preset(prstName, adjust);
315
+ return prstName === "rect" ? void 0 : prstName;
316
+ }
317
+ const custGeom = spPr.child(A_NS, "custGeom");
318
+ if (custGeom !== void 0) return readCustomGeometry(custGeom, part, slideIndex, sizePx, diagnostics);
319
+ }
320
+ function readBorderStyle(ln, part, slideIndex, diagnostics) {
321
+ if (ln.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "noFill")) return {};
322
+ const rawLn = ln.attrsObject(["w"]);
323
+ const parsedLn = lineAttributesFragmentSchema.safeParse(rawLn);
324
+ let borderWidth;
325
+ if (!parsedLn.success) diagnostics.push({
326
+ code: "invalid-xml-value",
327
+ category: "corrupt-input",
328
+ disposition: "recovered",
329
+ location: {
330
+ part,
331
+ xpath: ln.xpath,
332
+ slideIndex
333
+ },
334
+ attributeOrElement: "a:ln/@w",
335
+ rawValue: rawLn["w"] ?? ""
336
+ });
337
+ else if (parsedLn.data.w !== void 0) borderWidth = emuToPx(parsedLn.data.w);
338
+ let borderColor;
339
+ const solidFill = ln.child(A_NS, "solidFill");
340
+ if (solidFill !== void 0) borderColor = readColorElement(solidFill, part, slideIndex, diagnostics);
341
+ let borderStyle;
342
+ const prstDash = ln.child(A_NS, "prstDash");
343
+ if (prstDash !== void 0) {
344
+ const rawDash = prstDash.attrsObject(["val"]);
345
+ const parsedDash = presetDashFragmentSchema.safeParse(rawDash);
346
+ if (!parsedDash.success) diagnostics.push({
347
+ code: "invalid-xml-value",
348
+ category: "corrupt-input",
349
+ disposition: "recovered",
350
+ location: {
351
+ part,
352
+ xpath: prstDash.xpath,
353
+ slideIndex
354
+ },
355
+ attributeOrElement: "a:prstDash/@val",
356
+ rawValue: rawDash["val"] ?? ""
357
+ });
358
+ else switch (parsedDash.data.val) {
359
+ case "solid":
360
+ borderStyle = "solid";
361
+ break;
362
+ case "dash":
363
+ borderStyle = "dashed";
364
+ break;
365
+ case "sysDot":
366
+ case "dot": borderStyle = "dotted";
367
+ }
368
+ }
369
+ if (borderColor === void 0) return {};
370
+ return {
371
+ borderColor,
372
+ ...borderWidth === void 0 ? {} : { borderWidth },
373
+ ...borderStyle === void 0 ? {} : { borderStyle }
374
+ };
375
+ }
376
+ function readEffectList(effectLst, part, slideIndex, diagnostics) {
377
+ let boxShadow;
378
+ let softEdge;
379
+ const outerShdw = effectLst.child(A_NS, "outerShdw");
380
+ if (outerShdw !== void 0) {
381
+ const rawShadow = outerShdw.attrsObject([
382
+ "blurRad",
383
+ "dist",
384
+ "dir",
385
+ "algn",
386
+ "rotWithShape"
387
+ ]);
388
+ const parsedShadow = outerShadowFragmentSchema.safeParse(rawShadow);
389
+ if (!parsedShadow.success) diagnostics.push({
390
+ code: "invalid-xml-value",
391
+ category: "corrupt-input",
392
+ disposition: "recovered",
393
+ location: {
394
+ part,
395
+ xpath: outerShdw.xpath,
396
+ slideIndex
397
+ },
398
+ attributeOrElement: "a:outerShdw",
399
+ rawValue: JSON.stringify(rawShadow)
400
+ });
401
+ else {
402
+ const color = readColorElement(outerShdw, part, slideIndex, diagnostics);
403
+ boxShadow = {
404
+ ...color === void 0 ? {} : { color },
405
+ ...parsedShadow.data.blurRad === void 0 ? {} : { blur: emuToPx(parsedShadow.data.blurRad) },
406
+ ...parsedShadow.data.dist === void 0 ? {} : { distance: emuToPx(parsedShadow.data.dist) },
407
+ ...parsedShadow.data.dir === void 0 ? {} : { angle: parsedShadow.data.dir / 6e4 }
408
+ };
409
+ }
410
+ }
411
+ const softEdgeCursor = effectLst.child(A_NS, "softEdge");
412
+ if (softEdgeCursor !== void 0) {
413
+ const rawSoft = softEdgeCursor.attrsObject(["rad"]);
414
+ const parsedSoft = softEdgeFragmentSchema.safeParse(rawSoft);
415
+ if (!parsedSoft.success) diagnostics.push({
416
+ code: "invalid-xml-value",
417
+ category: "corrupt-input",
418
+ disposition: "recovered",
419
+ location: {
420
+ part,
421
+ xpath: softEdgeCursor.xpath,
422
+ slideIndex
423
+ },
424
+ attributeOrElement: "a:softEdge/@rad",
425
+ rawValue: rawSoft["rad"] ?? ""
426
+ });
427
+ else if (parsedSoft.data.rad > 0) softEdge = emuToPx(parsedSoft.data.rad);
428
+ }
429
+ return {
430
+ ...boxShadow === void 0 ? {} : { boxShadow },
431
+ ...softEdge === void 0 ? {} : { softEdge }
432
+ };
433
+ }
434
+ /**
435
+ * Reads a Transitional `<p:pic>` element into an editable `ImageNode`, supporting embedded media,
436
+ * external image links (without network access), crops, clipping geometries, visual effects, and click links.
437
+ */
438
+ function readImagePic(context) {
439
+ const { cursor, part, slideIndex, layoutPlaceholders } = context;
440
+ const diagnostics = [];
441
+ const nvPicPr = cursor.child(P_NS, "nvPicPr");
442
+ if (nvPicPr === void 0) {
443
+ diagnostics.push({
444
+ code: "corrupt-part",
445
+ category: "corrupt-input",
446
+ disposition: "omitted",
447
+ location: {
448
+ part,
449
+ xpath: cursor.xpath,
450
+ slideIndex
451
+ }
452
+ });
453
+ return { diagnostics };
454
+ }
455
+ let objectId;
456
+ let objectName;
457
+ let alt;
458
+ let clickResult;
459
+ const cNvPr = nvPicPr.child(P_NS, "cNvPr");
460
+ if (cNvPr !== void 0) {
461
+ const rawCNvPr = cNvPr.attrsObject([
462
+ "id",
463
+ "name",
464
+ "descr"
465
+ ]);
466
+ const parsedCNvPr = nonVisualPicIdSchema.safeParse(rawCNvPr);
467
+ if (!parsedCNvPr.success) diagnostics.push({
468
+ code: "invalid-xml-value",
469
+ category: "corrupt-input",
470
+ disposition: "recovered",
471
+ location: {
472
+ part,
473
+ xpath: cNvPr.xpath,
474
+ slideIndex
475
+ },
476
+ attributeOrElement: "p:cNvPr",
477
+ rawValue: JSON.stringify(rawCNvPr)
478
+ });
479
+ else {
480
+ objectId = parsedCNvPr.data.id;
481
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
482
+ if (parsedCNvPr.data.descr !== void 0 && parsedCNvPr.data.descr !== "") alt = parsedCNvPr.data.descr;
483
+ }
484
+ const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
485
+ if (hlinkClick !== void 0) clickResult = readClickLink(hlinkClick, context, {
486
+ ...objectId === void 0 ? {} : { objectId },
487
+ ...objectName === void 0 ? {} : { objectName }
488
+ });
489
+ cNvPr.ignoreEmptyChild(A_NS, "extLst");
490
+ }
491
+ const cNvPicPr = nvPicPr.child(P_NS, "cNvPicPr");
492
+ if (cNvPicPr !== void 0) {
493
+ const picLocks = cNvPicPr.child(A_NS, "picLocks");
494
+ if (picLocks !== void 0) {
495
+ picLocks.consumeAttr("noChangeAspect");
496
+ picLocks.consumeAttr("noGrp");
497
+ picLocks.consumeAttr("preferRelativeResize");
498
+ }
499
+ }
500
+ const picLocation = {
501
+ part,
502
+ xpath: cursor.xpath,
503
+ slideIndex,
504
+ ...objectId === void 0 ? {} : { objectId },
505
+ ...objectName === void 0 ? {} : { objectName }
506
+ };
507
+ const nvPr = nvPicPr.child(P_NS, "nvPr");
508
+ const phResult = readNvPrPlaceholder(nvPr, picLocation, diagnostics);
509
+ if (phResult.kind === "error") return { diagnostics };
510
+ const nativeRef = phResult.kind === "ok" ? phResult.nativeRef : void 0;
511
+ const cascadedForPicture = clickResult?.clickLocation !== void 0 ? [{
512
+ location: clickResult.clickLocation,
513
+ role: "link"
514
+ }] : [];
515
+ const blipFill = cursor.child(P_NS, "blipFill");
516
+ const spPr = cursor.child(P_NS, "spPr");
517
+ if (blipFill === void 0 || spPr === void 0) {
518
+ diagnostics.push({
519
+ code: "corrupt-part",
520
+ category: "corrupt-input",
521
+ disposition: "omitted",
522
+ location: picLocation,
523
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
524
+ });
525
+ return { diagnostics };
526
+ }
527
+ blipFill.consumeAttr("rotWithShape");
528
+ blipFill.consumeAttr("dpi");
529
+ const blip = blipFill.child(A_NS, "blip");
530
+ if (blip === void 0) {
531
+ diagnostics.push({
532
+ code: "corrupt-part",
533
+ category: "corrupt-input",
534
+ disposition: "omitted",
535
+ location: picLocation,
536
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
537
+ });
538
+ return { diagnostics };
539
+ }
540
+ const embedId = blip.attr("embed", R_NS);
541
+ const linkId = blip.attr("link", R_NS);
542
+ blip.consumeAttr("cstate");
543
+ let opacity;
544
+ const alphaModFix = blip.child(A_NS, "alphaModFix");
545
+ if (alphaModFix !== void 0) {
546
+ const rawAlpha = alphaModFix.attrsObject(["amt"]);
547
+ const parsedAlpha = alphaModFixFragmentSchema.safeParse(rawAlpha);
548
+ if (!parsedAlpha.success) diagnostics.push({
549
+ code: "invalid-xml-value",
550
+ category: "corrupt-input",
551
+ disposition: "recovered",
552
+ location: {
553
+ ...picLocation,
554
+ xpath: alphaModFix.xpath
555
+ },
556
+ attributeOrElement: "a:alphaModFix/@amt",
557
+ rawValue: rawAlpha["amt"] ?? ""
558
+ });
559
+ else if (parsedAlpha.data.amt < 1e5) opacity = parsedAlpha.data.amt / 1e5;
560
+ }
561
+ const blipExtLst = blip.child(A_NS, "extLst");
562
+ if (blipExtLst !== void 0) {
563
+ for (const ext of blipExtLst.children(A_NS, "ext")) if (ext.attr("uri") === "{28A0092B-C50C-407E-A947-70E740481C1C}") for (const child of ext.remainingElementChildren()) child.consumeAttr("val");
564
+ }
565
+ let src;
566
+ const relationships = context.relationships ?? /* @__PURE__ */ new Map();
567
+ if (embedId !== void 0 && embedId !== "") {
568
+ const resolved = resolveInternalRelationshipTarget(context.package, relationships, part, embedId, picLocation, REL_IMAGE);
569
+ if (!resolved.ok) {
570
+ diagnostics.push({
571
+ ...resolved.diagnostic,
572
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
573
+ });
574
+ return { diagnostics };
575
+ }
576
+ try {
577
+ readImage(resolved.bytes);
578
+ } catch {
579
+ const cascaded = [{
580
+ location: { part: resolved.targetPart },
581
+ role: "media"
582
+ }, ...cascadedForPicture];
583
+ diagnostics.push({
584
+ code: "corrupt-part",
585
+ category: "corrupt-input",
586
+ disposition: "omitted",
587
+ location: picLocation,
588
+ cascaded
589
+ });
590
+ return { diagnostics };
591
+ }
592
+ src = resolved.bytes;
593
+ } else if (linkId !== void 0 && linkId !== "") {
594
+ const resolved = resolveExternalRelationshipTarget(relationships, linkId, picLocation, REL_IMAGE);
595
+ if (!resolved.ok) {
596
+ diagnostics.push({
597
+ ...resolved.diagnostic,
598
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
599
+ });
600
+ return { diagnostics };
601
+ }
602
+ src = { externalUrl: resolved.target };
603
+ } else {
604
+ diagnostics.push({
605
+ code: "corrupt-part",
606
+ category: "corrupt-input",
607
+ disposition: "omitted",
608
+ location: picLocation,
609
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
610
+ });
611
+ return { diagnostics };
612
+ }
613
+ let crop;
614
+ const srcRect = blipFill.child(A_NS, "srcRect");
615
+ if (srcRect !== void 0) {
616
+ const rawCrop = srcRect.attrsObject([
617
+ "l",
618
+ "t",
619
+ "r",
620
+ "b"
621
+ ]);
622
+ const parsedCrop = srcRectFragmentSchema.safeParse(rawCrop);
623
+ if (!parsedCrop.success) diagnostics.push({
624
+ code: "invalid-xml-value",
625
+ category: "corrupt-input",
626
+ disposition: "recovered",
627
+ location: {
628
+ ...picLocation,
629
+ xpath: srcRect.xpath
630
+ },
631
+ attributeOrElement: "a:srcRect",
632
+ rawValue: JSON.stringify(rawCrop)
633
+ });
634
+ else {
635
+ const { l, t, r, b } = parsedCrop.data;
636
+ const nextCrop = {
637
+ ...l !== void 0 && l !== 0 ? { left: l / 1e5 } : {},
638
+ ...t !== void 0 && t !== 0 ? { top: t / 1e5 } : {},
639
+ ...r !== void 0 && r !== 0 ? { right: r / 1e5 } : {},
640
+ ...b !== void 0 && b !== 0 ? { bottom: b / 1e5 } : {}
641
+ };
642
+ if (Object.keys(nextCrop).length > 0) crop = nextCrop;
643
+ }
644
+ }
645
+ const stretch = blipFill.child(A_NS, "stretch");
646
+ if (stretch !== void 0) stretch.ignoreEmptyChild(A_NS, "fillRect");
647
+ const matchedKey = nativeRef === void 0 ? void 0 : matchLayoutPlaceholderKey(layoutPlaceholders, {
648
+ type: nativeRef.type,
649
+ idx: nativeRef.idx
650
+ });
651
+ const matchedLayoutPh = matchedKey === void 0 ? void 0 : layoutPlaceholders?.[matchedKey];
652
+ let localX;
653
+ let localY;
654
+ let localWidth;
655
+ let localHeight;
656
+ let rotate;
657
+ let flipH;
658
+ let flipV;
659
+ const xfrm = spPr.child(A_NS, "xfrm");
660
+ if (xfrm === void 0) {
661
+ if (nativeRef === void 0) {
662
+ diagnostics.push({
663
+ code: "corrupt-part",
664
+ category: "corrupt-input",
665
+ disposition: "omitted",
666
+ location: picLocation,
667
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
668
+ });
669
+ return { diagnostics };
670
+ }
671
+ } else {
672
+ const off = xfrm.child(A_NS, "off");
673
+ const ext = xfrm.child(A_NS, "ext");
674
+ if (off === void 0 || ext === void 0) {
675
+ diagnostics.push({
676
+ code: "corrupt-part",
677
+ category: "corrupt-input",
678
+ disposition: "omitted",
679
+ location: picLocation,
680
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
681
+ });
682
+ return { diagnostics };
683
+ }
684
+ const rawXfrm = xfrm.attrsObject([
685
+ "rot",
686
+ "flipH",
687
+ "flipV"
688
+ ]);
689
+ const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
690
+ const rawOff = off.attrsObject(["x", "y"]);
691
+ const parsedOff = offsetEmuFragmentSchema.safeParse(rawOff);
692
+ const rawExt = ext.attrsObject(["cx", "cy"]);
693
+ const parsedExt = extentEmuFragmentSchema.safeParse(rawExt);
694
+ if (!parsedOff.success || !parsedExt.success) {
695
+ diagnostics.push({
696
+ code: "invalid-xml-value",
697
+ category: "corrupt-input",
698
+ disposition: "omitted",
699
+ location: {
700
+ ...picLocation,
701
+ xpath: xfrm.xpath
702
+ },
703
+ attributeOrElement: "a:xfrm",
704
+ ...cascadedForPicture.length === 0 ? {} : { cascaded: cascadedForPicture }
705
+ });
706
+ return { diagnostics };
707
+ }
708
+ localX = emuToPx(parsedOff.data.x);
709
+ localY = emuToPx(parsedOff.data.y);
710
+ localWidth = emuToPx(parsedExt.data.cx);
711
+ localHeight = emuToPx(parsedExt.data.cy);
712
+ rotate = parsedXfrm.success && parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0 ? parsedXfrm.data.rot / 6e4 : void 0;
713
+ flipH = parsedXfrm.success && parsedXfrm.data.flipH === true ? true : void 0;
714
+ flipV = parsedXfrm.success && parsedXfrm.data.flipV === true ? true : void 0;
715
+ }
716
+ const geometry = readPictureGeometry(spPr, part, slideIndex, {
717
+ width: localWidth ?? matchedLayoutPh?.width ?? 100,
718
+ height: localHeight ?? matchedLayoutPh?.height ?? 100
719
+ }, diagnostics);
720
+ spPr.ignoreEmptyChild(A_NS, "noFill");
721
+ let border = {};
722
+ const ln = spPr.child(A_NS, "ln");
723
+ if (ln !== void 0) border = readBorderStyle(ln, part, slideIndex, diagnostics);
724
+ let effects = {};
725
+ const effectLst = spPr.child(A_NS, "effectLst");
726
+ if (effectLst !== void 0) effects = readEffectList(effectLst, part, slideIndex, diagnostics);
727
+ if (clickResult !== void 0) diagnostics.push(...clickResult.diagnostics);
728
+ const visualStyle = {
729
+ ...opacity === void 0 ? {} : { opacity },
730
+ ...rotate === void 0 ? {} : { rotate },
731
+ ...border,
732
+ ...effects
733
+ };
734
+ const props = {
735
+ src,
736
+ ...objectName === void 0 ? {} : { name: objectName },
737
+ ...matchedKey === void 0 ? {} : { placeholder: matchedKey },
738
+ ...nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
739
+ ...alt === void 0 ? {} : { alt },
740
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
741
+ ...localX === void 0 ? {} : { x: localX },
742
+ ...localY === void 0 ? {} : { y: localY },
743
+ ...localWidth === void 0 ? {} : { width: localWidth },
744
+ ...localHeight === void 0 ? {} : { height: localHeight },
745
+ ...geometry === void 0 ? {} : { geometry },
746
+ ...flipH === void 0 ? {} : { flipH },
747
+ ...flipV === void 0 ? {} : { flipV },
748
+ ...crop === void 0 ? {} : { crop },
749
+ ...Object.keys(visualStyle).length === 0 ? {} : { style: visualStyle }
750
+ };
751
+ const node = createImageNode(props);
752
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
753
+ const pending = clickResult.deferredSlideLink;
754
+ context.registerDeferredSlideLink({
755
+ ...pending,
756
+ apply(targetSlideId) {
757
+ node.set({ link: { id: targetSlideId } });
758
+ }
759
+ });
760
+ }
761
+ return {
762
+ node,
763
+ diagnostics
764
+ };
765
+ }
766
+ const imageImportHandler = {
767
+ target: "shape-tree",
768
+ localName: "pic",
769
+ matches: (cursor) => !isPlaceholderPicElement(cursor),
770
+ read: readImagePic
771
+ };
772
+ const picturePlaceholderImportHandler = {
773
+ target: "shape-tree",
774
+ localName: "pic",
775
+ matches: isPlaceholderPicElement,
776
+ read: readImagePic
777
+ };
778
+ export { imageImportHandler, picturePlaceholderImportHandler, readImagePic };