@chaibuilder/sdk 1.2.90 → 1.2.92

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 (45) hide show
  1. package/dist/CodeEditor-awVVPqel.cjs +1 -0
  2. package/dist/{CodeEditor-t2oVfSyK.js → CodeEditor-orTEdw7a.js} +31 -28
  3. package/dist/Topbar--KOfsR94.cjs +1 -0
  4. package/dist/{Topbar-x0tjZaWC.js → Topbar-OPlOc1Ha.js} +22 -19
  5. package/dist/{UnsplashImages-965l8pGL.js → UnsplashImages-WaGyNL1z.js} +36 -33
  6. package/dist/UnsplashImages-g-8MvB9W.cjs +1 -0
  7. package/dist/{UploadImages-glp4ZyQm.js → UploadImages-GiKofaXX.js} +37 -61
  8. package/dist/UploadImages-Ic_iZgWY.cjs +1 -0
  9. package/dist/_commonjsHelpers-f3sTPFkQ.js +8 -0
  10. package/dist/_commonjsHelpers-f52AuuUj.cjs +1 -0
  11. package/dist/button-9Duvj2dH.js +42 -0
  12. package/dist/button-oQgWN0j0.cjs +1 -0
  13. package/dist/context-menu-8MWP_Ikf.cjs +1 -0
  14. package/dist/context-menu-yLeOsx9j.js +943 -0
  15. package/dist/core.cjs +1 -1
  16. package/dist/core.d.ts +34 -11
  17. package/dist/core.js +81 -76
  18. package/dist/iconBase-BnEC5_qG.js +1583 -0
  19. package/dist/iconBase-_bgMuxa5.cjs +1 -0
  20. package/dist/index-Hj8wMhx_.cjs +223 -0
  21. package/dist/{index-qptv-vi2.js → index-yJ1H6b2C.js} +9771 -10776
  22. package/dist/plugin-02QsHeBE.cjs +1 -0
  23. package/dist/{plugin-P0tpo_XZ.cjs → plugin-BXpjdQxx.cjs} +1 -1
  24. package/dist/{plugin-f5uJtdXY.js → plugin-DdKuAR7p.js} +1 -1
  25. package/dist/plugin-VDzc8jUO.js +52 -0
  26. package/dist/render.cjs +2 -2
  27. package/dist/render.js +7 -6
  28. package/dist/tailwind.cjs +1 -1
  29. package/dist/tailwind.js +7 -6
  30. package/dist/ui.cjs +1 -1
  31. package/dist/ui.js +242 -301
  32. package/dist/web-blocks.cjs +1 -1
  33. package/dist/web-blocks.js +344 -289
  34. package/package.json +2 -2
  35. package/dist/CodeEditor-gqhS0hpB.cjs +0 -1
  36. package/dist/Topbar-s9YVXp9Z.cjs +0 -1
  37. package/dist/UnsplashImages-DRQaQoM-.cjs +0 -1
  38. package/dist/UploadImages-CumBJ3oE.cjs +0 -1
  39. package/dist/context-menu--DZnHfxj.cjs +0 -1
  40. package/dist/context-menu-DeUUflYX.js +0 -910
  41. package/dist/iconBase-vJD0OXxU.cjs +0 -1
  42. package/dist/iconBase-zweRWSz0.js +0 -323
  43. package/dist/index-BuZrwlQG.cjs +0 -223
  44. package/dist/plugin-_F-KZp1i.cjs +0 -1
  45. package/dist/plugin-sJ3Hzvpv.js +0 -57
