@cordystackx/cordy_minikit 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,12 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
7
  var __export = (target, all) => {
14
8
  for (var name in all)
15
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -32,486 +26,111 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
26
  ));
33
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
 
35
- // ../../../../node_modules/@swc/helpers/cjs/_interop_require_default.cjs
36
- var require_interop_require_default = __commonJS({
37
- "../../../../node_modules/@swc/helpers/cjs/_interop_require_default.cjs"(exports2) {
38
- "use strict";
39
- function _interop_require_default(obj) {
40
- return obj && obj.__esModule ? obj : { default: obj };
41
- }
42
- exports2._ = _interop_require_default;
43
- }
29
+ // index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ ConnectWalletBT: () => ConnectWalletBT,
33
+ CordyStackTrans: () => CordyStackTrans,
34
+ Disconnect: () => Disconnect,
35
+ ProvidersClientWrapper: () => WalletProviders,
36
+ UI_Comp: () => UI_Comp,
37
+ WalletButton: () => WalletButton,
38
+ getTokenBalance: () => getTokenBalance
44
39
  });
40
+ module.exports = __toCommonJS(index_exports);
45
41
 
46
- // ../../../../node_modules/next/dist/shared/lib/loadable-context.shared-runtime.js
47
- var require_loadable_context_shared_runtime = __commonJS({
48
- "../../../../node_modules/next/dist/shared/lib/loadable-context.shared-runtime.js"(exports2) {
49
- "use client";
50
- "use strict";
51
- Object.defineProperty(exports2, "__esModule", {
52
- value: true
53
- });
54
- Object.defineProperty(exports2, "LoadableContext", {
55
- enumerable: true,
56
- get: function() {
57
- return LoadableContext;
58
- }
59
- });
60
- var _interop_require_default = require_interop_require_default();
61
- var _react = /* @__PURE__ */ _interop_require_default._(require("react"));
62
- var LoadableContext = _react.default.createContext(null);
63
- if (process.env.NODE_ENV !== "production") {
64
- LoadableContext.displayName = "LoadableContext";
65
- }
66
- }
67
- });
42
+ // wagmi__providers.tsx
43
+ var import_react3 = require("react");
68
44
 
