@kywi-software/core 0.10.0 → 0.12.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 (248) hide show
  1. package/AGENT-PATTERNS.md +111 -23
  2. package/README.md +67 -0
  3. package/dist/admin/content-form.d.ts.map +1 -1
  4. package/dist/admin/content-form.js +97 -10
  5. package/dist/admin/content-form.js.map +1 -1
  6. package/dist/admin/layout-editor/component-actions.d.ts +219 -22
  7. package/dist/admin/layout-editor/component-actions.d.ts.map +1 -1
  8. package/dist/admin/layout-editor/component-actions.js +356 -36
  9. package/dist/admin/layout-editor/component-actions.js.map +1 -1
  10. package/dist/admin/layout-editor/component-fork.d.ts +224 -0
  11. package/dist/admin/layout-editor/component-fork.d.ts.map +1 -0
  12. package/dist/admin/layout-editor/component-fork.js +342 -0
  13. package/dist/admin/layout-editor/component-fork.js.map +1 -0
  14. package/dist/admin/layout-editor/editor-canvas.d.ts +28 -7
  15. package/dist/admin/layout-editor/editor-canvas.d.ts.map +1 -1
  16. package/dist/admin/layout-editor/editor-canvas.js +145 -32
  17. package/dist/admin/layout-editor/editor-canvas.js.map +1 -1
  18. package/dist/admin/layout-editor/editor-dialog.d.ts +164 -0
  19. package/dist/admin/layout-editor/editor-dialog.d.ts.map +1 -0
  20. package/dist/admin/layout-editor/editor-dialog.js +195 -0
  21. package/dist/admin/layout-editor/editor-dialog.js.map +1 -0
  22. package/dist/admin/layout-editor/editor-state.d.ts +76 -0
  23. package/dist/admin/layout-editor/editor-state.d.ts.map +1 -1
  24. package/dist/admin/layout-editor/editor-state.js +47 -1
  25. package/dist/admin/layout-editor/editor-state.js.map +1 -1
  26. package/dist/admin/layout-editor/editor.css +366 -4
  27. package/dist/admin/layout-editor/index.d.ts +10 -1
  28. package/dist/admin/layout-editor/index.d.ts.map +1 -1
  29. package/dist/admin/layout-editor/index.js +11 -1
  30. package/dist/admin/layout-editor/index.js.map +1 -1
  31. package/dist/admin/layout-editor/inline-text.d.ts +56 -4
  32. package/dist/admin/layout-editor/inline-text.d.ts.map +1 -1
  33. package/dist/admin/layout-editor/inline-text.js +134 -11
  34. package/dist/admin/layout-editor/inline-text.js.map +1 -1
  35. package/dist/admin/layout-editor/layout-editor.d.ts +58 -1
  36. package/dist/admin/layout-editor/layout-editor.d.ts.map +1 -1
  37. package/dist/admin/layout-editor/layout-editor.js +160 -190
  38. package/dist/admin/layout-editor/layout-editor.js.map +1 -1
  39. package/dist/admin/layout-editor/linked-component.d.ts +39 -0
  40. package/dist/admin/layout-editor/linked-component.d.ts.map +1 -0
  41. package/dist/admin/layout-editor/linked-component.js +42 -0
  42. package/dist/admin/layout-editor/linked-component.js.map +1 -0
  43. package/dist/admin/layout-editor/module-overlay.d.ts +36 -14
  44. package/dist/admin/layout-editor/module-overlay.d.ts.map +1 -1
  45. package/dist/admin/layout-editor/module-overlay.js +233 -25
  46. package/dist/admin/layout-editor/module-overlay.js.map +1 -1
  47. package/dist/admin/layout-editor/node-lookup.d.ts +35 -0
  48. package/dist/admin/layout-editor/node-lookup.d.ts.map +1 -1
  49. package/dist/admin/layout-editor/node-lookup.js +91 -0
  50. package/dist/admin/layout-editor/node-lookup.js.map +1 -1
  51. package/dist/admin/layout-editor/overlay-shell.d.ts.map +1 -1
  52. package/dist/admin/layout-editor/overlay-shell.js +150 -32
  53. package/dist/admin/layout-editor/overlay-shell.js.map +1 -1
  54. package/dist/admin/layout-editor/props-panel.d.ts +54 -1
  55. package/dist/admin/layout-editor/props-panel.d.ts.map +1 -1
  56. package/dist/admin/layout-editor/props-panel.js +119 -10
  57. package/dist/admin/layout-editor/props-panel.js.map +1 -1
  58. package/dist/admin/layout-editor/section-overlay.d.ts +16 -1
  59. package/dist/admin/layout-editor/section-overlay.d.ts.map +1 -1
  60. package/dist/admin/layout-editor/section-overlay.js +21 -11
  61. package/dist/admin/layout-editor/section-overlay.js.map +1 -1
  62. package/dist/admin/layout-editor/section-template-picker.d.ts +27 -1
  63. package/dist/admin/layout-editor/section-template-picker.d.ts.map +1 -1
  64. package/dist/admin/layout-editor/section-template-picker.js +71 -17
  65. package/dist/admin/layout-editor/section-template-picker.js.map +1 -1
  66. package/dist/admin/layout-editor/section-variant-container-config.js +5 -5
  67. package/dist/admin/layout-editor/section-variant-container-config.js.map +1 -1
  68. package/dist/admin/layout-editor/use-chrome-flip.d.ts +111 -11
  69. package/dist/admin/layout-editor/use-chrome-flip.d.ts.map +1 -1
  70. package/dist/admin/layout-editor/use-chrome-flip.js +233 -33
  71. package/dist/admin/layout-editor/use-chrome-flip.js.map +1 -1
  72. package/dist/admin/layout-editor/use-component-connect.d.ts +61 -0
  73. package/dist/admin/layout-editor/use-component-connect.d.ts.map +1 -0
  74. package/dist/admin/layout-editor/use-component-connect.js +292 -0
  75. package/dist/admin/layout-editor/use-component-connect.js.map +1 -0
  76. package/dist/admin/layout-editor/use-component-fork.d.ts +123 -0
  77. package/dist/admin/layout-editor/use-component-fork.d.ts.map +1 -0
  78. package/dist/admin/layout-editor/use-component-fork.js +346 -0
  79. package/dist/admin/layout-editor/use-component-fork.js.map +1 -0
  80. package/dist/admin/layout-editor/use-component-library.d.ts +94 -0
  81. package/dist/admin/layout-editor/use-component-library.d.ts.map +1 -0
  82. package/dist/admin/layout-editor/use-component-library.js +55 -0
  83. package/dist/admin/layout-editor/use-component-library.js.map +1 -0
  84. package/dist/admin/registry.d.ts +11 -2
  85. package/dist/admin/registry.d.ts.map +1 -1
  86. package/dist/admin/registry.js +40 -4
  87. package/dist/admin/registry.js.map +1 -1
  88. package/dist/admin/server.d.ts +1 -0
  89. package/dist/admin/server.d.ts.map +1 -1
  90. package/dist/admin/server.js +5 -0
  91. package/dist/admin/server.js.map +1 -1
  92. package/dist/admin/styles/admin.css +57 -1
  93. package/dist/admin/surfaces/components/component-edit.d.ts +3 -0
  94. package/dist/admin/surfaces/components/component-edit.d.ts.map +1 -0
  95. package/dist/admin/surfaces/components/component-edit.js +235 -0
  96. package/dist/admin/surfaces/components/component-edit.js.map +1 -0
  97. package/dist/admin/surfaces/components/components-data.d.ts +153 -0
  98. package/dist/admin/surfaces/components/components-data.d.ts.map +1 -0
  99. package/dist/admin/surfaces/components/components-data.js +154 -0
  100. package/dist/admin/surfaces/components/components-data.js.map +1 -0
  101. package/dist/admin/surfaces/components/components-list.d.ts +3 -0
  102. package/dist/admin/surfaces/components/components-list.d.ts.map +1 -0
  103. package/dist/admin/surfaces/components/components-list.js +196 -0
  104. package/dist/admin/surfaces/components/components-list.js.map +1 -0
  105. package/dist/admin/surfaces/components/definition-canvas.d.ts +73 -0
  106. package/dist/admin/surfaces/components/definition-canvas.d.ts.map +1 -0
  107. package/dist/admin/surfaces/components/definition-canvas.js +207 -0
  108. package/dist/admin/surfaces/components/definition-canvas.js.map +1 -0
  109. package/dist/admin/surfaces/layouts/layout-editor-client.d.ts.map +1 -1
  110. package/dist/admin/surfaces/layouts/layout-editor-client.js +14 -2
  111. package/dist/admin/surfaces/layouts/layout-editor-client.js.map +1 -1
  112. package/dist/admin/surfaces/layouts/layouts-data.d.ts +3 -14
  113. package/dist/admin/surfaces/layouts/layouts-data.d.ts.map +1 -1
  114. package/dist/admin/surfaces/layouts/layouts-data.js +4 -7
  115. package/dist/admin/surfaces/layouts/layouts-data.js.map +1 -1
  116. package/dist/admin/surfaces/layouts/layouts-list.d.ts.map +1 -1
  117. package/dist/admin/surfaces/layouts/layouts-list.js +16 -22
  118. package/dist/admin/surfaces/layouts/layouts-list.js.map +1 -1
  119. package/dist/admin/surfaces/settings/admin-features.d.ts.map +1 -1
  120. package/dist/admin/surfaces/settings/admin-features.js +1 -0
  121. package/dist/admin/surfaces/settings/admin-features.js.map +1 -1
  122. package/dist/api/bulk-routes.d.ts.map +1 -1
  123. package/dist/api/bulk-routes.js +25 -0
  124. package/dist/api/bulk-routes.js.map +1 -1
  125. package/dist/api/changeset-routes.d.ts.map +1 -1
  126. package/dist/api/changeset-routes.js +17 -3
  127. package/dist/api/changeset-routes.js.map +1 -1
  128. package/dist/api/component-routes.d.ts.map +1 -1
  129. package/dist/api/component-routes.js +228 -8
  130. package/dist/api/component-routes.js.map +1 -1
  131. package/dist/api/content-routes.d.ts.map +1 -1
  132. package/dist/api/content-routes.js +64 -0
  133. package/dist/api/content-routes.js.map +1 -1
  134. package/dist/api/feed-routes.d.ts +6 -6
  135. package/dist/api/graphql/resolvers.d.ts +4 -4
  136. package/dist/api/layout-routes.d.ts.map +1 -1
  137. package/dist/api/layout-routes.js +4 -17
  138. package/dist/api/layout-routes.js.map +1 -1
  139. package/dist/api/layout-write-guard.d.ts +80 -0
  140. package/dist/api/layout-write-guard.d.ts.map +1 -0
  141. package/dist/api/layout-write-guard.js +88 -0
  142. package/dist/api/layout-write-guard.js.map +1 -0
  143. package/dist/api/section-template-routes.d.ts.map +1 -1
  144. package/dist/api/section-template-routes.js +11 -0
  145. package/dist/api/section-template-routes.js.map +1 -1
  146. package/dist/api/translation-routes.d.ts.map +1 -1
  147. package/dist/api/translation-routes.js +8 -0
  148. package/dist/api/translation-routes.js.map +1 -1
  149. package/dist/api/version-routes.d.ts.map +1 -1
  150. package/dist/api/version-routes.js +20 -8
  151. package/dist/api/version-routes.js.map +1 -1
  152. package/dist/api/workflow-routes.d.ts.map +1 -1
  153. package/dist/api/workflow-routes.js +53 -8
  154. package/dist/api/workflow-routes.js.map +1 -1
  155. package/dist/db/analytics-queries.d.ts +3 -3
  156. package/dist/db/apply-snapshot.d.ts +75 -8
  157. package/dist/db/apply-snapshot.d.ts.map +1 -1
  158. package/dist/db/apply-snapshot.js +104 -8
  159. package/dist/db/apply-snapshot.js.map +1 -1
  160. package/dist/db/audit-queries.d.ts +12 -12
  161. package/dist/db/category-queries.d.ts +3 -3
  162. package/dist/db/changeset-audit-queries.d.ts +4 -4
  163. package/dist/db/changeset-queries.d.ts +7 -7
  164. package/dist/db/comment-queries.d.ts +8 -8
  165. package/dist/db/comment-subscription-queries.d.ts +2 -2
  166. package/dist/db/component-instance-queries.d.ts +197 -0
  167. package/dist/db/component-instance-queries.d.ts.map +1 -0
  168. package/dist/db/component-instance-queries.js +405 -0
  169. package/dist/db/component-instance-queries.js.map +1 -0
  170. package/dist/db/content-queries.d.ts.map +1 -1
  171. package/dist/db/content-queries.js +39 -2
  172. package/dist/db/content-queries.js.map +1 -1
  173. package/dist/db/extension-queries.d.ts +7 -7
  174. package/dist/db/feed-queries.d.ts +3 -3
  175. package/dist/db/index.d.ts +1 -0
  176. package/dist/db/index.d.ts.map +1 -1
  177. package/dist/db/index.js +1 -0
  178. package/dist/db/index.js.map +1 -1
  179. package/dist/db/layout-queries.d.ts +13 -1
  180. package/dist/db/layout-queries.d.ts.map +1 -1
  181. package/dist/db/layout-queries.js +52 -7
  182. package/dist/db/layout-queries.js.map +1 -1
  183. package/dist/db/locale-queries.d.ts.map +1 -1
  184. package/dist/db/locale-queries.js +0 -0
  185. package/dist/db/locale-queries.js.map +1 -1
  186. package/dist/db/media-queries.d.ts +12 -12
  187. package/dist/db/revision-queries.d.ts +3 -3
  188. package/dist/db/site-admin-queries.d.ts +2 -2
  189. package/dist/db/site-membership-queries.d.ts +3 -3
  190. package/dist/db/site-plugin-queries.d.ts +2 -2
  191. package/dist/db/site-queries.d.ts +6 -6
  192. package/dist/db/version-queries.d.ts +12 -12
  193. package/dist/db/webhook-queries.d.ts +11 -11
  194. package/dist/db/workflow-queries.d.ts +6 -6
  195. package/dist/db/workflow-queries.d.ts.map +1 -1
  196. package/dist/db/workflow-queries.js +11 -2
  197. package/dist/db/workflow-queries.js.map +1 -1
  198. package/dist/layout/comments-module.d.ts.map +1 -1
  199. package/dist/layout/comments-module.js +6 -2
  200. package/dist/layout/comments-module.js.map +1 -1
  201. package/dist/layout/component-refs.d.ts +465 -0
  202. package/dist/layout/component-refs.d.ts.map +1 -0
  203. package/dist/layout/component-refs.js +848 -0
  204. package/dist/layout/component-refs.js.map +1 -0
  205. package/dist/layout/index.d.ts +2 -1
  206. package/dist/layout/index.d.ts.map +1 -1
  207. package/dist/layout/index.js +1 -0
  208. package/dist/layout/index.js.map +1 -1
  209. package/dist/layout/module-permissions.d.ts +49 -1
  210. package/dist/layout/module-permissions.d.ts.map +1 -1
  211. package/dist/layout/module-permissions.js +117 -6
  212. package/dist/layout/module-permissions.js.map +1 -1
  213. package/dist/layout/module-render-context.d.ts +32 -0
  214. package/dist/layout/module-render-context.d.ts.map +1 -1
  215. package/dist/layout/module-render-context.js +32 -1
  216. package/dist/layout/module-render-context.js.map +1 -1
  217. package/dist/layout/modules-extended.d.ts.map +1 -1
  218. package/dist/layout/modules-extended.js +21 -11
  219. package/dist/layout/modules-extended.js.map +1 -1
  220. package/dist/layout/modules.d.ts.map +1 -1
  221. package/dist/layout/modules.js +15 -10
  222. package/dist/layout/modules.js.map +1 -1
  223. package/dist/layout/renderer.d.ts +51 -4
  224. package/dist/layout/renderer.d.ts.map +1 -1
  225. package/dist/layout/renderer.js +36 -38
  226. package/dist/layout/renderer.js.map +1 -1
  227. package/dist/layout/types.d.ts +42 -0
  228. package/dist/layout/types.d.ts.map +1 -1
  229. package/dist/layout/types.js +54 -11
  230. package/dist/layout/types.js.map +1 -1
  231. package/dist/schema/base.d.ts +1 -1
  232. package/dist/schema/components.d.ts +150 -0
  233. package/dist/schema/components.d.ts.map +1 -1
  234. package/dist/schema/components.js +50 -4
  235. package/dist/schema/components.js.map +1 -1
  236. package/dist/scope/inline-editing.d.ts.map +1 -1
  237. package/dist/scope/inline-editing.js +10 -0
  238. package/dist/scope/inline-editing.js.map +1 -1
  239. package/dist/scope/sticky-offset.d.ts +185 -0
  240. package/dist/scope/sticky-offset.d.ts.map +1 -0
  241. package/dist/scope/sticky-offset.js +432 -0
  242. package/dist/scope/sticky-offset.js.map +1 -0
  243. package/dist/site/styles.css +41 -3
  244. package/dist/versioning/scheduler.d.ts +8 -0
  245. package/dist/versioning/scheduler.d.ts.map +1 -1
  246. package/dist/versioning/scheduler.js +21 -7
  247. package/dist/versioning/scheduler.js.map +1 -1
  248. package/package.json +1 -1
