zudoku 0.66.6 → 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 (114) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.js +2 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/components/Pagination.js +2 -2
  5. package/dist/lib/components/Pagination.js.map +1 -1
  6. package/dist/lib/components/index.d.ts +3 -0
  7. package/dist/lib/components/index.js +4 -0
  8. package/dist/lib/components/index.js.map +1 -1
  9. package/dist/lib/components/navigation/NavigationItem.js +2 -2
  10. package/dist/lib/components/navigation/NavigationItem.js.map +1 -1
  11. package/dist/lib/core/react-query.d.ts +1 -0
  12. package/dist/lib/core/react-query.js +2 -0
  13. package/dist/lib/core/react-query.js.map +1 -0
  14. package/dist/lib/oas/graphql/circular.d.ts +1 -0
  15. package/dist/lib/oas/graphql/circular.js +15 -8
  16. package/dist/lib/oas/graphql/circular.js.map +1 -1
  17. package/dist/lib/oas/graphql/circular.test.d.ts +1 -0
  18. package/dist/lib/oas/graphql/circular.test.js +152 -0
  19. package/dist/lib/oas/graphql/circular.test.js.map +1 -0
  20. package/dist/vite/config.js +2 -0
  21. package/dist/vite/config.js.map +1 -1
  22. package/lib/{ClaudeLogo-BpqHBMS8.js → ClaudeLogo-DHxJUhN_.js} +20 -20
  23. package/lib/ClaudeLogo-DHxJUhN_.js.map +1 -0
  24. package/lib/HydrationBoundary-CNF2ZV3E.js +601 -0
  25. package/lib/HydrationBoundary-CNF2ZV3E.js.map +1 -0
  26. package/lib/Input-Cx-GeKoF.js +22 -0
  27. package/lib/Input-Cx-GeKoF.js.map +1 -0
  28. package/lib/{MdxPage-CeFSxGb_.js → MdxPage-CD36PJ17.js} +7 -7
  29. package/lib/{MdxPage-CeFSxGb_.js.map → MdxPage-CD36PJ17.js.map} +1 -1
  30. package/lib/{Mermaid-COVtAqcZ.js → Mermaid-Koc3z8mU.js} +3 -3
  31. package/lib/{Mermaid-COVtAqcZ.js.map → Mermaid-Koc3z8mU.js.map} +1 -1
  32. package/lib/{OAuthErrorPage-XTPBOMN8.js → OAuthErrorPage-4mN5DA86.js} +23 -22
  33. package/lib/{OAuthErrorPage-XTPBOMN8.js.map → OAuthErrorPage-4mN5DA86.js.map} +1 -1
  34. package/lib/{OasProvider-BS4rdzZC.js → OasProvider-DSe-hk5Y.js} +3 -3
  35. package/lib/{OasProvider-BS4rdzZC.js.map → OasProvider-DSe-hk5Y.js.map} +1 -1
  36. package/lib/{OperationList-Dg0Nm1tg.js → OperationList-CaknPbvq.js} +32 -31
  37. package/lib/{OperationList-Dg0Nm1tg.js.map → OperationList-CaknPbvq.js.map} +1 -1
  38. package/lib/{RouteGuard-kCicqF3x.js → RouteGuard--A04ESy8.js} +3 -3
  39. package/lib/{RouteGuard-kCicqF3x.js.map → RouteGuard--A04ESy8.js.map} +1 -1
  40. package/lib/{SchemaList-DZKBH2WC.js → SchemaList-Dw3-CJPb.js} +7 -7
  41. package/lib/{SchemaList-DZKBH2WC.js.map → SchemaList-Dw3-CJPb.js.map} +1 -1
  42. package/lib/{SchemaView-DBaqV2yU.js → SchemaView-DyJkiQkD.js} +3 -3
  43. package/lib/{SchemaView-DBaqV2yU.js.map → SchemaView-DyJkiQkD.js.map} +1 -1
  44. package/lib/{SignUp-DNmOFbLD.js → SignUp-DRvN-8cq.js} +3 -3
  45. package/lib/{SignUp-DNmOFbLD.js.map → SignUp-DRvN-8cq.js.map} +1 -1
  46. package/lib/{SyntaxHighlight-C75W8uCn.js → SyntaxHighlight-klTH8c6-.js} +2 -2
  47. package/lib/{SyntaxHighlight-C75W8uCn.js.map → SyntaxHighlight-klTH8c6-.js.map} +1 -1
  48. package/lib/{Toc-ICilS65g.js → Toc-PbuF-u9x.js} +2 -2
  49. package/lib/{Toc-ICilS65g.js.map → Toc-PbuF-u9x.js.map} +1 -1
  50. package/lib/ZudokuContext-BZB1TWdT.js +387 -0
  51. package/lib/ZudokuContext-BZB1TWdT.js.map +1 -0
  52. package/lib/{circular-DleWPaPP.js → circular-DFquXeY2.js} +21 -19
  53. package/lib/{circular-DleWPaPP.js.map → circular-DFquXeY2.js.map} +1 -1
  54. package/lib/{createServer-nqMW9kro.js → createServer-BXZ0CAUn.js} +4 -4
  55. package/lib/{createServer-nqMW9kro.js.map → createServer-BXZ0CAUn.js.map} +1 -1
  56. package/lib/{errors-D2FbERKl.js → errors-rWHkzVTd.js} +2 -2
  57. package/lib/{errors-D2FbERKl.js.map → errors-rWHkzVTd.js.map} +1 -1
  58. package/lib/{firebase-Cn9CmB6h.js → firebase-BmGU1FuD.js} +17 -15
  59. package/lib/{firebase-Cn9CmB6h.js.map → firebase-BmGU1FuD.js.map} +1 -1
  60. package/lib/{hook-B2nmfmYN.js → hook-BGlHBdET.js} +2 -2
  61. package/lib/{hook-B2nmfmYN.js.map → hook-BGlHBdET.js.map} +1 -1
  62. package/lib/{index-D5NeW2z6.js → index-BDsEwofZ.js} +1709 -1707
  63. package/lib/index-BDsEwofZ.js.map +1 -0
  64. package/lib/{index-CSDW7CHl.js → index-BQB9hb6n.js} +151 -149
  65. package/lib/{index-CSDW7CHl.js.map → index-BQB9hb6n.js.map} +1 -1
  66. package/lib/{index-CC4L3gtM.js → index-DBjOT2H1.js} +3 -3
  67. package/lib/{index-CC4L3gtM.js.map → index-DBjOT2H1.js.map} +1 -1
  68. package/lib/{index-DSKBOdpT.js → index-DRBOFufT.js} +2 -2
  69. package/lib/{index-DSKBOdpT.js.map → index-DRBOFufT.js.map} +1 -1
  70. package/lib/{index.esm-B35e7P83.js → index.esm-Cx8B1YJQ.js} +2 -2
  71. package/lib/index.esm-Cx8B1YJQ.js.map +1 -0
  72. package/lib/{mutation-BOYnEDf6.js → mutation-BISOc7OM.js} +2 -2
  73. package/lib/{mutation-BOYnEDf6.js.map → mutation-BISOc7OM.js.map} +1 -1
  74. package/lib/ui/SyntaxHighlight.js +2 -2
  75. package/lib/{Input-B6YcAPv-.js → useMutation-CFMGlAMW.js} +23 -40
  76. package/lib/useMutation-CFMGlAMW.js.map +1 -0
  77. package/lib/useSuspenseQuery-CSB_rVek.js +1226 -0
  78. package/lib/useSuspenseQuery-CSB_rVek.js.map +1 -0
  79. package/lib/zudoku.__internal.js +928 -1457
  80. package/lib/zudoku.__internal.js.map +1 -1
  81. package/lib/zudoku.auth-auth0.js +1 -1
  82. package/lib/zudoku.auth-azureb2c.js +4 -4
  83. package/lib/zudoku.auth-clerk.js +2 -2
  84. package/lib/zudoku.auth-firebase.js +4 -4
  85. package/lib/zudoku.auth-openid.js +4 -4
  86. package/lib/zudoku.auth-supabase.js +4 -4
  87. package/lib/zudoku.components.js +21 -18
  88. package/lib/zudoku.components.js.map +1 -1
  89. package/lib/zudoku.hooks.js +3 -3
  90. package/lib/zudoku.mermaid.js +3 -3
  91. package/lib/zudoku.plugin-api-catalog.js +6 -5
  92. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  93. package/lib/zudoku.plugin-api-keys.js +23 -21
  94. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  95. package/lib/zudoku.plugin-custom-pages.js +1 -1
  96. package/lib/zudoku.plugin-markdown.js +1 -1
  97. package/lib/zudoku.plugin-openapi.js +2 -2
  98. package/lib/zudoku.plugin-search-pagefind.js +29 -28
  99. package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
  100. package/lib/zudoku.react-query.js +440 -0
  101. package/lib/zudoku.react-query.js.map +1 -0
  102. package/package.json +5 -1
  103. package/src/lib/components/Pagination.tsx +4 -5
  104. package/src/lib/components/index.ts +4 -0
  105. package/src/lib/components/navigation/NavigationItem.tsx +9 -3
  106. package/src/lib/core/react-query.ts +1 -0
  107. package/src/lib/oas/graphql/circular.test.ts +186 -0
  108. package/src/lib/oas/graphql/circular.ts +22 -16
  109. package/lib/ClaudeLogo-BpqHBMS8.js.map +0 -1
  110. package/lib/Input-B6YcAPv-.js.map +0 -1
  111. package/lib/ZudokuContext-Ea7gxmGq.js +0 -1581
  112. package/lib/ZudokuContext-Ea7gxmGq.js.map +0 -1
  113. package/lib/index-D5NeW2z6.js.map +0 -1
  114. package/lib/index.esm-B35e7P83.js.map +0 -1