69
- // ../../../../node_modules/next/dist/shared/lib/loadable.shared-runtime.js
70
- var require_loadable_shared_runtime = __commonJS({
71
- "../../../../node_modules/next/dist/shared/lib/loadable.shared-runtime.js"(exports2) {
72
- "use strict";
73
- Object.defineProperty(exports2, "__esModule", {
74
- value: true
75
- });
76
- Object.defineProperty(exports2, "default", {
77
- enumerable: true,
78
- get: function() {
79
- return _default;
80
- }
81
- });
82
- var _interop_require_default = require_interop_require_default();
83
- var _react = /* @__PURE__ */ _interop_require_default._(require("react"));
84
- var _loadablecontextsharedruntime = require_loadable_context_shared_runtime();
85
- function resolve(obj) {
86
- return obj && obj.default ? obj.default : obj;
87
- }
88
- var ALL_INITIALIZERS = [];
89
- var READY_INITIALIZERS = [];
90
- var initialized = false;
91
- function load(loader) {
92
- let promise = loader();
93
- let state = {
94
- loading: true,
95
- loaded: null,
96
- error: null
97
- };
98
- state.promise = promise.then((loaded) => {
99
- state.loading = false;
100
- state.loaded = loaded;
101
- return loaded;
102
- }).catch((err) => {
103
- state.loading = false;
104
- state.error = err;
105
- throw err;
106
- });
107
- return state;
108
- }
109
- function createLoadableComponent(loadFn, options) {
110
- let opts = Object.assign({
111
- loader: null,
112
- loading: null,
113
- delay: 200,
114
- timeout: null,
115
- webpack: null,
116
- modules: null
117
- }, options);
118
- let subscription = null;
119
- function init() {
120
- if (!subscription) {
121
- const sub = new LoadableSubscription(loadFn, opts);
122
- subscription = {
123
- getCurrentValue: sub.getCurrentValue.bind(sub),
124
- subscribe: sub.subscribe.bind(sub),
125
- retry: sub.retry.bind(sub),
126
- promise: sub.promise.bind(sub)
127
- };
128
- }
129
- return subscription.promise();
130
- }
131
- if (typeof window === "undefined") {
132
- ALL_INITIALIZERS.push(init);
133
- }
134
- if (!initialized && typeof window !== "undefined") {
135
- const moduleIds = opts.webpack && typeof require.resolveWeak === "function" ? opts.webpack() : opts.modules;
136
- if (moduleIds) {
137
- READY_INITIALIZERS.push((ids) => {
138
- for (const moduleId of moduleIds) {
139
- if (ids.includes(moduleId)) {
140
- return init();
141
- }
142
- }
143
- });
144
- }
145
- }
146
- function useLoadableModule() {
147
- init();
148
- const context = _react.default.useContext(_loadablecontextsharedruntime.LoadableContext);
149
- if (context && Array.isArray(opts.modules)) {
150
- opts.modules.forEach((moduleName) => {
151
- context(moduleName);
152
- });
153
- }
154
- }
155
- function LoadableComponent(props, ref) {
156
- useLoadableModule();
157
- const state = _react.default.useSyncExternalStore(subscription.subscribe, subscription.getCurrentValue, subscription.getCurrentValue);
158
- _react.default.useImperativeHandle(ref, () => ({
159
- retry: subscription.retry
160
- }), []);
161
- return _react.default.useMemo(() => {
162
- if (state.loading || state.error) {
163
- return /* @__PURE__ */ _react.default.createElement(opts.loading, {
164
- isLoading: state.loading,
165
- pastDelay: state.pastDelay,
166
- timedOut: state.timedOut,
167
- error: state.error,
168
- retry: subscription.retry
169
- });
170
- } else if (state.loaded) {
171
- return /* @__PURE__ */ _react.default.createElement(resolve(state.loaded), props);
172
- } else {
173
- return null;
174
- }
175
- }, [
176
- props,
177
- state
178
- ]);
179
- }
180
- LoadableComponent.preload = () => init();
181
- LoadableComponent.displayName = "LoadableComponent";
182
- return /* @__PURE__ */ _react.default.forwardRef(LoadableComponent);
183
- }
184
- var LoadableSubscription = class {
185
- promise() {
186
- return this._res.promise;
187
- }
188
- retry() {
189
- this._clearTimeouts();
190
- this._res = this._loadFn(this._opts.loader);
191
- this._state = {
192
- pastDelay: false,
193
- timedOut: false
194
- };
195
- const { _res: res, _opts: opts } = this;
196
- if (res.loading) {
197
- if (typeof opts.delay === "number") {
198
- if (opts.delay === 0) {
199
- this._state.pastDelay = true;
200
- } else {
201
- this._delay = setTimeout(() => {
202
- this._update({
203
- pastDelay: true
204
- });
205
- }, opts.delay);
206
- }
207
- }
208
- if (typeof opts.timeout === "number") {
209
- this._timeout = setTimeout(() => {
210
- this._update({
211
- timedOut: true
212
- });
213
- }, opts.timeout);
214
- }
215
- }
216
- this._res.promise.then(() => {
217
- this._update({});
218
- this._clearTimeouts();
219
- }).catch((_err) => {
220
- this._update({});
221
- this._clearTimeouts();
222
- });
223
- this._update({});
224
- }
225
- _update(partial) {
226
- this._state = {
227
- ...this._state,
228
- error: this._res.error,
229
- loaded: this._res.loaded,
230
- loading: this._res.loading,
231
- ...partial
232
- };
233
- this._callbacks.forEach((callback) => callback());
234
- }
235
- _clearTimeouts() {
236
- clearTimeout(this._delay);
237
- clearTimeout(this._timeout);
238
- }
239
- getCurrentValue() {
240
- return this._state;
241
- }
242
- subscribe(callback) {
243
- this._callbacks.add(callback);
244
- return () => {
245
- this._callbacks.delete(callback);
246
- };
247
- }
248
- constructor(loadFn, opts) {
249
- this._loadFn = loadFn;
250
- this._opts = opts;
251
- this._callbacks = /* @__PURE__ */ new Set();
252
- this._delay = null;
253
- this._timeout = null;
254
- this.retry();
255
- }
256
- };
257
- function Loadable(opts) {
258
- return createLoadableComponent(load, opts);
259
- }
260
- function flushInitializers(initializers, ids) {
261
- let promises = [];
262
- while (initializers.length) {
263
- let init = initializers.pop();
264
- promises.push(init(ids));
265
- }
266
- return Promise.all(promises).then(() => {
267
- if (initializers.length) {
268
- return flushInitializers(initializers, ids);
269
- }
270
- });
271
- }
272
- Loadable.preloadAll = () => {
273
- return new Promise((resolveInitializers, reject) => {
274
- flushInitializers(ALL_INITIALIZERS).then(resolveInitializers, reject);
275
- });
276
- };
277
- Loadable.preloadReady = (ids) => {
278
- if (ids === void 0) ids = [];
279
- return new Promise((resolvePreload) => {
280
- const res = () => {
281
- initialized = true;
282
- return resolvePreload();
283
- };
284
- flushInitializers(READY_INITIALIZERS, ids).then(res, res);
285
- });
45
+ // node_modules/@tanstack/query-core/build/modern/subscribable.js
46
+ var Subscribable = class {
47
+ constructor() {
48
+ this.listeners = /* @__PURE__ */ new Set();
49
+ this.subscribe = this.subscribe.bind(this);
50
+ }
51
+ subscribe(listener) {
52
+ this.listeners.add(listener);
53
+ this.onSubscribe();
54
+ return () => {
55
+ this.listeners.delete(listener);
56
+ this.onUnsubscribe();
286
57
  };
287
- if (typeof window !== "undefined") {
288
- window.__NEXT_PRELOADREADY = Loadable.preloadReady;
289
- }
290
- var _default = Loadable;
291
58
  }
292
- });
59
+ hasListeners() {
60
+ return this.listeners.size > 0;
61
+ }
62
+ onSubscribe() {
63
+ }
64
+ onUnsubscribe() {
65
+ }
66
+ };
293
67
 
294
- // ../../../../node_modules/next/dist/shared/lib/dynamic.js
295
- var require_dynamic = __commonJS({
296
- "../../../../node_modules/next/dist/shared/lib/dynamic.js"(exports2, module2) {
297
- "use strict";
298
- Object.defineProperty(exports2, "__esModule", {
299
- value: true
300
- });
301
- function _export(target, all) {
302
- for (var name in all) Object.defineProperty(target, name, {
303
- enumerable: true,
304
- get: all[name]
305
- });
306
- }
307
- _export(exports2, {
308
- /**
309
- * This function lets you dynamically import a component.
310
- * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
311
- *
312
- * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)
313
- */
314
- default: function() {
315
- return dynamic2;
316
- },
317
- noSSR: function() {
318
- return noSSR;
319
- }
320
- });
321
- var _interop_require_default = require_interop_require_default();
322
- var _jsxruntime = require("react/jsx-runtime");
323
- var _react = /* @__PURE__ */ _interop_require_default._(require("react"));
324
- var _loadablesharedruntime = /* @__PURE__ */ _interop_require_default._(require_loadable_shared_runtime());
325
- var isServerSide = typeof window === "undefined";
326
- function convertModule(mod) {
327
- return {
328
- default: (mod == null ? void 0 : mod.default) || mod
329
- };
330
- }
331
- function noSSR(LoadableInitializer, loadableOptions) {
332
- delete loadableOptions.webpack;
333
- delete loadableOptions.modules;
334
- if (!isServerSide) {
335
- return LoadableInitializer(loadableOptions);
68
+ // node_modules/@tanstack/query-core/build/modern/timeoutManager.js
69
+ var defaultTimeoutProvider = {
70
+ // We need the wrapper function syntax below instead of direct references to
71
+ // global setTimeout etc.
72
+ //
73
+ // BAD: `setTimeout: setTimeout`
74
+ // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
75
+ //
76
+ // If we use direct references here, then anything that wants to spy on or
77
+ // replace the global setTimeout (like tests) won't work since we'll already
78
+ // have a hard reference to the original implementation at the time when this
79
+ // file was imported.
80
+ setTimeout: (callback, delay) => setTimeout(callback, delay),
81
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
82
+ setInterval: (callback, delay) => setInterval(callback, delay),
83
+ clearInterval: (intervalId) => clearInterval(intervalId)
84
+ };
85
+ var TimeoutManager = class {
86
+ // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
87
+ // type at app boot; and if we leave that type, then any new timer provider
88
+ // would need to support ReturnType<typeof setTimeout>, which is infeasible.
89
+ //
90
+ // We settle for type safety for the TimeoutProvider type, and accept that
91
+ // this class is unsafe internally to allow for extension.
92
+ #provider = defaultTimeoutProvider;
93
+ #providerCalled = false;
94
+ setTimeoutProvider(provider) {
95
+ if (process.env.NODE_ENV !== "production") {
96
+ if (this.#providerCalled && provider !== this.#provider) {
97
+ console.error(
98
+ `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
99
+ { previous: this.#provider, provider }
100
+ );
336
101
  }
337
- const Loading = loadableOptions.loading;
338
- return () => /* @__PURE__ */ (0, _jsxruntime.jsx)(Loading, {
339
- error: null,
340
- isLoading: true,
341
- pastDelay: false,
342
- timedOut: false
343
- });
344
102
  }
345
- function dynamic2(dynamicOptions, options) {
346
- let loadableFn = _loadablesharedruntime.default;
347
- let loadableOptions = {
348
- // A loading component is not required, so we default it
349
- loading: (param) => {
350
- let { error, isLoading, pastDelay } = param;
351
- if (!pastDelay) return null;
352
- if (process.env.NODE_ENV !== "production") {
353
- if (isLoading) {
354
- return null;
355
- }
356
- if (error) {
357
- return /* @__PURE__ */ (0, _jsxruntime.jsxs)("p", {
358
- children: [
359
- error.message,
360
- /* @__PURE__ */ (0, _jsxruntime.jsx)("br", {}),
361
- error.stack
362
- ]
363
- });
364
- }
365
- }
366
- return null;
367
- }
368
- };
369
- if (dynamicOptions instanceof Promise) {
370
- loadableOptions.loader = () => dynamicOptions;
371
- } else if (typeof dynamicOptions === "function") {
372
- loadableOptions.loader = dynamicOptions;
373
- } else if (typeof dynamicOptions === "object") {
374
- loadableOptions = {
375
- ...loadableOptions,
376
- ...dynamicOptions
377
- };
378
- }
379
- loadableOptions = {
380
- ...loadableOptions,
381
- ...options
382
- };
383
- const loaderFn = loadableOptions.loader;
384
- const loader = () => loaderFn != null ? loaderFn().then(convertModule) : Promise.resolve(convertModule(() => null));
385
- if (loadableOptions.loadableGenerated) {
386
- loadableOptions = {
387
- ...loadableOptions,
388
- ...loadableOptions.loadableGenerated
389
- };
390
- delete loadableOptions.loadableGenerated;
391
- }
392
- if (typeof loadableOptions.ssr === "boolean" && !loadableOptions.ssr) {
393
- delete loadableOptions.webpack;
394
- delete loadableOptions.modules;
395
- return noSSR(loadableFn, loadableOptions);
396
- }
397
- return loadableFn({
398
- ...loadableOptions,
399
- loader
400
- });
103
+ this.#provider = provider;
104
+ if (process.env.NODE_ENV !== "production") {
105
+ this.#providerCalled = false;
401
106
  }
402
- if ((typeof exports2.default === "function" || typeof exports2.default === "object" && exports2.default !== null) && typeof exports2.default.__esModule === "undefined") {
403
- Object.defineProperty(exports2.default, "__esModule", { value: true });
404
- Object.assign(exports2.default, exports2);
405
- module2.exports = exports2.default;
107
+ }
108
+ setTimeout(callback, delay) {
109
+ if (process.env.NODE_ENV !== "production") {
110
+ this.#providerCalled = true;
406
111
  }
112
+ return this.#provider.setTimeout(callback, delay);
407
113
  }
408
- });
409
-
410
- // ../../../../node_modules/next/dynamic.js
411
- var require_dynamic2 = __commonJS({
412
- "../../../../node_modules/next/dynamic.js"(exports2, module2) {
413
- module2.exports = require_dynamic();
114
+ clearTimeout(timeoutId) {
115
+ this.#provider.clearTimeout(timeoutId);
414
116
  }
415
- });
416
-
417
- // node_modules/@tanstack/query-core/build/modern/subscribable.js
418
- var Subscribable;
419
- var init_subscribable = __esm({
420
- "node_modules/@tanstack/query-core/build/modern/subscribable.js"() {
421
- Subscribable = class {
422
- constructor() {
423
- this.listeners = /* @__PURE__ */ new Set();
424
- this.subscribe = this.subscribe.bind(this);
425
- }
426
- subscribe(listener) {
427
- this.listeners.add(listener);
428
- this.onSubscribe();
429
- return () => {
430
- this.listeners.delete(listener);
431
- this.onUnsubscribe();
432
- };
433
- }
434
- hasListeners() {
435
- return this.listeners.size > 0;
436
- }
437
- onSubscribe() {
438
- }
439
- onUnsubscribe() {
440
- }
441
- };
117
+ setInterval(callback, delay) {
118
+ if (process.env.NODE_ENV !== "production") {
119
+ this.#providerCalled = true;
120
+ }
121
+ return this.#provider.setInterval(callback, delay);
442
122
  }
443
- });
444
-
445
- // node_modules/@tanstack/query-core/build/modern/timeoutManager.js
123
+ clearInterval(intervalId) {
124
+ this.#provider.clearInterval(intervalId);
125
+ }
126
+ };
127
+ var timeoutManager = new TimeoutManager();
446
128
  function systemSetTimeoutZero(callback) {
447
129
  setTimeout(callback, 0);
448
130
  }
449
- var defaultTimeoutProvider, TimeoutManager, timeoutManager;
450
- var init_timeoutManager = __esm({
451
- "node_modules/@tanstack/query-core/build/modern/timeoutManager.js"() {
452
- defaultTimeoutProvider = {
453
- // We need the wrapper function syntax below instead of direct references to
454
- // global setTimeout etc.
455
- //
456
- // BAD: `setTimeout: setTimeout`
457
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
458
- //
459
- // If we use direct references here, then anything that wants to spy on or
460
- // replace the global setTimeout (like tests) won't work since we'll already
461
- // have a hard reference to the original implementation at the time when this
462
- // file was imported.
463
- setTimeout: (callback, delay) => setTimeout(callback, delay),
464
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
465
- setInterval: (callback, delay) => setInterval(callback, delay),
466
- clearInterval: (intervalId) => clearInterval(intervalId)
467
- };
468
- TimeoutManager = class {
469
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
470
- // type at app boot; and if we leave that type, then any new timer provider
471
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
472
- //
473
- // We settle for type safety for the TimeoutProvider type, and accept that
474
- // this class is unsafe internally to allow for extension.
475
- #provider = defaultTimeoutProvider;
476
- #providerCalled = false;
477
- setTimeoutProvider(provider) {
478
- if (process.env.NODE_ENV !== "production") {
479
- if (this.#providerCalled && provider !== this.#provider) {
480
- console.error(
481
- `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
482
- { previous: this.#provider, provider }
483
- );
484
- }
485
- }
486
- this.#provider = provider;
487
- if (process.env.NODE_ENV !== "production") {
488
- this.#providerCalled = false;
489
- }
490
- }
491
- setTimeout(callback, delay) {
492
- if (process.env.NODE_ENV !== "production") {
493
- this.#providerCalled = true;
494
- }
495
- return this.#provider.setTimeout(callback, delay);
496
- }
497
- clearTimeout(timeoutId) {
498
- this.#provider.clearTimeout(timeoutId);
499
- }
500
- setInterval(callback, delay) {
501
- if (process.env.NODE_ENV !== "production") {
502
- this.#providerCalled = true;
503
- }
504
- return this.#provider.setInterval(callback, delay);
505
- }
506
- clearInterval(intervalId) {
507
- this.#provider.clearInterval(intervalId);
508
- }
509
- };
510
- timeoutManager = new TimeoutManager();
511
- }
512
- });
513
131
 
514
132
  // node_modules/@tanstack/query-core/build/modern/utils.js
133
+ var isServer = typeof window === "undefined" || "Deno" in globalThis;
515
134
  function noop() {
516
135
  }
517
136
  function functionalUpdate(updater, input) {
@@ -614,6 +233,7 @@ function partialMatchKey(a, b) {
614
233
  }
615
234
  return false;
616
235
  }
236
+ var hasOwn = Object.prototype.hasOwnProperty;
617
237
  function replaceEqualDeep(a, b) {
618
238
  if (a === b) {
619
239
  return a;
@@ -702,6 +322,7 @@ function addToStart(items, item, max = 0) {
702
322
  const newItems = [item, ...items];
703
323
  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
704
324
  }
325
+ var skipToken = Symbol();
705
326
  function ensureQueryFn(options, fetchOptions) {
706
327
  if (process.env.NODE_ENV !== "production") {
707
328
  if (options.queryFn === skipToken) {
@@ -718,84 +339,68 @@ function ensureQueryFn(options, fetchOptions) {
718
339
  }
719
340
  return options.queryFn;
720
341
  }
721
- var isServer, hasOwn, skipToken;
722
- var init_utils = __esm({
723
- "node_modules/@tanstack/query-core/build/modern/utils.js"() {
724
- init_timeoutManager();
725
- isServer = typeof window === "undefined" || "Deno" in globalThis;
726
- hasOwn = Object.prototype.hasOwnProperty;
727
- skipToken = Symbol();
728
- }
729
- });
730
342
 
731
343
  // node_modules/@tanstack/query-core/build/modern/focusManager.js
732
- var FocusManager, focusManager;
733
- var init_focusManager = __esm({
734
- "node_modules/@tanstack/query-core/build/modern/focusManager.js"() {
735
- init_subscribable();
736
- init_utils();
737
- FocusManager = class extends Subscribable {
738
- #focused;
739
- #cleanup;
740
- #setup;
741
- constructor() {
742
- super();
743
- this.#setup = (onFocus) => {
744
- if (!isServer && window.addEventListener) {
745
- const listener = () => onFocus();
746
- window.addEventListener("visibilitychange", listener, false);
747
- return () => {
748
- window.removeEventListener("visibilitychange", listener);
749
- };
750
- }
751
- return;
344
+ var FocusManager = class extends Subscribable {
345
+ #focused;
346
+ #cleanup;
347
+ #setup;
348
+ constructor() {
349
+ super();
350
+ this.#setup = (onFocus) => {
351
+ if (!isServer && window.addEventListener) {
352
+ const listener = () => onFocus();
353
+ window.addEventListener("visibilitychange", listener, false);
354
+ return () => {
355
+ window.removeEventListener("visibilitychange", listener);
752
356
  };
753
357
  }
754
- onSubscribe() {
755
- if (!this.#cleanup) {
756
- this.setEventListener(this.#setup);
757
- }
758
- }
759
- onUnsubscribe() {
760
- if (!this.hasListeners()) {
761
- this.#cleanup?.();
762
- this.#cleanup = void 0;
763
- }
764
- }
765
- setEventListener(setup) {
766
- this.#setup = setup;
767
- this.#cleanup?.();
768
- this.#cleanup = setup((focused) => {
769
- if (typeof focused === "boolean") {
770
- this.setFocused(focused);
771
- } else {
772
- this.onFocus();
773
- }
774
- });
775
- }
776
- setFocused(focused) {
777
- const changed = this.#focused !== focused;
778
- if (changed) {
779
- this.#focused = focused;
780
- this.onFocus();
781
- }
782
- }
783
- onFocus() {
784
- const isFocused = this.isFocused();
785
- this.listeners.forEach((listener) => {
786
- listener(isFocused);
787
- });
788
- }
789
- isFocused() {
790
- if (typeof this.#focused === "boolean") {
791
- return this.#focused;
792
- }
793
- return globalThis.document?.visibilityState !== "hidden";
794
- }
358
+ return;
795
359
  };
796
- focusManager = new FocusManager();
797
360
  }
798
- });
361
+ onSubscribe() {
362
+ if (!this.#cleanup) {
363
+ this.setEventListener(this.#setup);
364
+ }
365
+ }
366
+ onUnsubscribe() {
367
+ if (!this.hasListeners()) {
368
+ this.#cleanup?.();
369
+ this.#cleanup = void 0;
370
+ }
371
+ }
372
+ setEventListener(setup) {
373
+ this.#setup = setup;
374
+ this.#cleanup?.();
375
+ this.#cleanup = setup((focused) => {
376
+ if (typeof focused === "boolean") {
377
+ this.setFocused(focused);
378
+ } else {
379
+ this.onFocus();
380
+ }
381
+ });
382
+ }
383
+ setFocused(focused) {
384
+ const changed = this.#focused !== focused;
385
+ if (changed) {
386
+ this.#focused = focused;
387
+ this.onFocus();
388
+ }
389
+ }
390
+ onFocus() {
391
+ const isFocused = this.isFocused();
392
+ this.listeners.forEach((listener) => {
393
+ listener(isFocused);
394
+ });
395
+ }
396
+ isFocused() {
397
+ if (typeof this.#focused === "boolean") {
398
+ return this.#focused;
399
+ }
400
+ return globalThis.document?.visibilityState !== "hidden";
401
+ }
402
+ };
403
+ var focusManager = new FocusManager();
799
404
 
800
405
  // node_modules/@tanstack/query-core/build/modern/thenable.js
801
406
  function pendingThenable() {
@@ -829,12 +434,9 @@ function pendingThenable() {
829
434
  };
830
435
  return thenable;
831
436
  }
832
- var init_thenable = __esm({
833
- "node_modules/@tanstack/query-core/build/modern/thenable.js"() {
834
- }
835
- });
836
437
 
837
438
  // node_modules/@tanstack/query-core/build/modern/notifyManager.js
439
+ var defaultScheduler = systemSetTimeoutZero;
838
440
  function createNotifyManager() {
839
441
  let queue = [];
840
442
  let transactions = 0;
@@ -911,73 +513,59 @@ function createNotifyManager() {
911
513
  }
912
514
  };
913
515
  }
914
- var defaultScheduler, notifyManager;
915
- var init_notifyManager = __esm({
916
- "node_modules/@tanstack/query-core/build/modern/notifyManager.js"() {
917
- init_timeoutManager();
918
- defaultScheduler = systemSetTimeoutZero;
919
- notifyManager = createNotifyManager();
920
- }
921
- });
516
+ var notifyManager = createNotifyManager();
922
517
 
923
518
  // node_modules/@tanstack/query-core/build/modern/onlineManager.js
924
- var OnlineManager, onlineManager;
925
- var init_onlineManager = __esm({
926
- "node_modules/@tanstack/query-core/build/modern/onlineManager.js"() {
927
- init_subscribable();
928
- init_utils();
929
- OnlineManager = class extends Subscribable {
930
- #online = true;
931
- #cleanup;
932
- #setup;
933
- constructor() {
934
- super();
935
- this.#setup = (onOnline) => {
936
- if (!isServer && window.addEventListener) {
937
- const onlineListener = () => onOnline(true);
938
- const offlineListener = () => onOnline(false);
939
- window.addEventListener("online", onlineListener, false);
940
- window.addEventListener("offline", offlineListener, false);
941
- return () => {
942
- window.removeEventListener("online", onlineListener);
943
- window.removeEventListener("offline", offlineListener);
944
- };
945
- }
946
- return;
519
+ var OnlineManager = class extends Subscribable {
520
+ #online = true;
521
+ #cleanup;
522
+ #setup;
523
+ constructor() {
524
+ super();
525
+ this.#setup = (onOnline) => {
526
+ if (!isServer && window.addEventListener) {
527
+ const onlineListener = () => onOnline(true);
528
+ const offlineListener = () => onOnline(false);
529
+ window.addEventListener("online", onlineListener, false);
530
+ window.addEventListener("offline", offlineListener, false);
531
+ return () => {
532
+ window.removeEventListener("online", onlineListener);
533
+ window.removeEventListener("offline", offlineListener);
947
534
  };
948
535
  }
949
- onSubscribe() {
950
- if (!this.#cleanup) {
951
- this.setEventListener(this.#setup);
952
- }
953
- }
954
- onUnsubscribe() {
955
- if (!this.hasListeners()) {
956
- this.#cleanup?.();
957
- this.#cleanup = void 0;
958
- }
959
- }
960
- setEventListener(setup) {
961
- this.#setup = setup;
962
- this.#cleanup?.();
963
- this.#cleanup = setup(this.setOnline.bind(this));
964
- }
965
- setOnline(online) {
966
- const changed = this.#online !== online;
967
- if (changed) {
968
- this.#online = online;
969
- this.listeners.forEach((listener) => {
970
- listener(online);
971
- });
972
- }
973
- }
974
- isOnline() {
975
- return this.#online;
976
- }
536
+ return;
977
537
  };
978
- onlineManager = new OnlineManager();
979
538
  }
980
- });
539
+ onSubscribe() {
540
+ if (!this.#cleanup) {
541
+ this.setEventListener(this.#setup);
542
+ }
543
+ }
544
+ onUnsubscribe() {
545
+ if (!this.hasListeners()) {
546
+ this.#cleanup?.();
547
+ this.#cleanup = void 0;
548
+ }
549
+ }
550
+ setEventListener(setup) {
551
+ this.#setup = setup;
552
+ this.#cleanup?.();
553
+ this.#cleanup = setup(this.setOnline.bind(this));
554
+ }
555
+ setOnline(online) {
556
+ const changed = this.#online !== online;
557
+ if (changed) {
558
+ this.#online = online;
559
+ this.listeners.forEach((listener) => {
560
+ listener(online);
561
+ });
562
+ }
563
+ }
564
+ isOnline() {
565
+ return this.#online;
566
+ }
567
+ };
568
+ var onlineManager = new OnlineManager();
981
569
 
982
570
  // node_modules/@tanstack/query-core/build/modern/retryer.js
983
571
  function defaultRetryDelay(failureCount) {
@@ -986,6 +574,13 @@ function defaultRetryDelay(failureCount) {
986
574
  function canFetch(networkMode) {
987
575
  return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
988
576
  }
577
+ var CancelledError = class extends Error {
578
+ constructor(options) {
579
+ super("CancelledError");
580
+ this.revert = options?.revert;
581
+ this.silent = options?.silent;
582
+ }
583
+ };
989
584
  function createRetryer(config2) {
990
585
  let isRetryCancelled = false;
991
586
  let failureCount = 0;
@@ -1091,477 +686,445 @@ function createRetryer(config2) {
1091
686
  }
1092
687
  };
1093
688
  }
1094
- var CancelledError;
1095
- var init_retryer = __esm({
1096
- "node_modules/@tanstack/query-core/build/modern/retryer.js"() {
1097
- init_focusManager();
1098
- init_onlineManager();
1099
- init_thenable();
1100
- init_utils();
1101
- CancelledError = class extends Error {
1102
- constructor(options) {
1103
- super("CancelledError");
1104
- this.revert = options?.revert;
1105
- this.silent = options?.silent;
1106
- }
1107
- };
1108
- }
1109
- });
1110
689
 
1111
690
  // node_modules/@tanstack/query-core/build/modern/removable.js
1112
- var Removable;
1113
- var init_removable = __esm({
1114
- "node_modules/@tanstack/query-core/build/modern/removable.js"() {
1115
- init_timeoutManager();
1116
- init_utils();
1117
- Removable = class {
1118
- #gcTimeout;
1119
- destroy() {
1120
- this.clearGcTimeout();
1121
- }
1122
- scheduleGc() {
1123
- this.clearGcTimeout();
1124
- if (isValidTimeout(this.gcTime)) {
1125
- this.#gcTimeout = timeoutManager.setTimeout(() => {
1126
- this.optionalRemove();
1127
- }, this.gcTime);
1128
- }
1129
- }
1130
- updateGcTime(newGcTime) {
1131
- this.gcTime = Math.max(
1132
- this.gcTime || 0,
1133
- newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
1134
- );
1135
- }
1136
- clearGcTimeout() {
1137
- if (this.#gcTimeout) {
1138
- timeoutManager.clearTimeout(this.#gcTimeout);
1139
- this.#gcTimeout = void 0;
1140
- }
1141
- }
1142
- };
691
+ var Removable = class {
692
+ #gcTimeout;
693
+ destroy() {
694
+ this.clearGcTimeout();
695
+ }
696
+ scheduleGc() {
697
+ this.clearGcTimeout();
698
+ if (isValidTimeout(this.gcTime)) {
699
+ this.#gcTimeout = timeoutManager.setTimeout(() => {
700
+ this.optionalRemove();
701
+ }, this.gcTime);
702
+ }
1143
703
  }
1144
- });
704
+ updateGcTime(newGcTime) {
705
+ this.gcTime = Math.max(
706
+ this.gcTime || 0,
707
+ newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
708
+ );
709
+ }
710
+ clearGcTimeout() {
711
+ if (this.#gcTimeout) {
712
+ timeoutManager.clearTimeout(this.#gcTimeout);
713
+ this.#gcTimeout = void 0;
714
+ }
715
+ }
716
+ };
1145
717
 
1146
718
  // node_modules/@tanstack/query-core/build/modern/query.js
1147
- function fetchState(data, options) {
1148
- return {
1149
- fetchFailureCount: 0,
1150
- fetchFailureReason: null,
1151
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1152
- ...data === void 0 && {
1153
- error: null,
1154
- status: "pending"
719
+ var Query = class extends Removable {
720
+ #initialState;
721
+ #revertState;
722
+ #cache;
723
+ #client;
724
+ #retryer;
725
+ #defaultOptions;
726
+ #abortSignalConsumed;
727
+ constructor(config2) {
728
+ super();
729
+ this.#abortSignalConsumed = false;
730
+ this.#defaultOptions = config2.defaultOptions;
731
+ this.setOptions(config2.options);
732
+ this.observers = [];
733
+ this.#client = config2.client;
734
+ this.#cache = this.#client.getQueryCache();
735
+ this.queryKey = config2.queryKey;
736
+ this.queryHash = config2.queryHash;
737
+ this.#initialState = getDefaultState(this.options);
738
+ this.state = config2.state ?? this.#initialState;
739
+ this.scheduleGc();
740
+ }
741
+ get meta() {
742
+ return this.options.meta;
743
+ }
744
+ get promise() {
745
+ return this.#retryer?.promise;
746
+ }
747
+ setOptions(options) {
748
+ this.options = { ...this.#defaultOptions, ...options };
749
+ this.updateGcTime(this.options.gcTime);
750
+ if (this.state && this.state.data === void 0) {
751
+ const defaultState = getDefaultState(this.options);
752
+ if (defaultState.data !== void 0) {
753
+ this.setData(defaultState.data, {
754
+ updatedAt: defaultState.dataUpdatedAt,
755
+ manual: true
756
+ });
757
+ this.#initialState = defaultState;
758
+ }
1155
759
  }
1156
- };
1157
- }
1158
- function getDefaultState(options) {
1159
- const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
1160
- const hasData = data !== void 0;
1161
- const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
1162
- return {
1163
- data,
1164
- dataUpdateCount: 0,
1165
- dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
1166
- error: null,
1167
- errorUpdateCount: 0,
1168
- errorUpdatedAt: 0,
1169
- fetchFailureCount: 0,
1170
- fetchFailureReason: null,
1171
- fetchMeta: null,
1172
- isInvalidated: false,
1173
- status: hasData ? "success" : "pending",
1174
- fetchStatus: "idle"
1175
- };
1176
- }
1177
- var Query;
1178
- var init_query = __esm({
1179
- "node_modules/@tanstack/query-core/build/modern/query.js"() {
1180
- init_utils();
1181
- init_notifyManager();
1182
- init_retryer();
1183
- init_removable();
1184
- Query = class extends Removable {
1185
- #initialState;
1186
- #revertState;
1187
- #cache;
1188
- #client;
1189
- #retryer;
1190
- #defaultOptions;
1191
- #abortSignalConsumed;
1192
- constructor(config2) {
1193
- super();
1194
- this.#abortSignalConsumed = false;
1195
- this.#defaultOptions = config2.defaultOptions;
1196
- this.setOptions(config2.options);
1197
- this.observers = [];
1198
- this.#client = config2.client;
1199
- this.#cache = this.#client.getQueryCache();
1200
- this.queryKey = config2.queryKey;
1201
- this.queryHash = config2.queryHash;
1202
- this.#initialState = getDefaultState(this.options);
1203
- this.state = config2.state ?? this.#initialState;
1204
- this.scheduleGc();
1205
- }
1206
- get meta() {
1207
- return this.options.meta;
1208
- }
1209
- get promise() {
1210
- return this.#retryer?.promise;
1211
- }
1212
- setOptions(options) {
1213
- this.options = { ...this.#defaultOptions, ...options };
1214
- this.updateGcTime(this.options.gcTime);
1215
- if (this.state && this.state.data === void 0) {
1216
- const defaultState = getDefaultState(this.options);
1217
- if (defaultState.data !== void 0) {
1218
- this.setData(defaultState.data, {
1219
- updatedAt: defaultState.dataUpdatedAt,
1220
- manual: true
1221
- });
1222
- this.#initialState = defaultState;
760
+ }
761
+ optionalRemove() {
762
+ if (!this.observers.length && this.state.fetchStatus === "idle") {
763
+ this.#cache.remove(this);
764
+ }
765
+ }
766
+ setData(newData, options) {
767
+ const data = replaceData(this.state.data, newData, this.options);
768
+ this.#dispatch({
769
+ data,
770
+ type: "success",
771
+ dataUpdatedAt: options?.updatedAt,
772
+ manual: options?.manual
773
+ });
774
+ return data;
775
+ }
776
+ setState(state, setStateOptions) {
777
+ this.#dispatch({ type: "setState", state, setStateOptions });
778
+ }
779
+ cancel(options) {
780
+ const promise = this.#retryer?.promise;
781
+ this.#retryer?.cancel(options);
782
+ return promise ? promise.then(noop).catch(noop) : Promise.resolve();
783
+ }
784
+ destroy() {
785
+ super.destroy();
786
+ this.cancel({ silent: true });
787
+ }
788
+ reset() {
789
+ this.destroy();
790
+ this.setState(this.#initialState);
791
+ }
792
+ isActive() {
793
+ return this.observers.some(
794
+ (observer) => resolveEnabled(observer.options.enabled, this) !== false
795
+ );
796
+ }
797
+ isDisabled() {
798
+ if (this.getObserversCount() > 0) {
799
+ return !this.isActive();
800
+ }
801
+ return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
802
+ }
803
+ isStatic() {
804
+ if (this.getObserversCount() > 0) {
805
+ return this.observers.some(
806
+ (observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
807
+ );
808
+ }
809
+ return false;
810
+ }
811
+ isStale() {
812
+ if (this.getObserversCount() > 0) {
813
+ return this.observers.some(
814
+ (observer) => observer.getCurrentResult().isStale
815
+ );
816
+ }
817
+ return this.state.data === void 0 || this.state.isInvalidated;
818
+ }
819
+ isStaleByTime(staleTime = 0) {
820
+ if (this.state.data === void 0) {
821
+ return true;
822
+ }
823
+ if (staleTime === "static") {
824
+ return false;
825
+ }
826
+ if (this.state.isInvalidated) {
827
+ return true;
828
+ }
829
+ return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
830
+ }
831
+ onFocus() {
832
+ const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
833
+ observer?.refetch({ cancelRefetch: false });
834
+ this.#retryer?.continue();
835
+ }
836
+ onOnline() {
837
+ const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
838
+ observer?.refetch({ cancelRefetch: false });
839
+ this.#retryer?.continue();
840
+ }
841
+ addObserver(observer) {
842
+ if (!this.observers.includes(observer)) {
843
+ this.observers.push(observer);
844
+ this.clearGcTimeout();
845
+ this.#cache.notify({ type: "observerAdded", query: this, observer });
846
+ }
847
+ }
848
+ removeObserver(observer) {
849
+ if (this.observers.includes(observer)) {
850
+ this.observers = this.observers.filter((x) => x !== observer);
851
+ if (!this.observers.length) {
852
+ if (this.#retryer) {
853
+ if (this.#abortSignalConsumed) {
854
+ this.#retryer.cancel({ revert: true });
855
+ } else {
856
+ this.#retryer.cancelRetry();
1223
857
  }
1224
858
  }
859
+ this.scheduleGc();
1225
860
  }
1226
- optionalRemove() {
1227
- if (!this.observers.length && this.state.fetchStatus === "idle") {
1228
- this.#cache.remove(this);
1229
- }
1230
- }
1231
- setData(newData, options) {
1232
- const data = replaceData(this.state.data, newData, this.options);
1233
- this.#dispatch({
1234
- data,
1235
- type: "success",
1236
- dataUpdatedAt: options?.updatedAt,
1237
- manual: options?.manual
1238
- });
1239
- return data;
1240
- }
1241
- setState(state, setStateOptions) {
1242
- this.#dispatch({ type: "setState", state, setStateOptions });
1243
- }
1244
- cancel(options) {
1245
- const promise = this.#retryer?.promise;
1246
- this.#retryer?.cancel(options);
1247
- return promise ? promise.then(noop).catch(noop) : Promise.resolve();
1248
- }
1249
- destroy() {
1250
- super.destroy();
861
+ this.#cache.notify({ type: "observerRemoved", query: this, observer });
862
+ }
863
+ }
864
+ getObserversCount() {
865
+ return this.observers.length;
866
+ }
867
+ invalidate() {
868
+ if (!this.state.isInvalidated) {
869
+ this.#dispatch({ type: "invalidate" });
870
+ }
871
+ }
872
+ async fetch(options, fetchOptions) {
873
+ if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
874
+ // re-start the fetch; there is a chance that the query is still in a
875
+ // pending state when that happens
876
+ this.#retryer?.status() !== "rejected") {
877
+ if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
1251
878
  this.cancel({ silent: true });
879
+ } else if (this.#retryer) {
880
+ this.#retryer.continueRetry();
881
+ return this.#retryer.promise;
1252
882
  }
1253
- reset() {
1254
- this.destroy();
1255
- this.setState(this.#initialState);
883
+ }
884
+ if (options) {
885
+ this.setOptions(options);
886
+ }
887
+ if (!this.options.queryFn) {
888
+ const observer = this.observers.find((x) => x.options.queryFn);
889
+ if (observer) {
890
+ this.setOptions(observer.options);
1256
891
  }
1257
- isActive() {
1258
- return this.observers.some(
1259
- (observer) => resolveEnabled(observer.options.enabled, this) !== false
892
+ }
893
+ if (process.env.NODE_ENV !== "production") {
894
+ if (!Array.isArray(this.options.queryKey)) {
895
+ console.error(
896
+ `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']`
1260
897
  );
1261
898
  }
1262
- isDisabled() {
1263
- if (this.getObserversCount() > 0) {
1264
- return !this.isActive();
899
+ }
900
+ const abortController = new AbortController();
901
+ const addSignalProperty = (object) => {
902
+ Object.defineProperty(object, "signal", {
903
+ enumerable: true,
904
+ get: () => {
905
+ this.#abortSignalConsumed = true;
906
+ return abortController.signal;
1265
907
  }
1266
- return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
908
+ });
909
+ };
910
+ const fetchFn = () => {
911
+ const queryFn = ensureQueryFn(this.options, fetchOptions);
912
+ const createQueryFnContext = () => {
913
+ const queryFnContext2 = {
914
+ client: this.#client,
915
+ queryKey: this.queryKey,
916
+ meta: this.meta
917
+ };
918
+ addSignalProperty(queryFnContext2);
919
+ return queryFnContext2;
920
+ };
921
+ const queryFnContext = createQueryFnContext();
922
+ this.#abortSignalConsumed = false;
923
+ if (this.options.persister) {
924
+ return this.options.persister(
925
+ queryFn,
926
+ queryFnContext,
927
+ this
928
+ );
1267
929
  }
1268
- isStatic() {
1269
- if (this.getObserversCount() > 0) {
1270
- return this.observers.some(
1271
- (observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
1272
- );
930
+ return queryFn(queryFnContext);
931
+ };
932
+ const createFetchContext = () => {
933
+ const context2 = {
934
+ fetchOptions,
935
+ options: this.options,
936
+ queryKey: this.queryKey,
937
+ client: this.#client,
938
+ state: this.state,
939
+ fetchFn
940
+ };
941
+ addSignalProperty(context2);
942
+ return context2;
943
+ };
944
+ const context = createFetchContext();
945
+ this.options.behavior?.onFetch(context, this);
946
+ this.#revertState = this.state;
947
+ if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
948
+ this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
949
+ }
950
+ this.#retryer = createRetryer({
951
+ initialPromise: fetchOptions?.initialPromise,
952
+ fn: context.fetchFn,
953
+ onCancel: (error) => {
954
+ if (error instanceof CancelledError && error.revert) {
955
+ this.setState({
956
+ ...this.#revertState,
957
+ fetchStatus: "idle"
958
+ });
1273
959
  }
1274
- return false;
1275
- }
1276
- isStale() {
1277
- if (this.getObserversCount() > 0) {
1278
- return this.observers.some(
1279
- (observer) => observer.getCurrentResult().isStale
960
+ abortController.abort();
961
+ },
962
+ onFail: (failureCount, error) => {
963
+ this.#dispatch({ type: "failed", failureCount, error });
964
+ },
965
+ onPause: () => {
966
+ this.#dispatch({ type: "pause" });
967
+ },
968
+ onContinue: () => {
969
+ this.#dispatch({ type: "continue" });
970
+ },
971
+ retry: context.options.retry,
972
+ retryDelay: context.options.retryDelay,
973
+ networkMode: context.options.networkMode,
974
+ canRun: () => true
975
+ });
976
+ try {
977
+ const data = await this.#retryer.start();
978
+ if (data === void 0) {
979
+ if (process.env.NODE_ENV !== "production") {
980
+ console.error(
981
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
1280
982
  );
1281
983
  }
1282
- return this.state.data === void 0 || this.state.isInvalidated;
984
+ throw new Error(`${this.queryHash} data is undefined`);
1283
985
  }
1284
- isStaleByTime(staleTime = 0) {
1285
- if (this.state.data === void 0) {
1286
- return true;
1287
- }
1288
- if (staleTime === "static") {
1289
- return false;
1290
- }
1291
- if (this.state.isInvalidated) {
1292
- return true;
1293
- }
1294
- return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
1295
- }
1296
- onFocus() {
1297
- const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
1298
- observer?.refetch({ cancelRefetch: false });
1299
- this.#retryer?.continue();
1300
- }
1301
- onOnline() {
1302
- const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
1303
- observer?.refetch({ cancelRefetch: false });
1304
- this.#retryer?.continue();
1305
- }
1306
- addObserver(observer) {
1307
- if (!this.observers.includes(observer)) {
1308
- this.observers.push(observer);
1309
- this.clearGcTimeout();
1310
- this.#cache.notify({ type: "observerAdded", query: this, observer });
1311
- }
1312
- }
1313
- removeObserver(observer) {
1314
- if (this.observers.includes(observer)) {
1315
- this.observers = this.observers.filter((x) => x !== observer);
1316
- if (!this.observers.length) {
1317
- if (this.#retryer) {
1318
- if (this.#abortSignalConsumed) {
1319
- this.#retryer.cancel({ revert: true });
1320
- } else {
1321
- this.#retryer.cancelRetry();
1322
- }
1323
- }
1324
- this.scheduleGc();
986
+ this.setData(data);
987
+ this.#cache.config.onSuccess?.(data, this);
988
+ this.#cache.config.onSettled?.(
989
+ data,
990
+ this.state.error,
991
+ this
992
+ );
993
+ return data;
994
+ } catch (error) {
995
+ if (error instanceof CancelledError) {
996
+ if (error.silent) {
997
+ return this.#retryer.promise;
998
+ } else if (error.revert) {
999
+ if (this.state.data === void 0) {
1000
+ throw error;
1325
1001
  }
1326
- this.#cache.notify({ type: "observerRemoved", query: this, observer });
1327
- }
1328
- }
1329
- getObserversCount() {
1330
- return this.observers.length;
1331
- }
1332
- invalidate() {
1333
- if (!this.state.isInvalidated) {
1334
- this.#dispatch({ type: "invalidate" });
1002
+ return this.state.data;
1335
1003
  }
1336
1004
  }
1337
- async fetch(options, fetchOptions) {
1338
- if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
1339
- // re-start the fetch; there is a chance that the query is still in a
1340
- // pending state when that happens
1341
- this.#retryer?.status() !== "rejected") {
1342
- if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
1343
- this.cancel({ silent: true });
1344
- } else if (this.#retryer) {
1345
- this.#retryer.continueRetry();
1346
- return this.#retryer.promise;
1347
- }
1348
- }
1349
- if (options) {
1350
- this.setOptions(options);
1351
- }
1352
- if (!this.options.queryFn) {
1353
- const observer = this.observers.find((x) => x.options.queryFn);
1354
- if (observer) {
1355
- this.setOptions(observer.options);
1356
- }
1357
- }
1358
- if (process.env.NODE_ENV !== "production") {
1359
- if (!Array.isArray(this.options.queryKey)) {
1360
- console.error(
1361
- `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']`
1362
- );
1363
- }
1364
- }
1365
- const abortController = new AbortController();
1366
- const addSignalProperty = (object) => {
1367
- Object.defineProperty(object, "signal", {
1368
- enumerable: true,
1369
- get: () => {
1370
- this.#abortSignalConsumed = true;
1371
- return abortController.signal;
1372
- }
1373
- });
1374
- };
1375
- const fetchFn = () => {
1376
- const queryFn = ensureQueryFn(this.options, fetchOptions);
1377
- const createQueryFnContext = () => {
1378
- const queryFnContext2 = {
1379
- client: this.#client,
1380
- queryKey: this.queryKey,
1381
- meta: this.meta
1382
- };
1383
- addSignalProperty(queryFnContext2);
1384
- return queryFnContext2;
1005
+ this.#dispatch({
1006
+ type: "error",
1007
+ error
1008
+ });
1009
+ this.#cache.config.onError?.(
1010
+ error,
1011
+ this
1012
+ );
1013
+ this.#cache.config.onSettled?.(
1014
+ this.state.data,
1015
+ error,
1016
+ this
1017
+ );
1018
+ throw error;
1019
+ } finally {
1020
+ this.scheduleGc();
1021
+ }
1022
+ }
1023
+ #dispatch(action) {
1024
+ const reducer = (state) => {
1025
+ switch (action.type) {
1026
+ case "failed":
1027
+ return {
1028
+ ...state,
1029
+ fetchFailureCount: action.failureCount,
1030
+ fetchFailureReason: action.error
1385
1031
  };
1386
- const queryFnContext = createQueryFnContext();
1387
- this.#abortSignalConsumed = false;
1388
- if (this.options.persister) {
1389
- return this.options.persister(
1390
- queryFn,
1391
- queryFnContext,
1392
- this
1393
- );
1394
- }
1395
- return queryFn(queryFnContext);
1396
- };
1397
- const createFetchContext = () => {
1398
- const context2 = {
1399
- fetchOptions,
1400
- options: this.options,
1401
- queryKey: this.queryKey,
1402
- client: this.#client,
1403
- state: this.state,
1404
- fetchFn
1032
+ case "pause":
1033
+ return {
1034
+ ...state,
1035
+ fetchStatus: "paused"
1405
1036
  };
1406
- addSignalProperty(context2);
1407
- return context2;
1408
- };
1409
- const context = createFetchContext();
1410
- this.options.behavior?.onFetch(context, this);
1411
- this.#revertState = this.state;
1412
- if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
1413
- this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
1414
- }
1415
- this.#retryer = createRetryer({
1416
- initialPromise: fetchOptions?.initialPromise,
1417
- fn: context.fetchFn,
1418
- onCancel: (error) => {
1419
- if (error instanceof CancelledError && error.revert) {
1420
- this.setState({
1421
- ...this.#revertState,
1422
- fetchStatus: "idle"
1423
- });
1424
- }
1425
- abortController.abort();
1426
- },
1427
- onFail: (failureCount, error) => {
1428
- this.#dispatch({ type: "failed", failureCount, error });
1429
- },
1430
- onPause: () => {
1431
- this.#dispatch({ type: "pause" });
1432
- },
1433
- onContinue: () => {
1434
- this.#dispatch({ type: "continue" });
1435
- },
1436
- retry: context.options.retry,
1437
- retryDelay: context.options.retryDelay,
1438
- networkMode: context.options.networkMode,
1439
- canRun: () => true
1440
- });
1441
- try {
1442
- const data = await this.#retryer.start();
1443
- if (data === void 0) {
1444
- if (process.env.NODE_ENV !== "production") {
1445
- console.error(
1446
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
1447
- );
1448
- }
1449
- throw new Error(`${this.queryHash} data is undefined`);
1450
- }
1451
- this.setData(data);
1452
- this.#cache.config.onSuccess?.(data, this);
1453
- this.#cache.config.onSettled?.(
1454
- data,
1455
- this.state.error,
1456
- this
1457
- );
1458
- return data;
1459
- } catch (error) {
1460
- if (error instanceof CancelledError) {
1461
- if (error.silent) {
1462
- return this.#retryer.promise;
1463
- } else if (error.revert) {
1464
- if (this.state.data === void 0) {
1465
- throw error;
1466
- }
1467
- return this.state.data;
1037
+ case "continue":
1038
+ return {
1039
+ ...state,
1040
+ fetchStatus: "fetching"
1041
+ };
1042
+ case "fetch":
1043
+ return {
1044
+ ...state,
1045
+ ...fetchState(state.data, this.options),
1046
+ fetchMeta: action.meta ?? null
1047
+ };
1048
+ case "success":
1049
+ const newState = {
1050
+ ...state,
1051
+ data: action.data,
1052
+ dataUpdateCount: state.dataUpdateCount + 1,
1053
+ dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
1054
+ error: null,
1055
+ isInvalidated: false,
1056
+ status: "success",
1057
+ ...!action.manual && {
1058
+ fetchStatus: "idle",
1059
+ fetchFailureCount: 0,
1060
+ fetchFailureReason: null
1468
1061
  }
1469
- }
1470
- this.#dispatch({
1471
- type: "error",
1472
- error
1473
- });
1474
- this.#cache.config.onError?.(
1475
- error,
1476
- this
1477
- );
1478
- this.#cache.config.onSettled?.(
1479
- this.state.data,
1062
+ };
1063
+ this.#revertState = action.manual ? newState : void 0;
1064
+ return newState;
1065
+ case "error":
1066
+ const error = action.error;
1067
+ return {
1068
+ ...state,
1480
1069
  error,
1481
- this
1482
- );
1483
- throw error;
1484
- } finally {
1485
- this.scheduleGc();
1486
- }
1487
- }
1488
- #dispatch(action) {
1489
- const reducer = (state) => {
1490
- switch (action.type) {
1491
- case "failed":
1492
- return {
1493
- ...state,
1494
- fetchFailureCount: action.failureCount,
1495
- fetchFailureReason: action.error
1496
- };
1497
- case "pause":
1498
- return {
1499
- ...state,
1500
- fetchStatus: "paused"
1501
- };
1502
- case "continue":
1503
- return {
1504
- ...state,
1505
- fetchStatus: "fetching"
1506
- };
1507
- case "fetch":
1508
- return {
1509
- ...state,
1510
- ...fetchState(state.data, this.options),
1511
- fetchMeta: action.meta ?? null
1512
- };
1513
- case "success":
1514
- const newState = {
1515
- ...state,
1516
- data: action.data,
1517
- dataUpdateCount: state.dataUpdateCount + 1,
1518
- dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
1519
- error: null,
1520
- isInvalidated: false,
1521
- status: "success",
1522
- ...!action.manual && {
1523
- fetchStatus: "idle",
1524
- fetchFailureCount: 0,
1525
- fetchFailureReason: null
1526
- }
1527
- };
1528
- this.#revertState = action.manual ? newState : void 0;
1529
- return newState;
1530
- case "error":
1531
- const error = action.error;
1532
- return {
1533
- ...state,
1534
- error,
1535
- errorUpdateCount: state.errorUpdateCount + 1,
1536
- errorUpdatedAt: Date.now(),
1537
- fetchFailureCount: state.fetchFailureCount + 1,
1538
- fetchFailureReason: error,
1539
- fetchStatus: "idle",
1540
- status: "error"
1541
- };
1542
- case "invalidate":
1543
- return {
1544
- ...state,
1545
- isInvalidated: true
1546
- };
1547
- case "setState":
1548
- return {
1549
- ...state,
1550
- ...action.state
1551
- };
1552
- }
1553
- };
1554
- this.state = reducer(this.state);
1555
- notifyManager.batch(() => {
1556
- this.observers.forEach((observer) => {
1557
- observer.onQueryUpdate();
1558
- });
1559
- this.#cache.notify({ query: this, type: "updated", action });
1560
- });
1070
+ errorUpdateCount: state.errorUpdateCount + 1,
1071
+ errorUpdatedAt: Date.now(),
1072
+ fetchFailureCount: state.fetchFailureCount + 1,
1073
+ fetchFailureReason: error,
1074
+ fetchStatus: "idle",
1075
+ status: "error"
1076
+ };
1077
+ case "invalidate":
1078
+ return {
1079
+ ...state,
1080
+ isInvalidated: true
1081
+ };
1082
+ case "setState":
1083
+ return {
1084
+ ...state,
1085
+ ...action.state
1086
+ };
1561
1087
  }
1562
1088
  };
1089
+ this.state = reducer(this.state);
1090
+ notifyManager.batch(() => {
1091
+ this.observers.forEach((observer) => {
1092
+ observer.onQueryUpdate();
1093
+ });
1094
+ this.#cache.notify({ query: this, type: "updated", action });
1095
+ });
1563
1096
  }
1564
- });
1097
+ };
1098
+ function fetchState(data, options) {
1099
+ return {
1100
+ fetchFailureCount: 0,
1101
+ fetchFailureReason: null,
1102
+ fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1103
+ ...data === void 0 && {
1104
+ error: null,
1105
+ status: "pending"
1106
+ }
1107
+ };
1108
+ }
1109
+ function getDefaultState(options) {
1110
+ const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
1111
+ const hasData = data !== void 0;
1112
+ const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
1113
+ return {
1114
+ data,
1115
+ dataUpdateCount: 0,
1116
+ dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
1117
+ error: null,
1118
+ errorUpdateCount: 0,
1119
+ errorUpdatedAt: 0,
1120
+ fetchFailureCount: 0,
1121
+ fetchFailureReason: null,
1122
+ fetchMeta: null,
1123
+ isInvalidated: false,
1124
+ status: hasData ? "success" : "pending",
1125
+ fetchStatus: "idle"
1126
+ };
1127
+ }
1565
1128
 
1566
1129
  // node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
1567
1130
  function infiniteQueryBehavior(pages) {
@@ -1671,870 +1234,792 @@ function getNextPageParam(options, { pages, pageParams }) {
1671
1234
  function getPreviousPageParam(options, { pages, pageParams }) {
1672
1235
  return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
1673
1236
  }
1674
- var init_infiniteQueryBehavior = __esm({
1675
- "node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js"() {
1676
- init_utils();
1677
- }
1678
- });
1679
1237
 
1680
1238
  // node_modules/@tanstack/query-core/build/modern/mutation.js
1681
- function getDefaultState2() {
1682
- return {
1683
- context: void 0,
1684
- data: void 0,
1685
- error: null,
1686
- failureCount: 0,
1687
- failureReason: null,
1688
- isPaused: false,
1689
- status: "idle",
1690
- variables: void 0,
1691
- submittedAt: 0
1692
- };
1693
- }
1694
- var Mutation;
1695
- var init_mutation = __esm({
1696
- "node_modules/@tanstack/query-core/build/modern/mutation.js"() {
1697
- init_notifyManager();
1698
- init_removable();
1699
- init_retryer();
1700
- Mutation = class extends Removable {
1701
- #client;
1702
- #observers;
1703
- #mutationCache;
1704
- #retryer;
1705
- constructor(config2) {
1706
- super();
1707
- this.#client = config2.client;
1708
- this.mutationId = config2.mutationId;
1709
- this.#mutationCache = config2.mutationCache;
1710
- this.#observers = [];
1711
- this.state = config2.state || getDefaultState2();
1712
- this.setOptions(config2.options);
1713
- this.scheduleGc();
1714
- }
1715
- setOptions(options) {
1716
- this.options = options;
1717
- this.updateGcTime(this.options.gcTime);
1718
- }
1719
- get meta() {
1720
- return this.options.meta;
1721
- }
1722
- addObserver(observer) {
1723
- if (!this.#observers.includes(observer)) {
1724
- this.#observers.push(observer);
1725
- this.clearGcTimeout();
1726
- this.#mutationCache.notify({
1727
- type: "observerAdded",
1728
- mutation: this,
1729
- observer
1730
- });
1731
- }
1732
- }
1733
- removeObserver(observer) {
1734
- this.#observers = this.#observers.filter((x) => x !== observer);
1239
+ var Mutation = class extends Removable {
1240
+ #client;
1241
+ #observers;
1242
+ #mutationCache;
1243
+ #retryer;
1244
+ constructor(config2) {
1245
+ super();
1246
+ this.#client = config2.client;
1247
+ this.mutationId = config2.mutationId;
1248
+ this.#mutationCache = config2.mutationCache;
1249
+ this.#observers = [];
1250
+ this.state = config2.state || getDefaultState2();
1251
+ this.setOptions(config2.options);
1252
+ this.scheduleGc();
1253
+ }
1254
+ setOptions(options) {
1255
+ this.options = options;
1256
+ this.updateGcTime(this.options.gcTime);
1257
+ }
1258
+ get meta() {
1259
+ return this.options.meta;
1260
+ }
1261
+ addObserver(observer) {
1262
+ if (!this.#observers.includes(observer)) {
1263
+ this.#observers.push(observer);
1264
+ this.clearGcTimeout();
1265
+ this.#mutationCache.notify({
1266
+ type: "observerAdded",
1267
+ mutation: this,
1268
+ observer
1269
+ });
1270
+ }
1271
+ }
1272
+ removeObserver(observer) {
1273
+ this.#observers = this.#observers.filter((x) => x !== observer);
1274
+ this.scheduleGc();
1275
+ this.#mutationCache.notify({
1276
+ type: "observerRemoved",
1277
+ mutation: this,
1278
+ observer
1279
+ });
1280
+ }
1281
+ optionalRemove() {
1282
+ if (!this.#observers.length) {
1283
+ if (this.state.status === "pending") {
1735
1284
  this.scheduleGc();
1736
- this.#mutationCache.notify({
1737
- type: "observerRemoved",
1738
- mutation: this,
1739
- observer
1740
- });
1741
- }
1742
- optionalRemove() {
1743
- if (!this.#observers.length) {
1744
- if (this.state.status === "pending") {
1745
- this.scheduleGc();
1746
- } else {
1747
- this.#mutationCache.remove(this);
1748
- }
1749
- }
1750
- }
1751
- continue() {
1752
- return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
1753
- this.execute(this.state.variables);
1754
- }
1755
- async execute(variables) {
1756
- const onContinue = () => {
1757
- this.#dispatch({ type: "continue" });
1758
- };
1759
- const mutationFnContext = {
1760
- client: this.#client,
1761
- meta: this.options.meta,
1762
- mutationKey: this.options.mutationKey
1763
- };
1764
- this.#retryer = createRetryer({
1765
- fn: () => {
1766
- if (!this.options.mutationFn) {
1767
- return Promise.reject(new Error("No mutationFn found"));
1768
- }
1769
- return this.options.mutationFn(variables, mutationFnContext);
1770
- },
1771
- onFail: (failureCount, error) => {
1772
- this.#dispatch({ type: "failed", failureCount, error });
1773
- },
1774
- onPause: () => {
1775
- this.#dispatch({ type: "pause" });
1776
- },
1777
- onContinue,
1778
- retry: this.options.retry ?? 0,
1779
- retryDelay: this.options.retryDelay,
1780
- networkMode: this.options.networkMode,
1781
- canRun: () => this.#mutationCache.canRun(this)
1782
- });
1783
- const restored = this.state.status === "pending";
1784
- const isPaused = !this.#retryer.canStart();
1785
- try {
1786
- if (restored) {
1787
- onContinue();
1788
- } else {
1789
- this.#dispatch({ type: "pending", variables, isPaused });
1790
- await this.#mutationCache.config.onMutate?.(
1791
- variables,
1792
- this,
1793
- mutationFnContext
1794
- );
1795
- const context = await this.options.onMutate?.(
1796
- variables,
1797
- mutationFnContext
1798
- );
1799
- if (context !== this.state.context) {
1800
- this.#dispatch({
1801
- type: "pending",
1802
- context,
1803
- variables,
1804
- isPaused
1805
- });
1806
- }
1807
- }
1808
- const data = await this.#retryer.start();
1809
- await this.#mutationCache.config.onSuccess?.(
1810
- data,
1811
- variables,
1812
- this.state.context,
1813
- this,
1814
- mutationFnContext
1815
- );
1816
- await this.options.onSuccess?.(
1817
- data,
1818
- variables,
1819
- this.state.context,
1820
- mutationFnContext
1821
- );
1822
- await this.#mutationCache.config.onSettled?.(
1823
- data,
1824
- null,
1825
- this.state.variables,
1826
- this.state.context,
1827
- this,
1828
- mutationFnContext
1829
- );
1830
- await this.options.onSettled?.(
1831
- data,
1832
- null,
1833
- variables,
1834
- this.state.context,
1835
- mutationFnContext
1836
- );
1837
- this.#dispatch({ type: "success", data });
1838
- return data;
1839
- } catch (error) {
1840
- try {
1841
- await this.#mutationCache.config.onError?.(
1842
- error,
1843
- variables,
1844
- this.state.context,
1845
- this,
1846
- mutationFnContext
1847
- );
1848
- await this.options.onError?.(
1849
- error,
1850
- variables,
1851
- this.state.context,
1852
- mutationFnContext
1853
- );
1854
- await this.#mutationCache.config.onSettled?.(
1855
- void 0,
1856
- error,
1857
- this.state.variables,
1858
- this.state.context,
1859
- this,
1860
- mutationFnContext
1861
- );
1862
- await this.options.onSettled?.(
1863
- void 0,
1864
- error,
1865
- variables,
1866
- this.state.context,
1867
- mutationFnContext
1868
- );
1869
- throw error;
1870
- } finally {
1871
- this.#dispatch({ type: "error", error });
1872
- }
1873
- } finally {
1874
- this.#mutationCache.runNext(this);
1875
- }
1876
- }
1877
- #dispatch(action) {
1878
- const reducer = (state) => {
1879
- switch (action.type) {
1880
- case "failed":
1881
- return {
1882
- ...state,
1883
- failureCount: action.failureCount,
1884
- failureReason: action.error
1885
- };
1886
- case "pause":
1887
- return {
1888
- ...state,
1889
- isPaused: true
1890
- };
1891
- case "continue":
1892
- return {
1893
- ...state,
1894
- isPaused: false
1895
- };
1896
- case "pending":
1897
- return {
1898
- ...state,
1899
- context: action.context,
1900
- data: void 0,
1901
- failureCount: 0,
1902
- failureReason: null,
1903
- error: null,
1904
- isPaused: action.isPaused,
1905
- status: "pending",
1906
- variables: action.variables,
1907
- submittedAt: Date.now()
1908
- };
1909
- case "success":
1910
- return {
1911
- ...state,
1912
- data: action.data,
1913
- failureCount: 0,
1914
- failureReason: null,
1915
- error: null,
1916
- status: "success",
1917
- isPaused: false
1918
- };
1919
- case "error":
1920
- return {
1921
- ...state,
1922
- data: void 0,
1923
- error: action.error,
1924
- failureCount: state.failureCount + 1,
1925
- failureReason: action.error,
1926
- isPaused: false,
1927
- status: "error"
1928
- };
1929
- }
1930
- };
1931
- this.state = reducer(this.state);
1932
- notifyManager.batch(() => {
1933
- this.#observers.forEach((observer) => {
1934
- observer.onMutationUpdate(action);
1935
- });
1936
- this.#mutationCache.notify({
1937
- mutation: this,
1938
- type: "updated",
1939
- action
1940
- });
1941
- });
1285
+ } else {
1286
+ this.#mutationCache.remove(this);
1942
1287
  }
1943
- };
1288
+ }
1944
1289
  }
