@tanstack/react-query
Advanced tools
Comparing version 4.14.3 to 4.14.5
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react-dom"),require("react")):"function"==typeof define&&define.amd?define(["exports","react-dom","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactQuery={},t.ReactDOM,t.React)}(this,(function(t,e,s){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}})),e.default=t,Object.freeze(e)}var n=i(e),o=r(s),a=i(s);class u{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.push(t),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((e=>e!==t)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const c="undefined"==typeof window;function l(){}function h(t){return"number"==typeof t&&t>=0&&t!==1/0}function d(t,e){return t.filter((t=>-1===e.indexOf(t)))}function f(t,e){return Math.max(t+(e||0)-Date.now(),0)}function p(t,e,s){return M(t)?"function"==typeof e?{...s,queryKey:t,queryFn:e}:{...e,queryKey:t}:t}function y(t,e,s){return M(t)?"function"==typeof e?{...s,mutationKey:t,mutationFn:e}:{...e,mutationKey:t}:"function"==typeof t?{...e,mutationFn:t}:{...t}}function v(t,e,s){return M(t)?[{...e,queryKey:t},s]:[t||{},e]}function m(t,e,s){return M(t)?[{...e,mutationKey:t},s]:[t||{},e]}function b(t,e){const{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:o,stale:a}=t;if(M(o))if(r){if(e.queryHash!==O(o,e.options))return!1}else if(!R(e.queryKey,o))return!1;if("all"!==s){const t=e.isActive();if("active"===s&&!t)return!1;if("inactive"===s&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&((void 0===i||i===e.state.fetchStatus)&&!(n&&!n(e)))}function g(t,e){const{exact:s,fetching:r,predicate:i,mutationKey:n}=t;if(M(n)){if(!e.options.mutationKey)return!1;if(s){if(C(e.options.mutationKey)!==C(n))return!1}else if(!R(e.options.mutationKey,n))return!1}return("boolean"!=typeof r||"loading"===e.state.status===r)&&!(i&&!i(e))}function O(t,e){return((null==e?void 0:e.queryKeyHashFn)||C)(t)}function C(t){return JSON.stringify(t,((t,e)=>Q(e)?Object.keys(e).sort().reduce(((t,s)=>(t[s]=e[s],t)),{}):e))}function R(t,e){return q(t,e)}function q(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&!Object.keys(e).some((s=>!q(t[s],e[s]))))}function S(t,e){if(t===e)return t;const s=E(t)&&E(e);if(s||Q(t)&&Q(e)){const r=s?t.length:Object.keys(t).length,i=s?e:Object.keys(e),n=i.length,o=s?[]:{};let a=0;for(let r=0;r<n;r++){const n=s?r:i[r];o[n]=S(t[n],e[n]),o[n]===t[n]&&a++}return r===n&&a===r?t:o}return e}function P(t,e){if(t&&!e||e&&!t)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function E(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Q(t){if(!w(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!w(s)&&!!s.hasOwnProperty("isPrototypeOf")}function w(t){return"[object Object]"===Object.prototype.toString.call(t)}function M(t){return Array.isArray(t)}function x(t){return new Promise((e=>{setTimeout(e,t)}))}function F(t){x(0).then(t)}function A(t,e,s){return null!=s.isDataEqual&&s.isDataEqual(t,e)?t:"function"==typeof s.structuralSharing?s.structuralSharing(t,e):!1!==s.structuralSharing?S(t,e):e}const D=new class extends u{constructor(){super(),this.setup=t=>{if(!c&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",e,!1),()=>{window.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){this.focused=t,t&&this.onFocus()}onFocus(){this.listeners.forEach((t=>{t()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};const U=new class extends u{constructor(){super(),this.setup=t=>{if(!c&&window.addEventListener){const e=()=>t();return window.addEventListener("online",e,!1),window.addEventListener("offline",e,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setOnline(t):this.onOnline()}))}setOnline(t){this.online=t,t&&this.onOnline()}onOnline(){this.listeners.forEach((t=>{t()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};function I(t){return Math.min(1e3*2**t,3e4)}function T(t){return"online"!==(null!=t?t:"online")||U.isOnline()}class K{constructor(t){this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}}function k(t){return t instanceof K}function L(t){let e,s,r,i=!1,n=0,o=!1;const a=new Promise(((t,e)=>{s=t,r=e})),u=()=>!D.isFocused()||"always"!==t.networkMode&&!U.isOnline(),c=r=>{o||(o=!0,null==t.onSuccess||t.onSuccess(r),null==e||e(),s(r))},l=s=>{o||(o=!0,null==t.onError||t.onError(s),null==e||e(),r(s))},h=()=>new Promise((s=>{e=t=>{if(o||!u())return s(t)},null==t.onPause||t.onPause()})).then((()=>{e=void 0,o||null==t.onContinue||t.onContinue()})),d=()=>{if(o)return;let e;try{e=t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(c).catch((e=>{var s,r;if(o)return;const a=null!=(s=t.retry)?s:3,c=null!=(r=t.retryDelay)?r:I,f="function"==typeof c?c(n,e):c,p=!0===a||"number"==typeof a&&n<a||"function"==typeof a&&a(n,e);!i&&p?(n++,null==t.onFail||t.onFail(n,e),x(f).then((()=>{if(u())return h()})).then((()=>{i?l(e):d()}))):l(e)}))};return T(t.networkMode)?d():h().then(d),{promise:a,cancel:e=>{o||(l(new K(e)),null==t.abort||t.abort())},continue:()=>{null==e||e()},cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1}}}const j=console;const H=function(){let t=[],e=0,s=t=>{t()},r=t=>{t()};const i=r=>{e?t.push(r):F((()=>{s(r)}))},n=()=>{const e=t;t=[],e.length&&F((()=>{r((()=>{e.forEach((t=>{s(t)}))}))}))};return{batch:t=>{let s;e++;try{s=t()}finally{e--,e||n()}return s},batchCalls:t=>(...e)=>{i((()=>{t(...e)}))},schedule:i,setNotifyFunction:t=>{s=t},setBatchNotifyFunction:t=>{r=t}}}();class B{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),h(this.cacheTime)&&(this.gcTimeout=setTimeout((()=>{this.optionalRemove()}),this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,null!=t?t:c?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class N extends B{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||j,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||function(t){const e="function"==typeof t.initialData?t.initialData():t.initialData,s=void 0!==e,r=s?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?null!=r?r:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState,this.meta=t.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.meta=null==t?void 0:t.meta,this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(t,e){const s=A(this.state.data,t,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),s}setState(t,e){this.dispatch({type:"setState",state:t,setStateOptions:e})}cancel(t){var e;const s=this.promise;return null==(e=this.retryer)||e.cancel(t),s?s.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some((t=>!1!==t.options.enabled))}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some((t=>t.getCurrentResult().isStale))}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!f(this.state.dataUpdatedAt,t)}onFocus(){var t;const e=this.observers.find((t=>t.shouldFetchOnWindowFocus()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}onOnline(){var t;const e=this.observers.find((t=>t.shouldFetchOnReconnect()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){-1!==this.observers.indexOf(t)&&(this.observers=this.observers.filter((e=>e!==t)),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(t,e){var s,r;if("idle"!==this.state.fetchStatus)if(this.state.dataUpdatedAt&&null!=e&&e.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var i;return null==(i=this.retryer)||i.continueRetry(),this.promise}if(t&&this.setOptions(t),!this.options.queryFn){const t=this.observers.find((t=>t.options.queryFn));t&&this.setOptions(t.options)}Array.isArray(this.options.queryKey);const n=function(){if("function"==typeof AbortController)return new AbortController}(),o={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},a=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>{if(n)return this.abortSignalConsumed=!0,n.signal}})};a(o);const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(o)):Promise.reject("Missing queryFn"),meta:this.meta};var c;(a(u),null==(s=this.options.behavior)||s.onFetch(u),this.revertState=this.state,"idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(r=u.fetchOptions)?void 0:r.meta))&&this.dispatch({type:"fetch",meta:null==(c=u.fetchOptions)?void 0:c.meta});const l=t=>{var e,s;(k(t)&&t.silent||this.dispatch({type:"error",error:t}),k(t))||(null==(e=(s=this.cache.config).onError)||e.call(s,t,this));this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=L({fn:u.fetchFn,abort:null==n?void 0:n.abort.bind(n),onSuccess:t=>{var e,s;void 0!==t?(this.setData(t),null==(e=(s=this.cache.config).onSuccess)||e.call(s,t,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1):l(new Error("undefined"))},onError:l,onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){this.state=(e=>{var s,r;switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null!=(s=t.meta)?s:null,fetchStatus:T(this.options.networkMode)?"fetching":"paused",...!e.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(r=t.dataUpdatedAt)?r:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const i=t.error;return k(i)&&i.revert&&this.revertState?{...this.revertState}:{...e,error:i,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),H.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate(t)})),this.cache.notify({query:this,type:"updated",action:t})}))}}class _ extends u{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,e,s){var r;const i=e.queryKey,n=null!=(r=e.queryHash)?r:O(i,e);let o=this.get(n);return o||(o=new N({cache:this,logger:t.getLogger(),queryKey:i,queryHash:n,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(i),meta:e.meta}),this.add(o)),o}add(t){this.queriesMap[t.queryHash]||(this.queriesMap[t.queryHash]=t,this.queries.push(t),this.notify({type:"added",query:t}))}remove(t){const e=this.queriesMap[t.queryHash];e&&(t.destroy(),this.queries=this.queries.filter((e=>e!==t)),e===t&&delete this.queriesMap[t.queryHash],this.notify({type:"removed",query:t}))}clear(){H.batch((()=>{this.queries.forEach((t=>{this.remove(t)}))}))}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,e){const[s]=v(t,e);return void 0===s.exact&&(s.exact=!0),this.queries.find((t=>b(s,t)))}findAll(t,e){const[s]=v(t,e);return Object.keys(s).length>0?this.queries.filter((t=>b(s,t))):this.queries}notify(t){H.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){H.batch((()=>{this.queries.forEach((t=>{t.onFocus()}))}))}onOnline(){H.batch((()=>{this.queries.forEach((t=>{t.onOnline()}))}))}}class G extends B{constructor(t){super(),this.options={...t.defaultOptions,...t.options},this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||j,this.observers=[],this.state=t.state||W(),this.meta=t.meta,this.updateCacheTime(this.options.cacheTime),this.scheduleGc()}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.observers=this.observers.filter((e=>e!==t)),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()}async execute(){const t=()=>{var t;return this.retryer=L({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(t=this.options.retry)?t:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},e="loading"===this.state.status;try{var s,r,i,n,o,a;if(!e){var u,c,l,h;this.dispatch({type:"loading",variables:this.options.variables}),await(null==(u=(c=this.mutationCache.config).onMutate)?void 0:u.call(c,this.state.variables,this));const t=await(null==(l=(h=this.options).onMutate)?void 0:l.call(h,this.state.variables));t!==this.state.context&&this.dispatch({type:"loading",context:t,variables:this.state.variables})}const d=await t();return await(null==(s=(r=this.mutationCache.config).onSuccess)?void 0:s.call(r,d,this.state.variables,this.state.context,this)),await(null==(i=(n=this.options).onSuccess)?void 0:i.call(n,d,this.state.variables,this.state.context)),await(null==(o=(a=this.options).onSettled)?void 0:o.call(a,d,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:d}),d}catch(t){try{var d,f,p,y,v,m;throw await(null==(d=(f=this.mutationCache.config).onError)?void 0:d.call(f,t,this.state.variables,this.state.context,this)),await(null==(p=(y=this.options).onError)?void 0:p.call(y,t,this.state.variables,this.state.context)),await(null==(v=(m=this.options).onSettled)?void 0:v.call(m,void 0,t,this.state.variables,this.state.context)),t}finally{this.dispatch({type:"error",error:t})}}}dispatch(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"loading":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!T(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"};case"setState":return{...e,...t.state}}})(this.state),H.batch((()=>{this.observers.forEach((e=>{e.onMutationUpdate(t)})),this.mutationCache.notify({mutation:this,type:"updated",action:t})}))}}function W(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class z extends u{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,e,s){const r=new G({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(e),state:s,defaultOptions:e.mutationKey?t.getMutationDefaults(e.mutationKey):void 0,meta:e.meta});return this.add(r),r}add(t){this.mutations.push(t),this.notify({type:"added",mutation:t})}remove(t){this.mutations=this.mutations.filter((e=>e!==t)),this.notify({type:"removed",mutation:t})}clear(){H.batch((()=>{this.mutations.forEach((t=>{this.remove(t)}))}))}getAll(){return this.mutations}find(t){return void 0===t.exact&&(t.exact=!0),this.mutations.find((e=>g(t,e)))}findAll(t){return this.mutations.filter((e=>g(t,e)))}notify(t){H.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.mutations.filter((t=>t.state.isPaused));return H.batch((()=>t.reduce(((t,e)=>t.then((()=>e.continue().catch(l)))),Promise.resolve())))}}function J(){return{onFetch:t=>{t.fetchFn=()=>{var e,s,r,i,n,o;const a=null==(e=t.fetchOptions)||null==(s=e.meta)?void 0:s.refetchPage,u=null==(r=t.fetchOptions)||null==(i=r.meta)?void 0:i.fetchMore,c=null==u?void 0:u.pageParam,l="forward"===(null==u?void 0:u.direction),h="backward"===(null==u?void 0:u.direction),d=(null==(n=t.state.data)?void 0:n.pages)||[],f=(null==(o=t.state.data)?void 0:o.pageParams)||[];let p=f,y=!1;const v=t.options.queryFn||(()=>Promise.reject("Missing queryFn")),m=(t,e,s,r)=>(p=r?[e,...p]:[...p,e],r?[s,...t]:[...t,s]),b=(e,s,r,i)=>{if(y)return Promise.reject("Cancelled");if(void 0===r&&!s&&e.length)return Promise.resolve(e);const n={queryKey:t.queryKey,pageParam:r,meta:t.meta};var o;o=n,Object.defineProperty(o,"signal",{enumerable:!0,get:()=>{var e,s;return null!=(e=t.signal)&&e.aborted?y=!0:null==(s=t.signal)||s.addEventListener("abort",(()=>{y=!0})),t.signal}});const a=v(n);return Promise.resolve(a).then((t=>m(e,r,t,i)))};let g;if(d.length)if(l){const e=void 0!==c,s=e?c:V(t.options,d);g=b(d,e,s)}else if(h){const e=void 0!==c,s=e?c:X(t.options,d);g=b(d,e,s,!0)}else{p=[];const e=void 0===t.options.getNextPageParam;g=!a||!d[0]||a(d[0],0,d)?b([],e,f[0]):Promise.resolve(m([],f[0],d[0]));for(let s=1;s<d.length;s++)g=g.then((r=>{if(!a||!d[s]||a(d[s],s,d)){const i=e?f[s]:V(t.options,r);return b(r,e,i)}return Promise.resolve(m(r,f[s],d[s]))}))}else g=b([]);return g.then((t=>({pages:t,pageParams:p})))}}}}function V(t,e){return null==t.getNextPageParam?void 0:t.getNextPageParam(e[e.length-1],e)}function X(t,e){return null==t.getPreviousPageParam?void 0:t.getPreviousPageParam(e[0],e)}function Y(t,e){if(t.getNextPageParam&&Array.isArray(e)){const s=V(t,e);return null!=s&&!1!==s}}function Z(t,e){if(t.getPreviousPageParam&&Array.isArray(e)){const s=X(t,e);return null!=s&&!1!==s}}class $ extends u{constructor(t,e){super(),this.client=t,this.options=e,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.length&&(this.currentQuery.addObserver(this),tt(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.listeners.length||this.destroy()}shouldFetchOnReconnect(){return et(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return et(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=[],this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(t,e){const s=this.options,r=this.currentQuery;if(this.options=this.client.defaultQueryOptions(t),P(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const i=this.hasListeners();i&&st(this.currentQuery,r,this.options,s)&&this.executeFetch(),this.updateResult(e),!i||this.currentQuery===r&&this.options.enabled===s.enabled&&this.options.staleTime===s.staleTime||this.updateStaleTimeout();const n=this.computeRefetchInterval();!i||this.currentQuery===r&&this.options.enabled===s.enabled&&n===this.currentRefetchInterval||this.updateRefetchInterval(n)}getOptimisticResult(t){const e=this.client.getQueryCache().build(this.client,t);return this.createResult(e,t)}getCurrentResult(){return this.currentResult}trackResult(t){const e={};return Object.keys(t).forEach((s=>{Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),t[s])})})),e}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:t,...e}={}){return this.fetch({...e,meta:{refetchPage:t}})}fetchOptimistic(t){const e=this.client.defaultQueryOptions(t),s=this.client.getQueryCache().build(this.client,e);return s.isFetchingOptimistic=!0,s.fetch().then((()=>this.createResult(s,e)))}fetch(t){var e;return this.executeFetch({...t,cancelRefetch:null==(e=t.cancelRefetch)||e}).then((()=>(this.updateResult(),this.currentResult)))}executeFetch(t){this.updateQuery();let e=this.currentQuery.fetch(this.options,t);return null!=t&&t.throwOnError||(e=e.catch(l)),e}updateStaleTimeout(){if(this.clearStaleTimeout(),c||this.currentResult.isStale||!h(this.options.staleTime))return;const t=f(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout((()=>{this.currentResult.isStale||this.updateResult()}),t)}computeRefetchInterval(){var t;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(t=this.options.refetchInterval)&&t}updateRefetchInterval(t){this.clearRefetchInterval(),this.currentRefetchInterval=t,!c&&!1!==this.options.enabled&&h(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval((()=>{(this.options.refetchIntervalInBackground||D.isFocused())&&this.executeFetch()}),this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(t,e){const s=this.currentQuery,r=this.options,i=this.currentResult,n=this.currentResultState,o=this.currentResultOptions,a=t!==s,u=a?t.state:this.currentQueryInitialState,c=a?this.currentResult:this.previousQueryResult,{state:l}=t;let h,{dataUpdatedAt:d,error:f,errorUpdatedAt:p,fetchStatus:y,status:v}=l,m=!1,b=!1;if(e._optimisticResults){const i=this.hasListeners(),n=!i&&tt(t,e),o=i&&st(t,s,e,r);(n||o)&&(y=T(t.options.networkMode)?"fetching":"paused",d||(v="loading")),"isRestoring"===e._optimisticResults&&(y="idle")}if(e.keepPreviousData&&!l.dataUpdatedAt&&null!=c&&c.isSuccess&&"error"!==v)h=c.data,d=c.dataUpdatedAt,v=c.status,m=!0;else if(e.select&&void 0!==l.data)if(i&&l.data===(null==n?void 0:n.data)&&e.select===this.selectFn)h=this.selectResult;else try{this.selectFn=e.select,h=e.select(l.data),h=A(null==i?void 0:i.data,h,e),this.selectResult=h,this.selectError=null}catch(t){this.selectError=t}else h=l.data;if(void 0!==e.placeholderData&&void 0===h&&"loading"===v){let t;if(null!=i&&i.isPlaceholderData&&e.placeholderData===(null==o?void 0:o.placeholderData))t=i.data;else if(t="function"==typeof e.placeholderData?e.placeholderData():e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),this.selectError=null}catch(t){this.selectError=t}void 0!==t&&(v="success",h=A(null==i?void 0:i.data,t,e),b=!0)}this.selectError&&(f=this.selectError,h=this.selectResult,p=Date.now(),v="error");const g="fetching"===y,O="loading"===v,C="error"===v;return{status:v,fetchStatus:y,isLoading:O,isSuccess:"success"===v,isError:C,isInitialLoading:O&&g,data:h,dataUpdatedAt:d,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>u.dataUpdateCount||l.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!O,isLoadingError:C&&0===l.dataUpdatedAt,isPaused:"paused"===y,isPlaceholderData:b,isPreviousData:m,isRefetchError:C&&0!==l.dataUpdatedAt,isStale:rt(t,e),refetch:this.refetch,remove:this.remove}}updateResult(t){const e=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,P(s,e))return;this.currentResult=s;const r={cache:!0};!1!==(null==t?void 0:t.listeners)&&(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options;if("all"===t||!t&&!this.trackedProps.size)return!0;const s=new Set(null!=t?t:this.trackedProps);return this.options.useErrorBoundary&&s.add("error"),Object.keys(this.currentResult).some((t=>{const r=t;return this.currentResult[r]!==e[r]&&s.has(r)}))})()&&(r.listeners=!0),this.notify({...r,...t})}updateQuery(){const t=this.client.getQueryCache().build(this.client,this.options);if(t===this.currentQuery)return;const e=this.currentQuery;this.currentQuery=t,this.currentQueryInitialState=t.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==e||e.removeObserver(this),t.addObserver(this))}onQueryUpdate(t){const e={};"success"===t.type?e.onSuccess=!t.manual:"error"!==t.type||k(t.error)||(e.onError=!0),this.updateResult(e),this.hasListeners()&&this.updateTimers()}notify(t){H.batch((()=>{var e,s,r,i;if(t.onSuccess)null==(e=(s=this.options).onSuccess)||e.call(s,this.currentResult.data),null==(r=(i=this.options).onSettled)||r.call(i,this.currentResult.data,null);else if(t.onError){var n,o,a,u;null==(n=(o=this.options).onError)||n.call(o,this.currentResult.error),null==(a=(u=this.options).onSettled)||a.call(u,void 0,this.currentResult.error)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)})),t.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})}))}}function tt(t,e){return function(t,e){return!(!1===e.enabled||t.state.dataUpdatedAt||"error"===t.state.status&&!1===e.retryOnMount)}(t,e)||t.state.dataUpdatedAt>0&&et(t,e,e.refetchOnMount)}function et(t,e,s){if(!1!==e.enabled){const r="function"==typeof s?s(t):s;return"always"===r||!1!==r&&rt(t,e)}return!1}function st(t,e,s,r){return!1!==s.enabled&&(t!==e||!1===r.enabled)&&(!s.suspense||"error"!==t.state.status)&&rt(t,s)}function rt(t,e){return t.isStaleByTime(e.staleTime)}class it extends u{constructor(t,e){super(),this.client=t,this.queries=[],this.result=[],this.observers=[],this.observersMap={},e&&this.setQueries(e)}onSubscribe(){1===this.listeners.length&&this.observers.forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))}))}onUnsubscribe(){this.listeners.length||this.destroy()}destroy(){this.listeners=[],this.observers.forEach((t=>{t.destroy()}))}setQueries(t,e){this.queries=t,H.batch((()=>{const t=this.observers,s=this.findMatchingObservers(this.queries);s.forEach((t=>t.observer.setOptions(t.defaultedQueryOptions,e)));const r=s.map((t=>t.observer)),i=Object.fromEntries(r.map((t=>[t.options.queryHash,t]))),n=r.map((t=>t.getCurrentResult())),o=r.some(((e,s)=>e!==t[s]));(t.length!==r.length||o)&&(this.observers=r,this.observersMap=i,this.result=n,this.hasListeners()&&(d(t,r).forEach((t=>{t.destroy()})),d(r,t).forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))})),this.notify()))}))}getCurrentResult(){return this.result}getQueries(){return this.observers.map((t=>t.getCurrentQuery()))}getOptimisticResult(t){return this.findMatchingObservers(t).map((t=>t.observer.getOptimisticResult(t.defaultedQueryOptions)))}findMatchingObservers(t){const e=this.observers,s=t.map((t=>this.client.defaultQueryOptions(t))),r=s.flatMap((t=>{const s=e.find((e=>e.options.queryHash===t.queryHash));return null!=s?[{defaultedQueryOptions:t,observer:s}]:[]})),i=r.map((t=>t.defaultedQueryOptions.queryHash)),n=s.filter((t=>!i.includes(t.queryHash))),o=e.filter((t=>!r.some((e=>e.observer===t)))),a=t=>{const e=this.client.defaultQueryOptions(t),s=this.observersMap[e.queryHash];return null!=s?s:new $(this.client,e)},u=n.map(((t,e)=>{if(t.keepPreviousData){const s=o[e];if(void 0!==s)return{defaultedQueryOptions:t,observer:s}}return{defaultedQueryOptions:t,observer:a(t)}}));return r.concat(u).sort(((t,e)=>s.indexOf(t.defaultedQueryOptions)-s.indexOf(e.defaultedQueryOptions)))}onUpdate(t,e){const s=this.observers.indexOf(t);-1!==s&&(this.result=function(t,e,s){const r=t.slice(0);return r[e]=s,r}(this.result,s,e),this.notify())}notify(){H.batch((()=>{this.listeners.forEach((t=>{t(this.result)}))}))}}class nt extends ${constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t,e){super.setOptions({...t,behavior:J()},e)}getOptimisticResult(t){return t.behavior=J(),super.getOptimisticResult(t)}fetchNextPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"forward",pageParam:t}}})}fetchPreviousPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"backward",pageParam:t}}})}createResult(t,e){var s,r,i,n,o,a;const{state:u}=t;return{...super.createResult(t,e),fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Y(e,null==(s=u.data)?void 0:s.pages),hasPreviousPage:Z(e,null==(r=u.data)?void 0:r.pages),isFetchingNextPage:"fetching"===u.fetchStatus&&"forward"===(null==(i=u.fetchMeta)||null==(n=i.fetchMore)?void 0:n.direction),isFetchingPreviousPage:"fetching"===u.fetchStatus&&"backward"===(null==(o=u.fetchMeta)||null==(a=o.fetchMore)?void 0:a.direction)}}}class ot extends u{constructor(t,e){super(),this.client=t,this.setOptions(e),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.client.defaultMutationOptions(t),P(e,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){var t;this.listeners.length||(null==(t=this.currentMutation)||t.removeObserver(this))}onMutationUpdate(t){this.updateResult();const e={listeners:!0};"success"===t.type?e.onSuccess=!0:"error"===t.type&&(e.onError=!0),this.notify(e)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(t,e){return this.mutateOptions=e,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:void 0!==t?t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const t=this.currentMutation?this.currentMutation.state:{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0},e={...t,isLoading:"loading"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset};this.currentResult=e}notify(t){H.batch((()=>{var e,s,r,i;if(this.mutateOptions)if(t.onSuccess)null==(e=(s=this.mutateOptions).onSuccess)||e.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(r=(i=this.mutateOptions).onSettled)||r.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context);else if(t.onError){var n,o,a,u;null==(n=(o=this.mutateOptions).onError)||n.call(o,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(a=(u=this.mutateOptions).onSettled)||a.call(u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)}))}))}}function at(t){return t.state.isPaused}function ut(t){return"success"===t.state.status}function ct(t,e,s){if("object"!=typeof e||null===e)return;const r=t.getMutationCache(),i=t.getQueryCache(),n=e.mutations||[],o=e.queries||[];n.forEach((e=>{var i;r.build(t,{...null==s||null==(i=s.defaultOptions)?void 0:i.mutations,mutationKey:e.mutationKey},e.state)})),o.forEach((e=>{var r;const n=i.get(e.queryHash);n?n.state.dataUpdatedAt<e.state.dataUpdatedAt&&n.setState(e.state):i.build(t,{...null==s||null==(r=s.defaultOptions)?void 0:r.queries,queryKey:e.queryKey,queryHash:e.queryHash},e.state)}))}const lt=n.unstable_batchedUpdates;H.setBatchNotifyFunction(lt);var ht,dt={exports:{}},ft={};!function(t){t.exports=function(){if(ht)return ft;ht=1;var t=o.default,e="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=t.useState,r=t.useEffect,i=t.useLayoutEffect,n=t.useDebugValue;function a(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!e(t,r)}catch(t){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var o=e(),u=s({inst:{value:o,getSnapshot:e}}),c=u[0].inst,l=u[1];return i((function(){c.value=o,c.getSnapshot=e,a(c)&&l({inst:c})}),[t,o,e]),r((function(){return a(c)&&l({inst:c}),t((function(){a(c)&&l({inst:c})}))}),[t]),n(o),o};return ft.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:u,ft}()}(dt);const pt=dt.exports.useSyncExternalStore,yt=a.createContext(void 0),vt=a.createContext(!1);function mt(t,e){return t||(e&&"undefined"!=typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=yt),window.ReactQueryClientContext):yt)}const bt=({context:t}={})=>{const e=a.useContext(mt(t,a.useContext(vt)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},gt=a.createContext(!1),Ot=()=>a.useContext(gt),Ct=gt.Provider;function Rt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const qt=a.createContext(Rt()),St=()=>a.useContext(qt);function Pt(t,e){return"function"==typeof t?t(...e):!!t}const Et=(t,e)=>{(t.suspense||t.useErrorBoundary)&&(e.isReset()||(t.retryOnMount=!1))},Qt=t=>{a.useEffect((()=>{t.clearReset()}),[t])},wt=({result:t,errorResetBoundary:e,useErrorBoundary:s,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&Pt(s,[t.error,r]);function Mt(t,e){const s=bt({context:t.context}),r=Ot(),i=St(),n=s.defaultQueryOptions(t);n._optimisticResults=r?"isRestoring":"optimistic",n.onError&&(n.onError=H.batchCalls(n.onError)),n.onSuccess&&(n.onSuccess=H.batchCalls(n.onSuccess)),n.onSettled&&(n.onSettled=H.batchCalls(n.onSettled)),n.suspense&&"number"!=typeof n.staleTime&&(n.staleTime=1e3),Et(n,i),Qt(i);const[o]=a.useState((()=>new e(s,n))),u=o.getOptimisticResult(n);if(pt(a.useCallback((t=>r?()=>{}:o.subscribe(H.batchCalls(t))),[o,r]),(()=>o.getCurrentResult()),(()=>o.getCurrentResult())),a.useEffect((()=>{o.setOptions(n,{listeners:!1})}),[n,o]),n.suspense&&u.isLoading&&u.isFetching&&!r)throw o.fetchOptimistic(n).then((({data:t})=>{null==n.onSuccess||n.onSuccess(t),null==n.onSettled||n.onSettled(t,null)})).catch((t=>{i.clearReset(),null==n.onError||n.onError(t),null==n.onSettled||n.onSettled(void 0,t)}));if(wt({result:u,errorResetBoundary:i,useErrorBoundary:n.useErrorBoundary,query:o.getCurrentQuery()}))throw u.error;return n.notifyOnChangeProps?u:o.trackResult(u)}function xt(t,e={}){const s=bt({context:e.context}),r=a.useRef(e);r.current=e,a.useMemo((()=>{t&&ct(s,t,r.current)}),[s,t])}function Ft(){}t.CancelledError=K,t.Hydrate=({children:t,options:e,state:s})=>(xt(s,e),t),t.InfiniteQueryObserver=nt,t.IsRestoringProvider=Ct,t.MutationCache=z,t.MutationObserver=ot,t.QueriesObserver=it,t.QueryCache=_,t.QueryClient=class{constructor(t={}){this.queryCache=t.queryCache||new _,this.mutationCache=t.mutationCache||new z,this.logger=t.logger||j,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}mount(){this.unsubscribeFocus=D.subscribe((()=>{D.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())})),this.unsubscribeOnline=U.subscribe((()=>{U.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,e;null==(t=this.unsubscribeFocus)||t.call(this),null==(e=this.unsubscribeOnline)||e.call(this)}isFetching(t,e){const[s]=v(t,e);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state.data}getQueriesData(t){return this.getQueryCache().findAll(t).map((({queryKey:t,state:e})=>[t,e.data]))}setQueryData(t,e,s){const r=this.queryCache.find(t),i=function(t,e){return"function"==typeof t?t(e):t}(e,null==r?void 0:r.state.data);if(void 0===i)return;const n=p(t),o=this.defaultQueryOptions(n);return this.queryCache.build(this,o).setData(i,{...s,manual:!0})}setQueriesData(t,e,s){return H.batch((()=>this.getQueryCache().findAll(t).map((({queryKey:t})=>[t,this.setQueryData(t,e,s)]))))}getQueryState(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state}removeQueries(t,e){const[s]=v(t,e),r=this.queryCache;H.batch((()=>{r.findAll(s).forEach((t=>{r.remove(t)}))}))}resetQueries(t,e,s){const[r,i]=v(t,e,s),n=this.queryCache,o={type:"active",...r};return H.batch((()=>(n.findAll(r).forEach((t=>{t.reset()})),this.refetchQueries(o,i))))}cancelQueries(t,e,s){const[r,i={}]=v(t,e,s);void 0===i.revert&&(i.revert=!0);const n=H.batch((()=>this.queryCache.findAll(r).map((t=>t.cancel(i)))));return Promise.all(n).then(l).catch(l)}invalidateQueries(t,e,s){const[r,i]=v(t,e,s);return H.batch((()=>{var t,e;if(this.queryCache.findAll(r).forEach((t=>{t.invalidate()})),"none"===r.refetchType)return Promise.resolve();const s={...r,type:null!=(t=null!=(e=r.refetchType)?e:r.type)?t:"active"};return this.refetchQueries(s,i)}))}refetchQueries(t,e,s){const[r,i]=v(t,e,s),n=H.batch((()=>this.queryCache.findAll(r).filter((t=>!t.isDisabled())).map((t=>{var e;return t.fetch(void 0,{...i,cancelRefetch:null==(e=null==i?void 0:i.cancelRefetch)||e,meta:{refetchPage:r.refetchPage}})}))));let o=Promise.all(n).then(l);return null!=i&&i.throwOnError||(o=o.catch(l)),o}fetchQuery(t,e,s){const r=p(t,e,s),i=this.defaultQueryOptions(r);void 0===i.retry&&(i.retry=!1);const n=this.queryCache.build(this,i);return n.isStaleByTime(i.staleTime)?n.fetch(i):Promise.resolve(n.state.data)}prefetchQuery(t,e,s){return this.fetchQuery(t,e,s).then(l).catch(l)}fetchInfiniteQuery(t,e,s){const r=p(t,e,s);return r.behavior=J(),this.fetchQuery(r)}prefetchInfiniteQuery(t,e,s){return this.fetchInfiniteQuery(t,e,s).then(l).catch(l)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(t){this.defaultOptions=t}setQueryDefaults(t,e){const s=this.queryDefaults.find((e=>C(t)===C(e.queryKey)));s?s.defaultOptions=e:this.queryDefaults.push({queryKey:t,defaultOptions:e})}getQueryDefaults(t){if(!t)return;const e=this.queryDefaults.find((e=>R(t,e.queryKey)));return null==e?void 0:e.defaultOptions}setMutationDefaults(t,e){const s=this.mutationDefaults.find((e=>C(t)===C(e.mutationKey)));s?s.defaultOptions=e:this.mutationDefaults.push({mutationKey:t,defaultOptions:e})}getMutationDefaults(t){if(!t)return;const e=this.mutationDefaults.find((e=>R(t,e.mutationKey)));return null==e?void 0:e.defaultOptions}defaultQueryOptions(t){if(null!=t&&t._defaulted)return t;const e={...this.defaultOptions.queries,...this.getQueryDefaults(null==t?void 0:t.queryKey),...t,_defaulted:!0};return!e.queryHash&&e.queryKey&&(e.queryHash=O(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.useErrorBoundary&&(e.useErrorBoundary=!!e.suspense),e}defaultMutationOptions(t){return null!=t&&t._defaulted?t:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==t?void 0:t.mutationKey),...t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}},t.QueryClientProvider=({client:t,children:e,context:s,contextSharing:r=!1})=>{a.useEffect((()=>(t.mount(),()=>{t.unmount()})),[t]);const i=mt(s,r);return a.createElement(vt.Provider,{value:!s&&r},a.createElement(i.Provider,{value:t},e))},t.QueryErrorResetBoundary=({children:t})=>{const[e]=a.useState((()=>Rt()));return a.createElement(qt.Provider,{value:e},"function"==typeof t?t(e):t)},t.QueryObserver=$,t.defaultContext=yt,t.dehydrate=function(t,e={}){const s=[],r=[];if(!1!==e.dehydrateMutations){const r=e.shouldDehydrateMutation||at;t.getMutationCache().getAll().forEach((t=>{r(t)&&s.push(function(t){return{mutationKey:t.options.mutationKey,state:t.state}}(t))}))}if(!1!==e.dehydrateQueries){const s=e.shouldDehydrateQuery||ut;t.getQueryCache().getAll().forEach((t=>{s(t)&&r.push(function(t){return{state:t.state,queryKey:t.queryKey,queryHash:t.queryHash}}(t))}))}return{mutations:s,queries:r}},t.focusManager=D,t.hashQueryKey=C,t.hydrate=ct,t.isCancelledError=k,t.isError=function(t){return t instanceof Error},t.isServer=c,t.notifyManager=H,t.onlineManager=U,t.parseFilterArgs=v,t.parseMutationArgs=y,t.parseMutationFilterArgs=m,t.parseQueryArgs=p,t.replaceEqualDeep=S,t.useHydrate=xt,t.useInfiniteQuery=function(t,e,s){return Mt(p(t,e,s),nt)},t.useIsFetching=function(t,e,s){const[r,i={}]=v(t,e,s),n=bt({context:i.context}),o=n.getQueryCache();return pt(a.useCallback((t=>o.subscribe(H.batchCalls(t))),[o]),(()=>n.isFetching(r)),(()=>n.isFetching(r)))},t.useIsMutating=function(t,e,s){const[r,i={}]=m(t,e,s),n=bt({context:i.context}),o=n.getMutationCache();return pt(a.useCallback((t=>o.subscribe(H.batchCalls(t))),[o]),(()=>n.isMutating(r)),(()=>n.isMutating(r)))},t.useIsRestoring=Ot,t.useMutation=function(t,e,s){const r=y(t,e,s),i=bt({context:r.context}),[n]=a.useState((()=>new ot(i,r)));a.useEffect((()=>{n.setOptions(r)}),[n,r]);const o=pt(a.useCallback((t=>n.subscribe(H.batchCalls(t))),[n]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),u=a.useCallback(((t,e)=>{n.mutate(t,e).catch(Ft)}),[n]);if(o.error&&Pt(n.options.useErrorBoundary,[o.error]))throw o.error;return{...o,mutate:u,mutateAsync:o.mutate}},t.useQueries=function({queries:t,context:e}){const s=bt({context:e}),r=Ot(),i=a.useMemo((()=>t.map((t=>{const e=s.defaultQueryOptions(t);return e._optimisticResults=r?"isRestoring":"optimistic",e}))),[t,s,r]),[n]=a.useState((()=>new it(s,i))),o=n.getOptimisticResult(i);pt(a.useCallback((t=>r?()=>{}:n.subscribe(H.batchCalls(t))),[n,r]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),a.useEffect((()=>{n.setQueries(i,{listeners:!1})}),[i,n]);const u=St();i.forEach((t=>{Et(t,u)})),Qt(u);const c=o.find(((t,e)=>{var s,r;return wt({result:t,errorResetBoundary:u,useErrorBoundary:null!=(s=null==(r=i[e])?void 0:r.useErrorBoundary)&&s,query:n.getQueries()[e]})}));if(null!=c&&c.error)throw c.error;return o},t.useQuery=function(t,e,s){return Mt(p(t,e,s),$)},t.useQueryClient=bt,t.useQueryErrorResetBoundary=St,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react-dom"),require("react")):"function"==typeof define&&define.amd?define(["exports","react-dom","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactQuery={},t.ReactDOM,t.React)}(this,(function(t,e,s){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}})),e.default=t,Object.freeze(e)}var n=i(e),o=r(s),a=i(s);class u{constructor(){this.listeners=[],this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.push(t),this.onSubscribe(),()=>{this.listeners=this.listeners.filter((e=>e!==t)),this.onUnsubscribe()}}hasListeners(){return this.listeners.length>0}onSubscribe(){}onUnsubscribe(){}}const c="undefined"==typeof window;function l(){}function h(t){return"number"==typeof t&&t>=0&&t!==1/0}function d(t,e){return t.filter((t=>-1===e.indexOf(t)))}function f(t,e){return Math.max(t+(e||0)-Date.now(),0)}function p(t,e,s){return M(t)?"function"==typeof e?{...s,queryKey:t,queryFn:e}:{...e,queryKey:t}:t}function y(t,e,s){return M(t)?"function"==typeof e?{...s,mutationKey:t,mutationFn:e}:{...e,mutationKey:t}:"function"==typeof t?{...e,mutationFn:t}:{...t}}function v(t,e,s){return M(t)?[{...e,queryKey:t},s]:[t||{},e]}function m(t,e,s){return M(t)?[{...e,mutationKey:t},s]:[t||{},e]}function b(t,e){const{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:o,stale:a}=t;if(M(o))if(r){if(e.queryHash!==O(o,e.options))return!1}else if(!C(e.queryKey,o))return!1;if("all"!==s){const t=e.isActive();if("active"===s&&!t)return!1;if("inactive"===s&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&((void 0===i||i===e.state.fetchStatus)&&!(n&&!n(e)))}function g(t,e){const{exact:s,fetching:r,predicate:i,mutationKey:n}=t;if(M(n)){if(!e.options.mutationKey)return!1;if(s){if(R(e.options.mutationKey)!==R(n))return!1}else if(!C(e.options.mutationKey,n))return!1}return("boolean"!=typeof r||"loading"===e.state.status===r)&&!(i&&!i(e))}function O(t,e){return((null==e?void 0:e.queryKeyHashFn)||R)(t)}function R(t){return JSON.stringify(t,((t,e)=>Q(e)?Object.keys(e).sort().reduce(((t,s)=>(t[s]=e[s],t)),{}):e))}function C(t,e){return q(t,e)}function q(t,e){return t===e||typeof t==typeof e&&(!(!t||!e||"object"!=typeof t||"object"!=typeof e)&&!Object.keys(e).some((s=>!q(t[s],e[s]))))}function S(t,e){if(t===e)return t;const s=E(t)&&E(e);if(s||Q(t)&&Q(e)){const r=s?t.length:Object.keys(t).length,i=s?e:Object.keys(e),n=i.length,o=s?[]:{};let a=0;for(let r=0;r<n;r++){const n=s?r:i[r];o[n]=S(t[n],e[n]),o[n]===t[n]&&a++}return r===n&&a===r?t:o}return e}function P(t,e){if(t&&!e||e&&!t)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function E(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Q(t){if(!w(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!w(s)&&!!s.hasOwnProperty("isPrototypeOf")}function w(t){return"[object Object]"===Object.prototype.toString.call(t)}function M(t){return Array.isArray(t)}function x(t){return new Promise((e=>{setTimeout(e,t)}))}function F(t){x(0).then(t)}function A(t,e,s){return null!=s.isDataEqual&&s.isDataEqual(t,e)?t:"function"==typeof s.structuralSharing?s.structuralSharing(t,e):!1!==s.structuralSharing?S(t,e):e}const D=new class extends u{constructor(){super(),this.setup=t=>{if(!c&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),window.addEventListener("focus",e,!1),()=>{window.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){this.focused=t,t&&this.onFocus()}onFocus(){this.listeners.forEach((t=>{t()}))}isFocused(){return"boolean"==typeof this.focused?this.focused:"undefined"==typeof document||[void 0,"visible","prerender"].includes(document.visibilityState)}};const U=new class extends u{constructor(){super(),this.setup=t=>{if(!c&&window.addEventListener){const e=()=>t();return window.addEventListener("online",e,!1),window.addEventListener("offline",e,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){var t;this.hasListeners()||(null==(t=this.cleanup)||t.call(this),this.cleanup=void 0)}setEventListener(t){var e;this.setup=t,null==(e=this.cleanup)||e.call(this),this.cleanup=t((t=>{"boolean"==typeof t?this.setOnline(t):this.onOnline()}))}setOnline(t){this.online=t,t&&this.onOnline()}onOnline(){this.listeners.forEach((t=>{t()}))}isOnline(){return"boolean"==typeof this.online?this.online:"undefined"==typeof navigator||void 0===navigator.onLine||navigator.onLine}};function I(t){return Math.min(1e3*2**t,3e4)}function T(t){return"online"!==(null!=t?t:"online")||U.isOnline()}class K{constructor(t){this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}}function k(t){return t instanceof K}function L(t){let e,s,r,i=!1,n=0,o=!1;const a=new Promise(((t,e)=>{s=t,r=e})),u=()=>!D.isFocused()||"always"!==t.networkMode&&!U.isOnline(),c=r=>{o||(o=!0,null==t.onSuccess||t.onSuccess(r),null==e||e(),s(r))},l=s=>{o||(o=!0,null==t.onError||t.onError(s),null==e||e(),r(s))},h=()=>new Promise((s=>{e=t=>{if(o||!u())return s(t)},null==t.onPause||t.onPause()})).then((()=>{e=void 0,o||null==t.onContinue||t.onContinue()})),d=()=>{if(o)return;let e;try{e=t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(c).catch((e=>{var s,r;if(o)return;const a=null!=(s=t.retry)?s:3,c=null!=(r=t.retryDelay)?r:I,f="function"==typeof c?c(n,e):c,p=!0===a||"number"==typeof a&&n<a||"function"==typeof a&&a(n,e);!i&&p?(n++,null==t.onFail||t.onFail(n,e),x(f).then((()=>{if(u())return h()})).then((()=>{i?l(e):d()}))):l(e)}))};return T(t.networkMode)?d():h().then(d),{promise:a,cancel:e=>{o||(l(new K(e)),null==t.abort||t.abort())},continue:()=>{null==e||e()},cancelRetry:()=>{i=!0},continueRetry:()=>{i=!1}}}const j=console;const H=function(){let t=[],e=0,s=t=>{t()},r=t=>{t()};const i=r=>{e?t.push(r):F((()=>{s(r)}))},n=()=>{const e=t;t=[],e.length&&F((()=>{r((()=>{e.forEach((t=>{s(t)}))}))}))};return{batch:t=>{let s;e++;try{s=t()}finally{e--,e||n()}return s},batchCalls:t=>(...e)=>{i((()=>{t(...e)}))},schedule:i,setNotifyFunction:t=>{s=t},setBatchNotifyFunction:t=>{r=t}}}();class B{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),h(this.cacheTime)&&(this.gcTimeout=setTimeout((()=>{this.optionalRemove()}),this.cacheTime))}updateCacheTime(t){this.cacheTime=Math.max(this.cacheTime||0,null!=t?t:c?1/0:3e5)}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class N extends B{constructor(t){super(),this.abortSignalConsumed=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.logger=t.logger||j,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||function(t){const e="function"==typeof t.initialData?t.initialData():t.initialData,s=void 0!==e,r=s?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:s?null!=r?r:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"loading",fetchStatus:"idle"}}(this.options),this.state=this.initialState}get meta(){return this.options.meta}setOptions(t){this.options={...this.defaultOptions,...t},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.cache.remove(this)}setData(t,e){const s=A(this.state.data,t,this.options);return this.dispatch({data:s,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),s}setState(t,e){this.dispatch({type:"setState",state:t,setStateOptions:e})}cancel(t){var e;const s=this.promise;return null==(e=this.retryer)||e.cancel(t),s?s.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some((t=>!1!==t.options.enabled))}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some((t=>t.getCurrentResult().isStale))}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!f(this.state.dataUpdatedAt,t)}onFocus(){var t;const e=this.observers.find((t=>t.shouldFetchOnWindowFocus()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}onOnline(){var t;const e=this.observers.find((t=>t.shouldFetchOnReconnect()));e&&e.refetch({cancelRefetch:!1}),null==(t=this.retryer)||t.continue()}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){-1!==this.observers.indexOf(t)&&(this.observers=this.observers.filter((e=>e!==t)),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(t,e){var s,r;if("idle"!==this.state.fetchStatus)if(this.state.dataUpdatedAt&&null!=e&&e.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var i;return null==(i=this.retryer)||i.continueRetry(),this.promise}if(t&&this.setOptions(t),!this.options.queryFn){const t=this.observers.find((t=>t.options.queryFn));t&&this.setOptions(t.options)}Array.isArray(this.options.queryKey);const n=function(){if("function"==typeof AbortController)return new AbortController}(),o={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},a=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>{if(n)return this.abortSignalConsumed=!0,n.signal}})};a(o);const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(o)):Promise.reject("Missing queryFn")};var c;(a(u),null==(s=this.options.behavior)||s.onFetch(u),this.revertState=this.state,"idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(r=u.fetchOptions)?void 0:r.meta))&&this.dispatch({type:"fetch",meta:null==(c=u.fetchOptions)?void 0:c.meta});const l=t=>{var e,s;(k(t)&&t.silent||this.dispatch({type:"error",error:t}),k(t))||(null==(e=(s=this.cache.config).onError)||e.call(s,t,this));this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=L({fn:u.fetchFn,abort:null==n?void 0:n.abort.bind(n),onSuccess:t=>{var e,s;void 0!==t?(this.setData(t),null==(e=(s=this.cache.config).onSuccess)||e.call(s,t,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1):l(new Error("undefined"))},onError:l,onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(t){this.state=(e=>{var s,r;switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null!=(s=t.meta)?s:null,fetchStatus:T(this.options.networkMode)?"fetching":"paused",...!e.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(r=t.dataUpdatedAt)?r:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const i=t.error;return k(i)&&i.revert&&this.revertState?{...this.revertState}:{...e,error:i,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}})(this.state),H.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate(t)})),this.cache.notify({query:this,type:"updated",action:t})}))}}class _ extends u{constructor(t){super(),this.config=t||{},this.queries=[],this.queriesMap={}}build(t,e,s){var r;const i=e.queryKey,n=null!=(r=e.queryHash)?r:O(i,e);let o=this.get(n);return o||(o=new N({cache:this,logger:t.getLogger(),queryKey:i,queryHash:n,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){this.queriesMap[t.queryHash]||(this.queriesMap[t.queryHash]=t,this.queries.push(t),this.notify({type:"added",query:t}))}remove(t){const e=this.queriesMap[t.queryHash];e&&(t.destroy(),this.queries=this.queries.filter((e=>e!==t)),e===t&&delete this.queriesMap[t.queryHash],this.notify({type:"removed",query:t}))}clear(){H.batch((()=>{this.queries.forEach((t=>{this.remove(t)}))}))}get(t){return this.queriesMap[t]}getAll(){return this.queries}find(t,e){const[s]=v(t,e);return void 0===s.exact&&(s.exact=!0),this.queries.find((t=>b(s,t)))}findAll(t,e){const[s]=v(t,e);return Object.keys(s).length>0?this.queries.filter((t=>b(s,t))):this.queries}notify(t){H.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}onFocus(){H.batch((()=>{this.queries.forEach((t=>{t.onFocus()}))}))}onOnline(){H.batch((()=>{this.queries.forEach((t=>{t.onOnline()}))}))}}class G extends B{constructor(t){super(),this.options={...t.defaultOptions,...t.options},this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.logger=t.logger||j,this.observers=[],this.state=t.state||W(),this.updateCacheTime(this.options.cacheTime),this.scheduleGc()}get meta(){return this.options.meta}setState(t){this.dispatch({type:"setState",state:t})}addObserver(t){-1===this.observers.indexOf(t)&&(this.observers.push(t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.observers=this.observers.filter((e=>e!==t)),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.observers.length||("loading"===this.state.status?this.scheduleGc():this.mutationCache.remove(this))}continue(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()}async execute(){const t=()=>{var t;return this.retryer=L({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(t,e)=>{this.dispatch({type:"failed",failureCount:t,error:e})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:null!=(t=this.options.retry)?t:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},e="loading"===this.state.status;try{var s,r,i,n,o,a;if(!e){var u,c,l,h;this.dispatch({type:"loading",variables:this.options.variables}),await(null==(u=(c=this.mutationCache.config).onMutate)?void 0:u.call(c,this.state.variables,this));const t=await(null==(l=(h=this.options).onMutate)?void 0:l.call(h,this.state.variables));t!==this.state.context&&this.dispatch({type:"loading",context:t,variables:this.state.variables})}const d=await t();return await(null==(s=(r=this.mutationCache.config).onSuccess)?void 0:s.call(r,d,this.state.variables,this.state.context,this)),await(null==(i=(n=this.options).onSuccess)?void 0:i.call(n,d,this.state.variables,this.state.context)),await(null==(o=(a=this.options).onSettled)?void 0:o.call(a,d,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:d}),d}catch(t){try{var d,f,p,y,v,m;throw await(null==(d=(f=this.mutationCache.config).onError)?void 0:d.call(f,t,this.state.variables,this.state.context,this)),await(null==(p=(y=this.options).onError)?void 0:p.call(y,t,this.state.variables,this.state.context)),await(null==(v=(m=this.options).onSettled)?void 0:v.call(m,void 0,t,this.state.variables,this.state.context)),t}finally{this.dispatch({type:"error",error:t})}}}dispatch(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"loading":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!T(this.options.networkMode),status:"loading",variables:t.variables};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"};case"setState":return{...e,...t.state}}})(this.state),H.batch((()=>{this.observers.forEach((e=>{e.onMutationUpdate(t)})),this.mutationCache.notify({mutation:this,type:"updated",action:t})}))}}function W(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class z extends u{constructor(t){super(),this.config=t||{},this.mutations=[],this.mutationId=0}build(t,e,s){const r=new G({mutationCache:this,logger:t.getLogger(),mutationId:++this.mutationId,options:t.defaultMutationOptions(e),state:s,defaultOptions:e.mutationKey?t.getMutationDefaults(e.mutationKey):void 0});return this.add(r),r}add(t){this.mutations.push(t),this.notify({type:"added",mutation:t})}remove(t){this.mutations=this.mutations.filter((e=>e!==t)),this.notify({type:"removed",mutation:t})}clear(){H.batch((()=>{this.mutations.forEach((t=>{this.remove(t)}))}))}getAll(){return this.mutations}find(t){return void 0===t.exact&&(t.exact=!0),this.mutations.find((e=>g(t,e)))}findAll(t){return this.mutations.filter((e=>g(t,e)))}notify(t){H.batch((()=>{this.listeners.forEach((e=>{e(t)}))}))}resumePausedMutations(){const t=this.mutations.filter((t=>t.state.isPaused));return H.batch((()=>t.reduce(((t,e)=>t.then((()=>e.continue().catch(l)))),Promise.resolve())))}}function J(){return{onFetch:t=>{t.fetchFn=()=>{var e,s,r,i,n,o;const a=null==(e=t.fetchOptions)||null==(s=e.meta)?void 0:s.refetchPage,u=null==(r=t.fetchOptions)||null==(i=r.meta)?void 0:i.fetchMore,c=null==u?void 0:u.pageParam,l="forward"===(null==u?void 0:u.direction),h="backward"===(null==u?void 0:u.direction),d=(null==(n=t.state.data)?void 0:n.pages)||[],f=(null==(o=t.state.data)?void 0:o.pageParams)||[];let p=f,y=!1;const v=t.options.queryFn||(()=>Promise.reject("Missing queryFn")),m=(t,e,s,r)=>(p=r?[e,...p]:[...p,e],r?[s,...t]:[...t,s]),b=(e,s,r,i)=>{if(y)return Promise.reject("Cancelled");if(void 0===r&&!s&&e.length)return Promise.resolve(e);const n={queryKey:t.queryKey,pageParam:r,meta:t.options.meta};var o;o=n,Object.defineProperty(o,"signal",{enumerable:!0,get:()=>{var e,s;return null!=(e=t.signal)&&e.aborted?y=!0:null==(s=t.signal)||s.addEventListener("abort",(()=>{y=!0})),t.signal}});const a=v(n);return Promise.resolve(a).then((t=>m(e,r,t,i)))};let g;if(d.length)if(l){const e=void 0!==c,s=e?c:V(t.options,d);g=b(d,e,s)}else if(h){const e=void 0!==c,s=e?c:X(t.options,d);g=b(d,e,s,!0)}else{p=[];const e=void 0===t.options.getNextPageParam;g=!a||!d[0]||a(d[0],0,d)?b([],e,f[0]):Promise.resolve(m([],f[0],d[0]));for(let s=1;s<d.length;s++)g=g.then((r=>{if(!a||!d[s]||a(d[s],s,d)){const i=e?f[s]:V(t.options,r);return b(r,e,i)}return Promise.resolve(m(r,f[s],d[s]))}))}else g=b([]);return g.then((t=>({pages:t,pageParams:p})))}}}}function V(t,e){return null==t.getNextPageParam?void 0:t.getNextPageParam(e[e.length-1],e)}function X(t,e){return null==t.getPreviousPageParam?void 0:t.getPreviousPageParam(e[0],e)}function Y(t,e){if(t.getNextPageParam&&Array.isArray(e)){const s=V(t,e);return null!=s&&!1!==s}}function Z(t,e){if(t.getPreviousPageParam&&Array.isArray(e)){const s=X(t,e);return null!=s&&!1!==s}}class $ extends u{constructor(t,e){super(),this.client=t,this.options=e,this.trackedProps=new Set,this.selectError=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.length&&(this.currentQuery.addObserver(this),tt(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())}onUnsubscribe(){this.listeners.length||this.destroy()}shouldFetchOnReconnect(){return et(this.currentQuery,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return et(this.currentQuery,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=[],this.clearStaleTimeout(),this.clearRefetchInterval(),this.currentQuery.removeObserver(this)}setOptions(t,e){const s=this.options,r=this.currentQuery;if(this.options=this.client.defaultQueryOptions(t),P(s,this.options)||this.client.getQueryCache().notify({type:"observerOptionsUpdated",query:this.currentQuery,observer:this}),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=s.queryKey),this.updateQuery();const i=this.hasListeners();i&&st(this.currentQuery,r,this.options,s)&&this.executeFetch(),this.updateResult(e),!i||this.currentQuery===r&&this.options.enabled===s.enabled&&this.options.staleTime===s.staleTime||this.updateStaleTimeout();const n=this.computeRefetchInterval();!i||this.currentQuery===r&&this.options.enabled===s.enabled&&n===this.currentRefetchInterval||this.updateRefetchInterval(n)}getOptimisticResult(t){const e=this.client.getQueryCache().build(this.client,t);return this.createResult(e,t)}getCurrentResult(){return this.currentResult}trackResult(t){const e={};return Object.keys(t).forEach((s=>{Object.defineProperty(e,s,{configurable:!1,enumerable:!0,get:()=>(this.trackedProps.add(s),t[s])})})),e}getCurrentQuery(){return this.currentQuery}remove(){this.client.getQueryCache().remove(this.currentQuery)}refetch({refetchPage:t,...e}={}){return this.fetch({...e,meta:{refetchPage:t}})}fetchOptimistic(t){const e=this.client.defaultQueryOptions(t),s=this.client.getQueryCache().build(this.client,e);return s.isFetchingOptimistic=!0,s.fetch().then((()=>this.createResult(s,e)))}fetch(t){var e;return this.executeFetch({...t,cancelRefetch:null==(e=t.cancelRefetch)||e}).then((()=>(this.updateResult(),this.currentResult)))}executeFetch(t){this.updateQuery();let e=this.currentQuery.fetch(this.options,t);return null!=t&&t.throwOnError||(e=e.catch(l)),e}updateStaleTimeout(){if(this.clearStaleTimeout(),c||this.currentResult.isStale||!h(this.options.staleTime))return;const t=f(this.currentResult.dataUpdatedAt,this.options.staleTime)+1;this.staleTimeoutId=setTimeout((()=>{this.currentResult.isStale||this.updateResult()}),t)}computeRefetchInterval(){var t;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(t=this.options.refetchInterval)&&t}updateRefetchInterval(t){this.clearRefetchInterval(),this.currentRefetchInterval=t,!c&&!1!==this.options.enabled&&h(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval((()=>{(this.options.refetchIntervalInBackground||D.isFocused())&&this.executeFetch()}),this.currentRefetchInterval))}updateTimers(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())}clearStaleTimeout(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)}clearRefetchInterval(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)}createResult(t,e){const s=this.currentQuery,r=this.options,i=this.currentResult,n=this.currentResultState,o=this.currentResultOptions,a=t!==s,u=a?t.state:this.currentQueryInitialState,c=a?this.currentResult:this.previousQueryResult,{state:l}=t;let h,{dataUpdatedAt:d,error:f,errorUpdatedAt:p,fetchStatus:y,status:v}=l,m=!1,b=!1;if(e._optimisticResults){const i=this.hasListeners(),n=!i&&tt(t,e),o=i&&st(t,s,e,r);(n||o)&&(y=T(t.options.networkMode)?"fetching":"paused",d||(v="loading")),"isRestoring"===e._optimisticResults&&(y="idle")}if(e.keepPreviousData&&!l.dataUpdatedAt&&null!=c&&c.isSuccess&&"error"!==v)h=c.data,d=c.dataUpdatedAt,v=c.status,m=!0;else if(e.select&&void 0!==l.data)if(i&&l.data===(null==n?void 0:n.data)&&e.select===this.selectFn)h=this.selectResult;else try{this.selectFn=e.select,h=e.select(l.data),h=A(null==i?void 0:i.data,h,e),this.selectResult=h,this.selectError=null}catch(t){this.selectError=t}else h=l.data;if(void 0!==e.placeholderData&&void 0===h&&"loading"===v){let t;if(null!=i&&i.isPlaceholderData&&e.placeholderData===(null==o?void 0:o.placeholderData))t=i.data;else if(t="function"==typeof e.placeholderData?e.placeholderData():e.placeholderData,e.select&&void 0!==t)try{t=e.select(t),this.selectError=null}catch(t){this.selectError=t}void 0!==t&&(v="success",h=A(null==i?void 0:i.data,t,e),b=!0)}this.selectError&&(f=this.selectError,h=this.selectResult,p=Date.now(),v="error");const g="fetching"===y,O="loading"===v,R="error"===v;return{status:v,fetchStatus:y,isLoading:O,isSuccess:"success"===v,isError:R,isInitialLoading:O&&g,data:h,dataUpdatedAt:d,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>u.dataUpdateCount||l.errorUpdateCount>u.errorUpdateCount,isFetching:g,isRefetching:g&&!O,isLoadingError:R&&0===l.dataUpdatedAt,isPaused:"paused"===y,isPlaceholderData:b,isPreviousData:m,isRefetchError:R&&0!==l.dataUpdatedAt,isStale:rt(t,e),refetch:this.refetch,remove:this.remove}}updateResult(t){const e=this.currentResult,s=this.createResult(this.currentQuery,this.options);if(this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,P(s,e))return;this.currentResult=s;const r={cache:!0};!1!==(null==t?void 0:t.listeners)&&(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options;if("all"===t||!t&&!this.trackedProps.size)return!0;const s=new Set(null!=t?t:this.trackedProps);return this.options.useErrorBoundary&&s.add("error"),Object.keys(this.currentResult).some((t=>{const r=t;return this.currentResult[r]!==e[r]&&s.has(r)}))})()&&(r.listeners=!0),this.notify({...r,...t})}updateQuery(){const t=this.client.getQueryCache().build(this.client,this.options);if(t===this.currentQuery)return;const e=this.currentQuery;this.currentQuery=t,this.currentQueryInitialState=t.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==e||e.removeObserver(this),t.addObserver(this))}onQueryUpdate(t){const e={};"success"===t.type?e.onSuccess=!t.manual:"error"!==t.type||k(t.error)||(e.onError=!0),this.updateResult(e),this.hasListeners()&&this.updateTimers()}notify(t){H.batch((()=>{var e,s,r,i;if(t.onSuccess)null==(e=(s=this.options).onSuccess)||e.call(s,this.currentResult.data),null==(r=(i=this.options).onSettled)||r.call(i,this.currentResult.data,null);else if(t.onError){var n,o,a,u;null==(n=(o=this.options).onError)||n.call(o,this.currentResult.error),null==(a=(u=this.options).onSettled)||a.call(u,void 0,this.currentResult.error)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)})),t.cache&&this.client.getQueryCache().notify({query:this.currentQuery,type:"observerResultsUpdated"})}))}}function tt(t,e){return function(t,e){return!(!1===e.enabled||t.state.dataUpdatedAt||"error"===t.state.status&&!1===e.retryOnMount)}(t,e)||t.state.dataUpdatedAt>0&&et(t,e,e.refetchOnMount)}function et(t,e,s){if(!1!==e.enabled){const r="function"==typeof s?s(t):s;return"always"===r||!1!==r&&rt(t,e)}return!1}function st(t,e,s,r){return!1!==s.enabled&&(t!==e||!1===r.enabled)&&(!s.suspense||"error"!==t.state.status)&&rt(t,s)}function rt(t,e){return t.isStaleByTime(e.staleTime)}class it extends u{constructor(t,e){super(),this.client=t,this.queries=[],this.result=[],this.observers=[],this.observersMap={},e&&this.setQueries(e)}onSubscribe(){1===this.listeners.length&&this.observers.forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))}))}onUnsubscribe(){this.listeners.length||this.destroy()}destroy(){this.listeners=[],this.observers.forEach((t=>{t.destroy()}))}setQueries(t,e){this.queries=t,H.batch((()=>{const t=this.observers,s=this.findMatchingObservers(this.queries);s.forEach((t=>t.observer.setOptions(t.defaultedQueryOptions,e)));const r=s.map((t=>t.observer)),i=Object.fromEntries(r.map((t=>[t.options.queryHash,t]))),n=r.map((t=>t.getCurrentResult())),o=r.some(((e,s)=>e!==t[s]));(t.length!==r.length||o)&&(this.observers=r,this.observersMap=i,this.result=n,this.hasListeners()&&(d(t,r).forEach((t=>{t.destroy()})),d(r,t).forEach((t=>{t.subscribe((e=>{this.onUpdate(t,e)}))})),this.notify()))}))}getCurrentResult(){return this.result}getQueries(){return this.observers.map((t=>t.getCurrentQuery()))}getOptimisticResult(t){return this.findMatchingObservers(t).map((t=>t.observer.getOptimisticResult(t.defaultedQueryOptions)))}findMatchingObservers(t){const e=this.observers,s=t.map((t=>this.client.defaultQueryOptions(t))),r=s.flatMap((t=>{const s=e.find((e=>e.options.queryHash===t.queryHash));return null!=s?[{defaultedQueryOptions:t,observer:s}]:[]})),i=r.map((t=>t.defaultedQueryOptions.queryHash)),n=s.filter((t=>!i.includes(t.queryHash))),o=e.filter((t=>!r.some((e=>e.observer===t)))),a=t=>{const e=this.client.defaultQueryOptions(t),s=this.observersMap[e.queryHash];return null!=s?s:new $(this.client,e)},u=n.map(((t,e)=>{if(t.keepPreviousData){const s=o[e];if(void 0!==s)return{defaultedQueryOptions:t,observer:s}}return{defaultedQueryOptions:t,observer:a(t)}}));return r.concat(u).sort(((t,e)=>s.indexOf(t.defaultedQueryOptions)-s.indexOf(e.defaultedQueryOptions)))}onUpdate(t,e){const s=this.observers.indexOf(t);-1!==s&&(this.result=function(t,e,s){const r=t.slice(0);return r[e]=s,r}(this.result,s,e),this.notify())}notify(){H.batch((()=>{this.listeners.forEach((t=>{t(this.result)}))}))}}class nt extends ${constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t,e){super.setOptions({...t,behavior:J()},e)}getOptimisticResult(t){return t.behavior=J(),super.getOptimisticResult(t)}fetchNextPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"forward",pageParam:t}}})}fetchPreviousPage({pageParam:t,...e}={}){return this.fetch({...e,meta:{fetchMore:{direction:"backward",pageParam:t}}})}createResult(t,e){var s,r,i,n,o,a;const{state:u}=t,c=super.createResult(t,e),{isFetching:l,isRefetching:h}=c,d=l&&"forward"===(null==(s=u.fetchMeta)||null==(r=s.fetchMore)?void 0:r.direction),f=l&&"backward"===(null==(i=u.fetchMeta)||null==(n=i.fetchMore)?void 0:n.direction);return{...c,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Y(e,null==(o=u.data)?void 0:o.pages),hasPreviousPage:Z(e,null==(a=u.data)?void 0:a.pages),isFetchingNextPage:d,isFetchingPreviousPage:f,isRefetching:h&&!d&&!f}}}class ot extends u{constructor(t,e){super(),this.client=t,this.setOptions(e),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.client.defaultMutationOptions(t),P(e,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){var t;this.listeners.length||(null==(t=this.currentMutation)||t.removeObserver(this))}onMutationUpdate(t){this.updateResult();const e={listeners:!0};"success"===t.type?e.onSuccess=!0:"error"===t.type&&(e.onError=!0),this.notify(e)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(t,e){return this.mutateOptions=e,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:void 0!==t?t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const t=this.currentMutation?this.currentMutation.state:{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0},e={...t,isLoading:"loading"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset};this.currentResult=e}notify(t){H.batch((()=>{var e,s,r,i;if(this.mutateOptions)if(t.onSuccess)null==(e=(s=this.mutateOptions).onSuccess)||e.call(s,this.currentResult.data,this.currentResult.variables,this.currentResult.context),null==(r=(i=this.mutateOptions).onSettled)||r.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context);else if(t.onError){var n,o,a,u;null==(n=(o=this.mutateOptions).onError)||n.call(o,this.currentResult.error,this.currentResult.variables,this.currentResult.context),null==(a=(u=this.mutateOptions).onSettled)||a.call(u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}t.listeners&&this.listeners.forEach((t=>{t(this.currentResult)}))}))}}function at(t){return t.state.isPaused}function ut(t){return"success"===t.state.status}function ct(t,e,s){if("object"!=typeof e||null===e)return;const r=t.getMutationCache(),i=t.getQueryCache(),n=e.mutations||[],o=e.queries||[];n.forEach((e=>{var i;r.build(t,{...null==s||null==(i=s.defaultOptions)?void 0:i.mutations,mutationKey:e.mutationKey},e.state)})),o.forEach((e=>{var r;const n=i.get(e.queryHash);n?n.state.dataUpdatedAt<e.state.dataUpdatedAt&&n.setState(e.state):i.build(t,{...null==s||null==(r=s.defaultOptions)?void 0:r.queries,queryKey:e.queryKey,queryHash:e.queryHash},e.state)}))}const lt=n.unstable_batchedUpdates;H.setBatchNotifyFunction(lt);var ht,dt={exports:{}},ft={};!function(t){t.exports=function(){if(ht)return ft;ht=1;var t=o.default,e="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=t.useState,r=t.useEffect,i=t.useLayoutEffect,n=t.useDebugValue;function a(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!e(t,r)}catch(t){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var o=e(),u=s({inst:{value:o,getSnapshot:e}}),c=u[0].inst,l=u[1];return i((function(){c.value=o,c.getSnapshot=e,a(c)&&l({inst:c})}),[t,o,e]),r((function(){return a(c)&&l({inst:c}),t((function(){a(c)&&l({inst:c})}))}),[t]),n(o),o};return ft.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:u,ft}()}(dt);const pt=dt.exports.useSyncExternalStore,yt=a.createContext(void 0),vt=a.createContext(!1);function mt(t,e){return t||(e&&"undefined"!=typeof window?(window.ReactQueryClientContext||(window.ReactQueryClientContext=yt),window.ReactQueryClientContext):yt)}const bt=({context:t}={})=>{const e=a.useContext(mt(t,a.useContext(vt)));if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},gt=a.createContext(!1),Ot=()=>a.useContext(gt),Rt=gt.Provider;function Ct(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const qt=a.createContext(Ct()),St=()=>a.useContext(qt);function Pt(t,e){return"function"==typeof t?t(...e):!!t}const Et=(t,e)=>{(t.suspense||t.useErrorBoundary)&&(e.isReset()||(t.retryOnMount=!1))},Qt=t=>{a.useEffect((()=>{t.clearReset()}),[t])},wt=({result:t,errorResetBoundary:e,useErrorBoundary:s,query:r})=>t.isError&&!e.isReset()&&!t.isFetching&&Pt(s,[t.error,r]);function Mt(t,e){const s=bt({context:t.context}),r=Ot(),i=St(),n=s.defaultQueryOptions(t);n._optimisticResults=r?"isRestoring":"optimistic",n.onError&&(n.onError=H.batchCalls(n.onError)),n.onSuccess&&(n.onSuccess=H.batchCalls(n.onSuccess)),n.onSettled&&(n.onSettled=H.batchCalls(n.onSettled)),n.suspense&&"number"!=typeof n.staleTime&&(n.staleTime=1e3),Et(n,i),Qt(i);const[o]=a.useState((()=>new e(s,n))),u=o.getOptimisticResult(n);if(pt(a.useCallback((t=>r?()=>{}:o.subscribe(H.batchCalls(t))),[o,r]),(()=>o.getCurrentResult()),(()=>o.getCurrentResult())),a.useEffect((()=>{o.setOptions(n,{listeners:!1})}),[n,o]),n.suspense&&u.isLoading&&u.isFetching&&!r)throw o.fetchOptimistic(n).then((({data:t})=>{null==n.onSuccess||n.onSuccess(t),null==n.onSettled||n.onSettled(t,null)})).catch((t=>{i.clearReset(),null==n.onError||n.onError(t),null==n.onSettled||n.onSettled(void 0,t)}));if(wt({result:u,errorResetBoundary:i,useErrorBoundary:n.useErrorBoundary,query:o.getCurrentQuery()}))throw u.error;return n.notifyOnChangeProps?u:o.trackResult(u)}function xt(t,e={}){const s=bt({context:e.context}),r=a.useRef(e);r.current=e,a.useMemo((()=>{t&&ct(s,t,r.current)}),[s,t])}function Ft(){}t.CancelledError=K,t.Hydrate=({children:t,options:e,state:s})=>(xt(s,e),t),t.InfiniteQueryObserver=nt,t.IsRestoringProvider=Rt,t.MutationCache=z,t.MutationObserver=ot,t.QueriesObserver=it,t.QueryCache=_,t.QueryClient=class{constructor(t={}){this.queryCache=t.queryCache||new _,this.mutationCache=t.mutationCache||new z,this.logger=t.logger||j,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}mount(){this.unsubscribeFocus=D.subscribe((()=>{D.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())})),this.unsubscribeOnline=U.subscribe((()=>{U.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var t,e;null==(t=this.unsubscribeFocus)||t.call(this),null==(e=this.unsubscribeOnline)||e.call(this)}isFetching(t,e){const[s]=v(t,e);return s.fetchStatus="fetching",this.queryCache.findAll(s).length}isMutating(t){return this.mutationCache.findAll({...t,fetching:!0}).length}getQueryData(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state.data}getQueriesData(t){return this.getQueryCache().findAll(t).map((({queryKey:t,state:e})=>[t,e.data]))}setQueryData(t,e,s){const r=this.queryCache.find(t),i=function(t,e){return"function"==typeof t?t(e):t}(e,null==r?void 0:r.state.data);if(void 0===i)return;const n=p(t),o=this.defaultQueryOptions(n);return this.queryCache.build(this,o).setData(i,{...s,manual:!0})}setQueriesData(t,e,s){return H.batch((()=>this.getQueryCache().findAll(t).map((({queryKey:t})=>[t,this.setQueryData(t,e,s)]))))}getQueryState(t,e){var s;return null==(s=this.queryCache.find(t,e))?void 0:s.state}removeQueries(t,e){const[s]=v(t,e),r=this.queryCache;H.batch((()=>{r.findAll(s).forEach((t=>{r.remove(t)}))}))}resetQueries(t,e,s){const[r,i]=v(t,e,s),n=this.queryCache,o={type:"active",...r};return H.batch((()=>(n.findAll(r).forEach((t=>{t.reset()})),this.refetchQueries(o,i))))}cancelQueries(t,e,s){const[r,i={}]=v(t,e,s);void 0===i.revert&&(i.revert=!0);const n=H.batch((()=>this.queryCache.findAll(r).map((t=>t.cancel(i)))));return Promise.all(n).then(l).catch(l)}invalidateQueries(t,e,s){const[r,i]=v(t,e,s);return H.batch((()=>{var t,e;if(this.queryCache.findAll(r).forEach((t=>{t.invalidate()})),"none"===r.refetchType)return Promise.resolve();const s={...r,type:null!=(t=null!=(e=r.refetchType)?e:r.type)?t:"active"};return this.refetchQueries(s,i)}))}refetchQueries(t,e,s){const[r,i]=v(t,e,s),n=H.batch((()=>this.queryCache.findAll(r).filter((t=>!t.isDisabled())).map((t=>{var e;return t.fetch(void 0,{...i,cancelRefetch:null==(e=null==i?void 0:i.cancelRefetch)||e,meta:{refetchPage:r.refetchPage}})}))));let o=Promise.all(n).then(l);return null!=i&&i.throwOnError||(o=o.catch(l)),o}fetchQuery(t,e,s){const r=p(t,e,s),i=this.defaultQueryOptions(r);void 0===i.retry&&(i.retry=!1);const n=this.queryCache.build(this,i);return n.isStaleByTime(i.staleTime)?n.fetch(i):Promise.resolve(n.state.data)}prefetchQuery(t,e,s){return this.fetchQuery(t,e,s).then(l).catch(l)}fetchInfiniteQuery(t,e,s){const r=p(t,e,s);return r.behavior=J(),this.fetchQuery(r)}prefetchInfiniteQuery(t,e,s){return this.fetchInfiniteQuery(t,e,s).then(l).catch(l)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(t){this.defaultOptions=t}setQueryDefaults(t,e){const s=this.queryDefaults.find((e=>R(t)===R(e.queryKey)));s?s.defaultOptions=e:this.queryDefaults.push({queryKey:t,defaultOptions:e})}getQueryDefaults(t){if(!t)return;const e=this.queryDefaults.find((e=>C(t,e.queryKey)));return null==e?void 0:e.defaultOptions}setMutationDefaults(t,e){const s=this.mutationDefaults.find((e=>R(t)===R(e.mutationKey)));s?s.defaultOptions=e:this.mutationDefaults.push({mutationKey:t,defaultOptions:e})}getMutationDefaults(t){if(!t)return;const e=this.mutationDefaults.find((e=>C(t,e.mutationKey)));return null==e?void 0:e.defaultOptions}defaultQueryOptions(t){if(null!=t&&t._defaulted)return t;const e={...this.defaultOptions.queries,...this.getQueryDefaults(null==t?void 0:t.queryKey),...t,_defaulted:!0};return!e.queryHash&&e.queryKey&&(e.queryHash=O(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.useErrorBoundary&&(e.useErrorBoundary=!!e.suspense),e}defaultMutationOptions(t){return null!=t&&t._defaulted?t:{...this.defaultOptions.mutations,...this.getMutationDefaults(null==t?void 0:t.mutationKey),...t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}},t.QueryClientProvider=({client:t,children:e,context:s,contextSharing:r=!1})=>{a.useEffect((()=>(t.mount(),()=>{t.unmount()})),[t]);const i=mt(s,r);return a.createElement(vt.Provider,{value:!s&&r},a.createElement(i.Provider,{value:t},e))},t.QueryErrorResetBoundary=({children:t})=>{const[e]=a.useState((()=>Ct()));return a.createElement(qt.Provider,{value:e},"function"==typeof t?t(e):t)},t.QueryObserver=$,t.defaultContext=yt,t.dehydrate=function(t,e={}){const s=[],r=[];if(!1!==e.dehydrateMutations){const r=e.shouldDehydrateMutation||at;t.getMutationCache().getAll().forEach((t=>{r(t)&&s.push(function(t){return{mutationKey:t.options.mutationKey,state:t.state}}(t))}))}if(!1!==e.dehydrateQueries){const s=e.shouldDehydrateQuery||ut;t.getQueryCache().getAll().forEach((t=>{s(t)&&r.push(function(t){return{state:t.state,queryKey:t.queryKey,queryHash:t.queryHash}}(t))}))}return{mutations:s,queries:r}},t.focusManager=D,t.hashQueryKey=R,t.hydrate=ct,t.isCancelledError=k,t.isError=function(t){return t instanceof Error},t.isServer=c,t.notifyManager=H,t.onlineManager=U,t.parseFilterArgs=v,t.parseMutationArgs=y,t.parseMutationFilterArgs=m,t.parseQueryArgs=p,t.replaceEqualDeep=S,t.useHydrate=xt,t.useInfiniteQuery=function(t,e,s){return Mt(p(t,e,s),nt)},t.useIsFetching=function(t,e,s){const[r,i={}]=v(t,e,s),n=bt({context:i.context}),o=n.getQueryCache();return pt(a.useCallback((t=>o.subscribe(H.batchCalls(t))),[o]),(()=>n.isFetching(r)),(()=>n.isFetching(r)))},t.useIsMutating=function(t,e,s){const[r,i={}]=m(t,e,s),n=bt({context:i.context}),o=n.getMutationCache();return pt(a.useCallback((t=>o.subscribe(H.batchCalls(t))),[o]),(()=>n.isMutating(r)),(()=>n.isMutating(r)))},t.useIsRestoring=Ot,t.useMutation=function(t,e,s){const r=y(t,e,s),i=bt({context:r.context}),[n]=a.useState((()=>new ot(i,r)));a.useEffect((()=>{n.setOptions(r)}),[n,r]);const o=pt(a.useCallback((t=>n.subscribe(H.batchCalls(t))),[n]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),u=a.useCallback(((t,e)=>{n.mutate(t,e).catch(Ft)}),[n]);if(o.error&&Pt(n.options.useErrorBoundary,[o.error]))throw o.error;return{...o,mutate:u,mutateAsync:o.mutate}},t.useQueries=function({queries:t,context:e}){const s=bt({context:e}),r=Ot(),i=a.useMemo((()=>t.map((t=>{const e=s.defaultQueryOptions(t);return e._optimisticResults=r?"isRestoring":"optimistic",e}))),[t,s,r]),[n]=a.useState((()=>new it(s,i))),o=n.getOptimisticResult(i);pt(a.useCallback((t=>r?()=>{}:n.subscribe(H.batchCalls(t))),[n,r]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),a.useEffect((()=>{n.setQueries(i,{listeners:!1})}),[i,n]);const u=St();i.forEach((t=>{Et(t,u)})),Qt(u);const c=o.find(((t,e)=>{var s,r;return wt({result:t,errorResetBoundary:u,useErrorBoundary:null!=(s=null==(r=i[e])?void 0:r.useErrorBoundary)&&s,query:n.getQueries()[e]})}));if(null!=c&&c.error)throw c.error;return o},t.useQuery=function(t,e,s){return Mt(p(t,e,s),$)},t.useQueryClient=bt,t.useQueryErrorResetBoundary=St,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/react-query", | ||
"version": "4.14.3", | ||
"version": "4.14.5", | ||
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React", | ||
@@ -49,3 +49,3 @@ "author": "tannerlinsley", | ||
"dependencies": { | ||
"@tanstack/query-core": "4.14.3", | ||
"@tanstack/query-core": "4.14.5", | ||
"use-sync-external-store": "^1.2.0" | ||
@@ -52,0 +52,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1282859
18020
+ Added@tanstack/query-core@4.14.5(transitive)
- Removed@tanstack/query-core@4.14.3(transitive)
Updated@tanstack/query-core@4.14.5