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