1945
- });
1946
-
1947
- // node_modules/@tanstack/query-core/build/modern/mutationCache.js
1948
- function scopeFor(mutation) {
1949
- return mutation.options.scope?.id;
1950
- }
1951
- var MutationCache;
1952
- var init_mutationCache = __esm({
1953
- "node_modules/@tanstack/query-core/build/modern/mutationCache.js"() {
1954
- init_notifyManager();
1955
- init_mutation();
1956
- init_utils();
1957
- init_subscribable();
1958
- MutationCache = class extends Subscribable {
1959
- constructor(config2 = {}) {
1960
- super();
1961
- this.config = config2;
1962
- this.#mutations = /* @__PURE__ */ new Set();
1963
- this.#scopes = /* @__PURE__ */ new Map();
1964
- this.#mutationId = 0;
1965
- }
1966
- #mutations;
1967
- #scopes;
1968
- #mutationId;
1969
- build(client, options, state) {
1970
- const mutation = new Mutation({
1971
- client,
1972
- mutationCache: this,
1973
- mutationId: ++this.#mutationId,
1974
- options: client.defaultMutationOptions(options),
1975
- state
1976
- });
1977
- this.add(mutation);
1978
- return mutation;
1979
- }
1980
- add(mutation) {
1981
- this.#mutations.add(mutation);
1982
- const scope = scopeFor(mutation);
1983
- if (typeof scope === "string") {
1984
- const scopedMutations = this.#scopes.get(scope);
1985
- if (scopedMutations) {
1986
- scopedMutations.push(mutation);
1987
- } else {
1988
- this.#scopes.set(scope, [mutation]);
1989
- }
1990
- }
1991
- this.notify({ type: "added", mutation });
1992
- }
1993
- remove(mutation) {
1994
- if (this.#mutations.delete(mutation)) {
1995
- const scope = scopeFor(mutation);
1996
- if (typeof scope === "string") {
1997
- const scopedMutations = this.#scopes.get(scope);
1998
- if (scopedMutations) {
1999
- if (scopedMutations.length > 1) {
2000
- const index = scopedMutations.indexOf(mutation);
2001
- if (index !== -1) {
2002
- scopedMutations.splice(index, 1);
2003
- }
2004
- } else if (scopedMutations[0] === mutation) {
2005
- this.#scopes.delete(scope);
2006
- }
2007
- }
2008
- }
2009
- }
2010
- this.notify({ type: "removed", mutation });
2011
- }
2012
- canRun(mutation) {
2013
- const scope = scopeFor(mutation);
2014
- if (typeof scope === "string") {
2015
- const mutationsWithSameScope = this.#scopes.get(scope);
2016
- const firstPendingMutation = mutationsWithSameScope?.find(
2017
- (m) => m.state.status === "pending"
2018
- );
2019
- return !firstPendingMutation || firstPendingMutation === mutation;
2020
- } else {
2021
- return true;
2022
- }
2023
- }
2024
- runNext(mutation) {
2025
- const scope = scopeFor(mutation);
2026
- if (typeof scope === "string") {
2027
- const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);
2028
- return foundMutation?.continue() ?? Promise.resolve();
2029
- } else {
2030
- return Promise.resolve();
1290
+ continue() {
1291
+ return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
1292
+ this.execute(this.state.variables);
1293
+ }
1294
+ async execute(variables) {
1295
+ const onContinue = () => {
1296
+ this.#dispatch({ type: "continue" });
1297
+ };
1298
+ const mutationFnContext = {
1299
+ client: this.#client,
1300
+ meta: this.options.meta,
1301
+ mutationKey: this.options.mutationKey
1302
+ };
1303
+ this.#retryer = createRetryer({
1304
+ fn: () => {
1305
+ if (!this.options.mutationFn) {
1306
+ return Promise.reject(new Error("No mutationFn found"));
2031
1307
  }
2032
- }
2033
- clear() {
2034
- notifyManager.batch(() => {
2035
- this.#mutations.forEach((mutation) => {
2036
- this.notify({ type: "removed", mutation });
2037
- });
2038
- this.#mutations.clear();
2039
- this.#scopes.clear();
2040
- });
2041
- }
2042
- getAll() {
2043
- return Array.from(this.#mutations);
2044
- }
2045
- find(filters) {
2046
- const defaultedFilters = { exact: true, ...filters };
2047
- return this.getAll().find(
2048
- (mutation) => matchMutation(defaultedFilters, mutation)
1308
+ return this.options.mutationFn(variables, mutationFnContext);
1309
+ },
1310
+ onFail: (failureCount, error) => {
1311
+ this.#dispatch({ type: "failed", failureCount, error });
1312
+ },
1313
+ onPause: () => {
1314
+ this.#dispatch({ type: "pause" });
1315
+ },
1316
+ onContinue,
1317
+ retry: this.options.retry ?? 0,
1318
+ retryDelay: this.options.retryDelay,
1319
+ networkMode: this.options.networkMode,
1320
+ canRun: () => this.#mutationCache.canRun(this)
1321
+ });
1322
+ const restored = this.state.status === "pending";
1323
+ const isPaused = !this.#retryer.canStart();
1324
+ try {
1325
+ if (restored) {
1326
+ onContinue();
1327
+ } else {
1328
+ this.#dispatch({ type: "pending", variables, isPaused });
1329
+ await this.#mutationCache.config.onMutate?.(
1330
+ variables,
1331
+ this,
1332
+ mutationFnContext
2049
1333
  );
2050
- }
2051
- findAll(filters = {}) {
2052
- return this.getAll().filter((mutation) => matchMutation(filters, mutation));
2053
- }
2054
- notify(event) {
2055
- notifyManager.batch(() => {
2056
- this.listeners.forEach((listener) => {
2057
- listener(event);
2058
- });
2059
- });
2060
- }
2061
- resumePausedMutations() {
2062
- const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
2063
- return notifyManager.batch(
2064
- () => Promise.all(
2065
- pausedMutations.map((mutation) => mutation.continue().catch(noop))
2066
- )
1334
+ const context = await this.options.onMutate?.(
1335
+ variables,
1336
+ mutationFnContext
2067
1337
  );
2068
- }
2069
- };
2070
- }
2071
- });
2072
-
2073
- // node_modules/@tanstack/query-core/build/modern/queryCache.js
2074
- var QueryCache;
2075
- var init_queryCache = __esm({
2076
- "node_modules/@tanstack/query-core/build/modern/queryCache.js"() {
2077
- init_utils();
2078
- init_query();
2079
- init_notifyManager();
2080
- init_subscribable();
2081
- QueryCache = class extends Subscribable {
2082
- constructor(config2 = {}) {
2083
- super();
2084
- this.config = config2;
2085
- this.#queries = /* @__PURE__ */ new Map();
2086
- }
2087
- #queries;
2088
- build(client, options, state) {
2089
- const queryKey = options.queryKey;
2090
- const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
2091
- let query = this.get(queryHash);
2092
- if (!query) {
2093
- query = new Query({
2094
- client,
2095
- queryKey,
2096
- queryHash,
2097
- options: client.defaultQueryOptions(options),
2098
- state,
2099
- defaultOptions: client.getQueryDefaults(queryKey)
2100
- });
2101
- this.add(query);
2102
- }
2103
- return query;
2104
- }
2105
- add(query) {
2106
- if (!this.#queries.has(query.queryHash)) {
2107
- this.#queries.set(query.queryHash, query);
2108
- this.notify({
2109
- type: "added",
2110
- query
1338
+ if (context !== this.state.context) {
1339
+ this.#dispatch({
1340
+ type: "pending",
1341
+ context,
1342
+ variables,
1343
+ isPaused
2111
1344
  });
2112
1345
  }
2113
1346
  }
2114
- remove(query) {
2115
- const queryInMap = this.#queries.get(query.queryHash);
2116
- if (queryInMap) {
2117
- query.destroy();
2118
- if (queryInMap === query) {
2119
- this.#queries.delete(query.queryHash);
2120
- }
2121
- this.notify({ type: "removed", query });
2122
- }
2123
- }
2124
- clear() {
2125
- notifyManager.batch(() => {
2126
- this.getAll().forEach((query) => {
2127
- this.remove(query);
2128
- });
2129
- });
2130
- }
2131
- get(queryHash) {
2132
- return this.#queries.get(queryHash);
2133
- }
2134
- getAll() {
2135
- return [...this.#queries.values()];
2136
- }
2137
- find(filters) {
2138
- const defaultedFilters = { exact: true, ...filters };
2139
- return this.getAll().find(
2140
- (query) => matchQuery(defaultedFilters, query)
1347
+ const data = await this.#retryer.start();
1348
+ await this.#mutationCache.config.onSuccess?.(
1349
+ data,
1350
+ variables,
1351
+ this.state.context,
1352
+ this,
1353
+ mutationFnContext
1354
+ );
1355
+ await this.options.onSuccess?.(
1356
+ data,
1357
+ variables,
1358
+ this.state.context,
1359
+ mutationFnContext
1360
+ );
1361
+ await this.#mutationCache.config.onSettled?.(
1362
+ data,
1363
+ null,
1364
+ this.state.variables,
1365
+ this.state.context,
1366
+ this,
1367
+ mutationFnContext
1368
+ );
1369
+ await this.options.onSettled?.(
1370
+ data,
1371
+ null,
1372
+ variables,
1373
+ this.state.context,
1374
+ mutationFnContext
1375
+ );
1376
+ this.#dispatch({ type: "success", data });
1377
+ return data;
1378
+ } catch (error) {
1379
+ try {
1380
+ await this.#mutationCache.config.onError?.(
1381
+ error,
1382
+ variables,
1383
+ this.state.context,
1384
+ this,
1385
+ mutationFnContext
2141
1386
  );
2142
- }
2143
- findAll(filters = {}) {
2144
- const queries = this.getAll();
2145
- return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
2146
- }
2147
- notify(event) {
2148
- notifyManager.batch(() => {
2149
- this.listeners.forEach((listener) => {
2150
- listener(event);
2151
- });
2152
- });
2153
- }
2154
- onFocus() {
2155
- notifyManager.batch(() => {
2156
- this.getAll().forEach((query) => {
2157
- query.onFocus();
2158
- });
2159
- });
2160
- }
2161
- onOnline() {
2162
- notifyManager.batch(() => {
2163
- this.getAll().forEach((query) => {
2164
- query.onOnline();
2165
- });
2166
- });
2167
- }
2168
- };
2169
- }
2170
- });
2171
-
2172
- // node_modules/@tanstack/query-core/build/modern/queryClient.js
2173
- var QueryClient;
2174
- var init_queryClient = __esm({
2175
- "node_modules/@tanstack/query-core/build/modern/queryClient.js"() {
2176
- init_utils();
2177
- init_queryCache();
2178
- init_mutationCache();
2179
- init_focusManager();
2180
- init_onlineManager();
2181
- init_notifyManager();
2182
- init_infiniteQueryBehavior();
2183
- QueryClient = class {
2184
- #queryCache;
2185
- #mutationCache;
2186
- #defaultOptions;
2187
- #queryDefaults;
2188
- #mutationDefaults;
2189
- #mountCount;
2190
- #unsubscribeFocus;
2191
- #unsubscribeOnline;
2192
- constructor(config2 = {}) {
2193
- this.#queryCache = config2.queryCache || new QueryCache();
2194
- this.#mutationCache = config2.mutationCache || new MutationCache();
2195
- this.#defaultOptions = config2.defaultOptions || {};
2196
- this.#queryDefaults = /* @__PURE__ */ new Map();
2197
- this.#mutationDefaults = /* @__PURE__ */ new Map();
2198
- this.#mountCount = 0;
2199
- }
2200
- mount() {
2201
- this.#mountCount++;
2202
- if (this.#mountCount !== 1) return;
2203
- this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
2204
- if (focused) {
2205
- await this.resumePausedMutations();
2206
- this.#queryCache.onFocus();
2207
- }
2208
- });
2209
- this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
2210
- if (online) {
2211
- await this.resumePausedMutations();
2212
- this.#queryCache.onOnline();
2213
- }
2214
- });
2215
- }
2216
- unmount() {
2217
- this.#mountCount--;
2218
- if (this.#mountCount !== 0) return;
2219
- this.#unsubscribeFocus?.();
2220
- this.#unsubscribeFocus = void 0;
2221
- this.#unsubscribeOnline?.();
2222
- this.#unsubscribeOnline = void 0;
2223
- }
2224
- isFetching(filters) {
2225
- return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
2226
- }
2227
- isMutating(filters) {
2228
- return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
2229
- }
2230
- /**
2231
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
2232
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
2233
- *
2234
- * Hint: Do not use this function inside a component, because it won't receive updates.
2235
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2236
- */
2237
- getQueryData(queryKey) {
2238
- const options = this.defaultQueryOptions({ queryKey });
2239
- return this.#queryCache.get(options.queryHash)?.state.data;
2240
- }
2241
- ensureQueryData(options) {
2242
- const defaultedOptions = this.defaultQueryOptions(options);
2243
- const query = this.#queryCache.build(this, defaultedOptions);
2244
- const cachedData = query.state.data;
2245
- if (cachedData === void 0) {
2246
- return this.fetchQuery(options);
2247
- }
2248
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
2249
- void this.prefetchQuery(defaultedOptions);
2250
- }
2251
- return Promise.resolve(cachedData);
2252
- }
2253
- getQueriesData(filters) {
2254
- return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
2255
- const data = state.data;
2256
- return [queryKey, data];
2257
- });
2258
- }
2259
- setQueryData(queryKey, updater, options) {
2260
- const defaultedOptions = this.defaultQueryOptions({ queryKey });
2261
- const query = this.#queryCache.get(
2262
- defaultedOptions.queryHash
1387
+ await this.options.onError?.(
1388
+ error,
1389
+ variables,
1390
+ this.state.context,
1391
+ mutationFnContext
2263
1392
  );
2264
- const prevData = query?.state.data;
2265
- const data = functionalUpdate(updater, prevData);
2266
- if (data === void 0) {
2267
- return void 0;
2268
- }
2269
- return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
2270
- }
2271
- setQueriesData(filters, updater, options) {
2272
- return notifyManager.batch(
2273
- () => this.#queryCache.findAll(filters).map(({ queryKey }) => [
2274
- queryKey,
2275
- this.setQueryData(queryKey, updater, options)
2276
- ])
1393
+ await this.#mutationCache.config.onSettled?.(
1394
+ void 0,
1395
+ error,
1396
+ this.state.variables,
1397
+ this.state.context,
1398
+ this,
1399
+ mutationFnContext
2277
1400
  );
