@cocoar/vue-page-builder 2.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 (65) hide show
  1. package/dist/CoarPageBuilder.vue.d.ts +21 -0
  2. package/dist/CoarPageBuilder.vue.d.ts.map +1 -0
  3. package/dist/CoarPageRenderer.vue.d.ts +22 -0
  4. package/dist/CoarPageRenderer.vue.d.ts.map +1 -0
  5. package/dist/PageNode.vue.d.ts +7 -0
  6. package/dist/PageNode.vue.d.ts.map +1 -0
  7. package/dist/builder/BuilderCanvas.vue.d.ts +3 -0
  8. package/dist/builder/BuilderCanvas.vue.d.ts.map +1 -0
  9. package/dist/builder/BuilderCanvasNode.vue.d.ts +9 -0
  10. package/dist/builder/BuilderCanvasNode.vue.d.ts.map +1 -0
  11. package/dist/builder/BuilderOutline.vue.d.ts +3 -0
  12. package/dist/builder/BuilderOutline.vue.d.ts.map +1 -0
  13. package/dist/builder/BuilderOutlineNode.vue.d.ts +14 -0
  14. package/dist/builder/BuilderOutlineNode.vue.d.ts.map +1 -0
  15. package/dist/builder/BuilderPropsPanel.vue.d.ts +3 -0
  16. package/dist/builder/BuilderPropsPanel.vue.d.ts.map +1 -0
  17. package/dist/builder/builderContext.d.ts +10 -0
  18. package/dist/builder/builderContext.d.ts.map +1 -0
  19. package/dist/builder/nodeDefaults.d.ts +14 -0
  20. package/dist/builder/nodeDefaults.d.ts.map +1 -0
  21. package/dist/builder/operations.d.ts +21 -0
  22. package/dist/builder/operations.d.ts.map +1 -0
  23. package/dist/builder/props/ButtonProps.vue.d.ts +8 -0
  24. package/dist/builder/props/ButtonProps.vue.d.ts.map +1 -0
  25. package/dist/builder/props/CardProps.vue.d.ts +8 -0
  26. package/dist/builder/props/CardProps.vue.d.ts.map +1 -0
  27. package/dist/builder/props/CheckboxProps.vue.d.ts +8 -0
  28. package/dist/builder/props/CheckboxProps.vue.d.ts.map +1 -0
  29. package/dist/builder/props/HeadingProps.vue.d.ts +8 -0
  30. package/dist/builder/props/HeadingProps.vue.d.ts.map +1 -0
  31. package/dist/builder/props/ImageProps.vue.d.ts +8 -0
  32. package/dist/builder/props/ImageProps.vue.d.ts.map +1 -0
  33. package/dist/builder/props/LinkProps.vue.d.ts +8 -0
  34. package/dist/builder/props/LinkProps.vue.d.ts.map +1 -0
  35. package/dist/builder/props/ParagraphProps.vue.d.ts +8 -0
  36. package/dist/builder/props/ParagraphProps.vue.d.ts.map +1 -0
  37. package/dist/builder/props/SectionProps.vue.d.ts +8 -0
  38. package/dist/builder/props/SectionProps.vue.d.ts.map +1 -0
  39. package/dist/builder/props/SelectProps.vue.d.ts +8 -0
  40. package/dist/builder/props/SelectProps.vue.d.ts.map +1 -0
  41. package/dist/builder/props/SpacerProps.vue.d.ts +8 -0
  42. package/dist/builder/props/SpacerProps.vue.d.ts.map +1 -0
  43. package/dist/builder/props/StackProps.vue.d.ts +8 -0
  44. package/dist/builder/props/StackProps.vue.d.ts.map +1 -0
  45. package/dist/builder/props/StyleProps.vue.d.ts +8 -0
  46. package/dist/builder/props/StyleProps.vue.d.ts.map +1 -0
  47. package/dist/builder/props/TextInputProps.vue.d.ts +8 -0
  48. package/dist/builder/props/TextInputProps.vue.d.ts.map +1 -0
  49. package/dist/builder/props/registry.d.ts +15 -0
  50. package/dist/builder/props/registry.d.ts.map +1 -0
  51. package/dist/builder/useBuilderDnd.d.ts +26 -0
  52. package/dist/builder/useBuilderDnd.d.ts.map +1 -0
  53. package/dist/builder/usePageBuilder.d.ts +28 -0
  54. package/dist/builder/usePageBuilder.d.ts.map +1 -0
  55. package/dist/builder/useSchemaValidation.d.ts +28 -0
  56. package/dist/builder/useSchemaValidation.d.ts.map +1 -0
  57. package/dist/context.d.ts +24 -0
  58. package/dist/context.d.ts.map +1 -0
  59. package/dist/index.css +2 -0
  60. package/dist/index.d.ts +6 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +2454 -0
  63. package/dist/schema.d.ts +185 -0
  64. package/dist/schema.d.ts.map +1 -0
  65. package/package.json +47 -0
