UNPKG

@elevora/react

Version:

Official SDK for Elevora's public API

3,978 lines • 154 kB
"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 variables are set, mutation must have been dehydrated before
      this.execute(this.state.variables)
    );
  }
  execute(variables) {
    return __async(this, null, function* () {
      var _a10, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
      __privateSet(this, _retryer2, createRetryer({
        fn: () => {
          if (!this.options.mutationFn) {
            return Promise.reject(new Error("No mutationFn found"));
          }
          return this.options.mutationFn(variables);
        },
        onFail: (failureCount, error) => {
          __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "failed", failureCount, error });
        },
        onPause: () => {
          __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pause" });
        },
        onContinue: () => {
          __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "continue" });
        },
        retry: (_a10 = this.options.retry) != null ? _a10 : 0,
        retryDelay: this.options.retryDelay,
        networkMode: this.options.networkMode,
        canRun: () => __privateGet(this, _mutationCache).canRun(this)
      }));
      const restored = this.state.status === "pending";
      const isPaused = !__privateGet(this, _retryer2).canStart();
      try {
        if (!restored) {
          __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pending", variables, isPaused });
          yield (_c = (_b2 = __privateGet(this, _mutationCache).config).onMutate) == null ? void 0 : _c.call(
            _b2,
            variables,
            this
          );
          const context = yield (_e = (_d = this.options).onMutate) == null ? void 0 : _e.call(_d, variables);
          if (context !== this.state.context) {
            __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, {
              type: "pending",
              context,
              variables,
              isPaused
            });
          }
        }
        const data = yield __privateGet(this, _retryer2).start();
        yield (_g = (_f = __privateGet(this, _mutationCache).config).onSuccess) == null ? void 0 : _g.call(
          _f,
          data,
          variables,
          this.state.context,
          this
        );
        yield (_i = (_h = this.options).onSuccess) == null ? void 0 : _i.call(_h, data, variables, this.state.context);
        yield (_k = (_j = __privateGet(this, _mutationCache).config).onSettled) == null ? void 0 : _k.call(
          _j,
          data,
          null,
          this.state.variables,
          this.state.context,
          this
        );
        yield (_m = (_l = this.options).onSettled) == null ? void 0 : _m.call(_l, data, null, variables, this.state.context);
        __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "success", data });
        return data;
      } catch (error) {
        try {
          yield (_o = (_n = __privateGet(this, _mutationCache).config).onError) == null ? void 0 : _o.call(
            _n,
            error,
            variables,
            this.state.context,
            this
          );
          yield (_q = (_p = this.options).onError) == null ? void 0 : _q.call(
            _p,
            error,
            variables,
            this.state.context
          );
          yield (_s = (_r = __privateGet(this, _mutationCache).config).onSettled) == null ? void 0 : _s.call(
            _r,
            void 0,
            error,
            this.state.variables,
            this.state.context,
            this
          );
          yield (_u = (_t = this.options).onSettled) == null ? void 0 : _u.call(
            _t,
            void 0,
            error,
            variables,
            this.state.context
          );
          throw error;
        } finally {
          __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "error", error });
        }
      } finally {
        __privateGet(this, _mutationCache).runNext(this);
      }
    });
  }
}, _observers = new WeakMap(), _mutationCache = new WeakMap(), _retryer2 = new WeakMap(), _Mutation_instances = new WeakSet(), dispatch_fn2 = function(action) {
  const reducer = (state) => {
    switch (action.type) {
      case "failed":
        return __spreadProps(__spreadValues({}, state), {
          failureCount: action.failureCount,
          failureReason: action.error
        });
      case "pause":
        return __spreadProps(__spreadValues({}, state), {
          isPaused: true
        });
      case "continue":
        return __spreadProps(__spreadValues({}, state), {
          isPaused: false
        });
      case "pending":
        return __spreadProps(__spreadValues({}, state), {
          context: action.context,
          data: void 0,
          failureCount: 0,
          failureReason: null,
          error: null,
          isPaused: action.isPaused,
          status: "pending",
          variables: action.variables,
          submittedAt: Date.now()
        });
      case "success":
        return __spreadProps(__spreadValues({}, state), {
          data: action.data,
          failureCount: 0,
          failureReason: null,
          error: null,
          status: "success",
          isPaused: false
        });
      case "error":
        return __spreadProps(__spreadValues({}, state), {
          data: void 0,
          error: action.error,
          failureCount: state.failureCount + 1,
          failureReason: action.error,
          isPaused: false,
          status: "error"
        });
    }
  };
  this.state = reducer(this.state);
  notifyManager.batch(() => {
    __privateGet(this, _observers).forEach((observer) => {
      observer.onMutationUpdate(action);
    });
    __privateGet(this, _mutationCache).notify({
      mutation: this,
      type: "updated",
      action
    });
  });
}, _a6);
function getDefaultState2() {
  return {
    context: void 0,
    data: void 0,
    error: null,
    failureCount: 0,
    failureReason: null,
    isPaused: false,
    status: "idle",
    variables: void 0,
    submittedAt: 0
  };
}

// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/mutationCache.js
var _mutations, _mutationId, _a7;
var MutationCache = (_a7 = class extends Subscribable {
  constructor(config = {}) {
    super();
    __privateAdd(this, _mutations);
    __privateAdd(this, _mutationId);
    this.config = config;
    __privateSet(this, _mutations, /* @__PURE__ */ new Map());
    __privateSet(this, _mutationId, Date.now());
  }
  build(client, options, state) {
    const mutation = new Mutation({
      mutationCache: this,
      mutationId: ++__privateWrapper(this, _mutationId)._,
      options: client.defaultMutationOptions(options),
      state
    });
    this.add(mutation);
    return mutation;
  }
  add(mutation) {
    var _a10;
    const scope = scopeFor(mutation);
    const mutations = (_a10 = __privateGet(this, _mutations).get(scope)) != null ? _a10 : [];
    mutations.push(mutation);
    __privateGet(this, _mutations).set(scope, mutations);
    this.notify({ type: "added", mutation });
  }
  remove(mutation) {
    var _a10;
    const scope = scopeFor(mutation);
    if (__privateGet(this, _mutations).has(scope)) {
      const mutations = (_a10 = __privateGet(this, _mutations).get(scope)) == null ? void 0 : _a10.filter((x) => x !== mutation);
      if (mutations) {
        if (mutations.length === 0) {
          __privateGet(this, _mutations).delete(scope);
        } else {
          __privateGet(this, _mutations).set(scope, mutations);
        }
      }
    }
    this.notify({ type: "removed", mutation });
  }
  canRun(mutation) {
    var _a10;
    const firstPendingMutation = (_a10 = __privateGet(this, _mutations).get(scopeFor(mutation))) == null ? void 0 : _a10.find((m) => m.state.status === "pending");
    return !firstPendingMutation || firstPendingMutation === mutation;
  }
  runNext(mutation) {
    var _a10, _b2;
    const foundMutation = (_a10 = __privateGet(this, _mutations).get(scopeFor(mutation))) == null ? void 0 : _a10.find((m) => m !== mutation && m.state.isPaused);
    return (_b2 = foundMutation == null ? void 0 : foundMutation.continue()) != null ? _b2 : Promise.resolve();
  }
  clear() {
    notifyManager.batch(() => {
      this.getAll().forEach((mutation) => {
        this.remove(mutation);
      });
    });
  }
  getAll() {
    return [...__privateGet(this, _mutations).values()].flat();
  }
  find(filters) {
    const defaultedFilters = __spreadValues({ exact: true }, filters);
    return this.getAll().find(
      (mutation) => matchMutation(defaultedFilters, mutation)
    );
  }
  findAll(filters = {}) {
    return this.getAll().filter((mutation) => matchMutation(filters, mutation));
  }
  notify(event) {
    notifyManager.batch(() => {
      this.listeners.forEach((listener) => {
        listener(event);
      });
    });
  }
  resumePausedMutations() {
    const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
    return notifyManager.batch(
      () => Promise.all(
        pausedMutations.map((mutation) => mutation.continue().catch(noop))
      )
    );
  }
}, _mutations = new WeakMap(), _mutationId = new WeakMap(), _a7);
function scopeFor(mutation) {
  var _a10, _b2;
  return (_b2 = (_a10 = mutation.options.scope) == null ? void 0 : _a10.id) != null ? _b2 : String(mutation.mutationId);
}

// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
function infiniteQueryBehavior(pages) {
  return {
    onFetch: (context, query) => {
      var _a10, _b2, _c, _d, _e;
      const options = context.options;
      const direction = (_c = (_b2 = (_a10 = context.fetchOptions) == null ? void 0 : _a10.meta) == null ? void 0 : _b2.fetchMore) == null ? void 0 : _c.direction;
      const oldPages = ((_d = context.state.data) == null ? void 0 : _d.pages) || [];
      const oldPageParams = ((_e = context.state.data) == null ? void 0 : _e.pageParams) || [];
      let result = { pages: [], pageParams: [] };
      let currentPage = 0;
      const fetchFn = () => __async(this, null, function* () {
        var _a11;
        let cancelled = false;
        const addSignalProperty = (object) => {
          Object.defineProperty(object, "signal", {
            enumerable: true,
            get: () => {
              if (context.signal.aborted) {
                cancelled = true;
              } else {
                context.signal.addEventListener("abort", () => {
                  cancelled = true;
                });
              }
              return context.signal;
            }
          });
        };
        const queryFn = ensureQueryFn(context.options, context.fetchOptions);
        const fetchPage = (data, param, previous) => __async(this, null, function* () {
          if (cancelled) {
            return Promise.reject();
          }
          if (param == null && data.pages.length) {
            return Promise.resolve(data);
          }
          const queryFnContext = {
            queryKey: context.queryKey,
            pageParam: param,
            direction: previous ? "backward" : "forward",
            meta: context.options.meta
          };
          addSignalProperty(queryFnContext);
          const page = yield queryFn(
            queryFnContext
          );
          const { maxPages } = context.options;
          const addTo = previous ? addToStart : addToEnd;
          return {
            pages: addTo(data.pages, page, maxPages),
            pageParams: addTo(data.pageParams, param, maxPages)
          };
        });
        if (direction && oldPages.length) {
          const previous = direction === "backward";
          const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
          const oldData = {
            pages: oldPages,
            pageParams: oldPageParams
          };
          const param = pageParamFn(options, oldData);
          result = yield fetchPage(oldData, param, previous);
        } else {
          const remainingPages = pages != null ? pages : oldPages.length;
          do {
            const param = currentPage === 0 ? (_a11 = oldPageParams[0]) != null ? _a11 : options.initialPageParam : getNextPageParam(options, result);
            if (currentPage > 0 && param == null) {
              break;
            }
            result = yield fetchPage(result, param);
            currentPage++;
          } while (currentPage < remainingPages);
        }
        return result;
      });
      if (context.options.persister) {
        context.fetchFn = () => {
          var _a11, _b3;
          return (_b3 = (_a11 = context.options).persister) == null ? void 0 : _b3.call(
            _a11,
            fetchFn,
            {
              queryKey: context.queryKey,
              meta: context.options.meta,
              signal: context.signal
            },
            query
          );
        };
      } else {
        context.fetchFn = fetchFn;
      }
    }
  };
}
function getNextPageParam(options, { pages, pageParams }) {
  const lastIndex = pages.length - 1;
  return pages.length > 0 ? options.getNextPageParam(
    pages[lastIndex],
    pages,
    pageParams[lastIndex],
    pageParams
  ) : void 0;
}
function getPreviousPageParam(options, { pages, pageParams }) {
  var _a10;
  return pages.length > 0 ? (_a10 = options.getPreviousPageParam) == null ? void 0 : _a10.call(options, pages[0], pages, pageParams[0], pageParams) : void 0;
}

// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/queryClient.js
var _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _a8;
var QueryClient = (_a8 = class {
  constructor(config = {}) {
    __privateAdd(this, _queryCache);
    __privateAdd(this, _mutationCache2);
    __privateAdd(this, _defaultOptions2);
    __privateAdd(this, _queryDefaults);
    __privateAdd(this, _mutationDefaults);
    __privateAdd(this, _mountCount);
    __privateAdd(this, _unsubscribeFocus);
    __privateAdd(this, _unsubscribeOnline);
    __privateSet(this, _queryCache, config.queryCache || new QueryCache());
    __privateSet(this, _mutationCache2, config.mutationCache || new MutationCache());
    __privateSet(this, _defaultOptions2, config.defaultOptions || {});
    __privateSet(this, _queryDefaults, /* @__PURE__ */ new Map());
    __privateSet(this, _mutationDefaults, /* @__PURE__ */ new Map());
    __privateSet(this, _mountCount, 0);
  }
  mount() {
    __privateWrapper(this, _mountCount)._++;
    if (__privateGet(this, _mountCount) !== 1)
      return;
    __privateSet(this, _unsubscribeFocus, focusManager.subscribe((focused) => __async(this, null, function* () {
      if (focused) {
        yield this.resumePausedMutations();
        __privateGet(this, _queryCache).onFocus();
      }
    })));
    __privateSet(this, _unsubscribeOnline, onlineManager.subscribe((online) => __async(this, null, function* () {
      if (online) {
        yield this.resumePausedMutations();
        __privateGet(this, _queryCache).onOnline();
      }
    })));
  }
  unmount() {
    var _a10, _b2;
    __privateWrapper(this, _mountCount)._--;
    if (__privateGet(this, _mountCount) !== 0)
      return;
    (_a10 = __privateGet(this, _unsubscribeFocus)) == null ? void 0 : _a10.call(this);
    __privateSet(this, _unsubscribeFocus, void 0);
    (_b2 = __privateGet(this, _unsubscribeOnline)) == null ? void 0 : _b2.call(this);
    __privateSet(this, _unsubscribeOnline, void 0);
  }
  isFetching(filters) {
    return __privateGet(this, _queryCache).findAll(__spreadProps(__spreadValues({}, filters), { fetchStatus: "fetching" })).length;
  }
  isMutating(filters) {
    return __privateGet(this, _mutationCache2).findAll(__spreadProps(__spreadValues({}, filters), { status: "pending" })).length;
  }
  getQueryData(queryKey) {
    var _a10;
    const options = this.defaultQueryOptions({ queryKey });
    return (_a10 = __privateGet(this, _queryCache).get(options.queryHash)) == null ? void 0 : _a10.state.data;
  }
  ensureQueryData(options) {
    const defaultedOptions = this.defaultQueryOptions(options);
    const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
    const cachedData = query.state.data;
    if (cachedData === void 0) {
      return this.fetchQuery(options);
    }
    if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
      void this.prefetchQuery(defaultedOptions);
    }
    return Promise.resolve(cachedData);
  }
  getQueriesData(filters) {
    return __privateGet(this, _queryCache).findAll(filters).map(({ queryKey, state }) => {
      const data = state.data;
      return [queryKey, data];
    });
  }
  setQueryData(queryKey, updater, options) {
    const defaultedOptions = this.defaultQueryOptions({ queryKey });
    const query = __privateGet(this, _queryCache).get(
      defaultedOptions.queryHash
    );
    const prevData = query == null ? void 0 : query.state.data;
    const data = functionalUpdate(updater, prevData);
    if (data === void 0) {
      return void 0;
    }
    return __privateGet(this, _queryCache).build(this, defaultedOptions).setData(data, __spreadProps(__spreadValues({}, options), { manual: true }));
  }
  setQueriesData(filters, updater, options) {
    return notifyManager.batch(
      () => __privateGet(this, _queryCache).findAll(filters).map(({ queryKey }) => [
        queryKey,
        this.setQueryData(queryKey, updater, options)
      ])
    );
  }
  getQueryState(queryKey) {
    var _a10;
    const options = this.defaultQueryOptions({ queryKey });
    return (_a10 = __privateGet(this, _queryCache).get(
      options.queryHash
    )) == null ? void 0 : _a10.state;
  }
  removeQueries(filters) {
    const queryCache = __privateGet(this, _queryCache);
    notifyManager.batch(() => {
      queryCache.findAll(filters).forEach((query) => {
        queryCache.remove(query);
      });
    });
  }
  resetQueries(filters, options) {
    const queryCache = __privateGet(this, _queryCache);
    const refetchFilters = __spreadValues({
      type: "active"
    }, filters);
    return notifyManager.batch(() => {
      queryCache.findAll(filters).forEach((query) => {
        query.reset();
      });
      return this.refetchQueries(refetchFilters, options);
    });
  }
  cancelQueries(filters, cancelOptions = {}) {
    const defaultedCancelOptions = __spreadValues({ revert: true }, cancelOptions);
    const promises = notifyManager.batch(
      () => __privateGet(this, _queryCache).findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
    );
    return Promise.all(promises).then(noop).catch(noop);
  }
  invalidateQueries(filters, options = {}) {
    return notifyManager.batch(() => {
      var _a10, _b2;
      __privateGet(this, _queryCache).findAll(filters).forEach((query) => {
        query.invalidate();
      });
      if ((filters == null ? void 0 : filters.refetchType) === "none") {
        return Promise.resolve();
      }
      const refetchFilters = __spreadProps(__spreadValues({}, filters), {
        type: (_b2 = (_a10 = filters == null ? void 0 : filters.refetchType) != null ? _a10 : filters == null ? void 0 : filters.type) != null ? _b2 : "active"
      });
      return this.refetchQueries(refetchFilters, options);
    });
  }
  refetchQueries(filters, options = {}) {
    var _a10;
    const fetchOptions = __spreadProps(__spreadValues({}, options), {
      cancelRefetch: (_a10 = options.cancelRefetch) != null ? _a10 : true
    });
    const promises = notifyManager.batch(
      () => __privateGet(this, _queryCache).findAll(filters).filter((query) => !query.isDisabled()).map((query) => {
        let promise = query.fetch(void 0, fetchOptions);
        if (!fetchOptions.throwOnError) {
          promise = promise.catch(noop);
        }
        return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
      })
    );
    return Promise.all(promises).then(noop);
  }
  fetchQuery(options) {
    const defaultedOptions = this.defaultQueryOptions(options);
    if (defaultedOptions.retry === void 0) {
      defaultedOptions.retry = false;
    }
    const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
    return query.isStaleByTime(
      resolveStaleTime(defaultedOptions.staleTime, query)
    ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
  }
  prefetchQuery(options) {
    return this.fetchQuery(options).then(noop).catch(noop);
  }
  fetchInfiniteQuery(options) {
    options.behavior = infiniteQueryBehavior(options.pages);
    return this.fetchQuery(options);
  }
  prefetchInfiniteQuery(options) {
    return this.fetchInfiniteQuery(options).then(noop).catch(noop);
  }
  ensureInfiniteQueryData(options) {
    options.behavior = infiniteQueryBehavior(options.pages);
    return this.ensureQueryData(options);
  }
  resumePausedMutations() {
    if (onlineManager.isOnline()) {
      return __privateGet(this, _mutationCache2).resumePausedMutations();
    }
    return Promise.resolve();
  }
  getQueryCache() {
    return __privateGet(this, _queryCache);
  }
  getMutationCache() {
    return __privateGet(this, _mutationCache2);
  }
  getDefaultOptions() {
    return __privateGet(this, _defaultOptions2);
  }
  setDefaultOptions(options) {
    __privateSet(this, _defaultOptions2, options);
  }
  setQueryDefaults(queryKey, options) {
    __privateGet(this, _queryDefaults).set(hashKey(queryKey), {
      queryKey,
      defaultOptions: options
    });
  }
  getQueryDefaults(queryKey) {
    const defaults = [...__privateGet(this, _queryDefaults).values()];
    const result = {};
    defaults.forEach((queryDefault) => {
      if (partialMatchKey(queryKey, queryDefault.queryKey)) {
        Object.assign(result, queryDefault.defaultOptions);
      }
    });
    return result;
  }
  setMutationDefaults(mutationKey, options) {
    __privateGet(this, _mutationDefaults).set(hashKey(mutationKey), {
      mutationKey,
      defaultOptions: options
    });
  }
  getMutationDefaults(mutationKey) {
    const defaults = [...__privateGet(this, _mutationDefaults).values()];
    let result = {};
    defaults.forEach((queryDefault) => {
      if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
        result = __spreadValues(__spreadValues({}, result), queryDefault.defaultOptions);
      }
    });
    return result;
  }
  defaultQueryOptions(options) {
    if (options._defaulted) {
      return options;
    }
    const defaultedOptions = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, __privateGet(this, _defaultOptions2).queries), this.getQueryDefaults(options.queryKey)), options), {
      _defaulted: true
    });
    if (!defaultedOptions.queryHash) {
      defaultedOptions.queryHash = hashQueryKeyByOptions(
        defaultedOptions.queryKey,
        defaultedOptions
      );
    }
    if (defaultedOptions.refetchOnReconnect === void 0) {
      defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
    }
    if (defaultedOptions.throwOnError === void 0) {
      defaultedOptions.throwOnError = !!defaultedOptions.suspense;
    }
    if (!defaultedOptions.networkMode && defaultedOptions.persister) {
      defaultedOptions.networkMode = "offlineFirst";
    }
    if (defaultedOptions.queryFn === skipToken) {
      defaultedOptions.enabled = false;
    }
    return defaultedOptions;
  }
  defaultMutationOptions(options) {
    if (options == null ? void 0 : options._defaulted) {
      return options;
    }
    return __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, __privateGet(this, _defaultOptions2).mutations), (options == null ? void 0 : options.mutationKey) && this.getMutationDefaults(options.mutationKey)), options), {
      _defaulted: true
    });
  }
  clear() {
    __privateGet(this, _queryCache).clear();
    __privateGet(this, _mutationCache2).clear();
  }
}, _queryCache = new WeakMap(), _mutationCache2 = new WeakMap(), _defaultOptions2 = new WeakMap(), _queryDefaults = new WeakMap(), _mutationDefaults = new WeakMap(), _mountCount = new WeakMap(), _unsubscribeFocus = new WeakMap(), _unsubscribeOnline = new WeakMap(), _a8);

// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/queryObserver.js
var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _b;
var QueryObserver = (_b = class extends Subscribable {
  constructor(client, options) {
    super();
    __privateAdd(this, _QueryObserver_instances);
    __privateAdd(this, _client);
    __privateAdd(this, _currentQuery);
    __privateAdd(this, _currentQueryInitialState);
    __privateAdd(this, _currentResult);
    __privateAdd(this, _currentResultState);
    __privateAdd(this, _currentResultOptions);
    __privateAdd(this, _currentThenable);
    __privateAdd(this, _selectError);
    __privateAdd(this, _selectFn);
    __privateAdd(this, _selectResult);
    // This property keeps track of the last query with defined data.
    // It will be used to pass the previous data and query to the placeholder function between renders.
    __privateAdd(this, _lastQueryWithDefinedData);
    __privateAdd(this, _staleTimeoutId);
    __privateAdd(this, _refetchIntervalId);
    __privateAdd(this, _currentRefetchInterval);
    __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
    this.options = options;
    __privateSet(this, _client, client);
    __privateSet(this, _selectError, null);
    __privateSet(this, _currentThenable, pendingThenable());
    if (!this.options.experimental_prefetchInRender) {
      __privateGet(this, _currentThenable).reject(
        new Error("experimental_prefetchInRender feature flag is not enabled")
      );
    }
    this.bindMethods();
    this.setOptions(options);
  }
  bindMethods() {
    this.refetch = this.refetch.bind(this);
  }
  onSubscribe() {
    if (this.listeners.size === 1) {
      __privateGet(this, _currentQuery).addObserver(this);
      if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
        __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
      } else {
        this.updateResult();
      }
      __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
    }
  }
  onUnsubscribe() {
    if (!this.hasListeners()) {
      this.destroy();
    }
  }
  shouldFetchOnReconnect() {
    return shouldFetchOn(
      __privateGet(this, _currentQuery),
      this.options,
      this.options.refetchOnReconnect
    );
  }
  shouldFetchOnWindowFocus() {
    return shouldFetchOn(
      __privateGet(this, _currentQuery),
      this.options,
      this.options.refetchOnWindowFocus
    );
  }
  destroy() {
    this.listeners = /* @__PURE__ */ new Set();
    __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
    __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
    __privateGet(this, _currentQuery).removeObserver(this);
  }
  setOptions(options, notifyOptions) {
    const prevOptions = this.options;
    const prevQuery = __privateGet(this, _currentQuery);
    this.options = __privateGet(this, _client).defaultQueryOptions(options);
    if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
      throw new Error(
        "Expected enabled to be a boolean or a callback that returns a boolean"
      );
    }
    __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
    __privateGet(this, _currentQuery).setOptions(this.options);
    if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
      __privateGet(this, _client).getQueryCache().notify({
        type: "observerOptionsUpdated",
        query: __privateGet(this, _currentQuery),
        observer: this
      });
    }
    const mounted = this.hasListeners();
    if (mounted && shouldFetchOptionally(
      __privateGet(this, _currentQuery),
      prevQuery,
      this.options,
      prevOptions
    )) {
      __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
    }
    this.updateResult(notifyOptions);
    if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
      __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
    }
    const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
    if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
      __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
    }
  }
  getOptimisticResult(options) {
    const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
    const result = this.createResult(query, options);
    if (shouldAssignObserverCurrentProperties(this, result)) {
      __privateSet(this, _currentResult, result);
      __privateSet(this, _currentResultOptions, this.options);
      __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
    }
    return result;
  }
  getCurrentResult() {
    return __privateGet(this, _currentResult);
  }
  trackResult(result, onPropTracked) {
    const trackedResult = {};
    Object.keys(result).forEach((key) => {
      Object.defineProperty(trackedResult, key, {
        configurable: false,
        enumerable: true,
        get: () => {
          this.trackProp(key);
          onPropTracked == null ? void 0 : onPropTracked(key);
          return result[key];
        }
      });
    });
    return trackedResult;
  }
  trackProp(key) {
    __privateGet(this, _trackedProps).add(key);
  }
  getCurrentQuery() {
    return __privateGet(this, _currentQuery);
  }
  refetch(_a10 = {}) {
    var options = __objRest(_a10, []);
    return this.fetch(__spreadValues({}, options));
  }
  fetchOptimistic(options) {
    const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
    const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
    return query.fetch().then(() => this.createResult(query, defaultedOptions));
  }
  fetch(fetchOptions) {
    var _a10;
    return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, __spreadProps(__spreadValues({}, fetchOptions), {
      cancelRefetch: (_a10 = fetchOptions.cancelRefetch) != null ? _a10 : true
    })).then(() => {
      this.updateResult();
      return __privateGet(this, _currentResult);
    });
  }
  createResult(query, options) {
    var _a10;
    const prevQuery = __privateGet(this, _currentQuery);
    const prevOptions = this.options;
    const prevResult = __privateGet(this, _currentResult);
    const prevResultState = __privateGet(this, _currentResultState);
    const prevResultOptions = __privateGet(this, _currentResultOptions);
    const queryChange = query !== prevQuery;
    const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
    const { state } = query;
    let newState = __spreadValues({}, state);
    let isPlaceholderData = false;
    let data;
    if (options._optimisticResults) {
      const mounted = this.hasListeners();
      const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
      const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
      if (fetchOnMount || fetchOptionally) {
        newState = __spreadValues(__spreadValues({}, newState), fetchState(state.data, query.options));
      }
      if (options._optimisticResults === "isRestoring") {
        newState.fetchStatus = "idle";
      }
    }
    let { error, errorUpdatedAt, status } = newState;
    if (options.select && newState.data !== void 0) {
      if (prevResult && newState.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === __privateGet(this, _selectFn)) {
        data = __privateGet(this, _selectResult);
      } else {
        try {
          __privateSet(this, _selectFn, options.select);
          data = options.select(newState.data);
          data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
          __privateSet(this, _selectResult, data);
          __privateSet(this, _selectError, null);
        } catch (selectError) {
          __privateSet(this, _selectError, selectError);
        }
      }
    } else {
      data = newState.data;
    }
    if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
      let placeholderData;
      if ((prevResult == null ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
        placeholderData = prevResult.data;
      } else {
        placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
          (_a10 = __privateGet(this, _lastQueryWithDefinedData)) == null ? void 0 : _a10.state.data,
          __privateGet(this, _lastQueryWithDefinedData)
        ) : options.placeholderData;
        if (options.select && placeholderData !== void 0) {
          try {
            placeholderData = options.select(placeholderData);
            __privateSet(this, _selectError, null);
          } catch (selectError) {
            __privateSet(this, _selectError, selectError);
          }
        }
      }
      if (placeholderData !== void 0) {
        status = "success";
        data = replaceData(
          prevResult == null ? void 0 : prevResult.data,
          placeholderData,
          options
        );
        isPlaceholderData = true;
      }
    }
    if (__privateGet(this, _selectError)) {
      error = __privateGet(this, _selectError);
      data = __privateGet(this, _selectResult);
      errorUpdatedAt = Date.now();
      status = "error";
    }
    const isFetching = newState.fetchStatus === "fetching";
    const isPending = status === "pending";
    const isError = status === "error";
    const isLoading = isPending && isFetching;
    const hasData = data !== void 0;
    const result = {
      status,
      fetchStatus: newState.fetchStatus,
      isPending,
      isSuccess: status === "success",
      isError,
      isInitialLoading: isLoading,
      isLoading,
      data,
      dataUpdatedAt: newState.dataUpdatedAt,
      error,
      errorUpdatedAt,
      failureCount: newState.fetchFailureCount,
      failureReason: newState.fetchFailureReason,
      errorUpdateCount: newState.errorUpdateCount,
      isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
      isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
      isFetching,
      isRefetching: isFetching && !isPending,
      isLoadingError: isError && !hasData,
      isPaused: newState.fetchStatus === "paused",
      isPlaceholderData,
      isRefetchError: isError && hasData,
      isStale: isStale(query, options),
      refetch: this.refetch,
      promise: __privateGet(this, _currentThenable)
    };
    const nextResult = result;
    if (this.options.experimental_prefetchInRender) {
      const finalizeThenableIfPossible = (thenable) => {
        if (nextResult.status === "error") {
          thenable.reject(nextResult.error);
        } else if (nextResult.data !== void 0) {
          thenable.resolve(nextResult.data);
        }
      };
      const recreateThenable = () => {
        const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
        finalizeThenableIfPossible(pending);
      };
      const prevThenable = __privateGet(this, _currentThenable);
      switch (prevThenable.status) {
        case "pending":
          if (query.queryHash === prevQuery.queryHash) {
            finalizeThenableIfPossible(prevThenable);
          }
          break;
        case "fulfilled":
          if (nextResult.status === "error" || nextResult.data !== prevThenable.value) {
            recreateThenable();
          }
          break;
        case "rejected":
          if (nextResult.status !== "error" || nextResult.error !== prevThenable.reason) {
            recreateThenable();
          }
          break;
      }
    }
    return nextResult;
  }
  updateResult(notifyOptions) {
    const prevResult = __privateGet(this, _currentResult);
    const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
    __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
    __privateSet(this, _currentResultOptions, this.options);
    if (__privateGet(this, _currentResultState).data !== void 0) {
      __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
    }
    if (shallowEqualObjects(nextResult, prevResult)) {
      return;
    }
    __privateSet(this, _currentResult, nextResult);
    const defaultNotifyOptions = {};
    const shouldNotifyListeners = () => {
      if (!prevResult) {
        return true;
      }
      const { notifyOnChangeProps } = this.options;
      const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
      if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
        return true;
      }
      const includedProps = new Set(
        notifyOnChangePropsValue != null ? notifyOnChangePropsValue : __privateGet(this, _trackedProps)
      );
      if (this.options.throwOnError) {
        includedProps.add("error");
      }
      return Object.keys(__privateGet(this, _currentResult)).some((key) => {
        const typedKey = key;
        const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
        return changed && includedProps.has(typedKey);
      });
    };
    if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
      defaultNotifyOptions.listeners = true;
    }
    __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, __spreadValues(__spreadValues({}, defaultNotifyOptions), notifyOptions));
  }
  onQueryUpdate() {
    this.updateResult();
    if (this.hasListeners()) {
      __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
    }
  }
}, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
  __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
  let promise = __privateGet(this, _currentQuery).fetch(
    this.options,
    fetchOptions
  );
  if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
    promise = promise.catch(noop);
  }
  return promise;
}, updateStaleTimeout_fn = function() {
  __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
  const staleTime = resolveStaleTime(
    this.options.staleTime,
    __privateGet(this, _currentQuery)
  );
  if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
    return;
  }
  const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
  const timeout = time + 1;
  __privateSet(this, _staleTimeoutId, setTimeout(() => {
    if (!__privateGet(this, _currentResult).isStale) {
      this.updateResult();
    }
  }, timeout));
}, computeRefetchInterval_fn = function() {
  var _a10;
  return (_a10 = typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) != null ? _a10 : false;
}, updateRefetchInterval_fn = function(nextInterval) {
  __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
  __privateSet(this, _currentRefetchInterval, nextInterval);
  if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
    return;
  }
  __privateSet(this, _refetchIntervalId, setInterval(() => {
    if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
      __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
    }
  }, __privateGet(this, _currentRefetchInterval)));
}, updateTimers_fn = function() {
  __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
  __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
}, clearStaleTimeout_fn = function() {
  if (__privateGet(this, _staleTimeoutId)) {
    clearTimeout(__privateGet(this, _staleTimeoutId));
    __privateSet(this, _staleTimeoutId, void 0);
  }
}, clearRefetchInterval_fn = function() {
  if (__privateGet(this, _refetchIntervalId)) {
    clearInterval(__privateGet(this, _refetchIntervalId));
    __privateSet(this, _refetchIntervalId, void 0);
  }
}, updateQuery_fn = function() {
  const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
  if (query === __privateGet(this, _currentQuery)) {
    return;
  }
  const prevQuery = __privateGet(this, _currentQuery);
  __privateSet(this, _currentQuery, query);
  __privateSet(this, _currentQueryInitialState, query.state);
  if (this.hasListeners()) {
    prevQuery == null ? void 0 : prevQuery.removeObserver(this);
    query.addObserver(this);
  }
}, notify_fn = function(notifyOptions) {
  notifyManager.batch(() => {
    if (notifyOptions.listeners) {
      this.listeners.forEach((listener) => {
        listener(__privateGet(this, _currentResult));
      });
    }
    __privateGet(this, _client).getQueryCache().notify({
      query: __privateGet(this, _currentQuery),
      type: "observerResultsUpdated"
    });
  });
}, _b);
function shouldLoadOnMount(query, options) {
  return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
}
function shouldFetchOnMount(query, options) {
  return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
}
function shouldFetchOn(query, options, field) {
  if (resolveEnabled(options.enabled, query) !== false) {
    const value = typeof field === "function" ? field(query) : field;
    return value === "always" || value !== false && isStale(query, options);
  }
  return false;
}
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
  return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
}
function isStale(query, options) {
  return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
}
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
  if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
    return true;
  }
  return false;
}