2278
- }
2279
- getQueryState(queryKey) {
2280
- const options = this.defaultQueryOptions({ queryKey });
2281
- return this.#queryCache.get(
2282
- options.queryHash
2283
- )?.state;
2284
- }
2285
- removeQueries(filters) {
2286
- const queryCache = this.#queryCache;
2287
- notifyManager.batch(() => {
2288
- queryCache.findAll(filters).forEach((query) => {
2289
- queryCache.remove(query);
2290
- });
2291
- });
2292
- }
2293
- resetQueries(filters, options) {
2294
- const queryCache = this.#queryCache;
2295
- return notifyManager.batch(() => {
2296
- queryCache.findAll(filters).forEach((query) => {
2297
- query.reset();
2298
- });
2299
- return this.refetchQueries(
2300
- {
2301
- type: "active",
2302
- ...filters
2303
- },
2304
- options
2305
- );
2306
- });
2307
- }
2308
- cancelQueries(filters, cancelOptions = {}) {
2309
- const defaultedCancelOptions = { revert: true, ...cancelOptions };
2310
- const promises = notifyManager.batch(
2311
- () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
1401
+ await this.options.onSettled?.(
1402
+ void 0,
1403
+ error,
1404
+ variables,
1405
+ this.state.context,
1406
+ mutationFnContext
2312
1407
  );
2313
- return Promise.all(promises).then(noop).catch(noop);
1408
+ throw error;
1409
+ } finally {
1410
+ this.#dispatch({ type: "error", error });
2314
1411
  }
2315
- invalidateQueries(filters, options = {}) {
2316
- return notifyManager.batch(() => {
2317
- this.#queryCache.findAll(filters).forEach((query) => {
2318
- query.invalidate();
2319
- });
2320
- if (filters?.refetchType === "none") {
2321
- return Promise.resolve();
2322
- }
2323
- return this.refetchQueries(
2324
- {
2325
- ...filters,
2326
- type: filters?.refetchType ?? filters?.type ?? "active"
2327
- },
2328
- options
2329
- );
2330
- });
1412
+ } finally {
1413
+ this.#mutationCache.runNext(this);
1414
+ }
1415
+ }
1416
+ #dispatch(action) {
1417
+ const reducer = (state) => {
1418
+ switch (action.type) {
1419
+ case "failed":
1420
+ return {
1421
+ ...state,
1422
+ failureCount: action.failureCount,
1423
+ failureReason: action.error
1424
+ };
1425
+ case "pause":
1426
+ return {
1427
+ ...state,
1428
+ isPaused: true
1429
+ };
1430
+ case "continue":
1431
+ return {
1432
+ ...state,
1433
+ isPaused: false
1434
+ };
1435
+ case "pending":
1436
+ return {
1437
+ ...state,
1438
+ context: action.context,
1439
+ data: void 0,
1440
+ failureCount: 0,
1441
+ failureReason: null,
1442
+ error: null,
1443
+ isPaused: action.isPaused,
1444
+ status: "pending",
1445
+ variables: action.variables,
1446
+ submittedAt: Date.now()
1447
+ };
1448
+ case "success":
1449
+ return {
1450
+ ...state,
1451
+ data: action.data,
1452
+ failureCount: 0,
1453
+ failureReason: null,
1454
+ error: null,
1455
+ status: "success",
1456
+ isPaused: false
1457
+ };
1458
+ case "error":
1459
+ return {
1460
+ ...state,
1461
+ data: void 0,
1462
+ error: action.error,
1463
+ failureCount: state.failureCount + 1,
1464
+ failureReason: action.error,
1465
+ isPaused: false,
1466
+ status: "error"
1467
+ };
1468
+ }
1469
+ };
1470
+ this.state = reducer(this.state);
1471
+ notifyManager.batch(() => {
1472
+ this.#observers.forEach((observer) => {
1473
+ observer.onMutationUpdate(action);
1474
+ });
1475
+ this.#mutationCache.notify({
1476
+ mutation: this,
1477
+ type: "updated",
1478
+ action
1479
+ });
1480
+ });
1481
+ }
1482
+ };
1483
+ function getDefaultState2() {
1484
+ return {
1485
+ context: void 0,
1486
+ data: void 0,
1487
+ error: null,
1488
+ failureCount: 0,
1489
+ failureReason: null,
1490
+ isPaused: false,
1491
+ status: "idle",
1492
+ variables: void 0,
1493
+ submittedAt: 0
1494
+ };
1495
+ }
1496
+
1497
+ // node_modules/@tanstack/query-core/build/modern/mutationCache.js
1498
+ var MutationCache = class extends Subscribable {
1499
+ constructor(config2 = {}) {
1500
+ super();
1501
+ this.config = config2;
1502
+ this.#mutations = /* @__PURE__ */ new Set();
1503
+ this.#scopes = /* @__PURE__ */ new Map();
1504
+ this.#mutationId = 0;
1505
+ }
1506
+ #mutations;
1507
+ #scopes;
1508
+ #mutationId;
1509
+ build(client, options, state) {
1510
+ const mutation = new Mutation({
1511
+ client,
1512
+ mutationCache: this,
1513
+ mutationId: ++this.#mutationId,
1514
+ options: client.defaultMutationOptions(options),
1515
+ state
1516
+ });
1517
+ this.add(mutation);
1518
+ return mutation;
1519
+ }
1520
+ add(mutation) {
1521
+ this.#mutations.add(mutation);
1522
+ const scope = scopeFor(mutation);
1523
+ if (typeof scope === "string") {
1524
+ const scopedMutations = this.#scopes.get(scope);
1525
+ if (scopedMutations) {
1526
+ scopedMutations.push(mutation);
1527
+ } else {
1528
+ this.#scopes.set(scope, [mutation]);
2331
1529
  }
2332
- refetchQueries(filters, options = {}) {
2333
- const fetchOptions = {
2334
- ...options,
2335
- cancelRefetch: options.cancelRefetch ?? true
2336
- };
2337
- const promises = notifyManager.batch(
2338
- () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
2339
- let promise = query.fetch(void 0, fetchOptions);
2340
- if (!fetchOptions.throwOnError) {
2341
- promise = promise.catch(noop);
1530
+ }
1531
+ this.notify({ type: "added", mutation });
1532
+ }
1533
+ remove(mutation) {
1534
+ if (this.#mutations.delete(mutation)) {
1535
+ const scope = scopeFor(mutation);
1536
+ if (typeof scope === "string") {
1537
+ const scopedMutations = this.#scopes.get(scope);
1538
+ if (scopedMutations) {
1539
+ if (scopedMutations.length > 1) {
1540
+ const index = scopedMutations.indexOf(mutation);
1541
+ if (index !== -1) {
1542
+ scopedMutations.splice(index, 1);
2342
1543
  }
2343
- return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
2344
- })
2345
- );
2346
- return Promise.all(promises).then(noop);
2347
- }
2348
- fetchQuery(options) {
2349
- const defaultedOptions = this.defaultQueryOptions(options);
2350
- if (defaultedOptions.retry === void 0) {
2351
- defaultedOptions.retry = false;
1544
+ } else if (scopedMutations[0] === mutation) {
1545
+ this.#scopes.delete(scope);
1546
+ }
2352
1547
  }
2353
- const query = this.#queryCache.build(this, defaultedOptions);
2354
- return query.isStaleByTime(
2355
- resolveStaleTime(defaultedOptions.staleTime, query)
2356
- ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2357
1548
  }
2358
- prefetchQuery(options) {
2359
- return this.fetchQuery(options).then(noop).catch(noop);
2360
- }
2361
- fetchInfiniteQuery(options) {
2362
- options.behavior = infiniteQueryBehavior(options.pages);
2363
- return this.fetchQuery(options);
1549
+ }
1550
+ this.notify({ type: "removed", mutation });
1551
+ }
1552
+ canRun(mutation) {
1553
+ const scope = scopeFor(mutation);
1554
+ if (typeof scope === "string") {
1555
+ const mutationsWithSameScope = this.#scopes.get(scope);
1556
+ const firstPendingMutation = mutationsWithSameScope?.find(
1557
+ (m) => m.state.status === "pending"
1558
+ );
1559
+ return !firstPendingMutation || firstPendingMutation === mutation;
1560
+ } else {
1561
+ return true;
1562
+ }
1563
+ }
1564
+ runNext(mutation) {
1565
+ const scope = scopeFor(mutation);
1566
+ if (typeof scope === "string") {
1567
+ const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);
1568
+ return foundMutation?.continue() ?? Promise.resolve();
1569
+ } else {
1570
+ return Promise.resolve();
1571
+ }
1572
+ }
1573
+ clear() {
1574
+ notifyManager.batch(() => {
1575
+ this.#mutations.forEach((mutation) => {
1576
+ this.notify({ type: "removed", mutation });
1577
+ });
1578
+ this.#mutations.clear();
1579
+ this.#scopes.clear();
1580
+ });
1581
+ }
1582
+ getAll() {
1583
+ return Array.from(this.#mutations);
1584
+ }
1585
+ find(filters) {
1586
+ const defaultedFilters = { exact: true, ...filters };
1587
+ return this.getAll().find(
1588
+ (mutation) => matchMutation(defaultedFilters, mutation)
1589
+ );
1590
+ }
1591
+ findAll(filters = {}) {
1592
+ return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1593
+ }
1594
+ notify(event) {
1595
+ notifyManager.batch(() => {
1596
+ this.listeners.forEach((listener) => {
1597
+ listener(event);
1598
+ });
1599
+ });
1600
+ }
1601
+ resumePausedMutations() {
1602
+ const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1603
+ return notifyManager.batch(
1604
+ () => Promise.all(
1605
+ pausedMutations.map((mutation) => mutation.continue().catch(noop))
1606
+ )
1607
+ );
1608
+ }
1609
+ };
1610
+ function scopeFor(mutation) {
1611
+ return mutation.options.scope?.id;
1612
+ }
1613
+
1614
+ // node_modules/@tanstack/query-core/build/modern/queryCache.js
1615
+ var QueryCache = class extends Subscribable {
1616
+ constructor(config2 = {}) {
1617
+ super();
1618
+ this.config = config2;
1619
+ this.#queries = /* @__PURE__ */ new Map();
1620
+ }
1621
+ #queries;
1622
+ build(client, options, state) {
1623
+ const queryKey = options.queryKey;
1624
+ const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
1625
+ let query = this.get(queryHash);
1626
+ if (!query) {
1627
+ query = new Query({
1628
+ client,
1629
+ queryKey,
1630
+ queryHash,
1631
+ options: client.defaultQueryOptions(options),
1632
+ state,
1633
+ defaultOptions: client.getQueryDefaults(queryKey)
1634
+ });
1635
+ this.add(query);
1636
+ }
1637
+ return query;
1638
+ }
1639
+ add(query) {
1640
+ if (!this.#queries.has(query.queryHash)) {
1641
+ this.#queries.set(query.queryHash, query);
1642
+ this.notify({
1643
+ type: "added",
1644
+ query
1645
+ });
1646
+ }
1647
+ }
1648
+ remove(query) {
1649
+ const queryInMap = this.#queries.get(query.queryHash);
1650
+ if (queryInMap) {
1651
+ query.destroy();
1652
+ if (queryInMap === query) {
1653
+ this.#queries.delete(query.queryHash);
2364
1654
  }
2365
- prefetchInfiniteQuery(options) {
2366
- return this.fetchInfiniteQuery(options).then(noop).catch(noop);
1655
+ this.notify({ type: "removed", query });
1656
+ }
1657
+ }
1658
+ clear() {
1659
+ notifyManager.batch(() => {
1660
+ this.getAll().forEach((query) => {
1661
+ this.remove(query);
1662
+ });
1663
+ });
1664
+ }
1665
+ get(queryHash) {
1666
+ return this.#queries.get(queryHash);
1667
+ }
1668
+ getAll() {
1669
+ return [...this.#queries.values()];
1670
+ }
1671
+ find(filters) {
1672
+ const defaultedFilters = { exact: true, ...filters };
1673
+ return this.getAll().find(
1674
+ (query) => matchQuery(defaultedFilters, query)
1675
+ );
1676
+ }
1677
+ findAll(filters = {}) {
1678
+ const queries = this.getAll();
1679
+ return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1680
+ }
1681
+ notify(event) {
1682
+ notifyManager.batch(() => {
1683
+ this.listeners.forEach((listener) => {
1684
+ listener(event);
1685
+ });
1686
+ });
1687
+ }
1688
+ onFocus() {
1689
+ notifyManager.batch(() => {
1690
+ this.getAll().forEach((query) => {
1691
+ query.onFocus();
1692
+ });
1693
+ });
1694
+ }
1695
+ onOnline() {
1696
+ notifyManager.batch(() => {
1697
+ this.getAll().forEach((query) => {
1698
+ query.onOnline();
1699
+ });
1700
+ });
1701
+ }
1702
+ };
1703
+
1704
+ // node_modules/@tanstack/query-core/build/modern/queryClient.js
1705
+ var QueryClient = class {
1706
+ #queryCache;
1707
+ #mutationCache;
1708
+ #defaultOptions;
1709
+ #queryDefaults;
1710
+ #mutationDefaults;
1711
+ #mountCount;
1712
+ #unsubscribeFocus;
1713
+ #unsubscribeOnline;
1714
+ constructor(config2 = {}) {
1715
+ this.#queryCache = config2.queryCache || new QueryCache();
1716
+ this.#mutationCache = config2.mutationCache || new MutationCache();
1717
+ this.#defaultOptions = config2.defaultOptions || {};
1718
+ this.#queryDefaults = /* @__PURE__ */ new Map();
1719
+ this.#mutationDefaults = /* @__PURE__ */ new Map();
1720
+ this.#mountCount = 0;
1721
+ }
1722
+ mount() {
1723
+ this.#mountCount++;
1724
+ if (this.#mountCount !== 1) return;
1725
+ this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
1726
+ if (focused) {
1727
+ await this.resumePausedMutations();
1728
+ this.#queryCache.onFocus();
2367
1729
  }
2368
- ensureInfiniteQueryData(options) {
2369
- options.behavior = infiniteQueryBehavior(options.pages);
2370
- return this.ensureQueryData(options);
1730
+ });
1731
+ this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
1732
+ if (online) {
1733
+ await this.resumePausedMutations();
1734
+ this.#queryCache.onOnline();
2371
1735
  }
2372
- resumePausedMutations() {
2373
- if (onlineManager.isOnline()) {
2374
- return this.#mutationCache.resumePausedMutations();
2375
- }
1736
+ });
1737
+ }
1738
+ unmount() {
1739
+ this.#mountCount--;
1740
+ if (this.#mountCount !== 0) return;
1741
+ this.#unsubscribeFocus?.();
1742
+ this.#unsubscribeFocus = void 0;
1743
+ this.#unsubscribeOnline?.();
1744
+ this.#unsubscribeOnline = void 0;
1745
+ }
1746
+ isFetching(filters) {
1747
+ return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
1748
+ }
1749
+ isMutating(filters) {
1750
+ return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
1751
+ }
1752
+ /**
1753
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
1754
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1755
+ *
1756
+ * Hint: Do not use this function inside a component, because it won't receive updates.
1757
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1758
+ */
1759
+ getQueryData(queryKey) {
1760
+ const options = this.defaultQueryOptions({ queryKey });
1761
+ return this.#queryCache.get(options.queryHash)?.state.data;
1762
+ }
1763
+ ensureQueryData(options) {
1764
+ const defaultedOptions = this.defaultQueryOptions(options);
1765
+ const query = this.#queryCache.build(this, defaultedOptions);
1766
+ const cachedData = query.state.data;
1767
+ if (cachedData === void 0) {
1768
+ return this.fetchQuery(options);
1769
+ }
1770
+ if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
1771
+ void this.prefetchQuery(defaultedOptions);
1772
+ }
1773
+ return Promise.resolve(cachedData);
1774
+ }
1775
+ getQueriesData(filters) {
1776
+ return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
1777
+ const data = state.data;
1778
+ return [queryKey, data];
1779
+ });
1780
+ }
1781
+ setQueryData(queryKey, updater, options) {
1782
+ const defaultedOptions = this.defaultQueryOptions({ queryKey });
1783
+ const query = this.#queryCache.get(
1784
+ defaultedOptions.queryHash
1785
+ );
1786
+ const prevData = query?.state.data;
1787
+ const data = functionalUpdate(updater, prevData);
1788
+ if (data === void 0) {
1789
+ return void 0;
1790
+ }
1791
+ return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
1792
+ }
1793
+ setQueriesData(filters, updater, options) {
1794
+ return notifyManager.batch(
1795
+ () => this.#queryCache.findAll(filters).map(({ queryKey }) => [
1796
+ queryKey,
1797
+ this.setQueryData(queryKey, updater, options)
1798
+ ])
1799
+ );
1800
+ }
1801
+ getQueryState(queryKey) {
1802
+ const options = this.defaultQueryOptions({ queryKey });
1803
+ return this.#queryCache.get(
1804
+ options.queryHash
1805
+ )?.state;
1806
+ }
1807
+ removeQueries(filters) {
1808
+ const queryCache = this.#queryCache;
1809
+ notifyManager.batch(() => {
1810
+ queryCache.findAll(filters).forEach((query) => {
1811
+ queryCache.remove(query);
1812
+ });
1813
+ });
1814
+ }
1815
+ resetQueries(filters, options) {
1816
+ const queryCache = this.#queryCache;
1817
+ return notifyManager.batch(() => {
1818
+ queryCache.findAll(filters).forEach((query) => {
1819
+ query.reset();
1820
+ });
1821
+ return this.refetchQueries(
1822
+ {
1823
+ type: "active",
1824
+ ...filters
1825
+ },
1826
+ options
1827
+ );
1828
+ });
1829
+ }
1830
+ cancelQueries(filters, cancelOptions = {}) {
1831
+ const defaultedCancelOptions = { revert: true, ...cancelOptions };
1832
+ const promises = notifyManager.batch(
1833
+ () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
1834
+ );
1835
+ return Promise.all(promises).then(noop).catch(noop);
1836
+ }
1837
+ invalidateQueries(filters, options = {}) {
1838
+ return notifyManager.batch(() => {
1839
+ this.#queryCache.findAll(filters).forEach((query) => {
1840
+ query.invalidate();
1841
+ });
1842
+ if (filters?.refetchType === "none") {
2376
1843
  return Promise.resolve();
2377
1844
  }
2378
- getQueryCache() {
2379
- return this.#queryCache;
2380
- }
2381
- getMutationCache() {
2382
- return this.#mutationCache;
2383
- }
2384
- getDefaultOptions() {
2385
- return this.#defaultOptions;
2386
- }
2387
- setDefaultOptions(options) {
2388
- this.#defaultOptions = options;
2389
- }
2390
- setQueryDefaults(queryKey, options) {
2391
- this.#queryDefaults.set(hashKey(queryKey), {
2392
- queryKey,
2393
- defaultOptions: options
2394
- });
2395
- }
2396
- getQueryDefaults(queryKey) {
2397
- const defaults = [...this.#queryDefaults.values()];
2398
- const result = {};
2399
- defaults.forEach((queryDefault) => {
2400
- if (partialMatchKey(queryKey, queryDefault.queryKey)) {
2401
- Object.assign(result, queryDefault.defaultOptions);
2402
- }
2403
- });
2404
- return result;
2405
- }
2406
- setMutationDefaults(mutationKey, options) {
2407
- this.#mutationDefaults.set(hashKey(mutationKey), {
2408
- mutationKey,
2409
- defaultOptions: options
2410
- });
2411
- }
2412
- getMutationDefaults(mutationKey) {
2413
- const defaults = [...this.#mutationDefaults.values()];
2414
- const result = {};
2415
- defaults.forEach((queryDefault) => {
2416
- if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
2417
- Object.assign(result, queryDefault.defaultOptions);
2418
- }
2419
- });
2420
- return result;
2421
- }
2422
- defaultQueryOptions(options) {
2423
- if (options._defaulted) {
2424
- return options;
2425
- }
2426
- const defaultedOptions = {
2427
- ...this.#defaultOptions.queries,
2428
- ...this.getQueryDefaults(options.queryKey),
2429
- ...options,
2430
- _defaulted: true
2431
- };
2432
- if (!defaultedOptions.queryHash) {
2433
- defaultedOptions.queryHash = hashQueryKeyByOptions(
2434
- defaultedOptions.queryKey,
2435
- defaultedOptions
2436
- );
2437
- }
2438
- if (defaultedOptions.refetchOnReconnect === void 0) {
2439
- defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
2440
- }
2441
- if (defaultedOptions.throwOnError === void 0) {
2442
- defaultedOptions.throwOnError = !!defaultedOptions.suspense;
2443
- }
2444
- if (!defaultedOptions.networkMode && defaultedOptions.persister) {
2445
- defaultedOptions.networkMode = "offlineFirst";
2446
- }
2447
- if (defaultedOptions.queryFn === skipToken) {
2448
- defaultedOptions.enabled = false;
2449
- }
2450
- return defaultedOptions;
2451
- }
2452
- defaultMutationOptions(options) {
2453
- if (options?._defaulted) {
2454
- return options;
2455
- }
2456
- return {
2457
- ...this.#defaultOptions.mutations,
2458
- ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
2459
- ...options,
2460
- _defaulted: true
2461
- };
1845
+ return this.refetchQueries(
1846
+ {
1847
+ ...filters,
1848
+ type: filters?.refetchType ?? filters?.type ?? "active"
1849
+ },
1850
+ options
1851
+ );
1852
+ });
1853
+ }
1854
+ refetchQueries(filters, options = {}) {
1855
+ const fetchOptions = {
1856
+ ...options,
1857
+ cancelRefetch: options.cancelRefetch ?? true
1858
+ };
1859
+ const promises = notifyManager.batch(
1860
+ () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
1861
+ let promise = query.fetch(void 0, fetchOptions);
1862
+ if (!fetchOptions.throwOnError) {
1863
+ promise = promise.catch(noop);
1864
+ }
1865
+ return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
1866
+ })
1867
+ );
1868
+ return Promise.all(promises).then(noop);
1869
+ }
1870
+ fetchQuery(options) {
1871
+ const defaultedOptions = this.defaultQueryOptions(options);
1872
+ if (defaultedOptions.retry === void 0) {
1873
+ defaultedOptions.retry = false;
1874
+ }
1875
+ const query = this.#queryCache.build(this, defaultedOptions);
1876
+ return query.isStaleByTime(
1877
+ resolveStaleTime(defaultedOptions.staleTime, query)
1878
+ ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
1879
+ }
1880
+ prefetchQuery(options) {
1881
+ return this.fetchQuery(options).then(noop).catch(noop);
1882
+ }
1883
+ fetchInfiniteQuery(options) {
1884
+ options.behavior = infiniteQueryBehavior(options.pages);
1885
+ return this.fetchQuery(options);
1886
+ }
1887
+ prefetchInfiniteQuery(options) {
1888
+ return this.fetchInfiniteQuery(options).then(noop).catch(noop);
1889
+ }
1890
+ ensureInfiniteQueryData(options) {
1891
+ options.behavior = infiniteQueryBehavior(options.pages);
1892
+ return this.ensureQueryData(options);
1893
+ }
1894
+ resumePausedMutations() {
1895
+ if (onlineManager.isOnline()) {
1896
+ return this.#mutationCache.resumePausedMutations();
1897
+ }
1898
+ return Promise.resolve();
1899
+ }
1900
+ getQueryCache() {
1901
+ return this.#queryCache;
1902
+ }
1903
+ getMutationCache() {
1904
+ return this.#mutationCache;
1905
+ }
1906
+ getDefaultOptions() {
1907
+ return this.#defaultOptions;
1908
+ }
1909
+ setDefaultOptions(options) {
1910
+ this.#defaultOptions = options;
1911
+ }
1912
+ setQueryDefaults(queryKey, options) {
1913
+ this.#queryDefaults.set(hashKey(queryKey), {
1914
+ queryKey,
1915
+ defaultOptions: options
1916
+ });
1917
+ }
1918
+ getQueryDefaults(queryKey) {
1919
+ const defaults = [...this.#queryDefaults.values()];
1920
+ const result = {};
1921
+ defaults.forEach((queryDefault) => {
1922
+ if (partialMatchKey(queryKey, queryDefault.queryKey)) {
1923
+ Object.assign(result, queryDefault.defaultOptions);
2462
1924
  }
2463
- clear() {
2464
- this.#queryCache.clear();
2465
- this.#mutationCache.clear();
1925
+ });
1926
+ return result;
1927
+ }
1928
+ setMutationDefaults(mutationKey, options) {
1929
+ this.#mutationDefaults.set(hashKey(mutationKey), {
1930
+ mutationKey,
1931
+ defaultOptions: options
1932
+ });
1933
+ }
1934
+ getMutationDefaults(mutationKey) {
1935
+ const defaults = [...this.#mutationDefaults.values()];
1936
+ const result = {};
1937
+ defaults.forEach((queryDefault) => {
1938
+ if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
1939
+ Object.assign(result, queryDefault.defaultOptions);
2466
1940
  }
2467
- };
1941
+ });
1942
+ return result;
2468
1943
  }