@@ -0,0 +1,1226 @@
1
+ import * as p from "react";
2
+ import { j as ee } from "./jsx-runtime-BzflLqGi.js";
3
+ var H = class {
4
+ constructor() {
5
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
6
+ }
7
+ subscribe(e) {
8
+ return this.listeners.add(e), this.onSubscribe(), () => {
9
+ this.listeners.delete(e), this.onUnsubscribe();
10
+ };
11
+ }
12
+ hasListeners() {
13
+ return this.listeners.size > 0;
14
+ }
15
+ onSubscribe() {
16
+ }
17
+ onUnsubscribe() {
18
+ }
19
+ }, fe = {
20
+ // We need the wrapper function syntax below instead of direct references to
21
+ // global setTimeout etc.
22
+ //
23
+ // BAD: `setTimeout: setTimeout`
24
+ // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
25
+ //
26
+ // If we use direct references here, then anything that wants to spy on or
27
+ // replace the global setTimeout (like tests) won't work since we'll already
28
+ // have a hard reference to the original implementation at the time when this
29
+ // file was imported.
30
+ setTimeout: (e, t) => setTimeout(e, t),
31
+ clearTimeout: (e) => clearTimeout(e),
32
+ setInterval: (e, t) => setInterval(e, t),
33
+ clearInterval: (e) => clearInterval(e)
34
+ }, de = class {
35
+ // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
36
+ // type at app boot; and if we leave that type, then any new timer provider
37
+ // would need to support ReturnType<typeof setTimeout>, which is infeasible.
38
+ //
39
+ // We settle for type safety for the TimeoutProvider type, and accept that
40
+ // this class is unsafe internally to allow for extension.
41
+ #t = fe;
42
+ #e = !1;
43
+ setTimeoutProvider(e) {
44
+ process.env.NODE_ENV !== "production" && this.#e && e !== this.#t && console.error(
45
+ "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
46
+ { previous: this.#t, provider: e }
47
+ ), this.#t = e, process.env.NODE_ENV !== "production" && (this.#e = !1);
48
+ }
49
+ setTimeout(e, t) {
50
+ return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setTimeout(e, t);
51
+ }
52
+ clearTimeout(e) {
53
+ this.#t.clearTimeout(e);
54
+ }
55
+ setInterval(e, t) {
56
+ return process.env.NODE_ENV !== "production" && (this.#e = !0), this.#t.setInterval(e, t);
57
+ }
58
+ clearInterval(e) {
59
+ this.#t.clearInterval(e);
60
+ }
61
+ }, w = new de();
62
+ function pe(e) {
63
+ setTimeout(e, 0);
64
+ }
65
+ var E = typeof window > "u" || "Deno" in globalThis;
66
+ function C() {
67
+ }
68
+ function Le(e, t) {
69
+ return typeof e == "function" ? e(t) : e;
70
+ }
71
+ function j(e) {
72
+ return typeof e == "number" && e >= 0 && e !== 1 / 0;
73
+ }
74
+ function te(e, t) {
75
+ return Math.max(e + (t || 0) - Date.now(), 0);
76
+ }
77
+ function I(e, t) {
78
+ return typeof e == "function" ? e(t) : e;
79
+ }
80
+ function v(e, t) {
81
+ return typeof e == "function" ? e(t) : e;
82
+ }
83
+ function Ke(e, t) {
84
+ const {
85
+ type: s = "all",
86
+ exact: r,
87
+ fetchStatus: n,
88
+ predicate: u,
89
+ queryKey: a,
90
+ stale: i
91
+ } = e;
92
+ if (a) {
93
+ if (r) {
94
+ if (t.queryHash !== ye(a, t.options))
95
+ return !1;
96
+ } else if (!V(t.queryKey, a))
97
+ return !1;
98
+ }
99
+ if (s !== "all") {
100
+ const o = t.isActive();
101
+ if (s === "active" && !o || s === "inactive" && o)
102
+ return !1;
103
+ }
104
+ return !(typeof i == "boolean" && t.isStale() !== i || n && n !== t.state.fetchStatus || u && !u(t));
105
+ }
106
+ function He(e, t) {
107
+ const { exact: s, status: r, predicate: n, mutationKey: u } = e;
108
+ if (u) {
109
+ if (!t.options.mutationKey)
110
+ return !1;
111
+ if (s) {
112
+ if (q(t.options.mutationKey) !== q(u))
113
+ return !1;
114
+ } else if (!V(t.options.mutationKey, u))
115
+ return !1;
116
+ }
117
+ return !(r && t.state.status !== r || n && !n(t));
118
+ }
119
+ function ye(e, t) {
120
+ return (t?.queryKeyHashFn || q)(e);
121
+ }
122
+ function q(e) {
123
+ return JSON.stringify(
124
+ e,
125
+ (t, s) => A(s) ? Object.keys(s).sort().reduce((r, n) => (r[n] = s[n], r), {}) : s
126
+ );
127
+ }
128
+ function V(e, t) {
129
+ return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((s) => V(e[s], t[s])) : !1;
130
+ }
131
+ var ve = Object.prototype.hasOwnProperty;
132
+ function N(e, t) {
133
+ if (e === t)
134
+ return e;
135
+ const s = z(e) && z(t);
136
+ if (!s && !(A(e) && A(t))) return t;
137
+ const n = (s ? e : Object.keys(e)).length, u = s ? t : Object.keys(t), a = u.length, i = s ? new Array(a) : {};
138
+ let o = 0;
139
+ for (let l = 0; l < a; l++) {
140
+ const c = s ? l : u[l], d = e[c], h = t[c];
141
+ if (d === h) {
142
+ i[c] = d, (s ? l < n : ve.call(e, c)) && o++;
143
+ continue;
144
+ }
145
+ if (d === null || h === null || typeof d != "object" || typeof h != "object") {
146
+ i[c] = h;
147
+ continue;
148
+ }
149
+ const R = N(d, h);
150
+ i[c] = R, R === d && o++;
151
+ }
152
+ return n === a && o === n ? e : i;
153
+ }
154
+ function k(e, t) {
155
+ if (!t || Object.keys(e).length !== Object.keys(t).length)
156
+ return !1;
157
+ for (const s in e)
158
+ if (e[s] !== t[s])
159
+ return !1;
160
+ return !0;
161
+ }
162
+ function z(e) {
163
+ return Array.isArray(e) && e.length === Object.keys(e).length;
164
+ }
165
+ function A(e) {
166
+ if (!$(e))
167
+ return !1;
168
+ const t = e.constructor;
169
+ if (t === void 0)
170
+ return !0;
171
+ const s = t.prototype;
172
+ return !(!$(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
173
+ }
174
+ function $(e) {
175
+ return Object.prototype.toString.call(e) === "[object Object]";
176
+ }
177
+ function me(e) {
178
+ return new Promise((t) => {
179
+ w.setTimeout(t, e);
180
+ });
181
+ }
182
+ function _(e, t, s) {
183
+ if (typeof s.structuralSharing == "function")
184
+ return s.structuralSharing(e, t);
185
+ if (s.structuralSharing !== !1) {
186
+ if (process.env.NODE_ENV !== "production")
187
+ try {
188
+ return N(e, t);
189
+ } catch (r) {
190
+ throw console.error(
191
+ `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}`
192
+ ), r;
193
+ }
194
+ return N(e, t);
195
+ }
196
+ return t;
197
+ }
198
+ function Ve(e) {
199
+ return e;
200
+ }
201
+ function Be(e, t, s = 0) {
202
+ const r = [...e, t];
203
+ return s && r.length > s ? r.slice(1) : r;
204
+ }
205
+ function Ge(e, t, s = 0) {
206
+ const r = [t, ...e];
207
+ return s && r.length > s ? r.slice(0, -1) : r;
208
+ }
209
+ var U = Symbol();
210
+ function be(e, t) {
211
+ return process.env.NODE_ENV !== "production" && e.queryFn === U && console.error(
212
+ `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
213
+ ), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === U ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
214
+ }
215
+ function ge(e, t) {
216
+ return typeof e == "function" ? e(...t) : !!e;
217
+ }
218
+ var Se = class extends H {
219
+ #t;
220
+ #e;
221
+ #s;
222
+ constructor() {
223
+ super(), this.#s = (e) => {
224
+ if (!E && window.addEventListener) {
225
+ const t = () => e();
226
+ return window.addEventListener("visibilitychange", t, !1), () => {
227
+ window.removeEventListener("visibilitychange", t);
228
+ };
229
+ }
230
+ };
231
+ }
232
+ onSubscribe() {
233
+ this.#e || this.setEventListener(this.#s);
234
+ }
235
+ onUnsubscribe() {
236
+ this.hasListeners() || (this.#e?.(), this.#e = void 0);
237
+ }
238
+ setEventListener(e) {
239
+ this.#s = e, this.#e?.(), this.#e = e((t) => {
240
+ typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
241
+ });
242
+ }
243
+ setFocused(e) {
244
+ this.#t !== e && (this.#t = e, this.onFocus());
245
+ }
246
+ onFocus() {
247
+ const e = this.isFocused();
248
+ this.listeners.forEach((t) => {
249
+ t(e);
250
+ });
251
+ }
252
+ isFocused() {
253
+ return typeof this.#t == "boolean" ? this.#t : globalThis.document?.visibilityState !== "hidden";
254
+ }
255
+ }, se = new Se();
256
+ function L() {
257
+ let e, t;
258
+ const s = new Promise((n, u) => {
259
+ e = n, t = u;
260
+ });
261
+ s.status = "pending", s.catch(() => {
262
+ });
263
+ function r(n) {
264
+ Object.assign(s, n), delete s.resolve, delete s.reject;
265
+ }
266
+ return s.resolve = (n) => {
267
+ r({
268
+ status: "fulfilled",
269
+ value: n
270
+ }), e(n);
271
+ }, s.reject = (n) => {
272
+ r({
273
+ status: "rejected",
274
+ reason: n
275
+ }), t(n);
276
+ }, s;
277
+ }
278
+ function ze(e) {
279
+ let t;
280
+ if (e.then((s) => (t = s, s), C)?.catch(C), t !== void 0)
281
+ return { data: t };
282
+ }
283
+ var Re = pe;
284
+ function Oe() {
285
+ let e = [], t = 0, s = (i) => {
286
+ i();
287
+ }, r = (i) => {
288
+ i();
289
+ }, n = Re;
290
+ const u = (i) => {
291
+ t ? e.push(i) : n(() => {
292
+ s(i);
293
+ });
294
+ }, a = () => {
295
+ const i = e;
296
+ e = [], i.length && n(() => {
297
+ r(() => {
298
+ i.forEach((o) => {
299
+ s(o);
300
+ });
301
+ });
302
+ });
303
+ };
304
+ return {
305
+ batch: (i) => {
306
+ let o;
307
+ t++;
308
+ try {
309
+ o = i();
310
+ } finally {
311
+ t--, t || a();
312
+ }
313
+ return o;
314
+ },
315
+ /**
316
+ * All calls to the wrapped function will be batched.
317
+ */
318
+ batchCalls: (i) => (...o) => {
319
+ u(() => {
320
+ i(...o);
321
+ });
322
+ },
323
+ schedule: u,
324
+ /**
325
+ * Use this method to set a custom notify function.
326
+ * This can be used to for example wrap notifications with `React.act` while running tests.
327
+ */
328
+ setNotifyFunction: (i) => {
329
+ s = i;
330
+ },
331
+ /**
332
+ * Use this method to set a custom function to batch notifications together into a single tick.
333
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
334
+ */
335
+ setBatchNotifyFunction: (i) => {
336
+ r = i;
337
+ },
338
+ setScheduler: (i) => {
339
+ n = i;
340
+ }
341
+ };
342
+ }
343
+ var B = Oe(), we = class extends H {
344
+ #t = !0;
345
+ #e;
346
+ #s;
347
+ constructor() {
348
+ super(), this.#s = (e) => {
349
+ if (!E && window.addEventListener) {
350
+ const t = () => e(!0), s = () => e(!1);
351
+ return window.addEventListener("online", t, !1), window.addEventListener("offline", s, !1), () => {
352
+ window.removeEventListener("online", t), window.removeEventListener("offline", s);
353
+ };
354
+ }
355
+ };
356
+ }
357
+ onSubscribe() {
358
+ this.#e || this.setEventListener(this.#s);
359
+ }
360
+ onUnsubscribe() {
361
+ this.hasListeners() || (this.#e?.(), this.#e = void 0);
362
+ }
363
+ setEventListener(e) {
364
+ this.#s = e, this.#e?.(), this.#e = e(this.setOnline.bind(this));
365
+ }
366
+ setOnline(e) {
367
+ this.#t !== e && (this.#t = e, this.listeners.forEach((s) => {
368
+ s(e);
369
+ }));
370
+ }
371
+ isOnline() {
372
+ return this.#t;
373
+ }
374
+ }, re = new we();
375
+ function Ee(e) {
376
+ return Math.min(1e3 * 2 ** e, 3e4);
377
+ }
378
+ function ie(e) {
379
+ return (e ?? "online") === "online" ? re.isOnline() : !0;
380
+ }
381
+ var Q = class extends Error {
382
+ constructor(e) {
383
+ super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
384
+ }
385
+ };
386
+ function $e(e) {
387
+ return e instanceof Q;
388
+ }
389
+ function Ce(e) {
390
+ let t = !1, s = 0, r;
391
+ const n = L(), u = () => n.status !== "pending", a = (f) => {
392
+ if (!u()) {
393
+ const g = new Q(f);
394
+ h(g), e.onCancel?.(g);
395
+ }
396
+ }, i = () => {
397
+ t = !0;
398
+ }, o = () => {
399
+ t = !1;
400
+ }, l = () => se.isFocused() && (e.networkMode === "always" || re.isOnline()) && e.canRun(), c = () => ie(e.networkMode) && e.canRun(), d = (f) => {
401
+ u() || (r?.(), n.resolve(f));
402
+ }, h = (f) => {
403
+ u() || (r?.(), n.reject(f));
404
+ }, R = () => new Promise((f) => {
405
+ r = (g) => {
406
+ (u() || l()) && f(g);
407
+ }, e.onPause?.();
408
+ }).then(() => {
409
+ r = void 0, u() || e.onContinue?.();
410
+ }), F = () => {
411
+ if (u())
412
+ return;
413
+ let f;
414
+ const g = s === 0 ? e.initialPromise : void 0;
415
+ try {
416
+ f = g ?? e.fn();
417
+ } catch (m) {
418
+ f = Promise.reject(m);
419
+ }
420
+ Promise.resolve(f).then(d).catch((m) => {
421
+ if (u())
422
+ return;
423
+ const S = e.retry ?? (E ? 0 : 3), O = e.retryDelay ?? Ee, P = typeof O == "function" ? O(s, m) : O, D = S === !0 || typeof S == "number" && s < S || typeof S == "function" && S(s, m);
424
+ if (t || !D) {
425
+ h(m);
426
+ return;
427
+ }
428
+ s++, e.onFail?.(s, m), me(P).then(() => l() ? void 0 : R()).then(() => {
429
+ t ? h(m) : F();
430
+ });
431
+ });
432
+ };
433
+ return {
434
+ promise: n,
435
+ status: () => n.status,
436
+ cancel: a,
437
+ continue: () => (r?.(), n),
438
+ cancelRetry: i,
439
+ continueRetry: o,
440
+ canStart: c,
441
+ start: () => (c() ? F() : R().then(F), n)
442
+ };
443
+ }
444
+ var Fe = class {
445
+ #t;
446
+ destroy() {
447
+ this.clearGcTimeout();
448
+ }
449
+ scheduleGc() {
450
+ this.clearGcTimeout(), j(this.gcTime) && (this.#t = w.setTimeout(() => {
451
+ this.optionalRemove();
452
+ }, this.gcTime));
453
+ }
454
+ updateGcTime(e) {
455
+ this.gcTime = Math.max(
456
+ this.gcTime || 0,
457
+ e ?? (E ? 1 / 0 : 300 * 1e3)
458
+ );
459
+ }
460
+ clearGcTimeout() {
461
+ this.#t && (w.clearTimeout(this.#t), this.#t = void 0);
462
+ }
463
+ }, Je = class extends Fe {
464
+ #t;
465
+ #e;
466
+ #s;
467
+ #i;
468
+ #r;
469
+ #o;
470
+ #a;
471
+ constructor(e) {
472
+ super(), this.#a = !1, this.#o = e.defaultOptions, this.setOptions(e.options), this.observers = [], this.#i = e.client, this.#s = this.#i.getQueryCache(), this.queryKey = e.queryKey, this.queryHash = e.queryHash, this.#t = W(this.options), this.state = e.state ?? this.#t, this.scheduleGc();
473
+ }
474
+ get meta() {
475
+ return this.options.meta;
476
+ }
477
+ get promise() {
478
+ return this.#r?.promise;
479
+ }
480
+ setOptions(e) {
481
+ if (this.options = { ...this.#o, ...e }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
482
+ const t = W(this.options);
483
+ t.data !== void 0 && (this.setState(
484
+ J(t.data, t.dataUpdatedAt)
485
+ ), this.#t = t);
486
+ }
487
+ }
488
+ optionalRemove() {
489
+ !this.observers.length && this.state.fetchStatus === "idle" && this.#s.remove(this);
490
+ }
491
+ setData(e, t) {
492
+ const s = _(this.state.data, e, this.options);
493
+ return this.#n({
494
+ data: s,
495
+ type: "success",
496
+ dataUpdatedAt: t?.updatedAt,
497
+ manual: t?.manual
498
+ }), s;
499
+ }
500
+ setState(e, t) {
501
+ this.#n({ type: "setState", state: e, setStateOptions: t });
502
+ }
503
+ cancel(e) {
504
+ const t = this.#r?.promise;
505
+ return this.#r?.cancel(e), t ? t.then(C).catch(C) : Promise.resolve();
506
+ }
507
+ destroy() {
508
+ super.destroy(), this.cancel({ silent: !0 });
509
+ }
510
+ reset() {
511
+ this.destroy(), this.setState(this.#t);
512
+ }
513
+ isActive() {
514
+ return this.observers.some(
515
+ (e) => v(e.options.enabled, this) !== !1
516
+ );
517
+ }
518
+ isDisabled() {
519
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === U || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
520
+ }
521
+ isStatic() {
522
+ return this.getObserversCount() > 0 ? this.observers.some(
523
+ (e) => I(e.options.staleTime, this) === "static"
524
+ ) : !1;
525
+ }
526
+ isStale() {
527
+ return this.getObserversCount() > 0 ? this.observers.some(
528
+ (e) => e.getCurrentResult().isStale
529
+ ) : this.state.data === void 0 || this.state.isInvalidated;
530
+ }
531
+ isStaleByTime(e = 0) {
532
+ return this.state.data === void 0 ? !0 : e === "static" ? !1 : this.state.isInvalidated ? !0 : !te(this.state.dataUpdatedAt, e);
533
+ }
534
+ onFocus() {
535
+ this.observers.find((t) => t.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
536
+ }
537
+ onOnline() {
538
+ this.observers.find((t) => t.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
539
+ }
540
+ addObserver(e) {
541
+ this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), this.#s.notify({ type: "observerAdded", query: this, observer: e }));
542
+ }
543
+ removeObserver(e) {
544
+ this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), 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: e }));
545
+ }
546
+ getObserversCount() {
547
+ return this.observers.length;
548
+ }
549
+ invalidate() {
550
+ this.state.isInvalidated || this.#n({ type: "invalidate" });
551
+ }
552
+ async fetch(e, t) {
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 && t?.cancelRefetch)
558
+ this.cancel({ silent: !0 });
559
+ else if (this.#r)
560
+ return this.#r.continueRetry(), this.#r.promise;
561
+ }
562
+ if (e && this.setOptions(e), !this.options.queryFn) {
563
+ const i = this.observers.find((o) => o.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 = be(this.options, t), l = (() => {
576
+ const c = {
577
+ client: this.#i,
578
+ queryKey: this.queryKey,
579
+ meta: this.meta
580
+ };
581
+ return r(c), c;
582
+ })();
583
+ return this.#a = !1, this.options.persister ? this.options.persister(
584
+ i,
585
+ l,
586
+ this
587
+ ) : i(l);
588
+ }, a = (() => {
589
+ const i = {
590
+ fetchOptions: t,
591
+ options: this.options,
592
+ queryKey: this.queryKey,
593
+ client: this.#i,
594
+ state: this.state,
595
+ fetchFn: n
596
+ };
597
+ return r(i), i;
598
+ })();
599
+ this.options.behavior?.onFetch(a, this), this.#e = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== a.fetchOptions?.meta) && this.#n({ type: "fetch", meta: a.fetchOptions?.meta }), this.#r = Ce({
600
+ initialPromise: t?.initialPromise,
601
+ fn: a.fetchFn,
602
+ onCancel: (i) => {
603
+ i instanceof Q && i.revert && this.setState({
604
+ ...this.#e,
605
+ fetchStatus: "idle"
606
+ }), s.abort();
607
+ },
608
+ onFail: (i, o) => {
609
+ this.#n({ type: "failed", failureCount: i, error: o });
610
+ },
611
+ onPause: () => {
612
+ this.#n({ type: "pause" });
613
+ },
614
+ onContinue: () => {
615
+ this.#n({ type: "continue" });
616
+ },
617
+ retry: a.options.retry,
618
+ retryDelay: a.options.retryDelay,
619
+ networkMode: a.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 Q) {
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.#n({
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
+ #n(e) {
659
+ const t = (s) => {
660
+ switch (e.type) {
661
+ case "failed":
662
+ return {
663
+ ...s,
664
+ fetchFailureCount: e.failureCount,
665
+ fetchFailureReason: e.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
+ ...ne(s.data, this.options),
681
+ fetchMeta: e.meta ?? null
682
+ };
683
+ case "success":
684
+ const r = {
685
+ ...s,
686
+ ...J(e.data, e.dataUpdatedAt),
687
+ dataUpdateCount: s.dataUpdateCount + 1,
688
+ ...!e.manual && {
689
+ fetchStatus: "idle",
690
+ fetchFailureCount: 0,
691
+ fetchFailureReason: null
692
+ }
693
+ };
694
+ return this.#e = e.manual ? r : void 0, r;
695
+ case "error":
696
+ const n = e.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
+ ...e.state
716
+ };
717
+ }
718
+ };
719
+ this.state = t(this.state), B.batch(() => {
720
+ this.observers.forEach((s) => {
721
+ s.onQueryUpdate();
722
+ }), this.#s.notify({ query: this, type: "updated", action: e });
723
+ });
724
+ }
725
+ };
726
+ function ne(e, t) {
727
+ return {
728
+ fetchFailureCount: 0,
729
+ fetchFailureReason: null,
730
+ fetchStatus: ie(t.networkMode) ? "fetching" : "paused",
731
+ ...e === void 0 && {
732
+ error: null,
733
+ status: "pending"
734
+ }
735
+ };
736
+ }
737
+ function J(e, t) {
738
+ return {
739
+ data: e,
740
+ dataUpdatedAt: t ?? Date.now(),
741
+ error: null,
742
+ isInvalidated: !1,
743
+ status: "success"
744
+ };
745
+ }
746
+ function W(e) {
747
+ const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, s = t !== void 0, r = s ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
748
+ return {
749
+ data: t,
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 ae = class extends H {
764
+ constructor(e, t) {
765
+ super(), this.options = t, this.#t = e, this.#n = null, this.#a = L(), this.bindMethods(), this.setOptions(t);
766
+ }
767
+ #t;
768
+ #e = void 0;
769
+ #s = void 0;
770
+ #i = void 0;
771
+ #r;
772
+ #o;
773
+ #a;
774
+ #n;
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
+ #h;
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.#e.addObserver(this), Z(this.#e, this.options) ? this.#l() : this.updateResult(), this.#g());
789
+ }
790
+ onUnsubscribe() {
791
+ this.hasListeners() || this.destroy();
792
+ }
793
+ shouldFetchOnReconnect() {
794
+ return K(
795
+ this.#e,
796
+ this.options,
797
+ this.options.refetchOnReconnect
798
+ );
799
+ }
800
+ shouldFetchOnWindowFocus() {
801
+ return K(
802
+ this.#e,
803
+ this.options,
804
+ this.options.refetchOnWindowFocus
805
+ );
806
+ }
807
+ destroy() {
808
+ this.listeners = /* @__PURE__ */ new Set(), this.#S(), this.#R(), this.#e.removeObserver(this);
809
+ }
810
+ setOptions(e) {
811
+ const t = this.options, s = this.#e;
812
+ if (this.options = this.#t.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof v(this.options.enabled, this.#e) != "boolean")
813
+ throw new Error(
814
+ "Expected enabled to be a boolean or a callback that returns a boolean"
815
+ );
816
+ this.#O(), this.#e.setOptions(this.options), t._defaulted && !k(this.options, t) && this.#t.getQueryCache().notify({
817
+ type: "observerOptionsUpdated",
818
+ query: this.#e,
819
+ observer: this
820
+ });
821
+ const r = this.hasListeners();
822
+ r && X(
823
+ this.#e,
824
+ s,
825
+ this.options,
826
+ t
827
+ ) && this.#l(), this.updateResult(), r && (this.#e !== s || v(this.options.enabled, this.#e) !== v(t.enabled, this.#e) || I(this.options.staleTime, this.#e) !== I(t.staleTime, this.#e)) && this.#v();
828
+ const n = this.#m();
829
+ r && (this.#e !== s || v(this.options.enabled, this.#e) !== v(t.enabled, this.#e) || n !== this.#u) && this.#b(n);
830
+ }
831
+ getOptimisticResult(e) {
832
+ const t = this.#t.getQueryCache().build(this.#t, e), s = this.createResult(t, e);
833
+ return Ie(this, s) && (this.#i = s, this.#o = this.options, this.#r = this.#e.state), s;
834
+ }
835
+ getCurrentResult() {
836
+ return this.#i;
837
+ }
838
+ trackResult(e, t) {
839
+ return new Proxy(e, {
840
+ get: (s, r) => (this.trackProp(r), t?.(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(e) {
848
+ this.#p.add(e);
849
+ }
850
+ getCurrentQuery() {
851
+ return this.#e;
852
+ }
853
+ refetch({ ...e } = {}) {
854
+ return this.fetch({
855
+ ...e
856
+ });
857
+ }
858
+ fetchOptimistic(e) {
859
+ const t = this.#t.defaultQueryOptions(e), s = this.#t.getQueryCache().build(this.#t, t);
860
+ return s.fetch().then(() => this.createResult(s, t));
861
+ }
862
+ fetch(e) {
863
+ return this.#l({
864
+ ...e,
865
+ cancelRefetch: e.cancelRefetch ?? !0
866
+ }).then(() => (this.updateResult(), this.#i));
867
+ }
868
+ #l(e) {
869
+ this.#O();
870
+ let t = this.#e.fetch(
871
+ this.options,
872
+ e
873
+ );
874
+ return e?.throwOnError || (t = t.catch(C)), t;
875
+ }
876
+ #v() {
877
+ this.#S();
878
+ const e = I(
879
+ this.options.staleTime,
880
+ this.#e
881
+ );
882
+ if (E || this.#i.isStale || !j(e))
883
+ return;
884
+ const s = te(this.#i.dataUpdatedAt, e) + 1;
885
+ this.#c = w.setTimeout(() => {
886
+ this.#i.isStale || this.updateResult();
887
+ }, s);
888
+ }
889
+ #m() {
890
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
891
+ }
892
+ #b(e) {
893
+ this.#R(), this.#u = e, !(E || v(this.options.enabled, this.#e) === !1 || !j(this.#u) || this.#u === 0) && (this.#h = w.setInterval(() => {
894
+ (this.options.refetchIntervalInBackground || se.isFocused()) && this.#l();
895
+ }, this.#u));
896
+ }
897
+ #g() {
898
+ this.#v(), this.#b(this.#m());
899
+ }
900
+ #S() {
901
+ this.#c && (w.clearTimeout(this.#c), this.#c = void 0);
902
+ }
903
+ #R() {
904
+ this.#h && (w.clearInterval(this.#h), this.#h = void 0);
905
+ }
906
+ createResult(e, t) {
907
+ const s = this.#e, r = this.options, n = this.#i, u = this.#r, a = this.#o, o = e !== s ? e.state : this.#s, { state: l } = e;
908
+ let c = { ...l }, d = !1, h;
909
+ if (t._optimisticResults) {
910
+ const y = this.hasListeners(), M = !y && Z(e, t), T = y && X(e, s, t, r);
911
+ (M || T) && (c = {
912
+ ...c,
913
+ ...ne(l.data, e.options)
914
+ }), t._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
915
+ }
916
+ let { error: R, errorUpdatedAt: F, status: f } = c;
917
+ h = c.data;
918
+ let g = !1;
919
+ if (t.placeholderData !== void 0 && h === void 0 && f === "pending") {
920
+ let y;
921
+ n?.isPlaceholderData && t.placeholderData === a?.placeholderData ? (y = n.data, g = !0) : y = typeof t.placeholderData == "function" ? t.placeholderData(
922
+ this.#d?.state.data,
923
+ this.#d
924
+ ) : t.placeholderData, y !== void 0 && (f = "success", h = _(
925
+ n?.data,
926
+ y,
927
+ t
928
+ ), d = !0);
929
+ }
930
+ if (t.select && h !== void 0 && !g)
931
+ if (n && h === u?.data && t.select === this.#y)
932
+ h = this.#f;
933
+ else
934
+ try {
935
+ this.#y = t.select, h = t.select(h), h = _(n?.data, h, t), this.#f = h, this.#n = null;
936
+ } catch (y) {
937
+ this.#n = y;
938
+ }
939
+ this.#n && (R = this.#n, h = this.#f, F = Date.now(), f = "error");
940
+ const m = c.fetchStatus === "fetching", S = f === "pending", O = f === "error", P = S && m, D = h !== void 0, b = {
941
+ status: f,
942
+ fetchStatus: c.fetchStatus,
943
+ isPending: S,
944
+ isSuccess: f === "success",
945
+ isError: O,
946
+ isInitialLoading: P,
947
+ isLoading: P,
948
+ data: h,
949
+ dataUpdatedAt: c.dataUpdatedAt,
950
+ error: R,
951
+ errorUpdatedAt: F,
952
+ failureCount: c.fetchFailureCount,
953
+ failureReason: c.fetchFailureReason,
954
+ errorUpdateCount: c.errorUpdateCount,
955
+ isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
956
+ isFetchedAfterMount: c.dataUpdateCount > o.dataUpdateCount || c.errorUpdateCount > o.errorUpdateCount,
957
+ isFetching: m,
958
+ isRefetching: m && !S,
959
+ isLoadingError: O && !D,
960
+ isPaused: c.fetchStatus === "paused",
961
+ isPlaceholderData: d,
962
+ isRefetchError: O && D,
963
+ isStale: G(e, t),
964
+ refetch: this.refetch,
965
+ promise: this.#a,
966
+ isEnabled: v(t.enabled, e) !== !1
967
+ };
968
+ if (this.options.experimental_prefetchInRender) {
969
+ const y = (x) => {
970
+ b.status === "error" ? x.reject(b.error) : b.data !== void 0 && x.resolve(b.data);
971
+ }, M = () => {
972
+ const x = this.#a = b.promise = L();
973
+ y(x);
974
+ }, T = this.#a;
975
+ switch (T.status) {
976
+ case "pending":
977
+ e.queryHash === s.queryHash && y(T);
978
+ break;
979
+ case "fulfilled":
980
+ (b.status === "error" || b.data !== T.value) && M();
981
+ break;
982
+ case "rejected":
983
+ (b.status !== "error" || b.error !== T.reason) && M();
984
+ break;
985
+ }
986
+ }
987
+ return b;
988
+ }
989
+ updateResult() {
990
+ const e = this.#i, t = this.createResult(this.#e, this.options);
991
+ if (this.#r = this.#e.state, this.#o = this.options, this.#r.data !== void 0 && (this.#d = this.#e), k(t, e))
992
+ return;
993
+ this.#i = t;
994
+ const s = () => {
995
+ if (!e)
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 u = new Set(
1001
+ n ?? this.#p
1002
+ );
1003
+ return this.options.throwOnError && u.add("error"), Object.keys(this.#i).some((a) => {
1004
+ const i = a;
1005
+ return this.#i[i] !== e[i] && u.has(i);
1006
+ });
1007
+ };
1008
+ this.#w({ listeners: s() });
1009
+ }
1010
+ #O() {
1011
+ const e = this.#t.getQueryCache().build(this.#t, this.options);
1012
+ if (e === this.#e)
1013
+ return;
1014
+ const t = this.#e;
1015
+ this.#e = e, this.#s = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
1016
+ }
1017
+ onQueryUpdate() {
1018
+ this.updateResult(), this.hasListeners() && this.#g();
1019
+ }
1020
+ #w(e) {
1021
+ B.batch(() => {
1022
+ e.listeners && this.listeners.forEach((t) => {
1023
+ t(this.#i);
1024
+ }), this.#t.getQueryCache().notify({
1025
+ query: this.#e,
1026
+ type: "observerResultsUpdated"
1027
+ });
1028
+ });
1029
+ }
1030
+ };
1031
+ function Te(e, t) {
1032
+ return v(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
1033
+ }
1034
+ function Z(e, t) {
1035
+ return Te(e, t) || e.state.data !== void 0 && K(e, t, t.refetchOnMount);
1036
+ }
1037
+ function K(e, t, s) {
1038
+ if (v(t.enabled, e) !== !1 && I(t.staleTime, e) !== "static") {
1039
+ const r = typeof s == "function" ? s(e) : s;
1040
+ return r === "always" || r !== !1 && G(e, t);
1041
+ }
1042
+ return !1;
1043
+ }
1044
+ function X(e, t, s, r) {
1045
+ return (e !== t || v(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && G(e, s);
1046
+ }
1047
+ function G(e, t) {
1048
+ return v(t.enabled, e) !== !1 && e.isStaleByTime(I(t.staleTime, e));
1049
+ }
1050
+ function Ie(e, t) {
1051
+ return !k(e.getCurrentResult(), t);
1052
+ }
1053
+ var oe = p.createContext(
1054
+ void 0
1055
+ ), Pe = (e) => {
1056
+ const t = p.useContext(oe);
1057
+ if (e)
1058
+ return e;
1059
+ if (!t)
1060
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
1061
+ return t;
1062
+ }, We = ({
1063
+ client: e,
1064
+ children: t
1065
+ }) => (p.useEffect(() => (e.mount(), () => {
1066
+ e.unmount();
1067
+ }), [e]), /* @__PURE__ */ ee.jsx(oe.Provider, { value: e, children: t })), ue = p.createContext(!1), De = () => p.useContext(ue), Ze = ue.Provider;
1068
+ function ce() {
1069
+ let e = !1;
1070
+ return {
1071
+ clearReset: () => {
1072
+ e = !1;
1073
+ },
1074
+ reset: () => {
1075
+ e = !0;
1076
+ },
1077
+ isReset: () => e
1078
+ };
1079
+ }
1080
+ var he = p.createContext(ce()), Me = () => p.useContext(he), Xe = ({
1081
+ children: e
1082
+ }) => {
1083
+ const [t] = p.useState(() => ce());
1084
+ return /* @__PURE__ */ ee.jsx(he.Provider, { value: t, children: typeof e == "function" ? e(t) : e });
1085
+ }, xe = (e, t) => {
1086
+ (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
1087
+ }, Ue = (e) => {
1088
+ p.useEffect(() => {
1089
+ e.clearReset();
1090
+ }, [e]);
1091
+ }, Qe = ({
1092
+ result: e,
1093
+ errorResetBoundary: t,
1094
+ throwOnError: s,
1095
+ query: r,
1096
+ suspense: n
1097
+ }) => e.isError && !t.isReset() && !e.isFetching && r && (n && e.data === void 0 || ge(s, [e.error, r])), je = (e, t) => t.state.data === void 0, qe = (e) => {
1098
+ if (e.suspense) {
1099
+ const s = (n) => n === "static" ? n : Math.max(n ?? 1e3, 1e3), r = e.staleTime;
1100
+ e.staleTime = typeof r == "function" ? (...n) => s(r(...n)) : s(r), typeof e.gcTime == "number" && (e.gcTime = Math.max(
1101
+ e.gcTime,
1102
+ 1e3
1103
+ ));
1104
+ }
1105
+ }, Ne = (e, t) => e.isLoading && e.isFetching && !t, ke = (e, t) => e?.suspense && t.isPending, Y = (e, t, s) => t.fetchOptimistic(e).catch(() => {
1106
+ s.clearReset();
1107
+ });
1108
+ function le(e, t, s) {
1109
+ if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
1110
+ throw new Error(
1111
+ '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'
1112
+ );
1113
+ const r = De(), n = Me(), u = Pe(s), a = u.defaultQueryOptions(e);
1114
+ u.getDefaultOptions().queries?._experimental_beforeQuery?.(
1115
+ a
1116
+ ), process.env.NODE_ENV !== "production" && (a.queryFn || console.error(
1117
+ `[${a.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`
1118
+ )), a._optimisticResults = r ? "isRestoring" : "optimistic", qe(a), xe(a, n), Ue(n);
1119
+ const i = !u.getQueryCache().get(a.queryHash), [o] = p.useState(
1120
+ () => new t(
1121
+ u,
1122
+ a
1123
+ )
1124
+ ), l = o.getOptimisticResult(a), c = !r && e.subscribed !== !1;
1125
+ if (p.useSyncExternalStore(
1126
+ p.useCallback(
1127
+ (d) => {
1128
+ const h = c ? o.subscribe(B.batchCalls(d)) : C;
1129
+ return o.updateResult(), h;
1130
+ },
1131
+ [o, c]
1132
+ ),
1133
+ () => o.getCurrentResult(),
1134
+ () => o.getCurrentResult()
1135
+ ), p.useEffect(() => {
1136
+ o.setOptions(a);
1137
+ }, [a, o]), ke(a, l))
1138
+ throw Y(a, o, n);
1139
+ if (Qe({
1140
+ result: l,
1141
+ errorResetBoundary: n,
1142
+ throwOnError: a.throwOnError,
1143
+ query: u.getQueryCache().get(a.queryHash),
1144
+ suspense: a.suspense
1145
+ }))
1146
+ throw l.error;
1147
+ return u.getDefaultOptions().queries?._experimental_afterQuery?.(
1148
+ a,
1149
+ l
1150
+ ), a.experimental_prefetchInRender && !E && Ne(l, r) && (i ? (
1151
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
1152
+ Y(a, o, n)
1153
+ ) : (
1154
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
1155
+ u.getQueryCache().get(a.queryHash)?.promise
1156
+ ))?.catch(C).finally(() => {
1157
+ o.updateResult();
1158
+ }), a.notifyOnChangeProps ? l : o.trackResult(l);
1159
+ }
1160
+ function Ye(e, t) {
1161
+ return le(e, ae, t);
1162
+ }
1163
+ function et(e, t) {
1164
+ return process.env.NODE_ENV !== "production" && e.queryFn === U && console.error("skipToken is not allowed for useSuspenseQuery"), le(
1165
+ {
1166
+ ...e,
1167
+ enabled: !0,
1168
+ suspense: !0,
1169
+ throwOnError: je,
1170
+ placeholderData: void 0
1171
+ },
1172
+ ae,
1173
+ t
1174
+ );
1175
+ }
1176
+ export {
1177
+ Me as A,
1178
+ qe as B,
1179
+ xe as C,
1180
+ Ue as D,
1181
+ ke as E,
1182
+ Y as F,
1183
+ Ne as G,
1184
+ Qe as H,
1185
+ le as I,
1186
+ je as J,
1187
+ Ze as K,
1188
+ oe as L,
1189
+ We as M,
1190
+ Xe as N,
1191
+ Q as O,
1192
+ Re as P,
1193
+ Je as Q,
1194
+ Fe as R,
1195
+ H as S,
1196
+ $e as T,
1197
+ E as U,
1198
+ w as V,
1199
+ Pe as a,
1200
+ C as b,
1201
+ Ce as c,
1202
+ ge as d,
1203
+ Ye as e,
1204
+ be as f,
1205
+ Ge as g,
1206
+ q as h,
1207
+ Be as i,
1208
+ ye as j,
1209
+ Ve as k,
1210
+ Ke as l,
1211
+ He as m,
1212
+ B as n,
1213
+ se as o,
1214
+ re as p,
1215
+ Le as q,
1216
+ I as r,
1217
+ k as s,
1218
+ ze as t,
1219
+ et as u,
1220
+ V as v,
1221
+ U as w,
1222
+ ae as x,
1223
+ N as y,
1224
+ De as z
1225
+ };
1226
+ //# sourceMappingURL=useSuspenseQuery-CSB_rVek.js.map