zudoku 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/config/loader.js +4 -1
  2. package/dist/config/loader.js.map +1 -1
  3. package/dist/config/validators/common.d.ts +97 -12
  4. package/dist/config/validators/common.js +16 -1
  5. package/dist/config/validators/common.js.map +1 -1
  6. package/dist/config/validators/validate.d.ts +33 -6
  7. package/dist/lib/components/ThemeSwitch.js +8 -4
  8. package/dist/lib/components/ThemeSwitch.js.map +1 -1
  9. package/dist/lib/components/context/ZudokuContext.js +8 -2
  10. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  11. package/dist/lib/core/RouteGuard.js +6 -2
  12. package/dist/lib/core/RouteGuard.js.map +1 -1
  13. package/dist/lib/oas/parser/upgrade/index.js +2 -1
  14. package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
  15. package/dist/lib/plugins/openapi/index.js +2 -2
  16. package/dist/lib/plugins/openapi/index.js.map +1 -1
  17. package/dist/lib/util/useLatest.d.ts +1 -0
  18. package/dist/lib/util/useLatest.js +15 -0
  19. package/dist/lib/util/useLatest.js.map +1 -0
  20. package/dist/vite/config.js +25 -12
  21. package/dist/vite/config.js.map +1 -1
  22. package/dist/vite/plugin-api.js +26 -10
  23. package/dist/vite/plugin-api.js.map +1 -1
  24. package/dist/vite/plugin-mdx.js +31 -26
  25. package/dist/vite/plugin-mdx.js.map +1 -1
  26. package/dist/vite/prerender/prerender.d.ts +1 -1
  27. package/dist/vite/prerender/prerender.js +14 -16
  28. package/dist/vite/prerender/prerender.js.map +1 -1
  29. package/dist/vite/prerender/worker.d.ts +6 -4
  30. package/dist/vite/prerender/worker.js +14 -19
  31. package/dist/vite/prerender/worker.js.map +1 -1
  32. package/lib/{AuthenticationPlugin-DeEA69mE.js → AuthenticationPlugin-DjnQ5hs7.js} +2 -2
  33. package/lib/{AuthenticationPlugin-DeEA69mE.js.map → AuthenticationPlugin-DjnQ5hs7.js.map} +1 -1
  34. package/lib/{MdxPage-BalfwlsD.js → MdxPage-ZX2oquWw.js} +3 -3
  35. package/lib/{MdxPage-BalfwlsD.js.map → MdxPage-ZX2oquWw.js.map} +1 -1
  36. package/lib/{OpenApiRoute-ULLXjfro.js → OpenApiRoute-BP9kzG5k.js} +2 -2
  37. package/lib/{OpenApiRoute-ULLXjfro.js.map → OpenApiRoute-BP9kzG5k.js.map} +1 -1
  38. package/lib/{OperationList-Ej-q1c16.js → OperationList-c72qPMtm.js} +6 -7
  39. package/lib/{OperationList-Ej-q1c16.js.map → OperationList-c72qPMtm.js.map} +1 -1
  40. package/lib/{Select-BcAbBUmk.js → Select-NSz0gku6.js} +3 -3
  41. package/lib/{Select-BcAbBUmk.js.map → Select-NSz0gku6.js.map} +1 -1
  42. package/lib/{createServer-E3cXjB0P.js → createServer-ZDNGmPfQ.js} +2 -2
  43. package/lib/{createServer-E3cXjB0P.js.map → createServer-ZDNGmPfQ.js.map} +1 -1
  44. package/lib/hook-Dnj3SwPC.js +1455 -0
  45. package/lib/hook-Dnj3SwPC.js.map +1 -0
  46. package/lib/{index-CL0kr7nH.js → index-CZjcfK-H.js} +30 -32
  47. package/lib/{index-CL0kr7nH.js.map → index-CZjcfK-H.js.map} +1 -1
  48. package/lib/{hook-NIpDSpau.js → mutation-ByGtmi0-.js} +46 -65
  49. package/lib/mutation-ByGtmi0-.js.map +1 -0
  50. package/lib/{useScrollToAnchor-BVCQSeKB.js → useScrollToAnchor-DkVfWsxe.js} +2 -2
  51. package/lib/{useScrollToAnchor-BVCQSeKB.js.map → useScrollToAnchor-DkVfWsxe.js.map} +1 -1
  52. package/lib/zudoku.auth-auth0.js +1 -1
  53. package/lib/zudoku.auth-clerk.js +2 -2
  54. package/lib/zudoku.auth-openid.js +4 -5
  55. package/lib/zudoku.auth-openid.js.map +1 -1
  56. package/lib/zudoku.components.js +519 -489
  57. package/lib/zudoku.components.js.map +1 -1
  58. package/lib/zudoku.plugin-api-catalog.js +15 -16
  59. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  60. package/lib/zudoku.plugin-api-keys.js +12 -13
  61. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  62. package/lib/zudoku.plugin-markdown.js +1 -1
  63. package/lib/zudoku.plugin-openapi.js +2 -2
  64. package/package.json +3 -1
  65. package/src/app/main.css +2 -1
  66. package/src/lib/components/ThemeSwitch.tsx +28 -7
  67. package/src/lib/components/context/ZudokuContext.ts +13 -2
  68. package/src/lib/core/RouteGuard.tsx +6 -2
  69. package/src/lib/oas/parser/upgrade/index.ts +2 -1
  70. package/src/lib/plugins/openapi/index.tsx +2 -2
  71. package/src/lib/util/useLatest.ts +18 -0
  72. package/lib/ZudokuContext-dUyBGMap.js +0 -1229
  73. package/lib/ZudokuContext-dUyBGMap.js.map +0 -1
  74. package/lib/hook-NIpDSpau.js.map +0 -1
  75. package/lib/state-bfQxaDxU.js +0 -211
  76. package/lib/state-bfQxaDxU.js.map +0 -1