2469
- });
2470
-
2471
- // node_modules/@tanstack/query-core/build/modern/types.js
2472
- var dataTagSymbol, dataTagErrorSymbol, unsetMarker;
2473
- var init_types = __esm({
2474
- "node_modules/@tanstack/query-core/build/modern/types.js"() {
2475
- dataTagSymbol = Symbol("dataTagSymbol");
2476
- dataTagErrorSymbol = Symbol("dataTagErrorSymbol");
2477
- unsetMarker = Symbol("unsetMarker");
1944
+ defaultQueryOptions(options) {
1945
+ if (options._defaulted) {
1946
+ return options;
1947
+ }
1948
+ const defaultedOptions = {
1949
+ ...this.#defaultOptions.queries,
1950
+ ...this.getQueryDefaults(options.queryKey),
1951
+ ...options,
1952
+ _defaulted: true
1953
+ };
1954
+ if (!defaultedOptions.queryHash) {
1955
+ defaultedOptions.queryHash = hashQueryKeyByOptions(
1956
+ defaultedOptions.queryKey,
1957
+ defaultedOptions
1958
+ );
1959
+ }
1960
+ if (defaultedOptions.refetchOnReconnect === void 0) {
1961
+ defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
1962
+ }
1963
+ if (defaultedOptions.throwOnError === void 0) {
1964
+ defaultedOptions.throwOnError = !!defaultedOptions.suspense;
1965
+ }
1966
+ if (!defaultedOptions.networkMode && defaultedOptions.persister) {
1967
+ defaultedOptions.networkMode = "offlineFirst";
1968
+ }
1969
+ if (defaultedOptions.queryFn === skipToken) {
1970
+ defaultedOptions.enabled = false;
1971
+ }
1972
+ return defaultedOptions;
2478
1973
  }
2479
- });
2480
-
2481
- // node_modules/@tanstack/query-core/build/modern/index.js
2482
- var init_modern = __esm({
2483
- "node_modules/@tanstack/query-core/build/modern/index.js"() {
2484
- init_queryClient();
2485
- init_types();
1974
+ defaultMutationOptions(options) {
1975
+ if (options?._defaulted) {
1976
+ return options;
1977
+ }
1978
+ return {
1979
+ ...this.#defaultOptions.mutations,
1980
+ ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
1981
+ ...options,
1982
+ _defaulted: true
1983
+ };
2486
1984
  }
2487
- });
2488
-
2489
- // node_modules/@tanstack/react-query/build/modern/types.js
2490
- var init_types2 = __esm({
2491
- "node_modules/@tanstack/react-query/build/modern/types.js"() {
1985
+ clear() {
1986
+ this.#queryCache.clear();
1987
+ this.#mutationCache.clear();
2492
1988
  }
2493
- });
1989
+ };
2494
1990
 
2495
1991
  // node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
2496
- var React, import_jsx_runtime, QueryClientContext, QueryClientProvider;
2497
- var init_QueryClientProvider = __esm({
2498
- "node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js"() {
2499
- "use client";
2500
- React = __toESM(require("react"), 1);
2501
- import_jsx_runtime = require("react/jsx-runtime");
2502
- QueryClientContext = React.createContext(
2503
- void 0
2504
- );
2505
- QueryClientProvider = ({
2506
- client,
2507
- children
2508
- }) => {
2509
- React.useEffect(() => {
2510
- client.mount();
2511
- return () => {
2512
- client.unmount();
2513
- };
2514
- }, [client]);
2515
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, { value: client, children });
1992
+ var React = __toESM(require("react"), 1);
1993
+ var import_jsx_runtime = require("react/jsx-runtime");
1994
+ var QueryClientContext = React.createContext(
1995
+ void 0
1996
+ );
1997
+ var QueryClientProvider = ({
1998
+ client,
1999
+ children
2000
+ }) => {
2001
+ React.useEffect(() => {
2002
+ client.mount();
2003
+ return () => {
2004
+ client.unmount();
2516
2005
  };
2517
- }
2518
- });
2006
+ }, [client]);
2007
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, { value: client, children });
2008
+ };
2519
2009
 
2520
- // node_modules/@tanstack/react-query/build/modern/index.js
2521
- var init_modern2 = __esm({
2522
- "node_modules/@tanstack/react-query/build/modern/index.js"() {
2523
- init_modern();
2524
- init_types2();
2525
- init_QueryClientProvider();
2526
- }
2527
- });
2010
+ // wagmi__providers.tsx
2011
+ var import_wagmi6 = require("wagmi");
2012
+
2013
+ // config/walletConfig.ts
2014
+ var import_wagmi = require("wagmi");
2015
+ var import_chains = require("wagmi/chains");
2016
+ var import_connectors = require("wagmi/connectors");
2528
2017
 
2529
2018
  // chains/core.ts
2530
- var import_viem;
2531
- var init_core = __esm({
2532
- "chains/core.ts"() {
2533
- import_viem = require("viem");
2534
- }
2535
- });
2019
+ var import_viem = require("viem");
2536
2020
 
2537
2021
  // chains/base__sepolia.ts
2022
+ var import_viem2 = require("viem");
2538
2023
  function BaseSepolia() {
2539
2024
  const baseSepolia = (0, import_viem2.defineChain)({
2540
2025
  id: 84532,
@@ -2564,79 +2049,36 @@ function BaseSepolia() {
2564
2049
  });
2565
2050
  return baseSepolia;
2566
2051
  }
2567
- var import_viem2;
2568
- var init_base_sepolia = __esm({
2569
- "chains/base__sepolia.ts"() {
2570
- import_viem2 = require("viem");
2571
- }
2572
- });
2573
-
2574
- // chains/index.ts
2575
- var init_chains = __esm({
2576
- "chains/index.ts"() {
2577
- init_core();
2578
- init_base_sepolia();
2579
- }
2580
- });
2581
2052
 
2582
2053
  // config/walletConfig.ts
2583
- var import_wagmi, import_chains, import_connectors, projectId, config;
2584
- var init_walletConfig = __esm({
2585
- "config/walletConfig.ts"() {
2586
- import_wagmi = require("wagmi");
2587
- import_chains = require("wagmi/chains");
2588
- import_connectors = require("wagmi/connectors");
2589
- init_chains();
2590
- projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
2591
- config = (0, import_wagmi.createConfig)({
2592
- chains: [import_chains.mainnet, import_chains.base, BaseSepolia()],
2593
- connectors: [
2594
- (0, import_connectors.walletConnect)({ projectId })
2595
- ],
2596
- transports: {
2597
- [import_chains.mainnet.id]: (0, import_wagmi.http)(),
2598
- [import_chains.base.id]: (0, import_wagmi.http)(),
2599
- [BaseSepolia().id]: (0, import_wagmi.http)()
2600
- }
2601
- });
2054
+ var projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
2055
+ var config = (0, import_wagmi.createConfig)({
2056
+ chains: [import_chains.mainnet, import_chains.base, BaseSepolia()],
2057
+ connectors: [
2058
+ (0, import_connectors.walletConnect)({ projectId })
2059
+ ],
2060
+ transports: {
2061
+ [import_chains.mainnet.id]: (0, import_wagmi.http)(),
2062
+ [import_chains.base.id]: (0, import_wagmi.http)(),
2063
+ [BaseSepolia().id]: (0, import_wagmi.http)()
2602
2064
  }
2603
2065
  });
2604
2066
 
2605
2067
  // config/Image.json
2606
- var Image_default;
2607
- var init_Image = __esm({
2608
- "config/Image.json"() {
2609
- Image_default = {
2610
- logo: "https://cordy-stack-x.vercel.app/logo.svg"
2611
- };
2612
- }
2613
- });
2068
+ var Image_default = {
2069
+ logo: "https://cordy-stack-x.vercel.app/logo.svg"
2070
+ };
2614
2071
 
2615
2072
  // css/UI_Comp/styles.module.css
2616
- var styles_default;
2617
- var init_styles = __esm({
2618
- "css/UI_Comp/styles.module.css"() {
2619
- styles_default = {};
2620
- }
2621
- });
2073
+ var styles_default = {};
2622
2074
 
2623
2075
  // css/Buttons/styles.module.css
2624
- var styles_default2;
2625
- var init_styles2 = __esm({
2626
- "css/Buttons/styles.module.css"() {
2627
- styles_default2 = {};
2628
- }
2629
- });
2630
-
2631
- // css/index.ts
2632
- var init_css = __esm({
2633
- "css/index.ts"() {
2634
- init_styles();
2635
- init_styles2();
2636
- }
2637
- });
2076
+ var styles_default2 = {};
2638
2077
 
2639
2078
  // controllers/WagmiButton.tsx
2079
+ var import_react = __toESM(require("react"));
2080
+ var import_wagmi2 = require("wagmi");
2081
+ var import_jsx_runtime2 = require("react/jsx-runtime");
2640
2082
  function WalletButton({
2641
2083
  onStatusChange
2642
2084
  }) {
@@ -2652,7 +2094,7 @@ function WalletButton({
2652
2094
  });
2653
2095
  }
2654
2096
  }, [isPending, errorMsg, onStatusChange]);
2655
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: connectors.map((connector) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2097
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: connectors.map((connector) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2656
2098
  WalletOption,
2657
2099
  {
2658
2100
  connector,
@@ -2668,9 +2110,8 @@ function WalletButton({
2668
2110
  }
2669
2111
  },
2670
2112
  isPending: pendingConnector?.uid === connector.uid && isPending
2671
- },
2672
- connector.uid
2673
- )) });
2113
+ }
2114
+ ) }, connector.uid)) });
2674
2115
  }
