@officedk/pptxdk 0.0.0-stage → 0.2.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 (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build-zrZuX4fK.d.ts +3 -0
  3. package/dist/build.d.ts +35 -0
  4. package/dist/build.js +128 -0
  5. package/dist/capabilities/dist/all.js +34 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +84 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +32 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +142 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +79 -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 +2403 -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 +1088 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1119 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -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 +192 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +592 -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 +60 -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 +168 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +119 -0
  38. package/dist/capabilities/dist/font/font-engine.js +834 -0
  39. package/dist/capabilities/dist/font/font-import.js +766 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +72 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +74 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +41 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +649 -0
  46. package/dist/capabilities/dist/group/group-xml.js +8 -0
  47. package/dist/capabilities/dist/group/group.js +260 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +164 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +244 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +984 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +147 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +552 -0
  57. package/dist/capabilities/dist/line/line-codegen.js +89 -0
  58. package/dist/capabilities/dist/line/line-declaration.js +72 -0
  59. package/dist/capabilities/dist/line/line-elements.js +12 -0
  60. package/dist/capabilities/dist/line/line-import.js +504 -0
  61. package/dist/capabilities/dist/line/line-xml.js +9 -0
  62. package/dist/capabilities/dist/line/line.js +331 -0
  63. package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
  64. package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
  65. package/dist/capabilities/dist/masters/masters.js +250 -0
  66. package/dist/capabilities/dist/motion/motion-api.js +757 -0
  67. package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
  68. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  69. package/dist/capabilities/dist/motion/motion-import.js +1568 -0
  70. package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
  71. package/dist/capabilities/dist/motion/motion-query.js +423 -0
  72. package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
  73. package/dist/capabilities/dist/motion/motion.js +1617 -0
  74. package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
  75. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  76. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  77. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  78. package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
  79. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  80. package/dist/capabilities/dist/notes/notes.js +194 -0
  81. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
  82. package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
  83. package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
  84. package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
  85. package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
  86. package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
  87. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  88. package/dist/capabilities/dist/shape/shape-import.js +628 -0
  89. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  90. package/dist/capabilities/dist/shape/shape.js +320 -0
  91. package/dist/capabilities/dist/shared/geometry.js +1681 -0
  92. package/dist/capabilities/dist/shared/identity.js +205 -0
  93. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  94. package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
  95. package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
  96. package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
  97. package/dist/capabilities/dist/shared/text-schemas.js +241 -0
  98. package/dist/capabilities/dist/shared/text-service.js +2252 -0
  99. package/dist/capabilities/dist/shared/visual.js +1197 -0
  100. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  101. package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
  102. package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
  103. package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
  104. package/dist/capabilities/dist/table/table-codegen.js +125 -0
  105. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  106. package/dist/capabilities/dist/table/table-elements.js +27 -0
  107. package/dist/capabilities/dist/table/table-import.js +606 -0
  108. package/dist/capabilities/dist/table/table-schemas.js +334 -0
  109. package/dist/capabilities/dist/table/table-xml.js +30 -0
  110. package/dist/capabilities/dist/table/table.js +739 -0
  111. package/dist/capabilities/dist/text/text-codegen.js +198 -0
  112. package/dist/capabilities/dist/text/text-declaration.js +27 -0
  113. package/dist/capabilities/dist/text/text-elements.js +54 -0
  114. package/dist/capabilities/dist/text/text-import.js +1224 -0
  115. package/dist/capabilities/dist/text/text-xml.js +9 -0
  116. package/dist/capabilities/dist/text/text.js +320 -0
  117. package/dist/capabilities/dist/transition/transition-api.js +136 -0
  118. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  119. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  120. package/dist/capabilities/dist/transition/transition.js +260 -0
  121. package/dist/capability-BbKW9w4O.d.ts +2131 -0
  122. package/dist/cli.js +20 -0
  123. package/dist/codegen/dist/assets.js +79 -0
  124. package/dist/codegen/dist/codegen.js +691 -0
  125. package/dist/codegen/dist/identifiers.js +203 -0
  126. package/dist/codegen/dist/index.js +3 -0
  127. package/dist/codegen/dist/printer.js +143 -0
  128. package/dist/codegen/dist/types.js +77 -0
  129. package/dist/core/dist/author-ids.js +51 -0
  130. package/dist/core/dist/author-schemas.js +330 -0
  131. package/dist/core/dist/block-flex-layout.js +801 -0
  132. package/dist/core/dist/build.js +4 -0
  133. package/dist/core/dist/capability.js +15 -0
  134. package/dist/core/dist/declaration.js +16 -0
  135. package/dist/core/dist/diagnostics.js +353 -0
  136. package/dist/core/dist/document-internals.js +26 -0
  137. package/dist/core/dist/document.js +417 -0
  138. package/dist/core/dist/font-seal.js +204 -0
  139. package/dist/core/dist/geometry-schemas.js +256 -0
  140. package/dist/core/dist/grid-layout.js +449 -0
  141. package/dist/core/dist/host.js +40 -0
  142. package/dist/core/dist/index.js +15 -0
  143. package/dist/core/dist/input-values.js +61 -0
  144. package/dist/core/dist/layout-protocol.js +61 -0
  145. package/dist/core/dist/layout-schemas.js +201 -0
  146. package/dist/core/dist/layout.js +340 -0
  147. package/dist/core/dist/masters.js +194 -0
  148. package/dist/core/dist/morph.js +30 -0
  149. package/dist/core/dist/placeholders.js +275 -0
  150. package/dist/core/dist/query.js +190 -0
  151. package/dist/core/dist/resolution.js +12 -0
  152. package/dist/core/dist/resolve.js +2246 -0
  153. package/dist/core/dist/stage-options.js +300 -0
  154. package/dist/core/dist/theme.js +1023 -0
  155. package/dist/core/dist/transform-geometry.js +72 -0
  156. package/dist/document-41spD7bq.d.ts +1350 -0
  157. package/dist/emit/dist/emit.js +957 -0
  158. package/dist/emit/dist/index.js +5 -0
  159. package/dist/emit/dist/ooxml.js +661 -0
  160. package/dist/emit/dist/shape-tree.js +12 -0
  161. package/dist/import/dist/alternate-content.js +54 -0
  162. package/dist/import/dist/diagnostics.js +157 -0
  163. package/dist/import/dist/fonts.js +309 -0
  164. package/dist/import/dist/import.js +513 -0
  165. package/dist/import/dist/index.js +16 -0
  166. package/dist/import/dist/masters.js +1293 -0
  167. package/dist/import/dist/mechanism.js +10 -0
  168. package/dist/import/dist/namespaces.js +61 -0
  169. package/dist/import/dist/notes-masters.js +300 -0
  170. package/dist/import/dist/opc.js +233 -0
  171. package/dist/import/dist/resources.js +166 -0
  172. package/dist/import/dist/sections.js +139 -0
  173. package/dist/import/dist/themes.js +777 -0
  174. package/dist/import/dist/visual.js +821 -0
  175. package/dist/import/dist/xml-fragments.js +277 -0
  176. package/dist/import/dist/xml-reader.js +267 -0
  177. package/dist/index-1ag7U9Jt.d.ts +63 -0
  178. package/dist/index-BEwhk7c8.d.ts +72 -0
  179. package/dist/index-cK2KtukZ.d.ts +161 -0
  180. package/dist/index-v77CTJev.d.ts +55 -0
  181. package/dist/index.d.ts +8 -0
  182. package/dist/index.js +82 -0
  183. package/dist/node.d.ts +53 -0
  184. package/dist/node.js +225 -0
  185. package/dist/pptxdk/src/cli-commands.js +907 -0
  186. package/dist/pptxdk/src/compose.js +53 -0
  187. package/dist/pptxdk/src/slide.js +9 -0
  188. package/dist/preview/dist/index.js +342 -0
  189. package/dist/preview/dist/options.js +40 -0
  190. package/dist/preview/dist/svg-guard.js +1089 -0
  191. package/dist/preview.d.ts +12 -0
  192. package/dist/preview.js +29 -0
  193. package/dist/react/dist/append.js +66 -0
  194. package/dist/react/dist/document-adapter.js +404 -0
  195. package/dist/react/dist/elements.js +82 -0
  196. package/dist/react/dist/from-vanilla.js +57 -0
  197. package/dist/react/dist/index.js +89 -0
  198. package/dist/react/dist/mount.js +34 -0
  199. package/dist/react/dist/reconciler.js +290 -0
  200. package/dist/react.d.ts +235 -0
  201. package/dist/react.js +31 -0
  202. package/dist/transition-6n8GZxSg.d.ts +9 -0
  203. package/dist/vanilla.d.ts +4 -0
  204. package/dist/vanilla.js +15 -0
  205. package/package.json +79 -3
  206. package/README.md +0 -3
@@ -0,0 +1,161 @@
1
+ import { masterTextStyleCategoryForRole, resolvePlaceholderBoxFromLayers } from "../../../core/dist/placeholders.js";
2
+ import "../../../core/dist/capability.js";
3
+ // ../capabilities/dist/shared/style-inheritance.js
4
+ function replaceWhenDeclared(inherited, localValue, isDeclaredLocally) {
5
+ return isDeclaredLocally && localValue !== void 0 ? localValue : inherited;
6
+ }
7
+ function levelRule() {
8
+ return {
9
+ freeContainer: "inherit",
10
+ placeholderLayer: "levelStyle",
11
+ apply: replaceWhenDeclared
12
+ };
13
+ }
14
+ function bodyRule(freeContainer) {
15
+ return {
16
+ freeContainer,
17
+ placeholderLayer: "bodyPr",
18
+ apply: replaceWhenDeclared
19
+ };
20
+ }
21
+ function spPrRule() {
22
+ return {
23
+ freeContainer: "localOnly",
24
+ placeholderLayer: "spPr",
25
+ apply: replaceWhenDeclared
26
+ };
27
+ }
28
+ const sharedStyleRules = Object.freeze({
29
+ fontFamily: levelRule(),
30
+ eastAsianFontFamily: levelRule(),
31
+ fontSize: levelRule(),
32
+ fontWeight: levelRule(),
33
+ fontStyle: levelRule(),
34
+ color: levelRule(),
35
+ letterSpacing: levelRule(),
36
+ textTransform: levelRule(),
37
+ textDecoration: levelRule(),
38
+ textShadow: {
39
+ freeContainer: "inherit",
40
+ placeholderLayer: "levelStyle",
41
+ apply(inherited, localValue, isDeclaredLocally) {
42
+ if (!isDeclaredLocally || localValue === void 0) return inherited;
43
+ return localValue === "none" ? void 0 : localValue;
44
+ }
45
+ },
46
+ lang: levelRule(),
47
+ lineHeight: levelRule(),
48
+ align: levelRule(),
49
+ spacingAfter: levelRule(),
50
+ verticalAlign: bodyRule("inherit"),
51
+ textWrap: bodyRule("inherit"),
52
+ padding: bodyRule("localOnly"),
53
+ paddingTop: bodyRule("localOnly"),
54
+ paddingRight: bodyRule("localOnly"),
55
+ paddingBottom: bodyRule("localOnly"),
56
+ paddingLeft: bodyRule("localOnly"),
57
+ background: spPrRule(),
58
+ border: spPrRule(),
59
+ borderRadius: spPrRule(),
60
+ opacity: spPrRule(),
61
+ boxShadow: spPrRule(),
62
+ softEdge: spPrRule(),
63
+ rotate: spPrRule(),
64
+ flipH: spPrRule(),
65
+ flipV: spPrRule()
66
+ });
67
+ /** True iff `key` is an own defined declaration on `record`, honoring explicit `undefined` removal. */
68
+ function hasLocalDeclaration(record, key) {
69
+ return record !== void 0 && Object.hasOwn(record, key) && record[key] !== void 0;
70
+ }
71
+ /** Collects the subset of `keys` explicitly declared with defined values on `record`. */
72
+ function localDeclaredKeySet(record, keys) {
73
+ const result = /* @__PURE__ */ new Set();
74
+ if (record === void 0) return result;
75
+ for (const key of keys) if (hasLocalDeclaration(record, key)) result.add(key);
76
+ return result;
77
+ }
78
+ function levelStyleEntry(styles, levelIndex0) {
79
+ if (styles === void 0) return void 0;
80
+ return styles[Math.min(9, Math.max(1, levelIndex0 + 1))];
81
+ }
82
+ function applyLayer(accumulator, source, layerFilter) {
83
+ if (source === void 0) return;
84
+ for (const [key, rawRule] of Object.entries(sharedStyleRules)) {
85
+ const rule = rawRule;
86
+ if (layerFilter !== "all" && rule.placeholderLayer !== layerFilter) continue;
87
+ if (!hasLocalDeclaration(source, key)) continue;
88
+ const next = rule.apply(accumulator[key], source[key], true);
89
+ if (next === void 0) delete accumulator[key];
90
+ else accumulator[key] = next;
91
+ }
92
+ }
93
+ /**
94
+ * Evaluates Path B placeholder container defaults (`bodyPr` + level-0 base text properties):
95
+ * Master Theme -> Master txStyles -> Master Ph -> Layout Ph -> Slide local style.
96
+ * Note: Deck.style and Slide.style are intentionally excluded.
97
+ */
98
+ function resolvePlaceholderBaseTextStyle(placeholder, slideLocalStyle) {
99
+ const result = {};
100
+ const role = placeholder.layoutPlaceholder?.type ?? placeholder.nativeRef.type;
101
+ const category = masterTextStyleCategoryForRole(role);
102
+ const masterTxLevel1 = levelStyleEntry(placeholder.masterTextStyles?.[category], 0);
103
+ const masterPhStyle = placeholder.masterPlaceholder?.style;
104
+ const masterPhLevel1 = levelStyleEntry(placeholder.masterPlaceholder?.listStyles, 0);
105
+ const layoutPhStyle = placeholder.layoutPlaceholder?.style;
106
+ const layoutPhLevel1 = levelStyleEntry(placeholder.layoutPlaceholder?.listStyles, 0);
107
+ applyLayer(result, masterTxLevel1, "levelStyle");
108
+ applyLayer(result, masterPhStyle, "all");
109
+ applyLayer(result, masterPhLevel1, "levelStyle");
110
+ applyLayer(result, layoutPhStyle, "all");
111
+ applyLayer(result, layoutPhLevel1, "levelStyle");
112
+ applyLayer(result, slideLocalStyle, "all");
113
+ return result;
114
+ }
115
+ /**
116
+ * Evaluates level-specific paragraph/run defaults for a bound placeholder at `levelIndex0` (0..8),
117
+ * cascading Master txStyles -> Master Ph -> Layout Ph -> Slide local style -> P/Span local style.
118
+ */
119
+ function resolvePlaceholderLevelTextStyle(placeholder, levelIndex0, slideLocalStyle) {
120
+ const result = {};
121
+ const role = placeholder.layoutPlaceholder?.type ?? placeholder.nativeRef.type;
122
+ const category = masterTextStyleCategoryForRole(role);
123
+ const masterTxLevel = levelStyleEntry(placeholder.masterTextStyles?.[category], levelIndex0);
124
+ const masterPhLevel = levelStyleEntry(placeholder.masterPlaceholder?.listStyles, levelIndex0);
125
+ const layoutPhLevel = levelStyleEntry(placeholder.layoutPlaceholder?.listStyles, levelIndex0);
126
+ applyLayer(result, masterTxLevel, "levelStyle");
127
+ applyLayer(result, placeholder.masterPlaceholder?.style, "levelStyle");
128
+ applyLayer(result, masterPhLevel, "levelStyle");
129
+ applyLayer(result, placeholder.layoutPlaceholder?.style, "levelStyle");
130
+ applyLayer(result, layoutPhLevel, "levelStyle");
131
+ applyLayer(result, slideLocalStyle, "levelStyle");
132
+ const resolvedList = layoutPhLevel?.list ?? masterPhLevel?.list ?? masterTxLevel?.list;
133
+ if (resolvedList !== void 0) result["list"] = resolvedList;
134
+ return result;
135
+ }
136
+ /**
137
+ * Evaluates visual (`spPr`) style overrides on a bound placeholder along Path B
138
+ * without absorbing Deck.style or Slide.style.
139
+ */
140
+ function resolvePlaceholderVisualStyle(placeholder, slideLocalStyle) {
141
+ const result = {};
142
+ applyLayer(result, placeholder.masterPlaceholder?.style, "spPr");
143
+ applyLayer(result, placeholder.layoutPlaceholder?.style, "spPr");
144
+ applyLayer(result, slideLocalStyle, "spPr");
145
+ return result;
146
+ }
147
+ /** Resolves effective box coordinates for a bound placeholder plus slide-local geometry tracking. */
148
+ function resolvePlaceholderGeometry(placeholder, props) {
149
+ const style = typeof props["style"] === "object" && props["style"] !== null && !Array.isArray(props["style"]) ? props["style"] : void 0;
150
+ const hasLocalStyleKey = (key) => style !== void 0 && hasLocalDeclaration(style, key);
151
+ const hasLocalBoxOverride = hasLocalStyleKey("left") || hasLocalStyleKey("top") || hasLocalStyleKey("right") || hasLocalStyleKey("bottom") || hasLocalStyleKey("inset") || hasLocalStyleKey("width") || hasLocalStyleKey("height");
152
+ return {
153
+ ...resolvePlaceholderBoxFromLayers([
154
+ placeholder.masterPlaceholder,
155
+ placeholder.layoutPlaceholder,
156
+ props
157
+ ], placeholder.slideDimensions),
158
+ hasLocalBoxOverride
159
+ };
160
+ }
161
+ export { hasLocalDeclaration, localDeclaredKeySet, resolvePlaceholderBaseTextStyle, resolvePlaceholderGeometry, resolvePlaceholderLevelTextStyle, resolvePlaceholderVisualStyle, sharedStyleRules };
@@ -0,0 +1,241 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { authorIdSchema } from "../../../core/dist/author-ids.js";
3
+ import { layoutStyleShape, nonNegativeLayoutSpacingSchema } from "../../../core/dist/layout-schemas.js";
4
+ import { textStyleShape, validateTextStyle, visualStyleShape } from "../../../core/dist/theme.js";
5
+ import { nativePlaceholderRefSchema, textListSchema } from "../../../core/dist/placeholders.js";
6
+ import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
7
+ import "../../../core/dist/capability.js";
8
+ import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
9
+ import "../../../emit/dist/index.js";
10
+ import { motionPropsShape } from "../motion/motion-schemas.js";
11
+ import { optionalNameSchema } from "./identity.js";
12
+ import { morphKeySchema } from "./morph-api.js";
13
+ import { z } from "zod";
14
+ // ../capabilities/dist/shared/text-schemas.js
15
+ function isRecord(value) {
16
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17
+ }
18
+ const baselineShiftPattern = /^(-?\d+(?:\.\d+)?)%$/u;
19
+ /** Parses a DrawingML ST_Percentage baseline shift string into non-zero integer thousandths of a percent. */
20
+ function parseBaselineShiftThousandths(value) {
21
+ const match = baselineShiftPattern.exec(value);
22
+ if (match === null) return void 0;
23
+ const pct = Number(match[1]);
24
+ if (!Number.isFinite(pct)) return void 0;
25
+ const thousandths = Math.round(pct * 1e3);
26
+ if (thousandths === 0 || thousandths < -2147483648 || thousandths > 2147483647) return;
27
+ return thousandths;
28
+ }
29
+ const baselineShiftSchema = z.string().regex(baselineShiftPattern).refine((value) => parseBaselineShiftThousandths(value) !== void 0, "baselineShift must be a non-zero finite percentage within DrawingML ST_Percentage range");
30
+ const runStyleObjectSchema = z.strictObject({
31
+ fontFamily: textStyleShape.fontFamily,
32
+ eastAsianFontFamily: textStyleShape.eastAsianFontFamily,
33
+ fontSize: textStyleShape.fontSize,
34
+ fontWeight: textStyleShape.fontWeight,
35
+ fontStyle: textStyleShape.fontStyle,
36
+ color: textStyleShape.color,
37
+ letterSpacing: textStyleShape.letterSpacing,
38
+ textTransform: textStyleShape.textTransform,
39
+ textDecoration: textStyleShape.textDecoration,
40
+ textShadow: textStyleShape.textShadow,
41
+ lang: textStyleShape.lang,
42
+ baselineShift: baselineShiftSchema.optional()
43
+ });
44
+ const rawRunStyleSchema = runStyleObjectSchema.readonly();
45
+ /** Run-level style schema shared by `Span`, `Sup`, `Sub`, and `SlideNumber`. */
46
+ const runStyleSchema = rawRunStyleSchema;
47
+ const paragraphStyleObjectSchema = runStyleObjectSchema.omit({ baselineShift: true }).extend({
48
+ lineHeight: textStyleShape.lineHeight,
49
+ align: textStyleShape.align,
50
+ spacingAfter: textStyleShape.spacingAfter,
51
+ list: textListSchema.optional()
52
+ });
53
+ const rawParagraphStyleSchema = paragraphStyleObjectSchema.readonly();
54
+ /** Paragraph-level style schema shared by `P` across Text, Shape, Table Cell, and Notes. */
55
+ const paragraphStyleSchema = rawParagraphStyleSchema;
56
+ const runStyleKeys = new Set(Object.keys(runStyleObjectSchema.shape));
57
+ const paragraphStyleKeys = new Set(Object.keys(paragraphStyleObjectSchema.shape));
58
+ /** Coordinate bounds for text box `x` and `y` in logical pixels. */
59
+ const textCoordinateSchema = z.number().finite().min(-1e6).max(1e6);
60
+ /** Positive pixel dimension bounds convertible to DrawingML EMU. */
61
+ const textPositiveSizeSchema = z.number().finite().positive().refine((value) => {
62
+ const extent = pxToEmu(value);
63
+ return extent >= 1 && extent <= 2147483647;
64
+ }, "Converted value exceeds shape dimension range");
65
+ const maximumWritableInsetEmu = 2147483647;
66
+ const isWritableInsetPx = (value) => {
67
+ const converted = pxToEmu(value);
68
+ return Number.isSafeInteger(converted) && converted >= 0 && converted <= maximumWritableInsetEmu;
69
+ };
70
+ const nonNegativeInsetSchema = z.number().finite().nonnegative().refine(isWritableInsetPx, "Inset must be within DrawingML EMU range");
71
+ const spacingValuesWithinEmuRange = (spacing) => typeof spacing === "number" ? isWritableInsetPx(spacing) : spacing.every(isWritableInsetPx);
72
+ const textPaddingValueSchema = nonNegativeLayoutSpacingSchema.refine(spacingValuesWithinEmuRange, "Inset must be within DrawingML EMU range");
73
+ const textInsetsStyleSchema = z.object({
74
+ padding: textPaddingValueSchema.optional(),
75
+ paddingTop: nonNegativeInsetSchema.optional(),
76
+ paddingRight: nonNegativeInsetSchema.optional(),
77
+ paddingBottom: nonNegativeInsetSchema.optional(),
78
+ paddingLeft: nonNegativeInsetSchema.optional()
79
+ }).readonly();
80
+ const textBoxStyleObjectSchema = z.strictObject({
81
+ ...layoutStyleShape,
82
+ ...textStyleShape,
83
+ ...visualStyleShape
84
+ });
85
+ const textBoxStyleKeys = Object.keys(textBoxStyleObjectSchema.shape);
86
+ const rawTextBoxStyleSchema = textBoxStyleObjectSchema.readonly();
87
+ const textBoxStyleSchema = rawTextBoxStyleSchema;
88
+ const textAuthorPropsObjectSchema = z.strictObject({
89
+ id: authorIdSchema.optional(),
90
+ name: optionalNameSchema.optional(),
91
+ placeholder: z.string().optional(),
92
+ nativePlaceholder: nativePlaceholderRefSchema.optional(),
93
+ morphKey: morphKeySchema.optional(),
94
+ link: linkTargetSchema.optional(),
95
+ style: rawTextBoxStyleSchema.optional(),
96
+ ...motionPropsShape
97
+ });
98
+ const textAuthorPropsKeys = Object.keys(textAuthorPropsObjectSchema.shape);
99
+ textAuthorPropsObjectSchema.readonly();
100
+ const textBoxAllowedParamKeys = /* @__PURE__ */ new Set([...textAuthorPropsKeys, "children"]);
101
+ const paragraphAuthorPropsObjectSchema = z.strictObject({
102
+ id: authorIdSchema.optional(),
103
+ style: rawParagraphStyleSchema.optional(),
104
+ ...motionPropsShape
105
+ });
106
+ const paragraphAuthorPropsKeys = Object.keys(paragraphAuthorPropsObjectSchema.shape);
107
+ paragraphAuthorPropsObjectSchema.readonly();
108
+ const spanAuthorPropsObjectSchema = z.strictObject({
109
+ id: authorIdSchema.optional(),
110
+ style: rawRunStyleSchema.optional()
111
+ });
112
+ const spanAuthorPropsKeys = Object.keys(spanAuthorPropsObjectSchema.shape);
113
+ spanAuthorPropsObjectSchema.readonly();
114
+ const slideNumberAuthorPropsKeys = spanAuthorPropsKeys;
115
+ const supAuthorPropsKeys = spanAuthorPropsKeys;
116
+ const subAuthorPropsKeys = spanAuthorPropsKeys;
117
+ /** Parses and validates a paragraph list declaration, preserving DrawingML error codes. */
118
+ function parseTextList(value) {
119
+ if (!isRecord(value) || value["type"] !== "bullet" && value["type"] !== "number") throw new CapabilityError("invalid-list", "list.type must be bullet or number");
120
+ const parsed = textListSchema.safeParse(value);
121
+ if (!parsed.success) {
122
+ const issue = parsed.error.issues[0];
123
+ if (issue?.code === "unrecognized_keys") throw new CapabilityError("unknown-style-property", `list contains unimplemented style ${issue.keys[0]}`);
124
+ const field = issue?.path[0];
125
+ if (field === "level") throw new CapabilityError("invalid-list", "list.level must be an integer between 0 and 8");
126
+ if (field === "character") throw new CapabilityError("invalid-list", "Bullet must be a single Unicode character");
127
+ if (field === "style") throw new CapabilityError("invalid-list", "Numbering style currently only supports arabicPeriod");
128
+ if (field === "startAt") throw new CapabilityError("invalid-list", "Numbering start value must be an integer between 1 and 32767");
129
+ throw new CapabilityError("invalid-list", issue?.message ?? "Invalid list");
130
+ }
131
+ if (parsed.data.type === "bullet") {
132
+ const character = parsed.data.character ?? "•";
133
+ try {
134
+ xmlEscape(character);
135
+ } catch {
136
+ throw new CapabilityError("invalid-xml-character", "Bullet contains characters not allowed in XML 1.0");
137
+ }
138
+ }
139
+ return parsed.data;
140
+ }
141
+ function checkedStyleObject(value, allowedKeys, label) {
142
+ if (value === void 0) return {};
143
+ if (!isRecord(value)) throw new CapabilityError("invalid-style", `${label} must be an object`);
144
+ const unknown = Object.keys(value).find((key) => !allowedKeys.has(key));
145
+ if (unknown !== void 0) throw new CapabilityError("unknown-style-property", `${label} contains unimplemented style ${unknown}`);
146
+ return value;
147
+ }
148
+ /** Validates run-level style declarations using shared core text schemas. */
149
+ function parseRunStyle(value, label = "Span.style") {
150
+ const { baselineShift, ...textProps } = checkedStyleObject(value, runStyleKeys, label);
151
+ validateTextStyle(textProps);
152
+ if (baselineShift !== void 0) {
153
+ const parsedShift = baselineShiftSchema.safeParse(baselineShift);
154
+ if (!parsedShift.success) throw new CapabilityError("invalid-baseline-shift", "baselineShift must be a non-zero finite percentage string within DrawingML ST_Percentage range", void 0, { field: "style.baselineShift" });
155
+ return {
156
+ ...textProps,
157
+ baselineShift: parsedShift.data
158
+ };
159
+ }
160
+ return textProps;
161
+ }
162
+ /** Validates paragraph-level style declarations including `list`. */
163
+ function parseParagraphStyle(value, label = "P.style") {
164
+ const { list, ...textProps } = checkedStyleObject(value, paragraphStyleKeys, label);
165
+ validateTextStyle(textProps);
166
+ const parsedList = list === void 0 ? void 0 : parseTextList(list);
167
+ return {
168
+ ...textProps,
169
+ ...parsedList === void 0 ? {} : { list: parsedList }
170
+ };
171
+ }
172
+ /** Validates text box padding/inset declarations via Zod and converts edges to pixel numbers. */
173
+ function parseTextInsets(value) {
174
+ const style = isRecord(value) ? value : {};
175
+ const candidate = {
176
+ ...style["padding"] === void 0 ? {} : { padding: style["padding"] },
177
+ ...style["paddingTop"] === void 0 ? {} : { paddingTop: style["paddingTop"] },
178
+ ...style["paddingRight"] === void 0 ? {} : { paddingRight: style["paddingRight"] },
179
+ ...style["paddingBottom"] === void 0 ? {} : { paddingBottom: style["paddingBottom"] },
180
+ ...style["paddingLeft"] === void 0 ? {} : { paddingLeft: style["paddingLeft"] }
181
+ };
182
+ const parsed = textInsetsStyleSchema.safeParse(candidate);
183
+ if (!parsed.success) {
184
+ const issue = parsed.error.issues[0];
185
+ if (issue?.path[0] === "padding") {
186
+ const rawPadding = candidate.padding;
187
+ const isTupleOrNumber = typeof rawPadding === "number" || Array.isArray(rawPadding) && (rawPadding.length === 2 || rawPadding.length === 4);
188
+ throw new CapabilityError("invalid-text-insets", isTupleOrNumber ? "padding inset must be a finite non-negative pixel number" : "padding must be a number, a 2-tuple, or a 4-tuple");
189
+ }
190
+ const edge = String(issue?.path[0] ?? "padding").replace("padding", "");
191
+ const label = edge === "" ? "padding" : edge.toLowerCase();
192
+ throw new CapabilityError("invalid-text-insets", `${label} inset must be a finite non-negative pixel number`);
193
+ }
194
+ const raw = parsed.data.padding;
195
+ let edges = {
196
+ top: 0,
197
+ right: 0,
198
+ bottom: 0,
199
+ left: 0
200
+ };
201
+ if (typeof raw === "number") edges = {
202
+ top: raw,
203
+ right: raw,
204
+ bottom: raw,
205
+ left: raw
206
+ };
207
+ else if (Array.isArray(raw)) edges = raw.length === 2 ? {
208
+ top: raw[0],
209
+ right: raw[1],
210
+ bottom: raw[0],
211
+ left: raw[1]
212
+ } : {
213
+ top: raw[0],
214
+ right: raw[1],
215
+ bottom: raw[2],
216
+ left: raw[3]
217
+ };
218
+ return {
219
+ top: parsed.data.paddingTop ?? edges.top,
220
+ right: parsed.data.paddingRight ?? edges.right,
221
+ bottom: parsed.data.paddingBottom ?? edges.bottom,
222
+ left: parsed.data.paddingLeft ?? edges.left
223
+ };
224
+ }
225
+ /** Validates a text box coordinate (`x` or `y`) with Zod schema bounds. */
226
+ function parseTextCoordinate(value, label, path) {
227
+ const parsed = textCoordinateSchema.safeParse(value);
228
+ if (!parsed.success) throw new CapabilityError("invalid-text-box", `${label} must be a finite pixel number between -1000000 and 1000000`, path);
229
+ return parsed.data;
230
+ }
231
+ /** Validates a text box extent (`width` or `height`) with Zod schema bounds. */
232
+ function parseTextExtent(value, label, path) {
233
+ if (typeof value === "number" && Number.isFinite(value)) {
234
+ if (value === 0 || pxToEmu(value) === 0) throw new CapabilityError("invalid-text-box", `Computed ${label} is 0px; ${label} must be greater than 0px`, path);
235
+ if (value < 0 || pxToEmu(value) < 1) throw new CapabilityError("invalid-text-box", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, path);
236
+ } else throw new CapabilityError("invalid-text-box", `${label} must be a finite positive pixel number`, path);
237
+ const parsed = textPositiveSizeSchema.safeParse(value);
238
+ if (!parsed.success) throw new CapabilityError("invalid-text-box", `${label} converted value exceeds shape dimension range`, path);
239
+ return parsed.data;
240
+ }
241
+ export { baselineShiftSchema, paragraphAuthorPropsKeys, paragraphStyleKeys, paragraphStyleSchema, parseBaselineShiftThousandths, parseParagraphStyle, parseRunStyle, parseTextCoordinate, parseTextExtent, parseTextInsets, parseTextList, runStyleKeys, runStyleSchema, slideNumberAuthorPropsKeys, spanAuthorPropsKeys, subAuthorPropsKeys, supAuthorPropsKeys, textAuthorPropsKeys, textBoxAllowedParamKeys, textBoxStyleKeys, textBoxStyleSchema, textCoordinateSchema, textInsetsStyleSchema, textListSchema, textPaddingValueSchema, textPositiveSizeSchema };