// ../../node_modules/.pnpm/@tanstack+query-core@5.62.7/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
var _client2, _currentResult2, _currentMutation, _mutateOptions, _MutationObserver_instances, updateResult_fn, notify_fn2, _a9;
var MutationObserver = (_a9 = class extends Subscribable {
  constructor(client, options) {
    super();
    __privateAdd(this, _MutationObserver_instances);
    __privateAdd(this, _client2);
    __privateAdd(this, _currentResult2);
    __privateAdd(this, _currentMutation);
    __privateAdd(this, _mutateOptions);
    __privateSet(this, _client2, client);
    this.setOptions(options);
    this.bindMethods();
    __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
  }
  bindMethods() {
    this.mutate = this.mutate.bind(this);
    this.reset = this.reset.bind(this);
  }
  setOptions(options) {
    var _a10;
    const prevOptions = this.options;
    this.options = __privateGet(this, _client2).defaultMutationOptions(options);
    if (!shallowEqualObjects(this.options, prevOptions)) {
      __privateGet(this, _client2).getMutationCache().notify({
        type: "observerOptionsUpdated",
        mutation: __privateGet(this, _currentMutation),
        observer: this
      });
    }
    if ((prevOptions == null ? void 0 : prevOptions.mutationKey) && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
      this.reset();
    } else if (((_a10 = __privateGet(this, _currentMutation)) == null ? void 0 : _a10.state.status) === "pending") {
      __privateGet(this, _currentMutation).setOptions(this.options);
    }
  }
  onUnsubscribe() {
    var _a10;
    if (!this.hasListeners()) {
      (_a10 = __privateGet(this, _currentMutation)) == null ? void 0 : _a10.removeObserver(this);
    }
  }
  onMutationUpdate(action) {
    __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
    __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this, action);
  }
  getCurrentResult() {
    return __privateGet(this, _currentResult2);
  }
  reset() {
    var _a10;
    (_a10 = __privateGet(this, _currentMutation)) == null ? void 0 : _a10.removeObserver(this);
    __privateSet(this, _currentMutation, void 0);
    __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
    __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this);
  }
  mutate(variables, options) {
    var _a10;
    __privateSet(this, _mutateOptions, options);
    (_a10 = __privateGet(this, _currentMutation)) == null ? void 0 : _a10.removeObserver(this);
    __privateSet(this, _currentMutation, __privateGet(this, _client2).getMutationCache().build(__privateGet(this, _client2), this.options));
    __privateGet(this, _currentMutation).addObserver(this);
    return __privateGet(this, _currentMutation).execute(variables);
  }
}, _client2 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() {
  var _a10, _b2;
  const state = (_b2 = (_a10 = __privateGet(this, _currentMutation)) == null ? void 0 : _a10.state) != null ? _b2 : getDefaultState2();
  __privateSet(this, _currentResult2, __spreadProps(__spreadValues({}, state), {
    isPending: state.status === "pending",
    isSuccess: state.status === "success",
    isError: state.status === "error",
    isIdle: state.status === "idle",
    mutate: this.mutate,
    reset: this.reset
  }));
}, notify_fn2 = function(action) {
  notifyManager.batch(() => {
    var _a10, _b2, _c, _d, _e, _f, _g, _h;
    if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
      const variables = __privateGet(this, _currentResult2).variables;
      const context = __privateGet(this, _currentResult2).context;
      if ((action == null ? void 0 : action.type) === "success") {
        (_b2 = (_a10 = __privateGet(this, _mutateOptions)).onSuccess) == null ? void 0 : _b2.call(_a10, action.data, variables, context);
        (_d = (_c = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _d.call(_c, action.data, null, variables, context);
      } else if ((action == null ? void 0 : action.type) === "error") {
        (_f = (_e = __privateGet(this, _mutateOptions)).onError) == null ? void 0 : _f.call(_e, action.error, variables, context);
        (_h = (_g = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _h.call(
          _g,
          void 0,
          action.error,
          variables,
          context
        );
      }
    }
    this.listeners.forEach((listener) => {
      listener(__privateGet(this, _currentResult2));
    });
  });
}, _a9);

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
var React = __toESM(require("react"), 1);
var import_jsx_runtime = require("react/jsx-runtime");
var QueryClientContext = React.createContext(
  void 0
);
var useQueryClient = (queryClient2) => {
  const client = React.useContext(QueryClientContext);
  if (queryClient2) {
    return queryClient2;
  }
  if (!client) {
    throw new Error("No QueryClient set, use QueryClientProvider to set one");
  }
  return client;
};
var QueryClientProvider = ({
  client,
  children
}) => {
  React.useEffect(() => {
    client.mount();
    return () => {
      client.unmount();
    };
  }, [client]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientContext.Provider, { value: client, children });
};

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/isRestoring.js
var React2 = __toESM(require("react"), 1);
var IsRestoringContext = React2.createContext(false);
var useIsRestoring = () => React2.useContext(IsRestoringContext);
var IsRestoringProvider = IsRestoringContext.Provider;

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
var React3 = __toESM(require("react"), 1);
var import_jsx_runtime2 = require("react/jsx-runtime");
function createValue() {
  let isReset = false;
  return {
    clearReset: () => {
      isReset = false;
    },
    reset: () => {
      isReset = true;
    },
    isReset: () => {
      return isReset;
    }
  };
}
var QueryErrorResetBoundaryContext = React3.createContext(createValue());
var useQueryErrorResetBoundary = () => React3.useContext(QueryErrorResetBoundaryContext);

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
var React4 = __toESM(require("react"), 1);

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/utils.js
function shouldThrowError(throwError, params) {
  if (typeof throwError === "function") {
    return throwError(...params);
  }
  return !!throwError;
}
function noop2() {
}

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
  if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
    if (!errorResetBoundary.isReset()) {
      options.retryOnMount = false;
    }
  }
};
var useClearResetErrorBoundary = (errorResetBoundary) => {
  React4.useEffect(() => {
    errorResetBoundary.clearReset();
  }, [errorResetBoundary]);
};
var getHasError = ({
  result,
  errorResetBoundary,
  throwOnError,
  query
}) => {
  return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
};

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/suspense.js
var ensureSuspenseTimers = (defaultedOptions) => {
  if (defaultedOptions.suspense) {
    if (defaultedOptions.staleTime === void 0) {
      defaultedOptions.staleTime = 1e3;
    }
    if (typeof defaultedOptions.gcTime === "number") {
      defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3);
    }
  }
};
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
var shouldSuspend = (defaultedOptions, result) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && result.isPending;
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
  errorResetBoundary.clearReset();
});

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
var React5 = __toESM(require("react"), 1);
function useBaseQuery(options, Observer, queryClient2) {
  var _a10, _b2, _c, _d, _e;
  if (process.env.NODE_ENV !== "production") {
    if (typeof options !== "object" || Array.isArray(options)) {
      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 client = useQueryClient(queryClient2);
  const isRestoring = useIsRestoring();
  const errorResetBoundary = useQueryErrorResetBoundary();
  const defaultedOptions = client.defaultQueryOptions(options);
  (_b2 = (_a10 = client.getDefaultOptions().queries) == null ? void 0 : _a10._experimental_beforeQuery) == null ? void 0 : _b2.call(
    _a10,
    defaultedOptions
  );
  defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
  ensureSuspenseTimers(defaultedOptions);
  ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
  useClearResetErrorBoundary(errorResetBoundary);
  const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
  const [observer] = React5.useState(
    () => new Observer(
      client,
      defaultedOptions
    )
  );
  const result = observer.getOptimisticResult(defaultedOptions);
  React5.useSyncExternalStore(
    React5.useCallback(
      (onStoreChange) => {
        const unsubscribe = isRestoring ? noop2 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
        observer.updateResult();
        return unsubscribe;
      },
      [observer, isRestoring]
    ),
    () => observer.getCurrentResult(),
    () => observer.getCurrentResult()
  );
  React5.useEffect(() => {
    observer.setOptions(defaultedOptions, { listeners: false });
  }, [defaultedOptions, observer]);
  if (shouldSuspend(defaultedOptions, result)) {
    throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
  }
  if (getHasError({
    result,
    errorResetBoundary,
    throwOnError: defaultedOptions.throwOnError,
    query: client.getQueryCache().get(defaultedOptions.queryHash)
  })) {
    throw result.error;
  }
  ;
  (_d = (_c = client.getDefaultOptions().queries) == null ? void 0 : _c._experimental_afterQuery) == null ? void 0 : _d.call(
    _c,
    defaultedOptions,
    result
  );
  if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
    const promise = isNewCacheEntry ? (
      // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
      fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
    ) : (
      // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
      (_e = client.getQueryCache().get(defaultedOptions.queryHash)) == null ? void 0 : _e.promise
    );
    promise == null ? void 0 : promise.catch(noop2).finally(() => {
      observer.updateResult();
    });
  }
  return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
}

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/useQuery.js
function useQuery(options, queryClient2) {
  return useBaseQuery(options, QueryObserver, queryClient2);
}

// ../../node_modules/.pnpm/@tanstack+react-query@5.62.7_react@18.3.1/node_modules/@tanstack/react-query/build/modern/useMutation.js
var React6 = __toESM(require("react"), 1);
function useMutation(options, queryClient2) {
  const client = useQueryClient(queryClient2);
  const [observer] = React6.useState(
    () => new MutationObserver(
      client,
      options
    )
  );
  React6.useEffect(() => {
    observer.setOptions(options);
  }, [observer, options]);
  const result = React6.useSyncExternalStore(
    React6.useCallback(
      (onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
      [observer]
    ),
    () => observer.getCurrentResult(),
    () => observer.getCurrentResult()
  );
  const mutate = React6.useCallback(
    (variables, mutateOptions) => {
      observer.mutate(variables, mutateOptions).catch(noop2);
    },
    [observer]
  );
  if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
    throw result.error;
  }
  return __spreadProps(__spreadValues({}, result), { mutate, mutateAsync: result.mutate });
}

// src/api/queries.ts
var campaignsPublicControllerPublicDetails = (slug, options, signal) => {
  return customInstance(
    {
      url: `/public/campaigns/${slug}`,
      method: "GET",
      signal
    },
    options
  );
};
var getCampaignsPublicControllerPublicDetailsQueryKey = (slug) => {
  return [`/public/campaigns/${slug}`];
};
var getCampaignsPublicControllerPublicDetailsQueryOptions = (slug, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getCampaignsPublicControllerPublicDetailsQueryKey(slug);
  const queryFn = ({ signal }) => campaignsPublicControllerPublicDetails(slug, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!slug }, queryOptions);
};
function useCampaignsPublicControllerPublicDetails(slug, options) {
  const queryOptions = getCampaignsPublicControllerPublicDetailsQueryOptions(slug, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var campaignsPublicControllerPublicStats = (slug, options, signal) => {
  return customInstance(
    {
      url: `/public/campaigns/${slug}/stats`,
      method: "GET",
      signal
    },
    options
  );
};
var getCampaignsPublicControllerPublicStatsQueryKey = (slug) => {
  return [`/public/campaigns/${slug}/stats`];
};
var getCampaignsPublicControllerPublicStatsQueryOptions = (slug, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getCampaignsPublicControllerPublicStatsQueryKey(slug);
  const queryFn = ({ signal }) => campaignsPublicControllerPublicStats(slug, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!slug }, queryOptions);
};
function useCampaignsPublicControllerPublicStats(slug, options) {
  const queryOptions = getCampaignsPublicControllerPublicStatsQueryOptions(slug, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var campaignsPublicControllerLeaderboard = (slug, options, signal) => {
  return customInstance(
    {
      url: `/public/campaigns/${slug}/leaderboard`,
      method: "GET",
      signal
    },
    options
  );
};
var getCampaignsPublicControllerLeaderboardQueryKey = (slug) => {
  return [`/public/campaigns/${slug}/leaderboard`];
};
var getCampaignsPublicControllerLeaderboardQueryOptions = (slug, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getCampaignsPublicControllerLeaderboardQueryKey(slug);
  const queryFn = ({ signal }) => campaignsPublicControllerLeaderboard(slug, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!slug }, queryOptions);
};
function useCampaignsPublicControllerLeaderboard(slug, options) {
  const queryOptions = getCampaignsPublicControllerLeaderboardQueryOptions(slug, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var authControllerSendMagicLink = (leadRequestLoginDto, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/magic-link-request`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: leadRequestLoginDto,
      signal
    },
    options
  );
};
var getAuthControllerSendMagicLinkMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { data } = props != null ? props : {};
    return authControllerSendMagicLink(data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useAuthControllerSendMagicLink = (options) => {
  const mutationOptions = getAuthControllerSendMagicLinkMutationOptions(options);
  return useMutation(mutationOptions);
};
var authControllerVerifyToken = (params, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/verify-token`,
      method: "POST",
      params,
      signal
    },
    options
  );
};
var getAuthControllerVerifyTokenMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { params } = props != null ? props : {};
    return authControllerVerifyToken(params, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useAuthControllerVerifyToken = (options) => {
  const mutationOptions = getAuthControllerVerifyTokenMutationOptions(options);
  return useMutation(mutationOptions);
};
var authControllerVerifyCode = (verifyCodeDto, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/verify-code`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: verifyCodeDto,
      signal
    },
    options
  );
};
var getAuthControllerVerifyCodeMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { data } = props != null ? props : {};
    return authControllerVerifyCode(data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useAuthControllerVerifyCode = (options) => {
  const mutationOptions = getAuthControllerVerifyCodeMutationOptions(options);
  return useMutation(mutationOptions);
};
var authControllerGetMessage = (options, signal) => {
  return customInstance(
    {
      url: `/public/auth/web3-message`,
      method: "GET",
      signal
    },
    options
  );
};
var getAuthControllerGetMessageQueryKey = () => {
  return [`/public/auth/web3-message`];
};
var getAuthControllerGetMessageQueryOptions = (options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getAuthControllerGetMessageQueryKey();
  const queryFn = ({ signal }) => authControllerGetMessage(requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function useAuthControllerGetMessage(options) {
  const queryOptions = getAuthControllerGetMessageQueryOptions(options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var authControllerWeb3Login = (web3LoginDto, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/web3-login`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: web3LoginDto,
      signal
    },
    options
  );
};
var getAuthControllerWeb3LoginMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { data } = props != null ? props : {};
    return authControllerWeb3Login(data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useAuthControllerWeb3Login = (options) => {
  const mutationOptions = getAuthControllerWeb3LoginMutationOptions(options);
  return useMutation(mutationOptions);
};
var authControllerGetTwitterUrl = (params, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/twitter/get-url`,
      method: "GET",
      params,
      signal
    },
    options
  );
};
var getAuthControllerGetTwitterUrlQueryKey = (params) => {
  return [`/public/auth/twitter/get-url`, ...params ? [params] : []];
};
var getAuthControllerGetTwitterUrlQueryOptions = (params, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getAuthControllerGetTwitterUrlQueryKey(params);
  const queryFn = ({ signal }) => authControllerGetTwitterUrl(params, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function useAuthControllerGetTwitterUrl(params, options) {
  const queryOptions = getAuthControllerGetTwitterUrlQueryOptions(params, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var authControllerCallbackTwitter = (options, signal) => {
  return customInstance(
    {
      url: `/public/auth/twitter/callback`,
      method: "GET",
      signal
    },
    options
  );
};
var getAuthControllerCallbackTwitterQueryKey = () => {
  return [`/public/auth/twitter/callback`];
};
var getAuthControllerCallbackTwitterQueryOptions = (options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getAuthControllerCallbackTwitterQueryKey();
  const queryFn = ({ signal }) => authControllerCallbackTwitter(requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function useAuthControllerCallbackTwitter(options) {
  const queryOptions = getAuthControllerCallbackTwitterQueryOptions(options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var authControllerHandleTelegramAuth = (params, options, signal) => {
  return customInstance(
    {
      url: `/public/auth/telegram/callback`,
      method: "GET",
      params,
      signal
    },
    options
  );
};
var getAuthControllerHandleTelegramAuthQueryKey = (params) => {
  return [`/public/auth/telegram/callback`, ...params ? [params] : []];
};
var getAuthControllerHandleTelegramAuthQueryOptions = (params, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getAuthControllerHandleTelegramAuthQueryKey(params);
  const queryFn = ({ signal }) => authControllerHandleTelegramAuth(params, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function useAuthControllerHandleTelegramAuth(params, options) {
  const queryOptions = getAuthControllerHandleTelegramAuthQueryOptions(params, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var leadPublicControllerGetMe = (slug, options, signal) => {
  return customInstance(
    {
      url: `/public/me/${slug}`,
      method: "GET",
      signal
    },
    options
  );
};
var getLeadPublicControllerGetMeQueryKey = (slug) => {
  return [`/public/me/${slug}`];
};
var getLeadPublicControllerGetMeQueryOptions = (slug, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getLeadPublicControllerGetMeQueryKey(slug);
  const queryFn = ({ signal }) => leadPublicControllerGetMe(slug, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!slug }, queryOptions);
};
function useLeadPublicControllerGetMe(slug, options) {
  const queryOptions = getLeadPublicControllerGetMeQueryOptions(slug, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var leadPublicControllerSignin = (slug, createLeadEntryDto, options, signal) => {
  return customInstance(
    {
      url: `/public/me/signin/${slug}`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: createLeadEntryDto,
      signal
    },
    options
  );
};
var getLeadPublicControllerSigninMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { slug, data } = props != null ? props : {};
    return leadPublicControllerSignin(slug, data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useLeadPublicControllerSignin = (options) => {
  const mutationOptions = getLeadPublicControllerSigninMutationOptions(options);
  return useMutation(mutationOptions);
};
var leadPublicControllerGetLeadEntryForCampaign = (campaignSlug, options, signal) => {
  return customInstance(
    {
      url: `/public/me/entry/${campaignSlug}`,
      method: "GET",
      signal
    },
    options
  );
};
var getLeadPublicControllerGetLeadEntryForCampaignQueryKey = (campaignSlug) => {
  return [`/public/me/entry/${campaignSlug}`];
};
var getLeadPublicControllerGetLeadEntryForCampaignQueryOptions = (campaignSlug, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getLeadPublicControllerGetLeadEntryForCampaignQueryKey(campaignSlug);
  const queryFn = ({ signal }) => leadPublicControllerGetLeadEntryForCampaign(campaignSlug, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!campaignSlug }, queryOptions);
};
function useLeadPublicControllerGetLeadEntryForCampaign(campaignSlug, options) {
  const queryOptions = getLeadPublicControllerGetLeadEntryForCampaignQueryOptions(campaignSlug, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var questsPublicControllerValidate = (id, validateQuestDto, options, signal) => {
  return customInstance(
    {
      url: `/public/quests/${id}/validate`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: validateQuestDto,
      signal
    },
    options
  );
};
var getQuestsPublicControllerValidateMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { id, data } = props != null ? props : {};
    return questsPublicControllerValidate(id, data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useQuestsPublicControllerValidate = (options) => {
  const mutationOptions = getQuestsPublicControllerValidateMutationOptions(options);
  return useMutation(mutationOptions);
};
var questsPublicControllerUpload = (id, questsPublicControllerUploadBody, options, signal) => {
  return customInstance(
    {
      url: `/public/quests/${id}/upload`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: questsPublicControllerUploadBody,
      signal
    },
    options
  );
};
var getQuestsPublicControllerUploadMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { id, data } = props != null ? props : {};
    return questsPublicControllerUpload(id, data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useQuestsPublicControllerUpload = (options) => {
  const mutationOptions = getQuestsPublicControllerUploadMutationOptions(options);
  return useMutation(mutationOptions);
};
var questsPublicControllerGetProgress = (id, options, signal) => {
  return customInstance(
    {
      url: `/public/quests/${id}/progress`,
      method: "GET",
      signal
    },
    options
  );
};
var getQuestsPublicControllerGetProgressQueryKey = (id) => {
  return [`/public/quests/${id}/progress`];
};
var getQuestsPublicControllerGetProgressQueryOptions = (id, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getQuestsPublicControllerGetProgressQueryKey(id);
  const queryFn = ({ signal }) => questsPublicControllerGetProgress(id, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!id }, queryOptions);
};
function useQuestsPublicControllerGetProgress(id, options) {
  const queryOptions = getQuestsPublicControllerGetProgressQueryOptions(id, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var contentBattlePublicControllerGetCurrentRound = (contentBattleId, options, signal) => {
  return customInstance(
    {
      url: `/public/content-battle/${contentBattleId}/current-round`,
      method: "GET",
      signal
    },
    options
  );
};
var getContentBattlePublicControllerGetCurrentRoundQueryKey = (contentBattleId) => {
  return [`/public/content-battle/${contentBattleId}/current-round`];
};
var getContentBattlePublicControllerGetCurrentRoundQueryOptions = (contentBattleId, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getContentBattlePublicControllerGetCurrentRoundQueryKey(contentBattleId);
  const queryFn = ({ signal }) => contentBattlePublicControllerGetCurrentRound(contentBattleId, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!contentBattleId }, queryOptions);
};
function useContentBattlePublicControllerGetCurrentRound(contentBattleId, options) {
  const queryOptions = getContentBattlePublicControllerGetCurrentRoundQueryOptions(contentBattleId, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var contentBattlePublicControllerSubmitVote = (roundId, contentBattleVoteDto, options, signal) => {
  return customInstance(
    {
      url: `/public/content-battle/${roundId}/vote`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: contentBattleVoteDto,
      signal
    },
    options
  );
};
var getContentBattlePublicControllerSubmitVoteMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { roundId, data } = props != null ? props : {};
    return contentBattlePublicControllerSubmitVote(roundId, data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useContentBattlePublicControllerSubmitVote = (options) => {
  const mutationOptions = getContentBattlePublicControllerSubmitVoteMutationOptions(options);
  return useMutation(mutationOptions);
};
var contentBattlePublicControllerGetEntry = (battleId, options, signal) => {
  return customInstance(
    {
      url: `/public/content-battle/${battleId}/entry`,
      method: "GET",
      signal
    },
    options
  );
};
var getContentBattlePublicControllerGetEntryQueryKey = (battleId) => {
  return [`/public/content-battle/${battleId}/entry`];
};
var getContentBattlePublicControllerGetEntryQueryOptions = (battleId, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getContentBattlePublicControllerGetEntryQueryKey(battleId);
  const queryFn = ({ signal }) => contentBattlePublicControllerGetEntry(battleId, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn, enabled: !!battleId }, queryOptions);
};
function useContentBattlePublicControllerGetEntry(battleId, options) {
  const queryOptions = getContentBattlePublicControllerGetEntryQueryOptions(battleId, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var contentBattlePublicControllerSubmitEntry = (battleId, contentBattlePublicControllerSubmitEntryBody, options, signal) => {
  return customInstance(
    {
      url: `/public/content-battle/${battleId}/entry`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: contentBattlePublicControllerSubmitEntryBody,
      signal
    },
    options
  );
};
var getContentBattlePublicControllerSubmitEntryMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { battleId, data } = props != null ? props : {};
    return contentBattlePublicControllerSubmitEntry(battleId, data, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var useContentBattlePublicControllerSubmitEntry = (options) => {
  const mutationOptions = getContentBattlePublicControllerSubmitEntryMutationOptions(options);
  return useMutation(mutationOptions);
};
var pushNotificationsControllerGetVapidPublicKey = (options, signal) => {
  return customInstance(
    {
      url: `/public/push-notifications/vapid-public-key`,
      method: "GET",
      signal
    },
    options
  );
};
var getPushNotificationsControllerGetVapidPublicKeyQueryKey = () => {
  return [`/public/push-notifications/vapid-public-key`];
};
var getPushNotificationsControllerGetVapidPublicKeyQueryOptions = (options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getPushNotificationsControllerGetVapidPublicKeyQueryKey();
  const queryFn = ({ signal }) => pushNotificationsControllerGetVapidPublicKey(requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function usePushNotificationsControllerGetVapidPublicKey(options) {
  const queryOptions = getPushNotificationsControllerGetVapidPublicKeyQueryOptions(options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var pushNotificationsControllerGetSubscriptionStatus = (params, options, signal) => {
  return customInstance(
    {
      url: `/public/push-notifications/status`,
      method: "GET",
      params,
      signal
    },
    options
  );
};
var getPushNotificationsControllerGetSubscriptionStatusQueryKey = (params) => {
  return [`/public/push-notifications/status`, ...params ? [params] : []];
};
var getPushNotificationsControllerGetSubscriptionStatusQueryOptions = (params, options) => {
  var _a10;
  const { query: queryOptions, request: requestOptions } = options != null ? options : {};
  const queryKey = (_a10 = queryOptions == null ? void 0 : queryOptions.queryKey) != null ? _a10 : getPushNotificationsControllerGetSubscriptionStatusQueryKey(params);
  const queryFn = ({ signal }) => pushNotificationsControllerGetSubscriptionStatus(params, requestOptions, signal);
  return __spreadValues({ queryKey, queryFn }, queryOptions);
};
function usePushNotificationsControllerGetSubscriptionStatus(params, options) {
  const queryOptions = getPushNotificationsControllerGetSubscriptionStatusQueryOptions(params, options);
  const query = useQuery(queryOptions);
  query.queryKey = queryOptions.queryKey;
  return query;
}
var pushNotificationsControllerSubscribe = (subscriptionDto, params, options, signal) => {
  return customInstance(
    {
      url: `/public/push-notifications/subscribe`,
      method: "POST",
      headers: { "Content-Type": "application/json" },
      data: subscriptionDto,
      params,
      signal
    },
    options
  );
};
var getPushNotificationsControllerSubscribeMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { data, params } = props != null ? props : {};
    return pushNotificationsControllerSubscribe(data, params, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var usePushNotificationsControllerSubscribe = (options) => {
  const mutationOptions = getPushNotificationsControllerSubscribeMutationOptions(options);
  return useMutation(mutationOptions);
};
var pushNotificationsControllerUnsubscribe = (params, options) => {
  return customInstance(
    {
      url: `/public/push-notifications/unsubscribe`,
      method: "DELETE",
      params
    },
    options
  );
};
var getPushNotificationsControllerUnsubscribeMutationOptions = (options) => {
  const { mutation: mutationOptions, request: requestOptions } = options != null ? options : {};
  const mutationFn = (props) => {
    const { params } = props != null ? props : {};
    return pushNotificationsControllerUnsubscribe(params, requestOptions);
  };
  return __spreadValues({ mutationFn }, mutationOptions);
};
var usePushNotificationsControllerUnsubscribe = (options) => {
  const mutationOptions = getPushNotificationsControllerUnsubscribeMutationOptions(options);
  return useMutation(mutationOptions);
};

// src/ElevoraProvider.tsx
var ElevoraContext = (0, import_react2.createContext)(void 0);
var queryClient = new QueryClient();
function ElevoraProviderInternal({ campaignSlug, children, initialCampaignData }) {
  const { setToken, logout: _logout } = useSetElevoraToken();
  const { data: user, refetch: refetchUser, isLoading: isLoadingUser } = useLeadPublicControllerGetMe(campaignSlug);
  const { data: campaign } = useCampaignsPublicControllerPublicDetails(campaignSlug, {
    query: {
      initialData: initialCampaignData
    }
  });
  const {
    data: userEntry,
    refetch: refetchEntry,
    isLoading: isLoadingEntry
  } = useLeadPublicControllerGetLeadEntryForCampaign(campaignSlug, {
    query: {
      enabled: !!(user == null ? void 0 : user.user)
    }
  });
  const isConnected = (user == null ? void 0 : user.user) !== null;
  const haveEntry = !!(userEntry == null ? void 0 : userEntry.entry);
  const signin = (0, import_react2.useCallback)(
    (data) => __async(this, null, function* () {
      yield leadPublicControllerSignin(campaignSlug, data != null ? data : {});
      refetchEntry();
    }),
    [campaignSlug, refetchEntry]
  );
  const logout = (0, import_react2.useCallback)(() => {
    _logout();
    refetchEntry();
    refetchUser();
  }, [_logout, refetchEntry, refetchUser]);
  const style = (0, import_react2.useMemo)(() => {
    var _a10, _b2;
    return __spreadProps(__spreadValues({}, campaign == null ? void 0 : campaign.publicSettings), {
      primaryColor: (_b2 = (_a10 = campaign == null ? void 0 : campaign.publicSettings) == null ? void 0 : _a10.primaryColor) != null ? _b2 : "rgb(249, 115, 22)"
    });
  }, [campaign == null ? void 0 : campaign.publicSettings]);
  return /* @__PURE__ */ import_react2.default.createElement(
    ElevoraContext.Provider,
    {
      value: {
        campaignSlug,
        campaign,
        userEntry,
        setToken,
        isConnected,
        haveEntry,
        signin,
        refetch: refetchEntry,
        logout,
        style,
        user,
        refetchUser,
        isLoadingUser,
        isLoadingEntry
      }
    },
    children
  );
}
function ElevoraProvider({ campaignSlug, children, initialCampaignData }) {
  return /* @__PURE__ */ import_react2.default.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ import_react2.default.createElement(
    ElevoraProviderInternal,
    {
      campaignSlug,
      children,
      initialCampaignData
    }
  ));
}
function useElevora() {
  const context = (0, import_react2.useContext)(ElevoraContext);
  if (context === void 0) {
    throw new Error("useElevora must be used within an ElevoraProvider");
  }
  return context;
}

// src/useDailyReward.ts
var import_react3 = require("react");
function useDailyReward(quest) {
  var _a10, _b2;
  const { userEntry } = useElevora();
  const [timeUntilNextClaim, setTimeUntilNextClaim] = (0, import_react3.useState)("");
  const [canClaim, setCanClaim] = (0, import_react3.useState)(true);
  const currentStreak = ((_a10 = userEntry == null ? void 0 : userEntry.entry) == null ? void 0 : _a10.dailyRewardStreak) || 0;
  const lastClaimDate = ((_b2 = userEntry == null ? void 0 : userEntry.entry) == null ? void 0 : _b2.lastDailyRewardClaim) ? new Date(userEntry.entry.lastDailyRewardClaim) : null;
  const calculateDailyReward = (day) => {
    if (!quest) return 0;
    const settings = quest.settings.daily_reward;
    if (!settings) return quest.points;
    const multiplier = Math.min(1 + day * settings.multiplierStep, settings.maxMultiplier);
    return Math.floor(settings.basePoints * multiplier);
  };
  const calculateTimeUntilNextClaim = (0, import_react3.useCallback)(() => {
    if (!lastClaimDate) {
      setCanClaim(true);
      setTimeUntilNextClaim("");
      return;
    }
    const now = /* @__PURE__ */ new Date();
    const nextClaimDate = new Date(lastClaimDate);
    nextClaimDate.setHours(lastClaimDate.getHours() + 24);
    const nextExpirationDate = new Date(lastClaimDate);
    nextExpirationDate.setHours(lastClaimDate.getHours() + 48);
    const diffToNextClaim = nextClaimDate.getTime() - now.getTime();
    const diffToExpiration = nextExpirationDate.getTime() - now.getTime();
    if (diffToExpiration <= 0) {
      setCanClaim(true);
      setTimeUntilNextClaim("");
      return;
    }
    if (diffToNextClaim <= 0) {
      setCanClaim(true);
      setTimeUntilNextClaim(
        `${Math.floor(diffToExpiration / (1e3 * 60 * 60))}h ${Math.floor(diffToExpiration % (1e3 * 60 * 60) / (1e3 * 60))}m until streak expires`
      );
      return;
    }
    setCanClaim(false);
    setTimeUntilNextClaim(
      `${Math.floor(diffToNextClaim / (1e3 * 60 * 60))}h ${Math.floor(diffToNextClaim % (1e3 * 60 * 60) / (1e3 * 60))}m until next claim`
    );
  }, [lastClaimDate]);
  (0, import_react3.useEffect)(() => {
    calculateTimeUntilNextClaim();
    const interval = setInterval(calculateTimeUntilNextClaim, 6e4);
    return () => clearInterval(interval);
  }, [calculateTimeUntilNextClaim]);
  const isOverdue = (0, import_react3.useCallback)(() => {
    if (!lastClaimDate) return false;
    const now = /* @__PURE__ */ new Date();
    const nextExpirationDate = new Date(lastClaimDate);
    nextExpirationDate.setHours(lastClaimDate.getHours() + 48);
    return now.getTime() > nextExpirationDate.getTime();
  }, [lastClaimDate]);
  let currentStreakNotIncremented = isOverdue() ? 0 : canClaim ? currentStreak : currentStreak - 1;
  if (currentStreakNotIncremented < 0) {
    currentStreakNotIncremented = 0;
  }
  return {
    currentStreak,
    timeUntilNextClaim,
    canClaim,
    calculateDailyReward,
    currentStreakNotIncremented
  };
}

// src/useMissions.ts
var import_react4 = require("react");
function useMissions({ onSuccess, onError, vibrate } = {}) {
  const { campaign, refetch } = useElevora();
  const validateQuest = (0, import_react4.useCallback)(
    (questId, data) => __async(this, null, function* () {
      var _a10, _b2;
      try {
        const response = yield questsPublicControllerValidate(questId, data || {});
        if (response.success) {
          onSuccess == null ? void 0 : onSuccess();
          if (vibrate) {
            try {
              navigator.vibrate([50, 100, 50]);
            } catch (e) {
              console.log("Can't vibrate", e);
            }
          }
          return { success: true };
        } else {
          onError == null ? void 0 : onError({ message: response.message });
          return { success: false, message: response.message };
        }
      } catch (error) {
        return {
          success: false,
          // @ts-expect-error -- error is not typed
          message: ((_b2 = (_a10 = error == null ? void 0 : error.response) == null ? void 0 : _a10.data) == null ? void 0 : _b2.message) || "An error occurred"
        };
      } finally {
        refetch();
      }
    }),
    [onSuccess, onError, refetch]
  );
  const totalMissionsPoints = campaign == null ? void 0 : campaign.quests.reduce((acc, quest) => acc + quest.points, 0);
  return {
    validateQuest,
    totalMissionsPoints
  };
}

// src/useSocialConnect.ts
var import_react5 = require("react");
function useSocialConnect() {
  var _a10, _b2, _c;
  const { user, campaignSlug } = useElevora();
  const connectX = (0, import_react5.useCallback)(() => {
    authControllerGetTwitterUrl({ campaignSlug, callbackUrl: window.location.href }).then((r) => {
      window.location.href = r.url;
    });
  }, []);
  const accountX = (_a10 = user == null ? void 0 : user.userData) == null ? void 0 : _a10.twitterHandle;
  const accountTelegram = (_c = (_b2 = user == null ? void 0 : user.userData) == null ? void 0 : _b2.telegramInfo) == null ? void 0 : _c.username;
  return { connectX, accountX, accountTelegram };
}

// src/usePoints.ts
var import_react6 = require("react");
function usePoints() {
  var _a10, _b2, _c, _d, _e, _f, _g, _h;
  const { userEntry, campaign } = useElevora();
  const points = (_b2 = (_a10 = userEntry == null ? void 0 : userEntry.entry) == null ? void 0 : _a10.points) != null ? _b2 : 0;
  const currentMultiplierFactor = (_g = (_f = (_d = (_c = userEntry == null ? void 0 : userEntry.multipliers) == null ? void 0 : _c.currentTier) == null ? void 0 : _d.multiplier_value) != null ? _f : (_e = campaign == null ? void 0 : campaign.multiplier) == null ? void 0 : _e.baseMultiplier) != null ? _g : 1;
  const multiplierTiers = (0, import_react6.useMemo)(
    () => {
      var _a11;
      return (_a11 = userEntry == null ? void 0 : userEntry.multipliers) == null ? void 0 : _a11.allTiers.sort((a, b) => a.tier.multiplier_value - b.tier.multiplier_value);
    },
    [(_h = userEntry == null ? void 0 : userEntry.multipliers) == null ? void 0 : _h.allTiers]
  );
  const applyMultiplier = (0, import_react6.useCallback)(
    (points2) => Math.round(points2 * currentMultiplierFactor * 1) / 1,
    [currentMultiplierFactor]
  );
  return {
    points,
    currentMultiplierFactor,
    pointsWithMultiplier: applyMultiplier(points),
    multiplierTiers,
    applyMultiplier
  };
}

// src/useContentBattle.ts
var import_react7 = require("react");
function useContentBattle({
  battleId: _battleId,
  onSuccess,
  onError,
  onVoteSuccess,
  onSubmitEntrySuccess
}) {
  var _a10, _b2;
  const { campaign } = useElevora();
  const battleId = (_battleId == null ? void 0 : _battleId.toString()) || ((_b2 = (_a10 = campaign == null ? void 0 : campaign.contentBattles[0]) == null ? void 0 : _a10.id) == null ? void 0 : _b2.toString());
  const { data: _currentRound, refetch: refetchRound } = useContentBattlePublicControllerGetCurrentRound(
    battleId || "",
    {
      query: {
        enabled: !!battleId
      }
    }
  );
  const { data: userEntry, refetch: refetchEntry } = useContentBattlePublicControllerGetEntry(battleId || "", {
    query: {
      enabled: !!battleId
    }
  });
  const currentRound = _currentRound == null ? void 0 : _currentRound.round;
  const error = _currentRound == null ? void 0 : _currentRound.error;
  const submitEntry = (0, import_react7.useCallback)(
    (image) => __async(this, null, function* () {
      if (!image) {
        onError == null ? void 0 : onError("Missing image file");
        return { success: false, message: "Missing image file" };
      }
      try {
        const formData = new FormData();
        formData.append("image", image);
        yield contentBattlePublicControllerSubmitEntry(battleId || "", formData, {
          headers: {
            "Content-Type": "multipart/form-data"
          }
        });
        onSubmitEntrySuccess == null ? void 0 : onSubmitEntrySuccess();
        onSuccess == null ? void 0 : onSuccess();
        refetchEntry();
        return { success: true };
      } catch (error2) {
        const message = error2 instanceof Error ? error2.message : "Failed to submit entry";
        onError == null ? void 0 : onError(message);
        return { success: false, message };
      }
    }),
    [battleId, onError, onSuccess, onSubmitEntrySuccess, refetchEntry]
  );
  const submitVote = (0, import_react7.useCallback)(
    (contentId) => __async(this, null, function* () {
      if (!contentId || !(currentRound == null ? void 0 : currentRound.id)) {
        onError == null ? void 0 : onError("Invalid content or round");
        return { success: false, message: "Invalid content or round" };
      }
      try {
        yield contentBattlePublicControllerSubmitVote(currentRound.id.toString(), {
          winnerId: contentId
        });
        onVoteSuccess == null ? void 0 : onVoteSuccess();
        onSuccess == null ? void 0 : onSuccess();
        refetchRound();
        return { success: true };
      } catch (error2) {
        const message = error2 instanceof Error ? error2.message : "Failed to submit vote";
        onError == null ? void 0 : onError(message);
        return { success: false, message };
      }
    }),
    [currentRound == null ? void 0 : currentRound.id, onError, onSuccess, onVoteSuccess, refetchRound]
  );
  return {
    currentRound,
    error,
    userEntry,
    submitEntry,
    submitVote,
    refetchRound,
    refetchEntry
  };
}

// src/useLeaderboard.ts
function useLeaderboard() {
  const { campaignSlug } = useElevora();
  const { data } = useCampaignsPublicControllerLeaderboard(campaignSlug || "");
  const leaderboard = (data == null ? void 0 : data.leaderboard) || [];
  return {
    leaderboard,
    totalPoints: (data == null ? void 0 : data.totalPoints) || 0
  };
}

// src/useNotifications.ts
var import_react8 = require("react");
function useNotifications() {
  const { campaignSlug, isConnected } = useElevora();
  const [subscription, setSubscription] = (0, import_react8.useState)(null);
  const [isSubscribed, setIsSubscribed] = (0, import_react8.useState)(false);
  const [isSupported, setIsSupported] = (0, import_react8.useState)(false);
  const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
  const { data: vapidKey } = usePushNotificationsControllerGetVapidPublicKey({
    query: {
      enabled: isConnected
    }
  });
  const { data: subscriptionStatus } = usePushNotificationsControllerGetSubscriptionStatus(
    { endpoint: (subscription == null ? void 0 : subscription.endpoint) || "", campaignSlug },
    {
      query: {
        enabled: isConnected && !!(subscription == null ? void 0 : subscription.endpoint)
      }
    }
  );
  (0, import_react8.useEffect)(() => {
    if ("serviceWorker" in navigator && "PushManager" in window) {
      setIsSupported(true);
    }
    setIsLoading(false);
  }, []);
  (0, import_react8.useEffect)(() => {
    if (!isSupported || !isConnected || !navigator.serviceWorker) return;
    const checkSubscription = () => __async(this, null, function* () {
      var _a10;
      try {
        const registration = yield navigator.serviceWorker.ready;
        const subscription2 = yield registration.pushManager.getSubscription();
        setSubscription(subscription2);
        setIsSubscribed(!!subscription2 && ((_a10 = subscriptionStatus == null ? void 0 : subscriptionStatus.isSubscribed) != null ? _a10 : false));
      } catch (error) {
        console.error("Error checking push notification subscription:", error);
      }
    });
    checkSubscription();
  }, [isSupported, isConnected, subscriptionStatus == null ? void 0 : subscriptionStatus.isSubscribed]);
  const subscribe = (0, import_react8.useCallback)(() => __async(this, null, function* () {
    if (!isSupported || !(vapidKey == null ? void 0 : vapidKey.publicKey) || !navigator.serviceWorker) {
      throw new Error("Push notifications are not supported");
    }
    try {
      const registration = yield navigator.serviceWorker.ready;
      const subscription2 = yield registration.pushManager.subscribe({
        userVisibleOnly: true,
        applicationServerKey: vapidKey.publicKey
      });
      yield pushNotificationsControllerSubscribe(subscription2.toJSON(), {
        campaignSlug
      });
      setSubscription(subscription2);
      setIsSubscribed(true);
      return true;
    } catch (error) {
      console.error("Error subscribing to push notifications:", error);
      return false;
    }
  }), [campaignSlug, isSupported, vapidKey == null ? void 0 : vapidKey.publicKey]);
  const unsubscribe = (0, import_react8.useCallback)(() => __async(this, null, function* () {
    if (!subscription) return false;
    try {
      yield subscription.unsubscribe();
      yield pushNotificationsControllerUnsubscribe({
        endpoint: subscription.endpoint,
        campaignSlug
      });
      setSubscription(null);
      setIsSubscribed(false);
      return true;
    } catch (error) {
      console.error("Error unsubscribing from push notifications:", error);
      return false;
    }
  }), [subscription, campaignSlug]);
  return {
    isSupported,
    isSubscribed,
    isLoading,
    subscribe,
    unsubscribe
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ElevoraProvider,
  authControllerCallbackTwitter,
  authControllerGetMessage,
  authControllerGetTwitterUrl,
  authControllerHandleTelegramAuth,
  authControllerSendMagicLink,
  authControllerVerifyCode,
  authControllerVerifyToken,
  authControllerWeb3Login,
  campaignsPublicControllerLeaderboard,
  campaignsPublicControllerPublicDetails,
  campaignsPublicControllerPublicStats,
  contentBattlePublicControllerGetCurrentRound,
  contentBattlePublicControllerGetEntry,
  contentBattlePublicControllerSubmitEntry,
  contentBattlePublicControllerSubmitVote,
  getAuthControllerCallbackTwitterQueryKey,
  getAuthControllerCallbackTwitterQueryOptions,
  getAuthControllerGetMessageQueryKey,
  getAuthControllerGetMessageQueryOptions,
  getAuthControllerGetTwitterUrlQueryKey,
  getAuthControllerGetTwitterUrlQueryOptions,
  getAuthControllerHandleTelegramAuthQueryKey,
  getAuthControllerHandleTelegramAuthQueryOptions,
  getAuthControllerSendMagicLinkMutationOptions,
  getAuthControllerVerifyCodeMutationOptions,
  getAuthControllerVerifyTokenMutationOptions,
  getAuthControllerWeb3LoginMutationOptions,
  getCampaignsPublicControllerLeaderboardQueryKey,
  getCampaignsPublicControllerLeaderboardQueryOptions,
  getCampaignsPublicControllerPublicDetailsQueryKey,
  getCampaignsPublicControllerPublicDetailsQueryOptions,
  getCampaignsPublicControllerPublicStatsQueryKey,
  getCampaignsPublicControllerPublicStatsQueryOptions,
  getContentBattlePublicControllerGetCurrentRoundQueryKey,
  getContentBattlePublicControllerGetCurrentRoundQueryOptions,
  getContentBattlePublicControllerGetEntryQueryKey,
  getContentBattlePublicControllerGetEntryQueryOptions,
  getContentBattlePublicControllerSubmitEntryMutationOptions,
  getContentBattlePublicControllerSubmitVoteMutationOptions,
  getLeadPublicControllerGetLeadEntryForCampaignQueryKey,
  getLeadPublicControllerGetLeadEntryForCampaignQueryOptions,
  getLeadPublicControllerGetMeQueryKey,
  getLeadPublicControllerGetMeQueryOptions,
  getLeadPublicControllerSigninMutationOptions,
  getPushNotificationsControllerGetSubscriptionStatusQueryKey,
  getPushNotificationsControllerGetSubscriptionStatusQueryOptions,
  getPushNotificationsControllerGetVapidPublicKeyQueryKey,
  getPushNotificationsControllerGetVapidPublicKeyQueryOptions,
  getPushNotificationsControllerSubscribeMutationOptions,
  getPushNotificationsControllerUnsubscribeMutationOptions,
  getQuestsPublicControllerGetProgressQueryKey,
  getQuestsPublicControllerGetProgressQueryOptions,
  getQuestsPublicControllerUploadMutationOptions,
  getQuestsPublicControllerValidateMutationOptions,
  leadPublicControllerGetLeadEntryForCampaign,
  leadPublicControllerGetMe,
  leadPublicControllerSignin,
  pushNotificationsControllerGetSubscriptionStatus,
  pushNotificationsControllerGetVapidPublicKey,
  pushNotificationsControllerSubscribe,
  pushNotificationsControllerUnsubscribe,
  questsPublicControllerGetProgress,
  questsPublicControllerUpload,
  questsPublicControllerValidate,
  useAuthControllerCallbackTwitter,
  useAuthControllerGetMessage,
  useAuthControllerGetTwitterUrl,
  useAuthControllerHandleTelegramAuth,
  useAuthControllerSendMagicLink,
  useAuthControllerVerifyCode,
  useAuthControllerVerifyToken,
  useAuthControllerWeb3Login,
  useCampaignsPublicControllerLeaderboard,
  useCampaignsPublicControllerPublicDetails,
  useCampaignsPublicControllerPublicStats,
  useContentBattle,
  useContentBattlePublicControllerGetCurrentRound,
  useContentBattlePublicControllerGetEntry,
  useContentBattlePublicControllerSubmitEntry,
  useContentBattlePublicControllerSubmitVote,
  useDailyReward,
  useElevora,
  useLeadPublicControllerGetLeadEntryForCampaign,
  useLeadPublicControllerGetMe,
  useLeadPublicControllerSignin,
  useLeaderboard,
  useMissions,
  useNotifications,
  usePoints,
  usePushNotificationsControllerGetSubscriptionStatus,
  usePushNotificationsControllerGetVapidPublicKey,
  usePushNotificationsControllerSubscribe,
  usePushNotificationsControllerUnsubscribe,
  useQuestsPublicControllerGetProgress,
  useQuestsPublicControllerUpload,
  useQuestsPublicControllerValidate,
  useSocialConnect
});