2675
2116
  function WalletOption({
2676
2117
  connector,
@@ -2686,63 +2127,49 @@ function WalletOption({
2686
2127
  }, [connector]);
2687
2128
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { disabled: !ready || isPending, onClick, children: isPending ? "Connecting..." : connector.name });
2688
2129
  }
2689
- var import_react, import_wagmi2, import_jsx_runtime2;
2690
- var init_WagmiButton = __esm({
2691
- "controllers/WagmiButton.tsx"() {
2692
- "use client";
2693
- import_react = __toESM(require("react"));
2694
- import_wagmi2 = require("wagmi");
2695
- import_jsx_runtime2 = require("react/jsx-runtime");
2696
- }
2697
- });
2698
2130
 
2699
2131
  // controllers/Disconnect.tsx
2132
+ var import_wagmi3 = require("wagmi");
2133
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2700
2134
  function Disconnect() {
2701
2135
  const { disconnect } = (0, import_wagmi3.useDisconnect)();
2702
2136
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { onClick: () => disconnect(), children: "Disconnect" });
2703
2137
  }
2704
- var import_wagmi3, import_jsx_runtime3;
2705
- var init_Disconnect = __esm({
2706
- "controllers/Disconnect.tsx"() {
2707
- import_wagmi3 = require("wagmi");
2708
- import_jsx_runtime3 = require("react/jsx-runtime");
2709
- }
2710
- });
2138
+
2139
+ // controllers/Transactions.tsx
2140
+ var import_ethers = require("ethers");
2711
2141
 
