1import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{C as r,E as i,S as a,T as o,_ as s,b as c,g as l,h as u,m as d,p as f,v as p,w as m,x as h,y as g}from"./index-Cbnr50HK.js";var _=class extends l{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),y(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return b(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return b(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof h(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!a(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&x(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||h(this.options.enabled,this.#t)!==h(t.enabled,this.#t)||h(this.options.staleTime,this.#t)!==h(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||h(this.options.enabled,this.#t)!==h(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return a(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(g)),t}#h(e){return!s()&&h(this.options.enabled,this.#t)!==!1&&p(e)}#g(){this.#b();let e=h(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=m(this.#r.dataUpdatedAt,e)+1;this.#u=o.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=o.setInterval(()=>{(this.options.refetchIntervalInBackground||u.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(o.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(o.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:l}=e,u={...l},d=!1,p;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&y(e,t),o=i&&x(e,n,t,r);(a||o)&&(u={...u,...f(l.data,e.options)}),t._optimisticResults===`isRestoring`&&(u.fetchStatus=`idle`)}let{error:m,errorUpdatedAt:g,status:_}=u;p=u.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&_===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,v=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(_=`success`,p=c(i?.data,e,t),d=!0)}if(t.select&&p!==void 0&&!v){if(i&&p===a?.data&&t.select===this.#s)p=this.#c;else try{this.#s=t.select,p=t.select(p),p=c(i?.data,p,t),this.#c=p,this.#o=null}catch(e){this.#o=e}}else p===void 0&&(this.#o=null);this.#o&&(m=this.#o,p=this.#c,g=Date.now(),_=`error`,d=!1);let b=u.fetchStatus===`fetching`,C=_===`pending`,w=_===`error`,T=C&&b,E=p!==void 0;return{status:_,fetchStatus:u.fetchStatus,isPending:C,isSuccess:_===`
1success`,isError:w,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>s.dataUpdateCount||u.errorUpdateCount>s.errorUpdateCount,isFetching:b,isRefetching:b&&!C,isLoadingError:w&&!E,isPaused:u.fetchStatus===`paused`,isPlaceholderData:d,isRefetchError:w&&E,isStale:S(e,t),refetch:this.refetch,isEnabled:h(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),a(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();d.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function v(e,t){return h(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||h(t.retryOnMount,e)!==!1)}function y(e,t){return v(e,t)||e.state.data!==void 0&&b(e,t,t.refetchOnMount)}function b(e,t,n){if(h(t.enabled,e)!==!1&&h(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&S(e,t)}return!1}function x(e,t,n,r){return(e!==t||h(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&S(e,n)}function S(e,t){return h(t.enabled,e)!==!1&&e.isStaleByTime(h(t.staleTime,e))}var C=e(t(),1),w=C.createContext(!1),T=()=>C.useContext(w);w.Provider,n();function E(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var D=C.createContext(E()),O=()=>C.useContext(D),k=(e,t,n)=>{let i=n?.state.error&&typeof e.throwOnError==`function`?r(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||i)&&(t.isReset()||(e.retryOnMount=!1))},A=e=>{C.useEffect(()=>{e.clearReset()},[e])},j=({result:e,errorResetBoundary:t,throwOnError:n,query:i,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(a&&e.data===void 0||r(n,[e.error,i])),M=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},N=(e,t)=>e?.suspense&&t.isPending,P=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function F(e,t,n){let r=T(),a=O(),o=i(n),s=o.defaultQueryOptions(e),c=o.getQueryCache().get(s.queryHash),l=e.subscribed!==!1;s._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,M(s),k(s,a,c),A(a);let[u]=C.useState(()=>new t(o,s)),f=u.getOptimisticResult(s),p=!r&&l;if(C.useSyncExternalStore(C.useCallback(e=>{let t=p?u.subscribe(d.batchCalls(e)):g;return u.updateResult(),t},[u,p]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),C.useEffect(()=>{u.setOptions(s)},[s,u]),N(s,f))throw P(s,u,a);if(j({result:f,errorResetBoundary:a,throwOnError:s.throwOnError,query:c,suspense:s.suspense}))throw f.error;return s.notifyOnChangeProps?f:u.trackResult(f)}function I(e,t){return F(e,_,t)}export{I as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.