@cordystackx/cordy_minikit 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2324 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // wagmi__providers.tsx
34
+ import { createContext as createContext2, useContext as useContext2, useState as useState2 } from "react";
35
+
36
+ // node_modules/@tanstack/query-core/build/modern/subscribable.js
37
+ var Subscribable = class {
38
+ constructor() {
39
+ this.listeners = /* @__PURE__ */ new Set();
40
+ this.subscribe = this.subscribe.bind(this);
41
+ }
42
+ subscribe(listener) {
43
+ this.listeners.add(listener);
44
+ this.onSubscribe();
45
+ return () => {
46
+ this.listeners.delete(listener);
47
+ this.onUnsubscribe();
48
+ };
49
+ }
50
+ hasListeners() {
51
+ return this.listeners.size > 0;
52
+ }
53
+ onSubscribe() {
54
+ }
55
+ onUnsubscribe() {
56
+ }
57
+ };
58
+
59
+ // node_modules/@tanstack/query-core/build/modern/timeoutManager.js
60
+ var defaultTimeoutProvider = {
61
+ // We need the wrapper function syntax below instead of direct references to
62
+ // global setTimeout etc.
63
+ //
64
+ // BAD: `setTimeout: setTimeout`
65
+ // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
66
+ //
67
+ // If we use direct references here, then anything that wants to spy on or
68
+ // replace the global setTimeout (like tests) won't work since we'll already
69
+ // have a hard reference to the original implementation at the time when this
70
+ // file was imported.
71
+ setTimeout: (callback, delay) => setTimeout(callback, delay),
72
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
73
+ setInterval: (callback, delay) => setInterval(callback, delay),
74
+ clearInterval: (intervalId) => clearInterval(intervalId)
75
+ };
76
+ var TimeoutManager = class {
77
+ // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
78
+ // type at app boot; and if we leave that type, then any new timer provider
79
+ // would need to support ReturnType<typeof setTimeout>, which is infeasible.
80
+ //
81
+ // We settle for type safety for the TimeoutProvider type, and accept that
82
+ // this class is unsafe internally to allow for extension.
83
+ #provider = defaultTimeoutProvider;
84
+ #providerCalled = false;
85
+ setTimeoutProvider(provider) {
86
+ if (process.env.NODE_ENV !== "production") {
87
+ if (this.#providerCalled && provider !== this.#provider) {
88
+ console.error(
89
+ `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
90
+ { previous: this.#provider, provider }
91
+ );
92
+ }
93
+ }
94
+ this.#provider = provider;
95
+ if (process.env.NODE_ENV !== "production") {
96
+ this.#providerCalled = false;
97
+ }
98
+ }
99
+ setTimeout(callback, delay) {
100
+ if (process.env.NODE_ENV !== "production") {
101
+ this.#providerCalled = true;
102
+ }
103
+ return this.#provider.setTimeout(callback, delay);
104
+ }
105
+ clearTimeout(timeoutId) {
106
+ this.#provider.clearTimeout(timeoutId);
107
+ }
108
+ setInterval(callback, delay) {
109
+ if (process.env.NODE_ENV !== "production") {
110
+ this.#providerCalled = true;
111
+ }
112
+ return this.#provider.setInterval(callback, delay);
113
+ }
114
+ clearInterval(intervalId) {
115
+ this.#provider.clearInterval(intervalId);
116
+ }
117
+ };
118
+ var timeoutManager = new TimeoutManager();
119
+ function systemSetTimeoutZero(callback) {
120
+ setTimeout(callback, 0);
121
+ }
122
+
123
+ // node_modules/@tanstack/query-core/build/modern/utils.js
124
+ var isServer = typeof window === "undefined" || "Deno" in globalThis;
125
+ function noop() {
126
+ }
127
+ function functionalUpdate(updater, input) {
128
+ return typeof updater === "function" ? updater(input) : updater;
129
+ }
130
+ function isValidTimeout(value) {
131
+ return typeof value === "number" && value >= 0 && value !== Infinity;
132
+ }
133
+ function timeUntilStale(updatedAt, staleTime) {
134
+ return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
135
+ }
136
+ function resolveStaleTime(staleTime, query) {
137
+ return typeof staleTime === "function" ? staleTime(query) : staleTime;
138
+ }
139
+ function resolveEnabled(enabled, query) {
140
+ return typeof enabled === "function" ? enabled(query) : enabled;
141
+ }
142
+ function matchQuery(filters, query) {
143
+ const {
144
+ type = "all",
145
+ exact,
146
+ fetchStatus,
147
+ predicate,
148
+ queryKey,
149
+ stale
150
+ } = filters;
151
+ if (queryKey) {
152
+ if (exact) {
153
+ if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
154
+ return false;
155
+ }
156
+ } else if (!partialMatchKey(query.queryKey, queryKey)) {
157
+ return false;
158
+ }
159
+ }
160
+ if (type !== "all") {
161
+ const isActive = query.isActive();
162
+ if (type === "active" && !isActive) {
163
+ return false;
164
+ }
165
+ if (type === "inactive" && isActive) {
166
+ return false;
167
+ }
168
+ }
169
+ if (typeof stale === "boolean" && query.isStale() !== stale) {
170
+ return false;
171
+ }
172
+ if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
173
+ return false;
174
+ }
175
+ if (predicate && !predicate(query)) {
176
+ return false;
177
+ }
178
+ return true;
179
+ }
180
+ function matchMutation(filters, mutation) {
181
+ const { exact, status, predicate, mutationKey } = filters;
182
+ if (mutationKey) {
183
+ if (!mutation.options.mutationKey) {
184
+ return false;
185
+ }
186
+ if (exact) {
187
+ if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
188
+ return false;
189
+ }
190
+ } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
191
+ return false;
192
+ }
193
+ }
194
+ if (status && mutation.state.status !== status) {
195
+ return false;
196
+ }
197
+ if (predicate && !predicate(mutation)) {
198
+ return false;
199
+ }
200
+ return true;
201
+ }
202
+ function hashQueryKeyByOptions(queryKey, options) {
203
+ const hashFn = options?.queryKeyHashFn || hashKey;
204
+ return hashFn(queryKey);
205
+ }
206
+ function hashKey(queryKey) {
207
+ return JSON.stringify(
208
+ queryKey,
209
+ (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
210
+ result[key] = val[key];
211
+ return result;
212
+ }, {}) : val
213
+ );
214
+ }
215
+ function partialMatchKey(a, b) {
216
+ if (a === b) {
217
+ return true;
218
+ }
219
+ if (typeof a !== typeof b) {
220
+ return false;
221
+ }
222
+ if (a && b && typeof a === "object" && typeof b === "object") {
223
+ return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
224
+ }
225
+ return false;
226
+ }
227
+ var hasOwn = Object.prototype.hasOwnProperty;
228
+ function replaceEqualDeep(a, b) {
229
+ if (a === b) {
230
+ return a;
231
+ }
232
+ const array = isPlainArray(a) && isPlainArray(b);
233
+ if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
234
+ const aItems = array ? a : Object.keys(a);
235
+ const aSize = aItems.length;
236
+ const bItems = array ? b : Object.keys(b);
237
+ const bSize = bItems.length;
238
+ const copy = array ? new Array(bSize) : {};
239
+ let equalItems = 0;
240
+ for (let i = 0; i < bSize; i++) {
241
+ const key = array ? i : bItems[i];
242
+ const aItem = a[key];
243
+ const bItem = b[key];
244
+ if (aItem === bItem) {
245
+ copy[key] = aItem;
246
+ if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
247
+ continue;
248
+ }
249
+ if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
250
+ copy[key] = bItem;
251
+ continue;
252
+ }
253
+ const v = replaceEqualDeep(aItem, bItem);
254
+ copy[key] = v;
255
+ if (v === aItem) equalItems++;
256
+ }
257
+ return aSize === bSize && equalItems === aSize ? a : copy;
258
+ }
259
+ function isPlainArray(value) {
260
+ return Array.isArray(value) && value.length === Object.keys(value).length;
261
+ }
262
+ function isPlainObject(o) {
263
+ if (!hasObjectPrototype(o)) {
264
+ return false;
265
+ }
266
+ const ctor = o.constructor;
267
+ if (ctor === void 0) {
268
+ return true;
269
+ }
270
+ const prot = ctor.prototype;
271
+ if (!hasObjectPrototype(prot)) {
272
+ return false;
273
+ }
274
+ if (!prot.hasOwnProperty("isPrototypeOf")) {
275
+ return false;
276
+ }
277
+ if (Object.getPrototypeOf(o) !== Object.prototype) {
278
+ return false;
279
+ }
280
+ return true;
281
+ }
282
+ function hasObjectPrototype(o) {
283
+ return Object.prototype.toString.call(o) === "[object Object]";
284
+ }
285
+ function sleep(timeout) {
286
+ return new Promise((resolve) => {
287
+ timeoutManager.setTimeout(resolve, timeout);
288
+ });
289
+ }
290
+ function replaceData(prevData, data, options) {
291
+ if (typeof options.structuralSharing === "function") {
292
+ return options.structuralSharing(prevData, data);
293
+ } else if (options.structuralSharing !== false) {
294
+ if (process.env.NODE_ENV !== "production") {
295
+ try {
296
+ return replaceEqualDeep(prevData, data);
297
+ } catch (error) {
298
+ console.error(
299
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
300
+ );
301
+ throw error;
302
+ }
303
+ }
304
+ return replaceEqualDeep(prevData, data);
305
+ }
306
+ return data;
307
+ }
308
+ function addToEnd(items, item, max = 0) {
309
+ const newItems = [...items, item];
310
+ return max && newItems.length > max ? newItems.slice(1) : newItems;
311
+ }
312
+ function addToStart(items, item, max = 0) {
313
+ const newItems = [item, ...items];
314
+ return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
315
+ }
316
+ var skipToken = Symbol();
317
+ function ensureQueryFn(options, fetchOptions) {
318
+ if (process.env.NODE_ENV !== "production") {
319
+ if (options.queryFn === skipToken) {
320
+ console.error(
321
+ `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
322
+ );
323
+ }
324
+ }
325
+ if (!options.queryFn && fetchOptions?.initialPromise) {
326
+ return () => fetchOptions.initialPromise;
327
+ }
328
+ if (!options.queryFn || options.queryFn === skipToken) {
329
+ return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
330
+ }
331
+ return options.queryFn;
332
+ }
333
+
334
+ // node_modules/@tanstack/query-core/build/modern/focusManager.js
335
+ var FocusManager = class extends Subscribable {
336
+ #focused;
337
+ #cleanup;
338
+ #setup;
339
+ constructor() {
340
+ super();
341
+ this.#setup = (onFocus) => {
342
+ if (!isServer && window.addEventListener) {
343
+ const listener = () => onFocus();
344
+ window.addEventListener("visibilitychange", listener, false);
345
+ return () => {
346
+ window.removeEventListener("visibilitychange", listener);
347
+ };
348
+ }
349
+ return;
350
+ };
351
+ }
352
+ onSubscribe() {
353
+ if (!this.#cleanup) {
354
+ this.setEventListener(this.#setup);
355
+ }
356
+ }
357
+ onUnsubscribe() {
358
+ if (!this.hasListeners()) {
359
+ this.#cleanup?.();
360
+ this.#cleanup = void 0;
361
+ }
362
+ }
363
+ setEventListener(setup) {
364
+ this.#setup = setup;
365
+ this.#cleanup?.();
366
+ this.#cleanup = setup((focused) => {
367
+ if (typeof focused === "boolean") {
368
+ this.setFocused(focused);
369
+ } else {
370
+ this.onFocus();
371
+ }
372
+ });
373
+ }
374
+ setFocused(focused) {
375
+ const changed = this.#focused !== focused;
376
+ if (changed) {
377
+ this.#focused = focused;
378
+ this.onFocus();
379
+ }
380
+ }
381
+ onFocus() {
382
+ const isFocused = this.isFocused();
383
+ this.listeners.forEach((listener) => {
384
+ listener(isFocused);
385
+ });
386
+ }
387
+ isFocused() {
388
+ if (typeof this.#focused === "boolean") {
389
+ return this.#focused;
390
+ }
391
+ return globalThis.document?.visibilityState !== "hidden";
392
+ }
393
+ };
394
+ var focusManager = new FocusManager();
395
+
396
+ // node_modules/@tanstack/query-core/build/modern/thenable.js
397
+ function pendingThenable() {
398
+ let resolve;
399
+ let reject;
400
+ const thenable = new Promise((_resolve, _reject) => {
401
+ resolve = _resolve;
402
+ reject = _reject;
403
+ });
404
+ thenable.status = "pending";
405
+ thenable.catch(() => {
406
+ });
407
+ function finalize(data) {
408
+ Object.assign(thenable, data);
409
+ delete thenable.resolve;
410
+ delete thenable.reject;
411
+ }
412
+ thenable.resolve = (value) => {
413
+ finalize({
414
+ status: "fulfilled",
415
+ value
416
+ });
417
+ resolve(value);
418
+ };
419
+ thenable.reject = (reason) => {
420
+ finalize({
421
+ status: "rejected",
422
+ reason
423
+ });
424
+ reject(reason);
425
+ };
426
+ return thenable;
427
+ }
428
+
429
+ // node_modules/@tanstack/query-core/build/modern/notifyManager.js
430
+ var defaultScheduler = systemSetTimeoutZero;
431
+ function createNotifyManager() {
432
+ let queue = [];
433
+ let transactions = 0;
434
+ let notifyFn = (callback) => {
435
+ callback();
436
+ };
437
+ let batchNotifyFn = (callback) => {
438
+ callback();
439
+ };
440
+ let scheduleFn = defaultScheduler;
441
+ const schedule = (callback) => {
442
+ if (transactions) {
443
+ queue.push(callback);
444
+ } else {
445
+ scheduleFn(() => {
446
+ notifyFn(callback);
447
+ });
448
+ }
449
+ };
450
+ const flush = () => {
451
+ const originalQueue = queue;
452
+ queue = [];
453
+ if (originalQueue.length) {
454
+ scheduleFn(() => {
455
+ batchNotifyFn(() => {
456
+ originalQueue.forEach((callback) => {
457
+ notifyFn(callback);
458
+ });
459
+ });
460
+ });
461
+ }
462
+ };
463
+ return {
464
+ batch: (callback) => {
465
+ let result;
466
+ transactions++;
467
+ try {
468
+ result = callback();
469
+ } finally {
470
+ transactions--;
471
+ if (!transactions) {
472
+ flush();
473
+ }
474
+ }
475
+ return result;
476
+ },
477
+ /**
478
+ * All calls to the wrapped function will be batched.
479
+ */
480
+ batchCalls: (callback) => {
481
+ return (...args) => {
482
+ schedule(() => {
483
+ callback(...args);
484
+ });
485
+ };
486
+ },
487
+ schedule,
488
+ /**
489
+ * Use this method to set a custom notify function.
490
+ * This can be used to for example wrap notifications with `React.act` while running tests.
491
+ */
492
+ setNotifyFunction: (fn) => {
493
+ notifyFn = fn;
494
+ },
495
+ /**
496
+ * Use this method to set a custom function to batch notifications together into a single tick.
497
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
498
+ */
499
+ setBatchNotifyFunction: (fn) => {
500
+ batchNotifyFn = fn;
501
+ },
502
+ setScheduler: (fn) => {
503
+ scheduleFn = fn;
504
+ }
505
+ };
506
+ }
507
+ var notifyManager = createNotifyManager();
508
+
509
+ // node_modules/@tanstack/query-core/build/modern/onlineManager.js
510
+ var OnlineManager = class extends Subscribable {
511
+ #online = true;
512
+ #cleanup;
513
+ #setup;
514
+ constructor() {
515
+ super();
516
+ this.#setup = (onOnline) => {
517
+ if (!isServer && window.addEventListener) {
518
+ const onlineListener = () => onOnline(true);
519
+ const offlineListener = () => onOnline(false);
520
+ window.addEventListener("online", onlineListener, false);
521
+ window.addEventListener("offline", offlineListener, false);
522
+ return () => {
523
+ window.removeEventListener("online", onlineListener);
524
+ window.removeEventListener("offline", offlineListener);
525
+ };
526
+ }
527
+ return;
528
+ };
529
+ }
530
+ onSubscribe() {
531
+ if (!this.#cleanup) {
532
+ this.setEventListener(this.#setup);
533
+ }
534
+ }
535
+ onUnsubscribe() {
536
+ if (!this.hasListeners()) {
537
+ this.#cleanup?.();
538
+ this.#cleanup = void 0;
539
+ }
540
+ }
541
+ setEventListener(setup) {
542
+ this.#setup = setup;
543
+ this.#cleanup?.();
544
+ this.#cleanup = setup(this.setOnline.bind(this));
545
+ }
546
+ setOnline(online) {
547
+ const changed = this.#online !== online;
548
+ if (changed) {
549
+ this.#online = online;
550
+ this.listeners.forEach((listener) => {
551
+ listener(online);
552
+ });
553
+ }
554
+ }
555
+ isOnline() {
556
+ return this.#online;
557
+ }
558
+ };
559
+ var onlineManager = new OnlineManager();
560
+
561
+ // node_modules/@tanstack/query-core/build/modern/retryer.js
562
+ function defaultRetryDelay(failureCount) {
563
+ return Math.min(1e3 * 2 ** failureCount, 3e4);
564
+ }
565
+ function canFetch(networkMode) {
566
+ return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
567
+ }
568
+ var CancelledError = class extends Error {
569
+ constructor(options) {
570
+ super("CancelledError");
571
+ this.revert = options?.revert;
572
+ this.silent = options?.silent;
573
+ }
574
+ };
575
+ function createRetryer(config2) {
576
+ let isRetryCancelled = false;
577
+ let failureCount = 0;
578
+ let continueFn;
579
+ const thenable = pendingThenable();
580
+ const isResolved = () => thenable.status !== "pending";
581
+ const cancel = (cancelOptions) => {
582
+ if (!isResolved()) {
583
+ const error = new CancelledError(cancelOptions);
584
+ reject(error);
585
+ config2.onCancel?.(error);
586
+ }
587
+ };
588
+ const cancelRetry = () => {
589
+ isRetryCancelled = true;
590
+ };
591
+ const continueRetry = () => {
592
+ isRetryCancelled = false;
593
+ };
594
+ const canContinue = () => focusManager.isFocused() && (config2.networkMode === "always" || onlineManager.isOnline()) && config2.canRun();
595
+ const canStart = () => canFetch(config2.networkMode) && config2.canRun();
596
+ const resolve = (value) => {
597
+ if (!isResolved()) {
598
+ continueFn?.();
599
+ thenable.resolve(value);
600
+ }
601
+ };
602
+ const reject = (value) => {
603
+ if (!isResolved()) {
604
+ continueFn?.();
605
+ thenable.reject(value);
606
+ }
607
+ };
608
+ const pause = () => {
609
+ return new Promise((continueResolve) => {
610
+ continueFn = (value) => {
611
+ if (isResolved() || canContinue()) {
612
+ continueResolve(value);
613
+ }
614
+ };
615
+ config2.onPause?.();
616
+ }).then(() => {
617
+ continueFn = void 0;
618
+ if (!isResolved()) {
619
+ config2.onContinue?.();
620
+ }
621
+ });
622
+ };
623
+ const run = () => {
624
+ if (isResolved()) {
625
+ return;
626
+ }
627
+ let promiseOrValue;
628
+ const initialPromise = failureCount === 0 ? config2.initialPromise : void 0;
629
+ try {
630
+ promiseOrValue = initialPromise ?? config2.fn();
631
+ } catch (error) {
632
+ promiseOrValue = Promise.reject(error);
633
+ }
634
+ Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
635
+ if (isResolved()) {
636
+ return;
637
+ }
638
+ const retry = config2.retry ?? (isServer ? 0 : 3);
639
+ const retryDelay = config2.retryDelay ?? defaultRetryDelay;
640
+ const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
641
+ const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
642
+ if (isRetryCancelled || !shouldRetry) {
643
+ reject(error);
644
+ return;
645
+ }
646
+ failureCount++;
647
+ config2.onFail?.(failureCount, error);
648
+ sleep(delay).then(() => {
649
+ return canContinue() ? void 0 : pause();
650
+ }).then(() => {
651
+ if (isRetryCancelled) {
652
+ reject(error);
653
+ } else {
654
+ run();
655
+ }
656
+ });
657
+ });
658
+ };
659
+ return {
660
+ promise: thenable,
661
+ status: () => thenable.status,
662
+ cancel,
663
+ continue: () => {
664
+ continueFn?.();
665
+ return thenable;
666
+ },
667
+ cancelRetry,
668
+ continueRetry,
669
+ canStart,
670
+ start: () => {
671
+ if (canStart()) {
672
+ run();
673
+ } else {
674
+ pause().then(run);
675
+ }
676
+ return thenable;
677
+ }
678
+ };
679
+ }
680
+
681
+ // node_modules/@tanstack/query-core/build/modern/removable.js
682
+ var Removable = class {
683
+ #gcTimeout;
684
+ destroy() {
685
+ this.clearGcTimeout();
686
+ }
687
+ scheduleGc() {
688
+ this.clearGcTimeout();
689
+ if (isValidTimeout(this.gcTime)) {
690
+ this.#gcTimeout = timeoutManager.setTimeout(() => {
691
+ this.optionalRemove();
692
+ }, this.gcTime);
693
+ }
694
+ }
695
+ updateGcTime(newGcTime) {
696
+ this.gcTime = Math.max(
697
+ this.gcTime || 0,
698
+ newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
699
+ );
700
+ }
701
+ clearGcTimeout() {
702
+ if (this.#gcTimeout) {
703
+ timeoutManager.clearTimeout(this.#gcTimeout);
704
+ this.#gcTimeout = void 0;
705
+ }
706
+ }
707
+ };
708
+
709
+ // node_modules/@tanstack/query-core/build/modern/query.js
710
+ var Query = class extends Removable {
711
+ #initialState;
712
+ #revertState;
713
+ #cache;
714
+ #client;
715
+ #retryer;
716
+ #defaultOptions;
717
+ #abortSignalConsumed;
718
+ constructor(config2) {
719
+ super();
720
+ this.#abortSignalConsumed = false;
721
+ this.#defaultOptions = config2.defaultOptions;
722
+ this.setOptions(config2.options);
723
+ this.observers = [];
724
+ this.#client = config2.client;
725
+ this.#cache = this.#client.getQueryCache();
726
+ this.queryKey = config2.queryKey;
727
+ this.queryHash = config2.queryHash;
728
+ this.#initialState = getDefaultState(this.options);
729
+ this.state = config2.state ?? this.#initialState;
730
+ this.scheduleGc();
731
+ }
732
+ get meta() {
733
+ return this.options.meta;
734
+ }
735
+ get promise() {
736
+ return this.#retryer?.promise;
737
+ }
738
+ setOptions(options) {
739
+ this.options = { ...this.#defaultOptions, ...options };
740
+ this.updateGcTime(this.options.gcTime);
741
+ if (this.state && this.state.data === void 0) {
742
+ const defaultState = getDefaultState(this.options);
743
+ if (defaultState.data !== void 0) {
744
+ this.setData(defaultState.data, {
745
+ updatedAt: defaultState.dataUpdatedAt,
746
+ manual: true
747
+ });
748
+ this.#initialState = defaultState;
749
+ }
750
+ }
751
+ }
752
+ optionalRemove() {
753
+ if (!this.observers.length && this.state.fetchStatus === "idle") {
754
+ this.#cache.remove(this);
755
+ }
756
+ }
757
+ setData(newData, options) {
758
+ const data = replaceData(this.state.data, newData, this.options);
759
+ this.#dispatch({
760
+ data,
761
+ type: "success",
762
+ dataUpdatedAt: options?.updatedAt,
763
+ manual: options?.manual
764
+ });
765
+ return data;
766
+ }
767
+ setState(state, setStateOptions) {
768
+ this.#dispatch({ type: "setState", state, setStateOptions });
769
+ }
770
+ cancel(options) {
771
+ const promise = this.#retryer?.promise;
772
+ this.#retryer?.cancel(options);
773
+ return promise ? promise.then(noop).catch(noop) : Promise.resolve();
774
+ }
775
+ destroy() {
776
+ super.destroy();
777
+ this.cancel({ silent: true });
778
+ }
779
+ reset() {
780
+ this.destroy();
781
+ this.setState(this.#initialState);
782
+ }
783
+ isActive() {
784
+ return this.observers.some(
785
+ (observer) => resolveEnabled(observer.options.enabled, this) !== false
786
+ );
787
+ }
788
+ isDisabled() {
789
+ if (this.getObserversCount() > 0) {
790
+ return !this.isActive();
791
+ }
792
+ return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
793
+ }
794
+ isStatic() {
795
+ if (this.getObserversCount() > 0) {
796
+ return this.observers.some(
797
+ (observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
798
+ );
799
+ }
800
+ return false;
801
+ }
802
+ isStale() {
803
+ if (this.getObserversCount() > 0) {
804
+ return this.observers.some(
805
+ (observer) => observer.getCurrentResult().isStale
806
+ );
807
+ }
808
+ return this.state.data === void 0 || this.state.isInvalidated;
809
+ }
810
+ isStaleByTime(staleTime = 0) {
811
+ if (this.state.data === void 0) {
812
+ return true;
813
+ }
814
+ if (staleTime === "static") {
815
+ return false;
816
+ }
817
+ if (this.state.isInvalidated) {
818
+ return true;
819
+ }
820
+ return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
821
+ }
822
+ onFocus() {
823
+ const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
824
+ observer?.refetch({ cancelRefetch: false });
825
+ this.#retryer?.continue();
826
+ }
827
+ onOnline() {
828
+ const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
829
+ observer?.refetch({ cancelRefetch: false });
830
+ this.#retryer?.continue();
831
+ }
832
+ addObserver(observer) {
833
+ if (!this.observers.includes(observer)) {
834
+ this.observers.push(observer);
835
+ this.clearGcTimeout();
836
+ this.#cache.notify({ type: "observerAdded", query: this, observer });
837
+ }
838
+ }
839
+ removeObserver(observer) {
840
+ if (this.observers.includes(observer)) {
841
+ this.observers = this.observers.filter((x) => x !== observer);
842
+ if (!this.observers.length) {
843
+ if (this.#retryer) {
844
+ if (this.#abortSignalConsumed) {
845
+ this.#retryer.cancel({ revert: true });
846
+ } else {
847
+ this.#retryer.cancelRetry();
848
+ }
849
+ }
850
+ this.scheduleGc();
851
+ }
852
+ this.#cache.notify({ type: "observerRemoved", query: this, observer });
853
+ }
854
+ }
855
+ getObserversCount() {
856
+ return this.observers.length;
857
+ }
858
+ invalidate() {
859
+ if (!this.state.isInvalidated) {
860
+ this.#dispatch({ type: "invalidate" });
861
+ }
862
+ }
863
+ async fetch(options, fetchOptions) {
864
+ if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
865
+ // re-start the fetch; there is a chance that the query is still in a
866
+ // pending state when that happens
867
+ this.#retryer?.status() !== "rejected") {
868
+ if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
869
+ this.cancel({ silent: true });
870
+ } else if (this.#retryer) {
871
+ this.#retryer.continueRetry();
872
+ return this.#retryer.promise;
873
+ }
874
+ }
875
+ if (options) {
876
+ this.setOptions(options);
877
+ }
878
+ if (!this.options.queryFn) {
879
+ const observer = this.observers.find((x) => x.options.queryFn);
880
+ if (observer) {
881
+ this.setOptions(observer.options);
882
+ }
883
+ }
884
+ if (process.env.NODE_ENV !== "production") {
885
+ if (!Array.isArray(this.options.queryKey)) {
886
+ console.error(
887
+ `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']`
888
+ );
889
+ }
890
+ }
891
+ const abortController = new AbortController();
892
+ const addSignalProperty = (object) => {
893
+ Object.defineProperty(object, "signal", {
894
+ enumerable: true,
895
+ get: () => {
896
+ this.#abortSignalConsumed = true;
897
+ return abortController.signal;
898
+ }
899
+ });
900
+ };
901
+ const fetchFn = () => {
902
+ const queryFn = ensureQueryFn(this.options, fetchOptions);
903
+ const createQueryFnContext = () => {
904
+ const queryFnContext2 = {
905
+ client: this.#client,
906
+ queryKey: this.queryKey,
907
+ meta: this.meta
908
+ };
909
+ addSignalProperty(queryFnContext2);
910
+ return queryFnContext2;
911
+ };
912
+ const queryFnContext = createQueryFnContext();
913
+ this.#abortSignalConsumed = false;
914
+ if (this.options.persister) {
915
+ return this.options.persister(
916
+ queryFn,
917
+ queryFnContext,
918
+ this
919
+ );
920
+ }
921
+ return queryFn(queryFnContext);
922
+ };
923
+ const createFetchContext = () => {
924
+ const context2 = {
925
+ fetchOptions,
926
+ options: this.options,
927
+ queryKey: this.queryKey,
928
+ client: this.#client,
929
+ state: this.state,
930
+ fetchFn
931
+ };
932
+ addSignalProperty(context2);
933
+ return context2;
934
+ };
935
+ const context = createFetchContext();
936
+ this.options.behavior?.onFetch(context, this);
937
+ this.#revertState = this.state;
938
+ if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
939
+ this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
940
+ }
941
+ this.#retryer = createRetryer({
942
+ initialPromise: fetchOptions?.initialPromise,
943
+ fn: context.fetchFn,
944
+ onCancel: (error) => {
945
+ if (error instanceof CancelledError && error.revert) {
946
+ this.setState({
947
+ ...this.#revertState,
948
+ fetchStatus: "idle"
949
+ });
950
+ }
951
+ abortController.abort();
952
+ },
953
+ onFail: (failureCount, error) => {
954
+ this.#dispatch({ type: "failed", failureCount, error });
955
+ },
956
+ onPause: () => {
957
+ this.#dispatch({ type: "pause" });
958
+ },
959
+ onContinue: () => {
960
+ this.#dispatch({ type: "continue" });
961
+ },
962
+ retry: context.options.retry,
963
+ retryDelay: context.options.retryDelay,
964
+ networkMode: context.options.networkMode,
965
+ canRun: () => true
966
+ });
967
+ try {
968
+ const data = await this.#retryer.start();
969
+ if (data === void 0) {
970
+ if (process.env.NODE_ENV !== "production") {
971
+ console.error(
972
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
973
+ );
974
+ }
975
+ throw new Error(`${this.queryHash} data is undefined`);
976
+ }
977
+ this.setData(data);
978
+ this.#cache.config.onSuccess?.(data, this);
979
+ this.#cache.config.onSettled?.(
980
+ data,
981
+ this.state.error,
982
+ this
983
+ );
984
+ return data;
985
+ } catch (error) {
986
+ if (error instanceof CancelledError) {
987
+ if (error.silent) {
988
+ return this.#retryer.promise;
989
+ } else if (error.revert) {
990
+ if (this.state.data === void 0) {
991
+ throw error;
992
+ }
993
+ return this.state.data;
994
+ }
995
+ }
996
+ this.#dispatch({
997
+ type: "error",
998
+ error
999
+ });
1000
+ this.#cache.config.onError?.(
1001
+ error,
1002
+ this
1003
+ );
1004
+ this.#cache.config.onSettled?.(
1005
+ this.state.data,
1006
+ error,
1007
+ this
1008
+ );
1009
+ throw error;
1010
+ } finally {
1011
+ this.scheduleGc();
1012
+ }
1013
+ }
1014
+ #dispatch(action) {
1015
+ const reducer = (state) => {
1016
+ switch (action.type) {
1017
+ case "failed":
1018
+ return {
1019
+ ...state,
1020
+ fetchFailureCount: action.failureCount,
1021
+ fetchFailureReason: action.error
1022
+ };
1023
+ case "pause":
1024
+ return {
1025
+ ...state,
1026
+ fetchStatus: "paused"
1027
+ };
1028
+ case "continue":
1029
+ return {
1030
+ ...state,
1031
+ fetchStatus: "fetching"
1032
+ };
1033
+ case "fetch":
1034
+ return {
1035
+ ...state,
1036
+ ...fetchState(state.data, this.options),
1037
+ fetchMeta: action.meta ?? null
1038
+ };
1039
+ case "success":
1040
+ const newState = {
1041
+ ...state,
1042
+ data: action.data,
1043
+ dataUpdateCount: state.dataUpdateCount + 1,
1044
+ dataUpdatedAt: action.dataUpdatedAt ?? Date.now(),
1045
+ error: null,
1046
+ isInvalidated: false,
1047
+ status: "success",
1048
+ ...!action.manual && {
1049
+ fetchStatus: "idle",
1050
+ fetchFailureCount: 0,
1051
+ fetchFailureReason: null
1052
+ }
1053
+ };
1054
+ this.#revertState = action.manual ? newState : void 0;
1055
+ return newState;
1056
+ case "error":
1057
+ const error = action.error;
1058
+ return {
1059
+ ...state,
1060
+ error,
1061
+ errorUpdateCount: state.errorUpdateCount + 1,
1062
+ errorUpdatedAt: Date.now(),
1063
+ fetchFailureCount: state.fetchFailureCount + 1,
1064
+ fetchFailureReason: error,
1065
+ fetchStatus: "idle",
1066
+ status: "error"
1067
+ };
1068
+ case "invalidate":
1069
+ return {
1070
+ ...state,
1071
+ isInvalidated: true
1072
+ };
1073
+ case "setState":
1074
+ return {
1075
+ ...state,
1076
+ ...action.state
1077
+ };
1078
+ }
1079
+ };
1080
+ this.state = reducer(this.state);
1081
+ notifyManager.batch(() => {
1082
+ this.observers.forEach((observer) => {
1083
+ observer.onQueryUpdate();
1084
+ });
1085
+ this.#cache.notify({ query: this, type: "updated", action });
1086
+ });
1087
+ }
1088
+ };
1089
+ function fetchState(data, options) {
1090
+ return {
1091
+ fetchFailureCount: 0,
1092
+ fetchFailureReason: null,
1093
+ fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1094
+ ...data === void 0 && {
1095
+ error: null,
1096
+ status: "pending"
1097
+ }
1098
+ };
1099
+ }
1100
+ function getDefaultState(options) {
1101
+ const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
1102
+ const hasData = data !== void 0;
1103
+ const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
1104
+ return {
1105
+ data,
1106
+ dataUpdateCount: 0,
1107
+ dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
1108
+ error: null,
1109
+ errorUpdateCount: 0,
1110
+ errorUpdatedAt: 0,
1111
+ fetchFailureCount: 0,
1112
+ fetchFailureReason: null,
1113
+ fetchMeta: null,
1114
+ isInvalidated: false,
1115
+ status: hasData ? "success" : "pending",
1116
+ fetchStatus: "idle"
1117
+ };
1118
+ }
1119
+
1120
+ // node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
1121
+ function infiniteQueryBehavior(pages) {
1122
+ return {
1123
+ onFetch: (context, query) => {
1124
+ const options = context.options;
1125
+ const direction = context.fetchOptions?.meta?.fetchMore?.direction;
1126
+ const oldPages = context.state.data?.pages || [];
1127
+ const oldPageParams = context.state.data?.pageParams || [];
1128
+ let result = { pages: [], pageParams: [] };
1129
+ let currentPage = 0;
1130
+ const fetchFn = async () => {
1131
+ let cancelled = false;
1132
+ const addSignalProperty = (object) => {
1133
+ Object.defineProperty(object, "signal", {
1134
+ enumerable: true,
1135
+ get: () => {
1136
+ if (context.signal.aborted) {
1137
+ cancelled = true;
1138
+ } else {
1139
+ context.signal.addEventListener("abort", () => {
1140
+ cancelled = true;
1141
+ });
1142
+ }
1143
+ return context.signal;
1144
+ }
1145
+ });
1146
+ };
1147
+ const queryFn = ensureQueryFn(context.options, context.fetchOptions);
1148
+ const fetchPage = async (data, param, previous) => {
1149
+ if (cancelled) {
1150
+ return Promise.reject();
1151
+ }
1152
+ if (param == null && data.pages.length) {
1153
+ return Promise.resolve(data);
1154
+ }
1155
+ const createQueryFnContext = () => {
1156
+ const queryFnContext2 = {
1157
+ client: context.client,
1158
+ queryKey: context.queryKey,
1159
+ pageParam: param,
1160
+ direction: previous ? "backward" : "forward",
1161
+ meta: context.options.meta
1162
+ };
1163
+ addSignalProperty(queryFnContext2);
1164
+ return queryFnContext2;
1165
+ };
1166
+ const queryFnContext = createQueryFnContext();
1167
+ const page = await queryFn(queryFnContext);
1168
+ const { maxPages } = context.options;
1169
+ const addTo = previous ? addToStart : addToEnd;
1170
+ return {
1171
+ pages: addTo(data.pages, page, maxPages),
1172
+ pageParams: addTo(data.pageParams, param, maxPages)
1173
+ };
1174
+ };
1175
+ if (direction && oldPages.length) {
1176
+ const previous = direction === "backward";
1177
+ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
1178
+ const oldData = {
1179
+ pages: oldPages,
1180
+ pageParams: oldPageParams
1181
+ };
1182
+ const param = pageParamFn(options, oldData);
1183
+ result = await fetchPage(oldData, param, previous);
1184
+ } else {
1185
+ const remainingPages = pages ?? oldPages.length;
1186
+ do {
1187
+ const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
1188
+ if (currentPage > 0 && param == null) {
1189
+ break;
1190
+ }
1191
+ result = await fetchPage(result, param);
1192
+ currentPage++;
1193
+ } while (currentPage < remainingPages);
1194
+ }
1195
+ return result;
1196
+ };
1197
+ if (context.options.persister) {
1198
+ context.fetchFn = () => {
1199
+ return context.options.persister?.(
1200
+ fetchFn,
1201
+ {
1202
+ client: context.client,
1203
+ queryKey: context.queryKey,
1204
+ meta: context.options.meta,
1205
+ signal: context.signal
1206
+ },
1207
+ query
1208
+ );
1209
+ };
1210
+ } else {
1211
+ context.fetchFn = fetchFn;
1212
+ }
1213
+ }
1214
+ };
1215
+ }
1216
+ function getNextPageParam(options, { pages, pageParams }) {
1217
+ const lastIndex = pages.length - 1;
1218
+ return pages.length > 0 ? options.getNextPageParam(
1219
+ pages[lastIndex],
1220
+ pages,
1221
+ pageParams[lastIndex],
1222
+ pageParams
1223
+ ) : void 0;
1224
+ }
1225
+ function getPreviousPageParam(options, { pages, pageParams }) {
1226
+ return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
1227
+ }
1228
+
1229
+ // node_modules/@tanstack/query-core/build/modern/mutation.js
1230
+ var Mutation = class extends Removable {
1231
+ #client;
1232
+ #observers;
1233
+ #mutationCache;
1234
+ #retryer;
1235
+ constructor(config2) {
1236
+ super();
1237
+ this.#client = config2.client;
1238
+ this.mutationId = config2.mutationId;
1239
+ this.#mutationCache = config2.mutationCache;
1240
+ this.#observers = [];
1241
+ this.state = config2.state || getDefaultState2();
1242
+ this.setOptions(config2.options);
1243
+ this.scheduleGc();
1244
+ }
1245
+ setOptions(options) {
1246
+ this.options = options;
1247
+ this.updateGcTime(this.options.gcTime);
1248
+ }
1249
+ get meta() {
1250
+ return this.options.meta;
1251
+ }
1252
+ addObserver(observer) {
1253
+ if (!this.#observers.includes(observer)) {
1254
+ this.#observers.push(observer);
1255
+ this.clearGcTimeout();
1256
+ this.#mutationCache.notify({
1257
+ type: "observerAdded",
1258
+ mutation: this,
1259
+ observer
1260
+ });
1261
+ }
1262
+ }
1263
+ removeObserver(observer) {
1264
+ this.#observers = this.#observers.filter((x) => x !== observer);
1265
+ this.scheduleGc();
1266
+ this.#mutationCache.notify({
1267
+ type: "observerRemoved",
1268
+ mutation: this,
1269
+ observer
1270
+ });
1271
+ }
1272
+ optionalRemove() {
1273
+ if (!this.#observers.length) {
1274
+ if (this.state.status === "pending") {
1275
+ this.scheduleGc();
1276
+ } else {
1277
+ this.#mutationCache.remove(this);
1278
+ }
1279
+ }
1280
+ }
1281
+ continue() {
1282
+ return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
1283
+ this.execute(this.state.variables);
1284
+ }
1285
+ async execute(variables) {
1286
+ const onContinue = () => {
1287
+ this.#dispatch({ type: "continue" });
1288
+ };
1289
+ const mutationFnContext = {
1290
+ client: this.#client,
1291
+ meta: this.options.meta,
1292
+ mutationKey: this.options.mutationKey
1293
+ };
1294
+ this.#retryer = createRetryer({
1295
+ fn: () => {
1296
+ if (!this.options.mutationFn) {
1297
+ return Promise.reject(new Error("No mutationFn found"));
1298
+ }
1299
+ return this.options.mutationFn(variables, mutationFnContext);
1300
+ },
1301
+ onFail: (failureCount, error) => {
1302
+ this.#dispatch({ type: "failed", failureCount, error });
1303
+ },
1304
+ onPause: () => {
1305
+ this.#dispatch({ type: "pause" });
1306
+ },
1307
+ onContinue,
1308
+ retry: this.options.retry ?? 0,
1309
+ retryDelay: this.options.retryDelay,
1310
+ networkMode: this.options.networkMode,
1311
+ canRun: () => this.#mutationCache.canRun(this)
1312
+ });
1313
+ const restored = this.state.status === "pending";
1314
+ const isPaused = !this.#retryer.canStart();
1315
+ try {
1316
+ if (restored) {
1317
+ onContinue();
1318
+ } else {
1319
+ this.#dispatch({ type: "pending", variables, isPaused });
1320
+ await this.#mutationCache.config.onMutate?.(
1321
+ variables,
1322
+ this,
1323
+ mutationFnContext
1324
+ );
1325
+ const context = await this.options.onMutate?.(
1326
+ variables,
1327
+ mutationFnContext
1328
+ );
1329
+ if (context !== this.state.context) {
1330
+ this.#dispatch({
1331
+ type: "pending",
1332
+ context,
1333
+ variables,
1334
+ isPaused
1335
+ });
1336
+ }
1337
+ }
1338
+ const data = await this.#retryer.start();
1339
+ await this.#mutationCache.config.onSuccess?.(
1340
+ data,
1341
+ variables,
1342
+ this.state.context,
1343
+ this,
1344
+ mutationFnContext
1345
+ );
1346
+ await this.options.onSuccess?.(
1347
+ data,
1348
+ variables,
1349
+ this.state.context,
1350
+ mutationFnContext
1351
+ );
1352
+ await this.#mutationCache.config.onSettled?.(
1353
+ data,
1354
+ null,
1355
+ this.state.variables,
1356
+ this.state.context,
1357
+ this,
1358
+ mutationFnContext
1359
+ );
1360
+ await this.options.onSettled?.(
1361
+ data,
1362
+ null,
1363
+ variables,
1364
+ this.state.context,
1365
+ mutationFnContext
1366
+ );
1367
+ this.#dispatch({ type: "success", data });
1368
+ return data;
1369
+ } catch (error) {
1370
+ try {
1371
+ await this.#mutationCache.config.onError?.(
1372
+ error,
1373
+ variables,
1374
+ this.state.context,
1375
+ this,
1376
+ mutationFnContext
1377
+ );
1378
+ await this.options.onError?.(
1379
+ error,
1380
+ variables,
1381
+ this.state.context,
1382
+ mutationFnContext
1383
+ );
1384
+ await this.#mutationCache.config.onSettled?.(
1385
+ void 0,
1386
+ error,
1387
+ this.state.variables,
1388
+ this.state.context,
1389
+ this,
1390
+ mutationFnContext
1391
+ );
1392
+ await this.options.onSettled?.(
1393
+ void 0,
1394
+ error,
1395
+ variables,
1396
+ this.state.context,
1397
+ mutationFnContext
1398
+ );
1399
+ throw error;
1400
+ } finally {
1401
+ this.#dispatch({ type: "error", error });
1402
+ }
1403
+ } finally {
1404
+ this.#mutationCache.runNext(this);
1405
+ }
1406
+ }
1407
+ #dispatch(action) {
1408
+ const reducer = (state) => {
1409
+ switch (action.type) {
1410
+ case "failed":
1411
+ return {
1412
+ ...state,
1413
+ failureCount: action.failureCount,
1414
+ failureReason: action.error
1415
+ };
1416
+ case "pause":
1417
+ return {
1418
+ ...state,
1419
+ isPaused: true
1420
+ };
1421
+ case "continue":
1422
+ return {
1423
+ ...state,
1424
+ isPaused: false
1425
+ };
1426
+ case "pending":
1427
+ return {
1428
+ ...state,
1429
+ context: action.context,
1430
+ data: void 0,
1431
+ failureCount: 0,
1432
+ failureReason: null,
1433
+ error: null,
1434
+ isPaused: action.isPaused,
1435
+ status: "pending",
1436
+ variables: action.variables,
1437
+ submittedAt: Date.now()
1438
+ };
1439
+ case "success":
1440
+ return {
1441
+ ...state,
1442
+ data: action.data,
1443
+ failureCount: 0,
1444
+ failureReason: null,
1445
+ error: null,
1446
+ status: "success",
1447
+ isPaused: false
1448
+ };
1449
+ case "error":
1450
+ return {
1451
+ ...state,
1452
+ data: void 0,
1453
+ error: action.error,
1454
+ failureCount: state.failureCount + 1,
1455
+ failureReason: action.error,
1456
+ isPaused: false,
1457
+ status: "error"
1458
+ };
1459
+ }
1460
+ };
1461
+ this.state = reducer(this.state);
1462
+ notifyManager.batch(() => {
1463
+ this.#observers.forEach((observer) => {
1464
+ observer.onMutationUpdate(action);
1465
+ });
1466
+ this.#mutationCache.notify({
1467
+ mutation: this,
1468
+ type: "updated",
1469
+ action
1470
+ });
1471
+ });
1472
+ }
1473
+ };
1474
+ function getDefaultState2() {
1475
+ return {
1476
+ context: void 0,
1477
+ data: void 0,
1478
+ error: null,
1479
+ failureCount: 0,
1480
+ failureReason: null,
1481
+ isPaused: false,
1482
+ status: "idle",
1483
+ variables: void 0,
1484
+ submittedAt: 0
1485
+ };
1486
+ }
1487
+
1488
+ // node_modules/@tanstack/query-core/build/modern/mutationCache.js
1489
+ var MutationCache = class extends Subscribable {
1490
+ constructor(config2 = {}) {
1491
+ super();
1492
+ this.config = config2;
1493
+ this.#mutations = /* @__PURE__ */ new Set();
1494
+ this.#scopes = /* @__PURE__ */ new Map();
1495
+ this.#mutationId = 0;
1496
+ }
1497
+ #mutations;
1498
+ #scopes;
1499
+ #mutationId;
1500
+ build(client, options, state) {
1501
+ const mutation = new Mutation({
1502
+ client,
1503
+ mutationCache: this,
1504
+ mutationId: ++this.#mutationId,
1505
+ options: client.defaultMutationOptions(options),
1506
+ state
1507
+ });
1508
+ this.add(mutation);
1509
+ return mutation;
1510
+ }
1511
+ add(mutation) {
1512
+ this.#mutations.add(mutation);
1513
+ const scope = scopeFor(mutation);
1514
+ if (typeof scope === "string") {
1515
+ const scopedMutations = this.#scopes.get(scope);
1516
+ if (scopedMutations) {
1517
+ scopedMutations.push(mutation);
1518
+ } else {
1519
+ this.#scopes.set(scope, [mutation]);
1520
+ }
1521
+ }
1522
+ this.notify({ type: "added", mutation });
1523
+ }
1524
+ remove(mutation) {
1525
+ if (this.#mutations.delete(mutation)) {
1526
+ const scope = scopeFor(mutation);
1527
+ if (typeof scope === "string") {
1528
+ const scopedMutations = this.#scopes.get(scope);
1529
+ if (scopedMutations) {
1530
+ if (scopedMutations.length > 1) {
1531
+ const index = scopedMutations.indexOf(mutation);
1532
+ if (index !== -1) {
1533
+ scopedMutations.splice(index, 1);
1534
+ }
1535
+ } else if (scopedMutations[0] === mutation) {
1536
+ this.#scopes.delete(scope);
1537
+ }
1538
+ }
1539
+ }
1540
+ }
1541
+ this.notify({ type: "removed", mutation });
1542
+ }
1543
+ canRun(mutation) {
1544
+ const scope = scopeFor(mutation);
1545
+ if (typeof scope === "string") {
1546
+ const mutationsWithSameScope = this.#scopes.get(scope);
1547
+ const firstPendingMutation = mutationsWithSameScope?.find(
1548
+ (m) => m.state.status === "pending"
1549
+ );
1550
+ return !firstPendingMutation || firstPendingMutation === mutation;
1551
+ } else {
1552
+ return true;
1553
+ }
1554
+ }
1555
+ runNext(mutation) {
1556
+ const scope = scopeFor(mutation);
1557
+ if (typeof scope === "string") {
1558
+ const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);
1559
+ return foundMutation?.continue() ?? Promise.resolve();
1560
+ } else {
1561
+ return Promise.resolve();
1562
+ }
1563
+ }
1564
+ clear() {
1565
+ notifyManager.batch(() => {
1566
+ this.#mutations.forEach((mutation) => {
1567
+ this.notify({ type: "removed", mutation });
1568
+ });
1569
+ this.#mutations.clear();
1570
+ this.#scopes.clear();
1571
+ });
1572
+ }
1573
+ getAll() {
1574
+ return Array.from(this.#mutations);
1575
+ }
1576
+ find(filters) {
1577
+ const defaultedFilters = { exact: true, ...filters };
1578
+ return this.getAll().find(
1579
+ (mutation) => matchMutation(defaultedFilters, mutation)
1580
+ );
1581
+ }
1582
+ findAll(filters = {}) {
1583
+ return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1584
+ }
1585
+ notify(event) {
1586
+ notifyManager.batch(() => {
1587
+ this.listeners.forEach((listener) => {
1588
+ listener(event);
1589
+ });
1590
+ });
1591
+ }
1592
+ resumePausedMutations() {
1593
+ const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1594
+ return notifyManager.batch(
1595
+ () => Promise.all(
1596
+ pausedMutations.map((mutation) => mutation.continue().catch(noop))
1597
+ )
1598
+ );
1599
+ }
1600
+ };
1601
+ function scopeFor(mutation) {
1602
+ return mutation.options.scope?.id;
1603
+ }
1604
+
1605
+ // node_modules/@tanstack/query-core/build/modern/queryCache.js
1606
+ var QueryCache = class extends Subscribable {
1607
+ constructor(config2 = {}) {
1608
+ super();
1609
+ this.config = config2;
1610
+ this.#queries = /* @__PURE__ */ new Map();
1611
+ }
1612
+ #queries;
1613
+ build(client, options, state) {
1614
+ const queryKey = options.queryKey;
1615
+ const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
1616
+ let query = this.get(queryHash);
1617
+ if (!query) {
1618
+ query = new Query({
1619
+ client,
1620
+ queryKey,
1621
+ queryHash,
1622
+ options: client.defaultQueryOptions(options),
1623
+ state,
1624
+ defaultOptions: client.getQueryDefaults(queryKey)
1625
+ });
1626
+ this.add(query);
1627
+ }
1628
+ return query;
1629
+ }
1630
+ add(query) {
1631
+ if (!this.#queries.has(query.queryHash)) {
1632
+ this.#queries.set(query.queryHash, query);
1633
+ this.notify({
1634
+ type: "added",
1635
+ query
1636
+ });
1637
+ }
1638
+ }
1639
+ remove(query) {
1640
+ const queryInMap = this.#queries.get(query.queryHash);
1641
+ if (queryInMap) {
1642
+ query.destroy();
1643
+ if (queryInMap === query) {
1644
+ this.#queries.delete(query.queryHash);
1645
+ }
1646
+ this.notify({ type: "removed", query });
1647
+ }
1648
+ }
1649
+ clear() {
1650
+ notifyManager.batch(() => {
1651
+ this.getAll().forEach((query) => {
1652
+ this.remove(query);
1653
+ });
1654
+ });
1655
+ }
1656
+ get(queryHash) {
1657
+ return this.#queries.get(queryHash);
1658
+ }
1659
+ getAll() {
1660
+ return [...this.#queries.values()];
1661
+ }
1662
+ find(filters) {
1663
+ const defaultedFilters = { exact: true, ...filters };
1664
+ return this.getAll().find(
1665
+ (query) => matchQuery(defaultedFilters, query)
1666
+ );
1667
+ }
1668
+ findAll(filters = {}) {
1669
+ const queries = this.getAll();
1670
+ return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1671
+ }
1672
+ notify(event) {
1673
+ notifyManager.batch(() => {
1674
+ this.listeners.forEach((listener) => {
1675
+ listener(event);
1676
+ });
1677
+ });
1678
+ }
1679
+ onFocus() {
1680
+ notifyManager.batch(() => {
1681
+ this.getAll().forEach((query) => {
1682
+ query.onFocus();
1683
+ });
1684
+ });
1685
+ }
1686
+ onOnline() {
1687
+ notifyManager.batch(() => {
1688
+ this.getAll().forEach((query) => {
1689
+ query.onOnline();
1690
+ });
1691
+ });
1692
+ }
1693
+ };
1694
+
1695
+ // node_modules/@tanstack/query-core/build/modern/queryClient.js
1696
+ var QueryClient = class {
1697
+ #queryCache;
1698
+ #mutationCache;
1699
+ #defaultOptions;
1700
+ #queryDefaults;
1701
+ #mutationDefaults;
1702
+ #mountCount;
1703
+ #unsubscribeFocus;
1704
+ #unsubscribeOnline;
1705
+ constructor(config2 = {}) {
1706
+ this.#queryCache = config2.queryCache || new QueryCache();
1707
+ this.#mutationCache = config2.mutationCache || new MutationCache();
1708
+ this.#defaultOptions = config2.defaultOptions || {};
1709
+ this.#queryDefaults = /* @__PURE__ */ new Map();
1710
+ this.#mutationDefaults = /* @__PURE__ */ new Map();
1711
+ this.#mountCount = 0;
1712
+ }
1713
+ mount() {
1714
+ this.#mountCount++;
1715
+ if (this.#mountCount !== 1) return;
1716
+ this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
1717
+ if (focused) {
1718
+ await this.resumePausedMutations();
1719
+ this.#queryCache.onFocus();
1720
+ }
1721
+ });
1722
+ this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
1723
+ if (online) {
1724
+ await this.resumePausedMutations();
1725
+ this.#queryCache.onOnline();
1726
+ }
1727
+ });
1728
+ }
1729
+ unmount() {
1730
+ this.#mountCount--;
1731
+ if (this.#mountCount !== 0) return;
1732
+ this.#unsubscribeFocus?.();
1733
+ this.#unsubscribeFocus = void 0;
1734
+ this.#unsubscribeOnline?.();
1735
+ this.#unsubscribeOnline = void 0;
1736
+ }
1737
+ isFetching(filters) {
1738
+ return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length;
1739
+ }
1740
+ isMutating(filters) {
1741
+ return this.#mutationCache.findAll({ ...filters, status: "pending" }).length;
1742
+ }
1743
+ /**
1744
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
1745
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1746
+ *
1747
+ * Hint: Do not use this function inside a component, because it won't receive updates.
1748
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1749
+ */
1750
+ getQueryData(queryKey) {
1751
+ const options = this.defaultQueryOptions({ queryKey });
1752
+ return this.#queryCache.get(options.queryHash)?.state.data;
1753
+ }
1754
+ ensureQueryData(options) {
1755
+ const defaultedOptions = this.defaultQueryOptions(options);
1756
+ const query = this.#queryCache.build(this, defaultedOptions);
1757
+ const cachedData = query.state.data;
1758
+ if (cachedData === void 0) {
1759
+ return this.fetchQuery(options);
1760
+ }
1761
+ if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
1762
+ void this.prefetchQuery(defaultedOptions);
1763
+ }
1764
+ return Promise.resolve(cachedData);
1765
+ }
1766
+ getQueriesData(filters) {
1767
+ return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
1768
+ const data = state.data;
1769
+ return [queryKey, data];
1770
+ });
1771
+ }
1772
+ setQueryData(queryKey, updater, options) {
1773
+ const defaultedOptions = this.defaultQueryOptions({ queryKey });
1774
+ const query = this.#queryCache.get(
1775
+ defaultedOptions.queryHash
1776
+ );
1777
+ const prevData = query?.state.data;
1778
+ const data = functionalUpdate(updater, prevData);
1779
+ if (data === void 0) {
1780
+ return void 0;
1781
+ }
1782
+ return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });
1783
+ }
1784
+ setQueriesData(filters, updater, options) {
1785
+ return notifyManager.batch(
1786
+ () => this.#queryCache.findAll(filters).map(({ queryKey }) => [
1787
+ queryKey,
1788
+ this.setQueryData(queryKey, updater, options)
1789
+ ])
1790
+ );
1791
+ }
1792
+ getQueryState(queryKey) {
1793
+ const options = this.defaultQueryOptions({ queryKey });
1794
+ return this.#queryCache.get(
1795
+ options.queryHash
1796
+ )?.state;
1797
+ }
1798
+ removeQueries(filters) {
1799
+ const queryCache = this.#queryCache;
1800
+ notifyManager.batch(() => {
1801
+ queryCache.findAll(filters).forEach((query) => {
1802
+ queryCache.remove(query);
1803
+ });
1804
+ });
1805
+ }
1806
+ resetQueries(filters, options) {
1807
+ const queryCache = this.#queryCache;
1808
+ return notifyManager.batch(() => {
1809
+ queryCache.findAll(filters).forEach((query) => {
1810
+ query.reset();
1811
+ });
1812
+ return this.refetchQueries(
1813
+ {
1814
+ type: "active",
1815
+ ...filters
1816
+ },
1817
+ options
1818
+ );
1819
+ });
1820
+ }
1821
+ cancelQueries(filters, cancelOptions = {}) {
1822
+ const defaultedCancelOptions = { revert: true, ...cancelOptions };
1823
+ const promises = notifyManager.batch(
1824
+ () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
1825
+ );
1826
+ return Promise.all(promises).then(noop).catch(noop);
1827
+ }
1828
+ invalidateQueries(filters, options = {}) {
1829
+ return notifyManager.batch(() => {
1830
+ this.#queryCache.findAll(filters).forEach((query) => {
1831
+ query.invalidate();
1832
+ });
1833
+ if (filters?.refetchType === "none") {
1834
+ return Promise.resolve();
1835
+ }
1836
+ return this.refetchQueries(
1837
+ {
1838
+ ...filters,
1839
+ type: filters?.refetchType ?? filters?.type ?? "active"
1840
+ },
1841
+ options
1842
+ );
1843
+ });
1844
+ }
1845
+ refetchQueries(filters, options = {}) {
1846
+ const fetchOptions = {
1847
+ ...options,
1848
+ cancelRefetch: options.cancelRefetch ?? true
1849
+ };
1850
+ const promises = notifyManager.batch(
1851
+ () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
1852
+ let promise = query.fetch(void 0, fetchOptions);
1853
+ if (!fetchOptions.throwOnError) {
1854
+ promise = promise.catch(noop);
1855
+ }
1856
+ return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
1857
+ })
1858
+ );
1859
+ return Promise.all(promises).then(noop);
1860
+ }
1861
+ fetchQuery(options) {
1862
+ const defaultedOptions = this.defaultQueryOptions(options);
1863
+ if (defaultedOptions.retry === void 0) {
1864
+ defaultedOptions.retry = false;
1865
+ }
1866
+ const query = this.#queryCache.build(this, defaultedOptions);
1867
+ return query.isStaleByTime(
1868
+ resolveStaleTime(defaultedOptions.staleTime, query)
1869
+ ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
1870
+ }
1871
+ prefetchQuery(options) {
1872
+ return this.fetchQuery(options).then(noop).catch(noop);
1873
+ }
1874
+ fetchInfiniteQuery(options) {
1875
+ options.behavior = infiniteQueryBehavior(options.pages);
1876
+ return this.fetchQuery(options);
1877
+ }
1878
+ prefetchInfiniteQuery(options) {
1879
+ return this.fetchInfiniteQuery(options).then(noop).catch(noop);
1880
+ }
1881
+ ensureInfiniteQueryData(options) {
1882
+ options.behavior = infiniteQueryBehavior(options.pages);
1883
+ return this.ensureQueryData(options);
1884
+ }
1885
+ resumePausedMutations() {
1886
+ if (onlineManager.isOnline()) {
1887
+ return this.#mutationCache.resumePausedMutations();
1888
+ }
1889
+ return Promise.resolve();
1890
+ }
1891
+ getQueryCache() {
1892
+ return this.#queryCache;
1893
+ }
1894
+ getMutationCache() {
1895
+ return this.#mutationCache;
1896
+ }
1897
+ getDefaultOptions() {
1898
+ return this.#defaultOptions;
1899
+ }
1900
+ setDefaultOptions(options) {
1901
+ this.#defaultOptions = options;
1902
+ }
1903
+ setQueryDefaults(queryKey, options) {
1904
+ this.#queryDefaults.set(hashKey(queryKey), {
1905
+ queryKey,
1906
+ defaultOptions: options
1907
+ });
1908
+ }
1909
+ getQueryDefaults(queryKey) {
1910
+ const defaults = [...this.#queryDefaults.values()];
1911
+ const result = {};
1912
+ defaults.forEach((queryDefault) => {
1913
+ if (partialMatchKey(queryKey, queryDefault.queryKey)) {
1914
+ Object.assign(result, queryDefault.defaultOptions);
1915
+ }
1916
+ });
1917
+ return result;
1918
+ }
1919
+ setMutationDefaults(mutationKey, options) {
1920
+ this.#mutationDefaults.set(hashKey(mutationKey), {
1921
+ mutationKey,
1922
+ defaultOptions: options
1923
+ });
1924
+ }
1925
+ getMutationDefaults(mutationKey) {
1926
+ const defaults = [...this.#mutationDefaults.values()];
1927
+ const result = {};
1928
+ defaults.forEach((queryDefault) => {
1929
+ if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
1930
+ Object.assign(result, queryDefault.defaultOptions);
1931
+ }
1932
+ });
1933
+ return result;
1934
+ }
1935
+ defaultQueryOptions(options) {
1936
+ if (options._defaulted) {
1937
+ return options;
1938
+ }
1939
+ const defaultedOptions = {
1940
+ ...this.#defaultOptions.queries,
1941
+ ...this.getQueryDefaults(options.queryKey),
1942
+ ...options,
1943
+ _defaulted: true
1944
+ };
1945
+ if (!defaultedOptions.queryHash) {
1946
+ defaultedOptions.queryHash = hashQueryKeyByOptions(
1947
+ defaultedOptions.queryKey,
1948
+ defaultedOptions
1949
+ );
1950
+ }
1951
+ if (defaultedOptions.refetchOnReconnect === void 0) {
1952
+ defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
1953
+ }
1954
+ if (defaultedOptions.throwOnError === void 0) {
1955
+ defaultedOptions.throwOnError = !!defaultedOptions.suspense;
1956
+ }
1957
+ if (!defaultedOptions.networkMode && defaultedOptions.persister) {
1958
+ defaultedOptions.networkMode = "offlineFirst";
1959
+ }
1960
+ if (defaultedOptions.queryFn === skipToken) {
1961
+ defaultedOptions.enabled = false;
1962
+ }
1963
+ return defaultedOptions;
1964
+ }
1965
+ defaultMutationOptions(options) {
1966
+ if (options?._defaulted) {
1967
+ return options;
1968
+ }
1969
+ return {
1970
+ ...this.#defaultOptions.mutations,
1971
+ ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
1972
+ ...options,
1973
+ _defaulted: true
1974
+ };
1975
+ }
1976
+ clear() {
1977
+ this.#queryCache.clear();
1978
+ this.#mutationCache.clear();
1979
+ }
1980
+ };
1981
+
1982
+ // node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
1983
+ import * as React from "react";
1984
+ import { jsx } from "react/jsx-runtime";
1985
+ var QueryClientContext = React.createContext(
1986
+ void 0
1987
+ );
1988
+ var QueryClientProvider = ({
1989
+ client,
1990
+ children
1991
+ }) => {
1992
+ React.useEffect(() => {
1993
+ client.mount();
1994
+ return () => {
1995
+ client.unmount();
1996
+ };
1997
+ }, [client]);
1998
+ return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });
1999
+ };
2000
+
2001
+ // wagmi__providers.tsx
2002
+ import { WagmiProvider } from "wagmi";
2003
+
2004
+ // config/walletConfig.ts
2005
+ import { http, createConfig } from "wagmi";
2006
+ import { mainnet, base } from "wagmi/chains";
2007
+ import { walletConnect } from "wagmi/connectors";
2008
+
2009
+ // chains/core.ts
2010
+ import { defineChain } from "viem";
2011
+
2012
+ // chains/base__sepolia.ts
2013
+ import { defineChain as defineChain2 } from "viem";
2014
+ function BaseSepolia() {
2015
+ const baseSepolia = defineChain2({
2016
+ id: 84532,
2017
+ name: "Base Sepolia",
2018
+ network: "base-sepolia",
2019
+ nativeCurrency: {
2020
+ name: "Base Sepolia Ether",
2021
+ symbol: "ETH",
2022
+ decimals: 18
2023
+ },
2024
+ rpcUrls: {
2025
+ default: {
2026
+ http: [
2027
+ process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || ""
2028
+ ]
2029
+ },
2030
+ public: {
2031
+ http: [
2032
+ process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA || ""
2033
+ ]
2034
+ }
2035
+ },
2036
+ blockExplorers: {
2037
+ default: { name: "Basescan", url: "https://sepolia.basescan.org" }
2038
+ },
2039
+ testnet: true
2040
+ });
2041
+ return baseSepolia;
2042
+ }
2043
+
2044
+ // config/walletConfig.ts
2045
+ var projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
2046
+ var config = createConfig({
2047
+ chains: [mainnet, base, BaseSepolia()],
2048
+ connectors: [
2049
+ walletConnect({ projectId })
2050
+ ],
2051
+ transports: {
2052
+ [mainnet.id]: http(),
2053
+ [base.id]: http(),
2054
+ [BaseSepolia().id]: http()
2055
+ }
2056
+ });
2057
+
2058
+ // config/Image.json
2059
+ var Image_default = {
2060
+ logo: "https://cordy-stack-x.vercel.app/logo.svg"
2061
+ };
2062
+
2063
+ // css/UI_Comp/styles.module.css
2064
+ var styles_default = {};
2065
+
2066
+ // css/Buttons/styles.module.css
2067
+ var styles_default2 = {};
2068
+
2069
+ // controllers/WagmiButton.tsx
2070
+ import React2, { useEffect as useEffect2 } from "react";
2071
+ import { useConnect } from "wagmi";
2072
+ import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
2073
+ function WalletButton({
2074
+ onStatusChange
2075
+ }) {
2076
+ const { connectors, connectAsync, status } = useConnect();
2077
+ const [pendingConnector, setPendingConnector] = React2.useState(null);
2078
+ const [errorMsg, setErrorMsg] = React2.useState();
2079
+ const isPending = status === "pending";
2080
+ useEffect2(() => {
2081
+ if (onStatusChange) {
2082
+ onStatusChange({
2083
+ isPending,
2084
+ error: errorMsg
2085
+ });
2086
+ }
2087
+ }, [isPending, errorMsg, onStatusChange]);
2088
+ return /* @__PURE__ */ jsx2(Fragment, { children: connectors.map((connector) => /* @__PURE__ */ jsx2(
2089
+ WalletOption,
2090
+ {
2091
+ connector,
2092
+ onClick: async () => {
2093
+ setPendingConnector(connector);
2094
+ setErrorMsg(void 0);
2095
+ try {
2096
+ await connectAsync({ connector });
2097
+ } catch (err) {
2098
+ setErrorMsg(err?.message || "Connection failed");
2099
+ } finally {
2100
+ setPendingConnector(null);
2101
+ }
2102
+ },
2103
+ isPending: pendingConnector?.uid === connector.uid && isPending
2104
+ },
2105
+ connector.uid
2106
+ )) });
2107
+ }
2108
+ function WalletOption({
2109
+ connector,
2110
+ onClick,
2111
+ isPending
2112
+ }) {
2113
+ const [ready, setReady] = React2.useState(false);
2114
+ React2.useEffect(() => {
2115
+ (async () => {
2116
+ const provider = await connector.getProvider();
2117
+ setReady(!!provider);
2118
+ })();
2119
+ }, [connector]);
2120
+ return /* @__PURE__ */ jsx2("button", { disabled: !ready || isPending, onClick, children: isPending ? "Connecting..." : connector.name });
2121
+ }
2122
+
2123
+ // controllers/Disconnect.tsx
2124
+ import { useDisconnect } from "wagmi";
2125
+ import { jsx as jsx3 } from "react/jsx-runtime";
2126
+ function Disconnect() {
2127
+ const { disconnect } = useDisconnect();
2128
+ return /* @__PURE__ */ jsx3("button", { onClick: () => disconnect(), children: "Disconnect" });
2129
+ }
2130
+
2131
+ // controllers/Transactions.tsx
2132
+ import { ethers, parseUnits } from "ethers";
2133
+
2134
+ // config/ERC20_ABI.json
2135
+ var ERC20_ABI_default = [
2136
+ {
2137
+ constant: true,
2138
+ inputs: [{ name: "owner", type: "address" }],
2139
+ name: "balanceOf",
2140
+ outputs: [{ name: "balance", type: "uint256" }],
2141
+ type: "function"
2142
+ },
2143
+ {
2144
+ constant: false,
2145
+ inputs: [
2146
+ { name: "to", type: "address" },
2147
+ { name: "value", type: "uint256" }
2148
+ ],
2149
+ name: "transfer",
2150
+ outputs: [{ name: "", type: "bool" }],
2151
+ type: "function"
2152
+ },
2153
+ {
2154
+ constant: true,
2155
+ inputs: [],
2156
+ name: "decimals",
2157
+ outputs: [{ name: "", type: "uint8" }],
2158
+ type: "function"
2159
+ }
2160
+ ];
2161
+
2162
+ // controllers/Transactions.tsx
2163
+ var tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
2164
+ var platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
2165
+ async function CordyStackTrans(address, cost) {
2166
+ if (!address) return alert("Address Not Found");
2167
+ try {
2168
+ const provider = new ethers.BrowserProvider(window.ethereum);
2169
+ const signer = await provider.getSigner();
2170
+ const tokenContract = new ethers.Contract(tokenAddress, ERC20_ABI_default, signer);
2171
+ const decimals = 18;
2172
+ const amount = parseUnits(String(cost), decimals);
2173
+ const balance = await tokenContract.balanceOf(await signer.getAddress());
2174
+ if (balance < amount) {
2175
+ return alert("Insuficient Funds");
2176
+ }
2177
+ const tx = await tokenContract.transfer(platformAddress, amount);
2178
+ const receipt = await tx.wait();
2179
+ if (receipt) {
2180
+ return alert("Transactions Complete");
2181
+ } else {
2182
+ return alert("Transaction Failed");
2183
+ }
2184
+ } catch (err) {
2185
+ console.error(err);
2186
+ }
2187
+ }
2188
+
2189
+ // controllers/Get_Balance.tsx
2190
+ import { ethers as ethers2 } from "ethers";
2191
+ async function getTokenBalance(address, tokenAddress2) {
2192
+ if (!address) return "0";
2193
+ try {
2194
+ const provider = new ethers2.JsonRpcProvider(process.env.NEXT_PUBLIC_LINK_PROJECT_ID_SEPOLIA);
2195
+ const contract = new ethers2.Contract(tokenAddress2, ERC20_ABI_default, provider);
2196
+ const balance = await contract.balanceOf(address);
2197
+ return ethers2.formatUnits(balance, 18);
2198
+ } catch (err) {
2199
+ console.error("Error fetching token balance:", err);
2200
+ return "0";
2201
+ }
2202
+ }
2203
+
2204
+ // components/UI_Comp.tsx
2205
+ import { useAccount } from "wagmi";
2206
+ import { FaUser } from "react-icons/fa";
2207
+ import { useState, useEffect as useEffect3 } from "react";
2208
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
2209
+ function UI_Comp() {
2210
+ const { closeModal } = useWalletModal();
2211
+ const { isConnected, address } = useAccount();
2212
+ const [loading, setLoading] = useState(false);
2213
+ const [errorMsg, setErrorMsg] = useState();
2214
+ const [balance, setBalance] = useState("");
2215
+ useEffect3(() => {
2216
+ Get_Balance();
2217
+ }, [balance]);
2218
+ const Get_Balance = async () => {
2219
+ if (!address || !process.env.NEXT_PUBLIC_TOKENADDRESS) {
2220
+ throw new Error("Address or token address is undefined");
2221
+ }
2222
+ const balance2 = await getTokenBalance(address, process.env.NEXT_PUBLIC_TOKENADDRESS);
2223
+ setBalance(balance2);
2224
+ return;
2225
+ };
2226
+ if (isConnected) {
2227
+ if (balance === "") {
2228
+ Get_Balance();
2229
+ }
2230
+ return /* @__PURE__ */ jsx4("div", { className: styles_default.container, children: /* @__PURE__ */ jsxs("div", { className: styles_default.connector, children: [
2231
+ /* @__PURE__ */ jsx4("p", { className: styles_default.closed, onClick: closeModal, children: "\u2715" }),
2232
+ isConnected && /* @__PURE__ */ jsx4("div", { className: styles_default.info, children: balance ? /* @__PURE__ */ jsxs("span", { children: [
2233
+ /* @__PURE__ */ jsx4(FaUser, { size: 70 }),
2234
+ /* @__PURE__ */ jsx4("p", { style: { color: "#0f0" }, children: "Connected" }),
2235
+ /* @__PURE__ */ jsxs("p", { style: { color: "#0ff" }, children: [
2236
+ "Balance: ",
2237
+ Number(balance).toFixed(2),
2238
+ " ",
2239
+ process.env.NEXT_PUBLIC_SYMBOL
2240
+ ] }),
2241
+ /* @__PURE__ */ jsx4("p", { style: { color: "#ff0" }, children: address })
2242
+ ] }) : /* @__PURE__ */ jsx4("p", { style: { color: "var(--foreground_wagmi)" }, children: "Loading balance..." }) }),
2243
+ /* @__PURE__ */ jsx4(Disconnect, {}),
2244
+ /* @__PURE__ */ jsx4("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })
2245
+ ] }) });
2246
+ }
2247
+ return /* @__PURE__ */ jsx4("div", { className: styles_default.container, children: /* @__PURE__ */ jsxs("div", { className: styles_default.connector, children: [
2248
+ /* @__PURE__ */ jsx4("p", { className: styles_default.closed, onClick: closeModal, children: "\u2715" }),
2249
+ /* @__PURE__ */ jsx4("img", { src: Image_default.logo, width: 50, height: 50 }),
2250
+ /* @__PURE__ */ jsx4("h2", { children: "Cordy MiniKit" }),
2251
+ /* @__PURE__ */ jsxs("div", { children: [
2252
+ /* @__PURE__ */ jsx4("h3", { children: loading ? "Loading..." : "" }),
2253
+ /* @__PURE__ */ jsx4(
2254
+ WalletButton,
2255
+ {
2256
+ onStatusChange: ({ isPending, error }) => {
2257
+ setLoading(isPending);
2258
+ setErrorMsg(error);
2259
+ }
2260
+ }
2261
+ ),
2262
+ /* @__PURE__ */ jsx4("p", { children: errorMsg })
2263
+ ] }),
2264
+ /* @__PURE__ */ jsx4("a", { href: "https://cordy-stack-x.vercel.app/", children: "Powered By CordyStackX" })
2265
+ ] }) });
2266
+ }
2267
+
2268
+ // components/Connect_wallet_bt.tsx
2269
+ import { useAccount as useAccount2 } from "wagmi";
2270
+ import { jsx as jsx5 } from "react/jsx-runtime";
2271
+ function ConnectWalletBT() {
2272
+ const { openModal } = useWalletModal();
2273
+ const { isConnected, address } = useAccount2();
2274
+ return /* @__PURE__ */ jsx5(
2275
+ "button",
2276
+ {
2277
+ className: styles_default2.button__button,
2278
+ onClick: openModal,
2279
+ children: isConnected ? `Connected ${address}` : "Connect Wallet"
2280
+ }
2281
+ );
2282
+ }
2283
+
2284
+ // wagmi__providers.tsx
2285
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
2286
+ var WalletContext = createContext2(null);
2287
+ var queryClient = new QueryClient();
2288
+ function WalletProviders({ children }) {
2289
+ const [open, setOpen] = useState2(false);
2290
+ return /* @__PURE__ */ jsx6(WagmiProvider, { config, children: /* @__PURE__ */ jsx6(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxs2(
2291
+ WalletContext.Provider,
2292
+ {
2293
+ value: {
2294
+ openModal: () => setOpen(true),
2295
+ closeModal: () => setOpen(false)
2296
+ },
2297
+ children: [
2298
+ children,
2299
+ open && /* @__PURE__ */ jsx6(UI_Comp, {}),
2300
+ " "
2301
+ ]
2302
+ }
2303
+ ) }) });
2304
+ }
2305
+ function useWalletModal() {
2306
+ const ctx = useContext2(WalletContext);
2307
+ if (!ctx) throw new Error("Wrap in <WalletProviders>");
2308
+ return ctx;
2309
+ }
2310
+
2311
+ export {
2312
+ __require,
2313
+ __commonJS,
2314
+ __toESM,
2315
+ WalletButton,
2316
+ Disconnect,
2317
+ CordyStackTrans,
2318
+ getTokenBalance,
2319
+ UI_Comp,
2320
+ ConnectWalletBT,
2321
+ WalletProviders,
2322
+ useWalletModal
2323
+ };
2324
+ //# sourceMappingURL=chunk-F66KBLWQ.mjs.map