1import{a7 as N,ay as o,a8 as E,ac as U,az as k,aA as B,aB as A,aC as y,aD as H,aE as V,aF as M,ab as F,r as p,ad as x,i as z}from"./index-BxLXqTQ2.js";var st=class extends N{#e;#t=void 0;#f=void 0;#s=void 0;#a;#c;#i;#p;#u;#l;#n;#o;#r;#d=new Set;constructor(t,e){super(),this.options=e,this.#e=t,this.#i=null,this.bindMethods(),this.setOptions(e)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Q(this.#t,this.options)?this.#h():this.updateResult(),this.#S())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return O(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return O(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#g(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof o(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
1this.#E(),this.#t.setOptions(this.options),e._defaulted&&!E(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P(this.#t,s,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==s||o(this.options.enabled,this.#t)!==o(e.enabled,this.#t)||o(this.options.staleTime,this.#t)!==o(e.staleTime,this.#t))&&this.#R();const r=this.#v();i&&(this.#t!==s||o(this.options.enabled,this.#t)!==o(e.enabled,this.#t)||r!==this.#r)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return E(this.getCurrentResult(),s)||(this.#s=s,this.#c=this.options,this.#a=this.#t.state),s}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:(s,i)=>(this.trackProp(i),e?.(i),Reflect.get(s,i))})}trackProp(t){this.#d.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);let i=()=>{},r;const c=new Promise(n=>{r=n,i=this.#e.getQueryCache().subscribe(u=>{u.type==="updated"&&u.query.queryHash===s.queryHash&&s.state.data!==void 0&&(i(),n(this.createResult(s,e)))})});return Promise.race([s.fetch().then(()=>{const n=this.createResult(s,e);return r?.(n),n}).finally(()=>{i()}),c])}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#h(t){this.#E();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(U)),e}#b(t){return!k()&&o(this.options.enabled,this.#t)!==!1&&B(t)}#R(){this.#m();const t=o(this.options.staleTime,this.#t);if(this.#s.isStale||!this.#b(t))return;const e=A(this.#s.dataUpdatedAt,t)+1;this.#n=y.setTimeout(()=>{this.#s.isStale||this.updateResult()},e)}#v(){return o(this.options.refetchInterval,this.#t)??!1}#y(t){this.#g(),this.#r=t,!(this.#r===0||!this.#b(this.#r))&&(this.#o=y.setInterval(()=>{(this.options.refetchIntervalInBackground||H.isFocused())&&this.#h()},this.#r))}#S(){this.#R(),this.#y(this.#v())}#m(){this.#n!==void 0&&(y.clearTimeout(this.#n),this.#n=void 0)}#g(){this.#o!==void 0&&(y.clearInterval(this.#o),this.#o=void 0)}createResult(t,e){const s=this.#t,i=this.options,r=this.#s,c=this.#a,n=this.#c,u=t!==s?t.state:this.#f,{state:l}=t;let a={...l},d=!1,h;if(e._optimisticResults){const f=this.hasListeners(),D=!f&&Q(t,e),L=f&&P(t,s,e,i);(D||L)&&(a={...a,...V(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:R,errorUpdatedAt:v,status:b}=a;h=a.data;let T=!1;if(e.placeholderData!==void 0&&h===void 0&&b==="pending"){let f;r?.isPlaceholderData&&e.placeholderData===n?.placeholderData?(f=r.data,T=!0):f=typeof e.placeholderData=="function"?e.placeholderData(this.#l?.state.data,this.#l):e.placeholderData,f!==void 0&&(b="success",h=M(r?.data,f,e),d=!0)}if(e.select&&h!==void 0&&!T)if(r&&h===c?.data&&e.select===this.#p)h=this.#u;else try{this.#p=e.select,h=e.select(h),h=M(r?.data,h,e),this.#u=h,this.#i=null}catch(f){this.#i=f}else h===void 0&&(this.#i=null);this.#i&&(R=this.#i,h=this.#u,v=Date.now(),b="error",d=!1);const S=a.fetchStatus==="fetching",m=b==="pending",g=b==="error",w=m&&S,I=h!==void 0;return{status:b,fetchStatus:a.fetchStatus,isPending:m,isSuccess:b==="success",isError:g,isInitialLoading:w,isLoading:w,data:h,dataUpdatedAt:a.dataUpdatedAt,error:R,errorUpdatedAt:v,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:a.dataUpdateCount>u.dataUpdateCount||a.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!m,isLoadingError:g&&!I,isPaused:a.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:g&&I,isStale:C(t,e),refetch:this.refetch,isEnabled:o(e.enabled,t)!==!1}}updateResult(){const t=this.#s,e=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#c=this.options,this.#a.data!==void 0&&(this.#l=this.#t),E(e,t))return;this.#s=e;const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,c=typeof r=="function"?r():r;if(c==="all"||!c&&!this.#d.size)return!0;const n=new Set(c??this.#d);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(u=>{const l=u;return this.#s[l]!==t[l]&&n.has(l)})})();F.batch(()=>
1{i&&this.listeners.forEach(r=>{r(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}#E(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#f=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#S()}};function W(t,e){return o(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&o(e.retryOnMount,t)===!1)}function Q(t,e){return W(t,e)||t.state.data!==void 0&&O(t,e,e.refetchOnMount)}function O(t,e,s){if(o(e.enabled,t)!==!1&&o(e.staleTime,t)!=="static"){const i=o(s,t);return i==="always"||i!==!1&&C(t,e)}return!1}function P(t,e,s,i){return(t!==e||o(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&C(t,s)}function C(t,e){return o(e.enabled,t)!==!1&&t.isStaleByTime(o(e.staleTime,t))}const _=p.createContext(!1),j=()=>p.useContext(_);_.Provider;function K(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}const G=p.createContext(K()),J=()=>p.useContext(G),X=(t,e,s)=>{const i=s?.state.error&&typeof t.throwOnError=="function"?x(t.throwOnError,[s.state.error,s]):t.throwOnError;(t.suspense||i)&&(e.isReset()||(t.retryOnMount=!1))},Y=t=>{p.useEffect(()=>{t.clearReset()},[t])},Z=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||x(s,[t.error,i])),it=(t,e)=>e.state.data===void 0,$=t=>{if(t.suspense){const s=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>s(i(...r)):s(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},q=(t,e)=>t?.suspense&&e.isPending,tt=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function rt(t,e,s){const i=j(),r=J(),c=z(),n=c.defaultQueryOptions(t),u=c.getQueryCache().get(n.queryHash),l=t.subscribed!==!1;n._optimisticResults=i?"isRestoring":l?"optimistic":void 0,$(n),X(n,r,u),Y(r);const[a]=p.useState(()=>new e(c,n)),d=a.getOptimisticResult(n),h=!i&&l;if(p.useSyncExternalStore(p.useCallback(R=>{const v=h?a.subscribe(F.batchCalls(R)):U;return a.updateResult(),v},[a,h]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),p.useEffect(()=>{a.setOptions(n)},[n,a]),q(n,d))throw tt(n,a,r);if(Z({result:d,errorResetBoundary:r,throwOnError:n.throwOnError,query:u,suspense:n.suspense}))throw d.error;return n.notifyOnChangeProps?d:a.trackResult(d)}export{st as Q,it as d,rt as u};
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.