var Ge=e=>{throw TypeError(e)};var pe=(e,t,s)=>t.has(e)||Ge("Cannot "+s);var i=(e,t,s)=>(pe(e,t,"read from private field"),s?s.call(e):t.get(e)),c=(e,t,s)=>t.has(e)?Ge("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),o=(e,t,s,r)=>(pe(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),p=(e,t,s)=>(pe(e,t,"access private method"),s);var he=(e,t,s,r)=>({set _(n){o(e,t,n,s)},get _(){return i(e,t,r)}});import{r as C,j as ps}from"./vendor-react-C630P38J.js";var Ft=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},gt,at,xt,ss,ks=(ss=class extends Ft{constructor(){super();c(this,gt);c(this,at);c(this,xt);o(this,xt,t=>{if(typeof window<"u"&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){i(this,at)||this.setEventListener(i(this,xt))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,at))==null||t.call(this),o(this,at,void 0))}setEventListener(t){var s;o(this,xt,t),(s=i(this,at))==null||s.call(this),o(this,at,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){i(this,gt)!==t&&(o(this,gt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof i(this,gt)=="boolean"?i(this,gt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},gt=new WeakMap,at=new WeakMap,xt=new WeakMap,ss),qe=new ks,qs={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ut,ke,rs,_s=(rs=class{constructor(){c(this,ut,qs);c(this,ke,!1)}setTimeoutProvider(e){o(this,ut,e)}setTimeout(e,t){return i(this,ut).setTimeout(e,t)}clearTimeout(e){i(this,ut).clearTimeout(e)}setInterval(e,t){return i(this,ut).setInterval(e,t)}clearInterval(e){i(this,ut).clearInterval(e)}},ut=new WeakMap,ke=new WeakMap,rs),mt=new _s;function Ls(e){setTimeout(e,0)}var Ks=typeof window>"u"||"Deno"in globalThis;function U(){}function Ns(e,t){return typeof e=="function"?e(t):e}function ye(e){return typeof e=="number"&&e>=0&&e!==1/0}function ys(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vt(e,t){return typeof e=="function"?e(t):e}function G(e,t){return typeof e=="function"?e(t):e}function ze(e,t){const{type:s="all",exact:r,fetchStatus:n,predicate:a,queryKey:u,stale:h}=e;if(u){if(r){if(t.queryHash!==_e(u,t.options))return!1}else if(!zt(t.queryKey,u))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof h=="boolean"&&t.isStale()!==h||n&&n!==t.state.fetchStatus||a&&!a(t))}function Ve(e,t){const{exact:s,status:r,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(Mt(t.options.mutationKey)!==Mt(a))return!1}else if(!zt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||n&&!n(t))}function _e(e,t){return((t==null?void 0:t.queryKeyHashFn)||Mt)(e)}function Mt(e){return JSON.stringify(e,(t,s)=>ve(s)?Object.keys(s).sort().reduce((r,n)=>(r[n]=s[n],r),{}):s)}function zt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>zt(e[s],t[s])):!1}var Hs=Object.prototype.hasOwnProperty;function de(e,t,s=0){if(e===t)return e;if(s>500)return t;const r=We(e)&&We(t);if(!r&&!(ve(e)&&ve(t)))return t;const a=(r?e:Object.keys(e)).length,u=r?t:Object.keys(t),h=u.length,f=r?new Array(h):{};let S=0;for(let m=0;m{mt.setTimeout(t,e)})}function me(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?de(e,t):t}function vr(e){return e}function Gs(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function zs(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var Le=Symbol();function vs(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Le?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ke(e,t){return typeof e=="function"?e(...t):!!e}function Vs(e,t,s){let r=!1,n;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(n??(n=t()),r||(r=!0,n.aborted?s():n.addEventListener("abort",s,{once:!0})),n)}),e}var Wt=(()=>{let e=()=>Ks;return{isServer(){return e()},setIsServer(t){e=t}}})();function ge(){let e,t;const s=new Promise((n,a)=>{e=n,t=a});s.status="pending",s.catch(()=>{});function r(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{r({status:"fulfilled",value:n}),e(n)},s.reject=n=>{r({status:"rejected",reason:n}),t(n)},s}var Ws=Ls;function $s(){let e=[],t=0,s=h=>{h()},r=h=>{h()},n=Ws;const a=h=>{t?e.push(h):n(()=>{s(h)})},u=()=>{const h=e;e=[],h.length&&n(()=>{r(()=>{h.forEach(f=>{s(f)})})})};return{batch:h=>{let f;t++;try{f=h()}finally{t--,t||u()}return f},batchCalls:h=>(...f)=>{a(()=>{h(...f)})},schedule:a,setNotifyFunction:h=>{s=h},setBatchNotifyFunction:h=>{r=h},setScheduler:h=>{n=h}}}var M=$s(),It,ot,Tt,is,Js=(is=class extends Ft{constructor(){super();c(this,It,!0);c(this,ot);c(this,Tt);o(this,Tt,t=>{if(typeof window<"u"&&window.addEventListener){const s=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,ot)||this.setEventListener(i(this,Tt))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,ot))==null||t.call(this),o(this,ot,void 0))}setEventListener(t){var s;o(this,Tt,t),(s=i(this,ot))==null||s.call(this),o(this,ot,t(this.setOnline.bind(this)))}setOnline(t){i(this,It)!==t&&(o(this,It,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return i(this,It)}},It=new WeakMap,ot=new WeakMap,Tt=new WeakMap,is),fe=new Js;function Zs(e){return Math.min(1e3*2**e,3e4)}function ms(e){return(e??"online")==="online"?fe.isOnline():!0}var be=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function gs(e){let t=!1,s=0,r;const n=ge(),a=()=>n.status!=="pending",u=y=>{var b;if(!a()){const O=new be(y);g(O),(b=e.onCancel)==null||b.call(e,O)}},h=()=>{t=!0},f=()=>{t=!1},S=()=>qe.isFocused()&&(e.networkMode==="always"||fe.isOnline())&&e.canRun(),m=()=>ms(e.networkMode)&&e.canRun(),l=y=>{a()||(r==null||r(),n.resolve(y))},g=y=>{a()||(r==null||r(),n.reject(y))},d=()=>new Promise(y=>{var b;r=O=>{(a()||S())&&y(O)},(b=e.onPause)==null||b.call(e)}).then(()=>{var y;r=void 0,a()||(y=e.onContinue)==null||y.call(e)}),R=()=>{if(a())return;let y;const b=s===0?e.initialPromise:void 0;try{y=b??e.fn()}catch(O){y=Promise.reject(O)}Promise.resolve(y).then(l).catch(O=>{var _;if(a())return;const F=e.retry??(Wt.isServer()?0:3),Q=e.retryDelay??Zs,v=typeof Q=="function"?Q(s,O):Q,T=F===!0||typeof F=="number"&&sS()?void 0:d()).then(()=>{t?g(O):R()})})};return{promise:n,status:()=>n.status,cancel:u,continue:()=>(r==null||r(),n),cancelRetry:h,continueRetry:f,canStart:m,start:()=>(m()?R():d().then(R),n)}}var bt,ns,bs=(ns=class{constructor(){c(this,bt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ye(this.gcTime)&&o(this,bt,mt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Wt.isServer()?1/0:300*1e3))}clearGcTimeout(){i(this,bt)!==void 0&&(mt.clearTimeout(i(this,bt)),o(this,bt,void 0))}},bt=new WeakMap,ns);function Xs(e){return{onFetch:(t,s)=>{var m,l,g,d,R;const r=t.options,n=(g=(l=(m=t.fetchOptions)==null?void 0:m.meta)==null?void 0:l.fetchMore)==null?void 0:g.direction,a=((d=t.state.data)==null?void 0:d.pages)||[],u=((R=t.state.data)==null?void 0:R.pageParams)||[];let h={pages:[],pageParams:[]},f=0;const S=async()=>{let y=!1;const b=Q=>{Vs(Q,()=>t.signal,()=>y=!0)},O=vs(t.options,t.fetchOptions),F=async(Q,v,T)=>{if(y)return Promise.reject(t.signal.reason);if(v==null&&Q.pages.length)return Promise.resolve(Q);const rt=(()=>{const it={client:t.client,queryKey:t.queryKey,pageParam:v,direction:T?"backward":"forward",meta:t.options.meta};return b(it),it})(),E=await O(rt),{maxPages:D}=t.options,k=T?zs:Gs;return{pages:k(Q.pages,E,D),pageParams:k(Q.pageParams,v,D)}};if(n&&a.length){const Q=n==="backward",v=Q?Os:Oe,T={pages:a,pageParams:u},_=v(r,T);h=await F(T,_,Q)}else{const Q=e??a.length;do{const v=f===0?u[0]??r.initialPageParam:Oe(r,h);if(f>0&&v==null)break;h=await F(h,v),f++}while(f{var y,b;return(b=(y=t.options).persister)==null?void 0:b.call(y,S,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=S}}}function Oe(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function Os(e,{pages:t,pageParams:s}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,s[0],s):void 0}function Ys(e,t){return t?Oe(e,t)!=null:!1}function tr(e,t){return!t||!e.getPreviousPageParam?!1:Os(e,t)!=null}var Dt,Ot,At,z,wt,A,$t,St,B,ws,Z,as,er=(as=class extends bs{constructor(t){super();c(this,B);c(this,Dt);c(this,Ot);c(this,At);c(this,z);c(this,wt);c(this,A);c(this,$t);c(this,St);o(this,St,!1),o(this,$t,t.defaultOptions),this.setOptions(t.options),this.observers=[],o(this,wt,t.client),o(this,z,i(this,wt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,o(this,Ot,Ze(this.options)),this.state=t.state??i(this,Ot),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return i(this,Dt)}get promise(){var t;return(t=i(this,A))==null?void 0:t.promise}setOptions(t){if(this.options={...i(this,$t),...t},t!=null&&t._type&&o(this,Dt,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=Ze(this.options);s.data!==void 0&&(this.setState(Je(s.data,s.dataUpdatedAt)),o(this,Ot,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,z).remove(this)}setData(t,s){const r=me(this.state.data,t,this.options);return p(this,B,Z).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(t){p(this,B,Z).call(this,{type:"setState",state:t})}cancel(t){var r,n;const s=(r=i(this,A))==null?void 0:r.promise;return(n=i(this,A))==null||n.cancel(t),s?s.then(U).catch(U):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return i(this,Ot)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>G(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Le||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>vt(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!ys(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}onOnline(){var s;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=i(this,A))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),i(this,z).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(i(this,A)&&(i(this,St)||p(this,B,ws).call(this)?i(this,A).cancel({revert:!0}):i(this,A).cancelRetry()),this.scheduleGc()),i(this,z).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||p(this,B,Z).call(this,{type:"invalidate"})}async fetch(t,s){var S,m,l,g,d,R,y,b,O,F,Q;if(this.state.fetchStatus!=="idle"&&((S=i(this,A))==null?void 0:S.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(i(this,A))return i(this,A).continueRetry(),i(this,A).promise}if(t&&this.setOptions(t),!this.options.queryFn){const v=this.observers.find(T=>T.options.queryFn);v&&this.setOptions(v.options)}const r=new AbortController,n=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(o(this,St,!0),r.signal)})},a=()=>{const v=vs(this.options,s),_=(()=>{const rt={client:i(this,wt),queryKey:this.queryKey,meta:this.meta};return n(rt),rt})();return o(this,St,!1),this.options.persister?this.options.persister(v,_,this):v(_)},h=(()=>{const v={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:i(this,wt),state:this.state,fetchFn:a};return n(v),v})(),f=i(this,Dt)==="infinite"?Xs(this.options.pages):this.options.behavior;f==null||f.onFetch(h,this),o(this,At,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((m=h.fetchOptions)==null?void 0:m.meta))&&p(this,B,Z).call(this,{type:"fetch",meta:(l=h.fetchOptions)==null?void 0:l.meta}),o(this,A,gs({initialPromise:s==null?void 0:s.initialPromise,fn:h.fetchFn,onCancel:v=>{v instanceof be&&v.revert&&this.setState({...i(this,At),fetchStatus:"idle"}),r.abort()},onFail:(v,T)=>{p(this,B,Z).call(this,{type:"failed",failureCount:v,error:T})},onPause:()=>{p(this,B,Z).call(this,{type:"pause"})},onContinue:()=>{p(this,B,Z).call(this,{type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode,canRun:()=>!0}));try{const v=await i(this,A).start();if(v===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(v),(d=(g=i(this,z).config).onSuccess)==null||d.call(g,v,this),(y=(R=i(this,z).config).onSettled)==null||y.call(R,v,this.state.error,this),v}catch(v){if(v instanceof be){if(v.silent)return i(this,A).promise;if(v.revert){if(this.state.data===void 0)throw v;return this.state.data}}throw p(this,B,Z).call(this,{type:"error",error:v}),(O=(b=i(this,z).config).onError)==null||O.call(b,v,this),(Q=(F=i(this,z).config).onSettled)==null||Q.call(F,this.state.data,v,this),v}finally{this.scheduleGc()}}},Dt=new WeakMap,Ot=new WeakMap,At=new WeakMap,z=new WeakMap,wt=new WeakMap,A=new WeakMap,$t=new WeakMap,St=new WeakMap,B=new WeakSet,ws=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Z=function(t){const s=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ss(r.data,this.options),fetchMeta:t.meta??null};case"success":const n={...r,...Je(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return o(this,At,t.manual?n:void 0),n;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=s(this.state),M.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),i(this,z).notify({query:this,type:"updated",action:t})})},as);function Ss(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ms(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Je(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ze(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var L,w,Jt,q,Pt,jt,X,ht,Zt,Ut,kt,Rt,Ct,ct,qt,P,Gt,we,Se,Pe,Re,Ce,Ee,Qe,Ps,us,ie=(us=class extends Ft{constructor(t,s){super();c(this,P);c(this,L);c(this,w);c(this,Jt);c(this,q);c(this,Pt);c(this,jt);c(this,X);c(this,ht);c(this,Zt);c(this,Ut);c(this,kt);c(this,Rt);c(this,Ct);c(this,ct);c(this,qt,new Set);this.options=s,o(this,L,t),o(this,ht,null),o(this,X,ge()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,w).addObserver(this),Xe(i(this,w),this.options)?p(this,P,Gt).call(this):this.updateResult(),p(this,P,Re).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Me(i(this,w),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Me(i(this,w),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,p(this,P,Ce).call(this),p(this,P,Ee).call(this),i(this,w).removeObserver(this)}setOptions(t){const s=this.options,r=i(this,w);if(this.options=i(this,L).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof G(this.options.enabled,i(this,w))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");p(this,P,Qe).call(this),i(this,w).setOptions(this.options),s._defaulted&&!Vt(this.options,s)&&i(this,L).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,w),observer:this});const n=this.hasListeners();n&&Ye(i(this,w),r,this.options,s)&&p(this,P,Gt).call(this),this.updateResult(),n&&(i(this,w)!==r||G(this.options.enabled,i(this,w))!==G(s.enabled,i(this,w))||vt(this.options.staleTime,i(this,w))!==vt(s.staleTime,i(this,w)))&&p(this,P,we).call(this);const a=p(this,P,Se).call(this);n&&(i(this,w)!==r||G(this.options.enabled,i(this,w))!==G(s.enabled,i(this,w))||a!==i(this,ct))&&p(this,P,Pe).call(this,a)}getOptimisticResult(t){const s=i(this,L).getQueryCache().build(i(this,L),t),r=this.createResult(s,t);return rr(this,r)&&(o(this,q,r),o(this,jt,this.options),o(this,Pt,i(this,w).state)),r}getCurrentResult(){return i(this,q)}trackResult(t,s){return new Proxy(t,{get:(r,n)=>(this.trackProp(n),s==null||s(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,X).status==="pending"&&i(this,X).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,n))})}trackProp(t){i(this,qt).add(t)}getCurrentQuery(){return i(this,w)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=i(this,L).defaultQueryOptions(t),r=i(this,L).getQueryCache().build(i(this,L),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return p(this,P,Gt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,q)))}createResult(t,s){var D;const r=i(this,w),n=this.options,a=i(this,q),u=i(this,Pt),h=i(this,jt),S=t!==r?t.state:i(this,Jt),{state:m}=t;let l={...m},g=!1,d;if(s._optimisticResults){const k=this.hasListeners(),it=!k&&Xe(t,s),ae=k&&Ye(t,r,s,n);(it||ae)&&(l={...l,...Ss(m.data,t.options)}),s._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:R,errorUpdatedAt:y,status:b}=l;d=l.data;let O=!1;if(s.placeholderData!==void 0&&d===void 0&&b==="pending"){let k;a!=null&&a.isPlaceholderData&&s.placeholderData===(h==null?void 0:h.placeholderData)?(k=a.data,O=!0):k=typeof s.placeholderData=="function"?s.placeholderData((D=i(this,kt))==null?void 0:D.state.data,i(this,kt)):s.placeholderData,k!==void 0&&(b="success",d=me(a==null?void 0:a.data,k,s),g=!0)}if(s.select&&d!==void 0&&!O)if(a&&d===(u==null?void 0:u.data)&&s.select===i(this,Zt))d=i(this,Ut);else try{o(this,Zt,s.select),d=s.select(d),d=me(a==null?void 0:a.data,d,s),o(this,Ut,d),o(this,ht,null)}catch(k){o(this,ht,k)}i(this,ht)&&(R=i(this,ht),d=i(this,Ut),y=Date.now(),b="error");const F=l.fetchStatus==="fetching",Q=b==="pending",v=b==="error",T=Q&&F,_=d!==void 0,E={status:b,fetchStatus:l.fetchStatus,isPending:Q,isSuccess:b==="success",isError:v,isInitialLoading:T,isLoading:T,data:d,dataUpdatedAt:l.dataUpdatedAt,error:R,errorUpdatedAt:y,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:l.dataUpdateCount>S.dataUpdateCount||l.errorUpdateCount>S.errorUpdateCount,isFetching:F,isRefetching:F&&!Q,isLoadingError:v&&!_,isPaused:l.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:v&&_,isStale:Ne(t,s),refetch:this.refetch,promise:i(this,X),isEnabled:G(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const k=E.data!==void 0,it=E.status==="error"&&!k,ae=oe=>{it?oe.reject(E.error):k&&oe.resolve(E.data)},Be=()=>{const oe=o(this,X,E.promise=ge());ae(oe)},ue=i(this,X);switch(ue.status){case"pending":t.queryHash===r.queryHash&&ae(ue);break;case"fulfilled":(it||E.data!==ue.value)&&Be();break;case"rejected":(!it||E.error!==ue.reason)&&Be();break}}return E}updateResult(){const t=i(this,q),s=this.createResult(i(this,w),this.options);if(o(this,Pt,i(this,w).state),o(this,jt,this.options),i(this,Pt).data!==void 0&&o(this,kt,i(this,w)),Vt(s,t))return;o(this,q,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!i(this,qt).size)return!0;const u=new Set(a??i(this,qt));return this.options.throwOnError&&u.add("error"),Object.keys(i(this,q)).some(h=>{const f=h;return i(this,q)[f]!==t[f]&&u.has(f)})};p(this,P,Ps).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&p(this,P,Re).call(this)}},L=new WeakMap,w=new WeakMap,Jt=new WeakMap,q=new WeakMap,Pt=new WeakMap,jt=new WeakMap,X=new WeakMap,ht=new WeakMap,Zt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,ct=new WeakMap,qt=new WeakMap,P=new WeakSet,Gt=function(t){p(this,P,Qe).call(this);let s=i(this,w).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(U)),s},we=function(){p(this,P,Ce).call(this);const t=vt(this.options.staleTime,i(this,w));if(Wt.isServer()||i(this,q).isStale||!ye(t))return;const r=ys(i(this,q).dataUpdatedAt,t)+1;o(this,Rt,mt.setTimeout(()=>{i(this,q).isStale||this.updateResult()},r))},Se=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,w)):this.options.refetchInterval)??!1},Pe=function(t){p(this,P,Ee).call(this),o(this,ct,t),!(Wt.isServer()||G(this.options.enabled,i(this,w))===!1||!ye(i(this,ct))||i(this,ct)===0)&&o(this,Ct,mt.setInterval(()=>{(this.options.refetchIntervalInBackground||qe.isFocused())&&p(this,P,Gt).call(this)},i(this,ct)))},Re=function(){p(this,P,we).call(this),p(this,P,Pe).call(this,p(this,P,Se).call(this))},Ce=function(){i(this,Rt)!==void 0&&(mt.clearTimeout(i(this,Rt)),o(this,Rt,void 0))},Ee=function(){i(this,Ct)!==void 0&&(mt.clearInterval(i(this,Ct)),o(this,Ct,void 0))},Qe=function(){const t=i(this,L).getQueryCache().build(i(this,L),this.options);if(t===i(this,w))return;const s=i(this,w);o(this,w,t),o(this,Jt,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Ps=function(t){M.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(i(this,q))}),i(this,L).getQueryCache().notify({query:i(this,w),type:"observerResultsUpdated"})})},us);function sr(e,t){return G(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&G(t.retryOnMount,e)===!1)}function Xe(e,t){return sr(e,t)||e.state.data!==void 0&&Me(e,t,t.refetchOnMount)}function Me(e,t,s){if(G(t.enabled,e)!==!1&&vt(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&Ne(e,t)}return!1}function Ye(e,t,s,r){return(e!==t||G(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&Ne(e,s)}function Ne(e,t){return G(t.enabled,e)!==!1&&e.isStaleByTime(vt(t.staleTime,e))}function rr(e,t){return!Vt(e.getCurrentResult(),t)}var ir=class extends ie{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var R,y;const{state:s}=e,r=super.createResult(e,t),{isFetching:n,isRefetching:a,isError:u,isRefetchError:h}=r,f=(y=(R=s.fetchMeta)==null?void 0:R.fetchMore)==null?void 0:y.direction,S=u&&f==="forward",m=n&&f==="forward",l=u&&f==="backward",g=n&&f==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ys(t,s.data),hasPreviousPage:tr(t,s.data),isFetchNextPageError:S,isFetchingNextPage:m,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:h&&!S&&!l,isRefetching:a&&!m&&!g}}},Xt,W,j,Et,$,nt,os,nr=(os=class extends bs{constructor(t){super();c(this,$);c(this,Xt);c(this,W);c(this,j);c(this,Et);o(this,Xt,t.client),this.mutationId=t.mutationId,o(this,j,t.mutationCache),o(this,W,[]),this.state=t.state||Rs(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){i(this,W).includes(t)||(i(this,W).push(t),this.clearGcTimeout(),i(this,j).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){o(this,W,i(this,W).filter(s=>s!==t)),this.scheduleGc(),i(this,j).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){i(this,W).length||(this.state.status==="pending"?this.scheduleGc():i(this,j).remove(this))}continue(){var t;return((t=i(this,Et))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var u,h,f,S,m,l,g,d,R,y,b,O,F,Q,v,T,_,rt;const s=()=>{p(this,$,nt).call(this,{type:"continue"})},r={client:i(this,Xt),meta:this.options.meta,mutationKey:this.options.mutationKey};o(this,Et,gs({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(E,D)=>{p(this,$,nt).call(this,{type:"failed",failureCount:E,error:D})},onPause:()=>{p(this,$,nt).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,j).canRun(this)}));const n=this.state.status==="pending",a=!i(this,Et).canStart();try{if(n)s();else{p(this,$,nt).call(this,{type:"pending",variables:t,isPaused:a}),i(this,j).config.onMutate&&await i(this,j).config.onMutate(t,this,r);const D=await((h=(u=this.options).onMutate)==null?void 0:h.call(u,t,r));D!==this.state.context&&p(this,$,nt).call(this,{type:"pending",context:D,variables:t,isPaused:a})}const E=await i(this,Et).start();return await((S=(f=i(this,j).config).onSuccess)==null?void 0:S.call(f,E,t,this.state.context,this,r)),await((l=(m=this.options).onSuccess)==null?void 0:l.call(m,E,t,this.state.context,r)),await((d=(g=i(this,j).config).onSettled)==null?void 0:d.call(g,E,null,this.state.variables,this.state.context,this,r)),await((y=(R=this.options).onSettled)==null?void 0:y.call(R,E,null,t,this.state.context,r)),p(this,$,nt).call(this,{type:"success",data:E}),E}catch(E){try{await((O=(b=i(this,j).config).onError)==null?void 0:O.call(b,E,t,this.state.context,this,r))}catch(D){Promise.reject(D)}try{await((Q=(F=this.options).onError)==null?void 0:Q.call(F,E,t,this.state.context,r))}catch(D){Promise.reject(D)}try{await((T=(v=i(this,j).config).onSettled)==null?void 0:T.call(v,void 0,E,this.state.variables,this.state.context,this,r))}catch(D){Promise.reject(D)}try{await((rt=(_=this.options).onSettled)==null?void 0:rt.call(_,void 0,E,t,this.state.context,r))}catch(D){Promise.reject(D)}throw p(this,$,nt).call(this,{type:"error",error:E}),E}finally{i(this,j).runNext(this)}}},Xt=new WeakMap,W=new WeakMap,j=new WeakMap,Et=new WeakMap,$=new WeakSet,nt=function(t){const s=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),M.batch(()=>{i(this,W).forEach(r=>{r.onMutationUpdate(t)}),i(this,j).notify({mutation:this,type:"updated",action:t})})},os);function Rs(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Y,V,Yt,hs,ar=(hs=class extends Ft{constructor(t={}){super();c(this,Y);c(this,V);c(this,Yt);this.config=t,o(this,Y,new Set),o(this,V,new Map),o(this,Yt,0)}build(t,s,r){const n=new nr({client:t,mutationCache:this,mutationId:++he(this,Yt)._,options:t.defaultMutationOptions(s),state:r});return this.add(n),n}add(t){i(this,Y).add(t);const s=ce(t);if(typeof s=="string"){const r=i(this,V).get(s);r?r.push(t):i(this,V).set(s,[t])}this.notify({type:"added",mutation:t})}remove(t){if(i(this,Y).delete(t)){const s=ce(t);if(typeof s=="string"){const r=i(this,V).get(s);if(r)if(r.length>1){const n=r.indexOf(t);n!==-1&&r.splice(n,1)}else r[0]===t&&i(this,V).delete(s)}}this.notify({type:"removed",mutation:t})}canRun(t){const s=ce(t);if(typeof s=="string"){const r=i(this,V).get(s),n=r==null?void 0:r.find(a=>a.state.status==="pending");return!n||n===t}else return!0}runNext(t){var r;const s=ce(t);if(typeof s=="string"){const n=(r=i(this,V).get(s))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){M.batch(()=>{i(this,Y).forEach(t=>{this.notify({type:"removed",mutation:t})}),i(this,Y).clear(),i(this,V).clear()})}getAll(){return Array.from(i(this,Y))}find(t){const s={exact:!0,...t};return this.getAll().find(r=>Ve(s,r))}findAll(t={}){return this.getAll().filter(s=>Ve(t,s))}notify(t){M.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return M.batch(()=>Promise.all(t.map(s=>s.continue().catch(U))))}},Y=new WeakMap,V=new WeakMap,Yt=new WeakMap,hs);function ce(e){var t;return(t=e.options.scope)==null?void 0:t.id}var tt,lt,K,et,st,le,Fe,cs,ur=(cs=class extends Ft{constructor(t,s){super();c(this,st);c(this,tt);c(this,lt);c(this,K);c(this,et);o(this,tt,t),this.setOptions(s),this.bindMethods(),p(this,st,le).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=i(this,tt).defaultMutationOptions(t),Vt(this.options,s)||i(this,tt).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,K),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Mt(s.mutationKey)!==Mt(this.options.mutationKey)?this.reset():((r=i(this,K))==null?void 0:r.state.status)==="pending"&&i(this,K).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=i(this,K))==null||t.removeObserver(this)}onMutationUpdate(t){p(this,st,le).call(this),p(this,st,Fe).call(this,t)}getCurrentResult(){return i(this,lt)}reset(){var t;(t=i(this,K))==null||t.removeObserver(this),o(this,K,void 0),p(this,st,le).call(this),p(this,st,Fe).call(this)}mutate(t,s){var r;return o(this,et,s),(r=i(this,K))==null||r.removeObserver(this),o(this,K,i(this,tt).getMutationCache().build(i(this,tt),this.options)),i(this,K).addObserver(this),i(this,K).execute(t)}},tt=new WeakMap,lt=new WeakMap,K=new WeakMap,et=new WeakMap,st=new WeakSet,le=function(){var s;const t=((s=i(this,K))==null?void 0:s.state)??Rs();o(this,lt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Fe=function(t){M.batch(()=>{var s,r,n,a,u,h,f,S;if(i(this,et)&&this.hasListeners()){const m=i(this,lt).variables,l=i(this,lt).context,g={client:i(this,tt),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(s=i(this,et)).onSuccess)==null||r.call(s,t.data,m,l,g)}catch(d){Promise.reject(d)}try{(a=(n=i(this,et)).onSettled)==null||a.call(n,t.data,null,m,l,g)}catch(d){Promise.reject(d)}}else if((t==null?void 0:t.type)==="error"){try{(h=(u=i(this,et)).onError)==null||h.call(u,t.error,m,l,g)}catch(d){Promise.reject(d)}try{(S=(f=i(this,et)).onSettled)==null||S.call(f,void 0,t.error,m,l,g)}catch(d){Promise.reject(d)}}}this.listeners.forEach(m=>{m(i(this,lt))})})},cs);function ts(e,t){const s=new Set(t);return e.filter(r=>!s.has(r))}function or(e,t,s){const r=e.slice(0);return r[t]=s,r}var _t,N,Lt,Qt,H,ft,te,ee,se,re,I,xe,Ie,Cs,Te,De,Ae,ls,hr=(ls=class extends Ft{constructor(t,s,r){super();c(this,I);c(this,_t);c(this,N);c(this,Lt);c(this,Qt);c(this,H);c(this,ft);c(this,te);c(this,ee);c(this,se);c(this,re,[]);o(this,_t,t),o(this,Qt,r),o(this,Lt,[]),o(this,H,[]),o(this,N,[]),this.setQueries(s)}onSubscribe(){this.listeners.size===1&&i(this,H).forEach(t=>{t.subscribe(s=>{p(this,I,De).call(this,t,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,i(this,H).forEach(t=>{t.destroy()})}setQueries(t,s){o(this,Lt,t),o(this,Qt,s),M.batch(()=>{const r=i(this,H),n=p(this,I,Te).call(this,i(this,Lt));n.forEach(l=>l.observer.setOptions(l.defaultedQueryOptions));const a=n.map(l=>l.observer),u=a.map(l=>l.getCurrentResult()),h=r.length!==a.length,f=a.some((l,g)=>l!==r[g]),S=h||f,m=S?!0:u.some((l,g)=>{const d=i(this,N)[g];return!d||!Vt(l,d)});!S&&!m||(S&&(o(this,re,n),o(this,H,a)),o(this,N,u),this.hasListeners()&&(S&&(ts(r,a).forEach(l=>{l.destroy()}),ts(a,r).forEach(l=>{l.subscribe(g=>{p(this,I,De).call(this,l,g)})})),p(this,I,Ae).call(this)))})}getCurrentResult(){return i(this,N)}getQueries(){return i(this,H).map(t=>t.getCurrentQuery())}getObservers(){return i(this,H)}getOptimisticResult(t,s){const r=p(this,I,Te).call(this,t),n=r.map(u=>u.observer.getOptimisticResult(u.defaultedQueryOptions)),a=r.map(u=>u.defaultedQueryOptions.queryHash);return[n,u=>p(this,I,Ie).call(this,u??n,s,a),()=>p(this,I,xe).call(this,n,r)]}},_t=new WeakMap,N=new WeakMap,Lt=new WeakMap,Qt=new WeakMap,H=new WeakMap,ft=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,re=new WeakMap,I=new WeakSet,xe=function(t,s){return s.map((r,n)=>{const a=t[n];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,u=>{s.forEach(h=>{h.observer.trackProp(u)})})})},Ie=function(t,s,r){if(s){const n=i(this,se),a=r!==void 0&&n!==void 0&&(n.length!==r.length||r.some((u,h)=>u!==n[h]));return(!i(this,ft)||i(this,N)!==i(this,ee)||a||s!==i(this,te))&&(o(this,te,s),o(this,ee,i(this,N)),r!==void 0&&o(this,se,r),o(this,ft,de(i(this,ft),s(t)))),i(this,ft)}return t},Cs=function(){var t;return((t=i(this,Qt))==null?void 0:t.combine)!==void 0&&i(this,H).some((s,r)=>{var n;return s.options.suspense&&((n=i(this,N)[r])==null?void 0:n.data)===void 0})},Te=function(t){const s=new Map;i(this,H).forEach(n=>{const a=n.options.queryHash;if(!a)return;const u=s.get(a);u?u.push(n):s.set(a,[n])});const r=[];return t.forEach(n=>{var f;const a=i(this,_t).defaultQueryOptions(n),h=((f=s.get(a.queryHash))==null?void 0:f.shift())??new ie(i(this,_t),a);r.push({defaultedQueryOptions:a,observer:h})}),r},De=function(t,s){const r=i(this,H).indexOf(t);r!==-1&&(o(this,N,or(i(this,N),r,s)),p(this,I,Ae).call(this))},Ae=function(){var t;if(this.hasListeners()){const s=p(this,I,xe).call(this,i(this,N),i(this,re)),r=p(this,I,Cs).call(this),n=i(this,ft),a=r?n:p(this,I,Ie).call(this,s,(t=i(this,Qt))==null?void 0:t.combine);(r||n!==a)&&M.batch(()=>{this.listeners.forEach(u=>{u(i(this,N))})})}},ls),J,fs,cr=(fs=class extends Ft{constructor(t={}){super();c(this,J);this.config=t,o(this,J,new Map)}build(t,s,r){const n=s.queryKey,a=s.queryHash??_e(n,s);let u=this.get(a);return u||(u=new er({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(s),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(u)),u}add(t){i(this,J).has(t.queryHash)||(i(this,J).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=i(this,J).get(t.queryHash);s&&(t.destroy(),s===t&&i(this,J).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){M.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return i(this,J).get(t)}getAll(){return[...i(this,J).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(r=>ze(s,r))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(r=>ze(t,r)):s}notify(t){M.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){M.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},J=new WeakMap,fs),x,dt,pt,Kt,Nt,yt,Ht,Bt,ds,mr=(ds=class{constructor(e={}){c(this,x);c(this,dt);c(this,pt);c(this,Kt);c(this,Nt);c(this,yt);c(this,Ht);c(this,Bt);o(this,x,e.queryCache||new cr),o(this,dt,e.mutationCache||new ar),o(this,pt,e.defaultOptions||{}),o(this,Kt,new Map),o(this,Nt,new Map),o(this,yt,0)}mount(){he(this,yt)._++,i(this,yt)===1&&(o(this,Ht,qe.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,x).onFocus())})),o(this,Bt,fe.subscribe(async e=>{e&&(await this.resumePausedMutations(),i(this,x).onOnline())})))}unmount(){var e,t;he(this,yt)._--,i(this,yt)===0&&((e=i(this,Ht))==null||e.call(this),o(this,Ht,void 0),(t=i(this,Bt))==null||t.call(this),o(this,Bt,void 0))}isFetching(e){return i(this,x).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return i(this,dt).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,x).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=i(this,x).build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(vt(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return i(this,x).findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=i(this,x).get(r.queryHash),a=n==null?void 0:n.state.data,u=Ns(t,a);if(u!==void 0)return i(this,x).build(this,r).setData(u,{...s,manual:!0})}setQueriesData(e,t,s){return M.batch(()=>i(this,x).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=i(this,x).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=i(this,x);M.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=i(this,x);return M.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=M.batch(()=>i(this,x).findAll(e).map(n=>n.cancel(s)));return Promise.all(r).then(U).catch(U)}invalidateQueries(e,t={}){return M.batch(()=>(i(this,x).findAll(e).forEach(s=>{s.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=M.batch(()=>i(this,x).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,s);return s.throwOnError||(a=a.catch(U)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(U)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=i(this,x).build(this,t);return s.isStaleByTime(vt(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(U).catch(U)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(U).catch(U)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return fe.isOnline()?i(this,dt).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,x)}getMutationCache(){return i(this,dt)}getDefaultOptions(){return i(this,pt)}setDefaultOptions(e){o(this,pt,e)}setQueryDefaults(e,t){i(this,Kt).set(Mt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...i(this,Kt).values()],s={};return t.forEach(r=>{zt(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){i(this,Nt).set(Mt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...i(this,Nt).values()],s={};return t.forEach(r=>{zt(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...i(this,pt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=_e(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Le&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...i(this,pt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){i(this,x).clear(),i(this,dt).clear()}},x=new WeakMap,dt=new WeakMap,pt=new WeakMap,Kt=new WeakMap,Nt=new WeakMap,yt=new WeakMap,Ht=new WeakMap,Bt=new WeakMap,ds),Es=C.createContext(void 0),ne=e=>{const t=C.useContext(Es);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},gr=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),ps.jsx(Es.Provider,{value:e,children:t})),Qs=C.createContext(!1),Ms=()=>C.useContext(Qs);Qs.Provider;function Fs(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xs=C.createContext(Fs()),Is=()=>C.useContext(xs),br=({children:e})=>{const[t]=C.useState(()=>Fs());return ps.jsx(xs.Provider,{value:t,children:typeof e=="function"?e(t):e})},Ts=(e,t,s)=>{const r=s!=null&&s.state.error&&typeof e.throwOnError=="function"?Ke(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ds=e=>{C.useEffect(()=>{e.clearReset()},[e])},As=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(n&&e.data===void 0||Ke(s,[e.error,r])),js=(e,t)=>t.state.data===void 0,Us=e=>{if(e.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...n)=>s(r(...n)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},lr=(e,t)=>e.isLoading&&e.isFetching&&!t,je=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ue=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function fr({queries:e,...t},s){const r=ne(s),n=Ms(),a=Is(),u=C.useMemo(()=>e.map(y=>{const b=r.defaultQueryOptions(y);return b._optimisticResults=n?"isRestoring":"optimistic",b}),[e,r,n]);u.forEach(y=>{Us(y);const b=r.getQueryCache().get(y.queryHash);Ts(y,a,b)}),Ds(a);const[h]=C.useState(()=>new hr(r,u,t)),[f,S,m]=h.getOptimisticResult(u,t.combine),l=!n&&t.subscribed!==!1;C.useSyncExternalStore(C.useCallback(y=>l?h.subscribe(M.batchCalls(y)):U,[h,l]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),C.useEffect(()=>{h.setQueries(u,t)},[u,t,h]);const d=f.some((y,b)=>je(u[b],y))?f.flatMap((y,b)=>{const O=u[b];if(O&&je(O,y)){const F=new ie(r,O);return Ue(O,F,a)}return[]}):[];if(d.length>0)throw Promise.all(d);const R=f.find((y,b)=>{const O=u[b];return O&&As({result:y,errorResetBoundary:a,throwOnError:O.throwOnError,query:r.getQueryCache().get(O.queryHash),suspense:O.suspense})});if(R!=null&&R.error)throw R.error;return S(m())}function He(e,t,s){var d,R,y,b;const r=Ms(),n=Is(),a=ne(s),u=a.defaultQueryOptions(e);(R=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||R.call(d,u);const h=a.getQueryCache().get(u.queryHash),f=e.subscribed!==!1;u._optimisticResults=r?"isRestoring":f?"optimistic":void 0,Us(u),Ts(u,n,h),Ds(n);const S=!a.getQueryCache().get(u.queryHash),[m]=C.useState(()=>new t(a,u)),l=m.getOptimisticResult(u),g=!r&&f;if(C.useSyncExternalStore(C.useCallback(O=>{const F=g?m.subscribe(M.batchCalls(O)):U;return m.updateResult(),F},[m,g]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),C.useEffect(()=>{m.setOptions(u)},[u,m]),je(u,l))throw Ue(u,m,n);if(As({result:l,errorResetBoundary:n,throwOnError:u.throwOnError,query:h,suspense:u.suspense}))throw l.error;if((b=(y=a.getDefaultOptions().queries)==null?void 0:y._experimental_afterQuery)==null||b.call(y,u,l),u.experimental_prefetchInRender&&!Wt.isServer()&&lr(l,r)){const O=S?Ue(u,m,n):h==null?void 0:h.promise;O==null||O.catch(U).finally(()=>{m.updateResult()})}return u.notifyOnChangeProps?l:m.trackResult(l)}function Or(e,t){return He(e,ie,t)}function wr(e,t){return He({...e,enabled:!0,suspense:!0,throwOnError:js,placeholderData:void 0},ie,t)}function Sr(e,t){return fr({...e,queries:e.queries.map(s=>({...s,suspense:!0,throwOnError:js,enabled:!0,placeholderData:void 0}))},t)}function Pr(e){return e}function Rr(e){return e}function Cr(e,t){const s=ne(t);return dr({filters:{...e,status:"pending"}},s).length}function es(e,t){return e.findAll(t.filters).map(s=>t.select?t.select(s):s.state)}function dr(e={},t){const s=ne(t).getMutationCache(),r=C.useRef(e),n=C.useRef(null);return n.current===null&&(n.current=es(s,e)),C.useEffect(()=>{r.current=e}),C.useSyncExternalStore(C.useCallback(a=>s.subscribe(()=>{const u=de(n.current,es(s,r.current));n.current!==u&&(n.current=u,M.schedule(a))}),[s]),()=>n.current,()=>n.current)}function Er(e,t){const s=ne(t),[r]=C.useState(()=>new ur(s,e));C.useEffect(()=>{r.setOptions(e)},[r,e]);const n=C.useSyncExternalStore(C.useCallback(u=>r.subscribe(M.batchCalls(u)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=C.useCallback((u,h)=>{r.mutate(u,h).catch(U)},[r]);if(n.error&&Ke(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:a,mutateAsync:n.mutate}}function Qr(e,t){return He(e,ir,t)}export{br as Q,Or as a,Er as b,Cr as c,Qr as d,Is as e,wr as f,Sr as g,mr as h,Rr as i,gr as j,vr as k,fr as l,Pr as q,ne as u};