@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,4 @@
1
+ import { BuildError, CapabilityError } from "./diagnostics.js";
2
+ import { createResolver } from "./resolve.js";
3
+ import { buildOptionsSchema, diagnosticSchema, diagnosticSeveritySchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets } from "./stage-options.js";
4
+ export { BuildError, CapabilityError, buildOptionsSchema, createResolver, diagnosticSchema, diagnosticSeveritySchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets };
@@ -0,0 +1,13 @@
1
+ import { CapabilityError } from "./diagnostics.js";
2
+ import { authorIdSchema } from "./author-ids.js";
3
+ import { linkTargetSchema, parseLinkTarget, slideBackgroundSchema, slideFooterValueSchema, slideNumberValueSchema } from "./author-schemas.js";
4
+ import { createMorphScope, getMorphKeyLabel, isMorphKey } from "./morph.js";
5
+ import { footerPlaceholdersSchema, headerFooterSchema } from "./masters.js";
6
+ import { customGeometrySchema, geometryAdjustKeySchema, geometryAdjustSchema, geometrySchema, presetGeometryNameSchema, presetGeometryTuple } from "./geometry-schemas.js";
7
+ import { layoutStyleSchema } from "./layout-schemas.js";
8
+ import "./stage-options.js";
9
+ import { applyFormatColorTransforms, assertValidLang, bcp47LangSchema, colorValueSchema, defaultColorMap, defaultTheme, defineTheme, fontOptionsSchema, fontSchema, isFont, isTheme, linearGradientSchema, radialGradientSchema, schemeColorNameSchema, shadowSchema, textStyleFrom, textStyleKeys, textStyleSchema, themeScopeSchema, validateTextStyle, visualStyleSchema } from "./theme.js";
10
+ import { masterTextStyleCategoryForRole, matchLayoutPlaceholderKey, matchMasterPlaceholderSpec, nativePlaceholderRefSchema, placeholderRoleSchema, placeholderStyleSchema, textListSchema } from "./placeholders.js";
11
+ import { paddingStyleKeys } from "./block-flex-layout.js";
12
+ import { layoutStyleKeys, parseCapabilityLayoutContract } from "./layout.js";
13
+ export { CapabilityError, applyFormatColorTransforms, assertValidLang, authorIdSchema, bcp47LangSchema, colorValueSchema, createMorphScope, customGeometrySchema, defaultColorMap, defaultTheme, defineTheme, fontOptionsSchema, fontSchema, footerPlaceholdersSchema, geometryAdjustKeySchema, geometryAdjustSchema, geometrySchema, getMorphKeyLabel, headerFooterSchema, isFont, isMorphKey, isTheme, layoutStyleKeys, layoutStyleSchema, linearGradientSchema, linkTargetSchema, masterTextStyleCategoryForRole, matchLayoutPlaceholderKey, matchMasterPlaceholderSpec, nativePlaceholderRefSchema, paddingStyleKeys, parseCapabilityLayoutContract, parseLinkTarget, placeholderRoleSchema, placeholderStyleSchema, presetGeometryNameSchema, presetGeometryTuple, radialGradientSchema, schemeColorNameSchema, shadowSchema, slideBackgroundSchema, slideFooterValueSchema, slideNumberValueSchema, textListSchema, textStyleFrom, textStyleKeys, textStyleSchema, themeScopeSchema, validateTextStyle, visualStyleSchema };
@@ -0,0 +1,15 @@
1
+ // ../core/dist/declaration.js
2
+ function isDeclarationNode(child) {
3
+ return typeof child === "object" && child !== null && "props" in child && "children" in child;
4
+ }
5
+ /** Author-visible identity used in diagnostic labels; the scoped author id is the only identity. */
6
+ function declarationIdentity(props) {
7
+ return props["id"];
8
+ }
9
+ /** Diagnostic label for a child declaration, matching the existing build path vocabulary. */
10
+ function componentLabel(node, index) {
11
+ const identity = declarationIdentity(node.props);
12
+ const label = typeof identity === "string" && identity.trim() !== "" ? identity : String(index + 1);
13
+ return `${node.type}[${label}]`;
14
+ }
15
+ export { componentLabel, declarationIdentity, isDeclarationNode };
@@ -0,0 +1,21 @@
1
+ // ../core/dist/diagnostics.js
2
+ var BuildError = class extends Error {
3
+ diagnostics;
4
+ constructor(diagnostics) {
5
+ super(diagnostics.map((diagnostic) => `${diagnostic.path}: ${diagnostic.message}`).join("\n"));
6
+ this.name = "BuildError";
7
+ this.diagnostics = Object.freeze(diagnostics.map((diagnostic) => Object.freeze({ ...diagnostic })));
8
+ }
9
+ };
10
+ var CapabilityError = class extends Error {
11
+ code;
12
+ path;
13
+ /** Subpath relative to the native object triggering the capability, facilitating localization of cell declarations inside the object. */
14
+ constructor(code, message, path) {
15
+ super(message);
16
+ this.name = "CapabilityError";
17
+ this.code = code;
18
+ this.path = path;
19
+ }
20
+ };
21
+ export { BuildError, CapabilityError };
@@ -0,0 +1,13 @@
1
+ // ../core/dist/document-internals.js
2
+ /**
3
+ * Operation keys shared by the editable document and the React host adapter.
4
+ *
5
+ * The adapter must insert, reorder, and replace complete JSX declarations without exposing those
6
+ * reconciliation operations as author API. These symbols are internal to the core package and are
7
+ * not re-exported by the public document entry.
8
+ */
9
+ const replaceDeclarationProps = Symbol("pptxdk.replaceDeclarationProps");
10
+ const insertDeclarationChild = Symbol("pptxdk.insertDeclarationChild");
11
+ const removeDeclarationChild = Symbol("pptxdk.removeDeclarationChild");
12
+ const setDeclarationText = Symbol("pptxdk.setDeclarationText");
13
+ export { insertDeclarationChild, removeDeclarationChild, replaceDeclarationProps, setDeclarationText };
@@ -0,0 +1,408 @@
1
+ import "./author-ids.js";
2
+ import "./author-schemas.js";
3
+ import { isSlideLayoutDefinition } from "./masters.js";
4
+ import "./layout-schemas.js";
5
+ import { insertDeclarationChild, removeDeclarationChild, replaceDeclarationProps } from "./document-internals.js";
6
+ import { snapshotValue } from "./input-values.js";
7
+ import "./theme.js";
8
+ // ../core/dist/document.js
9
+ var _a;
10
+ var _b;
11
+ function isRecord(value) {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
14
+ function declarationChild(item) {
15
+ if (typeof item === "string") return Object.freeze({
16
+ type: "#text",
17
+ text: item
18
+ });
19
+ if (item instanceof CommonNode) return item;
20
+ throw new TypeError("Rich text content must be a string or an editable document node");
21
+ }
22
+ function requirePatchObject(value, label) {
23
+ if (!isRecord(value)) throw new TypeError(`${label} must be an object`);
24
+ }
25
+ function normalizeProps(props) {
26
+ const copy = {};
27
+ for (const [key, value] of Object.entries(props)) {
28
+ if (key === "children" || value === void 0) continue;
29
+ Object.defineProperty(copy, key, {
30
+ configurable: false,
31
+ enumerable: true,
32
+ value: snapshotValue(value),
33
+ writable: false
34
+ });
35
+ }
36
+ return Object.freeze(copy);
37
+ }
38
+ /**
39
+ * Common editable document node shared by command authoring and the React handoff.
40
+ *
41
+ * The node exposes a read-only declaration view to the formal build. Author mutations go through
42
+ * `set`, `style`, and structure operations so parent ownership, value isolation, and update timing
43
+ * stay in one place. Declaration getters return fresh isolated values; live nodes keep identity.
44
+ */
45
+ var CommonNode = class {
46
+ type;
47
+ kind;
48
+ /** Page-affiliated declarations are reached below hidden canvas parents by the formal build. */
49
+ pageAffiliated;
50
+ #props;
51
+ #children = [];
52
+ #childrenView = Object.freeze([]);
53
+ #parent;
54
+ #owner;
55
+ constructor(kind, type, props = {}, options = {}) {
56
+ this.kind = kind;
57
+ this.type = type;
58
+ this.pageAffiliated = options.pageAffiliated === true;
59
+ this.#props = normalizeProps(props);
60
+ if (kind === "deck") this.#owner = this;
61
+ }
62
+ /** Isolated declaration values for the formal build; mutating the returned value cannot edit the node. */
63
+ get props() {
64
+ return snapshotValue(this.#props);
65
+ }
66
+ /** Author id declared on this node, ignoring non-string values rejected by the formal build. */
67
+ get id() {
68
+ const value = this.#props["id"];
69
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
70
+ }
71
+ /** Current parent container, or undefined while detached. */
72
+ get parent() {
73
+ return this.#parent;
74
+ }
75
+ /** Scoped author query rooted at this node; it searches children and stops at the next named scope. */
76
+ get query() {
77
+ return new AuthorQuery(this);
78
+ }
79
+ /** Read-only child declaration view; node entries keep their editable identity. */
80
+ get children() {
81
+ return this.#childrenView;
82
+ }
83
+ /**
84
+ * Adapter-only complete declaration replacement for one React commit.
85
+ *
86
+ * React commits all current JSX props, so absent fields must disappear instead of surviving from a
87
+ * previous commit as they would under the author-facing single-level update. Values still pass
88
+ * through the same field-level input snapshot as construction.
89
+ */
90
+ [replaceDeclarationProps](props) {
91
+ this.#props = normalizeProps(props);
92
+ }
93
+ /**
94
+ * Adapter-only insertion or same-document reordering during React reconciliation.
95
+ *
96
+ * React may reposition an attached host instance with `insertBefore`; author `append` remains
97
+ * strict and the adapter reaches this operation explicitly. Text entries are accepted so rich-text
98
+ * containers can be reconciled in place without rebuilding their content.
99
+ */
100
+ [insertDeclarationChild](child, before) {
101
+ if (before === child) return;
102
+ if (child instanceof _a) {
103
+ if (child === this) throw new Error("Cannot attach a node inside its own descendant tree");
104
+ if (child.#parent === this) {
105
+ const index = this.#children.indexOf(child);
106
+ if (index !== -1) this.#children.splice(index, 1);
107
+ } else {
108
+ this.assertCanInsert(child, true);
109
+ const previousParent = child.#parent;
110
+ if (previousParent !== void 0) previousParent.#detach(child);
111
+ const owner = this.#owner;
112
+ if (owner !== void 0) child.#assignOwner(owner);
113
+ child.#parent = this;
114
+ }
115
+ } else {
116
+ const index = this.#children.indexOf(child);
117
+ if (index !== -1) this.#children.splice(index, 1);
118
+ }
119
+ const index = before === void 0 ? -1 : this.#children.indexOf(before);
120
+ if (index === -1) this.#children.push(child);
121
+ else this.#children.splice(index, 0, child);
122
+ this.#refreshChildren();
123
+ }
124
+ /** Adapter-only removal during React reconciliation; author removal remains `remove()`. */
125
+ [removeDeclarationChild](child) {
126
+ this.#detach(child);
127
+ }
128
+ /** Applies an ordinary property update; `style` and `children` use their dedicated operations. */
129
+ set(patch) {
130
+ const record = patch;
131
+ requirePatchObject(record, "set() patch");
132
+ if ("style" in record || "children" in record) throw new TypeError("set() cannot update style or children; use style() and structural operations");
133
+ const next = { ...this.#props };
134
+ for (const [key, value] of Object.entries(record)) if (value === void 0) delete next[key];
135
+ else next[key] = snapshotValue(value);
136
+ this.#props = Object.freeze(next);
137
+ return this;
138
+ }
139
+ /** Applies a single-level local style update; nested values replace and undefined removes a local declaration. */
140
+ style(patch) {
141
+ const record = patch;
142
+ requirePatchObject(record, "style() patch");
143
+ const next = { ...isRecord(this.#props["style"]) ? this.#props["style"] : {} };
144
+ for (const [key, value] of Object.entries(record)) if (value === void 0) delete next[key];
145
+ else next[key] = snapshotValue(value);
146
+ this.#props = Object.freeze({
147
+ ...this.#props,
148
+ style: Object.freeze(next)
149
+ });
150
+ return this;
151
+ }
152
+ /** Detaches this node while retaining its document ownership, mirroring explicit removal semantics. */
153
+ remove() {
154
+ const parent = this.#parent;
155
+ if (parent !== void 0) parent.#detach(this);
156
+ return this;
157
+ }
158
+ /** Moves a node in the same document or attaches a detached node, preserving identity. */
159
+ moveTo(parent, before) {
160
+ if (!(parent instanceof CommonContainer)) throw new TypeError("moveTo() target must be an editable container");
161
+ if (before !== void 0 && before.#parent !== parent) throw new Error("before must be a node that is a direct child of the target container");
162
+ if (before === this) return this;
163
+ parent.assertCanInsert(this, true);
164
+ const previousParent = this.#parent;
165
+ if (previousParent !== void 0) previousParent.#detach(this);
166
+ parent.insertNode(this, before);
167
+ return this;
168
+ }
169
+ #refreshChildren() {
170
+ this.#childrenView = Object.freeze([...this.#children]);
171
+ }
172
+ #detach(child) {
173
+ const index = this.#children.indexOf(child);
174
+ if (index === -1) return;
175
+ this.#children.splice(index, 1);
176
+ if (child instanceof _a) child.#parent = void 0;
177
+ this.#refreshChildren();
178
+ }
179
+ #ownerConflict(owner) {
180
+ if (this.#owner !== void 0 && this.#owner !== owner) return true;
181
+ return this.#children.some((child) => child instanceof _a && child.#ownerConflict(owner));
182
+ }
183
+ #assignOwner(owner) {
184
+ if (this.#owner === void 0) this.#owner = owner;
185
+ for (const child of this.#children) if (child instanceof _a) child.#assignOwner(owner);
186
+ }
187
+ assertCanInsert(child, allowAttached = false) {
188
+ if (child === this) throw new Error("Cannot attach a node inside its own descendant tree");
189
+ for (let ancestor = this.#parent; ancestor !== void 0; ancestor = ancestor.#parent) if (ancestor === child) throw new Error("Cannot attach a node inside its own descendant tree");
190
+ if (!allowAttached && child.#parent !== void 0) throw new Error("Node is already attached; use moveTo() for an explicit same-document move");
191
+ const owner = this.#owner;
192
+ if (owner !== void 0 && child.#ownerConflict(owner)) throw new Error("Cannot attach a node owned by another document");
193
+ }
194
+ insertNode(child, before) {
195
+ this.assertCanInsert(child);
196
+ if (before !== void 0 && before.#parent !== this) throw new Error("before must be a node that is a direct child of the target container");
197
+ const owner = this.#owner;
198
+ if (owner !== void 0) child.#assignOwner(owner);
199
+ child.#parent = this;
200
+ const index = before === void 0 ? this.#children.length : this.#children.indexOf(before);
201
+ this.#children.splice(index, 0, child);
202
+ this.#refreshChildren();
203
+ }
204
+ insertRichTextItems(items, replace) {
205
+ const next = items.map((item) => declarationChild(item));
206
+ const seen = /* @__PURE__ */ new Set();
207
+ for (const child of next) {
208
+ if (seen.has(child)) throw new Error("The same node cannot be attached twice");
209
+ seen.add(child);
210
+ if (child instanceof _a) this.assertCanInsert(child);
211
+ }
212
+ const owner = this.#owner;
213
+ if (replace) {
214
+ for (const child of this.#children) if (child instanceof _a) child.#parent = void 0;
215
+ this.#children = [];
216
+ }
217
+ for (const child of next) {
218
+ if (child instanceof _a) {
219
+ child.#parent = this;
220
+ if (owner !== void 0) child.#assignOwner(owner);
221
+ }
222
+ this.#children.push(child);
223
+ }
224
+ this.#refreshChildren();
225
+ }
226
+ };
227
+ _a = CommonNode;
228
+ /** Editable structural container: deck, slide, section, box, and annotation-only containers. */
229
+ var CommonContainer = class extends CommonNode {
230
+ append(...children) {
231
+ const seen = /* @__PURE__ */ new Set();
232
+ for (const child of children) {
233
+ if (!(child instanceof CommonNode)) throw new TypeError("append() accepts editable document nodes only");
234
+ if (seen.has(child)) throw new Error("The same node cannot be attached twice");
235
+ seen.add(child);
236
+ this.assertCanInsert(child);
237
+ }
238
+ for (const child of children) this.insertNode(child);
239
+ return this;
240
+ }
241
+ };
242
+ /** Rich-text container whose children may also be literal text. */
243
+ var RichTextContainer = class extends CommonContainer {
244
+ append(...items) {
245
+ this.insertRichTextItems(items, false);
246
+ return this;
247
+ }
248
+ /** Replaces all rich-text content atomically after validating every new item. */
249
+ content(...items) {
250
+ this.insertRichTextItems(items, true);
251
+ return this;
252
+ }
253
+ };
254
+ /** Explicit failures raised by scoped author queries instead of returning unchecked nodes. */
255
+ var AuthorQueryError = class extends Error {
256
+ code;
257
+ constructor(code, message) {
258
+ super(message);
259
+ this.code = code;
260
+ this.name = "AuthorQueryError";
261
+ }
262
+ };
263
+ function assertAuthorId(id) {
264
+ if (typeof id !== "string" || id.trim() === "") throw new AuthorQueryError("invalid-id", "Author id must be a non-empty string");
265
+ }
266
+ function authorIdOf(node) {
267
+ const value = node.props["id"];
268
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
269
+ }
270
+ function authorPath(node) {
271
+ const segments = [];
272
+ for (let current = node; current !== void 0; current = current.parent) {
273
+ if (current.parent === void 0 && current.kind === "deck") {
274
+ segments.unshift("deck");
275
+ continue;
276
+ }
277
+ const id = authorIdOf(current);
278
+ segments.unshift(id === void 0 ? current.kind : `${current.kind}[${id}]`);
279
+ }
280
+ return segments.join("/");
281
+ }
282
+ /**
283
+ * Author-facing locator over the live editable document.
284
+ *
285
+ * A query is scoped to one node. Lookups traverse anonymous layout nodes but stop at the next node
286
+ * declaring an author id, so callers descend explicitly through named scopes. Pages always declare
287
+ * their author id and act as the root author scope. Returned `.node` values are the same editable
288
+ * instances the document holds; they are never build observations.
289
+ */
290
+ var AuthorQuery = class {
291
+ #node;
292
+ constructor(node) {
293
+ this.#node = node;
294
+ }
295
+ /** Editable node at this query scope. */
296
+ get node() {
297
+ return this.#node;
298
+ }
299
+ /** Readable path derived from the current parent chain and declared author ids. */
300
+ get path() {
301
+ return authorPath(this.#node);
302
+ }
303
+ /** Returns the single editable node named `id` directly in this scope. */
304
+ getNode(id) {
305
+ assertAuthorId(id);
306
+ return this.#one(id, "getNode").node;
307
+ }
308
+ /** Returns a scoped query handle for the single node named `id`, enabling stepwise lookups. */
309
+ get(id) {
310
+ assertAuthorId(id);
311
+ return this.#one(id, "get");
312
+ }
313
+ /** Lists every node named `id` in this scope; duplicates remain visible to callers before build validation. */
314
+ getAll(id) {
315
+ assertAuthorId(id);
316
+ return Object.freeze(this.#matches(id).map((match) => new _b(match)));
317
+ }
318
+ /**
319
+ * Returns the node named `id` after checking the caller's type predicate.
320
+ *
321
+ * Missing, ambiguous, and type-mismatched results throw `AuthorQueryError` with distinct codes so
322
+ * callers never need an unchecked assertion to reach an editable capability node.
323
+ */
324
+ getAs(id, guard) {
325
+ const match = this.#one(id, "getAs").node;
326
+ if (!guard(match)) throw new AuthorQueryError("type-mismatch", `Author id ${JSON.stringify(id)} does not match the expected node type`);
327
+ return match;
328
+ }
329
+ #one(id, operation) {
330
+ assertAuthorId(id);
331
+ const matches = this.#matches(id);
332
+ if (matches.length === 0) throw new AuthorQueryError("missing-id", `No author node found for id ${JSON.stringify(id)} in ${this.path}`);
333
+ if (matches.length > 1) throw new AuthorQueryError("ambiguous-id", `Author id ${JSON.stringify(id)} is duplicated in ${this.path}`);
334
+ const [match] = matches;
335
+ if (match === void 0) throw new AuthorQueryError("missing-id", `${operation} could not resolve author id ${JSON.stringify(id)}`);
336
+ return new _b(match);
337
+ }
338
+ #matches(id) {
339
+ const matches = [];
340
+ const visit = (parent) => {
341
+ for (const child of parent.children) {
342
+ if (!(child instanceof CommonNode)) continue;
343
+ const childId = authorIdOf(child);
344
+ if (childId === id) matches.push(child);
345
+ else if (childId === void 0) visit(child);
346
+ }
347
+ };
348
+ visit(this.#node);
349
+ return matches;
350
+ }
351
+ };
352
+ _b = AuthorQuery;
353
+ /** Editable SlideLayout node owned by a SlideMaster. */
354
+ var SlideLayoutContainer = class extends CommonContainer {};
355
+ /** Editable Slide node exposing named placeholder lookup alongside slide styling. */
356
+ var SlideContainer = class extends CommonContainer {
357
+ /** Finds a bound placeholder node on this slide by its layout placeholder key. */
358
+ placeholder(key) {
359
+ for (const child of this.children) if (child instanceof CommonNode && child.props["placeholder"] === key) return child;
360
+ }
361
+ };
362
+ /** Editable SlideMaster node owning its SlideLayouts in declaration order. */
363
+ var SlideMasterContainer = class extends CommonContainer {
364
+ /** Native theme bound to this master (shared by object identity across masters when reused). */
365
+ get theme() {
366
+ return this.props["theme"];
367
+ }
368
+ /** Direct SlideLayout children owned by this master in `<p:sldLayoutIdLst>` order. */
369
+ get layouts() {
370
+ return Object.freeze(this.children.filter((child) => child instanceof CommonNode && child.kind === "slide-layout"));
371
+ }
372
+ };
373
+ /** Editable Deck root node exposing its explicit SlideMasters. */
374
+ var DeckContainer = class extends CommonContainer {
375
+ /** Direct SlideMaster children owned by this deck in `<p:sldMasterIdLst>` order. */
376
+ get masters() {
377
+ return Object.freeze(this.children.filter((child) => child instanceof CommonNode && child.kind === "slide-master"));
378
+ }
379
+ };
380
+ /** Creates the editable Deck node used by both React host expansion and command authoring. */
381
+ function createDeckNode(props) {
382
+ return new DeckContainer("deck", "deck", props);
383
+ }
384
+ /** Creates an editable SlideMaster node used by both React host expansion and command authoring. */
385
+ function createSlideMasterNode(props = {}) {
386
+ return new SlideMasterContainer("slide-master", "slide-master", props);
387
+ }
388
+ /** Creates an editable SlideLayout node from inline props or a shared `defineSlideLayout` definition. */
389
+ function createSlideLayoutNode(propsOrDefinition = {}) {
390
+ if (isSlideLayoutDefinition(propsOrDefinition)) return new SlideLayoutContainer("slide-layout", "slide-layout", {
391
+ ...propsOrDefinition.props,
392
+ layout: propsOrDefinition
393
+ });
394
+ if (isRecord(propsOrDefinition) && isSlideLayoutDefinition(propsOrDefinition["layout"])) return new SlideLayoutContainer("slide-layout", "slide-layout", {
395
+ ...propsOrDefinition["layout"].props,
396
+ ...propsOrDefinition
397
+ });
398
+ return new SlideLayoutContainer("slide-layout", "slide-layout", propsOrDefinition);
399
+ }
400
+ /** Creates the editable Slide node used by both React host expansion and command authoring. */
401
+ function createSlideNode(props) {
402
+ return new SlideContainer("slide", "slide", props);
403
+ }
404
+ /** Creates the editable Section node used by both React host expansion and command authoring. */
405
+ function createSectionNode(props) {
406
+ return new CommonContainer("section", "section", props);
407
+ }
408
+ export { AuthorQuery, AuthorQueryError, CommonContainer, CommonNode, DeckContainer, RichTextContainer, SlideContainer, SlideLayoutContainer, SlideMasterContainer, createDeckNode, createSectionNode, createSlideLayoutNode, createSlideMasterNode, createSlideNode };