reactjrx 1.88.0 → 1.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var bt=Object.defineProperty;var gt=(s,e,t)=>e in s?bt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(gt(s,typeof e!="symbol"?e+"":e,t),t),De=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(De(s,e,"read from private field"),t?t.call(s):e.get(s)),$=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},M=(s,e,t,n)=>(De(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),r=require("rxjs"),K=require("rxjs/operators"),Ke=require("react/jsx-runtime");function mt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const we=mt(v),A=s=>{const e=v.useRef(s);return v.useMemo(()=>{e.current=s},[s]),e};function yt(s,e){return typeof s=="string"&&s===e||typeof s=="number"&&s===e||typeof s=="boolean"&&s===e||typeof s=="symbol"&&s===e||typeof s=="bigint"&&s===e||typeof s>"u"&&s===e||s===null&&s===e}function fe(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,unsubscribeOnUnmount:!0},i=!t&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=v.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),l=A(n),h=v.useCallback(b=>{const d=a.current,g=(typeof d=="function"?d:()=>d)().pipe(r.distinctUntilChanged(yt),r.tap(m=>{u.current=m}),r.catchError(m=>(console.error(m),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&g.unsubscribe()}},[...i]),f=v.useCallback(()=>u.current,[]);return v.useSyncExternalStore(h,f,f)}function Ne(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function F(s){if(r.isObservable(s))return s;if(Ne(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ne(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Fe(s,e=[]){const t=A(s);v.useEffect(()=>{const n=F(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=v.useRef();return e.current||(e.current=s()),v.useEffect(()=>{process.env.NODE_ENV},[]),e},Re=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=v.useRef(!1),i=A(s),u=A(e);return v.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},St=()=>{const s=Re(),e=A(s.current.asObservable()),t=v.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Ue=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=v.useRef(!1),n=v.useRef(s);return v.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},vt=s=>{const e=Ue(s),t=A(e.current.asObservable()),n=v.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function Ot(s={}){const e={default:s.default,key:s.key},{default:t}=e??{},n=new r.BehaviorSubject(t),i=a=>{if(typeof a=="function"){const l=a(n.getValue());if(l===n.getValue())return;n.next(l);return}if(a===Je){n.next(t??void 0);return}n.next(a)},u=()=>n.getValue();if("get"in s){const a=h=>(h.subject.pipe(r.skip(1),r.first()).subscribe(()=>{var o;const f=(o=s.get)==null?void 0:o.call(s,a);i(f)}),h.getValue()),l=s.get(a);return i(l),{getValue:u,config:s,subject:n}}return{setValue:i,getValue:u,config:e,subject:n}}function wt(s,e){const n=e??(()=>s.getValue());return fe(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const $t=s=>({getItem:async e=>{const t=await s.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{await s.setItem(e,JSON.stringify(t))},removeItem:async e=>{},clear:async()=>{}}),Ee=s=>{if(!(!s||typeof s!="object"))return s},Ct=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ee(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ee(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ee(i)??{};await s.setItem(e,{...u,[t]:n})}}),Xe=({key:s}={})=>s?Ct({adapter:Xe(),key:s}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},se="__reactjrx",Et=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const qe=s=>{const e=Ue(s);return v.useEffect(()=>{e.current.next(s)},[s,e]),e},He=({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[se]:se,migrationVersion:t};return r.from(s.setItem(e.config.key,i)).pipe(r.catchError(u=>(console.error(u),r.of(null))))},Mt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=Et(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),jt=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=qe(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>{if(!f)return r.of(!1);const o=h.length===0?r.of(!0):r.zip(...h.map(({signal:b,version:d})=>Mt({adapter:f,signal:b,version:d}).pipe(r.mergeMap(()=>He({adapter:f,signal:b,version:d}))))).pipe(r.map(()=>!0));return r.merge(r.of(!1),o).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))}))},{defaultValue:!1},[u,n]),l=qe(a);return Fe(()=>l.current.pipe(r.filter(h=>h),r.switchMap(()=>u.current),r.filter(me),r.switchMap(h=>r.merge(...n.current.map(({signal:f,version:o})=>f.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(He({adapter:h,signal:f,version:o})))))))),[l,u]),{isHydrated:a}},Ft=()=>{const s=Re({onBeforeComplete:()=>{s.current.next()}});return s};function Ze(s,e){return Math.min(s,e)}function et(s,e){return Math.pow(2,s)*e}function xe(s){const{retry:e,retryDelay:t,retryAfterDelay:n,retryAfter:i=()=>r.of(!0)}=s,u=typeof e!="function"?e===!1?0:e===!0?1/0:e??1/0:1/0,a=typeof e=="function"?e:()=>!0,l=typeof t=="number"?t:100,h={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:o=!1,backoffDelay:b=et}=h;return d=>r.defer(()=>{let p=0;const g=(m,O)=>m<u?a(m,O):!1;return d.pipe(K.catchError(m=>{var w;if(p++,!g(p-1,m))throw m;const O=(w=s.caughtError)==null?void 0:w.call(s,p,m);if(!O)throw m;return O.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>m))))}),K.retryWhen(m=>m.pipe(K.concatMap(O=>{const w=p-1;return i().pipe(K.first(),K.mergeMap(()=>g(w,O)?r.timer(Ze(b(w,l),f)).pipe(K.mergeMap(k=>n&&!n(w,O)?r.throwError(()=>O):r.of(k))):r.throwError(()=>O)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(p,m);throw m}),K.tap(()=>{o&&(p=0)}))})}const Rt=(s,e)=>s.length===e.length&&s.every((t,n)=>t===e[n]);function Le(s){return Object.prototype.toString.call(s)==="[object Object]"}function Me(s){if(!Le(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!Le(t)||!t.hasOwnProperty("isPrototypeOf"))}const re=s=>JSON.stringify(s,(e,t)=>Me(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Ae=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),J=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function Qe(s){let e=0;return function(n){return new r.Observable(i=>{e++;const u=n.subscribe(i);return s(e),()=>{e--,s(e),u.unsubscribe()}})}}const ne=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var H;class Ut{constructor({__queryFinalizeHook:e}={}){$(this,H,new r.Subject);y(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,H).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const l=a.mapOperator??"merge",h=c(this,H).pipe(r.filter(()=>l==="merge")),f=c(this,H).pipe(r.filter(()=>l==="switch"),r.tap(()=>{u.cancel()})),o=r.defer(()=>(u.execute(i),r.EMPTY)),b=u.state$.pipe(ne,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,H))),d=u.state$.pipe(ne,r.skip(1)),p=r.merge(n,h,f,u.cancelled$);return r.merge(d,b,o).pipe(r.map(g=>({state:g,mutation:u})),e??r.identity,r.takeUntil(p))}),r.shareReplay({refCount:!0,bufferSize:1}),Qe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,H).next({args:e,options:t,mutation:n})}}H=new WeakMap;function Ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ce(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ce(s,e);function R(s,e){if(s==null||e===void 0||typeof s!="object"||typeof e!="object")return s===e;if(s.constructor!==(e==null?void 0:e.constructor))return!1;const t=Object.keys(s),n=Object.keys(e);if(t.length!==n.length)return!1;for(const i of t)if(!e.hasOwnProperty(i)||s[i]!==e[i])return!1;return!0}const tt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>R(t,i)&&R(e,n)));var z,I;class xt{constructor(e,t={},n){$(this,z,void 0);$(this,I,new r.BehaviorSubject(void 0));y(this,"observed$");y(this,"getObserverResultFromState",e=>({...J(),...e,isSuccess:e.status==="success",isPending:e.status==="pending",isIdle:e.status==="idle",isError:e.status==="error",mutate:this.mutate,reset:this.reset}));var i;this.client=e,this.options=t,this.options.mutationKey=((i=this.options)==null?void 0:i.mutationKey)??[Ae()],M(this,z,n??new Ut(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter(me),r.mergeMap(u=>c(this,z).state$.pipe(r.takeUntil(u.mutation.state$.pipe(ne,r.last()))))).subscribe(),this.observed$=c(this,I).pipe(r.switchMap(u=>(u==null?void 0:u.mutation.state$.pipe(r.map(a=>({state:a,options:u.options}))))??r.EMPTY),r.tap(({state:u,options:a})=>{u.status==="error"&&(a!=null&&a.onError&&(a==null||a.onError(u.error,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context))),u.status==="success"&&(a!=null&&a.onSuccess&&(a==null||a.onSuccess(u.data,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context)))}),r.ignoreElements())}setOptions(e){var i;const t=this.options;this.options=this.client.defaultMutationOptions({mutationKey:this.options.mutationKey,...e});const n=(i=c(this,I).getValue())==null?void 0:i.mutation;this.options.mutationKey&&t.mutationKey&&!ye(this.options.mutationKey,t.mutationKey,{exact:!0})?this.reset():n==null||n.setOptions(this.options)}observe(){var u;const e=this.getObserverResultFromState(((u=c(this,I).getValue())==null?void 0:u.mutation.state)??J()),t=c(this,z).state$.pipe(r.distinctUntilChanged(({mutation:a,state:{data:l,...h}},{mutation:f,state:{data:o,...b}})=>a===f&&R(h,b)&&R(l,o)),r.map(({state:a})=>a),r.scan((a,l)=>({...a,...l,...l.status==="pending"&&{data:l.data??a.data},...l.status==="pending"&&{error:l.error??a.error}})),r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter(me),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(J())));return{result$:r.merge(this.observed$,t,n).pipe(tt),lastValue:e}}subscribe(e){const t=this.observe().result$.subscribe(n=>{e(n)});return()=>{t.unsubscribe()}}async mutate(e,t={}){const n=this.client.getMutationCache().build(this.client,this.options);return c(this,I).next({mutation:n,options:t}),c(this,z).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(ne,r.last()).subscribe({error:a=>{u(a)},next:a=>{a.error?u(a.error):i(a.data)}})})}getCurrentResult(){var t;const e=this.client.getMutationCache().find({exact:!0,mutationKey:(t=this.options)==null?void 0:t.mutationKey});return this.getObserverResultFromState((e==null?void 0:e.state)??J())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}z=new WeakMap,I=new WeakMap;const rt=v.createContext(void 0),At=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Qt=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(rt.Provider,{value:t,children:[Ke.jsx(At,{client:e}),s]})}),Pe=s=>{const e=v.useContext(rt);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Pt(){}function kt(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=v.useState(()=>new xt(t,s));v.useEffect(()=>{a.setOptions(s)},[a,s]);const l=v.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=v.useCallback((o,b)=>{a.mutate(o,b).catch(Pt)},[a]);return v.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function Vt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const X=typeof window>"u"||"Deno"in window;class It{constructor(){y(this,"isOnlineSubject",new r.BehaviorSubject(!0));y(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));y(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(X?r.EMPTY:r.fromEvent(window,"offline").pipe(r.map(()=>!1)),X?r.EMPTY:r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(Vt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new It;function ke(s,e){return s.isStaleByTime(e.staleTime)}function Tt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function We(s,e){return Tt(s,e)||s.state.dataUpdatedAt>0&&st(s,e,e.refetchOnMount)}function _e(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&ke(s,t)}function Dt(s,e){return st(s,e,e.refetchOnWindowFocus)}function st(s,e,t){if(e.enabled!==!1){const n=typeof t=="function"?t(s):t;return n==="idle"?s.state.fetchStatus==="idle":n==="always"||n!==!1&&ke(s,e)}return!1}function Kt(s){return(s??"online")==="online"?_.isOnline():!0}function ze(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function Be(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function nt(s,e){if(s===e)return s;const t=Be(s)&&Be(e);if(t||Me(s)&&Me(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,l=t?[]:{};let h=0;for(let f=0;f<a;f++){const o=t?f:u[f];!t&&s[o]===void 0&&e[o]===void 0&&n.includes(o)?(l[o]=void 0,h++):(l[o]=nt(s[o],e[o]),l[o]===s[o]&&s[o]!==void 0&&h++)}return i===a&&h===i?s:l}return e}function Ve(s,e){return((e==null?void 0:e.queryKeyHashFn)??re)(s)}function Ye(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:l}=s;if(a){if(n){if(e.queryHash!==Ve(a,e.options))return!1}else if(!Ce(e.queryKey,a))return!1}if(t!=="all"){const h=e.isActive();if(t==="active"&&!h||t==="inactive"&&h)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Nt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function qt(s,e){return typeof s=="function"?s(e):s}function Se(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?nt(s,e):e}const je=Symbol(),Ht=({getOptions:s,getState:e,initialState:t})=>n=>n.pipe(r.scan((i,{command:u,state:a})=>{if(u==="reset")return{...i,...a};if(u==="cancel"){const E=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:E}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,o=a.status==="success",b=i.data!==void 0,d=i.error!==void 0||i.error!==null,p=a.status??i.status,g=h?Se(e().data,l,s()):f?a.data:i.data,m=i.status==="error"||i.status==="success",O=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,w=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&m&&(b||d),U=p==="pending"?null:a.error??i.error;return{...i,...a,status:p,error:U,errorUpdateCount:O,...o&&{isInvalidated:!1},data:g,dataUpdateCount:w,...k&&{status:i.status}}},t)),Lt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),it=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,L;class Wt{constructor(){$(this,Oe,r.merge(X?r.EMPTY:r.fromEvent(document,"visibilitychange"),X?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));$(this,L,new r.BehaviorSubject(X?!0:document.visibilityState==="visible"));y(this,"focused$",c(this,L));y(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Oe).pipe(r.tap(e=>{c(this,L).next(e==="visible")})).subscribe()}isFocused(){return c(this,L).getValue()}setFocused(e){c(this,L).getValue()!==(e??!0)&&c(this,L).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Oe=new WeakMap,L=new WeakMap;const ve=new Wt,_t=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(R));var q,C,ie,B,x,Z,ae;class at{constructor(e,t){$(this,q,void 0);$(this,C,void 0);$(this,ie,new r.Subject);y(this,"queryUpdateSubject",new r.Subject);$(this,B,void 0);$(this,x,void 0);$(this,Z,void 0);$(this,ae,0);y(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:l,selectError:h,selectResult:f}})=>{var ge;const o=t.state,b=t.state.status==="pending",d=c(this,C),p=this.options,m=t!==d?t.state:c(this,B);let{errorUpdatedAt:O,fetchStatus:w,error:k}=o;if(n){const Q=!!c(this,ae),Te=!Q&&We(t,e),pt=Q&&_e(t,d,e,p);(Te||pt)&&(w=Kt(t.options.networkMode)?"fetching":"paused")}const U=b&&w==="fetching";let E,S=h,T=l??null,D=f;if(e.select&&typeof o.data<"u")if(i&&o.data===(a==null?void 0:a.data)&&e.select===l)E=f;else try{T=e.select,E=e.select(o.data),E=Se(i==null?void 0:i.data,E,e),D=E,S=null}catch(Q){E=f,S=Q}else E=o.data,S=null;let V=w!=="idle"&&!o.dataUpdatedAt?"pending":o.status;S&&(k=S,E=f,O=(i==null?void 0:i.errorUpdatedAt)??O,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof E>"u"&&V==="pending"){let Q;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))Q=i.data;else if(Q=typeof e.placeholderData=="function"?e.placeholderData((ge=c(this,Z))==null?void 0:ge.state.data,c(this,Z)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=Se(i==null?void 0:i.data,Q,e),pe=!0)}const be=w==="fetching";return{result:{status:V,fetchStatus:w,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:o.dataUpdatedAt,error:k,errorUpdatedAt:O,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>m.dataUpdateCount||o.errorUpdateCount>m.errorUpdateCount,isFetching:be,isRefetching:be&&!b,isLoadingError:de&&o.dataUpdatedAt===0,isPaused:w==="paused",isPlaceholderData:pe,isRefetchError:de&&o.dataUpdatedAt!==0,isStale:ke(t,e),refetch:this.refetch},selectError:S,select:T,selectResult:D}});this.options=t,M(this,q,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,B,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});M(this,x,{state:n.state,options:t,result:i,select:u})}bindMethods(){this.refetch=this.refetch.bind(this)}setOptions(e){const t=this.options;if(this.options=c(this,q).defaultQueryOptions(e),R(this.options,t)||c(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,C),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");const n=this.buildQuery(this.options);return n!==c(this,C)&&(M(this,B,n.state),M(this,C,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,q).getQueryCache().build(c(this,q),e);return!t.options.queryFn&&this.options.queryFn&&t.setOptions(e),t}getCurrentResult(){return this.getObserverResultFromQuery({options:this.options,prevResult:c(this,x),query:c(this,C)}).result}getCurrentQuery(){return c(this,C)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:c(this,x)});return zt(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){c(this,x).state=e.state,c(this,x).result=t,c(this,x).selectResult=u,n!==void 0&&(c(this,x).selectError=n),i!==void 0&&(c(this,x).select=i),c(this,x).options=this.options,e.state.data!==void 0&&M(this,Z,e),c(this,q).getQueryCache().notify({query:c(this,C),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==c(this,C)&&(M(this,C,t),M(this,B,t.state),this.queryUpdateSubject.next({options:this.options,query:t}));const n={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0};c(this,C).fetch(this.options,n).catch(r.noop),c(this,ie).next({query:t,fetchOptions:n}),await t.getFetchResultAsPromise();const{result:i}=this.getObserverResultFromQuery({query:t,options:this.options,prevResult:c(this,x)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=c(this,C),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(c(this,C)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:c(this,C),options:this.options}),r.pairwise(),r.tap(([{options:a,query:l},{options:h,query:f}])=>{_e(f,l,h,a)&&this.fetch().catch(r.noop)}),r.ignoreElements()),i=t.pipe(r.switchMap(a=>a.observe(this)),r.ignoreElements());return r.merge(i,n,t.pipe(r.switchMap(a=>{const l=this.options,h=this.queryUpdateSubject.pipe(r.startWith({query:a,options:l}),r.filter(S=>S.query===a),r.map(S=>S.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ie).pipe(r.filter(S=>S.query===a)),o=a.state$.pipe(_t,r.switchMap(S=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(S).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(S,T)=>{const D=l.notifyOnChangeProps,V=typeof D=="function"?D():D;return(Array.isArray(V)?V.length===0?()=>!0:(pe,be)=>{const Ie=ze(pe,V),ge=ze(be,V);return R(Ie,ge)}:R)(S,T)},d=f.pipe(r.switchMap(()=>a.state$),it),p=h.pipe(r.map(({refetchInterval:S,refetchIntervalInBackground:T})=>({refetchInterval:(typeof S=="function"?S(c(this,C)):S)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(R),r.switchMap(({refetchInterval:S,refetchIntervalInBackground:T})=>S?r.interval(S).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),g=h.pipe(r.map(({enabled:S})=>S??!0),r.distinctUntilChanged()),m=g.pipe(r.filter(S=>!S),r.map(()=>a.state)),O=g.pipe(r.filter(S=>S),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,S])=>{Dt(a,S)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),w=m.pipe(r.map(()=>a.state)),k=S=>S.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:c(this,x)});return this.updateResult({query:a,...D}),D.result})),E=r.merge(w,d,a.state$,o).pipe(k,r.distinctUntilChanged(R),r.distinctUntilChanged(b));return r.merge(p,O,E)})).pipe(Qe(a=>M(this,ae,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,C=new WeakMap,ie=new WeakMap,B=new WeakMap,x=new WeakMap,Z=new WeakMap,ae=new WeakMap;function zt(s,e){return!R(s.getCurrentResult(),e)}const ut=we.createContext(!1),Bt=()=>we.useContext(ut);ut.Provider;function Yt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Gt=we.createContext(Yt()),Jt=()=>we.useContext(Gt);function Xt(s,e){return typeof s=="function"?s(...e):!!s}const Zt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Xt(t,[s.error,n]);function ct(s,e,t){if(process.env.NODE_ENV!=="production"&&(typeof s!="object"||Array.isArray(s)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Pe(t),i=Bt(),u=Jt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=v.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=A(l.getOptimisticResult(a)),o=f.current;fe(()=>h.current.pipe(r.filter(d=>!R(d,f.current))),[]),v.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&Zt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function er(s,e){return ct(s,at,e)}function tr(s,e){return ct({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},at,e)}function rr(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(h=>{console.error(h)})),a=v.useCallback(()=>F(s),t),l=v.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Fe(l,t)}const ot=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),sr=s=>{let e=0;return s.pipe(r.catchError(t=>(e++,e<=1&&!_.isOnline()?r.merge(r.of({failureCount:e,failureReason:t}),r.timer(1).pipe(r.mergeMap(()=>r.throwError(()=>t).pipe(ot())))):r.throwError(()=>t))))},nr=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,l=r.iif(()=>n,r.of(e.context),F(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0})).pipe(r.shareReplay(1)),h=(d,p,g)=>F(()=>{var O;return(O=t.onError)==null?void 0:O.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:g,error:d,failureReason:d,context:p,status:"error"}))),f=l.pipe(r.switchMap(d=>{const g=(typeof u=="function"?F(()=>u(s)):u).pipe(r.map(m=>({result:{data:m},error:null,context:d})),sr,xe({...t,retry:(m,O)=>{const w=t.retry??0;return typeof w=="function"?w(m,O):typeof w=="boolean"?w:m<w},caughtError:(m,O)=>r.of({failureCount:m,failureReason:O}),catchError:(m,O)=>h(O,d,m).pipe(r.map(w=>({...w,result:void 0})))}),r.takeWhile(({result:m,error:O})=>(m==null?void 0:m.data)===void 0&&O===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?g:g.pipe(ot())})),o=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(o,l.pipe(r.map(d=>({context:d}))),f.pipe(r.switchMap(({result:d,error:p,...g})=>{if(!d&&!p)return r.of({...g});const m=p?r.of(null):F(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,d==null?void 0:d.data,s,g.context)}),w=F(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,d==null?void 0:d.data,p,s,g.context)}).pipe(r.catchError(U=>d?r.of(d):r.of(U)));return r.concat(m,w).pipe(r.toArray(),r.map(()=>p?{error:p,data:void 0,variables:s,...g}:{status:"success",error:p,data:d==null?void 0:d.data,variables:s,failureCount:0,failureReason:null,...g}),r.catchError(U=>h(U,g.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),J()))};var ue,W,ee;class ir{constructor({options:e,mutationCache:t,state:n}){$(this,ue,new r.BehaviorSubject(0));$(this,W,new r.Subject);$(this,ee,new r.Subject);y(this,"state",J());y(this,"state$");y(this,"options");y(this,"observerCount$",c(this,ue).asObservable());y(this,"cancelled$",c(this,W).asObservable());this.options=e,this.state=n??this.state;const i=c(this,W).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=c(this,ee).pipe(r.switchMap(l=>nr({options:{...this.options,onMutate:h=>{const f=F(()=>{var p,g;return(g=(p=t.config).onMutate)==null?void 0:g.call(p,h,this)}),b=F(()=>{var p,g;return(g=(p=this.options).onMutate)==null?void 0:g.call(p,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onError)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onError)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())},onSettled:(h,f,o,b)=>{const d=F(()=>{var g,m;return(m=(g=t.config).onSettled)==null?void 0:m.call(g,h,f,o,b,this)}),p=F(()=>{var g,m;return(m=(g=this.options).onSettled)==null?void 0:m.call(g,h,f,o,b)});return r.concat(d,p).pipe(r.toArray())},onSuccess:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onSuccess)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onSuccess)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(c(this,W))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),tt,r.tap(l=>{this.state=l}),r.shareReplay(1),Qe(l=>{c(this,ue).next(l)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,ee).next(e),c(this,ee).complete(),this.state$.pipe(ne)}continue(){return this.execute(this.state.variables)}cancel(){c(this,W).next(),c(this,W).complete()}}ue=new WeakMap,W=new WeakMap,ee=new WeakMap;const Ge=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class lt{constructor(){y(this,"entriesSubject",new r.BehaviorSubject([]));y(this,"changeSubject",new r.Subject);y(this,"entries$",this.entriesSubject.pipe(r.share()));y(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));y(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));y(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var P;class ht{constructor(e={}){$(this,P,new lt);this.config=e}build(e,t,n){const i=new ir({mutationCache:this,options:e.defaultMutationOptions(t),state:n});return i.state$.pipe(r.filter(({status:u})=>u==="success"||u==="error"),r.switchMap(()=>i.observerCount$.pipe(r.filter(u=>u<=1),r.take(1))),r.switchMap(()=>r.timer(i.options.gcTime??5*60*1e3)),r.take(1)).subscribe({complete:()=>{this.remove(i)}}),c(this,P).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,P).getValues().find(n=>n===e);t==null||t.cancel(),c(this,P).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,P).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,P).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,P).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,P).stateChange$.pipe(r.tap(n=>{e({type:"updated",action:{...n.state,type:"success"},mutation:n})}))).subscribe();return()=>{t.unsubscribe()}}resumePausedMutations(){const e=this.findAll({predicate:n=>n.state.isPaused});if(!e.length)return r.EMPTY;const t=e.map(n=>n.continue());return r.combineLatest(t)}clear(){this.getAll().forEach(e=>{this.remove(e)})}}P=new WeakMap;function ar(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=typeof e<"u",n=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}const ur=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),cr=s=>{let e=0;return t=>{const n=_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({fetchStatus:"fetching"}),t)));return r.defer(()=>(e++,!_.isOnline()&&s.networkMode==="offlineFirst"&&e>1?r.merge(r.of({fetchStatus:"paused"}),n):!_.isOnline()&&s.networkMode!=="always"&&s.networkMode!=="offlineFirst"?r.merge(r.of({fetchStatus:"paused"}),n):t))}},or=s=>e=>{const t=new r.Subject,n=t.pipe(r.first(),r.delay(1),r.mergeMap(()=>s.pipe(r.filter(i=>i===0))));return e.pipe(r.tap(()=>{t.next()}),r.takeUntil(n))},lr=s=>{const e=async()=>await Promise.reject(new Error("No query found"));process.env.NODE_ENV!=="production"&&s.queryFn===je&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`);let t=!1;const n=s.queryFn&&s.queryFn!==je?s.queryFn:e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const h=(typeof n=="function"?F(()=>n(u)):n).pipe(or(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),cr(s),xe({...s,retryAfter:()=>r.of(!0).pipe(ur),catchError:(o,b)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:o,fetchFailureReason:b,error:b}),caughtError:(o,b)=>r.of({fetchFailureCount:o,fetchFailureReason:b})}),r.mergeMap(o=>"data"in o?r.of({...o,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(b=>t?b:{...b,fetchStatus:"fetching"})):r.of(o)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,h).pipe(r.share()),abortController:i}};class hr{constructor(e){y(this,"revert");y(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const fr={backgroundColor:"transparent",color:"inherit"};function ft(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ft();return i.namespaces.push({name:t,style:n??fr}),i},printNamespaces(){return{namespaces:e.namespaces.map(({name:t})=>`%c ${t} %c`).join(" "),styles:e.namespaces.reduce((t,{style:n})=>(t.push(`background-color: ${n.backgroundColor}; color: ${n.color};`),t.push("background-color: transparent; color: inherit;"),t),[])}},print(t,...n){return e},printWithoutNamespace(t,...n){return e},log(...t){return e.print("log",...t)},warn(...t){return e.print("warn",...t)},error(...t){return e.print("error",...t)},group(...t){return e.print("group",...t)},groupEnd(){return e}};return e}const dr=ft();var ce,Y;class pr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ce,void 0);$(this,Y,void 0);y(this,"state");y(this,"executeSubject",new r.Subject);y(this,"cancelSubject",new r.Subject);y(this,"setDataSubject",new r.Subject);y(this,"invalidatedSubject",new r.Subject);y(this,"resetSubject",new r.Subject);y(this,"destroySubject",new r.Subject);y(this,"observersSubject",new r.BehaviorSubject([]));y(this,"abortSignalConsumed",!1);y(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));y(this,"observers$",this.observersSubject.asObservable());y(this,"state$");M(this,ce,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??ar(this.options)),this.state=c(this,Y),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,Y)}))),this.invalidatedSubject.pipe(r.filter(()=>!this.state.isInvalidated),r.map(()=>({command:"invalidate",state:{isInvalidated:!0}}))),this.cancelSubject.pipe(r.filter(()=>!(this.state.error&&this.state.status==="error")),r.map(t=>({command:"cancel",state:{status:t!=null&&t.revert?this.state.status:"error",fetchStatus:"idle",error:new hr(t)}}))),this.executeSubject.pipe(r.mergeMap(()=>{let t=!1;const n=this.executeSubject.pipe(r.filter(f=>(f==null?void 0:f.cancelRefetch)!==!1)),i=this.observers$.pipe(r.pairwise(),r.tap(([f,o])=>{o.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=lr({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,o)=>{const b=this.options.retry??!0;return typeof b=="function"?b(f,o):typeof b=="boolean"?b:f<b},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),l=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),h=r.merge(this.cancelSubject,n,this.resetSubject,l).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(h))})),this.setDataSubject.pipe(r.map(({data:t,options:n})=>({command:"setData",state:{status:"success",data:t,dataUpdatedAt:(n==null?void 0:n.updatedAt)!==void 0?n.updatedAt:new Date().getTime()}})))).pipe(Ht({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(R),r.tap(t=>{this.state=t}),r.catchError(t=>{throw dr.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ce),...e},this.updateGcTime(this.options.gcTime),this.options}get meta(){return this.options.meta}get success$(){return this.state$.pipe(r.map(({data:e,status:t})=>({data:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="success"||e==="error"))}observe(e){return this.state$.pipe(r.tap({subscribe:()=>{this.observersSubject.next([e,...this.observersSubject.getValue()])},unsubscribe:()=>{this.observersSubject.next(this.observersSubject.getValue().filter(n=>n!==e))}}))}getObserversCount(){return this.observersSubject.getValue().length}updateGcTime(e){return this.gcTime=Math.max(this.gcTime||0,e??(X?1/0:5*60*1e3)),this.gcTime}isActive(){return this.observersSubject.getValue().some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observersSubject.getValue().some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Nt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(it,r.last()).subscribe({error:t,next:n=>{n.error?t(n.error):e(n.data)}})})}async fetch(e,t){const{cancelRefetch:n}=t??{};return this.state.fetchStatus!=="idle"&&!(!!this.state.dataUpdatedAt&&n)?await this.getFetchResultAsPromise():(e&&this.setOptions(e),this.executeSubject.next(t),await this.getFetchResultAsPromise())}setData(e,t){const n=Se(this.state.data,e,this.options);return this.setDataSubject.next({data:n,options:t}),n}invalidate(){this.invalidatedSubject.next()}async cancel(e){this.cancelSubject.next(e)}destroy(){this.destroySubject.next(),this.destroySubject.complete(),this.executeSubject.complete()}reset(){this.resetSubject.next()}}ce=new WeakMap,Y=new WeakMap;var oe,N;class dt{constructor(e={}){$(this,oe,new r.Subject);$(this,N,new lt);this.config=e}mount(){}unmount(){}notify(e){c(this,oe).next(e)}observeIsFetching(e){return c(this,N).stateChange$.pipe(r.startWith(),r.map(()=>this.findAll({...e,fetchStatus:"fetching"}).length),r.distinctUntilChanged())}getAll(){return[...c(this,N).getValues()]}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Ye(e,n)):t}build(e,t,n){const i=t.queryKey??[Ae()],u=t.queryHash??Ve(i,t);let a=this.get(u);return a||(a=new pr({cache:this,queryKey:i,queryHash:u,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){if(!c(this,N).find(t=>t.queryHash===e.queryHash)){c(this,N).add(e);const t=e.observerCount$.pipe(r.filter(n=>n<1),r.take(1));e.success$.subscribe(()=>{var n,i;(i=(n=this.config).onSuccess)==null||i.call(n,e.state.data,e)}),e.error$.subscribe(()=>{var n,i;(i=(n=this.config).onError)==null||i.call(n,e.state.error,e)}),e.settled$.subscribe(()=>{var n,i;(i=(n=this.config).onSettled)==null||i.call(n,e.state.data,e.state.error,e)}),e.state$.pipe(Lt,r.switchMap(n=>n?t.pipe(r.switchMap(()=>e.gcTime===1/0?r.NEVER:(setTimeout(r.noop,e.gcTime),r.timer(e.gcTime)))):r.NEVER),r.take(1)).subscribe({complete:()=>{this.remove(e)}})}}get(e){return c(this,N).find(t=>t.queryHash===e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ye(t,n))}subscribe(e){const t=r.merge(c(this,oe).pipe(r.tap(e))).subscribe();return()=>{t.unsubscribe()}}remove(e){const t=c(this,N).find(n=>n===e);t&&(e.destroy(),t===e&&c(this,N).remove(e))}clear(){}}oe=new WeakMap,N=new WeakMap;var G,j,le,he,te;class br{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,G,void 0);$(this,j,void 0);$(this,le,new Map);$(this,he,new Map);$(this,te,void 0);M(this,G,e??new ht),M(this,j,t??new dt),M(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,j)}defaultMutationOptions(e){return{...c(this,te).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e._defaulted)return e;const t={...c(this,te).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ve(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.enabled!==!0&&t.queryFn===je&&(t.enabled=!1),t}async fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=c(this,j).build(this,t);return n.isStaleByTime(t.staleTime)?await n.fetch(t):await Promise.resolve(n.state.data)}async prefetchQuery(e){await this.fetchQuery(e).then(r.noop).catch(r.noop)}async resetQueries(e,t){const n=c(this,j),i={type:"active",...e};n.findAll(e).forEach(u=>{u.reset()}),await this.refetchQueries(i,t)}async refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},i=c(this,j).findAll(e).filter(u=>!u.isDisabled()).map(async u=>{let a=u.fetch(void 0,n);return n.throwOnError||(a=a.catch(r.noop)),u.state.fetchStatus==="paused"?void 0:await a});await Promise.all(i).then(r.noop)}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=c(this,j).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=c(this,j).get(i.queryHash),a=u==null?void 0:u.state.data,l=qt(t,a);if(l!==void 0)return c(this,j).build(this,i).setData(l,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,le).values()];let n={};return t.forEach(i=>{ye(e,i.mutationKey)&&(n={...n,...i.defaultOptions})}),n}getQueryState(e){var t;return(t=c(this,j).find({queryKey:e}))==null?void 0:t.state}setMutationDefaults(e,t){c(this,le).set(re(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,he).set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,he).values()];let n={};return t.forEach(i=>{Ce(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=c(this,j);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=c(this,j).findAll(e).map(async u=>{await u.cancel(n)});await Promise.all(i).then(r.noop).catch(r.noop)}async invalidateQueries(e={},t={}){if(c(this,j).findAll(e).forEach(i=>{i.invalidate()}),e.refetchType==="none"){await Promise.resolve();return}const n={...e,type:e.refetchType??e.type??"active"};await this.refetchQueries(n,t)}async resumePausedMutations(){return await r.lastValueFrom(c(this,G).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,G).clear()}}G=new WeakMap,j=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=ht;exports.QueryCache=dt;exports.QueryClient=br;exports.QueryClientProvider=Qt;exports.SIGNAL_RESET=Je;exports.arrayEqual=Rt;exports.createLocalStorageAdapter=Xe;exports.createLocalforageAdapter=$t;exports.exponentialBackoffDelay=et;exports.getDelay=Ze;exports.isDefined=me;exports.retryBackoff=xe;exports.signal=Ot;exports.useBehaviorSubject=Ue;exports.useForeverQuery=tr;exports.useLiveRef=A;exports.useMutation=kt;exports.useObservableState=vt;exports.useObserve=fe;exports.useObserveCallback=St;exports.usePersistSignals=jt;exports.useQuery=er;exports.useQueryClient=Pe;exports.useSignalValue=wt;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=rr;exports.useUnmountObservable=Ft;
1
+ "use strict";var gt=Object.defineProperty;var mt=(s,e,t)=>e in s?gt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(mt(s,typeof e!="symbol"?e+"":e,t),t),De=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(De(s,e,"read from private field"),t?t.call(s):e.get(s)),$=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},M=(s,e,t,n)=>(De(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),r=require("rxjs"),K=require("rxjs/operators"),Ke=require("react/jsx-runtime");function yt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const we=yt(v),A=s=>{const e=v.useRef(s);return v.useMemo(()=>{e.current=s},[s]),e};function St(s,e){return typeof s=="string"&&s===e||typeof s=="number"&&s===e||typeof s=="boolean"&&s===e||typeof s=="symbol"&&s===e||typeof s=="bigint"&&s===e||typeof s>"u"&&s===e||s===null&&s===e}function fe(s,e,t){const n=e!=null&&!Array.isArray(e)?e:{defaultValue:void 0,unsubscribeOnUnmount:!0},i=!t&&Array.isArray(e)?e:typeof s=="function"?t??[]:[s],u=v.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),l=A(n),h=v.useCallback(b=>{const d=a.current,g=(typeof d=="function"?d:()=>d)().pipe(r.distinctUntilChanged(St),r.tap(m=>{u.current=m}),r.catchError(m=>(console.error(m),r.EMPTY))).subscribe(b);return()=>{l.current.unsubscribeOnUnmount!==!1&&g.unsubscribe()}},[...i]),f=v.useCallback(()=>u.current,[]);return v.useSyncExternalStore(h,f,f)}function Ne(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function F(s){if(r.isObservable(s))return s;if(Ne(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ne(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Fe(s,e=[]){const t=A(s);v.useEffect(()=>{const n=F(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const $e=s=>{const e=v.useRef();return e.current||(e.current=s()),v.useEffect(()=>{process.env.NODE_ENV},[]),e},Re=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=$e(()=>new r.Subject),n=v.useRef(!1),i=A(s),u=A(e);return v.useEffect(()=>(n.current&&(t.current=new r.Subject,n.current=!1),()=>{if(!u.current){n.current=!0;return}n.current||(i.current!=null&&i.current(),t.current.complete(),n.current=!0)}),[u,i,t]),t},vt=()=>{const s=Re(),e=A(s.current.asObservable()),t=v.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Ue=s=>{const e=$e(()=>new r.BehaviorSubject(s)),t=v.useRef(!1),n=v.useRef(s);return v.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},Ot=s=>{const e=Ue(s),t=A(e.current.asObservable()),n=v.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Je=Symbol("SIGNAL_RESET");function wt(s={}){const e={default:s.default,key:s.key},{default:t}=e??{},n=new r.BehaviorSubject(t),i=a=>{if(typeof a=="function"){const l=a(n.getValue());if(l===n.getValue())return;n.next(l);return}if(a===Je){n.next(t??void 0);return}n.next(a)},u=()=>n.getValue();if("get"in s){const a=h=>(h.subject.pipe(r.skip(1),r.first()).subscribe(()=>{var o;const f=(o=s.get)==null?void 0:o.call(s,a);i(f)}),h.getValue()),l=s.get(a);return i(l),{getValue:u,config:s,subject:n}}return{setValue:i,getValue:u,config:e,subject:n}}function $t(s,e){const n=e??(()=>s.getValue());return fe(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const Ct=s=>({getItem:async e=>{const t=await s.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{await s.setItem(e,JSON.stringify(t))},removeItem:async e=>{},clear:async()=>{}}),Ee=s=>{if(!(!s||typeof s!="object"))return s},Et=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ee(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ee(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ee(i)??{};await s.setItem(e,{...u,[t]:n})}}),Xe=({key:s}={})=>s?Et({adapter:Xe(),key:s}):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>{const t=localStorage.getItem(e);if(t)return JSON.parse(t)},setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},se="__reactjrx",Mt=s=>{if(typeof s=="object"&&s!==null&&se in s&&s[se]===se)return s};function me(s){return s!=null}const qe=s=>{const e=Ue(s);return v.useEffect(()=>{e.current.next(s)},[s,e]),e},He=({adapter:s,signal:e,version:t})=>{const i={value:e.getValue(),[se]:se,migrationVersion:t};return r.from(s.setItem(e.config.key,i)).pipe(r.catchError(u=>(console.error(u),r.of(null))))},jt=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=Mt(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),Ft=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=qe(t),a=fe(()=>{const h=n.current;return u.current.pipe(r.switchMap(f=>{if(!f)return r.of(!1);const o=h.length===0?r.of(!0):r.zip(...h.map(({signal:b,version:d})=>jt({adapter:f,signal:b,version:d}).pipe(r.mergeMap(()=>He({adapter:f,signal:b,version:d}))))).pipe(r.map(()=>!0));return r.merge(r.of(!1),o).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(b=>(console.error("Unable to hydrate",b),r.EMPTY)))}))},{defaultValue:!1},[u,n]),l=qe(a);return Fe(()=>l.current.pipe(r.filter(h=>h),r.switchMap(()=>u.current),r.filter(me),r.switchMap(h=>r.merge(...n.current.map(({signal:f,version:o})=>f.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(He({adapter:h,signal:f,version:o})))))))),[l,u]),{isHydrated:a}},Rt=()=>{const s=Re({onBeforeComplete:()=>{s.current.next()}});return s};function Ze(s,e){return Math.min(s,e)}function et(s,e){return Math.pow(2,s)*e}function xe(s){const{retry:e,retryDelay:t,retryAfterDelay:n,retryAfter:i=()=>r.of(!0)}=s,u=typeof e!="function"?e===!1?0:e===!0?1/0:e??1/0:1/0,a=typeof e=="function"?e:()=>!0,l=typeof t=="number"?t:100,h={shouldRetry:a,...s},{maxInterval:f=1/0,resetOnSuccess:o=!1,backoffDelay:b=et}=h;return d=>r.defer(()=>{let p=0;const g=(m,O)=>m<u?a(m,O):!1;return d.pipe(K.catchError(m=>{var w;if(p++,!g(p-1,m))throw m;const O=(w=s.caughtError)==null?void 0:w.call(s,p,m);if(!O)throw m;return O.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>m))))}),K.retryWhen(m=>m.pipe(K.concatMap(O=>{const w=p-1;return i().pipe(K.first(),K.mergeMap(()=>g(w,O)?r.timer(Ze(b(w,l),f)).pipe(K.mergeMap(k=>n&&!n(w,O)?r.throwError(()=>O):r.of(k))):r.throwError(()=>O)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(p,m);throw m}),K.tap(()=>{o&&(p=0)}))})}const Ut=(s,e)=>s.length===e.length&&s.every((t,n)=>t===e[n]),tt=s=>{v.useEffect(s,[])},xt=s=>{tt(()=>{s()})};function Le(s){return Object.prototype.toString.call(s)==="[object Object]"}function Me(s){if(!Le(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!Le(t)||!t.hasOwnProperty("isPrototypeOf"))}const re=s=>JSON.stringify(s,(e,t)=>Me(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Ae=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""),J=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function Qe(s){let e=0;return function(n){return new r.Observable(i=>{e++;const u=n.subscribe(i);return s(e),()=>{e--,s(e),u.unsubscribe()}})}}const ne=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var H;class At{constructor({__queryFinalizeHook:e}={}){$(this,H,new r.Subject);y(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,H).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const l=a.mapOperator??"merge",h=c(this,H).pipe(r.filter(()=>l==="merge")),f=c(this,H).pipe(r.filter(()=>l==="switch"),r.tap(()=>{u.cancel()})),o=r.defer(()=>(u.execute(i),r.EMPTY)),b=u.state$.pipe(ne,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,H))),d=u.state$.pipe(ne,r.skip(1)),p=r.merge(n,h,f,u.cancelled$);return r.merge(d,b,o).pipe(r.map(g=>({state:g,mutation:u})),e??r.identity,r.takeUntil(p))}),r.shareReplay({refCount:!0,bufferSize:1}),Qe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,H).next({args:e,options:t,mutation:n})}}H=new WeakMap;function Ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!Ce(s[t],e[t])):!1}const ye=(s,e,{exact:t=!1}={})=>t?re(s)===re(e):Ce(s,e);function R(s,e){if(s==null||e===void 0||typeof s!="object"||typeof e!="object")return s===e;if(s.constructor!==(e==null?void 0:e.constructor))return!1;const t=Object.keys(s),n=Object.keys(e);if(t.length!==n.length)return!1;for(const i of t)if(!e.hasOwnProperty(i)||s[i]!==e[i])return!1;return!0}const rt=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>R(t,i)&&R(e,n)));var z,I;class Qt{constructor(e,t={},n){$(this,z,void 0);$(this,I,new r.BehaviorSubject(void 0));y(this,"observed$");y(this,"getObserverResultFromState",e=>({...J(),...e,isSuccess:e.status==="success",isPending:e.status==="pending",isIdle:e.status==="idle",isError:e.status==="error",mutate:this.mutate,reset:this.reset}));var i;this.client=e,this.options=t,this.options.mutationKey=((i=this.options)==null?void 0:i.mutationKey)??[Ae()],M(this,z,n??new At(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter(me),r.mergeMap(u=>c(this,z).state$.pipe(r.takeUntil(u.mutation.state$.pipe(ne,r.last()))))).subscribe(),this.observed$=c(this,I).pipe(r.switchMap(u=>(u==null?void 0:u.mutation.state$.pipe(r.map(a=>({state:a,options:u.options}))))??r.EMPTY),r.tap(({state:u,options:a})=>{u.status==="error"&&(a!=null&&a.onError&&(a==null||a.onError(u.error,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context))),u.status==="success"&&(a!=null&&a.onSuccess&&(a==null||a.onSuccess(u.data,u.variables,u.context)),a!=null&&a.onSettled&&(a==null||a.onSettled(u.data,u.error,u.variables,u.context)))}),r.ignoreElements())}setOptions(e){var i;const t=this.options;this.options=this.client.defaultMutationOptions({mutationKey:this.options.mutationKey,...e});const n=(i=c(this,I).getValue())==null?void 0:i.mutation;this.options.mutationKey&&t.mutationKey&&!ye(this.options.mutationKey,t.mutationKey,{exact:!0})?this.reset():n==null||n.setOptions(this.options)}observe(){var u;const e=this.getObserverResultFromState(((u=c(this,I).getValue())==null?void 0:u.mutation.state)??J()),t=c(this,z).state$.pipe(r.distinctUntilChanged(({mutation:a,state:{data:l,...h}},{mutation:f,state:{data:o,...b}})=>a===f&&R(h,b)&&R(l,o)),r.map(({state:a})=>a),r.scan((a,l)=>({...a,...l,...l.status==="pending"&&{data:l.data??a.data},...l.status==="pending"&&{error:l.error??a.error}})),r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter(me),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(J())));return{result$:r.merge(this.observed$,t,n).pipe(rt),lastValue:e}}subscribe(e){const t=this.observe().result$.subscribe(n=>{e(n)});return()=>{t.unsubscribe()}}async mutate(e,t={}){const n=this.client.getMutationCache().build(this.client,this.options);return c(this,I).next({mutation:n,options:t}),c(this,z).trigger({args:e,options:this.options,mutation:n}),await new Promise((i,u)=>{n.state$.pipe(ne,r.last()).subscribe({error:a=>{u(a)},next:a=>{a.error?u(a.error):i(a.data)}})})}getCurrentResult(){var t;const e=this.client.getMutationCache().find({exact:!0,mutationKey:(t=this.options)==null?void 0:t.mutationKey});return this.getObserverResultFromState((e==null?void 0:e.state)??J())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}z=new WeakMap,I=new WeakMap;const st=v.createContext(void 0),Pt=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),kt=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(st.Provider,{value:t,children:[Ke.jsx(Pt,{client:e}),s]})}),Pe=s=>{const e=v.useContext(st);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Vt(){}function It(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=v.useState(()=>new Qt(t,s));v.useEffect(()=>{a.setOptions(s)},[a,s]);const l=v.useMemo(()=>a.observe(),[u,a]),h=fe(l.result$)??l.lastValue,f=v.useCallback((o,b)=>{a.mutate(o,b).catch(Vt)},[a]);return v.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function Tt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const X=typeof window>"u"||"Deno"in window;class Dt{constructor(){y(this,"isOnlineSubject",new r.BehaviorSubject(!0));y(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));y(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(X?r.EMPTY:r.fromEvent(window,"offline").pipe(r.map(()=>!1)),X?r.EMPTY:r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(Tt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Dt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function Kt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function We(s,e){return Kt(s,e)||s.state.dataUpdatedAt>0&&nt(s,e,e.refetchOnMount)}function _e(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&ke(s,t)}function Nt(s,e){return nt(s,e,e.refetchOnWindowFocus)}function nt(s,e,t){if(e.enabled!==!1){const n=typeof t=="function"?t(s):t;return n==="idle"?s.state.fetchStatus==="idle":n==="always"||n!==!1&&ke(s,e)}return!1}function qt(s){return(s??"online")==="online"?_.isOnline():!0}function ze(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function Be(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function it(s,e){if(s===e)return s;const t=Be(s)&&Be(e);if(t||Me(s)&&Me(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,l=t?[]:{};let h=0;for(let f=0;f<a;f++){const o=t?f:u[f];!t&&s[o]===void 0&&e[o]===void 0&&n.includes(o)?(l[o]=void 0,h++):(l[o]=it(s[o],e[o]),l[o]===s[o]&&s[o]!==void 0&&h++)}return i===a&&h===i?s:l}return e}function Ve(s,e){return((e==null?void 0:e.queryKeyHashFn)??re)(s)}function Ye(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:l}=s;if(a){if(n){if(e.queryHash!==Ve(a,e.options))return!1}else if(!Ce(e.queryKey,a))return!1}if(t!=="all"){const h=e.isActive();if(t==="active"&&!h||t==="inactive"&&h)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function Ht(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Lt(s,e){return typeof s=="function"?s(e):s}function Se(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?it(s,e):e}const je=Symbol(),Wt=({getOptions:s,getState:e,initialState:t})=>n=>n.pipe(r.scan((i,{command:u,state:a})=>{if(u==="reset")return{...i,...a};if(u==="cancel"){const E=i.status==="pending"?"pending":a.status??i.status;return{...i,...a,status:E}}const l=a.data,h=l!==void 0&&l!==i.data,f="data"in a,o=a.status==="success",b=i.data!==void 0,d=i.error!==void 0||i.error!==null,p=a.status??i.status,g=h?Se(e().data,l,s()):f?a.data:i.data,m=i.status==="error"||i.status==="success",O=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,w=h?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&m&&(b||d),U=p==="pending"?null:a.error??i.error;return{...i,...a,status:p,error:U,errorUpdateCount:O,...o&&{isInvalidated:!1},data:g,dataUpdateCount:w,...k&&{status:i.status}}},t)),_t=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),at=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var Oe,L;class zt{constructor(){$(this,Oe,r.merge(X?r.EMPTY:r.fromEvent(document,"visibilitychange"),X?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));$(this,L,new r.BehaviorSubject(X?!0:document.visibilityState==="visible"));y(this,"focused$",c(this,L));y(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,Oe).pipe(r.tap(e=>{c(this,L).next(e==="visible")})).subscribe()}isFocused(){return c(this,L).getValue()}setFocused(e){c(this,L).getValue()!==(e??!0)&&c(this,L).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}Oe=new WeakMap,L=new WeakMap;const ve=new zt,Bt=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(R));var q,C,ie,B,x,Z,ae;class ut{constructor(e,t){$(this,q,void 0);$(this,C,void 0);$(this,ie,new r.Subject);y(this,"queryUpdateSubject",new r.Subject);$(this,B,void 0);$(this,x,void 0);$(this,Z,void 0);$(this,ae,0);y(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:l,selectError:h,selectResult:f}})=>{var ge;const o=t.state,b=t.state.status==="pending",d=c(this,C),p=this.options,m=t!==d?t.state:c(this,B);let{errorUpdatedAt:O,fetchStatus:w,error:k}=o;if(n){const Q=!!c(this,ae),Te=!Q&&We(t,e),bt=Q&&_e(t,d,e,p);(Te||bt)&&(w=qt(t.options.networkMode)?"fetching":"paused")}const U=b&&w==="fetching";let E,S=h,T=l??null,D=f;if(e.select&&typeof o.data<"u")if(i&&o.data===(a==null?void 0:a.data)&&e.select===l)E=f;else try{T=e.select,E=e.select(o.data),E=Se(i==null?void 0:i.data,E,e),D=E,S=null}catch(Q){E=f,S=Q}else E=o.data,S=null;let V=w!=="idle"&&!o.dataUpdatedAt?"pending":o.status;S&&(k=S,E=f,O=(i==null?void 0:i.errorUpdatedAt)??O,V="error");const de=V==="error";let pe=!1;if(typeof e.placeholderData<"u"&&typeof E>"u"&&V==="pending"){let Q;if(i!=null&&i.isPlaceholderData&&e.placeholderData===(u==null?void 0:u.placeholderData))Q=i.data;else if(Q=typeof e.placeholderData=="function"?e.placeholderData((ge=c(this,Z))==null?void 0:ge.state.data,c(this,Z)):e.placeholderData,e.select&&typeof Q<"u")try{Q=e.select(Q)}catch{}typeof Q<"u"&&(V="success",E=Se(i==null?void 0:i.data,Q,e),pe=!0)}const be=w==="fetching";return{result:{status:V,fetchStatus:w,isPending:b,isSuccess:V==="success",isError:de,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:o.dataUpdatedAt,error:k,errorUpdatedAt:O,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>m.dataUpdateCount||o.errorUpdateCount>m.errorUpdateCount,isFetching:be,isRefetching:be&&!b,isLoadingError:de&&o.dataUpdatedAt===0,isPaused:w==="paused",isPlaceholderData:pe,isRefetchError:de&&o.dataUpdatedAt!==0,isStale:ke(t,e),refetch:this.refetch},selectError:S,select:T,selectResult:D}});this.options=t,M(this,q,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,B,n.state);const{result:i,select:u}=this.getObserverResultFromQuery({query:n,options:this.options,prevResult:{options:this.options,state:n.state}});M(this,x,{state:n.state,options:t,result:i,select:u})}bindMethods(){this.refetch=this.refetch.bind(this)}setOptions(e){const t=this.options;if(this.options=c(this,q).defaultQueryOptions(e),R(this.options,t)||c(this,q).getQueryCache().notify({type:"observerOptionsUpdated",query:c(this,C),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");const n=this.buildQuery(this.options);return n!==c(this,C)&&(M(this,B,n.state),M(this,C,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,q).getQueryCache().build(c(this,q),e);return!t.options.queryFn&&this.options.queryFn&&t.setOptions(e),t}getCurrentResult(){return this.getObserverResultFromQuery({options:this.options,prevResult:c(this,x),query:c(this,C)}).result}getCurrentQuery(){return c(this,C)}getOptimisticResult(e){const t=this.buildQuery(e),n=this.getObserverResultFromQuery({query:t,options:e,optimisticResult:!0,prevResult:c(this,x)});return Yt(this,n.result)&&this.updateResult({query:t,...n}),n.result}updateResult({query:e,result:t,selectError:n,select:i,selectResult:u}){c(this,x).state=e.state,c(this,x).result=t,c(this,x).selectResult=u,n!==void 0&&(c(this,x).selectError=n),i!==void 0&&(c(this,x).select=i),c(this,x).options=this.options,e.state.data!==void 0&&M(this,Z,e),c(this,q).getQueryCache().notify({query:c(this,C),type:"observerResultsUpdated"})}async refetch({...e}={}){return await this.fetch({...e})}async fetch(e){const t=this.buildQuery(this.options);t!==c(this,C)&&(M(this,C,t),M(this,B,t.state),this.queryUpdateSubject.next({options:this.options,query:t}));const n={...e,cancelRefetch:(e==null?void 0:e.cancelRefetch)??!0};c(this,C).fetch(this.options,n).catch(r.noop),c(this,ie).next({query:t,fetchOptions:n}),await t.getFetchResultAsPromise();const{result:i}=this.getObserverResultFromQuery({query:t,options:this.options,prevResult:c(this,x)});return i}subscribe(e){const t=this.observe().subscribe(e);return()=>{t.unsubscribe()}}observe(){const e=c(this,C),t=this.queryUpdateSubject.pipe(r.map(({query:a})=>a),r.startWith(c(this,C)),r.distinctUntilChanged()),n=this.queryUpdateSubject.pipe(r.startWith({query:c(this,C),options:this.options}),r.pairwise(),r.tap(([{options:a,query:l},{options:h,query:f}])=>{_e(f,l,h,a)&&this.fetch().catch(r.noop)}),r.ignoreElements()),i=t.pipe(r.switchMap(a=>a.observe(this)),r.ignoreElements());return r.merge(i,n,t.pipe(r.switchMap(a=>{const l=this.options,h=this.queryUpdateSubject.pipe(r.startWith({query:a,options:l}),r.filter(S=>S.query===a),r.map(S=>S.options),r.distinctUntilChanged(),r.shareReplay(1)),f=c(this,ie).pipe(r.filter(S=>S.query===a)),o=a.state$.pipe(Bt,r.switchMap(S=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(S).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),b=(S,T)=>{const D=l.notifyOnChangeProps,V=typeof D=="function"?D():D;return(Array.isArray(V)?V.length===0?()=>!0:(pe,be)=>{const Ie=ze(pe,V),ge=ze(be,V);return R(Ie,ge)}:R)(S,T)},d=f.pipe(r.switchMap(()=>a.state$),at),p=h.pipe(r.map(({refetchInterval:S,refetchIntervalInBackground:T})=>({refetchInterval:(typeof S=="function"?S(c(this,C)):S)??!1,refetchIntervalInBackground:T})),r.distinctUntilChanged(R),r.switchMap(({refetchInterval:S,refetchIntervalInBackground:T})=>S?r.interval(S).pipe(r.tap(()=>{(T||ve.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),g=h.pipe(r.map(({enabled:S})=>S??!0),r.distinctUntilChanged()),m=g.pipe(r.filter(S=>!S),r.map(()=>a.state)),O=g.pipe(r.filter(S=>S),r.switchMap(()=>ve.focusRegained$),r.withLatestFrom(h),r.tap(([,S])=>{Nt(a,S)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),w=m.pipe(r.map(()=>a.state)),k=S=>S.pipe(r.withLatestFrom(h),r.map(([,T])=>{const D=this.getObserverResultFromQuery({query:a,options:T,prevResult:c(this,x)});return this.updateResult({query:a,...D}),D.result})),E=r.merge(w,d,a.state$,o).pipe(k,r.distinctUntilChanged(R),r.distinctUntilChanged(b));return r.merge(p,O,E)})).pipe(Qe(a=>M(this,ae,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,C=new WeakMap,ie=new WeakMap,B=new WeakMap,x=new WeakMap,Z=new WeakMap,ae=new WeakMap;function Yt(s,e){return!R(s.getCurrentResult(),e)}const ct=we.createContext(!1),Gt=()=>we.useContext(ct);ct.Provider;function Jt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Xt=we.createContext(Jt()),Zt=()=>we.useContext(Xt);function er(s,e){return typeof s=="function"?s(...e):!!s}const tr=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&er(t,[s.error,n]);function ot(s,e,t){if(process.env.NODE_ENV!=="production"&&(typeof s!="object"||Array.isArray(s)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=Pe(t),i=Gt(),u=Zt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=v.useState(()=>new e(n,a)),h=$e(()=>l.observe()),f=A(l.getOptimisticResult(a)),o=f.current;fe(()=>h.current.pipe(r.filter(d=>!R(d,f.current))),[]),v.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&tr({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function rr(s,e){return ot(s,ut,e)}function sr(s,e){return ot({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},ut,e)}function nr(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(h=>{console.error(h)})),a=v.useCallback(()=>F(s),t),l=v.useCallback(()=>a().pipe(r.catchError(h=>{throw u.current(h),h}),i?r.retry():r.identity),[a,i,u]);Fe(l,t)}const lt=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),ir=s=>{let e=0;return s.pipe(r.catchError(t=>(e++,e<=1&&!_.isOnline()?r.merge(r.of({failureCount:e,failureReason:t}),r.timer(1).pipe(r.mergeMap(()=>r.throwError(()=>t).pipe(lt())))):r.throwError(()=>t))))},ar=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,l=r.iif(()=>n,r.of(e.context),F(()=>{var d;return((d=t.onMutate)==null?void 0:d.call(t,s))??void 0})).pipe(r.shareReplay(1)),h=(d,p,g)=>F(()=>{var O;return(O=t.onError)==null?void 0:O.call(t,d,s,p)}).pipe(r.catchError(()=>r.of(d)),r.map(()=>({failureCount:g,error:d,failureReason:d,context:p,status:"error"}))),f=l.pipe(r.switchMap(d=>{const g=(typeof u=="function"?F(()=>u(s)):u).pipe(r.map(m=>({result:{data:m},error:null,context:d})),ir,xe({...t,retry:(m,O)=>{const w=t.retry??0;return typeof w=="function"?w(m,O):typeof w=="boolean"?w:m<w},caughtError:(m,O)=>r.of({failureCount:m,failureReason:O}),catchError:(m,O)=>h(O,d,m).pipe(r.map(w=>({...w,result:void 0})))}),r.takeWhile(({result:m,error:O})=>(m==null?void 0:m.data)===void 0&&O===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?g:g.pipe(lt())})),o=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(o,l.pipe(r.map(d=>({context:d}))),f.pipe(r.switchMap(({result:d,error:p,...g})=>{if(!d&&!p)return r.of({...g});const m=p?r.of(null):F(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,d==null?void 0:d.data,s,g.context)}),w=F(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,d==null?void 0:d.data,p,s,g.context)}).pipe(r.catchError(U=>d?r.of(d):r.of(U)));return r.concat(m,w).pipe(r.toArray(),r.map(()=>p?{error:p,data:void 0,variables:s,...g}:{status:"success",error:p,data:d==null?void 0:d.data,variables:s,failureCount:0,failureReason:null,...g}),r.catchError(U=>h(U,g.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((d,p)=>({...d,...p,data:p.data??d.data,error:p.error??d.error}),J()))};var ue,W,ee;class ur{constructor({options:e,mutationCache:t,state:n}){$(this,ue,new r.BehaviorSubject(0));$(this,W,new r.Subject);$(this,ee,new r.Subject);y(this,"state",J());y(this,"state$");y(this,"options");y(this,"observerCount$",c(this,ue).asObservable());y(this,"cancelled$",c(this,W).asObservable());this.options=e,this.state=n??this.state;const i=c(this,W).pipe(r.filter(()=>this.state.status==="pending"),r.map(()=>({status:"idle"}))),u=c(this,ee).pipe(r.switchMap(l=>ar({options:{...this.options,onMutate:h=>{const f=F(()=>{var p,g;return(g=(p=t.config).onMutate)==null?void 0:g.call(p,h,this)}),b=F(()=>{var p,g;return(g=(p=this.options).onMutate)==null?void 0:g.call(p,h)});return f.pipe(r.mergeMap(()=>b))},onError:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onError)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onError)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())},onSettled:(h,f,o,b)=>{const d=F(()=>{var g,m;return(m=(g=t.config).onSettled)==null?void 0:m.call(g,h,f,o,b,this)}),p=F(()=>{var g,m;return(m=(g=this.options).onSettled)==null?void 0:m.call(g,h,f,o,b)});return r.concat(d,p).pipe(r.toArray())},onSuccess:(h,f,o)=>{const b=F(()=>{var p,g;return(g=(p=t.config).onSuccess)==null?void 0:g.call(p,h,f,o,this)}),d=F(()=>{var p,g;return(g=(p=this.options).onSuccess)==null?void 0:g.call(p,h,f,o)});return r.concat(b,d).pipe(r.toArray())}},state:this.state,variables:l}).pipe(r.takeUntil(c(this,W))))),a=r.merge(i,u);this.state$=a.pipe(r.startWith(this.state),r.scan((l,h)=>({...l,...h}),this.state),rt,r.tap(l=>{this.state=l}),r.shareReplay(1),Qe(l=>{c(this,ue).next(l)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,ee).next(e),c(this,ee).complete(),this.state$.pipe(ne)}continue(){return this.execute(this.state.variables)}cancel(){c(this,W).next(),c(this,W).complete()}}ue=new WeakMap,W=new WeakMap,ee=new WeakMap;const Ge=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!ye(u.options.mutationKey,s,{exact:n})||e&&u.state.status!==e?!1:t?t(u):!0;class ht{constructor(){y(this,"entriesSubject",new r.BehaviorSubject([]));y(this,"changeSubject",new r.Subject);y(this,"entries$",this.entriesSubject.pipe(r.share()));y(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));y(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));y(this,"stateChange$",r.merge(this.entriesSubject.pipe(r.first(),r.mergeMap(e=>r.from(e))),this.added$).pipe(r.mergeMap(e=>e.state$.pipe(r.map(()=>e),r.takeUntil(this.removed$.pipe(r.filter(t=>t===e))))),r.share()))}getValues(){return this.entriesSubject.getValue()}remove(e){this.entriesSubject.next(this.entriesSubject.getValue().filter(t=>e!==t)),this.changeSubject.next({type:"removed",entity:e})}add(e){this.entriesSubject.next([...this.entriesSubject.getValue(),e]),this.changeSubject.next({type:"added",entity:e})}find(e){return this.entriesSubject.getValue().find(e)}}var P;class ft{constructor(e={}){$(this,P,new ht);this.config=e}build(e,t,n){const i=new ur({mutationCache:this,options:e.defaultMutationOptions(t),state:n});return i.state$.pipe(r.filter(({status:u})=>u==="success"||u==="error"),r.switchMap(()=>i.observerCount$.pipe(r.filter(u=>u<=1),r.take(1))),r.switchMap(()=>r.timer(i.options.gcTime??5*60*1e3)),r.take(1)).subscribe({complete:()=>{this.remove(i)}}),c(this,P).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,P).getValues().find(n=>n===e);t==null||t.cancel(),c(this,P).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,P).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,P).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,P).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,P).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,P).stateChange$.pipe(r.tap(n=>{e({type:"updated",action:{...n.state,type:"success"},mutation:n})}))).subscribe();return()=>{t.unsubscribe()}}resumePausedMutations(){const e=this.findAll({predicate:n=>n.state.isPaused});if(!e.length)return r.EMPTY;const t=e.map(n=>n.continue());return r.combineLatest(t)}clear(){this.getAll().forEach(e=>{this.remove(e)})}}P=new WeakMap;function cr(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=typeof e<"u",n=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}const or=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),lr=s=>{let e=0;return t=>{const n=_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({fetchStatus:"fetching"}),t)));return r.defer(()=>(e++,!_.isOnline()&&s.networkMode==="offlineFirst"&&e>1?r.merge(r.of({fetchStatus:"paused"}),n):!_.isOnline()&&s.networkMode!=="always"&&s.networkMode!=="offlineFirst"?r.merge(r.of({fetchStatus:"paused"}),n):t))}},hr=s=>e=>{const t=new r.Subject,n=t.pipe(r.first(),r.delay(1),r.mergeMap(()=>s.pipe(r.filter(i=>i===0))));return e.pipe(r.tap(()=>{t.next()}),r.takeUntil(n))},fr=s=>{const e=async()=>await Promise.reject(new Error("No query found"));process.env.NODE_ENV!=="production"&&s.queryFn===je&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`);let t=!1;const n=s.queryFn&&s.queryFn!==je?s.queryFn:e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const h=(typeof n=="function"?F(()=>n(u)):n).pipe(hr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),lr(s),xe({...s,retryAfter:()=>r.of(!0).pipe(or),catchError:(o,b)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:o,fetchFailureReason:b,error:b}),caughtError:(o,b)=>r.of({fetchFailureCount:o,fetchFailureReason:b})}),r.mergeMap(o=>"data"in o?r.of({...o,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(b=>t?b:{...b,fetchStatus:"fetching"})):r.of(o)),r.endWith({fetchStatus:"idle"}),r.share()),f=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(f,h).pipe(r.share()),abortController:i}};class dr{constructor(e){y(this,"revert");y(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const pr={backgroundColor:"transparent",color:"inherit"};function dt(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=dt();return i.namespaces.push({name:t,style:n??pr}),i},printNamespaces(){return{namespaces:e.namespaces.map(({name:t})=>`%c ${t} %c`).join(" "),styles:e.namespaces.reduce((t,{style:n})=>(t.push(`background-color: ${n.backgroundColor}; color: ${n.color};`),t.push("background-color: transparent; color: inherit;"),t),[])}},print(t,...n){return e},printWithoutNamespace(t,...n){return e},log(...t){return e.print("log",...t)},warn(...t){return e.print("warn",...t)},error(...t){return e.print("error",...t)},group(...t){return e.print("group",...t)},groupEnd(){return e}};return e}const br=dt();var ce,Y;class gr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ce,void 0);$(this,Y,void 0);y(this,"state");y(this,"executeSubject",new r.Subject);y(this,"cancelSubject",new r.Subject);y(this,"setDataSubject",new r.Subject);y(this,"invalidatedSubject",new r.Subject);y(this,"resetSubject",new r.Subject);y(this,"destroySubject",new r.Subject);y(this,"observersSubject",new r.BehaviorSubject([]));y(this,"abortSignalConsumed",!1);y(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));y(this,"observers$",this.observersSubject.asObservable());y(this,"state$");M(this,ce,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??cr(this.options)),this.state=c(this,Y),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,Y)}))),this.invalidatedSubject.pipe(r.filter(()=>!this.state.isInvalidated),r.map(()=>({command:"invalidate",state:{isInvalidated:!0}}))),this.cancelSubject.pipe(r.filter(()=>!(this.state.error&&this.state.status==="error")),r.map(t=>({command:"cancel",state:{status:t!=null&&t.revert?this.state.status:"error",fetchStatus:"idle",error:new dr(t)}}))),this.executeSubject.pipe(r.mergeMap(()=>{let t=!1;const n=this.executeSubject.pipe(r.filter(f=>(f==null?void 0:f.cancelRefetch)!==!1)),i=this.observers$.pipe(r.pairwise(),r.tap(([f,o])=>{o.length===0&&f.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=fr({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(f,o)=>{const b=this.options.retry??!0;return typeof b=="function"?b(f,o):typeof b=="boolean"?b:f<b},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),l=this.observerCount$.pipe(r.filter(f=>f===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),h=r.merge(this.cancelSubject,n,this.resetSubject,l).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(f=>({command:"execute",state:f})),r.takeUntil(h))})),this.setDataSubject.pipe(r.map(({data:t,options:n})=>({command:"setData",state:{status:"success",data:t,dataUpdatedAt:(n==null?void 0:n.updatedAt)!==void 0?n.updatedAt:new Date().getTime()}})))).pipe(Wt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(R),r.tap(t=>{this.state=t}),r.catchError(t=>{throw br.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ce),...e},this.updateGcTime(this.options.gcTime),this.options}get meta(){return this.options.meta}get success$(){return this.state$.pipe(r.map(({data:e,status:t})=>({data:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(R),r.filter(({status:e})=>e==="success"||e==="error"))}observe(e){return this.state$.pipe(r.tap({subscribe:()=>{this.observersSubject.next([e,...this.observersSubject.getValue()])},unsubscribe:()=>{this.observersSubject.next(this.observersSubject.getValue().filter(n=>n!==e))}}))}getObserversCount(){return this.observersSubject.getValue().length}updateGcTime(e){return this.gcTime=Math.max(this.gcTime||0,e??(X?1/0:5*60*1e3)),this.gcTime}isActive(){return this.observersSubject.getValue().some(e=>e.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observersSubject.getValue().some(e=>e.getCurrentResult().isStale)}isStaleByTime(e=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Ht(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(at,r.last()).subscribe({error:t,next:n=>{n.error?t(n.error):e(n.data)}})})}async fetch(e,t){const{cancelRefetch:n}=t??{};return this.state.fetchStatus!=="idle"&&!(!!this.state.dataUpdatedAt&&n)?await this.getFetchResultAsPromise():(e&&this.setOptions(e),this.executeSubject.next(t),await this.getFetchResultAsPromise())}setData(e,t){const n=Se(this.state.data,e,this.options);return this.setDataSubject.next({data:n,options:t}),n}invalidate(){this.invalidatedSubject.next()}async cancel(e){this.cancelSubject.next(e)}destroy(){this.destroySubject.next(),this.destroySubject.complete(),this.executeSubject.complete()}reset(){this.resetSubject.next()}}ce=new WeakMap,Y=new WeakMap;var oe,N;class pt{constructor(e={}){$(this,oe,new r.Subject);$(this,N,new ht);this.config=e}mount(){}unmount(){}notify(e){c(this,oe).next(e)}observeIsFetching(e){return c(this,N).stateChange$.pipe(r.startWith(),r.map(()=>this.findAll({...e,fetchStatus:"fetching"}).length),r.distinctUntilChanged())}getAll(){return[...c(this,N).getValues()]}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Ye(e,n)):t}build(e,t,n){const i=t.queryKey??[Ae()],u=t.queryHash??Ve(i,t);let a=this.get(u);return a||(a=new gr({cache:this,queryKey:i,queryHash:u,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(a)),a}add(e){if(!c(this,N).find(t=>t.queryHash===e.queryHash)){c(this,N).add(e);const t=e.observerCount$.pipe(r.filter(n=>n<1),r.take(1));e.success$.subscribe(()=>{var n,i;(i=(n=this.config).onSuccess)==null||i.call(n,e.state.data,e)}),e.error$.subscribe(()=>{var n,i;(i=(n=this.config).onError)==null||i.call(n,e.state.error,e)}),e.settled$.subscribe(()=>{var n,i;(i=(n=this.config).onSettled)==null||i.call(n,e.state.data,e.state.error,e)}),e.state$.pipe(_t,r.switchMap(n=>n?t.pipe(r.switchMap(()=>e.gcTime===1/0?r.NEVER:(setTimeout(r.noop,e.gcTime),r.timer(e.gcTime)))):r.NEVER),r.take(1)).subscribe({complete:()=>{this.remove(e)}})}}get(e){return c(this,N).find(t=>t.queryHash===e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Ye(t,n))}subscribe(e){const t=r.merge(c(this,oe).pipe(r.tap(e))).subscribe();return()=>{t.unsubscribe()}}remove(e){const t=c(this,N).find(n=>n===e);t&&(e.destroy(),t===e&&c(this,N).remove(e))}clear(){}}oe=new WeakMap,N=new WeakMap;var G,j,le,he,te;class mr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,G,void 0);$(this,j,void 0);$(this,le,new Map);$(this,he,new Map);$(this,te,void 0);M(this,G,e??new ft),M(this,j,t??new pt),M(this,te,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,j)}defaultMutationOptions(e){return{...c(this,te).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e._defaulted)return e;const t={...c(this,te).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ve(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.enabled!==!0&&t.queryFn===je&&(t.enabled=!1),t}async fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=c(this,j).build(this,t);return n.isStaleByTime(t.staleTime)?await n.fetch(t):await Promise.resolve(n.state.data)}async prefetchQuery(e){await this.fetchQuery(e).then(r.noop).catch(r.noop)}async resetQueries(e,t){const n=c(this,j),i={type:"active",...e};n.findAll(e).forEach(u=>{u.reset()}),await this.refetchQueries(i,t)}async refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},i=c(this,j).findAll(e).filter(u=>!u.isDisabled()).map(async u=>{let a=u.fetch(void 0,n);return n.throwOnError||(a=a.catch(r.noop)),u.state.fetchStatus==="paused"?void 0:await a});await Promise.all(i).then(r.noop)}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=c(this,j).get(t.queryHash))==null?void 0:n.state.data}setQueryData(e,t,n){const i=this.defaultQueryOptions({queryKey:e}),u=c(this,j).get(i.queryHash),a=u==null?void 0:u.state.data,l=Lt(t,a);if(l!==void 0)return c(this,j).build(this,i).setData(l,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,le).values()];let n={};return t.forEach(i=>{ye(e,i.mutationKey)&&(n={...n,...i.defaultOptions})}),n}getQueryState(e){var t;return(t=c(this,j).find({queryKey:e}))==null?void 0:t.state}setMutationDefaults(e,t){c(this,le).set(re(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,he).set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,he).values()];let n={};return t.forEach(i=>{Ce(e,i.queryKey)&&(n={...n,...i.defaultOptions})}),n}removeQueries(e){const t=c(this,j);t.findAll(e).forEach(n=>{t.remove(n)})}async cancelQueries(e={},t={}){const n={revert:!0,...t},i=c(this,j).findAll(e).map(async u=>{await u.cancel(n)});await Promise.all(i).then(r.noop).catch(r.noop)}async invalidateQueries(e={},t={}){if(c(this,j).findAll(e).forEach(i=>{i.invalidate()}),e.refetchType==="none"){await Promise.resolve();return}const n={...e,type:e.refetchType??e.type??"active"};await this.refetchQueries(n,t)}async resumePausedMutations(){return await r.lastValueFrom(c(this,G).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,G).clear()}}G=new WeakMap,j=new WeakMap,le=new WeakMap,he=new WeakMap,te=new WeakMap;exports.MutationCache=ft;exports.QueryCache=pt;exports.QueryClient=mr;exports.QueryClientProvider=kt;exports.SIGNAL_RESET=Je;exports.arrayEqual=Ut;exports.createLocalStorageAdapter=Xe;exports.createLocalforageAdapter=Ct;exports.exponentialBackoffDelay=et;exports.getDelay=Ze;exports.isDefined=me;exports.retryBackoff=xe;exports.signal=wt;exports.useBehaviorSubject=Ue;exports.useEffectOnce=tt;exports.useForeverQuery=sr;exports.useLiveRef=A;exports.useMount=xt;exports.useMutation=It;exports.useObservableState=Ot;exports.useObserve=fe;exports.useObserveCallback=vt;exports.usePersistSignals=Ft;exports.useQuery=rr;exports.useQueryClient=Pe;exports.useSignalValue=$t;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=nr;exports.useUnmountObservable=Rt;
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ export * from './lib/utils/operators/retryBackoff';
15
15
  export * from './lib/utils/useLiveRef';
16
16
  export * from './lib/utils/isDefined';
17
17
  export * from './lib/utils/arrayEqual';
18
+ export * from './lib/utils/useMount';
19
+ export * from './lib/utils/useEffectOnce';
18
20
  export * from './lib/queries/react/mutations/useMutation';
19
21
  export * from './lib/queries/react/queries/useQuery';
20
22
  export * from './lib/queries/react/useQueryClient';
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@ var a = (s, e, t) => (yt(s, e, "read from private field"), t ? t.call(s) : e.get
10
10
  e instanceof WeakSet ? e.add(s) : e.set(s, t);
11
11
  }, M = (s, e, t, r) => (yt(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
12
12
  import * as Ge from "react";
13
- import { useRef as me, useMemo as ut, useCallback as le, useSyncExternalStore as Xt, useEffect as X, createContext as Zt, memo as es, useContext as ts, useState as jt } from "react";
14
- import { distinctUntilChanged as Q, tap as E, catchError as B, EMPTY as Z, isObservable as bt, from as Se, of as v, defer as Ae, Subject as I, BehaviorSubject as J, skip as at, first as Je, map as g, switchMap as x, zip as ss, mergeMap as k, merge as F, filter as O, throttleTime as rs, asyncScheduler as ns, throwError as Oe, timer as Qe, Observable as is, takeWhile as Ye, concatMap as us, last as Ke, takeUntil as ne, identity as Mt, shareReplay as Ue, ignoreElements as he, scan as Be, fromEvent as Ne, noop as N, startWith as ce, pairwise as At, NEVER as qe, delay as ot, interval as as, withLatestFrom as gt, retry as os, iif as cs, concat as ke, toArray as Te, share as de, take as He, combineLatest as ls, endWith as hs, lastValueFrom as ds } from "rxjs";
13
+ import { useRef as me, useMemo as ut, useCallback as le, useSyncExternalStore as Xt, useEffect as J, createContext as Zt, memo as es, useContext as ts, useState as jt } from "react";
14
+ import { distinctUntilChanged as Q, tap as E, catchError as X, EMPTY as Z, isObservable as bt, from as Se, of as v, defer as Ae, Subject as I, BehaviorSubject as Y, skip as at, first as Je, map as g, switchMap as x, zip as ss, mergeMap as k, merge as F, filter as O, throttleTime as rs, asyncScheduler as ns, throwError as Oe, timer as Qe, Observable as is, takeWhile as Ye, concatMap as us, last as Ke, takeUntil as ne, identity as Mt, shareReplay as Ue, ignoreElements as he, scan as Be, fromEvent as Ne, noop as N, startWith as ce, pairwise as At, NEVER as qe, delay as ot, interval as as, withLatestFrom as gt, retry as os, iif as cs, concat as ke, toArray as Te, share as de, take as He, combineLatest as ls, endWith as hs, lastValueFrom as ds } from "rxjs";
15
15
  import { catchError as mt, mergeMap as tt, retryWhen as fs, concatMap as ps, first as ys, tap as Qt } from "rxjs/operators";
16
16
  import { jsxs as bs, jsx as gs } from "react/jsx-runtime";
17
17
  const q = (s) => {
@@ -42,7 +42,7 @@ function Xe(s, e, t) {
42
42
  E((b) => {
43
43
  u.current = b;
44
44
  }),
45
- B((b) => (console.error(b), Z))
45
+ X((b) => (console.error(b), Z))
46
46
  ).subscribe(p);
47
47
  return () => {
48
48
  c.current.unsubscribeOnUnmount !== !1 && y.unsubscribe();
@@ -71,7 +71,7 @@ function U(s) {
71
71
  }
72
72
  function Ut(s, e = []) {
73
73
  const t = q(s);
74
- X(() => {
74
+ J(() => {
75
75
  const r = U(t.current).subscribe();
76
76
  return () => {
77
77
  r.unsubscribe();
@@ -84,7 +84,7 @@ function Ut(s, e = []) {
84
84
  }
85
85
  const Ze = (s) => {
86
86
  const e = me();
87
- return e.current || (e.current = s()), X(() => {
87
+ return e.current || (e.current = s()), J(() => {
88
88
  process.env.NODE_ENV;
89
89
  }, []), e;
90
90
  }, It = ({
@@ -92,14 +92,14 @@ const Ze = (s) => {
92
92
  completeOnUnmount: e = !0
93
93
  } = {}) => {
94
94
  const t = Ze(() => new I()), r = me(!1), n = q(s), u = q(e);
95
- return X(() => (r.current && (t.current = new I(), r.current = !1), () => {
95
+ return J(() => (r.current && (t.current = new I(), r.current = !1), () => {
96
96
  if (!u.current) {
97
97
  r.current = !0;
98
98
  return;
99
99
  }
100
100
  r.current || (n.current != null && n.current(), t.current.complete(), r.current = !0);
101
101
  }), [u, n, t]), t;
102
- }, fr = () => {
102
+ }, pr = () => {
103
103
  const s = It(), e = q(s.current.asObservable()), t = le(
104
104
  (r) => {
105
105
  s.current.next(r);
@@ -109,11 +109,11 @@ const Ze = (s) => {
109
109
  );
110
110
  return [e.current, t];
111
111
  }, Vt = (s) => {
112
- const e = Ze(() => new J(s)), t = me(!1), r = me(s);
113
- return X(() => (t.current && (e.current = new J(r.current), t.current = !1), () => {
112
+ const e = Ze(() => new Y(s)), t = me(!1), r = me(s);
113
+ return J(() => (t.current && (e.current = new Y(r.current), t.current = !1), () => {
114
114
  t.current || (e.current.complete(), t.current = !0);
115
115
  }), [e]), e;
116
- }, pr = (s) => {
116
+ }, yr = (s) => {
117
117
  const e = Vt(s), t = q(e.current.asObservable()), r = le(
118
118
  (n) => {
119
119
  e.current.next(n);
@@ -123,11 +123,11 @@ const Ze = (s) => {
123
123
  );
124
124
  return [t.current, r, e.current.getValue()];
125
125
  }, Ss = Symbol("SIGNAL_RESET");
126
- function yr(s = {}) {
126
+ function br(s = {}) {
127
127
  const e = {
128
128
  default: s.default,
129
129
  key: s.key
130
- }, { default: t } = e ?? {}, r = new J(t), n = (i) => {
130
+ }, { default: t } = e ?? {}, r = new Y(t), n = (i) => {
131
131
  if (typeof i == "function") {
132
132
  const c = i(r.getValue());
133
133
  if (c === r.getValue())
@@ -160,7 +160,7 @@ function yr(s = {}) {
160
160
  subject: r
161
161
  };
162
162
  }
163
- function br(s, e) {
163
+ function gr(s, e) {
164
164
  const r = e ?? (() => s.getValue());
165
165
  return Xe(
166
166
  () => s.subject.pipe(
@@ -173,7 +173,7 @@ function br(s, e) {
173
173
  []
174
174
  );
175
175
  }
176
- const gr = (s) => ({
176
+ const mr = (s) => ({
177
177
  getItem: async (e) => {
178
178
  const t = await s.getItem(e);
179
179
  if (t)
@@ -236,7 +236,7 @@ function rt(s) {
236
236
  }
237
237
  const vt = (s) => {
238
238
  const e = Vt(s);
239
- return X(() => {
239
+ return J(() => {
240
240
  e.current.next(s);
241
241
  }, [s, e]), e;
242
242
  }, Ot = ({
@@ -250,7 +250,7 @@ const vt = (s) => {
250
250
  migrationVersion: t
251
251
  };
252
252
  return Se(s.setItem(e.config.key, n)).pipe(
253
- B((u) => (console.error(u), v(null)))
253
+ X((u) => (console.error(u), v(null)))
254
254
  );
255
255
  }, ws = ({
256
256
  adapter: s,
@@ -261,7 +261,7 @@ const vt = (s) => {
261
261
  const n = $s(r);
262
262
  return n ? n.migrationVersion !== void 0 && e > n.migrationVersion ? v(r) : (t.setValue(n.value), v(r)) : v(r);
263
263
  })
264
- ), mr = ({
264
+ ), Sr = ({
265
265
  entries: s = [],
266
266
  onReady: e,
267
267
  adapter: t
@@ -294,7 +294,7 @@ const vt = (s) => {
294
294
  E(() => {
295
295
  n.current != null && n.current();
296
296
  }),
297
- B((p) => (console.error("Unable to hydrate", p), Z))
297
+ X((p) => (console.error("Unable to hydrate", p), Z))
298
298
  );
299
299
  })
300
300
  );
@@ -328,7 +328,7 @@ const vt = (s) => {
328
328
  ),
329
329
  [c, u]
330
330
  ), { isHydrated: i };
331
- }, Sr = () => {
331
+ }, vr = () => {
332
332
  const s = It({
333
333
  onBeforeComplete: () => {
334
334
  s.current.next();
@@ -408,7 +408,13 @@ function Pt(s) {
408
408
  );
409
409
  });
410
410
  }
411
- const vr = (s, e) => s.length === e.length && s.every((t, r) => t === e[r]);
411
+ const Or = (s, e) => s.length === e.length && s.every((t, r) => t === e[r]), Es = (s) => {
412
+ J(s, []);
413
+ }, $r = (s) => {
414
+ Es(() => {
415
+ s();
416
+ });
417
+ };
412
418
  function $t(s) {
413
419
  return Object.prototype.toString.call(s) === "[object Object]";
414
420
  }
@@ -454,13 +460,13 @@ const we = (s) => s.pipe(
454
460
  )
455
461
  );
456
462
  var ee;
457
- class Es {
463
+ class xs {
458
464
  constructor({
459
465
  __queryFinalizeHook: e
460
466
  } = {}) {
461
467
  C(this, ee, new I());
462
468
  m(this, "state$");
463
- const t = new J(0), r = t.pipe(
469
+ const t = new Y(0), r = t.pipe(
464
470
  O((n) => n === 0)
465
471
  );
466
472
  this.state$ = a(this, ee).pipe(
@@ -541,10 +547,10 @@ const Dt = (s) => s.pipe(
541
547
  )
542
548
  );
543
549
  var ie, L;
544
- class xs {
550
+ class Rs {
545
551
  constructor(e, t = {}, r) {
546
552
  C(this, ie, void 0);
547
- C(this, L, new J(void 0));
553
+ C(this, L, new Y(void 0));
548
554
  /**
549
555
  * @important
550
556
  * Used to maintain persistance to latest mutation. This ensure
@@ -565,7 +571,7 @@ class xs {
565
571
  reset: this.reset
566
572
  }));
567
573
  var n;
568
- this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [ct()], M(this, ie, r ?? new Es(this.options)), this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this), a(this, L).pipe(
574
+ this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [ct()], M(this, ie, r ?? new xs(this.options)), this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this), a(this, L).pipe(
569
575
  O(rt),
570
576
  k(
571
577
  (u) => a(this, ie).state$.pipe(
@@ -691,13 +697,13 @@ class xs {
691
697
  }
692
698
  }
693
699
  ie = new WeakMap(), L = new WeakMap();
694
- const kt = Zt(void 0), Rs = ({ client: s }) => (X(() => (s.mount(), () => {
700
+ const kt = Zt(void 0), js = ({ client: s }) => (J(() => (s.mount(), () => {
695
701
  s.unmount();
696
- }), [s]), null), Or = es(
702
+ }), [s]), null), wr = es(
697
703
  ({ children: s, client: e }) => {
698
704
  const t = ut(() => e, [e]);
699
705
  return /* @__PURE__ */ bs(kt.Provider, { value: t, children: [
700
- /* @__PURE__ */ gs(Rs, { client: e }),
706
+ /* @__PURE__ */ gs(js, { client: e }),
701
707
  s
702
708
  ] });
703
709
  }
@@ -709,29 +715,29 @@ const kt = Zt(void 0), Rs = ({ client: s }) => (X(() => (s.mount(), () => {
709
715
  throw new Error("No QueryClient set, use QueryClientProvider to set one");
710
716
  return e;
711
717
  };
712
- function js() {
718
+ function Ms() {
713
719
  }
714
- function $r(s, e) {
720
+ function Cr(s, e) {
715
721
  const t = Tt(e), r = q(s), n = Ze(() => [ct()]), u = ve(s.mutationKey ?? n.current), [i] = jt(
716
- () => new xs(
722
+ () => new Rs(
717
723
  t,
718
724
  s
719
725
  )
720
726
  );
721
- X(() => {
727
+ J(() => {
722
728
  i.setOptions(s);
723
729
  }, [i, s]);
724
730
  const c = ut(() => i.observe(), [u, i]), l = Xe(c.result$) ?? c.lastValue, h = le(
725
731
  (o, p) => {
726
- i.mutate(o, p).catch(js);
732
+ i.mutate(o, p).catch(Ms);
727
733
  },
728
734
  [i]
729
735
  );
730
- return X(() => () => {
736
+ return J(() => () => {
731
737
  r.current.cancelOnUnMount && i.reset();
732
738
  }, [i, r]), { ...l, mutate: h, mutateAsync: l.mutate };
733
739
  }
734
- function Ms(s) {
740
+ function As(s) {
735
741
  return (e) => e.pipe(
736
742
  Qt((t) => {
737
743
  s.next(t);
@@ -739,9 +745,9 @@ function Ms(s) {
739
745
  );
740
746
  }
741
747
  const pe = typeof window > "u" || "Deno" in window;
742
- class As {
748
+ class Qs {
743
749
  constructor() {
744
- m(this, "isOnlineSubject", new J(!0));
750
+ m(this, "isOnlineSubject", new Y(!0));
745
751
  m(this, "online$", this.isOnlineSubject.pipe(Q()));
746
752
  m(this, "backToOnline$", this.online$.pipe(
747
753
  O((e) => e),
@@ -750,7 +756,7 @@ class As {
750
756
  F(
751
757
  pe ? Z : Ne(window, "offline").pipe(g(() => !1)),
752
758
  pe ? Z : Ne(window, "online").pipe(g(() => !0))
753
- ).pipe(Ms(this.isOnlineSubject)).subscribe();
759
+ ).pipe(As(this.isOnlineSubject)).subscribe();
754
760
  }
755
761
  isOnline() {
756
762
  return this.isOnlineSubject.getValue();
@@ -759,20 +765,20 @@ class As {
759
765
  this.isOnlineSubject.getValue() !== e && this.isOnlineSubject.next(e);
760
766
  }
761
767
  }
762
- const re = new As();
768
+ const re = new Qs();
763
769
  function ht(s, e) {
764
770
  return s.isStaleByTime(e.staleTime);
765
771
  }
766
- function Qs(s, e) {
772
+ function Us(s, e) {
767
773
  return e.enabled !== !1 && !s.state.dataUpdatedAt && !(s.state.status === "error" && e.retryOnMount === !1) && s.state.fetchStatus !== "fetching";
768
774
  }
769
775
  function wt(s, e) {
770
- return Qs(s, e) || s.state.dataUpdatedAt > 0 && Kt(s, e, e.refetchOnMount);
776
+ return Us(s, e) || s.state.dataUpdatedAt > 0 && Kt(s, e, e.refetchOnMount);
771
777
  }
772
778
  function Ct(s, e, t, r) {
773
779
  return s.state.fetchStatus !== "fetching" && t.enabled !== !1 && (s !== e || r.enabled === !1) && (!t.suspense || s.state.status !== "error") && ht(s, t);
774
780
  }
775
- function Us(s, e) {
781
+ function Is(s, e) {
776
782
  return Kt(s, e, e.refetchOnWindowFocus);
777
783
  }
778
784
  function Kt(s, e, t) {
@@ -782,7 +788,7 @@ function Kt(s, e, t) {
782
788
  }
783
789
  return !1;
784
790
  }
785
- function Is(s) {
791
+ function Vs(s) {
786
792
  return (s ?? "online") === "online" ? re.isOnline() : !0;
787
793
  }
788
794
  function Ft(s, e) {
@@ -835,16 +841,16 @@ function xt(s, e) {
835
841
  }
836
842
  return !(typeof c == "boolean" && e.isStale() !== c || typeof n < "u" && n !== e.state.fetchStatus || u && !u(e));
837
843
  }
838
- function Vs(s, e) {
844
+ function Ps(s, e) {
839
845
  return Math.max(s + (e ?? 0) - Date.now(), 0);
840
846
  }
841
- function Ps(s, e) {
847
+ function Ds(s, e) {
842
848
  return typeof s == "function" ? s(e) : s;
843
849
  }
844
850
  function Le(s, e, t) {
845
851
  return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ? Nt(s, e) : e;
846
852
  }
847
- const it = Symbol(), Ds = ({
853
+ const it = Symbol(), ks = ({
848
854
  getOptions: s,
849
855
  getState: e,
850
856
  initialState: t
@@ -874,7 +880,7 @@ const it = Symbol(), Ds = ({
874
880
  }
875
881
  };
876
882
  }, t)
877
- ), ks = (s) => s.pipe(
883
+ ), Ts = (s) => s.pipe(
878
884
  g(
879
885
  ({ status: e, fetchStatus: t }) => t === "idle" && (e === "success" || e === "error")
880
886
  )
@@ -882,13 +888,13 @@ const it = Symbol(), Ds = ({
882
888
  Ye((e) => e.fetchStatus !== "idle", !0)
883
889
  );
884
890
  var We, te;
885
- class Ts {
891
+ class Ks {
886
892
  constructor() {
887
893
  C(this, We, F(
888
894
  pe ? Z : Ne(document, "visibilitychange"),
889
895
  pe ? Z : Ne(window, "visibilitychange")
890
896
  ).pipe(g(() => document.visibilityState)));
891
- C(this, te, new J(
897
+ C(this, te, new Y(
892
898
  pe ? !0 : document.visibilityState === "visible"
893
899
  ));
894
900
  // public readonly focused$ = this.#focusedSubject.pipe(distinctUntilChanged())
@@ -927,7 +933,7 @@ class Ts {
927
933
  }
928
934
  }
929
935
  We = new WeakMap(), te = new WeakMap();
930
- const ze = new Ts(), Ks = (s) => s.pipe(
936
+ const ze = new Ks(), Ns = (s) => s.pipe(
931
937
  O((e) => e.status === "success"),
932
938
  g((e) => ({
933
939
  data: e.data,
@@ -936,10 +942,10 @@ const ze = new Ts(), Ks = (s) => s.pipe(
936
942
  })),
937
943
  Q(V)
938
944
  );
939
- var Y, R, Ce, ue, D, ye, Fe;
945
+ var B, R, Ce, ue, D, ye, Fe;
940
946
  class Ht {
941
947
  constructor(e, t) {
942
- C(this, Y, void 0);
948
+ C(this, B, void 0);
943
949
  C(this, R, void 0);
944
950
  C(this, Ce, new I());
945
951
  /**
@@ -979,7 +985,7 @@ class Ht {
979
985
  let { errorUpdatedAt: $, fetchStatus: w, error: H } = o;
980
986
  if (r) {
981
987
  const T = !!a(this, Fe), pt = !T && wt(t, e), Jt = T && Ct(t, d, e, f);
982
- (pt || Jt) && (w = Is(t.options.networkMode) ? "fetching" : "paused");
988
+ (pt || Jt) && (w = Vs(t.options.networkMode) ? "fetching" : "paused");
983
989
  }
984
990
  const P = p && w === "fetching";
985
991
  let j, S = l, z = c ?? null, W = h;
@@ -1050,7 +1056,7 @@ class Ht {
1050
1056
  selectResult: W
1051
1057
  };
1052
1058
  });
1053
- this.options = t, M(this, Y, e), this.bindMethods(), M(this, R, this.setOptions(t));
1059
+ this.options = t, M(this, B, e), this.bindMethods(), M(this, R, this.setOptions(t));
1054
1060
  const r = a(this, R);
1055
1061
  M(this, ue, r.state);
1056
1062
  const { result: n, select: u } = this.getObserverResultFromQuery({
@@ -1073,7 +1079,7 @@ class Ht {
1073
1079
  }
1074
1080
  setOptions(e) {
1075
1081
  const t = this.options;
1076
- if (this.options = a(this, Y).defaultQueryOptions(e), V(this.options, t) || a(this, Y).getQueryCache().notify({
1082
+ if (this.options = a(this, B).defaultQueryOptions(e), V(this.options, t) || a(this, B).getQueryCache().notify({
1077
1083
  type: "observerOptionsUpdated",
1078
1084
  query: a(this, R),
1079
1085
  observer: this
@@ -1086,7 +1092,7 @@ class Ht {
1086
1092
  }), r;
1087
1093
  }
1088
1094
  buildQuery(e) {
1089
- const t = a(this, Y).getQueryCache().build(a(this, Y), e);
1095
+ const t = a(this, B).getQueryCache().build(a(this, B), e);
1090
1096
  return !t.options.queryFn && this.options.queryFn && t.setOptions(e), t;
1091
1097
  }
1092
1098
  getCurrentResult() {
@@ -1106,7 +1112,7 @@ class Ht {
1106
1112
  optimisticResult: !0,
1107
1113
  prevResult: a(this, D)
1108
1114
  });
1109
- return Ns(this, r.result) && this.updateResult({ query: t, ...r }), r.result;
1115
+ return qs(this, r.result) && this.updateResult({ query: t, ...r }), r.result;
1110
1116
  }
1111
1117
  updateResult({
1112
1118
  query: e,
@@ -1115,7 +1121,7 @@ class Ht {
1115
1121
  select: n,
1116
1122
  selectResult: u
1117
1123
  }) {
1118
- a(this, D).state = e.state, a(this, D).result = t, a(this, D).selectResult = u, r !== void 0 && (a(this, D).selectError = r), n !== void 0 && (a(this, D).select = n), a(this, D).options = this.options, e.state.data !== void 0 && M(this, ye, e), a(this, Y).getQueryCache().notify({
1124
+ a(this, D).state = e.state, a(this, D).result = t, a(this, D).selectResult = u, r !== void 0 && (a(this, D).selectError = r), n !== void 0 && (a(this, D).select = n), a(this, D).options = this.options, e.state.data !== void 0 && M(this, ye, e), a(this, B).getQueryCache().notify({
1119
1125
  query: a(this, R),
1120
1126
  type: "observerResultsUpdated"
1121
1127
  });
@@ -1194,7 +1200,7 @@ class Ht {
1194
1200
  ), h = a(this, Ce).pipe(
1195
1201
  O((S) => S.query === i)
1196
1202
  ), o = i.state$.pipe(
1197
- Ks,
1203
+ Ns,
1198
1204
  x(
1199
1205
  (S) => this.options.staleTime === 1 / 0 ? qe : (this.options.staleTime ?? 0) <= 0 ? v(S).pipe(ot(1)) : Qe(this.options.staleTime ?? 1)
1200
1206
  ),
@@ -1238,7 +1244,7 @@ class Ht {
1238
1244
  x(() => ze.focusRegained$),
1239
1245
  gt(l),
1240
1246
  E(([, S]) => {
1241
- Us(i, S) && this.fetch({ cancelRefetch: !1 }).catch(N);
1247
+ Is(i, S) && this.fetch({ cancelRefetch: !1 }).catch(N);
1242
1248
  }),
1243
1249
  he()
1244
1250
  ), w = b.pipe(
@@ -1281,13 +1287,13 @@ class Ht {
1281
1287
  destroy() {
1282
1288
  }
1283
1289
  }
1284
- Y = new WeakMap(), R = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), ye = new WeakMap(), Fe = new WeakMap();
1285
- function Ns(s, e) {
1290
+ B = new WeakMap(), R = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), ye = new WeakMap(), Fe = new WeakMap();
1291
+ function qs(s, e) {
1286
1292
  return !V(s.getCurrentResult(), e);
1287
1293
  }
1288
- const _t = Ge.createContext(!1), qs = () => Ge.useContext(_t);
1294
+ const _t = Ge.createContext(!1), Hs = () => Ge.useContext(_t);
1289
1295
  _t.Provider;
1290
- function Hs() {
1296
+ function _s() {
1291
1297
  let s = !1;
1292
1298
  return {
1293
1299
  clearReset: () => {
@@ -1299,22 +1305,22 @@ function Hs() {
1299
1305
  isReset: () => s
1300
1306
  };
1301
1307
  }
1302
- const _s = Ge.createContext(Hs()), Ls = () => Ge.useContext(_s);
1303
- function zs(s, e) {
1308
+ const Ls = Ge.createContext(_s()), zs = () => Ge.useContext(Ls);
1309
+ function Ws(s, e) {
1304
1310
  return typeof s == "function" ? s(...e) : !!s;
1305
1311
  }
1306
- const Ws = ({
1312
+ const Gs = ({
1307
1313
  result: s,
1308
1314
  errorResetBoundary: e,
1309
1315
  throwOnError: t,
1310
1316
  query: r
1311
- }) => s.isError && !e.isReset() && !s.isFetching && r && zs(t, [s.error, r]);
1317
+ }) => s.isError && !e.isReset() && !s.isFetching && r && Ws(t, [s.error, r]);
1312
1318
  function Lt(s, e, t) {
1313
1319
  if (process.env.NODE_ENV !== "production" && (typeof s != "object" || Array.isArray(s)))
1314
1320
  throw new Error(
1315
1321
  'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
1316
1322
  );
1317
- const r = Tt(t), n = qs(), u = Ls(), i = r.defaultQueryOptions(s);
1323
+ const r = Tt(t), n = Hs(), u = zs(), i = r.defaultQueryOptions(s);
1318
1324
  i._optimisticResults = n ? "isRestoring" : "optimistic";
1319
1325
  const [c] = jt(
1320
1326
  () => new e(
@@ -1334,11 +1340,11 @@ function Lt(s, e, t) {
1334
1340
  O((d) => !V(d, h.current))
1335
1341
  ),
1336
1342
  []
1337
- ), X(() => {
1343
+ ), J(() => {
1338
1344
  c.setOptions(i);
1339
1345
  }, [i, c]);
1340
1346
  const p = o.error;
1341
- if (p && Ws({
1347
+ if (p && Gs({
1342
1348
  result: o,
1343
1349
  errorResetBoundary: u,
1344
1350
  throwOnError: i.throwOnError,
@@ -1347,10 +1353,10 @@ function Lt(s, e, t) {
1347
1353
  throw p;
1348
1354
  return h.current;
1349
1355
  }
1350
- function wr(s, e) {
1356
+ function Fr(s, e) {
1351
1357
  return Lt(s, Ht, e);
1352
1358
  }
1353
- function Cr(s, e) {
1359
+ function Er(s, e) {
1354
1360
  return Lt(
1355
1361
  {
1356
1362
  refetchOnMount: "idle",
@@ -1363,14 +1369,14 @@ function Cr(s, e) {
1363
1369
  e
1364
1370
  );
1365
1371
  }
1366
- function Fr(s, e, t = []) {
1372
+ function xr(s, e, t = []) {
1367
1373
  const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u = q(
1368
1374
  r.onError ?? ((l) => {
1369
1375
  console.error(l);
1370
1376
  })
1371
1377
  ), i = le(() => U(s), t), c = le(
1372
1378
  () => i().pipe(
1373
- B((l) => {
1379
+ X((l) => {
1374
1380
  throw u.current(l), l;
1375
1381
  }),
1376
1382
  n ? os() : Mt
@@ -1390,10 +1396,10 @@ const zt = () => (s) => F(
1390
1396
  )
1391
1397
  )
1392
1398
  )
1393
- ), Gs = (s) => {
1399
+ ), Js = (s) => {
1394
1400
  let e = 0;
1395
1401
  return s.pipe(
1396
- B((t) => (e++, e <= 1 && !re.isOnline() ? F(
1402
+ X((t) => (e++, e <= 1 && !re.isOnline() ? F(
1397
1403
  v({
1398
1404
  failureCount: e,
1399
1405
  failureReason: t
@@ -1409,7 +1415,7 @@ const zt = () => (s) => F(
1409
1415
  )
1410
1416
  ) : Oe(() => t)))
1411
1417
  );
1412
- }, Js = ({
1418
+ }, Ys = ({
1413
1419
  variables: s,
1414
1420
  state: e,
1415
1421
  options: t
@@ -1430,7 +1436,7 @@ const zt = () => (s) => F(
1430
1436
  return ($ = t.onError) == null ? void 0 : $.call(t, d, s, f);
1431
1437
  }
1432
1438
  ).pipe(
1433
- B(() => v(d)),
1439
+ X(() => v(d)),
1434
1440
  g(
1435
1441
  () => ({
1436
1442
  failureCount: y,
@@ -1455,7 +1461,7 @@ const zt = () => (s) => F(
1455
1461
  context: d
1456
1462
  })
1457
1463
  ),
1458
- Gs,
1464
+ Js,
1459
1465
  Pt({
1460
1466
  ...t,
1461
1467
  retry: (b, $) => {
@@ -1524,7 +1530,7 @@ const zt = () => (s) => F(
1524
1530
  );
1525
1531
  }
1526
1532
  ).pipe(
1527
- B((P) => d ? v(d) : v(P))
1533
+ X((P) => d ? v(d) : v(P))
1528
1534
  );
1529
1535
  return ke(b, w).pipe(
1530
1536
  Te(),
@@ -1544,7 +1550,7 @@ const zt = () => (s) => F(
1544
1550
  ...y
1545
1551
  }
1546
1552
  ),
1547
- B(
1553
+ X(
1548
1554
  (P) => l(P, y.context, 0).pipe(
1549
1555
  g((j) => ({
1550
1556
  ...j,
@@ -1565,13 +1571,13 @@ const zt = () => (s) => F(
1565
1571
  );
1566
1572
  };
1567
1573
  var Ee, se, be;
1568
- class Ys {
1574
+ class Bs {
1569
1575
  constructor({
1570
1576
  options: e,
1571
1577
  mutationCache: t,
1572
1578
  state: r
1573
1579
  }) {
1574
- C(this, Ee, new J(0));
1580
+ C(this, Ee, new Y(0));
1575
1581
  C(this, se, new I());
1576
1582
  C(this, be, new I());
1577
1583
  m(this, "state", fe());
@@ -1587,7 +1593,7 @@ class Ys {
1587
1593
  }))
1588
1594
  ), u = a(this, be).pipe(
1589
1595
  x(
1590
- (c) => Js({
1596
+ (c) => Ys({
1591
1597
  options: {
1592
1598
  ...this.options,
1593
1599
  onMutate: (l) => {
@@ -1733,7 +1739,7 @@ class Wt {
1733
1739
  * @important
1734
1740
  * Query store. Could be turned into a map for more performance.
1735
1741
  */
1736
- m(this, "entriesSubject", new J([]));
1742
+ m(this, "entriesSubject", new Y([]));
1737
1743
  m(this, "changeSubject", new I());
1738
1744
  m(this, "entries$", this.entriesSubject.pipe(de()));
1739
1745
  m(this, "added$", this.changeSubject.pipe(
@@ -1782,13 +1788,13 @@ class Wt {
1782
1788
  }
1783
1789
  }
1784
1790
  var K;
1785
- class Bs {
1791
+ class Xs {
1786
1792
  constructor(e = {}) {
1787
1793
  C(this, K, new Wt());
1788
1794
  this.config = e;
1789
1795
  }
1790
1796
  build(e, t, r) {
1791
- const n = new Ys({
1797
+ const n = new Bs({
1792
1798
  mutationCache: this,
1793
1799
  options: e.defaultMutationOptions(t),
1794
1800
  state: r
@@ -1887,7 +1893,7 @@ class Bs {
1887
1893
  }
1888
1894
  }
1889
1895
  K = new WeakMap();
1890
- function Xs(s) {
1896
+ function Zs(s) {
1891
1897
  const e = typeof s.initialData == "function" ? s.initialData() : s.initialData, t = typeof e < "u", r = t ? typeof s.initialDataUpdatedAt == "function" ? s.initialDataUpdatedAt() : s.initialDataUpdatedAt : 0;
1892
1898
  return {
1893
1899
  data: e,
@@ -1904,7 +1910,7 @@ function Xs(s) {
1904
1910
  fetchStatus: "idle"
1905
1911
  };
1906
1912
  }
1907
- const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s))), er = (s) => {
1913
+ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s))), tr = (s) => {
1908
1914
  let e = 0;
1909
1915
  return (t) => {
1910
1916
  const r = re.backToOnline$.pipe(
@@ -1923,7 +1929,7 @@ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
1923
1929
  r
1924
1930
  ) : t));
1925
1931
  };
1926
- }, tr = (s) => (e) => {
1932
+ }, sr = (s) => (e) => {
1927
1933
  const t = new I(), r = t.pipe(
1928
1934
  Je(),
1929
1935
  /**
@@ -1939,7 +1945,7 @@ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
1939
1945
  }),
1940
1946
  ne(r)
1941
1947
  );
1942
- }, sr = (s) => {
1948
+ }, rr = (s) => {
1943
1949
  const e = async () => await Promise.reject(new Error("No query found"));
1944
1950
  process.env.NODE_ENV !== "production" && s.queryFn === it && console.error(
1945
1951
  `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`
@@ -1961,7 +1967,7 @@ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
1961
1967
  () => r(u)
1962
1968
  )
1963
1969
  ) : r).pipe(
1964
- tr(s.observers$),
1970
+ sr(s.observers$),
1965
1971
  E({
1966
1972
  complete: () => {
1967
1973
  t = !0;
@@ -1973,10 +1979,10 @@ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
1973
1979
  })
1974
1980
  ),
1975
1981
  // takeUntil(hasDataAndNoObservers$),
1976
- er(s),
1982
+ tr(s),
1977
1983
  Pt({
1978
1984
  ...s,
1979
- retryAfter: () => v(!0).pipe(Zs),
1985
+ retryAfter: () => v(!0).pipe(er),
1980
1986
  catchError: (o, p) => v({
1981
1987
  status: "error",
1982
1988
  fetchStatus: "idle",
@@ -2040,14 +2046,14 @@ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
2040
2046
  abortController: n
2041
2047
  };
2042
2048
  };
2043
- class rr {
2049
+ class nr {
2044
2050
  constructor(e) {
2045
2051
  m(this, "revert");
2046
2052
  m(this, "silent");
2047
2053
  this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
2048
2054
  }
2049
2055
  }
2050
- const nr = { backgroundColor: "transparent", color: "inherit" };
2056
+ const ir = { backgroundColor: "transparent", color: "inherit" };
2051
2057
  function Gt(s) {
2052
2058
  const e = {
2053
2059
  namespaces: [
@@ -2060,7 +2066,7 @@ function Gt(s) {
2060
2066
  const n = Gt();
2061
2067
  return n.namespaces.push({
2062
2068
  name: t,
2063
- style: r ?? nr
2069
+ style: r ?? ir
2064
2070
  }), n;
2065
2071
  },
2066
2072
  printNamespaces() {
@@ -2095,9 +2101,9 @@ function Gt(s) {
2095
2101
  };
2096
2102
  return e;
2097
2103
  }
2098
- const ir = Gt();
2104
+ const ur = Gt();
2099
2105
  var xe, ae;
2100
- class ur {
2106
+ class ar {
2101
2107
  constructor(e) {
2102
2108
  m(this, "queryKey");
2103
2109
  m(this, "queryHash");
@@ -2113,12 +2119,12 @@ class ur {
2113
2119
  m(this, "invalidatedSubject", new I());
2114
2120
  m(this, "resetSubject", new I());
2115
2121
  m(this, "destroySubject", new I());
2116
- m(this, "observersSubject", new J([]));
2122
+ m(this, "observersSubject", new Y([]));
2117
2123
  m(this, "abortSignalConsumed", !1);
2118
2124
  m(this, "observerCount$", this.observersSubject.asObservable().pipe(g((e) => e.length)));
2119
2125
  m(this, "observers$", this.observersSubject.asObservable());
2120
2126
  m(this, "state$");
2121
- M(this, xe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, M(this, ae, e.state ?? Xs(this.options)), this.state = a(this, ae), this.gcTime = this.updateGcTime(this.options.gcTime), this.state$ = F(
2127
+ M(this, xe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, M(this, ae, e.state ?? Zs(this.options)), this.state = a(this, ae), this.gcTime = this.updateGcTime(this.options.gcTime), this.state$ = F(
2122
2128
  this.resetSubject.pipe(
2123
2129
  g(() => ({ command: "reset", state: a(this, ae) }))
2124
2130
  ),
@@ -2138,7 +2144,7 @@ class ur {
2138
2144
  state: {
2139
2145
  status: t != null && t.revert ? this.state.status : "error",
2140
2146
  fetchStatus: "idle",
2141
- error: new rr(t)
2147
+ error: new nr(t)
2142
2148
  }
2143
2149
  }))
2144
2150
  ),
@@ -2155,7 +2161,7 @@ class ur {
2155
2161
  o.length === 0 && h.length > 0 ? t = !0 : t = !1;
2156
2162
  }),
2157
2163
  he()
2158
- ), { state$: u, abortController: i } = sr({
2164
+ ), { state$: u, abortController: i } = rr({
2159
2165
  ...this.options,
2160
2166
  observers$: this.observerCount$,
2161
2167
  queryKey: this.queryKey,
@@ -2202,7 +2208,7 @@ class ur {
2202
2208
  }))
2203
2209
  )
2204
2210
  ).pipe(
2205
- Ds({
2211
+ ks({
2206
2212
  initialState: this.state,
2207
2213
  getOptions: () => this.options,
2208
2214
  getState: () => this.state
@@ -2212,8 +2218,8 @@ class ur {
2212
2218
  E((t) => {
2213
2219
  this.state = t;
2214
2220
  }),
2215
- B((t) => {
2216
- throw ir.error(t), t;
2221
+ X((t) => {
2222
+ throw ur.error(t), t;
2217
2223
  }),
2218
2224
  ne(this.destroySubject),
2219
2225
  Ue({ bufferSize: 1, refCount: !1 })
@@ -2283,7 +2289,7 @@ class ur {
2283
2289
  return this.state.isInvalidated || !this.state.dataUpdatedAt || this.observersSubject.getValue().some((e) => e.getCurrentResult().isStale);
2284
2290
  }
2285
2291
  isStaleByTime(e = 0) {
2286
- return this.state.isInvalidated || !this.state.dataUpdatedAt || !Vs(this.state.dataUpdatedAt, e);
2292
+ return this.state.isInvalidated || !this.state.dataUpdatedAt || !Ps(this.state.dataUpdatedAt, e);
2287
2293
  }
2288
2294
  async getFetchResultAsPromise() {
2289
2295
  return await new Promise((e, t) => {
@@ -2320,7 +2326,7 @@ class ur {
2320
2326
  }
2321
2327
  xe = new WeakMap(), ae = new WeakMap();
2322
2328
  var Re, G;
2323
- class ar {
2329
+ class or {
2324
2330
  // protected mountSubscriptions: Subscription[]
2325
2331
  constructor(e = {}) {
2326
2332
  // readonly #queries: QueryStore = new Map<string, Query>()
@@ -2356,7 +2362,7 @@ class ar {
2356
2362
  build(e, t, r) {
2357
2363
  const n = t.queryKey ?? [ct()], u = t.queryHash ?? dt(n, t);
2358
2364
  let i = this.get(u);
2359
- return i || (i = new ur({
2365
+ return i || (i = new ar({
2360
2366
  cache: this,
2361
2367
  queryKey: n,
2362
2368
  queryHash: u,
@@ -2391,7 +2397,7 @@ class ar {
2391
2397
  * Once a mutation is finished and there are no more observers than us
2392
2398
  * we start the process of cleaning it up based on gc settings
2393
2399
  */
2394
- ks,
2400
+ Ts,
2395
2401
  x((r) => r ? t.pipe(
2396
2402
  // defaults to 5mn
2397
2403
  x(() => e.gcTime === 1 / 0 ? qe : (setTimeout(N, e.gcTime), Qe(e.gcTime)))
@@ -2453,7 +2459,7 @@ class ar {
2453
2459
  }
2454
2460
  Re = new WeakMap(), G = new WeakMap();
2455
2461
  var oe, A, je, Me, ge;
2456
- class Er {
2462
+ class Rr {
2457
2463
  // #destroy = () => {}
2458
2464
  constructor({
2459
2465
  mutationCache: e,
@@ -2465,7 +2471,7 @@ class Er {
2465
2471
  C(this, je, /* @__PURE__ */ new Map());
2466
2472
  C(this, Me, /* @__PURE__ */ new Map());
2467
2473
  C(this, ge, void 0);
2468
- M(this, oe, e ?? new Bs()), M(this, A, t ?? new ar()), M(this, ge, r ?? {});
2474
+ M(this, oe, e ?? new Xs()), M(this, A, t ?? new or()), M(this, ge, r ?? {});
2469
2475
  }
2470
2476
  mount() {
2471
2477
  }
@@ -2534,7 +2540,7 @@ class Er {
2534
2540
  setQueryData(e, t, r) {
2535
2541
  const n = this.defaultQueryOptions({ queryKey: e }), u = a(this, A).get(
2536
2542
  n.queryHash
2537
- ), i = u == null ? void 0 : u.state.data, c = Ps(t, i);
2543
+ ), i = u == null ? void 0 : u.state.data, c = Ds(t, i);
2538
2544
  if (c !== void 0)
2539
2545
  return a(this, A).build(this, n).setData(c, { ...r, manual: !0 });
2540
2546
  }
@@ -2605,32 +2611,34 @@ class Er {
2605
2611
  }
2606
2612
  oe = new WeakMap(), A = new WeakMap(), je = new WeakMap(), Me = new WeakMap(), ge = new WeakMap();
2607
2613
  export {
2608
- Bs as MutationCache,
2609
- ar as QueryCache,
2610
- Er as QueryClient,
2611
- Or as QueryClientProvider,
2614
+ Xs as MutationCache,
2615
+ or as QueryCache,
2616
+ Rr as QueryClient,
2617
+ wr as QueryClientProvider,
2612
2618
  Ss as SIGNAL_RESET,
2613
- vr as arrayEqual,
2619
+ Or as arrayEqual,
2614
2620
  Os as createLocalStorageAdapter,
2615
- gr as createLocalforageAdapter,
2621
+ mr as createLocalforageAdapter,
2616
2622
  Fs as exponentialBackoffDelay,
2617
2623
  Cs as getDelay,
2618
2624
  rt as isDefined,
2619
2625
  Pt as retryBackoff,
2620
- yr as signal,
2626
+ br as signal,
2621
2627
  Vt as useBehaviorSubject,
2622
- Cr as useForeverQuery,
2628
+ Es as useEffectOnce,
2629
+ Er as useForeverQuery,
2623
2630
  q as useLiveRef,
2624
- $r as useMutation,
2625
- pr as useObservableState,
2631
+ $r as useMount,
2632
+ Cr as useMutation,
2633
+ yr as useObservableState,
2626
2634
  Xe as useObserve,
2627
- fr as useObserveCallback,
2628
- mr as usePersistSignals,
2629
- wr as useQuery,
2635
+ pr as useObserveCallback,
2636
+ Sr as usePersistSignals,
2637
+ Fr as useQuery,
2630
2638
  Tt as useQueryClient,
2631
- br as useSignalValue,
2639
+ gr as useSignalValue,
2632
2640
  It as useSubject,
2633
2641
  Ut as useSubscribe,
2634
- Fr as useSubscribeEffect,
2635
- Sr as useUnmountObservable
2642
+ xr as useSubscribeEffect,
2643
+ vr as useUnmountObservable
2636
2644
  };
@@ -0,0 +1,3 @@
1
+ import { EffectCallback } from 'react';
2
+
3
+ export declare const useEffectOnce: (effect: EffectCallback) => void;
@@ -0,0 +1 @@
1
+ export declare const useMount: (fn: () => void) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.88.0",
4
+ "version": "1.89.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"