zudoku 0.66.5 → 0.66.7

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