reactjrx 1.87.0 → 1.87.1

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 he(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 he(()=>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))}},re="__reactjrx",Et=s=>{if(typeof s=="object"&&s!==null&&re in s&&s[re]===re)return s};function ge(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(),[re]:re,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=he(()=>{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(ge),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)}))})}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 te=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 se=s=>s.pipe(r.takeWhile(e=>e.status!=="error"&&e.status!=="success",!0));var H;class Rt{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(se,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,H))),d=u.state$.pipe(se,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 me=(s,e,{exact:t=!1}={})=>t?te(s)===te(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 Ut{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 Rt(this.options)),this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this),c(this,I).pipe(r.filter(ge),r.mergeMap(u=>c(this,z).state$.pipe(r.takeUntil(u.mutation.state$.pipe(se,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&&!me(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(ge),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(se,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),xt=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),At=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(rt.Provider,{value:t,children:[Ke.jsx(xt,{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 Qt(){}function Pt(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=te(s.mutationKey??i.current),[a]=v.useState(()=>new Ut(t,s));v.useEffect(()=>{a.setOptions(s)},[a,s]);const l=v.useMemo(()=>a.observe(),[u,a]),h=he(l.result$)??l.lastValue,f=v.useCallback((o,b)=>{a.mutate(o,b).catch(Qt)},[a]);return v.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function kt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const ye=typeof window>"u"||"Deno"in window;class Vt{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(ye?r.EMPTY:r.fromEvent(window,"offline").pipe(r.map(()=>!1)),ye?r.EMPTY:r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(kt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Vt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function It(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 It(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 Tt(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 Dt(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)??te)(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 Kt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Nt(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(),qt=({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)),Ht=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 Lt{constructor(){$(this,Oe,r.merge(r.fromEvent(document,"visibilitychange"),ye?r.EMPTY:r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));$(this,L,new r.BehaviorSubject(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 Lt,Wt=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,ne,B,x,X,ie;class at{constructor(e,t){$(this,q,void 0);$(this,C,void 0);$(this,ne,new r.Subject);y(this,"queryUpdateSubject",new r.Subject);$(this,B,void 0);$(this,x,void 0);$(this,X,void 0);$(this,ie,0);y(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:l,selectError:h,selectResult:f}})=>{var be;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,ie),Te=!Q&&We(t,e),pt=Q&&_e(t,d,e,p);(Te||pt)&&(w=Dt(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 fe=V==="error";let de=!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((be=c(this,X))==null?void 0:be.state.data,c(this,X)):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),de=!0)}const pe=w==="fetching";return{result:{status:V,fetchStatus:w,isPending:b,isSuccess:V==="success",isError:fe,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:pe,isRefetching:pe&&!b,isLoadingError:fe&&o.dataUpdatedAt===0,isPaused:w==="paused",isPlaceholderData:de,isRefetchError:fe&&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 _t(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,X,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,ne).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,ne).pipe(r.filter(S=>S.query===a)),o=a.state$.pipe(Wt,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:(de,pe)=>{const Ie=ze(de,V),be=ze(pe,V);return R(Ie,be)}: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])=>{Tt(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,ie,a)),r.tap({subscribe:()=>{We(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}q=new WeakMap,C=new WeakMap,ne=new WeakMap,B=new WeakMap,x=new WeakMap,X=new WeakMap,ie=new WeakMap;function _t(s,e){return!R(s.getCurrentResult(),e)}const ut=we.createContext(!1),zt=()=>we.useContext(ut);ut.Provider;function Bt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Yt=we.createContext(Bt()),Gt=()=>we.useContext(Yt);function Jt(s,e){return typeof s=="function"?s(...e):!!s}const Xt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Jt(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=zt(),u=Gt(),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;he(()=>h.current.pipe(r.filter(d=>!R(d,f.current))),[]),v.useEffect(()=>{l.setOptions(a)},[a,l]);const b=o.error;if(b&&Xt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function Zt(s,e){return ct(s,at,e)}function er(s,e){return ct({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},at,e)}function tr(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)))),rr=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))))},sr=({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})),rr,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 ae,W,Z;class nr{constructor({options:e,mutationCache:t,state:n}){$(this,ae,new r.BehaviorSubject(0));$(this,W,new r.Subject);$(this,Z,new r.Subject);y(this,"state",J());y(this,"state$");y(this,"options");y(this,"observerCount$",c(this,ae).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,Z).pipe(r.switchMap(l=>sr({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,ae).next(l)}))}get meta(){return this.options.meta}setOptions(e){this.options={...this.options,...e}}execute(e){return c(this,Z).next(e),c(this,Z).complete(),this.state$.pipe(se)}continue(){return this.execute(this.state.variables)}cancel(){c(this,W).next(),c(this,W).complete()}}ae=new WeakMap,W=new WeakMap,Z=new WeakMap;const Ge=({mutationKey:s,status:e,predicate:t,exact:n=!0}={})=>u=>n&&s!==void 0&&u.options.mutationKey!==void 0&&!me(u.options.mutationKey,s,{exact:n})||!n&&s!==void 0&&u.options.mutationKey!==void 0&&!me(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 nr({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 ir(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 ar=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),ur=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))}},cr=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))},or=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(cr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),ur(s),xe({...s,retryAfter:()=>r.of(!0).pipe(ar),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 lr{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 hr={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??hr}),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 fr=ft();var ue,Y;class dr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ue,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,ue,e.defaultOptions),this.options=this.setOptions(e.options),this.queryKey=e.queryKey,this.queryHash=e.queryHash,M(this,Y,e.state??ir(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 lr(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}=or({...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(qt({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 fr.error(t),t}),r.takeUntil(this.destroySubject),r.shareReplay({bufferSize:1,refCount:!1}))}setOptions(e){return this.options={...c(this,ue),...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??(ye?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||!Kt(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()}}ue=new WeakMap,Y=new WeakMap;var ce,N;class dt{constructor(e={}){$(this,ce,new r.Subject);$(this,N,new lt);this.config=e}mount(){}unmount(){}notify(e){c(this,ce).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 dr({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(Ht,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,ce).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(){}}ce=new WeakMap,N=new WeakMap;var G,j,oe,le,ee;class pr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,G,void 0);$(this,j,void 0);$(this,oe,new Map);$(this,le,new Map);$(this,ee,void 0);M(this,G,e??new ht),M(this,j,t??new dt),M(this,ee,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,G)}getQueryCache(){return c(this,j)}defaultMutationOptions(e){return{...c(this,ee).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e}}defaultQueryOptions(e){if(e._defaulted)return e;const t={...c(this,ee).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=Nt(t,a);if(l!==void 0)return c(this,j).build(this,i).setData(l,{...n,manual:!0})}getMutationDefaults(e){const t=[...c(this,oe).values()];let n={};return t.forEach(i=>{me(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,oe).set(te(e),{mutationKey:e,defaultOptions:t})}setQueryDefaults(e,t){c(this,le).set(te(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...c(this,le).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,oe=new WeakMap,le=new WeakMap,ee=new WeakMap;exports.MutationCache=ht;exports.QueryCache=dt;exports.QueryClient=pr;exports.QueryClientProvider=At;exports.SIGNAL_RESET=Je;exports.createLocalStorageAdapter=Xe;exports.createLocalforageAdapter=$t;exports.exponentialBackoffDelay=et;exports.getDelay=Ze;exports.isDefined=ge;exports.retryBackoff=xe;exports.signal=Ot;exports.useBehaviorSubject=Ue;exports.useForeverQuery=er;exports.useLiveRef=A;exports.useMutation=Pt;exports.useObservableState=vt;exports.useObserve=he;exports.useObserveCallback=St;exports.usePersistSignals=jt;exports.useQuery=Zt;exports.useQueryClient=Pe;exports.useSignalValue=wt;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=tr;exports.useUnmountObservable=Ft;
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)}))})}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 Rt{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 Ut{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 Rt(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),xt=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),At=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return Ke.jsxs(rt.Provider,{value:t,children:[Ke.jsx(xt,{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 Qt(){}function Pt(s,e){const t=Pe(e),n=A(s),i=$e(()=>[Ae()]),u=re(s.mutationKey??i.current),[a]=v.useState(()=>new Ut(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(Qt)},[a]);return v.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...h,mutate:f,mutateAsync:h.mutate}}function kt(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}const X=typeof window>"u"||"Deno"in window;class Vt{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(kt(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Vt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function It(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 It(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 Tt(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 Dt(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 Kt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Nt(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(),qt=({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)),Ht=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 Lt{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 Lt,Wt=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=Dt(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 _t(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(Wt,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])=>{Tt(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 _t(s,e){return!R(s.getCurrentResult(),e)}const ut=we.createContext(!1),zt=()=>we.useContext(ut);ut.Provider;function Bt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Yt=we.createContext(Bt()),Gt=()=>we.useContext(Yt);function Jt(s,e){return typeof s=="function"?s(...e):!!s}const Xt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Jt(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=zt(),u=Gt(),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&&Xt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function Zt(s,e){return ct(s,at,e)}function er(s,e){return ct({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},at,e)}function tr(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)))),rr=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))))},sr=({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})),rr,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 nr{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=>sr({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 nr({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 ir(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 ar=s=>r.defer(()=>ve.isFocused()?s:ve.focusRegained$.pipe(r.mergeMap(()=>s))),ur=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))}},cr=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))},or=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(cr(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(o=>({data:o})),ur(s),xe({...s,retryAfter:()=>r.of(!0).pipe(ar),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 lr{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 hr={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??hr}),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 fr=ft();var ce,Y;class dr{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??ir(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 lr(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}=or({...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(qt({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 fr.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||!Kt(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 dr({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(Ht,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 pr{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=Nt(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=pr;exports.QueryClientProvider=At;exports.SIGNAL_RESET=Je;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=er;exports.useLiveRef=A;exports.useMutation=Pt;exports.useObservableState=vt;exports.useObserve=fe;exports.useObserveCallback=St;exports.usePersistSignals=jt;exports.useQuery=Zt;exports.useQueryClient=Pe;exports.useSignalValue=wt;exports.useSubject=Re;exports.useSubscribe=Fe;exports.useSubscribeEffect=tr;exports.useUnmountObservable=Ft;
package/dist/index.js CHANGED
@@ -10,12 +10,12 @@ var a = (s, e, t) => (bt(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) => (bt(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 ge, 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 re, isObservable as yt, from as me, of as v, defer as Me, 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 ve, timer as Ae, Observable as is, takeWhile as Ye, concatMap as us, last as Te, takeUntil as ne, identity as Mt, shareReplay as Qe, ignoreElements as he, scan as Be, fromEvent as Ke, noop as N, startWith as ce, pairwise as At, NEVER as Ne, delay as ot, interval as as, withLatestFrom as gt, retry as os, iif as cs, concat as De, toArray as ke, share as de, take as qe, 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 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 yt, 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";
15
15
  import { catchError as mt, mergeMap as tt, retryWhen as fs, concatMap as ps, first as bs, tap as Qt } from "rxjs/operators";
16
16
  import { jsxs as ys, jsx as gs } from "react/jsx-runtime";
17
17
  const q = (s) => {
18
- const e = ge(s);
18
+ const e = me(s);
19
19
  return ut(() => {
20
20
  e.current = s;
21
21
  }, [s]), e;
@@ -27,7 +27,7 @@ function Xe(s, e, t) {
27
27
  const r = e != null && !Array.isArray(e) ? e : {
28
28
  defaultValue: void 0,
29
29
  unsubscribeOnUnmount: !0
30
- }, n = !t && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u = ge(
30
+ }, n = !t && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u = me(
31
31
  "getValue" in s && typeof s.getValue == "function" ? s.getValue() : r.defaultValue
32
32
  ), i = q(s), c = q(r), l = le(
33
33
  (p) => {
@@ -42,7 +42,7 @@ function Xe(s, e, t) {
42
42
  E((y) => {
43
43
  u.current = y;
44
44
  }),
45
- B((y) => (console.error(y), re))
45
+ B((y) => (console.error(y), Z))
46
46
  ).subscribe(p);
47
47
  return () => {
48
48
  c.current.unsubscribeOnUnmount !== !1 && b.unsubscribe();
@@ -60,13 +60,13 @@ function U(s) {
60
60
  if (yt(s))
61
61
  return s;
62
62
  if (St(s))
63
- return me(s);
63
+ return Se(s);
64
64
  if (typeof s != "function")
65
65
  return v(s);
66
66
  const e = s;
67
- return Me(() => {
67
+ return Ae(() => {
68
68
  const t = e();
69
- return St(t) ? me(t) : yt(t) ? t : v(t);
69
+ return St(t) ? Se(t) : yt(t) ? t : v(t);
70
70
  });
71
71
  }
72
72
  function Ut(s, e = []) {
@@ -83,7 +83,7 @@ function Ut(s, e = []) {
83
83
  ]);
84
84
  }
85
85
  const Ze = (s) => {
86
- const e = ge();
86
+ const e = me();
87
87
  return e.current || (e.current = s()), X(() => {
88
88
  process.env.NODE_ENV;
89
89
  }, []), e;
@@ -91,7 +91,7 @@ const Ze = (s) => {
91
91
  onBeforeComplete: s,
92
92
  completeOnUnmount: e = !0
93
93
  } = {}) => {
94
- const t = Ze(() => new I()), r = ge(!1), n = q(s), u = q(e);
94
+ const t = Ze(() => new I()), r = me(!1), n = q(s), u = q(e);
95
95
  return X(() => (r.current && (t.current = new I(), r.current = !1), () => {
96
96
  if (!u.current) {
97
97
  r.current = !0;
@@ -109,7 +109,7 @@ const Ze = (s) => {
109
109
  );
110
110
  return [e.current, t];
111
111
  }, Vt = (s) => {
112
- const e = Ze(() => new J(s)), t = ge(!1), r = ge(s);
112
+ const e = Ze(() => new J(s)), t = me(!1), r = me(s);
113
113
  return X(() => (t.current && (e.current = new J(r.current), t.current = !1), () => {
114
114
  t.current || (e.current.complete(), t.current = !0);
115
115
  }), [e]), e;
@@ -227,8 +227,8 @@ const gr = (s) => ({
227
227
  setItem: async (e, t) => {
228
228
  localStorage.setItem(e, JSON.stringify(t));
229
229
  }
230
- }, Oe = "__reactjrx", $s = (s) => {
231
- if (typeof s == "object" && s !== null && Oe in s && s[Oe] === Oe)
230
+ }, $e = "__reactjrx", $s = (s) => {
231
+ if (typeof s == "object" && s !== null && $e in s && s[$e] === $e)
232
232
  return s;
233
233
  };
234
234
  function rt(s) {
@@ -246,17 +246,17 @@ const vt = (s) => {
246
246
  }) => {
247
247
  const n = {
248
248
  value: e.getValue(),
249
- [Oe]: Oe,
249
+ [$e]: $e,
250
250
  migrationVersion: t
251
251
  };
252
- return me(s.setItem(e.config.key, n)).pipe(
252
+ return Se(s.setItem(e.config.key, n)).pipe(
253
253
  B((u) => (console.error(u), v(null)))
254
254
  );
255
255
  }, ws = ({
256
256
  adapter: s,
257
257
  version: e,
258
258
  signal: t
259
- }) => me(s.getItem(t.config.key)).pipe(
259
+ }) => Se(s.getItem(t.config.key)).pipe(
260
260
  x((r) => {
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);
@@ -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), re))
297
+ B((p) => (console.error("Unable to hydrate", p), Z))
298
298
  );
299
299
  })
300
300
  );
@@ -314,7 +314,7 @@ const vt = (s) => {
314
314
  rs(500, ns, {
315
315
  trailing: !0
316
316
  }),
317
- x(() => me(
317
+ x(() => Se(
318
318
  Ot({
319
319
  adapter: l,
320
320
  signal: h,
@@ -359,7 +359,7 @@ function Pt(s) {
359
359
  resetOnSuccess: o = !1,
360
360
  backoffDelay: p = Fs
361
361
  } = l;
362
- return (d) => Me(() => {
362
+ return (d) => Ae(() => {
363
363
  let f = 0;
364
364
  const b = (y, $) => y < u ? i(y, $) : !1;
365
365
  return d.pipe(
@@ -374,7 +374,7 @@ function Pt(s) {
374
374
  tt(
375
375
  (H) => F(
376
376
  v(H),
377
- ve(() => y)
377
+ Oe(() => y)
378
378
  )
379
379
  )
380
380
  );
@@ -385,14 +385,14 @@ function Pt(s) {
385
385
  return n().pipe(
386
386
  bs(),
387
387
  tt(
388
- () => b(w, $) ? Ae(
388
+ () => b(w, $) ? Qe(
389
389
  Cs(
390
390
  p(w, c),
391
391
  h
392
392
  )
393
393
  ).pipe(
394
- tt((H) => r && !r(w, $) ? ve(() => $) : v(H))
395
- ) : ve(() => $)
394
+ tt((H) => r && !r(w, $) ? Oe(() => $) : v(H))
395
+ ) : Oe(() => $)
396
396
  )
397
397
  );
398
398
  })
@@ -420,7 +420,7 @@ function nt(s) {
420
420
  const t = e.prototype;
421
421
  return !(!$t(t) || !t.hasOwnProperty("isPrototypeOf"));
422
422
  }
423
- const Se = (s) => JSON.stringify(
423
+ const ve = (s) => JSON.stringify(
424
424
  s,
425
425
  (e, t) => nt(t) ? Object.keys(t).sort().reduce((r, n) => (r[n] = t[n], r), {}) : t
426
426
  ), ct = (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), ""), fe = () => ({
@@ -446,38 +446,38 @@ function lt(s) {
446
446
  });
447
447
  };
448
448
  }
449
- const $e = (s) => s.pipe(
449
+ const we = (s) => s.pipe(
450
450
  Ye(
451
451
  (e) => e.status !== "error" && e.status !== "success",
452
452
  !0
453
453
  )
454
454
  );
455
- var Z;
455
+ var ee;
456
456
  class Es {
457
457
  constructor({
458
458
  __queryFinalizeHook: e
459
459
  } = {}) {
460
- C(this, Z, new I());
460
+ C(this, ee, new I());
461
461
  m(this, "state$");
462
462
  const t = new J(0), r = t.pipe(
463
463
  O((n) => n === 0)
464
464
  );
465
- this.state$ = a(this, Z).pipe(
465
+ this.state$ = a(this, ee).pipe(
466
466
  us(({ args: n, mutation: u, options: i }) => {
467
- const c = i.mapOperator ?? "merge", l = a(this, Z).pipe(
467
+ const c = i.mapOperator ?? "merge", l = a(this, ee).pipe(
468
468
  O(() => c === "merge")
469
- ), h = a(this, Z).pipe(
469
+ ), h = a(this, ee).pipe(
470
470
  O(() => c === "switch"),
471
471
  E(() => {
472
472
  u.cancel();
473
473
  })
474
- ), o = Me(() => (u.execute(n), re)), p = u.state$.pipe(
475
- $e,
476
- Te(),
474
+ ), o = Ae(() => (u.execute(n), Z)), p = u.state$.pipe(
475
+ we,
476
+ Ke(),
477
477
  k(() => u.state$),
478
- ne(a(this, Z))
478
+ ne(a(this, ee))
479
479
  ), d = u.state$.pipe(
480
- $e,
480
+ we,
481
481
  at(1)
482
482
  ), f = F(
483
483
  r,
@@ -499,7 +499,7 @@ class Es {
499
499
  ne(f)
500
500
  );
501
501
  }),
502
- Qe({
502
+ Ue({
503
503
  refCount: !0,
504
504
  bufferSize: 1
505
505
  }),
@@ -513,14 +513,14 @@ class Es {
513
513
  options: t,
514
514
  mutation: r
515
515
  }) {
516
- a(this, Z).next({ args: e, options: t, mutation: r });
516
+ a(this, ee).next({ args: e, options: t, mutation: r });
517
517
  }
518
518
  }
519
- Z = new WeakMap();
519
+ ee = new WeakMap();
520
520
  function et(s, e) {
521
521
  return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? !Object.keys(e).some((t) => !et(s[t], e[t])) : !1;
522
522
  }
523
- const He = (s, e, { exact: t = !1 } = {}) => t ? Se(s) === Se(e) : et(s, e);
523
+ const _e = (s, e, { exact: t = !1 } = {}) => t ? ve(s) === ve(e) : et(s, e);
524
524
  function V(s, e) {
525
525
  if (s == null || e === void 0 || typeof s != "object" || typeof e != "object")
526
526
  return s === e;
@@ -569,7 +569,7 @@ class xs {
569
569
  k(
570
570
  (u) => a(this, ie).state$.pipe(
571
571
  ne(
572
- u.mutation.state$.pipe($e, Te())
572
+ u.mutation.state$.pipe(we, Ke())
573
573
  )
574
574
  )
575
575
  )
@@ -580,7 +580,7 @@ class xs {
580
580
  state: i,
581
581
  options: u.options
582
582
  }))
583
- )) ?? re),
583
+ )) ?? Z),
584
584
  E(({ state: u, options: i }) => {
585
585
  u.status === "error" && (i != null && i.onError && (i == null || i.onError(
586
586
  u.error,
@@ -613,7 +613,7 @@ class xs {
613
613
  ...e
614
614
  });
615
615
  const r = (n = a(this, L).getValue()) == null ? void 0 : n.mutation;
616
- this.options.mutationKey && t.mutationKey && !He(this.options.mutationKey, t.mutationKey, {
616
+ this.options.mutationKey && t.mutationKey && !_e(this.options.mutationKey, t.mutationKey, {
617
617
  exact: !0
618
618
  }) ? this.reset() : r == null || r.setOptions(this.options);
619
619
  }
@@ -667,7 +667,7 @@ class xs {
667
667
  options: this.options,
668
668
  mutation: r
669
669
  }), await new Promise((n, u) => {
670
- r.state$.pipe($e, Te()).subscribe({
670
+ r.state$.pipe(we, Ke()).subscribe({
671
671
  error: (i) => {
672
672
  u(i);
673
673
  },
@@ -711,7 +711,7 @@ const kt = Zt(void 0), Rs = ({ client: s }) => (X(() => (s.mount(), () => {
711
711
  function js() {
712
712
  }
713
713
  function Or(s, e) {
714
- const t = Tt(e), r = q(s), n = Ze(() => [ct()]), u = Se(s.mutationKey ?? n.current), [i] = jt(
714
+ const t = Tt(e), r = q(s), n = Ze(() => [ct()]), u = ve(s.mutationKey ?? n.current), [i] = jt(
715
715
  () => new xs(
716
716
  t,
717
717
  s
@@ -737,7 +737,7 @@ function Ms(s) {
737
737
  })
738
738
  );
739
739
  }
740
- const _e = typeof window > "u" || "Deno" in window;
740
+ const pe = typeof window > "u" || "Deno" in window;
741
741
  class As {
742
742
  constructor() {
743
743
  m(this, "isOnlineSubject", new J(!0));
@@ -747,8 +747,8 @@ class As {
747
747
  Je()
748
748
  ));
749
749
  F(
750
- _e ? re : Ke(window, "offline").pipe(g(() => !1)),
751
- _e ? re : Ke(window, "online").pipe(g(() => !0))
750
+ pe ? Z : Ne(window, "offline").pipe(g(() => !1)),
751
+ pe ? Z : Ne(window, "online").pipe(g(() => !0))
752
752
  ).pipe(Ms(this.isOnlineSubject)).subscribe();
753
753
  }
754
754
  isOnline() {
@@ -758,7 +758,7 @@ class As {
758
758
  this.isOnlineSubject.getValue() !== e && this.isOnlineSubject.next(e);
759
759
  }
760
760
  }
761
- const se = new As();
761
+ const re = new As();
762
762
  function ht(s, e) {
763
763
  return s.isStaleByTime(e.staleTime);
764
764
  }
@@ -782,7 +782,7 @@ function Kt(s, e, t) {
782
782
  return !1;
783
783
  }
784
784
  function Is(s) {
785
- return (s ?? "online") === "online" ? se.isOnline() : !0;
785
+ return (s ?? "online") === "online" ? re.isOnline() : !0;
786
786
  }
787
787
  function Ft(s, e) {
788
788
  return e.reduce(
@@ -809,7 +809,7 @@ function Nt(s, e) {
809
809
  return e;
810
810
  }
811
811
  function dt(s, e) {
812
- return ((e == null ? void 0 : e.queryKeyHashFn) ?? Se)(s);
812
+ return ((e == null ? void 0 : e.queryKeyHashFn) ?? ve)(s);
813
813
  }
814
814
  function xt(s, e) {
815
815
  const {
@@ -880,33 +880,33 @@ const it = Symbol(), Ds = ({
880
880
  ), qt = (s) => s.pipe(
881
881
  Ye((e) => e.fetchStatus !== "idle", !0)
882
882
  );
883
- var We, ee;
883
+ var We, te;
884
884
  class Ts {
885
885
  constructor() {
886
886
  C(this, We, F(
887
- Ke(document, "visibilitychange"),
888
- _e ? re : Ke(window, "visibilitychange")
887
+ pe ? Z : Ne(document, "visibilitychange"),
888
+ pe ? Z : Ne(window, "visibilitychange")
889
889
  ).pipe(g(() => document.visibilityState)));
890
- C(this, ee, new J(
891
- document.visibilityState === "visible"
890
+ C(this, te, new J(
891
+ pe ? !0 : document.visibilityState === "visible"
892
892
  ));
893
893
  // public readonly focused$ = this.#focusedSubject.pipe(distinctUntilChanged())
894
- m(this, "focused$", a(this, ee));
894
+ m(this, "focused$", a(this, te));
895
895
  m(this, "focusRegained$", this.focused$.pipe(
896
896
  at(1),
897
897
  O((e) => e)
898
898
  ));
899
899
  a(this, We).pipe(
900
900
  E((e) => {
901
- a(this, ee).next(e === "visible");
901
+ a(this, te).next(e === "visible");
902
902
  })
903
903
  ).subscribe();
904
904
  }
905
905
  isFocused() {
906
- return a(this, ee).getValue();
906
+ return a(this, te).getValue();
907
907
  }
908
908
  setFocused(e) {
909
- a(this, ee).getValue() !== (e ?? !0) && a(this, ee).next(e ?? !0);
909
+ a(this, te).getValue() !== (e ?? !0) && a(this, te).next(e ?? !0);
910
910
  }
911
911
  subscribe(e) {
912
912
  const t = this.focused$.subscribe(e);
@@ -925,7 +925,7 @@ class Ts {
925
925
  document.dispatchEvent(new Event("visibilitychange"));
926
926
  }
927
927
  }
928
- We = new WeakMap(), ee = new WeakMap();
928
+ We = new WeakMap(), te = new WeakMap();
929
929
  const ze = new Ts(), Ks = (s) => s.pipe(
930
930
  O((e) => e.status === "success"),
931
931
  g((e) => ({
@@ -935,12 +935,12 @@ const ze = new Ts(), Ks = (s) => s.pipe(
935
935
  })),
936
936
  Q(V)
937
937
  );
938
- var Y, R, we, ue, D, pe, Ce;
938
+ var Y, R, Ce, ue, D, be, Fe;
939
939
  class Ht {
940
940
  constructor(e, t) {
941
941
  C(this, Y, void 0);
942
942
  C(this, R, void 0);
943
- C(this, we, new I());
943
+ C(this, Ce, new I());
944
944
  /**
945
945
  * Used to subscribe to changes in either query or options (or both).
946
946
  * We need to be able to track change to both of them at the same time
@@ -958,8 +958,8 @@ class Ht {
958
958
  C(this, D, void 0);
959
959
  // This property keeps track of the last query with defined data.
960
960
  // It will be used to pass the previous data and query to the placeholder function between renders.
961
- C(this, pe, void 0);
962
- C(this, Ce, 0);
961
+ C(this, be, void 0);
962
+ C(this, Fe, 0);
963
963
  m(this, "getObserverResultFromQuery", ({
964
964
  options: e,
965
965
  query: t,
@@ -973,11 +973,11 @@ class Ht {
973
973
  selectResult: h
974
974
  }
975
975
  }) => {
976
- var Pe;
976
+ var De;
977
977
  const o = t.state, p = t.state.status === "pending", d = a(this, R), f = this.options, y = t !== d ? t.state : a(this, ue);
978
978
  let { errorUpdatedAt: $, fetchStatus: w, error: H } = o;
979
979
  if (r) {
980
- const T = !!a(this, Ce), pt = !T && wt(t, e), Jt = T && Ct(t, d, e, f);
980
+ const T = !!a(this, Fe), pt = !T && wt(t, e), Jt = T && Ct(t, d, e, f);
981
981
  (pt || Jt) && (w = Is(t.options.networkMode) ? "fetching" : "paused");
982
982
  }
983
983
  const P = p && w === "fetching";
@@ -995,15 +995,15 @@ class Ht {
995
995
  j = o.data, S = null;
996
996
  let _ = w !== "idle" && !o.dataUpdatedAt ? "pending" : o.status;
997
997
  S && (H = S, j = h, $ = (n == null ? void 0 : n.errorUpdatedAt) ?? $, _ = "error");
998
- const Ue = _ === "error";
999
- let Ie = !1;
998
+ const Ie = _ === "error";
999
+ let Ve = !1;
1000
1000
  if (typeof e.placeholderData < "u" && typeof j > "u" && _ === "pending") {
1001
1001
  let T;
1002
1002
  if (n != null && n.isPlaceholderData && e.placeholderData === (u == null ? void 0 : u.placeholderData))
1003
1003
  T = n.data;
1004
1004
  else if (T = typeof e.placeholderData == "function" ? e.placeholderData(
1005
- (Pe = a(this, pe)) == null ? void 0 : Pe.state.data,
1006
- a(this, pe)
1005
+ (De = a(this, be)) == null ? void 0 : De.state.data,
1006
+ a(this, be)
1007
1007
  ) : e.placeholderData, e.select && typeof T < "u")
1008
1008
  try {
1009
1009
  T = e.select(T);
@@ -1013,16 +1013,16 @@ class Ht {
1013
1013
  n == null ? void 0 : n.data,
1014
1014
  T,
1015
1015
  e
1016
- ), Ie = !0);
1016
+ ), Ve = !0);
1017
1017
  }
1018
- const Ve = w === "fetching";
1018
+ const Pe = w === "fetching";
1019
1019
  return {
1020
1020
  result: {
1021
1021
  status: _,
1022
1022
  fetchStatus: w,
1023
1023
  isPending: p,
1024
1024
  isSuccess: _ === "success",
1025
- isError: Ue,
1025
+ isError: Ie,
1026
1026
  isInitialLoading: P,
1027
1027
  isLoading: P,
1028
1028
  data: j,
@@ -1034,12 +1034,12 @@ class Ht {
1034
1034
  errorUpdateCount: o.errorUpdateCount,
1035
1035
  isFetched: o.dataUpdateCount > 0 || o.errorUpdateCount > 0,
1036
1036
  isFetchedAfterMount: o.dataUpdateCount > y.dataUpdateCount || o.errorUpdateCount > y.errorUpdateCount,
1037
- isFetching: Ve,
1038
- isRefetching: Ve && !p,
1039
- isLoadingError: Ue && o.dataUpdatedAt === 0,
1037
+ isFetching: Pe,
1038
+ isRefetching: Pe && !p,
1039
+ isLoadingError: Ie && o.dataUpdatedAt === 0,
1040
1040
  isPaused: w === "paused",
1041
- isPlaceholderData: Ie,
1042
- isRefetchError: Ue && o.dataUpdatedAt !== 0,
1041
+ isPlaceholderData: Ve,
1042
+ isRefetchError: Ie && o.dataUpdatedAt !== 0,
1043
1043
  isStale: ht(t, e),
1044
1044
  // eslint-disable-next-line @typescript-eslint/unbound-method
1045
1045
  refetch: this.refetch
@@ -1114,7 +1114,7 @@ class Ht {
1114
1114
  select: n,
1115
1115
  selectResult: u
1116
1116
  }) {
1117
- 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, pe, e), a(this, Y).getQueryCache().notify({
1117
+ 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, be, e), a(this, Y).getQueryCache().notify({
1118
1118
  query: a(this, R),
1119
1119
  type: "observerResultsUpdated"
1120
1120
  });
@@ -1134,7 +1134,7 @@ class Ht {
1134
1134
  ...e,
1135
1135
  cancelRefetch: (e == null ? void 0 : e.cancelRefetch) ?? !0
1136
1136
  };
1137
- a(this, R).fetch(this.options, r).catch(N), a(this, we).next({
1137
+ a(this, R).fetch(this.options, r).catch(N), a(this, Ce).next({
1138
1138
  query: t,
1139
1139
  fetchOptions: r
1140
1140
  }), await t.getFetchResultAsPromise();
@@ -1189,26 +1189,26 @@ class Ht {
1189
1189
  O((S) => S.query === i),
1190
1190
  g((S) => S.options),
1191
1191
  Q(),
1192
- Qe(1)
1193
- ), h = a(this, we).pipe(
1192
+ Ue(1)
1193
+ ), h = a(this, Ce).pipe(
1194
1194
  O((S) => S.query === i)
1195
1195
  ), o = i.state$.pipe(
1196
1196
  Ks,
1197
1197
  x(
1198
- (S) => this.options.staleTime === 1 / 0 ? Ne : (this.options.staleTime ?? 0) <= 0 ? v(S).pipe(ot(1)) : Ae(this.options.staleTime ?? 1)
1198
+ (S) => this.options.staleTime === 1 / 0 ? qe : (this.options.staleTime ?? 0) <= 0 ? v(S).pipe(ot(1)) : Qe(this.options.staleTime ?? 1)
1199
1199
  ),
1200
1200
  Ye(() => this.options.enabled ?? !0)
1201
1201
  ), p = (S, z) => {
1202
1202
  const W = c.notifyOnChangeProps, _ = typeof W == "function" ? W() : W;
1203
- return (Array.isArray(_) ? _.length === 0 ? () => !0 : (Ie, Ve) => {
1203
+ return (Array.isArray(_) ? _.length === 0 ? () => !0 : (Ve, Pe) => {
1204
1204
  const ft = Ft(
1205
- Ie,
1206
- _
1207
- ), Pe = Ft(
1208
1205
  Ve,
1209
1206
  _
1207
+ ), De = Ft(
1208
+ Pe,
1209
+ _
1210
1210
  );
1211
- return V(ft, Pe);
1211
+ return V(ft, De);
1212
1212
  } : V)(S, z);
1213
1213
  }, d = h.pipe(
1214
1214
  x(() => i.state$),
@@ -1224,7 +1224,7 @@ class Ht {
1224
1224
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1225
1225
  (z || ze.isFocused()) && this.fetch({ cancelRefetch: !1 }).catch(N);
1226
1226
  })
1227
- ) : Ne),
1227
+ ) : qe),
1228
1228
  he()
1229
1229
  ), b = l.pipe(
1230
1230
  g(({ enabled: S }) => S ?? !0),
@@ -1268,7 +1268,7 @@ class Ht {
1268
1268
  return F(f, $, j);
1269
1269
  })
1270
1270
  ).pipe(
1271
- lt((i) => M(this, Ce, i)),
1271
+ lt((i) => M(this, Fe, i)),
1272
1272
  E({
1273
1273
  subscribe: () => {
1274
1274
  wt(e, this.options) && this.fetch().catch(N);
@@ -1280,7 +1280,7 @@ class Ht {
1280
1280
  destroy() {
1281
1281
  }
1282
1282
  }
1283
- Y = new WeakMap(), R = new WeakMap(), we = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), pe = new WeakMap(), Ce = new WeakMap();
1283
+ Y = new WeakMap(), R = new WeakMap(), Ce = new WeakMap(), ue = new WeakMap(), D = new WeakMap(), be = new WeakMap(), Fe = new WeakMap();
1284
1284
  function Ns(s, e) {
1285
1285
  return !V(s.getCurrentResult(), e);
1286
1286
  }
@@ -1381,7 +1381,7 @@ function Cr(s, e, t = []) {
1381
1381
  const zt = () => (s) => F(
1382
1382
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
1383
1383
  v({ isPaused: !0 }),
1384
- se.backToOnline$.pipe(
1384
+ re.backToOnline$.pipe(
1385
1385
  k(
1386
1386
  () => (
1387
1387
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
@@ -1392,7 +1392,7 @@ const zt = () => (s) => F(
1392
1392
  ), Gs = (s) => {
1393
1393
  let e = 0;
1394
1394
  return s.pipe(
1395
- B((t) => (e++, e <= 1 && !se.isOnline() ? F(
1395
+ B((t) => (e++, e <= 1 && !re.isOnline() ? F(
1396
1396
  v({
1397
1397
  failureCount: e,
1398
1398
  failureReason: t
@@ -1401,12 +1401,12 @@ const zt = () => (s) => F(
1401
1401
  * @important
1402
1402
  * timer needed to be iso RQ, so the state returned by mutation include both previous and next one
1403
1403
  */
1404
- Ae(1).pipe(
1404
+ Qe(1).pipe(
1405
1405
  k(
1406
- () => ve(() => t).pipe(zt())
1406
+ () => Oe(() => t).pipe(zt())
1407
1407
  )
1408
1408
  )
1409
- ) : ve(() => t)))
1409
+ ) : Oe(() => t)))
1410
1410
  );
1411
1411
  }, Js = ({
1412
1412
  variables: s,
@@ -1423,7 +1423,7 @@ const zt = () => (s) => F(
1423
1423
  return ((d = t.onMutate) == null ? void 0 : d.call(t, s)) ?? void 0;
1424
1424
  }
1425
1425
  )
1426
- ).pipe(Qe(1)), l = (d, f, b) => U(
1426
+ ).pipe(Ue(1)), l = (d, f, b) => U(
1427
1427
  () => {
1428
1428
  var $;
1429
1429
  return ($ = t.onError) == null ? void 0 : $.call(t, d, s, f);
@@ -1480,7 +1480,7 @@ const zt = () => (s) => F(
1480
1480
  !0
1481
1481
  )
1482
1482
  );
1483
- return se.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ? b : b.pipe(zt());
1483
+ return re.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ? b : b.pipe(zt());
1484
1484
  })
1485
1485
  ), o = v({
1486
1486
  ...e,
@@ -1525,8 +1525,8 @@ const zt = () => (s) => F(
1525
1525
  ).pipe(
1526
1526
  B((P) => d ? v(d) : v(P))
1527
1527
  );
1528
- return De(y, w).pipe(
1529
- ke(),
1528
+ return ke(y, w).pipe(
1529
+ Te(),
1530
1530
  g(
1531
1531
  () => f ? {
1532
1532
  error: f,
@@ -1563,28 +1563,28 @@ const zt = () => (s) => F(
1563
1563
  }), fe())
1564
1564
  );
1565
1565
  };
1566
- var Fe, te, be;
1566
+ var Ee, se, ye;
1567
1567
  class Ys {
1568
1568
  constructor({
1569
1569
  options: e,
1570
1570
  mutationCache: t,
1571
1571
  state: r
1572
1572
  }) {
1573
- C(this, Fe, new J(0));
1574
- C(this, te, new I());
1575
- C(this, be, new I());
1573
+ C(this, Ee, new J(0));
1574
+ C(this, se, new I());
1575
+ C(this, ye, new I());
1576
1576
  m(this, "state", fe());
1577
1577
  m(this, "state$");
1578
1578
  m(this, "options");
1579
- m(this, "observerCount$", a(this, Fe).asObservable());
1580
- m(this, "cancelled$", a(this, te).asObservable());
1579
+ m(this, "observerCount$", a(this, Ee).asObservable());
1580
+ m(this, "cancelled$", a(this, se).asObservable());
1581
1581
  this.options = e, this.state = r ?? this.state;
1582
- const n = a(this, te).pipe(
1582
+ const n = a(this, se).pipe(
1583
1583
  O(() => this.state.status === "pending"),
1584
1584
  g(() => ({
1585
1585
  status: "idle"
1586
1586
  }))
1587
- ), u = a(this, be).pipe(
1587
+ ), u = a(this, ye).pipe(
1588
1588
  x(
1589
1589
  (c) => Js({
1590
1590
  options: {
@@ -1625,7 +1625,7 @@ class Ys {
1625
1625
  return (b = (f = this.options).onError) == null ? void 0 : b.call(f, l, h, o);
1626
1626
  }
1627
1627
  );
1628
- return De(p, d).pipe(ke());
1628
+ return ke(p, d).pipe(Te());
1629
1629
  },
1630
1630
  onSettled: (l, h, o, p) => {
1631
1631
  const d = U(
@@ -1646,7 +1646,7 @@ class Ys {
1646
1646
  return (y = (b = this.options).onSettled) == null ? void 0 : y.call(b, l, h, o, p);
1647
1647
  }
1648
1648
  );
1649
- return De(d, f).pipe(ke());
1649
+ return ke(d, f).pipe(Te());
1650
1650
  },
1651
1651
  onSuccess: (l, h, o) => {
1652
1652
  const p = U(
@@ -1666,12 +1666,12 @@ class Ys {
1666
1666
  return (b = (f = this.options).onSuccess) == null ? void 0 : b.call(f, l, h, o);
1667
1667
  }
1668
1668
  );
1669
- return De(p, d).pipe(ke());
1669
+ return ke(p, d).pipe(Te());
1670
1670
  }
1671
1671
  },
1672
1672
  state: this.state,
1673
1673
  variables: c
1674
- }).pipe(ne(a(this, te)))
1674
+ }).pipe(ne(a(this, se)))
1675
1675
  )
1676
1676
  ), i = F(n, u);
1677
1677
  this.state$ = i.pipe(
@@ -1687,9 +1687,9 @@ class Ys {
1687
1687
  E((c) => {
1688
1688
  this.state = c;
1689
1689
  }),
1690
- Qe(1),
1690
+ Ue(1),
1691
1691
  lt((c) => {
1692
- a(this, Fe).next(c);
1692
+ a(this, Ee).next(c);
1693
1693
  })
1694
1694
  );
1695
1695
  }
@@ -1705,7 +1705,7 @@ class Ys {
1705
1705
  * is over, unlike the state which can be re-subscribed later.
1706
1706
  */
1707
1707
  execute(e) {
1708
- return a(this, be).next(e), a(this, be).complete(), this.state$.pipe($e);
1708
+ return a(this, ye).next(e), a(this, ye).complete(), this.state$.pipe(we);
1709
1709
  }
1710
1710
  continue() {
1711
1711
  return this.execute(this.state.variables);
@@ -1716,16 +1716,16 @@ class Ys {
1716
1716
  * when no more observers are listening
1717
1717
  */
1718
1718
  cancel() {
1719
- a(this, te).next(), a(this, te).complete();
1719
+ a(this, se).next(), a(this, se).complete();
1720
1720
  }
1721
1721
  }
1722
- Fe = new WeakMap(), te = new WeakMap(), be = new WeakMap();
1722
+ Ee = new WeakMap(), se = new WeakMap(), ye = new WeakMap();
1723
1723
  const Rt = ({
1724
1724
  mutationKey: s,
1725
1725
  status: e,
1726
1726
  predicate: t,
1727
1727
  exact: r = !0
1728
- } = {}) => (u) => r && s !== void 0 && u.options.mutationKey !== void 0 && !He(u.options.mutationKey, s, { exact: r }) || !r && s !== void 0 && u.options.mutationKey !== void 0 && !He(u.options.mutationKey, s, { exact: r }) || e && u.state.status !== e ? !1 : t ? t(u) : !0;
1728
+ } = {}) => (u) => r && s !== void 0 && u.options.mutationKey !== void 0 && !_e(u.options.mutationKey, s, { exact: r }) || !r && s !== void 0 && u.options.mutationKey !== void 0 && !_e(u.options.mutationKey, s, { exact: r }) || e && u.state.status !== e ? !1 : t ? t(u) : !0;
1729
1729
  class Wt {
1730
1730
  constructor() {
1731
1731
  /**
@@ -1748,7 +1748,7 @@ class Wt {
1748
1748
  m(this, "stateChange$", F(
1749
1749
  this.entriesSubject.pipe(
1750
1750
  Je(),
1751
- k((e) => me(e))
1751
+ k((e) => Se(e))
1752
1752
  ),
1753
1753
  this.added$
1754
1754
  ).pipe(
@@ -1801,12 +1801,12 @@ class Bs {
1801
1801
  x(
1802
1802
  () => n.observerCount$.pipe(
1803
1803
  O((u) => u <= 1),
1804
- qe(1)
1804
+ He(1)
1805
1805
  )
1806
1806
  ),
1807
1807
  // defaults to 5mn
1808
- x(() => Ae(n.options.gcTime ?? 5 * 60 * 1e3)),
1809
- qe(1)
1808
+ x(() => Qe(n.options.gcTime ?? 5 * 60 * 1e3)),
1809
+ He(1)
1810
1810
  ).subscribe({
1811
1811
  complete: () => {
1812
1812
  this.remove(n);
@@ -1875,7 +1875,7 @@ class Bs {
1875
1875
  predicate: (r) => r.state.isPaused
1876
1876
  });
1877
1877
  if (!e.length)
1878
- return re;
1878
+ return Z;
1879
1879
  const t = e.map((r) => r.continue());
1880
1880
  return ls(t);
1881
1881
  }
@@ -1903,10 +1903,10 @@ function Xs(s) {
1903
1903
  fetchStatus: "idle"
1904
1904
  };
1905
1905
  }
1906
- const Zs = (s) => Me(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s))), er = (s) => {
1906
+ const Zs = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s))), er = (s) => {
1907
1907
  let e = 0;
1908
1908
  return (t) => {
1909
- const r = se.backToOnline$.pipe(
1909
+ const r = re.backToOnline$.pipe(
1910
1910
  k(
1911
1911
  () => F(
1912
1912
  v({ fetchStatus: "fetching" }),
@@ -1914,10 +1914,10 @@ const Zs = (s) => Me(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
1914
1914
  )
1915
1915
  )
1916
1916
  );
1917
- return Me(() => (e++, !se.isOnline() && s.networkMode === "offlineFirst" && e > 1 ? F(
1917
+ return Ae(() => (e++, !re.isOnline() && s.networkMode === "offlineFirst" && e > 1 ? F(
1918
1918
  v({ fetchStatus: "paused" }),
1919
1919
  r
1920
- ) : !se.isOnline() && s.networkMode !== "always" && s.networkMode !== "offlineFirst" ? F(
1920
+ ) : !re.isOnline() && s.networkMode !== "always" && s.networkMode !== "offlineFirst" ? F(
1921
1921
  v({ fetchStatus: "paused" }),
1922
1922
  r
1923
1923
  ) : t));
@@ -2028,7 +2028,7 @@ const Zs = (s) => Me(() => ze.isFocused() ? s : ze.focusRegained$.pipe(k(() => s
2028
2028
  de()
2029
2029
  ), h = v({
2030
2030
  status: "pending",
2031
- fetchStatus: se.isOnline() ? "fetching" : "paused"
2031
+ fetchStatus: re.isOnline() ? "fetching" : "paused"
2032
2032
  });
2033
2033
  return {
2034
2034
  state$: F(
@@ -2095,14 +2095,14 @@ function Gt(s) {
2095
2095
  return e;
2096
2096
  }
2097
2097
  const ir = Gt();
2098
- var Ee, ae;
2098
+ var xe, ae;
2099
2099
  class ur {
2100
2100
  constructor(e) {
2101
2101
  m(this, "queryKey");
2102
2102
  m(this, "queryHash");
2103
2103
  m(this, "gcTime");
2104
2104
  m(this, "options");
2105
- C(this, Ee, void 0);
2105
+ C(this, xe, void 0);
2106
2106
  C(this, ae, void 0);
2107
2107
  m(this, "state");
2108
2108
  // @todo to share with mutation
@@ -2117,7 +2117,7 @@ class ur {
2117
2117
  m(this, "observerCount$", this.observersSubject.asObservable().pipe(g((e) => e.length)));
2118
2118
  m(this, "observers$", this.observersSubject.asObservable());
2119
2119
  m(this, "state$");
2120
- M(this, Ee, 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(
2120
+ 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(
2121
2121
  this.resetSubject.pipe(
2122
2122
  g(() => ({ command: "reset", state: a(this, ae) }))
2123
2123
  ),
@@ -2215,11 +2215,11 @@ class ur {
2215
2215
  throw ir.error(t), t;
2216
2216
  }),
2217
2217
  ne(this.destroySubject),
2218
- Qe({ bufferSize: 1, refCount: !1 })
2218
+ Ue({ bufferSize: 1, refCount: !1 })
2219
2219
  );
2220
2220
  }
2221
2221
  setOptions(e) {
2222
- return this.options = { ...a(this, Ee), ...e }, this.updateGcTime(this.options.gcTime), this.options;
2222
+ return this.options = { ...a(this, xe), ...e }, this.updateGcTime(this.options.gcTime), this.options;
2223
2223
  }
2224
2224
  get meta() {
2225
2225
  return this.options.meta;
@@ -2269,7 +2269,7 @@ class ur {
2269
2269
  updateGcTime(e) {
2270
2270
  return this.gcTime = Math.max(
2271
2271
  this.gcTime || 0,
2272
- e ?? (_e ? 1 / 0 : 5 * 60 * 1e3)
2272
+ e ?? (pe ? 1 / 0 : 5 * 60 * 1e3)
2273
2273
  ), this.gcTime;
2274
2274
  }
2275
2275
  isActive() {
@@ -2286,7 +2286,7 @@ class ur {
2286
2286
  }
2287
2287
  async getFetchResultAsPromise() {
2288
2288
  return await new Promise((e, t) => {
2289
- this.state$.pipe(qt, Te()).subscribe({
2289
+ this.state$.pipe(qt, Ke()).subscribe({
2290
2290
  error: t,
2291
2291
  next: (r) => {
2292
2292
  r.error ? t(r.error) : e(r.data);
@@ -2317,13 +2317,13 @@ class ur {
2317
2317
  this.resetSubject.next();
2318
2318
  }
2319
2319
  }
2320
- Ee = new WeakMap(), ae = new WeakMap();
2321
- var xe, G;
2320
+ xe = new WeakMap(), ae = new WeakMap();
2321
+ var Re, G;
2322
2322
  class ar {
2323
2323
  // protected mountSubscriptions: Subscription[]
2324
2324
  constructor(e = {}) {
2325
2325
  // readonly #queries: QueryStore = new Map<string, Query>()
2326
- C(this, xe, new I());
2326
+ C(this, Re, new I());
2327
2327
  C(this, G, new Wt());
2328
2328
  this.config = e;
2329
2329
  }
@@ -2332,7 +2332,7 @@ class ar {
2332
2332
  unmount() {
2333
2333
  }
2334
2334
  notify(e) {
2335
- a(this, xe).next(e);
2335
+ a(this, Re).next(e);
2336
2336
  }
2337
2337
  observeIsFetching(e) {
2338
2338
  return a(this, G).stateChange$.pipe(
@@ -2369,7 +2369,7 @@ class ar {
2369
2369
  a(this, G).add(e);
2370
2370
  const t = e.observerCount$.pipe(
2371
2371
  O((r) => r < 1),
2372
- qe(1)
2372
+ He(1)
2373
2373
  );
2374
2374
  e.success$.subscribe(() => {
2375
2375
  var r, n;
@@ -2393,9 +2393,9 @@ class ar {
2393
2393
  ks,
2394
2394
  x((r) => r ? t.pipe(
2395
2395
  // defaults to 5mn
2396
- x(() => e.gcTime === 1 / 0 ? Ne : (setTimeout(N, e.gcTime), Ae(e.gcTime)))
2397
- ) : Ne),
2398
- qe(1)
2396
+ x(() => e.gcTime === 1 / 0 ? qe : (setTimeout(N, e.gcTime), Qe(e.gcTime)))
2397
+ ) : qe),
2398
+ He(1)
2399
2399
  ).subscribe({
2400
2400
  complete: () => {
2401
2401
  this.remove(e);
@@ -2414,7 +2414,7 @@ class ar {
2414
2414
  }
2415
2415
  subscribe(e) {
2416
2416
  const t = F(
2417
- a(this, xe).pipe(E(e))
2417
+ a(this, Re).pipe(E(e))
2418
2418
  // this.#store.added$.pipe(
2419
2419
  // mergeMap((query) => {
2420
2420
  // fn({
@@ -2450,8 +2450,8 @@ class ar {
2450
2450
  clear() {
2451
2451
  }
2452
2452
  }
2453
- xe = new WeakMap(), G = new WeakMap();
2454
- var oe, A, Re, je, ye;
2453
+ Re = new WeakMap(), G = new WeakMap();
2454
+ var oe, A, je, Me, ge;
2455
2455
  class Fr {
2456
2456
  // #destroy = () => {}
2457
2457
  constructor({
@@ -2461,10 +2461,10 @@ class Fr {
2461
2461
  } = {}) {
2462
2462
  C(this, oe, void 0);
2463
2463
  C(this, A, void 0);
2464
- C(this, Re, /* @__PURE__ */ new Map());
2465
2464
  C(this, je, /* @__PURE__ */ new Map());
2466
- C(this, ye, void 0);
2467
- M(this, oe, e ?? new Bs()), M(this, A, t ?? new ar()), M(this, ye, r ?? {});
2465
+ C(this, Me, /* @__PURE__ */ new Map());
2466
+ C(this, ge, void 0);
2467
+ M(this, oe, e ?? new Bs()), M(this, A, t ?? new ar()), M(this, ge, r ?? {});
2468
2468
  }
2469
2469
  mount() {
2470
2470
  }
@@ -2478,7 +2478,7 @@ class Fr {
2478
2478
  }
2479
2479
  defaultMutationOptions(e) {
2480
2480
  return {
2481
- ...a(this, ye).mutations,
2481
+ ...a(this, ge).mutations,
2482
2482
  ...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
2483
2483
  ...e
2484
2484
  };
@@ -2487,7 +2487,7 @@ class Fr {
2487
2487
  if (e._defaulted)
2488
2488
  return e;
2489
2489
  const t = {
2490
- ...a(this, ye).queries,
2490
+ ...a(this, ge).queries,
2491
2491
  ...this.getQueryDefaults(e.queryKey),
2492
2492
  ...e,
2493
2493
  _defaulted: !0
@@ -2538,10 +2538,10 @@ class Fr {
2538
2538
  return a(this, A).build(this, n).setData(c, { ...r, manual: !0 });
2539
2539
  }
2540
2540
  getMutationDefaults(e) {
2541
- const t = [...a(this, Re).values()];
2541
+ const t = [...a(this, je).values()];
2542
2542
  let r = {};
2543
2543
  return t.forEach((n) => {
2544
- He(e, n.mutationKey) && (r = { ...r, ...n.defaultOptions });
2544
+ _e(e, n.mutationKey) && (r = { ...r, ...n.defaultOptions });
2545
2545
  }), r;
2546
2546
  }
2547
2547
  getQueryState(e) {
@@ -2549,19 +2549,19 @@ class Fr {
2549
2549
  return (t = a(this, A).find({ queryKey: e })) == null ? void 0 : t.state;
2550
2550
  }
2551
2551
  setMutationDefaults(e, t) {
2552
- a(this, Re).set(Se(e), {
2552
+ a(this, je).set(ve(e), {
2553
2553
  mutationKey: e,
2554
2554
  defaultOptions: t
2555
2555
  });
2556
2556
  }
2557
2557
  setQueryDefaults(e, t) {
2558
- a(this, je).set(Se(e), {
2558
+ a(this, Me).set(ve(e), {
2559
2559
  queryKey: e,
2560
2560
  defaultOptions: t
2561
2561
  });
2562
2562
  }
2563
2563
  getQueryDefaults(e) {
2564
- const t = [...a(this, je).values()];
2564
+ const t = [...a(this, Me).values()];
2565
2565
  let r = {};
2566
2566
  return t.forEach((n) => {
2567
2567
  et(e, n.queryKey) && (r = { ...r, ...n.defaultOptions });
@@ -2602,7 +2602,7 @@ class Fr {
2602
2602
  a(this, A).clear(), a(this, oe).clear();
2603
2603
  }
2604
2604
  }
2605
- oe = new WeakMap(), A = new WeakMap(), Re = new WeakMap(), je = new WeakMap(), ye = new WeakMap();
2605
+ oe = new WeakMap(), A = new WeakMap(), je = new WeakMap(), Me = new WeakMap(), ge = new WeakMap();
2606
2606
  export {
2607
2607
  Bs as MutationCache,
2608
2608
  ar as QueryCache,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.87.0",
4
+ "version": "1.87.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"