var St=s=>{throw TypeError(s)};var nt=(s,t,e)=>t.has(s)||St("Cannot "+e);var i=(s,t,e)=>(nt(s,t,"read from private field"),e?e.call(s):t.get(s)),l=(s,t,e)=>t.has(s)?St("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),o=(s,t,e,r)=>(nt(s,t,"write to private field"),r?r.call(s,e):t.set(s,e),e),d=(s,t,e)=>(nt(s,t,"access private method"),e);import{S as vt,i as J,r as y,s as at,c as G,a as ot,d as wt,t as Dt,e as et,f as Ct,n as Qt,b as _t,u as jt}from"./QueryClientProvider-D7wSf7Op.js";import{r as C}from"./index-JhL3uwfD.js";import"./jsx-runtime-D_zvdyIk.js";var Q,I,j,Tt,Nt=(Tt=class extends vt{constructor(){super();l(this,Q);l(this,I);l(this,j);o(this,j,t=>{if(!J&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}onSubscribe(){i(this,I)||this.setEventListener(i(this,j))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,I))==null||t.call(this),o(this,I,void 0))}setEventListener(t){var e;o(this,j,t),(e=i(this,I))==null||e.call(this),o(this,I,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){i(this,Q)!==t&&(o(this,Q,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return typeof i(this,Q)=="boolean"?i(this,Q):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Q=new WeakMap,I=new WeakMap,j=new WeakMap,Tt),kt=new Nt;function Ot(){let s,t;const e=new Promise((n,c)=>{s=n,t=c});e.status="pending",e.catch(()=>{});function r(n){Object.assign(e,n),delete e.resolve,delete e.reject}return e.resolve=n=>{r({status:"fulfilled",value:n}),s(n)},e.reject=n=>{r({status:"rejected",reason:n}),t(n)},e}var N,F,k,xt,Bt=(xt=class extends vt{constructor(){super();l(this,N,!0);l(this,F);l(this,k);o(this,k,t=>{if(!J&&window.addEventListener){const e=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}})}onSubscribe(){i(this,F)||this.setEventListener(i(this,k))}onUnsubscribe(){var t;this.hasListeners()||((t=i(this,F))==null||t.call(this),o(this,F,void 0))}setEventListener(t){var e;o(this,k,t),(e=i(this,F))==null||e.call(this),o(this,F,t(this.setOnline.bind(this)))}setOnline(t){i(this,N)!==t&&(o(this,N,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return i(this,N)}},N=new WeakMap,F=new WeakMap,k=new WeakMap,xt),At=new Bt;function Ht(s){return(s??"online")==="online"?At.isOnline():!0}function zt(s,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ht(t.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}var g,a,X,v,_,B,w,M,Y,A,H,U,P,T,z,h,K,ht,ct,ut,lt,dt,ft,pt,Ut,Lt,Wt=(Lt=class extends vt{constructor(t,e){super();l(this,h);l(this,g);l(this,a);l(this,X);l(this,v);l(this,_);l(this,B);l(this,w);l(this,M);l(this,Y);l(this,A);l(this,H);l(this,U);l(this,P);l(this,T);l(this,z,new Set);this.options=e,o(this,g,t),o(this,M,null),o(this,w,Ot()),this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,a).addObserver(this),It(i(this,a),this.options)?d(this,h,K).call(this):this.updateResult(),d(this,h,lt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return bt(i(this,a),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return bt(i(this,a),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,d(this,h,dt).call(this),d(this,h,ft).call(this),i(this,a).removeObserver(this)}setOptions(t){const e=this.options,r=i(this,a);if(this.options=i(this,g).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof y(this.options.enabled,i(this,a))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");d(this,h,pt).call(this),i(this,a).setOptions(this.options),e._defaulted&&!at(this.options,e)&&i(this,g).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,a),observer:this});const n=this.hasListeners();n&&Ft(i(this,a),r,this.options,e)&&d(this,h,K).call(this),this.updateResult(),n&&(i(this,a)!==r||y(this.options.enabled,i(this,a))!==y(e.enabled,i(this,a))||G(this.options.staleTime,i(this,a))!==G(e.staleTime,i(this,a)))&&d(this,h,ht).call(this);const c=d(this,h,ct).call(this);n&&(i(this,a)!==r||y(this.options.enabled,i(this,a))!==y(e.enabled,i(this,a))||c!==i(this,T))&&d(this,h,ut).call(this,c)}getOptimisticResult(t){const e=i(this,g).getQueryCache().build(i(this,g),t),r=this.createResult(e,t);return Kt(this,r)&&(o(this,v,r),o(this,B,this.options),o(this,_,i(this,a).state)),r}getCurrentResult(){return i(this,v)}trackResult(t,e){return new Proxy(t,{get:(r,n)=>(this.trackProp(n),e==null||e(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,w).status==="pending"&&i(this,w).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,n))})}trackProp(t){i(this,z).add(t)}getCurrentQuery(){return i(this,a)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=i(this,g).defaultQueryOptions(t),r=i(this,g).getQueryCache().build(i(this,g),e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return d(this,h,K).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,v)))}createResult(t,e){var Et;const r=i(this,a),n=this.options,c=i(this,v),u=i(this,_),E=i(this,B),b=t!==r?t.state:i(this,X),{state:S}=t;let f={...S},x=!1,p;if(e._optimisticResults){const R=this.hasListeners(),V=!R&&It(t,e),$=R&&Ft(t,r,e,n);(V||$)&&(f={...f,...zt(S.data,t.options)}),e._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:L,errorUpdatedAt:W,status:m}=f;p=f.data;let Z=!1;if(e.placeholderData!==void 0&&p===void 0&&m==="pending"){let R;c!=null&&c.isPlaceholderData&&e.placeholderData===(E==null?void 0:E.placeholderData)?(R=c.data,Z=!0):R=typeof e.placeholderData=="function"?e.placeholderData((Et=i(this,H))==null?void 0:Et.state.data,i(this,H)):e.placeholderData,R!==void 0&&(m="success",p=Ct(c==null?void 0:c.data,R,e),x=!0)}if(e.select&&p!==void 0&&!Z)if(c&&p===(u==null?void 0:u.data)&&e.select===i(this,Y))p=i(this,A);else try{o(this,Y,e.select),p=e.select(p),p=Ct(c==null?void 0:c.data,p,e),o(this,A,p),o(this,M,null)}catch(R){o(this,M,R)}i(this,M)&&(L=i(this,M),p=i(this,A),W=Date.now(),m="error");const st=f.fetchStatus==="fetching",it=m==="pending",rt=m==="error",mt=it&&st,Rt=p!==void 0,O={status:m,fetchStatus:f.fetchStatus,isPending:it,isSuccess:m==="success",isError:rt,isInitialLoading:mt,isLoading:mt,data:p,dataUpdatedAt:f.dataUpdatedAt,error:L,errorUpdatedAt:W,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>b.dataUpdateCount||f.errorUpdateCount>b.errorUpdateCount,isFetching:st,isRefetching:st&&!it,isLoadingError:rt&&!Rt,isPaused:f.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:rt&&Rt,isStale:gt(t,e),refetch:this.refetch,promise:i(this,w),isEnabled:y(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=O.data!==void 0,V=O.status==="error"&&!R,$=tt=>{V?tt.reject(O.error):R&&tt.resolve(O.data)},yt=()=>{const tt=o(this,w,O.promise=Ot());$(tt)},q=i(this,w);switch(q.status){case"pending":t.queryHash===r.queryHash&&$(q);break;case"fulfilled":(V||O.data!==q.value)&&yt();break;case"rejected":(!V||O.error!==q.reason)&&yt();break}}return O}updateResult(){const t=i(this,v),e=this.createResult(i(this,a),this.options);if(o(this,_,i(this,a).state),o(this,B,this.options),i(this,_).data!==void 0&&o(this,H,i(this,a)),at(e,t))return;o(this,v,e);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,c=typeof n=="function"?n():n;if(c==="all"||!c&&!i(this,z).size)return!0;const u=new Set(c??i(this,z));return this.options.throwOnError&&u.add("error"),Object.keys(i(this,v)).some(E=>{const D=E;return i(this,v)[D]!==t[D]&&u.has(D)})};d(this,h,Ut).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&d(this,h,lt).call(this)}},g=new WeakMap,a=new WeakMap,X=new WeakMap,v=new WeakMap,_=new WeakMap,B=new WeakMap,w=new WeakMap,M=new WeakMap,Y=new WeakMap,A=new WeakMap,H=new WeakMap,U=new WeakMap,P=new WeakMap,T=new WeakMap,z=new WeakMap,h=new WeakSet,K=function(t){d(this,h,pt).call(this);let e=i(this,a).fetch(this.options,t);return t!=null&&t.throwOnError||(e=e.catch(ot)),e},ht=function(){d(this,h,dt).call(this);const t=G(this.options.staleTime,i(this,a));if(J||i(this,v).isStale||!wt(t))return;const r=Dt(i(this,v).dataUpdatedAt,t)+1;o(this,U,et.setTimeout(()=>{i(this,v).isStale||this.updateResult()},r))},ct=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,a)):this.options.refetchInterval)??!1},ut=function(t){d(this,h,ft).call(this),o(this,T,t),!(J||y(this.options.enabled,i(this,a))===!1||!wt(i(this,T))||i(this,T)===0)&&o(this,P,et.setInterval(()=>{(this.options.refetchIntervalInBackground||kt.isFocused())&&d(this,h,K).call(this)},i(this,T)))},lt=function(){d(this,h,ht).call(this),d(this,h,ut).call(this,d(this,h,ct).call(this))},dt=function(){i(this,U)&&(et.clearTimeout(i(this,U)),o(this,U,void 0))},ft=function(){i(this,P)&&(et.clearInterval(i(this,P)),o(this,P,void 0))},pt=function(){const t=i(this,g).getQueryCache().build(i(this,g),this.options);if(t===i(this,a))return;const e=i(this,a);o(this,a,t),o(this,X,t.state),this.hasListeners()&&(e==null||e.removeObserver(this),t.addObserver(this))},Ut=function(t){Qt.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(i(this,v))}),i(this,g).getQueryCache().notify({query:i(this,a),type:"observerResultsUpdated"})})},Lt);function Vt(s,t){return y(t.enabled,s)!==!1&&s.state.data===void 0&&!(s.state.status==="error"&&t.retryOnMount===!1)}function It(s,t){return Vt(s,t)||s.state.data!==void 0&&bt(s,t,t.refetchOnMount)}function bt(s,t,e){if(y(t.enabled,s)!==!1&&G(t.staleTime,s)!=="static"){const r=typeof e=="function"?e(s):e;return r==="always"||r!==!1&>(s,t)}return!1}function Ft(s,t,e,r){return(s!==t||y(r.enabled,s)===!1)&&(!e.suspense||s.state.status!=="error")&>(s,e)}function gt(s,t){return y(t.enabled,s)!==!1&&s.isStaleByTime(G(t.staleTime,s))}function Kt(s,t){return!at(s.getCurrentResult(),t)}var Pt=C.createContext(!1),Gt=()=>C.useContext(Pt);Pt.Provider;function Jt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}var Xt=C.createContext(Jt()),Yt=()=>C.useContext(Xt),Zt=(s,t,e)=>{const r=e!=null&&e.state.error&&typeof s.throwOnError=="function"?_t(s.throwOnError,[e.state.error,e]):s.throwOnError;(s.suspense||s.experimental_prefetchInRender||r)&&(t.isReset()||(s.retryOnMount=!1))},$t=s=>{C.useEffect(()=>{s.clearReset()},[s])},qt=({result:s,errorResetBoundary:t,throwOnError:e,query:r,suspense:n})=>s.isError&&!t.isReset()&&!s.isFetching&&r&&(n&&s.data===void 0||_t(e,[s.error,r])),te=s=>{if(s.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=s.staleTime;s.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof s.gcTime=="number"&&(s.gcTime=Math.max(s.gcTime,1e3))}},ee=(s,t)=>s.isLoading&&s.isFetching&&!t,se=(s,t)=>(s==null?void 0:s.suspense)&&t.isPending,Mt=(s,t,e)=>t.fetchOptimistic(s).catch(()=>{e.clearReset()});function ie(s,t,e){var x,p,L,W;const r=Gt(),n=Yt(),c=jt(),u=c.defaultQueryOptions(s);(p=(x=c.getDefaultOptions().queries)==null?void 0:x._experimental_beforeQuery)==null||p.call(x,u);const E=c.getQueryCache().get(u.queryHash);u._optimisticResults=r?"isRestoring":"optimistic",te(u),Zt(u,n,E),$t(n);const D=!c.getQueryCache().get(u.queryHash),[b]=C.useState(()=>new t(c,u)),S=b.getOptimisticResult(u),f=!r&&s.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(m=>{const Z=f?b.subscribe(Qt.batchCalls(m)):ot;return b.updateResult(),Z},[b,f]),()=>b.getCurrentResult(),()=>b.getCurrentResult()),C.useEffect(()=>{b.setOptions(u)},[u,b]),se(u,S))throw Mt(u,b,n);if(qt({result:S,errorResetBoundary:n,throwOnError:u.throwOnError,query:E,suspense:u.suspense}))throw S.error;if((W=(L=c.getDefaultOptions().queries)==null?void 0:L._experimental_afterQuery)==null||W.call(L,u,S),u.experimental_prefetchInRender&&!J&&ee(S,r)){const m=D?Mt(u,b,n):E==null?void 0:E.promise;m==null||m.catch(ot).finally(()=>{b.updateResult()})}return u.notifyOnChangeProps?S:b.trackResult(S)}function ce(s,t){return ie(s,Wt)}export{ce as u};