UNPKG

@bonfida/sns-widget

Version:

SNS Widget for 3rd-party apps for quick domain search and register

1,187 lines 552 kB
"use client"; var Ha = (e) => { throw TypeError(e); }; var Qo = (e, t, n) => t.has(e) || Ha("Cannot " + n); var L = (e, t, n) => (Qo(e, t, "read from private field"), n ? n.call(e) : t.get(e)), ue = (e, t, n) => t.has(e) ? Ha("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), re = (e, t, n, i) => (Qo(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), ge = (e, t, n) => (Qo(e, t, "access private method"), n); var ro = (e, t, n, i) => ({ set _(u) { re(e, t, u, n); }, get _() { return L(e, t, i); } }); import { jsx as D, Fragment as it, jsxs as te } from "react/jsx-runtime"; import * as mt from "react"; import { useRef as lt, useMemo as Lo, useEffect as Ct, useState as qe, createContext as Vo, useContext as an, Fragment as _a, createElement as Re, useCallback as Jt, useLayoutEffect as r0 } from "react"; import { useConnection as o0, useWallet as i0, ConnectionProvider as s0, WalletProvider as a0 } from "@solana/wallet-adapter-react"; import { SolflareWalletAdapter as u0 } from "@solana/wallet-adapter-wallets"; import { useWalletModal as c0, WalletModalProvider as f0 } from "@solana/wallet-adapter-react-ui"; import { PublicKey as V, SystemProgram as Cs, TransactionInstruction as zf, SYSVAR_RENT_PUBKEY as h0, Transaction as Vf, LAMPORTS_PER_SOL as l0 } from "@solana/web3.js"; import { t as Pe } from "./index-DCJCUdhV.js"; import { createAssociatedTokenAccountInstruction as d0, NATIVE_MINT as $o, createSyncNativeInstruction as p0, createCloseAccountInstruction as y0, getAssociatedTokenAddressSync as Ga } from "@solana/spl-token"; import { parsePriceData as g0 } from "@pythnetwork/client"; var Jr = class { constructor() { this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this); } subscribe(e) { return this.listeners.add(e), this.onSubscribe(), () => { this.listeners.delete(e), this.onUnsubscribe(); }; } hasListeners() { return this.listeners.size > 0; } onSubscribe() { } onUnsubscribe() { } }; function w0(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var en, tn, qf = { exports: {} }, Te = qf.exports = {}; function Rs() { throw new Error("setTimeout has not been defined"); } function Ls() { throw new Error("clearTimeout has not been defined"); } function Zf(e) { if (en === setTimeout) return setTimeout(e, 0); if ((en === Rs || !en) && setTimeout) return en = setTimeout, setTimeout(e, 0); try { return en(e, 0); } catch { try { return en.call(null, e, 0); } catch { return en.call(this, e, 0); } } } (function() { try { en = typeof setTimeout == "function" ? setTimeout : Rs; } catch { en = Rs; } try { tn = typeof clearTimeout == "function" ? clearTimeout : Ls; } catch { tn = Ls; } })(); var kn, sn = [], ur = !1, So = -1; function b0() { ur && kn && (ur = !1, kn.length ? sn = kn.concat(sn) : So = -1, sn.length && Hf()); } function Hf() { if (!ur) { var e = Zf(b0); ur = !0; for (var t = sn.length; t; ) { for (kn = sn, sn = []; ++So < t; ) kn && kn[So].run(); So = -1, t = sn.length; } kn = null, ur = !1, function(n) { if (tn === clearTimeout) return clearTimeout(n); if ((tn === Ls || !tn) && clearTimeout) return tn = clearTimeout, clearTimeout(n); try { return tn(n); } catch { try { return tn.call(null, n); } catch { return tn.call(this, n); } } }(e); } } function Wa(e, t) { this.fun = e, this.array = t; } function Qt() { } Te.nextTick = function(e) { var t = new Array(arguments.length - 1); if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n]; sn.push(new Wa(e, t)), sn.length !== 1 || ur || Zf(Hf); }, Wa.prototype.run = function() { this.fun.apply(null, this.array); }, Te.title = "browser", Te.browser = !0, Te.env = {}, Te.argv = [], Te.version = "", Te.versions = {}, Te.on = Qt, Te.addListener = Qt, Te.once = Qt, Te.off = Qt, Te.removeListener = Qt, Te.removeAllListeners = Qt, Te.emit = Qt, Te.prependListener = Qt, Te.prependOnceListener = Qt, Te.listeners = function(e) { return []; }, Te.binding = function(e) { throw new Error("process.binding is not supported"); }, Te.cwd = function() { return "/"; }, Te.chdir = function(e) { throw new Error("process.chdir is not supported"); }, Te.umask = function() { return 0; }; const Sr = w0(qf.exports); var Ur = typeof window > "u" || "Deno" in globalThis; function bt() { } function Ts(e) { return typeof e == "number" && e >= 0 && e !== 1 / 0; } function _f(e, t) { return Math.max(e + (t || 0) - Date.now(), 0); } function cr(e, t) { return typeof e == "function" ? e(t) : e; } function It(e, t) { return typeof e == "function" ? e(t) : e; } function Qa(e, t) { const { type: n = "all", exact: i, fetchStatus: u, predicate: h, queryKey: c, stale: p } = e; if (c) { if (i) { if (t.queryHash !== pa(c, t.options)) return !1; } else if (!Hr(t.queryKey, c)) return !1; } if (n !== "all") { const w = t.isActive(); if (n === "active" && !w || n === "inactive" && w) return !1; } return (typeof p != "boolean" || t.isStale() === p) && (!u || u === t.state.fetchStatus) && !(h && !h(t)); } function $a(e, t) { const { exact: n, status: i, predicate: u, mutationKey: h } = e; if (h) { if (!t.options.mutationKey) return !1; if (n) { if (Zr(t.options.mutationKey) !== Zr(h)) return !1; } else if (!Hr(t.options.mutationKey, h)) return !1; } return (!i || t.state.status === i) && !(u && !u(t)); } function pa(e, t) { return ((t == null ? void 0 : t.queryKeyHashFn) || Zr)(e); } function Zr(e) { return JSON.stringify(e, (t, n) => Os(n) ? Object.keys(n).sort().reduce((i, u) => (i[u] = n[u], i), {}) : n); } function Hr(e, t) { return e === t || typeof e == typeof t && !(!e || !t || typeof e != "object" || typeof t != "object") && !Object.keys(t).some((n) => !Hr(e[n], t[n])); } function Gf(e, t) { if (e === t) return e; const n = Xa(e) && Xa(t); if (n || Os(e) && Os(t)) { const i = n ? e : Object.keys(e), u = i.length, h = n ? t : Object.keys(t), c = h.length, p = n ? [] : {}; let w = 0; for (let m = 0; m < c; m++) { const g = n ? m : h[m]; (!n && i.includes(g) || n) && e[g] === void 0 && t[g] === void 0 ? (p[g] = void 0, w++) : (p[g] = Gf(e[g], t[g]), p[g] === e[g] && e[g] !== void 0 && w++); } return u === c && w === u ? e : p; } return t; } function Xo(e, t) { if (!t || Object.keys(e).length !== Object.keys(t).length) return !1; for (const n in e) if (e[n] !== t[n]) return !1; return !0; } function Xa(e) { return Array.isArray(e) && e.length === Object.keys(e).length; } function Os(e) { if (!Ya(e)) return !1; const t = e.constructor; if (t === void 0) return !0; const n = t.prototype; return !!Ya(n) && !!n.hasOwnProperty("isPrototypeOf") && Object.getPrototypeOf(e) === Object.prototype; } function Ya(e) { return Object.prototype.toString.call(e) === "[object Object]"; } function Ps(e, t, n) { return typeof n.structuralSharing == "function" ? n.structuralSharing(e, t) : n.structuralSharing !== !1 ? Gf(e, t) : t; } function m0(e, t, n = 0) { const i = [...e, t]; return n && i.length > n ? i.slice(1) : i; } function v0(e, t, n = 0) { const i = [t, ...e]; return n && i.length > n ? i.slice(0, -1) : i; } var Ns = Symbol(); function Wf(e, t) { return Sr.env.NODE_ENV !== "production" && e.queryFn === Ns && console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`), !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : e.queryFn && e.queryFn !== Ns ? e.queryFn : () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)); } var Dn, xn, dr, Tf, ya = new (Tf = class extends Jr { constructor() { super(); ue(this, Dn); ue(this, xn); ue(this, dr); re(this, dr, (t) => { if (!Ur && window.addEventListener) { const n = () => t(); return window.addEventListener("visibilitychange", n, !1), () => { window.removeEventListener("visibilitychange", n); }; } }); } onSubscribe() { L(this, xn) || this.setEventListener(L(this, dr)); } onUnsubscribe() { var t; this.hasListeners() || ((t = L(this, xn)) == null || t.call(this), re(this, xn, void 0)); } setEventListener(t) { var n; re(this, dr, t), (n = L(this, xn)) == null || n.call(this), re(this, xn, t((i) => { typeof i == "boolean" ? this.setFocused(i) : this.onFocus(); })); } setFocused(t) { L(this, Dn) !== t && (re(this, Dn, t), this.onFocus()); } onFocus() { const t = this.isFocused(); this.listeners.forEach((n) => { n(t); }); } isFocused() { var t; return typeof L(this, Dn) == "boolean" ? L(this, Dn) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden"; } }, Dn = new WeakMap(), xn = new WeakMap(), dr = new WeakMap(), Tf)(), pr, An, yr, Of, To = new (Of = class extends Jr { constructor() { super(); ue(this, pr, !0); ue(this, An); ue(this, yr); re(this, yr, (t) => { if (!Ur && window.addEventListener) { const n = () => t(!0), i = () => t(!1); return window.addEventListener("online", n, !1), window.addEventListener("offline", i, !1), () => { window.removeEventListener("online", n), window.removeEventListener("offline", i); }; } }); } onSubscribe() { L(this, An) || this.setEventListener(L(this, yr)); } onUnsubscribe() { var t; this.hasListeners() || ((t = L(this, An)) == null || t.call(this), re(this, An, void 0)); } setEventListener(t) { var n; re(this, yr, t), (n = L(this, An)) == null || n.call(this), re(this, An, t(this.setOnline.bind(this))); } setOnline(t) { L(this, pr) !== t && (re(this, pr, t), this.listeners.forEach((n) => { n(t); })); } isOnline() { return L(this, pr); } }, pr = new WeakMap(), An = new WeakMap(), yr = new WeakMap(), Of)(); function E0(e) { return Math.min(1e3 * 2 ** e, 3e4); } function Qf(e) { return (e ?? "online") !== "online" || To.isOnline(); } var $f = class extends Error { constructor(e) { super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent; } }; function Yo(e) { return e instanceof $f; } function Xf(e) { let t, n, i, u = !1, h = 0, c = !1; const p = new Promise((b, v) => { n = b, i = v; }), w = () => ya.isFocused() && (e.networkMode === "always" || To.isOnline()) && e.canRun(), m = () => Qf(e.networkMode) && e.canRun(), g = (b) => { var v; c || (c = !0, (v = e.onSuccess) == null || v.call(e, b), t == null || t(), n(b)); }, I = (b) => { var v; c || (c = !0, (v = e.onError) == null || v.call(e, b), t == null || t(), i(b)); }, x = () => new Promise((b) => { var v; t = (E) => { (c || w()) && b(E); }, (v = e.onPause) == null || v.call(e); }).then(() => { var b; t = void 0, c || ((b = e.onContinue) == null || b.call(e)); }), d = () => { if (c) return; let b; const v = h === 0 ? e.initialPromise : void 0; try { b = v ?? e.fn(); } catch (E) { b = Promise.reject(E); } Promise.resolve(b).then(g).catch((E) => { var X; if (c) return; const S = e.retry ?? (Ur ? 0 : 3), B = e.retryDelay ?? E0, T = typeof B == "function" ? B(h, E) : B, H = S === !0 || typeof S == "number" && h < S || typeof S == "function" && S(h, E); var q; !u && H ? (h++, (X = e.onFail) == null || X.call(e, h, E), (q = T, new Promise((ne) => { setTimeout(ne, q); })).then(() => w() ? void 0 : x()).then(() => { u ? I(E) : d(); })) : I(E); }); }; return { promise: p, cancel: (b) => { var v; c || (I(new $f(b)), (v = e.abort) == null || v.call(e)); }, continue: () => (t == null || t(), p), cancelRetry: () => { u = !0; }, continueRetry: () => { u = !1; }, canStart: m, start: () => (m() ? d() : x().then(d), p) }; } var Ke = /* @__PURE__ */ function() { let e = [], t = 0, n = (p) => { p(); }, i = (p) => { p(); }, u = (p) => setTimeout(p, 0); const h = (p) => { t ? e.push(p) : u(() => { n(p); }); }, c = () => { const p = e; e = [], p.length && u(() => { i(() => { p.forEach((w) => { n(w); }); }); }); }; return { batch: (p) => { let w; t++; try { w = p(); } finally { t--, t || c(); } return w; }, batchCalls: (p) => (...w) => { h(() => { p(...w); }); }, schedule: h, setNotifyFunction: (p) => { n = p; }, setBatchNotifyFunction: (p) => { i = p; }, setScheduler: (p) => { u = p; } }; }(), Fn, Pf, Yf = (Pf = class { constructor() { ue(this, Fn); } destroy() { this.clearGcTimeout(); } scheduleGc() { this.clearGcTimeout(), Ts(this.gcTime) && re(this, Fn, setTimeout(() => { this.optionalRemove(); }, this.gcTime)); } updateGcTime(e) { this.gcTime = Math.max(this.gcTime || 0, e ?? (Ur ? 1 / 0 : 3e5)); } clearGcTimeout() { L(this, Fn) && (clearTimeout(L(this, Fn)), re(this, Fn, void 0)); } }, Fn = new WeakMap(), Pf), gr, wr, wt, Je, $r, Mn, Bt, Kt, Nf, x0 = (Nf = class extends Yf { constructor(t) { super(); ue(this, Bt); ue(this, gr); ue(this, wr); ue(this, wt); ue(this, Je); ue(this, $r); ue(this, Mn); re(this, Mn, !1), re(this, $r, t.defaultOptions), this.setOptions(t.options), this.observers = [], re(this, wt, t.cache), this.queryKey = t.queryKey, this.queryHash = t.queryHash, re(this, gr, function(n) { const i = typeof n.initialData == "function" ? n.initialData() : n.initialData, u = i !== void 0, h = u ? typeof n.initialDataUpdatedAt == "function" ? n.initialDataUpdatedAt() : n.initialDataUpdatedAt : 0; return { data: i, dataUpdateCount: 0, dataUpdatedAt: u ? h ?? Date.now() : 0, error: null, errorUpdateCount: 0, errorUpdatedAt: 0, fetchFailureCount: 0, fetchFailureReason: null, fetchMeta: null, isInvalidated: !1, status: u ? "success" : "pending", fetchStatus: "idle" }; }(this.options)), this.state = t.state ?? L(this, gr), this.scheduleGc(); } get meta() { return this.options.meta; } get promise() { var t; return (t = L(this, Je)) == null ? void 0 : t.promise; } setOptions(t) { this.options = { ...L(this, $r), ...t }, this.updateGcTime(this.options.gcTime); } optionalRemove() { this.observers.length || this.state.fetchStatus !== "idle" || L(this, wt).remove(this); } setData(t, n) { const i = Ps(this.state.data, t, this.options); return ge(this, Bt, Kt).call(this, { data: i, type: "success", dataUpdatedAt: n == null ? void 0 : n.updatedAt, manual: n == null ? void 0 : n.manual }), i; } setState(t, n) { ge(this, Bt, Kt).call(this, { type: "setState", state: t, setStateOptions: n }); } cancel(t) { var i, u; const n = (i = L(this, Je)) == null ? void 0 : i.promise; return (u = L(this, Je)) == null || u.cancel(t), n ? n.then(bt).catch(bt) : Promise.resolve(); } destroy() { super.destroy(), this.cancel({ silent: !0 }); } reset() { this.destroy(), this.setState(L(this, gr)); } isActive() { return this.observers.some((t) => It(t.options.enabled, this) !== !1); } isDisabled() { return this.getObserversCount() > 0 && !this.isActive(); } isStale() { return !!this.state.isInvalidated || (this.getObserversCount() > 0 ? this.observers.some((t) => t.getCurrentResult().isStale) : this.state.data === void 0); } isStaleByTime(t = 0) { return this.state.isInvalidated || this.state.data === void 0 || !_f(this.state.dataUpdatedAt, t); } onFocus() { var n; const t = this.observers.find((i) => i.shouldFetchOnWindowFocus()); t == null || t.refetch({ cancelRefetch: !1 }), (n = L(this, Je)) == null || n.continue(); } onOnline() { var n; const t = this.observers.find((i) => i.shouldFetchOnReconnect()); t == null || t.refetch({ cancelRefetch: !1 }), (n = L(this, Je)) == null || n.continue(); } addObserver(t) { this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), L(this, wt).notify({ type: "observerAdded", query: this, observer: t })); } removeObserver(t) { this.observers.includes(t) && (this.observers = this.observers.filter((n) => n !== t), this.observers.length || (L(this, Je) && (L(this, Mn) ? L(this, Je).cancel({ revert: !0 }) : L(this, Je).cancelRetry()), this.scheduleGc()), L(this, wt).notify({ type: "observerRemoved", query: this, observer: t })); } getObserversCount() { return this.observers.length; } invalidate() { this.state.isInvalidated || ge(this, Bt, Kt).call(this, { type: "invalidate" }); } fetch(t, n) { var p, w, m; if (this.state.fetchStatus !== "idle") { if (this.state.data !== void 0 && (n != null && n.cancelRefetch)) this.cancel({ silent: !0 }); else if (L(this, Je)) return L(this, Je).continueRetry(), L(this, Je).promise; } if (t && this.setOptions(t), !this.options.queryFn) { const g = this.observers.find((I) => I.options.queryFn); g && this.setOptions(g.options); } Sr.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error("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']")); const i = new AbortController(), u = (g) => { Object.defineProperty(g, "signal", { enumerable: !0, get: () => (re(this, Mn, !0), i.signal) }); }, h = { fetchOptions: n, options: this.options, queryKey: this.queryKey, state: this.state, fetchFn: () => { const g = Wf(this.options, n), I = { queryKey: this.queryKey, meta: this.meta }; return u(I), re(this, Mn, !1), this.options.persister ? this.options.persister(g, I, this) : g(I); } }; u(h), (p = this.options.behavior) == null || p.onFetch(h, this), re(this, wr, this.state), this.state.fetchStatus !== "idle" && this.state.fetchMeta === ((w = h.fetchOptions) == null ? void 0 : w.meta) || ge(this, Bt, Kt).call(this, { type: "fetch", meta: (m = h.fetchOptions) == null ? void 0 : m.meta }); const c = (g) => { var I, x, d, b; Yo(g) && g.silent || ge(this, Bt, Kt).call(this, { type: "error", error: g }), Yo(g) || ((x = (I = L(this, wt).config).onError) == null || x.call(I, g, this), (b = (d = L(this, wt).config).onSettled) == null || b.call(d, this.state.data, g, this)), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1; }; return re(this, Je, Xf({ initialPromise: n == null ? void 0 : n.initialPromise, fn: h.fetchFn, abort: i.abort.bind(i), onSuccess: (g) => { var I, x, d, b; if (g === void 0) return Sr.env.NODE_ENV !== "production" && console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`), void c(new Error(`${this.queryHash} data is undefined`)); this.setData(g), (x = (I = L(this, wt).config).onSuccess) == null || x.call(I, g, this), (b = (d = L(this, wt).config).onSettled) == null || b.call(d, g, this.state.error, this), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1; }, onError: c, onFail: (g, I) => { ge(this, Bt, Kt).call(this, { type: "failed", failureCount: g, error: I }); }, onPause: () => { ge(this, Bt, Kt).call(this, { type: "pause" }); }, onContinue: () => { ge(this, Bt, Kt).call(this, { type: "continue" }); }, retry: h.options.retry, retryDelay: h.options.retryDelay, networkMode: h.options.networkMode, canRun: () => !0 })), L(this, Je).start(); } }, gr = new WeakMap(), wr = new WeakMap(), wt = new WeakMap(), Je = new WeakMap(), $r = new WeakMap(), Mn = new WeakMap(), Bt = new WeakSet(), Kt = function(t) { this.state = ((n) => { switch (t.type) { case "failed": return { ...n, fetchFailureCount: t.failureCount, fetchFailureReason: t.error }; case "pause": return { ...n, fetchStatus: "paused" }; case "continue": return { ...n, fetchStatus: "fetching" }; case "fetch": return { ...n, ...Kf(n.data, this.options), fetchMeta: t.meta ?? null }; case "success": return { ...n, data: t.data, dataUpdateCount: n.dataUpdateCount + 1, dataUpdatedAt: t.dataUpdatedAt ?? Date.now(), error: null, isInvalidated: !1, status: "success", ...!t.manual && { fetchStatus: "idle", fetchFailureCount: 0, fetchFailureReason: null } }; case "error": const i = t.error; return Yo(i) && i.revert && L(this, wr) ? { ...L(this, wr), fetchStatus: "idle" } : { ...n, error: i, errorUpdateCount: n.errorUpdateCount + 1, errorUpdatedAt: Date.now(), fetchFailureCount: n.fetchFailureCount + 1, fetchFailureReason: i, fetchStatus: "idle", status: "error" }; case "invalidate": return { ...n, isInvalidated: !0 }; case "setState": return { ...n, ...t.state }; } })(this.state), Ke.batch(() => { this.observers.forEach((n) => { n.onQueryUpdate(); }), L(this, wt).notify({ query: this, type: "updated", action: t }); }); }, Nf); function Kf(e, t) { return { fetchFailureCount: 0, fetchFailureReason: null, fetchStatus: Qf(t.networkMode) ? "fetching" : "paused", ...e === void 0 && { error: null, status: "pending" } }; } var zt, kf, A0 = (kf = class extends Jr { constructor(t = {}) { super(); ue(this, zt); this.config = t, re(this, zt, /* @__PURE__ */ new Map()); } build(t, n, i) { const u = n.queryKey, h = n.queryHash ?? pa(u, n); let c = this.get(h); return c || (c = new x0({ cache: this, queryKey: u, queryHash: h, options: t.defaultQueryOptions(n), state: i, defaultOptions: t.getQueryDefaults(u) }), this.add(c)), c; } add(t) { L(this, zt).has(t.queryHash) || (L(this, zt).set(t.queryHash, t), this.notify({ type: "added", query: t })); } remove(t) { const n = L(this, zt).get(t.queryHash); n && (t.destroy(), n === t && L(this, zt).delete(t.queryHash), this.notify({ type: "removed", query: t })); } clear() { Ke.batch(() => { this.getAll().forEach((t) => { this.remove(t); }); }); } get(t) { return L(this, zt).get(t); } getAll() { return [...L(this, zt).values()]; } find(t) { const n = { exact: !0, ...t }; return this.getAll().find((i) => Qa(n, i)); } findAll(t = {}) { const n = this.getAll(); return Object.keys(t).length > 0 ? n.filter((i) => Qa(t, i)) : n; } notify(t) { Ke.batch(() => { this.listeners.forEach((n) => { n(t); }); }); } onFocus() { Ke.batch(() => { this.getAll().forEach((t) => { t.onFocus(); }); }); } onOnline() { Ke.batch(() => { this.getAll().forEach((t) => { t.onOnline(); }); }); } }, zt = new WeakMap(), kf), Vt, tt, jn, qt, bn, Df, B0 = (Df = class extends Yf { constructor(t) { super(); ue(this, qt); ue(this, Vt); ue(this, tt); ue(this, jn); this.mutationId = t.mutationId, re(this, tt, t.mutationCache), re(this, Vt, []), this.state = t.state || { context: void 0, data: void 0, error: null, failureCount: 0, failureReason: null, isPaused: !1, status: "idle", variables: void 0, submittedAt: 0 }, this.setOptions(t.options), this.scheduleGc(); } setOptions(t) { this.options = t, this.updateGcTime(this.options.gcTime); } get meta() { return this.options.meta; } addObserver(t) { L(this, Vt).includes(t) || (L(this, Vt).push(t), this.clearGcTimeout(), L(this, tt).notify({ type: "observerAdded", mutation: this, observer: t })); } removeObserver(t) { re(this, Vt, L(this, Vt).filter((n) => n !== t)), this.scheduleGc(), L(this, tt).notify({ type: "observerRemoved", mutation: this, observer: t }); } optionalRemove() { L(this, Vt).length || (this.state.status === "pending" ? this.scheduleGc() : L(this, tt).remove(this)); } continue() { var t; return ((t = L(this, jn)) == null ? void 0 : t.continue()) ?? this.execute(this.state.variables); } async execute(t) { var u, h, c, p, w, m, g, I, x, d, b, v, E, S, B, T, H, q, X, ne; re(this, jn, Xf({ fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")), onFail: ($, ce) => { ge(this, qt, bn).call(this, { type: "failed", failureCount: $, error: ce }); }, onPause: () => { ge(this, qt, bn).call(this, { type: "pause" }); }, onContinue: () => { ge(this, qt, bn).call(this, { type: "continue" }); }, retry: this.options.retry ?? 0, retryDelay: this.options.retryDelay, networkMode: this.options.networkMode, canRun: () => L(this, tt).canRun(this) })); const n = this.state.status === "pending", i = !L(this, jn).canStart(); try { if (!n) { ge(this, qt, bn).call(this, { type: "pending", variables: t, isPaused: i }), await ((h = (u = L(this, tt).config).onMutate) == null ? void 0 : h.call(u, t, this)); const ce = await ((p = (c = this.options).onMutate) == null ? void 0 : p.call(c, t)); ce !== this.state.context && ge(this, qt, bn).call(this, { type: "pending", context: ce, variables: t, isPaused: i }); } const $ = await L(this, jn).start(); return await ((m = (w = L(this, tt).config).onSuccess) == null ? void 0 : m.call(w, $, t, this.state.context, this)), await ((I = (g = this.options).onSuccess) == null ? void 0 : I.call(g, $, t, this.state.context)), await ((d = (x = L(this, tt).config).onSettled) == null ? void 0 : d.call(x, $, null, this.state.variables, this.state.context, this)), await ((v = (b = this.options).onSettled) == null ? void 0 : v.call(b, $, null, t, this.state.context)), ge(this, qt, bn).call(this, { type: "success", data: $ }), $; } catch ($) { try { throw await ((S = (E = L(this, tt).config).onError) == null ? void 0 : S.call(E, $, t, this.state.context, this)), await ((T = (B = this.options).onError) == null ? void 0 : T.call(B, $, t, this.state.context)), await ((q = (H = L(this, tt).config).onSettled) == null ? void 0 : q.call(H, void 0, $, this.state.variables, this.state.context, this)), await ((ne = (X = this.options).onSettled) == null ? void 0 : ne.call(X, void 0, $, t, this.state.context)), $; } finally { ge(this, qt, bn).call(this, { type: "error", error: $ }); } } finally { L(this, tt).runNext(this); } } }, Vt = new WeakMap(), tt = new WeakMap(), jn = new WeakMap(), qt = new WeakSet(), bn = function(t) { this.state = ((n) => { switch (t.type) { case "failed": return { ...n, failureCount: t.failureCount, failureReason: t.error }; case "pause": return { ...n, isPaused: !0 }; case "continue": return { ...n, isPaused: !1 }; case "pending": return { ...n, context: t.context, data: void 0, failureCount: 0, failureReason: null, error: null, isPaused: t.isPaused, status: "pending", variables: t.variables, submittedAt: Date.now() }; case "success": return { ...n, data: t.data, failureCount: 0, failureReason: null, error: null, status: "success", isPaused: !1 }; case "error": return { ...n, data: void 0, error: t.error, failureCount: n.failureCount + 1, failureReason: t.error, isPaused: !1, status: "error" }; } })(this.state), Ke.batch(() => { L(this, Vt).forEach((n) => { n.onMutationUpdate(t); }), L(this, tt).notify({ mutation: this, type: "updated", action: t }); }); }, Df), ht, Xr, Ff, I0 = (Ff = class extends Jr { constructor(t = {}) { super(); ue(this, ht); ue(this, Xr); this.config = t, re(this, ht, /* @__PURE__ */ new Map()), re(this, Xr, Date.now()); } build(t, n, i) { const u = new B0({ mutationCache: this, mutationId: ++ro(this, Xr)._, options: t.defaultMutationOptions(n), state: i }); return this.add(u), u; } add(t) { const n = oo(t), i = L(this, ht).get(n) ?? []; i.push(t), L(this, ht).set(n, i), this.notify({ type: "added", mutation: t }); } remove(t) { var i; const n = oo(t); if (L(this, ht).has(n)) { const u = (i = L(this, ht).get(n)) == null ? void 0 : i.filter((h) => h !== t); u && (u.length === 0 ? L(this, ht).delete(n) : L(this, ht).set(n, u)); } this.notify({ type: "removed", mutation: t }); } canRun(t) { var i; const n = (i = L(this, ht).get(oo(t))) == null ? void 0 : i.find((u) => u.state.status === "pending"); return !n || n === t; } runNext(t) { var i; const n = (i = L(this, ht).get(oo(t))) == null ? void 0 : i.find((u) => u !== t && u.state.isPaused); return (n == null ? void 0 : n.continue()) ?? Promise.resolve(); } clear() { Ke.batch(() => { this.getAll().forEach((t) => { this.remove(t); }); }); } getAll() { return [...L(this, ht).values()].flat(); } find(t) { const n = { exact: !0, ...t }; return this.getAll().find((i) => $a(n, i)); } findAll(t = {}) { return this.getAll().filter((n) => $a(t, n)); } notify(t) { Ke.batch(() => { this.listeners.forEach((n) => { n(t); }); }); } resumePausedMutations() { const t = this.getAll().filter((n) => n.state.isPaused); return Ke.batch(() => Promise.all(t.map((n) => n.continue().catch(bt)))); } }, ht = new WeakMap(), Xr = new WeakMap(), Ff); function oo(e) { var t; return ((t = e.options.scope) == null ? void 0 : t.id) ?? String(e.mutationId); } function S0(e) { return { onFetch: (t, n) => { const i = async () => { var d, b, v, E, S; const u = t.options, h = (v = (b = (d = t.fetchOptions) == null ? void 0 : d.meta) == null ? void 0 : b.fetchMore) == null ? void 0 : v.direction, c = ((E = t.state.data) == null ? void 0 : E.pages) || [], p = ((S = t.state.data) == null ? void 0 : S.pageParams) || [], w = { pages: [], pageParams: [] }; let m = !1; const g = Wf(t.options, t.fetchOptions), I = async (B, T, H) => { if (m) return Promise.reject(); if (T == null && B.pages.length) return Promise.resolve(B); const q = { queryKey: t.queryKey, pageParam: T, direction: H ? "backward" : "forward", meta: t.options.meta }; var X; X = q, Object.defineProperty(X, "signal", { enumerable: !0, get: () => (t.signal.aborted ? m = !0 : t.signal.addEventListener("abort", () => { m = !0; }), t.signal) }); const ne = await g(q), { maxPages: $ } = t.options, ce = H ? v0 : m0; return { pages: ce(B.pages, ne, $), pageParams: ce(B.pageParams, T, $) }; }; let x; if (h && c.length) { const B = h === "backward", T = { pages: c, pageParams: p }, H = (B ? U0 : Ka)(u, T); x = await I(T, H, B); } else { x = await I(w, p[0] ?? u.initialPageParam); const B = e ?? c.length; for (let T = 1; T < B; T++) { const H = Ka(u, x); if (H == null) break; x = await I(x, H); } } return x; }; t.options.persister ? t.fetchFn = () => { var u, h; return (h = (u = t.options).persister) == null ? void 0 : h.call(u, i, { queryKey: t.queryKey, meta: t.options.meta, signal: t.signal }, n); } : t.fetchFn = i; } }; } function Ka(e, { pages: t, pageParams: n }) { const i = t.length - 1; return t.length > 0 ? e.getNextPageParam(t[i], t, n[i], n) : void 0; } function U0(e, { pages: t, pageParams: n }) { var i; return t.length > 0 ? (i = e.getPreviousPageParam) == null ? void 0 : i.call(e, t[0], t, n[0], n) : void 0; } var Le, Bn, In, br, mr, Sn, vr, Er, Mf, C0 = (Mf = class { constructor(e = {}) { ue(this, Le); ue(this, Bn); ue(this, In); ue(this, br); ue(this, mr); ue(this, Sn); ue(this, vr); ue(this, Er); re(this, Le, e.queryCache || new A0()), re(this, Bn, e.mutationCache || new I0()), re(this, In, e.defaultOptions || {}), re(this, br, /* @__PURE__ */ new Map()), re(this, mr, /* @__PURE__ */ new Map()), re(this, Sn, 0); } mount() { ro(this, Sn)._++, L(this, Sn) === 1 && (re(this, vr, ya.subscribe(async (e) => { e && (await this.resumePausedMutations(), L(this, Le).onFocus()); })), re(this, Er, To.subscribe(async (e) => { e && (await this.resumePausedMutations(), L(this, Le).onOnline()); }))); } unmount() { var e, t; ro(this, Sn)._--, L(this, Sn) === 0 && ((e = L(this, vr)) == null || e.call(this), re(this, vr, void 0), (t = L(this, Er)) == null || t.call(this), re(this, Er, void 0)); } isFetching(e) { return L(this, Le).findAll({ ...e, fetchStatus: "fetching" }).length; } isMutating(e) { return L(this, Bn).findAll({ ...e, status: "pending" }).length; } getQueryData(e) { var n; const t = this.defaultQueryOptions({ queryKey: e }); return (n = L(this, Le).get(t.queryHash)) == null ? void 0 : n.state.data; } ensureQueryData(e) { const t = this.getQueryData(e.queryKey); if (t === void 0) return this.fetchQuery(e); { const n = this.defaultQueryOptions(e), i = L(this, Le).build(this, n); return e.revalidateIfStale && i.isStaleByTime(cr(n.staleTime, i)) && this.prefetchQuery(n), Promise.resolve(t); } } getQueriesData(e) { return L(this, Le).findAll(e).map(({ queryKey: t, state: n }) => [t, n.data]); } setQueryData(e, t, n) { const i = this.defaultQueryOptions({ queryKey: e }), u = L(this, Le).get(i.queryHash), h = u == null ? void 0 : u.state.data, c = function(p, w) { return typeof p == "function" ? p(w) : p; }(t, h); if (c !== void 0) return L(this, Le).build(this, i).setData(c, { ...n, manual: !0 }); } setQueriesData(e, t, n) { return Ke.batch(() => L(this, Le).findAll(e).map(({ queryKey: i }) => [i, this.setQueryData(i, t, n)])); } getQueryState(e) { var n; const t = this.defaultQueryOptions({ queryKey: e }); return (n = L(this, Le).get(t.queryHash)) == null ? void 0 : n.state; } removeQueries(e) { const t = L(this, Le); Ke.batch(() => { t.findAll(e).forEach((n) => { t.remove(n); }); }); } resetQueries(e, t) { const n = L(this, Le), i = { type: "active", ...e }; return Ke.batch(() => (n.findAll(e).forEach((u) => { u.reset(); }), this.refetchQueries(i, t))); } cancelQueries(e = {}, t = {}) { const n = { revert: !0, ...t }, i = Ke.batch(() => L(this, Le).findAll(e).map((u) => u.cancel(n))); return Promise.all(i).then(bt).catch(bt); } invalidateQueries(e = {}, t = {}) { return Ke.batch(() => { if (L(this, Le).findAll(e).forEach((i) => { i.invalidate(); }), e.refetchType === "none") return Promise.resolve(); const n = { ...e, type: e.refetchType ?? e.type ?? "active" }; return this.refetchQueries(n, t); }); } refetchQueries(e = {}, t) { const n = { ...t, cancelRefetch: (t == null ? void 0 : t.cancelRefetch) ?? !0 }, i = Ke.batch(() => L(this, Le).findAll(e).filter((u) => !u.isDisabled()).map((u) => { let h = u.fetch(void 0, n); return n.throwOnError || (h = h.catch(bt)), u.state.fetchStatus === "paused" ? Promise.resolve() : h; })); return Promise.all(i).then(bt); } fetchQuery(e) { const t = this.defaultQueryOptions(e); t.retry === void 0 && (t.retry = !1); const n = L(this, Le).build(this, t); return n.isStaleByTime(cr(t.staleTime, n)) ? n.fetch(t) : Promise.resolve(n.state.data); } prefetchQuery(e) { return this.fetchQuery(e).then(bt).catch(bt); } fetchInfiniteQuery(e) { return e.behavior = S0(e.pages), this.fetchQuery(e); } prefetchInfiniteQuery(e) { return this.fetchInfiniteQuery(e).then(bt).catch(bt); } resumePausedMutations() { return To.isOnline() ? L(this, Bn).resumePausedMutations() : Promise.resolve(); } getQueryCache() { return L(this, Le); } getMutationCache() { return L(this, Bn); } getDefaultOptions() { return L(this, In); } setDefaultOptions(e) { re(this, In, e); } setQueryDefaults(e, t) { L(this, br).set(Zr(e), { queryKey: e, defaultOptions: t }); } getQueryDefaults(e) { const t = [...L(this, br).values()]; let n = {}; return t.forEach((i) => { Hr(e, i.queryKey) && (n = { ...n, ...i.defaultOptions }); }), n; } setMutationDefaults(e, t) { L(this, mr).set(Zr(e), { mutationKey: e, defaultOptions: t }); } getMutationDefaults(e) { const t = [...L(this, mr).values()]; let n = {}; return t.forEach((i) => { Hr(e, i.mutationKey) && (n = { ...n, ...i.defaultOptions }); }), n; } defaultQueryOptions(e) { if (e._defaulted) return e; const t = { ...L(this, In).queries, ...this.getQueryDefaults(e.queryKey), ...e, _defaulted: !0 }; return t.queryHash || (t.queryHash = pa(t.queryKey, t)), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.enabled !== !0 && t.queryFn === Ns && (t.enabled = !1), t; } defaultMutationOptions(e) { return e != null && e._defaulted ? e : { ...L(this, In).mutations, ...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey), ...e, _defaulted: !0 }; } clear() { L(this, Le).clear(), L(this, Bn).clear(); } }, Le = new WeakMap(), Bn = new WeakMap(), In = new WeakMap(), br = new WeakMap(), mr = new WeakMap(), Sn = new WeakMap(), vr = new WeakMap(), Er = new WeakMap(), Mf), rt, we, Yr, nt, zn, xr, Zt, Kr, Ar, Br, Vn, qn, Un, Ir, Ae, zr, ks, Ds, Fs, Ms, js, zs, Vs, Jf, jf, R0 = (jf = class extends Jr { constructor(t, n) { super(); ue(this, Ae); ue(this, rt); ue(this, we); ue(this, Yr); ue(this, nt); ue(this, zn); ue(this, xr); ue(this, Zt); ue(this, Kr); ue(this, Ar); ue(this, Br); ue(this, Vn); ue(this, qn); ue(this, Un); ue(this, Ir, /* @__PURE__ */ new Set()); this.options = n, re(this, rt, t), re(this, Zt, null), this.bindMethods(), this.setOptions(n); } bindMethods() { this.refetch = this.refetch.bind(this); } onSubscribe() { this.listeners.size === 1 && (L(this, we).addObserver(this), Ja(L(this, we), this.options) ? ge(this, Ae, zr).call(this) : this.updateResult(), ge(this, Ae, Ms).call(this)); } onUnsubscribe() { this.hasListeners() || this.destroy(); } shouldFetchOnReconnect() { return qs(L(this, we), this.options, this.options.refetchOnReconnect); } shouldFetchOnWindowFocus() { return qs(L(this, we), this.options, this.options.refetchOnWindowFocus); } destroy() { this.listeners = /* @__PURE__ */ new Set(), ge(this, Ae, js).call(this), ge(this, Ae, zs).call(this), L(this, we).removeObserver(this); } setOptions(t, n) { const i = this.options, u = L(this, we); if (this.options = L(this, rt).defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof It(this.options.enabled, L(this, we)) != "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean"); ge(this, Ae, Vs).call(this), L(this, we).setOptions(this.options), i._defaulted && !Xo(this.options, i) && L(this, rt).getQueryCache().notify({ type: "observerOptionsUpdated", query: L(this, we), observer: this }); const h = this.hasListeners(); h && eu(L(this, we), u, this.options, i) && ge(this, Ae, zr).call(this), this.updateResult(n), !h || L(this, we) === u && It(this.options.enabled, L(this, we)) === It(i.enabled, L(this, we)) && cr(this.options.staleTime, L(this, we)) === cr(i.staleTime, L(this, we)) || ge(this, Ae, ks).call(this); const c = ge(this, Ae, Ds).call(this); !h || L(this, we) === u && It(this.options.enabled, L(this, we)) === It(i.enabled, L(this, we)) && c === L(this, Un) || ge(this, Ae, Fs).call(this, c); } getOptimisticResult(t) { const n = L(this, rt).getQueryCache().build(L(this, rt), t), i = this.createResult(n, t); return function(u, h) { return !Xo(u.getCurrentResult(), h); }(this, i) && (re(this, nt, i), re(this, xr, this.options), re(this, zn, L(this, we).state)), i; } getCurrentResult() { return L(this, nt); } trackResult(t, n) { const i = {}; return Object.keys(t).forEach((u) => { Object.defineProperty(i, u, { configurable: !1, enumerable: !0, get: () => (this.trackProp(u), n == null || n(u), t[u]) }); }), i; } trackProp(t) { L(this, Ir).add(t); } getCurrentQuery() { return L(this, we); } refetch({ ...t } = {}) { return this.fetch({ ...t }); } fetchOptimistic(t) { const n = L(this, rt).defaultQueryOptions(t), i = L(this, rt).getQueryCache().build(L(this, rt), n); return i.isFetchingOptimistic = !0, i.fetch().then(() => this.createResult(i, n)); } fetch(t) { return ge(this, Ae, zr).call(this, { ...t, cancelRefetch: t.cancelRefetch ?? !0 }).then(() => (this.updateResult(), L(this, nt))); } createResult(t, n) { var q; const i = L(this, we), u = this.options, h = L(this, nt), c = L(this, zn), p = L(this, xr), w = t !== i ? t.state : L(this, Yr), { state: m } = t; let g, I = { ...m }, x = !1; if (n._optimisticResults) { const X = this.hasListeners(), ne = !X && Ja(t, n), $ = X && eu(t, i, n, u); (ne || $) && (I = { ...I, ...Kf(m.data, t.options) }), n._optimisticResults === "isRestoring" && (I.fetchStatus = "idle"); } let { error: d, errorUpdatedAt: b, status: v } = I; if (n.select && I.data !== void 0) if (h && I.data === (c == null ? void 0 : c.data) && n.select === L(this, Kr)) g = L(this, Ar); else try { re(this, Kr, n.select), g = n.select(I.data), g = Ps(h == null ? void 0 : h.data, g, n), re(this, Ar, g), re(this, Zt, null); } catch (X) { re(this, Zt, X); } else g = I.data; if (n.placeholderData !== void 0 && g === void 0 && v === "pending") { let X; if (h != null && h.isPlaceholderData && n.placeholderData === (p == null ? void 0 : p.placeholderData)) X = h.data; else if (X = typeof n.placeholderData == "function" ? n.placeholderData((q = L(this, Br)) == null ? void 0 : q.state.data, L(this, Br)) : n.placeholderData, n.select && X !== void 0) try { X = n.select(X), re(this, Zt, null); } catch (ne) { re(this, Zt, ne); } X !== void 0 && (v = "success", g = Ps(h == null ? void 0 : h.data, X, n), x = !0); } L(this, Zt) && (d = L(this, Zt), g = L(this, Ar), b = Date.now(), v = "error"); const E = I.fetchStatus === "fetching", S = v === "pending", B = v === "error", T = S && E, H = g !== void 0; return { status: v, fetchStatus: I.fetchStatus, isPending: S, isSuccess: v === "success", isError: B, isInitialLoading: T, isLoading: T, data: g, dataUpdatedAt: I.dataUpdatedAt, error: d, errorUpdatedAt: b, failureCount: I.fetchFailureCount, failureReason: I.fetchFailureReason, errorUpdateCount: I.errorUpdateCount, isFetched: I.dataUpdateCount > 0 || I.errorUpdateCount > 0, isFetchedAfterMount: I.dataUpdateCount > w.dataUpdateCount || I.errorUpdateCount > w.errorUpdateCount, isFetching: E, isRefetching: E && !S, isLoadingError: B && !H, isPaused: I.fetchStatus === "paused", isPlaceholderData: x, isRefetchError: B && H, isStale: ga(t, n), refetch: this.refetch }; } updateResult(t) { const n = L(this, nt), i = this.createResult(L(this, we), this.options); if (re(this, zn, L(this, we).state), re(this, xr, this.options), L(this, zn).data !== void 0 && re(this, Br, L(this, we)), Xo(i, n)) return; re(this, nt, i); const u = {}; (t == null ? void 0 : t.listeners) !== !1 && (() => { if (!n) return !0; const { notifyOnChangeProps: h } = this.options, c = typeof h == "function" ? h() : h; if (c === "all" || !c && !L(this, Ir).size) return !0; const p = new Set(c ?? L(this, Ir)); return this.options.throwOnError && p.add("error"), Object.keys(L(this, nt)).some((w) => { const m = w; return L(this, nt)[m] !== n[m] && p.has(m); }); })() && (u.listeners = !0), ge(this, Ae, Jf).call(this, { ...u, ...t }); } onQueryUpdate() { this.updateResult(), this.hasListeners() && ge(this, Ae, Ms).call(this); } }, rt = new WeakMap(), we = new WeakMap(), Yr = new WeakMap(), nt = new WeakMap(), zn = new WeakMap(), xr = new WeakMap(), Zt = new WeakMap(), Kr = new WeakMap(), Ar = new WeakMap(), Br = new WeakMap(), Vn = new WeakMap(), qn = new WeakMap(), Un = new WeakMap(), Ir = new WeakMap(), Ae = new WeakSet(), zr = function(t) { ge(this, Ae, Vs).call(this); let n = L(this, we).fetch(this.options, t); return t != null && t.throwOnError || (n = n.catch(bt)), n; }, ks = function() { ge(this, Ae, js).call(this); const t = cr(this.options.staleTime, L(this, we)); if (Ur || L(this, nt).isStale || !Ts(t)) return; const n = _f(L(this, nt).dataUpdatedAt, t) + 1; re(this, Vn, setTimeout(() => { L(this, nt).isStale || this.updateResult(); }, n)); }, Ds = function() { return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(L(this, we)) : this.options.refetchInterval) ?? !1; }, Fs = function(t) { ge(this, Ae, zs).call(this), re(this, Un, t), !Ur && It(this.options.enabled, L(this, we)) !== !1 && Ts(L(this, Un)) && L(this, Un) !== 0 && re(this, qn, setInterval(() => { (this.options.refetchIntervalInBackground || ya.isFocused()) && ge(this, Ae, zr).call(this); }, L(this, Un))); }, Ms = function() { ge(this, Ae, ks).call(this), ge(this, Ae, Fs).call(this, ge(this, Ae, Ds).call(this)); }, js = function() { L(this, Vn) && (clearTimeout(L(this, Vn)), re(this, Vn, void 0)); }, zs = function() { L(this, qn) && (clearInterval(L(this, qn)), re(this, qn, void 0)); }, Vs = function() { const t = L(this, rt).getQueryCache().build(L(this, rt), this.options); if (t === L(this, we)) return; const n = L(this, we); re(this, we, t), re(this, Yr, t.state), this.hasListeners() && (n == null || n.removeObserver(this), t.addObserver(this)); }, Jf = function(t) { Ke.batch(() => { t.listeners && this.listeners.forEach((n) => { n(L(this, nt)); }), L(this, rt).getQueryCache().notify({ query: L(this, we), type: "observerResultsUpdated" }); }); }, jf); function Ja(e, t) { return function(n, i) { return It(i.enabled, n) !== !1 && n.state.data === void 0 && !(n.state.status === "error" && i.retryOnMount === !1); }(e, t) || e.state.data !== void 0 && qs(e, t, t.refetchOnMount); } function qs(e, t, n) { if (It(t.enabled, e) !== !1) { const i = typeof n == "function" ? n(e) : n; return i === "always" || i !== !1 && ga(e, t); } return !1; } function eu(e, t, n, i) { return (e !== t || It(i.enabled, e) === !1) && (!n.suspense || e.state.status !== "error") && ga(e, n); } function ga(e, t) { return It(t.enabled, e) !== !1 && e.isStaleByTime(cr(t.staleTime, e)); } var eh = mt.createContext(void 0), L0 = (e) => { const t = mt.useContext(eh); if (!t) throw new Error("No QueryClient set, use QueryClientProvider to set one"); return t; }, T0 = ({ client: e, children: t }) => (mt.useEffect(() => (e.mount(), () => { e.unmount(); }), [e]), D(eh.Provider, { value: e, children: t })), th = mt.createContext(!1), O0 = () => mt.useContext(th); th.Provider; var P0 = mt.createContext(/* @__PURE__ */ function() { let e = !1; return { clearReset: () => { e = !1; }, reset: () => { e = !0; }, isReset: () => e }; }()), N0 = () => mt.useContext(P0), k0 = (e, t) => { (e.suspense || e.throwOnError) && (t.isReset() || (e.retryOnMount = !1)); }, D0 = (e) => { mt.useEffect(() => { e.clearReset(); }, [e]); }, F0 = ({ result: e, errorResetBoundary: t, throwOnError: n, query: i }) => { return e.isError && !t.isReset() && !e.isFetching && i && (u = n, h = [e.error, i], typeof u == "function" ? u(...h) : !!u); var u, h; }, M0 = (e) => { e.suspense && (typeof e.staleTime != "number" && (e.staleTime = 1e3), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3))); }, j0 = (e, t) => (e == null ? void 0 : e.suspense) && t.isPending, z0 = (e, t, n) => t.fetchOptimistic(e).catch(() => { n.clearReset(); }); function tu(e, t) { return function(n, i, u) { var I, x, d, b; if (Sr.env.NODE_ENV !== "production" && (typeof n != "object" || Array.isArray(n))) throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'); const h = L0(), c = O0(), p = N0(), w = h.defaultQueryOptions(n); (x = (I = h.getDefaultOptions().queries) == null ? void 0 : I._experimental_beforeQuery) == null || x.call(I, w), w._optimisticResults = c ? "isRestoring" : "optimistic", M0(w), k0(w, p), D0(p); const [m] = mt.useState(() => new i(h, w)), g = m.getOptimisticResult(w); if (mt.useSyncExternalStore(mt.useCallback((v) => { const E = c ? () => { } : m.subscribe(Ke.batchCalls(v)); return m.updateResult(), E; }, [m, c]), () => m.getCurrentResult(), () => m.getCurrentResult()), mt.useEffect(() => { m.setOptions(w,