import{rase}from"./chunk-DECur_0Z.js";import{rast,tasn}from"./jsx-runtime-BpGWiA-R.js";import{Aasr,Basi,Dasa,Faso,Hass,Iasc,Lasl,Masu,Nasd,Oasf,Pasp,Rasm,Vash,jasg,kas_,zasv}from"./index-B_QKaSWI.js";vary=classextendss{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=r(),this.bindMethods(),this.setOptions(t)}#e;#t=void0;#n=void0;#r=void0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=newSet;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),x(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){returnS(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){returnS(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=newSet,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){lett=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void0&&typeofthis.options.enabled!=`boolean`&&typeofthis.options.enabled!=`function`&&typeofc(this.options.enabled,this.#t)!=`boolean`)throwError(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!m(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});letr=this.hasListeners();r&&C(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||c(this.options.enabled,this.#t)!==c(t.enabled,this.#t)||l(this.options.staleTime,this.#t)!==l(t.staleTime,this.#t))&&this.#g();leti=this.#_();r&&(this.#t!==n||c(this.options.enabled,this.#t)!==c(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){lett=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);returnT(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){returnthis.#r}trackResult(e,t){returnnewProxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){returnthis.#t}refetch({...e}={}){returnthis.fetch({...e})}fetchOptimistic(e){lett=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);returnn.fetch().then(()=>this.createResult(n,t))}fetch(e){returnthis.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();lett=this.#t.fetch(this.options,e);returne?.throwOnError||(t=t.catch(p)),t}#g(){this.#b();lete=l(this.options.staleTime,this.#t);if(u||this.#r.isStale||!d(e))return;lett=i(this.#r.dataUpdatedAt,e)+1;this.#d=h.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeofthis.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(u||c(this.options.enabled,this.#t)===!1||!d(this.#p)||this.#p===0)&&(this.#f=h.setInterval(()=>{(this.options.refetchIntervalInBackground||g.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(h.clearTimeout(this.#d),void0)}#x(){this.#f&&=(h.clearInterval(this.#f),void0)}createResult(e,t){letn=this.#t,i=this.options,a=this.#r,s=this.#i,l=this.#a,u=e===n?this.#n:e.state,{state:d}=e,p={...d},m=!1,h;if(t._optimisticResults){letr=this.hasListeners(),a=!r&&x(e,t),o=r&&C(e,n,t,i);(a||o)&&(p={...p,...f(d.data,e.options)}),t._optimisticResults===`isRestoring`&&(p.fetchStatus=`idle`)}let{error:g,errorUpdatedAt:_,status:v}=p;h=p.data;lety=!1;if(t.placeholderData!==void0&&h===void0&&v===`pending`){lete;a?.isPlaceholderData&&t.placeholderData===l?.placeholderData?(e=a.data,y=!0):e=typeoft.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void0&&(v=`success`,h=o(a?.data,e,t),m=!0)}if(t.select&&h!==void0&&!y)