@@ -1 +1 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BAAiB,CAAC,OAAsB;IACtD,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAC9E,OAAO;QACL,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import type { LayoutDocument } from '../../layout/types.js';
3
+ import type { EditorAction } from './editor-state.js';
4
+ import type { ComponentAffordances } from './linked-component.js';
5
+ import type { ComponentLibrary } from './use-component-library.js';
6
+ /**
7
+ * use-component-connect.tsx
8
+ * The save-as-component → POST → connect-in-place flow, and detach, for BOTH
9
+ * editor shells (kywi-cms#147).
10
+ *
11
+ * This is one implementation on purpose. The admin Layout tab already had two
12
+ * near-copies of the flow (one for modules, one for sections), each with its own
13
+ * `window.prompt`, its own fetch and its own error swallowing, and the overlay
14
+ * shell had none — so adding containers would have made six. The shells now
15
+ * differ only in where they render the dialog and which selection they hand in.
16
+ */
17
+ interface ComponentConnectArgs {
18
+ layout: LayoutDocument;
19
+ dispatch: React.Dispatch<EditorAction>;
20
+ library: ComponentLibrary;
21
+ }
22
+ export interface ComponentConnect {
23
+ /** Chrome affordances for `EditorCanvas` (stable reference — it is memoized). */
24
+ affordances: ComponentAffordances;
25
+ /** The open save dialog, or null. Render anywhere: it portals to the body. */
26
+ dialog: React.ReactNode;
27
+ saveModule: (moduleId: string) => void;
28
+ saveSection: (sectionId: string) => void;
29
+ saveVariantContainer: (containerId: string) => void;
30
+ detachModule: (moduleId: string) => void;
31
+ detachSection: (sectionId: string) => void;
32
+ detachVariantContainer: (containerId: string) => void;
33
+ /** Point an unlinked `component` placeholder node at a saved component. */
34
+ linkModule: (moduleId: string, componentId: string) => void;
35
+ /**
36
+ * Does this node live inside ANOTHER node's linked component instance?
37
+ *
38
+ * Every component action is refused there (the reasoning is at
39
+ * `isInsideLinkedComponent` below, and at `findLinkedAncestor`), and a refusal
40
+ * the owner can click is worse than one they never see — so the
41
+ * surfaces that offer those actions ask this and simply do not offer them. The
42
+ * canvas threads the same fact down its own tree (`linkedAncestor`); the props
43
+ * rail, which addresses whatever is selected, asks here.
44
+ */
45
+ isInsideLinkedComponent: (nodeId: string) => boolean;
46
+ }
47
+ /**
48
+ * The server's own words for a refused component write, details included.
49
+ *
50
+ * `readError` (host-client) reports only `error.message`, which for a rejected
51
+ * definition is the generic "Validation failed" — the useful half is in
52
+ * `details[]` ("A component definition may not link to another component…").
53
+ * The owner is looking at a dialog they cannot get past, so they get the reason.
54
+ *
55
+ * Shared with the save fork (`use-component-fork.tsx`), which puts a refused
56
+ * definition PUT in front of the owner for the same reason.
57
+ */
58
+ export declare function componentErrorMessage(res: Response): Promise<string>;
59
+ export declare function useComponentConnect({ layout, dispatch, library, }: ComponentConnectArgs): ComponentConnect;
60
+ export {};
61
+ //# sourceMappingURL=use-component-connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-connect.d.ts","sourceRoot":"","sources":["../../../src/admin/layout-editor/use-component-connect.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,cAAc,EAA+C,MAAM,uBAAuB,CAAA;AAExG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAgBrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,4BAA4B,CAAA;AAEnF;;;;;;;;;;GAUG;AAEH,UAAU,oBAAoB;IAC5B,MAAM,EAAE,cAAc,CAAA;IACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IACtC,OAAO,EAAE,gBAAgB,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,WAAW,EAAE,oBAAoB,CAAA;IACjC,8EAA8E;IAC9E,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,oBAAoB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,sBAAsB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACrD,2EAA2E;IAC3E,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3D;;;;;;;;;OASG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAA;CACrD;AAQD;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAY1E;AAED,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,QAAQ,EACR,OAAO,GACR,EAAE,oBAAoB,GAAG,gBAAgB,CAyTzC"}
@@ -0,0 +1,292 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React from 'react';
4
+ import { adminFetch } from '../../host-client/index.js';
5
+ import { countComponentLinksToFlatten, detachModuleFromComponent, detachSectionFromComponent, detachVariantContainerFromComponent, flattenComponentLinks, saveAsComponent, } from './component-actions.js';
6
+ import { findModuleInDocument, findSectionInDocument, findVariantContainerInDocument, hasLinkedAncestor, } from './node-lookup.js';
7
+ import { ComponentSaveDialog } from './editor-dialog.js';
8
+ /**
9
+ * The server's own words for a refused component write, details included.
10
+ *
11
+ * `readError` (host-client) reports only `error.message`, which for a rejected
12
+ * definition is the generic "Validation failed" — the useful half is in
13
+ * `details[]` ("A component definition may not link to another component…").
14
+ * The owner is looking at a dialog they cannot get past, so they get the reason.
15
+ *
16
+ * Shared with the save fork (`use-component-fork.tsx`), which puts a refused
17
+ * definition PUT in front of the owner for the same reason.
18
+ */
19
+ export async function componentErrorMessage(res) {
20
+ try {
21
+ const body = (await res.json());
22
+ const detail = body.error?.details?.map(d => d.message).filter(Boolean).join('; ');
23
+ if (detail)
24
+ return detail;
25
+ if (body.error?.message)
26
+ return body.error.message;
27
+ }
28
+ catch {
29
+ /* non-JSON body — fall through to the status line */
30
+ }
31
+ return `Could not save the component (${res.status}).`;
32
+ }
33
+ export function useComponentConnect({ layout, dispatch, library, }) {
34
+ const [pending, setPending] = React.useState(null);
35
+ const [busy, setBusy] = React.useState(false);
36
+ const [error, setError] = React.useState(null);
37
+ /**
38
+ * Is `nodeId` inside another node's component instance? (kywi-cms#147 T3
39
+ * review, I1.)
40
+ *
41
+ * THE HOLE THIS CLOSES. Connecting a node that sits inside an already-linked
42
+ * ancestor writes a bare link into what is really the ancestor's inline
43
+ * FALLBACK copy: the content that node used to hold is gone from the stored
44
+ * document, and the new link is invisible to `collectComponentRefs` (it stops
45
+ * at the connected ancestor), so it never reaches the instance index, the usage
46
+ * counts or the delete gate, and the render-side placement pass strips it. The
47
+ * page looks fine right up to the moment the outer component stops resolving —
48
+ * and then that node renders EMPTY with nothing to recover it from.
49
+ *
50
+ * The gate lives HERE, not only in the canvas chrome, because the canvas is
51
+ * not the only caller: the props rail addresses the current selection and would
52
+ * otherwise reach `saveModule` / `saveSection` / `linkModule` directly. The
53
+ * canvas threading (`linkedAncestor`) and the rail's `isInsideLinkedComponent`
54
+ * make the actions invisible; this makes them impossible.
55
+ */
56
+ const isInsideLinkedComponent = React.useCallback((nodeId) => hasLinkedAncestor(layout, nodeId), [layout]);
57
+ const openSave = React.useCallback((kind, nodeId) => {
58
+ if (hasLinkedAncestor(layout, nodeId))
59
+ return;
60
+ setError(null);
61
+ setBusy(false);
62
+ setPending({ kind, nodeId });
63
+ }, [layout]);
64
+ const closeSave = React.useCallback(() => {
65
+ setPending(null);
66
+ setBusy(false);
67
+ setError(null);
68
+ }, []);
69
+ const saveModule = React.useCallback((moduleId) => openSave('module', moduleId), [openSave]);
70
+ const saveSection = React.useCallback((sectionId) => openSave('section', sectionId), [openSave]);
71
+ const saveVariantContainer = React.useCallback((containerId) => openSave('variantContainer', containerId), [openSave]);
72
+ // ── Connect in place ───────────────────────────────────────────────────────
73
+ //
74
+ // Each of these swaps the source node for a CLEAN linked instance, keeping its
75
+ // id and its position (that is what REPLACE_* exist for). "Clean" means the
76
+ // node carries no local content of its own, which is what makes the link
77
+ // STRICT: `isCleanComponentInstance` reads exactly this shape, and the renderer
78
+ // then draws the definition alone rather than merging the node's props over it.
79
+ //
80
+ // The node handed in is the FLATTENED one — the same tree that was just stored
81
+ // as the definition — so a freshly connected instance's fallback copy holds the
82
+ // same CONTENT the link resolves to. (Not byte-identical: rendering a resolved
83
+ // definition re-keys its ids per placement — `${nodeId}:${storedId}`, see
84
+ // `rekeyResolvedSection` — so the ids differ by construction. What matters is
85
+ // that the props, style and structure agree, which is what makes an
86
+ // unresolvable link degrade to the same page rather than a different one.)
87
+ // Keeping the pre-flatten copy would instead leave a nested link sitting in the
88
+ // page's fallback data: unindexed (`collectComponentRefs` stops at a connected
89
+ // node), unrendered, and able to reappear if the outer component ever became
90
+ // unresolvable.
91
+ const connectModule = React.useCallback((node, componentId) => {
92
+ dispatch({
93
+ type: 'REPLACE_MODULE',
94
+ moduleId: node.id,
95
+ node: { ...node, componentId, props: { componentId }, style: {} },
96
+ });
97
+ }, [dispatch]);
98
+ const connectSection = React.useCallback((section, componentId) => {
99
+ dispatch({
100
+ type: 'REPLACE_SECTION',
101
+ sectionId: section.id,
102
+ section: { ...section, componentId },
103
+ });
104
+ }, [dispatch]);
105
+ const connectVariantContainer = React.useCallback((container, componentId) => {
106
+ // `experimentId` / `winnerId` stay exactly as the page has them: they bind
107
+ // THIS page's container to THIS page's experiment run, and
108
+ // `applyVariantContainerPlacement` gives the placement's binding priority
109
+ // over the definition's for precisely that reason. Connecting must not
110
+ // silently re-point a live experiment at the saved component's.
111
+ dispatch({
112
+ type: 'REPLACE_VARIANT_CONTAINER',
113
+ containerId: container.id,
114
+ container: { ...container, componentId },
115
+ });
116
+ }, [dispatch]);
117
+ const linkModule = React.useCallback((moduleId, componentId) => {
118
+ const node = findModuleInDocument(layout, moduleId);
119
+ if (!node)
120
+ return;
121
+ // Same refusal as saving, for the same reason: this link would live in
122
+ // another component's fallback copy, where nothing can see it.
123
+ if (hasLinkedAncestor(layout, moduleId))
124
+ return;
125
+ connectModule(node, componentId);
126
+ }, [layout, connectModule]);
127
+ // ── The save itself ────────────────────────────────────────────────────────
128
+ const submitSave = React.useCallback(async (name, description) => {
129
+ if (!pending)
130
+ return;
131
+ const { kind, nodeId } = pending;
132
+ const source = kind === 'module'
133
+ ? findModuleInDocument(layout, nodeId)
134
+ : kind === 'section'
135
+ ? findSectionInDocument(layout, nodeId)
136
+ : findVariantContainerInDocument(layout, nodeId);
137
+ if (!source) {
138
+ setError('That element is no longer on the page.');
139
+ return;
140
+ }
141
+ // Materialise any component link INSIDE the selection before storing it:
142
+ // the API refuses a definition that links to another component, so without
143
+ // this a section holding a connected module would simply 400 (kywi-cms#147,
144
+ // ledger C2b). Flattening is idempotent, so passing the flattened node to
145
+ // `saveAsComponent` below re-walks it and finds nothing left to do.
146
+ const flattened = flattenComponentLinks(source, library.lookup);
147
+ const input = saveAsComponent(flattened, name, {
148
+ ...(description ? { description } : {}),
149
+ resolveLink: library.lookup,
150
+ });
151
+ setBusy(true);
152
+ setError(null);
153
+ try {
154
+ const res = await adminFetch('/api/v1/components', {
155
+ method: 'POST',
156
+ body: JSON.stringify(input),
157
+ });
158
+ if (!res.ok) {
159
+ setError(await componentErrorMessage(res));
160
+ setBusy(false);
161
+ return;
162
+ }
163
+ const body = (await res.json());
164
+ const created = body.data;
165
+ if (!created?.id) {
166
+ setError('The server did not return the saved component.');
167
+ setBusy(false);
168
+ return;
169
+ }
170
+ library.add(created);
171
+ if (kind === 'module')
172
+ connectModule(flattened, created.id);
173
+ else if (kind === 'section')
174
+ connectSection(flattened, created.id);
175
+ else
176
+ connectVariantContainer(flattened, created.id);
177
+ closeSave();
178
+ }
179
+ catch {
180
+ // Network-level failure: the node stays exactly as it was, unlinked.
181
+ setError('Could not reach the server. Nothing was changed.');
182
+ setBusy(false);
183
+ }
184
+ }, [pending, layout, library, connectModule, connectSection, connectVariantContainer, closeSave]);
185
+ // ── Detach ────────────────────────────────────────────────────────────────
186
+ //
187
+ // Materialise the component's CURRENT definition into the node and drop the
188
+ // link, through the helpers the server-side detach-all shares — so detaching
189
+ // one instance here and detaching every instance from the API produce
190
+ // byte-identical nodes for the same placement.
191
+ const detachModule = React.useCallback((moduleId) => {
192
+ const node = findModuleInDocument(layout, moduleId);
193
+ if (!node?.componentId)
194
+ return;
195
+ dispatch({
196
+ type: 'REPLACE_MODULE',
197
+ moduleId,
198
+ node: detachModuleFromComponent(node, library.byId(node.componentId)),
199
+ });
200
+ dispatch({ type: 'DESELECT' });
201
+ }, [layout, library, dispatch]);
202
+ const detachSection = React.useCallback((sectionId) => {
203
+ const section = findSectionInDocument(layout, sectionId);
204
+ if (!section?.componentId)
205
+ return;
206
+ dispatch({
207
+ type: 'REPLACE_SECTION',
208
+ sectionId,
209
+ section: detachSectionFromComponent(section, library.byId(section.componentId)),
210
+ });
211
+ dispatch({ type: 'DESELECT' });
212
+ }, [layout, library, dispatch]);
213
+ const detachVariantContainer = React.useCallback((containerId) => {
214
+ const container = findVariantContainerInDocument(layout, containerId);
215
+ if (!container?.componentId)
216
+ return;
217
+ dispatch({
218
+ type: 'REPLACE_VARIANT_CONTAINER',
219
+ containerId,
220
+ container: detachVariantContainerFromComponent(container, library.byId(container.componentId)),
221
+ });
222
+ dispatch({ type: 'DESELECT' });
223
+ }, [layout, library, dispatch]);
224
+ // ── Canvas chrome ─────────────────────────────────────────────────────────
225
+ const affordances = React.useMemo(() => ({
226
+ nameOf: library.nameOf,
227
+ onSaveModule: saveModule,
228
+ onSaveSection: saveSection,
229
+ onSaveVariantContainer: saveVariantContainer,
230
+ }), [library.nameOf, saveModule, saveSection, saveVariantContainer]);
231
+ // A container is a "personalized section" or an "A/B tested section" — the
232
+ // dialog cannot know which from the granularity, and the canvas names it that
233
+ // way in its own badge, so tell it.
234
+ const pendingSubject = () => {
235
+ if (!pending || pending.kind !== 'variantContainer')
236
+ return undefined;
237
+ const container = findVariantContainerInDocument(layout, pending.nodeId);
238
+ if (!container)
239
+ return undefined;
240
+ return container.mode === 'ab_test' ? 'A/B tested section' : 'personalized section';
241
+ };
242
+ /**
243
+ * How many component links sit INSIDE the pending selection.
244
+ *
245
+ * Saving materialises them (the API refuses a definition that links out), which
246
+ * means those inner instances stop following their own source — a real change
247
+ * to the page, not a formality, so it is said out loud before the owner commits
248
+ * rather than discovered later when editing the inner component changes nothing
249
+ * here.
250
+ *
251
+ * Counted by RUNNING the flattening (`countComponentLinksToFlatten`), not by
252
+ * asking `collectComponentRefs` (kywi-cms#147 T3 review, M2): that walker stops
253
+ * at a connected node, so a link hidden inside a connected node's inline
254
+ * fallback copy — the case an unresolvable inner link produces — is invisible to
255
+ * it while the flattening rewrites it on the next pass regardless. The disclosure
256
+ * has to match what the save actually does.
257
+ *
258
+ * The selection's own link is subtracted, though it is never present: saving an
259
+ * already-linked node as a new component is not offered anywhere.
260
+ */
261
+ const pendingNestedLinks = () => {
262
+ if (!pending || pending.kind === 'module')
263
+ return 0;
264
+ const node = pending.kind === 'section'
265
+ ? findSectionInDocument(layout, pending.nodeId)
266
+ : findVariantContainerInDocument(layout, pending.nodeId);
267
+ if (!node)
268
+ return 0;
269
+ const total = countComponentLinksToFlatten(node, library.lookup);
270
+ return Math.max(0, total - (node.componentId ? 1 : 0));
271
+ };
272
+ const subject = pendingSubject();
273
+ const nested = pendingNestedLinks();
274
+ const notice = nested > 0
275
+ ? `${nested} linked component${nested === 1 ? '' : 's'} inside will be copied into this one, ` +
276
+ `and ${nested === 1 ? 'that instance' : 'those instances'} will stop following ${nested === 1 ? 'its' : 'their'} source.`
277
+ : null;
278
+ const dialog = pending ? (_jsx(ComponentSaveDialog, { kind: pending.kind, ...(subject ? { subject } : {}), ...(notice ? { notice } : {}), busy: busy, error: error, onCancel: closeSave, onSubmit: (name, description) => { void submitSave(name, description); } })) : null;
279
+ return {
280
+ affordances,
281
+ dialog,
282
+ saveModule,
283
+ saveSection,
284
+ saveVariantContainer,
285
+ detachModule,
286
+ detachSection,
287
+ detachVariantContainer,
288
+ linkModule,
289
+ isInsideLinkedComponent,
290
+ };
291
+ }
292
+ //# sourceMappingURL=use-component-connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-connect.js","sourceRoot":"","sources":["../../../src/admin/layout-editor/use-component-connect.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,EAC1B,mCAAmC,EACnC,qBAAqB,EACrB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,mBAAmB,EAA0B,MAAM,oBAAoB,CAAA;AAsDhF;;;;;;;;;;GAUG;AACH,M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AA;IAER,OAAO;QACL,WAAW;QACX,MAAM;QACN,UAAU;QACV,WAAW;QACX,oBAAoB;QACpB,YAAY;QACZ,aAAa;QACb,sBAAsB;QACtB,UAAU;QACV,uBAAuB;KACxB,CAAA;AACH,CAAC"}
@@ -0,0 +1,123 @@
1
+ import React from 'react';
2
+ import type { LayoutDocument } from '../../layout/types.js';
3
+ import type { EditorAction } from './editor-state.js';
4
+ import { type ComponentForkSaveMode } from './editor-dialog.js';
5
+ import type { ComponentLibrary } from './use-component-library.js';
6
+ /**
7
+ * use-component-fork.tsx
8
+ * The save fork, driven (kywi-cms#147 T4). One implementation for both editor
9
+ * shells, as with the connect flow.
10
+ *
11
+ * WHAT IT DOES TO A SAVE. Every save path in both shells goes through
12
+ * {@link ComponentFork.guardSave} instead of handing `state.layout` straight to
13
+ * its callback. With no edited linked instances that is a pass-through — the
14
+ * document goes out unchanged, and nothing about saving has changed. With one or
15
+ * more, the save is INTERRUPTED: the owner answers per component, the answers are
16
+ * applied to the document, the definitions that need writing are written, and
17
+ * only then does the save proceed — with the resolved document, so the page that
18
+ * lands on the server is one whose linked instances are all coherent again.
19
+ *
20
+ * ORDERING, AND THE PARTIAL STATE IT ADMITS TO. Component definitions are PUT
21
+ * first, the page second. That is the safer order of the two: a definition write
22
+ * is idempotent and self-contained (it makes every instance render the edit, on
23
+ * this page too — resolution is live), whereas a page write that landed before a
24
+ * failed definition write would leave the page storing a CLEAN instance of a
25
+ * definition that never received the edit, i.e. the edit deleted. The remaining
26
+ * failure — definitions written, page save failed — is real and is SAID rather
27
+ * than hidden: the message names it, nothing is marked saved, the document stays
28
+ * dirty, and retrying re-runs the same idempotent PUT and saves again.
29
+ *
30
+ * THE SECOND DOOR, AND WHY IT IS NOW SHUT (kywi-cms#147 T4 review, I1). The fork
31
+ * sits on the EDITOR's own save paths. The admin Layout tab used to also stage
32
+ * every edit into the surrounding content form (`onChange` → `handleChange`), so a
33
+ * page-level form Submit persisted a layout the fork had never seen, and switching
34
+ * tabs remounted the editor with that staged document as its new baseline — which
35
+ * made the staged state permanent rather than provisional. For a SECTION or
36
+ * CONTAINER instance the consequence was worse than a stray override: those resolve
37
+ * WHOLESALE, so the edit sat in a fallback copy the renderer never reads. It was
38
+ * persisted and never rendered, and the following editor session took it as the
39
+ * baseline, so nothing normalised it either.
40
+ *
41
+ * `content-form.tsx` therefore no longer stages the layout, and no longer sends it
42
+ * with the page form — the Layout tab's own Save is the layout's save path, and the
43
+ * fork is on it. The one exception is a page being CREATED, where there is no
44
+ * content row to PUT a layout against and the create payload is the only door
45
+ * there is; a first-save page's linked instances were all connected in this same
46
+ * session, so their definitions were written by the connect flow moments earlier.
47
+ * The front-of-site overlay — the primary editing surface — never had a second door.
48
+ */
49
+ /** What the shell hands over: persist this document, report whether it landed. */
50
+ export type PerformSave = (layout: LayoutDocument) => boolean | void | Promise<boolean | void>;
51
+ export interface ComponentFork {
52
+ /** The open fork dialog, or null. Render anywhere — it portals to the body. */
53
+ dialog: React.ReactNode;
54
+ /**
55
+ * Run a save, asking about edited linked instances first.
56
+ *
57
+ * `perform` must be the shell's own persist step and must REPORT the outcome
58
+ * the way `onSave` does (`false`/rejection = did not persist), or a failed page
59
+ * save after a successful definition write cannot be told apart from a clean
60
+ * one.
61
+ *
62
+ * `mode` is which button was pressed, and only changes what the dialog SAYS: a
63
+ * component write is immediate whichever one it was, which is exactly the thing
64
+ * "Save Draft" and "Schedule" imply is not happening.
65
+ */
66
+ guardSave: (perform: PerformSave, mode?: ComponentForkSaveMode) => void;
67
+ }
68
+ export declare function useComponentFork({ layout, originalLayout, dispatch, library, inlineEditActive, inert, }: {
69
+ layout: LayoutDocument;
70
+ /** The last-saved document — the baseline an instance is "edited" against. */
71
+ originalLayout: LayoutDocument;
72
+ dispatch: React.Dispatch<EditorAction>;
73
+ library: ComponentLibrary;
74
+ /**
75
+ * True while the front-of-site overlay has a LIVE inline text edit open —
76
+ * i.e. `OverlayShell`'s own `textEdit.id !== null` (kywi-cms#147 T4 review
77
+ * round 2). The admin canvas never has one (module-overlay.tsx: "admin canvas
78
+ * never carries `inlineEdit`"), so it simply never passes this.
79
+ *
80
+ * Why the fallback-copy refresh below needs to know: an inline edit's
81
+ * keystrokes live in the DOM only until commit (blur/Enter), so
82
+ * `state.isDirty` — which the reducer's REFRESH_COMPONENT_COPIES case already
83
+ * refuses to touch — never sees them. A library load landing mid-session finds
84
+ * a document the reducer calls pristine and refreshes it anyway. Worse than an
85
+ * ordinary stale-copy overwrite: `rekeyResolvedSection` gives the refreshed
86
+ * copy the exact ids the placement already had, so React updates the bound
87
+ * element's text IN PLACE instead of remounting it — the #145 orphan recovery
88
+ * (`isOrphanedEdit` in module-overlay.tsx) exists for a bound element that
89
+ * DISCONNECTS, and this element never does, so recovery never fires. The
90
+ * result (pinned in `overlay-refresh-mid-inline-edit.test.tsx`) is a session
91
+ * that looks perfectly healthy — still `contenteditable`, no cancel, no error
92
+ * — while the refresh has silently overwritten whatever was typed with the
93
+ * definition's current value.
94
+ */
95
+ inlineEditActive?: boolean;
96
+ /**
97
+ * THE DOCUMENT IS NOT A PAGE, so there is no fork (kywi-cms#147 T5 review I1,
98
+ * final review M2). Set only by `LayoutEditor`'s `canvasKind` — the admin
99
+ * `components.edit` definition canvas, and the standalone Layouts editor's
100
+ * blueprint canvas.
101
+ *
102
+ * WHY INERT AND NOT "CAREFUL". The fork's question is "does this edit belong to
103
+ * the component, or to this page only?" — and on neither canvas is there a "this
104
+ * page". On a definition canvas the answer is fixed before the question (a
105
+ * definition save IS the propagation) and every branch behind it is wrong:
106
+ * "update all" would PUT some OTHER component's definition (whatever the edited
107
+ * node happened to link to) and only then let the definition save be refused by
108
+ * the extract's nested-link check — a site-wide write nobody asked for, in place
109
+ * of the one they did — while "this page only" would detach a node inside a
110
+ * definition. On a blueprint canvas the blast radius the dialog would name is not
111
+ * even readable: blueprints are outside the instance index, so a linked node in
112
+ * one reports "0 instances across 0 pages" and every number in the fork's copy
113
+ * would be a lie.
114
+ *
115
+ * `guardSave` therefore passes straight through, no dialog is ever built, and the
116
+ * fallback-copy refresh is skipped too: refreshing rewrites a linked node's
117
+ * inline copy from the library, which inside a definition would be silently
118
+ * editing stored content the owner never touched, and inside a blueprint would
119
+ * rewrite a stencil nobody opened for that.
120
+ */
121
+ inert?: boolean;
122
+ }): ComponentFork;
123
+ //# sourceMappingURL=use-component-fork.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-component-fork.d.ts","sourceRoot":"","sources":["../../../src/admin/layout-editor/use-component-fork.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,cAAc,EAA+C,MAAM,uBAAuB,CAAA;AAUxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAUrD,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,cAAc,KACnB,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;AAE7C,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB;;;;;;;;;;;OAWG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAA;CACxE;AA6BD,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,cAAc,EACd,QAAQ,EACR,OAAO,EACP,gBAAwB,EACxB,KAAa,GACd,EAAE;IACD,MAAM,EAAE,cAAc,CAAA;IACtB,8EAA8E;IAC9E,cAAc,EAAE,cAAc,CAAA;IAC9B,QAAQ,EAAE,KA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