@chaibuilder/pages 0.1.19 → 0.2.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.
@@ -0,0 +1,4844 @@
1
+ var qn = (e) => {
2
+ throw TypeError(e);
3
+ };
4
+ var Kn = (e, t, n) => t.has(e) || qn("Cannot " + n);
5
+ var T = (e, t, n) => (Kn(e, t, "read from private field"), n ? n.call(e) : t.get(e)), F = (e, t, n) => t.has(e) ? qn("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), M = (e, t, n, r) => (Kn(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n);
6
+ import { jsx as u, jsxs as m, Fragment as ar } from "react/jsx-runtime";
7
+ import { PERMISSIONS as ps, usePermissions as ir, useLanguages as Ot, getBlocksFromHTML as vs, useTheme as Ss, useTranslation as As, registerChaiSidebarPanel as Vn, ChaiBuilderEditor as ws } from "@chaibuilder/sdk";
8
+ import { loadWebBlocks as bs } from "@chaibuilder/sdk/web-blocks";
9
+ import { useQueryClient as Ae, onlineManager as or, useMutation as xe, useQuery as Pe, QueryClient as Ts, QueryClientProvider as _s } from "@tanstack/react-query";
10
+ import * as Z from "react";
11
+ import { useState as ge, useEffect as Ut, useMemo as me, useCallback as Ue, useRef as $t } from "react";
12
+ import { get as ae, isEmpty as Ie, find as Se, reverse as Ps, sortBy as Ns, startsWith as yt, isEqual as Ln, filter as xn, map as lr, toLower as Cs, trim as Is, each as Ls, includes as xs, has as tn, pick as cr, keys as Gs, pickBy as ks, endsWith as Ds, isArray as Os, startCase as Us, cloneDeep as Rs, isString as Wn } from "lodash-es";
13
+ import { AlertCircle as Ms, StarIcon as Bs, MoreHorizontal as Fs, PencilIcon as js, Power as Hs, TrashIcon as qs, LockIcon as ur, UserIcon as Ks, AlertTriangleIcon as Vs, LanguagesIcon as Ws, DatabaseIcon as zs, ChevronLeft as $s, ChevronRight as Qs, Loader2 as Ys } from "lucide-react";
14
+ import { atom as Gn, useAtom as kn } from "jotai";
15
+ import { toast as Ee } from "sonner";
16
+ import { useRegisteredChaiBlocks as Xs, getDefaultBlockProps as Zs } from "@chaibuilder/runtime";
17
+ import { Dialog as nn, DialogContent as rn, DialogHeader as sn, DialogTitle as an, DialogDescription as on, Alert as dr, Label as ue, Input as Te, DialogFooter as ln, Button as re, DropdownMenu as Js, DropdownMenuTrigger as ea, DropdownMenuContent as ta, DropdownMenuItem as gn, Card as fr, CardHeader as hr, CardTitle as gr, CardContent as mr, CardFooter as yr, AlertDialog as na, AlertDialogTrigger as ra, AlertDialogContent as sa, AlertDialogHeader as aa, AlertDialogTitle as ia, AlertDialogDescription as oa, AlertDialogFooter as la, AlertDialogCancel as ca, AlertDialogAction as ua, Popover as da, Tooltip as fa, TooltipTrigger as ha, PopoverTrigger as ga, TooltipContent as ma, PopoverContent as ya, Command as Ea, CommandInput as pa, CommandList as va, CommandEmpty as Sa, CommandGroup as Aa, CommandItem as zn, AlertDescription as wa, Accordion as ba, AccordionItem as Mt, AccordionTrigger as Bt, AccordionContent as Ft, Textarea as jt } from "@chaibuilder/sdk/ui";
18
+ var _ = {
19
+ context: void 0,
20
+ registry: void 0,
21
+ effects: void 0,
22
+ done: !1,
23
+ getContextId() {
24
+ return $n(this.context.count);
25
+ },
26
+ getNextContextId() {
27
+ return $n(this.context.count++);
28
+ }
29
+ };
30
+ function $n(e) {
31
+ const t = String(e), n = t.length - 1;
32
+ return _.context.id + (n ? String.fromCharCode(96 + n) : "") + t;
33
+ }
34
+ function mt(e) {
35
+ _.context = e;
36
+ }
37
+ var Ta = (e, t) => e === t, Qt = Symbol("solid-proxy"), Er = typeof Proxy == "function", pr = Symbol("solid-track"), Yt = {
38
+ equals: Ta
39
+ }, vr = _r, Ge = 1, Xt = 2, Sr = {
40
+ owned: null,
41
+ cleanups: null,
42
+ context: null,
43
+ owner: null
44
+ }, mn = {}, R = null, yn = null, _a = null, j = null, ce = null, Le = null, cn = 0;
45
+ function je(e, t) {
46
+ const n = j, r = R, s = e.length === 0, a = t === void 0 ? r : t, i = s ? Sr : {
47
+ owned: null,
48
+ cleanups: null,
49
+ context: a ? a.context : null,
50
+ owner: a
51
+ }, o = s ? e : () => e(() => le(() => St(i)));
52
+ R = i, j = null;
53
+ try {
54
+ return _e(o, !0);
55
+ } finally {
56
+ j = n, R = r;
57
+ }
58
+ }
59
+ function J(e, t) {
60
+ t = t ? Object.assign({}, Yt, t) : Yt;
61
+ const n = {
62
+ value: e,
63
+ observers: null,
64
+ observerSlots: null,
65
+ comparator: t.equals || void 0
66
+ }, r = (s) => (typeof s == "function" && (s = s(n.value)), Tr(n, s));
67
+ return [br.bind(n), r];
68
+ }
69
+ function Pa(e, t, n) {
70
+ const r = un(e, t, !0, Ge);
71
+ dt(r);
72
+ }
73
+ function He(e, t, n) {
74
+ const r = un(e, t, !1, Ge);
75
+ dt(r);
76
+ }
77
+ function Ar(e, t, n) {
78
+ vr = Ua;
79
+ const r = un(e, t, !1, Ge);
80
+ (!n || !n.render) && (r.user = !0), Le ? Le.push(r) : dt(r);
81
+ }
82
+ function fe(e, t, n) {
83
+ n = n ? Object.assign({}, Yt, n) : Yt;
84
+ const r = un(e, t, !0, 0);
85
+ return r.observers = null, r.observerSlots = null, r.comparator = n.equals || void 0, dt(r), br.bind(r);
86
+ }
87
+ function Na(e) {
88
+ return e && typeof e == "object" && "then" in e;
89
+ }
90
+ function Ca(e, t, n) {
91
+ let r, s, a;
92
+ arguments.length === 1 ? (r = !0, s = e, a = {}) : (r = e, s = t, a = {});
93
+ let i = null, o = mn, l = null, d = !1, h = "initialValue" in a, g = typeof r == "function" && fe(r);
94
+ const v = /* @__PURE__ */ new Set(), [A, E] = (a.storage || J)(a.initialValue), [N, y] = J(void 0), [Q, p] = J(void 0, {
95
+ equals: !1
96
+ }), [C, O] = J(h ? "ready" : "unresolved");
97
+ _.context && (l = _.getNextContextId(), a.ssrLoadFrom === "initial" ? o = a.initialValue : _.load && _.has(l) && (o = _.load(l)));
98
+ function q(B, U, K, ne) {
99
+ return i === B && (i = null, ne !== void 0 && (h = !0), (B === o || U === o) && a.onHydrated && queueMicrotask(
100
+ () => a.onHydrated(ne, {
101
+ value: U
102
+ })
103
+ ), o = mn, ie(U, K)), U;
104
+ }
105
+ function ie(B, U) {
106
+ _e(() => {
107
+ U === void 0 && E(() => B), O(U !== void 0 ? "errored" : h ? "ready" : "unresolved"), y(U);
108
+ for (const K of v.keys())
109
+ K.decrement();
110
+ v.clear();
111
+ }, !1);
112
+ }
113
+ function se() {
114
+ const B = ka, U = A(), K = N();
115
+ if (K !== void 0 && !i)
116
+ throw K;
117
+ return j && j.user, U;
118
+ }
119
+ function k(B = !0) {
120
+ if (B !== !1 && d)
121
+ return;
122
+ d = !1;
123
+ const U = g ? g() : r;
124
+ if (U == null || U === !1) {
125
+ q(i, le(A));
126
+ return;
127
+ }
128
+ const K = o !== mn ? o : le(
129
+ () => s(U, {
130
+ value: A(),
131
+ refetching: B
132
+ })
133
+ );
134
+ return Na(K) ? (i = K, "value" in K ? (K.status === "success" ? q(i, K.value, void 0, U) : q(i, void 0, vn(K.value), U), K) : (d = !0, queueMicrotask(() => d = !1), _e(() => {
135
+ O(h ? "refreshing" : "pending"), p();
136
+ }, !1), K.then(
137
+ (ne) => q(K, ne, void 0, U),
138
+ (ne) => q(K, void 0, vn(ne), U)
139
+ ))) : (q(i, K, void 0, U), K);
140
+ }
141
+ return Object.defineProperties(se, {
142
+ state: {
143
+ get: () => C()
144
+ },
145
+ error: {
146
+ get: () => N()
147
+ },
148
+ loading: {
149
+ get() {
150
+ const B = C();
151
+ return B === "pending" || B === "refreshing";
152
+ }
153
+ },
154
+ latest: {
155
+ get() {
156
+ if (!h)
157
+ return se();
158
+ const B = N();
159
+ if (B && !i)
160
+ throw B;
161
+ return A();
162
+ }
163
+ }
164
+ }), g ? Pa(() => k(!1)) : k(!1), [
165
+ se,
166
+ {
167
+ refetch: k,
168
+ mutate: E
169
+ }
170
+ ];
171
+ }
172
+ function Jo(e) {
173
+ return _e(e, !1);
174
+ }
175
+ function le(e) {
176
+ if (j === null)
177
+ return e();
178
+ const t = j;
179
+ j = null;
180
+ try {
181
+ return e();
182
+ } finally {
183
+ j = t;
184
+ }
185
+ }
186
+ function el(e, t, n) {
187
+ const r = Array.isArray(e);
188
+ let s, a = n && n.defer;
189
+ return (i) => {
190
+ let o;
191
+ if (r) {
192
+ o = Array(e.length);
193
+ for (let d = 0; d < e.length; d++)
194
+ o[d] = e[d]();
195
+ } else
196
+ o = e();
197
+ if (a)
198
+ return a = !1, i;
199
+ const l = le(() => t(o, s, i));
200
+ return s = o, l;
201
+ };
202
+ }
203
+ function Ia(e) {
204
+ Ar(() => le(e));
205
+ }
206
+ function vt(e) {
207
+ return R === null || (R.cleanups === null ? R.cleanups = [e] : R.cleanups.push(e)), e;
208
+ }
209
+ function Qn() {
210
+ return R;
211
+ }
212
+ function La(e, t) {
213
+ const n = R, r = j;
214
+ R = e, j = null;
215
+ try {
216
+ return _e(t, !0);
217
+ } catch (s) {
218
+ Dn(s);
219
+ } finally {
220
+ R = n, j = r;
221
+ }
222
+ }
223
+ function xa(e) {
224
+ const t = j, n = R;
225
+ return Promise.resolve().then(() => {
226
+ j = t, R = n;
227
+ let r;
228
+ return _e(e, !1), j = R = null, r ? r.done : void 0;
229
+ });
230
+ }
231
+ var [Ga, tl] = /* @__PURE__ */ J(!1);
232
+ function nl() {
233
+ return [Ga, xa];
234
+ }
235
+ function rl(e, t) {
236
+ const n = Symbol("context");
237
+ return {
238
+ id: n,
239
+ Provider: Ra(n),
240
+ defaultValue: e
241
+ };
242
+ }
243
+ function sl(e) {
244
+ let t;
245
+ return R && R.context && (t = R.context[e.id]) !== void 0 ? t : e.defaultValue;
246
+ }
247
+ function wr(e) {
248
+ const t = fe(e), n = fe(() => Sn(t()));
249
+ return n.toArray = () => {
250
+ const r = n();
251
+ return Array.isArray(r) ? r : r != null ? [r] : [];
252
+ }, n;
253
+ }
254
+ var ka;
255
+ function br() {
256
+ if (this.sources && this.state)
257
+ if (this.state === Ge)
258
+ dt(this);
259
+ else {
260
+ const e = ce;
261
+ ce = null, _e(() => Jt(this), !1), ce = e;
262
+ }
263
+ if (j) {
264
+ const e = this.observers ? this.observers.length : 0;
265
+ j.sources ? (j.sources.push(this), j.sourceSlots.push(e)) : (j.sources = [this], j.sourceSlots = [e]), this.observers ? (this.observers.push(j), this.observerSlots.push(j.sources.length - 1)) : (this.observers = [j], this.observerSlots = [j.sources.length - 1]);
266
+ }
267
+ return this.value;
268
+ }
269
+ function Tr(e, t, n) {
270
+ let r = e.value;
271
+ return (!e.comparator || !e.comparator(r, t)) && (e.value = t, e.observers && e.observers.length && _e(() => {
272
+ for (let s = 0; s < e.observers.length; s += 1) {
273
+ const a = e.observers[s], i = yn && yn.running;
274
+ i && yn.disposed.has(a), (i ? !a.tState : !a.state) && (a.pure ? ce.push(a) : Le.push(a), a.observers && Pr(a)), i || (a.state = Ge);
275
+ }
276
+ if (ce.length > 1e6)
277
+ throw ce = [], new Error();
278
+ }, !1)), t;
279
+ }
280
+ function dt(e) {
281
+ if (!e.fn)
282
+ return;
283
+ St(e);
284
+ const t = cn;
285
+ Da(
286
+ e,
287
+ e.value,
288
+ t
289
+ );
290
+ }
291
+ function Da(e, t, n) {
292
+ let r;
293
+ const s = R, a = j;
294
+ j = R = e;
295
+ try {
296
+ r = e.fn(t);
297
+ } catch (i) {
298
+ return e.pure && (e.state = Ge, e.owned && e.owned.forEach(St), e.owned = null), e.updatedAt = n + 1, Dn(i);
299
+ } finally {
300
+ j = a, R = s;
301
+ }
302
+ (!e.updatedAt || e.updatedAt <= n) && (e.updatedAt != null && "observers" in e ? Tr(e, r) : e.value = r, e.updatedAt = n);
303
+ }
304
+ function un(e, t, n, r = Ge, s) {
305
+ const a = {
306
+ fn: e,
307
+ state: r,
308
+ updatedAt: null,
309
+ owned: null,
310
+ sources: null,
311
+ sourceSlots: null,
312
+ cleanups: null,
313
+ value: t,
314
+ owner: R,
315
+ context: R ? R.context : null,
316
+ pure: n
317
+ };
318
+ return R === null || R !== Sr && (R.owned ? R.owned.push(a) : R.owned = [a]), a;
319
+ }
320
+ function Zt(e) {
321
+ if (e.state === 0)
322
+ return;
323
+ if (e.state === Xt)
324
+ return Jt(e);
325
+ if (e.suspense && le(e.suspense.inFallback))
326
+ return e.suspense.effects.push(e);
327
+ const t = [e];
328
+ for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < cn); )
329
+ e.state && t.push(e);
330
+ for (let n = t.length - 1; n >= 0; n--)
331
+ if (e = t[n], e.state === Ge)
332
+ dt(e);
333
+ else if (e.state === Xt) {
334
+ const r = ce;
335
+ ce = null, _e(() => Jt(e, t[0]), !1), ce = r;
336
+ }
337
+ }
338
+ function _e(e, t) {
339
+ if (ce)
340
+ return e();
341
+ let n = !1;
342
+ t || (ce = []), Le ? n = !0 : Le = [], cn++;
343
+ try {
344
+ const r = e();
345
+ return Oa(n), r;
346
+ } catch (r) {
347
+ n || (Le = null), ce = null, Dn(r);
348
+ }
349
+ }
350
+ function Oa(e) {
351
+ if (ce && (_r(ce), ce = null), e)
352
+ return;
353
+ const t = Le;
354
+ Le = null, t.length && _e(() => vr(t), !1);
355
+ }
356
+ function _r(e) {
357
+ for (let t = 0; t < e.length; t++)
358
+ Zt(e[t]);
359
+ }
360
+ function Ua(e) {
361
+ let t, n = 0;
362
+ for (t = 0; t < e.length; t++) {
363
+ const r = e[t];
364
+ r.user ? e[n++] = r : Zt(r);
365
+ }
366
+ if (_.context) {
367
+ if (_.count) {
368
+ _.effects || (_.effects = []), _.effects.push(...e.slice(0, n));
369
+ return;
370
+ }
371
+ mt();
372
+ }
373
+ for (_.effects && (_.done || !_.count) && (e = [..._.effects, ...e], n += _.effects.length, delete _.effects), t = 0; t < n; t++)
374
+ Zt(e[t]);
375
+ }
376
+ function Jt(e, t) {
377
+ e.state = 0;
378
+ for (let n = 0; n < e.sources.length; n += 1) {
379
+ const r = e.sources[n];
380
+ if (r.sources) {
381
+ const s = r.state;
382
+ s === Ge ? r !== t && (!r.updatedAt || r.updatedAt < cn) && Zt(r) : s === Xt && Jt(r, t);
383
+ }
384
+ }
385
+ }
386
+ function Pr(e) {
387
+ for (let t = 0; t < e.observers.length; t += 1) {
388
+ const n = e.observers[t];
389
+ n.state || (n.state = Xt, n.pure ? ce.push(n) : Le.push(n), n.observers && Pr(n));
390
+ }
391
+ }
392
+ function St(e) {
393
+ let t;
394
+ if (e.sources)
395
+ for (; e.sources.length; ) {
396
+ const n = e.sources.pop(), r = e.sourceSlots.pop(), s = n.observers;
397
+ if (s && s.length) {
398
+ const a = s.pop(), i = n.observerSlots.pop();
399
+ r < s.length && (a.sourceSlots[i] = r, s[r] = a, n.observerSlots[r] = i);
400
+ }
401
+ }
402
+ if (e.tOwned) {
403
+ for (t = e.tOwned.length - 1; t >= 0; t--)
404
+ St(e.tOwned[t]);
405
+ delete e.tOwned;
406
+ }
407
+ if (e.owned) {
408
+ for (t = e.owned.length - 1; t >= 0; t--)
409
+ St(e.owned[t]);
410
+ e.owned = null;
411
+ }
412
+ if (e.cleanups) {
413
+ for (t = e.cleanups.length - 1; t >= 0; t--)
414
+ e.cleanups[t]();
415
+ e.cleanups = null;
416
+ }
417
+ e.state = 0;
418
+ }
419
+ function vn(e) {
420
+ return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
421
+ cause: e
422
+ });
423
+ }
424
+ function Dn(e, t = R) {
425
+ throw vn(e);
426
+ }
427
+ function Sn(e) {
428
+ if (typeof e == "function" && !e.length)
429
+ return Sn(e());
430
+ if (Array.isArray(e)) {
431
+ const t = [];
432
+ for (let n = 0; n < e.length; n++) {
433
+ const r = Sn(e[n]);
434
+ Array.isArray(r) ? t.push.apply(t, r) : t.push(r);
435
+ }
436
+ return t;
437
+ }
438
+ return e;
439
+ }
440
+ function Ra(e, t) {
441
+ return function(r) {
442
+ let s;
443
+ return He(
444
+ () => s = le(() => (R.context = {
445
+ ...R.context,
446
+ [e]: r.value
447
+ }, wr(() => r.children))),
448
+ void 0
449
+ ), s;
450
+ };
451
+ }
452
+ var An = Symbol("fallback");
453
+ function en(e) {
454
+ for (let t = 0; t < e.length; t++)
455
+ e[t]();
456
+ }
457
+ function Ma(e, t, n = {}) {
458
+ let r = [], s = [], a = [], i = 0, o = t.length > 1 ? [] : null;
459
+ return vt(() => en(a)), () => {
460
+ let l = e() || [], d = l.length, h, g;
461
+ return l[pr], le(() => {
462
+ let A, E, N, y, Q, p, C, O, q;
463
+ if (d === 0)
464
+ i !== 0 && (en(a), a = [], r = [], s = [], i = 0, o && (o = [])), n.fallback && (r = [An], s[0] = je((ie) => (a[0] = ie, n.fallback())), i = 1);
465
+ else if (i === 0) {
466
+ for (s = new Array(d), g = 0; g < d; g++)
467
+ r[g] = l[g], s[g] = je(v);
468
+ i = d;
469
+ } else {
470
+ for (N = new Array(d), y = new Array(d), o && (Q = new Array(d)), p = 0, C = Math.min(i, d); p < C && r[p] === l[p]; p++)
471
+ ;
472
+ for (C = i - 1, O = d - 1; C >= p && O >= p && r[C] === l[O]; C--, O--)
473
+ N[O] = s[C], y[O] = a[C], o && (Q[O] = o[C]);
474
+ for (A = /* @__PURE__ */ new Map(), E = new Array(O + 1), g = O; g >= p; g--)
475
+ q = l[g], h = A.get(q), E[g] = h === void 0 ? -1 : h, A.set(q, g);
476
+ for (h = p; h <= C; h++)
477
+ q = r[h], g = A.get(q), g !== void 0 && g !== -1 ? (N[g] = s[h], y[g] = a[h], o && (Q[g] = o[h]), g = E[g], A.set(q, g)) : a[h]();
478
+ for (g = p; g < d; g++)
479
+ g in N ? (s[g] = N[g], a[g] = y[g], o && (o[g] = Q[g], o[g](g))) : s[g] = je(v);
480
+ s = s.slice(0, i = d), r = l.slice(0);
481
+ }
482
+ return s;
483
+ });
484
+ function v(A) {
485
+ if (a[g] = A, o) {
486
+ const [E, N] = J(g);
487
+ return o[g] = N, t(l[g], E);
488
+ }
489
+ return t(l[g]);
490
+ }
491
+ };
492
+ }
493
+ function Ba(e, t, n = {}) {
494
+ let r = [], s = [], a = [], i = [], o = 0, l;
495
+ return vt(() => en(a)), () => {
496
+ const d = e() || [], h = d.length;
497
+ return d[pr], le(() => {
498
+ if (h === 0)
499
+ return o !== 0 && (en(a), a = [], r = [], s = [], o = 0, i = []), n.fallback && (r = [An], s[0] = je((v) => (a[0] = v, n.fallback())), o = 1), s;
500
+ for (r[0] === An && (a[0](), a = [], r = [], s = [], o = 0), l = 0; l < h; l++)
501
+ l < r.length && r[l] !== d[l] ? i[l](() => d[l]) : l >= r.length && (s[l] = je(g));
502
+ for (; l < r.length; l++)
503
+ a[l]();
504
+ return o = i.length = a.length = h, r = d.slice(0), s = s.slice(0, o);
505
+ });
506
+ function g(v) {
507
+ a[l] = v;
508
+ const [A, E] = J(d[l]);
509
+ return i[l] = E, t(A, l);
510
+ }
511
+ };
512
+ }
513
+ function Nr(e, t) {
514
+ return le(() => e(t || {}));
515
+ }
516
+ function Ht() {
517
+ return !0;
518
+ }
519
+ var wn = {
520
+ get(e, t, n) {
521
+ return t === Qt ? n : e.get(t);
522
+ },
523
+ has(e, t) {
524
+ return t === Qt ? !0 : e.has(t);
525
+ },
526
+ set: Ht,
527
+ deleteProperty: Ht,
528
+ getOwnPropertyDescriptor(e, t) {
529
+ return {
530
+ configurable: !0,
531
+ enumerable: !0,
532
+ get() {
533
+ return e.get(t);
534
+ },
535
+ set: Ht,
536
+ deleteProperty: Ht
537
+ };
538
+ },
539
+ ownKeys(e) {
540
+ return e.keys();
541
+ }
542
+ };
543
+ function En(e) {
544
+ return (e = typeof e == "function" ? e() : e) ? e : {};
545
+ }
546
+ function Fa() {
547
+ for (let e = 0, t = this.length; e < t; ++e) {
548
+ const n = this[e]();
549
+ if (n !== void 0)
550
+ return n;
551
+ }
552
+ }
553
+ function Cr(...e) {
554
+ let t = !1;
555
+ for (let i = 0; i < e.length; i++) {
556
+ const o = e[i];
557
+ t = t || !!o && Qt in o, e[i] = typeof o == "function" ? (t = !0, fe(o)) : o;
558
+ }
559
+ if (Er && t)
560
+ return new Proxy(
561
+ {
562
+ get(i) {
563
+ for (let o = e.length - 1; o >= 0; o--) {
564
+ const l = En(e[o])[i];
565
+ if (l !== void 0)
566
+ return l;
567
+ }
568
+ },
569
+ has(i) {
570
+ for (let o = e.length - 1; o >= 0; o--)
571
+ if (i in En(e[o]))
572
+ return !0;
573
+ return !1;
574
+ },
575
+ keys() {
576
+ const i = [];
577
+ for (let o = 0; o < e.length; o++)
578
+ i.push(...Object.keys(En(e[o])));
579
+ return [...new Set(i)];
580
+ }
581
+ },
582
+ wn
583
+ );
584
+ const n = {}, r = /* @__PURE__ */ Object.create(null);
585
+ for (let i = e.length - 1; i >= 0; i--) {
586
+ const o = e[i];
587
+ if (!o)
588
+ continue;
589
+ const l = Object.getOwnPropertyNames(o);
590
+ for (let d = l.length - 1; d >= 0; d--) {
591
+ const h = l[d];
592
+ if (h === "__proto__" || h === "constructor")
593
+ continue;
594
+ const g = Object.getOwnPropertyDescriptor(o, h);
595
+ if (!r[h])
596
+ r[h] = g.get ? {
597
+ enumerable: !0,
598
+ configurable: !0,
599
+ get: Fa.bind(n[h] = [g.get.bind(o)])
600
+ } : g.value !== void 0 ? g : void 0;
601
+ else {
602
+ const v = n[h];
603
+ v && (g.get ? v.push(g.get.bind(o)) : g.value !== void 0 && v.push(() => g.value));
604
+ }
605
+ }
606
+ }
607
+ const s = {}, a = Object.keys(r);
608
+ for (let i = a.length - 1; i >= 0; i--) {
609
+ const o = a[i], l = r[o];
610
+ l && l.get ? Object.defineProperty(s, o, l) : s[o] = l ? l.value : void 0;
611
+ }
612
+ return s;
613
+ }
614
+ function ja(e, ...t) {
615
+ if (Er && Qt in e) {
616
+ const s = new Set(t.length > 1 ? t.flat() : t[0]), a = t.map((i) => new Proxy(
617
+ {
618
+ get(o) {
619
+ return i.includes(o) ? e[o] : void 0;
620
+ },
621
+ has(o) {
622
+ return i.includes(o) && o in e;
623
+ },
624
+ keys() {
625
+ return i.filter((o) => o in e);
626
+ }
627
+ },
628
+ wn
629
+ ));
630
+ return a.push(
631
+ new Proxy(
632
+ {
633
+ get(i) {
634
+ return s.has(i) ? void 0 : e[i];
635
+ },
636
+ has(i) {
637
+ return s.has(i) ? !1 : i in e;
638
+ },
639
+ keys() {
640
+ return Object.keys(e).filter((i) => !s.has(i));
641
+ }
642
+ },
643
+ wn
644
+ )
645
+ ), a;
646
+ }
647
+ const n = {}, r = t.map(() => ({}));
648
+ for (const s of Object.getOwnPropertyNames(e)) {
649
+ const a = Object.getOwnPropertyDescriptor(e, s), i = !a.get && !a.set && a.enumerable && a.writable && a.configurable;
650
+ let o = !1, l = 0;
651
+ for (const d of t)
652
+ d.includes(s) && (o = !0, i ? r[l][s] = a.value : Object.defineProperty(r[l], s, a)), ++l;
653
+ o || (i ? n[s] = a.value : Object.defineProperty(n, s, a));
654
+ }
655
+ return [...r, n];
656
+ }
657
+ function Ir(e) {
658
+ let t, n;
659
+ const r = (s) => {
660
+ const a = _.context;
661
+ if (a) {
662
+ const [o, l] = J();
663
+ _.count || (_.count = 0), _.count++, (n || (n = e())).then((d) => {
664
+ !_.done && mt(a), _.count--, l(() => d.default), mt();
665
+ }), t = o;
666
+ } else if (!t) {
667
+ const [o] = Ca(() => (n || (n = e())).then((l) => l.default));
668
+ t = o;
669
+ }
670
+ let i;
671
+ return fe(
672
+ () => (i = t()) ? le(() => {
673
+ if (!a || _.done)
674
+ return i(s);
675
+ const o = _.context;
676
+ mt(a);
677
+ const l = i(s);
678
+ return mt(o), l;
679
+ }) : ""
680
+ );
681
+ };
682
+ return r.preload = () => n || ((n = e()).then((s) => t = () => s.default), n), r;
683
+ }
684
+ var Ha = 0;
685
+ function al() {
686
+ return _.context ? _.getNextContextId() : `cl-${Ha++}`;
687
+ }
688
+ var Lr = (e) => `Stale read from <${e}>.`;
689
+ function il(e) {
690
+ const t = "fallback" in e && {
691
+ fallback: () => e.fallback
692
+ };
693
+ return fe(Ma(() => e.each, e.children, t || void 0));
694
+ }
695
+ function ol(e) {
696
+ const t = "fallback" in e && {
697
+ fallback: () => e.fallback
698
+ };
699
+ return fe(Ba(() => e.each, e.children, t || void 0));
700
+ }
701
+ function ll(e) {
702
+ const t = e.keyed, n = fe(() => e.when, void 0, {
703
+ equals: (r, s) => t ? r === s : !r == !s
704
+ });
705
+ return fe(
706
+ () => {
707
+ const r = n();
708
+ if (r) {
709
+ const s = e.children;
710
+ return typeof s == "function" && s.length > 0 ? le(
711
+ () => s(
712
+ t ? r : () => {
713
+ if (!le(n))
714
+ throw Lr("Show");
715
+ return e.when;
716
+ }
717
+ )
718
+ ) : s;
719
+ }
720
+ return e.fallback;
721
+ },
722
+ void 0,
723
+ void 0
724
+ );
725
+ }
726
+ function cl(e) {
727
+ let t = !1;
728
+ const n = (a, i) => (t ? a[1] === i[1] : !a[1] == !i[1]) && a[2] === i[2], r = wr(() => e.children), s = fe(
729
+ () => {
730
+ let a = r();
731
+ Array.isArray(a) || (a = [a]);
732
+ for (let i = 0; i < a.length; i++) {
733
+ const o = a[i].when;
734
+ if (o)
735
+ return t = !!a[i].keyed, [i, o, a[i]];
736
+ }
737
+ return [-1];
738
+ },
739
+ void 0,
740
+ {
741
+ equals: n
742
+ }
743
+ );
744
+ return fe(
745
+ () => {
746
+ const [a, i, o] = s();
747
+ if (a < 0)
748
+ return e.fallback;
749
+ const l = o.children;
750
+ return typeof l == "function" && l.length > 0 ? le(
751
+ () => l(
752
+ t ? i : () => {
753
+ if (le(s)[0] !== a)
754
+ throw Lr("Match");
755
+ return o.when;
756
+ }
757
+ )
758
+ ) : l;
759
+ },
760
+ void 0,
761
+ void 0
762
+ );
763
+ }
764
+ function ul(e) {
765
+ return e;
766
+ }
767
+ var qa = [
768
+ "allowfullscreen",
769
+ "async",
770
+ "autofocus",
771
+ "autoplay",
772
+ "checked",
773
+ "controls",
774
+ "default",
775
+ "disabled",
776
+ "formnovalidate",
777
+ "hidden",
778
+ "indeterminate",
779
+ "inert",
780
+ "ismap",
781
+ "loop",
782
+ "multiple",
783
+ "muted",
784
+ "nomodule",
785
+ "novalidate",
786
+ "open",
787
+ "playsinline",
788
+ "readonly",
789
+ "required",
790
+ "reversed",
791
+ "seamless",
792
+ "selected"
793
+ ], Ka = /* @__PURE__ */ new Set([
794
+ "className",
795
+ "value",
796
+ "readOnly",
797
+ "formNoValidate",
798
+ "isMap",
799
+ "noModule",
800
+ "playsInline",
801
+ ...qa
802
+ ]), Va = /* @__PURE__ */ new Set([
803
+ "innerHTML",
804
+ "textContent",
805
+ "innerText",
806
+ "children"
807
+ ]), Wa = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
808
+ className: "class",
809
+ htmlFor: "for"
810
+ }), za = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
811
+ class: "className",
812
+ formnovalidate: {
813
+ $: "formNoValidate",
814
+ BUTTON: 1,
815
+ INPUT: 1
816
+ },
817
+ ismap: {
818
+ $: "isMap",
819
+ IMG: 1
820
+ },
821
+ nomodule: {
822
+ $: "noModule",
823
+ SCRIPT: 1
824
+ },
825
+ playsinline: {
826
+ $: "playsInline",
827
+ VIDEO: 1
828
+ },
829
+ readonly: {
830
+ $: "readOnly",
831
+ INPUT: 1,
832
+ TEXTAREA: 1
833
+ }
834
+ });
835
+ function $a(e, t) {
836
+ const n = za[e];
837
+ return typeof n == "object" ? n[t] ? n.$ : void 0 : n;
838
+ }
839
+ var Qa = /* @__PURE__ */ new Set([
840
+ "beforeinput",
841
+ "click",
842
+ "dblclick",
843
+ "contextmenu",
844
+ "focusin",
845
+ "focusout",
846
+ "input",
847
+ "keydown",
848
+ "keyup",
849
+ "mousedown",
850
+ "mousemove",
851
+ "mouseout",
852
+ "mouseover",
853
+ "mouseup",
854
+ "pointerdown",
855
+ "pointermove",
856
+ "pointerout",
857
+ "pointerover",
858
+ "pointerup",
859
+ "touchend",
860
+ "touchmove",
861
+ "touchstart"
862
+ ]), Ya = /* @__PURE__ */ new Set([
863
+ "altGlyph",
864
+ "altGlyphDef",
865
+ "altGlyphItem",
866
+ "animate",
867
+ "animateColor",
868
+ "animateMotion",
869
+ "animateTransform",
870
+ "circle",
871
+ "clipPath",
872
+ "color-profile",
873
+ "cursor",
874
+ "defs",
875
+ "desc",
876
+ "ellipse",
877
+ "feBlend",
878
+ "feColorMatrix",
879
+ "feComponentTransfer",
880
+ "feComposite",
881
+ "feConvolveMatrix",
882
+ "feDiffuseLighting",
883
+ "feDisplacementMap",
884
+ "feDistantLight",
885
+ "feDropShadow",
886
+ "feFlood",
887
+ "feFuncA",
888
+ "feFuncB",
889
+ "feFuncG",
890
+ "feFuncR",
891
+ "feGaussianBlur",
892
+ "feImage",
893
+ "feMerge",
894
+ "feMergeNode",
895
+ "feMorphology",
896
+ "feOffset",
897
+ "fePointLight",
898
+ "feSpecularLighting",
899
+ "feSpotLight",
900
+ "feTile",
901
+ "feTurbulence",
902
+ "filter",
903
+ "font",
904
+ "font-face",
905
+ "font-face-format",
906
+ "font-face-name",
907
+ "font-face-src",
908
+ "font-face-uri",
909
+ "foreignObject",
910
+ "g",
911
+ "glyph",
912
+ "glyphRef",
913
+ "hkern",
914
+ "image",
915
+ "line",
916
+ "linearGradient",
917
+ "marker",
918
+ "mask",
919
+ "metadata",
920
+ "missing-glyph",
921
+ "mpath",
922
+ "path",
923
+ "pattern",
924
+ "polygon",
925
+ "polyline",
926
+ "radialGradient",
927
+ "rect",
928
+ "set",
929
+ "stop",
930
+ "svg",
931
+ "switch",
932
+ "symbol",
933
+ "text",
934
+ "textPath",
935
+ "tref",
936
+ "tspan",
937
+ "use",
938
+ "view",
939
+ "vkern"
940
+ ]), Xa = {
941
+ xlink: "http://www.w3.org/1999/xlink",
942
+ xml: "http://www.w3.org/XML/1998/namespace"
943
+ };
944
+ function Za(e, t, n) {
945
+ let r = n.length, s = t.length, a = r, i = 0, o = 0, l = t[s - 1].nextSibling, d = null;
946
+ for (; i < s || o < a; ) {
947
+ if (t[i] === n[o]) {
948
+ i++, o++;
949
+ continue;
950
+ }
951
+ for (; t[s - 1] === n[a - 1]; )
952
+ s--, a--;
953
+ if (s === i) {
954
+ const h = a < r ? o ? n[o - 1].nextSibling : n[a - o] : l;
955
+ for (; o < a; )
956
+ e.insertBefore(n[o++], h);
957
+ } else if (a === o)
958
+ for (; i < s; )
959
+ (!d || !d.has(t[i])) && t[i].remove(), i++;
960
+ else if (t[i] === n[a - 1] && n[o] === t[s - 1]) {
961
+ const h = t[--s].nextSibling;
962
+ e.insertBefore(n[o++], t[i++].nextSibling), e.insertBefore(n[--a], h), t[s] = n[a];
963
+ } else {
964
+ if (!d) {
965
+ d = /* @__PURE__ */ new Map();
966
+ let g = o;
967
+ for (; g < a; )
968
+ d.set(n[g], g++);
969
+ }
970
+ const h = d.get(t[i]);
971
+ if (h != null)
972
+ if (o < h && h < a) {
973
+ let g = i, v = 1, A;
974
+ for (; ++g < s && g < a && !((A = d.get(t[g])) == null || A !== h + v); )
975
+ v++;
976
+ if (v > h - o) {
977
+ const E = t[i];
978
+ for (; o < h; )
979
+ e.insertBefore(n[o++], E);
980
+ } else
981
+ e.replaceChild(n[o++], t[i++]);
982
+ } else
983
+ i++;
984
+ else
985
+ t[i++].remove();
986
+ }
987
+ }
988
+ }
989
+ var Et = "_$DX_DELEGATE";
990
+ function xr(e, t, n, r = {}) {
991
+ let s;
992
+ return je((a) => {
993
+ s = a, t === document ? e() : Tn(t, e(), t.firstChild ? null : void 0, n);
994
+ }, r.owner), () => {
995
+ s(), t.textContent = "";
996
+ };
997
+ }
998
+ function dl(e, t, n) {
999
+ let r;
1000
+ const s = () => {
1001
+ const i = document.createElement("template");
1002
+ return i.innerHTML = e, i.content.firstChild;
1003
+ }, a = () => (r || (r = s())).cloneNode(!0);
1004
+ return a.cloneNode = a, a;
1005
+ }
1006
+ function Ja(e, t = window.document) {
1007
+ const n = t[Et] || (t[Et] = /* @__PURE__ */ new Set());
1008
+ for (let r = 0, s = e.length; r < s; r++) {
1009
+ const a = e[r];
1010
+ n.has(a) || (n.add(a), t.addEventListener(a, Gr));
1011
+ }
1012
+ }
1013
+ function fl(e = window.document) {
1014
+ if (e[Et]) {
1015
+ for (let t of e[Et].keys())
1016
+ e.removeEventListener(t, Gr);
1017
+ delete e[Et];
1018
+ }
1019
+ }
1020
+ function bn(e, t, n) {
1021
+ Ve(e) || (n == null ? e.removeAttribute(t) : e.setAttribute(t, n));
1022
+ }
1023
+ function ei(e, t, n, r) {
1024
+ Ve(e) || (r == null ? e.removeAttributeNS(t, n) : e.setAttributeNS(t, n, r));
1025
+ }
1026
+ function ti(e, t, n) {
1027
+ Ve(e) || (n ? e.setAttribute(t, "") : e.removeAttribute(t));
1028
+ }
1029
+ function ni(e, t) {
1030
+ Ve(e) || (t == null ? e.removeAttribute("class") : e.className = t);
1031
+ }
1032
+ function ri(e, t, n, r) {
1033
+ if (r)
1034
+ Array.isArray(n) ? (e[`$$${t}`] = n[0], e[`$$${t}Data`] = n[1]) : e[`$$${t}`] = n;
1035
+ else if (Array.isArray(n)) {
1036
+ const s = n[0];
1037
+ e.addEventListener(t, n[0] = (a) => s.call(e, n[1], a));
1038
+ } else
1039
+ e.addEventListener(t, n, typeof n != "function" && n);
1040
+ }
1041
+ function si(e, t, n = {}) {
1042
+ const r = Object.keys(t || {}), s = Object.keys(n);
1043
+ let a, i;
1044
+ for (a = 0, i = s.length; a < i; a++) {
1045
+ const o = s[a];
1046
+ !o || o === "undefined" || t[o] || (Yn(e, o, !1), delete n[o]);
1047
+ }
1048
+ for (a = 0, i = r.length; a < i; a++) {
1049
+ const o = r[a], l = !!t[o];
1050
+ !o || o === "undefined" || n[o] === l || !l || (Yn(e, o, !0), n[o] = l);
1051
+ }
1052
+ return n;
1053
+ }
1054
+ function ai(e, t, n) {
1055
+ if (!t)
1056
+ return n ? bn(e, "style") : t;
1057
+ const r = e.style;
1058
+ if (typeof t == "string")
1059
+ return r.cssText = t;
1060
+ typeof n == "string" && (r.cssText = n = void 0), n || (n = {}), t || (t = {});
1061
+ let s, a;
1062
+ for (a in n)
1063
+ t[a] == null && r.removeProperty(a), delete n[a];
1064
+ for (a in t)
1065
+ s = t[a], s !== n[a] && (r.setProperty(a, s), n[a] = s);
1066
+ return n;
1067
+ }
1068
+ function ii(e, t = {}, n, r) {
1069
+ const s = {};
1070
+ return r || He(
1071
+ () => s.children = At(e, t.children, s.children)
1072
+ ), He(() => typeof t.ref == "function" && oi(t.ref, e)), He(() => li(e, t, n, !0, s, !0)), s;
1073
+ }
1074
+ function oi(e, t, n) {
1075
+ return le(() => e(t, n));
1076
+ }
1077
+ function Tn(e, t, n, r) {
1078
+ if (n !== void 0 && !r && (r = []), typeof t != "function")
1079
+ return At(e, t, r, n);
1080
+ He((s) => At(e, t(), s, n), r);
1081
+ }
1082
+ function li(e, t, n, r, s = {}, a = !1) {
1083
+ t || (t = {});
1084
+ for (const i in s)
1085
+ if (!(i in t)) {
1086
+ if (i === "children")
1087
+ continue;
1088
+ s[i] = Xn(e, i, null, s[i], n, a, t);
1089
+ }
1090
+ for (const i in t) {
1091
+ if (i === "children")
1092
+ continue;
1093
+ const o = t[i];
1094
+ s[i] = Xn(e, i, o, s[i], n, a, t);
1095
+ }
1096
+ }
1097
+ function ci(e) {
1098
+ let t, n;
1099
+ return !Ve() || !(t = _.registry.get(n = di())) ? e() : (_.completed && _.completed.add(t), _.registry.delete(n), t);
1100
+ }
1101
+ function Ve(e) {
1102
+ return !!_.context && !_.done && (!e || e.isConnected);
1103
+ }
1104
+ function ui(e) {
1105
+ return e.toLowerCase().replace(/-([a-z])/g, (t, n) => n.toUpperCase());
1106
+ }
1107
+ function Yn(e, t, n) {
1108
+ const r = t.trim().split(/\s+/);
1109
+ for (let s = 0, a = r.length; s < a; s++)
1110
+ e.classList.toggle(r[s], n);
1111
+ }
1112
+ function Xn(e, t, n, r, s, a, i) {
1113
+ let o, l, d, h, g;
1114
+ if (t === "style")
1115
+ return ai(e, n, r);
1116
+ if (t === "classList")
1117
+ return si(e, n, r);
1118
+ if (n === r)
1119
+ return r;
1120
+ if (t === "ref")
1121
+ a || n(e);
1122
+ else if (t.slice(0, 3) === "on:") {
1123
+ const v = t.slice(3);
1124
+ r && e.removeEventListener(v, r, typeof r != "function" && r), n && e.addEventListener(v, n, typeof n != "function" && n);
1125
+ } else if (t.slice(0, 10) === "oncapture:") {
1126
+ const v = t.slice(10);
1127
+ r && e.removeEventListener(v, r, !0), n && e.addEventListener(v, n, !0);
1128
+ } else if (t.slice(0, 2) === "on") {
1129
+ const v = t.slice(2).toLowerCase(), A = Qa.has(v);
1130
+ if (!A && r) {
1131
+ const E = Array.isArray(r) ? r[0] : r;
1132
+ e.removeEventListener(v, E);
1133
+ }
1134
+ (A || n) && (ri(e, v, n, A), A && Ja([v]));
1135
+ } else if (t.slice(0, 5) === "attr:")
1136
+ bn(e, t.slice(5), n);
1137
+ else if (t.slice(0, 5) === "bool:")
1138
+ ti(e, t.slice(5), n);
1139
+ else if ((g = t.slice(0, 5) === "prop:") || (d = Va.has(t)) || !s && ((h = $a(t, e.tagName)) || (l = Ka.has(t))) || (o = e.nodeName.includes("-") || "is" in i)) {
1140
+ if (g)
1141
+ t = t.slice(5), l = !0;
1142
+ else if (Ve(e))
1143
+ return n;
1144
+ t === "class" || t === "className" ? ni(e, n) : o && !l && !d ? e[ui(t)] = n : e[h || t] = n;
1145
+ } else {
1146
+ const v = s && t.indexOf(":") > -1 && Xa[t.split(":")[0]];
1147
+ v ? ei(e, v, t, n) : bn(e, Wa[t] || t, n);
1148
+ }
1149
+ return n;
1150
+ }
1151
+ function Gr(e) {
1152
+ if (_.registry && _.events && _.events.find(([l, d]) => d === e))
1153
+ return;
1154
+ let t = e.target;
1155
+ const n = `$$${e.type}`, r = e.target, s = e.currentTarget, a = (l) => Object.defineProperty(e, "target", {
1156
+ configurable: !0,
1157
+ value: l
1158
+ }), i = () => {
1159
+ const l = t[n];
1160
+ if (l && !t.disabled) {
1161
+ const d = t[`${n}Data`];
1162
+ if (d !== void 0 ? l.call(t, d, e) : l.call(t, e), e.cancelBubble)
1163
+ return;
1164
+ }
1165
+ return t.host && typeof t.host != "string" && !t.host._$host && t.contains(e.target) && a(t.host), !0;
1166
+ }, o = () => {
1167
+ for (; i() && (t = t._$host || t.parentNode || t.host); )
1168
+ ;
1169
+ };
1170
+ if (Object.defineProperty(e, "currentTarget", {
1171
+ configurable: !0,
1172
+ get() {
1173
+ return t || document;
1174
+ }
1175
+ }), _.registry && !_.done && (_.done = _$HY.done = !0), e.composedPath) {
1176
+ const l = e.composedPath();
1177
+ a(l[0]);
1178
+ for (let d = 0; d < l.length - 2 && (t = l[d], !!i()); d++) {
1179
+ if (t._$host) {
1180
+ t = t._$host, o();
1181
+ break;
1182
+ }
1183
+ if (t.parentNode === s)
1184
+ break;
1185
+ }
1186
+ } else
1187
+ o();
1188
+ a(r);
1189
+ }
1190
+ function At(e, t, n, r, s) {
1191
+ const a = Ve(e);
1192
+ if (a) {
1193
+ !n && (n = [...e.childNodes]);
1194
+ let l = [];
1195
+ for (let d = 0; d < n.length; d++) {
1196
+ const h = n[d];
1197
+ h.nodeType === 8 && h.data.slice(0, 2) === "!$" ? h.remove() : l.push(h);
1198
+ }
1199
+ n = l;
1200
+ }
1201
+ for (; typeof n == "function"; )
1202
+ n = n();
1203
+ if (t === n)
1204
+ return n;
1205
+ const i = typeof t, o = r !== void 0;
1206
+ if (e = o && n[0] && n[0].parentNode || e, i === "string" || i === "number") {
1207
+ if (a || i === "number" && (t = t.toString(), t === n))
1208
+ return n;
1209
+ if (o) {
1210
+ let l = n[0];
1211
+ l && l.nodeType === 3 ? l.data !== t && (l.data = t) : l = document.createTextNode(t), n = ze(e, n, r, l);
1212
+ } else
1213
+ n !== "" && typeof n == "string" ? n = e.firstChild.data = t : n = e.textContent = t;
1214
+ } else if (t == null || i === "boolean") {
1215
+ if (a)
1216
+ return n;
1217
+ n = ze(e, n, r);
1218
+ } else {
1219
+ if (i === "function")
1220
+ return He(() => {
1221
+ let l = t();
1222
+ for (; typeof l == "function"; )
1223
+ l = l();
1224
+ n = At(e, l, n, r);
1225
+ }), () => n;
1226
+ if (Array.isArray(t)) {
1227
+ const l = [], d = n && Array.isArray(n);
1228
+ if (_n(l, t, n, s))
1229
+ return He(() => n = At(e, l, n, r, !0)), () => n;
1230
+ if (a) {
1231
+ if (!l.length)
1232
+ return n;
1233
+ if (r === void 0)
1234
+ return n = [...e.childNodes];
1235
+ let h = l[0];
1236
+ if (h.parentNode !== e)
1237
+ return n;
1238
+ const g = [h];
1239
+ for (; (h = h.nextSibling) !== r; )
1240
+ g.push(h);
1241
+ return n = g;
1242
+ }
1243
+ if (l.length === 0) {
1244
+ if (n = ze(e, n, r), o)
1245
+ return n;
1246
+ } else d ? n.length === 0 ? Zn(e, l, r) : Za(e, n, l) : (n && ze(e), Zn(e, l));
1247
+ n = l;
1248
+ } else if (t.nodeType) {
1249
+ if (a && t.parentNode)
1250
+ return n = o ? [t] : t;
1251
+ if (Array.isArray(n)) {
1252
+ if (o)
1253
+ return n = ze(e, n, r, t);
1254
+ ze(e, n, null, t);
1255
+ } else n == null || n === "" || !e.firstChild ? e.appendChild(t) : e.replaceChild(t, e.firstChild);
1256
+ n = t;
1257
+ }
1258
+ }
1259
+ return n;
1260
+ }
1261
+ function _n(e, t, n, r) {
1262
+ let s = !1;
1263
+ for (let a = 0, i = t.length; a < i; a++) {
1264
+ let o = t[a], l = n && n[e.length], d;
1265
+ if (!(o == null || o === !0 || o === !1))
1266
+ if ((d = typeof o) == "object" && o.nodeType)
1267
+ e.push(o);
1268
+ else if (Array.isArray(o))
1269
+ s = _n(e, o, l) || s;
1270
+ else if (d === "function")
1271
+ if (r) {
1272
+ for (; typeof o == "function"; )
1273
+ o = o();
1274
+ s = _n(
1275
+ e,
1276
+ Array.isArray(o) ? o : [o],
1277
+ Array.isArray(l) ? l : [l]
1278
+ ) || s;
1279
+ } else
1280
+ e.push(o), s = !0;
1281
+ else {
1282
+ const h = String(o);
1283
+ l && l.nodeType === 3 && l.data === h ? e.push(l) : e.push(document.createTextNode(h));
1284
+ }
1285
+ }
1286
+ return s;
1287
+ }
1288
+ function Zn(e, t, n = null) {
1289
+ for (let r = 0, s = t.length; r < s; r++)
1290
+ e.insertBefore(t[r], n);
1291
+ }
1292
+ function ze(e, t, n, r) {
1293
+ if (n === void 0)
1294
+ return e.textContent = "";
1295
+ const s = r || document.createTextNode("");
1296
+ if (t.length) {
1297
+ let a = !1;
1298
+ for (let i = t.length - 1; i >= 0; i--) {
1299
+ const o = t[i];
1300
+ if (s !== o) {
1301
+ const l = o.parentNode === e;
1302
+ !a && !i ? l ? e.replaceChild(s, o) : e.insertBefore(s, n) : l && o.remove();
1303
+ } else
1304
+ a = !0;
1305
+ }
1306
+ } else
1307
+ e.insertBefore(s, n);
1308
+ return [s];
1309
+ }
1310
+ function di() {
1311
+ return _.getNextContextId();
1312
+ }
1313
+ var fi = "http://www.w3.org/2000/svg";
1314
+ function kr(e, t = !1) {
1315
+ return t ? document.createElementNS(fi, e) : document.createElement(e);
1316
+ }
1317
+ function hl(e) {
1318
+ const { useShadow: t } = e, n = document.createTextNode(""), r = () => e.mount || document.body, s = Qn();
1319
+ let a, i = !!_.context;
1320
+ return Ar(
1321
+ () => {
1322
+ i && (Qn().user = i = !1), a || (a = La(s, () => fe(() => e.children)));
1323
+ const o = r();
1324
+ if (o instanceof HTMLHeadElement) {
1325
+ const [l, d] = J(!1), h = () => d(!0);
1326
+ je((g) => Tn(o, () => l() ? g() : a(), null)), vt(h);
1327
+ } else {
1328
+ const l = kr(e.isSVG ? "g" : "div", e.isSVG), d = t && l.attachShadow ? l.attachShadow({
1329
+ mode: "open"
1330
+ }) : l;
1331
+ Object.defineProperty(l, "_$host", {
1332
+ get() {
1333
+ return n.parentNode;
1334
+ },
1335
+ configurable: !0
1336
+ }), Tn(d, a), o.appendChild(l), e.ref && e.ref(l), vt(() => o.removeChild(l));
1337
+ }
1338
+ },
1339
+ void 0,
1340
+ {
1341
+ render: !i
1342
+ }
1343
+ ), n;
1344
+ }
1345
+ function gl(e) {
1346
+ const [t, n] = ja(e, ["component"]), r = fe(() => t.component);
1347
+ return fe(() => {
1348
+ const s = r();
1349
+ switch (typeof s) {
1350
+ case "function":
1351
+ return le(() => s(n));
1352
+ case "string":
1353
+ const a = Ya.has(s), i = _.context ? ci() : kr(s, a);
1354
+ return ii(i, n, a), i;
1355
+ }
1356
+ });
1357
+ }
1358
+ var hi = class {
1359
+ constructor() {
1360
+ this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
1361
+ }
1362
+ set(e, t) {
1363
+ this.keyToValue.set(e, t), this.valueToKey.set(t, e);
1364
+ }
1365
+ getByKey(e) {
1366
+ return this.keyToValue.get(e);
1367
+ }
1368
+ getByValue(e) {
1369
+ return this.valueToKey.get(e);
1370
+ }
1371
+ clear() {
1372
+ this.keyToValue.clear(), this.valueToKey.clear();
1373
+ }
1374
+ }, Dr = class {
1375
+ constructor(e) {
1376
+ this.generateIdentifier = e, this.kv = new hi();
1377
+ }
1378
+ register(e, t) {
1379
+ this.kv.getByValue(e) || (t || (t = this.generateIdentifier(e)), this.kv.set(t, e));
1380
+ }
1381
+ clear() {
1382
+ this.kv.clear();
1383
+ }
1384
+ getIdentifier(e) {
1385
+ return this.kv.getByValue(e);
1386
+ }
1387
+ getValue(e) {
1388
+ return this.kv.getByKey(e);
1389
+ }
1390
+ }, gi = class extends Dr {
1391
+ constructor() {
1392
+ super((e) => e.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
1393
+ }
1394
+ register(e, t) {
1395
+ typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(e, t.allowProps), super.register(e, t.identifier)) : super.register(e, t);
1396
+ }
1397
+ getAllowedProps(e) {
1398
+ return this.classToAllowedProps.get(e);
1399
+ }
1400
+ };
1401
+ function mi(e) {
1402
+ if ("values" in Object)
1403
+ return Object.values(e);
1404
+ const t = [];
1405
+ for (const n in e)
1406
+ e.hasOwnProperty(n) && t.push(e[n]);
1407
+ return t;
1408
+ }
1409
+ function yi(e, t) {
1410
+ const n = mi(e);
1411
+ if ("find" in n)
1412
+ return n.find(t);
1413
+ const r = n;
1414
+ for (let s = 0; s < r.length; s++) {
1415
+ const a = r[s];
1416
+ if (t(a))
1417
+ return a;
1418
+ }
1419
+ }
1420
+ function ut(e, t) {
1421
+ Object.entries(e).forEach(([n, r]) => t(r, n));
1422
+ }
1423
+ function zt(e, t) {
1424
+ return e.indexOf(t) !== -1;
1425
+ }
1426
+ function Jn(e, t) {
1427
+ for (let n = 0; n < e.length; n++) {
1428
+ const r = e[n];
1429
+ if (t(r))
1430
+ return r;
1431
+ }
1432
+ }
1433
+ var Ei = class {
1434
+ constructor() {
1435
+ this.transfomers = {};
1436
+ }
1437
+ register(e) {
1438
+ this.transfomers[e.name] = e;
1439
+ }
1440
+ findApplicable(e) {
1441
+ return yi(this.transfomers, (t) => t.isApplicable(e));
1442
+ }
1443
+ findByName(e) {
1444
+ return this.transfomers[e];
1445
+ }
1446
+ }, pi = (e) => Object.prototype.toString.call(e).slice(8, -1), Or = (e) => typeof e > "u", vi = (e) => e === null, wt = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, Pn = (e) => wt(e) && Object.keys(e).length === 0, Re = (e) => Array.isArray(e), Si = (e) => typeof e == "string", Ai = (e) => typeof e == "number" && !isNaN(e), wi = (e) => typeof e == "boolean", bi = (e) => e instanceof RegExp, bt = (e) => e instanceof Map, Tt = (e) => e instanceof Set, Ur = (e) => pi(e) === "Symbol", Ti = (e) => e instanceof Date && !isNaN(e.valueOf()), _i = (e) => e instanceof Error, er = (e) => typeof e == "number" && isNaN(e), Pi = (e) => wi(e) || vi(e) || Or(e) || Ai(e) || Si(e) || Ur(e), Ni = (e) => typeof e == "bigint", Ci = (e) => e === 1 / 0 || e === -1 / 0, Ii = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), Li = (e) => e instanceof URL, Rr = (e) => e.replace(/\./g, "\\."), pn = (e) => e.map(String).map(Rr).join("."), pt = (e) => {
1447
+ const t = [];
1448
+ let n = "";
1449
+ for (let s = 0; s < e.length; s++) {
1450
+ let a = e.charAt(s);
1451
+ if (a === "\\" && e.charAt(s + 1) === ".") {
1452
+ n += ".", s++;
1453
+ continue;
1454
+ }
1455
+ if (a === ".") {
1456
+ t.push(n), n = "";
1457
+ continue;
1458
+ }
1459
+ n += a;
1460
+ }
1461
+ const r = n;
1462
+ return t.push(r), t;
1463
+ };
1464
+ function be(e, t, n, r) {
1465
+ return {
1466
+ isApplicable: e,
1467
+ annotation: t,
1468
+ transform: n,
1469
+ untransform: r
1470
+ };
1471
+ }
1472
+ var Mr = [
1473
+ be(Or, "undefined", () => null, () => {
1474
+ }),
1475
+ be(Ni, "bigint", (e) => e.toString(), (e) => typeof BigInt < "u" ? BigInt(e) : e),
1476
+ be(Ti, "Date", (e) => e.toISOString(), (e) => new Date(e)),
1477
+ be(_i, "Error", (e, t) => {
1478
+ const n = {
1479
+ name: e.name,
1480
+ message: e.message
1481
+ };
1482
+ return t.allowedErrorProps.forEach((r) => {
1483
+ n[r] = e[r];
1484
+ }), n;
1485
+ }, (e, t) => {
1486
+ const n = new Error(e.message);
1487
+ return n.name = e.name, n.stack = e.stack, t.allowedErrorProps.forEach((r) => {
1488
+ n[r] = e[r];
1489
+ }), n;
1490
+ }),
1491
+ be(bi, "regexp", (e) => "" + e, (e) => {
1492
+ const t = e.slice(1, e.lastIndexOf("/")), n = e.slice(e.lastIndexOf("/") + 1);
1493
+ return new RegExp(t, n);
1494
+ }),
1495
+ be(
1496
+ Tt,
1497
+ "set",
1498
+ // (sets only exist in es6+)
1499
+ // eslint-disable-next-line es5/no-es6-methods
1500
+ (e) => [...e.values()],
1501
+ (e) => new Set(e)
1502
+ ),
1503
+ be(bt, "map", (e) => [...e.entries()], (e) => new Map(e)),
1504
+ be((e) => er(e) || Ci(e), "number", (e) => er(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
1505
+ be((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
1506
+ be(Li, "URL", (e) => e.toString(), (e) => new URL(e))
1507
+ ];
1508
+ function dn(e, t, n, r) {
1509
+ return {
1510
+ isApplicable: e,
1511
+ annotation: t,
1512
+ transform: n,
1513
+ untransform: r
1514
+ };
1515
+ }
1516
+ var Br = dn((e, t) => Ur(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, n) => {
1517
+ const r = n.symbolRegistry.getValue(t[1]);
1518
+ if (!r)
1519
+ throw new Error("Trying to deserialize unknown symbol");
1520
+ return r;
1521
+ }), xi = [
1522
+ Int8Array,
1523
+ Uint8Array,
1524
+ Int16Array,
1525
+ Uint16Array,
1526
+ Int32Array,
1527
+ Uint32Array,
1528
+ Float32Array,
1529
+ Float64Array,
1530
+ Uint8ClampedArray
1531
+ ].reduce((e, t) => (e[t.name] = t, e), {}), Fr = dn(Ii, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
1532
+ const n = xi[t[1]];
1533
+ if (!n)
1534
+ throw new Error("Trying to deserialize unknown typed array");
1535
+ return new n(e);
1536
+ });
1537
+ function jr(e, t) {
1538
+ return e != null && e.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
1539
+ }
1540
+ var Hr = dn(jr, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
1541
+ const n = t.classRegistry.getAllowedProps(e.constructor);
1542
+ if (!n)
1543
+ return { ...e };
1544
+ const r = {};
1545
+ return n.forEach((s) => {
1546
+ r[s] = e[s];
1547
+ }), r;
1548
+ }, (e, t, n) => {
1549
+ const r = n.classRegistry.getValue(t[1]);
1550
+ if (!r)
1551
+ throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");
1552
+ return Object.assign(Object.create(r.prototype), e);
1553
+ }), qr = dn((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, n) => {
1554
+ const r = n.customTransformerRegistry.findByName(t[1]);
1555
+ if (!r)
1556
+ throw new Error("Trying to deserialize unknown custom value");
1557
+ return r.deserialize(e);
1558
+ }), Gi = [Hr, Br, qr, Fr], tr = (e, t) => {
1559
+ const n = Jn(Gi, (s) => s.isApplicable(e, t));
1560
+ if (n)
1561
+ return {
1562
+ value: n.transform(e, t),
1563
+ type: n.annotation(e, t)
1564
+ };
1565
+ const r = Jn(Mr, (s) => s.isApplicable(e, t));
1566
+ if (r)
1567
+ return {
1568
+ value: r.transform(e, t),
1569
+ type: r.annotation
1570
+ };
1571
+ }, Kr = {};
1572
+ Mr.forEach((e) => {
1573
+ Kr[e.annotation] = e;
1574
+ });
1575
+ var ki = (e, t, n) => {
1576
+ if (Re(t))
1577
+ switch (t[0]) {
1578
+ case "symbol":
1579
+ return Br.untransform(e, t, n);
1580
+ case "class":
1581
+ return Hr.untransform(e, t, n);
1582
+ case "custom":
1583
+ return qr.untransform(e, t, n);
1584
+ case "typed-array":
1585
+ return Fr.untransform(e, t, n);
1586
+ default:
1587
+ throw new Error("Unknown transformation: " + t);
1588
+ }
1589
+ else {
1590
+ const r = Kr[t];
1591
+ if (!r)
1592
+ throw new Error("Unknown transformation: " + t);
1593
+ return r.untransform(e, n);
1594
+ }
1595
+ }, $e = (e, t) => {
1596
+ const n = e.keys();
1597
+ for (; t > 0; )
1598
+ n.next(), t--;
1599
+ return n.next().value;
1600
+ };
1601
+ function Vr(e) {
1602
+ if (zt(e, "__proto__"))
1603
+ throw new Error("__proto__ is not allowed as a property");
1604
+ if (zt(e, "prototype"))
1605
+ throw new Error("prototype is not allowed as a property");
1606
+ if (zt(e, "constructor"))
1607
+ throw new Error("constructor is not allowed as a property");
1608
+ }
1609
+ var Di = (e, t) => {
1610
+ Vr(t);
1611
+ for (let n = 0; n < t.length; n++) {
1612
+ const r = t[n];
1613
+ if (Tt(e))
1614
+ e = $e(e, +r);
1615
+ else if (bt(e)) {
1616
+ const s = +r, a = +t[++n] == 0 ? "key" : "value", i = $e(e, s);
1617
+ switch (a) {
1618
+ case "key":
1619
+ e = i;
1620
+ break;
1621
+ case "value":
1622
+ e = e.get(i);
1623
+ break;
1624
+ }
1625
+ } else
1626
+ e = e[r];
1627
+ }
1628
+ return e;
1629
+ }, Nn = (e, t, n) => {
1630
+ if (Vr(t), t.length === 0)
1631
+ return n(e);
1632
+ let r = e;
1633
+ for (let a = 0; a < t.length - 1; a++) {
1634
+ const i = t[a];
1635
+ if (Re(r)) {
1636
+ const o = +i;
1637
+ r = r[o];
1638
+ } else if (wt(r))
1639
+ r = r[i];
1640
+ else if (Tt(r)) {
1641
+ const o = +i;
1642
+ r = $e(r, o);
1643
+ } else if (bt(r)) {
1644
+ if (a === t.length - 2)
1645
+ break;
1646
+ const l = +i, d = +t[++a] == 0 ? "key" : "value", h = $e(r, l);
1647
+ switch (d) {
1648
+ case "key":
1649
+ r = h;
1650
+ break;
1651
+ case "value":
1652
+ r = r.get(h);
1653
+ break;
1654
+ }
1655
+ }
1656
+ }
1657
+ const s = t[t.length - 1];
1658
+ if (Re(r) ? r[+s] = n(r[+s]) : wt(r) && (r[s] = n(r[s])), Tt(r)) {
1659
+ const a = $e(r, +s), i = n(a);
1660
+ a !== i && (r.delete(a), r.add(i));
1661
+ }
1662
+ if (bt(r)) {
1663
+ const a = +t[t.length - 2], i = $e(r, a);
1664
+ switch (+s == 0 ? "key" : "value") {
1665
+ case "key": {
1666
+ const l = n(i);
1667
+ r.set(l, r.get(i)), l !== i && r.delete(i);
1668
+ break;
1669
+ }
1670
+ case "value": {
1671
+ r.set(i, n(r.get(i)));
1672
+ break;
1673
+ }
1674
+ }
1675
+ }
1676
+ return e;
1677
+ };
1678
+ function Cn(e, t, n = []) {
1679
+ if (!e)
1680
+ return;
1681
+ if (!Re(e)) {
1682
+ ut(e, (a, i) => Cn(a, t, [...n, ...pt(i)]));
1683
+ return;
1684
+ }
1685
+ const [r, s] = e;
1686
+ s && ut(s, (a, i) => {
1687
+ Cn(a, t, [...n, ...pt(i)]);
1688
+ }), t(r, n);
1689
+ }
1690
+ function Oi(e, t, n) {
1691
+ return Cn(t, (r, s) => {
1692
+ e = Nn(e, s, (a) => ki(a, r, n));
1693
+ }), e;
1694
+ }
1695
+ function Ui(e, t) {
1696
+ function n(r, s) {
1697
+ const a = Di(e, pt(s));
1698
+ r.map(pt).forEach((i) => {
1699
+ e = Nn(e, i, () => a);
1700
+ });
1701
+ }
1702
+ if (Re(t)) {
1703
+ const [r, s] = t;
1704
+ r.forEach((a) => {
1705
+ e = Nn(e, pt(a), () => e);
1706
+ }), s && ut(s, n);
1707
+ } else
1708
+ ut(t, n);
1709
+ return e;
1710
+ }
1711
+ var Ri = (e, t) => wt(e) || Re(e) || bt(e) || Tt(e) || jr(e, t);
1712
+ function Mi(e, t, n) {
1713
+ const r = n.get(e);
1714
+ r ? r.push(t) : n.set(e, [t]);
1715
+ }
1716
+ function Bi(e, t) {
1717
+ const n = {};
1718
+ let r;
1719
+ return e.forEach((s) => {
1720
+ if (s.length <= 1)
1721
+ return;
1722
+ t || (s = s.map((o) => o.map(String)).sort((o, l) => o.length - l.length));
1723
+ const [a, ...i] = s;
1724
+ a.length === 0 ? r = i.map(pn) : n[pn(a)] = i.map(pn);
1725
+ }), r ? Pn(n) ? [r] : [r, n] : Pn(n) ? void 0 : n;
1726
+ }
1727
+ var Wr = (e, t, n, r, s = [], a = [], i = /* @__PURE__ */ new Map()) => {
1728
+ const o = Pi(e);
1729
+ if (!o) {
1730
+ Mi(e, s, t);
1731
+ const A = i.get(e);
1732
+ if (A)
1733
+ return r ? {
1734
+ transformedValue: null
1735
+ } : A;
1736
+ }
1737
+ if (!Ri(e, n)) {
1738
+ const A = tr(e, n), E = A ? {
1739
+ transformedValue: A.value,
1740
+ annotations: [A.type]
1741
+ } : {
1742
+ transformedValue: e
1743
+ };
1744
+ return o || i.set(e, E), E;
1745
+ }
1746
+ if (zt(a, e))
1747
+ return {
1748
+ transformedValue: null
1749
+ };
1750
+ const l = tr(e, n), d = (l == null ? void 0 : l.value) ?? e, h = Re(d) ? [] : {}, g = {};
1751
+ ut(d, (A, E) => {
1752
+ if (E === "__proto__" || E === "constructor" || E === "prototype")
1753
+ throw new Error(`Detected property ${E}. This is a prototype pollution risk, please remove it from your object.`);
1754
+ const N = Wr(A, t, n, r, [...s, E], [...a, e], i);
1755
+ h[E] = N.transformedValue, Re(N.annotations) ? g[E] = N.annotations : wt(N.annotations) && ut(N.annotations, (y, Q) => {
1756
+ g[Rr(E) + "." + Q] = y;
1757
+ });
1758
+ });
1759
+ const v = Pn(g) ? {
1760
+ transformedValue: h,
1761
+ annotations: l ? [l.type] : void 0
1762
+ } : {
1763
+ transformedValue: h,
1764
+ annotations: l ? [l.type, g] : g
1765
+ };
1766
+ return o || i.set(e, v), v;
1767
+ };
1768
+ function zr(e) {
1769
+ return Object.prototype.toString.call(e).slice(8, -1);
1770
+ }
1771
+ function nr(e) {
1772
+ return zr(e) === "Array";
1773
+ }
1774
+ function Fi(e) {
1775
+ if (zr(e) !== "Object")
1776
+ return !1;
1777
+ const t = Object.getPrototypeOf(e);
1778
+ return !!t && t.constructor === Object && t === Object.prototype;
1779
+ }
1780
+ function ji(e, t, n, r, s) {
1781
+ const a = {}.propertyIsEnumerable.call(r, t) ? "enumerable" : "nonenumerable";
1782
+ a === "enumerable" && (e[t] = n), s && a === "nonenumerable" && Object.defineProperty(e, t, {
1783
+ value: n,
1784
+ enumerable: !1,
1785
+ writable: !0,
1786
+ configurable: !0
1787
+ });
1788
+ }
1789
+ function In(e, t = {}) {
1790
+ if (nr(e))
1791
+ return e.map((s) => In(s, t));
1792
+ if (!Fi(e))
1793
+ return e;
1794
+ const n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertySymbols(e);
1795
+ return [...n, ...r].reduce((s, a) => {
1796
+ if (nr(t.props) && !t.props.includes(a))
1797
+ return s;
1798
+ const i = e[a], o = In(i, t);
1799
+ return ji(s, a, o, e, t.nonenumerable), s;
1800
+ }, {});
1801
+ }
1802
+ var H = class {
1803
+ /**
1804
+ * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
1805
+ */
1806
+ constructor({ dedupe: e = !1 } = {}) {
1807
+ this.classRegistry = new gi(), this.symbolRegistry = new Dr((t) => t.description ?? ""), this.customTransformerRegistry = new Ei(), this.allowedErrorProps = [], this.dedupe = e;
1808
+ }
1809
+ serialize(e) {
1810
+ const t = /* @__PURE__ */ new Map(), n = Wr(e, t, this, this.dedupe), r = {
1811
+ json: n.transformedValue
1812
+ };
1813
+ n.annotations && (r.meta = {
1814
+ ...r.meta,
1815
+ values: n.annotations
1816
+ });
1817
+ const s = Bi(t, this.dedupe);
1818
+ return s && (r.meta = {
1819
+ ...r.meta,
1820
+ referentialEqualities: s
1821
+ }), r;
1822
+ }
1823
+ deserialize(e) {
1824
+ const { json: t, meta: n } = e;
1825
+ let r = In(t);
1826
+ return n != null && n.values && (r = Oi(r, n.values, this)), n != null && n.referentialEqualities && (r = Ui(r, n.referentialEqualities)), r;
1827
+ }
1828
+ stringify(e) {
1829
+ return JSON.stringify(this.serialize(e));
1830
+ }
1831
+ parse(e) {
1832
+ return this.deserialize(JSON.parse(e));
1833
+ }
1834
+ registerClass(e, t) {
1835
+ this.classRegistry.register(e, t);
1836
+ }
1837
+ registerSymbol(e, t) {
1838
+ this.symbolRegistry.register(e, t);
1839
+ }
1840
+ registerCustom(e, t) {
1841
+ this.customTransformerRegistry.register({
1842
+ name: t,
1843
+ ...e
1844
+ });
1845
+ }
1846
+ allowErrorProps(...e) {
1847
+ this.allowedErrorProps.push(...e);
1848
+ }
1849
+ };
1850
+ H.defaultInstance = new H();
1851
+ H.serialize = H.defaultInstance.serialize.bind(H.defaultInstance);
1852
+ H.deserialize = H.defaultInstance.deserialize.bind(H.defaultInstance);
1853
+ H.stringify = H.defaultInstance.stringify.bind(H.defaultInstance);
1854
+ H.parse = H.defaultInstance.parse.bind(H.defaultInstance);
1855
+ H.registerClass = H.defaultInstance.registerClass.bind(H.defaultInstance);
1856
+ H.registerSymbol = H.defaultInstance.registerSymbol.bind(H.defaultInstance);
1857
+ H.registerCustom = H.defaultInstance.registerCustom.bind(H.defaultInstance);
1858
+ H.allowErrorProps = H.defaultInstance.allowErrorProps.bind(H.defaultInstance);
1859
+ var Hi = H.serialize, ml = H.stringify;
1860
+ function yl(e) {
1861
+ return e.state.fetchStatus === "fetching" ? "fetching" : e.getObserversCount() ? e.state.fetchStatus === "paused" ? "paused" : e.isStale() ? "stale" : "fresh" : "inactive";
1862
+ }
1863
+ function El(e, t) {
1864
+ return `${e}${t.charAt(0).toUpperCase() + t.slice(1)}`;
1865
+ }
1866
+ function pl({
1867
+ queryState: e,
1868
+ observerCount: t,
1869
+ isStale: n
1870
+ }) {
1871
+ return e.fetchStatus === "fetching" ? "blue" : t ? e.fetchStatus === "paused" ? "purple" : n ? "yellow" : "green" : "gray";
1872
+ }
1873
+ function vl({
1874
+ status: e,
1875
+ isPaused: t
1876
+ }) {
1877
+ return t ? "purple" : e === "error" ? "red" : e === "pending" ? "yellow" : e === "success" ? "green" : "gray";
1878
+ }
1879
+ function Sl(e) {
1880
+ return e === "fresh" ? "green" : e === "stale" ? "yellow" : e === "paused" ? "purple" : e === "inactive" ? "gray" : "blue";
1881
+ }
1882
+ var Al = (e, t = !1) => {
1883
+ const {
1884
+ json: n
1885
+ } = Hi(e);
1886
+ return JSON.stringify(n, null, t ? 2 : void 0);
1887
+ }, qt = (e) => e.state.fetchStatus !== "idle" ? 0 : e.getObserversCount() ? e.isStale() ? 2 : 1 : 3, qi = (e, t) => e.queryHash.localeCompare(t.queryHash), $r = (e, t) => e.state.dataUpdatedAt < t.state.dataUpdatedAt ? 1 : -1, Ki = (e, t) => qt(e) === qt(t) ? $r(e, t) : qt(e) > qt(t) ? 1 : -1, wl = {
1888
+ status: Ki,
1889
+ "query hash": qi,
1890
+ "last updated": $r
1891
+ }, Kt = (e) => e.state.isPaused ? 0 : e.state.status === "error" ? 2 : e.state.status === "pending" ? 1 : 3, Qr = (e, t) => e.state.submittedAt < t.state.submittedAt ? 1 : -1, Vi = (e, t) => Kt(e) === Kt(t) ? Qr(e, t) : Kt(e) > Kt(t) ? 1 : -1, bl = {
1892
+ status: Vi,
1893
+ "last updated": Qr
1894
+ }, Tl = (e) => e * parseFloat(getComputedStyle(document.documentElement).fontSize), _l = () => {
1895
+ const [e, t] = J("dark");
1896
+ return Ia(() => {
1897
+ const n = window.matchMedia("(prefers-color-scheme: dark)");
1898
+ t(n.matches ? "dark" : "light");
1899
+ const r = (s) => {
1900
+ t(s.matches ? "dark" : "light");
1901
+ };
1902
+ n.addEventListener("change", r), vt(() => n.removeEventListener("change", r));
1903
+ }), e;
1904
+ }, Vt = (e, t, n) => {
1905
+ if (t.length === 0)
1906
+ return n;
1907
+ if (e instanceof Map) {
1908
+ const r = new Map(e);
1909
+ if (t.length === 1)
1910
+ return r.set(t[0], n), r;
1911
+ const [s, ...a] = t;
1912
+ return r.set(s, Vt(r.get(s), a, n)), r;
1913
+ }
1914
+ if (e instanceof Set) {
1915
+ const r = Vt(Array.from(e), t, n);
1916
+ return new Set(r);
1917
+ }
1918
+ if (Array.isArray(e)) {
1919
+ const r = [...e];
1920
+ if (t.length === 1)
1921
+ return r[t[0]] = n, r;
1922
+ const [s, ...a] = t;
1923
+ return r[s] = Vt(r[s], a, n), r;
1924
+ }
1925
+ if (e instanceof Object) {
1926
+ const r = {
1927
+ ...e
1928
+ };
1929
+ if (t.length === 1)
1930
+ return r[t[0]] = n, r;
1931
+ const [s, ...a] = t;
1932
+ return r[s] = Vt(r[s], a, n), r;
1933
+ }
1934
+ return e;
1935
+ }, Wt = (e, t) => {
1936
+ if (e instanceof Map) {
1937
+ const n = new Map(e);
1938
+ if (t.length === 1)
1939
+ return n.delete(t[0]), n;
1940
+ const [r, ...s] = t;
1941
+ return n.set(r, Wt(n.get(r), s)), n;
1942
+ }
1943
+ if (e instanceof Set) {
1944
+ const n = Wt(Array.from(e), t);
1945
+ return new Set(n);
1946
+ }
1947
+ if (Array.isArray(e)) {
1948
+ const n = [...e];
1949
+ if (t.length === 1)
1950
+ return n.filter((a, i) => i.toString() !== t[0]);
1951
+ const [r, ...s] = t;
1952
+ return n[r] = Wt(n[r], s), n;
1953
+ }
1954
+ if (e instanceof Object) {
1955
+ const n = {
1956
+ ...e
1957
+ };
1958
+ if (t.length === 1)
1959
+ return delete n[t[0]], n;
1960
+ const [r, ...s] = t;
1961
+ return n[r] = Wt(n[r], s), n;
1962
+ }
1963
+ return e;
1964
+ }, Yr = (e, t) => {
1965
+ if (!e || document.querySelector("#_goober") || (t == null ? void 0 : t.querySelector("#_goober")))
1966
+ return;
1967
+ const r = document.createElement("style"), s = document.createTextNode("");
1968
+ r.appendChild(s), r.id = "_goober", r.setAttribute("nonce", e), t ? t.appendChild(r) : document.head.appendChild(r);
1969
+ }, Qe, _t, Pt, Nt, Be, Ct, Ye, Xe, Ze, Je, et, tt, It, rr, Wi = (rr = class {
1970
+ constructor(e) {
1971
+ F(this, Qe);
1972
+ F(this, _t);
1973
+ F(this, Pt);
1974
+ F(this, Nt);
1975
+ F(this, Be, !1);
1976
+ F(this, Ct);
1977
+ F(this, Ye);
1978
+ F(this, Xe);
1979
+ F(this, Ze);
1980
+ F(this, Je);
1981
+ F(this, et);
1982
+ F(this, tt);
1983
+ F(this, It);
1984
+ const {
1985
+ client: t,
1986
+ queryFlavor: n,
1987
+ version: r,
1988
+ onlineManager: s,
1989
+ buttonPosition: a,
1990
+ position: i,
1991
+ initialIsOpen: o,
1992
+ errorTypes: l,
1993
+ styleNonce: d,
1994
+ shadowDOMTarget: h
1995
+ } = e;
1996
+ M(this, Qe, J(t)), M(this, Pt, n), M(this, Nt, r), M(this, _t, s), M(this, Ct, d), M(this, Ye, h), M(this, Xe, J(a)), M(this, Ze, J(i)), M(this, Je, J(o)), M(this, et, J(l));
1997
+ }
1998
+ setButtonPosition(e) {
1999
+ T(this, Xe)[1](e);
2000
+ }
2001
+ setPosition(e) {
2002
+ T(this, Ze)[1](e);
2003
+ }
2004
+ setInitialIsOpen(e) {
2005
+ T(this, Je)[1](e);
2006
+ }
2007
+ setErrorTypes(e) {
2008
+ T(this, et)[1](e);
2009
+ }
2010
+ setClient(e) {
2011
+ T(this, Qe)[1](e);
2012
+ }
2013
+ mount(e) {
2014
+ if (T(this, Be))
2015
+ throw new Error("Devtools is already mounted");
2016
+ const t = xr(() => {
2017
+ const n = this, [r] = T(this, Xe), [s] = T(this, Ze), [a] = T(this, Je), [i] = T(this, et), [o] = T(this, Qe);
2018
+ let l;
2019
+ return T(this, tt) ? l = T(this, tt) : (l = Ir(() => import("./HO4MOOFI-Cb3CTzDI.js")), M(this, tt, l)), Yr(T(this, Ct), T(this, Ye)), Nr(l, Cr({
2020
+ get queryFlavor() {
2021
+ return T(n, Pt);
2022
+ },
2023
+ get version() {
2024
+ return T(n, Nt);
2025
+ },
2026
+ get onlineManager() {
2027
+ return T(n, _t);
2028
+ },
2029
+ get shadowDOMTarget() {
2030
+ return T(n, Ye);
2031
+ }
2032
+ }, {
2033
+ get client() {
2034
+ return o();
2035
+ },
2036
+ get buttonPosition() {
2037
+ return r();
2038
+ },
2039
+ get position() {
2040
+ return s();
2041
+ },
2042
+ get initialIsOpen() {
2043
+ return a();
2044
+ },
2045
+ get errorTypes() {
2046
+ return i();
2047
+ }
2048
+ }));
2049
+ }, e);
2050
+ M(this, Be, !0), M(this, It, t);
2051
+ }
2052
+ unmount() {
2053
+ var e;
2054
+ if (!T(this, Be))
2055
+ throw new Error("Devtools is not mounted");
2056
+ (e = T(this, It)) == null || e.call(this), M(this, Be, !1);
2057
+ }
2058
+ }, Qe = new WeakMap(), _t = new WeakMap(), Pt = new WeakMap(), Nt = new WeakMap(), Be = new WeakMap(), Ct = new WeakMap(), Ye = new WeakMap(), Xe = new WeakMap(), Ze = new WeakMap(), Je = new WeakMap(), et = new WeakMap(), tt = new WeakMap(), It = new WeakMap(), rr), nt, Lt, xt, Gt, Fe, kt, rt, st, at, it, ot, lt, ct, Dt, sr, zi = (sr = class {
2059
+ constructor(e) {
2060
+ F(this, nt);
2061
+ F(this, Lt);
2062
+ F(this, xt);
2063
+ F(this, Gt);
2064
+ F(this, Fe, !1);
2065
+ F(this, kt);
2066
+ F(this, rt);
2067
+ F(this, st);
2068
+ F(this, at);
2069
+ F(this, it);
2070
+ F(this, ot);
2071
+ F(this, lt);
2072
+ F(this, ct);
2073
+ F(this, Dt);
2074
+ const {
2075
+ client: t,
2076
+ queryFlavor: n,
2077
+ version: r,
2078
+ onlineManager: s,
2079
+ buttonPosition: a,
2080
+ position: i,
2081
+ initialIsOpen: o,
2082
+ errorTypes: l,
2083
+ styleNonce: d,
2084
+ shadowDOMTarget: h,
2085
+ onClose: g
2086
+ } = e;
2087
+ M(this, nt, J(t)), M(this, xt, n), M(this, Gt, r), M(this, Lt, s), M(this, kt, d), M(this, rt, h), M(this, st, J(a)), M(this, at, J(i)), M(this, it, J(o)), M(this, ot, J(l)), M(this, lt, J(g));
2088
+ }
2089
+ setButtonPosition(e) {
2090
+ T(this, st)[1](e);
2091
+ }
2092
+ setPosition(e) {
2093
+ T(this, at)[1](e);
2094
+ }
2095
+ setInitialIsOpen(e) {
2096
+ T(this, it)[1](e);
2097
+ }
2098
+ setErrorTypes(e) {
2099
+ T(this, ot)[1](e);
2100
+ }
2101
+ setClient(e) {
2102
+ T(this, nt)[1](e);
2103
+ }
2104
+ setOnClose(e) {
2105
+ T(this, lt)[1](() => e);
2106
+ }
2107
+ mount(e) {
2108
+ if (T(this, Fe))
2109
+ throw new Error("Devtools is already mounted");
2110
+ const t = xr(() => {
2111
+ const n = this, [r] = T(this, st), [s] = T(this, at), [a] = T(this, it), [i] = T(this, ot), [o] = T(this, nt), [l] = T(this, lt);
2112
+ let d;
2113
+ return T(this, ct) ? d = T(this, ct) : (d = Ir(() => import("./HUY7CZI3-w0XnbOPP.js")), M(this, ct, d)), Yr(T(this, kt), T(this, rt)), Nr(d, Cr({
2114
+ get queryFlavor() {
2115
+ return T(n, xt);
2116
+ },
2117
+ get version() {
2118
+ return T(n, Gt);
2119
+ },
2120
+ get onlineManager() {
2121
+ return T(n, Lt);
2122
+ },
2123
+ get shadowDOMTarget() {
2124
+ return T(n, rt);
2125
+ }
2126
+ }, {
2127
+ get client() {
2128
+ return o();
2129
+ },
2130
+ get buttonPosition() {
2131
+ return r();
2132
+ },
2133
+ get position() {
2134
+ return s();
2135
+ },
2136
+ get initialIsOpen() {
2137
+ return a();
2138
+ },
2139
+ get errorTypes() {
2140
+ return i();
2141
+ },
2142
+ get onClose() {
2143
+ return l();
2144
+ }
2145
+ }));
2146
+ }, e);
2147
+ M(this, Fe, !0), M(this, Dt, t);
2148
+ }
2149
+ unmount() {
2150
+ var e;
2151
+ if (!T(this, Fe))
2152
+ throw new Error("Devtools is not mounted");
2153
+ (e = T(this, Dt)) == null || e.call(this), M(this, Fe, !1);
2154
+ }
2155
+ }, nt = new WeakMap(), Lt = new WeakMap(), xt = new WeakMap(), Gt = new WeakMap(), Fe = new WeakMap(), kt = new WeakMap(), rt = new WeakMap(), st = new WeakMap(), at = new WeakMap(), it = new WeakMap(), ot = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), Dt = new WeakMap(), sr);
2156
+ function $i(e) {
2157
+ const t = Ae(e.client), n = Z.useRef(null), {
2158
+ buttonPosition: r,
2159
+ position: s,
2160
+ initialIsOpen: a,
2161
+ errorTypes: i,
2162
+ styleNonce: o,
2163
+ shadowDOMTarget: l
2164
+ } = e, [d] = Z.useState(
2165
+ new Wi({
2166
+ client: t,
2167
+ queryFlavor: "React Query",
2168
+ version: "5",
2169
+ onlineManager: or,
2170
+ buttonPosition: r,
2171
+ position: s,
2172
+ initialIsOpen: a,
2173
+ errorTypes: i,
2174
+ styleNonce: o,
2175
+ shadowDOMTarget: l
2176
+ })
2177
+ );
2178
+ return Z.useEffect(() => {
2179
+ d.setClient(t);
2180
+ }, [t, d]), Z.useEffect(() => {
2181
+ r && d.setButtonPosition(r);
2182
+ }, [r, d]), Z.useEffect(() => {
2183
+ s && d.setPosition(s);
2184
+ }, [s, d]), Z.useEffect(() => {
2185
+ d.setInitialIsOpen(a || !1);
2186
+ }, [a, d]), Z.useEffect(() => {
2187
+ d.setErrorTypes(i || []);
2188
+ }, [i, d]), Z.useEffect(() => (n.current && d.mount(n.current), () => {
2189
+ d.unmount();
2190
+ }), [d]), /* @__PURE__ */ u("div", { className: "tsqd-parent-container", ref: n });
2191
+ }
2192
+ function Qi(e) {
2193
+ const t = Ae(e.client), n = Z.useRef(null), { errorTypes: r, styleNonce: s, shadowDOMTarget: a } = e, [i] = Z.useState(
2194
+ new zi({
2195
+ client: t,
2196
+ queryFlavor: "React Query",
2197
+ version: "5",
2198
+ onlineManager: or,
2199
+ buttonPosition: "bottom-left",
2200
+ position: "bottom",
2201
+ initialIsOpen: !0,
2202
+ errorTypes: r,
2203
+ styleNonce: s,
2204
+ shadowDOMTarget: a,
2205
+ onClose: e.onClose
2206
+ })
2207
+ );
2208
+ return Z.useEffect(() => {
2209
+ i.setClient(t);
2210
+ }, [t, i]), Z.useEffect(() => {
2211
+ i.setOnClose(e.onClose ?? (() => {
2212
+ }));
2213
+ }, [e.onClose, i]), Z.useEffect(() => {
2214
+ i.setErrorTypes(r || []);
2215
+ }, [r, i]), Z.useEffect(() => (n.current && i.mount(n.current), () => {
2216
+ i.unmount();
2217
+ }), [i]), /* @__PURE__ */ u(
2218
+ "div",
2219
+ {
2220
+ style: { height: "500px", ...e.style },
2221
+ className: "tsqd-parent-container",
2222
+ ref: n
2223
+ }
2224
+ );
2225
+ }
2226
+ var Yi = process.env.NODE_ENV !== "development" ? function() {
2227
+ return null;
2228
+ } : $i;
2229
+ process.env.NODE_ENV;
2230
+ const qe = {
2231
+ ab: "Abkhazian",
2232
+ aa: "Afar",
2233
+ af: "Afrikaans",
2234
+ ak: "Akan",
2235
+ sq: "Albanian",
2236
+ am: "Amharic",
2237
+ ar: "Arabic",
2238
+ an: "Aragonese",
2239
+ hy: "Armenian",
2240
+ as: "Assamese",
2241
+ av: "Avaric",
2242
+ ae: "Avestan",
2243
+ ay: "Aymara",
2244
+ az: "Azerbaijani",
2245
+ bm: "Bambara",
2246
+ ba: "Bashkir",
2247
+ eu: "Basque",
2248
+ be: "Belarusian",
2249
+ bn: "Bengali",
2250
+ bh: "Bihari",
2251
+ bi: "Bislama",
2252
+ bs: "Bosnian",
2253
+ br: "Breton",
2254
+ bg: "Bulgarian",
2255
+ my: "Burmese",
2256
+ ca: "Catalan",
2257
+ ch: "Chamorro",
2258
+ ce: "Chechen",
2259
+ ny: "Chichewa",
2260
+ zh: "Chinese",
2261
+ "zh-Hans": "Chinese (Simplified)",
2262
+ "zh-Hant": "Chinese (Traditional)",
2263
+ cv: "Chuvash",
2264
+ kw: "Cornish",
2265
+ co: "Corsican",
2266
+ cr: "Cree",
2267
+ hr: "Croatian",
2268
+ cs: "Czech",
2269
+ da: "Danish",
2270
+ dv: "Maldivian",
2271
+ nl: "Dutch",
2272
+ dz: "Dzongkha",
2273
+ en: "English",
2274
+ eo: "Esperanto",
2275
+ et: "Estonian",
2276
+ ee: "Ewe",
2277
+ fo: "Faroese",
2278
+ fj: "Fijian",
2279
+ fi: "Finnish",
2280
+ fr: "French",
2281
+ ff: "Fula, Pular",
2282
+ gl: "Galician",
2283
+ gd: "Gaelic (Scottish)",
2284
+ gv: "Manx",
2285
+ ka: "Georgian",
2286
+ de: "German",
2287
+ el: "Greek",
2288
+ kl: "Kalaallisut",
2289
+ gn: "Guarani",
2290
+ gu: "Gujarati",
2291
+ ht: "Haitian Creole",
2292
+ ha: "Hausa",
2293
+ he: "Hebrew",
2294
+ hz: "Herero",
2295
+ hi: "Hindi",
2296
+ ho: "Hiri Motu",
2297
+ hu: "Hungarian",
2298
+ is: "Icelandic",
2299
+ io: "Ido",
2300
+ ig: "Igbo",
2301
+ id: "Indonesian",
2302
+ ia: "Interlingua",
2303
+ ie: "Interlingue",
2304
+ iu: "Inuktitut",
2305
+ ik: "Inupiak",
2306
+ ga: "Irish",
2307
+ it: "Italian",
2308
+ ja: "Japanese",
2309
+ jv: "Javanese",
2310
+ kn: "Kannada",
2311
+ kr: "Kanuri",
2312
+ ks: "Kashmiri",
2313
+ kk: "Kazakh",
2314
+ km: "Khmer",
2315
+ ki: "Kikuyu",
2316
+ rw: "Kinyarwanda",
2317
+ rn: "Kirundi",
2318
+ ky: "Kyrgyz",
2319
+ kv: "Komi",
2320
+ kg: "Kongo",
2321
+ ko: "Korean",
2322
+ ku: "Kurdish",
2323
+ kj: "Kwanyama",
2324
+ lo: "Lao",
2325
+ la: "Latin",
2326
+ lv: "Latvian",
2327
+ li: "Limburgish",
2328
+ ln: "Lingala",
2329
+ lt: "Lithuanian",
2330
+ lu: "Luga-Katanga",
2331
+ lg: "Luganda, Ganda",
2332
+ lb: "Luxembourgish",
2333
+ mk: "Macedonian",
2334
+ mg: "Malagasy",
2335
+ ms: "Malay",
2336
+ ml: "Malayalam",
2337
+ mt: "Maltese",
2338
+ mi: "Maori",
2339
+ mr: "Marathi",
2340
+ mh: "Marshallese",
2341
+ mo: "Moldavian",
2342
+ mn: "Mongolian",
2343
+ na: "Nauru",
2344
+ nv: "Navajo",
2345
+ ng: "Ndonga",
2346
+ nd: "Northern Ndebele",
2347
+ ne: "Nepali",
2348
+ no: "Norwegian",
2349
+ nb: "Norwegian bokmål",
2350
+ nn: "Norwegian nynorsk",
2351
+ ii: "Sichuan Yi",
2352
+ oc: "Occitan",
2353
+ oj: "Ojibwe",
2354
+ cu: "Old Church Slavonic",
2355
+ or: "Oriya",
2356
+ om: "Oromo",
2357
+ os: "Ossetian",
2358
+ pi: "Pāli",
2359
+ ps: "Pashto, Pushto",
2360
+ fa: "Persian (Farsi)",
2361
+ pl: "Polish",
2362
+ pt: "Portuguese",
2363
+ pa: "Punjabi (Eastern)",
2364
+ qu: "Quechua",
2365
+ rm: "Romansh",
2366
+ ro: "Romanian",
2367
+ ru: "Russian",
2368
+ se: "Sami",
2369
+ sm: "Samoan",
2370
+ sg: "Sango",
2371
+ sa: "Sanskrit",
2372
+ sr: "Serbian",
2373
+ sh: "Serbo-Croatian",
2374
+ st: "Sesotho",
2375
+ tn: "Setswana",
2376
+ sn: "Shona",
2377
+ sd: "Sindhi",
2378
+ si: "Sinhalese",
2379
+ ss: "Swati",
2380
+ sk: "Slovak",
2381
+ sl: "Slovenian",
2382
+ so: "Somali",
2383
+ nr: "Southern Ndebele",
2384
+ es: "Spanish",
2385
+ su: "Sundanese",
2386
+ sw: "Swahili (Kiswahili)",
2387
+ sv: "Swedish",
2388
+ tl: "Tagalog",
2389
+ ty: "Tahitian",
2390
+ tg: "Tajik",
2391
+ ta: "Tamil",
2392
+ tt: "Tatar",
2393
+ te: "Telugu",
2394
+ th: "Thai",
2395
+ bo: "Tibetan",
2396
+ ti: "Tigrinya",
2397
+ to: "Tonga",
2398
+ ts: "Tsonga",
2399
+ tr: "Turkish",
2400
+ tk: "Turkmen",
2401
+ tw: "Twi",
2402
+ ug: "Uyghur",
2403
+ uk: "Ukrainian",
2404
+ ur: "Urdu",
2405
+ uz: "Uzbek",
2406
+ ve: "Venda",
2407
+ vi: "Vietnamese",
2408
+ vo: "Volapük",
2409
+ wa: "Wallon",
2410
+ cy: "Welsh",
2411
+ wo: "Wolof",
2412
+ fy: "Western Frisian",
2413
+ xh: "Xhosa",
2414
+ yi: "Yiddish",
2415
+ yo: "Yoruba",
2416
+ za: "Zhuang, Chuang",
2417
+ zu: "Zulu"
2418
+ };
2419
+ function ke() {
2420
+ const [e, t] = ge(
2421
+ new URLSearchParams(window.location.search)
2422
+ );
2423
+ return Ut(() => {
2424
+ const n = () => {
2425
+ t(new URLSearchParams(window.location.search));
2426
+ };
2427
+ return window.addEventListener("popstate", n), () => {
2428
+ window.removeEventListener("popstate", n);
2429
+ };
2430
+ }, []), [e, t];
2431
+ }
2432
+ const P = {
2433
+ ASK_AI: "ASK_AI",
2434
+ GET_PAGE: "GET_PAGE",
2435
+ CREATE_PAGE: "CREATE_PAGE",
2436
+ UPDATE_PAGE: "UPDATE_PAGE",
2437
+ DELETE_PAGE: "DELETE_PAGE",
2438
+ CHANGE_SLUG: "CHANGE_SLUG",
2439
+ TAKE_OFFLINE: "TAKE_OFFLINE",
2440
+ PUBLISH_PAGE: "PUBLISH_PAGE",
2441
+ PUBLISH_CHANGES: "PUBLISH_CHANGES",
2442
+ ADD_NEW_LANGUAGE: "ADD_NEW_LANGUAGE",
2443
+ EDIT_LANGUAGE: "EDIT_LANGUAGE",
2444
+ DELETE_LANGUAGE: "DELETE_LANGUAGE",
2445
+ GET_CHANGES: "GET_CHANGES",
2446
+ GET_SERVER_BLOCK: "GET_SERVER_BLOCK",
2447
+ GET_LANGUAGE_PAGES: "GET_LANGUAGE_PAGES",
2448
+ GET_PROJECT_PAGES: "GET_PROJECT_PAGES",
2449
+ GET_WEBSITE_PAGES: "GET_WEBSITE_PAGES",
2450
+ UPDATE_WEBSITE_SETTINGS: "UPDATE_WEBSITE_SETTINGS",
2451
+ GET_COLLECTIONS: "GET_COLLECTIONS",
2452
+ GET_PAGE_TYPES: "GET_PAGE_TYPES",
2453
+ SEARCH_PAGES: "SEARCH_PAGES",
2454
+ GET_WEBSITE_SETTINGS: "GET_WEBSITE_SETTINGS",
2455
+ AI_CONTEXT: "AI_CONTEXT",
2456
+ GET_WEBSITE_DATA: "GET_WEBSITE_DATA",
2457
+ UPDATE_WEBSITE_DATA: "UPDATE_WEBSITE_DATA",
2458
+ GET_CHAI_USER: "GET_CHAI_USER",
2459
+ RELEASE_LOCK: "RELEASE_LOCK",
2460
+ GET_SEO_FIELDS: "GET_SEO_FIELDS",
2461
+ GET_BUILDER_PAGE_DATA: "GET_BUILDER_PAGE_DATA",
2462
+ GET_PAGE_REVISIONS: "GET_PAGE_REVISIONS",
2463
+ DELETE_PAGE_REVISION: "DELETE_PAGE_REVISION",
2464
+ RESTORE_PAGE_REVISION: "RESTORE_PAGE_REVISION",
2465
+ GET_ROLE_AND_PERMISSIONS: "GET_ROLE_AND_PERMISSIONS",
2466
+ UPSERT_LIBRARY_ITEM: "UPSERT_LIBRARY_ITEM",
2467
+ GET_LIBRARIES: "GET_LIBRARIES",
2468
+ GET_LIBRARY_ITEM: "GET_LIBRARY_ITEM",
2469
+ GET_LIBRARY_ITEMS: "GET_LIBRARY_ITEMS"
2470
+ }, Xr = async (e, t, n = {}) => await fetch(e, {
2471
+ method: "POST",
2472
+ headers: {
2473
+ "Content-Type": "application/json",
2474
+ ...n
2475
+ },
2476
+ body: JSON.stringify(t)
2477
+ });
2478
+ if (import.meta.vitest) {
2479
+ const { it: e, expect: t } = import.meta.vitest;
2480
+ e("should fetch API", async () => {
2481
+ const n = await Xr("/v1/api/chai", {
2482
+ action: "test"
2483
+ });
2484
+ t(n).toBeDefined();
2485
+ });
2486
+ }
2487
+ const Pl = () => {
2488
+ const e = Ke("user"), t = Ke("onSessionExpired"), n = me(() => e == null ? void 0 : e.authToken, [e == null ? void 0 : e.authToken]);
2489
+ return Ue(
2490
+ async (r, s, a = {}) => {
2491
+ if (n)
2492
+ try {
2493
+ const i = await fetch(r, {
2494
+ method: "POST",
2495
+ body: s,
2496
+ headers: {
2497
+ ...a,
2498
+ Authorization: `Bearer ${n}`,
2499
+ "x-chai-upload": "true"
2500
+ }
2501
+ });
2502
+ if (i.status === 401)
2503
+ throw console.log("session expired", s, i), t(), new Error("Session expired");
2504
+ if (i.status === 400)
2505
+ throw console.log("Something went wrong", s, i), new Error((await i.json()).error);
2506
+ return await i.json();
2507
+ } catch (i) {
2508
+ throw console.log("Something went wrong", s, i), i;
2509
+ }
2510
+ },
2511
+ [n, t]
2512
+ );
2513
+ }, ee = () => {
2514
+ const e = Ke("user"), t = Ke("onSessionExpired"), n = me(() => e == null ? void 0 : e.authToken, [e == null ? void 0 : e.authToken]);
2515
+ return Ue(
2516
+ async (r, s, a = {}) => {
2517
+ if (n)
2518
+ try {
2519
+ const i = ae(s, "action", "").toLowerCase(), o = await Xr(
2520
+ r + (i ? `?action=${i}` : ""),
2521
+ s,
2522
+ {
2523
+ ...a,
2524
+ Authorization: `Bearer ${n}`
2525
+ }
2526
+ );
2527
+ if (o.status === 401)
2528
+ throw console.log("session expired", s, o), t(), new Error("Session expired");
2529
+ if (o.status === 400)
2530
+ throw console.log("Something went wrong", s, o), new Error((await o.json()).error);
2531
+ return await o.json();
2532
+ } catch (i) {
2533
+ throw console.log("Something went wrong", s, i), i;
2534
+ }
2535
+ },
2536
+ [n, t]
2537
+ );
2538
+ }, Zr = () => {
2539
+ const e = te(), t = Ae(), n = ee();
2540
+ return xe({
2541
+ mutationFn: async (r) => n(e, { action: P.RELEASE_LOCK, data: r }),
2542
+ onSuccess: (r, s) => {
2543
+ t.invalidateQueries({
2544
+ queryKey: [P.GET_PAGE, s.id ?? ""]
2545
+ });
2546
+ }
2547
+ });
2548
+ }, Jr = () => {
2549
+ const e = te(), t = Ae(), n = ee();
2550
+ return xe({
2551
+ mutationFn: async (r) => n(e, {
2552
+ action: P.UPDATE_WEBSITE_SETTINGS,
2553
+ data: r
2554
+ }),
2555
+ onSuccess: (r, s) => {
2556
+ var a;
2557
+ t.invalidateQueries({
2558
+ queryKey: [P.GET_WEBSITE_SETTINGS]
2559
+ }), (a = s == null ? void 0 : s.settings) != null && a.theme || Ee.success("Website settings updated successfully.");
2560
+ },
2561
+ onError: (r) => {
2562
+ Ee.error("Failed to update website settings", {
2563
+ description: r.message
2564
+ });
2565
+ }
2566
+ });
2567
+ }, Xi = Gn({}), es = () => kn(Xi), Zi = () => {
2568
+ const [e] = ke(), t = e.get("page"), n = $t(""), { mutate: r } = Zr();
2569
+ Ut(() => {
2570
+ !Ie(n.current) && t !== n.current && r({ id: n.current }), n.current = t;
2571
+ }, [t, r, n]);
2572
+ }, Ke = (e, t) => {
2573
+ const [n] = es();
2574
+ return ae(n, e, t);
2575
+ }, te = () => Ke("apiUrl", "/chai/api"), ts = () => {
2576
+ const e = ee(), t = te();
2577
+ return Pe({
2578
+ queryKey: [P.GET_WEBSITE_PAGES],
2579
+ staleTime: 1e3 * 60 * 5,
2580
+ queryFn: async () => e(t, { action: P.GET_WEBSITE_PAGES }) || []
2581
+ });
2582
+ }, Ji = Gn({ lastSaved: void 0 }), ns = () => kn(Ji), ft = () => {
2583
+ const [e] = ke(), t = e.get("page"), { data: n, isFetching: r } = ts();
2584
+ return { data: me(
2585
+ () => Se(n, { id: t }) || {},
2586
+ [n, t]
2587
+ ), isFetching: r };
2588
+ }, On = () => {
2589
+ const e = te(), [t] = ke(), n = t.get("page"), r = ee();
2590
+ return Pe({
2591
+ queryKey: [P.GET_LANGUAGE_PAGES, n],
2592
+ initialData: [],
2593
+ queryFn: async () => {
2594
+ if (!n) return null;
2595
+ const s = await r(e, {
2596
+ action: P.GET_LANGUAGE_PAGES,
2597
+ data: { id: n }
2598
+ });
2599
+ return Ps(Ns(s, "primaryPage"));
2600
+ },
2601
+ enabled: !!n
2602
+ });
2603
+ }, fn = () => {
2604
+ const e = te(), t = ee();
2605
+ return Pe({
2606
+ queryKey: [P.GET_WEBSITE_SETTINGS],
2607
+ initialData: {
2608
+ theme: {},
2609
+ fallbackLang: "en",
2610
+ languages: []
2611
+ },
2612
+ queryFn: async () => t(e, {
2613
+ action: P.GET_WEBSITE_SETTINGS,
2614
+ data: { draft: !0 }
2615
+ })
2616
+ });
2617
+ }, z = {
2618
+ PREVIEW: "Preview",
2619
+ THEME: "Theme",
2620
+ SAVEDRAFT: "Save draft",
2621
+ SAVING: "Saving",
2622
+ SAVED: "Saved",
2623
+ PUBLISHED: "Published",
2624
+ PUBLISH: "Publish",
2625
+ UNPUBLISH: "Unpublish",
2626
+ WEBSITEDATA: "Website data",
2627
+ OPEN: "Open",
2628
+ EDIT_LANGUAGE: "Edit language",
2629
+ ADD_NEW_LANGUAGE: "Add New language",
2630
+ ENTER_LANGUAGE_DETAILS: "Enter the details for the language",
2631
+ LANGUAGE: "Language",
2632
+ PAGE_NAME: "Page Name",
2633
+ SLUG: "Slug",
2634
+ UPDATE: "Update",
2635
+ UPDATING: "Updating...",
2636
+ ADDING: "Adding...",
2637
+ CHOOSE_LANGUAGE: "Choose language",
2638
+ ALL_AVAILABLE_LANGUAGE_PAGE: "All available language page is created.",
2639
+ TO_UPDATE_SLUG: "To update slug use 'Change slug' action",
2640
+ SLUG_SHOULD_START_WITH: " (Slug should start with /{lang})",
2641
+ CHOOSE_LANGUAGE_TO_ADD_SLUG: "Choose language to add slug",
2642
+ ENTER_PAGE_SLUG: "Enter page slug",
2643
+ ENTER_PAGE_NAME: "Enter page name",
2644
+ DELETE: "Delete",
2645
+ CHANGE_SLUG: "Change slug",
2646
+ PRIMARY: "Primary",
2647
+ SLUG_MUST_START_WITH: "Slug must start with /",
2648
+ EDIT: "Edit",
2649
+ UNPUBLISH_MSG: "Are you sure you want to unpublish",
2650
+ SAVE_AS_TEMPLATE: "Save as template",
2651
+ // * TOAST SUCCESS
2652
+ PAGE_ADD_SUCCESS: "New page added successfully.",
2653
+ GLOBAL_BLOCK_ADD_SUCCESS: "New global block added successfully.",
2654
+ SEO_SETTINGS_UPDATE_SUCCESS: "SEO Settings updated successfully.",
2655
+ PAGE_UPDATE_SUCCESS: "Page updated successfully.",
2656
+ GLOBAL_BLOCK_UPDATE_SUCCESS: "Global block updated successfully.",
2657
+ PAGE_DELETE_SUCCESS: "Page deleted successfully.",
2658
+ GLOBAL_BLOCK_DELETE_SUCCESS: "Global block deleted successfully.",
2659
+ PAGE_UNPUBLISH_SUCCESS: "Page unpublished successfully.",
2660
+ GLOBAL_BLOCK_UNPUBLISH_SUCCESS: "Global block unpublished successfully.",
2661
+ PAGE_PUBLISH_SUCCESS: "Page published successfully.",
2662
+ GLOBAL_BLOCK_PUBLISH_SUCCESS: "Global block published successfully.",
2663
+ PAGES_PUBLISH_SUCCESS: "Your changes have been published successfully.",
2664
+ SLUG_CHANGE_SUCCESS: "Slug changed successfully."
2665
+ }, Oe = {
2666
+ ...ps,
2667
+ //pages
2668
+ ADD_PAGE: "add_page",
2669
+ EDIT_PAGE: "edit_page",
2670
+ EDIT_SLUG: "edit_slug",
2671
+ DELETE_PAGE: "delete_page",
2672
+ PUBLISH_PAGE: "publish_page",
2673
+ UNPUBLISH_PAGE: "unpublish_page",
2674
+ SAVE_AS_TEMPLATE: "save_as_template",
2675
+ //PARTIALS
2676
+ ADD_PARTIAL: "add_partial",
2677
+ EDIT_PARTIAL: "edit_partial",
2678
+ DELETE_PARTIAL: "delete_partial",
2679
+ PUBLISH_PARTIAL: "publish_partial",
2680
+ UNPUBLISH_PARTIAL: "unpublish_partial",
2681
+ //SEO
2682
+ EDIT_SEO: "edit_seo",
2683
+ // revisions
2684
+ RESTORE_REVISION: "restore_revision",
2685
+ DELETE_REVISION: "delete_revision",
2686
+ //theme
2687
+ PUBLISH_THEME: "publish_theme",
2688
+ EDIT_SETTINGS: "edit_settings",
2689
+ // library and templates
2690
+ ADD_LIBRARY_BLOCK: "add_library_block",
2691
+ ADD_LIBRARY_TEMPLATE: "add_library_template",
2692
+ EDIT_LIBRARY_BLOCK: "edit_library_block",
2693
+ EDIT_LIBRARY_TEMPLATE: "edit_library_template",
2694
+ DELETE_LIBRARY_BLOCK: "delete_library_block",
2695
+ DELETE_LIBRARY_TEMPLATE: "delete_library_template",
2696
+ //media
2697
+ ADD_MEDIA: "add_media",
2698
+ EDIT_MEDIA: "edit_media",
2699
+ DELETE_MEDIA: "delete_media"
2700
+ }, eo = {
2701
+ SLUG_ALREADY_USED: "This slug is already in use. Please choose a different one."
2702
+ }, De = () => {
2703
+ const e = te(), t = ee();
2704
+ return Pe({
2705
+ queryKey: [P.GET_PAGE_TYPES],
2706
+ initialData: [],
2707
+ queryFn: async () => t(e, { action: P.GET_PAGE_TYPES })
2708
+ });
2709
+ }, to = (e) => {
2710
+ const { data: t } = De();
2711
+ return me(
2712
+ () => t == null ? void 0 : t.find((n) => n.key === e),
2713
+ [t, e]
2714
+ );
2715
+ }, no = () => {
2716
+ const e = te(), t = ee();
2717
+ return xe({
2718
+ mutationFn: async ({ pageType: n, query: r }) => {
2719
+ try {
2720
+ return t(e, {
2721
+ action: P.SEARCH_PAGES,
2722
+ data: {
2723
+ pageType: n,
2724
+ query: Array.isArray(r) && r.length > 0 ? r[0] : r
2725
+ }
2726
+ }) || [];
2727
+ } catch (s) {
2728
+ return console.error(s), [];
2729
+ }
2730
+ }
2731
+ });
2732
+ }, ro = () => {
2733
+ const e = te(), t = Ae(), n = ee(), { data: r } = De();
2734
+ return xe({
2735
+ mutationFn: async (s) => n(e, { action: P.CREATE_PAGE, data: s }),
2736
+ onSuccess: (s, a) => {
2737
+ a && (a != null && a.primaryPage) ? t.invalidateQueries({
2738
+ queryKey: [P.GET_LANGUAGE_PAGES, a == null ? void 0 : a.primaryPage]
2739
+ }) : t.invalidateQueries({
2740
+ queryKey: [P.GET_WEBSITE_PAGES]
2741
+ });
2742
+ },
2743
+ onError: (s, a) => {
2744
+ const i = Se(r, { key: a.pageType });
2745
+ Ee.error(
2746
+ `Failed to add new ${i != null && i.hasSlug ? "page" : i.name}.`,
2747
+ {
2748
+ description: ae(eo, s.message, s.message)
2749
+ }
2750
+ );
2751
+ }
2752
+ });
2753
+ }, rs = () => {
2754
+ const e = te(), t = Ae(), n = ee(), { data: r } = De();
2755
+ return xe({
2756
+ mutationFn: async (s) => await n(e, {
2757
+ action: P.UPDATE_PAGE,
2758
+ data: s
2759
+ }),
2760
+ onSuccess: (s, a) => {
2761
+ a && (a != null && a.primaryPage || a != null && a.seo) ? t.invalidateQueries({
2762
+ queryKey: [P.GET_LANGUAGE_PAGES, a == null ? void 0 : a.primaryPage]
2763
+ }) : t.invalidateQueries({
2764
+ queryKey: [P.GET_WEBSITE_PAGES]
2765
+ });
2766
+ },
2767
+ onError: (s, a) => {
2768
+ const i = Se(r, { key: a.pageType });
2769
+ Ee.error(
2770
+ `Failed to update ${i != null && i.hasSlug ? "page" : i.name}.`,
2771
+ {
2772
+ description: s.message
2773
+ }
2774
+ );
2775
+ }
2776
+ });
2777
+ }, so = () => {
2778
+ const e = te(), t = Ae(), n = ee(), { data: r } = De();
2779
+ return xe({
2780
+ mutationFn: async (s) => n(e, {
2781
+ action: P.DELETE_PAGE,
2782
+ data: { id: s == null ? void 0 : s.id }
2783
+ }),
2784
+ onSuccess: (s, a) => {
2785
+ if (s.code === "PAGE_LOCKED") {
2786
+ Ee.error("Delete not allowed", {
2787
+ description: "Page is currently being edited by another user."
2788
+ });
2789
+ return;
2790
+ }
2791
+ a && (a != null && a.primaryPage) ? t.invalidateQueries({
2792
+ queryKey: [P.GET_LANGUAGE_PAGES, a == null ? void 0 : a.primaryPage]
2793
+ }) : t.invalidateQueries({
2794
+ queryKey: [P.GET_WEBSITE_PAGES]
2795
+ });
2796
+ },
2797
+ onError: (s, a) => {
2798
+ const i = Se(r, { key: a.pageType });
2799
+ Ee.error(
2800
+ `Failed to delete ${i != null && i.hasSlug ? "page" : i.name}.`,
2801
+ {
2802
+ description: s.message
2803
+ }
2804
+ );
2805
+ }
2806
+ });
2807
+ }, ao = () => {
2808
+ const e = te(), t = Ae(), n = ee(), { data: r } = De();
2809
+ return xe({
2810
+ mutationFn: async (s) => n(e, {
2811
+ action: P.TAKE_OFFLINE,
2812
+ data: { id: s == null ? void 0 : s.id }
2813
+ }),
2814
+ onSuccess: (s, a) => {
2815
+ a && (a != null && a.primaryPage) ? t.invalidateQueries({
2816
+ queryKey: [P.GET_LANGUAGE_PAGES, a == null ? void 0 : a.primaryPage]
2817
+ }) : t.invalidateQueries({
2818
+ queryKey: [P.GET_WEBSITE_PAGES]
2819
+ });
2820
+ const i = Se(r, { key: a.pageType });
2821
+ Ee.success(
2822
+ i != null && i.hasSlug ? z.PAGE_UNPUBLISH_SUCCESS : "New " + i.name + " added successfully."
2823
+ );
2824
+ },
2825
+ onError: (s, a) => {
2826
+ const i = Se(r, { key: a.pageType });
2827
+ Ee.error(
2828
+ `Failed to take offline ${i != null && i.hasSlug ? "page" : i.name}.`,
2829
+ {
2830
+ description: s.message
2831
+ }
2832
+ );
2833
+ }
2834
+ });
2835
+ }, io = () => {
2836
+ const e = te(), t = ee(), n = Ae(), { data: r } = ft();
2837
+ return xe({
2838
+ mutationFn: async ({ ids: s }) => t(e, {
2839
+ action: P.PUBLISH_CHANGES,
2840
+ data: { ids: s }
2841
+ }),
2842
+ onSuccess: () => {
2843
+ n.invalidateQueries({ queryKey: [P.GET_CHANGES] }), n.invalidateQueries({ queryKey: [P.GET_WEBSITE_PAGES] }), n.invalidateQueries({
2844
+ queryKey: [P.GET_LANGUAGE_PAGES, r == null ? void 0 : r.id]
2845
+ });
2846
+ },
2847
+ onError: () => {
2848
+ Ee.error("Failed to publish pages.");
2849
+ }
2850
+ });
2851
+ }, oo = () => {
2852
+ const e = te(), t = ee(), n = Ae();
2853
+ return xe({
2854
+ mutationFn: async ({ id: r, slug: s }) => t(e, {
2855
+ action: P.CHANGE_SLUG,
2856
+ data: { id: r, slug: s }
2857
+ }),
2858
+ onSuccess: (r, { primaryPage: s }) => {
2859
+ Ee.success(z.SLUG_CHANGE_SUCCESS), s ? n.invalidateQueries({
2860
+ queryKey: [P.GET_LANGUAGE_PAGES, s]
2861
+ }) : n.invalidateQueries({
2862
+ queryKey: [P.GET_WEBSITE_PAGES]
2863
+ });
2864
+ },
2865
+ onError: () => {
2866
+ Ee.error("Failed to change slug");
2867
+ }
2868
+ });
2869
+ }, lo = ({
2870
+ page: e,
2871
+ onClose: t
2872
+ }) => {
2873
+ const [n, r] = ge(e.slug || ""), { mutate: s, isPending: a } = oo(), { data: i } = De(), o = Se(i, { key: e == null ? void 0 : e.pageType }), l = (h) => {
2874
+ if (h.preventDefault(), !(e != null && e.primaryPage) && Object.keys(qe).some((A) => n === `/${A}` || yt(n, `/${A}/`))) {
2875
+ Ee.error("Error", {
2876
+ description: "Slugs cannot start with a language code for primary page"
2877
+ });
2878
+ return;
2879
+ }
2880
+ s({ ...e, slug: n }, { onSuccess: t });
2881
+ }, d = (e == null ? void 0 : e.lang) || "";
2882
+ return /* @__PURE__ */ u(nn, { open: !!e, onOpenChange: t, children: /* @__PURE__ */ m(rn, { children: [
2883
+ /* @__PURE__ */ m(sn, { children: [
2884
+ /* @__PURE__ */ u(an, { children: "Change Slug" }),
2885
+ /* @__PURE__ */ u(on, { className: "text-xs", children: /* @__PURE__ */ m(dr, { variant: "destructive", className: "mt-2", children: [
2886
+ /* @__PURE__ */ u(Ms, { className: "h-4 w-4" }),
2887
+ "Changing the slug may have impact on your SEO. Please proceed with caution."
2888
+ ] }) })
2889
+ ] }),
2890
+ /* @__PURE__ */ m("form", { onSubmit: l, children: [
2891
+ /* @__PURE__ */ m("div", { className: "space-y-4 py-4 text-sm ", children: [
2892
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
2893
+ /* @__PURE__ */ m("div", { children: [
2894
+ /* @__PURE__ */ u("span", { children: "Type:" }),
2895
+ /* @__PURE__ */ m("span", { className: "font-medium text-gray-600", children: [
2896
+ " ",
2897
+ (o == null ? void 0 : o.name) || (e == null ? void 0 : e.pageType)
2898
+ ] })
2899
+ ] }),
2900
+ /* @__PURE__ */ m("div", { children: [
2901
+ /* @__PURE__ */ u("span", { children: "Name:" }),
2902
+ /* @__PURE__ */ m("span", { className: "font-medium text-gray-600", children: [
2903
+ " ",
2904
+ e.name
2905
+ ] })
2906
+ ] })
2907
+ ] }),
2908
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
2909
+ /* @__PURE__ */ m(ue, { htmlFor: "slug", className: "text-right", children: [
2910
+ "Slug",
2911
+ " ",
2912
+ /* @__PURE__ */ m("small", { className: "font-light text-gray-500", children: [
2913
+ "Slug should start with /",
2914
+ d
2915
+ ] })
2916
+ ] }),
2917
+ /* @__PURE__ */ u(
2918
+ Te,
2919
+ {
2920
+ id: "slug",
2921
+ value: n,
2922
+ onChange: (h) => {
2923
+ const g = h.target.value;
2924
+ yt(g, `/${d}`) && r(g);
2925
+ },
2926
+ className: "col-span-3",
2927
+ required: !0,
2928
+ pattern: "^/.*",
2929
+ title: "Slug must start with /",
2930
+ placeholder: "Enter page slug"
2931
+ }
2932
+ )
2933
+ ] })
2934
+ ] }),
2935
+ /* @__PURE__ */ u(ln, { children: /* @__PURE__ */ u(
2936
+ re,
2937
+ {
2938
+ type: "submit",
2939
+ disabled: a || !yt(n, `/${d}`) || Ln(e == null ? void 0 : e.slug, n),
2940
+ children: a ? "Changing..." : "Change Slug"
2941
+ }
2942
+ ) })
2943
+ ] })
2944
+ ] }) });
2945
+ };
2946
+ function co({
2947
+ page: e,
2948
+ onClose: t
2949
+ }) {
2950
+ const [, n] = ke(), { mutate: r, isPending: s } = so(), { data: a } = De(), i = () => {
2951
+ r(e, {
2952
+ onSuccess: () => {
2953
+ e != null && e.primaryPage || (window.history.replaceState(null, "", "/"), n(new URLSearchParams({})), window.dispatchEvent(new PopStateEvent("popstate"))), t();
2954
+ }
2955
+ });
2956
+ }, o = a == null ? void 0 : a.find(
2957
+ (l) => l.key === (e == null ? void 0 : e.pageType)
2958
+ );
2959
+ return /* @__PURE__ */ u(nn, { open: !!e, onOpenChange: t, children: /* @__PURE__ */ m(rn, { children: [
2960
+ /* @__PURE__ */ m(sn, { children: [
2961
+ /* @__PURE__ */ u(an, { children: "Confirm Deletion" }),
2962
+ /* @__PURE__ */ m(on, { className: "py-4 text-slate-500", children: [
2963
+ /* @__PURE__ */ m("div", { children: [
2964
+ "Are you sure you want to remove ",
2965
+ /* @__PURE__ */ u("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
2966
+ " ",
2967
+ o != null && o.hasSlug ? (o == null ? void 0 : o.name) + "?" : `page? ${e != null && e.primaryPage ? "" : "This will also delete all associated language pages."}`
2968
+ ] }),
2969
+ e.lang && /* @__PURE__ */ m("div", { className: "py-2 text-sm", children: [
2970
+ "Language:",
2971
+ " ",
2972
+ /* @__PURE__ */ u("span", { className: "font-medium text-gray-500", children: ae(qe, e.lang, e.lang) })
2973
+ ] })
2974
+ ] })
2975
+ ] }),
2976
+ /* @__PURE__ */ m(ln, { children: [
2977
+ /* @__PURE__ */ u(re, { variant: "outline", onClick: t, children: "Cancel" }),
2978
+ /* @__PURE__ */ u(
2979
+ re,
2980
+ {
2981
+ variant: "destructive",
2982
+ disabled: s,
2983
+ onClick: i,
2984
+ children: s ? "Deleting..." : "Delete"
2985
+ }
2986
+ )
2987
+ ] })
2988
+ ] }) });
2989
+ }
2990
+ const gt = ({
2991
+ permission: e,
2992
+ permissions: t,
2993
+ children: n,
2994
+ fallback: r = null
2995
+ }) => {
2996
+ const { hasPermission: s } = ir();
2997
+ return e && !s(e) || t && !t.some((a) => s(a)) ? r : n;
2998
+ }, uo = ({
2999
+ page: e,
3000
+ onClose: t
3001
+ }) => {
3002
+ const { mutate: n, isPending: r } = ao(), s = async () => {
3003
+ n(e, { onSuccess: t });
3004
+ };
3005
+ return /* @__PURE__ */ u(nn, { open: !!e, onOpenChange: t, children: /* @__PURE__ */ m(rn, { children: [
3006
+ /* @__PURE__ */ m(sn, { children: [
3007
+ /* @__PURE__ */ u(an, { children: "Confirm action" }),
3008
+ /* @__PURE__ */ m(on, { children: [
3009
+ z.UNPUBLISH_MSG,
3010
+ " ",
3011
+ /* @__PURE__ */ u("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
3012
+ "?"
3013
+ ] })
3014
+ ] }),
3015
+ /* @__PURE__ */ m(ln, { children: [
3016
+ /* @__PURE__ */ u(re, { variant: "outline", onClick: t, children: "Cancel" }),
3017
+ /* @__PURE__ */ u(
3018
+ re,
3019
+ {
3020
+ variant: "destructive",
3021
+ disabled: r,
3022
+ onClick: s,
3023
+ children: r ? z.UPDATING : z.UNPUBLISH
3024
+ }
3025
+ )
3026
+ ] })
3027
+ ] }) });
3028
+ }, fo = ({
3029
+ langProps: e,
3030
+ onClose: t,
3031
+ languages: n
3032
+ }) => {
3033
+ const { data: r } = ft(), { data: s } = De(), [a, i] = ge(e.name || ""), [o, l] = ge(e.edit ? e.lang : ""), [d, h] = ge(e.edit ? e.slug : ""), { mutate: g, isPending: v } = ro(), { mutate: A, isPending: E } = rs(), N = me(
3034
+ () => s == null ? void 0 : s.find(
3035
+ (C) => C.key === e.pageType
3036
+ ),
3037
+ [s, e.pageType]
3038
+ ), y = !(N != null && N.hasSlug), Q = v || E, p = (C) => {
3039
+ C.preventDefault();
3040
+ const O = {
3041
+ name: a,
3042
+ lang: o,
3043
+ primaryPage: r == null ? void 0 : r.id,
3044
+ slug: d,
3045
+ pageType: r == null ? void 0 : r.pageType
3046
+ };
3047
+ O.pageType = e.pageType, e.edit && (O.id = e == null ? void 0 : e.id), e.edit ? A(O, { onSuccess: t }) : g(O, { onSuccess: t });
3048
+ };
3049
+ return /* @__PURE__ */ u(nn, { open: !!e, onOpenChange: t, children: /* @__PURE__ */ m(rn, { className: "sm:max-w-[425px] text-slate-600", children: [
3050
+ /* @__PURE__ */ m(sn, { children: [
3051
+ /* @__PURE__ */ u(an, { children: e.edit ? z.EDIT_LANGUAGE : z.ADD_NEW_LANGUAGE }),
3052
+ /* @__PURE__ */ u(on, { className: "font-light", children: z.ENTER_LANGUAGE_DETAILS })
3053
+ ] }),
3054
+ /* @__PURE__ */ m("form", { onSubmit: p, children: [
3055
+ /* @__PURE__ */ m("div", { className: "grid gap-4 py-4", children: [
3056
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
3057
+ /* @__PURE__ */ u(ue, { htmlFor: "lang", className: "text-right", children: z.LANGUAGE }),
3058
+ /* @__PURE__ */ m(
3059
+ "select",
3060
+ {
3061
+ value: o,
3062
+ disabled: e.edit || Ie(n),
3063
+ onChange: (C) => {
3064
+ const O = C.target.value;
3065
+ l(O), !y && h(`/${O}`);
3066
+ },
3067
+ className: "flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 col-span-3",
3068
+ children: [
3069
+ /* @__PURE__ */ u("option", { value: "", disabled: !0, selected: !0, children: e.edit ? ae(qe, e.lang, e.lang) : Ie(n) ? z.ALL_AVAILABLE_LANGUAGE_PAGE : z.CHOOSE_LANGUAGE }),
3070
+ lr(n, (C) => /* @__PURE__ */ u("option", { value: C, children: ae(qe, C, C) }, C))
3071
+ ]
3072
+ }
3073
+ )
3074
+ ] }),
3075
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
3076
+ /* @__PURE__ */ u(ue, { htmlFor: "slug", className: "text-right", children: z.PAGE_NAME }),
3077
+ /* @__PURE__ */ u(
3078
+ Te,
3079
+ {
3080
+ id: "name",
3081
+ value: a,
3082
+ onChange: (C) => i(C.target.value),
3083
+ className: "col-span-3",
3084
+ required: !0,
3085
+ placeholder: z.ENTER_PAGE_NAME
3086
+ }
3087
+ )
3088
+ ] }),
3089
+ !y && /* @__PURE__ */ m("div", { className: "space-y-1", children: [
3090
+ /* @__PURE__ */ m(ue, { htmlFor: "slug", className: "text-right", children: [
3091
+ z.SLUG,
3092
+ " ",
3093
+ /* @__PURE__ */ u("small", { className: "font-light", children: z.SLUG_SHOULD_START_WITH })
3094
+ ] }),
3095
+ /* @__PURE__ */ u(
3096
+ Te,
3097
+ {
3098
+ id: "slug",
3099
+ value: d,
3100
+ onChange: (C) => {
3101
+ const O = C.target.value;
3102
+ yt(O, `/${o}`) && h(Cs(Is(O)));
3103
+ },
3104
+ className: "col-span-3",
3105
+ required: !0,
3106
+ pattern: "^/.*",
3107
+ disabled: Ie(o),
3108
+ title: z.SLUG_MUST_START_WITH,
3109
+ placeholder: Ie(o) ? z.CHOOSE_LANGUAGE_TO_ADD_SLUG : z.ENTER_PAGE_SLUG
3110
+ }
3111
+ )
3112
+ ] })
3113
+ ] }),
3114
+ /* @__PURE__ */ u(ln, { children: /* @__PURE__ */ u(
3115
+ re,
3116
+ {
3117
+ type: "submit",
3118
+ disabled: Q || !a || !o || !y && !yt(d, `/${o}`),
3119
+ children: Q ? e.edit ? z.UPDATING : z.ADDING : e.edit ? z.UPDATE : z.ADD_NEW_LANGUAGE
3120
+ }
3121
+ ) })
3122
+ ] })
3123
+ ] }) });
3124
+ }, ho = () => {
3125
+ const [e, t] = ge(null), { selectedLang: n, fallbackLang: r, setSelectedLang: s } = Ot(), { data: a, isFetching: i } = On(), { data: o } = ft(), [l, d] = ge(null), [h, g] = ge(null), [v, A] = ge(null), { data: E } = fn(), N = xn(
3126
+ ae(E, "languages") || ["en"],
3127
+ (y) => !Se(a, { lang: y }) && y !== ae(E, "fallbackLang")
3128
+ );
3129
+ return /* @__PURE__ */ m("div", { className: "space-y-4 pt-2", children: [
3130
+ /* @__PURE__ */ u("ul", { className: "space-y-2 mt-4", children: i ? /* @__PURE__ */ m("div", { className: "w-full space-y-3 py-4", children: [
3131
+ /* @__PURE__ */ u("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
3132
+ /* @__PURE__ */ u("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
3133
+ /* @__PURE__ */ u("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" })
3134
+ ] }) : lr(a, (y) => {
3135
+ const Q = y.lang, p = y.slug, C = !y.primaryPage;
3136
+ return /* @__PURE__ */ m(ar, { children: [
3137
+ /* @__PURE__ */ m(
3138
+ "li",
3139
+ {
3140
+ className: `text-slate-500 w-full p-2 rounded cursor-pointer flex items-center justify-between ${Q === n ? "bg-gray-200" : "hover:bg-gray-100"}`,
3141
+ onClick: () => s(Q),
3142
+ children: [
3143
+ /* @__PURE__ */ m("div", { className: " flex-1 gap-x-3", children: [
3144
+ /* @__PURE__ */ m(
3145
+ "div",
3146
+ {
3147
+ className: "text-[13px] text-slate-800 flex items-center gap-x-2",
3148
+ children: [
3149
+ /* @__PURE__ */ u(
3150
+ "div",
3151
+ {
3152
+ className: `w-2.5 h-2.5 rounded-full ${y.online ? "bg-green-300" : "bg-gray-300"}`
3153
+ }
3154
+ ),
3155
+ ae(qe, C ? r : Q, Q)
3156
+ ]
3157
+ }
3158
+ ),
3159
+ /* @__PURE__ */ m("div", { children: [
3160
+ p && /* @__PURE__ */ m("div", { className: "text-[11px] text-slate-600 font-light", children: [
3161
+ "Slug: ",
3162
+ /* @__PURE__ */ u("b", { className: "font-medium", children: p })
3163
+ ] }),
3164
+ /* @__PURE__ */ m("div", { className: "text-[11px] text-slate-600 font-light", children: [
3165
+ "Name:",
3166
+ /* @__PURE__ */ m("b", { className: "font-medium", children: [
3167
+ " ",
3168
+ y.name,
3169
+ " "
3170
+ ] })
3171
+ ] })
3172
+ ] })
3173
+ ] }),
3174
+ C ? /* @__PURE__ */ m("div", { className: "flex items-center text-[11px] text-orange-500 gap-x-1", children: [
3175
+ /* @__PURE__ */ u(Bs, { fill: "orange", className: "w-3 h-3" }),
3176
+ /* @__PURE__ */ u("b", { children: " Primary" })
3177
+ ] }) : /* @__PURE__ */ u("div", { className: "flex items-center gap-x-3", children: /* @__PURE__ */ u(
3178
+ gt,
3179
+ {
3180
+ permissions: [
3181
+ Oe.EDIT_PAGE,
3182
+ Oe.DELETE_PAGE,
3183
+ Oe.UNPUBLISH_PAGE
3184
+ ],
3185
+ children: /* @__PURE__ */ m(Js, { children: [
3186
+ /* @__PURE__ */ u(
3187
+ ea,
3188
+ {
3189
+ asChild: !0,
3190
+ onClick: (q) => q.stopPropagation(),
3191
+ children: /* @__PURE__ */ u(
3192
+ re,
3193
+ {
3194
+ variant: "ghost",
3195
+ size: "sm",
3196
+ className: "h-8 w-8 p-0",
3197
+ children: /* @__PURE__ */ u(Fs, { className: "h-4 w-4" })
3198
+ }
3199
+ )
3200
+ }
3201
+ ),
3202
+ /* @__PURE__ */ m(ta, { align: "end", className: "text-sm", children: [
3203
+ /* @__PURE__ */ u(
3204
+ gt,
3205
+ {
3206
+ permissions: [Oe.EDIT_PAGE],
3207
+ children: /* @__PURE__ */ m(
3208
+ gn,
3209
+ {
3210
+ className: "flex items-center gap-2 cursor-pointer",
3211
+ onClick: (q) => {
3212
+ q.stopPropagation(), t({ ...y, edit: !0 });
3213
+ },
3214
+ children: [
3215
+ /* @__PURE__ */ u(js, { className: "size-3" }),
3216
+ z.EDIT
3217
+ ]
3218
+ }
3219
+ )
3220
+ }
3221
+ ),
3222
+ /* @__PURE__ */ u(
3223
+ gt,
3224
+ {
3225
+ permissions: [Oe.UNPUBLISH_PAGE],
3226
+ children: (y == null ? void 0 : y.online) && /* @__PURE__ */ m(
3227
+ gn,
3228
+ {
3229
+ className: "flex items-center gap-2 cursor-pointer",
3230
+ onClick: (q) => {
3231
+ q.stopPropagation(), g(y);
3232
+ },
3233
+ children: [
3234
+ /* @__PURE__ */ u(Hs, { className: "size-3" }),
3235
+ z.UNPUBLISH
3236
+ ]
3237
+ }
3238
+ )
3239
+ }
3240
+ ),
3241
+ /* @__PURE__ */ u(
3242
+ gt,
3243
+ {
3244
+ permissions: [Oe.DELETE_PAGE],
3245
+ children: /* @__PURE__ */ m(
3246
+ gn,
3247
+ {
3248
+ className: "flex items-center gap-2 cursor-pointer",
3249
+ onClick: (q) => {
3250
+ q.stopPropagation(), d(y);
3251
+ },
3252
+ children: [
3253
+ /* @__PURE__ */ u(qs, { className: "size-3" }),
3254
+ z.DELETE
3255
+ ]
3256
+ }
3257
+ )
3258
+ }
3259
+ )
3260
+ ] })
3261
+ ] })
3262
+ }
3263
+ ) })
3264
+ ]
3265
+ },
3266
+ y.id
3267
+ ),
3268
+ /* @__PURE__ */ u("div", { className: "h-1 w-full border-b" })
3269
+ ] });
3270
+ }) }),
3271
+ /* @__PURE__ */ u(gt, { permissions: [Oe.ADD_PAGE], children: /* @__PURE__ */ u("div", { className: "flex justify-center w-full", children: /* @__PURE__ */ u(
3272
+ re,
3273
+ {
3274
+ variant: "default",
3275
+ size: "sm",
3276
+ disabled: Ie(N),
3277
+ onClick: () => {
3278
+ t({
3279
+ name: o == null ? void 0 : o.name,
3280
+ pageType: o == null ? void 0 : o.pageType,
3281
+ lang: "",
3282
+ slug: "",
3283
+ edit: !1
3284
+ });
3285
+ },
3286
+ children: z.ADD_NEW_LANGUAGE
3287
+ }
3288
+ ) }) }),
3289
+ e && /* @__PURE__ */ u(
3290
+ fo,
3291
+ {
3292
+ languages: N,
3293
+ langProps: e,
3294
+ onClose: () => t(null)
3295
+ }
3296
+ ),
3297
+ l && /* @__PURE__ */ u(co, { page: l, onClose: () => d(null) }),
3298
+ h && /* @__PURE__ */ u(
3299
+ uo,
3300
+ {
3301
+ page: h,
3302
+ onClose: () => g(null)
3303
+ }
3304
+ ),
3305
+ v && /* @__PURE__ */ u(
3306
+ lo,
3307
+ {
3308
+ page: v,
3309
+ onClose: () => A(null)
3310
+ }
3311
+ )
3312
+ ] });
3313
+ }, go = (e) => {
3314
+ const { fallbackLang: t } = Ot(), { data: n } = fn(), { data: r, isFetching: s } = On(), a = me(() => {
3315
+ const i = { [t]: !0 };
3316
+ return Ls(ae(n, "languages"), (o) => {
3317
+ const l = Se(r, { lang: o });
3318
+ i[o] = !!l;
3319
+ }), i;
3320
+ }, [t, r, n]);
3321
+ return s || Ie(e) || e && a[e];
3322
+ }, mo = (e) => {
3323
+ const t = te(), n = ee();
3324
+ return Pe({
3325
+ queryKey: ["chaiUserInfo", e],
3326
+ queryFn: async () => await n(t, {
3327
+ action: P.GET_CHAI_USER,
3328
+ data: { userId: e }
3329
+ }),
3330
+ enabled: !!e && e !== "EXPIRED"
3331
+ });
3332
+ }, yo = Gn(void 0), Un = () => {
3333
+ const [e] = ke(), t = e.get("page"), n = Ke("user"), [r, s] = kn(yo);
3334
+ return me(() => ({
3335
+ isLocked: t && (n == null ? void 0 : n.id) !== r,
3336
+ currentEditor: r,
3337
+ setCurrentEditor: (a) => s(a)
3338
+ }), [r, t, s, n == null ? void 0 : n.id]);
3339
+ };
3340
+ var Rn = {};
3341
+ (function e(t, n, r, s) {
3342
+ var a = !!(t.Worker && t.Blob && t.Promise && t.OffscreenCanvas && t.OffscreenCanvasRenderingContext2D && t.HTMLCanvasElement && t.HTMLCanvasElement.prototype.transferControlToOffscreen && t.URL && t.URL.createObjectURL), i = typeof Path2D == "function" && typeof DOMMatrix == "function", o = function() {
3343
+ if (!t.OffscreenCanvas)
3344
+ return !1;
3345
+ var f = new OffscreenCanvas(1, 1), c = f.getContext("2d");
3346
+ c.fillRect(0, 0, 1, 1);
3347
+ var S = f.transferToImageBitmap();
3348
+ try {
3349
+ c.createPattern(S, "no-repeat");
3350
+ } catch {
3351
+ return !1;
3352
+ }
3353
+ return !0;
3354
+ }();
3355
+ function l() {
3356
+ }
3357
+ function d(f) {
3358
+ var c = n.exports.Promise, S = c !== void 0 ? c : t.Promise;
3359
+ return typeof S == "function" ? new S(f) : (f(l, l), null);
3360
+ }
3361
+ var h = /* @__PURE__ */ function(f, c) {
3362
+ return {
3363
+ transform: function(S) {
3364
+ if (f)
3365
+ return S;
3366
+ if (c.has(S))
3367
+ return c.get(S);
3368
+ var b = new OffscreenCanvas(S.width, S.height), I = b.getContext("2d");
3369
+ return I.drawImage(S, 0, 0), c.set(S, b), b;
3370
+ },
3371
+ clear: function() {
3372
+ c.clear();
3373
+ }
3374
+ };
3375
+ }(o, /* @__PURE__ */ new Map()), g = function() {
3376
+ var f = Math.floor(16.666666666666668), c, S, b = {}, I = 0;
3377
+ return typeof requestAnimationFrame == "function" && typeof cancelAnimationFrame == "function" ? (c = function(L) {
3378
+ var x = Math.random();
3379
+ return b[x] = requestAnimationFrame(function w(G) {
3380
+ I === G || I + f - 1 < G ? (I = G, delete b[x], L()) : b[x] = requestAnimationFrame(w);
3381
+ }), x;
3382
+ }, S = function(L) {
3383
+ b[L] && cancelAnimationFrame(b[L]);
3384
+ }) : (c = function(L) {
3385
+ return setTimeout(L, f);
3386
+ }, S = function(L) {
3387
+ return clearTimeout(L);
3388
+ }), { frame: c, cancel: S };
3389
+ }(), v = /* @__PURE__ */ function() {
3390
+ var f, c, S = {};
3391
+ function b(I) {
3392
+ function L(x, w) {
3393
+ I.postMessage({ options: x || {}, callback: w });
3394
+ }
3395
+ I.init = function(w) {
3396
+ var G = w.transferControlToOffscreen();
3397
+ I.postMessage({ canvas: G }, [G]);
3398
+ }, I.fire = function(w, G, W) {
3399
+ if (c)
3400
+ return L(w, null), c;
3401
+ var Y = Math.random().toString(36).slice(2);
3402
+ return c = d(function($) {
3403
+ function X(oe) {
3404
+ oe.data.callback === Y && (delete S[Y], I.removeEventListener("message", X), c = null, h.clear(), W(), $());
3405
+ }
3406
+ I.addEventListener("message", X), L(w, Y), S[Y] = X.bind(null, { data: { callback: Y } });
3407
+ }), c;
3408
+ }, I.reset = function() {
3409
+ I.postMessage({ reset: !0 });
3410
+ for (var w in S)
3411
+ S[w](), delete S[w];
3412
+ };
3413
+ }
3414
+ return function() {
3415
+ if (f)
3416
+ return f;
3417
+ if (!r && a) {
3418
+ var I = [
3419
+ "var CONFETTI, SIZE = {}, module = {};",
3420
+ "(" + e.toString() + ")(this, module, true, SIZE);",
3421
+ "onmessage = function(msg) {",
3422
+ " if (msg.data.options) {",
3423
+ " CONFETTI(msg.data.options).then(function () {",
3424
+ " if (msg.data.callback) {",
3425
+ " postMessage({ callback: msg.data.callback });",
3426
+ " }",
3427
+ " });",
3428
+ " } else if (msg.data.reset) {",
3429
+ " CONFETTI && CONFETTI.reset();",
3430
+ " } else if (msg.data.resize) {",
3431
+ " SIZE.width = msg.data.resize.width;",
3432
+ " SIZE.height = msg.data.resize.height;",
3433
+ " } else if (msg.data.canvas) {",
3434
+ " SIZE.width = msg.data.canvas.width;",
3435
+ " SIZE.height = msg.data.canvas.height;",
3436
+ " CONFETTI = module.exports.create(msg.data.canvas);",
3437
+ " }",
3438
+ "}"
3439
+ ].join(`
3440
+ `);
3441
+ try {
3442
+ f = new Worker(URL.createObjectURL(new Blob([I])));
3443
+ } catch (L) {
3444
+ return typeof console !== void 0 && typeof console.warn == "function" && console.warn("🎊 Could not load worker", L), null;
3445
+ }
3446
+ b(f);
3447
+ }
3448
+ return f;
3449
+ };
3450
+ }(), A = {
3451
+ particleCount: 50,
3452
+ angle: 90,
3453
+ spread: 45,
3454
+ startVelocity: 45,
3455
+ decay: 0.9,
3456
+ gravity: 1,
3457
+ drift: 0,
3458
+ ticks: 200,
3459
+ x: 0.5,
3460
+ y: 0.5,
3461
+ shapes: ["square", "circle"],
3462
+ zIndex: 100,
3463
+ colors: [
3464
+ "#26ccff",
3465
+ "#a25afd",
3466
+ "#ff5e7e",
3467
+ "#88ff5a",
3468
+ "#fcff42",
3469
+ "#ffa62d",
3470
+ "#ff36ff"
3471
+ ],
3472
+ // probably should be true, but back-compat
3473
+ disableForReducedMotion: !1,
3474
+ scalar: 1
3475
+ };
3476
+ function E(f, c) {
3477
+ return c ? c(f) : f;
3478
+ }
3479
+ function N(f) {
3480
+ return f != null;
3481
+ }
3482
+ function y(f, c, S) {
3483
+ return E(
3484
+ f && N(f[c]) ? f[c] : A[c],
3485
+ S
3486
+ );
3487
+ }
3488
+ function Q(f) {
3489
+ return f < 0 ? 0 : Math.floor(f);
3490
+ }
3491
+ function p(f, c) {
3492
+ return Math.floor(Math.random() * (c - f)) + f;
3493
+ }
3494
+ function C(f) {
3495
+ return parseInt(f, 16);
3496
+ }
3497
+ function O(f) {
3498
+ return f.map(q);
3499
+ }
3500
+ function q(f) {
3501
+ var c = String(f).replace(/[^0-9a-f]/gi, "");
3502
+ return c.length < 6 && (c = c[0] + c[0] + c[1] + c[1] + c[2] + c[2]), {
3503
+ r: C(c.substring(0, 2)),
3504
+ g: C(c.substring(2, 4)),
3505
+ b: C(c.substring(4, 6))
3506
+ };
3507
+ }
3508
+ function ie(f) {
3509
+ var c = y(f, "origin", Object);
3510
+ return c.x = y(c, "x", Number), c.y = y(c, "y", Number), c;
3511
+ }
3512
+ function se(f) {
3513
+ f.width = document.documentElement.clientWidth, f.height = document.documentElement.clientHeight;
3514
+ }
3515
+ function k(f) {
3516
+ var c = f.getBoundingClientRect();
3517
+ f.width = c.width, f.height = c.height;
3518
+ }
3519
+ function B(f) {
3520
+ var c = document.createElement("canvas");
3521
+ return c.style.position = "fixed", c.style.top = "0px", c.style.left = "0px", c.style.pointerEvents = "none", c.style.zIndex = f, c;
3522
+ }
3523
+ function U(f, c, S, b, I, L, x, w, G) {
3524
+ f.save(), f.translate(c, S), f.rotate(L), f.scale(b, I), f.arc(0, 0, 1, x, w, G), f.restore();
3525
+ }
3526
+ function K(f) {
3527
+ var c = f.angle * (Math.PI / 180), S = f.spread * (Math.PI / 180);
3528
+ return {
3529
+ x: f.x,
3530
+ y: f.y,
3531
+ wobble: Math.random() * 10,
3532
+ wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05),
3533
+ velocity: f.startVelocity * 0.5 + Math.random() * f.startVelocity,
3534
+ angle2D: -c + (0.5 * S - Math.random() * S),
3535
+ tiltAngle: (Math.random() * (0.75 - 0.25) + 0.25) * Math.PI,
3536
+ color: f.color,
3537
+ shape: f.shape,
3538
+ tick: 0,
3539
+ totalTicks: f.ticks,
3540
+ decay: f.decay,
3541
+ drift: f.drift,
3542
+ random: Math.random() + 2,
3543
+ tiltSin: 0,
3544
+ tiltCos: 0,
3545
+ wobbleX: 0,
3546
+ wobbleY: 0,
3547
+ gravity: f.gravity * 3,
3548
+ ovalScalar: 0.6,
3549
+ scalar: f.scalar,
3550
+ flat: f.flat
3551
+ };
3552
+ }
3553
+ function ne(f, c) {
3554
+ c.x += Math.cos(c.angle2D) * c.velocity + c.drift, c.y += Math.sin(c.angle2D) * c.velocity + c.gravity, c.velocity *= c.decay, c.flat ? (c.wobble = 0, c.wobbleX = c.x + 10 * c.scalar, c.wobbleY = c.y + 10 * c.scalar, c.tiltSin = 0, c.tiltCos = 0, c.random = 1) : (c.wobble += c.wobbleSpeed, c.wobbleX = c.x + 10 * c.scalar * Math.cos(c.wobble), c.wobbleY = c.y + 10 * c.scalar * Math.sin(c.wobble), c.tiltAngle += 0.1, c.tiltSin = Math.sin(c.tiltAngle), c.tiltCos = Math.cos(c.tiltAngle), c.random = Math.random() + 2);
3555
+ var S = c.tick++ / c.totalTicks, b = c.x + c.random * c.tiltCos, I = c.y + c.random * c.tiltSin, L = c.wobbleX + c.random * c.tiltCos, x = c.wobbleY + c.random * c.tiltSin;
3556
+ if (f.fillStyle = "rgba(" + c.color.r + ", " + c.color.g + ", " + c.color.b + ", " + (1 - S) + ")", f.beginPath(), i && c.shape.type === "path" && typeof c.shape.path == "string" && Array.isArray(c.shape.matrix))
3557
+ f.fill(ht(
3558
+ c.shape.path,
3559
+ c.shape.matrix,
3560
+ c.x,
3561
+ c.y,
3562
+ Math.abs(L - b) * 0.1,
3563
+ Math.abs(x - I) * 0.1,
3564
+ Math.PI / 10 * c.wobble
3565
+ ));
3566
+ else if (c.shape.type === "bitmap") {
3567
+ var w = Math.PI / 10 * c.wobble, G = Math.abs(L - b) * 0.1, W = Math.abs(x - I) * 0.1, Y = c.shape.bitmap.width * c.scalar, $ = c.shape.bitmap.height * c.scalar, X = new DOMMatrix([
3568
+ Math.cos(w) * G,
3569
+ Math.sin(w) * G,
3570
+ -Math.sin(w) * W,
3571
+ Math.cos(w) * W,
3572
+ c.x,
3573
+ c.y
3574
+ ]);
3575
+ X.multiplySelf(new DOMMatrix(c.shape.matrix));
3576
+ var oe = f.createPattern(h.transform(c.shape.bitmap), "no-repeat");
3577
+ oe.setTransform(X), f.globalAlpha = 1 - S, f.fillStyle = oe, f.fillRect(
3578
+ c.x - Y / 2,
3579
+ c.y - $ / 2,
3580
+ Y,
3581
+ $
3582
+ ), f.globalAlpha = 1;
3583
+ } else if (c.shape === "circle")
3584
+ f.ellipse ? f.ellipse(c.x, c.y, Math.abs(L - b) * c.ovalScalar, Math.abs(x - I) * c.ovalScalar, Math.PI / 10 * c.wobble, 0, 2 * Math.PI) : U(f, c.x, c.y, Math.abs(L - b) * c.ovalScalar, Math.abs(x - I) * c.ovalScalar, Math.PI / 10 * c.wobble, 0, 2 * Math.PI);
3585
+ else if (c.shape === "star")
3586
+ for (var D = Math.PI / 2 * 3, de = 4 * c.scalar, pe = 8 * c.scalar, ve = c.x, Ne = c.y, Me = 5, we = Math.PI / Me; Me--; )
3587
+ ve = c.x + Math.cos(D) * pe, Ne = c.y + Math.sin(D) * pe, f.lineTo(ve, Ne), D += we, ve = c.x + Math.cos(D) * de, Ne = c.y + Math.sin(D) * de, f.lineTo(ve, Ne), D += we;
3588
+ else
3589
+ f.moveTo(Math.floor(c.x), Math.floor(c.y)), f.lineTo(Math.floor(c.wobbleX), Math.floor(I)), f.lineTo(Math.floor(L), Math.floor(x)), f.lineTo(Math.floor(b), Math.floor(c.wobbleY));
3590
+ return f.closePath(), f.fill(), c.tick < c.totalTicks;
3591
+ }
3592
+ function Rt(f, c, S, b, I) {
3593
+ var L = c.slice(), x = f.getContext("2d"), w, G, W = d(function(Y) {
3594
+ function $() {
3595
+ w = G = null, x.clearRect(0, 0, b.width, b.height), h.clear(), I(), Y();
3596
+ }
3597
+ function X() {
3598
+ r && !(b.width === s.width && b.height === s.height) && (b.width = f.width = s.width, b.height = f.height = s.height), !b.width && !b.height && (S(f), b.width = f.width, b.height = f.height), x.clearRect(0, 0, b.width, b.height), L = L.filter(function(oe) {
3599
+ return ne(x, oe);
3600
+ }), L.length ? w = g.frame(X) : $();
3601
+ }
3602
+ w = g.frame(X), G = $;
3603
+ });
3604
+ return {
3605
+ addFettis: function(Y) {
3606
+ return L = L.concat(Y), W;
3607
+ },
3608
+ canvas: f,
3609
+ promise: W,
3610
+ reset: function() {
3611
+ w && g.cancel(w), G && G();
3612
+ }
3613
+ };
3614
+ }
3615
+ function ye(f, c) {
3616
+ var S = !f, b = !!y(c || {}, "resize"), I = !1, L = y(c, "disableForReducedMotion", Boolean), x = a && !!y(c || {}, "useWorker"), w = x ? v() : null, G = S ? se : k, W = f && w ? !!f.__confetti_initialized : !1, Y = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion)").matches, $;
3617
+ function X(D, de, pe) {
3618
+ for (var ve = y(D, "particleCount", Q), Ne = y(D, "angle", Number), Me = y(D, "spread", Number), we = y(D, "startVelocity", Number), us = y(D, "decay", Number), ds = y(D, "gravity", Number), fs = y(D, "drift", Number), Bn = y(D, "colors", O), hs = y(D, "ticks", Number), Fn = y(D, "shapes"), gs = y(D, "scalar"), ms = !!y(D, "flat"), jn = ie(D), Hn = ve, hn = [], ys = f.width * jn.x, Es = f.height * jn.y; Hn--; )
3619
+ hn.push(
3620
+ K({
3621
+ x: ys,
3622
+ y: Es,
3623
+ angle: Ne,
3624
+ spread: Me,
3625
+ startVelocity: we,
3626
+ color: Bn[Hn % Bn.length],
3627
+ shape: Fn[p(0, Fn.length)],
3628
+ ticks: hs,
3629
+ decay: us,
3630
+ gravity: ds,
3631
+ drift: fs,
3632
+ scalar: gs,
3633
+ flat: ms
3634
+ })
3635
+ );
3636
+ return $ ? $.addFettis(hn) : ($ = Rt(f, hn, G, de, pe), $.promise);
3637
+ }
3638
+ function oe(D) {
3639
+ var de = L || y(D, "disableForReducedMotion", Boolean), pe = y(D, "zIndex", Number);
3640
+ if (de && Y)
3641
+ return d(function(we) {
3642
+ we();
3643
+ });
3644
+ S && $ ? f = $.canvas : S && !f && (f = B(pe), document.body.appendChild(f)), b && !W && G(f);
3645
+ var ve = {
3646
+ width: f.width,
3647
+ height: f.height
3648
+ };
3649
+ w && !W && w.init(f), W = !0, w && (f.__confetti_initialized = !0);
3650
+ function Ne() {
3651
+ if (w) {
3652
+ var we = {
3653
+ getBoundingClientRect: function() {
3654
+ if (!S)
3655
+ return f.getBoundingClientRect();
3656
+ }
3657
+ };
3658
+ G(we), w.postMessage({
3659
+ resize: {
3660
+ width: we.width,
3661
+ height: we.height
3662
+ }
3663
+ });
3664
+ return;
3665
+ }
3666
+ ve.width = ve.height = null;
3667
+ }
3668
+ function Me() {
3669
+ $ = null, b && (I = !1, t.removeEventListener("resize", Ne)), S && f && (document.body.contains(f) && document.body.removeChild(f), f = null, W = !1);
3670
+ }
3671
+ return b && !I && (I = !0, t.addEventListener("resize", Ne, !1)), w ? w.fire(D, ve, Me) : X(D, ve, Me);
3672
+ }
3673
+ return oe.reset = function() {
3674
+ w && w.reset(), $ && $.reset();
3675
+ }, oe;
3676
+ }
3677
+ var V;
3678
+ function he() {
3679
+ return V || (V = ye(null, { useWorker: !0, resize: !0 })), V;
3680
+ }
3681
+ function ht(f, c, S, b, I, L, x) {
3682
+ var w = new Path2D(f), G = new Path2D();
3683
+ G.addPath(w, new DOMMatrix(c));
3684
+ var W = new Path2D();
3685
+ return W.addPath(G, new DOMMatrix([
3686
+ Math.cos(x) * I,
3687
+ Math.sin(x) * I,
3688
+ -Math.sin(x) * L,
3689
+ Math.cos(x) * L,
3690
+ S,
3691
+ b
3692
+ ])), W;
3693
+ }
3694
+ function We(f) {
3695
+ if (!i)
3696
+ throw new Error("path confetti are not supported in this browser");
3697
+ var c, S;
3698
+ typeof f == "string" ? c = f : (c = f.path, S = f.matrix);
3699
+ var b = new Path2D(c), I = document.createElement("canvas"), L = I.getContext("2d");
3700
+ if (!S) {
3701
+ for (var x = 1e3, w = x, G = x, W = 0, Y = 0, $, X, oe = 0; oe < x; oe += 2)
3702
+ for (var D = 0; D < x; D += 2)
3703
+ L.isPointInPath(b, oe, D, "nonzero") && (w = Math.min(w, oe), G = Math.min(G, D), W = Math.max(W, oe), Y = Math.max(Y, D));
3704
+ $ = W - w, X = Y - G;
3705
+ var de = 10, pe = Math.min(de / $, de / X);
3706
+ S = [
3707
+ pe,
3708
+ 0,
3709
+ 0,
3710
+ pe,
3711
+ -Math.round($ / 2 + w) * pe,
3712
+ -Math.round(X / 2 + G) * pe
3713
+ ];
3714
+ }
3715
+ return {
3716
+ type: "path",
3717
+ path: c,
3718
+ matrix: S
3719
+ };
3720
+ }
3721
+ function cs(f) {
3722
+ var c, S = 1, b = "#000000", I = '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';
3723
+ typeof f == "string" ? c = f : (c = f.text, S = "scalar" in f ? f.scalar : S, I = "fontFamily" in f ? f.fontFamily : I, b = "color" in f ? f.color : b);
3724
+ var L = 10 * S, x = "" + L + "px " + I, w = new OffscreenCanvas(L, L), G = w.getContext("2d");
3725
+ G.font = x;
3726
+ var W = G.measureText(c), Y = Math.ceil(W.actualBoundingBoxRight + W.actualBoundingBoxLeft), $ = Math.ceil(W.actualBoundingBoxAscent + W.actualBoundingBoxDescent), X = 2, oe = W.actualBoundingBoxLeft + X, D = W.actualBoundingBoxAscent + X;
3727
+ Y += X + X, $ += X + X, w = new OffscreenCanvas(Y, $), G = w.getContext("2d"), G.font = x, G.fillStyle = b, G.fillText(c, oe, D);
3728
+ var de = 1 / S;
3729
+ return {
3730
+ type: "bitmap",
3731
+ // TODO these probably need to be transfered for workers
3732
+ bitmap: w.transferToImageBitmap(),
3733
+ matrix: [de, 0, 0, de, -Y * de / 2, -$ * de / 2]
3734
+ };
3735
+ }
3736
+ n.exports = function() {
3737
+ return he().apply(this, arguments);
3738
+ }, n.exports.reset = function() {
3739
+ he().reset();
3740
+ }, n.exports.create = ye, n.exports.shapeFromPath = We, n.exports.shapeFromText = cs;
3741
+ })(/* @__PURE__ */ function() {
3742
+ return typeof window < "u" ? window : typeof self < "u" ? self : this || {};
3743
+ }(), Rn, !1);
3744
+ const Eo = Rn.exports;
3745
+ Rn.exports.create;
3746
+ const po = {
3747
+ particleCount: 350,
3748
+ spread: 120,
3749
+ origin: { y: 0.6 },
3750
+ angle: 90
3751
+ }, vo = {
3752
+ TOP_RIGHT: {
3753
+ angle: 225,
3754
+ origin: { x: 0.9, y: 0 }
3755
+ },
3756
+ BOTTOM_RIGHT: {
3757
+ angle: 100,
3758
+ origin: { x: 0.9, y: 0.9 }
3759
+ }
3760
+ }, So = (e) => {
3761
+ let t = vo[e];
3762
+ t || (t = {});
3763
+ const n = { ...po, ...t };
3764
+ Eo(n);
3765
+ }, Mn = () => {
3766
+ const e = Ae(), { data: t } = Pe({
3767
+ queryKey: [P.AI_CONTEXT],
3768
+ initialData: "",
3769
+ queryFn: () => ""
3770
+ });
3771
+ return { setAiContext: Ue((r) => {
3772
+ e.setQueryData([P.AI_CONTEXT], r);
3773
+ }, []), aiContext: t };
3774
+ }, Ao = () => {
3775
+ const e = te(), { aiContext: t } = Mn(), n = ee();
3776
+ return Ue(
3777
+ async (r, s, a, i) => n(e, {
3778
+ action: P.ASK_AI,
3779
+ data: { type: r, prompt: s, blocks: a, context: t, lang: i }
3780
+ }),
3781
+ [e, t, n]
3782
+ );
3783
+ }, wo = (e, t) => t.map((n) => {
3784
+ if (tn(e, n._type)) {
3785
+ const r = Zs(n._type);
3786
+ return {
3787
+ ...r,
3788
+ ...cr(n, [
3789
+ ...Gs(r),
3790
+ "_type",
3791
+ "_id",
3792
+ "_name",
3793
+ "_parent",
3794
+ "_bindings"
3795
+ ]),
3796
+ ...ks(n, (s, a) => Ds(a, "_attrs")),
3797
+ ...n
3798
+ };
3799
+ }
3800
+ return n;
3801
+ }), bo = (e) => {
3802
+ const t = Xs();
3803
+ return me(() => {
3804
+ if (!e || Ie(e)) return { blocks: [] };
3805
+ const n = xn(
3806
+ e,
3807
+ (r) => !xs(r == null ? void 0 : r._type, "@chai/")
3808
+ );
3809
+ return { blocks: wo(t, n) };
3810
+ }, [e, t]);
3811
+ }, ss = () => {
3812
+ const [e] = ke(), t = e.get("page"), n = te(), { setAiContext: r } = Mn(), { setCurrentEditor: s } = Un(), [, a] = ns(), i = ee();
3813
+ return Pe({
3814
+ queryKey: [P.GET_PAGE, t],
3815
+ staleTime: 1 / 0,
3816
+ gcTime: 1 / 0,
3817
+ queryFn: async () => {
3818
+ s("");
3819
+ const o = await i(n, {
3820
+ action: P.GET_PAGE,
3821
+ data: { id: t, draft: !0 }
3822
+ });
3823
+ s(o.currentEditor);
3824
+ const l = o.blocks ?? [], d = Se(l, { _type: "@chai/ai-context" });
3825
+ return r(ae(d, "_value", "") || ""), a((h) => ({ ...h, lastSaved: o.lastSaved })), l;
3826
+ },
3827
+ enabled: !!t
3828
+ });
3829
+ }, as = ({
3830
+ pageType: e,
3831
+ lang: t
3832
+ }) => {
3833
+ const n = te(), r = ee();
3834
+ return Pe({
3835
+ queryKey: [P.GET_BUILDER_PAGE_DATA, e, t],
3836
+ initialData: {},
3837
+ queryFn: async () => r(n, {
3838
+ action: P.GET_BUILDER_PAGE_DATA,
3839
+ data: { pageType: e, lang: t }
3840
+ }),
3841
+ enabled: !!e && !!t
3842
+ });
3843
+ }, To = () => {
3844
+ const e = te(), t = ee();
3845
+ return Pe({
3846
+ queryKey: ["uiLibraries"],
3847
+ initialData: [],
3848
+ queryFn: async () => (await t(e, { action: "GET_LIBRARIES" })).map((r) => ({
3849
+ ...r
3850
+ }))
3851
+ });
3852
+ }, _o = () => {
3853
+ const e = te(), t = ee(), { setCurrentEditor: n } = Un(), [, r] = ns();
3854
+ return { getUILibraryBlock: async (o, l) => {
3855
+ const d = await t(e, {
3856
+ action: "GET_LIBRARY_ITEM",
3857
+ data: { id: l.id }
3858
+ }), h = ae(d, "html", ""), g = ae(d, "blocks", []);
3859
+ return Os(g) ? g : vs(h);
3860
+ }, getUILibraryBlocks: async (o) => {
3861
+ try {
3862
+ return (await t(e, {
3863
+ action: "GET_LIBRARY_ITEMS",
3864
+ data: { id: o.id }
3865
+ })).map((d) => ({
3866
+ ...d
3867
+ }));
3868
+ } catch (l) {
3869
+ return console.error(l), [];
3870
+ }
3871
+ }, onSave: async ({
3872
+ page: o,
3873
+ blocks: l
3874
+ }) => {
3875
+ try {
3876
+ const d = await t(e, {
3877
+ action: "UPDATE_PAGE",
3878
+ data: { id: o, blocks: l }
3879
+ });
3880
+ return d.code === "PAGE_LOCKED" ? (n(
3881
+ d.editor === null ? "EXPIRED" : d.editor
3882
+ ), !0) : (r((h) => ({
3883
+ ...h,
3884
+ lastSaved: (/* @__PURE__ */ new Date()).toISOString()
3885
+ })), d);
3886
+ } catch (d) {
3887
+ return console.error(d), new Error("Failed to save blocks");
3888
+ }
3889
+ } };
3890
+ }, Po = () => {
3891
+ const { data: e } = ts(), t = te(), n = ee();
3892
+ return {
3893
+ getPartialBlocks: Ue(async () => {
3894
+ const r = {};
3895
+ for (const s of e ?? [])
3896
+ Ie(s == null ? void 0 : s.slug) && (r[s.id] = {
3897
+ type: s.pageType,
3898
+ name: Us(s.name ?? s.slug),
3899
+ description: ""
3900
+ });
3901
+ return r;
3902
+ }, [e]),
3903
+ getPartialBlockBlocks: Ue(
3904
+ async (r) => {
3905
+ if (!r) return [];
3906
+ const s = await n(t, {
3907
+ action: "GET_PAGE",
3908
+ data: { id: r, draft: !0, editor: !1 }
3909
+ });
3910
+ return xn(s.blocks, (a) => tn(a, "_id"));
3911
+ },
3912
+ [n, t]
3913
+ )
3914
+ };
3915
+ };
3916
+ function No({
3917
+ avatar: e,
3918
+ name: t,
3919
+ email: n,
3920
+ onTakeOver: r,
3921
+ currentEditor: s
3922
+ }) {
3923
+ const [a, i] = ge(!1), o = () => {
3924
+ i(!1), r();
3925
+ };
3926
+ return console.log("currentEditor", s), /* @__PURE__ */ u("div", { className: "fixed bottom-0 left-0 right-0 z-[20] flex items-center justify-center w-screen top-14 bg-black/30 backdrop-blur-sm", children: /* @__PURE__ */ m(fr, { className: "w-full max-w-md mx-auto", children: [
3927
+ /* @__PURE__ */ u(hr, { className: "space-y-1", children: /* @__PURE__ */ m(gr, { className: "flex items-center gap-2 text-2xl", children: [
3928
+ /* @__PURE__ */ u(ur, { className: "w-6 h-6 text-yellow-500" }),
3929
+ s === "EXPIRED" ? "Editing access timed out" : "Page locked for editing"
3930
+ ] }) }),
3931
+ /* @__PURE__ */ u(mr, { className: "grid gap-4", children: s === "EXPIRED" ? /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u("p", { children: "Your editing access has been paused due to inactivity. Please refresh the page to continue" }) }) : /* @__PURE__ */ m("div", { children: [
3932
+ /* @__PURE__ */ m("div", { className: "flex items-center space-x-4", children: [
3933
+ e ? /* @__PURE__ */ u(
3934
+ "img",
3935
+ {
3936
+ src: e,
3937
+ alt: t,
3938
+ className: "w-12 h-12 border border-gray-300 rounded-full"
3939
+ }
3940
+ ) : /* @__PURE__ */ u(Ks, { className: "w-12 h-12 p-2 border border-gray-300 rounded-full" }),
3941
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
3942
+ /* @__PURE__ */ u("h3", { className: "font-semibold", children: t }),
3943
+ n && /* @__PURE__ */ u("p", { className: "text-sm text-muted-foreground", children: n })
3944
+ ] })
3945
+ ] }),
3946
+ /* @__PURE__ */ u("div", { className: "text-sm mt-4", children: /* @__PURE__ */ u("p", { children: "This user is currently editing the page. You cannot make changes." }) })
3947
+ ] }) }),
3948
+ /* @__PURE__ */ u(yr, { children: s === "EXPIRED" ? /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u(
3949
+ re,
3950
+ {
3951
+ className: "w-full",
3952
+ onClick: () => window.location.reload(),
3953
+ variant: "destructive",
3954
+ children: "Refresh"
3955
+ }
3956
+ ) }) : /* @__PURE__ */ m(na, { open: a, onOpenChange: i, children: [
3957
+ /* @__PURE__ */ u(ra, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "flex flex-col items-center", children: [
3958
+ /* @__PURE__ */ u(re, { className: "w-full", variant: "destructive", children: "Take Over" }),
3959
+ /* @__PURE__ */ u("p", { className: "mt-2 text-xs text-muted-foreground", children: "If you need to edit, you can take over the lock, but be aware that the other user might lose unsaved changes." })
3960
+ ] }) }),
3961
+ /* @__PURE__ */ m(sa, { className: "z-[99]", children: [
3962
+ /* @__PURE__ */ m(aa, { children: [
3963
+ /* @__PURE__ */ u(ia, { children: "Are you sure you want to take over?" }),
3964
+ /* @__PURE__ */ m(oa, { children: [
3965
+ /* @__PURE__ */ m("span", { className: "flex items-center space-x-2 text-yellow-500", children: [
3966
+ /* @__PURE__ */ u(Vs, { className: "w-5 h-5" }),
3967
+ /* @__PURE__ */ u("span", { children: "This action might cause the other user to lose unsaved changes." })
3968
+ ] }),
3969
+ /* @__PURE__ */ u("br", {}),
3970
+ /* @__PURE__ */ m("span", { className: "mt-2", children: [
3971
+ "By taking over, you will become the active editor of this page, and ",
3972
+ t,
3973
+ " will lose their editing access."
3974
+ ] })
3975
+ ] })
3976
+ ] }),
3977
+ /* @__PURE__ */ m(la, { children: [
3978
+ /* @__PURE__ */ u(ca, { children: "Cancel" }),
3979
+ /* @__PURE__ */ u(ua, { onClick: o, children: "Yes, Take Over" })
3980
+ ] })
3981
+ ] })
3982
+ ] }) })
3983
+ ] }) });
3984
+ }
3985
+ const Co = () => {
3986
+ const { isLocked: e, currentEditor: t } = Un(), { data: n } = mo(t), [r] = ke(), s = r.get("page"), { mutate: a } = Zr(), { isFetching: i } = ss(), o = Ue(() => {
3987
+ a({ id: s });
3988
+ }, [s, a]);
3989
+ return console.log("---- is locked-------", n, e, t), !e || i ? /* @__PURE__ */ u("div", { className: "" }) : /* @__PURE__ */ u(
3990
+ No,
3991
+ {
3992
+ ...n,
3993
+ name: (n == null ? void 0 : n.name) || "Unknown User",
3994
+ email: (n == null ? void 0 : n.email) || "",
3995
+ currentEditor: t ?? null,
3996
+ onTakeOver: o
3997
+ }
3998
+ );
3999
+ }, Io = () => {
4000
+ const [e, t] = ke(), n = e.get("lang"), r = go(n), { setSelectedLang: s } = Ot(), a = () => {
4001
+ const o = new URLSearchParams(window.location.search);
4002
+ o.delete("lang");
4003
+ const l = o.toString(), d = `${window.location.pathname}${l ? `?${l}` : ""}`;
4004
+ window.history.pushState({}, "", d), t(o), s(""), window.dispatchEvent(new PopStateEvent("popstate"));
4005
+ };
4006
+ if (r) return null;
4007
+ const i = ae(qe, n);
4008
+ return /* @__PURE__ */ u("div", { className: "fixed bottom-0 left-0 right-0 z-[20] flex items-center justify-center w-screen top-14 bg-black/30 backdrop-blur-sm", children: /* @__PURE__ */ m(fr, { className: "w-full max-w-md mx-auto", children: [
4009
+ /* @__PURE__ */ u(hr, { className: "space-y-1", children: /* @__PURE__ */ m(gr, { className: "flex items-center gap-2 text-2xl", children: [
4010
+ /* @__PURE__ */ u(ur, { className: "w-6 h-6 text-yellow-500" }),
4011
+ 'Page missing for "',
4012
+ i,
4013
+ '" language.'
4014
+ ] }) }),
4015
+ /* @__PURE__ */ u(mr, { className: "grid gap-4", children: /* @__PURE__ */ m("div", { children: [
4016
+ 'Page is not available in the "',
4017
+ i,
4018
+ '" language. Either create the page in the "',
4019
+ i,
4020
+ '" language or switch to the base language.'
4021
+ ] }) }),
4022
+ /* @__PURE__ */ u(yr, { children: /* @__PURE__ */ u(
4023
+ re,
4024
+ {
4025
+ onClick: a,
4026
+ className: "w-full",
4027
+ variant: "destructive",
4028
+ children: "Switch to default language"
4029
+ }
4030
+ ) })
4031
+ ] }) });
4032
+ }, Lo = () => {
4033
+ const [e] = Ss(), { mutate: t, isPending: n } = io(), { mutateAsync: r, isPending: s } = Jr();
4034
+ return /* @__PURE__ */ m("div", { className: "bg-white py-3 flex items-center justify-center gap-x-3 border-t", children: [
4035
+ /* @__PURE__ */ u(
4036
+ re,
4037
+ {
4038
+ size: "sm",
4039
+ variant: "outline",
4040
+ disabled: n || s,
4041
+ onClick: () => {
4042
+ r({ settings: { theme: e } });
4043
+ },
4044
+ children: "Save draft"
4045
+ }
4046
+ ),
4047
+ /* @__PURE__ */ u(
4048
+ re,
4049
+ {
4050
+ size: "sm",
4051
+ disabled: n || s,
4052
+ onClick: () => {
4053
+ t(
4054
+ { ids: ["THEME"] },
4055
+ {
4056
+ onSuccess: () => {
4057
+ So("BOTTOM_RIGHT");
4058
+ }
4059
+ }
4060
+ );
4061
+ },
4062
+ children: "Publish"
4063
+ }
4064
+ )
4065
+ ] });
4066
+ }, xo = () => {
4067
+ const e = te(), t = ee(), n = Ke("user"), r = n == null ? void 0 : n.id;
4068
+ return Pe({
4069
+ queryKey: ["permissions", r],
4070
+ queryFn: () => t(e, {
4071
+ action: P.GET_ROLE_AND_PERMISSIONS,
4072
+ data: { userId: r }
4073
+ }),
4074
+ enabled: !!r
4075
+ });
4076
+ }, Go = ({
4077
+ isActive: e,
4078
+ show: t
4079
+ }) => {
4080
+ const { data: n } = fn();
4081
+ return !tn(n, "languages") || !ae(n, "languages", []).length ? null : /* @__PURE__ */ u(re, { size: "sm", onClick: t, variant: e ? "default" : "ghost", children: /* @__PURE__ */ u(Ws, { className: "w-4 h-4" }) });
4082
+ }, is = "lang", ko = {
4083
+ id: is,
4084
+ label: "Languages",
4085
+ position: "top",
4086
+ panel: ho,
4087
+ button: Go
4088
+ }, Do = () => {
4089
+ const { selectedLang: e } = Ot(), { data: t, isFetching: n } = On();
4090
+ return { data: me(() => Se(t, { lang: e || "" }) || {}, [t, e]), isFetching: n };
4091
+ };
4092
+ function Ce({
4093
+ data: e,
4094
+ onSelect: t,
4095
+ dataType: n = "value",
4096
+ disabled: r = !1
4097
+ }) {
4098
+ const [s, a] = Z.useState(!1), [i, o] = Z.useState([]), [l, d] = Z.useState(e);
4099
+ Z.useEffect(() => {
4100
+ s || o([]), d(e);
4101
+ }, [e, s]);
4102
+ const h = (E) => Array.isArray(E) ? "array" : typeof E == "object" && E !== null ? "object" : "value", g = Z.useCallback(
4103
+ (E) => {
4104
+ const N = (y) => n === "value" ? y === "value" || y === "object" : n === "array" ? y === "array" : y === n;
4105
+ E.type === "object" ? (o((y) => [...y, E.key]), d(E.value)) : N(E.type) && (t([...i, E.key].join(".")), a(!1));
4106
+ },
4107
+ [i, t, n]
4108
+ ), v = Z.useCallback(() => {
4109
+ if (i.length > 0) {
4110
+ const E = i.slice(0, -1);
4111
+ o(E), d(E.reduce((N, y) => N[y], e));
4112
+ }
4113
+ }, [i, e]), A = Z.useMemo(() => Object.entries(l).map(([E, N]) => ({
4114
+ key: E,
4115
+ value: N,
4116
+ type: h(N)
4117
+ })).filter((E) => n === "value" ? E.type === "value" || E.type === "object" : n === "array" ? E.type === "array" || E.type === "object" : n === "object" ? E.type === "object" : !0), [l, n]);
4118
+ return /* @__PURE__ */ m(da, { open: s, onOpenChange: a, children: [
4119
+ /* @__PURE__ */ m(fa, { children: [
4120
+ /* @__PURE__ */ u(ha, { asChild: !0, children: /* @__PURE__ */ u(ga, { asChild: !0, children: /* @__PURE__ */ u(
4121
+ re,
4122
+ {
4123
+ size: "sm",
4124
+ variant: "outline",
4125
+ className: "h-6 w-6 px-1 py-0 text-[9px] text-muted-foreground",
4126
+ role: "combobox",
4127
+ "aria-expanded": s,
4128
+ disabled: r,
4129
+ children: /* @__PURE__ */ u(zs, { className: "h-3 w-3" })
4130
+ }
4131
+ ) }) }),
4132
+ /* @__PURE__ */ u(ma, { children: "Add field" })
4133
+ ] }),
4134
+ /* @__PURE__ */ u(ya, { className: "w-[200px] p-0", children: /* @__PURE__ */ m(Ea, { children: [
4135
+ /* @__PURE__ */ u(pa, { className: "border-none", placeholder: "Search..." }),
4136
+ /* @__PURE__ */ m(va, { children: [
4137
+ /* @__PURE__ */ u(Sa, { children: "No option found." }),
4138
+ /* @__PURE__ */ m(Aa, { children: [
4139
+ i.length > 0 && /* @__PURE__ */ m(
4140
+ zn,
4141
+ {
4142
+ onSelect: v,
4143
+ className: "flex items-center text-sm",
4144
+ children: [
4145
+ /* @__PURE__ */ u($s, { className: "w-4 h-4 mr-2" }),
4146
+ "Back"
4147
+ ]
4148
+ }
4149
+ ),
4150
+ A.map((E) => /* @__PURE__ */ m(
4151
+ zn,
4152
+ {
4153
+ onSelect: () => g(E),
4154
+ className: "flex items-center justify-between",
4155
+ children: [
4156
+ /* @__PURE__ */ u("span", { children: E.key }),
4157
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
4158
+ n === "object" && E.type === "object" && /* @__PURE__ */ u(
4159
+ re,
4160
+ {
4161
+ size: "sm",
4162
+ variant: "ghost",
4163
+ className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4164
+ onClick: (N) => {
4165
+ N.stopPropagation(), t([...i, E.key].join(".")), a(!1);
4166
+ },
4167
+ children: "Select"
4168
+ }
4169
+ ),
4170
+ (E.type === "object" || E.type === "array") && /* @__PURE__ */ u("div", { className: "p-1 rounded hover:bg-muted cursor-pointer", children: /* @__PURE__ */ u(Qs, { className: "w-4 h-4 opacity-50" }) })
4171
+ ] })
4172
+ ]
4173
+ },
4174
+ E.key
4175
+ ))
4176
+ ] })
4177
+ ] })
4178
+ ] }) })
4179
+ ] });
4180
+ }
4181
+ const Oo = (e, t) => {
4182
+ const n = e.selectionStart || 0, r = e.selectionEnd || 0, s = e.value, a = s.substring(0, n), i = s.substring(r);
4183
+ let o = !1;
4184
+ if (n > 0 && a.length > 0) {
4185
+ const E = a.charAt(a.length - 1);
4186
+ o = !/[\s.,!?;:()[\]{}]/.test(E) && E !== "";
4187
+ }
4188
+ let l = !1;
4189
+ if (i.length > 0) {
4190
+ const E = i.charAt(0);
4191
+ l = !/[\s.,!?;:()[\]{}]/.test(E) && E !== "";
4192
+ }
4193
+ const d = o ? " " : "", h = l ? " " : "", g = `{{${t}}}`, v = a + (o ? d : "") + g + (l ? h : "") + i, A = n + (o ? 1 : 0) + // Account for space before if added
4194
+ g.length;
4195
+ return {
4196
+ value: v,
4197
+ newCursorPos: A
4198
+ };
4199
+ }, os = () => {
4200
+ const { t: e } = As(), { selectedLang: t, fallbackLang: n, languages: r } = Ot(), { data: s } = ft(), { data: a } = as({
4201
+ lang: t || n,
4202
+ pageType: s == null ? void 0 : s.pageType
4203
+ }), { data: i, isFetching: o } = Do(), l = i == null ? void 0 : i.seo, d = $t(
4204
+ null
4205
+ ), [h, g] = ge({
4206
+ title: "",
4207
+ description: "",
4208
+ cononicalUrl: "",
4209
+ noIndex: !1,
4210
+ noFollow: "",
4211
+ ogTitle: "",
4212
+ ogDescription: "",
4213
+ ogImage: "",
4214
+ searchTitle: "",
4215
+ searchDescription: "",
4216
+ jsonLD: "",
4217
+ ...l
4218
+ }), v = $t({ initial: h, updated: h }), A = t.length ? t : n, { mutate: E, isPending: N } = rs(), y = N, { hasPermission: Q } = ir(), p = Q(Oe.EDIT_SEO);
4219
+ Ut(() => {
4220
+ !o && l && g({
4221
+ title: "",
4222
+ description: "",
4223
+ cononicalUrl: "",
4224
+ noIndex: !1,
4225
+ noFollow: "",
4226
+ ogTitle: "",
4227
+ ogDescription: "",
4228
+ ogImage: "",
4229
+ searchTitle: "",
4230
+ searchDescription: "",
4231
+ jsonLD: "",
4232
+ ...l
4233
+ });
4234
+ }, [o, l]);
4235
+ const C = async () => {
4236
+ E({ id: i == null ? void 0 : i.id, seo: h }), v.current.initial = h, v.current.updated = h;
4237
+ }, O = () => {
4238
+ g({
4239
+ ...h,
4240
+ ogTitle: h.title,
4241
+ ogDescription: h.description
4242
+ });
4243
+ }, q = () => {
4244
+ g({
4245
+ ...h,
4246
+ searchTitle: h.ogTitle,
4247
+ searchDescription: h.ogDescription
4248
+ });
4249
+ }, ie = (k, B) => {
4250
+ const U = document.getElementById(B);
4251
+ if (U) {
4252
+ const { value: K, newCursorPos: ne } = Oo(
4253
+ U,
4254
+ k
4255
+ );
4256
+ d.current = {
4257
+ id: B,
4258
+ position: ne
4259
+ }, U.tagName.toLowerCase() === "input" ? (U.value = K, g((V) => ({
4260
+ ...V,
4261
+ [U.name]: K
4262
+ })), U.focus(), U.setSelectionRange(ne, ne), [0, 10, 50, 100, 200].forEach((V) => {
4263
+ setTimeout(() => {
4264
+ const he = document.getElementById(B);
4265
+ he && (he.focus(), he.setSelectionRange(ne, ne));
4266
+ }, V);
4267
+ })) : (g((ye) => ({
4268
+ ...ye,
4269
+ [U.name]: K
4270
+ })), requestAnimationFrame(() => {
4271
+ const ye = document.getElementById(
4272
+ B
4273
+ );
4274
+ ye && (ye.focus(), ye.setSelectionRange(ne, ne), setTimeout(() => {
4275
+ const V = document.getElementById(
4276
+ B
4277
+ );
4278
+ V && (V.focus(), V.setSelectionRange(ne, ne));
4279
+ }, 50));
4280
+ }));
4281
+ }
4282
+ }, se = (k) => {
4283
+ const B = {
4284
+ ...h,
4285
+ [k.target.name]: k.target.name === "noIndex" || k.target.name === "noFollow" ? k.target.checked : k.target.value
4286
+ };
4287
+ g(B), v.current.updated = B;
4288
+ };
4289
+ return /* @__PURE__ */ m("div", { className: "relative pb-40", children: [
4290
+ !p && /* @__PURE__ */ u("div", { className: "absolute inset-0 z-10 backdrop-blur-sm flex items-center justify-center", children: /* @__PURE__ */ u(dr, { variant: "default", className: "w-[80%] max-w-md text-xs", children: /* @__PURE__ */ u(wa, { children: e(
4291
+ "You don't have permission to edit SEO settings. Contact your administrator for access."
4292
+ ) }) }) }),
4293
+ /* @__PURE__ */ m("div", { className: "p-2 text-xs text-left bg-gray-100 rounded-md", children: [
4294
+ e("Slug"),
4295
+ ": ",
4296
+ i == null ? void 0 : i.slug,
4297
+ "  ",
4298
+ r.length > 0 && /* @__PURE__ */ m("span", { className: "font-semibold text-blue-500", children: [
4299
+ "(",
4300
+ ae(qe, A, A),
4301
+ ")"
4302
+ ] })
4303
+ ] }),
4304
+ /* @__PURE__ */ u("form", { className: "space-y-8", children: /* @__PURE__ */ m(ba, { type: "multiple", defaultValue: ["page"], children: [
4305
+ /* @__PURE__ */ m(Mt, { value: "page", children: [
4306
+ /* @__PURE__ */ u(Bt, { className: "font-semibold text-slate-700", children: e("SEO") }),
4307
+ /* @__PURE__ */ u(Ft, { className: "pt-2", children: /* @__PURE__ */ m("div", { className: "space-y-4", children: [
4308
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4309
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4310
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "title", children: e("SEO Title") }),
4311
+ p && /* @__PURE__ */ u(
4312
+ Ce,
4313
+ {
4314
+ dataType: "value",
4315
+ data: a ?? {},
4316
+ onSelect: (k) => ie(k, "title")
4317
+ }
4318
+ )
4319
+ ] }),
4320
+ /* @__PURE__ */ u(
4321
+ Te,
4322
+ {
4323
+ type: "text",
4324
+ id: "title",
4325
+ name: "title",
4326
+ value: h.title,
4327
+ onChange: se,
4328
+ disabled: y || !p,
4329
+ placeholder: e("Enter SEO title"),
4330
+ readOnly: !p
4331
+ }
4332
+ )
4333
+ ] }),
4334
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4335
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4336
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "description", children: e("SEO Description") }),
4337
+ p && /* @__PURE__ */ u(
4338
+ Ce,
4339
+ {
4340
+ data: a ?? {},
4341
+ onSelect: (k) => ie(k, "description")
4342
+ }
4343
+ )
4344
+ ] }),
4345
+ /* @__PURE__ */ u(
4346
+ jt,
4347
+ {
4348
+ id: "description",
4349
+ name: "description",
4350
+ rows: 5,
4351
+ value: h.description,
4352
+ onChange: se,
4353
+ disabled: y || !p,
4354
+ placeholder: e("Enter SEO description"),
4355
+ readOnly: !p
4356
+ }
4357
+ )
4358
+ ] }),
4359
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4360
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4361
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "title", children: e("Canonical URL") }),
4362
+ p && /* @__PURE__ */ u(
4363
+ Ce,
4364
+ {
4365
+ dataType: "value",
4366
+ data: a ?? {},
4367
+ onSelect: (k) => ie(k, "canonicalUrl")
4368
+ }
4369
+ )
4370
+ ] }),
4371
+ /* @__PURE__ */ u(
4372
+ Te,
4373
+ {
4374
+ type: "text",
4375
+ id: "canonicalUrl",
4376
+ name: "canonicalUrl",
4377
+ value: h.canonicalUrl,
4378
+ onChange: se,
4379
+ disabled: y || !p,
4380
+ placeholder: e("Enter Canonical URL"),
4381
+ readOnly: !p
4382
+ }
4383
+ )
4384
+ ] }),
4385
+ /* @__PURE__ */ m("div", { className: "", children: [
4386
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-x-2", children: [
4387
+ /* @__PURE__ */ u(
4388
+ Te,
4389
+ {
4390
+ type: "checkbox",
4391
+ id: "noIndex",
4392
+ name: "noIndex",
4393
+ checked: h.noIndex,
4394
+ onChange: se,
4395
+ disabled: y || !p,
4396
+ className: "w-4 h-4"
4397
+ }
4398
+ ),
4399
+ /* @__PURE__ */ u(ue, { className: "pb-1 text-xs", htmlFor: "noIndex", children: e("No Index") })
4400
+ ] }),
4401
+ /* @__PURE__ */ u("p", { className: "mt-0 text-[10px] font-light text-gray-400 leading-4", children: e(
4402
+ "Check this if you don't want search engines to index this page."
4403
+ ) })
4404
+ ] }),
4405
+ /* @__PURE__ */ m("div", { className: "", children: [
4406
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-x-2", children: [
4407
+ /* @__PURE__ */ u(
4408
+ Te,
4409
+ {
4410
+ type: "checkbox",
4411
+ id: "noFollow",
4412
+ name: "noFollow",
4413
+ checked: h.noFollow,
4414
+ onChange: se,
4415
+ disabled: y || !p,
4416
+ className: "w-4 h-4"
4417
+ }
4418
+ ),
4419
+ /* @__PURE__ */ u(ue, { className: "pb-1 text-xs", htmlFor: "noIndex", children: e("No Follow") })
4420
+ ] }),
4421
+ /* @__PURE__ */ u("p", { className: "text-[10px] font-light text-gray-400 leading-4", children: e(
4422
+ "Check this if you don't want search engines to follow links on this page."
4423
+ ) })
4424
+ ] })
4425
+ ] }) })
4426
+ ] }),
4427
+ /* @__PURE__ */ m(Mt, { value: "og", children: [
4428
+ /* @__PURE__ */ u(Bt, { className: "font-bold text-slate-700", children: e("Open Graph") }),
4429
+ /* @__PURE__ */ u(Ft, { children: /* @__PURE__ */ m("div", { className: "space-y-4", children: [
4430
+ /* @__PURE__ */ u("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ u(
4431
+ re,
4432
+ {
4433
+ type: "button",
4434
+ variant: "outline",
4435
+ size: "sm",
4436
+ onClick: O,
4437
+ disabled: !p,
4438
+ children: e("Copy from SEO Settings")
4439
+ }
4440
+ ) }),
4441
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4442
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4443
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "ogTitle", children: e("OG Title") }),
4444
+ p && /* @__PURE__ */ u(
4445
+ Ce,
4446
+ {
4447
+ dataType: "value",
4448
+ data: a ?? {},
4449
+ onSelect: (k) => ie(k, "ogTitle")
4450
+ }
4451
+ )
4452
+ ] }),
4453
+ /* @__PURE__ */ u(
4454
+ Te,
4455
+ {
4456
+ type: "text",
4457
+ id: "ogTitle",
4458
+ name: "ogTitle",
4459
+ value: h.ogTitle,
4460
+ onChange: se,
4461
+ disabled: y || !p,
4462
+ placeholder: e("Enter OG title"),
4463
+ readOnly: !p
4464
+ }
4465
+ )
4466
+ ] }),
4467
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4468
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4469
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "ogDescription", children: e("OG Description") }),
4470
+ p && /* @__PURE__ */ u(
4471
+ Ce,
4472
+ {
4473
+ dataType: "value",
4474
+ data: a ?? {},
4475
+ onSelect: (k) => ie(k, "ogDescription")
4476
+ }
4477
+ )
4478
+ ] }),
4479
+ /* @__PURE__ */ u(
4480
+ jt,
4481
+ {
4482
+ id: "ogDescription",
4483
+ name: "ogDescription",
4484
+ rows: 5,
4485
+ value: h.ogDescription,
4486
+ onChange: se,
4487
+ disabled: y || !p,
4488
+ placeholder: e("Enter OG description"),
4489
+ readOnly: !p
4490
+ }
4491
+ )
4492
+ ] }),
4493
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4494
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4495
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "ogImage", children: e("OG Image URL") }),
4496
+ p && /* @__PURE__ */ u(
4497
+ Ce,
4498
+ {
4499
+ dataType: "value",
4500
+ data: a ?? {},
4501
+ onSelect: (k) => ie(k, "ogImage")
4502
+ }
4503
+ )
4504
+ ] }),
4505
+ /* @__PURE__ */ u(
4506
+ Te,
4507
+ {
4508
+ type: "text",
4509
+ id: "ogImage",
4510
+ name: "ogImage",
4511
+ value: h.ogImage,
4512
+ onChange: se,
4513
+ disabled: y || !p,
4514
+ placeholder: e("Enter OG image URL"),
4515
+ readOnly: !p
4516
+ }
4517
+ )
4518
+ ] })
4519
+ ] }) })
4520
+ ] }),
4521
+ /* @__PURE__ */ m(Mt, { value: "search", children: [
4522
+ /* @__PURE__ */ u(Bt, { className: "font-bold text-slate-700", children: e("Search") }),
4523
+ /* @__PURE__ */ u(Ft, { children: /* @__PURE__ */ m("div", { className: "space-y-4", children: [
4524
+ /* @__PURE__ */ u("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ u(
4525
+ re,
4526
+ {
4527
+ type: "button",
4528
+ variant: "outline",
4529
+ size: "sm",
4530
+ onClick: q,
4531
+ disabled: !p,
4532
+ children: e("Copy from OG Settings")
4533
+ }
4534
+ ) }),
4535
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4536
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4537
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "searchTitle", children: e("Search Title") }),
4538
+ p && /* @__PURE__ */ u(
4539
+ Ce,
4540
+ {
4541
+ dataType: "value",
4542
+ data: a ?? {},
4543
+ onSelect: (k) => ie(k, "searchTitle")
4544
+ }
4545
+ )
4546
+ ] }),
4547
+ /* @__PURE__ */ u(
4548
+ Te,
4549
+ {
4550
+ type: "text",
4551
+ id: "searchTitle",
4552
+ name: "searchTitle",
4553
+ value: h.searchTitle,
4554
+ onChange: se,
4555
+ disabled: y || !p,
4556
+ placeholder: e("Enter search title"),
4557
+ readOnly: !p
4558
+ }
4559
+ )
4560
+ ] }),
4561
+ /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4562
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4563
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "searchDescription", children: e("Search Description") }),
4564
+ p && /* @__PURE__ */ u(
4565
+ Ce,
4566
+ {
4567
+ dataType: "value",
4568
+ data: a ?? {},
4569
+ onSelect: (k) => ie(k, "searchDescription")
4570
+ }
4571
+ )
4572
+ ] }),
4573
+ /* @__PURE__ */ u(
4574
+ jt,
4575
+ {
4576
+ id: "searchDescription",
4577
+ rows: 5,
4578
+ name: "searchDescription",
4579
+ value: h.searchDescription,
4580
+ onChange: se,
4581
+ placeholder: e("Enter search description"),
4582
+ disabled: y || !p,
4583
+ readOnly: !p
4584
+ }
4585
+ )
4586
+ ] })
4587
+ ] }) })
4588
+ ] }),
4589
+ /* @__PURE__ */ m(Mt, { value: "jsonLD", children: [
4590
+ /* @__PURE__ */ u(Bt, { className: "font-bold text-slate-700", children: e("JSON-LD") }),
4591
+ /* @__PURE__ */ u(Ft, { children: /* @__PURE__ */ u("div", { className: "space-y-4", children: /* @__PURE__ */ m("div", { className: "space-y-1", children: [
4592
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
4593
+ /* @__PURE__ */ u(ue, { className: "text-xs", htmlFor: "jsonLD", children: e("JSON-LD") }),
4594
+ p && /* @__PURE__ */ u(
4595
+ Ce,
4596
+ {
4597
+ dataType: "value",
4598
+ data: a ?? {},
4599
+ onSelect: (k) => ie(k, "jsonLD")
4600
+ }
4601
+ )
4602
+ ] }),
4603
+ /* @__PURE__ */ u(
4604
+ jt,
4605
+ {
4606
+ id: "jsonLD",
4607
+ name: "jsonLD",
4608
+ rows: 6,
4609
+ value: h.jsonLD,
4610
+ onChange: se,
4611
+ placeholder: e("Enter JSON-LD"),
4612
+ disabled: y || !p,
4613
+ readOnly: !p
4614
+ }
4615
+ )
4616
+ ] }) }) })
4617
+ ] })
4618
+ ] }) }),
4619
+ p && /* @__PURE__ */ u("div", { className: "flex items-center justify-end w-full mt-4", children: /* @__PURE__ */ u(
4620
+ re,
4621
+ {
4622
+ size: "lg",
4623
+ variant: "default",
4624
+ onClick: C,
4625
+ disabled: Ln(v.current.initial, h) || y || !p,
4626
+ children: e(N ? "Saving..." : "Save")
4627
+ }
4628
+ ) })
4629
+ ] });
4630
+ };
4631
+ os.displayName = "SeoPanel";
4632
+ const ls = "seo", Uo = ({
4633
+ isActive: e,
4634
+ show: t
4635
+ }) => {
4636
+ const { data: n } = ft(), r = to(n == null ? void 0 : n.pageType);
4637
+ return !tn(r, "hasSlug") || !r.hasSlug ? null : /* @__PURE__ */ u(
4638
+ re,
4639
+ {
4640
+ size: "sm",
4641
+ className: "my-1",
4642
+ onClick: t,
4643
+ variant: e ? "default" : "ghost",
4644
+ children: /* @__PURE__ */ m(
4645
+ "svg",
4646
+ {
4647
+ className: "w-4 h-4",
4648
+ xmlns: "http://www.w3.org/2000/svg",
4649
+ viewBox: "0 0 21 21",
4650
+ fill: "currentColor",
4651
+ children: [
4652
+ /* @__PURE__ */ u("path", { d: "M9.931 6.818c-1.238 0-2.136.925-2.136 2.2 0 1.279.898 2.207 2.136 2.207.664 0 1.257-.246 1.67-.694a.15.15 0 0 0-.009-.213l-.311-.286a.15.15 0 0 0-.213.009c-.273.297-.677.46-1.137.46-.699 0-1.233-.444-1.375-1.12h3.295a.15.15 0 0 0 .151-.151v-.211c0-1.295-.852-2.2-2.072-2.2m0 .724c.697 0 1.188.422 1.315 1.113h-2.69c.142-.673.676-1.113 1.374-1.113m4.332-.724c-1.246 0-2.15.925-2.15 2.2 0 1.279.904 2.207 2.15 2.207.596 0 1.143-.223 1.538-.628s.612-.965.612-1.579c0-1.275-.904-2.2-2.15-2.2m0 3.683c-.826 0-1.426-.624-1.426-1.483 0-.855.6-1.475 1.426-1.475s1.426.621 1.426 1.476c0 .423-.144.804-.406 1.073-.258.264-.62.41-1.019.41M6.318 8.71c-.665-.206-.902-.335-.902-.645 0-.47.564-.521.806-.521.29 0 .552.07.801.215a.15.15 0 0 0 .206-.055l.212-.366a.15.15 0 0 0-.055-.206 2.27 2.27 0 0 0-1.165-.312c-.915 0-1.53.501-1.53 1.245 0 .899.816 1.152 1.411 1.336.655.203.812.307.804.53-.016.398-.567.429-.735.429-.386 0-.722-.129-.972-.374q-.043-.042-.107-.043a.15.15 0 0 0-.106.045l-.295.302a.15.15 0 0 0 .002.213c.383.374.908.58 1.478.58.859 0 1.432-.441 1.459-1.125.031-.833-.746-1.074-1.313-1.249" }),
4653
+ /* @__PURE__ */ u("path", { d: "M20.396 2.049H.604A.604.604 0 0 0 0 2.653v12.7c0 .333.27.604.604.604h6.941c-.266 1.296-.881 1.966-.886 1.971a.604.604 0 0 0 .434 1.024h6.815a.604.604 0 0 0 .434-1.024c-.007-.007-.621-.675-.886-1.971h6.941c.333 0 .604-.27.604-.604V2.652a.604.604 0 0 0-.604-.604m-.604 12.701h-.985v-.17a.604.604 0 0 0-1.208 0v.17h-.63v-.17a.604.604 0 0 0-1.208 0v.17H1.207V3.256h18.585z" })
4654
+ ]
4655
+ }
4656
+ )
4657
+ }
4658
+ );
4659
+ }, Ro = {
4660
+ id: ls,
4661
+ label: "SEO",
4662
+ panel: os,
4663
+ button: Uo,
4664
+ position: "top"
4665
+ }, Mo = () => {
4666
+ Vn(ls, Ro), Vn(is, ko);
4667
+ };
4668
+ bs();
4669
+ Mo();
4670
+ const Bo = (e) => {
4671
+ const t = $t([]), [n] = ke(), r = n.get("page"), s = n.get("lang"), { data: a } = ft(), {
4672
+ data: i = {
4673
+ role: "",
4674
+ permissions: null
4675
+ }
4676
+ } = xo(), { data: o } = To(), { data: l, isFetching: d } = ss(), { blocks: h } = bo(l), { data: g } = fn(), { data: v } = De(), { mutateAsync: A } = Jr(), E = Ao(), { getUILibraryBlock: N, getUILibraryBlocks: y, onSave: Q } = _o(), { getPartialBlocks: p, getPartialBlockBlocks: C } = Po(), { aiContext: O, setAiContext: q } = Mn(), { mutateAsync: ie } = no(), [se, k] = ge(!1), B = me(
4677
+ () => (g == null ? void 0 : g.fallbackLang) || "en",
4678
+ [g]
4679
+ ), { data: U } = as({
4680
+ pageType: a == null ? void 0 : a.pageType,
4681
+ lang: s || B
4682
+ });
4683
+ Zi(), Ut(() => {
4684
+ const V = () => {
4685
+ document.hidden ? k(!0) : k(!1);
4686
+ };
4687
+ return window.addEventListener("visibilitychange", V), () => window.removeEventListener("visibilitychange", V);
4688
+ }, []), t.current = h;
4689
+ const K = me(() => {
4690
+ const V = {};
4691
+ return i && (V.permissions = ae(i, "permissions", null), V.role = ae(i, "role", "user")), V;
4692
+ }, [i]), ne = me(() => o, [o]), Rt = Ue(
4693
+ async (V, he) => await ie({ pageType: V, query: he }),
4694
+ [ie]
4695
+ ), ye = me(
4696
+ () => ae(g, "theme", {}) || {},
4697
+ [g]
4698
+ );
4699
+ return /* @__PURE__ */ m(ar, { children: [
4700
+ d && /* @__PURE__ */ u("div", { className: "absolute inset-0 z-50 flex items-center justify-center w-screen h-screen bg-white/30", children: /* @__PURE__ */ u("div", { className: "flex items-center justify-center bg-white rounded-full size-10", children: /* @__PURE__ */ u(Ys, { className: "size-5 animate-spin" }) }) }),
4701
+ /* @__PURE__ */ u(
4702
+ ws,
4703
+ {
4704
+ pageExternalData: U,
4705
+ themePresets: e.themePresets ?? [],
4706
+ pageId: a == null ? void 0 : a.id,
4707
+ loading: d,
4708
+ fallbackLang: B,
4709
+ languages: (g == null ? void 0 : g.languages) || [],
4710
+ brandingOptions: (g == null ? void 0 : g.theme) || {},
4711
+ translations: e.translations || {},
4712
+ locale: e.locale || "en",
4713
+ htmlDir: e.htmlDir || "ltr",
4714
+ autoSaveSupport: !se && (e.autoSaveSupport ?? !0),
4715
+ autoSaveInterval: e.autoSaveInterval ?? 15,
4716
+ onError: e.onError || console.error,
4717
+ getPartialBlockBlocks: C,
4718
+ getPartialBlocks: p,
4719
+ blocks: d ? [] : h,
4720
+ theme: Rs(ye),
4721
+ getUILibraryBlock: N,
4722
+ getUILibraryBlocks: y,
4723
+ uiLibraries: ne,
4724
+ pageTypes: v,
4725
+ searchPageTypeItems: Rt,
4726
+ saveAiContextCallback: async (V) => {
4727
+ if (!r) return !0;
4728
+ const he = t.current, ht = {
4729
+ _type: "@chai/ai-context",
4730
+ _value: Wn(V) ? V : ""
4731
+ }, We = [...he, ht];
4732
+ return await Q({ page: r, blocks: We }), q(V), !0;
4733
+ },
4734
+ aiContext: O,
4735
+ askAiCallBack: E,
4736
+ onSave: async ({ blocks: V, theme: he }) => {
4737
+ if (!r) return !0;
4738
+ t.current = V;
4739
+ const ht = {
4740
+ _type: "@chai/ai-context",
4741
+ _value: Wn(O) ? O : ""
4742
+ }, We = [...V, ht];
4743
+ return await Q({ page: r, blocks: We }), t.current = We, Ln(he, ye) || await A({ settings: { theme: he } }), !0;
4744
+ },
4745
+ themePanelComponent: Lo,
4746
+ ...K
4747
+ }
4748
+ ),
4749
+ /* @__PURE__ */ m("div", { children: [
4750
+ /* @__PURE__ */ u(Co, {}),
4751
+ /* @__PURE__ */ u(Io, {})
4752
+ ] })
4753
+ ] });
4754
+ }, Fo = new Ts({
4755
+ defaultOptions: {
4756
+ queries: {
4757
+ refetchOnWindowFocus: !1,
4758
+ refetchOnReconnect: !1
4759
+ }
4760
+ }
4761
+ }), Nl = (e) => {
4762
+ const [, t] = es(), [n, r] = ge(!1);
4763
+ return Ut(() => (t(
4764
+ cr(e, [
4765
+ "apiUrl",
4766
+ "getPreviewUrl",
4767
+ "logo",
4768
+ "settingComponent",
4769
+ "user",
4770
+ "onSessionExpired",
4771
+ "pageLockComponent"
4772
+ ])
4773
+ ), setTimeout(() => {
4774
+ r(!0);
4775
+ }, 200), () => {
4776
+ r(!1), t({});
4777
+ }), [e, t]), n ? /* @__PURE__ */ m(_s, { client: Fo, children: [
4778
+ /* @__PURE__ */ u(Bo, { ...e }),
4779
+ /* @__PURE__ */ u(Yi, {})
4780
+ ] }) : /* @__PURE__ */ u("div", {});
4781
+ };
4782
+ if (typeof window > "u")
4783
+ throw new Error("@chaibuilder/pages is not available on the server");
4784
+ export {
4785
+ pr as $,
4786
+ Al as A,
4787
+ Jo as B,
4788
+ fl as C,
4789
+ gl as D,
4790
+ le as E,
4791
+ il as F,
4792
+ Pa as G,
4793
+ Hi as H,
4794
+ ol as I,
4795
+ Vt as J,
4796
+ Tl as K,
4797
+ El as L,
4798
+ yl as M,
4799
+ je as N,
4800
+ ri as O,
4801
+ hl as P,
4802
+ ml as Q,
4803
+ ul as R,
4804
+ ll as S,
4805
+ cl as T,
4806
+ Wt as U,
4807
+ nl as V,
4808
+ Nl as W,
4809
+ gt as X,
4810
+ ft as Y,
4811
+ On as Z,
4812
+ ts as _,
4813
+ Nr as a,
4814
+ fn as a0,
4815
+ xo as a1,
4816
+ ee as a2,
4817
+ Pl as a3,
4818
+ mo as a4,
4819
+ J as b,
4820
+ fe as c,
4821
+ Ja as d,
4822
+ Ar as e,
4823
+ Cr as f,
4824
+ _l as g,
4825
+ ja as h,
4826
+ rl as i,
4827
+ He as j,
4828
+ bn as k,
4829
+ al as l,
4830
+ bl as m,
4831
+ vt as n,
4832
+ el as o,
4833
+ Ia as p,
4834
+ oi as q,
4835
+ Tn as r,
4836
+ wl as s,
4837
+ dl as t,
4838
+ sl as u,
4839
+ ni as v,
4840
+ pl as w,
4841
+ vl as x,
4842
+ ii as y,
4843
+ Sl as z
4844
+ };