2712
2142
  // config/ERC20_ABI.json
2713
- var ERC20_ABI_default;
2714
- var init_ERC20_ABI = __esm({
2715
- "config/ERC20_ABI.json"() {
2716
- ERC20_ABI_default = [
2717
- {
2718
- constant: true,
2719
- inputs: [{ name: "owner", type: "address" }],
2720
- name: "balanceOf",
2721
- outputs: [{ name: "balance", type: "uint256" }],
2722
- type: "function"
2723
- },
2724
- {
2725
- constant: false,
2726
- inputs: [
2727
- { name: "to", type: "address" },
2728
- { name: "value", type: "uint256" }
2729
- ],
2730
- name: "transfer",
2731
- outputs: [{ name: "", type: "bool" }],
2732
- type: "function"
2733
- },
2734
- {
2735
- constant: true,
2736
- inputs: [],
2737
- name: "decimals",
2738
- outputs: [{ name: "", type: "uint8" }],
2739
- type: "function"
2740
- }
2741
- ];
2742
- }
2743
- });
2143
+ var ERC20_ABI_default = [
2144
+ {
2145
+ constant: true,
2146
+ inputs: [{ name: "owner", type: "address" }],
2147
+ name: "balanceOf",
2148
+ outputs: [{ name: "balance", type: "uint256" }],
2149
+ type: "function"
2150
+ },
2151
+ {
2152
+ constant: false,
2153
+ inputs: [
2154
+ { name: "to", type: "address" },
2155
+ { name: "value", type: "uint256" }
2156
+ ],
2157
+ name: "transfer",
2158
+ outputs: [{ name: "", type: "bool" }],
2159
+ type: "function"
2160
+ },
2161
+ {
2162
+ constant: true,
2163
+ inputs: [],
2164
+ name: "decimals",
2165
+ outputs: [{ name: "", type: "uint8" }],
2166
+ type: "function"
2167
+ }
2168
+ ];
2744
2169
 
