@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,662 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { assertValidLang } from "../../../core/dist/theme.js";
3
+ import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
4
+ import { layoutStyleKeys, parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
5
+ import "../../../core/dist/capability.js";
6
+ import { assertXml10Characters, xmlEscape } from "../../../emit/dist/ooxml.js";
7
+ import "../../../emit/dist/index.js";
8
+ import "../../../import/dist/index.js";
9
+ import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
10
+ import { fontPresentationContributions } from "../font/font-embedding.js";
11
+ import { motionAnnotations } from "../motion/motion-api.js";
12
+ import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
13
+ import { resolvePlaceholderGeometry } from "../shared/style-inheritance.js";
14
+ import { emitTextBody, parseTextParagraphs, renderTextOutlinesSvg, resolveTextBody } from "../shared/text-service.js";
15
+ import { tableCodegen } from "./table-codegen.js";
16
+ import { tableImportHandler, tablePlaceholderImportHandler } from "./table-import.js";
17
+ import { assertAllowedTableKeys, assertTableEmuExtent, cellAllowedParameters, cellStyleKeys, parseOptionalTableId, parseTableCellBorder, parseTableCellPadding, parseTableColumns, parseTableCoordinate, parseTableMergeSpan, parseTablePositiveSize, parseTableVerticalAlign, rowAllowedParameters, rowStyleKeys, tableAllowedParameters, tableStyleKeys, tableTextStyleKeys } from "./table-schemas.js";
18
+ import { emptyTableCellXml, tableCellPropertiesXml, tableFrameXml } from "./table-xml.js";
19
+ import "./table-declaration.js";
20
+ // ../capabilities/dist/table/table.js
21
+ const maximumExtentEmu = 2147483647;
22
+ function fail(code, message, path) {
23
+ throw new CapabilityError(code, message, path);
24
+ }
25
+ function isRecord(value) {
26
+ return typeof value === "object" && value !== null && !Array.isArray(value);
27
+ }
28
+ function record(value, label, path) {
29
+ if (!isRecord(value)) fail("invalid-parameter", `${label} must be an object`, path);
30
+ return value;
31
+ }
32
+ function pathLabel(value, fallback) {
33
+ return typeof value === "string" && value.trim() !== "" ? value : fallback;
34
+ }
35
+ function color(value, label, theme, path) {
36
+ if (value === void 0) return void 0;
37
+ try {
38
+ return theme.resolveColor(value);
39
+ } catch (error) {
40
+ if (error instanceof CapabilityError) fail(error.code, `${label}: ${error.message}`, path);
41
+ throw error;
42
+ }
43
+ }
44
+ function textStyle(styleValue, label, path, additional = []) {
45
+ const style = record(styleValue ?? {}, `${label}.style`, path);
46
+ assertAllowedTableKeys(style, [...tableTextStyleKeys, ...additional], `${label}.style`, path);
47
+ if (style["lang"] !== void 0) try {
48
+ assertValidLang(style["lang"]);
49
+ } catch (error) {
50
+ if (error instanceof CapabilityError) fail(error.code, error.message, path);
51
+ throw error;
52
+ }
53
+ const textStyle = {};
54
+ for (const key of tableTextStyleKeys) {
55
+ const value = style[key];
56
+ if (value !== void 0) textStyle[key] = value;
57
+ }
58
+ parseTableVerticalAlign(style["verticalAlign"], path);
59
+ return {
60
+ textStyle,
61
+ style
62
+ };
63
+ }
64
+ function mergeTextStyle(parent, child) {
65
+ return {
66
+ ...parent,
67
+ ...child
68
+ };
69
+ }
70
+ function trackStyle(input, type, path) {
71
+ const additional = type === "table" ? layoutStyleKeys : type === "row" ? rowStyleKeys : cellStyleKeys;
72
+ return textStyle(input.props["style"], type === "table" ? "Table" : type === "row" ? "Row" : "Cell", path, additional);
73
+ }
74
+ function resolveCellBody(cell, theme, width, height, contentSized = false) {
75
+ try {
76
+ return resolveTextBody(cell.paragraphs, cell.textStyle, theme, cell.verticalAlign, {
77
+ width,
78
+ ...height === void 0 ? {} : { height },
79
+ ...contentSized ? { contentSized: true } : {}
80
+ }, "table-cell");
81
+ } catch (error) {
82
+ if (error instanceof CapabilityError) fail(error.code, error.message, cell.path);
83
+ throw error;
84
+ }
85
+ }
86
+ function identityPath(type, props, index) {
87
+ return `${type}[${pathLabel(props["id"], String(index + 1))}]`;
88
+ }
89
+ function prepareRows(input, columns, tableTextStyle, tableVerticalAlign, theme, slideNumber) {
90
+ const rows = [];
91
+ const cells = [];
92
+ const owners = /* @__PURE__ */ new Map();
93
+ for (const child of input.children) {
94
+ if (!("props" in child)) {
95
+ if (child.text.trim() !== "") fail("invalid-table-structure", "Text in Table must be placed inside Cell");
96
+ continue;
97
+ }
98
+ if (child.type !== "row") fail("invalid-table-structure", "Table can only contain Row directly");
99
+ const rowIndex = rows.length;
100
+ const rowPath = identityPath("row", child.props, rowIndex);
101
+ assertAllowedTableKeys(child.props, rowAllowedParameters, "Row", rowPath);
102
+ const rowAuthorId = parseOptionalTableId(child.props["id"], rowPath);
103
+ const rowStyle = trackStyle(child, "row", rowPath);
104
+ const heightValue = rowStyle.style["height"];
105
+ const height = heightValue === void 0 ? void 0 : parseTablePositiveSize(heightValue, "Row.style.height", rowPath);
106
+ const rowFill = color(rowStyle.style["backgroundColor"], "Row.style.backgroundColor", theme, rowPath);
107
+ const rowVerticalAlign = parseTableVerticalAlign(rowStyle.style["verticalAlign"], rowPath) ?? tableVerticalAlign;
108
+ const row = {
109
+ path: rowPath,
110
+ ...rowAuthorId === void 0 ? {} : { authorId: rowAuthorId },
111
+ ...height === void 0 ? {} : { height },
112
+ textStyle: mergeTextStyle(tableTextStyle, rowStyle.textStyle),
113
+ verticalAlign: rowVerticalAlign,
114
+ ...rowFill === void 0 ? {} : { fill: rowFill }
115
+ };
116
+ rows.push(row);
117
+ let column = 0;
118
+ let cellIndex = 0;
119
+ for (const cellChild of child.children) {
120
+ if (!("props" in cellChild)) {
121
+ if (cellChild.text.trim() !== "") fail("invalid-table-structure", "Text in Row must be placed inside Cell", rowPath);
122
+ continue;
123
+ }
124
+ if (cellChild.type !== "cell") fail("invalid-table-structure", "Row can only contain Cell directly", rowPath);
125
+ const cellPath = `${rowPath}/${identityPath("cell", cellChild.props, cellIndex)}`;
126
+ cellIndex += 1;
127
+ assertAllowedTableKeys(cellChild.props, cellAllowedParameters, "Cell", cellPath);
128
+ const cellAuthorId = parseOptionalTableId(cellChild.props["id"], cellPath);
129
+ while (owners.has(`${rowIndex}:${column}`)) column += 1;
130
+ const colSpan = parseTableMergeSpan(cellChild.props["colSpan"], "colSpan", cellPath);
131
+ const rowSpan = parseTableMergeSpan(cellChild.props["rowSpan"], "rowSpan", cellPath);
132
+ if (column + colSpan > columns.length) fail("invalid-table-merge", `Cells in row ${rowIndex + 1} exceed ${columns.length} column count`, cellPath);
133
+ if (rowIndex + rowSpan > input.children.filter((item) => "props" in item && item.type === "row").length) fail("invalid-table-merge", `rowSpan ${rowSpan} extends past the last row of the table`, cellPath);
134
+ for (let row = rowIndex; row < rowIndex + rowSpan; row += 1) for (let col = column; col < column + colSpan; col += 1) if (owners.has(`${row}:${col}`)) fail("conflicting-table-merge", "Cell merge region overlaps with an existing cell", cellPath);
135
+ const cellStyle = trackStyle(cellChild, "cell", cellPath);
136
+ const fill = color(cellStyle.style["backgroundColor"], "Cell.style.backgroundColor", theme, cellPath) ?? row.fill;
137
+ const cellVerticalAlign = parseTableVerticalAlign(cellStyle.style["verticalAlign"], cellPath) ?? rowVerticalAlign;
138
+ const border = parseTableCellBorder(cellStyle.style, (value, label, itemPath) => color(value, label, theme, itemPath), theme, cellPath);
139
+ const cellTextStyle = {
140
+ ...mergeTextStyle(row.textStyle, cellStyle.textStyle),
141
+ textWrap: "normal"
142
+ };
143
+ let parsedParagraphs;
144
+ let parsedTextStyle;
145
+ try {
146
+ const textResult = parseTextParagraphs(cellChild.children, cellTextStyle, theme, { slideNumber }, cellPath);
147
+ parsedParagraphs = textResult.paragraphs;
148
+ parsedTextStyle = textResult.style;
149
+ } catch (error) {
150
+ if (error instanceof CapabilityError) fail(error.code, error.message, cellPath);
151
+ throw error;
152
+ }
153
+ const cell = {
154
+ row: rowIndex,
155
+ column,
156
+ rowSpan,
157
+ colSpan,
158
+ path: cellPath,
159
+ ...cellAuthorId === void 0 ? {} : { authorId: cellAuthorId },
160
+ paragraphs: parsedParagraphs,
161
+ textStyle: parsedTextStyle,
162
+ verticalAlign: cellVerticalAlign,
163
+ padding: parseTableCellPadding(cellStyle.style, cellPath),
164
+ ...fill === void 0 ? {} : { fill },
165
+ ...border === void 0 ? {} : { border }
166
+ };
167
+ cells.push(cell);
168
+ for (let row = rowIndex; row < rowIndex + rowSpan; row += 1) for (let col = column; col < column + colSpan; col += 1) owners.set(`${row}:${col}`, cell);
169
+ column += colSpan;
170
+ }
171
+ }
172
+ if (rows.length === 0) fail("invalid-table-structure", "Table requires at least one row");
173
+ for (let row = 0; row < rows.length; row += 1) {
174
+ const missing = columns.findIndex((_, column) => !owners.has(`${row}:${column}`));
175
+ if (missing >= 0) fail("invalid-table-structure", `Row ${row + 1}, column ${missing + 1} is not covered by a Cell or merged cell`, rows[row]?.path);
176
+ }
177
+ return {
178
+ rows,
179
+ cells
180
+ };
181
+ }
182
+ function roundSvgNumber(value) {
183
+ const rounded = Math.round(value * 1e6) / 1e6;
184
+ return Object.is(rounded, -0) ? "0" : String(rounded);
185
+ }
186
+ function tableBorderAttributes(border) {
187
+ const w = Math.max(1, border.width);
188
+ let dashAttr = "";
189
+ switch (border.dash) {
190
+ case "solid":
191
+ dashAttr = "";
192
+ break;
193
+ case "dash":
194
+ dashAttr = ` stroke-dasharray="${roundSvgNumber(w * 4)} ${roundSvgNumber(w * 3)}"`;
195
+ break;
196
+ case "dot":
197
+ dashAttr = ` stroke-dasharray="${roundSvgNumber(w)} ${roundSvgNumber(w * 2)}"`;
198
+ break;
199
+ default: return border.dash;
200
+ }
201
+ return `fill="none" stroke="#${border.color.hex}" stroke-opacity="${roundSvgNumber(border.color.alpha ?? 1)}" stroke-width="${roundSvgNumber(border.width)}"${dashAttr}`;
202
+ }
203
+ function emitTableModel(model, emitContext) {
204
+ const { x, y, widths, heights, rows, columns, resolvedAnchors, owners, name, fontUses } = model;
205
+ const embedFonts = emitContext.options.embedFonts;
206
+ const rowsXml = rows.map((_, rowIndex) => {
207
+ const rowCells = [];
208
+ for (let column = 0; column < columns.length; column += 1) {
209
+ const entry = resolvedAnchors.get(`${rowIndex}:${column}`);
210
+ if (entry === void 0) {
211
+ const owner = owners.get(`${rowIndex}:${column}`);
212
+ const hMerge = column > owner.column ? " hMerge=\"1\"" : "";
213
+ const vMerge = rowIndex > owner.row ? " vMerge=\"1\"" : "";
214
+ const spanAttributes = [...rowIndex === owner.row && owner.rowSpan > 1 ? [`rowSpan="${owner.rowSpan}"`] : [], ...column === owner.column && owner.colSpan > 1 ? [`gridSpan="${owner.colSpan}"`] : []];
215
+ rowCells.push(`<a:tc${hMerge}${vMerge}${spanAttributes.length === 0 ? "" : ` ${spanAttributes.join(" ")}`}>${emptyTableCellXml(owner.textStyle["lang"])}</a:tc>`);
216
+ continue;
217
+ }
218
+ const { cell, body, fill } = entry;
219
+ if ((embedFonts === "full" || embedFonts === "subset") && body.missingGlyphErrors.length > 0) fail("font-missing-glyph", body.missingGlyphErrors[0], cell.path);
220
+ let emittedXml;
221
+ try {
222
+ emittedXml = emitTextBody(body, emitContext.theme, { createFieldId: emitContext.createTextFieldId }).xml;
223
+ } catch (error) {
224
+ if (error instanceof CapabilityError) fail(error.code, error.message, error.path ?? cell.path);
225
+ throw error;
226
+ }
227
+ const spanAttributes = [...cell.colSpan > 1 ? [`gridSpan="${cell.colSpan}"`] : [], ...cell.rowSpan > 1 ? [`rowSpan="${cell.rowSpan}"`] : []];
228
+ const attributes = spanAttributes.length === 0 ? "" : ` ${spanAttributes.join(" ")}`;
229
+ const properties = tableCellPropertiesXml(cell.padding, cell.verticalAlign, cell.border, fill);
230
+ rowCells.push(`<a:tc${attributes}>${emittedXml}${properties}</a:tc>`);
231
+ }
232
+ return rowCells.join("");
233
+ });
234
+ const presentationContributions = fontPresentationContributions(fontUses, embedFonts);
235
+ return {
236
+ xml: tableFrameXml(emitContext.id, xmlEscape(name), x, y, widths, heights, rowsXml, nativeLinkXml(emitContext.nativeLink), model.placeholder),
237
+ ...presentationContributions.length === 0 ? {} : { presentationContributions }
238
+ };
239
+ }
240
+ function paintTableModel(model, paintContext) {
241
+ const defs = [];
242
+ const fills = [];
243
+ const texts = [];
244
+ const borders = [];
245
+ for (const entry of model.resolvedCells) {
246
+ const { cell, box: cellBox, fill, body, hasText, hasOverflow } = entry;
247
+ if (fill !== void 0) fills.push(`<rect x="${roundSvgNumber(cellBox.x)}" y="${roundSvgNumber(cellBox.y)}" width="${roundSvgNumber(cellBox.width)}" height="${roundSvgNumber(cellBox.height)}" fill="#${fill.hex}" fill-opacity="${roundSvgNumber(fill.alpha ?? 1)}" stroke="none"/>`);
248
+ if (hasText) {
249
+ const idPrefix = `tbl-s${paintContext.slideNumber}-o${paintContext.objectId}-r${cell.row}-c${cell.column}`;
250
+ try {
251
+ const glyphs = renderTextOutlinesSvg({
252
+ paragraphs: body.paragraphs,
253
+ box: cellBox,
254
+ insets: cell.padding,
255
+ verticalAlign: cell.verticalAlign,
256
+ theme: paintContext.theme,
257
+ measuredLayout: body.measuredLayout,
258
+ idPrefix
259
+ });
260
+ if (glyphs !== "") {
261
+ if (hasOverflow) {
262
+ const clipId = `${idPrefix}-clip`;
263
+ defs.push(`<clipPath id="${clipId}" clipPathUnits="userSpaceOnUse"><rect x="${roundSvgNumber(cellBox.x)}" y="${roundSvgNumber(cellBox.y)}" width="${roundSvgNumber(cellBox.width)}" height="${roundSvgNumber(cellBox.height)}"/></clipPath>`);
264
+ texts.push(`<g clip-path="url(#${clipId})">${glyphs}</g>`);
265
+ } else texts.push(glyphs);
266
+ }
267
+ } catch (error) {
268
+ if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, error.path ?? cell.path);
269
+ throw error;
270
+ }
271
+ }
272
+ if (cell.border !== void 0) borders.push(`<rect x="${roundSvgNumber(cellBox.x)}" y="${roundSvgNumber(cellBox.y)}" width="${roundSvgNumber(cellBox.width)}" height="${roundSvgNumber(cellBox.height)}" ${tableBorderAttributes(cell.border)}/>`);
273
+ }
274
+ return { svg: `${defs.length > 0 ? `<defs>${defs.join("")}</defs>` : ""}<g>${fills.join("")}${texts.join("")}${borders.join("")}</g>` };
275
+ }
276
+ /** Shared calculation of table tracks and text dimensions used by layout measurement and table resolution. */
277
+ function tableLayoutModel(parsed, requestedWidth, theme) {
278
+ const { columns, tableStyle, rows, cells } = parsed;
279
+ const warnings = [];
280
+ const claims = [];
281
+ const warningKeys = /* @__PURE__ */ new Set();
282
+ const addTextResult = (result, path) => {
283
+ for (const warning of result.warnings) {
284
+ const key = `${path}\u0000${warning.code}\u0000${warning.message}`;
285
+ if (warningKeys.has(key)) continue;
286
+ warningKeys.add(key);
287
+ warnings.push({
288
+ ...warning,
289
+ path
290
+ });
291
+ }
292
+ claims.push(...result.resourceClaims);
293
+ };
294
+ const naturalWidths = /* @__PURE__ */ new Map();
295
+ if (columns.some((track) => track.kind === "auto" || track.kind === "fr" && requestedWidth === void 0)) for (const cell of cells) {
296
+ if (cell.colSpan !== 1) continue;
297
+ const track = columns[cell.column];
298
+ if (!(track?.kind === "auto" || track?.kind === "fr" && requestedWidth === void 0)) continue;
299
+ const measured = resolveCellBody(cell, theme, "max-content", void 0, false);
300
+ addTextResult(measured, cell.path);
301
+ if (measured.measurement === void 0 && measured.text.trim() !== "") fail("font-measurement-unavailable", "auto columns require available font metrics; provide measurement fonts or use explicit column widths", cell.path);
302
+ naturalWidths.set(cell, measured.measurement?.width ?? 0);
303
+ }
304
+ const widths = columns.map((track, index) => {
305
+ if (track.kind === "px") return track.value;
306
+ const intrinsic = Math.max(0, ...cells.filter((cell) => cell.column === index && cell.colSpan === 1).map((cell) => (naturalWidths.get(cell) ?? 0) + cell.padding.left + cell.padding.right));
307
+ return Math.max(1, intrinsic);
308
+ });
309
+ if (requestedWidth !== void 0) {
310
+ const fractionTotal = columns.reduce((sum, track) => sum + (track.kind === "fr" ? track.value : 0), 0);
311
+ const fixedWidth = widths.reduce((sum, value, index) => sum + (columns[index]?.kind === "fr" ? 0 : value), 0);
312
+ if (fractionTotal > 0) {
313
+ const free = requestedWidth - fixedWidth;
314
+ if (free >= columns.filter((track) => track.kind === "fr").length) columns.forEach((track, index) => {
315
+ if (track.kind === "fr") widths[index] = free * track.value / fractionTotal;
316
+ });
317
+ else columns.forEach((track, index) => {
318
+ if (track.kind === "fr") widths[index] = 1;
319
+ });
320
+ } else {
321
+ const baseWidth = widths.reduce((sum, value) => sum + value, 0);
322
+ if (requestedWidth > baseWidth && baseWidth > 0) widths.forEach((value, index) => {
323
+ widths[index] = value * requestedWidth / baseWidth;
324
+ });
325
+ }
326
+ const actualWidth = widths.reduce((sum, value) => sum + value, 0);
327
+ if (actualWidth > requestedWidth + .01) warnings.push({
328
+ code: "table-width-overflow",
329
+ message: `Sum of column minimum widths ${actualWidth}px exceeds declared width ${requestedWidth}px; build preserves column widths`
330
+ });
331
+ }
332
+ if (widths.map((width, index) => assertTableEmuExtent(width, `column ${index + 1} width`)).reduce((sum, value) => sum + value, 0) > maximumExtentEmu) fail("invalid-table-geometry", "Total table column width exceeds writable range");
333
+ const heights = rows.map((row) => row.height ?? 0);
334
+ const widthOf = (cell) => widths.slice(cell.column, cell.column + cell.colSpan).reduce((sum, width) => sum + width, 0);
335
+ const requiredHeight = (cell) => {
336
+ const result = resolveCellBody(cell, theme, Math.max(0, widthOf(cell) - cell.padding.left - cell.padding.right), void 0, false);
337
+ addTextResult(result, cell.path);
338
+ if (result.measurement === void 0 && result.text.trim() !== "") fail("font-measurement-unavailable", "Automatic row height requires available font metrics; provide measurement fonts or specify height on Row", cell.path);
339
+ return (result.measurement?.height ?? 0) + cell.padding.top + cell.padding.bottom;
340
+ };
341
+ for (const cell of cells) {
342
+ if (cell.rowSpan !== 1 || rows[cell.row]?.height !== void 0) continue;
343
+ heights[cell.row] = Math.max(heights[cell.row] ?? 0, requiredHeight(cell));
344
+ }
345
+ for (const cell of cells) {
346
+ if (cell.rowSpan === 1) continue;
347
+ const covered = Array.from({ length: cell.rowSpan }, (_, index) => cell.row + index);
348
+ const growable = covered.filter((row) => rows[row]?.height === void 0);
349
+ if (growable.length === 0) continue;
350
+ const currentHeight = covered.reduce((sum, row) => sum + (heights[row] ?? 0), 0);
351
+ const missing = requiredHeight(cell) - currentHeight;
352
+ if (missing <= 0) continue;
353
+ const targetRow = growable.at(-1);
354
+ if (targetRow !== void 0) heights[targetRow] = (heights[targetRow] ?? 0) + missing;
355
+ }
356
+ heights.forEach((height, index) => {
357
+ if (height <= 0) heights[index] = 1;
358
+ });
359
+ if (heights.map((height, index) => assertTableEmuExtent(height, `row ${index + 1} height`, rows[index]?.path)).reduce((sum, value) => sum + value, 0) > maximumExtentEmu) fail("invalid-table-geometry", "Total table row height exceeds writable range");
360
+ return {
361
+ columns,
362
+ tableStyle,
363
+ rows,
364
+ cells,
365
+ widths,
366
+ heights,
367
+ warnings,
368
+ warningKeys,
369
+ claims
370
+ };
371
+ }
372
+ const tableCompatiblePlaceholderRoles = /* @__PURE__ */ new Set(["tbl", "obj"]);
373
+ /** Typed native canvas mechanism connecting emit, paint, and import for `table`. */
374
+ const tableMechanism = defineCanvasMechanism({
375
+ key: "table",
376
+ role: "canvas",
377
+ emit: emitTableModel,
378
+ paint: paintTableModel,
379
+ import: tableImportHandler
380
+ });
381
+ /** Typed native canvas mechanism connecting emit, paint, and import for `table-placeholder`. */
382
+ const tablePlaceholderMechanism = defineCanvasMechanism({
383
+ key: "table-placeholder",
384
+ role: "canvas",
385
+ emit: emitTableModel,
386
+ paint: paintTableModel,
387
+ import: tablePlaceholderImportHandler
388
+ });
389
+ /** Table module independently validates row and column structure, resolving layout/cells once for emit and paint. */
390
+ const tableCapability = {
391
+ declaration: "table",
392
+ mechanisms: [tableMechanism, tablePlaceholderMechanism],
393
+ codegen: tableCodegen,
394
+ bind(input, context) {
395
+ const placeholder = context.placeholder;
396
+ if (placeholder !== void 0) {
397
+ const role = placeholder.layoutPlaceholder?.type ?? placeholder.nativeRef.type;
398
+ if (!tableCompatiblePlaceholderRoles.has(role)) fail("incompatible-placeholder-content", `Table cannot be bound to ${role} placeholder`);
399
+ }
400
+ assertAllowedTableKeys(input.props, tableAllowedParameters, "Table");
401
+ const requestedName = parseOptionalName(input.props["name"]);
402
+ const morphKey = parseMorphKey(input.props["morphKey"]);
403
+ const link = parseLinkTarget(input.props["link"]);
404
+ const allowedStyleKeys = new Set(tableStyleKeys);
405
+ const contract = parseCapabilityLayoutContract({
406
+ nativeKind: "graphicFrame",
407
+ props: input.props,
408
+ allowedStyleKeys,
409
+ allowPadding: false,
410
+ path: context.path
411
+ });
412
+ const columns = parseTableColumns(input.props["columns"]);
413
+ const tableStyle = trackStyle(input, "table");
414
+ const tableVerticalAlign = parseTableVerticalAlign(tableStyle.style["verticalAlign"]) ?? "middle";
415
+ const { rows, cells } = prepareRows(input, columns, tableStyle.textStyle, tableVerticalAlign, context.theme, context.slideNumber);
416
+ const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
417
+ const parsed = {
418
+ columns,
419
+ tableStyle,
420
+ tableVerticalAlign,
421
+ rows,
422
+ cells,
423
+ contract,
424
+ declaredX: placeholderGeometry?.x ?? input.props["x"],
425
+ declaredY: placeholderGeometry?.y ?? input.props["y"],
426
+ declaredWidth: contract.layoutStyle.width ?? input.props["width"] ?? placeholderGeometry?.width
427
+ };
428
+ const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
429
+ const motionProps = {
430
+ ...input.props["enter"] !== void 0 ? { enter: input.props["enter"] } : {},
431
+ ...input.props["emphasis"] !== void 0 ? { emphasis: input.props["emphasis"] } : {},
432
+ ...input.props["motion"] !== void 0 ? { motion: input.props["motion"] } : {}
433
+ };
434
+ const native = {
435
+ ...morphKey === void 0 ? {} : { morphKey },
436
+ ...requestedName === void 0 ? {} : { hasExplicitName: true },
437
+ ...link === void 0 ? {} : { link }
438
+ };
439
+ return {
440
+ contract,
441
+ ...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
442
+ measureLayout(request) {
443
+ const declaredSize = typeof parsed.declaredWidth === "number" ? parseTablePositiveSize(parsed.declaredWidth, "Table.width") : void 0;
444
+ const natural = tableLayoutModel(parsed, void 0, request.theme);
445
+ const naturalWidth = natural.widths.reduce((sum, width) => sum + width, 0);
446
+ const availableWidth = request.availableWidth !== void 0 && request.availableWidth > 0 ? request.availableWidth : void 0;
447
+ const requestedWidth = declaredSize ?? (availableWidth !== void 0 && (request.widthMode === "exactly" || request.widthMode === void 0 || naturalWidth > availableWidth) ? availableWidth : void 0);
448
+ const model = requestedWidth === void 0 ? natural : tableLayoutModel(parsed, requestedWidth, request.theme);
449
+ return {
450
+ width: model.widths.reduce((sum, value) => sum + value, 0),
451
+ height: model.heights.reduce((sum, value) => sum + value, 0),
452
+ minContentWidth: natural.widths.reduce((sum, value) => sum + value, 0),
453
+ minContentHeight: natural.heights.reduce((sum, value) => sum + value, 0)
454
+ };
455
+ },
456
+ resolve(resolveContext) {
457
+ const requestedWidth = resolveContext.layoutBox?.width ?? (typeof parsed.declaredWidth === "number" ? parseTablePositiveSize(parsed.declaredWidth, "Table.width") : void 0);
458
+ const model = tableLayoutModel(parsed, requestedWidth, resolveContext.theme);
459
+ const { widths } = model;
460
+ const heights = [...model.heights];
461
+ const warnings = [...model.warnings];
462
+ const claims = [...model.claims];
463
+ const fontUses = [];
464
+ const warningKeys = new Set(model.warningKeys);
465
+ const addTextResult = (result, path) => {
466
+ for (const warning of result.warnings) {
467
+ const key = `${path}\u0000${warning.code}\u0000${warning.message}`;
468
+ if (warningKeys.has(key)) continue;
469
+ warningKeys.add(key);
470
+ warnings.push({
471
+ ...warning,
472
+ path
473
+ });
474
+ }
475
+ claims.push(...result.resourceClaims);
476
+ fontUses.push(...result.fontUses.map((use) => ({
477
+ ...use,
478
+ path
479
+ })));
480
+ };
481
+ const targetHeight = resolveContext.layoutBox?.height;
482
+ if (targetHeight !== void 0) {
483
+ const naturalHeight = heights.reduce((sum, value) => sum + value, 0);
484
+ if (targetHeight > naturalHeight + .01) {
485
+ const growable = rows.flatMap((row, index) => row.height === void 0 ? [index] : []);
486
+ if (growable.length > 0) {
487
+ const extra = (targetHeight - naturalHeight) / growable.length;
488
+ for (const row of growable) heights[row] = (heights[row] ?? 0) + extra;
489
+ } else warnings.push({
490
+ code: "table-height-underflow",
491
+ message: `Sum of fixed row heights ${naturalHeight}px is less than layout height ${targetHeight}px; build preserves row heights`
492
+ });
493
+ } else if (targetHeight < naturalHeight - .01) warnings.push({
494
+ code: "table-height-overflow",
495
+ message: `Sum of row heights ${naturalHeight}px exceeds layout height ${targetHeight}px; build preserves row heights`
496
+ });
497
+ }
498
+ const x = parseTableCoordinate(resolveContext.layoutBox?.x ?? parsed.declaredX, "x");
499
+ const y = parseTableCoordinate(resolveContext.layoutBox?.y ?? parsed.declaredY, "y");
500
+ const width = widths.reduce((sum, value) => sum + value, 0);
501
+ const box = {
502
+ x,
503
+ y,
504
+ width,
505
+ height: heights.reduce((sum, value) => sum + value, 0)
506
+ };
507
+ const columnOffsets = [];
508
+ let offsetX = x;
509
+ for (const w of widths) {
510
+ columnOffsets.push(offsetX);
511
+ offsetX += w;
512
+ }
513
+ const rowOffsets = [];
514
+ let offsetY = y;
515
+ for (const h of heights) {
516
+ rowOffsets.push(offsetY);
517
+ offsetY += h;
518
+ }
519
+ const cellBoxes = /* @__PURE__ */ new Map();
520
+ for (const cell of cells) cellBoxes.set(cell, {
521
+ x: columnOffsets[cell.column] ?? x,
522
+ y: rowOffsets[cell.row] ?? y,
523
+ width: widths.slice(cell.column, cell.column + cell.colSpan).reduce((sum, value) => sum + value, 0),
524
+ height: heights.slice(cell.row, cell.row + cell.rowSpan).reduce((sum, value) => sum + value, 0)
525
+ });
526
+ const widthOf = (cell) => widths.slice(cell.column, cell.column + cell.colSpan).reduce((sum, width) => sum + width, 0);
527
+ const innerWidthOf = (cell) => Math.max(0, widthOf(cell) - cell.padding.left - cell.padding.right);
528
+ const anchors = new Map(cells.map((cell) => [`${cell.row}:${cell.column}`, cell]));
529
+ const owners = /* @__PURE__ */ new Map();
530
+ for (const cell of cells) for (let row = cell.row; row < cell.row + cell.rowSpan; row += 1) for (let column = cell.column; column < cell.column + cell.colSpan; column += 1) owners.set(`${row}:${column}`, cell);
531
+ const matrix = rows.map(() => Array.from({ length: columns.length }, () => ""));
532
+ const resolvedCells = [];
533
+ const resolvedAnchors = /* @__PURE__ */ new Map();
534
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) for (let column = 0; column < columns.length; column += 1) {
535
+ const cell = anchors.get(`${rowIndex}:${column}`);
536
+ if (cell === void 0) {
537
+ if (owners.get(`${rowIndex}:${column}`) === void 0) fail("invalid-table-structure", "Table row contains undeclared cells");
538
+ continue;
539
+ }
540
+ const innerHeight = Math.max(0, heights.slice(cell.row, cell.row + cell.rowSpan).reduce((sum, value) => sum + value, 0) - cell.padding.top - cell.padding.bottom);
541
+ const contentSized = rows.slice(cell.row, cell.row + cell.rowSpan).some((row) => row.height === void 0);
542
+ const body = resolveCellBody(cell, resolveContext.theme, innerWidthOf(cell), innerHeight, contentSized);
543
+ addTextResult(body, cell.path);
544
+ matrix[rowIndex][column] = body.text;
545
+ const rowFill = rows[cell.row]?.fill;
546
+ const fill = cell.fill ?? rowFill;
547
+ const entry = {
548
+ cell,
549
+ box: cellBoxes.get(cell),
550
+ ...fill === void 0 ? {} : { fill },
551
+ body,
552
+ hasText: cell.paragraphs.some((paragraph) => paragraph.style.list !== void 0 || paragraph.runs.some((run) => run.text.length > 0)),
553
+ hasOverflow: body.warnings.some((warning) => warning.code === "overset")
554
+ };
555
+ resolvedCells.push(entry);
556
+ resolvedAnchors.set(`${rowIndex}:${column}`, entry);
557
+ }
558
+ for (const warning of warnings) if (warning.code === "overset") warning.message = `${warning.message} (table cell preserves original content and declared dimensions)`;
559
+ const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Table ${resolveContext.id - 1}`;
560
+ try {
561
+ assertXml10Characters(name);
562
+ } catch {
563
+ fail("invalid-xml-character", "Table.name contains characters not allowed in XML 1.0");
564
+ }
565
+ const tableParts = [...rows.map((row, rowIndex) => ({
566
+ kind: "row",
567
+ ...row.authorId === void 0 ? {} : { authorId: row.authorId },
568
+ row: rowIndex,
569
+ box: {
570
+ x,
571
+ y: rowOffsets[rowIndex] ?? y,
572
+ width,
573
+ height: heights[rowIndex] ?? 0
574
+ },
575
+ text: matrix[rowIndex]?.join(" ") ?? ""
576
+ })), ...cells.map((cell) => ({
577
+ kind: "cell",
578
+ ...cell.authorId === void 0 ? {} : { authorId: cell.authorId },
579
+ row: cell.row,
580
+ column: cell.column,
581
+ rowSpan: cell.rowSpan,
582
+ colSpan: cell.colSpan,
583
+ box: cellBoxes.get(cell),
584
+ text: matrix[cell.row]?.[cell.column] ?? ""
585
+ }))];
586
+ const subParts = rows.map((row, rowIndex) => ({
587
+ ...row.authorId === void 0 ? {} : { authorId: row.authorId },
588
+ box: {
589
+ x,
590
+ y: rowOffsets[rowIndex] ?? y,
591
+ width,
592
+ height: heights[rowIndex] ?? 0
593
+ },
594
+ text: matrix[rowIndex]?.join(" ") ?? "",
595
+ parts: cells.filter((cell) => cell.row === rowIndex).map((cell) => ({
596
+ ...cell.authorId === void 0 ? {} : { authorId: cell.authorId },
597
+ box: cellBoxes.get(cell),
598
+ text: matrix[cell.row]?.[cell.column] ?? ""
599
+ }))
600
+ }));
601
+ const observation = {
602
+ columnWidths: [...widths],
603
+ rowHeights: [...heights],
604
+ cells: matrix,
605
+ merges: cells.filter((cell) => cell.colSpan > 1 || cell.rowSpan > 1).map(({ row, column, rowSpan, colSpan }) => ({
606
+ row,
607
+ column,
608
+ rowSpan,
609
+ colSpan
610
+ })),
611
+ ...tableParts.some(({ authorId }) => authorId !== void 0) ? { parts: tableParts } : {}
612
+ };
613
+ const annotations = motionAnnotations(motionProps, {
614
+ kind: "table",
615
+ name,
616
+ ...authorId === void 0 ? {} : { authorId },
617
+ textBody: true,
618
+ filled: cells.some((cell) => cell.fill !== void 0 || rows[cell.row]?.fill !== void 0),
619
+ box,
620
+ rotationDegrees: 0,
621
+ hasBackground: cells.some((cell) => cell.fill !== void 0 || rows[cell.row]?.fill !== void 0)
622
+ });
623
+ const resolvedModel = {
624
+ x,
625
+ y,
626
+ widths,
627
+ heights,
628
+ rows,
629
+ columns,
630
+ resolvedCells,
631
+ resolvedAnchors,
632
+ owners,
633
+ name,
634
+ fontUses,
635
+ ...placeholder === void 0 ? {} : { placeholder: placeholder.nativeRef }
636
+ };
637
+ const mechanism = placeholder === void 0 ? tableMechanism : tablePlaceholderMechanism;
638
+ return {
639
+ observation: {
640
+ id: resolveContext.id,
641
+ kind: "table",
642
+ name,
643
+ box,
644
+ table: observation
645
+ },
646
+ parts: subParts,
647
+ extensions: [],
648
+ ...annotations.length === 0 ? {} : { annotations },
649
+ resourceClaims: claims,
650
+ ...warnings.length === 0 ? {} : { warnings },
651
+ emit(emitContext) {
652
+ return mechanism.emit(resolvedModel, emitContext);
653
+ },
654
+ paint(paintContext) {
655
+ return mechanism.paint(resolvedModel, paintContext);
656
+ }
657
+ };
658
+ }
659
+ };
660
+ }
661
+ };
662
+ export { tableCapability, tableMechanism, tablePlaceholderMechanism };