@@ -0,0 +1,1583 @@
1
+ import W, { createContext as it, useReducer as ct, useEffect as fe, useDebugValue as lt, useCallback as V, useContext as ut, useState as at, useMemo as dt } from "react";
2
+ import { find as te, filter as X, flatten as z, map as T, omit as N, isString as Re, has as Fe, includes as ne, without as ft, get as w, compact as pt, isObject as gt, each as ee, set as me, first as oe, noop as ve, isEmpty as ht, keys as be, chunk as mt, forEach as vt } from "lodash-es";
3
+ import { atom as O, useAtomValue as Z, useAtom as $ } from "jotai";
4
+ import { clsx as bt } from "clsx";
5
+ import { twMerge as yt } from "tailwind-merge";
6
+ import { g as Bt } from "./_commonjsHelpers-f3sTPFkQ.js";
7
+ import { useThrottledCallback as kt } from "@react-hookz/web";
8
+ import "react-i18next";
9
+ import "@chaibuilder/runtime";
10
+ import _t from "tree-model";
11
+ function ce(e = 6, t = "abcdefghijklmnopqrstuvwxyzABCD") {
12
+ let n = "";
13
+ for (let o = e; o > 0; --o)
14
+ n += t[Math.floor(Math.random() * t.length)];
15
+ return n;
16
+ }
17
+ const Vn = (e) => e >= 1536 ? "2XL" : e >= 1280 ? "XL" : e >= 1024 ? "LG" : e >= 768 ? "MD" : e >= 640 ? "SM" : "XS", Un = (...e) => yt(bt(e));
18
+ var x = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
19
+ let At = 0;
20
+ function F(e, t) {
21
+ const n = `atom${++At}`, o = {
22
+ toString: () => n
23
+ };
24
+ return typeof e == "function" ? o.read = e : (o.init = e, o.read = (r) => r(o), o.write = (r, s, i) => s(
25
+ o,
26
+ typeof i == "function" ? i(r(o)) : i
27
+ )), t && (o.write = t), o;
28
+ }
29
+ const pe = (e) => "init" in e, ge = (e) => !!e.write, le = /* @__PURE__ */ new WeakMap(), wt = (e, t) => {
30
+ le.set(e, t), e.catch(() => {
31
+ }).finally(() => le.delete(e));
32
+ }, Le = (e, t) => {
33
+ const n = le.get(e);
34
+ n && (le.delete(e), n(t));
35
+ }, Ie = (e, t) => {
36
+ e.status = "fulfilled", e.value = t;
37
+ }, Ce = (e, t) => {
38
+ e.status = "rejected", e.reason = t;
39
+ }, St = (e) => typeof (e == null ? void 0 : e.then) == "function", Q = (e, t) => "v" in e && "v" in t && Object.is(e.v, t.v), xe = (e, t) => "e" in e && "e" in t && Object.is(e.e, t.e), J = (e) => "v" in e && e.v instanceof Promise, Et = (e, t) => "v" in e && "v" in t && e.v.orig && e.v.orig === t.v.orig, ie = (e) => {
40
+ if ("e" in e)
41
+ throw e.e;
42
+ return e.v;
43
+ }, Pt = () => {
44
+ const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
45
+ let o, r, s;
46
+ (x ? "production" : void 0) !== "production" && (o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set());
47
+ const i = (c) => e.get(c), u = (c, d) => {
48
+ (x ? "production" : void 0) !== "production" && Object.freeze(d);
49
+ const g = e.get(c);
50
+ if (e.set(c, d), n.has(c) || n.set(c, g), g && J(g)) {
51
+ const f = "v" in d ? d.v instanceof Promise ? d.v : Promise.resolve(d.v) : Promise.reject(d.e);
52
+ Le(g.v, f);
53
+ }
54
+ }, a = (c, d, g) => {
55
+ const f = /* @__PURE__ */ new Map();
56
+ let h = !1;
57
+ g.forEach((p, v) => {
58
+ !p && v === c && (p = d), p ? (f.set(v, p), d.d.get(v) !== p && (h = !0)) : (x ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
59
+ }), (h || d.d.size !== f.size) && (d.d = f);
60
+ }, l = (c, d, g) => {
61
+ const f = i(c), h = {
62
+ d: (f == null ? void 0 : f.d) || /* @__PURE__ */ new Map(),
63
+ v: d
64
+ };
65
+ if (g && a(c, h, g), f && Q(f, h) && f.d === h.d)
66
+ return f;
67
+ if (f && J(f) && J(h) && Et(f, h)) {
68
+ if (f.d === h.d)
69
+ return f;
70
+ h.v = f.v;
71
+ }
72
+ return u(c, h), h;
73
+ }, m = (c, d, g, f) => {
74
+ if (St(d)) {
75
+ let h;
76
+ const p = new Promise((v, E) => {
77
+ let y = !1;
78
+ d.then(
79
+ (k) => {
80
+ if (!y) {
81
+ y = !0;
82
+ const B = i(c), q = l(
83
+ c,
84
+ p,
85
+ g
86
+ );
87
+ Ie(p, k), v(k), (B == null ? void 0 : B.d) !== q.d && C(c, q, B == null ? void 0 : B.d);
88
+ }
89
+ },
90
+ (k) => {
91
+ if (!y) {
92
+ y = !0;
93
+ const B = i(c), q = l(
94
+ c,
95
+ p,
96
+ g
97
+ );
98
+ Ce(p, k), E(k), (B == null ? void 0 : B.d) !== q.d && C(c, q, B == null ? void 0 : B.d);
99
+ }
100
+ }
101
+ ), h = (k) => {
102
+ y || (y = !0, k.then(
103
+ (B) => Ie(p, B),
104
+ (B) => Ce(p, B)
105
+ ), v(k));
106
+ };
107
+ });
108
+ return p.orig = d, p.status = "pending", wt(p, (v) => {
109
+ v && h(v), f == null || f();
110
+ }), l(c, p, g);
111
+ }
112
+ return l(c, d, g);
113
+ }, I = (c, d, g) => {
114
+ const f = i(c), h = {
115
+ d: (f == null ? void 0 : f.d) || /* @__PURE__ */ new Map(),
116
+ e: d
117
+ };
118
+ return g && a(c, h, g), f && xe(f, h) && f.d === h.d ? f : (u(c, h), h);
119
+ }, R = (c) => {
120
+ const d = i(c);
121
+ if (d && (d.d.forEach((y, k) => {
122
+ k !== c && !t.has(k) && R(k);
123
+ }), Array.from(d.d).every(([y, k]) => {
124
+ const B = i(y);
125
+ return y === c || B === k || // TODO This is a hack, we should find a better solution.
126
+ B && !J(B) && Q(B, k);
127
+ })))
128
+ return d;
129
+ const g = /* @__PURE__ */ new Map();
130
+ let f = !0;
131
+ const h = (y) => {
132
+ if (y === c) {
133
+ const B = i(y);
134
+ if (B)
135
+ return g.set(y, B), ie(B);
136
+ if (pe(y))
137
+ return g.set(y, void 0), y.init;
138
+ throw new Error("no atom init");
139
+ }
140
+ const k = R(y);
141
+ return g.set(y, k), ie(k);
142
+ };
143
+ let p, v;
144
+ const E = {
145
+ get signal() {
146
+ return p || (p = new AbortController()), p.signal;
147
+ },
148
+ get setSelf() {
149
+ return (x ? "production" : void 0) !== "production" && !ge(c) && console.warn("setSelf function cannot be used with read-only atom"), !v && ge(c) && (v = (...y) => {
150
+ if ((x ? "production" : void 0) !== "production" && f && console.warn("setSelf function cannot be called in sync"), !f)
151
+ return A(c, ...y);
152
+ }), v;
153
+ }
154
+ };
155
+ try {
156
+ const y = c.read(h, E);
157
+ return m(
158
+ c,
159
+ y,
160
+ g,
161
+ () => p == null ? void 0 : p.abort()
162
+ );
163
+ } catch (y) {
164
+ return I(c, y, g);
165
+ } finally {
166
+ f = !1;
167
+ }
168
+ }, U = (c) => ie(R(c)), b = (c) => {
169
+ let d = t.get(c);
170
+ return d || (d = P(c)), d;
171
+ }, _ = (c, d) => !d.l.size && (!d.t.size || d.t.size === 1 && d.t.has(c)), L = (c) => {
172
+ const d = t.get(c);
173
+ d && _(c, d) && M(c);
174
+ }, j = (c) => {
175
+ const d = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new WeakMap(), f = (p) => {
176
+ const v = t.get(p);
177
+ v == null || v.t.forEach((E) => {
178
+ E !== p && (d.set(
179
+ E,
180
+ (d.get(E) || /* @__PURE__ */ new Set()).add(p)
181
+ ), g.set(E, (g.get(E) || 0) + 1), f(E));
182
+ });
183
+ };
184
+ f(c);
185
+ const h = (p) => {
186
+ const v = t.get(p);
187
+ v == null || v.t.forEach((E) => {
188
+ var y;
189
+ if (E !== p) {
190
+ let k = g.get(E);
191
+ if (k && g.set(E, --k), !k) {
192
+ let B = !!((y = d.get(E)) != null && y.size);
193
+ if (B) {
194
+ const q = i(E), st = R(E);
195
+ B = !q || !Q(q, st);
196
+ }
197
+ B || d.forEach((q) => q.delete(E));
198
+ }
199
+ h(E);
200
+ }
201
+ });
202
+ };
203
+ h(c);
204
+ }, S = (c, ...d) => {
205
+ let g = !0;
206
+ const f = (v) => ie(R(v)), h = (v, ...E) => {
207
+ let y;
208
+ if (v === c) {
209
+ if (!pe(v))
210
+ throw new Error("atom not writable");
211
+ const k = i(v), B = m(v, E[0]);
212
+ (!k || !Q(k, B)) && j(v);
213
+ } else
214
+ y = S(v, ...E);
215
+ if (!g) {
216
+ const k = G();
217
+ (x ? "production" : void 0) !== "production" && r.forEach(
218
+ (B) => B({ type: "async-write", flushed: k })
219
+ );
220
+ }
221
+ return y;
222
+ }, p = c.write(f, h, ...d);
223
+ return g = !1, p;
224
+ }, A = (c, ...d) => {
225
+ const g = S(c, ...d), f = G();
226
+ return (x ? "production" : void 0) !== "production" && r.forEach(
227
+ (h) => h({ type: "write", flushed: f })
228
+ ), g;
229
+ }, P = (c, d) => {
230
+ const g = {
231
+ t: new Set(d && [d]),
232
+ l: /* @__PURE__ */ new Set()
233
+ };
234
+ if (t.set(c, g), (x ? "production" : void 0) !== "production" && s.add(c), R(c).d.forEach((f, h) => {
235
+ const p = t.get(h);
236
+ p ? p.t.add(c) : h !== c && P(h, c);
237
+ }), R(c), ge(c) && c.onMount) {
238
+ const f = c.onMount((...h) => A(c, ...h));
239
+ f && (g.u = f);
240
+ }
241
+ return g;
242
+ }, M = (c) => {
243
+ var d;
244
+ const g = (d = t.get(c)) == null ? void 0 : d.u;
245
+ g && g(), t.delete(c), (x ? "production" : void 0) !== "production" && s.delete(c);
246
+ const f = i(c);
247
+ f ? (J(f) && Le(f.v), f.d.forEach((h, p) => {
248
+ if (p !== c) {
249
+ const v = t.get(p);
250
+ v && (v.t.delete(c), _(p, v) && M(p));
251
+ }
252
+ })) : (x ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount", c);
253
+ }, C = (c, d, g) => {
254
+ const f = new Set(d.d.keys());
255
+ g == null || g.forEach((h, p) => {
256
+ if (f.has(p)) {
257
+ f.delete(p);
258
+ return;
259
+ }
260
+ const v = t.get(p);
261
+ v && (v.t.delete(c), _(p, v) && M(p));
262
+ }), f.forEach((h) => {
263
+ const p = t.get(h);
264
+ p ? p.t.add(c) : t.has(c) && P(h, c);
265
+ });
266
+ }, G = () => {
267
+ let c;
268
+ for ((x ? "production" : void 0) !== "production" && (c = /* @__PURE__ */ new Set()); n.size; ) {
269
+ const d = Array.from(n);
270
+ n.clear(), d.forEach(([g, f]) => {
271
+ const h = i(g);
272
+ if (h) {
273
+ h.d !== (f == null ? void 0 : f.d) && C(g, h, f == null ? void 0 : f.d);
274
+ const p = t.get(g);
275
+ p && !// TODO This seems pretty hacky. Hope to fix it.
276
+ // Maybe we could `mountDependencies` in `setAtomState`?
277
+ (f && !J(f) && (Q(f, h) || xe(f, h))) && (p.l.forEach((v) => v()), (x ? "production" : void 0) !== "production" && c.add(g));
278
+ } else
279
+ (x ? "production" : void 0) !== "production" && console.warn("[Bug] no atom state to flush");
280
+ });
281
+ }
282
+ if ((x ? "production" : void 0) !== "production")
283
+ return o.forEach((d) => d("state")), c;
284
+ }, D = (c, d) => {
285
+ const g = b(c), f = G(), h = g.l;
286
+ return h.add(d), (x ? "production" : void 0) !== "production" && (o.forEach((p) => p("sub")), r.forEach(
287
+ (p) => p({ type: "sub", flushed: f })
288
+ )), () => {
289
+ h.delete(d), L(c), (x ? "production" : void 0) !== "production" && (o.forEach((p) => p("unsub")), r.forEach((p) => p({ type: "unsub" })));
290
+ };
291
+ };
292
+ return (x ? "production" : void 0) !== "production" ? {
293
+ get: U,
294
+ set: A,
295
+ sub: D,
296
+ // store dev methods (these are tentative and subject to change without notice)
297
+ dev_subscribe_store: (c, d) => d !== 2 ? (console.warn(
298
+ "The current StoreListener revision is 2. The older ones are deprecated."
299
+ ), o.add(c), () => {
300
+ o.delete(c);
301
+ }) : (r.add(c), () => {
302
+ r.delete(c);
303
+ }),
304
+ dev_get_mounted_atoms: () => s.values(),
305
+ dev_get_atom_state: (c) => e.get(c),
306
+ dev_get_mounted: (c) => t.get(c),
307
+ dev_restore_atoms: (c) => {
308
+ for (const [g, f] of c)
309
+ pe(g) && (m(g, f), j(g));
310
+ const d = G();
311
+ r.forEach(
312
+ (g) => g({ type: "restore", flushed: d })
313
+ );
314
+ }
315
+ } : {
316
+ get: U,
317
+ set: A,
318
+ sub: D
319
+ };
320
+ };
321
+ let he;
322
+ const Ot = () => (he || (he = Pt()), he);
323
+ var ke = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
324
+ const Ve = Symbol(), Me = (e, t, n) => (t.has(n) ? t : t.set(n, e())).get(n), Lt = /* @__PURE__ */ new WeakMap(), It = (e, t, n) => {
325
+ const o = Me(() => /* @__PURE__ */ new WeakMap(), Lt, t);
326
+ return Me(e, o, n);
327
+ }, Ct = {}, Te = (e) => !!e.write, xt = (e) => typeof e == "function";
328
+ function Mt(e, t) {
329
+ return It(
330
+ () => {
331
+ const n = /* @__PURE__ */ new WeakMap(), o = (i, u) => {
332
+ let a = n.get(i);
333
+ if (a)
334
+ return a;
335
+ const l = u && n.get(u), m = [], I = [];
336
+ return i.forEach((R, U) => {
337
+ const b = t ? t(R) : U;
338
+ I[U] = b;
339
+ const _ = l && l.atomList[l.keyList.indexOf(b)];
340
+ if (_) {
341
+ m[U] = _;
342
+ return;
343
+ }
344
+ const L = (S) => {
345
+ const A = S(r), P = S(e), C = o(P, A == null ? void 0 : A.arr).keyList.indexOf(b);
346
+ if (C < 0 || C >= P.length) {
347
+ const G = i[o(i).keyList.indexOf(b)];
348
+ if (G)
349
+ return G;
350
+ throw new Error("splitAtom: index out of bounds for read");
351
+ }
352
+ return P[C];
353
+ }, j = (S, A, P) => {
354
+ const M = S(r), C = S(e), D = o(C, M == null ? void 0 : M.arr).keyList.indexOf(b);
355
+ if (D < 0 || D >= C.length)
356
+ throw new Error("splitAtom: index out of bounds for write");
357
+ const c = xt(P) ? P(C[D]) : P;
358
+ A(e, [
359
+ ...C.slice(0, D),
360
+ c,
361
+ ...C.slice(D + 1)
362
+ ]);
363
+ };
364
+ m[U] = Te(e) ? F(L, j) : F(L);
365
+ }), l && l.keyList.length === I.length && l.keyList.every((R, U) => R === I[U]) ? a = l : a = { arr: i, atomList: m, keyList: I }, n.set(i, a), a;
366
+ }, r = F((i) => {
367
+ const u = i(r), a = i(e);
368
+ return o(a, u == null ? void 0 : u.arr);
369
+ });
370
+ (ke ? "production" : void 0) !== "production" && (r.debugPrivate = !0), r.init = void 0;
371
+ const s = Te(e) ? F(
372
+ (i) => i(r).atomList,
373
+ (i, u, a) => {
374
+ switch (a.type) {
375
+ case "remove": {
376
+ const l = i(s).indexOf(a.atom);
377
+ if (l >= 0) {
378
+ const m = i(e);
379
+ u(e, [
380
+ ...m.slice(0, l),
381
+ ...m.slice(l + 1)
382
+ ]);
383
+ }
384
+ break;
385
+ }
386
+ case "insert": {
387
+ const l = a.before ? i(s).indexOf(a.before) : i(s).length;
388
+ if (l >= 0) {
389
+ const m = i(e);
390
+ u(e, [
391
+ ...m.slice(0, l),
392
+ a.value,
393
+ ...m.slice(l)
394
+ ]);
395
+ }
396
+ break;
397
+ }
398
+ case "move": {
399
+ const l = i(s).indexOf(a.atom), m = a.before ? i(s).indexOf(a.before) : i(s).length;
400
+ if (l >= 0 && m >= 0) {
401
+ const I = i(e);
402
+ l < m ? u(e, [
403
+ ...I.slice(0, l),
404
+ ...I.slice(l + 1, m),
405
+ I[l],
406
+ ...I.slice(m)
407
+ ]) : u(e, [
408
+ ...I.slice(0, m),
409
+ I[l],
410
+ ...I.slice(m, l),
411
+ ...I.slice(l + 1)
412
+ ]);
413
+ }
414
+ break;
415
+ }
416
+ }
417
+ }
418
+ ) : F((i) => i(r).atomList);
419
+ return s;
420
+ },
421
+ e,
422
+ t || Ct
423
+ );
424
+ }
425
+ function Gn(e) {
426
+ const t = Symbol(), n = F(t);
427
+ (ke ? "production" : void 0) !== "production" && (n.debugPrivate = !0);
428
+ const o = F(
429
+ (r, s) => {
430
+ const i = r(n);
431
+ return i !== t ? i : e(r, s);
432
+ },
433
+ (r, s, i) => {
434
+ if (i === Ve)
435
+ s(n, t);
436
+ else if (typeof i == "function") {
437
+ const u = r(o);
438
+ s(n, i(u));
439
+ } else
440
+ s(n, i);
441
+ }
442
+ );
443
+ return o;
444
+ }
445
+ const Tt = (e) => typeof (e == null ? void 0 : e.then) == "function";
446
+ function jt(e) {
447
+ let t, n;
448
+ const o = {
449
+ getItem: (r, s) => {
450
+ var i, u;
451
+ const a = (m) => {
452
+ if (m = m || "", t !== m) {
453
+ try {
454
+ n = JSON.parse(m);
455
+ } catch {
456
+ return s;
457
+ }
458
+ t = m;
459
+ }
460
+ return n;
461
+ }, l = (u = (i = e()) == null ? void 0 : i.getItem(r)) != null ? u : null;
462
+ return Tt(l) ? l.then(a) : a(l);
463
+ },
464
+ setItem: (r, s) => {
465
+ var i;
466
+ return (i = e()) == null ? void 0 : i.setItem(r, JSON.stringify(s));
467
+ },
468
+ removeItem: (r) => {
469
+ var s;
470
+ return (s = e()) == null ? void 0 : s.removeItem(r);
471
+ }
472
+ };
473
+ return typeof window < "u" && typeof window.addEventListener == "function" && (o.subscribe = (r, s, i) => {
474
+ if (!(e() instanceof window.Storage))
475
+ return () => {
476
+ };
477
+ const u = (a) => {
478
+ if (a.storageArea === e() && a.key === r) {
479
+ let l;
480
+ try {
481
+ l = JSON.parse(a.newValue || "");
482
+ } catch {
483
+ l = i;
484
+ }
485
+ s(l);
486
+ }
487
+ };
488
+ return window.addEventListener("storage", u), () => {
489
+ window.removeEventListener("storage", u);
490
+ };
491
+ }), o;
492
+ }
493
+ const Dt = jt(
494
+ () => typeof window < "u" ? window.localStorage : void 0
495
+ );
496
+ function Nt(e, t, n = Dt, o) {
497
+ const r = o == null ? void 0 : o.unstable_getOnInit, s = F(
498
+ r ? n.getItem(e, t) : t
499
+ );
500
+ return (ke ? "production" : void 0) !== "production" && (s.debugPrivate = !0), s.onMount = (u) => {
501
+ r || u(n.getItem(e, t));
502
+ let a;
503
+ return n.subscribe && (a = n.subscribe(e, u, t)), a;
504
+ }, F(
505
+ (u) => u(s),
506
+ (u, a, l) => {
507
+ const m = typeof l == "function" ? l(u(s)) : l;
508
+ return m === Ve ? (a(s, t), n.removeItem(e)) : m instanceof Promise ? m.then((I) => (a(s, I), n.setItem(e, I))) : (a(s, m), n.setItem(e, m));
509
+ }
510
+ );
511
+ }
512
+ var Rt = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
513
+ const Ft = it(void 0), Ue = (e) => {
514
+ const t = ut(Ft);
515
+ return (e == null ? void 0 : e.store) || t || Ot();
516
+ }, Vt = (e) => typeof (e == null ? void 0 : e.then) == "function", Ut = W.use || ((e) => {
517
+ if (e.status === "pending")
518
+ throw e;
519
+ if (e.status === "fulfilled")
520
+ return e.value;
521
+ throw e.status === "rejected" ? e.reason : (e.status = "pending", e.then(
522
+ (t) => {
523
+ e.status = "fulfilled", e.value = t;
524
+ },
525
+ (t) => {
526
+ e.status = "rejected", e.reason = t;
527
+ }
528
+ ), e);
529
+ });
530
+ function Gt(e, t) {
531
+ const n = Ue(t), [[o, r, s], i] = ct(
532
+ (l) => {
533
+ const m = n.get(e);
534
+ return Object.is(l[0], m) && l[1] === n && l[2] === e ? l : [m, n, e];
535
+ },
536
+ void 0,
537
+ () => [n.get(e), n, e]
538
+ );
539
+ let u = o;
540
+ (r !== n || s !== e) && (i(), u = n.get(e));
541
+ const a = t == null ? void 0 : t.delay;
542
+ return fe(() => {
543
+ const l = n.sub(e, () => {
544
+ if (typeof a == "number") {
545
+ setTimeout(i, a);
546
+ return;
547
+ }
548
+ i();
549
+ });
550
+ return i(), l;
551
+ }, [n, e, a]), lt(u), Vt(u) ? Ut(u) : u;
552
+ }
553
+ function qt(e, t) {
554
+ const n = Ue(t);
555
+ return V(
556
+ (...r) => {
557
+ if ((Rt ? "production" : void 0) !== "production" && !("write" in e))
558
+ throw new Error("not writable atom");
559
+ return n.set(e, ...r);
560
+ },
561
+ [n, e]
562
+ );
563
+ }
564
+ function ue(e, t) {
565
+ return [
566
+ Gt(e, t),
567
+ // We do wrong type assertion here, which results in throwing an error.
568
+ qt(e, t)
569
+ ];
570
+ }
571
+ function Ge(e, t, n) {
572
+ const o = X(e, (s) => s._parent === t), r = [];
573
+ for (let s = 0; s < o.length; s++) {
574
+ const i = Ye(o[s]);
575
+ if (Object.keys(i).length > 0 && Object.keys(i).forEach((u) => {
576
+ o[s][u] = `slot:${ce()}`;
577
+ }), X(e, { _parent: o[s]._id }).length > 0) {
578
+ const u = ce();
579
+ r.push({ ...o[s], oldId: o[s]._id, _id: u, _parent: n }), r.push(z(Ge(e, o[s]._id, u)));
580
+ } else
581
+ r.push({
582
+ ...o[s],
583
+ oldId: o[s]._id,
584
+ _id: ce(),
585
+ _parent: n
586
+ });
587
+ }
588
+ return z(r);
589
+ }
590
+ function qe(e) {
591
+ const t = {};
592
+ e.forEach((o) => {
593
+ t[o._id] = { ...o, children: [] };
594
+ });
595
+ const n = [];
596
+ return e.forEach((o) => {
597
+ if (o._parent) {
598
+ const r = t[o._parent];
599
+ r && r.children.push(t[o._id]);
600
+ } else
601
+ n.push(t[o._id]);
602
+ }), n;
603
+ }
604
+ const Ye = (e) => {
605
+ const t = {};
606
+ return Object.keys(e).forEach((n) => {
607
+ Re(e[n]) && e[n].startsWith("slot") && (t[n] = e[n].replace("slot:", ""));
608
+ }), t;
609
+ }, qn = (e, t, n = null) => {
610
+ let o = te(e, { _id: t });
611
+ o = { ...o, oldId: o._id, _id: ce() }, n && (o = { ...o, _parent: n });
612
+ const r = [o];
613
+ X(e, { _parent: t }).length > 0 && r.push(z(Ge(e, t, o._id)));
614
+ const s = z(r);
615
+ return T(s, (i) => {
616
+ const u = i, a = Ye(u);
617
+ return Object.keys(a).length > 0 && Object.keys(a).forEach((l) => {
618
+ const m = te(s, { oldId: a[l].replace("slot:", "") });
619
+ u[l] = `slot:${m._id}`;
620
+ }), N(u, ["global", "oldId"]);
621
+ });
622
+ }, H = O([]);
623
+ H.debugLabel = "presentBlocksAtom";
624
+ const Yt = O((e) => {
625
+ const t = e(H);
626
+ return qe([...t]);
627
+ });
628
+ Yt.debugLabel = "treeDSBlocks";
629
+ H.debugLabel = "presentBlocksAtom";
630
+ const zt = Mt(H);
631
+ zt.debugLabel = "pageBlocksAtomsAtom";
632
+ const Xt = O("");
633
+ Xt.debugLabel = "builderActivePageAtom";
634
+ const Wt = O(-1);
635
+ Wt.debugLabel = "destinationDropIndexAtom";
636
+ const ze = O([]);
637
+ ze.debugLabel = "buildingBlocksAtom";
638
+ const Ht = O((e) => {
639
+ const t = e(ze);
640
+ return X(t, (n) => Fe(n, "blockId"));
641
+ });
642
+ Ht.debugLabel = "globalBlocksAtom";
643
+ const _e = O([]);
644
+ _e.debugLabel = "selectedBlockIdsAtom";
645
+ const Ae = O((e) => {
646
+ const t = e(H), n = e(_e);
647
+ return T(
648
+ X(t, ({ _id: o }) => ne(n, o)),
649
+ (o) => ({ ...o })
650
+ );
651
+ });
652
+ Ae.debugLabel = "selectedBlocksAtom";
653
+ const we = O((e) => {
654
+ const t = e(Ae);
655
+ if (t.length === 0)
656
+ return null;
657
+ if (t.length === 1)
658
+ return t[0];
659
+ });
660
+ we.debugLabel = "selectedBlockAtom";
661
+ const $t = (e) => w(e, "_parent", null), Jt = O((e) => {
662
+ const t = e(Ae), n = T(t, $t);
663
+ return X(e(H), (o) => ne(n, o._id));
664
+ });
665
+ Jt.debugLabel = "selectedBlocksParentsAtom";
666
+ const Xe = O(() => !1);
667
+ Xe.debugLabel = "selectedBlockFlexChildAtom";
668
+ const We = O(() => !1);
669
+ We.debugLabel = "selectedBlockGridChildAtom";
670
+ const Zt = O("");
671
+ Zt.debugLabel = "styleStateAtom";
672
+ const Kt = Nt("styleBreakpoint", "xs");
673
+ Kt.debugLabel = "styleBreakpointAtom";
674
+ const Yn = () => ({
675
+ flexChild: Z(Xe),
676
+ gridChild: Z(We)
677
+ }), zn = () => Z(we), Qt = O((e) => {
678
+ const t = e(we), n = e(H);
679
+ let o = t;
680
+ const r = [t];
681
+ do {
682
+ const s = n.find(({ _id: i }) => i === (o == null ? void 0 : o._parent));
683
+ o = s, s && r.push(s);
684
+ } while (o != null && o._parent);
685
+ return r;
686
+ }), Xn = () => pt(Z(Qt)), en = () => {
687
+ const [e, t] = $(_e), n = V(
688
+ (o) => {
689
+ t((r) => ne(r, o) ? ft(r, o) : [...r, o]);
690
+ },
691
+ [t]
692
+ );
693
+ return [e, t, n];
694
+ };
695
+ var He = { exports: {} };
696
+ (function(e) {
697
+ (function() {
698
+ function t(o, r, s) {
699
+ return o.splice(
700
+ r,
701
+ !s || 1 + s - r + (!(s < 0 ^ r >= 0) && (s < 0 || -1) * o.length)
702
+ ), o.length;
703
+ }
704
+ let n = function() {
705
+ let o = [], r = -1, s = 0, i = !1, u;
706
+ function a(l, m) {
707
+ return !l || typeof l[m] != "function" ? this : (i = !0, l[m](), i = !1, this);
708
+ }
709
+ return {
710
+ /**
711
+ * Adds a command to the queue.
712
+ * @property {object} command - Command
713
+ * @property {function} command.undo - Undo function
714
+ * @property {function} command.redo - Redo function
715
+ * @property {string} [command.groupId] - Optional group id
716
+ */
717
+ add: function(l) {
718
+ return i ? this : (o.splice(r + 1, o.length - r), o.push(l), s && o.length > s && t(o, 0, -(s + 1)), r = o.length - 1, u && u(), this);
719
+ },
720
+ /**
721
+ * Pass a function to be called on undo and redo actions.
722
+ * @property {function} callbackFunc - Callback function
723
+ */
724
+ setCallback: function(l) {
725
+ u = l;
726
+ },
727
+ /**
728
+ * Performs undo: call the undo function at the current index and decrease the index by 1.
729
+ */
730
+ undo: function() {
731
+ let l = o[r];
732
+ if (!l)
733
+ return this;
734
+ const m = l.groupId;
735
+ for (; l.groupId === m && (a(l, "undo"), r -= 1, l = o[r], !(!l || !l.groupId)); )
736
+ ;
737
+ return u && u(), this;
738
+ },
739
+ /**
740
+ * Performs redo: call the redo function at the next index and increase the index by 1.
741
+ */
742
+ redo: function() {
743
+ let l = o[r + 1];
744
+ if (!l)
745
+ return this;
746
+ const m = l.groupId;
747
+ for (; l.groupId === m && (a(l, "redo"), r += 1, l = o[r + 1], !(!l || !l.groupId)); )
748
+ ;
749
+ return u && u(), this;
750
+ },
751
+ /**
752
+ * Clears the memory, losing all stored states. Resets the index.
753
+ */
754
+ clear: function() {
755
+ let l = o.length;
756
+ o = [], r = -1, u && l > 0 && u();
757
+ },
758
+ /**
759
+ * Tests if any undo actions exist.
760
+ * @returns {boolean}
761
+ */
762
+ hasUndo: function() {
763
+ return r !== -1;
764
+ },
765
+ /**
766
+ * Tests if any redo actions exist.
767
+ * @returns {boolean}
768
+ */
769
+ hasRedo: function() {
770
+ return r < o.length - 1;
771
+ },
772
+ /**
773
+ * Returns the list of queued commands.
774
+ * @param {string} [groupId] - Optionally filter commands by group ID
775
+ * @returns {array}
776
+ */
777
+ getCommands: function(l) {
778
+ return l ? o.filter((m) => m.groupId === l) : o;
779
+ },
780
+ /**
781
+ * Returns the index of the actions list.
782
+ * @returns {number}
783
+ */
784
+ getIndex: function() {
785
+ return r;
786
+ },
787
+ /**
788
+ * Sets the maximum number of undo steps. Default: 0 (unlimited).
789
+ * @property {number} max - Maximum number of undo steps
790
+ */
791
+ setLimit: function(l) {
792
+ s = l;
793
+ }
794
+ };
795
+ };
796
+ e.exports ? e.exports = n : window.UndoManager = n;
797
+ })();
798
+ })(He);
799
+ var tn = He.exports;
800
+ const nn = /* @__PURE__ */ Bt(tn), Wn = [
801
+ "hover",
802
+ "focus",
803
+ "focus-within",
804
+ "focus-visible",
805
+ "active",
806
+ "visited",
807
+ "target",
808
+ "first",
809
+ "last",
810
+ "only",
811
+ "odd",
812
+ "even",
813
+ "first-of-type",
814
+ "last-of-type",
815
+ "only-of-type",
816
+ "empty",
817
+ "disabled",
818
+ "checked",
819
+ "indeterminate",
820
+ "default",
821
+ "required",
822
+ "valid",
823
+ "invalid",
824
+ "in-range",
825
+ "out-of-range",
826
+ "placeholder-shown",
827
+ "autofill",
828
+ "read-only",
829
+ "open",
830
+ "before",
831
+ "after",
832
+ "first-letter",
833
+ "first-line",
834
+ "marker",
835
+ "selection",
836
+ "file",
837
+ "placeholder",
838
+ // preline
839
+ "hs-collapse-open",
840
+ "hs-accordion-active"
841
+ ], ye = {
842
+ bodyFont: "Inter",
843
+ headingFont: "Inter",
844
+ roundedCorners: 5,
845
+ primaryColor: "#570df8",
846
+ secondaryColor: "#f002b8",
847
+ bodyBgDarkColor: "#031022",
848
+ bodyBgLightColor: "#fcfcfc",
849
+ bodyTextDarkColor: "#ffffff",
850
+ bodyTextLightColor: "#000000"
851
+ }, on = O(ye), rn = O(null), $e = () => {
852
+ const [e, t] = $(on);
853
+ return [
854
+ gt(e) ? { ...ye, ...e } : ye,
855
+ t
856
+ ];
857
+ }, Hn = () => $(rn), sn = O(null), cn = () => ({ currentPage: Z(sn) });
858
+ function Je(e) {
859
+ return qe(e);
860
+ }
861
+ const Se = (e, t) => z(
862
+ e.map((n) => {
863
+ if (n = t ? { ...n, _parent: t } : { ...n }, n.children) {
864
+ const o = [...n.children];
865
+ return delete n.children, z([n, ...Se(o, n._id)]);
866
+ }
867
+ return n;
868
+ })
869
+ );
870
+ function Ee(e, t = !1) {
871
+ for (let n = 0; n < e.length; n++) {
872
+ const o = e[n];
873
+ o.global && !t ? e[n] = {
874
+ type: "GlobalBlock",
875
+ blockId: o.blockId,
876
+ _parent: w(o, "_parent", null),
877
+ _id: o._id
878
+ } : o.children && o.children.length && Ee(o.children);
879
+ }
880
+ }
881
+ function Ze(e) {
882
+ let t = [], n = X(e, { type: "GlobalBlock" });
883
+ return n.length > 0 && (n = T(n, Ke), ee(n, (o) => {
884
+ t = [...t, ...ln(o)];
885
+ })), t;
886
+ }
887
+ function ln(e) {
888
+ let t = [];
889
+ const n = w(oe(e), "_parent", null);
890
+ me(oe(e), "_parent", null);
891
+ const o = [flatToNestedInstance.convert(Qe(e))];
892
+ Ee(o, !0);
893
+ let r = Se(o, e[0]._id);
894
+ return r = me(r, "0._parent", n), t = [...t, r, ...Ze(r)], t;
895
+ }
896
+ function Ke(e) {
897
+ const t = te(Be, { _id: e._id });
898
+ if (!t)
899
+ return [];
900
+ const n = [t], o = X(Be, { _parent: e._id });
901
+ return o.length ? z([...n, ...z(T(o, Ke))]) : z(n);
902
+ }
903
+ const Qe = (e) => JSON.parse(JSON.stringify(e));
904
+ let Be = [];
905
+ function un(e) {
906
+ Be = e;
907
+ const t = Je(Qe(e));
908
+ Ee(t);
909
+ const n = Se(t, null), o = Ze(n), r = {};
910
+ return ee(o, (s) => me(r, oe(s).blockId, s)), [n, r];
911
+ }
912
+ const an = () => {
913
+ const [e] = $e(), { currentPage: t } = cn(), [n] = se();
914
+ return V(() => {
915
+ const o = T(
916
+ n,
917
+ (s) => N(s, ["expanded", "order", "title", "siblings", "tempClasses"])
918
+ ), [r = []] = un(o);
919
+ return {
920
+ currentPage: t,
921
+ blocks: r
922
+ };
923
+ }, [e, t, n]);
924
+ }, et = O(null);
925
+ et.debugLabel = "chaiBuilderPropsAtom";
926
+ const dn = O({});
927
+ dn.debugLabel = "chaiExternalDataAtom";
928
+ const re = (e, t = void 0) => {
929
+ const n = Z(et);
930
+ return w(n, e, t);
931
+ }, tt = O([]);
932
+ tt.debugLabel = "dataProvidersAtom";
933
+ const fn = () => $(tt), Pe = O("SAVED");
934
+ Pe.debugLabel = "builderSaveStateAtom";
935
+ const $n = () => {
936
+ const [e, t] = $(Pe), n = re("onSave", async (a) => {
937
+ }), o = re("onSaveStateChange", ve), r = an(), [s] = fn(), [i] = $e();
938
+ return { savePage: kt(
939
+ async () => {
940
+ t("SAVING"), o("SAVING");
941
+ const a = r();
942
+ return await n({ blocks: a.blocks, providers: s, brandingOptions: i, themeConfiguration: i }), setTimeout(() => {
943
+ t("SAVED"), o("SAVED");
944
+ }, 100), !0;
945
+ },
946
+ [r, t, i, n, o],
947
+ 3e3
948
+ // save only every 5 seconds
949
+ ), saveState: e, setSaveState: t };
950
+ }, Y = new nn();
951
+ Y.setLimit(50);
952
+ const pn = () => {
953
+ const [, e] = $(Pe), t = re("onSaveStateChange", ve);
954
+ return fe(() => (Y.setCallback(() => {
955
+ e("UNSAVED"), t("UNSAVED");
956
+ }), () => {
957
+ Y.setCallback(ve);
958
+ }), []), {
959
+ add: Y.add,
960
+ undo: Y.undo,
961
+ redo: Y.redo,
962
+ hasRedo: Y.hasRedo,
963
+ hasUndo: Y.hasUndo,
964
+ clear: Y.clear
965
+ };
966
+ }, Oe = (e, t) => {
967
+ const n = [], o = X(e, (r) => ne(t, r._id) || ne(t, r._parent) ? (n.push(r._id), !1) : !0);
968
+ return ht(n) ? o : Oe(o, n);
969
+ }, Jn = () => {
970
+ const [e] = se(), [t, n] = en(), { setNewBlocks: o } = K();
971
+ return V(
972
+ (r) => {
973
+ var i;
974
+ const s = ((i = te(e, { _id: r[0] })) == null ? void 0 : i._parent) || null;
975
+ o(Oe(e, r)), setTimeout(() => n(s ? [s] : []), 200);
976
+ },
977
+ [e, n, t]
978
+ );
979
+ };
980
+ function gn(e, t, n, o) {
981
+ let r = e.filter((u) => !u._parent);
982
+ n && (r = e.filter((u) => u._parent === n));
983
+ const s = o !== void 0 ? o : r.length;
984
+ let i = e.length;
985
+ for (let u = 0, a = 0; u < e.length; u++)
986
+ if (e[u]._parent === n) {
987
+ if (a === s) {
988
+ i = u;
989
+ break;
990
+ }
991
+ a++;
992
+ }
993
+ return !n && o !== void 0 && o >= r.length && (i = e.length), [...e.slice(0, i), ...t, ...e.slice(i)];
994
+ }
995
+ function hn(e) {
996
+ let t = [];
997
+ return e.walk((n) => (delete n.model.children, t.push(n.model), !0)), t;
998
+ }
999
+ function je(e, t) {
1000
+ return e.first((n) => n.model._id === t) || null;
1001
+ }
1002
+ function mn(e, t, n, o) {
1003
+ const r = je(e, t), s = je(e, n);
1004
+ if (r && s) {
1005
+ r.drop(), s.children || (s.model.children = []);
1006
+ try {
1007
+ s.addChildAtIndex(r, o);
1008
+ } catch (i) {
1009
+ return console.error("Error adding child to parent:", i), !1;
1010
+ }
1011
+ return !0;
1012
+ }
1013
+ return !1;
1014
+ }
1015
+ function vn(e, t, n, o) {
1016
+ if (!t)
1017
+ return e;
1018
+ n = n || "root";
1019
+ const s = new _t().parse({ _id: "root", children: Je(e) });
1020
+ if (mn(s, t, n, o)) {
1021
+ const i = hn(s), u = i.find((a) => a._id === t);
1022
+ return u && (u._parent = n === "root" ? null : n), i.shift(), i;
1023
+ }
1024
+ return e;
1025
+ }
1026
+ const bn = () => {
1027
+ const [, e] = se();
1028
+ return {
1029
+ setNewBlocks: (t) => {
1030
+ e(t);
1031
+ },
1032
+ addBlocks: (t, n, o) => {
1033
+ e((r) => gn(r, t, n, o));
1034
+ },
1035
+ removeBlocks: (t) => {
1036
+ e((n) => Oe(n, t));
1037
+ },
1038
+ moveBlocks: (t, n, o) => {
1039
+ e((r) => {
1040
+ let s = r;
1041
+ for (let i = 0; i < t.length; i++)
1042
+ s = vn(s, t[i], n, o);
1043
+ return s;
1044
+ });
1045
+ },
1046
+ updateBlocksProps: (t) => {
1047
+ e((n) => {
1048
+ const o = t.map((r) => r._id);
1049
+ return n.map((r) => {
1050
+ if (o.includes(r._id)) {
1051
+ const s = te(t, { _id: r._id });
1052
+ return { ...r, ...N(s, "_id") };
1053
+ }
1054
+ return r;
1055
+ });
1056
+ });
1057
+ }
1058
+ };
1059
+ }, se = () => $(H), K = () => {
1060
+ const { add: e } = pn(), [t] = se(), {
1061
+ setNewBlocks: n,
1062
+ addBlocks: o,
1063
+ removeBlocks: r,
1064
+ moveBlocks: s,
1065
+ updateBlocksProps: i
1066
+ } = bn();
1067
+ return {
1068
+ moveBlocks: (b, _, L) => {
1069
+ const j = T(b, (A) => {
1070
+ const M = t.find((D) => D._id === A)._parent || null, G = t.filter((D) => M ? D._parent === M : !D._parent).map((D) => D._id).indexOf(A);
1071
+ return { _id: A, oldParent: M, oldPosition: G };
1072
+ }), S = j.find(({ _id: A }) => A === b[0]);
1073
+ S && S.oldParent === _ && S.oldPosition === L || (s(b, _, L), e({
1074
+ undo: () => ee(j, ({ _id: A, oldParent: P, oldPosition: M }) => {
1075
+ s([A], P, M);
1076
+ }),
1077
+ redo: () => s(b, _, L)
1078
+ }));
1079
+ },
1080
+ addBlocks: (b, _, L) => {
1081
+ o(b, _, L), e({
1082
+ undo: () => r(T(b, "_id")),
1083
+ redo: () => o(b, _, L)
1084
+ });
1085
+ },
1086
+ removeBlocks: (b) => {
1087
+ var S;
1088
+ const _ = (S = oe(b)) == null ? void 0 : S._parent, j = t.filter((A) => _ ? A._parent === _ : !A._parent).indexOf(oe(b));
1089
+ r(T(b, "_id")), e({
1090
+ undo: () => o(b, _, j),
1091
+ redo: () => r(T(b, "_id"))
1092
+ });
1093
+ },
1094
+ updateBlocks: (b, _, L) => {
1095
+ let j = [];
1096
+ if (L)
1097
+ j = T(b, (S) => ({ _id: S, ...L }));
1098
+ else {
1099
+ const S = be(_);
1100
+ j = T(b, (A) => {
1101
+ const P = t.find((C) => C._id === A), M = { _id: A };
1102
+ return ee(S, (C) => M[C] = P[C]), M;
1103
+ });
1104
+ }
1105
+ i(T(b, (S) => ({ _id: S, ..._ }))), e({
1106
+ undo: () => i(j),
1107
+ redo: () => i(T(b, (S) => ({ _id: S, ..._ })))
1108
+ });
1109
+ },
1110
+ updateBlocksRuntime: (b, _) => {
1111
+ i(T(b, (L) => ({ _id: L, ..._ })));
1112
+ },
1113
+ setNewBlocks: (b) => {
1114
+ n(b), e({
1115
+ undo: () => n(t),
1116
+ redo: () => n(b)
1117
+ });
1118
+ },
1119
+ updateMultipleBlocksProps: (b) => {
1120
+ let _ = [];
1121
+ _ = T(b, (L) => {
1122
+ const j = be(L), S = t.find((P) => P._id === L._id), A = {};
1123
+ return ee(j, (P) => A[P] = S[P]), A;
1124
+ }), i(b), e({
1125
+ undo: () => i(_),
1126
+ redo: () => i(b)
1127
+ });
1128
+ }
1129
+ };
1130
+ }, Zn = () => {
1131
+ const { updateBlocks: e } = K();
1132
+ return V(
1133
+ (t, n, o) => {
1134
+ e(t, n, o);
1135
+ },
1136
+ [e]
1137
+ );
1138
+ }, Kn = () => {
1139
+ const { updateMultipleBlocksProps: e } = K();
1140
+ return V(
1141
+ (t) => {
1142
+ e(t);
1143
+ },
1144
+ [e]
1145
+ );
1146
+ }, yn = () => {
1147
+ const { updateBlocksRuntime: e } = K();
1148
+ return V(
1149
+ async (t, n, o = 30) => {
1150
+ const r = be(N(n, ["_id"]));
1151
+ for (const s of r) {
1152
+ const i = n[s];
1153
+ if (Re(i)) {
1154
+ const u = mt(i.split(""), 12);
1155
+ let a = "";
1156
+ e([t], { [s]: "" });
1157
+ for (let l = 0; l < u.length; l++)
1158
+ a += u[l].join(""), e([t], { [s]: a }), await new Promise((m) => setTimeout(m, o));
1159
+ }
1160
+ }
1161
+ },
1162
+ [e]
1163
+ );
1164
+ }, Qn = () => {
1165
+ const { updateMultipleBlocksProps: e } = K(), t = yn();
1166
+ return V(
1167
+ async (n) => {
1168
+ for (const o of n)
1169
+ await t(o._id, o);
1170
+ e(n);
1171
+ },
1172
+ [e]
1173
+ );
1174
+ }, eo = () => {
1175
+ const { updateBlocksRuntime: e } = K();
1176
+ return V(
1177
+ (t, n) => {
1178
+ e(t, n);
1179
+ },
1180
+ [e]
1181
+ );
1182
+ }, nt = F({}), Bn = F({}), to = () => {
1183
+ const [e, t] = ue(nt), n = V(
1184
+ (r) => w(e, r == null ? void 0 : r.globalBlock, []),
1185
+ [e]
1186
+ ), o = V(() => {
1187
+ t({});
1188
+ }, [t]);
1189
+ return { getGlobalBlocks: n, reset: o };
1190
+ }, no = () => {
1191
+ const [e] = se(), [t, n] = ue(nt), [o, r] = ue(Bn), s = re("getGlobalBlockBlocks", async (u) => []), i = dt(() => e.filter((a) => a._type === "GlobalBlock").filter((a) => a._type === "GlobalBlock").map((a) => a.globalBlock), [e]);
1192
+ fe(() => {
1193
+ vt(i, (u) => {
1194
+ Fe(t, u) || w(o, `${u}.loading`, !1) || (r((a) => ({ ...a, [u]: { loading: !0, error: null } })), s(u).then((a) => {
1195
+ n((l) => ({ ...l, [u]: a })), r((l) => ({
1196
+ ...l,
1197
+ [u]: { loading: !1, error: null }
1198
+ }));
1199
+ }).catch((a) => {
1200
+ r((l) => ({
1201
+ ...l,
1202
+ [u]: { loading: !1, error: a.message }
1203
+ }));
1204
+ }));
1205
+ });
1206
+ }, [
1207
+ s,
1208
+ t,
1209
+ i,
1210
+ o,
1211
+ n,
1212
+ r
1213
+ ]);
1214
+ }, kn = F({}), oo = () => {
1215
+ const [e, t] = at(!1), [n, o] = ue(kn), r = re("getGlobalBlocks", async () => []), s = V(async () => {
1216
+ t(!0);
1217
+ const i = await r();
1218
+ o(i), t(!1);
1219
+ }, [r, o]);
1220
+ return fe(() => {
1221
+ s();
1222
+ }, []), { data: n, isLoading: e, refetch: s };
1223
+ }, _n = "#styles:", ro = (e) => ({
1224
+ type: "singular",
1225
+ default: e.default || "",
1226
+ binding: w(e, "binding", !0),
1227
+ dataType: "string",
1228
+ schema: {
1229
+ type: "string",
1230
+ ...N(e, ["i18n", "required"])
1231
+ },
1232
+ uiSchema: {
1233
+ "ui:widget": "code"
1234
+ }
1235
+ }), so = (e) => ({
1236
+ type: "singular",
1237
+ default: e.default || "",
1238
+ hidden: w(e, "hidden", !1),
1239
+ binding: w(e, "binding", !0),
1240
+ dataType: "string",
1241
+ required: e.required || !1,
1242
+ ai: e.ai || void 0,
1243
+ schema: {
1244
+ type: "string",
1245
+ ...N(e, ["ai", "required"])
1246
+ },
1247
+ uiSchema: {
1248
+ "ui:placeholder": e.placeholder || "Enter here"
1249
+ }
1250
+ }), io = (e) => ({
1251
+ type: "singular",
1252
+ default: e.default || "",
1253
+ hidden: w(e, "hidden", !1),
1254
+ binding: w(e, "binding", !0),
1255
+ dataType: "string",
1256
+ required: e.required || !1,
1257
+ ai: e.ai || void 0,
1258
+ schema: {
1259
+ type: "string",
1260
+ ...N(e, ["i18n", "required", "rows"])
1261
+ },
1262
+ uiSchema: {
1263
+ "ui:widget": "textarea",
1264
+ "ui:placeholder": e.placeholder || "Enter here",
1265
+ "ui:options": {
1266
+ rows: e.rows || 4
1267
+ }
1268
+ }
1269
+ }), co = (e) => ({
1270
+ type: "singular",
1271
+ i18n: e.i18n || !1,
1272
+ default: e.default || !1,
1273
+ dataType: "boolean",
1274
+ hidden: w(e, "hidden", !1),
1275
+ binding: w(e, "binding", !0),
1276
+ ai: e.ai || void 0,
1277
+ schema: {
1278
+ type: "boolean",
1279
+ ...N(e, ["i18n", "required"])
1280
+ },
1281
+ uiSchema: {
1282
+ "ui:title": e.title || "Select Item",
1283
+ "ui:description": ""
1284
+ }
1285
+ }), lo = (e) => ({
1286
+ type: "singular",
1287
+ default: e.default || "",
1288
+ hidden: w(e, "hidden", !1),
1289
+ binding: w(e, "binding", !0),
1290
+ dataType: "number",
1291
+ required: e.required || !1,
1292
+ ai: e.ai || void 0,
1293
+ schema: {
1294
+ type: "number",
1295
+ ...N(e, ["i18n", "required"])
1296
+ },
1297
+ uiSchema: {}
1298
+ }), uo = (e) => ({
1299
+ type: "singular",
1300
+ default: e.default || "",
1301
+ hidden: w(e, "hidden", !1),
1302
+ binding: w(e, "binding", !0),
1303
+ required: e.required || !1,
1304
+ dataType: "string",
1305
+ ai: e.ai || void 0,
1306
+ schema: {
1307
+ type: "string",
1308
+ ...N(e, ["i18n", "required", "options", "binding"]),
1309
+ oneOf: e.options.map((t) => ({ const: t.value, title: t.title }))
1310
+ },
1311
+ uiSchema: {
1312
+ "ui:widget": "select"
1313
+ }
1314
+ }), ao = (e) => ({
1315
+ type: "singular",
1316
+ i18n: e.i18n || !1,
1317
+ default: e.default || "",
1318
+ hidden: w(e, "hidden", !1),
1319
+ binding: w(e, "binding", !0),
1320
+ dataType: "string",
1321
+ ai: e.ai || void 0,
1322
+ schema: {
1323
+ type: "string",
1324
+ ...N(e, ["i18n", "required"])
1325
+ },
1326
+ uiSchema: {
1327
+ "ui:widget": "color"
1328
+ }
1329
+ }), fo = (e) => ({
1330
+ type: "singular",
1331
+ default: e.default || "",
1332
+ binding: w(e, "binding", !0),
1333
+ dataType: "string",
1334
+ ai: e.ai || void 0,
1335
+ schema: {
1336
+ type: "string",
1337
+ ...N(e, ["i18n", "required"])
1338
+ },
1339
+ uiSchema: {
1340
+ "ui:widget": "richtext"
1341
+ }
1342
+ }), po = (e) => ({
1343
+ type: "model",
1344
+ title: e.title,
1345
+ dataType: "object",
1346
+ default: e.default || {},
1347
+ binding: w(e, "binding", !0),
1348
+ properties: e.properties
1349
+ }), go = (e) => ({
1350
+ type: "list",
1351
+ itemProperties: e.itemProperties,
1352
+ binding: w(e, "binding", !0),
1353
+ title: e.title,
1354
+ ai: e.ai || void 0,
1355
+ dataType: "array",
1356
+ default: e.default || [],
1357
+ itemTitle: e.getItemLabel ? e.getItemLabel({}) : () => ""
1358
+ }), ho = (e) => ({
1359
+ type: "styles",
1360
+ binding: !1,
1361
+ default: `${_n},${e.default || ""}`,
1362
+ presets: e.presets || {}
1363
+ }), mo = (e) => ({
1364
+ default: e.default || "",
1365
+ binding: w(e, "binding", !0),
1366
+ type: "singular",
1367
+ dataType: "string",
1368
+ ai: e.ai || void 0,
1369
+ schema: {
1370
+ type: "string",
1371
+ title: "Icon",
1372
+ default: e.default || ""
1373
+ },
1374
+ uiSchema: {
1375
+ "ui:widget": "icon"
1376
+ }
1377
+ }), vo = (e) => ({
1378
+ default: e.default,
1379
+ type: "singular",
1380
+ binding: w(e, "binding", !0),
1381
+ dataType: "object",
1382
+ ai: e.ai || void 0,
1383
+ schema: {
1384
+ type: "object",
1385
+ ...e || {},
1386
+ properties: {
1387
+ type: { type: "string" },
1388
+ href: { type: "string" },
1389
+ target: { type: "string" }
1390
+ }
1391
+ },
1392
+ uiSchema: {
1393
+ "ui:field": "link"
1394
+ }
1395
+ }), bo = (e) => ({
1396
+ type: "singular",
1397
+ default: e.default || "",
1398
+ hidden: w(e, "hidden", !1),
1399
+ binding: w(e, "binding", !0),
1400
+ dataType: "string",
1401
+ ai: e.ai || void 0,
1402
+ schema: {
1403
+ type: "string",
1404
+ ...N(e, ["i18n", "required"])
1405
+ },
1406
+ uiSchema: {
1407
+ "ui:widget": "image"
1408
+ }
1409
+ });
1410
+ var ot = {
1411
+ color: void 0,
1412
+ size: void 0,
1413
+ className: void 0,
1414
+ style: void 0,
1415
+ attr: void 0
1416
+ }, De = W.createContext && /* @__PURE__ */ W.createContext(ot), An = ["attr", "size", "title"];
1417
+ function wn(e, t) {
1418
+ if (e == null)
1419
+ return {};
1420
+ var n = Sn(e, t), o, r;
1421
+ if (Object.getOwnPropertySymbols) {
1422
+ var s = Object.getOwnPropertySymbols(e);
1423
+ for (r = 0; r < s.length; r++)
1424
+ o = s[r], !(t.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(e, o) && (n[o] = e[o]);
1425
+ }
1426
+ return n;
1427
+ }
1428
+ function Sn(e, t) {
1429
+ if (e == null)
1430
+ return {};
1431
+ var n = {};
1432
+ for (var o in e)
1433
+ if (Object.prototype.hasOwnProperty.call(e, o)) {
1434
+ if (t.indexOf(o) >= 0)
1435
+ continue;
1436
+ n[o] = e[o];
1437
+ }
1438
+ return n;
1439
+ }
1440
+ function ae() {
1441
+ return ae = Object.assign ? Object.assign.bind() : function(e) {
1442
+ for (var t = 1; t < arguments.length; t++) {
1443
+ var n = arguments[t];
1444
+ for (var o in n)
1445
+ Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
1446
+ }
1447
+ return e;
1448
+ }, ae.apply(this, arguments);
1449
+ }
1450
+ function Ne(e, t) {
1451
+ var n = Object.keys(e);
1452
+ if (Object.getOwnPropertySymbols) {
1453
+ var o = Object.getOwnPropertySymbols(e);
1454
+ t && (o = o.filter(function(r) {
1455
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1456
+ })), n.push.apply(n, o);
1457
+ }
1458
+ return n;
1459
+ }
1460
+ function de(e) {
1461
+ for (var t = 1; t < arguments.length; t++) {
1462
+ var n = arguments[t] != null ? arguments[t] : {};
1463
+ t % 2 ? Ne(Object(n), !0).forEach(function(o) {
1464
+ En(e, o, n[o]);
1465
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Ne(Object(n)).forEach(function(o) {
1466
+ Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(n, o));
1467
+ });
1468
+ }
1469
+ return e;
1470
+ }
1471
+ function En(e, t, n) {
1472
+ return t = Pn(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
1473
+ }
1474
+ function Pn(e) {
1475
+ var t = On(e, "string");
1476
+ return typeof t == "symbol" ? t : t + "";
1477
+ }
1478
+ function On(e, t) {
1479
+ if (typeof e != "object" || !e)
1480
+ return e;
1481
+ var n = e[Symbol.toPrimitive];
1482
+ if (n !== void 0) {
1483
+ var o = n.call(e, t || "default");
1484
+ if (typeof o != "object")
1485
+ return o;
1486
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1487
+ }
1488
+ return (t === "string" ? String : Number)(e);
1489
+ }
1490
+ function rt(e) {
1491
+ return e && e.map((t, n) => /* @__PURE__ */ W.createElement(t.tag, de({
1492
+ key: n
1493
+ }, t.attr), rt(t.child)));
1494
+ }
1495
+ function yo(e) {
1496
+ return (t) => /* @__PURE__ */ W.createElement(Ln, ae({
1497
+ attr: de({}, e.attr)
1498
+ }, t), rt(e.child));
1499
+ }
1500
+ function Ln(e) {
1501
+ var t = (n) => {
1502
+ var {
1503
+ attr: o,
1504
+ size: r,
1505
+ title: s
1506
+ } = e, i = wn(e, An), u = r || n.size || "1em", a;
1507
+ return n.className && (a = n.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ W.createElement("svg", ae({
1508
+ stroke: "currentColor",
1509
+ fill: "currentColor",
1510
+ strokeWidth: "0"
1511
+ }, n.attr, o, i, {
1512
+ className: a,
1513
+ style: de(de({
1514
+ color: e.color || n.color
1515
+ }, n.style), e.style),
1516
+ height: u,
1517
+ width: u,
1518
+ xmlns: "http://www.w3.org/2000/svg"
1519
+ }), s && /* @__PURE__ */ W.createElement("title", null, s), e.children);
1520
+ };
1521
+ return De !== void 0 ? /* @__PURE__ */ W.createElement(De.Consumer, null, (n) => t(n)) : t(ot);
1522
+ }
1523
+ export {
1524
+ io as $,
1525
+ ao as A,
1526
+ Un as B,
1527
+ Yt as C,
1528
+ eo as D,
1529
+ Qn as E,
1530
+ Kn as F,
1531
+ yo as G,
1532
+ Yn as H,
1533
+ Ue as I,
1534
+ F as J,
1535
+ Gn as K,
1536
+ Gt as L,
1537
+ Wn as M,
1538
+ qt as N,
1539
+ Pt as O,
1540
+ Pe as P,
1541
+ no as Q,
1542
+ et as R,
1543
+ tt as S,
1544
+ $n as T,
1545
+ oo as U,
1546
+ cn as V,
1547
+ ho as W,
1548
+ bo as X,
1549
+ so as Y,
1550
+ mo as Z,
1551
+ ro as _,
1552
+ en as a,
1553
+ fo as a0,
1554
+ vo as a1,
1555
+ co as a2,
1556
+ po as a3,
1557
+ go as a4,
1558
+ K as b,
1559
+ Nt as c,
1560
+ Vn as d,
1561
+ qn as e,
1562
+ H as f,
1563
+ ce as g,
1564
+ we as h,
1565
+ Zt as i,
1566
+ pn as j,
1567
+ ue as k,
1568
+ to as l,
1569
+ re as m,
1570
+ Zn as n,
1571
+ Jn as o,
1572
+ zt as p,
1573
+ $e as q,
1574
+ dn as r,
1575
+ Kt as s,
1576
+ fn as t,
1577
+ se as u,
1578
+ zn as v,
1579
+ Xn as w,
1580
+ Hn as x,
1581
+ uo as y,
1582
+ lo as z
1583
+ };