@webx-ui/module-blocks 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2461 @@
1
+ import { defineComponent as K, computed as C, openBlock as r, createElementBlock as S, createVNode as u, unref as e, createElementVNode as V, createTextVNode as x, toDisplayString as f, Fragment as j, createCommentVNode as E, renderList as te, ref as U, onMounted as ge, watch as le, createBlock as A, withCtx as p, normalizeStyle as de, reactive as Ne, onBeforeUnmount as De, resolveComponent as Oe, withDirectives as Bt, vModelText as At, isRef as ot, normalizeClass as he, withKeys as Ke, withModifiers as Ie, provide as it, inject as Be, useModel as Wt, getCurrentInstance as zt, mergeModels as Et } from "vue";
2
+ import { useRoute as Ut, useRouter as rt } from "vue-router";
3
+ import { useTranslate as Y, useAdmin as ke, adminKey as Nt } from "@webx-ui/module-admin";
4
+ import { WxIcon as ne, WxSkeleton as We, WxText as R, WxBadge as G, WxButton as q, confirm as Pe, toast as F, useElementWidth as Re, WxSegmented as ut, WxAlert as ct, WxTabs as It, WxTab as ce, WxCodeEditor as Ce, WxFormItem as J, WxInput as pe, WxSelect as dt, WxTextarea as Lt, WxInputNumber as Ze, WxTagsInput as Ge, WxSwitch as Mt, WxCard as Ye, useModal as pt, WxDialog as ft, WxEmpty as mt, WxSortableList as Pt, WxAction as Qe, createModal as vt, WxSpace as Dt, WxHeading as Ot } from "@webx-ui/core";
5
+ import { WxScreenRenderer as ht, coreTypes as Le } from "@webx-ui/schema";
6
+ function fe(t) {
7
+ const l = `${t.apiPath}/blocks`, a = (s) => s.data;
8
+ return {
9
+ list: () => t.http.get(l).then(a),
10
+ catalog: () => t.http.get(`${l}/catalog`).then(a),
11
+ get: (s) => t.http.get(`${l}/${s}`).then(a),
12
+ create: (s) => t.http.post(l, s).then(a),
13
+ update: (s, o) => t.http.put(`${l}/${s}`, o).then(a),
14
+ remove: (s) => t.http.delete(`${l}/${s}`),
15
+ publish: (s) => t.http.post(`${l}/${s}/publish`, {}).then(a),
16
+ render: (s, o = {}) => t.http.post(`${l}/${s}/render`, o).then(a),
17
+ usage: (s) => t.http.get(`${l}/${s}/usage`).then(a),
18
+ versions: (s) => t.http.get(`${l}/${s}/versions`).then(a),
19
+ version: (s, o) => t.http.get(`${l}/${s}/versions/${o}`).then(a),
20
+ restore: (s, o) => t.http.post(`${l}/${s}/versions/${o}/restore`, {}).then(a)
21
+ };
22
+ }
23
+ const Rt = { class: "wx-block-checks" }, jt = {
24
+ key: 0,
25
+ class: "wx-block-checks__line is-error"
26
+ }, Ht = /* @__PURE__ */ K({
27
+ __name: "BlockChecks",
28
+ props: {
29
+ file: {},
30
+ lints: {},
31
+ slug: {},
32
+ error: {}
33
+ },
34
+ setup(t) {
35
+ const l = t, a = Y("webx-blocks"), s = C(() => l.lints.filter((i) => i.file === l.file)), o = C(() => {
36
+ const i = new Set(s.value.map((b) => b.code)), n = [];
37
+ return l.file === "template" && (i.has("no-marker") || n.push(a("checks.ok-marker")), i.has("variables-missing") || n.push(a("checks.ok-variables"))), l.file === "styles" && (i.has("stray-selectors") || n.push(a("checks.ok-prefix", { slug: l.slug })), i.has("bare-selectors") || n.push(a("checks.ok-bare")), i.has("media-query") || n.push(a("checks.ok-container"))), n;
38
+ });
39
+ return (i, n) => (r(), S("div", Rt, [
40
+ t.error ? (r(), S("div", jt, [
41
+ u(e(ne), { name: "close-circle" }),
42
+ V("span", null, [
43
+ x(f(t.error.message) + " ", 1),
44
+ t.error.line !== null ? (r(), S(j, { key: 0 }, [
45
+ x(" · " + f(e(a)("page.line", { line: t.error.line })), 1)
46
+ ], 64)) : E("", !0),
47
+ t.error.where ? (r(), S(j, { key: 1 }, [
48
+ x(" · " + f(t.error.where), 1)
49
+ ], 64)) : E("", !0)
50
+ ])
51
+ ])) : E("", !0),
52
+ (r(!0), S(j, null, te(s.value, (b) => (r(), S("div", {
53
+ key: b.code,
54
+ class: "wx-block-checks__line is-warning"
55
+ }, [
56
+ u(e(ne), { name: "warning" }),
57
+ V("span", null, [
58
+ x(f(b.message) + " ", 1),
59
+ b.line !== null ? (r(), S(j, { key: 0 }, [
60
+ x(" · " + f(e(a)("page.line", { line: b.line })), 1)
61
+ ], 64)) : E("", !0)
62
+ ])
63
+ ]))), 128)),
64
+ (r(!0), S(j, null, te(o.value, (b) => (r(), S("div", {
65
+ key: b,
66
+ class: "wx-block-checks__line is-ok"
67
+ }, [
68
+ u(e(ne), { name: "check" }),
69
+ V("span", null, f(b), 1)
70
+ ]))), 128))
71
+ ]));
72
+ }
73
+ }), Z = (t, l) => {
74
+ const a = t.__vccOpts || t;
75
+ for (const [s, o] of l)
76
+ a[s] = o;
77
+ return a;
78
+ }, Xe = /* @__PURE__ */ Z(Ht, [["__scopeId", "data-v-a96ffa19"]]), Ft = { class: "wx-block-history" }, qt = { class: "wx-block-history__number" }, Jt = { class: "wx-block-history__who" }, Kt = /* @__PURE__ */ K({
79
+ __name: "BlockHistory",
80
+ props: {
81
+ block: {},
82
+ canManage: { type: Boolean }
83
+ },
84
+ emits: ["restored"],
85
+ setup(t, { emit: l }) {
86
+ const a = t, s = l, o = ke(), i = fe(o), n = Y("webx-blocks"), b = U(null);
87
+ async function d() {
88
+ b.value = await i.versions(a.block.id);
89
+ }
90
+ function $(h) {
91
+ return a.block.draft?.number === h.number ? "draft" : a.block.published?.number === h.number ? "live" : "replaced";
92
+ }
93
+ function _(h) {
94
+ return h.created_at ? new Date(h.created_at).toLocaleString(o.i18n.state.locale) : "";
95
+ }
96
+ async function k(h) {
97
+ if (await Pe({
98
+ title: n("page.restore-title", { number: h.number }),
99
+ message: n("page.restore-text"),
100
+ confirmText: n("page.restore"),
101
+ cancelText: n("page.cancel")
102
+ }))
103
+ try {
104
+ const y = await i.restore(a.block.id, h.number);
105
+ F.success(n("page.restored", { number: y.draft?.number ?? h.number })), s("restored", y), await d();
106
+ } catch (y) {
107
+ F.danger(y.body?.message ?? String(y));
108
+ }
109
+ }
110
+ return ge(d), le(
111
+ () => [a.block.draft?.number, a.block.published?.number],
112
+ () => {
113
+ d();
114
+ }
115
+ ), (h, m) => (r(), S("div", Ft, [
116
+ b.value === null ? (r(), A(e(We), {
117
+ key: 0,
118
+ rows: 3
119
+ })) : (r(!0), S(j, { key: 1 }, te(b.value, (y) => (r(), S("div", {
120
+ key: y.number,
121
+ class: "wx-block-history__row"
122
+ }, [
123
+ V("code", qt, f(e(n)("page.version", { number: y.number })), 1),
124
+ V("div", Jt, [
125
+ u(e(R), null, {
126
+ default: p(() => [
127
+ x(f(e(n)(`page.version-${$(y)}`)), 1)
128
+ ]),
129
+ _: 2
130
+ }, 1024),
131
+ u(e(R), {
132
+ size: "sm",
133
+ tone: "muted"
134
+ }, {
135
+ default: p(() => [
136
+ x(f(_(y)) + " · " + f(y.author ?? e(n)(`page.source-${y.source}`)) + " ", 1),
137
+ y.comment ? (r(), S(j, { key: 0 }, [
138
+ x(" · " + f(y.comment), 1)
139
+ ], 64)) : E("", !0)
140
+ ]),
141
+ _: 2
142
+ }, 1024)
143
+ ]),
144
+ $(y) === "draft" ? (r(), A(e(G), {
145
+ key: 0,
146
+ type: "warning",
147
+ dot: ""
148
+ }, {
149
+ default: p(() => [
150
+ x(f(e(n)("page.version-draft")), 1)
151
+ ]),
152
+ _: 1
153
+ })) : $(y) === "live" ? (r(), A(e(G), {
154
+ key: 1,
155
+ type: "success",
156
+ dot: ""
157
+ }, {
158
+ default: p(() => [
159
+ x(f(e(n)("page.version-live")), 1)
160
+ ]),
161
+ _: 1
162
+ })) : E("", !0),
163
+ t.canManage && $(y) === "replaced" ? (r(), A(e(q), {
164
+ key: 2,
165
+ size: "sm",
166
+ variant: "outline",
167
+ onClick: (g) => k(y)
168
+ }, {
169
+ default: p(() => [
170
+ x(f(e(n)("page.restore")), 1)
171
+ ]),
172
+ _: 1
173
+ }, 8, ["onClick"])) : E("", !0)
174
+ ]))), 128))
175
+ ]));
176
+ }
177
+ }), Zt = /* @__PURE__ */ Z(Kt, [["__scopeId", "data-v-e88160ce"]]), Ae = "wx-preview-selected", et = "wx-preview-style";
178
+ function bt(t, l) {
179
+ const s = (t.ownerDocument ?? t).createTreeWalker(
180
+ t,
181
+ 128
182
+ /* NodeFilter.SHOW_COMMENT */
183
+ );
184
+ let o = null;
185
+ for (let i = s.nextNode(); i; i = s.nextNode()) {
186
+ const n = i.data.trim();
187
+ if (o === null && n === `wx:${l}`)
188
+ o = i;
189
+ else if (o !== null && n === `/wx:${l}`)
190
+ return { start: o, end: i };
191
+ }
192
+ return null;
193
+ }
194
+ function Gt(t, l, a) {
195
+ const s = bt(t, l);
196
+ if (!s) return !1;
197
+ const o = s.start.parentNode;
198
+ if (!o) return !1;
199
+ const i = t.createElement("template");
200
+ i.innerHTML = a;
201
+ const n = s.end.nextSibling;
202
+ let b = s.start;
203
+ for (; b; ) {
204
+ const k = b.nextSibling, h = b === s.end;
205
+ if (o.removeChild(b), h) break;
206
+ b = k;
207
+ }
208
+ const d = i.content, $ = Array.from(d.childNodes);
209
+ o.insertBefore(d, n);
210
+ const _ = t.defaultView?.webx;
211
+ if (_?.mount)
212
+ for (const k of $)
213
+ k.nodeType === 1 && _.mount(k);
214
+ return !0;
215
+ }
216
+ function Yt(t, l) {
217
+ const a = bt(t, l);
218
+ if (!a) return null;
219
+ for (let s = a.start.nextSibling; s && s !== a.end; s = s.nextSibling)
220
+ if (s.nodeType === 1) return s;
221
+ return null;
222
+ }
223
+ function Me(t, l) {
224
+ Qt(t);
225
+ for (const s of Array.from(t.querySelectorAll(`.${Ae}`)))
226
+ s.classList.remove(Ae);
227
+ if (l === null) return null;
228
+ const a = Yt(t, l);
229
+ return a?.classList.add(Ae), a;
230
+ }
231
+ function Qt(t) {
232
+ if (t.getElementById(et)) return;
233
+ const l = t.createElement("style");
234
+ l.id = et, l.textContent = `.${Ae}{outline:2px solid #427edd;outline-offset:-2px;}`, (t.head ?? t.documentElement).appendChild(l);
235
+ }
236
+ function gt(t) {
237
+ const l = t.base ? `<base href="${tt(t.base)}">` : "", a = t.frame ? `<style>${t.frame}</style>` : "", s = t.script && t.runtime ? `<script src="${tt(t.runtime)}"><\/script><script>${t.script}<\/script>` : "";
238
+ return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${l}<style>html,body{margin:0}body{container-type:inline-size}</style>${a}<style>${t.styles}</style></head><body>${t.html}${s}</body></html>`;
239
+ }
240
+ function tt(t) {
241
+ return t.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
242
+ }
243
+ const Xt = { class: "wx-block-stage" }, el = { class: "wx-block-stage__bar" }, tl = ["srcdoc", "title"], ll = /* @__PURE__ */ K({
244
+ __name: "BlockStage",
245
+ props: {
246
+ html: {},
247
+ styles: {},
248
+ script: { default: null },
249
+ runtime: { default: null },
250
+ loading: { type: Boolean, default: !1 }
251
+ },
252
+ setup(t) {
253
+ const l = t, a = Y("webx-blocks"), s = C(() => [
254
+ { value: 1280, label: a("page.width-desktop") },
255
+ { value: 834, label: a("page.width-tablet") },
256
+ { value: 390, label: a("page.width-phone") }
257
+ ]), o = U(1280), i = U(null), n = U(null), b = Re(i), d = U(360), $ = C(() => b.value === 0 ? 1 : Math.min(1, b.value / o.value)), _ = C(
258
+ () => gt({
259
+ html: l.html,
260
+ styles: l.styles,
261
+ script: l.script,
262
+ runtime: l.runtime,
263
+ base: typeof location > "u" ? null : location.origin + "/"
264
+ })
265
+ );
266
+ function k() {
267
+ const g = n.value?.contentDocument;
268
+ g?.documentElement && (d.value = Math.max(120, g.documentElement.scrollHeight));
269
+ }
270
+ function h() {
271
+ k(), setTimeout(k, 300);
272
+ }
273
+ le(o, () => setTimeout(k, 50));
274
+ const m = C(() => ({
275
+ width: `${o.value}px`,
276
+ height: `${d.value}px`,
277
+ transform: `scale(${$.value})`
278
+ })), y = C(() => ({
279
+ width: `${Math.round(o.value * $.value)}px`,
280
+ height: `${Math.round(d.value * $.value)}px`
281
+ }));
282
+ return (g, c) => (r(), S("div", Xt, [
283
+ V("div", el, [
284
+ u(e(ut), {
285
+ modelValue: o.value,
286
+ "onUpdate:modelValue": c[0] || (c[0] = (w) => o.value = w),
287
+ options: s.value,
288
+ size: "sm"
289
+ }, null, 8, ["modelValue", "options"])
290
+ ]),
291
+ V("div", {
292
+ ref_key: "box",
293
+ ref: i,
294
+ class: "wx-block-stage__ground"
295
+ }, [
296
+ t.loading && !t.html ? (r(), A(e(We), {
297
+ key: 0,
298
+ rows: 3
299
+ })) : (r(), S("div", {
300
+ key: 1,
301
+ class: "wx-block-stage__clip",
302
+ style: de(y.value)
303
+ }, [
304
+ V("iframe", {
305
+ ref_key: "frame",
306
+ ref: n,
307
+ class: "wx-block-stage__frame",
308
+ srcdoc: _.value,
309
+ style: de(m.value),
310
+ sandbox: "allow-same-origin allow-scripts",
311
+ title: e(a)("page.preview"),
312
+ onLoad: h
313
+ }, null, 44, tl)
314
+ ], 4))
315
+ ], 512)
316
+ ]));
317
+ }
318
+ }), nl = /* @__PURE__ */ Z(ll, [["__scopeId", "data-v-976b03f0"]]);
319
+ function kt(t) {
320
+ return typeof t == "object" && t !== null && typeof t.type == "string" && t.type !== "";
321
+ }
322
+ function je(t) {
323
+ return Array.isArray(t) && t.length > 0 && t.every(kt);
324
+ }
325
+ function yt() {
326
+ return (typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID().replace(/-/g, "") : Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).slice(0, 12);
327
+ }
328
+ function al(t, l = {}) {
329
+ return { key: yt(), type: t, values: l };
330
+ }
331
+ function oe(t, l) {
332
+ return wt(t, l, null, null);
333
+ }
334
+ function wt(t, l, a, s) {
335
+ for (let o = 0; o < t.length; o++) {
336
+ const i = t[o];
337
+ if (i.key === l) return { node: i, parent: a, field: s, list: t, index: o };
338
+ for (const [n, b] of Object.entries(i.values ?? {}))
339
+ if (je(b)) {
340
+ const d = wt(b, l, i, n);
341
+ if (d) return d;
342
+ }
343
+ }
344
+ return null;
345
+ }
346
+ function He(t, l, a = 0, s = null) {
347
+ for (const o of t)
348
+ if (kt(o)) {
349
+ l(o, a, s);
350
+ for (const i of Object.values(o.values ?? {}))
351
+ je(i) && He(i, l, a + 1, o);
352
+ }
353
+ }
354
+ function sl(t, l) {
355
+ let a = 0;
356
+ return He(t, (s) => {
357
+ s.type === l && a++;
358
+ }), a;
359
+ }
360
+ function jn(t) {
361
+ const l = [];
362
+ return He(t, (a) => {
363
+ l.includes(a.type) || l.push(a.type);
364
+ }), l;
365
+ }
366
+ function _t(t) {
367
+ const l = [];
368
+ for (const a of t)
369
+ a.type === "wx-blocks" && l.push(a), a.children && l.push(..._t(a.children));
370
+ return l;
371
+ }
372
+ function xt(t) {
373
+ const l = {};
374
+ for (const [a, s] of Object.entries(t.values ?? {}))
375
+ l[a] = je(s) ? s.map(xt) : ae(s);
376
+ return { key: yt(), type: t.type, values: l };
377
+ }
378
+ function ol(t, l, a) {
379
+ if (l === null) return t;
380
+ const s = oe(t, l);
381
+ if (!s || a === null) return null;
382
+ const o = s.node.values[a];
383
+ return Array.isArray(o) || (s.node.values[a] = []), s.node.values[a];
384
+ }
385
+ function lt(t, l, a, s, o) {
386
+ const i = ae(t), n = ol(i, l, a);
387
+ return n ? (n.splice(Math.max(0, Math.min(s, n.length)), 0, o), i) : t;
388
+ }
389
+ function il(t, l) {
390
+ const a = ae(t), s = oe(a, l);
391
+ return s ? (s.list.splice(s.index, 1), a) : t;
392
+ }
393
+ function rl(t, l, a) {
394
+ const s = ae(t), o = oe(s, l);
395
+ return o ? (o.node.values = a, s) : t;
396
+ }
397
+ function ul(t, l, a, s) {
398
+ if (l === null) return ae(s);
399
+ const o = ae(t), i = oe(o, l);
400
+ return !i || a === null ? t : (i.node.values[a] = ae(s), o);
401
+ }
402
+ function ae(t) {
403
+ return t === void 0 ? t : JSON.parse(JSON.stringify(t));
404
+ }
405
+ const cl = {
406
+ module: {
407
+ title: "Blocks"
408
+ },
409
+ page: {
410
+ blocks: "Blocks",
411
+ new: "New block",
412
+ search: "Search by name or identifier",
413
+ empty: "No block types yet.",
414
+ "empty-help": "A block type is made here entirely: its fields, its template, its styles and its script.",
415
+ "editing-off": "Editing is switched off on this site: the types arrive by import, and the section is read-only.",
416
+ "on-pages": "on :count pages",
417
+ "not-used": "not used yet",
418
+ draft: "Draft v:number",
419
+ live: "Live v:number",
420
+ "never-published": "Not published",
421
+ hidden: "Hidden from editors",
422
+ identifier: "Identifier",
423
+ "identifier-help": "The type in the page content. Renaming it breaks every page the block stands on.",
424
+ title: "Name",
425
+ description: "Description",
426
+ "description-help": "A hint for the editor, and the instruction an agent reads.",
427
+ icon: "Icon",
428
+ group: "Group",
429
+ "group-help": "The section of the list an editor picks a block from.",
430
+ allow: "May hold",
431
+ "allow-help": "Types that can be put inside. Empty — the block is not a container.",
432
+ "allowed-in": "Allowed in",
433
+ "allowed-in-help": "Types that may hold this one. Empty — anywhere, the page itself included.",
434
+ root: "The page itself",
435
+ "max-per-entity": "Per page",
436
+ "max-per-entity-help": "How many instances a page may hold. Empty — no limit.",
437
+ sort: "Order",
438
+ "sort-help": "The order in the CSS cascade and in the list.",
439
+ enabled: "Offered to editors",
440
+ "enabled-help": "Switched off, the block stays on the pages where it already is but cannot be added.",
441
+ "tab-template": "Template",
442
+ "tab-styles": "Styles",
443
+ "tab-script": "Script",
444
+ "tab-fields": "Fields",
445
+ "tab-settings": "Settings",
446
+ "tab-history": "History",
447
+ "insert-field": "Insert a field:",
448
+ "script-help": "The body of an initialiser: el is the root of one instance, values are its values. Called for every instance, and again for a block replaced in the preview.",
449
+ provides: "This site provides through webx.provide(): :names",
450
+ "provides-none": "This site has not declared anything through webx.provide().",
451
+ "fields-help": "Screen nodes, the same ones described screens are built from. The sample form on the right is built from them.",
452
+ "schema-invalid": "The schema is not valid JSON: :error",
453
+ sample: "Sample values",
454
+ "sample-help": "What the thumbnail is drawn on, and what the publish check runs on.",
455
+ preview: "Preview",
456
+ "width-desktop": "Desktop",
457
+ "width-tablet": "Tablet",
458
+ "width-phone": "Phone",
459
+ usage: "Where it is used",
460
+ "usage-empty": "Not on any page yet.",
461
+ "usage-more": "and :count more",
462
+ "unpublished-page": "draft",
463
+ save: "Save",
464
+ saved: "Saved as version :number.",
465
+ unchanged: "Nothing changed.",
466
+ publish: "Publish",
467
+ "publish-title": "Publish version :number?",
468
+ "publish-text": "The version takes effect on every page where the block stands: :count.",
469
+ published: "Version :number is live.",
470
+ "publish-failed": "The version cannot be published.",
471
+ "failed-on": 'Fails on ":title".',
472
+ "no-draft": "There is no draft to publish.",
473
+ failed: "Some values were not accepted. Check the highlighted fields.",
474
+ delete: "Delete",
475
+ "delete-title": 'Delete ":title"?',
476
+ "delete-text": "Every version goes with it. This cannot be undone.",
477
+ "delete-used": "The block stands on :count pages and cannot be deleted.",
478
+ deleted: "Deleted.",
479
+ cancel: "Cancel",
480
+ create: "Create",
481
+ unsaved: "Unsaved changes",
482
+ back: "Blocks",
483
+ line: "line :line",
484
+ version: "v:number",
485
+ "version-draft": "Draft",
486
+ "version-live": "Live",
487
+ "version-replaced": "Replaced",
488
+ restore: "Restore",
489
+ "restore-title": "Restore version :number?",
490
+ "restore-text": "It becomes the draft; publishing it is a separate step.",
491
+ restored: "Version :number is the draft now.",
492
+ "restored-from": "Restored from v:number",
493
+ "source-panel": "panel",
494
+ "source-mcp": "agent",
495
+ "source-import": "import"
496
+ },
497
+ field: {
498
+ blocks: "Blocks",
499
+ add: "Add a block",
500
+ "add-inside": "Add inside",
501
+ done: "Done",
502
+ remove: "Remove",
503
+ "remove-title": 'Remove ":title"?',
504
+ "remove-text": "The blocks inside it go with it.",
505
+ duplicate: "Duplicate",
506
+ empty: "No blocks yet. Add the first one.",
507
+ "nested-note": "Nested blocks are edited in the tree on the left.",
508
+ "unknown-type": 'Unknown block type ":type"',
509
+ "draft-type": "The block type has an unpublished version",
510
+ "disabled-type": "The block type is hidden from editors",
511
+ pick: "Add a block",
512
+ search: "Search by name or identifier",
513
+ "pick-empty": "Nothing matches.",
514
+ "pick-none": "There are no block types yet.",
515
+ "pick-none-link": "Make one in the Blocks section.",
516
+ "pick-limited": 'Only these can go inside ":parent": :types',
517
+ "pick-nothing-allowed": 'Nothing can be put inside ":parent".',
518
+ "limit-reached": "Already :count on this page, the limit for this block",
519
+ preview: "Preview",
520
+ "open-site": "Open on the site",
521
+ fullscreen: "Full screen",
522
+ close: "Close",
523
+ "width-desktop": "Desktop",
524
+ "width-tablet": "Tablet",
525
+ "width-phone": "Phone"
526
+ },
527
+ groups: {
528
+ content: "Content",
529
+ layout: "Layout",
530
+ media: "Media"
531
+ },
532
+ checks: {
533
+ "no-marker": "No data-wx-block on the root: the script will not run, and the panel cannot highlight the block in the preview.",
534
+ "stray-selectors": "Selectors outside the block prefix .b-:slug: :selectors",
535
+ "bare-selectors": "Element selectors reach the whole site: :selectors",
536
+ "media-query": "@media measures the window. A block is sized by its container: use @container.",
537
+ "variables-missing": "The template uses :variables, which the schema does not declare. Publishing will be refused.",
538
+ "ok-marker": "The root carries data-wx-block.",
539
+ "ok-prefix": "Every selector starts with .b-:slug.",
540
+ "ok-bare": "No bare element selectors.",
541
+ "ok-container": "Width is decided by container queries.",
542
+ "ok-variables": "Every variable of the template is a field of the schema."
543
+ }
544
+ }, nt = /* @__PURE__ */ new WeakSet();
545
+ function ye() {
546
+ try {
547
+ const { i18n: t } = ke();
548
+ nt.has(t) || (t.defaults("webx-blocks", cl), nt.add(t));
549
+ } catch {
550
+ }
551
+ }
552
+ const dl = ["block", "entity", "loop", "__env", "errors", "app"];
553
+ function pl(t, l, a) {
554
+ const s = [];
555
+ /data-wx-block\s*=/.test(l.template) || s.push({ file: "template", code: "no-marker", line: null, message: a("checks.no-marker") });
556
+ const o = fl(l.template, l.schema);
557
+ o.length > 0 && s.push({
558
+ file: "template",
559
+ code: "variables-missing",
560
+ line: null,
561
+ message: a("checks.variables-missing", {
562
+ variables: o.map((_) => `$${_}`).join(", ")
563
+ })
564
+ });
565
+ const i = [], n = [], b = `.b-${t}`;
566
+ for (const [_, k] of ml(l.styles))
567
+ _.startsWith(b) || _.startsWith("&") || (/^[a-z][a-z0-9-]*/i.test(_) ? n.push([_, k]) : i.push([_, k]));
568
+ i.length > 0 && s.push({
569
+ file: "styles",
570
+ code: "stray-selectors",
571
+ line: i[0][1],
572
+ message: a("checks.stray-selectors", { slug: t, selectors: at(i) })
573
+ }), n.length > 0 && s.push({
574
+ file: "styles",
575
+ code: "bare-selectors",
576
+ line: n[0][1],
577
+ message: a("checks.bare-selectors", { selectors: at(n) })
578
+ });
579
+ const d = Vt(l.styles), $ = /@media\b/.exec(d);
580
+ return $ && s.push({
581
+ file: "styles",
582
+ code: "media-query",
583
+ line: St(d, $.index),
584
+ message: a("checks.media-query")
585
+ }), s;
586
+ }
587
+ function $t(t) {
588
+ const l = [];
589
+ for (const a of t)
590
+ a.id && l.push(a.id), a.children && l.push(...$t(a.children));
591
+ return l;
592
+ }
593
+ function fl(t, l) {
594
+ const a = /* @__PURE__ */ new Set([...$t(l), ...dl]);
595
+ for (const o of t.matchAll(/\bas\s+\$([a-zA-Z_]\w*)(?:\s*=>\s*\$([a-zA-Z_]\w*))?/g))
596
+ a.add(o[1]), o[2] && a.add(o[2]);
597
+ for (const o of t.matchAll(/\$([a-zA-Z_]\w*)\s*(?:=[^=]|\+\+|--|\.=|\+=|-=)/g))
598
+ a.add(o[1]);
599
+ const s = [];
600
+ for (const o of t.matchAll(/\$([a-zA-Z_]\w*)/g)) {
601
+ const i = o[1];
602
+ !a.has(i) && !s.includes(i) && s.push(i);
603
+ }
604
+ return s;
605
+ }
606
+ function ml(t) {
607
+ const l = Vt(t), a = [];
608
+ for (const s of l.matchAll(/([^{};]+)\{/g)) {
609
+ const o = s[1], i = o.trim();
610
+ if (!(i === "" || i.startsWith("@")))
611
+ for (const n of o.split(",")) {
612
+ const b = n.trim();
613
+ b === "" || b === "from" || b === "to" || b.endsWith("%") || a.push([b, St(l, s.index + o.indexOf(b))]);
614
+ }
615
+ }
616
+ return a;
617
+ }
618
+ function Vt(t) {
619
+ return t.replace(/\/\*[\s\S]*?\*\//g, (l) => l.replace(/[^\n]/g, " "));
620
+ }
621
+ function St(t, l) {
622
+ return t.slice(0, Math.max(0, l)).split(`
623
+ `).length;
624
+ }
625
+ function at(t) {
626
+ const l = [...new Set(t.map(([a]) => a))];
627
+ return l.slice(0, 3).join(", ") + (l.length > 3 ? ", …" : "");
628
+ }
629
+ function Fe(t) {
630
+ return t.map((l) => ({
631
+ ...l,
632
+ name: l.name ?? l.id,
633
+ children: l.children ? Fe(l.children) : l.children
634
+ }));
635
+ }
636
+ function be(t, l) {
637
+ const a = `groups.${t}`, s = l(a);
638
+ return s === a || s === `webx-blocks::${a}` ? t.charAt(0).toUpperCase() + t.slice(1) : s;
639
+ }
640
+ const vl = { class: "wx-block-editor" }, hl = { class: "wx-block-editor__head" }, bl = { class: "wx-block-editor__id" }, gl = ["aria-label", "disabled"], kl = { class: "wx-block-editor__actions" }, yl = { class: "wx-block-editor__columns" }, wl = { class: "wx-block-editor__files" }, _l = { class: "wx-block-editor__pane" }, xl = {
641
+ key: 0,
642
+ class: "wx-block-editor__pills"
643
+ }, $l = ["disabled", "onClick", "textContent"], Vl = { class: "wx-block-editor__pane" }, Sl = { class: "wx-block-editor__pane" }, Tl = { class: "wx-block-editor__note" }, Cl = { class: "wx-block-editor__pane" }, Bl = { class: "wx-block-editor__note" }, Al = { class: "wx-block-editor__settings" }, Wl = {
644
+ key: 0,
645
+ class: "is-wide wx-block-editor__danger"
646
+ }, zl = { class: "wx-block-editor__side" }, El = {
647
+ key: 1,
648
+ class: "wx-block-editor__usage"
649
+ }, Ul = /* @__PURE__ */ K({
650
+ __name: "BlockEditorPage",
651
+ props: {
652
+ base: { default: "/blocks" }
653
+ },
654
+ setup(t) {
655
+ const l = t, a = ke(), s = fe(a), o = Ut(), i = rt();
656
+ ye();
657
+ const n = Y("webx-blocks"), b = C(() => Number(o.params.id)), d = U(null), $ = U([]), _ = U(!0), k = U(!1), h = U(!1), m = U("template"), y = C(() => {
658
+ const T = a.state.manifest?.modules.find((v) => v.id === "blocks")?.meta;
659
+ return {
660
+ groups: T?.groups ?? [],
661
+ editing: T?.editing ?? !0,
662
+ provides: T?.provides ?? []
663
+ };
664
+ }), g = C(() => a.can("blocks.manage") && y.value.editing), c = Ne({
665
+ slug: "",
666
+ title: "",
667
+ description: "",
668
+ icon: "",
669
+ group: "content",
670
+ sort: 0,
671
+ allow: [],
672
+ allowed_in: [],
673
+ max_per_entity: null,
674
+ is_enabled: !0
675
+ }), w = Ne({
676
+ schema: [],
677
+ template: "",
678
+ styles: "",
679
+ script: null,
680
+ sample: {}
681
+ }), B = U("[]"), M = U(null), I = U(""), N = U({}), P = U(null), H = Ne({
682
+ html: "",
683
+ styles: "",
684
+ script: null,
685
+ runtime: null,
686
+ loading: !1
687
+ }), we = C(() => JSON.stringify({ settings: c, content: w })), ie = C(() => I.value !== "" && we.value !== I.value), _e = C(() => pl(c.slug, w, n)), ze = C(() => {
688
+ const T = [...y.value.groups];
689
+ return T.includes(c.group) || T.push(c.group), T.map((v) => ({ value: v, label: be(v, n) }));
690
+ }), me = C({
691
+ get: () => w.sample,
692
+ set: (T) => {
693
+ w.sample = T;
694
+ }
695
+ }), xe = C(() => re(w.schema));
696
+ function re(T) {
697
+ const v = [];
698
+ for (const O of T)
699
+ O.type !== "wx-blocks" && !(O.children?.length && !O.name) && v.push(O.id), O.children && v.push(...re(O.children));
700
+ return v;
701
+ }
702
+ function se(T) {
703
+ d.value = T, Object.assign(c, {
704
+ slug: T.slug,
705
+ title: T.title,
706
+ description: T.description,
707
+ icon: T.icon,
708
+ group: T.group,
709
+ sort: T.sort,
710
+ allow: T.allow ?? [],
711
+ allowed_in: T.allowed_in ?? [],
712
+ max_per_entity: T.max_per_entity,
713
+ is_enabled: T.is_enabled
714
+ });
715
+ const v = T.content ?? {
716
+ schema: [],
717
+ template: "",
718
+ styles: "",
719
+ script: null,
720
+ sample: {}
721
+ };
722
+ Object.assign(w, ae(v)), B.value = JSON.stringify(v.schema, null, 2), M.value = null, I.value = we.value;
723
+ }
724
+ async function $e() {
725
+ _.value = !0;
726
+ try {
727
+ se(await s.get(b.value)), $.value = await s.usage(b.value);
728
+ } catch (T) {
729
+ F.danger(T.body?.message ?? String(T));
730
+ } finally {
731
+ _.value = !1;
732
+ }
733
+ }
734
+ function W(T) {
735
+ B.value = T;
736
+ try {
737
+ const v = JSON.parse(T);
738
+ if (!Array.isArray(v)) throw new Error("not a list");
739
+ w.schema = v, M.value = null;
740
+ } catch (v) {
741
+ M.value = n("page.schema-invalid", { error: v.message });
742
+ }
743
+ }
744
+ let L, D = 0;
745
+ function Q() {
746
+ clearTimeout(L), L = setTimeout(() => {
747
+ X();
748
+ }, 250);
749
+ }
750
+ async function X() {
751
+ if (!d.value) return;
752
+ const T = ++D;
753
+ H.loading = !0;
754
+ try {
755
+ const v = await s.render(d.value.id, {
756
+ values: w.sample,
757
+ content: g.value ? {
758
+ template: w.template,
759
+ styles: w.styles,
760
+ script: w.script,
761
+ schema: w.schema
762
+ } : void 0
763
+ });
764
+ if (T !== D) return;
765
+ H.html = v.html, H.styles = v.styles, H.script = v.script, H.runtime = v.runtime;
766
+ } catch (v) {
767
+ T === D && F.danger(v.body?.message ?? String(v));
768
+ } finally {
769
+ T === D && (H.loading = !1);
770
+ }
771
+ }
772
+ le(
773
+ () => [w.template, w.styles, w.script, w.schema, w.sample],
774
+ Q,
775
+ { deep: !0 }
776
+ );
777
+ const Ve = U(null);
778
+ function ve(T) {
779
+ return `{{ $${T} }}`;
780
+ }
781
+ function Se(T) {
782
+ const O = Ve.value?.view?.value;
783
+ if (!O) {
784
+ w.template += `{{ $${T} }}`;
785
+ return;
786
+ }
787
+ O.dispatch(O.state.replaceSelection(`{{ $${T} }}`)), O.focus();
788
+ }
789
+ async function ue() {
790
+ if (!d.value) return;
791
+ k.value = !0, N.value = {}, P.value = null;
792
+ const T = d.value.draft?.number ?? null;
793
+ try {
794
+ const v = await s.update(d.value.id, {
795
+ ...c,
796
+ allow: c.allow.length ? c.allow : null,
797
+ allowed_in: c.allowed_in.length ? c.allowed_in : null,
798
+ description: c.description || null,
799
+ icon: c.icon || null,
800
+ content: M.value ? { ...w, schema: void 0 } : w
801
+ });
802
+ se(v), F.success(
803
+ v.draft && v.draft.number !== T ? n("page.saved", { number: v.draft.number }) : n("page.unchanged")
804
+ );
805
+ } catch (v) {
806
+ const O = v.body;
807
+ O?.errors ? (N.value = O.errors, F.danger(n("page.failed"))) : F.danger(O?.message ?? n("page.failed"));
808
+ } finally {
809
+ k.value = !1;
810
+ }
811
+ }
812
+ async function Te() {
813
+ if (!(!d.value?.draft || (ie.value && await ue(), !d.value.draft) || !await Pe({
814
+ title: n("page.publish-title", { number: d.value.draft.number }),
815
+ message: n("page.publish-text", { count: d.value.usage_count }),
816
+ confirmText: n("page.publish"),
817
+ cancelText: n("page.cancel")
818
+ }))) {
819
+ h.value = !0, P.value = null;
820
+ try {
821
+ se(await s.publish(d.value.id)), F.success(n("page.published", { number: d.value.published?.number ?? 0 }));
822
+ } catch (v) {
823
+ const O = v.body;
824
+ O?.errors ? (P.value = O, m.value = "template", F.danger(n("page.publish-failed"))) : F.danger(O?.message ?? n("page.publish-failed"));
825
+ } finally {
826
+ h.value = !1;
827
+ }
828
+ }
829
+ }
830
+ async function Ee() {
831
+ if (!(!d.value || !await Pe({
832
+ title: n("page.delete-title", { title: d.value.title }),
833
+ message: n("page.delete-text"),
834
+ confirmText: n("page.delete"),
835
+ cancelText: n("page.cancel"),
836
+ tone: "danger"
837
+ })))
838
+ try {
839
+ await s.remove(d.value.id), F.success(n("page.deleted")), i.push(l.base);
840
+ } catch (v) {
841
+ F.danger(v.body?.message ?? String(v));
842
+ }
843
+ }
844
+ const Ct = C(
845
+ () => P.value ? {
846
+ message: P.value.errors.template?.[0] ?? P.value.message,
847
+ line: P.value.line,
848
+ where: P.value.entity ? n("page.failed-on", {
849
+ title: P.value.entity.title ?? `#${P.value.entity.id}`
850
+ }) : null
851
+ } : null
852
+ ), Ue = C(() => $.value.slice(0, 5));
853
+ function ee(T) {
854
+ return N.value[T]?.[0];
855
+ }
856
+ function Je(T) {
857
+ ie.value && T.preventDefault();
858
+ }
859
+ return ge(() => {
860
+ $e(), window.addEventListener("beforeunload", Je);
861
+ }), De(() => {
862
+ clearTimeout(L), window.removeEventListener("beforeunload", Je);
863
+ }), le(b, () => {
864
+ $e();
865
+ }), (T, v) => {
866
+ const O = Oe("router-link");
867
+ return r(), S("div", vl, [
868
+ _.value || !d.value ? (r(), A(e(We), {
869
+ key: 0,
870
+ rows: 6
871
+ })) : (r(), S(j, { key: 1 }, [
872
+ V("div", hl, [
873
+ V("div", bl, [
874
+ u(O, {
875
+ to: t.base,
876
+ class: "wx-block-editor__back"
877
+ }, {
878
+ default: p(() => [
879
+ x("‹ " + f(e(n)("page.back")), 1)
880
+ ]),
881
+ _: 1
882
+ }, 8, ["to"]),
883
+ Bt(V("input", {
884
+ "onUpdate:modelValue": v[0] || (v[0] = (z) => c.title = z),
885
+ class: "wx-block-editor__title",
886
+ "aria-label": e(n)("page.title"),
887
+ disabled: !g.value
888
+ }, null, 8, gl), [
889
+ [At, c.title]
890
+ ]),
891
+ u(e(R), {
892
+ size: "sm",
893
+ tone: "muted"
894
+ }, {
895
+ default: p(() => [
896
+ V("code", null, f(c.slug), 1),
897
+ x(" · " + f(e(be)(c.group, e(n))) + " · " + f(d.value.usage_count > 0 ? e(n)("page.on-pages", { count: d.value.usage_count }) : e(n)("page.not-used")), 1)
898
+ ]),
899
+ _: 1
900
+ })
901
+ ]),
902
+ V("div", kl, [
903
+ ie.value ? (r(), A(e(G), {
904
+ key: 0,
905
+ type: "primary",
906
+ dot: ""
907
+ }, {
908
+ default: p(() => [
909
+ x(f(e(n)("page.unsaved")), 1)
910
+ ]),
911
+ _: 1
912
+ })) : E("", !0),
913
+ d.value.draft ? (r(), A(e(G), {
914
+ key: 1,
915
+ type: "warning",
916
+ dot: ""
917
+ }, {
918
+ default: p(() => [
919
+ x(f(e(n)("page.draft", { number: d.value.draft.number })), 1)
920
+ ]),
921
+ _: 1
922
+ })) : E("", !0),
923
+ d.value.published ? (r(), A(e(G), {
924
+ key: 2,
925
+ type: "success",
926
+ dot: ""
927
+ }, {
928
+ default: p(() => [
929
+ x(f(e(n)("page.live", { number: d.value.published.number })), 1)
930
+ ]),
931
+ _: 1
932
+ })) : (r(), A(e(G), {
933
+ key: 3,
934
+ type: "default"
935
+ }, {
936
+ default: p(() => [
937
+ x(f(e(n)("page.never-published")), 1)
938
+ ]),
939
+ _: 1
940
+ })),
941
+ g.value ? (r(), S(j, { key: 4 }, [
942
+ u(e(q), {
943
+ variant: "outline",
944
+ loading: k.value,
945
+ onClick: ue
946
+ }, {
947
+ default: p(() => [
948
+ x(f(e(n)("page.save")), 1)
949
+ ]),
950
+ _: 1
951
+ }, 8, ["loading"]),
952
+ u(e(q), {
953
+ type: "primary",
954
+ loading: h.value,
955
+ disabled: !d.value.draft && !ie.value,
956
+ onClick: Te
957
+ }, {
958
+ default: p(() => [
959
+ x(f(e(n)("page.publish")), 1)
960
+ ]),
961
+ _: 1
962
+ }, 8, ["loading", "disabled"])
963
+ ], 64)) : E("", !0)
964
+ ])
965
+ ]),
966
+ y.value.editing ? E("", !0) : (r(), A(e(ct), {
967
+ key: 0,
968
+ type: "info",
969
+ variant: "soft",
970
+ description: e(n)("page.editing-off")
971
+ }, null, 8, ["description"])),
972
+ V("div", yl, [
973
+ V("div", wl, [
974
+ u(e(It), {
975
+ modelValue: m.value,
976
+ "onUpdate:modelValue": v[13] || (v[13] = (z) => m.value = z),
977
+ "keep-alive": ""
978
+ }, {
979
+ default: p(() => [
980
+ u(e(ce), {
981
+ value: "template",
982
+ label: e(n)("page.tab-template")
983
+ }, {
984
+ default: p(() => [
985
+ V("div", _l, [
986
+ u(e(Ce), {
987
+ ref_key: "templateEditor",
988
+ ref: Ve,
989
+ modelValue: w.template,
990
+ "onUpdate:modelValue": v[1] || (v[1] = (z) => w.template = z),
991
+ language: "php",
992
+ readonly: !g.value,
993
+ "min-height": "340px",
994
+ "max-height": "70vh",
995
+ "line-wrapping": ""
996
+ }, null, 8, ["modelValue", "readonly"]),
997
+ xe.value.length ? (r(), S("div", xl, [
998
+ u(e(R), {
999
+ size: "sm",
1000
+ tone: "muted"
1001
+ }, {
1002
+ default: p(() => [
1003
+ x(f(e(n)("page.insert-field")), 1)
1004
+ ]),
1005
+ _: 1
1006
+ }),
1007
+ (r(!0), S(j, null, te(xe.value, (z) => (r(), S("button", {
1008
+ key: z,
1009
+ type: "button",
1010
+ class: "wx-block-editor__pill",
1011
+ disabled: !g.value,
1012
+ onClick: (Ln) => Se(z),
1013
+ textContent: f(ve(z))
1014
+ }, null, 8, $l))), 128))
1015
+ ])) : E("", !0),
1016
+ u(Xe, {
1017
+ file: "template",
1018
+ lints: _e.value,
1019
+ slug: c.slug,
1020
+ error: Ct.value
1021
+ }, null, 8, ["lints", "slug", "error"])
1022
+ ])
1023
+ ]),
1024
+ _: 1
1025
+ }, 8, ["label"]),
1026
+ u(e(ce), {
1027
+ value: "styles",
1028
+ label: e(n)("page.tab-styles")
1029
+ }, {
1030
+ default: p(() => [
1031
+ V("div", Vl, [
1032
+ u(e(Ce), {
1033
+ modelValue: w.styles,
1034
+ "onUpdate:modelValue": v[2] || (v[2] = (z) => w.styles = z),
1035
+ language: "css",
1036
+ readonly: !g.value,
1037
+ "min-height": "340px",
1038
+ "max-height": "70vh"
1039
+ }, null, 8, ["modelValue", "readonly"]),
1040
+ u(Xe, {
1041
+ file: "styles",
1042
+ lints: _e.value,
1043
+ slug: c.slug
1044
+ }, null, 8, ["lints", "slug"])
1045
+ ])
1046
+ ]),
1047
+ _: 1
1048
+ }, 8, ["label"]),
1049
+ u(e(ce), {
1050
+ value: "script",
1051
+ label: e(n)("page.tab-script")
1052
+ }, {
1053
+ default: p(() => [
1054
+ V("div", Sl, [
1055
+ u(e(Ce), {
1056
+ "model-value": w.script ?? "",
1057
+ language: "javascript",
1058
+ readonly: !g.value,
1059
+ "min-height": "340px",
1060
+ "max-height": "70vh",
1061
+ "onUpdate:modelValue": v[3] || (v[3] = (z) => w.script = z || null)
1062
+ }, null, 8, ["model-value", "readonly"]),
1063
+ V("div", Tl, [
1064
+ u(e(R), {
1065
+ size: "sm",
1066
+ tone: "muted"
1067
+ }, {
1068
+ default: p(() => [
1069
+ x(f(e(n)("page.script-help")), 1)
1070
+ ]),
1071
+ _: 1
1072
+ }),
1073
+ u(e(R), {
1074
+ size: "sm",
1075
+ tone: "muted"
1076
+ }, {
1077
+ default: p(() => [
1078
+ x(f(y.value.provides.length ? e(n)("page.provides", { names: y.value.provides.join(", ") }) : e(n)("page.provides-none")), 1)
1079
+ ]),
1080
+ _: 1
1081
+ })
1082
+ ])
1083
+ ])
1084
+ ]),
1085
+ _: 1
1086
+ }, 8, ["label"]),
1087
+ u(e(ce), {
1088
+ value: "fields",
1089
+ label: e(n)("page.tab-fields")
1090
+ }, {
1091
+ default: p(() => [
1092
+ V("div", Cl, [
1093
+ u(e(Ce), {
1094
+ "model-value": B.value,
1095
+ language: "json",
1096
+ lint: "",
1097
+ readonly: !g.value,
1098
+ "min-height": "340px",
1099
+ "max-height": "70vh",
1100
+ "onUpdate:modelValue": W
1101
+ }, null, 8, ["model-value", "readonly"]),
1102
+ V("div", Bl, [
1103
+ M.value ? (r(), A(e(R), {
1104
+ key: 0,
1105
+ size: "sm",
1106
+ tone: "danger"
1107
+ }, {
1108
+ default: p(() => [
1109
+ x(f(M.value), 1)
1110
+ ]),
1111
+ _: 1
1112
+ })) : ee("content.schema") ? (r(), A(e(R), {
1113
+ key: 1,
1114
+ size: "sm",
1115
+ tone: "danger"
1116
+ }, {
1117
+ default: p(() => [
1118
+ x(f(ee("content.schema")), 1)
1119
+ ]),
1120
+ _: 1
1121
+ })) : (r(), A(e(R), {
1122
+ key: 2,
1123
+ size: "sm",
1124
+ tone: "muted"
1125
+ }, {
1126
+ default: p(() => [
1127
+ x(f(e(n)("page.fields-help")), 1)
1128
+ ]),
1129
+ _: 1
1130
+ }))
1131
+ ])
1132
+ ])
1133
+ ]),
1134
+ _: 1
1135
+ }, 8, ["label"]),
1136
+ u(e(ce), {
1137
+ value: "settings",
1138
+ label: e(n)("page.tab-settings")
1139
+ }, {
1140
+ default: p(() => [
1141
+ V("div", Al, [
1142
+ u(e(J), {
1143
+ label: e(n)("page.identifier"),
1144
+ help: e(n)("page.identifier-help"),
1145
+ error: ee("slug"),
1146
+ disabled: !g.value
1147
+ }, {
1148
+ default: p(() => [
1149
+ u(e(pe), {
1150
+ modelValue: c.slug,
1151
+ "onUpdate:modelValue": v[4] || (v[4] = (z) => c.slug = z)
1152
+ }, null, 8, ["modelValue"])
1153
+ ]),
1154
+ _: 1
1155
+ }, 8, ["label", "help", "error", "disabled"]),
1156
+ u(e(J), {
1157
+ label: e(n)("page.group"),
1158
+ help: e(n)("page.group-help"),
1159
+ error: ee("group"),
1160
+ disabled: !g.value
1161
+ }, {
1162
+ default: p(() => [
1163
+ u(e(dt), {
1164
+ modelValue: c.group,
1165
+ "onUpdate:modelValue": v[5] || (v[5] = (z) => c.group = z),
1166
+ options: ze.value
1167
+ }, null, 8, ["modelValue", "options"])
1168
+ ]),
1169
+ _: 1
1170
+ }, 8, ["label", "help", "error", "disabled"]),
1171
+ u(e(J), {
1172
+ class: "is-wide",
1173
+ label: e(n)("page.description"),
1174
+ help: e(n)("page.description-help"),
1175
+ error: ee("description"),
1176
+ disabled: !g.value
1177
+ }, {
1178
+ default: p(() => [
1179
+ u(e(Lt), {
1180
+ "model-value": c.description ?? "",
1181
+ rows: 2,
1182
+ "onUpdate:modelValue": v[6] || (v[6] = (z) => c.description = String(z ?? ""))
1183
+ }, null, 8, ["model-value"])
1184
+ ]),
1185
+ _: 1
1186
+ }, 8, ["label", "help", "error", "disabled"]),
1187
+ u(e(J), {
1188
+ label: e(n)("page.icon"),
1189
+ error: ee("icon"),
1190
+ disabled: !g.value
1191
+ }, {
1192
+ default: p(() => [
1193
+ u(e(pe), {
1194
+ "model-value": c.icon ?? "",
1195
+ placeholder: "grid",
1196
+ "onUpdate:modelValue": v[7] || (v[7] = (z) => c.icon = String(z ?? ""))
1197
+ }, null, 8, ["model-value"])
1198
+ ]),
1199
+ _: 1
1200
+ }, 8, ["label", "error", "disabled"]),
1201
+ u(e(J), {
1202
+ label: e(n)("page.sort"),
1203
+ help: e(n)("page.sort-help"),
1204
+ error: ee("sort"),
1205
+ disabled: !g.value
1206
+ }, {
1207
+ default: p(() => [
1208
+ u(e(Ze), {
1209
+ modelValue: c.sort,
1210
+ "onUpdate:modelValue": v[8] || (v[8] = (z) => c.sort = z)
1211
+ }, null, 8, ["modelValue"])
1212
+ ]),
1213
+ _: 1
1214
+ }, 8, ["label", "help", "error", "disabled"]),
1215
+ u(e(J), {
1216
+ label: e(n)("page.allow"),
1217
+ help: e(n)("page.allow-help"),
1218
+ error: ee("allow"),
1219
+ disabled: !g.value
1220
+ }, {
1221
+ default: p(() => [
1222
+ u(e(Ge), {
1223
+ modelValue: c.allow,
1224
+ "onUpdate:modelValue": v[9] || (v[9] = (z) => c.allow = z),
1225
+ "allow-create": ""
1226
+ }, null, 8, ["modelValue"])
1227
+ ]),
1228
+ _: 1
1229
+ }, 8, ["label", "help", "error", "disabled"]),
1230
+ u(e(J), {
1231
+ label: e(n)("page.allowed-in"),
1232
+ help: e(n)("page.allowed-in-help"),
1233
+ error: ee("allowed_in"),
1234
+ disabled: !g.value
1235
+ }, {
1236
+ default: p(() => [
1237
+ u(e(Ge), {
1238
+ modelValue: c.allowed_in,
1239
+ "onUpdate:modelValue": v[10] || (v[10] = (z) => c.allowed_in = z),
1240
+ "allow-create": "",
1241
+ suggestions: ["root"]
1242
+ }, null, 8, ["modelValue"])
1243
+ ]),
1244
+ _: 1
1245
+ }, 8, ["label", "help", "error", "disabled"]),
1246
+ u(e(J), {
1247
+ label: e(n)("page.max-per-entity"),
1248
+ help: e(n)("page.max-per-entity-help"),
1249
+ error: ee("max_per_entity"),
1250
+ disabled: !g.value
1251
+ }, {
1252
+ default: p(() => [
1253
+ u(e(Ze), {
1254
+ "model-value": c.max_per_entity ?? void 0,
1255
+ min: 1,
1256
+ "onUpdate:modelValue": v[11] || (v[11] = (z) => c.max_per_entity = z ?? null)
1257
+ }, null, 8, ["model-value"])
1258
+ ]),
1259
+ _: 1
1260
+ }, 8, ["label", "help", "error", "disabled"]),
1261
+ u(e(J), {
1262
+ label: e(n)("page.enabled"),
1263
+ help: e(n)("page.enabled-help"),
1264
+ disabled: !g.value
1265
+ }, {
1266
+ default: p(() => [
1267
+ u(e(Mt), {
1268
+ modelValue: c.is_enabled,
1269
+ "onUpdate:modelValue": v[12] || (v[12] = (z) => c.is_enabled = z)
1270
+ }, null, 8, ["modelValue"])
1271
+ ]),
1272
+ _: 1
1273
+ }, 8, ["label", "help", "disabled"]),
1274
+ g.value ? (r(), S("div", Wl, [
1275
+ u(e(q), {
1276
+ type: "danger",
1277
+ variant: "outline",
1278
+ disabled: d.value.usage_count > 0,
1279
+ onClick: Ee
1280
+ }, {
1281
+ default: p(() => [
1282
+ x(f(e(n)("page.delete")), 1)
1283
+ ]),
1284
+ _: 1
1285
+ }, 8, ["disabled"]),
1286
+ d.value.usage_count > 0 ? (r(), A(e(R), {
1287
+ key: 0,
1288
+ size: "sm",
1289
+ tone: "muted"
1290
+ }, {
1291
+ default: p(() => [
1292
+ x(f(e(n)("page.delete-used", { count: d.value.usage_count })), 1)
1293
+ ]),
1294
+ _: 1
1295
+ })) : E("", !0)
1296
+ ])) : E("", !0)
1297
+ ])
1298
+ ]),
1299
+ _: 1
1300
+ }, 8, ["label"]),
1301
+ u(e(ce), {
1302
+ value: "history",
1303
+ label: e(n)("page.tab-history")
1304
+ }, {
1305
+ default: p(() => [
1306
+ u(Zt, {
1307
+ block: d.value,
1308
+ "can-manage": g.value,
1309
+ onRestored: se
1310
+ }, null, 8, ["block", "can-manage"])
1311
+ ]),
1312
+ _: 1
1313
+ }, 8, ["label"])
1314
+ ]),
1315
+ _: 1
1316
+ }, 8, ["modelValue"])
1317
+ ]),
1318
+ V("div", zl, [
1319
+ u(nl, {
1320
+ html: H.html,
1321
+ styles: H.styles,
1322
+ script: H.script,
1323
+ runtime: H.runtime,
1324
+ loading: H.loading
1325
+ }, null, 8, ["html", "styles", "script", "runtime", "loading"]),
1326
+ u(e(Ye), {
1327
+ title: e(n)("page.sample")
1328
+ }, {
1329
+ default: p(() => [
1330
+ w.schema.length ? (r(), A(e(ht), {
1331
+ key: 0,
1332
+ modelValue: me.value,
1333
+ "onUpdate:modelValue": v[14] || (v[14] = (z) => me.value = z),
1334
+ root: e(Fe)(w.schema),
1335
+ types: e(a).types,
1336
+ translate: e(a).i18n.t,
1337
+ can: e(a).can,
1338
+ disabled: !g.value,
1339
+ size: "sm"
1340
+ }, null, 8, ["modelValue", "root", "types", "translate", "can", "disabled"])) : E("", !0),
1341
+ u(e(R), {
1342
+ size: "sm",
1343
+ tone: "muted"
1344
+ }, {
1345
+ default: p(() => [
1346
+ x(f(e(n)("page.sample-help")), 1)
1347
+ ]),
1348
+ _: 1
1349
+ })
1350
+ ]),
1351
+ _: 1
1352
+ }, 8, ["title"]),
1353
+ u(e(Ye), {
1354
+ title: e(n)("page.usage")
1355
+ }, {
1356
+ default: p(() => [
1357
+ $.value.length === 0 ? (r(), A(e(R), {
1358
+ key: 0,
1359
+ size: "sm",
1360
+ tone: "muted"
1361
+ }, {
1362
+ default: p(() => [
1363
+ x(f(e(n)("page.usage-empty")), 1)
1364
+ ]),
1365
+ _: 1
1366
+ })) : (r(), S("div", El, [
1367
+ (r(!0), S(j, null, te(Ue.value, (z) => (r(), S("div", {
1368
+ key: `${z.model}:${z.id}`,
1369
+ class: "wx-block-editor__use"
1370
+ }, [
1371
+ V("span", null, f(z.title ?? `#${z.id}`), 1),
1372
+ z.published ? E("", !0) : (r(), A(e(G), {
1373
+ key: 0,
1374
+ type: "warning",
1375
+ size: "sm"
1376
+ }, {
1377
+ default: p(() => [
1378
+ x(f(e(n)("page.unpublished-page")), 1)
1379
+ ]),
1380
+ _: 1
1381
+ }))
1382
+ ]))), 128)),
1383
+ $.value.length > Ue.value.length ? (r(), A(e(R), {
1384
+ key: 0,
1385
+ size: "sm",
1386
+ tone: "muted"
1387
+ }, {
1388
+ default: p(() => [
1389
+ x(f(e(n)("page.usage-more", { count: $.value.length - Ue.value.length })), 1)
1390
+ ]),
1391
+ _: 1
1392
+ })) : E("", !0)
1393
+ ]))
1394
+ ]),
1395
+ _: 1
1396
+ }, 8, ["title"])
1397
+ ])
1398
+ ])
1399
+ ], 64))
1400
+ ]);
1401
+ };
1402
+ }
1403
+ }), Nl = /* @__PURE__ */ Z(Ul, [["__scopeId", "data-v-2c17889f"]]), Il = ["srcdoc"], Ll = {
1404
+ key: 1,
1405
+ class: "wx-block-thumb__empty"
1406
+ }, Ml = /* @__PURE__ */ K({
1407
+ __name: "BlockThumb",
1408
+ props: {
1409
+ thumbnail: {},
1410
+ width: { default: 1280 },
1411
+ height: { default: 120 }
1412
+ },
1413
+ setup(t) {
1414
+ const l = t, a = U(null), s = Re(a), o = C(() => s.value > 0 ? s.value / l.width : 0.2), i = C(
1415
+ () => l.thumbnail ? gt({ html: l.thumbnail.html, styles: l.thumbnail.styles }) : ""
1416
+ ), n = C(() => ({
1417
+ width: `${l.width}px`,
1418
+ height: `${Math.round(l.height / o.value)}px`,
1419
+ transform: `scale(${o.value})`
1420
+ }));
1421
+ return (b, d) => (r(), S("div", {
1422
+ ref_key: "box",
1423
+ ref: a,
1424
+ class: "wx-block-thumb",
1425
+ style: de({ height: `${t.height}px` })
1426
+ }, [
1427
+ t.thumbnail ? (r(), S("iframe", {
1428
+ key: 0,
1429
+ class: "wx-block-thumb__frame",
1430
+ srcdoc: i.value,
1431
+ style: de(n.value),
1432
+ sandbox: "allow-same-origin",
1433
+ tabindex: "-1",
1434
+ "aria-hidden": "true"
1435
+ }, null, 12, Il)) : (r(), S("div", Ll, [
1436
+ u(e(ne), { name: "grid" })
1437
+ ]))
1438
+ ], 4));
1439
+ }
1440
+ }), Tt = /* @__PURE__ */ Z(Ml, [["__scopeId", "data-v-615b818a"]]), Pl = { class: "wx-block-picker" }, Dl = {
1441
+ key: 0,
1442
+ class: "wx-block-picker__group-title"
1443
+ }, Ol = { class: "wx-block-picker__cards" }, Rl = ["disabled", "title", "onClick"], jl = { class: "wx-block-picker__body" }, Hl = { class: "wx-block-picker__title" }, Fl = /* @__PURE__ */ K({
1444
+ __name: "BlockPicker",
1445
+ props: {
1446
+ catalog: {},
1447
+ parent: { default: null },
1448
+ allow: { default: null },
1449
+ tree: { default: () => [] },
1450
+ groups: { default: () => [] },
1451
+ blocksPath: { default: null }
1452
+ },
1453
+ setup(t) {
1454
+ const l = t, { resolve: a, dismiss: s, open: o } = pt();
1455
+ ye();
1456
+ const i = Y("webx-blocks"), n = U("");
1457
+ function b(h) {
1458
+ if (l.parent === null)
1459
+ return h.allowed_in === null || h.allowed_in.includes("root");
1460
+ const m = l.allow ? l.allow.includes(h.slug) : l.parent.allow?.includes(h.slug) === !0, y = h.allowed_in === null || h.allowed_in.includes(l.parent.slug);
1461
+ return m && y;
1462
+ }
1463
+ const d = C(
1464
+ () => l.catalog.filter((h) => h.is_enabled && h.published !== null && b(h)).map((h) => {
1465
+ const m = sl(l.tree, h.slug), y = h.max_per_entity !== null && m >= h.max_per_entity;
1466
+ return { type: h, reason: y ? i("field.limit-reached", { count: m }) : null };
1467
+ })
1468
+ ), $ = C(() => {
1469
+ const h = n.value.trim().toLowerCase();
1470
+ return h === "" ? d.value : d.value.filter(
1471
+ ({ type: m }) => m.title.toLowerCase().includes(h) || m.slug.includes(h) || (m.description ?? "").toLowerCase().includes(h)
1472
+ );
1473
+ }), _ = C(() => {
1474
+ const h = [...l.groups];
1475
+ for (const { type: g } of $.value)
1476
+ h.includes(g.group) || h.push(g.group);
1477
+ const m = h.map((g) => ({
1478
+ id: g,
1479
+ label: be(g, i),
1480
+ options: $.value.filter((c) => c.type.group === g)
1481
+ })).filter((g) => g.options.length > 0);
1482
+ return $.value.length <= 5 || n.value.trim() !== "" || m.length < 2 ? [{ id: "", label: "", options: $.value }] : m;
1483
+ }), k = C(() => {
1484
+ if (l.catalog.length === 0) return i("field.pick-none");
1485
+ if (d.value.length === 0 && l.parent) {
1486
+ const h = (l.allow ?? l.parent.allow ?? []).filter(
1487
+ (m) => l.catalog.some((y) => y.slug === m)
1488
+ );
1489
+ return h.length === 0 ? i("field.pick-nothing-allowed", { parent: l.parent.title }) : i("field.pick-limited", { parent: l.parent.title, types: h.join(", ") });
1490
+ }
1491
+ return i("field.pick-empty");
1492
+ });
1493
+ return (h, m) => {
1494
+ const y = Oe("router-link");
1495
+ return r(), A(e(ft), {
1496
+ open: e(o),
1497
+ "onUpdate:open": m[2] || (m[2] = (g) => ot(o) ? o.value = g : null),
1498
+ title: e(i)("field.pick"),
1499
+ width: 860
1500
+ }, {
1501
+ footer: p(() => [
1502
+ u(e(q), {
1503
+ variant: "outline",
1504
+ onClick: m[1] || (m[1] = (g) => e(s)())
1505
+ }, {
1506
+ default: p(() => [
1507
+ x(f(e(i)("field.close")), 1)
1508
+ ]),
1509
+ _: 1
1510
+ })
1511
+ ]),
1512
+ default: p(() => [
1513
+ V("div", Pl, [
1514
+ d.value.length > 5 ? (r(), A(e(pe), {
1515
+ key: 0,
1516
+ modelValue: n.value,
1517
+ "onUpdate:modelValue": m[0] || (m[0] = (g) => n.value = g),
1518
+ placeholder: e(i)("field.search"),
1519
+ clearable: "",
1520
+ autofocus: ""
1521
+ }, null, 8, ["modelValue", "placeholder"])) : E("", !0),
1522
+ $.value.length === 0 ? (r(), A(e(mt), {
1523
+ key: 1,
1524
+ icon: "grid",
1525
+ title: k.value,
1526
+ size: "sm"
1527
+ }, {
1528
+ default: p(() => [
1529
+ t.catalog.length === 0 && t.blocksPath ? (r(), A(y, {
1530
+ key: 0,
1531
+ to: t.blocksPath
1532
+ }, {
1533
+ default: p(() => [
1534
+ x(f(e(i)("field.pick-none-link")), 1)
1535
+ ]),
1536
+ _: 1
1537
+ }, 8, ["to"])) : E("", !0)
1538
+ ]),
1539
+ _: 1
1540
+ }, 8, ["title"])) : E("", !0),
1541
+ (r(!0), S(j, null, te(_.value, (g) => (r(), S("section", {
1542
+ key: g.id,
1543
+ class: "wx-block-picker__group"
1544
+ }, [
1545
+ g.label ? (r(), S("div", Dl, f(g.label), 1)) : E("", !0),
1546
+ V("div", Ol, [
1547
+ (r(!0), S(j, null, te(g.options, (c) => (r(), S("button", {
1548
+ key: c.type.id,
1549
+ type: "button",
1550
+ class: he(["wx-block-picker__card", { "is-disabled": c.reason !== null }]),
1551
+ disabled: c.reason !== null,
1552
+ title: c.reason ?? void 0,
1553
+ onClick: (w) => e(a)(c.type)
1554
+ }, [
1555
+ u(Tt, {
1556
+ thumbnail: c.type.thumbnail,
1557
+ height: 96
1558
+ }, null, 8, ["thumbnail"]),
1559
+ V("div", jl, [
1560
+ V("div", Hl, f(c.type.title), 1),
1561
+ c.reason ? (r(), A(e(R), {
1562
+ key: 0,
1563
+ size: "sm",
1564
+ tone: "warning"
1565
+ }, {
1566
+ default: p(() => [
1567
+ x(f(c.reason), 1)
1568
+ ]),
1569
+ _: 2
1570
+ }, 1024)) : c.type.description ? (r(), A(e(R), {
1571
+ key: 1,
1572
+ size: "sm",
1573
+ tone: "muted"
1574
+ }, {
1575
+ default: p(() => [
1576
+ x(f(c.type.description), 1)
1577
+ ]),
1578
+ _: 2
1579
+ }, 1024)) : E("", !0)
1580
+ ])
1581
+ ], 10, Rl))), 128))
1582
+ ])
1583
+ ]))), 128))
1584
+ ])
1585
+ ]),
1586
+ _: 1
1587
+ }, 8, ["open", "title"]);
1588
+ };
1589
+ }
1590
+ }), ql = /* @__PURE__ */ Z(Fl, [["__scopeId", "data-v-a60d5d48"]]), Jl = { class: "wx-blocks-preview__bar" }, Kl = { class: "wx-blocks-preview__tools" }, Zl = ["src", "title"], Gl = /* @__PURE__ */ K({
1591
+ __name: "BlocksPreview",
1592
+ props: {
1593
+ url: {},
1594
+ selected: { default: null },
1595
+ mode: { default: "wide" },
1596
+ reload: { default: 0 }
1597
+ },
1598
+ setup(t, { expose: l }) {
1599
+ const a = t, s = Y("webx-blocks"), o = U(null), i = U(null), n = Re(i), b = U(!1), d = U(1280), $ = U(!1), _ = C(() => [
1600
+ { value: 1280, label: s("field.width-desktop") },
1601
+ { value: 834, label: s("field.width-tablet") },
1602
+ { value: 390, label: s("field.width-phone") }
1603
+ ]), k = C(
1604
+ () => b.value ? d.value : a.mode === "phone" ? 390 : 1280
1605
+ ), h = C(() => b.value || a.mode === "phone" || n.value === 0 ? 1 : Math.min(1, n.value / k.value)), m = C(() => ({
1606
+ width: `${k.value}px`,
1607
+ transform: `scale(${h.value})`
1608
+ })), y = C(() => {
1609
+ if (!a.url) return "";
1610
+ try {
1611
+ return `${new URL(a.url, location.origin).pathname} · ${k.value} px`;
1612
+ } catch {
1613
+ return a.url;
1614
+ }
1615
+ });
1616
+ function g() {
1617
+ try {
1618
+ return o.value?.contentDocument ?? null;
1619
+ } catch {
1620
+ return null;
1621
+ }
1622
+ }
1623
+ function c() {
1624
+ $.value = !0;
1625
+ const I = g();
1626
+ I && Me(I, a.selected ?? null);
1627
+ }
1628
+ function w(I, N) {
1629
+ const P = g();
1630
+ if (!P || !$.value) return !1;
1631
+ const H = Gt(P, I, N);
1632
+ return H && Me(P, a.selected ?? null), H;
1633
+ }
1634
+ function B() {
1635
+ $.value = !1, o.value && a.url && (o.value.src = a.url);
1636
+ }
1637
+ function M(I) {
1638
+ I.key === "Escape" && b.value && (b.value = !1, I.stopPropagation());
1639
+ }
1640
+ return le(
1641
+ () => a.selected,
1642
+ (I) => {
1643
+ const N = g();
1644
+ N && $.value && Me(N, I ?? null);
1645
+ }
1646
+ ), le(() => a.reload, B), le(
1647
+ () => a.url,
1648
+ () => $.value = !1
1649
+ ), ge(() => window.addEventListener("keydown", M)), De(() => window.removeEventListener("keydown", M)), l({ replace: w, refresh: B, open: () => b.value = !0 }), (I, N) => (r(), S("div", {
1650
+ class: he(["wx-blocks-preview", { "is-fullscreen": b.value, "is-phone": t.mode === "phone" }])
1651
+ }, [
1652
+ V("div", Jl, [
1653
+ u(e(R), {
1654
+ size: "xs",
1655
+ tone: "muted",
1656
+ class: "wx-blocks-preview__label",
1657
+ truncate: ""
1658
+ }, {
1659
+ default: p(() => [
1660
+ x(f(y.value), 1)
1661
+ ]),
1662
+ _: 1
1663
+ }),
1664
+ V("div", Kl, [
1665
+ b.value ? (r(), A(e(ut), {
1666
+ key: 0,
1667
+ modelValue: d.value,
1668
+ "onUpdate:modelValue": N[0] || (N[0] = (P) => d.value = P),
1669
+ options: _.value,
1670
+ size: "sm"
1671
+ }, null, 8, ["modelValue", "options"])) : E("", !0),
1672
+ t.url ? (r(), A(e(q), {
1673
+ key: 1,
1674
+ size: "sm",
1675
+ variant: "outline",
1676
+ href: t.url,
1677
+ target: "_blank",
1678
+ rel: "noopener"
1679
+ }, {
1680
+ default: p(() => [
1681
+ x(f(e(s)("field.open-site")), 1)
1682
+ ]),
1683
+ _: 1
1684
+ }, 8, ["href"])) : E("", !0),
1685
+ u(e(q), {
1686
+ size: "sm",
1687
+ variant: "outline",
1688
+ onClick: N[1] || (N[1] = (P) => b.value = !b.value)
1689
+ }, {
1690
+ default: p(() => [
1691
+ x(f(b.value ? e(s)("field.close") : e(s)("field.fullscreen")), 1)
1692
+ ]),
1693
+ _: 1
1694
+ })
1695
+ ])
1696
+ ]),
1697
+ V("div", {
1698
+ ref_key: "box",
1699
+ ref: i,
1700
+ class: "wx-blocks-preview__ground"
1701
+ }, [
1702
+ V("div", {
1703
+ class: "wx-blocks-preview__clip",
1704
+ style: de({ width: `${Math.round(k.value * h.value)}px` })
1705
+ }, [
1706
+ t.url ? (r(), S("iframe", {
1707
+ key: 0,
1708
+ ref_key: "frame",
1709
+ ref: o,
1710
+ class: "wx-blocks-preview__frame",
1711
+ src: t.url,
1712
+ style: de(m.value),
1713
+ title: e(s)("field.preview"),
1714
+ onLoad: c
1715
+ }, null, 44, Zl)) : E("", !0)
1716
+ ], 4)
1717
+ ], 512)
1718
+ ], 2));
1719
+ }
1720
+ }), Yl = /* @__PURE__ */ Z(Gl, [["__scopeId", "data-v-1436a310"]]), Ql = { class: "wx-blocks-tree__node" }, Xl = ["onClick", "onKeydown"], en = { class: "wx-blocks-tree__icon" }, tn = { class: "wx-blocks-tree__name" }, ln = ["title"], nn = ["title"], an = ["title"], sn = ["onClick"], on = /* @__PURE__ */ K({
1721
+ __name: "BlocksTree",
1722
+ props: {
1723
+ nodes: {},
1724
+ catalog: {},
1725
+ parentKey: { default: null },
1726
+ field: { default: null },
1727
+ selected: { default: null },
1728
+ disabled: { type: Boolean, default: !1 },
1729
+ depth: { default: 0 }
1730
+ },
1731
+ emits: ["select", "add", "remove", "duplicate", "reorder"],
1732
+ setup(t, { emit: l }) {
1733
+ const a = t, s = l, o = Y("webx-blocks");
1734
+ function i(_) {
1735
+ return a.catalog.find((k) => k.slug === _.type) ?? null;
1736
+ }
1737
+ function n(_) {
1738
+ return i(_)?.title ?? _.type;
1739
+ }
1740
+ function b(_) {
1741
+ const k = i(_);
1742
+ return k?.content ? _t(k.content.schema) : [];
1743
+ }
1744
+ function d(_, k) {
1745
+ const h = _.values[k.id];
1746
+ return Array.isArray(h) ? h : [];
1747
+ }
1748
+ function $(_) {
1749
+ return i(_)?.icon ?? "grid";
1750
+ }
1751
+ return (_, k) => {
1752
+ const h = Oe("blocks-tree", !0);
1753
+ return r(), A(e(Pt), {
1754
+ "model-value": t.nodes,
1755
+ "item-key": "key",
1756
+ "item-label": (m) => n(m),
1757
+ disabled: t.disabled,
1758
+ plain: "",
1759
+ size: "sm",
1760
+ "empty-text": t.depth === 0 ? e(o)("field.empty") : "",
1761
+ class: he(["wx-blocks-tree", { "is-nested": t.depth > 0 }]),
1762
+ "onUpdate:modelValue": k[6] || (k[6] = (m) => s("reorder", t.parentKey, t.field, m))
1763
+ }, {
1764
+ default: p(({ item: m }) => [
1765
+ V("div", Ql, [
1766
+ V("div", {
1767
+ class: he(["wx-blocks-tree__row", { "is-selected": t.selected === m.key }]),
1768
+ role: "button",
1769
+ tabindex: "0",
1770
+ onClick: (y) => s("select", m.key),
1771
+ onKeydown: [
1772
+ Ke(Ie((y) => s("select", m.key), ["prevent"]), ["enter"]),
1773
+ Ke(Ie((y) => s("select", m.key), ["prevent"]), ["space"])
1774
+ ]
1775
+ }, [
1776
+ V("span", en, [
1777
+ u(e(ne), {
1778
+ name: $(m)
1779
+ }, null, 8, ["name"])
1780
+ ]),
1781
+ V("span", tn, f(n(m)), 1),
1782
+ i(m) ? i(m)?.draft ? (r(), S("span", {
1783
+ key: 1,
1784
+ class: "wx-blocks-tree__flag is-warning",
1785
+ title: e(o)("field.draft-type")
1786
+ }, [
1787
+ u(e(ne), { name: "warning" })
1788
+ ], 8, nn)) : i(m)?.is_enabled === !1 ? (r(), S("span", {
1789
+ key: 2,
1790
+ class: "wx-blocks-tree__flag",
1791
+ title: e(o)("field.disabled-type")
1792
+ }, [
1793
+ u(e(ne), { name: "eye-off" })
1794
+ ], 8, an)) : E("", !0) : (r(), S("span", {
1795
+ key: 0,
1796
+ class: "wx-blocks-tree__flag is-danger",
1797
+ title: e(o)("field.unknown-type", { type: m.type })
1798
+ }, [
1799
+ u(e(ne), { name: "close-circle" })
1800
+ ], 8, ln)),
1801
+ t.disabled ? E("", !0) : (r(), S("span", {
1802
+ key: 3,
1803
+ class: "wx-blocks-tree__actions",
1804
+ onClick: k[0] || (k[0] = Ie(() => {
1805
+ }, ["stop"]))
1806
+ }, [
1807
+ u(e(Qe), {
1808
+ icon: "copy",
1809
+ size: "sm",
1810
+ title: e(o)("field.duplicate"),
1811
+ onClick: (y) => s("duplicate", m.key)
1812
+ }, null, 8, ["title", "onClick"]),
1813
+ u(e(Qe), {
1814
+ icon: "trash",
1815
+ size: "sm",
1816
+ tone: "danger",
1817
+ title: e(o)("field.remove"),
1818
+ onClick: (y) => s("remove", m.key)
1819
+ }, null, 8, ["title", "onClick"])
1820
+ ]))
1821
+ ], 42, Xl),
1822
+ (r(!0), S(j, null, te(b(m), (y) => (r(), S("div", {
1823
+ key: y.id,
1824
+ class: "wx-blocks-tree__kids"
1825
+ }, [
1826
+ u(h, {
1827
+ nodes: d(m, y),
1828
+ catalog: t.catalog,
1829
+ "parent-key": m.key,
1830
+ field: y.id,
1831
+ selected: t.selected,
1832
+ disabled: t.disabled,
1833
+ depth: t.depth + 1,
1834
+ onSelect: k[1] || (k[1] = (g) => s("select", g)),
1835
+ onAdd: k[2] || (k[2] = (g, c, w) => s("add", g, c, w)),
1836
+ onRemove: k[3] || (k[3] = (g) => s("remove", g)),
1837
+ onDuplicate: k[4] || (k[4] = (g) => s("duplicate", g)),
1838
+ onReorder: k[5] || (k[5] = (g, c, w) => s("reorder", g, c, w))
1839
+ }, null, 8, ["nodes", "catalog", "parent-key", "field", "selected", "disabled", "depth"]),
1840
+ t.disabled ? E("", !0) : (r(), S("button", {
1841
+ key: 0,
1842
+ type: "button",
1843
+ class: "wx-blocks-tree__add is-inner",
1844
+ onClick: (g) => s("add", m.key, y.id, y)
1845
+ }, [
1846
+ x(" + " + f(e(o)("field.add-inside")), 1),
1847
+ b(m).length > 1 ? (r(), S(j, { key: 0 }, [
1848
+ x(" · " + f(y.label ?? y.id), 1)
1849
+ ], 64)) : E("", !0)
1850
+ ], 8, sn))
1851
+ ]))), 128))
1852
+ ])
1853
+ ]),
1854
+ _: 1
1855
+ }, 8, ["model-value", "item-label", "disabled", "empty-text", "class"]);
1856
+ };
1857
+ }
1858
+ }), rn = /* @__PURE__ */ Z(on, [["__scopeId", "data-v-5d559d85"]]), qe = /* @__PURE__ */ Symbol("wx-blocks-preview");
1859
+ function Hn(t) {
1860
+ it(qe, t);
1861
+ }
1862
+ function Fn() {
1863
+ return Be(qe, null);
1864
+ }
1865
+ const st = /* @__PURE__ */ Symbol("wx-blocks-root"), un = {
1866
+ key: 0,
1867
+ class: "wx-blocks-nested"
1868
+ }, cn = {
1869
+ key: 1,
1870
+ class: "wx-blocks-host"
1871
+ }, dn = { class: "wx-blocks__tree" }, pn = { class: "wx-blocks__panel-head" }, fn = { class: "wx-blocks__panel-title" }, mn = {
1872
+ key: 0,
1873
+ class: "wx-blocks__fields"
1874
+ }, vn = { class: "wx-blocks__panel-head" }, hn = { class: "wx-blocks__panel-title" }, bn = { class: "wx-blocks__panel-extra" }, gn = { class: "wx-blocks__form" }, kn = {
1875
+ key: 1,
1876
+ class: "wx-blocks__preview"
1877
+ }, yn = /* @__PURE__ */ K({
1878
+ name: "WxBlocks",
1879
+ inheritAttrs: !1,
1880
+ __name: "BlocksField",
1881
+ props: /* @__PURE__ */ Et({
1882
+ node: { default: void 0 },
1883
+ context: { default: void 0 },
1884
+ name: { default: void 0 },
1885
+ localized: { type: Boolean, default: !1 },
1886
+ allow: { default: null },
1887
+ max: { default: null },
1888
+ catalog: { default: null },
1889
+ disabled: { type: Boolean, default: !1 },
1890
+ blocksPath: { default: "/blocks" }
1891
+ }, {
1892
+ modelValue: { default: () => [] },
1893
+ modelModifiers: {}
1894
+ }),
1895
+ emits: ["update:modelValue"],
1896
+ setup(t) {
1897
+ const l = t, a = Wt(t, "modelValue"), s = Be(st, !1);
1898
+ it(st, !0), ye();
1899
+ const o = Y("webx-blocks"), i = Be(Nt, null);
1900
+ let n = null;
1901
+ const b = U([]), d = C(() => l.catalog ?? b.value), $ = C(() => Array.isArray(a.value) ? a.value : []), _ = U(null), k = C(() => _.value ? oe($.value, _.value) : null), h = C(
1902
+ () => k.value ? d.value.find((W) => W.slug === k.value?.node.type) ?? null : null
1903
+ ), m = Be(qe, null), y = U(null), g = C(
1904
+ () => i?.state.manifest?.modules.find((W) => W.id === "blocks")?.meta?.groups ?? []
1905
+ ), c = zt()?.type, w = C(() => l.context?.types ? l.context.types : i?.types ? { ...Le, ...i.types } : c ? { ...Le, "wx-blocks": { component: c, kind: "field", nested: !0 } } : Le), B = C(
1906
+ () => l.context?.translate ?? i?.i18n.t ?? ((W) => W)
1907
+ ), M = C(() => l.context?.can ?? i?.can ?? (() => !0)), I = vt(ql);
1908
+ function N(W) {
1909
+ a.value = W;
1910
+ }
1911
+ async function P(W, L, D) {
1912
+ const Q = W ? oe($.value, W) : null, X = Q ? d.value.find((Ee) => Ee.slug === Q.node.type) ?? null : null, Ve = W === null ? l.allow : D?.props?.allow ?? null, ve = W === null ? l.max : D?.props?.max ?? null, Se = W === null ? $.value : Q && L ? Q.node.values[L] ?? [] : [];
1913
+ if (ve != null && Se.length >= ve) return;
1914
+ const ue = await I({
1915
+ catalog: d.value,
1916
+ parent: X,
1917
+ allow: Ve,
1918
+ tree: $.value,
1919
+ groups: g.value,
1920
+ blocksPath: l.blocksPath
1921
+ });
1922
+ if (!ue) return;
1923
+ const Te = al(ue.slug, H(ue));
1924
+ N(lt($.value, W, L, Se.length, Te)), _.value = Te.key;
1925
+ }
1926
+ function H(W) {
1927
+ const L = W.content?.sample ?? {}, D = {};
1928
+ for (const [Q, X] of Object.entries(L))
1929
+ (!Array.isArray(X) || X.length === 0 || typeof X[0] != "object") && (D[Q] = X);
1930
+ return D;
1931
+ }
1932
+ function we(W) {
1933
+ _.value === W && (_.value = null), N(il($.value, W));
1934
+ }
1935
+ function ie(W) {
1936
+ const L = oe($.value, W);
1937
+ if (!L) return;
1938
+ const D = xt(L.node);
1939
+ N(lt($.value, L.parent?.key ?? null, L.field, L.index + 1, D)), _.value = D.key;
1940
+ }
1941
+ function _e(W, L, D) {
1942
+ N(ul($.value, W, L, D));
1943
+ }
1944
+ function ze(W) {
1945
+ _.value = _.value === W ? null : W;
1946
+ }
1947
+ function me() {
1948
+ _.value = null;
1949
+ }
1950
+ function xe(W) {
1951
+ _.value && N(rl($.value, _.value, W));
1952
+ }
1953
+ let re;
1954
+ le(
1955
+ () => k.value?.node.values,
1956
+ (W, L) => {
1957
+ if (!W || !L || !h.value || !n || !m) return;
1958
+ const D = _.value, Q = h.value.id;
1959
+ clearTimeout(re), re = setTimeout(() => {
1960
+ !D || !n || n.render(Q, { values: W, key: D }).then((X) => {
1961
+ y.value?.replace(D, X.html) || y.value?.refresh();
1962
+ }).catch(() => {
1963
+ });
1964
+ }, 300);
1965
+ },
1966
+ { deep: !0 }
1967
+ );
1968
+ function se(W) {
1969
+ W.key === "Escape" && _.value && me();
1970
+ }
1971
+ ge(async () => {
1972
+ if (window.addEventListener("keydown", se), l.catalog === null && i) {
1973
+ n = fe(i);
1974
+ try {
1975
+ b.value = await n.catalog();
1976
+ } catch (W) {
1977
+ F.danger(W.body?.message ?? String(W));
1978
+ }
1979
+ } else i && (n = fe(i));
1980
+ }), De(() => {
1981
+ clearTimeout(re), window.removeEventListener("keydown", se);
1982
+ });
1983
+ const $e = C(
1984
+ () => h.value?.content ? Fe(h.value.content.schema) : []
1985
+ );
1986
+ return (W, L) => e(s) ? (r(), S("div", un, [
1987
+ u(e(R), {
1988
+ size: "sm",
1989
+ tone: "muted"
1990
+ }, {
1991
+ default: p(() => [
1992
+ x(f(e(o)("field.nested-note")), 1)
1993
+ ]),
1994
+ _: 1
1995
+ })
1996
+ ])) : (r(), S("div", cn, [
1997
+ V("div", {
1998
+ class: he(["wx-blocks", {
1999
+ "is-editing": k.value !== null,
2000
+ "has-preview": e(m) !== null && e(m).url.value !== null
2001
+ }])
2002
+ }, [
2003
+ V("div", dn, [
2004
+ V("div", pn, [
2005
+ V("span", fn, f(e(o)("field.blocks")), 1),
2006
+ u(e(R), {
2007
+ size: "sm",
2008
+ tone: "muted"
2009
+ }, {
2010
+ default: p(() => [
2011
+ x(f($.value.length), 1)
2012
+ ]),
2013
+ _: 1
2014
+ })
2015
+ ]),
2016
+ u(rn, {
2017
+ nodes: $.value,
2018
+ catalog: d.value,
2019
+ selected: _.value,
2020
+ disabled: t.disabled,
2021
+ onSelect: ze,
2022
+ onAdd: P,
2023
+ onRemove: we,
2024
+ onDuplicate: ie,
2025
+ onReorder: _e
2026
+ }, null, 8, ["nodes", "catalog", "selected", "disabled"]),
2027
+ !t.disabled && (t.max === null || $.value.length < t.max) ? (r(), A(e(q), {
2028
+ key: 0,
2029
+ variant: "outline",
2030
+ block: "",
2031
+ icon: "plus",
2032
+ class: "wx-blocks__add",
2033
+ onClick: L[0] || (L[0] = (D) => P(null, null, null))
2034
+ }, {
2035
+ default: p(() => [
2036
+ x(f(e(o)("field.add")), 1)
2037
+ ]),
2038
+ _: 1
2039
+ })) : E("", !0),
2040
+ e(m) && e(m).url.value ? (r(), A(e(q), {
2041
+ key: 1,
2042
+ variant: "text",
2043
+ block: "",
2044
+ class: "wx-blocks__preview-button",
2045
+ onClick: L[1] || (L[1] = (D) => y.value?.open())
2046
+ }, {
2047
+ default: p(() => [
2048
+ x(f(e(o)("field.preview")), 1)
2049
+ ]),
2050
+ _: 1
2051
+ })) : E("", !0)
2052
+ ]),
2053
+ k.value ? (r(), S("div", mn, [
2054
+ V("div", vn, [
2055
+ V("span", hn, f(h.value?.title ?? k.value.node.type), 1),
2056
+ V("span", bn, [
2057
+ V("code", null, f(k.value.node.type), 1),
2058
+ u(e(q), {
2059
+ size: "sm",
2060
+ variant: "outline",
2061
+ onClick: me
2062
+ }, {
2063
+ default: p(() => [
2064
+ x(f(e(o)("field.done")) + " · Esc", 1)
2065
+ ]),
2066
+ _: 1
2067
+ })
2068
+ ])
2069
+ ]),
2070
+ V("div", gn, [
2071
+ h.value?.content ? (r(), A(e(ht), {
2072
+ key: k.value.node.key,
2073
+ "model-value": k.value.node.values,
2074
+ root: $e.value,
2075
+ types: w.value,
2076
+ translate: B.value,
2077
+ can: M.value,
2078
+ disabled: t.disabled,
2079
+ "onUpdate:modelValue": xe
2080
+ }, null, 8, ["model-value", "root", "types", "translate", "can", "disabled"])) : (r(), A(e(R), {
2081
+ key: 1,
2082
+ size: "sm",
2083
+ tone: "danger"
2084
+ }, {
2085
+ default: p(() => [
2086
+ x(f(e(o)("field.unknown-type", { type: k.value.node.type })), 1)
2087
+ ]),
2088
+ _: 1
2089
+ }))
2090
+ ])
2091
+ ])) : E("", !0),
2092
+ e(m) && e(m).url.value ? (r(), S("div", kn, [
2093
+ u(Yl, {
2094
+ ref_key: "previewEl",
2095
+ ref: y,
2096
+ url: e(m).url.value,
2097
+ selected: _.value,
2098
+ mode: k.value ? "phone" : "wide",
2099
+ reload: e(m).reload?.value ?? 0
2100
+ }, null, 8, ["url", "selected", "mode", "reload"])
2101
+ ])) : E("", !0)
2102
+ ], 2)
2103
+ ]));
2104
+ }
2105
+ }), wn = /* @__PURE__ */ Z(yn, [["__scopeId", "data-v-f1ec0da8"]]), _n = { class: "wx-block-card__body" }, xn = { class: "wx-block-card__title" }, $n = { class: "wx-block-card__chips" }, Vn = /* @__PURE__ */ K({
2106
+ __name: "BlockCard",
2107
+ props: {
2108
+ block: {}
2109
+ },
2110
+ emits: ["open"],
2111
+ setup(t, { emit: l }) {
2112
+ const a = l, s = Y("webx-blocks");
2113
+ return (o, i) => (r(), S("button", {
2114
+ type: "button",
2115
+ class: "wx-block-card",
2116
+ onClick: i[0] || (i[0] = (n) => a("open", t.block))
2117
+ }, [
2118
+ u(Tt, {
2119
+ thumbnail: t.block.thumbnail,
2120
+ height: 120
2121
+ }, null, 8, ["thumbnail"]),
2122
+ V("div", _n, [
2123
+ V("div", xn, f(t.block.title), 1),
2124
+ u(e(R), {
2125
+ size: "sm",
2126
+ tone: "muted"
2127
+ }, {
2128
+ default: p(() => [
2129
+ V("code", null, f(t.block.slug), 1),
2130
+ x(" · " + f(t.block.usage_count > 0 ? e(s)("page.on-pages", { count: t.block.usage_count }) : e(s)("page.not-used")), 1)
2131
+ ]),
2132
+ _: 1
2133
+ }),
2134
+ V("div", $n, [
2135
+ t.block.draft ? (r(), A(e(G), {
2136
+ key: 0,
2137
+ type: "warning",
2138
+ dot: ""
2139
+ }, {
2140
+ default: p(() => [
2141
+ x(f(e(s)("page.draft", { number: t.block.draft.number })), 1)
2142
+ ]),
2143
+ _: 1
2144
+ })) : E("", !0),
2145
+ t.block.published ? (r(), A(e(G), {
2146
+ key: 1,
2147
+ type: "success",
2148
+ dot: ""
2149
+ }, {
2150
+ default: p(() => [
2151
+ x(f(e(s)("page.live", { number: t.block.published.number })), 1)
2152
+ ]),
2153
+ _: 1
2154
+ })) : (r(), A(e(G), {
2155
+ key: 2,
2156
+ type: "default"
2157
+ }, {
2158
+ default: p(() => [
2159
+ x(f(e(s)("page.never-published")), 1)
2160
+ ]),
2161
+ _: 1
2162
+ })),
2163
+ t.block.is_enabled ? E("", !0) : (r(), A(e(G), {
2164
+ key: 3,
2165
+ type: "default",
2166
+ variant: "outline"
2167
+ }, {
2168
+ default: p(() => [
2169
+ x(f(e(s)("page.hidden")), 1)
2170
+ ]),
2171
+ _: 1
2172
+ }))
2173
+ ])
2174
+ ])
2175
+ ]));
2176
+ }
2177
+ }), Sn = /* @__PURE__ */ Z(Vn, [["__scopeId", "data-v-daa12de4"]]), Tn = { class: "wx-block-create" }, Cn = /* @__PURE__ */ K({
2178
+ __name: "BlockCreateDialog",
2179
+ setup(t) {
2180
+ const { resolve: l, dismiss: a, open: s } = pt(), o = ke(), i = fe(o);
2181
+ ye();
2182
+ const n = Y("webx-blocks"), b = C(() => o.state.manifest?.modules.find((w) => w.id === "blocks")?.meta?.groups ?? ["content"]), d = U({ title: "", slug: "", group: b.value[0] ?? "content" }), $ = U({}), _ = U(!1), k = U(!1), h = C(
2183
+ () => b.value.map((c) => ({ value: c, label: be(c, n) }))
2184
+ );
2185
+ function m(c) {
2186
+ return c.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/^[^a-z]+/, "").slice(0, 64);
2187
+ }
2188
+ le(
2189
+ () => d.value.title,
2190
+ (c) => {
2191
+ k.value || (d.value.slug = m(c));
2192
+ }
2193
+ );
2194
+ function y(c) {
2195
+ return $.value[c]?.[0];
2196
+ }
2197
+ async function g() {
2198
+ _.value = !0, $.value = {};
2199
+ try {
2200
+ l(await i.create(d.value));
2201
+ } catch (c) {
2202
+ const w = c.body;
2203
+ w?.errors ? $.value = w.errors : F.danger(w?.message ?? n("page.failed"));
2204
+ } finally {
2205
+ _.value = !1;
2206
+ }
2207
+ }
2208
+ return (c, w) => (r(), A(e(ft), {
2209
+ open: e(s),
2210
+ "onUpdate:open": w[5] || (w[5] = (B) => ot(s) ? s.value = B : null),
2211
+ title: e(n)("page.new"),
2212
+ width: 520
2213
+ }, {
2214
+ footer: p(() => [
2215
+ u(e(Dt), { size: "sm" }, {
2216
+ default: p(() => [
2217
+ u(e(q), {
2218
+ variant: "outline",
2219
+ onClick: w[4] || (w[4] = (B) => e(a)())
2220
+ }, {
2221
+ default: p(() => [
2222
+ x(f(e(n)("page.cancel")), 1)
2223
+ ]),
2224
+ _: 1
2225
+ }),
2226
+ u(e(q), {
2227
+ type: "primary",
2228
+ loading: _.value,
2229
+ onClick: g
2230
+ }, {
2231
+ default: p(() => [
2232
+ x(f(e(n)("page.create")), 1)
2233
+ ]),
2234
+ _: 1
2235
+ }, 8, ["loading"])
2236
+ ]),
2237
+ _: 1
2238
+ })
2239
+ ]),
2240
+ default: p(() => [
2241
+ V("div", Tn, [
2242
+ u(e(J), {
2243
+ label: e(n)("page.title"),
2244
+ error: y("title")
2245
+ }, {
2246
+ default: p(() => [
2247
+ u(e(pe), {
2248
+ modelValue: d.value.title,
2249
+ "onUpdate:modelValue": w[0] || (w[0] = (B) => d.value.title = B),
2250
+ autofocus: ""
2251
+ }, null, 8, ["modelValue"])
2252
+ ]),
2253
+ _: 1
2254
+ }, 8, ["label", "error"]),
2255
+ u(e(J), {
2256
+ label: e(n)("page.identifier"),
2257
+ help: e(n)("page.identifier-help"),
2258
+ error: y("slug")
2259
+ }, {
2260
+ default: p(() => [
2261
+ u(e(pe), {
2262
+ modelValue: d.value.slug,
2263
+ "onUpdate:modelValue": w[1] || (w[1] = (B) => d.value.slug = B),
2264
+ placeholder: "hero",
2265
+ onInput: w[2] || (w[2] = (B) => k.value = !0)
2266
+ }, null, 8, ["modelValue"])
2267
+ ]),
2268
+ _: 1
2269
+ }, 8, ["label", "help", "error"]),
2270
+ u(e(J), {
2271
+ label: e(n)("page.group"),
2272
+ help: e(n)("page.group-help"),
2273
+ error: y("group")
2274
+ }, {
2275
+ default: p(() => [
2276
+ u(e(dt), {
2277
+ modelValue: d.value.group,
2278
+ "onUpdate:modelValue": w[3] || (w[3] = (B) => d.value.group = B),
2279
+ options: h.value
2280
+ }, null, 8, ["modelValue", "options"])
2281
+ ]),
2282
+ _: 1
2283
+ }, 8, ["label", "help", "error"])
2284
+ ])
2285
+ ]),
2286
+ _: 1
2287
+ }, 8, ["open", "title"]));
2288
+ }
2289
+ }), Bn = /* @__PURE__ */ Z(Cn, [["__scopeId", "data-v-274bc88a"]]), An = { class: "wx-blocks-page" }, Wn = { class: "wx-blocks-page__head" }, zn = { class: "wx-blocks-page__tools" }, En = {
2290
+ key: 0,
2291
+ class: "wx-blocks-page__group-title"
2292
+ }, Un = { class: "wx-blocks-page__cards" }, Nn = /* @__PURE__ */ K({
2293
+ __name: "BlocksPage",
2294
+ props: {
2295
+ base: { default: "/blocks" }
2296
+ },
2297
+ setup(t) {
2298
+ const l = t, a = ke(), s = fe(a), o = rt();
2299
+ ye();
2300
+ const i = Y("webx-blocks"), n = U([]), b = U(!0), d = U(""), $ = vt(Bn), _ = C(() => {
2301
+ const B = a.state.manifest?.modules.find((M) => M.id === "blocks")?.meta;
2302
+ return {
2303
+ groups: B?.groups ?? [],
2304
+ editing: B?.editing ?? !0,
2305
+ provides: B?.provides ?? []
2306
+ };
2307
+ }), k = C(() => a.can("blocks.manage") && _.value.editing), h = C(
2308
+ () => a.state.manifest?.modules.find((B) => B.id === "blocks")?.title ?? i("module.title")
2309
+ ), m = C(() => {
2310
+ const B = d.value.trim().toLowerCase();
2311
+ return B === "" ? n.value : n.value.filter(
2312
+ (M) => M.title.toLowerCase().includes(B) || M.slug.includes(B) || (M.description ?? "").toLowerCase().includes(B)
2313
+ );
2314
+ }), y = C(() => {
2315
+ const B = [..._.value.groups];
2316
+ for (const N of m.value)
2317
+ B.includes(N.group) || B.push(N.group);
2318
+ const M = B.map((N) => ({
2319
+ id: N,
2320
+ label: be(N, i),
2321
+ blocks: m.value.filter((P) => P.group === N)
2322
+ })).filter((N) => N.blocks.length > 0);
2323
+ return m.value.length <= 5 || d.value.trim() !== "" || M.length < 2 ? [{ id: "", label: "", blocks: m.value }] : M;
2324
+ });
2325
+ async function g() {
2326
+ b.value = !0;
2327
+ try {
2328
+ n.value = await s.list();
2329
+ } catch (B) {
2330
+ F.danger(B.body?.message ?? String(B));
2331
+ } finally {
2332
+ b.value = !1;
2333
+ }
2334
+ }
2335
+ function c(B) {
2336
+ o.push(`${l.base}/${B.id}`);
2337
+ }
2338
+ async function w() {
2339
+ const B = await $({});
2340
+ B && c(B);
2341
+ }
2342
+ return ge(g), (B, M) => (r(), S("div", An, [
2343
+ V("div", Wn, [
2344
+ u(e(Ot), { level: 2 }, {
2345
+ default: p(() => [
2346
+ x(f(h.value), 1)
2347
+ ]),
2348
+ _: 1
2349
+ }),
2350
+ V("div", zn, [
2351
+ u(e(pe), {
2352
+ modelValue: d.value,
2353
+ "onUpdate:modelValue": M[0] || (M[0] = (I) => d.value = I),
2354
+ placeholder: e(i)("page.search"),
2355
+ clearable: ""
2356
+ }, null, 8, ["modelValue", "placeholder"]),
2357
+ k.value ? (r(), A(e(q), {
2358
+ key: 0,
2359
+ type: "primary",
2360
+ icon: "plus",
2361
+ onClick: w
2362
+ }, {
2363
+ default: p(() => [
2364
+ x(f(e(i)("page.new")), 1)
2365
+ ]),
2366
+ _: 1
2367
+ })) : E("", !0)
2368
+ ])
2369
+ ]),
2370
+ _.value.editing ? E("", !0) : (r(), A(e(ct), {
2371
+ key: 0,
2372
+ type: "info",
2373
+ variant: "soft",
2374
+ description: e(i)("page.editing-off")
2375
+ }, null, 8, ["description"])),
2376
+ b.value ? (r(), A(e(We), {
2377
+ key: 1,
2378
+ rows: 4
2379
+ })) : n.value.length === 0 ? (r(), A(e(mt), {
2380
+ key: 2,
2381
+ icon: "grid",
2382
+ title: e(i)("page.empty"),
2383
+ description: e(i)("page.empty-help")
2384
+ }, null, 8, ["title", "description"])) : (r(!0), S(j, { key: 3 }, te(y.value, (I) => (r(), S("section", {
2385
+ key: I.id,
2386
+ class: "wx-blocks-page__group"
2387
+ }, [
2388
+ I.label ? (r(), S("div", En, f(I.label), 1)) : E("", !0),
2389
+ V("div", Un, [
2390
+ (r(!0), S(j, null, te(I.blocks, (N) => (r(), A(Sn, {
2391
+ key: N.id,
2392
+ block: N,
2393
+ onOpen: c
2394
+ }, null, 8, ["block"]))), 128))
2395
+ ])
2396
+ ]))), 128))
2397
+ ]));
2398
+ }
2399
+ }), In = /* @__PURE__ */ Z(Nn, [["__scopeId", "data-v-2dffcfb4"]]);
2400
+ function qn(t = {}) {
2401
+ const l = t.path ?? "/blocks";
2402
+ return {
2403
+ id: "blocks",
2404
+ path: l,
2405
+ routes: [
2406
+ { path: l, name: "webx.blocks", component: In, props: { base: l } },
2407
+ {
2408
+ path: `${l}/:id(\\d+)`,
2409
+ name: "webx.blocks.edit",
2410
+ component: Nl,
2411
+ props: { base: l }
2412
+ }
2413
+ ],
2414
+ // What a screen means by `wx-blocks`: the content of an entity as a tree of blocks. A
2415
+ // nested field, so the renderer hands it the node and the way down — though it never
2416
+ // draws its children through the renderer; it needs the node for `props.allow` alone.
2417
+ types: {
2418
+ "wx-blocks": {
2419
+ component: wn,
2420
+ kind: "field",
2421
+ nested: !0,
2422
+ bind: () => ({ blocksPath: l })
2423
+ }
2424
+ }
2425
+ };
2426
+ }
2427
+ export {
2428
+ Nl as WxBlockEditorPage,
2429
+ ql as WxBlockPicker,
2430
+ nl as WxBlockStage,
2431
+ Tt as WxBlockThumb,
2432
+ wn as WxBlocks,
2433
+ In as WxBlocksPage,
2434
+ qn as blocks,
2435
+ cl as blocksMessages,
2436
+ qe as blocksPreviewKey,
2437
+ xt as cloneNode,
2438
+ sl as countType,
2439
+ fe as createBlocksApi,
2440
+ bt as findRange,
2441
+ Fe as formSchema,
2442
+ Me as highlightBlock,
2443
+ lt as insertNode,
2444
+ kt as isNode,
2445
+ je as isNodeList,
2446
+ pl as lintBlock,
2447
+ oe as locate,
2448
+ al as makeNode,
2449
+ yt as newKey,
2450
+ Hn as provideBlocksPreview,
2451
+ il as removeNode,
2452
+ Gt as replaceBlock,
2453
+ ul as replaceList,
2454
+ gt as stageDocument,
2455
+ jn as typesIn,
2456
+ fl as undeclared,
2457
+ rl as updateValues,
2458
+ Fn as useBlocksPreview,
2459
+ He as walk
2460
+ };
2461
+ //# sourceMappingURL=index.js.map