@elevora/react
Version:
Official SDK for Elevora's public API
1,389 lines (1,375 loc) • 154 kB
JavaScript
"use client";
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __pow = Math.pow;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
var __privateWrapper = (obj, member, setter, getter) => ({
set _(value) {
__privateSet(obj, member, value, setter);
},
get _() {
return __privateGet(obj, member, getter);
}
});
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
ElevoraProvider: () => ElevoraProvider,
authControllerCallbackTwitter: () => authControllerCallbackTwitter,
authControllerGetMessage: () => authControllerGetMessage,
authControllerGetTwitterUrl: () => authControllerGetTwitterUrl,
authControllerHandleTelegramAuth: () => authControllerHandleTelegramAuth,
authControllerSendMagicLink: () => authControllerSendMagicLink,
authControllerVerifyCode: () => authControllerVerifyCode,
authControllerVerifyToken: () => authControllerVerifyToken,
authControllerWeb3Login: () => authControllerWeb3Login,
campaignsPublicControllerLeaderboard: () => campaignsPublicControllerLeaderboard,
campaignsPublicControllerPublicDetails: () => campaignsPublicControllerPublicDetails,
campaignsPublicControllerPublicStats: () => campaignsPublicControllerPublicStats,
contentBattlePublicControllerGetCurrentRound: () => contentBattlePublicControllerGetCurrentRound,
contentBattlePublicControllerGetEntry: () => contentBattlePublicControllerGetEntry,
contentBattlePublicControllerSubmitEntry: () => contentBattlePublicControllerSubmitEntry,
contentBattlePublicControllerSubmitVote: () => contentBattlePublicControllerSubmitVote,
getAuthControllerCallbackTwitterQueryKey: () => getAuthControllerCallbackTwitterQueryKey,
getAuthControllerCallbackTwitterQueryOptions: () => getAuthControllerCallbackTwitterQueryOptions,
getAuthControllerGetMessageQueryKey: () => getAuthControllerGetMessageQueryKey,
getAuthControllerGetMessageQueryOptions: () => getAuthControllerGetMessageQueryOptions,
getAuthControllerGetTwitterUrlQueryKey: () => getAuthControllerGetTwitterUrlQueryKey,
getAuthControllerGetTwitterUrlQueryOptions: () => getAuthControllerGetTwitterUrlQueryOptions,
getAuthControllerHandleTelegramAuthQueryKey: () => getAuthControllerHandleTelegramAuthQueryKey,
getAuthControllerHandleTelegramAuthQueryOptions: () => getAuthControllerHandleTelegramAuthQueryOptions,
getAuthControllerSendMagicLinkMutationOptions: () => getAuthControllerSendMagicLinkMutationOptions,
getAuthControllerVerifyCodeMutationOptions: () => getAuthControllerVerifyCodeMutationOptions,
getAuthControllerVerifyTokenMutationOptions: () => getAuthControllerVerifyTokenMutationOptions,
getAuthControllerWeb3LoginMutationOptions: () => getAuthControllerWeb3LoginMutationOptions,
getCampaignsPublicControllerLeaderboardQueryKey: () => getCampaignsPublicControllerLeaderboardQueryKey,
getCampaignsPublicControllerLeaderboardQueryOptions: () => getCampaignsPublicControllerLeaderboardQueryOptions,
getCampaignsPublicControllerPublicDetailsQueryKey: () => getCampaignsPublicControllerPublicDetailsQueryKey,
getCampaignsPublicControllerPublicDetailsQueryOptions: () => getCampaignsPublicControllerPublicDetailsQueryOptions,
getCampaignsPublicControllerPublicStatsQueryKey: () => getCampaignsPublicControllerPublicStatsQueryKey,
getCampaignsPublicControllerPublicStatsQueryOptions: () => getCampaignsPublicControllerPublicStatsQueryOptions,
getContentBattlePublicControllerGetCurrentRoundQueryKey: () => getContentBattlePublicControllerGetCurrentRoundQueryKey,
getContentBattlePublicControllerGetCurrentRoundQueryOptions: () => getContentBattlePublicControllerGetCurrentRoundQueryOptions,
getContentBattlePublicControllerGetEntryQueryKey: () => getContentBattlePublicControllerGetEntryQueryKey,
getContentBattlePublicControllerGetEntryQueryOptions: () => getContentBattlePublicControllerGetEntryQueryOptions,
getContentBattlePublicControllerSubmitEntryMutationOptions: () => getContentBattlePublicControllerSubmitEntryMutationOptions,
getContentBattlePublicControllerSubmitVoteMutationOptions: () => getContentBattlePublicControllerSubmitVoteMutationOptions,
getLeadPublicControllerGetLeadEntryForCampaignQueryKey: () => getLeadPublicControllerGetLeadEntryForCampaignQueryKey,
getLeadPublicControllerGetLeadEntryForCampaignQueryOptions: () => getLeadPublicControllerGetLeadEntryForCampaignQueryOptions,
getLeadPublicControllerGetMeQueryKey: () => getLeadPublicControllerGetMeQueryKey,
getLeadPublicControllerGetMeQueryOptions: () => getLeadPublicControllerGetMeQueryOptions,
getLeadPublicControllerSigninMutationOptions: () => getLeadPublicControllerSigninMutationOptions,
getPushNotificationsControllerGetSubscriptionStatusQueryKey: () => getPushNotificationsControllerGetSubscriptionStatusQueryKey,
getPushNotificationsControllerGetSubscriptionStatusQueryOptions: () => getPushNotificationsControllerGetSubscriptionStatusQueryOptions,
getPushNotificationsControllerGetVapidPublicKeyQueryKey: () => getPushNotificationsControllerGetVapidPublicKeyQueryKey,
getPushNotificationsControllerGetVapidPublicKeyQueryOptions: () => getPushNotificationsControllerGetVapidPublicKeyQueryOptions,
getPushNotificationsControllerSubscribeMutationOptions: () => getPushNotificationsControllerSubscribeMutationOptions,
getPushNotificationsControllerUnsubscribeMutationOptions: () => getPushNotificationsControllerUnsubscribeMutationOptions,
getQuestsPublicControllerGetProgressQueryKey: () => getQuestsPublicControllerGetProgressQueryKey,
getQuestsPublicControllerGetProgressQueryOptions: () => getQuestsPublicControllerGetProgressQueryOptions,
getQuestsPublicControllerUploadMutationOptions: () => getQuestsPublicControllerUploadMutationOptions,
getQuestsPublicControllerValidateMutationOptions: () => getQuestsPublicControllerValidateMutationOptions,
leadPublicControllerGetLeadEntryForCampaign: () => leadPublicControllerGetLeadEntryForCampaign,
leadPublicControllerGetMe: () => leadPublicControllerGetMe,
leadPublicControllerSignin: () => leadPublicControllerSignin,
pushNotificationsControllerGetSubscriptionStatus: () => pushNotificationsControllerGetSubscriptionStatus,
pushNotificationsControllerGetVapidPublicKey: () => pushNotificationsControllerGetVapidPublicKey,
pushNotificationsControllerSubscribe: () => pushNotificationsControllerSubscribe,
pushNotificationsControllerUnsubscribe: () => pushNotificationsControllerUnsubscribe,
questsPublicControllerGetProgress: () => questsPublicControllerGetProgress,
questsPublicControllerUpload: () => questsPublicControllerUpload,
questsPublicControllerValidate: () => questsPublicControllerValidate,
useAuthControllerCallbackTwitter: () => useAuthControllerCallbackTwitter,
useAuthControllerGetMessage: () => useAuthControllerGetMessage,
useAuthControllerGetTwitterUrl: () => useAuthControllerGetTwitterUrl,
useAuthControllerHandleTelegramAuth: () => useAuthControllerHandleTelegramAuth,
useAuthControllerSendMagicLink: () => useAuthControllerSendMagicLink,
useAuthControllerVerifyCode: () => useAuthControllerVerifyCode,
useAuthControllerVerifyToken: () => useAuthControllerVerifyToken,
useAuthControllerWeb3Login: () => useAuthControllerWeb3Login,
useCampaignsPublicControllerLeaderboard: () => useCampaignsPublicControllerLeaderboard,
useCampaignsPublicControllerPublicDetails: () => useCampaignsPublicControllerPublicDetails,
useCampaignsPublicControllerPublicStats: () => useCampaignsPublicControllerPublicStats,
useContentBattle: () => useContentBattle,
useContentBattlePublicControllerGetCurrentRound: () => useContentBattlePublicControllerGetCurrentRound,
useContentBattlePublicControllerGetEntry: () => useContentBattlePublicControllerGetEntry,
useContentBattlePublicControllerSubmitEntry: () => useContentBattlePublicControllerSubmitEntry,
useContentBattlePublicControllerSubmitVote: () => useContentBattlePublicControllerSubmitVote,
useDailyReward: () => useDailyReward,
useElevora: () => useElevora,
useLeadPublicControllerGetLeadEntryForCampaign: () => useLeadPublicControllerGetLeadEntryForCampaign,
useLeadPublicControllerGetMe: () => useLeadPublicControllerGetMe,
useLeadPublicControllerSignin: () => useLeadPublicControllerSignin,
useLeaderboard: () => useLeaderboard,
useMissions: () => useMissions,
useNotifications: () => useNotifications,
usePoints: () => usePoints,
usePushNotificationsControllerGetSubscriptionStatus: () => usePushNotificationsControllerGetSubscriptionStatus,
usePushNotificationsControllerGetVapidPublicKey: () => usePushNotificationsControllerGetVapidPublicKey,
usePushNotificationsControllerSubscribe: () => usePushNotificationsControllerSubscribe,
usePushNotificationsControllerUnsubscribe: () => usePushNotificationsControllerUnsubscribe,
useQuestsPublicControllerGetProgress: () => useQuestsPublicControllerGetProgress,
useQuestsPublicControllerUpload: () => useQuestsPublicControllerUpload,
useQuestsPublicControllerValidate: () => useQuestsPublicControllerValidate,
useSocialConnect: () => useSocialConnect
});
module.exports = __toCommonJS(src_exports);
// src/ElevoraProvider.tsx
var import_react2 = __toESM(require("react"), 1);
// src/elevora-axios-instance.ts
var import_axios = __toESM(require("axios"), 1);
var import_react = require("react");
var import_hooks = require("@thibault.sh/hooks");
var baseURL = process.env.NEXT_PUBLIC_ELEVORA || "https://api.dev.elevora.app";
var elevoraClient = import_axios.default.create({
baseURL
});
var customInstance = (config, options) => __async(void 0, null, function* () {
const response = yield elevoraClient(__spreadValues(__spreadValues({}, config), options));
return response.data;
});
function setAxiosToken(token) {
if (token) {
elevoraClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
} else {
elevoraClient.defaults.headers.common["Authorization"] = void 0;
}
}
function useSetElevoraToken() {
const [token, _setToken] = (0, import_hooks.useLocalStorageState)("elevoraToken", "");
(0, import_react.useEffect)(() => {
setAxiosToken(token);
}, [token]);
const logout = () => {
_setToken("");
setAxiosToken("");
};
const setToken = (token2) => {
_setToken(token2);
setAxiosToken(token2);
};
return { setToken, logout };
}
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/subscribable.js
var Subscribable = class {
constructor() {
this.listeners = /* @__PURE__ */ new Set();
this.subscribe = this.subscribe.bind(this);
}
subscribe(listener) {
this.listeners.add(listener);
this.onSubscribe();
return () => {
this.listeners.delete(listener);
this.onUnsubscribe();
};
}
hasListeners() {
return this.listeners.size > 0;
}
onSubscribe() {
}
onUnsubscribe() {
}
};
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/utils.js
var isServer = typeof window === "undefined" || "Deno" in globalThis;
function noop() {
}
function functionalUpdate(updater, input) {
return typeof updater === "function" ? updater(input) : updater;
}
function isValidTimeout(value) {
return typeof value === "number" && value >= 0 && value !== Infinity;
}
function timeUntilStale(updatedAt, staleTime) {
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
}
function resolveStaleTime(staleTime, query) {
return typeof staleTime === "function" ? staleTime(query) : staleTime;
}
function resolveEnabled(enabled, query) {
return typeof enabled === "function" ? enabled(query) : enabled;
}
function matchQuery(filters, query) {
const {
type = "all",
exact,
fetchStatus,
predicate,
queryKey,
stale
} = filters;
if (queryKey) {
if (exact) {
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
return false;
}
} else if (!partialMatchKey(query.queryKey, queryKey)) {
return false;
}
}
if (type !== "all") {
const isActive = query.isActive();
if (type === "active" && !isActive) {
return false;
}
if (type === "inactive" && isActive) {
return false;
}
}
if (typeof stale === "boolean" && query.isStale() !== stale) {
return false;
}
if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
return false;
}
if (predicate && !predicate(query)) {
return false;
}
return true;
}
function matchMutation(filters, mutation) {
const { exact, status, predicate, mutationKey } = filters;
if (mutationKey) {
if (!mutation.options.mutationKey) {
return false;
}
if (exact) {
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
return false;
}
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
return false;
}
}
if (status && mutation.state.status !== status) {
return false;
}
if (predicate && !predicate(mutation)) {
return false;
}
return true;
}
function hashQueryKeyByOptions(queryKey, options) {
const hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashKey;
return hashFn(queryKey);
}
function hashKey(queryKey) {
return JSON.stringify(
queryKey,
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
result[key] = val[key];
return result;
}, {}) : val
);
}
function partialMatchKey(a, b) {
if (a === b) {
return true;
}
if (typeof a !== typeof b) {
return false;
}
if (a && b && typeof a === "object" && typeof b === "object") {
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]));
}
return false;
}
function replaceEqualDeep(a, b) {
if (a === b) {
return a;
}
const array = isPlainArray(a) && isPlainArray(b);
if (array || isPlainObject(a) && isPlainObject(b)) {
const aItems = array ? a : Object.keys(a);
const aSize = aItems.length;
const bItems = array ? b : Object.keys(b);
const bSize = bItems.length;
const copy = array ? [] : {};
let equalItems = 0;
for (let i = 0; i < bSize; i++) {
const key = array ? i : bItems[i];
if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
copy[key] = void 0;
equalItems++;
} else {
copy[key] = replaceEqualDeep(a[key], b[key]);
if (copy[key] === a[key] && a[key] !== void 0) {
equalItems++;
}
}
}
return aSize === bSize && equalItems === aSize ? a : copy;
}
return b;
}
function shallowEqualObjects(a, b) {
if (!b || Object.keys(a).length !== Object.keys(b).length) {
return false;
}
for (const key in a) {
if (a[key] !== b[key]) {
return false;
}
}
return true;
}
function isPlainArray(value) {
return Array.isArray(value) && value.length === Object.keys(value).length;
}
function isPlainObject(o) {
if (!hasObjectPrototype(o)) {
return false;
}
const ctor = o.constructor;
if (ctor === void 0) {
return true;
}
const prot = ctor.prototype;
if (!hasObjectPrototype(prot)) {
return false;
}
if (!prot.hasOwnProperty("isPrototypeOf")) {
return false;
}
if (Object.getPrototypeOf(o) !== Object.prototype) {
return false;
}
return true;
}
function hasObjectPrototype(o) {
return Object.prototype.toString.call(o) === "[object Object]";
}
function sleep(timeout) {
return new Promise((resolve) => {
setTimeout(resolve, timeout);
});
}
function replaceData(prevData, data, options) {
if (typeof options.structuralSharing === "function") {
return options.structuralSharing(prevData, data);
} else if (options.structuralSharing !== false) {
if (process.env.NODE_ENV !== "production") {
try {
return replaceEqualDeep(prevData, data);
} catch (error) {
console.error(
`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}`
);
}
}
return replaceEqualDeep(prevData, data);
}
return data;
}
function addToEnd(items, item, max = 0) {
const newItems = [...items, item];
return max && newItems.length > max ? newItems.slice(1) : newItems;
}
function addToStart(items, item, max = 0) {
const newItems = [item, ...items];
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
}
var skipToken = Symbol();
function ensureQueryFn(options, fetchOptions) {
if (process.env.NODE_ENV !== "production") {
if (options.queryFn === skipToken) {
console.error(
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
);
}
}
if (!options.queryFn && (fetchOptions == null ? void 0 : fetchOptions.initialPromise)) {
return () => fetchOptions.initialPromise;
}
if (!options.queryFn || options.queryFn === skipToken) {
return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
}
return options.queryFn;
}
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/focusManager.js
var _focused, _cleanup, _setup, _a;
var FocusManager = (_a = class extends Subscribable {
constructor() {
super();
__privateAdd(this, _focused);
__privateAdd(this, _cleanup);
__privateAdd(this, _setup);
__privateSet(this, _setup, (onFocus) => {
if (!isServer && window.addEventListener) {
const listener = () => onFocus();
window.addEventListener("visibilitychange", listener, false);
return () => {
window.removeEventListener("visibilitychange", listener);
};
}
return;
});
}
onSubscribe() {
if (!__privateGet(this, _cleanup)) {
this.setEventListener(__privateGet(this, _setup));
}
}
onUnsubscribe() {
var _a10;
if (!this.hasListeners()) {
(_a10 = __privateGet(this, _cleanup)) == null ? void 0 : _a10.call(this);
__privateSet(this, _cleanup, void 0);
}
}
setEventListener(setup) {
var _a10;
__privateSet(this, _setup, setup);
(_a10 = __privateGet(this, _cleanup)) == null ? void 0 : _a10.call(this);
__privateSet(this, _cleanup, setup((focused) => {
if (typeof focused === "boolean") {
this.setFocused(focused);
} else {
this.onFocus();
}
}));
}
setFocused(focused) {
const changed = __privateGet(this, _focused) !== focused;
if (changed) {
__privateSet(this, _focused, focused);
this.onFocus();
}
}
onFocus() {
const isFocused = this.isFocused();
this.listeners.forEach((listener) => {
listener(isFocused);
});
}
isFocused() {
var _a10;
if (typeof __privateGet(this, _focused) === "boolean") {
return __privateGet(this, _focused);
}
return ((_a10 = globalThis.document) == null ? void 0 : _a10.visibilityState) !== "hidden";
}
}, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a);
var focusManager = new FocusManager();
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/onlineManager.js
var _online, _cleanup2, _setup2, _a2;
var OnlineManager = (_a2 = class extends Subscribable {
constructor() {
super();
__privateAdd(this, _online, true);
__privateAdd(this, _cleanup2);
__privateAdd(this, _setup2);
__privateSet(this, _setup2, (onOnline) => {
if (!isServer && window.addEventListener) {
const onlineListener = () => onOnline(true);
const offlineListener = () => onOnline(false);
window.addEventListener("online", onlineListener, false);
window.addEventListener("offline", offlineListener, false);
return () => {
window.removeEventListener("online", onlineListener);
window.removeEventListener("offline", offlineListener);
};
}
return;
});
}
onSubscribe() {
if (!__privateGet(this, _cleanup2)) {
this.setEventListener(__privateGet(this, _setup2));
}
}
onUnsubscribe() {
var _a10;
if (!this.hasListeners()) {
(_a10 = __privateGet(this, _cleanup2)) == null ? void 0 : _a10.call(this);
__privateSet(this, _cleanup2, void 0);
}
}
setEventListener(setup) {
var _a10;
__privateSet(this, _setup2, setup);
(_a10 = __privateGet(this, _cleanup2)) == null ? void 0 : _a10.call(this);
__privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
}
setOnline(online) {
const changed = __privateGet(this, _online) !== online;
if (changed) {
__privateSet(this, _online, online);
this.listeners.forEach((listener) => {
listener(online);
});
}
}
isOnline() {
return __privateGet(this, _online);
}
}, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a2);
var onlineManager = new OnlineManager();
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/thenable.js
function pendingThenable() {
let resolve;
let reject;
const thenable = new Promise((_resolve, _reject) => {
resolve = _resolve;
reject = _reject;
});
thenable.status = "pending";
thenable.catch(() => {
});
function finalize(data) {
Object.assign(thenable, data);
delete thenable.resolve;
delete thenable.reject;
}
thenable.resolve = (value) => {
finalize({
status: "fulfilled",
value
});
resolve(value);
};
thenable.reject = (reason) => {
finalize({
status: "rejected",
reason
});
reject(reason);
};
return thenable;
}
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/retryer.js
function defaultRetryDelay(failureCount) {
return Math.min(1e3 * __pow(2, failureCount), 3e4);
}
function canFetch(networkMode) {
return (networkMode != null ? networkMode : "online") === "online" ? onlineManager.isOnline() : true;
}
var CancelledError = class extends Error {
constructor(options) {
super("CancelledError");
this.revert = options == null ? void 0 : options.revert;
this.silent = options == null ? void 0 : options.silent;
}
};
function isCancelledError(value) {
return value instanceof CancelledError;
}
function createRetryer(config) {
let isRetryCancelled = false;
let failureCount = 0;
let isResolved = false;
let continueFn;
const thenable = pendingThenable();
const cancel = (cancelOptions) => {
var _a10;
if (!isResolved) {
reject(new CancelledError(cancelOptions));
(_a10 = config.abort) == null ? void 0 : _a10.call(config);
}
};
const cancelRetry = () => {
isRetryCancelled = true;
};
const continueRetry = () => {
isRetryCancelled = false;
};
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
const canStart = () => canFetch(config.networkMode) && config.canRun();
const resolve = (value) => {
var _a10;
if (!isResolved) {
isResolved = true;
(_a10 = config.onSuccess) == null ? void 0 : _a10.call(config, value);
continueFn == null ? void 0 : continueFn();
thenable.resolve(value);
}
};
const reject = (value) => {
var _a10;
if (!isResolved) {
isResolved = true;
(_a10 = config.onError) == null ? void 0 : _a10.call(config, value);
continueFn == null ? void 0 : continueFn();
thenable.reject(value);
}
};
const pause = () => {
return new Promise((continueResolve) => {
var _a10;
continueFn = (value) => {
if (isResolved || canContinue()) {
continueResolve(value);
}
};
(_a10 = config.onPause) == null ? void 0 : _a10.call(config);
}).then(() => {
var _a10;
continueFn = void 0;
if (!isResolved) {
(_a10 = config.onContinue) == null ? void 0 : _a10.call(config);
}
});
};
const run = () => {
if (isResolved) {
return;
}
let promiseOrValue;
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
try {
promiseOrValue = initialPromise != null ? initialPromise : config.fn();
} catch (error) {
promiseOrValue = Promise.reject(error);
}
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
var _a10, _b2, _c;
if (isResolved) {
return;
}
const retry = (_a10 = config.retry) != null ? _a10 : isServer ? 0 : 3;
const retryDelay = (_b2 = config.retryDelay) != null ? _b2 : defaultRetryDelay;
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
if (isRetryCancelled || !shouldRetry) {
reject(error);
return;
}
failureCount++;
(_c = config.onFail) == null ? void 0 : _c.call(config, failureCount, error);
sleep(delay).then(() => {
return canContinue() ? void 0 : pause();
}).then(() => {
if (isRetryCancelled) {
reject(error);
} else {
run();
}
});
});
};
return {
promise: thenable,
cancel,
continue: () => {
continueFn == null ? void 0 : continueFn();
return thenable;
},
cancelRetry,
continueRetry,
canStart,
start: () => {
if (canStart()) {
run();
} else {
pause().then(run);
}
return thenable;
}
};
}
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/notifyManager.js
function createNotifyManager() {
let queue = [];
let transactions = 0;
let notifyFn = (callback) => {
callback();
};
let batchNotifyFn = (callback) => {
callback();
};
let scheduleFn = (cb) => setTimeout(cb, 0);
const schedule = (callback) => {
if (transactions) {
queue.push(callback);
} else {
scheduleFn(() => {
notifyFn(callback);
});
}
};
const flush = () => {
const originalQueue = queue;
queue = [];
if (originalQueue.length) {
scheduleFn(() => {
batchNotifyFn(() => {
originalQueue.forEach((callback) => {
notifyFn(callback);
});
});
});
}
};
return {
batch: (callback) => {
let result;
transactions++;
try {
result = callback();
} finally {
transactions--;
if (!transactions) {
flush();
}
}
return result;
},
/**
* All calls to the wrapped function will be batched.
*/
batchCalls: (callback) => {
return (...args) => {
schedule(() => {
callback(...args);
});
};
},
schedule,
/**
* Use this method to set a custom notify function.
* This can be used to for example wrap notifications with `React.act` while running tests.
*/
setNotifyFunction: (fn) => {
notifyFn = fn;
},
/**
* Use this method to set a custom function to batch notifications together into a single tick.
* By default React Query will use the batch function provided by ReactDOM or React Native.
*/
setBatchNotifyFunction: (fn) => {
batchNotifyFn = fn;
},
setScheduler: (fn) => {
scheduleFn = fn;
}
};
}
var notifyManager = createNotifyManager();
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/removable.js
var _gcTimeout, _a3;
var Removable = (_a3 = class {
constructor() {
__privateAdd(this, _gcTimeout);
}
destroy() {
this.clearGcTimeout();
}
scheduleGc() {
this.clearGcTimeout();
if (isValidTimeout(this.gcTime)) {
__privateSet(this, _gcTimeout, setTimeout(() => {
this.optionalRemove();
}, this.gcTime));
}
}
updateGcTime(newGcTime) {
this.gcTime = Math.max(
this.gcTime || 0,
newGcTime != null ? newGcTime : isServer ? Infinity : 5 * 60 * 1e3
);
}
clearGcTimeout() {
if (__privateGet(this, _gcTimeout)) {
clearTimeout(__privateGet(this, _gcTimeout));
__privateSet(this, _gcTimeout, void 0);
}
}
}, _gcTimeout = new WeakMap(), _a3);
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/query.js
var _initialState, _revertState, _cache, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, dispatch_fn, _a4;
var Query = (_a4 = class extends Removable {
constructor(config) {
var _a10;
super();
__privateAdd(this, _Query_instances);
__privateAdd(this, _initialState);
__privateAdd(this, _revertState);
__privateAdd(this, _cache);
__privateAdd(this, _retryer);
__privateAdd(this, _defaultOptions);
__privateAdd(this, _abortSignalConsumed);
__privateSet(this, _abortSignalConsumed, false);
__privateSet(this, _defaultOptions, config.defaultOptions);
this.setOptions(config.options);
this.observers = [];
__privateSet(this, _cache, config.cache);
this.queryKey = config.queryKey;
this.queryHash = config.queryHash;
__privateSet(this, _initialState, getDefaultState(this.options));
this.state = (_a10 = config.state) != null ? _a10 : __privateGet(this, _initialState);
this.scheduleGc();
}
get meta() {
return this.options.meta;
}
get promise() {
var _a10;
return (_a10 = __privateGet(this, _retryer)) == null ? void 0 : _a10.promise;
}
setOptions(options) {
this.options = __spreadValues(__spreadValues({}, __privateGet(this, _defaultOptions)), options);
this.updateGcTime(this.options.gcTime);
}
optionalRemove() {
if (!this.observers.length && this.state.fetchStatus === "idle") {
__privateGet(this, _cache).remove(this);
}
}
setData(newData, options) {
const data = replaceData(this.state.data, newData, this.options);
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
data,
type: "success",
dataUpdatedAt: options == null ? void 0 : options.updatedAt,
manual: options == null ? void 0 : options.manual
});
return data;
}
setState(state, setStateOptions) {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "setState", state, setStateOptions });
}
cancel(options) {
var _a10, _b2;
const promise = (_a10 = __privateGet(this, _retryer)) == null ? void 0 : _a10.promise;
(_b2 = __privateGet(this, _retryer)) == null ? void 0 : _b2.cancel(options);
return promise ? promise.then(noop).catch(noop) : Promise.resolve();
}
destroy() {
super.destroy();
this.cancel({ silent: true });
}
reset() {
this.destroy();
this.setState(__privateGet(this, _initialState));
}
isActive() {
return this.observers.some(
(observer) => resolveEnabled(observer.options.enabled, this) !== false
);
}
isDisabled() {
if (this.getObserversCount() > 0) {
return !this.isActive();
}
return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
}
isStale() {
if (this.state.isInvalidated) {
return true;
}
if (this.getObserversCount() > 0) {
return this.observers.some(
(observer) => observer.getCurrentResult().isStale
);
}
return this.state.data === void 0;
}
isStaleByTime(staleTime = 0) {
return this.state.isInvalidated || this.state.data === void 0 || !timeUntilStale(this.state.dataUpdatedAt, staleTime);
}
onFocus() {
var _a10;
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
observer == null ? void 0 : observer.refetch({ cancelRefetch: false });
(_a10 = __privateGet(this, _retryer)) == null ? void 0 : _a10.continue();
}
onOnline() {
var _a10;
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
observer == null ? void 0 : observer.refetch({ cancelRefetch: false });
(_a10 = __privateGet(this, _retryer)) == null ? void 0 : _a10.continue();
}
addObserver(observer) {
if (!this.observers.includes(observer)) {
this.observers.push(observer);
this.clearGcTimeout();
__privateGet(this, _cache).notify({ type: "observerAdded", query: this, observer });
}
}
removeObserver(observer) {
if (this.observers.includes(observer)) {
this.observers = this.observers.filter((x) => x !== observer);
if (!this.observers.length) {
if (__privateGet(this, _retryer)) {
if (__privateGet(this, _abortSignalConsumed)) {
__privateGet(this, _retryer).cancel({ revert: true });
} else {
__privateGet(this, _retryer).cancelRetry();
}
}
this.scheduleGc();
}
__privateGet(this, _cache).notify({ type: "observerRemoved", query: this, observer });
}
}
getObserversCount() {
return this.observers.length;
}
invalidate() {
if (!this.state.isInvalidated) {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "invalidate" });
}
}
fetch(options, fetchOptions) {
var _a10, _b2, _c;
if (this.state.fetchStatus !== "idle") {
if (this.state.data !== void 0 && (fetchOptions == null ? void 0 : fetchOptions.cancelRefetch)) {
this.cancel({ silent: true });
} else if (__privateGet(this, _retryer)) {
__privateGet(this, _retryer).continueRetry();
return __privateGet(this, _retryer).promise;
}
}
if (options) {
this.setOptions(options);
}
if (!this.options.queryFn) {
const observer = this.observers.find((x) => x.options.queryFn);
if (observer) {
this.setOptions(observer.options);
}
}
if (process.env.NODE_ENV !== "production") {
if (!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 abortController = new AbortController();
const addSignalProperty = (object) => {
Object.defineProperty(object, "signal", {
enumerable: true,
get: () => {
__privateSet(this, _abortSignalConsumed, true);
return abortController.signal;
}
});
};
const fetchFn = () => {
const queryFn = ensureQueryFn(this.options, fetchOptions);
const queryFnContext = {
queryKey: this.queryKey,
meta: this.meta
};
addSignalProperty(queryFnContext);
__privateSet(this, _abortSignalConsumed, false);
if (this.options.persister) {
return this.options.persister(
queryFn,
queryFnContext,
this
);
}
return queryFn(queryFnContext);
};
const context = {
fetchOptions,
options: this.options,
queryKey: this.queryKey,
state: this.state,
fetchFn
};
addSignalProperty(context);
(_a10 = this.options.behavior) == null ? void 0 : _a10.onFetch(
context,
this
);
__privateSet(this, _revertState, this.state);
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((_b2 = context.fetchOptions) == null ? void 0 : _b2.meta)) {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "fetch", meta: (_c = context.fetchOptions) == null ? void 0 : _c.meta });
}
const onError = (error) => {
var _a11, _b3, _c2, _d;
if (!(isCancelledError(error) && error.silent)) {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
type: "error",
error
});
}
if (!isCancelledError(error)) {
(_b3 = (_a11 = __privateGet(this, _cache).config).onError) == null ? void 0 : _b3.call(
_a11,
error,
this
);
(_d = (_c2 = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _d.call(
_c2,
this.state.data,
error,
this
);
}
this.scheduleGc();
};
__privateSet(this, _retryer, createRetryer({
initialPromise: fetchOptions == null ? void 0 : fetchOptions.initialPromise,
fn: context.fetchFn,
abort: abortController.abort.bind(abortController),
onSuccess: (data) => {
var _a11, _b3, _c2, _d;
if (data === void 0) {
if (process.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}`
);
}
onError(new Error(`${this.queryHash} data is undefined`));
return;
}
try {
this.setData(data);
} catch (error) {
onError(error);
return;
}
(_b3 = (_a11 = __privateGet(this, _cache).config).onSuccess) == null ? void 0 : _b3.call(_a11, data, this);
(_d = (_c2 = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _d.call(
_c2,
data,
this.state.error,
this
);
this.scheduleGc();
},
onError,
onFail: (failureCount, error) => {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "failed", failureCount, error });
},
onPause: () => {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "pause" });
},
onContinue: () => {
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "continue" });
},
retry: context.options.retry,
retryDelay: context.options.retryDelay,
networkMode: context.options.networkMode,
canRun: () => true
}));
return __privateGet(this, _retryer).start();
}
}, _initialState = new WeakMap(), _revertState = new WeakMap(), _cache = new WeakMap(), _retryer = new WeakMap(), _defaultOptions = new WeakMap(), _abortSignalConsumed = new WeakMap(), _Query_instances = new WeakSet(), dispatch_fn = function(action) {
const reducer = (state) => {
var _a10, _b2;
switch (action.type) {
case "failed":
return __spreadProps(__spreadValues({}, state), {
fetchFailureCount: action.failureCount,
fetchFailureReason: action.error
});
case "pause":
return __spreadProps(__spreadValues({}, state), {
fetchStatus: "paused"
});
case "continue":
return __spreadProps(__spreadValues({}, state), {
fetchStatus: "fetching"
});
case "fetch":
return __spreadProps(__spreadValues(__spreadValues({}, state), fetchState(state.data, this.options)), {
fetchMeta: (_a10 = action.meta) != null ? _a10 : null
});
case "success":
return __spreadValues(__spreadProps(__spreadValues({}, state), {
data: action.data,
dataUpdateCount: state.dataUpdateCount + 1,
dataUpdatedAt: (_b2 = action.dataUpdatedAt) != null ? _b2 : Date.now(),
error: null,
isInvalidated: false,
status: "success"
}), !action.manual && {
fetchStatus: "idle",
fetchFailureCount: 0,
fetchFailureReason: null
});
case "error":
const error = action.error;
if (isCancelledError(error) && error.revert && __privateGet(this, _revertState)) {
return __spreadProps(__spreadValues({}, __privateGet(this, _revertState)), { fetchStatus: "idle" });
}
return __spreadProps(__spreadValues({}, state), {
error,
errorUpdateCount: state.errorUpdateCount + 1,
errorUpdatedAt: Date.now(),
fetchFailureCount: state.fetchFailureCount + 1,
fetchFailureReason: error,
fetchStatus: "idle",
status: "error"
});
case "invalidate":
return __spreadProps(__spreadValues({}, state), {
isInvalidated: true
});
case "setState":
return __spreadValues(__spreadValues({}, state), action.state);
}
};
this.state = reducer(this.state);
notifyManager.batch(() => {
this.observers.forEach((observer) => {
observer.onQueryUpdate();
});
__privateGet(this, _cache).notify({ query: this, type: "updated", action });
});
}, _a4);
function fetchState(data, options) {
return __spreadValues({
fetchFailureCount: 0,
fetchFailureReason: null,
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused"
}, data === void 0 && {
error: null,
status: "pending"
});
}
function getDefaultState(options) {
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
const hasData = data !== void 0;
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
return {
data,
dataUpdateCount: 0,
dataUpdatedAt: hasData ? initialDataUpdatedAt != null ? initialDataUpdatedAt : Date.now() : 0,
error: null,
errorUpdateCount: 0,
errorUpdatedAt: 0,
fetchFailureCount: 0,
fetchFailureReason: null,
fetchMeta: null,
isInvalidated: false,
status: hasData ? "success" : "pending",
fetchStatus: "idle"
};
}
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/queryCache.js
var _queries, _a5;
var QueryCache = (_a5 = class extends Subscribable {
constructor(config = {}) {
super();
__privateAdd(this, _queries);
this.config = config;
__privateSet(this, _queries, /* @__PURE__ */ new Map());
}
build(client, options, state) {
var _a10;
const queryKey = options.queryKey;
const queryHash = (_a10 = options.queryHash) != null ? _a10 : hashQueryKeyByOptions(queryKey, options);
let query = this.get(queryHash);
if (!query) {
query = new Query({
cache: this,
queryKey,
queryHash,
options: client.defaultQueryOptions(options),
state,
defaultOptions: client.getQueryDefaults(queryKey)
});
this.add(query);
}
return query;
}
add(query) {
if (!__privateGet(this, _queries).has(query.queryHash)) {
__privateGet(this, _queries).set(query.queryHash, query);
this.notify({
type: "added",
query
});
}
}
remove(query) {
const queryInMap = __privateGet(this, _queries).get(query.queryHash);
if (queryInMap) {
query.destroy();
if (queryInMap === query) {
__privateGet(this, _queries).delete(query.queryHash);
}
this.notify({ type: "removed", query });
}
}
clear() {
notifyManager.batch(() => {
this.getAll().forEach((query) => {
this.remove(query);
});
});
}
get(queryHash) {
return __privateGet(this, _queries).get(queryHash);
}
getAll() {
return [...__privateGet(this, _queries).values()];
}
find(filters) {
const defaultedFilters = __spreadValues({ exact: true }, filters);
return this.getAll().find(
(query) => matchQuery(defaultedFilters, query)
);
}
findAll(filters = {}) {
const queries = this.getAll();
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
}
notify(event) {
notifyManager.batch(() => {
this.listeners.forEach((listener) => {
listener(event);
});
});
}
onFocus() {
notifyManager.batch(() => {
this.getAll().forEach((query) => {
query.onFocus();
});
});
}
onOnline() {
notifyManager.batch(() => {
this.getAll().forEach((query) => {
query.onOnline();
});
});
}
}, _queries = new WeakMap(), _a5);
// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/mutation.js
var _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _a6;
var Mutation = (_a6 = class extends Removable {
constructor(config) {
super();
__privateAdd(this, _Mutation_instances);
__privateAdd(this, _observers);
__privateAdd(this, _mutationCache);
__privateAdd(this, _retryer2);
this.mutationId = config.mutationId;
__privateSet(this, _mutationCache, config.mutationCache);
__privateSet(this, _observers, []);
this.state = config.state || getDefaultState2();
this.setOptions(config.options);
this.scheduleGc();
}
setOptions(options) {
this.options = options;
this.updateGcTime(this.options.gcTime);
}
get meta() {
return this.options.meta;
}
addObserver(observer) {
if (!__privateGet(this, _observers).includes(observer)) {
__privateGet(this, _observers).push(observer);
this.clearGcTimeout();
__privateGet(this, _mutationCache).notify({
type: "observerAdded",
mutation: this,
observer
});
}
}
removeObserver(observer) {
__privateSet(this, _observers, __privateGet(this, _observers).filter((x) => x !== observer));
this.scheduleGc();
__privateGet(this, _mutationCache).notify({
type: "observerRemoved",
mutation: this,
observer
});
}
optionalRemove() {
if (!__privateGet(this, _observers).length) {
if (this.state.status === "pending") {
this.scheduleGc();
} else {
__privateGet(this, _mutationCache).remove(this);
}
}
}
continue() {
var _a10, _b2;
return (_b2 = (_a10 = __privateGet(this, _retryer2)) == null ? void 0 : _a10.continue()) != null ? _b2 : (
// continuing a mutation assumes that variable