2745
2170
  // controllers/Transactions.tsx
2171
+ var tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
2172
+ var platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
2746
2173
  async function CordyStackTrans(address, cost) {
2747
2174
  if (!address) return alert("Address Not Found");
2748
2175
  try {
@@ -2766,17 +2193,9 @@ async function CordyStackTrans(address, cost) {
2766
2193
  console.error(err);
2767
2194
  }
2768
2195
  }
2769
- var import_ethers, tokenAddress, platformAddress;
2770
- var init_Transactions = __esm({
2771
- "controllers/Transactions.tsx"() {
2772
- import_ethers = require("ethers");
2773
- init_ERC20_ABI();
2774
- tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
2775
- platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
2776
- }
2777
- });
2778
2196
 
2779
2197
  // controllers/Get_Balance.tsx
2198
+ var import_ethers2 = require("ethers");
2780
2199
  async function getTokenBalance(address, tokenAddress2) {
2781
2200
  if (!address) return "0";
2782
2201
  try {
@@ -2789,25 +2208,12 @@ async function getTokenBalance(address, tokenAddress2) {
2789
2208
  return "0";
2790
2209
  }
2791
2210
  }
2792
- var import_ethers2;
2793
- var init_Get_Balance = __esm({
2794
- "controllers/Get_Balance.tsx"() {
2795
- import_ethers2 = require("ethers");
2796
- init_ERC20_ABI();
2797
- }
2798
- });
2799
-
2800
- // controllers/index.ts
2801
- var init_controllers = __esm({
2802
- "controllers/index.ts"() {
2803
- init_WagmiButton();
2804
- init_Disconnect();
2805
- init_Transactions();
2806
- init_Get_Balance();
2807
- }
2808
- });
2809
2211
 
2810
2212
  // components/UI_Comp.tsx
2213
+ var import_wagmi4 = require("wagmi");
2214
+ var import_fa = require("react-icons/fa");
2215
+ var import_react2 = require("react");
2216
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2811
2217
  function UI_Comp() {
2812
2218
  const { closeModal } = useWalletModal();
2813
2219
  const { isConnected, address } = (0, import_wagmi4.useAccount)();
@@ -2866,22 +2272,10 @@ function UI_Comp() {
2866
2272
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })
2867
2273
  ] }) });
2868
2274
  }
2869
- var import_wagmi4, import_fa, import_react2, import_jsx_runtime4;
2870
- var init_UI_Comp = __esm({
2871
- "components/UI_Comp.tsx"() {
2872
- "use client";
2873
- init_Image();
2874
- init_css();
2875
- init_controllers();
2876
- init_wagmi_providers();
2877
- import_wagmi4 = require("wagmi");
2878
- import_fa = require("react-icons/fa");
2879
- import_react2 = require("react");
2880
- import_jsx_runtime4 = require("react/jsx-runtime");
2881
- }
2882
- });
2883
2275
 
2884
2276
  // components/Connect_wallet_bt.tsx
2277
+ var import_wagmi5 = require("wagmi");
2278
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2885
2279
  function ConnectWalletBT() {
2886
2280
  const { openModal } = useWalletModal();
2887
2281
  const { isConnected, address } = (0, import_wagmi5.useAccount)();
@@ -2894,31 +2288,11 @@ function ConnectWalletBT() {
2894
2288
  }
2895
2289
  );
2896
2290
  }
2897
- var import_wagmi5, import_jsx_runtime5;
2898
- var init_Connect_wallet_bt = __esm({
2899
- "components/Connect_wallet_bt.tsx"() {
2900
- "use client";
2901
- init_css();
2902
- init_wagmi_providers();
2903
- import_wagmi5 = require("wagmi");
2904
- import_jsx_runtime5 = require("react/jsx-runtime");
2905
- }
2906
- });
2907
-
2908
- // components/index.ts
2909
- var init_components = __esm({
2910
- "components/index.ts"() {
2911
- init_UI_Comp();
2912
- init_Connect_wallet_bt();
2913
- }
2914
- });
2915
2291
 
2916
2292
  // wagmi__providers.tsx
2917
- var wagmi_providers_exports = {};
2918
- __export(wagmi_providers_exports, {
2919
- default: () => WalletProviders,
2920
- useWalletModal: () => useWalletModal
2921
- });
2293
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2294
+ var WalletContext = (0, import_react3.createContext)(null);
2295
+ var queryClient = new QueryClient();
2922
2296
  function WalletProviders({ children }) {
2923
2297
  const [open, setOpen] = (0, import_react3.useState)(false);
2924
2298
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_wagmi6.WagmiProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
@@ -2941,47 +2315,6 @@ function useWalletModal() {
2941
2315
  if (!ctx) throw new Error("Wrap in <WalletProviders>");
2942
2316
  return ctx;
2943
2317
  }
2944
- var import_react3, import_wagmi6, import_jsx_runtime6, WalletContext, queryClient;
2945
- var init_wagmi_providers = __esm({
2946
- "wagmi__providers.tsx"() {
2947
- "use client";
2948
- import_react3 = require("react");
2949
- init_modern2();
2950
- import_wagmi6 = require("wagmi");
2951
- init_walletConfig();
2952
- init_components();
2953
- import_jsx_runtime6 = require("react/jsx-runtime");
2954
- WalletContext = (0, import_react3.createContext)(null);
2955
- queryClient = new QueryClient();
2956
- }
2957
- });
2958
-
2959
- // index.ts
2960
- var index_exports = {};
2961
- __export(index_exports, {
2962
- ConnectWalletBT: () => ConnectWalletBT,
2963
- CordyStackTrans: () => CordyStackTrans,
2964
- Disconnect: () => Disconnect,
2965
- ProvidersClientWrapper: () => ProvidersClientWrapper,
2966
- UI_Comp: () => UI_Comp,
2967
- WalletButton: () => WalletButton,
2968
- getTokenBalance: () => getTokenBalance
2969
- });
2970
- module.exports = __toCommonJS(index_exports);
2971
-
2972
- // client__provider.tsx
2973
- var import_dynamic = __toESM(require_dynamic2());
2974
- var import_jsx_runtime7 = require("react/jsx-runtime");
2975
- var WalletProviders2 = (0, import_dynamic.default)(() => Promise.resolve().then(() => (init_wagmi_providers(), wagmi_providers_exports)), {
2976
- ssr: false
2977
- });
2978
- function ProvidersClientWrapper({ children }) {
2979
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WalletProviders2, { children });
2980
- }
2981
-
2982
- // index.ts
2983
- init_components();
2984
- init_controllers();
2985
2318
  // Annotate the CommonJS export names for ESM import in node:
2986
2319
  0 && (module.exports = {
2987
2320
  ConnectWalletBT,
@@ -2992,4 +2325,3 @@ init_controllers();
2992
2325
  WalletButton,
2993
2326
  getTokenBalance
2994
2327
  });
2995
- //# sourceMappingURL=index.js.map