@chaibuilder/sdk 1.2.25 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddBlocks-l1JENNvq.js +206 -0
- package/dist/AddBlocks-zPPKkeKs.cjs +1 -0
- package/dist/BrandingOptions-DkpqGARR.cjs +1 -0
- package/dist/{BrandingOptions-iTyWpwTs.js → BrandingOptions-udtH5yJs.js} +54 -40
- package/dist/{CanvasArea-dZjng782.js → CanvasArea-h0W-Tyha.js} +324 -340
- package/dist/CanvasArea-zme1r3Zi.cjs +55 -0
- package/dist/Class-PoYusiA5.cjs +1 -0
- package/dist/{Class-ahc3NIbq.js → Class-lGzsNBOK.js} +29 -26
- package/dist/CurrentPage-Hl52iub_.cjs +1 -0
- package/dist/{CurrentPage-Kmfp-kFk.js → CurrentPage-tJUjXWdb.js} +54 -40
- package/dist/Functions-7jnEwJyw.js +15 -0
- package/dist/Functions-N3yhPYKY.cjs +1 -0
- package/dist/ListTree-WvTjY5rr.cjs +1 -0
- package/dist/{ListTree-N3jeD790.js → ListTree-cZ-Ihlt3.js} +96 -86
- package/dist/MODIFIERS-0g14w5RS.cjs +1 -0
- package/dist/{MODIFIERS-CNqNUapY.js → MODIFIERS-dytZ-osO.js} +4 -10
- package/dist/PagesPanel-6rrLXEO-.js +64 -0
- package/dist/PagesPanel-WzCocl6u.cjs +1 -0
- package/dist/ProjectPanel-o7gdcwPn.cjs +1 -0
- package/dist/ProjectPanel-tz3bjdXy.js +85 -0
- package/dist/{STRINGS-b432aBJJ.js → STRINGS--j49GZJP.js} +2 -2
- package/dist/{Settings-jCcd-VE6.js → Settings-4s2LUVmC.js} +401 -407
- package/dist/Settings-AqoKwR92.cjs +1 -0
- package/dist/SidePanels-3o6Okmvu.cjs +1 -0
- package/dist/{SidePanels-pHMYprpW.js → SidePanels-bugFfInz.js} +118 -108
- package/dist/Topbar-CqW7G360.cjs +1 -0
- package/dist/Topbar-pWzBEOed.js +132 -0
- package/dist/UnsplashImages-NGskB93R.cjs +1 -0
- package/dist/{UnsplashImages-L7x_3RQf.js → UnsplashImages-qvwFbV-E.js} +63 -50
- package/dist/{UploadImages-zdEJRLD8.js → UploadImages-9NapgXBq.js} +60 -37
- package/dist/UploadImages-Oh7Glr9A.cjs +1 -0
- package/dist/_commonjsHelpers-UyOWmZb0.js +8 -0
- package/dist/_commonjsHelpers-wDK0ZLPo.cjs +1 -0
- package/dist/add-page-modal--6TTBRYa.cjs +1 -0
- package/dist/add-page-modal-k2Kb92HS.js +104 -0
- package/dist/confirm-alert-C4M9eF-o.cjs +1 -0
- package/dist/confirm-alert-GUhZ_G8w.js +60 -0
- package/dist/controls-KK2oLIa8.cjs +1 -0
- package/dist/{controls-IS5qnRce.js → controls-OfJWSEqC.js} +85 -20
- package/dist/core.cjs +1 -1
- package/dist/core.js +75 -150
- package/dist/defaultTheme-7VqqhOcp.cjs +1 -0
- package/dist/{defaultTheme-4kA60XdB.js → defaultTheme-D8B4-wHO.js} +8 -6
- package/dist/delete-page-modal-cFoL-wdo.cjs +1 -0
- package/dist/delete-page-modal-zONvdebd.js +83 -0
- package/dist/email-blocks.cjs +1 -1
- package/dist/email-blocks.js +292 -3
- package/dist/email.cjs +1 -1
- package/dist/email.js +37 -18
- package/dist/empty-slot-ZBlsQi6m.js +15 -0
- package/dist/empty-slot-nzYOgZuS.cjs +1 -0
- package/dist/{form-0_RLz2TB.js → form-STUz-6nE.js} +12 -12
- package/dist/form-lBQ_76Uw.cjs +1 -0
- package/dist/{html-to-json-uSnxl72F.cjs → html-to-json-efmv1pCj.cjs} +1 -1
- package/dist/{html-to-json-2xtb7520.js → html-to-json-ngX9ef2u.js} +41 -41
- package/dist/index-Gk6sASBd.js +3080 -0
- package/dist/index-OB199Izc.cjs +206 -0
- package/dist/index-SkyM3d6Q.js +39503 -0
- package/dist/index-YpnaudSM.js +63 -0
- package/dist/index-e0c8PmRQ.js +205 -0
- package/dist/index-ecnGWzh9.cjs +1 -0
- package/dist/index-gi1LIOCw.cjs +1 -0
- package/dist/index-h-hd6EvN.cjs +1 -0
- package/dist/index-llTXLDGE.js +2201 -0
- package/dist/index-mbyqq81O.cjs +1 -0
- package/dist/{jsx-runtime-Sp0orL4X.js → jsx-runtime-WbnYoNE9.js} +109 -106
- package/dist/jsx-runtime-Z_BpKhVy.cjs +27 -0
- package/dist/lib.cjs +2 -2
- package/dist/lib.js +66 -62
- package/dist/page-viewer-2kwnKM6v.cjs +1 -0
- package/dist/{page-viewer-NnOwmAmu.js → page-viewer-Pdg9F5Hv.js} +57 -43
- package/dist/project-general-setting-CnNL98NM.cjs +1 -0
- package/dist/{project-general-setting-9ju3TDju.js → project-general-setting-f8Ebsn6K.js} +43 -35
- package/dist/project-seo-setting-mlxL_e2_.cjs +1 -0
- package/dist/{project-seo-setting-36CdUszM.js → project-seo-setting-pX34Qsym.js} +40 -23
- package/dist/render.cjs +1 -1
- package/dist/render.js +14 -13
- package/dist/single-page-detail-XfzrGlzA.cjs +1 -0
- package/dist/{single-page-detail-hD1jKZ8k.js → single-page-detail-dpe5LT0M.js} +74 -66
- package/dist/studio.cjs +1 -1
- package/dist/studio.js +40 -24
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +160 -365
- package/dist/web-blocks.cjs +6 -1
- package/dist/web-blocks.js +1153 -3
- package/package.json +1 -1
- package/dist/AddBlocks-Ol3iIVKa.js +0 -207
- package/dist/AddBlocks-a1c-7Ewz.cjs +0 -1
- package/dist/BrandingOptions-6rnt0UaA.cjs +0 -1
- package/dist/CanvasArea-R4ogF9AT.cjs +0 -55
- package/dist/ChaiBuilderEditor-m30yoOgJ.cjs +0 -163
- package/dist/ChaiBuilderEditor-vP4at00I.js +0 -27974
- package/dist/Class-eieto7e-.cjs +0 -1
- package/dist/Controls-3Cc1XYXg.js +0 -105
- package/dist/Controls-ky25Ebo3.cjs +0 -1
- package/dist/CurrentPage-3gQTH0Zt.cjs +0 -1
- package/dist/Functions-Hvon6AMZ.cjs +0 -1
- package/dist/Functions-NzT2Six_.js +0 -15
- package/dist/ImagesPanel-J1RlG7xG.cjs +0 -1
- package/dist/ImagesPanel-Wb0GF_NA.js +0 -29
- package/dist/ListTree-CZ-mtjZ9.cjs +0 -1
- package/dist/MODIFIERS-o1p3VnpS.cjs +0 -1
- package/dist/PagesPanel-Gi0z6gaf.cjs +0 -1
- package/dist/PagesPanel-u1IB-nRr.js +0 -48
- package/dist/ProjectPanel-EydGZmMW.js +0 -71
- package/dist/ProjectPanel-kiiljG4H.cjs +0 -1
- package/dist/Settings-8ilCSH8b.cjs +0 -1
- package/dist/SidePanels-T36C6Lhc.cjs +0 -1
- package/dist/Topbar-CvWQuspR.cjs +0 -1
- package/dist/Topbar-pbIDUE_B.js +0 -122
- package/dist/UnsplashImages-KBZPd9dv.cjs +0 -1
- package/dist/UploadImages-GkkJVAgG.cjs +0 -1
- package/dist/accordion-oPUeqPCZ.js +0 -42
- package/dist/accordion-ynvFtV_p.cjs +0 -1
- package/dist/add-page-modal-9SGv2hgc.cjs +0 -1
- package/dist/add-page-modal-JCDXZIPW.js +0 -95
- package/dist/alert-dialog-P9xMMB6C.cjs +0 -1
- package/dist/alert-dialog-rypfO5ly.js +0 -64
- package/dist/badge-E-S7CqUt.cjs +0 -1
- package/dist/badge-tEwO7C51.js +0 -23
- package/dist/block-helpers-OKHmRRol.cjs +0 -1
- package/dist/block-helpers-oSFpSsGz.js +0 -23
- package/dist/command-BxR6jaCI.cjs +0 -1
- package/dist/command-Pn3HKDuV.js +0 -97
- package/dist/confirm-alert-uNm0lZ0y.cjs +0 -1
- package/dist/confirm-alert-wR5_VJ1l.js +0 -36
- package/dist/context-menu-8dC9uGXj.js +0 -122
- package/dist/context-menu-IgLbIuth.cjs +0 -1
- package/dist/controls-L7DPvB0m.cjs +0 -1
- package/dist/defaultTheme-mrkeGFGI.cjs +0 -1
- package/dist/delete-page-modal-7KmP1elv.js +0 -67
- package/dist/delete-page-modal-SgfwvfNu.cjs +0 -1
- package/dist/dropdown-menu-El86_9Uo.js +0 -124
- package/dist/dropdown-menu-SiHzqWwZ.cjs +0 -1
- package/dist/form-W58AVUdf.cjs +0 -1
- package/dist/hover-card-KUwpDkW8.cjs +0 -1
- package/dist/hover-card-q138xxXR.js +0 -45
- package/dist/iconBase-gbUAAO2L.cjs +0 -1
- package/dist/iconBase-h4DuR_XT.js +0 -63
- package/dist/index-9MmykVSc.cjs +0 -1
- package/dist/index-hElOGcFr.js +0 -2200
- package/dist/index-lDTsQp7h.js +0 -188
- package/dist/index-rq5Y9ZDy.cjs +0 -1
- package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
- package/dist/label-KaP7MRrs.js +0 -10
- package/dist/label-tFm8HZdb.cjs +0 -1
- package/dist/link-WbcKdQ9k.cjs +0 -1
- package/dist/link-xuhP-4dN.js +0 -196
- package/dist/page-viewer-Hx5hxHKm.cjs +0 -1
- package/dist/popover-a84pbVhQ.js +0 -23
- package/dist/popover-fKjgcRUx.cjs +0 -1
- package/dist/project-general-setting-FxkwjvJz.cjs +0 -1
- package/dist/project-seo-setting-RU7qiXxb.cjs +0 -1
- package/dist/scroll-area-FiHvy-TZ.cjs +0 -1
- package/dist/scroll-area-ewXbxc3n.js +0 -30
- package/dist/select-7bjg-rr9.cjs +0 -1
- package/dist/select-POGdEDHT.js +0 -75
- package/dist/separator-3Civ-6hb.cjs +0 -1
- package/dist/separator-SctTn0Qi.js +0 -18
- package/dist/single-page-detail-beY0MT1b.cjs +0 -1
- package/dist/skeleton-STeL9VrJ.cjs +0 -1
- package/dist/skeleton-lu8e7q2y.js +0 -239
- package/dist/tabs-_4WbA1cc.cjs +0 -1
- package/dist/tabs-yQ3oGziM.js +0 -106
- package/dist/textarea-1kZEh7ki.cjs +0 -1
- package/dist/textarea-b2QvVhrK.js +0 -73
- package/dist/useAddBlock-8pxOEYIl.cjs +0 -1
- package/dist/useAddBlock-FEKFJNwQ.js +0 -69
- package/dist/useChaiExternalData-fkFgoS80.js +0 -6
- package/dist/useChaiExternalData-rwoAZ6uU.cjs +0 -1
- package/dist/useDarkMode-7i57segK.cjs +0 -1
- package/dist/useDarkMode-8VHJlYyE.js +0 -23
- package/dist/useSelectedBreakpoints-6NK5qd7T.js +0 -10
- package/dist/useSelectedBreakpoints-7ONXb-vN.cjs +0 -1
- package/dist/useStylingState-Iuj84yvc.js +0 -186
- package/dist/useStylingState-OIvJMV6p.cjs +0 -1
- package/dist/useUiLibraries-nCdauJ4N.cjs +0 -1
- package/dist/useUiLibraries-psyWFbNc.js +0 -12
- package/dist/useUpdateBlocksProps-Unn8lUyj.cjs +0 -1
- package/dist/useUpdateBlocksProps-vWcDp-P9.js +0 -23
- package/dist/utils-dze1SGvB.js +0 -6
- package/dist/utils-qK_SjzzV.cjs +0 -1
package/dist/index-hElOGcFr.js
DELETED
|
@@ -1,2200 +0,0 @@
|
|
|
1
|
-
var lt = (t, e, s) => {
|
|
2
|
-
if (!e.has(t))
|
|
3
|
-
throw TypeError("Cannot " + s);
|
|
4
|
-
};
|
|
5
|
-
var i = (t, e, s) => (lt(t, e, "read from private field"), s ? s.call(t) : e.get(t)), h = (t, e, s) => {
|
|
6
|
-
if (e.has(t))
|
|
7
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
8
|
-
e instanceof WeakSet ? e.add(t) : e.set(t, s);
|
|
9
|
-
}, o = (t, e, s, r) => (lt(t, e, "write to private field"), r ? r.call(t, s) : e.set(t, s), s);
|
|
10
|
-
var rt = (t, e, s, r) => ({
|
|
11
|
-
set _(n) {
|
|
12
|
-
o(t, e, n, s);
|
|
13
|
-
},
|
|
14
|
-
get _() {
|
|
15
|
-
return i(t, e, r);
|
|
16
|
-
}
|
|
17
|
-
}), y = (t, e, s) => (lt(t, e, "access private method"), s);
|
|
18
|
-
import { j as u } from "./jsx-runtime-Sp0orL4X.js";
|
|
19
|
-
import * as M from "react";
|
|
20
|
-
import ps, { lazy as Ft, useCallback as dt, useState as ft, Suspense as ms, useEffect as gs } from "react";
|
|
21
|
-
import { c as bs, C as vs } from "./ChaiBuilderEditor-vP4at00I.js";
|
|
22
|
-
import { useTranslation as xs } from "react-i18next";
|
|
23
|
-
import { B as Xt, u as ws } from "./skeleton-lu8e7q2y.js";
|
|
24
|
-
import { FileTextIcon as Cs, GearIcon as Ps, EyeClosedIcon as Os, EyeOpenIcon as Ss } from "@radix-ui/react-icons";
|
|
25
|
-
import { toast as se, Toaster as js } from "sonner";
|
|
26
|
-
import { sortBy as Es, filter as Fs, has as Rs, set as As, capitalize as Ms, get as Mt, omit as qs, size as qt } from "lodash-es";
|
|
27
|
-
import { g as Us } from "./html-to-json-2xtb7520.js";
|
|
28
|
-
import { Loader as ks, LogOutIcon as Ds, Loader2 as Qs } from "lucide-react";
|
|
29
|
-
import { G as Zt } from "./iconBase-h4DuR_XT.js";
|
|
30
|
-
import { A as Ns, a as Ts, b as Is, c as Ls, e as Ks, f as Bs, d as _s, h as $s } from "./alert-dialog-rypfO5ly.js";
|
|
31
|
-
var Ie = class {
|
|
32
|
-
constructor() {
|
|
33
|
-
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
34
|
-
}
|
|
35
|
-
subscribe(t) {
|
|
36
|
-
return this.listeners.add(t), this.onSubscribe(), () => {
|
|
37
|
-
this.listeners.delete(t), this.onUnsubscribe();
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
hasListeners() {
|
|
41
|
-
return this.listeners.size > 0;
|
|
42
|
-
}
|
|
43
|
-
onSubscribe() {
|
|
44
|
-
}
|
|
45
|
-
onUnsubscribe() {
|
|
46
|
-
}
|
|
47
|
-
}, Te = typeof window > "u" || "Deno" in window;
|
|
48
|
-
function H() {
|
|
49
|
-
}
|
|
50
|
-
function Hs(t, e) {
|
|
51
|
-
return typeof t == "function" ? t(e) : t;
|
|
52
|
-
}
|
|
53
|
-
function pt(t) {
|
|
54
|
-
return typeof t == "number" && t >= 0 && t !== 1 / 0;
|
|
55
|
-
}
|
|
56
|
-
function es(t, e) {
|
|
57
|
-
return Math.max(t + (e || 0) - Date.now(), 0);
|
|
58
|
-
}
|
|
59
|
-
function Ut(t, e) {
|
|
60
|
-
const {
|
|
61
|
-
type: s = "all",
|
|
62
|
-
exact: r,
|
|
63
|
-
fetchStatus: n,
|
|
64
|
-
predicate: a,
|
|
65
|
-
queryKey: c,
|
|
66
|
-
stale: d
|
|
67
|
-
} = t;
|
|
68
|
-
if (c) {
|
|
69
|
-
if (r) {
|
|
70
|
-
if (e.queryHash !== Rt(c, e.options))
|
|
71
|
-
return !1;
|
|
72
|
-
} else if (!Be(e.queryKey, c))
|
|
73
|
-
return !1;
|
|
74
|
-
}
|
|
75
|
-
if (s !== "all") {
|
|
76
|
-
const g = e.isActive();
|
|
77
|
-
if (s === "active" && !g || s === "inactive" && g)
|
|
78
|
-
return !1;
|
|
79
|
-
}
|
|
80
|
-
return !(typeof d == "boolean" && e.isStale() !== d || typeof n < "u" && n !== e.state.fetchStatus || a && !a(e));
|
|
81
|
-
}
|
|
82
|
-
function kt(t, e) {
|
|
83
|
-
const { exact: s, status: r, predicate: n, mutationKey: a } = t;
|
|
84
|
-
if (a) {
|
|
85
|
-
if (!e.options.mutationKey)
|
|
86
|
-
return !1;
|
|
87
|
-
if (s) {
|
|
88
|
-
if (Ke(e.options.mutationKey) !== Ke(a))
|
|
89
|
-
return !1;
|
|
90
|
-
} else if (!Be(e.options.mutationKey, a))
|
|
91
|
-
return !1;
|
|
92
|
-
}
|
|
93
|
-
return !(r && e.state.status !== r || n && !n(e));
|
|
94
|
-
}
|
|
95
|
-
function Rt(t, e) {
|
|
96
|
-
return ((e == null ? void 0 : e.queryKeyHashFn) || Ke)(t);
|
|
97
|
-
}
|
|
98
|
-
function Ke(t) {
|
|
99
|
-
return JSON.stringify(
|
|
100
|
-
t,
|
|
101
|
-
(e, s) => mt(s) ? Object.keys(s).sort().reduce((r, n) => (r[n] = s[n], r), {}) : s
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
function Be(t, e) {
|
|
105
|
-
return t === e ? !0 : typeof t != typeof e ? !1 : t && e && typeof t == "object" && typeof e == "object" ? !Object.keys(e).some((s) => !Be(t[s], e[s])) : !1;
|
|
106
|
-
}
|
|
107
|
-
function ts(t, e) {
|
|
108
|
-
if (t === e)
|
|
109
|
-
return t;
|
|
110
|
-
const s = Dt(t) && Dt(e);
|
|
111
|
-
if (s || mt(t) && mt(e)) {
|
|
112
|
-
const r = s ? t.length : Object.keys(t).length, n = s ? e : Object.keys(e), a = n.length, c = s ? [] : {};
|
|
113
|
-
let d = 0;
|
|
114
|
-
for (let g = 0; g < a; g++) {
|
|
115
|
-
const b = s ? g : n[g];
|
|
116
|
-
c[b] = ts(t[b], e[b]), c[b] === t[b] && d++;
|
|
117
|
-
}
|
|
118
|
-
return r === a && d === r ? t : c;
|
|
119
|
-
}
|
|
120
|
-
return e;
|
|
121
|
-
}
|
|
122
|
-
function at(t, e) {
|
|
123
|
-
if (t && !e || e && !t)
|
|
124
|
-
return !1;
|
|
125
|
-
for (const s in t)
|
|
126
|
-
if (t[s] !== e[s])
|
|
127
|
-
return !1;
|
|
128
|
-
return !0;
|
|
129
|
-
}
|
|
130
|
-
function Dt(t) {
|
|
131
|
-
return Array.isArray(t) && t.length === Object.keys(t).length;
|
|
132
|
-
}
|
|
133
|
-
function mt(t) {
|
|
134
|
-
if (!Qt(t))
|
|
135
|
-
return !1;
|
|
136
|
-
const e = t.constructor;
|
|
137
|
-
if (typeof e > "u")
|
|
138
|
-
return !0;
|
|
139
|
-
const s = e.prototype;
|
|
140
|
-
return !(!Qt(s) || !s.hasOwnProperty("isPrototypeOf"));
|
|
141
|
-
}
|
|
142
|
-
function Qt(t) {
|
|
143
|
-
return Object.prototype.toString.call(t) === "[object Object]";
|
|
144
|
-
}
|
|
145
|
-
function ss(t) {
|
|
146
|
-
return new Promise((e) => {
|
|
147
|
-
setTimeout(e, t);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function Nt(t) {
|
|
151
|
-
ss(0).then(t);
|
|
152
|
-
}
|
|
153
|
-
function gt(t, e, s) {
|
|
154
|
-
return typeof s.structuralSharing == "function" ? s.structuralSharing(t, e) : s.structuralSharing !== !1 ? ts(t, e) : e;
|
|
155
|
-
}
|
|
156
|
-
function Gs(t, e, s = 0) {
|
|
157
|
-
const r = [...t, e];
|
|
158
|
-
return s && r.length > s ? r.slice(1) : r;
|
|
159
|
-
}
|
|
160
|
-
function zs(t, e, s = 0) {
|
|
161
|
-
const r = [e, ...t];
|
|
162
|
-
return s && r.length > s ? r.slice(0, -1) : r;
|
|
163
|
-
}
|
|
164
|
-
var de, ie, Ce, Bt, Vs = (Bt = class extends Ie {
|
|
165
|
-
constructor() {
|
|
166
|
-
super();
|
|
167
|
-
h(this, de, void 0);
|
|
168
|
-
h(this, ie, void 0);
|
|
169
|
-
h(this, Ce, void 0);
|
|
170
|
-
o(this, Ce, (e) => {
|
|
171
|
-
if (!Te && window.addEventListener) {
|
|
172
|
-
const s = () => e();
|
|
173
|
-
return window.addEventListener("visibilitychange", s, !1), () => {
|
|
174
|
-
window.removeEventListener("visibilitychange", s);
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
onSubscribe() {
|
|
180
|
-
i(this, ie) || this.setEventListener(i(this, Ce));
|
|
181
|
-
}
|
|
182
|
-
onUnsubscribe() {
|
|
183
|
-
var e;
|
|
184
|
-
this.hasListeners() || ((e = i(this, ie)) == null || e.call(this), o(this, ie, void 0));
|
|
185
|
-
}
|
|
186
|
-
setEventListener(e) {
|
|
187
|
-
var s;
|
|
188
|
-
o(this, Ce, e), (s = i(this, ie)) == null || s.call(this), o(this, ie, e((r) => {
|
|
189
|
-
typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
192
|
-
setFocused(e) {
|
|
193
|
-
i(this, de) !== e && (o(this, de, e), this.onFocus());
|
|
194
|
-
}
|
|
195
|
-
onFocus() {
|
|
196
|
-
this.listeners.forEach((e) => {
|
|
197
|
-
e();
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
isFocused() {
|
|
201
|
-
var e;
|
|
202
|
-
return typeof i(this, de) == "boolean" ? i(this, de) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
|
|
203
|
-
}
|
|
204
|
-
}, de = new WeakMap(), ie = new WeakMap(), Ce = new WeakMap(), Bt), ot = new Vs(), Pe, ne, Oe, _t, Js = (_t = class extends Ie {
|
|
205
|
-
constructor() {
|
|
206
|
-
super();
|
|
207
|
-
h(this, Pe, !0);
|
|
208
|
-
h(this, ne, void 0);
|
|
209
|
-
h(this, Oe, void 0);
|
|
210
|
-
o(this, Oe, (e) => {
|
|
211
|
-
if (!Te && window.addEventListener) {
|
|
212
|
-
const s = () => e(!0), r = () => e(!1);
|
|
213
|
-
return window.addEventListener("online", s, !1), window.addEventListener("offline", r, !1), () => {
|
|
214
|
-
window.removeEventListener("online", s), window.removeEventListener("offline", r);
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
onSubscribe() {
|
|
220
|
-
i(this, ne) || this.setEventListener(i(this, Oe));
|
|
221
|
-
}
|
|
222
|
-
onUnsubscribe() {
|
|
223
|
-
var e;
|
|
224
|
-
this.hasListeners() || ((e = i(this, ne)) == null || e.call(this), o(this, ne, void 0));
|
|
225
|
-
}
|
|
226
|
-
setEventListener(e) {
|
|
227
|
-
var s;
|
|
228
|
-
o(this, Oe, e), (s = i(this, ne)) == null || s.call(this), o(this, ne, e(this.setOnline.bind(this)));
|
|
229
|
-
}
|
|
230
|
-
setOnline(e) {
|
|
231
|
-
i(this, Pe) !== e && (o(this, Pe, e), this.listeners.forEach((r) => {
|
|
232
|
-
r(e);
|
|
233
|
-
}));
|
|
234
|
-
}
|
|
235
|
-
isOnline() {
|
|
236
|
-
return i(this, Pe);
|
|
237
|
-
}
|
|
238
|
-
}, Pe = new WeakMap(), ne = new WeakMap(), Oe = new WeakMap(), _t), ut = new Js();
|
|
239
|
-
function Ws(t) {
|
|
240
|
-
return Math.min(1e3 * 2 ** t, 3e4);
|
|
241
|
-
}
|
|
242
|
-
function ht(t) {
|
|
243
|
-
return (t ?? "online") === "online" ? ut.isOnline() : !0;
|
|
244
|
-
}
|
|
245
|
-
var rs = class {
|
|
246
|
-
constructor(t) {
|
|
247
|
-
this.revert = t == null ? void 0 : t.revert, this.silent = t == null ? void 0 : t.silent;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
function yt(t) {
|
|
251
|
-
return t instanceof rs;
|
|
252
|
-
}
|
|
253
|
-
function is(t) {
|
|
254
|
-
let e = !1, s = 0, r = !1, n, a, c;
|
|
255
|
-
const d = new Promise((f, m) => {
|
|
256
|
-
a = f, c = m;
|
|
257
|
-
}), g = (f) => {
|
|
258
|
-
var m;
|
|
259
|
-
r || (p(new rs(f)), (m = t.abort) == null || m.call(t));
|
|
260
|
-
}, b = () => {
|
|
261
|
-
e = !0;
|
|
262
|
-
}, l = () => {
|
|
263
|
-
e = !1;
|
|
264
|
-
}, P = () => !ot.isFocused() || t.networkMode !== "always" && !ut.isOnline(), U = (f) => {
|
|
265
|
-
var m;
|
|
266
|
-
r || (r = !0, (m = t.onSuccess) == null || m.call(t, f), n == null || n(), a(f));
|
|
267
|
-
}, p = (f) => {
|
|
268
|
-
var m;
|
|
269
|
-
r || (r = !0, (m = t.onError) == null || m.call(t, f), n == null || n(), c(f));
|
|
270
|
-
}, v = () => new Promise((f) => {
|
|
271
|
-
var m;
|
|
272
|
-
n = (E) => {
|
|
273
|
-
const x = r || !P();
|
|
274
|
-
return x && f(E), x;
|
|
275
|
-
}, (m = t.onPause) == null || m.call(t);
|
|
276
|
-
}).then(() => {
|
|
277
|
-
var f;
|
|
278
|
-
n = void 0, r || (f = t.onContinue) == null || f.call(t);
|
|
279
|
-
}), S = () => {
|
|
280
|
-
if (r)
|
|
281
|
-
return;
|
|
282
|
-
let f;
|
|
283
|
-
try {
|
|
284
|
-
f = t.fn();
|
|
285
|
-
} catch (m) {
|
|
286
|
-
f = Promise.reject(m);
|
|
287
|
-
}
|
|
288
|
-
Promise.resolve(f).then(U).catch((m) => {
|
|
289
|
-
var Q;
|
|
290
|
-
if (r)
|
|
291
|
-
return;
|
|
292
|
-
const E = t.retry ?? (Te ? 0 : 3), x = t.retryDelay ?? Ws, w = typeof x == "function" ? x(s, m) : x, q = E === !0 || typeof E == "number" && s < E || typeof E == "function" && E(s, m);
|
|
293
|
-
if (e || !q) {
|
|
294
|
-
p(m);
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
s++, (Q = t.onFail) == null || Q.call(t, s, m), ss(w).then(() => {
|
|
298
|
-
if (P())
|
|
299
|
-
return v();
|
|
300
|
-
}).then(() => {
|
|
301
|
-
e ? p(m) : S();
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
return ht(t.networkMode) ? S() : v().then(S), {
|
|
306
|
-
promise: d,
|
|
307
|
-
cancel: g,
|
|
308
|
-
continue: () => (n == null ? void 0 : n()) ? d : Promise.resolve(),
|
|
309
|
-
cancelRetry: b,
|
|
310
|
-
continueRetry: l
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
function Ys() {
|
|
314
|
-
let t = [], e = 0, s = (l) => {
|
|
315
|
-
l();
|
|
316
|
-
}, r = (l) => {
|
|
317
|
-
l();
|
|
318
|
-
};
|
|
319
|
-
const n = (l) => {
|
|
320
|
-
let P;
|
|
321
|
-
e++;
|
|
322
|
-
try {
|
|
323
|
-
P = l();
|
|
324
|
-
} finally {
|
|
325
|
-
e--, e || d();
|
|
326
|
-
}
|
|
327
|
-
return P;
|
|
328
|
-
}, a = (l) => {
|
|
329
|
-
e ? t.push(l) : Nt(() => {
|
|
330
|
-
s(l);
|
|
331
|
-
});
|
|
332
|
-
}, c = (l) => (...P) => {
|
|
333
|
-
a(() => {
|
|
334
|
-
l(...P);
|
|
335
|
-
});
|
|
336
|
-
}, d = () => {
|
|
337
|
-
const l = t;
|
|
338
|
-
t = [], l.length && Nt(() => {
|
|
339
|
-
r(() => {
|
|
340
|
-
l.forEach((P) => {
|
|
341
|
-
s(P);
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
};
|
|
346
|
-
return {
|
|
347
|
-
batch: n,
|
|
348
|
-
batchCalls: c,
|
|
349
|
-
schedule: a,
|
|
350
|
-
setNotifyFunction: (l) => {
|
|
351
|
-
s = l;
|
|
352
|
-
},
|
|
353
|
-
setBatchNotifyFunction: (l) => {
|
|
354
|
-
r = l;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
var R = Ys(), fe, $t, ns = ($t = class {
|
|
359
|
-
constructor() {
|
|
360
|
-
h(this, fe, void 0);
|
|
361
|
-
}
|
|
362
|
-
destroy() {
|
|
363
|
-
this.clearGcTimeout();
|
|
364
|
-
}
|
|
365
|
-
scheduleGc() {
|
|
366
|
-
this.clearGcTimeout(), pt(this.gcTime) && o(this, fe, setTimeout(() => {
|
|
367
|
-
this.optionalRemove();
|
|
368
|
-
}, this.gcTime));
|
|
369
|
-
}
|
|
370
|
-
updateGcTime(t) {
|
|
371
|
-
this.gcTime = Math.max(
|
|
372
|
-
this.gcTime || 0,
|
|
373
|
-
t ?? (Te ? 1 / 0 : 5 * 60 * 1e3)
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
clearGcTimeout() {
|
|
377
|
-
i(this, fe) && (clearTimeout(i(this, fe)), o(this, fe, void 0));
|
|
378
|
-
}
|
|
379
|
-
}, fe = new WeakMap(), $t), Se, je, K, ae, B, A, _e, ye, Ee, it, z, ee, Ht, Xs = (Ht = class extends ns {
|
|
380
|
-
constructor(e) {
|
|
381
|
-
super();
|
|
382
|
-
h(this, Ee);
|
|
383
|
-
h(this, z);
|
|
384
|
-
h(this, Se, void 0);
|
|
385
|
-
h(this, je, void 0);
|
|
386
|
-
h(this, K, void 0);
|
|
387
|
-
h(this, ae, void 0);
|
|
388
|
-
h(this, B, void 0);
|
|
389
|
-
h(this, A, void 0);
|
|
390
|
-
h(this, _e, void 0);
|
|
391
|
-
h(this, ye, void 0);
|
|
392
|
-
o(this, ye, !1), o(this, _e, e.defaultOptions), y(this, Ee, it).call(this, e.options), o(this, A, []), o(this, K, e.cache), this.queryKey = e.queryKey, this.queryHash = e.queryHash, o(this, Se, e.state || Zs(this.options)), this.state = i(this, Se), this.scheduleGc();
|
|
393
|
-
}
|
|
394
|
-
get meta() {
|
|
395
|
-
return this.options.meta;
|
|
396
|
-
}
|
|
397
|
-
optionalRemove() {
|
|
398
|
-
!i(this, A).length && this.state.fetchStatus === "idle" && i(this, K).remove(this);
|
|
399
|
-
}
|
|
400
|
-
setData(e, s) {
|
|
401
|
-
const r = gt(this.state.data, e, this.options);
|
|
402
|
-
return y(this, z, ee).call(this, {
|
|
403
|
-
data: r,
|
|
404
|
-
type: "success",
|
|
405
|
-
dataUpdatedAt: s == null ? void 0 : s.updatedAt,
|
|
406
|
-
manual: s == null ? void 0 : s.manual
|
|
407
|
-
}), r;
|
|
408
|
-
}
|
|
409
|
-
setState(e, s) {
|
|
410
|
-
y(this, z, ee).call(this, { type: "setState", state: e, setStateOptions: s });
|
|
411
|
-
}
|
|
412
|
-
cancel(e) {
|
|
413
|
-
var r;
|
|
414
|
-
const s = i(this, ae);
|
|
415
|
-
return (r = i(this, B)) == null || r.cancel(e), s ? s.then(H).catch(H) : Promise.resolve();
|
|
416
|
-
}
|
|
417
|
-
destroy() {
|
|
418
|
-
super.destroy(), this.cancel({ silent: !0 });
|
|
419
|
-
}
|
|
420
|
-
reset() {
|
|
421
|
-
this.destroy(), this.setState(i(this, Se));
|
|
422
|
-
}
|
|
423
|
-
isActive() {
|
|
424
|
-
return i(this, A).some(
|
|
425
|
-
(e) => e.options.enabled !== !1
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
isDisabled() {
|
|
429
|
-
return this.getObserversCount() > 0 && !this.isActive();
|
|
430
|
-
}
|
|
431
|
-
isStale() {
|
|
432
|
-
return this.state.isInvalidated || !this.state.dataUpdatedAt || i(this, A).some((e) => e.getCurrentResult().isStale);
|
|
433
|
-
}
|
|
434
|
-
isStaleByTime(e = 0) {
|
|
435
|
-
return this.state.isInvalidated || !this.state.dataUpdatedAt || !es(this.state.dataUpdatedAt, e);
|
|
436
|
-
}
|
|
437
|
-
onFocus() {
|
|
438
|
-
var s;
|
|
439
|
-
const e = i(this, A).find((r) => r.shouldFetchOnWindowFocus());
|
|
440
|
-
e == null || e.refetch({ cancelRefetch: !1 }), (s = i(this, B)) == null || s.continue();
|
|
441
|
-
}
|
|
442
|
-
onOnline() {
|
|
443
|
-
var s;
|
|
444
|
-
const e = i(this, A).find((r) => r.shouldFetchOnReconnect());
|
|
445
|
-
e == null || e.refetch({ cancelRefetch: !1 }), (s = i(this, B)) == null || s.continue();
|
|
446
|
-
}
|
|
447
|
-
addObserver(e) {
|
|
448
|
-
i(this, A).includes(e) || (i(this, A).push(e), this.clearGcTimeout(), i(this, K).notify({ type: "observerAdded", query: this, observer: e }));
|
|
449
|
-
}
|
|
450
|
-
removeObserver(e) {
|
|
451
|
-
i(this, A).includes(e) && (o(this, A, i(this, A).filter((s) => s !== e)), i(this, A).length || (i(this, B) && (i(this, ye) ? i(this, B).cancel({ revert: !0 }) : i(this, B).cancelRetry()), this.scheduleGc()), i(this, K).notify({ type: "observerRemoved", query: this, observer: e }));
|
|
452
|
-
}
|
|
453
|
-
getObserversCount() {
|
|
454
|
-
return i(this, A).length;
|
|
455
|
-
}
|
|
456
|
-
invalidate() {
|
|
457
|
-
this.state.isInvalidated || y(this, z, ee).call(this, { type: "invalidate" });
|
|
458
|
-
}
|
|
459
|
-
fetch(e, s) {
|
|
460
|
-
var b, l, P, U;
|
|
461
|
-
if (this.state.fetchStatus !== "idle") {
|
|
462
|
-
if (this.state.dataUpdatedAt && (s != null && s.cancelRefetch))
|
|
463
|
-
this.cancel({ silent: !0 });
|
|
464
|
-
else if (i(this, ae))
|
|
465
|
-
return (b = i(this, B)) == null || b.continueRetry(), i(this, ae);
|
|
466
|
-
}
|
|
467
|
-
if (e && y(this, Ee, it).call(this, e), !this.options.queryFn) {
|
|
468
|
-
const p = i(this, A).find((v) => v.options.queryFn);
|
|
469
|
-
p && y(this, Ee, it).call(this, p.options);
|
|
470
|
-
}
|
|
471
|
-
process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
|
|
472
|
-
"As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
|
|
473
|
-
));
|
|
474
|
-
const r = new AbortController(), n = {
|
|
475
|
-
queryKey: this.queryKey,
|
|
476
|
-
meta: this.meta
|
|
477
|
-
}, a = (p) => {
|
|
478
|
-
Object.defineProperty(p, "signal", {
|
|
479
|
-
enumerable: !0,
|
|
480
|
-
get: () => (o(this, ye, !0), r.signal)
|
|
481
|
-
});
|
|
482
|
-
};
|
|
483
|
-
a(n);
|
|
484
|
-
const c = () => this.options.queryFn ? (o(this, ye, !1), this.options.persister ? this.options.persister(
|
|
485
|
-
this.options.queryFn,
|
|
486
|
-
n,
|
|
487
|
-
this
|
|
488
|
-
) : this.options.queryFn(
|
|
489
|
-
n
|
|
490
|
-
)) : Promise.reject(
|
|
491
|
-
new Error(`Missing queryFn: '${this.options.queryHash}'`)
|
|
492
|
-
), d = {
|
|
493
|
-
fetchOptions: s,
|
|
494
|
-
options: this.options,
|
|
495
|
-
queryKey: this.queryKey,
|
|
496
|
-
state: this.state,
|
|
497
|
-
fetchFn: c
|
|
498
|
-
};
|
|
499
|
-
a(d), (l = this.options.behavior) == null || l.onFetch(
|
|
500
|
-
d,
|
|
501
|
-
this
|
|
502
|
-
), o(this, je, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((P = d.fetchOptions) == null ? void 0 : P.meta)) && y(this, z, ee).call(this, { type: "fetch", meta: (U = d.fetchOptions) == null ? void 0 : U.meta });
|
|
503
|
-
const g = (p) => {
|
|
504
|
-
var v, S, f, m;
|
|
505
|
-
yt(p) && p.silent || y(this, z, ee).call(this, {
|
|
506
|
-
type: "error",
|
|
507
|
-
error: p
|
|
508
|
-
}), yt(p) || ((S = (v = i(this, K).config).onError) == null || S.call(
|
|
509
|
-
v,
|
|
510
|
-
p,
|
|
511
|
-
this
|
|
512
|
-
), (m = (f = i(this, K).config).onSettled) == null || m.call(
|
|
513
|
-
f,
|
|
514
|
-
this.state.data,
|
|
515
|
-
p,
|
|
516
|
-
this
|
|
517
|
-
)), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
|
|
518
|
-
};
|
|
519
|
-
return o(this, B, is({
|
|
520
|
-
fn: d.fetchFn,
|
|
521
|
-
abort: r.abort.bind(r),
|
|
522
|
-
onSuccess: (p) => {
|
|
523
|
-
var v, S, f, m;
|
|
524
|
-
if (typeof p > "u") {
|
|
525
|
-
process.env.NODE_ENV !== "production" && console.error(
|
|
526
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
527
|
-
), g(new Error(`${this.queryHash} data is undefined`));
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
this.setData(p), (S = (v = i(this, K).config).onSuccess) == null || S.call(v, p, this), (m = (f = i(this, K).config).onSettled) == null || m.call(
|
|
531
|
-
f,
|
|
532
|
-
p,
|
|
533
|
-
this.state.error,
|
|
534
|
-
this
|
|
535
|
-
), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
|
|
536
|
-
},
|
|
537
|
-
onError: g,
|
|
538
|
-
onFail: (p, v) => {
|
|
539
|
-
y(this, z, ee).call(this, { type: "failed", failureCount: p, error: v });
|
|
540
|
-
},
|
|
541
|
-
onPause: () => {
|
|
542
|
-
y(this, z, ee).call(this, { type: "pause" });
|
|
543
|
-
},
|
|
544
|
-
onContinue: () => {
|
|
545
|
-
y(this, z, ee).call(this, { type: "continue" });
|
|
546
|
-
},
|
|
547
|
-
retry: d.options.retry,
|
|
548
|
-
retryDelay: d.options.retryDelay,
|
|
549
|
-
networkMode: d.options.networkMode
|
|
550
|
-
})), o(this, ae, i(this, B).promise), i(this, ae);
|
|
551
|
-
}
|
|
552
|
-
}, Se = new WeakMap(), je = new WeakMap(), K = new WeakMap(), ae = new WeakMap(), B = new WeakMap(), A = new WeakMap(), _e = new WeakMap(), ye = new WeakMap(), Ee = new WeakSet(), it = function(e) {
|
|
553
|
-
this.options = { ...i(this, _e), ...e }, this.updateGcTime(this.options.gcTime);
|
|
554
|
-
}, z = new WeakSet(), ee = function(e) {
|
|
555
|
-
const s = (r) => {
|
|
556
|
-
switch (e.type) {
|
|
557
|
-
case "failed":
|
|
558
|
-
return {
|
|
559
|
-
...r,
|
|
560
|
-
fetchFailureCount: e.failureCount,
|
|
561
|
-
fetchFailureReason: e.error
|
|
562
|
-
};
|
|
563
|
-
case "pause":
|
|
564
|
-
return {
|
|
565
|
-
...r,
|
|
566
|
-
fetchStatus: "paused"
|
|
567
|
-
};
|
|
568
|
-
case "continue":
|
|
569
|
-
return {
|
|
570
|
-
...r,
|
|
571
|
-
fetchStatus: "fetching"
|
|
572
|
-
};
|
|
573
|
-
case "fetch":
|
|
574
|
-
return {
|
|
575
|
-
...r,
|
|
576
|
-
fetchFailureCount: 0,
|
|
577
|
-
fetchFailureReason: null,
|
|
578
|
-
fetchMeta: e.meta ?? null,
|
|
579
|
-
fetchStatus: ht(this.options.networkMode) ? "fetching" : "paused",
|
|
580
|
-
...!r.dataUpdatedAt && {
|
|
581
|
-
error: null,
|
|
582
|
-
status: "pending"
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
case "success":
|
|
586
|
-
return {
|
|
587
|
-
...r,
|
|
588
|
-
data: e.data,
|
|
589
|
-
dataUpdateCount: r.dataUpdateCount + 1,
|
|
590
|
-
dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
|
|
591
|
-
error: null,
|
|
592
|
-
isInvalidated: !1,
|
|
593
|
-
status: "success",
|
|
594
|
-
...!e.manual && {
|
|
595
|
-
fetchStatus: "idle",
|
|
596
|
-
fetchFailureCount: 0,
|
|
597
|
-
fetchFailureReason: null
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
case "error":
|
|
601
|
-
const n = e.error;
|
|
602
|
-
return yt(n) && n.revert && i(this, je) ? { ...i(this, je), fetchStatus: "idle" } : {
|
|
603
|
-
...r,
|
|
604
|
-
error: n,
|
|
605
|
-
errorUpdateCount: r.errorUpdateCount + 1,
|
|
606
|
-
errorUpdatedAt: Date.now(),
|
|
607
|
-
fetchFailureCount: r.fetchFailureCount + 1,
|
|
608
|
-
fetchFailureReason: n,
|
|
609
|
-
fetchStatus: "idle",
|
|
610
|
-
status: "error"
|
|
611
|
-
};
|
|
612
|
-
case "invalidate":
|
|
613
|
-
return {
|
|
614
|
-
...r,
|
|
615
|
-
isInvalidated: !0
|
|
616
|
-
};
|
|
617
|
-
case "setState":
|
|
618
|
-
return {
|
|
619
|
-
...r,
|
|
620
|
-
...e.state
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
this.state = s(this.state), R.batch(() => {
|
|
625
|
-
i(this, A).forEach((r) => {
|
|
626
|
-
r.onQueryUpdate();
|
|
627
|
-
}), i(this, K).notify({ query: this, type: "updated", action: e });
|
|
628
|
-
});
|
|
629
|
-
}, Ht);
|
|
630
|
-
function Zs(t) {
|
|
631
|
-
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = typeof e < "u", r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
|
|
632
|
-
return {
|
|
633
|
-
data: e,
|
|
634
|
-
dataUpdateCount: 0,
|
|
635
|
-
dataUpdatedAt: s ? r ?? Date.now() : 0,
|
|
636
|
-
error: null,
|
|
637
|
-
errorUpdateCount: 0,
|
|
638
|
-
errorUpdatedAt: 0,
|
|
639
|
-
fetchFailureCount: 0,
|
|
640
|
-
fetchFailureReason: null,
|
|
641
|
-
fetchMeta: null,
|
|
642
|
-
isInvalidated: !1,
|
|
643
|
-
status: s ? "success" : "pending",
|
|
644
|
-
fetchStatus: "idle"
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
var J, Gt, er = (Gt = class extends Ie {
|
|
648
|
-
constructor(e = {}) {
|
|
649
|
-
super();
|
|
650
|
-
h(this, J, void 0);
|
|
651
|
-
this.config = e, o(this, J, /* @__PURE__ */ new Map());
|
|
652
|
-
}
|
|
653
|
-
build(e, s, r) {
|
|
654
|
-
const n = s.queryKey, a = s.queryHash ?? Rt(n, s);
|
|
655
|
-
let c = this.get(a);
|
|
656
|
-
return c || (c = new Xs({
|
|
657
|
-
cache: this,
|
|
658
|
-
queryKey: n,
|
|
659
|
-
queryHash: a,
|
|
660
|
-
options: e.defaultQueryOptions(s),
|
|
661
|
-
state: r,
|
|
662
|
-
defaultOptions: e.getQueryDefaults(n)
|
|
663
|
-
}), this.add(c)), c;
|
|
664
|
-
}
|
|
665
|
-
add(e) {
|
|
666
|
-
i(this, J).has(e.queryHash) || (i(this, J).set(e.queryHash, e), this.notify({
|
|
667
|
-
type: "added",
|
|
668
|
-
query: e
|
|
669
|
-
}));
|
|
670
|
-
}
|
|
671
|
-
remove(e) {
|
|
672
|
-
const s = i(this, J).get(e.queryHash);
|
|
673
|
-
s && (e.destroy(), s === e && i(this, J).delete(e.queryHash), this.notify({ type: "removed", query: e }));
|
|
674
|
-
}
|
|
675
|
-
clear() {
|
|
676
|
-
R.batch(() => {
|
|
677
|
-
this.getAll().forEach((e) => {
|
|
678
|
-
this.remove(e);
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
get(e) {
|
|
683
|
-
return i(this, J).get(e);
|
|
684
|
-
}
|
|
685
|
-
getAll() {
|
|
686
|
-
return [...i(this, J).values()];
|
|
687
|
-
}
|
|
688
|
-
find(e) {
|
|
689
|
-
const s = { exact: !0, ...e };
|
|
690
|
-
return this.getAll().find(
|
|
691
|
-
(r) => Ut(s, r)
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
findAll(e = {}) {
|
|
695
|
-
const s = this.getAll();
|
|
696
|
-
return Object.keys(e).length > 0 ? s.filter((r) => Ut(e, r)) : s;
|
|
697
|
-
}
|
|
698
|
-
notify(e) {
|
|
699
|
-
R.batch(() => {
|
|
700
|
-
this.listeners.forEach((s) => {
|
|
701
|
-
s(e);
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
onFocus() {
|
|
706
|
-
R.batch(() => {
|
|
707
|
-
this.getAll().forEach((e) => {
|
|
708
|
-
e.onFocus();
|
|
709
|
-
});
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
onOnline() {
|
|
713
|
-
R.batch(() => {
|
|
714
|
-
this.getAll().forEach((e) => {
|
|
715
|
-
e.onOnline();
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
}, J = new WeakMap(), Gt), W, $e, I, Fe, Y, re, zt, tr = (zt = class extends ns {
|
|
720
|
-
constructor(e) {
|
|
721
|
-
super();
|
|
722
|
-
h(this, Y);
|
|
723
|
-
h(this, W, void 0);
|
|
724
|
-
h(this, $e, void 0);
|
|
725
|
-
h(this, I, void 0);
|
|
726
|
-
h(this, Fe, void 0);
|
|
727
|
-
this.mutationId = e.mutationId, o(this, $e, e.defaultOptions), o(this, I, e.mutationCache), o(this, W, []), this.state = e.state || as(), this.setOptions(e.options), this.scheduleGc();
|
|
728
|
-
}
|
|
729
|
-
setOptions(e) {
|
|
730
|
-
this.options = { ...i(this, $e), ...e }, this.updateGcTime(this.options.gcTime);
|
|
731
|
-
}
|
|
732
|
-
get meta() {
|
|
733
|
-
return this.options.meta;
|
|
734
|
-
}
|
|
735
|
-
addObserver(e) {
|
|
736
|
-
i(this, W).includes(e) || (i(this, W).push(e), this.clearGcTimeout(), i(this, I).notify({
|
|
737
|
-
type: "observerAdded",
|
|
738
|
-
mutation: this,
|
|
739
|
-
observer: e
|
|
740
|
-
}));
|
|
741
|
-
}
|
|
742
|
-
removeObserver(e) {
|
|
743
|
-
o(this, W, i(this, W).filter((s) => s !== e)), this.scheduleGc(), i(this, I).notify({
|
|
744
|
-
type: "observerRemoved",
|
|
745
|
-
mutation: this,
|
|
746
|
-
observer: e
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
optionalRemove() {
|
|
750
|
-
i(this, W).length || (this.state.status === "pending" ? this.scheduleGc() : i(this, I).remove(this));
|
|
751
|
-
}
|
|
752
|
-
continue() {
|
|
753
|
-
var e;
|
|
754
|
-
return ((e = i(this, Fe)) == null ? void 0 : e.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
755
|
-
this.execute(this.state.variables);
|
|
756
|
-
}
|
|
757
|
-
async execute(e) {
|
|
758
|
-
var n, a, c, d, g, b, l, P, U, p, v, S, f, m, E, x, w, q, Q, j;
|
|
759
|
-
const s = () => (o(this, Fe, is({
|
|
760
|
-
fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
|
|
761
|
-
onFail: (O, Z) => {
|
|
762
|
-
y(this, Y, re).call(this, { type: "failed", failureCount: O, error: Z });
|
|
763
|
-
},
|
|
764
|
-
onPause: () => {
|
|
765
|
-
y(this, Y, re).call(this, { type: "pause" });
|
|
766
|
-
},
|
|
767
|
-
onContinue: () => {
|
|
768
|
-
y(this, Y, re).call(this, { type: "continue" });
|
|
769
|
-
},
|
|
770
|
-
retry: this.options.retry ?? 0,
|
|
771
|
-
retryDelay: this.options.retryDelay,
|
|
772
|
-
networkMode: this.options.networkMode
|
|
773
|
-
})), i(this, Fe).promise), r = this.state.status === "pending";
|
|
774
|
-
try {
|
|
775
|
-
if (!r) {
|
|
776
|
-
y(this, Y, re).call(this, { type: "pending", variables: e }), await ((a = (n = i(this, I).config).onMutate) == null ? void 0 : a.call(
|
|
777
|
-
n,
|
|
778
|
-
e,
|
|
779
|
-
this
|
|
780
|
-
));
|
|
781
|
-
const Z = await ((d = (c = this.options).onMutate) == null ? void 0 : d.call(c, e));
|
|
782
|
-
Z !== this.state.context && y(this, Y, re).call(this, {
|
|
783
|
-
type: "pending",
|
|
784
|
-
context: Z,
|
|
785
|
-
variables: e
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
const O = await s();
|
|
789
|
-
return await ((b = (g = i(this, I).config).onSuccess) == null ? void 0 : b.call(
|
|
790
|
-
g,
|
|
791
|
-
O,
|
|
792
|
-
e,
|
|
793
|
-
this.state.context,
|
|
794
|
-
this
|
|
795
|
-
)), await ((P = (l = this.options).onSuccess) == null ? void 0 : P.call(l, O, e, this.state.context)), await ((p = (U = i(this, I).config).onSettled) == null ? void 0 : p.call(
|
|
796
|
-
U,
|
|
797
|
-
O,
|
|
798
|
-
null,
|
|
799
|
-
this.state.variables,
|
|
800
|
-
this.state.context,
|
|
801
|
-
this
|
|
802
|
-
)), await ((S = (v = this.options).onSettled) == null ? void 0 : S.call(v, O, null, e, this.state.context)), y(this, Y, re).call(this, { type: "success", data: O }), O;
|
|
803
|
-
} catch (O) {
|
|
804
|
-
try {
|
|
805
|
-
throw await ((m = (f = i(this, I).config).onError) == null ? void 0 : m.call(
|
|
806
|
-
f,
|
|
807
|
-
O,
|
|
808
|
-
e,
|
|
809
|
-
this.state.context,
|
|
810
|
-
this
|
|
811
|
-
)), await ((x = (E = this.options).onError) == null ? void 0 : x.call(
|
|
812
|
-
E,
|
|
813
|
-
O,
|
|
814
|
-
e,
|
|
815
|
-
this.state.context
|
|
816
|
-
)), await ((q = (w = i(this, I).config).onSettled) == null ? void 0 : q.call(
|
|
817
|
-
w,
|
|
818
|
-
void 0,
|
|
819
|
-
O,
|
|
820
|
-
this.state.variables,
|
|
821
|
-
this.state.context,
|
|
822
|
-
this
|
|
823
|
-
)), await ((j = (Q = this.options).onSettled) == null ? void 0 : j.call(
|
|
824
|
-
Q,
|
|
825
|
-
void 0,
|
|
826
|
-
O,
|
|
827
|
-
e,
|
|
828
|
-
this.state.context
|
|
829
|
-
)), O;
|
|
830
|
-
} finally {
|
|
831
|
-
y(this, Y, re).call(this, { type: "error", error: O });
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}, W = new WeakMap(), $e = new WeakMap(), I = new WeakMap(), Fe = new WeakMap(), Y = new WeakSet(), re = function(e) {
|
|
836
|
-
const s = (r) => {
|
|
837
|
-
switch (e.type) {
|
|
838
|
-
case "failed":
|
|
839
|
-
return {
|
|
840
|
-
...r,
|
|
841
|
-
failureCount: e.failureCount,
|
|
842
|
-
failureReason: e.error
|
|
843
|
-
};
|
|
844
|
-
case "pause":
|
|
845
|
-
return {
|
|
846
|
-
...r,
|
|
847
|
-
isPaused: !0
|
|
848
|
-
};
|
|
849
|
-
case "continue":
|
|
850
|
-
return {
|
|
851
|
-
...r,
|
|
852
|
-
isPaused: !1
|
|
853
|
-
};
|
|
854
|
-
case "pending":
|
|
855
|
-
return {
|
|
856
|
-
...r,
|
|
857
|
-
context: e.context,
|
|
858
|
-
data: void 0,
|
|
859
|
-
failureCount: 0,
|
|
860
|
-
failureReason: null,
|
|
861
|
-
error: null,
|
|
862
|
-
isPaused: !ht(this.options.networkMode),
|
|
863
|
-
status: "pending",
|
|
864
|
-
variables: e.variables,
|
|
865
|
-
submittedAt: Date.now()
|
|
866
|
-
};
|
|
867
|
-
case "success":
|
|
868
|
-
return {
|
|
869
|
-
...r,
|
|
870
|
-
data: e.data,
|
|
871
|
-
failureCount: 0,
|
|
872
|
-
failureReason: null,
|
|
873
|
-
error: null,
|
|
874
|
-
status: "success",
|
|
875
|
-
isPaused: !1
|
|
876
|
-
};
|
|
877
|
-
case "error":
|
|
878
|
-
return {
|
|
879
|
-
...r,
|
|
880
|
-
data: void 0,
|
|
881
|
-
error: e.error,
|
|
882
|
-
failureCount: r.failureCount + 1,
|
|
883
|
-
failureReason: e.error,
|
|
884
|
-
isPaused: !1,
|
|
885
|
-
status: "error"
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
this.state = s(this.state), R.batch(() => {
|
|
890
|
-
i(this, W).forEach((r) => {
|
|
891
|
-
r.onMutationUpdate(e);
|
|
892
|
-
}), i(this, I).notify({
|
|
893
|
-
mutation: this,
|
|
894
|
-
type: "updated",
|
|
895
|
-
action: e
|
|
896
|
-
});
|
|
897
|
-
});
|
|
898
|
-
}, zt);
|
|
899
|
-
function as() {
|
|
900
|
-
return {
|
|
901
|
-
context: void 0,
|
|
902
|
-
data: void 0,
|
|
903
|
-
error: null,
|
|
904
|
-
failureCount: 0,
|
|
905
|
-
failureReason: null,
|
|
906
|
-
isPaused: !1,
|
|
907
|
-
status: "idle",
|
|
908
|
-
variables: void 0,
|
|
909
|
-
submittedAt: 0
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
var _, He, pe, Vt, sr = (Vt = class extends Ie {
|
|
913
|
-
constructor(e = {}) {
|
|
914
|
-
super();
|
|
915
|
-
h(this, _, void 0);
|
|
916
|
-
h(this, He, void 0);
|
|
917
|
-
h(this, pe, void 0);
|
|
918
|
-
this.config = e, o(this, _, []), o(this, He, 0);
|
|
919
|
-
}
|
|
920
|
-
build(e, s, r) {
|
|
921
|
-
const n = new tr({
|
|
922
|
-
mutationCache: this,
|
|
923
|
-
mutationId: ++rt(this, He)._,
|
|
924
|
-
options: e.defaultMutationOptions(s),
|
|
925
|
-
state: r
|
|
926
|
-
});
|
|
927
|
-
return this.add(n), n;
|
|
928
|
-
}
|
|
929
|
-
add(e) {
|
|
930
|
-
i(this, _).push(e), this.notify({ type: "added", mutation: e });
|
|
931
|
-
}
|
|
932
|
-
remove(e) {
|
|
933
|
-
o(this, _, i(this, _).filter((s) => s !== e)), this.notify({ type: "removed", mutation: e });
|
|
934
|
-
}
|
|
935
|
-
clear() {
|
|
936
|
-
R.batch(() => {
|
|
937
|
-
i(this, _).forEach((e) => {
|
|
938
|
-
this.remove(e);
|
|
939
|
-
});
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
getAll() {
|
|
943
|
-
return i(this, _);
|
|
944
|
-
}
|
|
945
|
-
find(e) {
|
|
946
|
-
const s = { exact: !0, ...e };
|
|
947
|
-
return i(this, _).find(
|
|
948
|
-
(r) => kt(s, r)
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
findAll(e = {}) {
|
|
952
|
-
return i(this, _).filter(
|
|
953
|
-
(s) => kt(e, s)
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
notify(e) {
|
|
957
|
-
R.batch(() => {
|
|
958
|
-
this.listeners.forEach((s) => {
|
|
959
|
-
s(e);
|
|
960
|
-
});
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
resumePausedMutations() {
|
|
964
|
-
return o(this, pe, (i(this, pe) ?? Promise.resolve()).then(() => {
|
|
965
|
-
const e = i(this, _).filter((s) => s.state.isPaused);
|
|
966
|
-
return R.batch(
|
|
967
|
-
() => e.reduce(
|
|
968
|
-
(s, r) => s.then(() => r.continue().catch(H)),
|
|
969
|
-
Promise.resolve()
|
|
970
|
-
)
|
|
971
|
-
);
|
|
972
|
-
}).then(() => {
|
|
973
|
-
o(this, pe, void 0);
|
|
974
|
-
})), i(this, pe);
|
|
975
|
-
}
|
|
976
|
-
}, _ = new WeakMap(), He = new WeakMap(), pe = new WeakMap(), Vt);
|
|
977
|
-
function rr(t) {
|
|
978
|
-
return {
|
|
979
|
-
onFetch: (e, s) => {
|
|
980
|
-
const r = async () => {
|
|
981
|
-
var v, S, f, m, E;
|
|
982
|
-
const n = e.options, a = (f = (S = (v = e.fetchOptions) == null ? void 0 : v.meta) == null ? void 0 : S.fetchMore) == null ? void 0 : f.direction, c = ((m = e.state.data) == null ? void 0 : m.pages) || [], d = ((E = e.state.data) == null ? void 0 : E.pageParams) || [], g = { pages: [], pageParams: [] };
|
|
983
|
-
let b = !1;
|
|
984
|
-
const l = (x) => {
|
|
985
|
-
Object.defineProperty(x, "signal", {
|
|
986
|
-
enumerable: !0,
|
|
987
|
-
get: () => (e.signal.aborted ? b = !0 : e.signal.addEventListener("abort", () => {
|
|
988
|
-
b = !0;
|
|
989
|
-
}), e.signal)
|
|
990
|
-
});
|
|
991
|
-
}, P = e.options.queryFn || (() => Promise.reject(
|
|
992
|
-
new Error(`Missing queryFn: '${e.options.queryHash}'`)
|
|
993
|
-
)), U = async (x, w, q) => {
|
|
994
|
-
if (b)
|
|
995
|
-
return Promise.reject();
|
|
996
|
-
if (w == null && x.pages.length)
|
|
997
|
-
return Promise.resolve(x);
|
|
998
|
-
const Q = {
|
|
999
|
-
queryKey: e.queryKey,
|
|
1000
|
-
pageParam: w,
|
|
1001
|
-
direction: q ? "backward" : "forward",
|
|
1002
|
-
meta: e.options.meta
|
|
1003
|
-
};
|
|
1004
|
-
l(Q);
|
|
1005
|
-
const j = await P(
|
|
1006
|
-
Q
|
|
1007
|
-
), { maxPages: O } = e.options, Z = q ? zs : Gs;
|
|
1008
|
-
return {
|
|
1009
|
-
pages: Z(x.pages, j, O),
|
|
1010
|
-
pageParams: Z(x.pageParams, w, O)
|
|
1011
|
-
};
|
|
1012
|
-
};
|
|
1013
|
-
let p;
|
|
1014
|
-
if (a && c.length) {
|
|
1015
|
-
const x = a === "backward", w = x ? ir : Tt, q = {
|
|
1016
|
-
pages: c,
|
|
1017
|
-
pageParams: d
|
|
1018
|
-
}, Q = w(n, q);
|
|
1019
|
-
p = await U(q, Q, x);
|
|
1020
|
-
} else {
|
|
1021
|
-
p = await U(
|
|
1022
|
-
g,
|
|
1023
|
-
d[0] ?? n.initialPageParam
|
|
1024
|
-
);
|
|
1025
|
-
const x = t ?? c.length;
|
|
1026
|
-
for (let w = 1; w < x; w++) {
|
|
1027
|
-
const q = Tt(n, p);
|
|
1028
|
-
p = await U(p, q);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
return p;
|
|
1032
|
-
};
|
|
1033
|
-
e.options.persister ? e.fetchFn = () => {
|
|
1034
|
-
var n, a;
|
|
1035
|
-
return (a = (n = e.options).persister) == null ? void 0 : a.call(
|
|
1036
|
-
n,
|
|
1037
|
-
r,
|
|
1038
|
-
{
|
|
1039
|
-
queryKey: e.queryKey,
|
|
1040
|
-
meta: e.options.meta,
|
|
1041
|
-
signal: e.signal
|
|
1042
|
-
},
|
|
1043
|
-
s
|
|
1044
|
-
);
|
|
1045
|
-
} : e.fetchFn = r;
|
|
1046
|
-
}
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
function Tt(t, { pages: e, pageParams: s }) {
|
|
1050
|
-
const r = e.length - 1;
|
|
1051
|
-
return t.getNextPageParam(
|
|
1052
|
-
e[r],
|
|
1053
|
-
e,
|
|
1054
|
-
s[r],
|
|
1055
|
-
s
|
|
1056
|
-
);
|
|
1057
|
-
}
|
|
1058
|
-
function ir(t, { pages: e, pageParams: s }) {
|
|
1059
|
-
var r;
|
|
1060
|
-
return (r = t.getPreviousPageParam) == null ? void 0 : r.call(
|
|
1061
|
-
t,
|
|
1062
|
-
e[0],
|
|
1063
|
-
e,
|
|
1064
|
-
s[0],
|
|
1065
|
-
s
|
|
1066
|
-
);
|
|
1067
|
-
}
|
|
1068
|
-
var F, oe, ue, Re, Ae, ce, Me, qe, Jt, nr = (Jt = class {
|
|
1069
|
-
constructor(t = {}) {
|
|
1070
|
-
h(this, F, void 0);
|
|
1071
|
-
h(this, oe, void 0);
|
|
1072
|
-
h(this, ue, void 0);
|
|
1073
|
-
h(this, Re, void 0);
|
|
1074
|
-
h(this, Ae, void 0);
|
|
1075
|
-
h(this, ce, void 0);
|
|
1076
|
-
h(this, Me, void 0);
|
|
1077
|
-
h(this, qe, void 0);
|
|
1078
|
-
o(this, F, t.queryCache || new er()), o(this, oe, t.mutationCache || new sr()), o(this, ue, t.defaultOptions || {}), o(this, Re, /* @__PURE__ */ new Map()), o(this, Ae, /* @__PURE__ */ new Map()), o(this, ce, 0);
|
|
1079
|
-
}
|
|
1080
|
-
mount() {
|
|
1081
|
-
rt(this, ce)._++, i(this, ce) === 1 && (o(this, Me, ot.subscribe(() => {
|
|
1082
|
-
ot.isFocused() && (this.resumePausedMutations(), i(this, F).onFocus());
|
|
1083
|
-
})), o(this, qe, ut.subscribe(() => {
|
|
1084
|
-
ut.isOnline() && (this.resumePausedMutations(), i(this, F).onOnline());
|
|
1085
|
-
})));
|
|
1086
|
-
}
|
|
1087
|
-
unmount() {
|
|
1088
|
-
var t, e;
|
|
1089
|
-
rt(this, ce)._--, i(this, ce) === 0 && ((t = i(this, Me)) == null || t.call(this), o(this, Me, void 0), (e = i(this, qe)) == null || e.call(this), o(this, qe, void 0));
|
|
1090
|
-
}
|
|
1091
|
-
isFetching(t) {
|
|
1092
|
-
return i(this, F).findAll({ ...t, fetchStatus: "fetching" }).length;
|
|
1093
|
-
}
|
|
1094
|
-
isMutating(t) {
|
|
1095
|
-
return i(this, oe).findAll({ ...t, status: "pending" }).length;
|
|
1096
|
-
}
|
|
1097
|
-
getQueryData(t) {
|
|
1098
|
-
var e;
|
|
1099
|
-
return (e = i(this, F).find({ queryKey: t })) == null ? void 0 : e.state.data;
|
|
1100
|
-
}
|
|
1101
|
-
ensureQueryData(t) {
|
|
1102
|
-
const e = this.getQueryData(t.queryKey);
|
|
1103
|
-
return e !== void 0 ? Promise.resolve(e) : this.fetchQuery(t);
|
|
1104
|
-
}
|
|
1105
|
-
getQueriesData(t) {
|
|
1106
|
-
return this.getQueryCache().findAll(t).map(({ queryKey: e, state: s }) => {
|
|
1107
|
-
const r = s.data;
|
|
1108
|
-
return [e, r];
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
setQueryData(t, e, s) {
|
|
1112
|
-
const r = i(this, F).find({ queryKey: t }), n = r == null ? void 0 : r.state.data, a = Hs(e, n);
|
|
1113
|
-
if (typeof a > "u")
|
|
1114
|
-
return;
|
|
1115
|
-
const c = this.defaultQueryOptions({ queryKey: t });
|
|
1116
|
-
return i(this, F).build(this, c).setData(a, { ...s, manual: !0 });
|
|
1117
|
-
}
|
|
1118
|
-
setQueriesData(t, e, s) {
|
|
1119
|
-
return R.batch(
|
|
1120
|
-
() => this.getQueryCache().findAll(t).map(({ queryKey: r }) => [
|
|
1121
|
-
r,
|
|
1122
|
-
this.setQueryData(r, e, s)
|
|
1123
|
-
])
|
|
1124
|
-
);
|
|
1125
|
-
}
|
|
1126
|
-
getQueryState(t) {
|
|
1127
|
-
var e;
|
|
1128
|
-
return (e = i(this, F).find({ queryKey: t })) == null ? void 0 : e.state;
|
|
1129
|
-
}
|
|
1130
|
-
removeQueries(t) {
|
|
1131
|
-
const e = i(this, F);
|
|
1132
|
-
R.batch(() => {
|
|
1133
|
-
e.findAll(t).forEach((s) => {
|
|
1134
|
-
e.remove(s);
|
|
1135
|
-
});
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
resetQueries(t, e) {
|
|
1139
|
-
const s = i(this, F), r = {
|
|
1140
|
-
type: "active",
|
|
1141
|
-
...t
|
|
1142
|
-
};
|
|
1143
|
-
return R.batch(() => (s.findAll(t).forEach((n) => {
|
|
1144
|
-
n.reset();
|
|
1145
|
-
}), this.refetchQueries(r, e)));
|
|
1146
|
-
}
|
|
1147
|
-
cancelQueries(t = {}, e = {}) {
|
|
1148
|
-
const s = { revert: !0, ...e }, r = R.batch(
|
|
1149
|
-
() => i(this, F).findAll(t).map((n) => n.cancel(s))
|
|
1150
|
-
);
|
|
1151
|
-
return Promise.all(r).then(H).catch(H);
|
|
1152
|
-
}
|
|
1153
|
-
invalidateQueries(t = {}, e = {}) {
|
|
1154
|
-
return R.batch(() => {
|
|
1155
|
-
if (i(this, F).findAll(t).forEach((r) => {
|
|
1156
|
-
r.invalidate();
|
|
1157
|
-
}), t.refetchType === "none")
|
|
1158
|
-
return Promise.resolve();
|
|
1159
|
-
const s = {
|
|
1160
|
-
...t,
|
|
1161
|
-
type: t.refetchType ?? t.type ?? "active"
|
|
1162
|
-
};
|
|
1163
|
-
return this.refetchQueries(s, e);
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
refetchQueries(t = {}, e) {
|
|
1167
|
-
const s = {
|
|
1168
|
-
...e,
|
|
1169
|
-
cancelRefetch: (e == null ? void 0 : e.cancelRefetch) ?? !0
|
|
1170
|
-
}, r = R.batch(
|
|
1171
|
-
() => i(this, F).findAll(t).filter((n) => !n.isDisabled()).map((n) => {
|
|
1172
|
-
let a = n.fetch(void 0, s);
|
|
1173
|
-
return s.throwOnError || (a = a.catch(H)), n.state.fetchStatus === "paused" ? Promise.resolve() : a;
|
|
1174
|
-
})
|
|
1175
|
-
);
|
|
1176
|
-
return Promise.all(r).then(H);
|
|
1177
|
-
}
|
|
1178
|
-
fetchQuery(t) {
|
|
1179
|
-
const e = this.defaultQueryOptions(t);
|
|
1180
|
-
typeof e.retry > "u" && (e.retry = !1);
|
|
1181
|
-
const s = i(this, F).build(this, e);
|
|
1182
|
-
return s.isStaleByTime(e.staleTime) ? s.fetch(e) : Promise.resolve(s.state.data);
|
|
1183
|
-
}
|
|
1184
|
-
prefetchQuery(t) {
|
|
1185
|
-
return this.fetchQuery(t).then(H).catch(H);
|
|
1186
|
-
}
|
|
1187
|
-
fetchInfiniteQuery(t) {
|
|
1188
|
-
return t.behavior = rr(t.pages), this.fetchQuery(t);
|
|
1189
|
-
}
|
|
1190
|
-
prefetchInfiniteQuery(t) {
|
|
1191
|
-
return this.fetchInfiniteQuery(t).then(H).catch(H);
|
|
1192
|
-
}
|
|
1193
|
-
resumePausedMutations() {
|
|
1194
|
-
return i(this, oe).resumePausedMutations();
|
|
1195
|
-
}
|
|
1196
|
-
getQueryCache() {
|
|
1197
|
-
return i(this, F);
|
|
1198
|
-
}
|
|
1199
|
-
getMutationCache() {
|
|
1200
|
-
return i(this, oe);
|
|
1201
|
-
}
|
|
1202
|
-
getDefaultOptions() {
|
|
1203
|
-
return i(this, ue);
|
|
1204
|
-
}
|
|
1205
|
-
setDefaultOptions(t) {
|
|
1206
|
-
o(this, ue, t);
|
|
1207
|
-
}
|
|
1208
|
-
setQueryDefaults(t, e) {
|
|
1209
|
-
i(this, Re).set(Ke(t), {
|
|
1210
|
-
queryKey: t,
|
|
1211
|
-
defaultOptions: e
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
getQueryDefaults(t) {
|
|
1215
|
-
const e = [...i(this, Re).values()];
|
|
1216
|
-
let s = {};
|
|
1217
|
-
return e.forEach((r) => {
|
|
1218
|
-
Be(t, r.queryKey) && (s = { ...s, ...r.defaultOptions });
|
|
1219
|
-
}), s;
|
|
1220
|
-
}
|
|
1221
|
-
setMutationDefaults(t, e) {
|
|
1222
|
-
i(this, Ae).set(Ke(t), {
|
|
1223
|
-
mutationKey: t,
|
|
1224
|
-
defaultOptions: e
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
getMutationDefaults(t) {
|
|
1228
|
-
const e = [...i(this, Ae).values()];
|
|
1229
|
-
let s = {};
|
|
1230
|
-
return e.forEach((r) => {
|
|
1231
|
-
Be(t, r.mutationKey) && (s = { ...s, ...r.defaultOptions });
|
|
1232
|
-
}), s;
|
|
1233
|
-
}
|
|
1234
|
-
defaultQueryOptions(t) {
|
|
1235
|
-
if (t != null && t._defaulted)
|
|
1236
|
-
return t;
|
|
1237
|
-
const e = {
|
|
1238
|
-
...i(this, ue).queries,
|
|
1239
|
-
...(t == null ? void 0 : t.queryKey) && this.getQueryDefaults(t.queryKey),
|
|
1240
|
-
...t,
|
|
1241
|
-
_defaulted: !0
|
|
1242
|
-
};
|
|
1243
|
-
return e.queryHash || (e.queryHash = Rt(
|
|
1244
|
-
e.queryKey,
|
|
1245
|
-
e
|
|
1246
|
-
)), typeof e.refetchOnReconnect > "u" && (e.refetchOnReconnect = e.networkMode !== "always"), typeof e.throwOnError > "u" && (e.throwOnError = !!e.suspense), typeof e.networkMode > "u" && e.persister && (e.networkMode = "offlineFirst"), e;
|
|
1247
|
-
}
|
|
1248
|
-
defaultMutationOptions(t) {
|
|
1249
|
-
return t != null && t._defaulted ? t : {
|
|
1250
|
-
...i(this, ue).mutations,
|
|
1251
|
-
...(t == null ? void 0 : t.mutationKey) && this.getMutationDefaults(t.mutationKey),
|
|
1252
|
-
...t,
|
|
1253
|
-
_defaulted: !0
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
clear() {
|
|
1257
|
-
i(this, F).clear(), i(this, oe).clear();
|
|
1258
|
-
}
|
|
1259
|
-
}, F = new WeakMap(), oe = new WeakMap(), ue = new WeakMap(), Re = new WeakMap(), Ae = new WeakMap(), ce = new WeakMap(), Me = new WeakMap(), qe = new WeakMap(), Jt), T, C, Ue, k, me, ke, X, Ge, De, Qe, ge, be, he, ve, xe, Le, ze, bt, Ve, vt, Je, xt, We, wt, Ye, Ct, Xe, Pt, Ze, Ot, ct, os, Wt, ar = (Wt = class extends Ie {
|
|
1260
|
-
constructor(e, s) {
|
|
1261
|
-
super();
|
|
1262
|
-
h(this, xe);
|
|
1263
|
-
h(this, ze);
|
|
1264
|
-
h(this, Ve);
|
|
1265
|
-
h(this, Je);
|
|
1266
|
-
h(this, We);
|
|
1267
|
-
h(this, Ye);
|
|
1268
|
-
h(this, Xe);
|
|
1269
|
-
h(this, Ze);
|
|
1270
|
-
h(this, ct);
|
|
1271
|
-
h(this, T, void 0);
|
|
1272
|
-
h(this, C, void 0);
|
|
1273
|
-
h(this, Ue, void 0);
|
|
1274
|
-
h(this, k, void 0);
|
|
1275
|
-
h(this, me, void 0);
|
|
1276
|
-
h(this, ke, void 0);
|
|
1277
|
-
h(this, X, void 0);
|
|
1278
|
-
h(this, Ge, void 0);
|
|
1279
|
-
h(this, De, void 0);
|
|
1280
|
-
// This property keeps track of the last query with defined data.
|
|
1281
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
1282
|
-
h(this, Qe, void 0);
|
|
1283
|
-
h(this, ge, void 0);
|
|
1284
|
-
h(this, be, void 0);
|
|
1285
|
-
h(this, he, void 0);
|
|
1286
|
-
h(this, ve, void 0);
|
|
1287
|
-
o(this, C, void 0), o(this, Ue, void 0), o(this, k, void 0), o(this, ve, /* @__PURE__ */ new Set()), o(this, T, e), this.options = s, o(this, X, null), this.bindMethods(), this.setOptions(s);
|
|
1288
|
-
}
|
|
1289
|
-
bindMethods() {
|
|
1290
|
-
this.refetch = this.refetch.bind(this);
|
|
1291
|
-
}
|
|
1292
|
-
onSubscribe() {
|
|
1293
|
-
this.listeners.size === 1 && (i(this, C).addObserver(this), It(i(this, C), this.options) ? y(this, xe, Le).call(this) : this.updateResult(), y(this, We, wt).call(this));
|
|
1294
|
-
}
|
|
1295
|
-
onUnsubscribe() {
|
|
1296
|
-
this.hasListeners() || this.destroy();
|
|
1297
|
-
}
|
|
1298
|
-
shouldFetchOnReconnect() {
|
|
1299
|
-
return St(
|
|
1300
|
-
i(this, C),
|
|
1301
|
-
this.options,
|
|
1302
|
-
this.options.refetchOnReconnect
|
|
1303
|
-
);
|
|
1304
|
-
}
|
|
1305
|
-
shouldFetchOnWindowFocus() {
|
|
1306
|
-
return St(
|
|
1307
|
-
i(this, C),
|
|
1308
|
-
this.options,
|
|
1309
|
-
this.options.refetchOnWindowFocus
|
|
1310
|
-
);
|
|
1311
|
-
}
|
|
1312
|
-
destroy() {
|
|
1313
|
-
this.listeners = /* @__PURE__ */ new Set(), y(this, Ye, Ct).call(this), y(this, Xe, Pt).call(this), i(this, C).removeObserver(this);
|
|
1314
|
-
}
|
|
1315
|
-
setOptions(e, s) {
|
|
1316
|
-
const r = this.options, n = i(this, C);
|
|
1317
|
-
if (this.options = i(this, T).defaultQueryOptions(e), at(r, this.options) || i(this, T).getQueryCache().notify({
|
|
1318
|
-
type: "observerOptionsUpdated",
|
|
1319
|
-
query: i(this, C),
|
|
1320
|
-
observer: this
|
|
1321
|
-
}), typeof this.options.enabled < "u" && typeof this.options.enabled != "boolean")
|
|
1322
|
-
throw new Error("Expected enabled to be a boolean");
|
|
1323
|
-
this.options.queryKey || (this.options.queryKey = r.queryKey), y(this, Ze, Ot).call(this);
|
|
1324
|
-
const a = this.hasListeners();
|
|
1325
|
-
a && Lt(
|
|
1326
|
-
i(this, C),
|
|
1327
|
-
n,
|
|
1328
|
-
this.options,
|
|
1329
|
-
r
|
|
1330
|
-
) && y(this, xe, Le).call(this), this.updateResult(s), a && (i(this, C) !== n || this.options.enabled !== r.enabled || this.options.staleTime !== r.staleTime) && y(this, ze, bt).call(this);
|
|
1331
|
-
const c = y(this, Ve, vt).call(this);
|
|
1332
|
-
a && (i(this, C) !== n || this.options.enabled !== r.enabled || c !== i(this, he)) && y(this, Je, xt).call(this, c);
|
|
1333
|
-
}
|
|
1334
|
-
getOptimisticResult(e) {
|
|
1335
|
-
const s = i(this, T).getQueryCache().build(i(this, T), e), r = this.createResult(s, e);
|
|
1336
|
-
return ur(this, r) && (o(this, k, r), o(this, ke, this.options), o(this, me, i(this, C).state)), r;
|
|
1337
|
-
}
|
|
1338
|
-
getCurrentResult() {
|
|
1339
|
-
return i(this, k);
|
|
1340
|
-
}
|
|
1341
|
-
trackResult(e) {
|
|
1342
|
-
const s = {};
|
|
1343
|
-
return Object.keys(e).forEach((r) => {
|
|
1344
|
-
Object.defineProperty(s, r, {
|
|
1345
|
-
configurable: !1,
|
|
1346
|
-
enumerable: !0,
|
|
1347
|
-
get: () => (i(this, ve).add(r), e[r])
|
|
1348
|
-
});
|
|
1349
|
-
}), s;
|
|
1350
|
-
}
|
|
1351
|
-
getCurrentQuery() {
|
|
1352
|
-
return i(this, C);
|
|
1353
|
-
}
|
|
1354
|
-
refetch({ ...e } = {}) {
|
|
1355
|
-
return this.fetch({
|
|
1356
|
-
...e
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
fetchOptimistic(e) {
|
|
1360
|
-
const s = i(this, T).defaultQueryOptions(e), r = i(this, T).getQueryCache().build(i(this, T), s);
|
|
1361
|
-
return r.isFetchingOptimistic = !0, r.fetch().then(() => this.createResult(r, s));
|
|
1362
|
-
}
|
|
1363
|
-
fetch(e) {
|
|
1364
|
-
return y(this, xe, Le).call(this, {
|
|
1365
|
-
...e,
|
|
1366
|
-
cancelRefetch: e.cancelRefetch ?? !0
|
|
1367
|
-
}).then(() => (this.updateResult(), i(this, k)));
|
|
1368
|
-
}
|
|
1369
|
-
createResult(e, s) {
|
|
1370
|
-
var Q;
|
|
1371
|
-
const r = i(this, C), n = this.options, a = i(this, k), c = i(this, me), d = i(this, ke), b = e !== r ? e.state : i(this, Ue), { state: l } = e;
|
|
1372
|
-
let { error: P, errorUpdatedAt: U, fetchStatus: p, status: v } = l, S = !1, f;
|
|
1373
|
-
if (s._optimisticResults) {
|
|
1374
|
-
const j = this.hasListeners(), O = !j && It(e, s), Z = j && Lt(e, r, s, n);
|
|
1375
|
-
(O || Z) && (p = ht(e.options.networkMode) ? "fetching" : "paused", l.dataUpdatedAt || (v = "pending")), s._optimisticResults === "isRestoring" && (p = "idle");
|
|
1376
|
-
}
|
|
1377
|
-
if (s.select && typeof l.data < "u")
|
|
1378
|
-
if (a && l.data === (c == null ? void 0 : c.data) && s.select === i(this, Ge))
|
|
1379
|
-
f = i(this, De);
|
|
1380
|
-
else
|
|
1381
|
-
try {
|
|
1382
|
-
o(this, Ge, s.select), f = s.select(l.data), f = gt(a == null ? void 0 : a.data, f, s), o(this, De, f), o(this, X, null);
|
|
1383
|
-
} catch (j) {
|
|
1384
|
-
o(this, X, j);
|
|
1385
|
-
}
|
|
1386
|
-
else
|
|
1387
|
-
f = l.data;
|
|
1388
|
-
if (typeof s.placeholderData < "u" && typeof f > "u" && v === "pending") {
|
|
1389
|
-
let j;
|
|
1390
|
-
if (a != null && a.isPlaceholderData && s.placeholderData === (d == null ? void 0 : d.placeholderData))
|
|
1391
|
-
j = a.data;
|
|
1392
|
-
else if (j = typeof s.placeholderData == "function" ? s.placeholderData(
|
|
1393
|
-
(Q = i(this, Qe)) == null ? void 0 : Q.state.data,
|
|
1394
|
-
i(this, Qe)
|
|
1395
|
-
) : s.placeholderData, s.select && typeof j < "u")
|
|
1396
|
-
try {
|
|
1397
|
-
j = s.select(j), o(this, X, null);
|
|
1398
|
-
} catch (O) {
|
|
1399
|
-
o(this, X, O);
|
|
1400
|
-
}
|
|
1401
|
-
typeof j < "u" && (v = "success", f = gt(
|
|
1402
|
-
a == null ? void 0 : a.data,
|
|
1403
|
-
j,
|
|
1404
|
-
s
|
|
1405
|
-
), S = !0);
|
|
1406
|
-
}
|
|
1407
|
-
i(this, X) && (P = i(this, X), f = i(this, De), U = Date.now(), v = "error");
|
|
1408
|
-
const m = p === "fetching", E = v === "pending", x = v === "error", w = E && m;
|
|
1409
|
-
return {
|
|
1410
|
-
status: v,
|
|
1411
|
-
fetchStatus: p,
|
|
1412
|
-
isPending: E,
|
|
1413
|
-
isSuccess: v === "success",
|
|
1414
|
-
isError: x,
|
|
1415
|
-
isInitialLoading: w,
|
|
1416
|
-
isLoading: w,
|
|
1417
|
-
data: f,
|
|
1418
|
-
dataUpdatedAt: l.dataUpdatedAt,
|
|
1419
|
-
error: P,
|
|
1420
|
-
errorUpdatedAt: U,
|
|
1421
|
-
failureCount: l.fetchFailureCount,
|
|
1422
|
-
failureReason: l.fetchFailureReason,
|
|
1423
|
-
errorUpdateCount: l.errorUpdateCount,
|
|
1424
|
-
isFetched: l.dataUpdateCount > 0 || l.errorUpdateCount > 0,
|
|
1425
|
-
isFetchedAfterMount: l.dataUpdateCount > b.dataUpdateCount || l.errorUpdateCount > b.errorUpdateCount,
|
|
1426
|
-
isFetching: m,
|
|
1427
|
-
isRefetching: m && !E,
|
|
1428
|
-
isLoadingError: x && l.dataUpdatedAt === 0,
|
|
1429
|
-
isPaused: p === "paused",
|
|
1430
|
-
isPlaceholderData: S,
|
|
1431
|
-
isRefetchError: x && l.dataUpdatedAt !== 0,
|
|
1432
|
-
isStale: At(e, s),
|
|
1433
|
-
refetch: this.refetch
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
updateResult(e) {
|
|
1437
|
-
const s = i(this, k), r = this.createResult(i(this, C), this.options);
|
|
1438
|
-
if (o(this, me, i(this, C).state), o(this, ke, this.options), i(this, me).data !== void 0 && o(this, Qe, i(this, C)), at(r, s))
|
|
1439
|
-
return;
|
|
1440
|
-
o(this, k, r);
|
|
1441
|
-
const n = {}, a = () => {
|
|
1442
|
-
if (!s)
|
|
1443
|
-
return !0;
|
|
1444
|
-
const { notifyOnChangeProps: c } = this.options, d = typeof c == "function" ? c() : c;
|
|
1445
|
-
if (d === "all" || !d && !i(this, ve).size)
|
|
1446
|
-
return !0;
|
|
1447
|
-
const g = new Set(
|
|
1448
|
-
d ?? i(this, ve)
|
|
1449
|
-
);
|
|
1450
|
-
return this.options.throwOnError && g.add("error"), Object.keys(i(this, k)).some((b) => {
|
|
1451
|
-
const l = b;
|
|
1452
|
-
return i(this, k)[l] !== s[l] && g.has(l);
|
|
1453
|
-
});
|
|
1454
|
-
};
|
|
1455
|
-
(e == null ? void 0 : e.listeners) !== !1 && a() && (n.listeners = !0), y(this, ct, os).call(this, { ...n, ...e });
|
|
1456
|
-
}
|
|
1457
|
-
onQueryUpdate() {
|
|
1458
|
-
this.updateResult(), this.hasListeners() && y(this, We, wt).call(this);
|
|
1459
|
-
}
|
|
1460
|
-
}, T = new WeakMap(), C = new WeakMap(), Ue = new WeakMap(), k = new WeakMap(), me = new WeakMap(), ke = new WeakMap(), X = new WeakMap(), Ge = new WeakMap(), De = new WeakMap(), Qe = new WeakMap(), ge = new WeakMap(), be = new WeakMap(), he = new WeakMap(), ve = new WeakMap(), xe = new WeakSet(), Le = function(e) {
|
|
1461
|
-
y(this, Ze, Ot).call(this);
|
|
1462
|
-
let s = i(this, C).fetch(
|
|
1463
|
-
this.options,
|
|
1464
|
-
e
|
|
1465
|
-
);
|
|
1466
|
-
return e != null && e.throwOnError || (s = s.catch(H)), s;
|
|
1467
|
-
}, ze = new WeakSet(), bt = function() {
|
|
1468
|
-
if (y(this, Ye, Ct).call(this), Te || i(this, k).isStale || !pt(this.options.staleTime))
|
|
1469
|
-
return;
|
|
1470
|
-
const s = es(
|
|
1471
|
-
i(this, k).dataUpdatedAt,
|
|
1472
|
-
this.options.staleTime
|
|
1473
|
-
) + 1;
|
|
1474
|
-
o(this, ge, setTimeout(() => {
|
|
1475
|
-
i(this, k).isStale || this.updateResult();
|
|
1476
|
-
}, s));
|
|
1477
|
-
}, Ve = new WeakSet(), vt = function() {
|
|
1478
|
-
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(i(this, C)) : this.options.refetchInterval) ?? !1;
|
|
1479
|
-
}, Je = new WeakSet(), xt = function(e) {
|
|
1480
|
-
y(this, Xe, Pt).call(this), o(this, he, e), !(Te || this.options.enabled === !1 || !pt(i(this, he)) || i(this, he) === 0) && o(this, be, setInterval(() => {
|
|
1481
|
-
(this.options.refetchIntervalInBackground || ot.isFocused()) && y(this, xe, Le).call(this);
|
|
1482
|
-
}, i(this, he)));
|
|
1483
|
-
}, We = new WeakSet(), wt = function() {
|
|
1484
|
-
y(this, ze, bt).call(this), y(this, Je, xt).call(this, y(this, Ve, vt).call(this));
|
|
1485
|
-
}, Ye = new WeakSet(), Ct = function() {
|
|
1486
|
-
i(this, ge) && (clearTimeout(i(this, ge)), o(this, ge, void 0));
|
|
1487
|
-
}, Xe = new WeakSet(), Pt = function() {
|
|
1488
|
-
i(this, be) && (clearInterval(i(this, be)), o(this, be, void 0));
|
|
1489
|
-
}, Ze = new WeakSet(), Ot = function() {
|
|
1490
|
-
const e = i(this, T).getQueryCache().build(i(this, T), this.options);
|
|
1491
|
-
if (e === i(this, C))
|
|
1492
|
-
return;
|
|
1493
|
-
const s = i(this, C);
|
|
1494
|
-
o(this, C, e), o(this, Ue, e.state), this.hasListeners() && (s == null || s.removeObserver(this), e.addObserver(this));
|
|
1495
|
-
}, ct = new WeakSet(), os = function(e) {
|
|
1496
|
-
R.batch(() => {
|
|
1497
|
-
e.listeners && this.listeners.forEach((s) => {
|
|
1498
|
-
s(i(this, k));
|
|
1499
|
-
}), i(this, T).getQueryCache().notify({
|
|
1500
|
-
query: i(this, C),
|
|
1501
|
-
type: "observerResultsUpdated"
|
|
1502
|
-
});
|
|
1503
|
-
});
|
|
1504
|
-
}, Wt);
|
|
1505
|
-
function or(t, e) {
|
|
1506
|
-
return e.enabled !== !1 && !t.state.dataUpdatedAt && !(t.state.status === "error" && e.retryOnMount === !1);
|
|
1507
|
-
}
|
|
1508
|
-
function It(t, e) {
|
|
1509
|
-
return or(t, e) || t.state.dataUpdatedAt > 0 && St(t, e, e.refetchOnMount);
|
|
1510
|
-
}
|
|
1511
|
-
function St(t, e, s) {
|
|
1512
|
-
if (e.enabled !== !1) {
|
|
1513
|
-
const r = typeof s == "function" ? s(t) : s;
|
|
1514
|
-
return r === "always" || r !== !1 && At(t, e);
|
|
1515
|
-
}
|
|
1516
|
-
return !1;
|
|
1517
|
-
}
|
|
1518
|
-
function Lt(t, e, s, r) {
|
|
1519
|
-
return s.enabled !== !1 && (t !== e || r.enabled === !1) && (!s.suspense || t.state.status !== "error") && At(t, s);
|
|
1520
|
-
}
|
|
1521
|
-
function At(t, e) {
|
|
1522
|
-
return t.isStaleByTime(e.staleTime);
|
|
1523
|
-
}
|
|
1524
|
-
function ur(t, e) {
|
|
1525
|
-
return !at(t.getCurrentResult(), e);
|
|
1526
|
-
}
|
|
1527
|
-
var le, N, $, te, Ne, nt, et, jt, Yt, cr = (Yt = class extends Ie {
|
|
1528
|
-
constructor(e, s) {
|
|
1529
|
-
super();
|
|
1530
|
-
h(this, Ne);
|
|
1531
|
-
h(this, et);
|
|
1532
|
-
h(this, le, void 0);
|
|
1533
|
-
h(this, N, void 0);
|
|
1534
|
-
h(this, $, void 0);
|
|
1535
|
-
h(this, te, void 0);
|
|
1536
|
-
o(this, N, void 0), o(this, le, e), this.setOptions(s), this.bindMethods(), y(this, Ne, nt).call(this);
|
|
1537
|
-
}
|
|
1538
|
-
bindMethods() {
|
|
1539
|
-
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
1540
|
-
}
|
|
1541
|
-
setOptions(e) {
|
|
1542
|
-
var r;
|
|
1543
|
-
const s = this.options;
|
|
1544
|
-
this.options = i(this, le).defaultMutationOptions(e), at(s, this.options) || i(this, le).getMutationCache().notify({
|
|
1545
|
-
type: "observerOptionsUpdated",
|
|
1546
|
-
mutation: i(this, $),
|
|
1547
|
-
observer: this
|
|
1548
|
-
}), (r = i(this, $)) == null || r.setOptions(this.options);
|
|
1549
|
-
}
|
|
1550
|
-
onUnsubscribe() {
|
|
1551
|
-
var e;
|
|
1552
|
-
this.hasListeners() || (e = i(this, $)) == null || e.removeObserver(this);
|
|
1553
|
-
}
|
|
1554
|
-
onMutationUpdate(e) {
|
|
1555
|
-
y(this, Ne, nt).call(this), y(this, et, jt).call(this, e);
|
|
1556
|
-
}
|
|
1557
|
-
getCurrentResult() {
|
|
1558
|
-
return i(this, N);
|
|
1559
|
-
}
|
|
1560
|
-
reset() {
|
|
1561
|
-
o(this, $, void 0), y(this, Ne, nt).call(this), y(this, et, jt).call(this);
|
|
1562
|
-
}
|
|
1563
|
-
mutate(e, s) {
|
|
1564
|
-
var r;
|
|
1565
|
-
return o(this, te, s), (r = i(this, $)) == null || r.removeObserver(this), o(this, $, i(this, le).getMutationCache().build(i(this, le), this.options)), i(this, $).addObserver(this), i(this, $).execute(e);
|
|
1566
|
-
}
|
|
1567
|
-
}, le = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), te = new WeakMap(), Ne = new WeakSet(), nt = function() {
|
|
1568
|
-
var s;
|
|
1569
|
-
const e = ((s = i(this, $)) == null ? void 0 : s.state) ?? as();
|
|
1570
|
-
o(this, N, {
|
|
1571
|
-
...e,
|
|
1572
|
-
isPending: e.status === "pending",
|
|
1573
|
-
isSuccess: e.status === "success",
|
|
1574
|
-
isError: e.status === "error",
|
|
1575
|
-
isIdle: e.status === "idle",
|
|
1576
|
-
mutate: this.mutate,
|
|
1577
|
-
reset: this.reset
|
|
1578
|
-
});
|
|
1579
|
-
}, et = new WeakSet(), jt = function(e) {
|
|
1580
|
-
R.batch(() => {
|
|
1581
|
-
var s, r, n, a, c, d, g, b;
|
|
1582
|
-
i(this, te) && this.hasListeners() && ((e == null ? void 0 : e.type) === "success" ? ((r = (s = i(this, te)).onSuccess) == null || r.call(
|
|
1583
|
-
s,
|
|
1584
|
-
e.data,
|
|
1585
|
-
i(this, N).variables,
|
|
1586
|
-
i(this, N).context
|
|
1587
|
-
), (a = (n = i(this, te)).onSettled) == null || a.call(
|
|
1588
|
-
n,
|
|
1589
|
-
e.data,
|
|
1590
|
-
null,
|
|
1591
|
-
i(this, N).variables,
|
|
1592
|
-
i(this, N).context
|
|
1593
|
-
)) : (e == null ? void 0 : e.type) === "error" && ((d = (c = i(this, te)).onError) == null || d.call(
|
|
1594
|
-
c,
|
|
1595
|
-
e.error,
|
|
1596
|
-
i(this, N).variables,
|
|
1597
|
-
i(this, N).context
|
|
1598
|
-
), (b = (g = i(this, te)).onSettled) == null || b.call(
|
|
1599
|
-
g,
|
|
1600
|
-
void 0,
|
|
1601
|
-
e.error,
|
|
1602
|
-
i(this, N).variables,
|
|
1603
|
-
i(this, N).context
|
|
1604
|
-
))), this.listeners.forEach((l) => {
|
|
1605
|
-
l(i(this, N));
|
|
1606
|
-
});
|
|
1607
|
-
});
|
|
1608
|
-
}, Yt), us = M.createContext(
|
|
1609
|
-
void 0
|
|
1610
|
-
), G = (t) => {
|
|
1611
|
-
const e = M.useContext(us);
|
|
1612
|
-
if (t)
|
|
1613
|
-
return t;
|
|
1614
|
-
if (!e)
|
|
1615
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1616
|
-
return e;
|
|
1617
|
-
}, hr = ({
|
|
1618
|
-
client: t,
|
|
1619
|
-
children: e
|
|
1620
|
-
}) => (M.useEffect(() => (t.mount(), () => {
|
|
1621
|
-
t.unmount();
|
|
1622
|
-
}), [t]), /* @__PURE__ */ M.createElement(us.Provider, { value: t }, e)), cs = M.createContext(!1), lr = () => M.useContext(cs);
|
|
1623
|
-
cs.Provider;
|
|
1624
|
-
function dr() {
|
|
1625
|
-
let t = !1;
|
|
1626
|
-
return {
|
|
1627
|
-
clearReset: () => {
|
|
1628
|
-
t = !1;
|
|
1629
|
-
},
|
|
1630
|
-
reset: () => {
|
|
1631
|
-
t = !0;
|
|
1632
|
-
},
|
|
1633
|
-
isReset: () => t
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
var fr = M.createContext(dr()), yr = () => M.useContext(fr);
|
|
1637
|
-
function hs(t, e) {
|
|
1638
|
-
return typeof t == "function" ? t(...e) : !!t;
|
|
1639
|
-
}
|
|
1640
|
-
var pr = (t, e) => {
|
|
1641
|
-
(t.suspense || t.throwOnError) && (e.isReset() || (t.retryOnMount = !1));
|
|
1642
|
-
}, mr = (t) => {
|
|
1643
|
-
M.useEffect(() => {
|
|
1644
|
-
t.clearReset();
|
|
1645
|
-
}, [t]);
|
|
1646
|
-
}, gr = ({
|
|
1647
|
-
result: t,
|
|
1648
|
-
errorResetBoundary: e,
|
|
1649
|
-
throwOnError: s,
|
|
1650
|
-
query: r
|
|
1651
|
-
}) => t.isError && !e.isReset() && !t.isFetching && hs(s, [t.error, r]), br = (t) => {
|
|
1652
|
-
t.suspense && typeof t.staleTime != "number" && (t.staleTime = 1e3);
|
|
1653
|
-
}, vr = (t, e) => (t == null ? void 0 : t.suspense) && e.isPending, xr = (t, e, s) => e.fetchOptimistic(t).catch(() => {
|
|
1654
|
-
s.clearReset();
|
|
1655
|
-
});
|
|
1656
|
-
function wr(t, e, s) {
|
|
1657
|
-
if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
|
|
1658
|
-
throw new Error(
|
|
1659
|
-
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
1660
|
-
);
|
|
1661
|
-
const r = G(s), n = lr(), a = yr(), c = r.defaultQueryOptions(t);
|
|
1662
|
-
c._optimisticResults = n ? "isRestoring" : "optimistic", br(c), pr(c, a), mr(a);
|
|
1663
|
-
const [d] = M.useState(
|
|
1664
|
-
() => new e(
|
|
1665
|
-
r,
|
|
1666
|
-
c
|
|
1667
|
-
)
|
|
1668
|
-
), g = d.getOptimisticResult(c);
|
|
1669
|
-
if (M.useSyncExternalStore(
|
|
1670
|
-
M.useCallback(
|
|
1671
|
-
(b) => {
|
|
1672
|
-
const l = n ? () => {
|
|
1673
|
-
} : d.subscribe(R.batchCalls(b));
|
|
1674
|
-
return d.updateResult(), l;
|
|
1675
|
-
},
|
|
1676
|
-
[d, n]
|
|
1677
|
-
),
|
|
1678
|
-
() => d.getCurrentResult(),
|
|
1679
|
-
() => d.getCurrentResult()
|
|
1680
|
-
), M.useEffect(() => {
|
|
1681
|
-
d.setOptions(c, { listeners: !1 });
|
|
1682
|
-
}, [c, d]), vr(c, g))
|
|
1683
|
-
throw xr(c, d, a);
|
|
1684
|
-
if (gr({
|
|
1685
|
-
result: g,
|
|
1686
|
-
errorResetBoundary: a,
|
|
1687
|
-
throwOnError: c.throwOnError,
|
|
1688
|
-
query: d.getCurrentQuery()
|
|
1689
|
-
}))
|
|
1690
|
-
throw g.error;
|
|
1691
|
-
return c.notifyOnChangeProps ? g : d.trackResult(g);
|
|
1692
|
-
}
|
|
1693
|
-
function tt(t, e) {
|
|
1694
|
-
return wr(t, ar, e);
|
|
1695
|
-
}
|
|
1696
|
-
function V(t, e) {
|
|
1697
|
-
const s = G(e), [r] = M.useState(
|
|
1698
|
-
() => new cr(
|
|
1699
|
-
s,
|
|
1700
|
-
t
|
|
1701
|
-
)
|
|
1702
|
-
);
|
|
1703
|
-
M.useEffect(() => {
|
|
1704
|
-
r.setOptions(t);
|
|
1705
|
-
}, [r, t]);
|
|
1706
|
-
const n = M.useSyncExternalStore(
|
|
1707
|
-
M.useCallback(
|
|
1708
|
-
(c) => r.subscribe(R.batchCalls(c)),
|
|
1709
|
-
[r]
|
|
1710
|
-
),
|
|
1711
|
-
() => r.getCurrentResult(),
|
|
1712
|
-
() => r.getCurrentResult()
|
|
1713
|
-
), a = M.useCallback(
|
|
1714
|
-
(c, d) => {
|
|
1715
|
-
r.mutate(c, d).catch(Cr);
|
|
1716
|
-
},
|
|
1717
|
-
[r]
|
|
1718
|
-
);
|
|
1719
|
-
if (n.error && hs(r.options.throwOnError, [n.error]))
|
|
1720
|
-
throw n.error;
|
|
1721
|
-
return { ...n, mutate: a, mutateAsync: n.mutate };
|
|
1722
|
-
}
|
|
1723
|
-
function Cr() {
|
|
1724
|
-
}
|
|
1725
|
-
function D() {
|
|
1726
|
-
return G().getQueryData(["apiBaseUrl"]) || "/api/chaibuilder";
|
|
1727
|
-
}
|
|
1728
|
-
const we = () => {
|
|
1729
|
-
const { data: t, refetch: e } = tt({
|
|
1730
|
-
queryKey: ["currentPage"],
|
|
1731
|
-
queryFn: () => localStorage.getItem("currentPage") || ""
|
|
1732
|
-
});
|
|
1733
|
-
return [
|
|
1734
|
-
t,
|
|
1735
|
-
(s) => {
|
|
1736
|
-
s && (localStorage.setItem("currentPage", s || ""), e());
|
|
1737
|
-
}
|
|
1738
|
-
];
|
|
1739
|
-
};
|
|
1740
|
-
let Kt = "";
|
|
1741
|
-
const st = () => (Kt = localStorage.getItem("__chai_at"), Kt);
|
|
1742
|
-
function Pr(t) {
|
|
1743
|
-
const e = {
|
|
1744
|
-
method: "GET",
|
|
1745
|
-
headers: { "x-chai-access-token": st() }
|
|
1746
|
-
};
|
|
1747
|
-
return fetch(t, e);
|
|
1748
|
-
}
|
|
1749
|
-
function Or(t, e) {
|
|
1750
|
-
const s = {
|
|
1751
|
-
method: "POST",
|
|
1752
|
-
headers: { "x-chai-access-token": st() },
|
|
1753
|
-
body: JSON.stringify(e)
|
|
1754
|
-
};
|
|
1755
|
-
return fetch(t, s);
|
|
1756
|
-
}
|
|
1757
|
-
function Sr(t, e) {
|
|
1758
|
-
const s = {
|
|
1759
|
-
method: "PUT",
|
|
1760
|
-
headers: { "x-chai-access-token": st() },
|
|
1761
|
-
body: JSON.stringify(e)
|
|
1762
|
-
};
|
|
1763
|
-
return fetch(t, s);
|
|
1764
|
-
}
|
|
1765
|
-
function jr(t, e) {
|
|
1766
|
-
const s = {
|
|
1767
|
-
method: "DELETE",
|
|
1768
|
-
headers: { "x-chai-access-token": st() },
|
|
1769
|
-
body: JSON.stringify(e)
|
|
1770
|
-
};
|
|
1771
|
-
return fetch(t, s);
|
|
1772
|
-
}
|
|
1773
|
-
const L = {
|
|
1774
|
-
get: Pr,
|
|
1775
|
-
post: Or,
|
|
1776
|
-
put: Sr,
|
|
1777
|
-
delete: jr
|
|
1778
|
-
}, ls = () => {
|
|
1779
|
-
const [t, e] = we(), s = D();
|
|
1780
|
-
return tt({
|
|
1781
|
-
queryKey: ["project"],
|
|
1782
|
-
queryFn: async () => {
|
|
1783
|
-
const { data: r } = await L.get(`${s}/project`).then((n) => n.json());
|
|
1784
|
-
if (!t && r) {
|
|
1785
|
-
const n = localStorage.getItem("currentPage");
|
|
1786
|
-
e(n || (r == null ? void 0 : r.homepage));
|
|
1787
|
-
}
|
|
1788
|
-
return r;
|
|
1789
|
-
}
|
|
1790
|
-
});
|
|
1791
|
-
}, ds = () => {
|
|
1792
|
-
const t = D();
|
|
1793
|
-
return tt({
|
|
1794
|
-
queryKey: ["pages"],
|
|
1795
|
-
queryFn: async () => {
|
|
1796
|
-
const { data: e } = await L.get(`${t}/pages`).then((s) => s.json());
|
|
1797
|
-
return e || [];
|
|
1798
|
-
}
|
|
1799
|
-
});
|
|
1800
|
-
}, fs = () => {
|
|
1801
|
-
const [t] = we(), e = D();
|
|
1802
|
-
return tt({
|
|
1803
|
-
queryKey: ["page_data", t],
|
|
1804
|
-
queryFn: async () => {
|
|
1805
|
-
const { data: s } = await L.get(`${e}/page?uuid=${t}`).then((r) => r.json());
|
|
1806
|
-
return s;
|
|
1807
|
-
},
|
|
1808
|
-
enabled: !!t,
|
|
1809
|
-
staleTime: 3e3
|
|
1810
|
-
});
|
|
1811
|
-
}, Et = () => /* @__PURE__ */ u.jsx("div", { className: "h-screen w-screen bg-gray-200", children: /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col h-full w-full justify-center items-center", children: [
|
|
1812
|
-
/* @__PURE__ */ u.jsxs("div", { className: "flex flex-row gap-2", children: [
|
|
1813
|
-
/* @__PURE__ */ u.jsx("div", { className: "w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]" }),
|
|
1814
|
-
/* @__PURE__ */ u.jsx("div", { className: "w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]" }),
|
|
1815
|
-
/* @__PURE__ */ u.jsx("div", { className: "w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]" }),
|
|
1816
|
-
/* @__PURE__ */ u.jsx("div", { className: "w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]" })
|
|
1817
|
-
] }),
|
|
1818
|
-
/* @__PURE__ */ u.jsx("div", { className: "text-gray-700 font-thin", children: "Loading Builder..." })
|
|
1819
|
-
] }) }), Er = (t = "Project updated successfully.") => {
|
|
1820
|
-
const e = G(), s = D();
|
|
1821
|
-
return V({
|
|
1822
|
-
mutationFn: async (r) => await L.put(`${s}/project`, r).then((n) => n.json()),
|
|
1823
|
-
onSuccess: () => {
|
|
1824
|
-
e.invalidateQueries({ queryKey: ["project"] }), se.success(t);
|
|
1825
|
-
}
|
|
1826
|
-
});
|
|
1827
|
-
}, Fr = () => {
|
|
1828
|
-
const [t] = ["SAVED"], [e, s] = we(), r = bs(), { t: n } = xs();
|
|
1829
|
-
return (a) => t !== "SAVED" ? (se.error(n("You have unsaved changes. Please save before changing the page.")), !1) : e === a.uuid ? !1 : (r(), setTimeout(() => s(a.uuid), 100), !0);
|
|
1830
|
-
}, li = () => {
|
|
1831
|
-
const t = G(), e = Fr(), s = D();
|
|
1832
|
-
return V({
|
|
1833
|
-
mutationFn: async (r) => L.post(`${s}/pages`, r).then((n) => n.json()),
|
|
1834
|
-
onSuccess: (r) => {
|
|
1835
|
-
t.invalidateQueries({ queryKey: ["pages"] }), e({ uuid: r.uuid, slug: r.slug }), se.success("Page added successfully.");
|
|
1836
|
-
}
|
|
1837
|
-
});
|
|
1838
|
-
}, Rr = () => {
|
|
1839
|
-
const t = D(), [e] = we(), s = G();
|
|
1840
|
-
return V({
|
|
1841
|
-
mutationFn: async (r) => L.put(`${t}/page`, r).then((n) => n.json()),
|
|
1842
|
-
onSuccess: async (r) => {
|
|
1843
|
-
var n;
|
|
1844
|
-
if (r.result === "error" && ((n = r.error) == null ? void 0 : n.code) == "PAGE_LOCKED") {
|
|
1845
|
-
s.invalidateQueries({ queryKey: ["page_data", e] });
|
|
1846
|
-
return;
|
|
1847
|
-
}
|
|
1848
|
-
se.success("Page saved successfully.");
|
|
1849
|
-
}
|
|
1850
|
-
});
|
|
1851
|
-
}, Ar = () => {
|
|
1852
|
-
const t = D(), { data: e } = ds(), [s] = we(), { data: r } = ls(), n = G();
|
|
1853
|
-
return V({
|
|
1854
|
-
mutationFn: async () => {
|
|
1855
|
-
const a = e.find((c) => c.uuid === s).slug;
|
|
1856
|
-
return await L.post(`${t}/publish`, {
|
|
1857
|
-
slug: a,
|
|
1858
|
-
uuid: s,
|
|
1859
|
-
isHomepage: (r == null ? void 0 : r.homepage) === s
|
|
1860
|
-
}).then((c) => c.json());
|
|
1861
|
-
},
|
|
1862
|
-
onSuccess: async (a) => {
|
|
1863
|
-
var c;
|
|
1864
|
-
if (a.result === "error" && ((c = a.error) == null ? void 0 : c.code) == "PAGE_LOCKED") {
|
|
1865
|
-
n.invalidateQueries({ queryKey: ["page_data", s] });
|
|
1866
|
-
return;
|
|
1867
|
-
}
|
|
1868
|
-
se.success("Page published successfully.", {
|
|
1869
|
-
position: "bottom-right",
|
|
1870
|
-
duration: 2e3
|
|
1871
|
-
});
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
}, di = () => {
|
|
1875
|
-
const t = G(), e = D();
|
|
1876
|
-
return V({
|
|
1877
|
-
mutationFn: async (s) => L.delete(`${e}/page`, s).then((r) => r.json()),
|
|
1878
|
-
onSuccess: () => {
|
|
1879
|
-
se.success("Page deleted successfully."), t.invalidateQueries({ queryKey: ["pages"] });
|
|
1880
|
-
}
|
|
1881
|
-
});
|
|
1882
|
-
}, Mr = () => {
|
|
1883
|
-
const t = G(), e = D();
|
|
1884
|
-
return V({
|
|
1885
|
-
mutationFn: async (s) => L.post(`${e}/take-control`, { uuid: s }).then((r) => r.json()),
|
|
1886
|
-
onSuccess: (s, r) => {
|
|
1887
|
-
t.invalidateQueries({ queryKey: ["page_data", r] });
|
|
1888
|
-
}
|
|
1889
|
-
});
|
|
1890
|
-
}, qr = () => {
|
|
1891
|
-
const t = D();
|
|
1892
|
-
return V({
|
|
1893
|
-
mutationFn: async () => {
|
|
1894
|
-
const { data: e } = await L.get(`${t}/library`).then((s) => s.json());
|
|
1895
|
-
return Es(
|
|
1896
|
-
Fs(e, (s) => !Rs(s, "hidden")),
|
|
1897
|
-
"group"
|
|
1898
|
-
);
|
|
1899
|
-
}
|
|
1900
|
-
});
|
|
1901
|
-
}, Ur = () => {
|
|
1902
|
-
const t = D();
|
|
1903
|
-
return V({
|
|
1904
|
-
mutationFn: async (e) => {
|
|
1905
|
-
if (!e || !e.uuid)
|
|
1906
|
-
return [];
|
|
1907
|
-
try {
|
|
1908
|
-
const { data: s } = await L.get(`${t}/block?uuid=${e.uuid}&format=${e.format}`).then(async (r) => e.format === "html" ? Us(await r.text()) : await r.json());
|
|
1909
|
-
return As(s, "0._name", Ms(e.group)), s || [];
|
|
1910
|
-
} catch {
|
|
1911
|
-
return [];
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
});
|
|
1915
|
-
}, kr = () => {
|
|
1916
|
-
const t = D();
|
|
1917
|
-
return V({
|
|
1918
|
-
mutationFn: async (e) => {
|
|
1919
|
-
const s = new FormData();
|
|
1920
|
-
s.append("file", e);
|
|
1921
|
-
const { data: r } = await fetch(`${t}/upload`, {
|
|
1922
|
-
method: "POST",
|
|
1923
|
-
headers: { "x-chai-access-token": st() },
|
|
1924
|
-
body: s
|
|
1925
|
-
}).then((n) => n.json());
|
|
1926
|
-
return r;
|
|
1927
|
-
}
|
|
1928
|
-
});
|
|
1929
|
-
};
|
|
1930
|
-
function ys(t) {
|
|
1931
|
-
return Zt({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" } }, { tag: "path", attr: { d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z" } }] })(t);
|
|
1932
|
-
}
|
|
1933
|
-
function Dr(t) {
|
|
1934
|
-
return Zt({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" } }, { tag: "path", attr: { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" } }] })(t);
|
|
1935
|
-
}
|
|
1936
|
-
const Qr = () => {
|
|
1937
|
-
const { mutate: t, isPending: e } = Mr(), [s] = we(), { data: r } = fs(), n = Mt(r, "lockedBy.name", ""), a = Mt(r, "lockedBy.email", "");
|
|
1938
|
-
return /* @__PURE__ */ u.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl", children: [
|
|
1939
|
-
/* @__PURE__ */ u.jsxs("h2", { className: "text-2xl font-bold", children: [
|
|
1940
|
-
"Page is ",
|
|
1941
|
-
/* @__PURE__ */ u.jsx("span", { className: "text-red-500", children: "locked" })
|
|
1942
|
-
] }),
|
|
1943
|
-
/* @__PURE__ */ u.jsxs("div", { className: "text-gray-500 dark:text-gray-400 font-light", children: [
|
|
1944
|
-
"This page is currently being edited by ",
|
|
1945
|
-
/* @__PURE__ */ u.jsx("br", {}),
|
|
1946
|
-
/* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm", children: [
|
|
1947
|
-
/* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md", children: [
|
|
1948
|
-
/* @__PURE__ */ u.jsx(Dr, { className: "w-4 h-4 text-gray-500" }),
|
|
1949
|
-
" ",
|
|
1950
|
-
n
|
|
1951
|
-
] }),
|
|
1952
|
-
/* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase", children: [
|
|
1953
|
-
/* @__PURE__ */ u.jsx(ys, { className: "w-4 h-4 text-gray-500" }),
|
|
1954
|
-
" ",
|
|
1955
|
-
a
|
|
1956
|
-
] })
|
|
1957
|
-
] }),
|
|
1958
|
-
/* @__PURE__ */ u.jsxs("div", { className: "pt-4", children: [
|
|
1959
|
-
"If you take control, ",
|
|
1960
|
-
n,
|
|
1961
|
-
" will be ",
|
|
1962
|
-
/* @__PURE__ */ u.jsx("span", { className: "text-red-500", children: "restricted" }),
|
|
1963
|
-
" from making additional edits."
|
|
1964
|
-
] })
|
|
1965
|
-
] }),
|
|
1966
|
-
/* @__PURE__ */ u.jsx(
|
|
1967
|
-
Xt,
|
|
1968
|
-
{
|
|
1969
|
-
disabled: e,
|
|
1970
|
-
onClick: () => t(s),
|
|
1971
|
-
className: `w-36 ${e ? "bg-transparent shadow-none hover:bg-transparent" : ""}`,
|
|
1972
|
-
children: e ? /* @__PURE__ */ u.jsx(ks, { className: "text-sm animate-spin text-gray-500" }) : "Take Over"
|
|
1973
|
-
}
|
|
1974
|
-
)
|
|
1975
|
-
] });
|
|
1976
|
-
}, Nr = () => {
|
|
1977
|
-
const t = D(), e = G();
|
|
1978
|
-
return V({
|
|
1979
|
-
mutationFn: async (s) => {
|
|
1980
|
-
const r = await fetch(`${t}/login`, { method: "POST", body: JSON.stringify(s) });
|
|
1981
|
-
if (r.ok)
|
|
1982
|
-
return await r.json();
|
|
1983
|
-
throw r.status === 401 ? new Error("Invalid login credentials") : new Error("Invalid");
|
|
1984
|
-
},
|
|
1985
|
-
onSuccess: (s) => {
|
|
1986
|
-
const { data: r } = s;
|
|
1987
|
-
if (!r.accessToken) {
|
|
1988
|
-
se.error("Something went wrong. Please try again.", { position: "top-center" });
|
|
1989
|
-
return;
|
|
1990
|
-
}
|
|
1991
|
-
localStorage.setItem("__chai_at", r.accessToken), localStorage.setItem("__chai_ur", JSON.stringify(qs(r, ["accessToken"]))), e.invalidateQueries({ queryKey: ["verify"] }), se.success("Logged in successfully.");
|
|
1992
|
-
},
|
|
1993
|
-
onError: () => {
|
|
1994
|
-
se.error("Invalid login credentials. Please try again.", { position: "top-center" });
|
|
1995
|
-
}
|
|
1996
|
-
});
|
|
1997
|
-
}, Tr = () => {
|
|
1998
|
-
const t = D();
|
|
1999
|
-
return tt({
|
|
2000
|
-
queryKey: ["verify"],
|
|
2001
|
-
queryFn: async () => {
|
|
2002
|
-
const e = await L.get(`${t}/verify`);
|
|
2003
|
-
return e.ok ? (await e.json()).result === "success" ? { valid: !0 } : (localStorage.removeItem("__chai_at"), { valid: !1 }) : (localStorage.removeItem("__chai_at"), { valid: !0 });
|
|
2004
|
-
}
|
|
2005
|
-
});
|
|
2006
|
-
}, Ir = () => {
|
|
2007
|
-
const t = D(), e = G();
|
|
2008
|
-
return V({
|
|
2009
|
-
mutationFn: async () => {
|
|
2010
|
-
const { result: s } = await L.post(`${t}/logout`).then((r) => r.json());
|
|
2011
|
-
if (s === "success")
|
|
2012
|
-
return localStorage.clear(), e.invalidateQueries({ queryKey: ["verify"] }), { logout: !0 };
|
|
2013
|
-
throw new Error("Invalid session");
|
|
2014
|
-
}
|
|
2015
|
-
});
|
|
2016
|
-
}, Lr = ({ children: t }) => {
|
|
2017
|
-
const e = Ir();
|
|
2018
|
-
return /* @__PURE__ */ u.jsxs(Ns, { children: [
|
|
2019
|
-
/* @__PURE__ */ u.jsx(Ts, { asChild: !0, children: t }),
|
|
2020
|
-
/* @__PURE__ */ u.jsxs(Is, { children: [
|
|
2021
|
-
/* @__PURE__ */ u.jsxs(Ls, { children: [
|
|
2022
|
-
/* @__PURE__ */ u.jsxs(Ks, { children: [
|
|
2023
|
-
"Are you sure, you want to ",
|
|
2024
|
-
/* @__PURE__ */ u.jsx("span", { className: "text-red-500", children: "Sign Out" }),
|
|
2025
|
-
"?"
|
|
2026
|
-
] }),
|
|
2027
|
-
/* @__PURE__ */ u.jsx(Bs, { children: "Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information" })
|
|
2028
|
-
] }),
|
|
2029
|
-
/* @__PURE__ */ u.jsxs(_s, { children: [
|
|
2030
|
-
/* @__PURE__ */ u.jsx($s, { disabled: e.isPending, children: "Cancel" }),
|
|
2031
|
-
/* @__PURE__ */ u.jsxs(
|
|
2032
|
-
"button",
|
|
2033
|
-
{
|
|
2034
|
-
disabled: e.isPending,
|
|
2035
|
-
onClick: () => e.mutate(),
|
|
2036
|
-
className: "rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",
|
|
2037
|
-
children: [
|
|
2038
|
-
e.isPending && /* @__PURE__ */ u.jsx(Qs, { className: "animate-spin w-5 h-5" }),
|
|
2039
|
-
"Sign Out"
|
|
2040
|
-
]
|
|
2041
|
-
}
|
|
2042
|
-
)
|
|
2043
|
-
] })
|
|
2044
|
-
] })
|
|
2045
|
-
] });
|
|
2046
|
-
}, Kr = () => /* @__PURE__ */ u.jsx(Lr, { children: /* @__PURE__ */ u.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ u.jsx(Ds, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), Br = Kr, _r = Ft(() => import("./PagesPanel-u1IB-nRr.js")), $r = Ft(() => import("./ProjectPanel-EydGZmMW.js")), Hr = Ft(() => import("./CurrentPage-Kmfp-kFk.js")), Gr = () => /* @__PURE__ */ u.jsx("h2", { children: "Your Logo" }), zr = () => {
|
|
2047
|
-
const { mutate: t } = Ar();
|
|
2048
|
-
return ws("editable", !0) ? /* @__PURE__ */ u.jsx(Xt, { onClick: t, className: "bg-blue-600 text-white", children: "Publish" }) : null;
|
|
2049
|
-
}, Vr = (t) => {
|
|
2050
|
-
var x;
|
|
2051
|
-
const { data: e, isLoading: s } = ls(), { data: r, isLoading: n } = ds(), { data: a } = fs(), { mutate: c } = Er(), { mutate: d } = Rr(), [g] = we(), b = kr(), l = qr(), P = Ur(), U = D(), p = dt(
|
|
2052
|
-
async (w) => await b.mutateAsync(w),
|
|
2053
|
-
[b]
|
|
2054
|
-
), v = dt(async () => await l.mutateAsync(), [l]), S = dt(
|
|
2055
|
-
async (w) => await P.mutateAsync(w),
|
|
2056
|
-
[P]
|
|
2057
|
-
), f = async (w = 20, q = 0) => {
|
|
2058
|
-
const Q = `limit=${w}&offset=${q}`, j = await fetch(`${U}/assets?${Q}`).then((O) => O.json());
|
|
2059
|
-
return j.result === "success" ? j.data : [];
|
|
2060
|
-
}, { logo: m = Gr } = t;
|
|
2061
|
-
if (s || !e)
|
|
2062
|
-
return /* @__PURE__ */ u.jsx(Et, {});
|
|
2063
|
-
if (n || !r)
|
|
2064
|
-
return /* @__PURE__ */ u.jsx(Et, {});
|
|
2065
|
-
const E = {
|
|
2066
|
-
...t,
|
|
2067
|
-
editable: a != null && a.lockedBy ? a == null ? void 0 : a.lockedBy.self : !0,
|
|
2068
|
-
nonEditableComponent: Qr,
|
|
2069
|
-
blocks: (a == null ? void 0 : a.blocks) || [],
|
|
2070
|
-
brandingOptions: e.brandingOptions,
|
|
2071
|
-
darkMode: t.darkMode || !1,
|
|
2072
|
-
dataProviders: (a == null ? void 0 : a.providers) || [],
|
|
2073
|
-
onSavePage: async ({ blocks: w, providers: q }) => (await d({ blocks: w, providers: q, uuid: g }), !0),
|
|
2074
|
-
onSaveBrandingOptions: async (w) => (await c({ brandingOptions: w }), !0),
|
|
2075
|
-
topBarComponents: {
|
|
2076
|
-
left: [m],
|
|
2077
|
-
center: [Hr],
|
|
2078
|
-
right: [zr]
|
|
2079
|
-
},
|
|
2080
|
-
sideBarComponents: {
|
|
2081
|
-
top: [
|
|
2082
|
-
{ icon: Cs, name: "pages", panel: _r },
|
|
2083
|
-
{ icon: Ps, name: "settings", panel: $r },
|
|
2084
|
-
...((x = t.sideBarComponents) == null ? void 0 : x.top) || []
|
|
2085
|
-
],
|
|
2086
|
-
bottom: [Br]
|
|
2087
|
-
},
|
|
2088
|
-
uploadMediaCallback: p,
|
|
2089
|
-
fetchMediaCallback: f,
|
|
2090
|
-
getUILibraryBlocks: v,
|
|
2091
|
-
getExternalPredefinedBlock: S,
|
|
2092
|
-
getPages: () => r
|
|
2093
|
-
};
|
|
2094
|
-
return /* @__PURE__ */ u.jsx(vs, { ...E });
|
|
2095
|
-
}, Jr = ({ logo: t }) => {
|
|
2096
|
-
const [e, s] = ft(!1), [r, n] = ft(""), [a, c] = ft(""), { mutate: d, isPending: g } = Nr(), b = (l) => {
|
|
2097
|
-
l.preventDefault(), d({ email: r, password: a });
|
|
2098
|
-
};
|
|
2099
|
-
return /* @__PURE__ */ u.jsx("section", { className: "h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]", children: /* @__PURE__ */ u.jsx("div", { className: "overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300", children: /* @__PURE__ */ u.jsxs("div", { className: "p-12", children: [
|
|
2100
|
-
/* @__PURE__ */ u.jsxs("div", { className: "max-w-2xl mx-auto text-center", children: [
|
|
2101
|
-
/* @__PURE__ */ u.jsx(ms, { children: t ? ps.createElement(t) : "" }),
|
|
2102
|
-
/* @__PURE__ */ u.jsx("p", { className: "max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin", children: "Enter your login credential to continue" })
|
|
2103
|
-
] }),
|
|
2104
|
-
/* @__PURE__ */ u.jsx("div", { className: "mt-8", children: /* @__PURE__ */ u.jsxs("form", { method: "POST", onSubmit: b, className: "space-y-5", children: [
|
|
2105
|
-
/* @__PURE__ */ u.jsx("div", { children: /* @__PURE__ */ u.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
|
|
2106
|
-
/* @__PURE__ */ u.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ u.jsx(ys, {}) }),
|
|
2107
|
-
/* @__PURE__ */ u.jsx(
|
|
2108
|
-
"input",
|
|
2109
|
-
{
|
|
2110
|
-
value: r,
|
|
2111
|
-
onChange: (l) => n(l.target.value),
|
|
2112
|
-
type: "email",
|
|
2113
|
-
id: "email",
|
|
2114
|
-
placeholder: "Enter email",
|
|
2115
|
-
className: "block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"
|
|
2116
|
-
}
|
|
2117
|
-
)
|
|
2118
|
-
] }) }),
|
|
2119
|
-
/* @__PURE__ */ u.jsx("div", { children: /* @__PURE__ */ u.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
|
|
2120
|
-
/* @__PURE__ */ u.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ u.jsx(
|
|
2121
|
-
"svg",
|
|
2122
|
-
{
|
|
2123
|
-
className: "w-5 h-5",
|
|
2124
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2125
|
-
fill: "none",
|
|
2126
|
-
viewBox: "0 0 24 24",
|
|
2127
|
-
stroke: "currentColor",
|
|
2128
|
-
children: /* @__PURE__ */ u.jsx(
|
|
2129
|
-
"path",
|
|
2130
|
-
{
|
|
2131
|
-
strokeLinecap: "round",
|
|
2132
|
-
strokeLinejoin: "round",
|
|
2133
|
-
strokeWidth: "2",
|
|
2134
|
-
d: "M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"
|
|
2135
|
-
}
|
|
2136
|
-
)
|
|
2137
|
-
}
|
|
2138
|
-
) }),
|
|
2139
|
-
/* @__PURE__ */ u.jsx(
|
|
2140
|
-
"input",
|
|
2141
|
-
{
|
|
2142
|
-
value: a,
|
|
2143
|
-
onChange: (l) => c(l.target.value),
|
|
2144
|
-
type: e ? "text" : "password",
|
|
2145
|
-
id: "pwd",
|
|
2146
|
-
placeholder: "Enter password",
|
|
2147
|
-
className: "block w-full py-4 px-10 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"
|
|
2148
|
-
}
|
|
2149
|
-
),
|
|
2150
|
-
/* @__PURE__ */ u.jsx(
|
|
2151
|
-
"button",
|
|
2152
|
-
{
|
|
2153
|
-
type: "button",
|
|
2154
|
-
className: "absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",
|
|
2155
|
-
onClick: () => s(!e),
|
|
2156
|
-
children: e ? /* @__PURE__ */ u.jsx(Os, {}) : /* @__PURE__ */ u.jsx(Ss, {})
|
|
2157
|
-
}
|
|
2158
|
-
)
|
|
2159
|
-
] }) }),
|
|
2160
|
-
/* @__PURE__ */ u.jsx("div", { children: /* @__PURE__ */ u.jsx(
|
|
2161
|
-
"button",
|
|
2162
|
-
{
|
|
2163
|
-
disabled: g || qt(r) < 2 || qt(a) < 2,
|
|
2164
|
-
type: "submit",
|
|
2165
|
-
className: "inline-flex disabled:bg-gray-400 items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",
|
|
2166
|
-
children: g ? "Signing in..." : "Login"
|
|
2167
|
-
}
|
|
2168
|
-
) })
|
|
2169
|
-
] }) }),
|
|
2170
|
-
/* @__PURE__ */ u.jsx("div", { className: "mt-4 flex items-center justify-end gap-x-2 text-sm", children: /* @__PURE__ */ u.jsx(
|
|
2171
|
-
"a",
|
|
2172
|
-
{
|
|
2173
|
-
href: "https://apps.chaibuilder.com/settings",
|
|
2174
|
-
target: "_blank",
|
|
2175
|
-
className: "text-gray-500 hover:text-blue-400",
|
|
2176
|
-
children: "Forget your password?"
|
|
2177
|
-
}
|
|
2178
|
-
) })
|
|
2179
|
-
] }) }) });
|
|
2180
|
-
}, Wr = (t) => {
|
|
2181
|
-
const { data: e, isLoading: s } = Tr(), r = G();
|
|
2182
|
-
return gs(() => {
|
|
2183
|
-
r.setQueryData(["apiBaseUrl"], t.apiBaseUrl || "/api/chaibuilder");
|
|
2184
|
-
}, [t.apiBaseUrl, r]), s ? /* @__PURE__ */ u.jsx(Et, {}) : e != null && e.valid ? /* @__PURE__ */ u.jsx(Vr, { ...t }) : /* @__PURE__ */ u.jsx(Jr, { logo: t.logo });
|
|
2185
|
-
}, Yr = new nr(), fi = (t) => /* @__PURE__ */ u.jsxs(hr, { client: Yr, children: [
|
|
2186
|
-
/* @__PURE__ */ u.jsx(js, { richColors: !0 }),
|
|
2187
|
-
/* @__PURE__ */ u.jsx(Wr, { ...t })
|
|
2188
|
-
] });
|
|
2189
|
-
export {
|
|
2190
|
-
fi as C,
|
|
2191
|
-
ls as a,
|
|
2192
|
-
Er as b,
|
|
2193
|
-
Fr as c,
|
|
2194
|
-
we as d,
|
|
2195
|
-
li as e,
|
|
2196
|
-
G as f,
|
|
2197
|
-
Rr as g,
|
|
2198
|
-
di as h,
|
|
2199
|
-
ds as u
|
|
2200
|
-
};
|