@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,337 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { assertValidLang, textStyleKeys } from "../../../core/dist/theme.js";
3
+ import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
4
+ import "../../../core/dist/geometry-schemas.js";
5
+ import { paddingStyleKeys } from "../../../core/dist/block-flex-layout.js";
6
+ import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
7
+ import "../../../core/dist/capability.js";
8
+ import { xmlEscape } from "../../../emit/dist/ooxml.js";
9
+ import "../../../emit/dist/index.js";
10
+ import "../../../import/dist/index.js";
11
+ import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
12
+ import { blockArc, evaluateGeometry, path, preset } from "../shared/geometry.js";
13
+ import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
14
+ import { customGeometryShapeImportHandler, presetShapeImportHandler } from "./shape-import.js";
15
+ import { shapeXml } from "./shape-xml.js";
16
+ import { emitVisualModel, gradientFillMechanism, imageFillMechanism, linearGradient, paintVisualModel, radialGradient, resolveVisualModel, solidFillMechanism } from "../shared/visual.js";
17
+ import { motionAnnotations } from "../motion/motion-api.js";
18
+ import { emitTextBody, measureTextLayoutFromParagraphs, parseTextContent, renderTextOutlinesSvg, resolveTextBody, textInsets } from "../shared/text-service.js";
19
+ import { shapeCodegen } from "./shape-codegen.js";
20
+ import { shapeCoordinateSchema, shapeDeclarationPropsKeys, shapeSizeSchema, shapeStyleSchema } from "./shape-declaration.js";
21
+ // ../capabilities/dist/shape/shape.js
22
+ const allowedParameters = shapeDeclarationPropsKeys;
23
+ const shapeStyleKeys = Object.keys(shapeStyleSchema.unwrap().shape);
24
+ function record(input) {
25
+ return typeof input === "object" && input !== null && !Array.isArray(input) ? input : {};
26
+ }
27
+ function shapeTextStyle(props) {
28
+ const layoutStyle = record(props["style"]);
29
+ if (layoutStyle["lang"] !== void 0) assertValidLang(layoutStyle["lang"]);
30
+ const inherited = Object.fromEntries(Object.entries(layoutStyle).filter(([key]) => textStyleKeys.has(key)));
31
+ const explicit = props["textStyle"];
32
+ if (explicit === void 0) return inherited;
33
+ if (typeof explicit !== "object" || explicit === null || Array.isArray(explicit)) throw new CapabilityError("invalid-style", "Shape.textStyle must be an object");
34
+ const explicitObj = explicit;
35
+ if (explicitObj["lang"] !== void 0) assertValidLang(explicitObj["lang"]);
36
+ return {
37
+ ...inherited,
38
+ ...explicitObj
39
+ };
40
+ }
41
+ function shapeTextContent(input, path) {
42
+ const text = input.props["text"];
43
+ if (text !== void 0) {
44
+ if (typeof text !== "string") throw new CapabilityError("invalid-text", "Shape.text must be a string", path);
45
+ if (input.children.length > 0) throw new CapabilityError("conflicting-text-content", "Shape.text and Shape children text cannot be declared simultaneously", path);
46
+ return text === "" ? [] : [{
47
+ type: "#text",
48
+ text
49
+ }];
50
+ }
51
+ return input.children;
52
+ }
53
+ function validateCoordinate(value, name, path) {
54
+ const parsed = shapeCoordinateSchema.safeParse(value);
55
+ if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number, width and height must be greater than 0, and coordinates must be between -1000000 and 1000000`, path);
56
+ return parsed.data;
57
+ }
58
+ function validateSize(value, name, path) {
59
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number, width and height must be greater than 0, and coordinates must be between -1000000 and 1000000`, path);
60
+ const parsed = shapeSizeSchema.safeParse(value);
61
+ if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must convert to an EMU value between 1 and 2147483647 inclusive`, path);
62
+ return parsed.data;
63
+ }
64
+ function roundSvgNumber(value) {
65
+ const rounded = Math.round(value * 1e6) / 1e6;
66
+ return Object.is(rounded, -0) ? "0" : String(rounded);
67
+ }
68
+ function emitShapeModel(model, emitContext) {
69
+ const properties = emitVisualModel(model.visual, (resource) => emitContext.registerResource(resource));
70
+ const embedFonts = emitContext.options.embedFonts;
71
+ switch (model.text.kind) {
72
+ case "none": return { xml: shapeXml(emitContext.id, model.escapedName, properties.xml, "", nativeLinkXml(emitContext.nativeLink)) };
73
+ case "body": {
74
+ const emittedBody = emitTextBody(model.text.body, emitContext.theme, {
75
+ createFieldId: emitContext.createTextFieldId,
76
+ ...embedFonts === void 0 ? {} : { embedFonts }
77
+ });
78
+ return {
79
+ xml: shapeXml(emitContext.id, model.escapedName, properties.xml, emittedBody.xml, nativeLinkXml(emitContext.nativeLink)),
80
+ presentationContributions: emittedBody.presentationContributions
81
+ };
82
+ }
83
+ default: return model.text;
84
+ }
85
+ }
86
+ function paintShapeModel(model, paintContext) {
87
+ const visualPaint = paintVisualModel({
88
+ model: model.visual,
89
+ slideNumber: paintContext.slideNumber,
90
+ objectId: paintContext.objectId
91
+ });
92
+ switch (model.text.kind) {
93
+ case "none": return visualPaint;
94
+ case "body": {
95
+ const { box, flipH, flipV, rotate, geometry } = model.visual;
96
+ const paintBox = paintContext.box ?? box;
97
+ const { textRect } = evaluateGeometry(geometry, paintBox);
98
+ const cx = paintBox.x + paintBox.width / 2;
99
+ const cy = paintBox.y + paintBox.height / 2;
100
+ const effectiveTextRect = {
101
+ x: flipH ? 2 * cx - (textRect.x + textRect.width) : textRect.x,
102
+ y: flipV ? 2 * cy - (textRect.y + textRect.height) : textRect.y,
103
+ width: textRect.width,
104
+ height: textRect.height
105
+ };
106
+ const glyphsSvg = renderTextOutlinesSvg({
107
+ paragraphs: model.text.body.paragraphs,
108
+ box: effectiveTextRect,
109
+ insets: model.text.insets,
110
+ verticalAlign: model.text.verticalAlign,
111
+ theme: paintContext.theme,
112
+ measuredLayout: paintBox.width === box.width && paintBox.height === box.height ? model.text.body.measuredLayout : void 0,
113
+ idPrefix: `obj-s${paintContext.slideNumber}-o${paintContext.objectId}`,
114
+ rotate
115
+ });
116
+ const textLayer = glyphsSvg === "" ? "" : rotate === 0 ? glyphsSvg : `<g transform="rotate(${roundSvgNumber(rotate)} ${roundSvgNumber(cx)} ${roundSvgNumber(cy)})">${glyphsSvg}</g>`;
117
+ return { svg: `${visualPaint.svg}${textLayer}` };
118
+ }
119
+ default: return model.text;
120
+ }
121
+ }
122
+ /** Native canvas mechanism for DrawingML `<a:prstGeom>` shapes. */
123
+ const presetShapeMechanism = defineCanvasMechanism({
124
+ key: "preset-shape",
125
+ role: "canvas",
126
+ emit: emitShapeModel,
127
+ paint: paintShapeModel,
128
+ import: presetShapeImportHandler
129
+ });
130
+ /** Native canvas mechanism for DrawingML `<a:custGeom>` shapes. */
131
+ const customGeometryShapeMechanism = defineCanvasMechanism({
132
+ key: "custom-geometry-shape",
133
+ role: "canvas",
134
+ emit: emitShapeModel,
135
+ paint: paintShapeModel,
136
+ import: customGeometryShapeImportHandler
137
+ });
138
+ /** Shape module independently validates input, encapsulates bound state, and emits native PresentationML objects. */
139
+ const shapeCapability = {
140
+ declaration: "shape",
141
+ codegen: shapeCodegen,
142
+ mechanisms: [
143
+ presetShapeMechanism,
144
+ customGeometryShapeMechanism,
145
+ solidFillMechanism,
146
+ gradientFillMechanism,
147
+ imageFillMechanism
148
+ ],
149
+ bind(input, context) {
150
+ const unknown = Object.keys(input.props).find((key) => key !== "children" && !allowedParameters.includes(key));
151
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Shape contains unsupported parameter ${unknown}`);
152
+ const requestedName = parseOptionalName(input.props["name"]);
153
+ const morphKey = parseMorphKey(input.props["morphKey"]);
154
+ const link = parseLinkTarget(input.props["link"]);
155
+ const declaredX = input.props["x"];
156
+ const declaredY = input.props["y"];
157
+ if (declaredX !== void 0) validateCoordinate(declaredX, "x");
158
+ if (declaredY !== void 0) validateCoordinate(declaredY, "y");
159
+ if (input.props["width"] !== void 0) validateSize(input.props["width"], "width");
160
+ if (input.props["height"] !== void 0) validateSize(input.props["height"], "height");
161
+ const textProp = input.props["text"];
162
+ if (textProp !== void 0 && typeof textProp !== "string") throw new CapabilityError("invalid-text", "Shape.text must be a string");
163
+ if (textProp !== void 0 && input.children.length > 0) throw new CapabilityError("conflicting-text-content", "Shape.text and Shape children text cannot be declared simultaneously");
164
+ const hasText = typeof textProp === "string" && textProp !== "" || textProp === void 0 && input.children.length > 0;
165
+ const allowedStyleKeys = new Set(hasText ? shapeStyleKeys : shapeStyleKeys.filter((key) => !textStyleKeys.has(key) && !paddingStyleKeys.includes(key)));
166
+ const contract = parseCapabilityLayoutContract({
167
+ nativeKind: "sp",
168
+ props: input.props,
169
+ allowedStyleKeys,
170
+ allowPadding: hasText,
171
+ path: context.path
172
+ });
173
+ const insets = hasText ? textInsets(input.props["style"]) : {
174
+ top: 0,
175
+ right: 0,
176
+ bottom: 0,
177
+ left: 0
178
+ };
179
+ const textChildren = shapeTextContent(input);
180
+ const rawTextStyle = shapeTextStyle(input.props);
181
+ const effectiveTextStyle = {
182
+ ...rawTextStyle,
183
+ verticalAlign: rawTextStyle["verticalAlign"] ?? "middle"
184
+ };
185
+ const { paragraphs, style: parsedTextStyle } = hasText ? parseTextContent(textChildren, effectiveTextStyle, context.theme, { slideNumber: context.slideNumber }, "Shape.style") : {
186
+ paragraphs: [],
187
+ style: parseTextContent([], {}, context.theme, { slideNumber: context.slideNumber }, "Shape.style").style
188
+ };
189
+ const visualStyle = { ...record(input.props["style"]) };
190
+ const geometry = input.props["geometry"];
191
+ const flipH = input.props["flipH"];
192
+ const flipV = input.props["flipV"];
193
+ const fill = input.props["fill"];
194
+ const explicitText = typeof textProp === "string" ? textProp : void 0;
195
+ const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
196
+ const motionProps = {
197
+ ...input.props["enter"] !== void 0 ? { enter: input.props["enter"] } : {},
198
+ ...input.props["emphasis"] !== void 0 ? { emphasis: input.props["emphasis"] } : {},
199
+ ...input.props["motion"] !== void 0 ? { motion: input.props["motion"] } : {}
200
+ };
201
+ resolveVisualModel({
202
+ theme: context.theme,
203
+ style: visualStyle,
204
+ box: {
205
+ x: 0,
206
+ y: 0,
207
+ width: 100,
208
+ height: 100
209
+ },
210
+ ...geometry !== void 0 ? { geometry } : {},
211
+ ...flipH !== void 0 ? { flipH } : {},
212
+ ...flipV !== void 0 ? { flipV } : {},
213
+ ...fill !== void 0 ? { fill } : {}
214
+ });
215
+ const declaredWidth = contract.width;
216
+ const declaredHeight = contract.height;
217
+ const hasFixedSize = typeof declaredWidth === "number" && typeof declaredHeight === "number";
218
+ const native = {
219
+ ...morphKey === void 0 ? {} : { morphKey },
220
+ ...requestedName === void 0 ? {} : { hasExplicitName: true },
221
+ ...link === void 0 ? {} : { link }
222
+ };
223
+ return {
224
+ contract,
225
+ ...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
226
+ measureLayout(request) {
227
+ if (!hasText || paragraphs.length === 0) return {
228
+ minContentWidth: 0,
229
+ minContentHeight: 0
230
+ };
231
+ const width = request.availableWidth ?? declaredWidth;
232
+ const innerWidth = request.availableWidth !== void 0 ? request.availableWidth : typeof width === "number" ? Math.max(0, width - insets.left - insets.right) : void 0;
233
+ try {
234
+ const measured = measureTextLayoutFromParagraphs(paragraphs, parsedTextStyle, innerWidth);
235
+ const baseline = parsedTextStyle.verticalAlign === "top" ? measured.baseline ?? "unavailable" : "unavailable";
236
+ return {
237
+ ...measured,
238
+ baseline
239
+ };
240
+ } catch (error) {
241
+ if (hasFixedSize && error instanceof CapabilityError && error.code === "font-measurement-unavailable") return { baseline: "unavailable" };
242
+ throw error;
243
+ }
244
+ },
245
+ resolve(resolveContext) {
246
+ const box = resolveContext.layoutBox === void 0 ? {
247
+ x: validateCoordinate(declaredX, "x"),
248
+ y: validateCoordinate(declaredY, "y"),
249
+ width: validateSize(declaredWidth, "width"),
250
+ height: validateSize(declaredHeight, "height")
251
+ } : {
252
+ x: validateCoordinate(resolveContext.layoutBox.x, "x"),
253
+ y: validateCoordinate(resolveContext.layoutBox.y, "y"),
254
+ width: validateSize(resolveContext.layoutBox.width, "width"),
255
+ height: validateSize(resolveContext.layoutBox.height, "height")
256
+ };
257
+ const visual = resolveVisualModel({
258
+ theme: resolveContext.theme,
259
+ style: visualStyle,
260
+ box,
261
+ ...geometry === void 0 ? {} : { geometry },
262
+ ...flipH === void 0 ? {} : { flipH },
263
+ ...flipV === void 0 ? {} : { flipV },
264
+ ...fill === void 0 ? {} : { fill }
265
+ });
266
+ const geometryName = visual.geometry.kind === "custom" ? "custom" : visual.geometry.name;
267
+ let resolvedText;
268
+ if (hasText && paragraphs.length > 0) {
269
+ const { textRect } = evaluateGeometry(visual.geometry, box);
270
+ resolvedText = resolveTextBody(paragraphs, parsedTextStyle, resolveContext.theme, parsedTextStyle.verticalAlign ?? "middle", {
271
+ width: Math.max(0, textRect.width - insets.left - insets.right),
272
+ height: Math.max(0, textRect.height - insets.top - insets.bottom),
273
+ insets
274
+ }, "text-box");
275
+ }
276
+ const name = resolveContext.morphName ?? requestedName ?? `Shape ${resolveContext.id - 1}`;
277
+ const annotations = motionAnnotations(motionProps, {
278
+ kind: "shape",
279
+ name,
280
+ ...authorId === void 0 ? {} : { authorId },
281
+ textBody: resolvedText !== void 0,
282
+ filled: fill !== void 0 || visualStyle["backgroundColor"] !== void 0 || visualStyle["backgroundImage"] !== void 0,
283
+ solidFilled: (fill ?? visualStyle["backgroundColor"]) !== void 0 && (fill ?? visualStyle["backgroundColor"]) !== "none" && visualStyle["backgroundImage"] === void 0,
284
+ box,
285
+ rotationDegrees: visual.rotate,
286
+ hasBackground: fill !== void 0 || visualStyle["backgroundColor"] !== void 0 || visualStyle["backgroundImage"] !== void 0 || visualStyle["borderColor"] !== void 0 || typeof visualStyle["borderWidth"] === "number" && visualStyle["borderWidth"] > 0,
287
+ ...resolvedText === void 0 ? {} : { paragraphCount: resolvedText.paragraphCount }
288
+ });
289
+ let escapedName;
290
+ try {
291
+ escapedName = xmlEscape(name);
292
+ } catch {
293
+ throw new CapabilityError("invalid-xml-character", "Shape.name contains characters not allowed in XML 1.0");
294
+ }
295
+ const warnings = [...visual.warnings, ...resolvedText?.warnings ?? []];
296
+ const resolvedModel = {
297
+ escapedName,
298
+ visual,
299
+ text: resolvedText === void 0 ? { kind: "none" } : {
300
+ kind: "body",
301
+ body: resolvedText,
302
+ insets,
303
+ verticalAlign: parsedTextStyle.verticalAlign ?? "middle"
304
+ }
305
+ };
306
+ const transform = {
307
+ box,
308
+ angle: visual.rotate,
309
+ flipH: visual.flipH,
310
+ flipV: visual.flipV
311
+ };
312
+ return {
313
+ observation: {
314
+ id: resolveContext.id,
315
+ kind: "shape",
316
+ name,
317
+ geometry: geometryName,
318
+ box,
319
+ ...resolvedText === void 0 ? explicitText === void 0 ? {} : { text: explicitText } : { text: resolvedText.text }
320
+ },
321
+ transform,
322
+ extensions: [],
323
+ ...warnings.length === 0 ? {} : { warnings },
324
+ ...annotations.length === 0 ? {} : { annotations },
325
+ ...resolvedText === void 0 ? {} : { resourceClaims: resolvedText.resourceClaims },
326
+ emit(emitContext) {
327
+ return resolvedModel.visual.geometry.kind === "custom" ? customGeometryShapeMechanism.emit(resolvedModel, emitContext) : presetShapeMechanism.emit(resolvedModel, emitContext);
328
+ },
329
+ paint(paintContext) {
330
+ return resolvedModel.visual.geometry.kind === "custom" ? customGeometryShapeMechanism.paint(resolvedModel, paintContext) : presetShapeMechanism.paint(resolvedModel, paintContext);
331
+ }
332
+ };
333
+ }
334
+ };
335
+ }
336
+ };
337
+ export { blockArc, customGeometryShapeMechanism, linearGradient, path, preset, presetShapeMechanism, radialGradient, shapeCapability, shapeStyleKeys };