package/dist/index.js ADDED
@@ -0,0 +1,2454 @@
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, inject as l, mergeModels as u, normalizeClass as d, normalizeStyle as f, onBeforeUnmount as p, onMounted as m, openBlock as h, provide as g, ref as _, renderList as v, resolveComponent as y, resolveDynamicComponent as b, shallowRef as x, toDisplayString as S, unref as C, useCssVars as w, useModel as T, watch as E, withCtx as D, withModifiers as O } from "vue";
2
+ import { CoarButton as k, CoarCard as A, CoarCheckbox as j, CoarDivider as M, CoarFormField as N, CoarIcon as P, CoarPasswordInput as F, CoarSelect as I, CoarTab as L, CoarTabGroup as ee, CoarTextInput as R, setCoarDragImageFromElement as z } from "@cocoar/vue-ui";
3
+ //#region src/context.ts
4
+ var B = Symbol("page-renderer");
5
+ //#endregion
6
+ //#region src/schema.ts
7
+ function V(e) {
8
+ return e.type === "page" || e.type === "stack" || e.type === "card" || e.type === "section";
9
+ }
10
+ function H(e, t) {
11
+ return e === "page" || !t?.allowedElements ? !0 : t.allowedElements.includes(e);
12
+ }
13
+ //#endregion
14
+ //#region src/PageNode.vue?vue&type=script&setup=true&lang.ts
15
+ var U = {
16
+ key: 0,
17
+ class: "pb-section__title"
18
+ }, W = ["src", "alt"], te = /* @__PURE__ */ c({
19
+ name: "PageNode",
20
+ __name: "PageNode",
21
+ props: { node: {} },
22
+ setup(c) {
23
+ let u = c, p = l(B);
24
+ if (!p) throw Error("PageNode must be rendered inside CoarPageRenderer.");
25
+ let m = t(() => {
26
+ let e = H(u.node.type, p.config);
27
+ return e || p.reportDisallowed?.(u.node.type), e;
28
+ });
29
+ function g(e) {
30
+ if (!e) return {};
31
+ let t = {};
32
+ return e.padding && (t.padding = e.padding), e.width && (t.width = e.width), t;
33
+ }
34
+ function _(e) {
35
+ let t = e.style?.gap, n = e.style?.align, r = {};
36
+ return t && (r.gap = t), n && (r.alignItems = n), r;
37
+ }
38
+ let x = t(() => g(u.node.style)), w = t(() => u.node);
39
+ function T(e, t) {
40
+ e && p.triggerAction(e, t);
41
+ }
42
+ function E(e) {
43
+ return p.assetResolver?.(e) ?? "";
44
+ }
45
+ function O(e) {
46
+ return (e ?? []).map((e) => ({
47
+ value: e.value,
48
+ label: e.label
49
+ }));
50
+ }
51
+ return (t, c) => {
52
+ let l = y("PageNode", !0);
53
+ return m.value ? (h(), i(e, { key: 0 }, [w.value.type === "page" ? (h(), i("div", {
54
+ key: 0,
55
+ class: "pb-stack",
56
+ style: f({
57
+ ...x.value,
58
+ ..._(w.value)
59
+ })
60
+ }, [(h(!0), i(e, null, v(w.value.children, (e) => (h(), n(l, {
61
+ key: e.id,
62
+ node: e
63
+ }, null, 8, ["node"]))), 128))], 4)) : w.value.type === "stack" ? (h(), i("div", {
64
+ key: 1,
65
+ class: d(["pb-stack", {
66
+ "pb-stack--row": w.value.direction === "row",
67
+ "pb-stack--wrap": w.value.wrap
68
+ }]),
69
+ style: f({
70
+ ...x.value,
71
+ ..._(w.value)
72
+ })
73
+ }, [(h(!0), i(e, null, v(w.value.children, (e) => (h(), n(l, {
74
+ key: e.id,
75
+ node: e
76
+ }, null, 8, ["node"]))), 128))], 6)) : w.value.type === "card" ? (h(), n(C(A), {
77
+ key: 2,
78
+ title: w.value.title,
79
+ style: f(x.value)
80
+ }, {
81
+ default: D(() => [a("div", {
82
+ class: "pb-card-body",
83
+ style: f(_(w.value))
84
+ }, [(h(!0), i(e, null, v(w.value.children, (e) => (h(), n(l, {
85
+ key: e.id,
86
+ node: e
87
+ }, null, 8, ["node"]))), 128))], 4)]),
88
+ _: 1
89
+ }, 8, ["title", "style"])) : w.value.type === "section" ? (h(), i("section", {
90
+ key: 3,
91
+ class: "pb-section",
92
+ style: f(x.value)
93
+ }, [w.value.title ? (h(), i("h3", U, S(w.value.title), 1)) : r("", !0), a("div", {
94
+ class: "pb-section__body",
95
+ style: f(_(w.value))
96
+ }, [(h(!0), i(e, null, v(w.value.children, (e) => (h(), n(l, {
97
+ key: e.id,
98
+ node: e
99
+ }, null, 8, ["node"]))), 128))], 4)], 4)) : w.value.type === "divider" ? (h(), n(C(M), {
100
+ key: 4,
101
+ style: f(x.value)
102
+ }, null, 8, ["style"])) : w.value.type === "spacer" ? (h(), i("div", {
103
+ key: 5,
104
+ class: "pb-spacer",
105
+ style: f(w.value.size ? {
106
+ height: w.value.size,
107
+ width: w.value.size
108
+ } : { flex: "1" })
109
+ }, null, 4)) : w.value.type === "heading" ? (h(), n(b(`h${w.value.level ?? 2}`), {
110
+ key: 6,
111
+ class: "pb-heading",
112
+ style: f(x.value)
113
+ }, {
114
+ default: D(() => [o(S(w.value.text), 1)]),
115
+ _: 1
116
+ }, 8, ["style"])) : w.value.type === "paragraph" ? (h(), i("p", {
117
+ key: 7,
118
+ class: "pb-paragraph",
119
+ style: f(x.value)
120
+ }, S(w.value.text), 5)) : w.value.type === "text-input" ? (h(), n(C(N), {
121
+ key: 8,
122
+ label: w.value.label,
123
+ required: w.value.validation?.required,
124
+ error: w.value.name ? C(p).getError(w.value.name) : "",
125
+ disabled: w.value.disabled,
126
+ style: f(x.value)
127
+ }, {
128
+ default: D(() => [w.value.inputType === "password" ? (h(), n(C(F), {
129
+ key: 0,
130
+ "model-value": w.value.name ? C(p).getValue(w.value.name) ?? "" : "",
131
+ placeholder: w.value.placeholder,
132
+ disabled: w.value.disabled,
133
+ "onUpdate:modelValue": c[0] ||= (e) => w.value.name && C(p).setValue(w.value.name, e),
134
+ onBlurred: c[1] ||= (e) => w.value.name && C(p).markTouched(w.value.name)
135
+ }, null, 8, [
136
+ "model-value",
137
+ "placeholder",
138
+ "disabled"
139
+ ])) : (h(), n(C(R), {
140
+ key: 1,
141
+ "model-value": w.value.name ? C(p).getValue(w.value.name) ?? "" : "",
142
+ placeholder: w.value.placeholder,
143
+ disabled: w.value.disabled,
144
+ "onUpdate:modelValue": c[2] ||= (e) => w.value.name && C(p).setValue(w.value.name, e),
145
+ onBlurred: c[3] ||= (e) => w.value.name && C(p).markTouched(w.value.name)
146
+ }, null, 8, [
147
+ "model-value",
148
+ "placeholder",
149
+ "disabled"
150
+ ]))]),
151
+ _: 1
152
+ }, 8, [
153
+ "label",
154
+ "required",
155
+ "error",
156
+ "disabled",
157
+ "style"
158
+ ])) : w.value.type === "checkbox" ? (h(), n(C(j), {
159
+ key: 9,
160
+ "model-value": w.value.name ? C(p).getValue(w.value.name) ?? !1 : !1,
161
+ label: w.value.label,
162
+ required: w.value.validation?.required,
163
+ disabled: w.value.disabled,
164
+ style: f(x.value),
165
+ "onUpdate:modelValue": c[4] ||= (e) => w.value.name && C(p).setValue(w.value.name, e)
166
+ }, null, 8, [
167
+ "model-value",
168
+ "label",
169
+ "required",
170
+ "disabled",
171
+ "style"
172
+ ])) : w.value.type === "select" ? (h(), n(C(N), {
173
+ key: 10,
174
+ label: w.value.label,
175
+ required: w.value.validation?.required,
176
+ error: w.value.name ? C(p).getError(w.value.name) : "",
177
+ disabled: w.value.disabled,
178
+ style: f(x.value)
179
+ }, {
180
+ default: D(() => [s(C(I), {
181
+ "model-value": w.value.name ? C(p).getValue(w.value.name) ?? null : null,
182
+ options: O(w.value.options),
183
+ placeholder: w.value.placeholder,
184
+ disabled: w.value.disabled,
185
+ "onUpdate:modelValue": c[5] ||= (e) => w.value.name && C(p).setValue(w.value.name, e)
186
+ }, null, 8, [
187
+ "model-value",
188
+ "options",
189
+ "placeholder",
190
+ "disabled"
191
+ ])]),
192
+ _: 1
193
+ }, 8, [
194
+ "label",
195
+ "required",
196
+ "error",
197
+ "disabled",
198
+ "style"
199
+ ])) : w.value.type === "button" ? (h(), n(C(k), {
200
+ key: 11,
201
+ class: "pb-button",
202
+ variant: w.value.variant ?? "primary",
203
+ size: w.value.size,
204
+ "icon-left": w.value.icon,
205
+ disabled: w.value.validates && !C(p).isFormValid.value,
206
+ style: f(x.value),
207
+ onClick: c[6] ||= (e) => T(w.value.action, w.value.validates)
208
+ }, {
209
+ default: D(() => [o(S(w.value.label), 1)]),
210
+ _: 1
211
+ }, 8, [
212
+ "variant",
213
+ "size",
214
+ "icon-left",
215
+ "disabled",
216
+ "style"
217
+ ])) : w.value.type === "link" ? (h(), i("button", {
218
+ key: 12,
219
+ class: "pb-link",
220
+ style: f(x.value),
221
+ onClick: c[7] ||= (e) => T(w.value.action)
222
+ }, S(w.value.label), 5)) : w.value.type === "image" ? (h(), i("img", {
223
+ key: 13,
224
+ class: "pb-image",
225
+ src: E(w.value.assetId),
226
+ alt: w.value.alt ?? "",
227
+ style: f(x.value)
228
+ }, null, 12, W)) : r("", !0)], 64)) : r("", !0);
229
+ };
230
+ }
231
+ }), G = (e, t) => {
232
+ let n = e.__vccOpts || e;
233
+ for (let [e, r] of t) n[e] = r;
234
+ return n;
235
+ }, ne = /* @__PURE__ */ G(te, [["__scopeId", "data-v-0632b6f4"]]), K = { class: "coar-page-renderer" }, q = /* @__PURE__ */ G(/* @__PURE__ */ c({
236
+ __name: "CoarPageRenderer",
237
+ props: {
238
+ schema: {},
239
+ actions: {},
240
+ onValidate: { type: Function },
241
+ assetResolver: { type: Function },
242
+ config: {}
243
+ },
244
+ setup(e) {
245
+ let n = e, r = _({}), a = _({});
246
+ function o(e) {
247
+ return (e.type === "text-input" || e.type === "checkbox" || e.type === "select") && !!e.name;
248
+ }
249
+ function c(e) {
250
+ let t = {};
251
+ if (o(e) && e.name && e.defaultValue !== void 0 && (t[e.name] = e.defaultValue), "children" in e) for (let n of e.children) Object.assign(t, c(n));
252
+ return t;
253
+ }
254
+ function l() {
255
+ r.value = c(n.schema), a.value = {};
256
+ }
257
+ l(), E(() => n.schema, l, { deep: !1 });
258
+ function u(e) {
259
+ let t = r.value[e.name], n = e.validation;
260
+ if (!n) return "";
261
+ if (n.required && (t == null || t === "" || t === !1)) return n.message ?? "This field is required";
262
+ if (e.type === "text-input" && typeof t == "string") {
263
+ if (n.minLength && t.length < n.minLength) return n.message ?? `Minimum ${n.minLength} characters`;
264
+ if (n.maxLength && t.length > n.maxLength) return n.message ?? `Maximum ${n.maxLength} characters`;
265
+ if (n.pattern && !new RegExp(n.pattern).test(t)) return n.message ?? "Invalid format";
266
+ }
267
+ return n.matchField && t !== r.value[n.matchField] ? n.message ?? "Does not match" : "";
268
+ }
269
+ function d(e, t) {
270
+ if (o(e) && e.name) {
271
+ let n = u(e);
272
+ n && (t[e.name] = n);
273
+ }
274
+ "children" in e && e.children.forEach((e) => d(e, t));
275
+ }
276
+ let f = t(() => {
277
+ let e = {};
278
+ if (d(n.schema, e), n.onValidate) {
279
+ let t = n.onValidate(r.value);
280
+ for (let [n, r] of Object.entries(t)) r && (e[n] = r);
281
+ }
282
+ return e;
283
+ }), p = t(() => Object.keys(f.value).length === 0);
284
+ function m(e) {
285
+ o(e) && e.name && (a.value[e.name] = !0), "children" in e && e.children.forEach(m);
286
+ }
287
+ let v = /* @__PURE__ */ new Set();
288
+ return g(B, {
289
+ get actions() {
290
+ return n.actions;
291
+ },
292
+ get assetResolver() {
293
+ return n.assetResolver;
294
+ },
295
+ get config() {
296
+ return n.config;
297
+ },
298
+ reportDisallowed(e) {
299
+ v.has(e) || (v.add(e), console.warn(`[CoarPageRenderer] Element type "${e}" is not in config.allowedElements; instances were skipped at render time.`));
300
+ },
301
+ isFormValid: p,
302
+ getValue: (e) => r.value[e],
303
+ setValue: (e, t) => {
304
+ r.value[e] = t;
305
+ },
306
+ getError: (e) => a.value[e] ? f.value[e] ?? "" : "",
307
+ markTouched: (e) => {
308
+ a.value[e] = !0;
309
+ },
310
+ triggerAction(e, t = !1) {
311
+ t && (m(n.schema), !p.value) || n.actions?.[e]?.(r.value);
312
+ }
313
+ }), (t, n) => (h(), i("div", K, [s(ne, { node: e.schema }, null, 8, ["node"])]));
314
+ }
315
+ }), [["__scopeId", "data-v-8ff147bf"]]), J = 0;
316
+ function Y() {
317
+ return J += 1, `node_${J}`;
318
+ }
319
+ function X(e) {
320
+ switch (e) {
321
+ case "page": return {
322
+ id: Y(),
323
+ type: "page",
324
+ children: []
325
+ };
326
+ case "stack": return {
327
+ id: Y(),
328
+ type: "stack",
329
+ children: []
330
+ };
331
+ case "card": return {
332
+ id: Y(),
333
+ type: "card",
334
+ children: []
335
+ };
336
+ case "section": return {
337
+ id: Y(),
338
+ type: "section",
339
+ title: "Section",
340
+ children: []
341
+ };
342
+ case "divider": return {
343
+ id: Y(),
344
+ type: "divider"
345
+ };
346
+ case "spacer": return {
347
+ id: Y(),
348
+ type: "spacer"
349
+ };
350
+ case "heading": return {
351
+ id: Y(),
352
+ type: "heading",
353
+ text: "Heading",
354
+ level: 2
355
+ };
356
+ case "paragraph": return {
357
+ id: Y(),
358
+ type: "paragraph",
359
+ text: "Paragraph text."
360
+ };
361
+ case "text-input": return {
362
+ id: Y(),
363
+ type: "text-input",
364
+ label: "Label",
365
+ name: Y()
366
+ };
367
+ case "checkbox": return {
368
+ id: Y(),
369
+ type: "checkbox",
370
+ label: "Checkbox",
371
+ name: Y()
372
+ };
373
+ case "select": return {
374
+ id: Y(),
375
+ type: "select",
376
+ label: "Select",
377
+ name: Y(),
378
+ options: [{
379
+ value: "a",
380
+ label: "Option A"
381
+ }, {
382
+ value: "b",
383
+ label: "Option B"
384
+ }]
385
+ };
386
+ case "button": return {
387
+ id: Y(),
388
+ type: "button",
389
+ label: "Button"
390
+ };
391
+ case "link": return {
392
+ id: Y(),
393
+ type: "link",
394
+ label: "Link"
395
+ };
396
+ case "image": return {
397
+ id: Y(),
398
+ type: "image",
399
+ assetId: ""
400
+ };
401
+ }
402
+ }
403
+ //#endregion
404
+ //#region src/builder/operations.ts
405
+ function Z(e, t) {
406
+ let n = e, r = null, i = -1;
407
+ for (let e of t) {
408
+ if (!V(n) || e < 0 || e >= n.children.length) return null;
409
+ r = n, i = e, n = n.children[e];
410
+ }
411
+ return {
412
+ path: t,
413
+ node: n,
414
+ parent: r,
415
+ index: i
416
+ };
417
+ }
418
+ function re(e, t) {
419
+ if (e === t) return [];
420
+ function n(e, r) {
421
+ if (!V(e)) return null;
422
+ for (let i = 0; i < e.children.length; i++) {
423
+ let a = e.children[i];
424
+ if (a === t) return [...r, i];
425
+ let o = n(a, [...r, i]);
426
+ if (o) return o;
427
+ }
428
+ return null;
429
+ }
430
+ return n(e, []);
431
+ }
432
+ function ie(e, t) {
433
+ if (e.length > t.length) return !1;
434
+ for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
435
+ return !0;
436
+ }
437
+ function ae(e, t, n, r) {
438
+ return fe(e, t, (e) => {
439
+ if (!V(e)) return e;
440
+ let t = Math.max(0, Math.min(n, e.children.length));
441
+ return {
442
+ ...e,
443
+ children: [
444
+ ...e.children.slice(0, t),
445
+ r,
446
+ ...e.children.slice(t)
447
+ ]
448
+ };
449
+ });
450
+ }
451
+ function oe(e, t) {
452
+ if (t.length === 0) return e;
453
+ let n = t.slice(0, -1), r = t[t.length - 1];
454
+ return fe(e, n, (e) => V(e) ? {
455
+ ...e,
456
+ children: e.children.filter((e, t) => t !== r)
457
+ } : e);
458
+ }
459
+ function se(e, t, n) {
460
+ if (t.length === 0) return n;
461
+ let r = t.slice(0, -1), i = t[t.length - 1];
462
+ return fe(e, r, (e) => V(e) ? {
463
+ ...e,
464
+ children: e.children.map((e, t) => t === i ? n : e)
465
+ } : e);
466
+ }
467
+ function ce(e, t, n) {
468
+ let r = Z(e, t);
469
+ if (!r) return e;
470
+ let i = r.node, a = { ...r.node }, o = !1;
471
+ for (let [e, t] of Object.entries(n)) e === "type" || e === "id" || (t === "" || t == null ? i[e] !== void 0 && (delete a[e], o = !0) : i[e] !== t && (a[e] = t, o = !0));
472
+ return o ? se(e, t, a) : e;
473
+ }
474
+ function le(e, t, n, r) {
475
+ if (t.length === 0 || ie(t, n)) return e;
476
+ let i = Z(e, t);
477
+ if (!i) return e;
478
+ let a = t.slice(0, -1), o = t[t.length - 1];
479
+ return de(a, n) && r === o ? e : ae(oe(e, t), n, r, i.node);
480
+ }
481
+ function ue(e, t, n) {
482
+ if (t.length === 0) return e;
483
+ let r = t.slice(0, -1), i = t[t.length - 1], a = Z(e, r);
484
+ if (!a || !V(a.node)) return e;
485
+ let o = i + n;
486
+ return o < 0 || o >= a.node.children.length ? e : le(e, t, r, o);
487
+ }
488
+ function de(e, t) {
489
+ if (e.length !== t.length) return !1;
490
+ for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
491
+ return !0;
492
+ }
493
+ function fe(e, t, n) {
494
+ function r(e, i) {
495
+ if (i === t.length) return n(e);
496
+ if (!V(e)) return e;
497
+ let a = t[i];
498
+ return a < 0 || a >= e.children.length ? e : {
499
+ ...e,
500
+ children: e.children.map((e, t) => t === a ? r(e, i + 1) : e)
501
+ };
502
+ }
503
+ return r(e, 0);
504
+ }
505
+ //#endregion
506
+ //#region src/builder/usePageBuilder.ts
507
+ var pe = 500;
508
+ function me(e = {}) {
509
+ let n = e.schema ?? x(e.initial ?? {
510
+ id: "root",
511
+ type: "page",
512
+ children: []
513
+ }), r = _([]), i = _(0), a = () => {
514
+ i.value++;
515
+ }, o = _([]), s = _([]), c = null;
516
+ function l(e, t) {
517
+ if (t.kind === "structural") {
518
+ o.value = [...o.value, e], s.value = [], c = { kind: "structural" };
519
+ return;
520
+ }
521
+ let n = t.path.join("/"), r = Date.now();
522
+ c?.kind === "patch" && c.pathKey === n && r - c.time < pe || (o.value = [...o.value, e], s.value = []), c = {
523
+ kind: "patch",
524
+ pathKey: n,
525
+ time: r
526
+ };
527
+ }
528
+ function u() {
529
+ if (o.value.length === 0) return;
530
+ let e = o.value[o.value.length - 1];
531
+ o.value = o.value.slice(0, -1), s.value = [...s.value, n.value], n.value = e, (!r.value || !Z(e, r.value)) && (r.value = []), c = null, a();
532
+ }
533
+ function d() {
534
+ if (s.value.length === 0) return;
535
+ let e = s.value[s.value.length - 1];
536
+ s.value = s.value.slice(0, -1), o.value = [...o.value, n.value], n.value = e, (!r.value || !Z(e, r.value)) && (r.value = []), c = null, a();
537
+ }
538
+ let f = t(() => o.value.length > 0), p = t(() => s.value.length > 0), m = t(() => r.value ? Z(n.value, r.value)?.node ?? null : null);
539
+ function h(e) {
540
+ r.value = e;
541
+ }
542
+ function g(e) {
543
+ r.value = re(n.value, e);
544
+ }
545
+ function v(e, t, i) {
546
+ let o = Z(n.value, e);
547
+ if (!o) return;
548
+ let s = n.value, c = X(t), u = "children" in o.node ? o.node.children.length : 0, d = i ?? u;
549
+ n.value = ae(n.value, e, d, c), r.value = [...e, d], l(s, { kind: "structural" }), a();
550
+ }
551
+ function y(e) {
552
+ if (e.length === 0) return;
553
+ let t = n.value, i = oe(n.value, e);
554
+ n.value = i;
555
+ let o = e.slice(0, -1), s = e[e.length - 1], c = Z(i, o);
556
+ if (c && "children" in c.node && c.node.children.length > 0) {
557
+ let e = Math.max(0, s - 1);
558
+ r.value = [...o, Math.min(e, c.node.children.length - 1)];
559
+ } else r.value = o;
560
+ l(t, { kind: "structural" }), a();
561
+ }
562
+ function b(e, t) {
563
+ let i = n.value, o = ue(i, e, t);
564
+ i !== o && (n.value = o, r.value = [...e.slice(0, -1), e[e.length - 1] + t], l(i, { kind: "structural" }), a());
565
+ }
566
+ function S(e, t, i) {
567
+ let o = n.value, s = le(o, e, t, i);
568
+ o !== s && (n.value = s, r.value = [...t, i], l(o, { kind: "structural" }), a());
569
+ }
570
+ function C(e, t) {
571
+ let r = n.value, i = ce(n.value, e, t);
572
+ r !== i && (n.value = i, l(r, {
573
+ kind: "patch",
574
+ path: e
575
+ }));
576
+ }
577
+ function w(e) {
578
+ let t = n.value;
579
+ n.value = e, r.value = [], l(t, { kind: "structural" }), a();
580
+ }
581
+ return {
582
+ schema: n,
583
+ selectedPath: r,
584
+ selectedNode: m,
585
+ structuralVersion: i,
586
+ canUndo: f,
587
+ canRedo: p,
588
+ select: h,
589
+ selectNode: g,
590
+ addChild: v,
591
+ remove: y,
592
+ move: b,
593
+ moveTo: S,
594
+ patch: C,
595
+ replaceSchema: w,
596
+ undo: u,
597
+ redo: d
598
+ };
599
+ }
600
+ //#endregion
601
+ //#region src/builder/useSchemaValidation.ts
602
+ function he(e, n) {
603
+ let r = t(() => {
604
+ let t = [], r = [], i = new Set(n.value?.availableActions?.map((e) => e.id) ?? []), a = (n.value?.availableActions?.length ?? 0) > 0, o = new Set([
605
+ "text-input",
606
+ "checkbox",
607
+ "select"
608
+ ]);
609
+ ge(e.value, (e) => {
610
+ if (e.type === "button" && (e.action ? a && !i.has(e.action) && t.push({
611
+ nodeId: e.id,
612
+ field: "action",
613
+ severity: "warning",
614
+ message: `Action "${e.action}" is not in config.availableActions.`
615
+ }) : t.push({
616
+ nodeId: e.id,
617
+ field: "action",
618
+ severity: "warning",
619
+ message: "Button has no Action — clicking it will do nothing."
620
+ })), e.type === "link" && (e.action ? a && !i.has(e.action) && t.push({
621
+ nodeId: e.id,
622
+ field: "action",
623
+ severity: "warning",
624
+ message: `Action "${e.action}" is not in config.availableActions.`
625
+ }) : t.push({
626
+ nodeId: e.id,
627
+ field: "action",
628
+ severity: "warning",
629
+ message: "Link has no Action — clicking it will do nothing."
630
+ })), e.type === "image" && !e.assetId && t.push({
631
+ nodeId: e.id,
632
+ field: "assetId",
633
+ severity: "error",
634
+ message: "Image has no Asset ID — nothing will render."
635
+ }), o.has(e.type)) {
636
+ let t = e.name;
637
+ t && r.push({
638
+ node: e,
639
+ name: t
640
+ });
641
+ }
642
+ });
643
+ let s = /* @__PURE__ */ new Map();
644
+ for (let { node: e, name: t } of r) {
645
+ let n = s.get(t) ?? [];
646
+ n.push(e), s.set(t, n);
647
+ }
648
+ for (let [e, n] of s) if (!(n.length < 2)) for (let r of n) t.push({
649
+ nodeId: r.id,
650
+ field: "name",
651
+ severity: "error",
652
+ message: `Duplicate field name "${e}" — values will overwrite each other.`
653
+ });
654
+ return t;
655
+ });
656
+ return {
657
+ issues: r,
658
+ byNodeId: t(() => {
659
+ let e = /* @__PURE__ */ new Map();
660
+ for (let t of r.value) {
661
+ let n = e.get(t.nodeId) ?? [];
662
+ n.push(t), e.set(t.nodeId, n);
663
+ }
664
+ return e;
665
+ })
666
+ };
667
+ }
668
+ function ge(e, t) {
669
+ if (t(e), "children" in e) for (let n of e.children) ge(n, t);
670
+ }
671
+ //#endregion
672
+ //#region src/builder/builderContext.ts
673
+ var Q = Symbol("PageBuilderApi"), $ = Symbol("PageBuilderConfig"), _e = Symbol("PageBuilderValidation"), ve = {
674
+ class: "pb-tree-grip",
675
+ "aria-hidden": "true"
676
+ }, ye = {
677
+ class: "pb-tree-type-icon",
678
+ "aria-hidden": "true"
679
+ }, be = { class: "pb-tree-label" }, xe = { class: "pb-tree-label-text" }, Se = {
680
+ key: 0,
681
+ class: "pb-tree-label-key"
682
+ }, Ce = ["title"], we = { class: "pb-tree-actions" }, Te = ["disabled"], Ee = ["disabled"], De = {
683
+ key: 0,
684
+ class: "pb-tree-add__menu",
685
+ role: "menu"
686
+ }, Oe = ["onClick"], ke = ["onClick"], Ae = /* @__PURE__ */ G(/* @__PURE__ */ c({
687
+ name: "BuilderOutlineNode",
688
+ __name: "BuilderOutlineNode",
689
+ props: {
690
+ node: {},
691
+ path: {},
692
+ depth: { default: 0 }
693
+ },
694
+ setup(o) {
695
+ let c = o, u = l(Q), g = l($), b = l(_e), x = t(() => N.filter((e) => H(e.type, g?.value))), w = t(() => b?.byNodeId.value.get(c.node.id) ?? []), T = t(() => w.value.some((e) => e.severity === "error") ? "error" : w.value.length > 0 ? "warning" : null), E = t(() => w.value.map((e) => `• ${e.message}`).join("\n")), D = t(() => c.path.length === 0), k = t(() => {
696
+ let e = u.selectedPath.value;
697
+ return e !== null && e.length === c.path.length && e.every((e, t) => e === c.path[t]);
698
+ }), A = {
699
+ page: "file",
700
+ stack: "layers",
701
+ card: "square-dashed",
702
+ section: "panel-left",
703
+ divider: "minus",
704
+ spacer: "more-horizontal",
705
+ heading: "heading",
706
+ paragraph: "pilcrow",
707
+ "text-input": "file-text",
708
+ checkbox: "check-circle-2",
709
+ select: "list",
710
+ button: "zap",
711
+ link: "link",
712
+ image: "image"
713
+ }, j = t(() => {
714
+ let e = c.node;
715
+ return e.type === "page" ? "Page" : e.type === "stack" ? e.direction === "row" ? "Row" : "Column" : e.text ? String(e.text) : e.label ? String(e.label) : e.title ? String(e.title) : e.type;
716
+ }), M = t(() => {
717
+ let e = c.node;
718
+ return e.name ? String(e.name) : void 0;
719
+ }), N = [
720
+ {
721
+ type: "stack",
722
+ label: "Stack",
723
+ icon: "layers",
724
+ group: "container"
725
+ },
726
+ {
727
+ type: "card",
728
+ label: "Card",
729
+ icon: "square-dashed",
730
+ group: "container"
731
+ },
732
+ {
733
+ type: "section",
734
+ label: "Section",
735
+ icon: "panel-left",
736
+ group: "container"
737
+ },
738
+ {
739
+ type: "heading",
740
+ label: "Heading",
741
+ icon: "heading",
742
+ group: "element"
743
+ },
744
+ {
745
+ type: "paragraph",
746
+ label: "Paragraph",
747
+ icon: "pilcrow",
748
+ group: "element"
749
+ },
750
+ {
751
+ type: "divider",
752
+ label: "Divider",
753
+ icon: "minus",
754
+ group: "element"
755
+ },
756
+ {
757
+ type: "spacer",
758
+ label: "Spacer",
759
+ icon: "more-horizontal",
760
+ group: "element"
761
+ },
762
+ {
763
+ type: "text-input",
764
+ label: "Text Input",
765
+ icon: "file-text",
766
+ group: "element"
767
+ },
768
+ {
769
+ type: "checkbox",
770
+ label: "Checkbox",
771
+ icon: "check-circle-2",
772
+ group: "element"
773
+ },
774
+ {
775
+ type: "select",
776
+ label: "Select",
777
+ icon: "list",
778
+ group: "element"
779
+ },
780
+ {
781
+ type: "button",
782
+ label: "Button",
783
+ icon: "zap",
784
+ group: "element"
785
+ },
786
+ {
787
+ type: "link",
788
+ label: "Link",
789
+ icon: "link",
790
+ group: "element"
791
+ },
792
+ {
793
+ type: "image",
794
+ label: "Image",
795
+ icon: "image",
796
+ group: "element"
797
+ }
798
+ ], F = _(!1), I = _(null);
799
+ function L() {
800
+ F.value = !F.value;
801
+ }
802
+ function ee(e) {
803
+ F.value = !1, u.addChild(c.path, e);
804
+ }
805
+ function R(e) {
806
+ if (!F.value) return;
807
+ let t = e.target;
808
+ t && I.value && !I.value.contains(t) && (F.value = !1);
809
+ }
810
+ function z(e) {
811
+ e.key === "Escape" && (F.value = !1);
812
+ }
813
+ m(() => {
814
+ document.addEventListener("click", R), document.addEventListener("keydown", z);
815
+ }), p(() => {
816
+ document.removeEventListener("click", R), document.removeEventListener("keydown", z);
817
+ });
818
+ function B() {
819
+ return c.path.length > 0 && c.path[c.path.length - 1] > 0;
820
+ }
821
+ function U() {
822
+ if (c.path.length === 0) return !1;
823
+ let e = c.path.slice(0, -1), t = c.path[c.path.length - 1], n = u.schema.value;
824
+ for (let t of e) {
825
+ if (!V(n)) return !1;
826
+ n = n.children[t];
827
+ }
828
+ return V(n) && t < n.children.length - 1;
829
+ }
830
+ return (t, c) => {
831
+ let l = y("BuilderOutlineNode", !0);
832
+ return h(), i("div", { class: d(["pb-tree-node", {
833
+ "pb-tree-node--selected": k.value,
834
+ "pb-tree-node--root": D.value
835
+ }]) }, [a("div", {
836
+ class: "pb-tree-row",
837
+ style: f({ paddingLeft: `${8 + o.depth * 16}px` }),
838
+ onClick: c[3] ||= O((e) => C(u).select(o.path), ["stop"])
839
+ }, [
840
+ a("span", ve, [s(C(P), {
841
+ name: "grip-vertical",
842
+ size: "xs"
843
+ })]),
844
+ a("span", ye, [s(C(P), {
845
+ name: A[o.node.type],
846
+ size: "s"
847
+ }, null, 8, ["name"])]),
848
+ a("span", be, [a("span", xe, S(j.value), 1), M.value ? (h(), i("span", Se, S(M.value), 1)) : r("", !0)]),
849
+ T.value ? (h(), i("span", {
850
+ key: 0,
851
+ class: d(["pb-tree-issue", `pb-tree-issue--${T.value}`]),
852
+ title: E.value,
853
+ "aria-label": "Validation issues"
854
+ }, [s(C(P), {
855
+ name: T.value === "error" ? "circle-alert" : "triangle-alert",
856
+ size: "s"
857
+ }, null, 8, ["name"])], 10, Ce)) : r("", !0),
858
+ a("div", we, [
859
+ D.value ? r("", !0) : (h(), i("button", {
860
+ key: 0,
861
+ type: "button",
862
+ class: "pb-tree-btn",
863
+ disabled: !B(),
864
+ title: "Move up",
865
+ onClick: c[0] ||= O((e) => C(u).move(o.path, -1), ["stop"])
866
+ }, [s(C(P), {
867
+ name: "chevron-up",
868
+ size: "s"
869
+ })], 8, Te)),
870
+ D.value ? r("", !0) : (h(), i("button", {
871
+ key: 1,
872
+ type: "button",
873
+ class: "pb-tree-btn",
874
+ disabled: !U(),
875
+ title: "Move down",
876
+ onClick: c[1] ||= O((e) => C(u).move(o.path, 1), ["stop"])
877
+ }, [s(C(P), {
878
+ name: "chevron-down",
879
+ size: "s"
880
+ })], 8, Ee)),
881
+ D.value ? r("", !0) : (h(), i("button", {
882
+ key: 2,
883
+ type: "button",
884
+ class: "pb-tree-btn pb-tree-btn--danger",
885
+ title: "Delete",
886
+ onClick: c[2] ||= O((e) => C(u).remove(o.path), ["stop"])
887
+ }, [s(C(P), {
888
+ name: "trash-2",
889
+ size: "s"
890
+ })]))
891
+ ])
892
+ ], 4), C(V)(o.node) ? (h(), i(e, { key: 0 }, [(h(!0), i(e, null, v(o.node.children, (e, t) => (h(), n(l, {
893
+ key: t,
894
+ node: e,
895
+ path: [...o.path, t],
896
+ depth: o.depth + 1
897
+ }, null, 8, [
898
+ "node",
899
+ "path",
900
+ "depth"
901
+ ]))), 128)), a("div", {
902
+ ref_key: "addMenuRoot",
903
+ ref: I,
904
+ class: "pb-tree-add",
905
+ style: f({ paddingLeft: `${8 + (o.depth + 1) * 16}px` })
906
+ }, [a("button", {
907
+ type: "button",
908
+ class: d(["pb-tree-add__trigger", { "pb-tree-add__trigger--open": F.value }]),
909
+ onClick: O(L, ["stop"])
910
+ }, [s(C(P), {
911
+ name: "plus",
912
+ size: "s"
913
+ }), c[4] ||= a("span", null, "Add child", -1)], 2), F.value ? (h(), i("div", De, [
914
+ c[5] ||= a("div", { class: "pb-tree-add__group-label" }, "Containers", -1),
915
+ (h(!0), i(e, null, v(x.value.filter((e) => e.group === "container"), (e) => (h(), i("button", {
916
+ key: e.type,
917
+ type: "button",
918
+ class: "pb-tree-add__item",
919
+ role: "menuitem",
920
+ onClick: O((t) => ee(e.type), ["stop"])
921
+ }, [s(C(P), {
922
+ name: e.icon,
923
+ size: "s"
924
+ }, null, 8, ["name"]), a("span", null, S(e.label), 1)], 8, Oe))), 128)),
925
+ c[6] ||= a("div", { class: "pb-tree-add__divider" }, null, -1),
926
+ c[7] ||= a("div", { class: "pb-tree-add__group-label" }, "Elements", -1),
927
+ (h(!0), i(e, null, v(x.value.filter((e) => e.group === "element"), (e) => (h(), i("button", {
928
+ key: e.type,
929
+ type: "button",
930
+ class: "pb-tree-add__item",
931
+ role: "menuitem",
932
+ onClick: O((t) => ee(e.type), ["stop"])
933
+ }, [s(C(P), {
934
+ name: e.icon,
935
+ size: "s"
936
+ }, null, 8, ["name"]), a("span", null, S(e.label), 1)], 8, ke))), 128))
937
+ ])) : r("", !0)], 4)], 64)) : r("", !0)], 2);
938
+ };
939
+ }
940
+ }), [["__scopeId", "data-v-be04973b"]]), je = { class: "pb-outline-wrap" }, Me = /* @__PURE__ */ G(/* @__PURE__ */ c({
941
+ name: "BuilderOutline",
942
+ __name: "BuilderOutline",
943
+ setup(e) {
944
+ let t = l(Q);
945
+ return (e, n) => (h(), i("div", je, [s(Ae, {
946
+ node: C(t).schema.value,
947
+ path: [],
948
+ depth: 0
949
+ }, null, 8, ["node"])]));
950
+ }
951
+ }), [["__scopeId", "data-v-fc62f26e"]]), Ne = Symbol("PageBuilderDnd"), Pe = 80;
952
+ function Fe(e) {
953
+ let t = _(!1), n = _(null), r = _(null), i = null;
954
+ function a() {
955
+ i !== null && (clearTimeout(i), i = null);
956
+ }
957
+ function o(e) {
958
+ let t = n.value;
959
+ return t ? t.kind === "new" ? !0 : !ie(t.path, e) : !1;
960
+ }
961
+ function s(e) {
962
+ a(), t.value = !0, n.value = e;
963
+ }
964
+ function c() {
965
+ t.value = !1, n.value = null, r.value = null, a();
966
+ }
967
+ function l(e, t) {
968
+ return o(t) ? (a(), r.value = e, !0) : !1;
969
+ }
970
+ function u(e) {
971
+ r.value === e && (a(), i = setTimeout(() => {
972
+ r.value === e && (r.value = null), i = null;
973
+ }, Pe));
974
+ }
975
+ function d(t, r) {
976
+ let i = n.value;
977
+ if (!i || !o(t)) return;
978
+ if (i.kind === "new") {
979
+ e.addChild(t, i.type, r);
980
+ return;
981
+ }
982
+ let a = i.path;
983
+ if (a.length === 0) return;
984
+ let s = a.slice(0, -1), c = a[a.length - 1], l = s.length === t.length && s.every((e, n) => e === t[n]), u = r;
985
+ l && (c < r && (u = r - 1), u === c) || e.moveTo(a, t, u);
986
+ }
987
+ let f = {
988
+ isDragging: t,
989
+ payload: n,
990
+ activeZoneKey: r,
991
+ startDrag: s,
992
+ endDrag: c,
993
+ onZoneEnter: l,
994
+ onZoneLeave: u,
995
+ onZoneDrop: d,
996
+ canDrop: o
997
+ };
998
+ return g(Ne, f), f;
999
+ }
1000
+ function Ie() {
1001
+ let e = l(Ne);
1002
+ if (!e) throw Error("useBuilderDnd must be called inside CoarPageBuilder.");
1003
+ return e;
1004
+ }
1005
+ //#endregion
1006
+ //#region src/builder/BuilderCanvasNode.vue?vue&type=script&setup=true&lang.ts
1007
+ var Le = ["title", "draggable"], Re = { class: "canvas-node__tab-label" }, ze = {
1008
+ key: 0,
1009
+ class: "canvas-node__section-title"
1010
+ }, Be = ["data-dropzone"], Ve = ["data-dropzone"], He = [
1011
+ "data-dropzone",
1012
+ "onDragenter",
1013
+ "onDragover",
1014
+ "onDragleave",
1015
+ "onDrop"
1016
+ ], Ue = {
1017
+ key: 2,
1018
+ class: "canvas-node__preview"
1019
+ }, We = {
1020
+ key: 1,
1021
+ class: "canvas-node__spacer-preview"
1022
+ }, Ge = {
1023
+ key: 3,
1024
+ class: "canvas-node__paragraph"
1025
+ }, Ke = {
1026
+ key: 8,
1027
+ class: "canvas-node__link",
1028
+ type: "button"
1029
+ }, qe = ["src", "alt"], Je = {
1030
+ key: 1,
1031
+ class: "canvas-node__image-placeholder"
1032
+ }, Ye = /* @__PURE__ */ G(/* @__PURE__ */ c({
1033
+ name: "BuilderCanvasNode",
1034
+ __name: "BuilderCanvasNode",
1035
+ props: {
1036
+ node: {},
1037
+ path: {}
1038
+ },
1039
+ setup(c) {
1040
+ let u = c, p = l(Q), m = l($), g = Ie();
1041
+ function _(e) {
1042
+ return m?.value?.assetResolver?.(e) ?? "";
1043
+ }
1044
+ let x = t(() => u.path.length === 0), w = t(() => u.path.join("/")), T = t(() => {
1045
+ let e = g.payload.value;
1046
+ return !e || e.kind !== "move" ? !1 : e.path.length === u.path.length && e.path.every((e, t) => e === u.path[t]);
1047
+ }), E = t(() => {
1048
+ let e = p.selectedPath.value;
1049
+ return e !== null && e.length === u.path.length && e.every((e, t) => e === u.path[t]);
1050
+ }), A = {
1051
+ page: "file",
1052
+ stack: "layers",
1053
+ card: "square-dashed",
1054
+ section: "panel-left",
1055
+ divider: "minus",
1056
+ spacer: "more-horizontal",
1057
+ heading: "heading",
1058
+ paragraph: "pilcrow",
1059
+ "text-input": "file-text",
1060
+ checkbox: "check-circle-2",
1061
+ select: "list",
1062
+ button: "zap",
1063
+ link: "link",
1064
+ image: "image"
1065
+ }, L = t(() => {
1066
+ let e = u.node;
1067
+ return e.text ? `${e.type} · ${String(e.text).slice(0, 24)}` : e.label ? `${e.type} · ${String(e.label).slice(0, 24)}` : e.title ? `${e.type} · ${String(e.title).slice(0, 24)}` : e.name ? `${e.type} · ${String(e.name)}` : e.type;
1068
+ }), ee = t(() => V(u.node) ? "container" : "element"), B = t(() => {
1069
+ let e = u.node;
1070
+ return e.type === "stack" ? e.direction ?? "column" : "column";
1071
+ }), H = t(() => {
1072
+ let e = u.node;
1073
+ if (!V(e)) return {};
1074
+ let t = e.style?.gap, n = e.style?.align, r = e.style?.padding;
1075
+ switch (e.type) {
1076
+ case "page":
1077
+ case "section": return {
1078
+ display: "flex",
1079
+ flexDirection: "column",
1080
+ ...t && { gap: t },
1081
+ ...n && { alignItems: n },
1082
+ ...r && { padding: r }
1083
+ };
1084
+ case "stack": return {
1085
+ display: "flex",
1086
+ flexDirection: e.direction ?? "column",
1087
+ ...t && { gap: t },
1088
+ ...n && { alignItems: n },
1089
+ ...r && { padding: r }
1090
+ };
1091
+ case "card": return {
1092
+ display: "flex",
1093
+ flexDirection: "column",
1094
+ ...t && { gap: t },
1095
+ ...n && { alignItems: n }
1096
+ };
1097
+ default: return {};
1098
+ }
1099
+ }), U = t(() => {
1100
+ let e = u.node.style;
1101
+ if (!e) return {};
1102
+ let t = {};
1103
+ return e.width && (t.width = e.width), t;
1104
+ });
1105
+ function W(e) {
1106
+ return (e ?? []).map((e) => ({
1107
+ value: e.value,
1108
+ label: e.label
1109
+ }));
1110
+ }
1111
+ function te(e) {
1112
+ e.stopPropagation(), p.select(u.path);
1113
+ }
1114
+ function G(e) {
1115
+ if (x.value) {
1116
+ e.preventDefault();
1117
+ return;
1118
+ }
1119
+ if (!e.dataTransfer) return;
1120
+ g.startDrag({
1121
+ kind: "move",
1122
+ path: [...u.path]
1123
+ }), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData("text/plain", "move");
1124
+ let t = e.currentTarget?.closest(".canvas-node");
1125
+ t && z(e, t, {
1126
+ offsetX: 20,
1127
+ offsetY: 16
1128
+ }), e.stopPropagation();
1129
+ }
1130
+ function ne() {
1131
+ g.endDrag();
1132
+ }
1133
+ function K(e) {
1134
+ return `${w.value}:${e}`;
1135
+ }
1136
+ function q(e) {
1137
+ return g.activeZoneKey.value === K(e);
1138
+ }
1139
+ function J(e) {
1140
+ let t = g.isDragging.value, n = g.canDrop(u.path);
1141
+ return {
1142
+ "canvas-dropzone--drag-active": t && n,
1143
+ "canvas-dropzone--disabled": t && !n,
1144
+ "canvas-dropzone--over": q(e)
1145
+ };
1146
+ }
1147
+ function Y(e, t) {
1148
+ g.onZoneEnter(K(t), u.path) && e.preventDefault();
1149
+ }
1150
+ function X(e, t) {
1151
+ g.canDrop(u.path) && (e.preventDefault(), q(t) || g.onZoneEnter(K(t), u.path));
1152
+ }
1153
+ function Z(e) {
1154
+ g.onZoneLeave(K(e));
1155
+ }
1156
+ function re(e, t) {
1157
+ e.preventDefault(), e.stopPropagation(), g.onZoneDrop([...u.path], t), g.endDrag();
1158
+ }
1159
+ return (t, l) => {
1160
+ let u = y("BuilderCanvasNode", !0);
1161
+ return h(), i("div", {
1162
+ class: d(["canvas-node", [`canvas-node--${ee.value}`, {
1163
+ "canvas-node--selected": E.value,
1164
+ "canvas-node--root": x.value,
1165
+ "canvas-node--dragging": T.value
1166
+ }]]),
1167
+ style: f(U.value),
1168
+ onClick: te
1169
+ }, [
1170
+ a("span", {
1171
+ class: d(["canvas-node__tab", { "canvas-node__tab--grabbable": !x.value }]),
1172
+ title: L.value,
1173
+ draggable: !x.value,
1174
+ onDragstart: G,
1175
+ onDragend: ne
1176
+ }, [s(C(P), {
1177
+ name: A[c.node.type],
1178
+ size: "xs"
1179
+ }, null, 8, ["name"]), a("span", Re, S(L.value), 1)], 42, Le),
1180
+ x.value ? r("", !0) : (h(), i("button", {
1181
+ key: 0,
1182
+ type: "button",
1183
+ class: "canvas-node__delete",
1184
+ title: "Delete",
1185
+ onClick: l[0] ||= O((e) => C(p).remove(c.path), ["stop"])
1186
+ }, [s(C(P), {
1187
+ name: "x",
1188
+ size: "xs"
1189
+ })])),
1190
+ C(V)(c.node) ? (h(), i("div", {
1191
+ key: 1,
1192
+ class: d(["canvas-node__body", [`canvas-node__body--${c.node.type}`, `canvas-node__body--dir-${B.value}`]]),
1193
+ style: f(H.value)
1194
+ }, [c.node.type === "section" && c.node.title ? (h(), i("div", ze, S(c.node.title), 1)) : r("", !0), c.node.children.length === 0 ? (h(), i("div", {
1195
+ key: 1,
1196
+ class: d(["canvas-dropzone canvas-dropzone--empty", J(0)]),
1197
+ "data-dropzone": K(0),
1198
+ onDragenter: l[1] ||= (e) => Y(e, 0),
1199
+ onDragover: l[2] ||= (e) => X(e, 0),
1200
+ onDragleave: l[3] ||= (e) => Z(0),
1201
+ onDrop: l[4] ||= (e) => re(e, 0)
1202
+ }, " Empty " + S(c.node.type) + " — drop something here ", 43, Be)) : (h(), i(e, { key: 2 }, [a("div", {
1203
+ class: d(["canvas-dropzone", [`canvas-dropzone--${B.value}`, J(0)]]),
1204
+ "data-dropzone": K(0),
1205
+ "aria-hidden": "true",
1206
+ onDragenter: l[5] ||= (e) => Y(e, 0),
1207
+ onDragover: l[6] ||= (e) => X(e, 0),
1208
+ onDragleave: l[7] ||= (e) => Z(0),
1209
+ onDrop: l[8] ||= (e) => re(e, 0)
1210
+ }, null, 42, Ve), (h(!0), i(e, null, v(c.node.children, (t, n) => (h(), i(e, { key: t.id }, [s(u, {
1211
+ node: t,
1212
+ path: [...c.path, n]
1213
+ }, null, 8, ["node", "path"]), a("div", {
1214
+ class: d(["canvas-dropzone", [`canvas-dropzone--${B.value}`, J(n + 1)]]),
1215
+ "data-dropzone": K(n + 1),
1216
+ "aria-hidden": "true",
1217
+ onDragenter: (e) => Y(e, n + 1),
1218
+ onDragover: (e) => X(e, n + 1),
1219
+ onDragleave: (e) => Z(n + 1),
1220
+ onDrop: (e) => re(e, n + 1)
1221
+ }, null, 42, He)], 64))), 128))], 64))], 6)) : (h(), i("div", Ue, [c.node.type === "divider" ? (h(), n(C(M), { key: 0 })) : c.node.type === "spacer" ? (h(), i("div", We)) : c.node.type === "heading" ? (h(), n(b(`h${c.node.level ?? 2}`), {
1222
+ key: 2,
1223
+ class: "canvas-node__heading"
1224
+ }, {
1225
+ default: D(() => [o(S(c.node.text || "Heading"), 1)]),
1226
+ _: 1
1227
+ })) : c.node.type === "paragraph" ? (h(), i("p", Ge, S(c.node.text || "Paragraph text."), 1)) : c.node.type === "text-input" ? (h(), n(C(N), {
1228
+ key: 4,
1229
+ label: c.node.label,
1230
+ required: c.node.validation?.required
1231
+ }, {
1232
+ default: D(() => [c.node.inputType === "password" ? (h(), n(C(F), {
1233
+ key: 0,
1234
+ "model-value": "",
1235
+ placeholder: c.node.placeholder,
1236
+ disabled: ""
1237
+ }, null, 8, ["placeholder"])) : (h(), n(C(R), {
1238
+ key: 1,
1239
+ "model-value": "",
1240
+ placeholder: c.node.placeholder,
1241
+ readonly: ""
1242
+ }, null, 8, ["placeholder"]))]),
1243
+ _: 1
1244
+ }, 8, ["label", "required"])) : c.node.type === "checkbox" ? (h(), n(C(j), {
1245
+ key: 5,
1246
+ "model-value": !1,
1247
+ label: c.node.label || "Checkbox",
1248
+ required: c.node.validation?.required,
1249
+ disabled: ""
1250
+ }, null, 8, ["label", "required"])) : c.node.type === "select" ? (h(), n(C(N), {
1251
+ key: 6,
1252
+ label: c.node.label,
1253
+ required: c.node.validation?.required
1254
+ }, {
1255
+ default: D(() => [s(C(I), {
1256
+ "model-value": null,
1257
+ options: W(c.node.options),
1258
+ placeholder: c.node.placeholder,
1259
+ disabled: ""
1260
+ }, null, 8, ["options", "placeholder"])]),
1261
+ _: 1
1262
+ }, 8, ["label", "required"])) : c.node.type === "button" ? (h(), n(C(k), {
1263
+ key: 7,
1264
+ variant: c.node.variant ?? "primary",
1265
+ size: c.node.size,
1266
+ style: f(c.node.style?.width ? { width: c.node.style.width } : {}),
1267
+ disabled: ""
1268
+ }, {
1269
+ default: D(() => [o(S(c.node.label || "Button"), 1)]),
1270
+ _: 1
1271
+ }, 8, [
1272
+ "variant",
1273
+ "size",
1274
+ "style"
1275
+ ])) : c.node.type === "link" ? (h(), i("button", Ke, S(c.node.label || "Link"), 1)) : c.node.type === "image" ? (h(), i(e, { key: 9 }, [c.node.assetId && _(c.node.assetId) ? (h(), i("img", {
1276
+ key: 0,
1277
+ src: _(c.node.assetId),
1278
+ alt: c.node.alt ?? "",
1279
+ class: "canvas-node__image-preview"
1280
+ }, null, 8, qe)) : (h(), i("div", Je, [s(C(P), {
1281
+ name: "image",
1282
+ size: "m"
1283
+ }), a("span", null, S(c.node.assetId || "No image"), 1)]))], 64)) : r("", !0)]))
1284
+ ], 6);
1285
+ };
1286
+ }
1287
+ }), [["__scopeId", "data-v-3ae4c5ac"]]), Xe = { class: "pb-canvas-shell" }, Ze = { class: "pb-palette" }, Qe = { class: "pb-palette__group" }, $e = ["title", "onDragstart"], et = { class: "pb-palette__group" }, tt = ["title", "onDragstart"], nt = 120, rt = 60, it = /* @__PURE__ */ G(/* @__PURE__ */ c({
1288
+ name: "BuilderCanvas",
1289
+ __name: "BuilderCanvas",
1290
+ setup(n) {
1291
+ let r = l(Q), o = l($), c = Fe(r), u = t(() => f.filter((e) => H(e.type, o?.value))), f = [
1292
+ {
1293
+ type: "stack",
1294
+ label: "Stack",
1295
+ icon: "layers",
1296
+ group: "container"
1297
+ },
1298
+ {
1299
+ type: "card",
1300
+ label: "Card",
1301
+ icon: "square-dashed",
1302
+ group: "container"
1303
+ },
1304
+ {
1305
+ type: "section",
1306
+ label: "Section",
1307
+ icon: "panel-left",
1308
+ group: "container"
1309
+ },
1310
+ {
1311
+ type: "heading",
1312
+ label: "Heading",
1313
+ icon: "heading",
1314
+ group: "element"
1315
+ },
1316
+ {
1317
+ type: "paragraph",
1318
+ label: "Paragraph",
1319
+ icon: "pilcrow",
1320
+ group: "element"
1321
+ },
1322
+ {
1323
+ type: "divider",
1324
+ label: "Divider",
1325
+ icon: "minus",
1326
+ group: "element"
1327
+ },
1328
+ {
1329
+ type: "spacer",
1330
+ label: "Spacer",
1331
+ icon: "more-horizontal",
1332
+ group: "element"
1333
+ },
1334
+ {
1335
+ type: "text-input",
1336
+ label: "Text Input",
1337
+ icon: "file-text",
1338
+ group: "element"
1339
+ },
1340
+ {
1341
+ type: "checkbox",
1342
+ label: "Checkbox",
1343
+ icon: "check-circle-2",
1344
+ group: "element"
1345
+ },
1346
+ {
1347
+ type: "select",
1348
+ label: "Select",
1349
+ icon: "list",
1350
+ group: "element"
1351
+ },
1352
+ {
1353
+ type: "button",
1354
+ label: "Button",
1355
+ icon: "zap",
1356
+ group: "element"
1357
+ },
1358
+ {
1359
+ type: "link",
1360
+ label: "Link",
1361
+ icon: "link",
1362
+ group: "element"
1363
+ },
1364
+ {
1365
+ type: "image",
1366
+ label: "Image",
1367
+ icon: "image",
1368
+ group: "element"
1369
+ }
1370
+ ];
1371
+ function g(e) {
1372
+ let t = c.payload.value;
1373
+ return !!(t && t.kind === "new" && t.type === e);
1374
+ }
1375
+ function _(e, t) {
1376
+ if (!e.dataTransfer) return;
1377
+ c.startDrag({
1378
+ kind: "new",
1379
+ type: t
1380
+ }), e.dataTransfer.effectAllowed = "copy", e.dataTransfer.setData("text/plain", t);
1381
+ let n = e.currentTarget;
1382
+ n && z(e, n);
1383
+ }
1384
+ function y() {
1385
+ c.endDrag();
1386
+ }
1387
+ function b() {
1388
+ r.select([]);
1389
+ }
1390
+ function x(e) {
1391
+ if (!c.isDragging.value) return;
1392
+ let t = e.clientX, n = e.clientY, r = document.querySelectorAll(".canvas-dropzone:not(.canvas-dropzone--empty)");
1393
+ for (let e of r) {
1394
+ let r = e.getBoundingClientRect(), i = Math.max(r.left - t, 0, t - r.right), a = Math.max(r.top - n, 0, n - r.bottom), o = Math.hypot(i, a);
1395
+ if (o >= nt) e.style.opacity = "0", e.style.pointerEvents = "none";
1396
+ else {
1397
+ let t = 1 - o / nt;
1398
+ e.style.opacity = t.toFixed(3), e.style.pointerEvents = o <= rt ? "auto" : "none";
1399
+ }
1400
+ }
1401
+ }
1402
+ function w() {
1403
+ let e = document.querySelectorAll(".canvas-dropzone:not(.canvas-dropzone--empty)");
1404
+ for (let t of e) t.style.opacity = "", t.style.pointerEvents = "";
1405
+ }
1406
+ E(() => c.isDragging.value, (e) => {
1407
+ e || w();
1408
+ });
1409
+ function T(e) {
1410
+ let t = e.ctrlKey || e.metaKey;
1411
+ if (t && (e.key === "z" || e.key === "Z")) {
1412
+ e.preventDefault(), e.shiftKey ? r.redo() : r.undo();
1413
+ return;
1414
+ }
1415
+ if (t && (e.key === "y" || e.key === "Y")) {
1416
+ e.preventDefault(), r.redo();
1417
+ return;
1418
+ }
1419
+ if (e.key !== "Delete" && e.key !== "Backspace") return;
1420
+ let n = e.target;
1421
+ if (!n) return;
1422
+ let i = n.tagName;
1423
+ if (i === "INPUT" || i === "TEXTAREA" || i === "SELECT" || n.isContentEditable) return;
1424
+ let a = r.selectedPath.value;
1425
+ !a || a.length === 0 || (e.preventDefault(), r.remove(a));
1426
+ }
1427
+ return m(() => window.addEventListener("keydown", T)), p(() => window.removeEventListener("keydown", T)), (t, n) => (h(), i("div", Xe, [a("div", Ze, [
1428
+ a("div", Qe, [n[0] ||= a("span", { class: "pb-palette__label" }, "Containers", -1), (h(!0), i(e, null, v(u.value.filter((e) => e.group === "container"), (e) => (h(), i("button", {
1429
+ key: e.type,
1430
+ type: "button",
1431
+ class: d(["pb-palette__card pb-palette__card--container", { "pb-palette__card--dragging": g(e.type) }]),
1432
+ title: `Drag to add ${e.label}`,
1433
+ draggable: "true",
1434
+ onDragstart: (t) => _(t, e.type),
1435
+ onDragend: y
1436
+ }, [s(C(P), {
1437
+ name: e.icon,
1438
+ size: "s"
1439
+ }, null, 8, ["name"]), a("span", null, S(e.label), 1)], 42, $e))), 128))]),
1440
+ n[2] ||= a("div", { class: "pb-palette__divider" }, null, -1),
1441
+ a("div", et, [n[1] ||= a("span", { class: "pb-palette__label" }, "Elements", -1), (h(!0), i(e, null, v(u.value.filter((e) => e.group === "element"), (e) => (h(), i("button", {
1442
+ key: e.type,
1443
+ type: "button",
1444
+ class: d(["pb-palette__card pb-palette__card--element", { "pb-palette__card--dragging": g(e.type) }]),
1445
+ title: `Drag to add ${e.label}`,
1446
+ draggable: "true",
1447
+ onDragstart: (t) => _(t, e.type),
1448
+ onDragend: y
1449
+ }, [s(C(P), {
1450
+ name: e.icon,
1451
+ size: "s"
1452
+ }, null, 8, ["name"]), a("span", null, S(e.label), 1)], 42, tt))), 128))])
1453
+ ]), a("div", {
1454
+ class: d(["pb-canvas", { "pb-canvas--dragging": C(c).isDragging.value }]),
1455
+ onClick: O(b, ["self"]),
1456
+ onDragover: x
1457
+ }, [s(Ye, {
1458
+ node: C(r).schema.value,
1459
+ path: []
1460
+ }, null, 8, ["node"])], 34)]));
1461
+ }
1462
+ }), [["__scopeId", "data-v-4d674269"]]), at = { class: "pb-prop-group" }, ot = {
1463
+ class: "pb-prop-seg",
1464
+ role: "radiogroup",
1465
+ "aria-label": "Stack direction"
1466
+ }, st = ["aria-checked"], ct = ["aria-checked"], lt = /* @__PURE__ */ G(/* @__PURE__ */ c({
1467
+ __name: "StackProps",
1468
+ props: {
1469
+ node: {},
1470
+ patch: { type: Function }
1471
+ },
1472
+ setup(t) {
1473
+ let o = t;
1474
+ return (t, s) => (h(), i(e, null, [a("div", at, [s[3] ||= a("span", { class: "pb-prop-label" }, "Direction", -1), a("div", ot, [a("button", {
1475
+ type: "button",
1476
+ class: d(["pb-prop-seg__btn", { "pb-prop-seg__btn--active": (o.node.direction ?? "column") === "column" }]),
1477
+ role: "radio",
1478
+ "aria-checked": (o.node.direction ?? "column") === "column",
1479
+ onClick: s[0] ||= (e) => o.patch({ direction: "column" })
1480
+ }, " ↓ Column ", 10, st), a("button", {
1481
+ type: "button",
1482
+ class: d(["pb-prop-seg__btn", { "pb-prop-seg__btn--active": o.node.direction === "row" }]),
1483
+ role: "radio",
1484
+ "aria-checked": o.node.direction === "row",
1485
+ onClick: s[1] ||= (e) => o.patch({ direction: "row" })
1486
+ }, " → Row ", 10, ct)])]), o.node.direction === "row" ? (h(), n(C(j), {
1487
+ key: 0,
1488
+ "model-value": !!o.node.wrap,
1489
+ label: "Wrap children",
1490
+ "onUpdate:modelValue": s[2] ||= (e) => o.patch({ wrap: e })
1491
+ }, null, 8, ["model-value"])) : r("", !0)], 64));
1492
+ }
1493
+ }), [["__scopeId", "data-v-e4171f7c"]]), ut = /* @__PURE__ */ c({
1494
+ __name: "CardProps",
1495
+ props: {
1496
+ node: {},
1497
+ patch: { type: Function }
1498
+ },
1499
+ setup(e) {
1500
+ let t = e;
1501
+ return (e, r) => (h(), n(C(N), { label: "Title" }, {
1502
+ default: D(() => [s(C(R), {
1503
+ "model-value": t.node.title ?? "",
1504
+ "onUpdate:modelValue": r[0] ||= (e) => t.patch({ title: e })
1505
+ }, null, 8, ["model-value"])]),
1506
+ _: 1
1507
+ }));
1508
+ }
1509
+ }), dt = /* @__PURE__ */ c({
1510
+ __name: "SectionProps",
1511
+ props: {
1512
+ node: {},
1513
+ patch: { type: Function }
1514
+ },
1515
+ setup(e) {
1516
+ let t = e;
1517
+ return (e, r) => (h(), n(C(N), { label: "Title" }, {
1518
+ default: D(() => [s(C(R), {
1519
+ "model-value": t.node.title ?? "",
1520
+ "onUpdate:modelValue": r[0] ||= (e) => t.patch({ title: e })
1521
+ }, null, 8, ["model-value"])]),
1522
+ _: 1
1523
+ }));
1524
+ }
1525
+ }), ft = /* @__PURE__ */ c({
1526
+ __name: "HeadingProps",
1527
+ props: {
1528
+ node: {},
1529
+ patch: { type: Function }
1530
+ },
1531
+ setup(t) {
1532
+ let n = t, r = [
1533
+ {
1534
+ value: 1,
1535
+ label: "H1"
1536
+ },
1537
+ {
1538
+ value: 2,
1539
+ label: "H2"
1540
+ },
1541
+ {
1542
+ value: 3,
1543
+ label: "H3"
1544
+ },
1545
+ {
1546
+ value: 4,
1547
+ label: "H4"
1548
+ },
1549
+ {
1550
+ value: 5,
1551
+ label: "H5"
1552
+ },
1553
+ {
1554
+ value: 6,
1555
+ label: "H6"
1556
+ }
1557
+ ];
1558
+ return (t, a) => (h(), i(e, null, [s(C(N), { label: "Text" }, {
1559
+ default: D(() => [s(C(R), {
1560
+ "model-value": n.node.text ?? "",
1561
+ "onUpdate:modelValue": a[0] ||= (e) => n.patch({ text: e })
1562
+ }, null, 8, ["model-value"])]),
1563
+ _: 1
1564
+ }), s(C(N), { label: "Level" }, {
1565
+ default: D(() => [s(C(I), {
1566
+ "model-value": n.node.level ?? 2,
1567
+ options: r,
1568
+ "onUpdate:modelValue": a[1] ||= (e) => n.patch({ level: e })
1569
+ }, null, 8, ["model-value"])]),
1570
+ _: 1
1571
+ })], 64));
1572
+ }
1573
+ }), pt = ["value"], mt = /* @__PURE__ */ G(/* @__PURE__ */ c({
1574
+ __name: "ParagraphProps",
1575
+ props: {
1576
+ node: {},
1577
+ patch: { type: Function }
1578
+ },
1579
+ setup(e) {
1580
+ let t = e;
1581
+ return (e, r) => (h(), n(C(N), { label: "Text" }, {
1582
+ default: D(() => [a("textarea", {
1583
+ class: "pb-prop-textarea",
1584
+ value: t.node.text ?? "",
1585
+ rows: "3",
1586
+ onInput: r[0] ||= (e) => t.patch({ text: e.target.value })
1587
+ }, null, 40, pt)]),
1588
+ _: 1
1589
+ }));
1590
+ }
1591
+ }), [["__scopeId", "data-v-13b6b029"]]), ht = /* @__PURE__ */ c({
1592
+ __name: "SpacerProps",
1593
+ props: {
1594
+ node: {},
1595
+ patch: { type: Function }
1596
+ },
1597
+ setup(e) {
1598
+ let t = e;
1599
+ return (e, r) => (h(), n(C(N), {
1600
+ label: "Size (CSS)",
1601
+ hint: "Leave empty to fill available space"
1602
+ }, {
1603
+ default: D(() => [s(C(R), {
1604
+ "model-value": t.node.size ?? "",
1605
+ placeholder: "e.g. 24px",
1606
+ "onUpdate:modelValue": r[0] ||= (e) => t.patch({ size: e })
1607
+ }, null, 8, ["model-value"])]),
1608
+ _: 1
1609
+ }));
1610
+ }
1611
+ }), gt = /* @__PURE__ */ c({
1612
+ __name: "TextInputProps",
1613
+ props: {
1614
+ node: {},
1615
+ patch: { type: Function }
1616
+ },
1617
+ setup(t) {
1618
+ let n = t, r = [
1619
+ {
1620
+ value: "text",
1621
+ label: "text"
1622
+ },
1623
+ {
1624
+ value: "email",
1625
+ label: "email"
1626
+ },
1627
+ {
1628
+ value: "password",
1629
+ label: "password"
1630
+ },
1631
+ {
1632
+ value: "url",
1633
+ label: "url"
1634
+ }
1635
+ ];
1636
+ function a(e) {
1637
+ n.patch({ validation: e ? { required: !0 } : {} });
1638
+ }
1639
+ return (t, o) => (h(), i(e, null, [
1640
+ s(C(N), { label: "Label" }, {
1641
+ default: D(() => [s(C(R), {
1642
+ "model-value": n.node.label ?? "",
1643
+ "onUpdate:modelValue": o[0] ||= (e) => n.patch({ label: e })
1644
+ }, null, 8, ["model-value"])]),
1645
+ _: 1
1646
+ }),
1647
+ s(C(N), { label: "Name (field key)" }, {
1648
+ default: D(() => [s(C(R), {
1649
+ "model-value": n.node.name ?? "",
1650
+ "onUpdate:modelValue": o[1] ||= (e) => n.patch({ name: e })
1651
+ }, null, 8, ["model-value"])]),
1652
+ _: 1
1653
+ }),
1654
+ s(C(N), { label: "Placeholder" }, {
1655
+ default: D(() => [s(C(R), {
1656
+ "model-value": n.node.placeholder ?? "",
1657
+ "onUpdate:modelValue": o[2] ||= (e) => n.patch({ placeholder: e })
1658
+ }, null, 8, ["model-value"])]),
1659
+ _: 1
1660
+ }),
1661
+ s(C(N), { label: "Input type" }, {
1662
+ default: D(() => [s(C(I), {
1663
+ "model-value": n.node.inputType ?? "text",
1664
+ options: r,
1665
+ "onUpdate:modelValue": o[3] ||= (e) => n.patch({ inputType: e })
1666
+ }, null, 8, ["model-value"])]),
1667
+ _: 1
1668
+ }),
1669
+ s(C(j), {
1670
+ "model-value": !!n.node.validation?.required,
1671
+ label: "Required",
1672
+ "onUpdate:modelValue": a
1673
+ }, null, 8, ["model-value"]),
1674
+ s(C(j), {
1675
+ "model-value": !!n.node.disabled,
1676
+ label: "Disabled",
1677
+ "onUpdate:modelValue": o[4] ||= (e) => n.patch({ disabled: e })
1678
+ }, null, 8, ["model-value"])
1679
+ ], 64));
1680
+ }
1681
+ }), _t = /* @__PURE__ */ c({
1682
+ __name: "CheckboxProps",
1683
+ props: {
1684
+ node: {},
1685
+ patch: { type: Function }
1686
+ },
1687
+ setup(t) {
1688
+ let n = t;
1689
+ function r(e) {
1690
+ n.patch({ validation: e ? { required: !0 } : {} });
1691
+ }
1692
+ return (t, a) => (h(), i(e, null, [
1693
+ s(C(N), { label: "Label" }, {
1694
+ default: D(() => [s(C(R), {
1695
+ "model-value": n.node.label ?? "",
1696
+ "onUpdate:modelValue": a[0] ||= (e) => n.patch({ label: e })
1697
+ }, null, 8, ["model-value"])]),
1698
+ _: 1
1699
+ }),
1700
+ s(C(N), { label: "Name (field key)" }, {
1701
+ default: D(() => [s(C(R), {
1702
+ "model-value": n.node.name ?? "",
1703
+ "onUpdate:modelValue": a[1] ||= (e) => n.patch({ name: e })
1704
+ }, null, 8, ["model-value"])]),
1705
+ _: 1
1706
+ }),
1707
+ s(C(j), {
1708
+ "model-value": !!n.node.validation?.required,
1709
+ label: "Required",
1710
+ "onUpdate:modelValue": r
1711
+ }, null, 8, ["model-value"]),
1712
+ s(C(j), {
1713
+ "model-value": !!n.node.disabled,
1714
+ label: "Disabled",
1715
+ "onUpdate:modelValue": a[2] ||= (e) => n.patch({ disabled: e })
1716
+ }, null, 8, ["model-value"])
1717
+ ], 64));
1718
+ }
1719
+ }), vt = /* @__PURE__ */ c({
1720
+ __name: "SelectProps",
1721
+ props: {
1722
+ node: {},
1723
+ patch: { type: Function }
1724
+ },
1725
+ setup(t) {
1726
+ let n = t;
1727
+ function r(e) {
1728
+ n.patch({ validation: e ? { required: !0 } : {} });
1729
+ }
1730
+ return (t, a) => (h(), i(e, null, [
1731
+ s(C(N), { label: "Label" }, {
1732
+ default: D(() => [s(C(R), {
1733
+ "model-value": n.node.label ?? "",
1734
+ "onUpdate:modelValue": a[0] ||= (e) => n.patch({ label: e })
1735
+ }, null, 8, ["model-value"])]),
1736
+ _: 1
1737
+ }),
1738
+ s(C(N), { label: "Name (field key)" }, {
1739
+ default: D(() => [s(C(R), {
1740
+ "model-value": n.node.name ?? "",
1741
+ "onUpdate:modelValue": a[1] ||= (e) => n.patch({ name: e })
1742
+ }, null, 8, ["model-value"])]),
1743
+ _: 1
1744
+ }),
1745
+ s(C(N), { label: "Placeholder" }, {
1746
+ default: D(() => [s(C(R), {
1747
+ "model-value": n.node.placeholder ?? "",
1748
+ "onUpdate:modelValue": a[2] ||= (e) => n.patch({ placeholder: e })
1749
+ }, null, 8, ["model-value"])]),
1750
+ _: 1
1751
+ }),
1752
+ s(C(j), {
1753
+ "model-value": !!n.node.validation?.required,
1754
+ label: "Required",
1755
+ "onUpdate:modelValue": r
1756
+ }, null, 8, ["model-value"]),
1757
+ s(C(j), {
1758
+ "model-value": !!n.node.disabled,
1759
+ label: "Disabled",
1760
+ "onUpdate:modelValue": a[3] ||= (e) => n.patch({ disabled: e })
1761
+ }, null, 8, ["model-value"])
1762
+ ], 64));
1763
+ }
1764
+ }), yt = /* @__PURE__ */ c({
1765
+ __name: "ButtonProps",
1766
+ props: {
1767
+ node: {},
1768
+ patch: { type: Function }
1769
+ },
1770
+ setup(r) {
1771
+ let a = r, o = l($), c = t(() => {
1772
+ let e = o?.value?.availableActions;
1773
+ if (!e || e.length === 0) return null;
1774
+ let t = /* @__PURE__ */ new Set(), n = [{
1775
+ value: "",
1776
+ label: "— none"
1777
+ }];
1778
+ for (let r of e) t.has(r.id) || (t.add(r.id), n.push({
1779
+ value: r.id,
1780
+ label: r.label
1781
+ }));
1782
+ let r = a.node.action;
1783
+ return r && !t.has(r) && n.push({
1784
+ value: r,
1785
+ label: `${r} (not configured)`
1786
+ }), n;
1787
+ }), u = [
1788
+ {
1789
+ value: "primary",
1790
+ label: "primary"
1791
+ },
1792
+ {
1793
+ value: "secondary",
1794
+ label: "secondary"
1795
+ },
1796
+ {
1797
+ value: "ghost",
1798
+ label: "ghost"
1799
+ },
1800
+ {
1801
+ value: "danger",
1802
+ label: "danger"
1803
+ }
1804
+ ], d = [
1805
+ {
1806
+ value: "",
1807
+ label: "— default"
1808
+ },
1809
+ {
1810
+ value: "xs",
1811
+ label: "xs"
1812
+ },
1813
+ {
1814
+ value: "s",
1815
+ label: "s"
1816
+ },
1817
+ {
1818
+ value: "m",
1819
+ label: "m"
1820
+ },
1821
+ {
1822
+ value: "l",
1823
+ label: "l"
1824
+ }
1825
+ ];
1826
+ return (t, r) => (h(), i(e, null, [
1827
+ s(C(N), { label: "Label" }, {
1828
+ default: D(() => [s(C(R), {
1829
+ "model-value": a.node.label ?? "",
1830
+ "onUpdate:modelValue": r[0] ||= (e) => a.patch({ label: e })
1831
+ }, null, 8, ["model-value"])]),
1832
+ _: 1
1833
+ }),
1834
+ s(C(N), {
1835
+ label: "Action",
1836
+ hint: "Matched against the actions map at render time"
1837
+ }, {
1838
+ default: D(() => [c.value ? (h(), n(C(I), {
1839
+ key: 0,
1840
+ "model-value": a.node.action ?? "",
1841
+ options: c.value,
1842
+ "onUpdate:modelValue": r[1] ||= (e) => a.patch({ action: e || void 0 })
1843
+ }, null, 8, ["model-value", "options"])) : (h(), n(C(R), {
1844
+ key: 1,
1845
+ "model-value": a.node.action ?? "",
1846
+ placeholder: "e.g. auth:login",
1847
+ "onUpdate:modelValue": r[2] ||= (e) => a.patch({ action: e })
1848
+ }, null, 8, ["model-value"]))]),
1849
+ _: 1
1850
+ }),
1851
+ s(C(N), { label: "Variant" }, {
1852
+ default: D(() => [s(C(I), {
1853
+ "model-value": a.node.variant ?? "primary",
1854
+ options: u,
1855
+ "onUpdate:modelValue": r[3] ||= (e) => a.patch({ variant: e })
1856
+ }, null, 8, ["model-value"])]),
1857
+ _: 1
1858
+ }),
1859
+ s(C(N), { label: "Size" }, {
1860
+ default: D(() => [s(C(I), {
1861
+ "model-value": a.node.size ?? "",
1862
+ options: d,
1863
+ "onUpdate:modelValue": r[4] ||= (e) => a.patch({ size: e || void 0 })
1864
+ }, null, 8, ["model-value"])]),
1865
+ _: 1
1866
+ }),
1867
+ s(C(N), { label: "Icon (left)" }, {
1868
+ default: D(() => [s(C(R), {
1869
+ "model-value": a.node.icon ?? "",
1870
+ placeholder: "e.g. log-in",
1871
+ "onUpdate:modelValue": r[5] ||= (e) => a.patch({ icon: e })
1872
+ }, null, 8, ["model-value"])]),
1873
+ _: 1
1874
+ }),
1875
+ s(C(j), {
1876
+ "model-value": !!a.node.validates,
1877
+ label: "Validates form before firing",
1878
+ "onUpdate:modelValue": r[6] ||= (e) => a.patch({ validates: e })
1879
+ }, null, 8, ["model-value"])
1880
+ ], 64));
1881
+ }
1882
+ }), bt = /* @__PURE__ */ c({
1883
+ __name: "LinkProps",
1884
+ props: {
1885
+ node: {},
1886
+ patch: { type: Function }
1887
+ },
1888
+ setup(r) {
1889
+ let a = r, o = l($), c = t(() => {
1890
+ let e = o?.value?.availableActions;
1891
+ if (!e || e.length === 0) return null;
1892
+ let t = /* @__PURE__ */ new Set(), n = [{
1893
+ value: "",
1894
+ label: "— none"
1895
+ }];
1896
+ for (let r of e) t.has(r.id) || (t.add(r.id), n.push({
1897
+ value: r.id,
1898
+ label: r.label
1899
+ }));
1900
+ let r = a.node.action;
1901
+ return r && !t.has(r) && n.push({
1902
+ value: r,
1903
+ label: `${r} (not configured)`
1904
+ }), n;
1905
+ });
1906
+ return (t, r) => (h(), i(e, null, [s(C(N), { label: "Label" }, {
1907
+ default: D(() => [s(C(R), {
1908
+ "model-value": a.node.label ?? "",
1909
+ "onUpdate:modelValue": r[0] ||= (e) => a.patch({ label: e })
1910
+ }, null, 8, ["model-value"])]),
1911
+ _: 1
1912
+ }), s(C(N), { label: "Action" }, {
1913
+ default: D(() => [c.value ? (h(), n(C(I), {
1914
+ key: 0,
1915
+ "model-value": a.node.action ?? "",
1916
+ options: c.value,
1917
+ "onUpdate:modelValue": r[1] ||= (e) => a.patch({ action: e || void 0 })
1918
+ }, null, 8, ["model-value", "options"])) : (h(), n(C(R), {
1919
+ key: 1,
1920
+ "model-value": a.node.action ?? "",
1921
+ placeholder: "e.g. nav:forgot-password",
1922
+ "onUpdate:modelValue": r[2] ||= (e) => a.patch({ action: e })
1923
+ }, null, 8, ["model-value"]))]),
1924
+ _: 1
1925
+ })], 64));
1926
+ }
1927
+ }), xt = { class: "pb-image-asset" }, St = { class: "pb-image-asset__thumb" }, Ct = ["src", "alt"], wt = {
1928
+ key: 1,
1929
+ class: "pb-image-asset__empty"
1930
+ }, Tt = { class: "pb-image-asset__empty-label" }, Et = { class: "pb-image-asset__controls" }, Dt = {
1931
+ stack: {
1932
+ component: lt,
1933
+ sectionTitle: "Layout"
1934
+ },
1935
+ card: {
1936
+ component: ut,
1937
+ sectionTitle: "Card"
1938
+ },
1939
+ section: {
1940
+ component: dt,
1941
+ sectionTitle: "Section"
1942
+ },
1943
+ heading: {
1944
+ component: ft,
1945
+ sectionTitle: "Heading"
1946
+ },
1947
+ paragraph: {
1948
+ component: mt,
1949
+ sectionTitle: "Paragraph"
1950
+ },
1951
+ spacer: {
1952
+ component: ht,
1953
+ sectionTitle: "Spacer"
1954
+ },
1955
+ "text-input": {
1956
+ component: gt,
1957
+ sectionTitle: "Text input"
1958
+ },
1959
+ checkbox: {
1960
+ component: _t,
1961
+ sectionTitle: "Checkbox"
1962
+ },
1963
+ select: {
1964
+ component: vt,
1965
+ sectionTitle: "Select"
1966
+ },
1967
+ button: {
1968
+ component: yt,
1969
+ sectionTitle: "Button"
1970
+ },
1971
+ link: {
1972
+ component: bt,
1973
+ sectionTitle: "Link"
1974
+ },
1975
+ image: {
1976
+ component: /* @__PURE__ */ G(/* @__PURE__ */ c({
1977
+ __name: "ImageProps",
1978
+ props: {
1979
+ node: {},
1980
+ patch: { type: Function }
1981
+ },
1982
+ setup(c) {
1983
+ let u = c, d = l($), f = t(() => !!d?.value?.pickAsset), p = t(() => {
1984
+ let e = u.node.assetId;
1985
+ return e ? d?.value?.assetResolver?.(e) ?? "" : "";
1986
+ });
1987
+ async function m() {
1988
+ let e = d?.value?.pickAsset;
1989
+ if (!e) return;
1990
+ let t = await e(u.node.assetId || void 0);
1991
+ t != null && u.patch({ assetId: t });
1992
+ }
1993
+ function g() {
1994
+ u.patch({ assetId: "" });
1995
+ }
1996
+ return (t, c) => (h(), i(e, null, [f.value ? (h(), n(C(N), {
1997
+ key: 0,
1998
+ label: "Asset"
1999
+ }, {
2000
+ default: D(() => [a("div", xt, [a("div", St, [p.value ? (h(), i("img", {
2001
+ key: 0,
2002
+ src: p.value,
2003
+ alt: u.node.alt ?? ""
2004
+ }, null, 8, Ct)) : (h(), i("span", wt, [s(C(P), {
2005
+ name: "image",
2006
+ size: "m"
2007
+ }), a("span", Tt, S(u.node.assetId ? "No preview" : "No image"), 1)]))]), a("div", Et, [s(C(k), {
2008
+ size: "s",
2009
+ variant: "secondary",
2010
+ onClick: m
2011
+ }, {
2012
+ default: D(() => [o(S(u.node.assetId ? "Change…" : "Choose…"), 1)]),
2013
+ _: 1
2014
+ }), u.node.assetId ? (h(), n(C(k), {
2015
+ key: 0,
2016
+ size: "s",
2017
+ variant: "ghost",
2018
+ onClick: g
2019
+ }, {
2020
+ default: D(() => [...c[2] ||= [o(" Clear ", -1)]]),
2021
+ _: 1
2022
+ })) : r("", !0)])])]),
2023
+ _: 1
2024
+ })) : (h(), n(C(N), {
2025
+ key: 1,
2026
+ label: "Asset ID",
2027
+ hint: "Resolved via assetResolver at render time"
2028
+ }, {
2029
+ default: D(() => [s(C(R), {
2030
+ "model-value": u.node.assetId ?? "",
2031
+ "onUpdate:modelValue": c[0] ||= (e) => u.patch({ assetId: e })
2032
+ }, null, 8, ["model-value"])]),
2033
+ _: 1
2034
+ })), s(C(N), { label: "Alt text" }, {
2035
+ default: D(() => [s(C(R), {
2036
+ "model-value": u.node.alt ?? "",
2037
+ "onUpdate:modelValue": c[1] ||= (e) => u.patch({ alt: e })
2038
+ }, null, 8, ["model-value"])]),
2039
+ _: 1
2040
+ })], 64));
2041
+ }
2042
+ }), [["__scopeId", "data-v-49a42b45"]]),
2043
+ sectionTitle: "Image"
2044
+ }
2045
+ }, Ot = /* @__PURE__ */ c({
2046
+ __name: "StyleProps",
2047
+ props: {
2048
+ node: {},
2049
+ patchStyle: { type: Function }
2050
+ },
2051
+ setup(a) {
2052
+ let o = a, c = t(() => V(o.node)), l = [
2053
+ {
2054
+ value: "",
2055
+ label: "— inherit"
2056
+ },
2057
+ {
2058
+ value: "start",
2059
+ label: "start"
2060
+ },
2061
+ {
2062
+ value: "center",
2063
+ label: "center"
2064
+ },
2065
+ {
2066
+ value: "end",
2067
+ label: "end"
2068
+ },
2069
+ {
2070
+ value: "stretch",
2071
+ label: "stretch"
2072
+ }
2073
+ ];
2074
+ return (t, a) => (h(), i(e, null, [
2075
+ c.value ? (h(), n(C(N), {
2076
+ key: 0,
2077
+ label: "Gap"
2078
+ }, {
2079
+ default: D(() => [s(C(R), {
2080
+ "model-value": o.node.style?.gap ?? "",
2081
+ placeholder: "e.g. 8px",
2082
+ "onUpdate:modelValue": a[0] ||= (e) => o.patchStyle({ gap: e })
2083
+ }, null, 8, ["model-value"])]),
2084
+ _: 1
2085
+ })) : r("", !0),
2086
+ s(C(N), { label: "Padding" }, {
2087
+ default: D(() => [s(C(R), {
2088
+ "model-value": o.node.style?.padding ?? "",
2089
+ placeholder: "e.g. 16px",
2090
+ "onUpdate:modelValue": a[1] ||= (e) => o.patchStyle({ padding: e })
2091
+ }, null, 8, ["model-value"])]),
2092
+ _: 1
2093
+ }),
2094
+ s(C(N), { label: "Width" }, {
2095
+ default: D(() => [s(C(R), {
2096
+ "model-value": o.node.style?.width ?? "",
2097
+ placeholder: "e.g. 100%, 380px",
2098
+ "onUpdate:modelValue": a[2] ||= (e) => o.patchStyle({ width: e })
2099
+ }, null, 8, ["model-value"])]),
2100
+ _: 1
2101
+ }),
2102
+ c.value ? (h(), n(C(N), {
2103
+ key: 1,
2104
+ label: "Align children"
2105
+ }, {
2106
+ default: D(() => [s(C(I), {
2107
+ "model-value": o.node.style?.align ?? "",
2108
+ options: l,
2109
+ "onUpdate:modelValue": a[3] ||= (e) => o.patchStyle({ align: e || void 0 })
2110
+ }, null, 8, ["model-value"])]),
2111
+ _: 1
2112
+ })) : r("", !0)
2113
+ ], 64));
2114
+ }
2115
+ }), kt = { class: "pb-props" }, At = { class: "pb-props__header" }, jt = {
2116
+ key: 0,
2117
+ class: "pb-props__empty"
2118
+ }, Mt = {
2119
+ key: 1,
2120
+ class: "pb-props__body"
2121
+ }, Nt = {
2122
+ key: 0,
2123
+ class: "pb-props__issues"
2124
+ }, Pt = {
2125
+ key: 1,
2126
+ class: "pb-props__section"
2127
+ }, Ft = { class: "pb-props__section-title" }, It = /* @__PURE__ */ G(/* @__PURE__ */ c({
2128
+ name: "BuilderPropsPanel",
2129
+ __name: "BuilderPropsPanel",
2130
+ setup(o) {
2131
+ let c = l(Q), u = l(_e), f = t(() => c.selectedNode.value), p = t(() => c.selectedPath.value ?? []), m = t(() => f.value ? Dt[f.value.type] : void 0), g = t(() => f.value ? u?.byNodeId.value.get(f.value.id) ?? [] : []);
2132
+ function _(e) {
2133
+ p.value && c.patch(p.value, e);
2134
+ }
2135
+ function y(e) {
2136
+ f.value && _({ style: {
2137
+ ...f.value.style ?? {},
2138
+ ...e
2139
+ } });
2140
+ }
2141
+ return (t, o) => (h(), i("aside", kt, [a("header", At, [s(C(P), {
2142
+ name: "settings",
2143
+ size: "s"
2144
+ }), o[0] ||= a("span", { class: "pb-props__title" }, "Properties", -1)]), f.value ? (h(), i("div", Mt, [
2145
+ g.value.length > 0 ? (h(), i("ul", Nt, [(h(!0), i(e, null, v(g.value, (e, t) => (h(), i("li", {
2146
+ key: t,
2147
+ class: d(["pb-props__issue", `pb-props__issue--${e.severity}`])
2148
+ }, [s(C(P), {
2149
+ name: e.severity === "error" ? "circle-alert" : "triangle-alert",
2150
+ size: "s"
2151
+ }, null, 8, ["name"]), a("span", null, S(e.message), 1)], 2))), 128))])) : r("", !0),
2152
+ m.value ? (h(), i("section", Pt, [a("h4", Ft, S(m.value.sectionTitle), 1), (h(), n(b(m.value.component), {
2153
+ node: f.value,
2154
+ patch: _
2155
+ }, null, 8, ["node"]))])) : r("", !0),
2156
+ f.value.type === "spacer" ? r("", !0) : (h(), i("section", {
2157
+ key: 2,
2158
+ class: d(["pb-props__section", { "pb-props__section--separated": !!m.value }])
2159
+ }, [o[3] ||= a("h4", { class: "pb-props__section-title" }, "Style", -1), s(Ot, {
2160
+ node: f.value,
2161
+ "patch-style": y
2162
+ }, null, 8, ["node"])], 2))
2163
+ ])) : (h(), i("div", jt, [
2164
+ s(C(P), {
2165
+ name: "settings",
2166
+ size: "l"
2167
+ }),
2168
+ o[1] ||= a("p", { class: "pb-props__empty-title" }, "No node selected", -1),
2169
+ o[2] ||= a("p", { class: "pb-props__empty-hint" }, "Click a node in the outline or canvas to edit it.", -1)
2170
+ ]))]));
2171
+ }
2172
+ }), [["__scopeId", "data-v-380ec929"]]), Lt = { class: "pb-builder__pane-header" }, Rt = { class: "pb-builder__tree-scroll" }, zt = { class: "pb-builder__pane pb-builder__pane--center" }, Bt = ["disabled"], Vt = ["disabled"], Ht = { class: "pb-builder__tab-label" }, Ut = { class: "pb-builder__tab-label" }, Wt = { class: "pb-builder__preview-pane" }, Gt = { class: "pb-builder__preview-toolbar" }, Kt = {
2173
+ class: "pb-builder__seg",
2174
+ role: "radiogroup",
2175
+ "aria-label": "Preview width"
2176
+ }, qt = ["aria-checked"], Jt = ["aria-checked"], Yt = ["aria-checked"], Xt = { class: "pb-builder__preview" }, Zt = { class: "pb-builder__tab-label" }, Qt = { class: "pb-builder__json-pane" }, $t = { class: "pb-builder__json-toolbar" }, en = {
2177
+ key: 0,
2178
+ class: "pb-builder__json-error"
2179
+ }, tn = ["disabled"], nn = ["value"], rn = 260, an = 180, on = 280, sn = 220, cn = 360, ln = 36, un = /* @__PURE__ */ G(/* @__PURE__ */ c({
2180
+ __name: "CoarPageBuilder",
2181
+ props: /* @__PURE__ */ u({ config: {} }, {
2182
+ modelValue: { required: !1 },
2183
+ modelModifiers: {}
2184
+ }),
2185
+ emits: ["update:modelValue"],
2186
+ setup(n) {
2187
+ w((e) => ({
2188
+ v0d1c4c4b: N.value,
2189
+ v0f378b9d: F.value
2190
+ }));
2191
+ let c = T(n, "modelValue"), l = n, u = me({
2192
+ schema: c.value === void 0 ? void 0 : c,
2193
+ initial: {
2194
+ id: "root",
2195
+ type: "page",
2196
+ style: {
2197
+ gap: "16px",
2198
+ padding: "24px"
2199
+ },
2200
+ children: []
2201
+ }
2202
+ }), p = t(() => l.config), m = he(u.schema, p);
2203
+ g(Q, u), g($, p), g(_e, m);
2204
+ let v = _("editor"), y = _("full"), b = {
2205
+ tablet: 768,
2206
+ mobile: 375
2207
+ }, x = t(() => y.value === "full" ? {} : {
2208
+ maxWidth: `${b[y.value]}px`,
2209
+ width: "100%",
2210
+ margin: "0 auto"
2211
+ }), O = _(rn), k = _(on), A = _(!1), j = _(!1), M = _(null), N = _(`${rn}px`), F = _(`${on}px`);
2212
+ E([A, O], () => {
2213
+ N.value = A.value ? `${ln}px` : `${O.value}px`;
2214
+ }), E([j, k], () => {
2215
+ F.value = j.value ? `${ln}px` : `${k.value}px`;
2216
+ });
2217
+ let I = _(null);
2218
+ function R(e, t) {
2219
+ if (e === "outline" && A.value || e === "props" && j.value) return;
2220
+ t.preventDefault(), M.value = e;
2221
+ let n = t.clientX, r = O.value, i = k.value;
2222
+ function a(t) {
2223
+ let a = I.value?.getBoundingClientRect().width ?? 0;
2224
+ if (!a) return;
2225
+ let o = a - (e === "outline" ? j.value ? ln : k.value : A.value ? ln : O.value) - cn - 2, s = t.clientX - n;
2226
+ e === "outline" ? O.value = Math.min(Math.max(r + s, an), Math.max(an, o)) : k.value = Math.min(Math.max(i - s, sn), Math.max(sn, o));
2227
+ }
2228
+ function o() {
2229
+ M.value = null, window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", o);
2230
+ }
2231
+ window.addEventListener("pointermove", a), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", o);
2232
+ }
2233
+ let z = _(JSON.stringify(u.schema.value, null, 2)), B = _(""), V = !1;
2234
+ E(u.schema, (e) => {
2235
+ V || (z.value = JSON.stringify(e, null, 2));
2236
+ }, { deep: !1 });
2237
+ function H(e) {
2238
+ V = !0, z.value = e.target.value;
2239
+ try {
2240
+ JSON.parse(z.value), B.value = "";
2241
+ } catch {
2242
+ B.value = "Invalid JSON";
2243
+ }
2244
+ }
2245
+ function U() {
2246
+ V = !1;
2247
+ }
2248
+ function W(e) {
2249
+ if (!e || typeof e != "object") return e;
2250
+ let t = e, n = Array.isArray(t.children) ? t.children.map(W) : t.children;
2251
+ return t.type === "column" ? {
2252
+ ...t,
2253
+ type: "stack",
2254
+ direction: "column",
2255
+ children: n
2256
+ } : t.type === "row" ? {
2257
+ ...t,
2258
+ type: "stack",
2259
+ direction: "row",
2260
+ children: n
2261
+ } : n === t.children ? e : {
2262
+ ...t,
2263
+ children: n
2264
+ };
2265
+ }
2266
+ function te(e) {
2267
+ let t = W(e);
2268
+ return t.type === "page" ? t : {
2269
+ id: "root",
2270
+ type: "page",
2271
+ style: {
2272
+ gap: "16px",
2273
+ padding: "24px"
2274
+ },
2275
+ children: [t]
2276
+ };
2277
+ }
2278
+ function G() {
2279
+ try {
2280
+ let e = JSON.parse(z.value);
2281
+ u.replaceSchema(te(e)), B.value = "", v.value = "editor";
2282
+ } catch (e) {
2283
+ B.value = e instanceof Error ? e.message : "Invalid JSON";
2284
+ }
2285
+ }
2286
+ return (t, c) => (h(), i("div", {
2287
+ ref_key: "rootRef",
2288
+ ref: I,
2289
+ class: d(["pb-builder", {
2290
+ "pb-builder--outline-collapsed": A.value,
2291
+ "pb-builder--props-collapsed": j.value,
2292
+ "pb-builder--resizing": M.value !== null
2293
+ }])
2294
+ }, [
2295
+ a("section", { class: d(["pb-builder__pane pb-builder__pane--tree", { "pb-builder__pane--rail": A.value }]) }, [A.value ? (h(), i("button", {
2296
+ key: 1,
2297
+ type: "button",
2298
+ class: "pb-builder__rail-btn",
2299
+ title: "Expand outline",
2300
+ onClick: c[1] ||= (e) => A.value = !1
2301
+ }, [s(C(P), {
2302
+ name: "chevrons-right",
2303
+ size: "s"
2304
+ })])) : (h(), i(e, { key: 0 }, [a("header", Lt, [
2305
+ s(C(P), {
2306
+ name: "list",
2307
+ size: "s"
2308
+ }),
2309
+ c[12] ||= a("span", { class: "pb-builder__pane-title" }, "Outline", -1),
2310
+ a("button", {
2311
+ type: "button",
2312
+ class: "pb-builder__icon-btn",
2313
+ title: "Collapse outline",
2314
+ onClick: c[0] ||= (e) => A.value = !0
2315
+ }, [s(C(P), {
2316
+ name: "chevrons-left",
2317
+ size: "s"
2318
+ })])
2319
+ ]), a("div", Rt, [s(Me)])], 64))], 2),
2320
+ a("div", {
2321
+ class: d(["pb-builder__divider", { "pb-builder__divider--inert": A.value }]),
2322
+ role: "separator",
2323
+ onPointerdown: c[2] ||= (e) => R("outline", e)
2324
+ }, null, 34),
2325
+ a("section", zt, [s(C(ee), {
2326
+ modelValue: v.value,
2327
+ "onUpdate:modelValue": c[8] ||= (e) => v.value = e,
2328
+ class: "pb-builder__tabs"
2329
+ }, {
2330
+ actions: D(() => [a("button", {
2331
+ type: "button",
2332
+ class: "pb-builder__icon-btn",
2333
+ disabled: !C(u).canUndo.value,
2334
+ title: "Undo (Ctrl+Z)",
2335
+ onClick: c[3] ||= (e) => C(u).undo()
2336
+ }, [s(C(P), {
2337
+ name: "undo-2",
2338
+ size: "s"
2339
+ })], 8, Bt), a("button", {
2340
+ type: "button",
2341
+ class: "pb-builder__icon-btn",
2342
+ disabled: !C(u).canRedo.value,
2343
+ title: "Redo (Ctrl+Y)",
2344
+ onClick: c[4] ||= (e) => C(u).redo()
2345
+ }, [s(C(P), {
2346
+ name: "redo-2",
2347
+ size: "s"
2348
+ })], 8, Vt)]),
2349
+ default: D(() => [
2350
+ s(C(L), { id: "editor" }, {
2351
+ default: D(() => [a("span", Ht, [s(C(P), {
2352
+ name: "pencil",
2353
+ size: "s"
2354
+ }), c[13] ||= o(" Editor ", -1)])]),
2355
+ content: D(() => [s(it)]),
2356
+ _: 1
2357
+ }),
2358
+ s(C(L), { id: "preview" }, {
2359
+ default: D(() => [a("span", Ut, [s(C(P), {
2360
+ name: "eye",
2361
+ size: "s"
2362
+ }), c[14] ||= o(" Preview ", -1)])]),
2363
+ content: D(() => [a("div", Wt, [a("div", Gt, [a("div", Kt, [
2364
+ a("button", {
2365
+ type: "button",
2366
+ class: d(["pb-builder__seg-btn", { "pb-builder__seg-btn--active": y.value === "full" }]),
2367
+ role: "radio",
2368
+ "aria-checked": y.value === "full",
2369
+ title: "Full width",
2370
+ onClick: c[5] ||= (e) => y.value = "full"
2371
+ }, " Desktop ", 10, qt),
2372
+ a("button", {
2373
+ type: "button",
2374
+ class: d(["pb-builder__seg-btn", { "pb-builder__seg-btn--active": y.value === "tablet" }]),
2375
+ role: "radio",
2376
+ "aria-checked": y.value === "tablet",
2377
+ title: "768px",
2378
+ onClick: c[6] ||= (e) => y.value = "tablet"
2379
+ }, " Tablet · 768 ", 10, Jt),
2380
+ a("button", {
2381
+ type: "button",
2382
+ class: d(["pb-builder__seg-btn", { "pb-builder__seg-btn--active": y.value === "mobile" }]),
2383
+ role: "radio",
2384
+ "aria-checked": y.value === "mobile",
2385
+ title: "375px",
2386
+ onClick: c[7] ||= (e) => y.value = "mobile"
2387
+ }, " Mobile · 375 ", 10, Yt)
2388
+ ])]), a("div", Xt, [a("div", {
2389
+ class: "pb-builder__preview-frame",
2390
+ style: f(x.value)
2391
+ }, [s(q, {
2392
+ schema: C(u).schema.value,
2393
+ config: n.config,
2394
+ "asset-resolver": n.config?.assetResolver
2395
+ }, null, 8, [
2396
+ "schema",
2397
+ "config",
2398
+ "asset-resolver"
2399
+ ])], 4)])])]),
2400
+ _: 1
2401
+ }),
2402
+ s(C(L), { id: "json" }, {
2403
+ default: D(() => [a("span", Zt, [s(C(P), {
2404
+ name: "code",
2405
+ size: "s"
2406
+ }), c[15] ||= o(" JSON ", -1)])]),
2407
+ content: D(() => [a("div", Qt, [a("div", $t, [
2408
+ c[16] ||= a("span", { class: "pb-builder__json-hint" }, "Paste or edit JSON, then click Apply", -1),
2409
+ B.value ? (h(), i("span", en, S(B.value), 1)) : r("", !0),
2410
+ a("button", {
2411
+ class: "pb-builder__json-apply",
2412
+ disabled: !!B.value,
2413
+ onClick: G
2414
+ }, " Apply → ", 8, tn)
2415
+ ]), a("textarea", {
2416
+ class: "pb-builder__json-editor",
2417
+ value: z.value,
2418
+ spellcheck: "false",
2419
+ onInput: H,
2420
+ onBlur: U
2421
+ }, null, 40, nn)])]),
2422
+ _: 1
2423
+ })
2424
+ ]),
2425
+ _: 1
2426
+ }, 8, ["modelValue"])]),
2427
+ a("div", {
2428
+ class: d(["pb-builder__divider", { "pb-builder__divider--inert": j.value }]),
2429
+ role: "separator",
2430
+ onPointerdown: c[9] ||= (e) => R("props", e)
2431
+ }, null, 34),
2432
+ a("section", { class: d(["pb-builder__pane pb-builder__pane--props", { "pb-builder__pane--rail": j.value }]) }, [j.value ? (h(), i("button", {
2433
+ key: 1,
2434
+ type: "button",
2435
+ class: "pb-builder__rail-btn",
2436
+ title: "Expand properties",
2437
+ onClick: c[11] ||= (e) => j.value = !1
2438
+ }, [s(C(P), {
2439
+ name: "chevrons-left",
2440
+ size: "s"
2441
+ })])) : (h(), i(e, { key: 0 }, [a("button", {
2442
+ type: "button",
2443
+ class: "pb-builder__icon-btn pb-builder__icon-btn--corner",
2444
+ title: "Collapse properties",
2445
+ onClick: c[10] ||= (e) => j.value = !0
2446
+ }, [s(C(P), {
2447
+ name: "chevrons-right",
2448
+ size: "s"
2449
+ })]), s(It, { class: "pb-builder__pane-inner" })], 64))], 2)
2450
+ ], 2));
2451
+ }
2452
+ }), [["__scopeId", "data-v-fb26dca9"]]);
2453
+ //#endregion
2454
+ export { un as CoarPageBuilder, q as CoarPageRenderer, V as isContainerNode, H as isElementAllowed };