@@ -0,0 +1,1455 @@
1
+ var Be = (t) => {
2
+ throw TypeError(t);
3
+ };
4
+ var me = (t, e, s) => e.has(t) || Be("Cannot " + s);
5
+ var n = (t, e, s) => (me(t, e, "read from private field"), s ? s.call(t) : e.get(t)), g = (t, e, s) => e.has(t) ? Be("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), d = (t, e, s, r) => (me(t, e, "write to private field"), r ? r.call(t, s) : e.set(t, s), s), w = (t, e, s) => (me(t, e, "access private method"), s);
6
+ import * as A from "react";
7
+ import Ge, { createContext as Ct, useContext as Et, useMemo as Ot } from "react";
8
+ import { j as It } from "./jsx-runtime-Bdg6XQ1m.js";
9
+ import { u as pe, m as $e } from "./chunk-SYFQ2XB5-QijJrSf0.js";
10
+ var qe = class {
11
+ constructor() {
12
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
13
+ }
14
+ subscribe(t) {
15
+ return this.listeners.add(t), this.onSubscribe(), () => {
16
+ this.listeners.delete(t), this.onUnsubscribe();
17
+ };
18
+ }
19
+ hasListeners() {
20
+ return this.listeners.size > 0;
21
+ }
22
+ onSubscribe() {
23
+ }
24
+ onUnsubscribe() {
25
+ }
26
+ }, J = typeof window > "u" || "Deno" in globalThis;
27
+ function ge() {
28
+ }
29
+ function ds(t, e) {
30
+ return typeof t == "function" ? t(e) : t;
31
+ }
32
+ function Se(t) {
33
+ return typeof t == "number" && t >= 0 && t !== 1 / 0;
34
+ }
35
+ function it(t, e) {
36
+ return Math.max(t + (e || 0) - Date.now(), 0);
37
+ }
38
+ function fe(t, e) {
39
+ return typeof t == "function" ? t(e) : t;
40
+ }
41
+ function k(t, e) {
42
+ return typeof t == "function" ? t(e) : t;
43
+ }
44
+ function fs(t, e) {
45
+ const {
46
+ type: s = "all",
47
+ exact: r,
48
+ fetchStatus: i,
49
+ predicate: a,
50
+ queryKey: o,
51
+ stale: u
52
+ } = t;
53
+ if (o) {
54
+ if (r) {
55
+ if (e.queryHash !== Ft(o, e.options))
56
+ return !1;
57
+ } else if (!Qe(e.queryKey, o))
58
+ return !1;
59
+ }
60
+ if (s !== "all") {
61
+ const l = e.isActive();
62
+ if (s === "active" && !l || s === "inactive" && l)
63
+ return !1;
64
+ }
65
+ return !(typeof u == "boolean" && e.isStale() !== u || i && i !== e.state.fetchStatus || a && !a(e));
66
+ }
67
+ function ys(t, e) {
68
+ const { exact: s, status: r, predicate: i, mutationKey: a } = t;
69
+ if (a) {
70
+ if (!e.options.mutationKey)
71
+ return !1;
72
+ if (s) {
73
+ if (we(e.options.mutationKey) !== we(a))
74
+ return !1;
75
+ } else if (!Qe(e.options.mutationKey, a))
76
+ return !1;
77
+ }
78
+ return !(r && e.state.status !== r || i && !i(e));
79
+ }
80
+ function Ft(t, e) {
81
+ return ((e == null ? void 0 : e.queryKeyHashFn) || we)(t);
82
+ }
83
+ function we(t) {
84
+ return JSON.stringify(
85
+ t,
86
+ (e, s) => Ee(s) ? Object.keys(s).sort().reduce((r, i) => (r[i] = s[i], r), {}) : s
87
+ );
88
+ }
89
+ function Qe(t, e) {
90
+ return t === e ? !0 : typeof t != typeof e ? !1 : t && e && typeof t == "object" && typeof e == "object" ? !Object.keys(e).some((s) => !Qe(t[s], e[s])) : !1;
91
+ }
92
+ function Re(t, e) {
93
+ if (t === e)
94
+ return t;
95
+ const s = ze(t) && ze(e);
96
+ if (s || Ee(t) && Ee(e)) {
97
+ const r = s ? t : Object.keys(t), i = r.length, a = s ? e : Object.keys(e), o = a.length, u = s ? [] : {};
98
+ let l = 0;
99
+ for (let f = 0; f < o; f++) {
100
+ const v = s ? f : a[f];
101
+ (!s && r.includes(v) || s) && t[v] === void 0 && e[v] === void 0 ? (u[v] = void 0, l++) : (u[v] = Re(t[v], e[v]), u[v] === t[v] && t[v] !== void 0 && l++);
102
+ }
103
+ return i === o && l === i ? t : u;
104
+ }
105
+ return e;
106
+ }
107
+ function Ce(t, e) {
108
+ if (!e || Object.keys(t).length !== Object.keys(e).length)
109
+ return !1;
110
+ for (const s in t)
111
+ if (t[s] !== e[s])
112
+ return !1;
113
+ return !0;
114
+ }
115
+ function ze(t) {
116
+ return Array.isArray(t) && t.length === Object.keys(t).length;
117
+ }
118
+ function Ee(t) {
119
+ if (!Je(t))
120
+ return !1;
121
+ const e = t.constructor;
122
+ if (e === void 0)
123
+ return !0;
124
+ const s = e.prototype;
125
+ return !(!Je(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
126
+ }
127
+ function Je(t) {
128
+ return Object.prototype.toString.call(t) === "[object Object]";
129
+ }
130
+ function Pt(t) {
131
+ return new Promise((e) => {
132
+ setTimeout(e, t);
133
+ });
134
+ }
135
+ function Oe(t, e, s) {
136
+ if (typeof s.structuralSharing == "function")
137
+ return s.structuralSharing(t, e);
138
+ if (s.structuralSharing !== !1) {
139
+ if (process.env.NODE_ENV !== "production")
140
+ try {
141
+ return Re(t, e);
142
+ } catch (r) {
143
+ console.error(
144
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`
145
+ );
146
+ }
147
+ return Re(t, e);
148
+ }
149
+ return e;
150
+ }
151
+ function ps(t, e, s = 0) {
152
+ const r = [...t, e];
153
+ return s && r.length > s ? r.slice(1) : r;
154
+ }
155
+ function bs(t, e, s = 0) {
156
+ const r = [e, ...t];
157
+ return s && r.length > s ? r.slice(0, -1) : r;
158
+ }
159
+ var ye = Symbol();
160
+ function Tt(t, e) {
161
+ return process.env.NODE_ENV !== "production" && t.queryFn === ye && console.error(
162
+ `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`
163
+ ), !t.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !t.queryFn || t.queryFn === ye ? () => Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)) : t.queryFn;
164
+ }
165
+ var H, L, X, et, Dt = (et = class extends qe {
166
+ constructor() {
167
+ super();
168
+ g(this, H);
169
+ g(this, L);
170
+ g(this, X);
171
+ d(this, X, (e) => {
172
+ if (!J && window.addEventListener) {
173
+ const s = () => e();
174
+ return window.addEventListener("visibilitychange", s, !1), () => {
175
+ window.removeEventListener("visibilitychange", s);
176
+ };
177
+ }
178
+ });
179
+ }
180
+ onSubscribe() {
181
+ n(this, L) || this.setEventListener(n(this, X));
182
+ }
183
+ onUnsubscribe() {
184
+ var e;
185
+ this.hasListeners() || ((e = n(this, L)) == null || e.call(this), d(this, L, void 0));
186
+ }
187
+ setEventListener(e) {
188
+ var s;
189
+ d(this, X, e), (s = n(this, L)) == null || s.call(this), d(this, L, e((r) => {
190
+ typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
191
+ }));
192
+ }
193
+ setFocused(e) {
194
+ n(this, H) !== e && (d(this, H, e), this.onFocus());
195
+ }
196
+ onFocus() {
197
+ const e = this.isFocused();
198
+ this.listeners.forEach((s) => {
199
+ s(e);
200
+ });
201
+ }
202
+ isFocused() {
203
+ var e;
204
+ return typeof n(this, H) == "boolean" ? n(this, H) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
205
+ }
206
+ }, H = new WeakMap(), L = new WeakMap(), X = new WeakMap(), et), at = new Dt(), ee, M, te, tt, At = (tt = class extends qe {
207
+ constructor() {
208
+ super();
209
+ g(this, ee, !0);
210
+ g(this, M);
211
+ g(this, te);
212
+ d(this, te, (e) => {
213
+ if (!J && window.addEventListener) {
214
+ const s = () => e(!0), r = () => e(!1);
215
+ return window.addEventListener("online", s, !1), window.addEventListener("offline", r, !1), () => {
216
+ window.removeEventListener("online", s), window.removeEventListener("offline", r);
217
+ };
218
+ }
219
+ });
220
+ }
221
+ onSubscribe() {
222
+ n(this, M) || this.setEventListener(n(this, te));
223
+ }
224
+ onUnsubscribe() {
225
+ var e;
226
+ this.hasListeners() || ((e = n(this, M)) == null || e.call(this), d(this, M, void 0));
227
+ }
228
+ setEventListener(e) {
229
+ var s;
230
+ d(this, te, e), (s = n(this, M)) == null || s.call(this), d(this, M, e(this.setOnline.bind(this)));
231
+ }
232
+ setOnline(e) {
233
+ n(this, ee) !== e && (d(this, ee, e), this.listeners.forEach((r) => {
234
+ r(e);
235
+ }));
236
+ }
237
+ isOnline() {
238
+ return n(this, ee);
239
+ }
240
+ }, ee = new WeakMap(), M = new WeakMap(), te = new WeakMap(), tt), ot = new At();
241
+ function Ie() {
242
+ let t, e;
243
+ const s = new Promise((i, a) => {
244
+ t = i, e = a;
245
+ });
246
+ s.status = "pending", s.catch(() => {
247
+ });
248
+ function r(i) {
249
+ Object.assign(s, i), delete s.resolve, delete s.reject;
250
+ }
251
+ return s.resolve = (i) => {
252
+ r({
253
+ status: "fulfilled",
254
+ value: i
255
+ }), t(i);
256
+ }, s.reject = (i) => {
257
+ r({
258
+ status: "rejected",
259
+ reason: i
260
+ }), e(i);
261
+ }, s;
262
+ }
263
+ function jt(t) {
264
+ return Math.min(1e3 * 2 ** t, 3e4);
265
+ }
266
+ function ut(t) {
267
+ return (t ?? "online") === "online" ? ot.isOnline() : !0;
268
+ }
269
+ var ct = class extends Error {
270
+ constructor(t) {
271
+ super("CancelledError"), this.revert = t == null ? void 0 : t.revert, this.silent = t == null ? void 0 : t.silent;
272
+ }
273
+ };
274
+ function ve(t) {
275
+ return t instanceof ct;
276
+ }
277
+ function kt(t) {
278
+ let e = !1, s = 0, r = !1, i;
279
+ const a = Ie(), o = (h) => {
280
+ var b;
281
+ r || (p(new ct(h)), (b = t.abort) == null || b.call(t));
282
+ }, u = () => {
283
+ e = !0;
284
+ }, l = () => {
285
+ e = !1;
286
+ }, f = () => at.isFocused() && (t.networkMode === "always" || ot.isOnline()) && t.canRun(), v = () => ut(t.networkMode) && t.canRun(), c = (h) => {
287
+ var b;
288
+ r || (r = !0, (b = t.onSuccess) == null || b.call(t, h), i == null || i(), a.resolve(h));
289
+ }, p = (h) => {
290
+ var b;
291
+ r || (r = !0, (b = t.onError) == null || b.call(t, h), i == null || i(), a.reject(h));
292
+ }, y = () => new Promise((h) => {
293
+ var b;
294
+ i = (C) => {
295
+ (r || f()) && h(C);
296
+ }, (b = t.onPause) == null || b.call(t);
297
+ }).then(() => {
298
+ var h;
299
+ i = void 0, r || (h = t.onContinue) == null || h.call(t);
300
+ }), E = () => {
301
+ if (r)
302
+ return;
303
+ let h;
304
+ const b = s === 0 ? t.initialPromise : void 0;
305
+ try {
306
+ h = b ?? t.fn();
307
+ } catch (C) {
308
+ h = Promise.reject(C);
309
+ }
310
+ Promise.resolve(h).then(c).catch((C) => {
311
+ var be;
312
+ if (r)
313
+ return;
314
+ const R = t.retry ?? (J ? 0 : 3), O = t.retryDelay ?? jt, Q = typeof O == "function" ? O(s, C) : O, Z = R === !0 || typeof R == "number" && s < R || typeof R == "function" && R(s, C);
315
+ if (e || !Z) {
316
+ p(C);
317
+ return;
318
+ }
319
+ s++, (be = t.onFail) == null || be.call(t, s, C), Pt(Q).then(() => f() ? void 0 : y()).then(() => {
320
+ e ? p(C) : E();
321
+ });
322
+ });
323
+ };
324
+ return {
325
+ promise: a,
326
+ cancel: o,
327
+ continue: () => (i == null || i(), a),
328
+ cancelRetry: u,
329
+ continueRetry: l,
330
+ canStart: v,
331
+ start: () => (v() ? E() : y().then(E), a)
332
+ };
333
+ }
334
+ function xt() {
335
+ let t = [], e = 0, s = (u) => {
336
+ u();
337
+ }, r = (u) => {
338
+ u();
339
+ }, i = (u) => setTimeout(u, 0);
340
+ const a = (u) => {
341
+ e ? t.push(u) : i(() => {
342
+ s(u);
343
+ });
344
+ }, o = () => {
345
+ const u = t;
346
+ t = [], u.length && i(() => {
347
+ r(() => {
348
+ u.forEach((l) => {
349
+ s(l);
350
+ });
351
+ });
352
+ });
353
+ };
354
+ return {
355
+ batch: (u) => {
356
+ let l;
357
+ e++;
358
+ try {
359
+ l = u();
360
+ } finally {
361
+ e--, e || o();
362
+ }
363
+ return l;
364
+ },
365
+ /**
366
+ * All calls to the wrapped function will be batched.
367
+ */
368
+ batchCalls: (u) => (...l) => {
369
+ a(() => {
370
+ u(...l);
371
+ });
372
+ },
373
+ schedule: a,
374
+ /**
375
+ * Use this method to set a custom notify function.
376
+ * This can be used to for example wrap notifications with `React.act` while running tests.
377
+ */
378
+ setNotifyFunction: (u) => {
379
+ s = u;
380
+ },
381
+ /**
382
+ * Use this method to set a custom function to batch notifications together into a single tick.
383
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
384
+ */
385
+ setBatchNotifyFunction: (u) => {
386
+ r = u;
387
+ },
388
+ setScheduler: (u) => {
389
+ i = u;
390
+ }
391
+ };
392
+ }
393
+ var Le = xt(), K, st, Ut = (st = class {
394
+ constructor() {
395
+ g(this, K);
396
+ }
397
+ destroy() {
398
+ this.clearGcTimeout();
399
+ }
400
+ scheduleGc() {
401
+ this.clearGcTimeout(), Se(this.gcTime) && d(this, K, setTimeout(() => {
402
+ this.optionalRemove();
403
+ }, this.gcTime));
404
+ }
405
+ updateGcTime(t) {
406
+ this.gcTime = Math.max(
407
+ this.gcTime || 0,
408
+ t ?? (J ? 1 / 0 : 5 * 60 * 1e3)
409
+ );
410
+ }
411
+ clearGcTimeout() {
412
+ n(this, K) && (clearTimeout(n(this, K)), d(this, K, void 0));
413
+ }
414
+ }, K = new WeakMap(), st), se, re, D, I, ce, B, j, q, rt, ms = (rt = class extends Ut {
415
+ constructor(e) {
416
+ super();
417
+ g(this, j);
418
+ g(this, se);
419
+ g(this, re);
420
+ g(this, D);
421
+ g(this, I);
422
+ g(this, ce);
423
+ g(this, B);
424
+ d(this, B, !1), d(this, ce, e.defaultOptions), this.setOptions(e.options), this.observers = [], d(this, D, e.cache), this.queryKey = e.queryKey, this.queryHash = e.queryHash, d(this, se, qt(this.options)), this.state = e.state ?? n(this, se), this.scheduleGc();
425
+ }
426
+ get meta() {
427
+ return this.options.meta;
428
+ }
429
+ get promise() {
430
+ var e;
431
+ return (e = n(this, I)) == null ? void 0 : e.promise;
432
+ }
433
+ setOptions(e) {
434
+ this.options = { ...n(this, ce), ...e }, this.updateGcTime(this.options.gcTime);
435
+ }
436
+ optionalRemove() {
437
+ !this.observers.length && this.state.fetchStatus === "idle" && n(this, D).remove(this);
438
+ }
439
+ setData(e, s) {
440
+ const r = Oe(this.state.data, e, this.options);
441
+ return w(this, j, q).call(this, {
442
+ data: r,
443
+ type: "success",
444
+ dataUpdatedAt: s == null ? void 0 : s.updatedAt,
445
+ manual: s == null ? void 0 : s.manual
446
+ }), r;
447
+ }
448
+ setState(e, s) {
449
+ w(this, j, q).call(this, { type: "setState", state: e, setStateOptions: s });
450
+ }
451
+ cancel(e) {
452
+ var r, i;
453
+ const s = (r = n(this, I)) == null ? void 0 : r.promise;
454
+ return (i = n(this, I)) == null || i.cancel(e), s ? s.then(ge).catch(ge) : Promise.resolve();
455
+ }
456
+ destroy() {
457
+ super.destroy(), this.cancel({ silent: !0 });
458
+ }
459
+ reset() {
460
+ this.destroy(), this.setState(n(this, se));
461
+ }
462
+ isActive() {
463
+ return this.observers.some(
464
+ (e) => k(e.options.enabled, this) !== !1
465
+ );
466
+ }
467
+ isDisabled() {
468
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === ye || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
469
+ }
470
+ isStale() {
471
+ return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
472
+ (e) => e.getCurrentResult().isStale
473
+ ) : this.state.data === void 0;
474
+ }
475
+ isStaleByTime(e = 0) {
476
+ return this.state.isInvalidated || this.state.data === void 0 || !it(this.state.dataUpdatedAt, e);
477
+ }
478
+ onFocus() {
479
+ var s;
480
+ const e = this.observers.find((r) => r.shouldFetchOnWindowFocus());
481
+ e == null || e.refetch({ cancelRefetch: !1 }), (s = n(this, I)) == null || s.continue();
482
+ }
483
+ onOnline() {
484
+ var s;
485
+ const e = this.observers.find((r) => r.shouldFetchOnReconnect());
486
+ e == null || e.refetch({ cancelRefetch: !1 }), (s = n(this, I)) == null || s.continue();
487
+ }
488
+ addObserver(e) {
489
+ this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), n(this, D).notify({ type: "observerAdded", query: this, observer: e }));
490
+ }
491
+ removeObserver(e) {
492
+ this.observers.includes(e) && (this.observers = this.observers.filter((s) => s !== e), this.observers.length || (n(this, I) && (n(this, B) ? n(this, I).cancel({ revert: !0 }) : n(this, I).cancelRetry()), this.scheduleGc()), n(this, D).notify({ type: "observerRemoved", query: this, observer: e }));
493
+ }
494
+ getObserversCount() {
495
+ return this.observers.length;
496
+ }
497
+ invalidate() {
498
+ this.state.isInvalidated || w(this, j, q).call(this, { type: "invalidate" });
499
+ }
500
+ fetch(e, s) {
501
+ var l, f, v;
502
+ if (this.state.fetchStatus !== "idle") {
503
+ if (this.state.data !== void 0 && (s != null && s.cancelRefetch))
504
+ this.cancel({ silent: !0 });
505
+ else if (n(this, I))
506
+ return n(this, I).continueRetry(), n(this, I).promise;
507
+ }
508
+ if (e && this.setOptions(e), !this.options.queryFn) {
509
+ const c = this.observers.find((p) => p.options.queryFn);
510
+ c && this.setOptions(c.options);
511
+ }
512
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
513
+ "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']"
514
+ ));
515
+ const r = new AbortController(), i = (c) => {
516
+ Object.defineProperty(c, "signal", {
517
+ enumerable: !0,
518
+ get: () => (d(this, B, !0), r.signal)
519
+ });
520
+ }, a = () => {
521
+ const c = Tt(this.options, s), p = {
522
+ queryKey: this.queryKey,
523
+ meta: this.meta
524
+ };
525
+ return i(p), d(this, B, !1), this.options.persister ? this.options.persister(
526
+ c,
527
+ p,
528
+ this
529
+ ) : c(p);
530
+ }, o = {
531
+ fetchOptions: s,
532
+ options: this.options,
533
+ queryKey: this.queryKey,
534
+ state: this.state,
535
+ fetchFn: a
536
+ };
537
+ i(o), (l = this.options.behavior) == null || l.onFetch(
538
+ o,
539
+ this
540
+ ), d(this, re, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((f = o.fetchOptions) == null ? void 0 : f.meta)) && w(this, j, q).call(this, { type: "fetch", meta: (v = o.fetchOptions) == null ? void 0 : v.meta });
541
+ const u = (c) => {
542
+ var p, y, E, h;
543
+ ve(c) && c.silent || w(this, j, q).call(this, {
544
+ type: "error",
545
+ error: c
546
+ }), ve(c) || ((y = (p = n(this, D).config).onError) == null || y.call(
547
+ p,
548
+ c,
549
+ this
550
+ ), (h = (E = n(this, D).config).onSettled) == null || h.call(
551
+ E,
552
+ this.state.data,
553
+ c,
554
+ this
555
+ )), this.scheduleGc();
556
+ };
557
+ return d(this, I, kt({
558
+ initialPromise: s == null ? void 0 : s.initialPromise,
559
+ fn: o.fetchFn,
560
+ abort: r.abort.bind(r),
561
+ onSuccess: (c) => {
562
+ var p, y, E, h;
563
+ if (c === void 0) {
564
+ process.env.NODE_ENV !== "production" && console.error(
565
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
566
+ ), u(new Error(`${this.queryHash} data is undefined`));
567
+ return;
568
+ }
569
+ try {
570
+ this.setData(c);
571
+ } catch (b) {
572
+ u(b);
573
+ return;
574
+ }
575
+ (y = (p = n(this, D).config).onSuccess) == null || y.call(p, c, this), (h = (E = n(this, D).config).onSettled) == null || h.call(
576
+ E,
577
+ c,
578
+ this.state.error,
579
+ this
580
+ ), this.scheduleGc();
581
+ },
582
+ onError: u,
583
+ onFail: (c, p) => {
584
+ w(this, j, q).call(this, { type: "failed", failureCount: c, error: p });
585
+ },
586
+ onPause: () => {
587
+ w(this, j, q).call(this, { type: "pause" });
588
+ },
589
+ onContinue: () => {
590
+ w(this, j, q).call(this, { type: "continue" });
591
+ },
592
+ retry: o.options.retry,
593
+ retryDelay: o.options.retryDelay,
594
+ networkMode: o.options.networkMode,
595
+ canRun: () => !0
596
+ })), n(this, I).start();
597
+ }
598
+ }, se = new WeakMap(), re = new WeakMap(), D = new WeakMap(), I = new WeakMap(), ce = new WeakMap(), B = new WeakMap(), j = new WeakSet(), q = function(e) {
599
+ const s = (r) => {
600
+ switch (e.type) {
601
+ case "failed":
602
+ return {
603
+ ...r,
604
+ fetchFailureCount: e.failureCount,
605
+ fetchFailureReason: e.error
606
+ };
607
+ case "pause":
608
+ return {
609
+ ...r,
610
+ fetchStatus: "paused"
611
+ };
612
+ case "continue":
613
+ return {
614
+ ...r,
615
+ fetchStatus: "fetching"
616
+ };
617
+ case "fetch":
618
+ return {
619
+ ...r,
620
+ ...ht(r.data, this.options),
621
+ fetchMeta: e.meta ?? null
622
+ };
623
+ case "success":
624
+ return {
625
+ ...r,
626
+ data: e.data,
627
+ dataUpdateCount: r.dataUpdateCount + 1,
628
+ dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
629
+ error: null,
630
+ isInvalidated: !1,
631
+ status: "success",
632
+ ...!e.manual && {
633
+ fetchStatus: "idle",
634
+ fetchFailureCount: 0,
635
+ fetchFailureReason: null
636
+ }
637
+ };
638
+ case "error":
639
+ const i = e.error;
640
+ return ve(i) && i.revert && n(this, re) ? { ...n(this, re), fetchStatus: "idle" } : {
641
+ ...r,
642
+ error: i,
643
+ errorUpdateCount: r.errorUpdateCount + 1,
644
+ errorUpdatedAt: Date.now(),
645
+ fetchFailureCount: r.fetchFailureCount + 1,
646
+ fetchFailureReason: i,
647
+ fetchStatus: "idle",
648
+ status: "error"
649
+ };
650
+ case "invalidate":
651
+ return {
652
+ ...r,
653
+ isInvalidated: !0
654
+ };
655
+ case "setState":
656
+ return {
657
+ ...r,
658
+ ...e.state
659
+ };
660
+ }
661
+ };
662
+ this.state = s(this.state), Le.batch(() => {
663
+ this.observers.forEach((r) => {
664
+ r.onQueryUpdate();
665
+ }), n(this, D).notify({ query: this, type: "updated", action: e });
666
+ });
667
+ }, rt);
668
+ function ht(t, e) {
669
+ return {
670
+ fetchFailureCount: 0,
671
+ fetchFailureReason: null,
672
+ fetchStatus: ut(e.networkMode) ? "fetching" : "paused",
673
+ ...t === void 0 && {
674
+ error: null,
675
+ status: "pending"
676
+ }
677
+ };
678
+ }
679
+ function qt(t) {
680
+ const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
681
+ return {
682
+ data: e,
683
+ dataUpdateCount: 0,
684
+ dataUpdatedAt: s ? r ?? Date.now() : 0,
685
+ error: null,
686
+ errorUpdateCount: 0,
687
+ errorUpdatedAt: 0,
688
+ fetchFailureCount: 0,
689
+ fetchFailureReason: null,
690
+ fetchMeta: null,
691
+ isInvalidated: !1,
692
+ status: s ? "success" : "pending",
693
+ fetchStatus: "idle"
694
+ };
695
+ }
696
+ var T, m, he, P, G, ne, N, U, le, ie, ae, $, z, _, oe, S, ue, Fe, Pe, Te, De, Ae, je, ke, dt, nt, lt = (nt = class extends qe {
697
+ constructor(e, s) {
698
+ super();
699
+ g(this, S);
700
+ g(this, T);
701
+ g(this, m);
702
+ g(this, he);
703
+ g(this, P);
704
+ g(this, G);
705
+ g(this, ne);
706
+ g(this, N);
707
+ g(this, U);
708
+ g(this, le);
709
+ g(this, ie);
710
+ // This property keeps track of the last query with defined data.
711
+ // It will be used to pass the previous data and query to the placeholder function between renders.
712
+ g(this, ae);
713
+ g(this, $);
714
+ g(this, z);
715
+ g(this, _);
716
+ g(this, oe, /* @__PURE__ */ new Set());
717
+ this.options = s, d(this, T, e), d(this, U, null), d(this, N, Ie()), this.options.experimental_prefetchInRender || n(this, N).reject(
718
+ new Error("experimental_prefetchInRender feature flag is not enabled")
719
+ ), this.bindMethods(), this.setOptions(s);
720
+ }
721
+ bindMethods() {
722
+ this.refetch = this.refetch.bind(this);
723
+ }
724
+ onSubscribe() {
725
+ this.listeners.size === 1 && (n(this, m).addObserver(this), Ve(n(this, m), this.options) ? w(this, S, ue).call(this) : this.updateResult(), w(this, S, De).call(this));
726
+ }
727
+ onUnsubscribe() {
728
+ this.hasListeners() || this.destroy();
729
+ }
730
+ shouldFetchOnReconnect() {
731
+ return xe(
732
+ n(this, m),
733
+ this.options,
734
+ this.options.refetchOnReconnect
735
+ );
736
+ }
737
+ shouldFetchOnWindowFocus() {
738
+ return xe(
739
+ n(this, m),
740
+ this.options,
741
+ this.options.refetchOnWindowFocus
742
+ );
743
+ }
744
+ destroy() {
745
+ this.listeners = /* @__PURE__ */ new Set(), w(this, S, Ae).call(this), w(this, S, je).call(this), n(this, m).removeObserver(this);
746
+ }
747
+ setOptions(e, s) {
748
+ const r = this.options, i = n(this, m);
749
+ if (this.options = n(this, T).defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof k(this.options.enabled, n(this, m)) != "boolean")
750
+ throw new Error(
751
+ "Expected enabled to be a boolean or a callback that returns a boolean"
752
+ );
753
+ w(this, S, ke).call(this), n(this, m).setOptions(this.options), r._defaulted && !Ce(this.options, r) && n(this, T).getQueryCache().notify({
754
+ type: "observerOptionsUpdated",
755
+ query: n(this, m),
756
+ observer: this
757
+ });
758
+ const a = this.hasListeners();
759
+ a && Ze(
760
+ n(this, m),
761
+ i,
762
+ this.options,
763
+ r
764
+ ) && w(this, S, ue).call(this), this.updateResult(s), a && (n(this, m) !== i || k(this.options.enabled, n(this, m)) !== k(r.enabled, n(this, m)) || fe(this.options.staleTime, n(this, m)) !== fe(r.staleTime, n(this, m))) && w(this, S, Fe).call(this);
765
+ const o = w(this, S, Pe).call(this);
766
+ a && (n(this, m) !== i || k(this.options.enabled, n(this, m)) !== k(r.enabled, n(this, m)) || o !== n(this, _)) && w(this, S, Te).call(this, o);
767
+ }
768
+ getOptimisticResult(e) {
769
+ const s = n(this, T).getQueryCache().build(n(this, T), e), r = this.createResult(s, e);
770
+ return Lt(this, r) && (d(this, P, r), d(this, ne, this.options), d(this, G, n(this, m).state)), r;
771
+ }
772
+ getCurrentResult() {
773
+ return n(this, P);
774
+ }
775
+ trackResult(e, s) {
776
+ const r = {};
777
+ return Object.keys(e).forEach((i) => {
778
+ Object.defineProperty(r, i, {
779
+ configurable: !1,
780
+ enumerable: !0,
781
+ get: () => (this.trackProp(i), s == null || s(i), e[i])
782
+ });
783
+ }), r;
784
+ }
785
+ trackProp(e) {
786
+ n(this, oe).add(e);
787
+ }
788
+ getCurrentQuery() {
789
+ return n(this, m);
790
+ }
791
+ refetch({ ...e } = {}) {
792
+ return this.fetch({
793
+ ...e
794
+ });
795
+ }
796
+ fetchOptimistic(e) {
797
+ const s = n(this, T).defaultQueryOptions(e), r = n(this, T).getQueryCache().build(n(this, T), s);
798
+ return r.fetch().then(() => this.createResult(r, s));
799
+ }
800
+ fetch(e) {
801
+ return w(this, S, ue).call(this, {
802
+ ...e,
803
+ cancelRefetch: e.cancelRefetch ?? !0
804
+ }).then(() => (this.updateResult(), n(this, P)));
805
+ }
806
+ createResult(e, s) {
807
+ var Ke;
808
+ const r = n(this, m), i = this.options, a = n(this, P), o = n(this, G), u = n(this, ne), f = e !== r ? e.state : n(this, he), { state: v } = e;
809
+ let c = { ...v }, p = !1, y;
810
+ if (s._optimisticResults) {
811
+ const F = this.hasListeners(), W = !F && Ve(e, s), Y = F && Ze(e, r, s, i);
812
+ (W || Y) && (c = {
813
+ ...c,
814
+ ...ht(v.data, e.options)
815
+ }), s._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
816
+ }
817
+ let { error: E, errorUpdatedAt: h, status: b } = c;
818
+ if (s.select && c.data !== void 0)
819
+ if (a && c.data === (o == null ? void 0 : o.data) && s.select === n(this, le))
820
+ y = n(this, ie);
821
+ else
822
+ try {
823
+ d(this, le, s.select), y = s.select(c.data), y = Oe(a == null ? void 0 : a.data, y, s), d(this, ie, y), d(this, U, null);
824
+ } catch (F) {
825
+ d(this, U, F);
826
+ }
827
+ else
828
+ y = c.data;
829
+ if (s.placeholderData !== void 0 && y === void 0 && b === "pending") {
830
+ let F;
831
+ if (a != null && a.isPlaceholderData && s.placeholderData === (u == null ? void 0 : u.placeholderData))
832
+ F = a.data;
833
+ else if (F = typeof s.placeholderData == "function" ? s.placeholderData(
834
+ (Ke = n(this, ae)) == null ? void 0 : Ke.state.data,
835
+ n(this, ae)
836
+ ) : s.placeholderData, s.select && F !== void 0)
837
+ try {
838
+ F = s.select(F), d(this, U, null);
839
+ } catch (W) {
840
+ d(this, U, W);
841
+ }
842
+ F !== void 0 && (b = "success", y = Oe(
843
+ a == null ? void 0 : a.data,
844
+ F,
845
+ s
846
+ ), p = !0);
847
+ }
848
+ n(this, U) && (E = n(this, U), y = n(this, ie), h = Date.now(), b = "error");
849
+ const C = c.fetchStatus === "fetching", R = b === "pending", O = b === "error", Q = R && C, Z = y !== void 0, x = {
850
+ status: b,
851
+ fetchStatus: c.fetchStatus,
852
+ isPending: R,
853
+ isSuccess: b === "success",
854
+ isError: O,
855
+ isInitialLoading: Q,
856
+ isLoading: Q,
857
+ data: y,
858
+ dataUpdatedAt: c.dataUpdatedAt,
859
+ error: E,
860
+ errorUpdatedAt: h,
861
+ failureCount: c.fetchFailureCount,
862
+ failureReason: c.fetchFailureReason,
863
+ errorUpdateCount: c.errorUpdateCount,
864
+ isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
865
+ isFetchedAfterMount: c.dataUpdateCount > f.dataUpdateCount || c.errorUpdateCount > f.errorUpdateCount,
866
+ isFetching: C,
867
+ isRefetching: C && !R,
868
+ isLoadingError: O && !Z,
869
+ isPaused: c.fetchStatus === "paused",
870
+ isPlaceholderData: p,
871
+ isRefetchError: O && Z,
872
+ isStale: Me(e, s),
873
+ refetch: this.refetch,
874
+ promise: n(this, N)
875
+ };
876
+ if (this.options.experimental_prefetchInRender) {
877
+ const F = (de) => {
878
+ x.status === "error" ? de.reject(x.error) : x.data !== void 0 && de.resolve(x.data);
879
+ }, W = () => {
880
+ const de = d(this, N, x.promise = Ie());
881
+ F(de);
882
+ }, Y = n(this, N);
883
+ switch (Y.status) {
884
+ case "pending":
885
+ e.queryHash === r.queryHash && F(Y);
886
+ break;
887
+ case "fulfilled":
888
+ (x.status === "error" || x.data !== Y.value) && W();
889
+ break;
890
+ case "rejected":
891
+ (x.status !== "error" || x.error !== Y.reason) && W();
892
+ break;
893
+ }
894
+ }
895
+ return x;
896
+ }
897
+ updateResult(e) {
898
+ const s = n(this, P), r = this.createResult(n(this, m), this.options);
899
+ if (d(this, G, n(this, m).state), d(this, ne, this.options), n(this, G).data !== void 0 && d(this, ae, n(this, m)), Ce(r, s))
900
+ return;
901
+ d(this, P, r);
902
+ const i = {}, a = () => {
903
+ if (!s)
904
+ return !0;
905
+ const { notifyOnChangeProps: o } = this.options, u = typeof o == "function" ? o() : o;
906
+ if (u === "all" || !u && !n(this, oe).size)
907
+ return !0;
908
+ const l = new Set(
909
+ u ?? n(this, oe)
910
+ );
911
+ return this.options.throwOnError && l.add("error"), Object.keys(n(this, P)).some((f) => {
912
+ const v = f;
913
+ return n(this, P)[v] !== s[v] && l.has(v);
914
+ });
915
+ };
916
+ (e == null ? void 0 : e.listeners) !== !1 && a() && (i.listeners = !0), w(this, S, dt).call(this, { ...i, ...e });
917
+ }
918
+ onQueryUpdate() {
919
+ this.updateResult(), this.hasListeners() && w(this, S, De).call(this);
920
+ }
921
+ }, T = new WeakMap(), m = new WeakMap(), he = new WeakMap(), P = new WeakMap(), G = new WeakMap(), ne = new WeakMap(), N = new WeakMap(), U = new WeakMap(), le = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), $ = new WeakMap(), z = new WeakMap(), _ = new WeakMap(), oe = new WeakMap(), S = new WeakSet(), ue = function(e) {
922
+ w(this, S, ke).call(this);
923
+ let s = n(this, m).fetch(
924
+ this.options,
925
+ e
926
+ );
927
+ return e != null && e.throwOnError || (s = s.catch(ge)), s;
928
+ }, Fe = function() {
929
+ w(this, S, Ae).call(this);
930
+ const e = fe(
931
+ this.options.staleTime,
932
+ n(this, m)
933
+ );
934
+ if (J || n(this, P).isStale || !Se(e))
935
+ return;
936
+ const r = it(n(this, P).dataUpdatedAt, e) + 1;
937
+ d(this, $, setTimeout(() => {
938
+ n(this, P).isStale || this.updateResult();
939
+ }, r));
940
+ }, Pe = function() {
941
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(n(this, m)) : this.options.refetchInterval) ?? !1;
942
+ }, Te = function(e) {
943
+ w(this, S, je).call(this), d(this, _, e), !(J || k(this.options.enabled, n(this, m)) === !1 || !Se(n(this, _)) || n(this, _) === 0) && d(this, z, setInterval(() => {
944
+ (this.options.refetchIntervalInBackground || at.isFocused()) && w(this, S, ue).call(this);
945
+ }, n(this, _)));
946
+ }, De = function() {
947
+ w(this, S, Fe).call(this), w(this, S, Te).call(this, w(this, S, Pe).call(this));
948
+ }, Ae = function() {
949
+ n(this, $) && (clearTimeout(n(this, $)), d(this, $, void 0));
950
+ }, je = function() {
951
+ n(this, z) && (clearInterval(n(this, z)), d(this, z, void 0));
952
+ }, ke = function() {
953
+ const e = n(this, T).getQueryCache().build(n(this, T), this.options);
954
+ if (e === n(this, m))
955
+ return;
956
+ const s = n(this, m);
957
+ d(this, m, e), d(this, he, e.state), this.hasListeners() && (s == null || s.removeObserver(this), e.addObserver(this));
958
+ }, dt = function(e) {
959
+ Le.batch(() => {
960
+ e.listeners && this.listeners.forEach((s) => {
961
+ s(n(this, P));
962
+ }), n(this, T).getQueryCache().notify({
963
+ query: n(this, m),
964
+ type: "observerResultsUpdated"
965
+ });
966
+ });
967
+ }, nt);
968
+ function Qt(t, e) {
969
+ return k(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
970
+ }
971
+ function Ve(t, e) {
972
+ return Qt(t, e) || t.state.data !== void 0 && xe(t, e, e.refetchOnMount);
973
+ }
974
+ function xe(t, e, s) {
975
+ if (k(e.enabled, t) !== !1) {
976
+ const r = typeof s == "function" ? s(t) : s;
977
+ return r === "always" || r !== !1 && Me(t, e);
978
+ }
979
+ return !1;
980
+ }
981
+ function Ze(t, e, s, r) {
982
+ return (t !== e || k(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && Me(t, s);
983
+ }
984
+ function Me(t, e) {
985
+ return k(e.enabled, t) !== !1 && t.isStaleByTime(fe(e.staleTime, t));
986
+ }
987
+ function Lt(t, e) {
988
+ return !Ce(t.getCurrentResult(), e);
989
+ }
990
+ var ft = A.createContext(
991
+ void 0
992
+ ), yt = (t) => {
993
+ const e = A.useContext(ft);
994
+ if (t)
995
+ return t;
996
+ if (!e)
997
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
998
+ return e;
999
+ }, vs = ({
1000
+ client: t,
1001
+ children: e
1002
+ }) => (A.useEffect(() => (t.mount(), () => {
1003
+ t.unmount();
1004
+ }), [t]), /* @__PURE__ */ It.jsx(ft.Provider, { value: t, children: e })), pt = A.createContext(!1), Mt = () => A.useContext(pt);
1005
+ pt.Provider;
1006
+ function Nt() {
1007
+ let t = !1;
1008
+ return {
1009
+ clearReset: () => {
1010
+ t = !1;
1011
+ },
1012
+ reset: () => {
1013
+ t = !0;
1014
+ },
1015
+ isReset: () => t
1016
+ };
1017
+ }
1018
+ var _t = A.createContext(Nt()), Ht = () => A.useContext(_t);
1019
+ function Kt(t, e) {
1020
+ return typeof t == "function" ? t(...e) : !!t;
1021
+ }
1022
+ function We() {
1023
+ }
1024
+ var Bt = (t, e) => {
1025
+ (t.suspense || t.throwOnError || t.experimental_prefetchInRender) && (e.isReset() || (t.retryOnMount = !1));
1026
+ }, Gt = (t) => {
1027
+ A.useEffect(() => {
1028
+ t.clearReset();
1029
+ }, [t]);
1030
+ }, $t = ({
1031
+ result: t,
1032
+ errorResetBoundary: e,
1033
+ throwOnError: s,
1034
+ query: r
1035
+ }) => t.isError && !e.isReset() && !t.isFetching && r && Kt(s, [t.error, r]), zt = (t, e) => e.state.data === void 0, Jt = (t) => {
1036
+ const e = t.staleTime;
1037
+ t.suspense && (t.staleTime = typeof e == "function" ? (...s) => Math.max(e(...s), 1e3) : Math.max(e ?? 1e3, 1e3), typeof t.gcTime == "number" && (t.gcTime = Math.max(t.gcTime, 1e3)));
1038
+ }, Vt = (t, e) => t.isLoading && t.isFetching && !e, Zt = (t, e) => (t == null ? void 0 : t.suspense) && e.isPending, Ye = (t, e, s) => e.fetchOptimistic(t).catch(() => {
1039
+ s.clearReset();
1040
+ });
1041
+ function bt(t, e, s) {
1042
+ var c, p, y, E, h;
1043
+ if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
1044
+ throw new Error(
1045
+ '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'
1046
+ );
1047
+ const r = yt(s), i = Mt(), a = Ht(), o = r.defaultQueryOptions(t);
1048
+ (p = (c = r.getDefaultOptions().queries) == null ? void 0 : c._experimental_beforeQuery) == null || p.call(
1049
+ c,
1050
+ o
1051
+ ), o._optimisticResults = i ? "isRestoring" : "optimistic", Jt(o), Bt(o, a), Gt(a);
1052
+ const u = !r.getQueryCache().get(o.queryHash), [l] = A.useState(
1053
+ () => new e(
1054
+ r,
1055
+ o
1056
+ )
1057
+ ), f = l.getOptimisticResult(o), v = !i && t.subscribed !== !1;
1058
+ if (A.useSyncExternalStore(
1059
+ A.useCallback(
1060
+ (b) => {
1061
+ const C = v ? l.subscribe(Le.batchCalls(b)) : We;
1062
+ return l.updateResult(), C;
1063
+ },
1064
+ [l, v]
1065
+ ),
1066
+ () => l.getCurrentResult(),
1067
+ () => l.getCurrentResult()
1068
+ ), A.useEffect(() => {
1069
+ l.setOptions(o, { listeners: !1 });
1070
+ }, [o, l]), Zt(o, f))
1071
+ throw Ye(o, l, a);
1072
+ if ($t({
1073
+ result: f,
1074
+ errorResetBoundary: a,
1075
+ throwOnError: o.throwOnError,
1076
+ query: r.getQueryCache().get(o.queryHash)
1077
+ }))
1078
+ throw f.error;
1079
+ if ((E = (y = r.getDefaultOptions().queries) == null ? void 0 : y._experimental_afterQuery) == null || E.call(
1080
+ y,
1081
+ o,
1082
+ f
1083
+ ), o.experimental_prefetchInRender && !J && Vt(f, i)) {
1084
+ const b = u ? (
1085
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
1086
+ Ye(o, l, a)
1087
+ ) : (
1088
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
1089
+ (h = r.getQueryCache().get(o.queryHash)) == null ? void 0 : h.promise
1090
+ );
1091
+ b == null || b.catch(We).finally(() => {
1092
+ l.updateResult();
1093
+ });
1094
+ }
1095
+ return o.notifyOnChangeProps ? f : l.trackResult(f);
1096
+ }
1097
+ function Wt(t, e) {
1098
+ return bt(t, lt, e);
1099
+ }
1100
+ function Yt(t, e) {
1101
+ return process.env.NODE_ENV !== "production" && t.queryFn === ye && console.error("skipToken is not allowed for useSuspenseQuery"), bt(
1102
+ {
1103
+ ...t,
1104
+ enabled: !0,
1105
+ suspense: !0,
1106
+ throwOnError: zt,
1107
+ placeholderData: void 0
1108
+ },
1109
+ lt,
1110
+ e
1111
+ );
1112
+ }
1113
+ const V = (...t) => {
1114
+ const e = t.filter((s) => !!s).map((s) => s.replace(/(^\/+|\/+$)/g, "")).join("/").replace(/(^\/+|\/+$)/g, "");
1115
+ return e ? `/${e}` : "/";
1116
+ }, mt = Object.freeze({
1117
+ API_IDENTITIES: ["api-identities"]
1118
+ }), gs = () => {
1119
+ const t = yt();
1120
+ return {
1121
+ invalidateCache: async (e) => {
1122
+ await t.invalidateQueries({ queryKey: mt[e] });
1123
+ }
1124
+ };
1125
+ }, Ne = (t, e) => {
1126
+ for (const s of t) {
1127
+ const r = _e(s, e);
1128
+ if (r !== void 0) return r;
1129
+ }
1130
+ }, _e = (t, e, s = []) => {
1131
+ const r = e(t, s);
1132
+ if (r !== void 0) return r;
1133
+ if (t.type === "category")
1134
+ for (const i of t.items) {
1135
+ const a = _e(i, e, [
1136
+ ...s,
1137
+ t
1138
+ ]);
1139
+ if (a !== void 0) return a;
1140
+ }
1141
+ }, Ss = () => {
1142
+ const t = pe(), s = vt().sidebar;
1143
+ return Ne(s, (r) => {
1144
+ if (r.type === "doc" && V(r.id) === t.pathname)
1145
+ return r;
1146
+ });
1147
+ }, ws = (t) => {
1148
+ const e = pe();
1149
+ return _e(t, (s) => {
1150
+ if (s.type === "category" && s.link && V(s.link.id) === e.pathname || s.type === "doc" && V(s.id) === e.pathname)
1151
+ return !0;
1152
+ });
1153
+ }, Rs = () => {
1154
+ const t = pe().pathname, s = vt().sidebar;
1155
+ let r, i, a = !1;
1156
+ return Ne(s, (o) => {
1157
+ const u = o.type === "doc" ? V(o.id) : o.type === "category" && o.link ? V(o.link.id) : void 0;
1158
+ if (u) {
1159
+ if (a)
1160
+ return i = { label: o.label, id: u }, !0;
1161
+ t === u ? a = !0 : r = { label: o.label, id: u };
1162
+ }
1163
+ }), { prev: r, next: i };
1164
+ }, Xt = Ct(
1165
+ void 0
1166
+ ), He = () => {
1167
+ const t = Et(Xt);
1168
+ if (!t)
1169
+ throw new Error("useZudoku must be used within a ZudokuProvider.");
1170
+ return t;
1171
+ }, Cs = () => {
1172
+ const { getApiIdentities: t } = He();
1173
+ return Wt({
1174
+ queryFn: t,
1175
+ queryKey: [mt.API_IDENTITIES]
1176
+ });
1177
+ }, vt = () => {
1178
+ var c;
1179
+ const { getPluginSidebar: t, sidebars: e, topNavigation: s, options: r } = He(), i = pe(), a = os(), o = (c = r.protectedRoutes) == null ? void 0 : c.some(
1180
+ (p) => $e(p, i.pathname)
1181
+ ), u = Object.entries(e).find(([, p]) => Ne(p, (y) => {
1182
+ if ((y.type === "doc" ? V(y.id) : y.type === "category" && y.link ? V(y.link.id) : void 0) === i.pathname)
1183
+ return y;
1184
+ })), l = s.find((p) => p.id === (u == null ? void 0 : u[0])) ?? s.find((p) => $e(p.id, i.pathname)), { data: f } = Yt({
1185
+ queryFn: () => t(i.pathname),
1186
+ queryKey: ["plugin-sidebar", i.pathname]
1187
+ });
1188
+ return {
1189
+ sidebar: a.isAuthEnabled && !a.isAuthenticated && o ? [] : [...u ? u[1] : [], ...f],
1190
+ topNavItem: l
1191
+ };
1192
+ }, Xe = (t) => {
1193
+ let e;
1194
+ const s = /* @__PURE__ */ new Set(), r = (f, v) => {
1195
+ const c = typeof f == "function" ? f(e) : f;
1196
+ if (!Object.is(c, e)) {
1197
+ const p = e;
1198
+ e = v ?? (typeof c != "object" || c === null) ? c : Object.assign({}, e, c), s.forEach((y) => y(e, p));
1199
+ }
1200
+ }, i = () => e, u = { setState: r, getState: i, getInitialState: () => l, subscribe: (f) => (s.add(f), () => s.delete(f)) }, l = e = t(r, i, u);
1201
+ return u;
1202
+ }, es = (t) => t ? Xe(t) : Xe, ts = (t) => t;
1203
+ function ss(t, e = ts) {
1204
+ const s = Ge.useSyncExternalStore(
1205
+ t.subscribe,
1206
+ () => e(t.getState()),
1207
+ () => e(t.getInitialState())
1208
+ );
1209
+ return Ge.useDebugValue(s), s;
1210
+ }
1211
+ const rs = (t) => {
1212
+ const e = es(t), s = (r) => ss(e, r);
1213
+ return Object.assign(s, e), s;
1214
+ }, gt = (t) => rs;
1215
+ function St(t, e) {
1216
+ let s;
1217
+ try {
1218
+ s = t();
1219
+ } catch {
1220
+ return;
1221
+ }
1222
+ return {
1223
+ getItem: (i) => {
1224
+ var a;
1225
+ const o = (l) => l === null ? null : JSON.parse(l, void 0), u = (a = s.getItem(i)) != null ? a : null;
1226
+ return u instanceof Promise ? u.then(o) : o(u);
1227
+ },
1228
+ setItem: (i, a) => s.setItem(
1229
+ i,
1230
+ JSON.stringify(a, void 0)
1231
+ ),
1232
+ removeItem: (i) => s.removeItem(i)
1233
+ };
1234
+ }
1235
+ const Ue = (t) => (e) => {
1236
+ try {
1237
+ const s = t(e);
1238
+ return s instanceof Promise ? s : {
1239
+ then(r) {
1240
+ return Ue(r)(s);
1241
+ },
1242
+ catch(r) {
1243
+ return this;
1244
+ }
1245
+ };
1246
+ } catch (s) {
1247
+ return {
1248
+ then(r) {
1249
+ return this;
1250
+ },
1251
+ catch(r) {
1252
+ return Ue(r)(s);
1253
+ }
1254
+ };
1255
+ }
1256
+ }, ns = (t, e) => (s, r, i) => {
1257
+ let a = {
1258
+ storage: St(() => localStorage),
1259
+ partialize: (h) => h,
1260
+ version: 0,
1261
+ merge: (h, b) => ({
1262
+ ...b,
1263
+ ...h
1264
+ }),
1265
+ ...e
1266
+ }, o = !1;
1267
+ const u = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
1268
+ let f = a.storage;
1269
+ if (!f)
1270
+ return t(
1271
+ (...h) => {
1272
+ console.warn(
1273
+ `[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`
1274
+ ), s(...h);
1275
+ },
1276
+ r,
1277
+ i
1278
+ );
1279
+ const v = () => {
1280
+ const h = a.partialize({ ...r() });
1281
+ return f.setItem(a.name, {
1282
+ state: h,
1283
+ version: a.version
1284
+ });
1285
+ }, c = i.setState;
1286
+ i.setState = (h, b) => {
1287
+ c(h, b), v();
1288
+ };
1289
+ const p = t(
1290
+ (...h) => {
1291
+ s(...h), v();
1292
+ },
1293
+ r,
1294
+ i
1295
+ );
1296
+ i.getInitialState = () => p;
1297
+ let y;
1298
+ const E = () => {
1299
+ var h, b;
1300
+ if (!f) return;
1301
+ o = !1, u.forEach((R) => {
1302
+ var O;
1303
+ return R((O = r()) != null ? O : p);
1304
+ });
1305
+ const C = ((b = a.onRehydrateStorage) == null ? void 0 : b.call(a, (h = r()) != null ? h : p)) || void 0;
1306
+ return Ue(f.getItem.bind(f))(a.name).then((R) => {
1307
+ if (R)
1308
+ if (typeof R.version == "number" && R.version !== a.version) {
1309
+ if (a.migrate) {
1310
+ const O = a.migrate(
1311
+ R.state,
1312
+ R.version
1313
+ );
1314
+ return O instanceof Promise ? O.then((Q) => [!0, Q]) : [!0, O];
1315
+ }
1316
+ console.error(
1317
+ "State loaded from storage couldn't be migrated since no migrate function was provided"
1318
+ );
1319
+ } else
1320
+ return [!1, R.state];
1321
+ return [!1, void 0];
1322
+ }).then((R) => {
1323
+ var O;
1324
+ const [Q, Z] = R;
1325
+ if (y = a.merge(
1326
+ Z,
1327
+ (O = r()) != null ? O : p
1328
+ ), s(y, !0), Q)
1329
+ return v();
1330
+ }).then(() => {
1331
+ C == null || C(y, void 0), y = r(), o = !0, l.forEach((R) => R(y));
1332
+ }).catch((R) => {
1333
+ C == null || C(void 0, R);
1334
+ });
1335
+ };
1336
+ return i.persist = {
1337
+ setOptions: (h) => {
1338
+ a = {
1339
+ ...a,
1340
+ ...h
1341
+ }, h.storage && (f = h.storage);
1342
+ },
1343
+ clearStorage: () => {
1344
+ f == null || f.removeItem(a.name);
1345
+ },
1346
+ getOptions: () => a,
1347
+ rehydrate: () => E(),
1348
+ hasHydrated: () => o,
1349
+ onHydrate: (h) => (u.add(h), () => {
1350
+ u.delete(h);
1351
+ }),
1352
+ onFinishHydration: (h) => (l.add(h), () => {
1353
+ l.delete(h);
1354
+ })
1355
+ }, a.skipHydration || E(), y || p;
1356
+ }, wt = ns, is = (t) => {
1357
+ const e = (s) => {
1358
+ s.key === t.persist.getOptions().name && s.newValue && t.persist.rehydrate();
1359
+ };
1360
+ return window.addEventListener("storage", e), () => {
1361
+ window.removeEventListener("storage", e);
1362
+ };
1363
+ }, Rt = gt()(
1364
+ wt(
1365
+ (t) => ({
1366
+ isAuthenticated: !1,
1367
+ isPending: !1,
1368
+ profile: null,
1369
+ providerData: null
1370
+ }),
1371
+ {
1372
+ name: "auth-state",
1373
+ storage: St(() => localStorage)
1374
+ // partialize: (s) => ({ state: s }),
1375
+ }
1376
+ )
1377
+ );
1378
+ typeof window < "u" && is(Rt);
1379
+ const as = gt()(
1380
+ wt(
1381
+ (t) => ({
1382
+ selectedServer: void 0,
1383
+ setSelectedServer: (e) => t({ selectedServer: e })
1384
+ }),
1385
+ { name: "zudoku-selected-server" }
1386
+ )
1387
+ ), Es = (t) => {
1388
+ const { selectedServer: e, setSelectedServer: s } = as();
1389
+ return { selectedServer: Ot(
1390
+ () => {
1391
+ var i;
1392
+ return e && t.some((a) => a.url === e) ? e : ((i = t.at(0)) == null ? void 0 : i.url) ?? "";
1393
+ },
1394
+ [e, t]
1395
+ ), setSelectedServer: s };
1396
+ }, os = () => {
1397
+ const { authentication: t } = He(), e = Rt(), s = typeof t < "u";
1398
+ return {
1399
+ isAuthEnabled: s,
1400
+ ...e,
1401
+ login: async () => {
1402
+ if (!s)
1403
+ throw new Error("Authentication is not enabled.");
1404
+ await t.signIn();
1405
+ },
1406
+ logout: async () => {
1407
+ if (!s)
1408
+ throw new Error("Authentication is not enabled.");
1409
+ await t.signOut(), window.location.href = "/";
1410
+ }
1411
+ };
1412
+ };
1413
+ export {
1414
+ ot as A,
1415
+ fe as B,
1416
+ ds as C,
1417
+ Qe as D,
1418
+ ye as E,
1419
+ vs as F,
1420
+ vt as G,
1421
+ Ne as H,
1422
+ gs as I,
1423
+ mt as J,
1424
+ ms as Q,
1425
+ Ut as R,
1426
+ qe as S,
1427
+ Xt as Z,
1428
+ Yt as a,
1429
+ Ss as b,
1430
+ kt as c,
1431
+ Rs as d,
1432
+ yt as e,
1433
+ We as f,
1434
+ Kt as g,
1435
+ we as h,
1436
+ He as i,
1437
+ V as j,
1438
+ os as k,
1439
+ ws as l,
1440
+ Wt as m,
1441
+ Le as n,
1442
+ Es as o,
1443
+ Cs as p,
1444
+ Ft as q,
1445
+ fs as r,
1446
+ Ce as s,
1447
+ ys as t,
1448
+ Rt as u,
1449
+ ge as v,
1450
+ Tt as w,
1451
+ bs as x,
1452
+ ps as y,
1453
+ at as z
1454
+ };
1455
+ //# sourceMappingURL=hook-Dnj3SwPC.js.map