reactjrx 1.82.0 → 1.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +2 -2
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +1058 -1047
  4. package/dist/lib/binding/useSubject.d.ts +2 -2
  5. package/dist/lib/queries/client/QueryClient.d.ts +7 -7
  6. package/dist/lib/queries/client/keys/matchKey.d.ts +1 -1
  7. package/dist/lib/queries/client/mutations/mutation/Mutation.d.ts +5 -0
  8. package/dist/lib/queries/client/mutations/runner/MutationRunner.d.ts +4 -1
  9. package/dist/lib/queries/client/mutations/{defaultMutationState.d.ts → utils/defaultMutationState.d.ts} +1 -1
  10. package/dist/lib/queries/client/mutations/utils/distinctUntilStateChanged.d.ts +4 -0
  11. package/dist/lib/queries/client/mutations/{filters.d.ts → utils/filters.d.ts} +2 -2
  12. package/dist/lib/queries/client/queries/cache/QueryCache.d.ts +1 -1
  13. package/dist/lib/queries/client/queries/observer/QueryObserver.d.ts +3 -3
  14. package/dist/lib/queries/client/queries/observer/types.d.ts +2 -2
  15. package/dist/lib/queries/client/queries/query/delayOnNetworkMode.d.ts +1 -1
  16. package/dist/lib/queries/client/queries/query/execution/executeQuery.d.ts +1 -1
  17. package/dist/lib/queries/client/queries/query/operators.d.ts +1 -1
  18. package/dist/lib/queries/client/queries/query/types.d.ts +2 -0
  19. package/dist/lib/queries/client/queries/types.d.ts +5 -4
  20. package/dist/lib/queries/client/queries/utils.d.ts +3 -1
  21. package/dist/lib/queries/client/types.d.ts +1 -1
  22. package/dist/lib/queries/react/mutations/useIsMutating.d.ts +1 -1
  23. package/dist/lib/queries/react/queries/QueryOptions.rq.types.typeTest.d.ts +1 -0
  24. package/dist/lib/queries/react/queries/isRestoring.d.ts +1 -1
  25. package/dist/lib/queries/react/queries/queryOptions.d.ts +3 -3
  26. package/dist/lib/queries/react/queries/types.d.ts +3 -3
  27. package/dist/lib/state/persistance/adapters/createLocalStorageAdapter.d.ts +1 -1
  28. package/dist/lib/state/persistance/usePersistSignals.d.ts +4 -4
  29. package/dist/lib/utils/types.d.ts +3 -2
  30. package/package.json +2 -2
  31. /package/dist/lib/queries/{react/queries/QueryOptions.rq.types.test.d.ts → client/QueryClient.rq.test.d.ts} +0 -0
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # reactjrx
2
2
 
3
- `reactjrx` is an innovative library designed to bridge RxJS and React, offering developers a powerful set of tools to integrate observables into their React applications seamlessly.
3
+ `reactjrx` is an innovative library designed to bridge RxJS and React, offering developers a powerful set of tools to integrate observables into their React applications seamlessly.
4
4
 
5
- It simplifies the reactive programming approach by providing easy-to-use bindings for observing and reacting to data changes, coupled with advanced state management and queries helpers akin to `react-query` for handling effects, mutations, and asynchronous data fetching.
5
+ It simplifies the reactive programming approach by providing easy-to-use bindings for observing and reacting to data changes, coupled with advanced state management and queries helpers akin to `react-query` for handling effects, mutations, and asynchronous data fetching.
6
6
 
7
7
  Tailored for projects where RxJS is a core dependency, `reactjrx` enhances the development experience by enabling more dynamic, efficient, and responsive UIs, making it an essential addition for developers looking to leverage the full potential of RxJS within their React applications.
8
8
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ht=Object.defineProperty;var dt=(s,e,t)=>e in s?ht(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>(dt(s,typeof e!="symbol"?e+"":e,t),t),Ie=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(Ie(s,e,"read from private field"),t?t.call(s):e.get(s)),w=(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)=>(Ie(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),r=require("rxjs"),K=require("rxjs/operators"),De=require("react/jsx-runtime");function pt(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 Oe=pt(S),A=s=>{const e=S.useRef(s);return S.useMemo(()=>{e.current=s},[s]),e};function bt(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=S.useRef("getValue"in s&&typeof s.getValue=="function"?s.getValue():n.defaultValue),a=A(s),f=A(n),d=S.useCallback(p=>{const o=a.current,$=(typeof o=="function"?o:()=>o)().pipe(r.distinctUntilChanged(bt),r.tap(b=>{u.current=b}),r.catchError(b=>(console.error(b),r.EMPTY))).subscribe(p);return()=>{f.current.unsubscribeOnUnmount!==!1&&$.unsubscribe()}},[...i]),h=S.useCallback(()=>u.current,[]);return S.useSyncExternalStore(d,h,h)}function Te(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function R(s){if(r.isObservable(s))return s;if(Te(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Te(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function Me(s,e=[]){const t=A(s);S.useEffect(()=>{const n=R(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const we=s=>{const e=S.useRef();return e.current||(e.current=s()),S.useEffect(()=>{process.env.NODE_ENV},[]),e},je=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=we(()=>new r.Subject),n=S.useRef(!1),i=A(s),u=A(e);return S.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},gt=()=>{const s=je(),e=A(s.current.asObservable()),t=S.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Re=s=>{const e=we(()=>new r.BehaviorSubject(s)),t=S.useRef(!1),n=S.useRef(s);return S.useEffect(()=>(t.current&&(e.current=new r.BehaviorSubject(n.current),t.current=!1),()=>{t.current||(e.current.complete(),t.current=!0)}),[e]),e},mt=s=>{const e=Re(s),t=A(e.current.asObservable()),n=S.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Ge=Symbol("SIGNAL_RESET");function yt(s={}){const e={default:s.default,key:s.key},{default:t}=e??{},n=new r.BehaviorSubject(t),i=a=>{if(typeof a=="function"){const f=a(n.getValue());if(f===n.getValue())return;n.next(f);return}if(a===Ge){n.next(t??void 0);return}n.next(a)},u=()=>n.getValue();if("get"in s){const a=d=>(d.subject.pipe(r.skip(1),r.first()).subscribe(()=>{var l;const h=(l=s.get)==null?void 0:l.call(s,a);i(h)}),d.getValue()),f=s.get(a);return i(f),{getValue:u,config:s,subject:n}}return{setValue:i,getValue:u,config:e,subject:n}}function St(s,e){const n=e??(()=>s.getValue());return fe(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const vt=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()=>{}}),Ce=s=>{if(!(!s||typeof s!="object"))return s},Ot=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ce(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ce(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ce(i)??{};await s.setItem(e,{...u,[t]:n})}}),Ye=({key:s}={})=>s?Ot({adapter:Ye(),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",wt=s=>{if(typeof s=="object"&&s!==null&&re in s&&s[re]===re)return s};function ge(s){return s!=null}const Ke=s=>{const e=Re(s);return S.useEffect(()=>{e.current.next(s)},[s,e]),e},Ne=({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))))},$t=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=wt(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),Ct=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=Ke(t),a=fe(()=>{const d=n.current;return u.current.pipe(r.switchMap(h=>{if(!h)return r.of(!1);const l=d.length===0?r.of(!0):r.zip(...d.map(({signal:p,version:o})=>$t({adapter:h,signal:p,version:o}).pipe(r.mergeMap(()=>Ne({adapter:h,signal:p,version:o}))))).pipe(r.map(()=>!0));return r.merge(r.of(!1),l).pipe(r.tap(()=>{i.current!=null&&i.current()}),r.catchError(p=>(console.error("Unable to hydrate",p),r.EMPTY)))}))},{defaultValue:!1},[u,n]),f=Ke(a);return Me(()=>f.current.pipe(r.filter(d=>d),r.switchMap(()=>u.current),r.filter(ge),r.switchMap(d=>r.merge(...n.current.map(({signal:h,version:l})=>h.subject.pipe(r.throttleTime(500,r.asyncScheduler,{trailing:!0}),r.switchMap(()=>r.from(Ne({adapter:d,signal:h,version:l})))))))),[f,u]),{isHydrated:a}},Et=()=>{const s=je({onBeforeComplete:()=>{s.current.next()}});return s};function Je(s,e){return Math.min(s,e)}function Xe(s,e){return Math.pow(2,s)*e}function Fe(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,f=typeof t=="number"?t:100,d={shouldRetry:a,...s},{maxInterval:h=1/0,resetOnSuccess:l=!1,backoffDelay:p=Xe}=d;return o=>r.defer(()=>{let m=0;const $=(b,v)=>b<u?a(b,v):!1;return o.pipe(K.catchError(b=>{var O;if(m++,!$(m-1,b))throw b;const v=(O=s.caughtError)==null?void 0:O.call(s,m,b);if(!v)throw b;return v.pipe(K.mergeMap(k=>r.merge(r.of(k),r.throwError(()=>b))))}),K.retryWhen(b=>b.pipe(K.concatMap(v=>{const O=m-1;return i().pipe(K.first(),K.mergeMap(()=>$(O,v)?r.timer(Je(p(O,f),h)).pipe(K.mergeMap(k=>n&&!n(O,v)?r.throwError(()=>v):r.of(k))):r.throwError(()=>v)))}))),K.catchError(b=>{if(s.catchError)return s.catchError(m,b);throw b}),K.tap(()=>{l&&(m=0)}))})}function He(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ee(s){if(!He(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!He(t)||!t.hasOwnProperty("isPrototypeOf"))}const te=s=>JSON.stringify(s,(e,t)=>Ee(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),Ue=(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),""),z=()=>({context:void 0,data:void 0,error:null,status:"idle",submittedAt:0,variables:void 0,failureCount:0,failureReason:null,isPaused:!1});function F(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}function xe(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 L;class Mt{constructor({__queryFinalizeHook:e}={}){w(this,L,new r.Subject);g(this,"state$");const t=new r.BehaviorSubject(0),n=t.pipe(r.filter(i=>i===0));this.state$=c(this,L).pipe(r.concatMap(({args:i,mutation:u,options:a})=>{const f=a.mapOperator??"merge",d=c(this,L).pipe(r.filter(()=>f==="merge")),h=c(this,L).pipe(r.filter(()=>f==="switch"),r.tap(()=>{u.cancel()})),l=r.defer(()=>(u.execute(i),r.EMPTY)),p=u.state$.pipe(se,r.last(),r.mergeMap(()=>u.state$),r.takeUntil(c(this,L))),o=u.state$.pipe(se,r.skip(1)),m=r.merge(n,d,h,u.cancelled$);return r.merge(o,p,l).pipe(e??r.identity,r.takeUntil(m))}),r.scan((i,u)=>({...i,...u,...u.status==="pending"&&{data:u.data??i.data},...u.status==="pending"&&{error:u.error??i.error}}),z()),r.distinctUntilChanged(({data:i,...u},{data:a,...f})=>F(u,f)&&F(i,a)),r.shareReplay({refCount:!0,bufferSize:1}),xe(i=>{t.next(i)}))}trigger({args:e,options:t,mutation:n}){c(this,L).next({args:e,options:t,mutation:n})}}L=new WeakMap;function $e(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!$e(s[t],e[t])):!1}const me=(s,e,{exact:t=!1}={})=>t?te(s)===te(e):$e(s,e);var B,I;class jt{constructor(e,t={},n){w(this,B,void 0);w(this,I,new r.BehaviorSubject(void 0));g(this,"observed$");g(this,"getObserverResultFromState",e=>({...z(),...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)??[Ue()],M(this,B,n??new Mt(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,B).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)??z()),t=c(this,B).state$.pipe(r.map(a=>this.getObserverResultFromState(a))),n=c(this,I).pipe(r.filter(ge),r.switchMap(a=>a.mutation.cancelled$),r.map(()=>this.getObserverResultFromState(z())));return{result$:r.merge(this.observed$,t,n),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,B).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)??z())}reset(){const{mutation:e}=c(this,I).getValue()??{};c(this,I).next(void 0),e==null||e.cancel()}}B=new WeakMap,I=new WeakMap;const Ze=S.createContext(void 0),Rt=({client:s})=>(S.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),Ft=S.memo(({children:s,client:e})=>{const t=S.useMemo(()=>e,[e]);return De.jsxs(Ze.Provider,{value:t,children:[De.jsx(Rt,{client:e}),s]})}),Ae=s=>{const e=S.useContext(Ze);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function Ut(){}function xt(s,e){const t=Ae(e),n=A(s),i=we(()=>[Ue()]),u=te(s.mutationKey??i.current),[a]=S.useState(()=>new jt(t,s));S.useEffect(()=>{a.setOptions(s)},[a,s]);const f=S.useMemo(()=>a.observe(),[u,a]),d=fe(f.result$)??f.lastValue,h=S.useCallback((l,p)=>{a.mutate(l,p).catch(Ut)},[a]);return S.useEffect(()=>()=>{n.current.cancelOnUnMount&&a.reset()},[a,n]),{...d,mutate:h,mutateAsync:d.mutate}}function At(s){return e=>e.pipe(K.tap(t=>{s.next(t)}))}class Qt{constructor(){g(this,"isOnlineSubject",new r.BehaviorSubject(!0));g(this,"online$",this.isOnlineSubject.pipe(r.distinctUntilChanged()));g(this,"backToOnline$",this.online$.pipe(r.filter(e=>e),r.first()));r.merge(r.fromEvent(window,"offline").pipe(r.map(()=>!1)),r.fromEvent(window,"online").pipe(r.map(()=>!0))).pipe(At(this.isOnlineSubject)).subscribe()}isOnline(){return this.isOnlineSubject.getValue()}setOnline(e){this.isOnlineSubject.getValue()!==e&&this.isOnlineSubject.next(e)}}const _=new Qt;function Qe(s,e){return s.isStaleByTime(e.staleTime)}function Pt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function Le(s,e){return Pt(s,e)||s.state.dataUpdatedAt>0&&et(s,e,e.refetchOnMount)}function We(s,e,t,n){return s.state.fetchStatus!=="fetching"&&t.enabled!==!1&&(s!==e||n.enabled===!1)&&(!t.suspense||s.state.status!=="error")&&Qe(s,t)}function kt(s,e){return et(s,e,e.refetchOnWindowFocus)}function et(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&&Qe(s,e)}return!1}function Vt(s){return(s??"online")==="online"?_.isOnline():!0}function qe(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function _e(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function tt(s,e){if(s===e)return s;const t=_e(s)&&_e(e);if(t||Ee(s)&&Ee(e)){const n=t?s:Object.keys(s),i=n.length,u=t?e:Object.keys(e),a=u.length,f=t?[]:{};let d=0;for(let h=0;h<a;h++){const l=t?h:u[h];!t&&s[l]===void 0&&e[l]===void 0&&n.includes(l)?(f[l]=void 0,d++):(f[l]=tt(s[l],e[l]),f[l]===s[l]&&s[l]!==void 0&&d++)}return i===a&&d===i?s:f}return e}function Pe(s,e){return((e==null?void 0:e.queryKeyHashFn)??te)(s)}function ze(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:f}=s;if(a){if(n){if(e.queryHash!==Pe(a,e.options))return!1}else if(!$e(e.queryKey,a))return!1}if(t!=="all"){const d=e.isActive();if(t==="active"&&!d||t==="inactive"&&d)return!1}return!(typeof f=="boolean"&&e.isStale()!==f||typeof i<"u"&&i!==e.state.fetchStatus||u&&!u(e))}function It(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Dt(s,e){return typeof s=="function"?s(e):s}function ye(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?tt(s,e):e}const Tt=({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 f=a.data,d=f!==void 0&&f!==i.data,h="data"in a,l=a.status==="success",p=i.data!==void 0,o=i.error!==void 0||i.error!==null,m=a.status??i.status,$=d?ye(e().data,f,s()):h?a.data:i.data,b=i.status==="error"||i.status==="success",v=a.status==="error"&&(i.status==="error"&&i.fetchStatus==="fetching"||i.status!=="error")?i.errorUpdateCount+1:i.errorUpdateCount,O=d?i.dataUpdateCount+1:a.dataUpdateCount??i.dataUpdateCount,k=a.status==="pending"&&b&&(p||o),U=m==="pending"?null:a.error??i.error;return{...i,...a,status:m,error:U,errorUpdateCount:v,...l&&{isInvalidated:!1},data:$,dataUpdateCount:O,...k&&{status:i.status}}},t)),Kt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),rt=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var ve,W;class Nt{constructor(){w(this,ve,r.merge(r.fromEvent(document,"visibilitychange"),r.fromEvent(window,"visibilitychange")).pipe(r.map(()=>document.visibilityState)));w(this,W,new r.BehaviorSubject(document.visibilityState==="visible"));g(this,"focused$",c(this,W));g(this,"focusRegained$",this.focused$.pipe(r.skip(1),r.filter(e=>e)));c(this,ve).pipe(r.tap(e=>{c(this,W).next(e==="visible")})).subscribe()}isFocused(){return c(this,W).getValue()}setFocused(e){c(this,W).getValue()!==(e??!0)&&c(this,W).next(e??!0)}subscribe(e){const t=this.focused$.subscribe(e);return()=>{t.unsubscribe()}}refresh(){document.dispatchEvent(new Event("visibilitychange"))}}ve=new WeakMap,W=new WeakMap;const Se=new Nt,Ht=s=>s.pipe(r.filter(e=>e.status==="success"),r.map(e=>({data:e.data,status:e.status,dataUpdatedAt:e.dataUpdatedAt})),r.distinctUntilChanged(F));var H,C,ne,G,x,X,ie;class st{constructor(e,t){w(this,H,void 0);w(this,C,void 0);w(this,ne,new r.Subject);g(this,"queryUpdateSubject",new r.Subject);w(this,G,void 0);w(this,x,void 0);w(this,X,void 0);w(this,ie,0);g(this,"getObserverResultFromQuery",({options:e,query:t,optimisticResult:n,prevResult:{result:i,options:u,state:a,select:f,selectError:d,selectResult:h}})=>{var be;const l=t.state,p=t.state.status==="pending",o=c(this,C),m=this.options,b=t!==o?t.state:c(this,G);let{errorUpdatedAt:v,fetchStatus:O,error:k}=l;if(n){const Q=!!c(this,ie),Ve=!Q&&Le(t,e),ft=Q&&We(t,o,e,m);(Ve||ft)&&(O=Vt(t.options.networkMode)?"fetching":"paused")}const U=p&&O==="fetching";let E,y=d,D=f??null,T=h;if(e.select&&typeof l.data<"u")if(i&&l.data===(a==null?void 0:a.data)&&e.select===f)E=h;else try{D=e.select,E=e.select(l.data),E=ye(i==null?void 0:i.data,E,e),T=E,y=null}catch(Q){E=h,y=Q}else E=l.data,y=null;let V=O!=="idle"&&!l.dataUpdatedAt?"pending":l.status;y&&(k=y,E=h,v=(i==null?void 0:i.errorUpdatedAt)??v,V="error");const he=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=ye(i==null?void 0:i.data,Q,e),de=!0)}const pe=O==="fetching";return{result:{status:V,fetchStatus:O,isPending:p,isSuccess:V==="success",isError:he,isInitialLoading:U,isLoading:U,data:E,dataUpdatedAt:l.dataUpdatedAt,error:k,errorUpdatedAt:v,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>b.dataUpdateCount||l.errorUpdateCount>b.errorUpdateCount,isFetching:pe,isRefetching:pe&&!p,isLoadingError:he&&l.dataUpdatedAt===0,isPaused:O==="paused",isPlaceholderData:de,isRefetchError:he&&l.dataUpdatedAt!==0,isStale:Qe(t,e),refetch:this.refetch},selectError:y,select:D,selectResult:T}});this.options=t,M(this,H,e),this.bindMethods(),M(this,C,this.setOptions(t));const n=c(this,C);M(this,G,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,H).defaultQueryOptions(e),F(this.options,t)||c(this,H).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,G,n.state),M(this,C,n)),this.queryUpdateSubject.next({options:this.options,query:n}),n}buildQuery(e){const t=c(this,H).getQueryCache().build(c(this,H),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 Lt(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,H).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,G,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:f},{options:d,query:h}])=>{We(h,f,d,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 f=this.options,d=this.queryUpdateSubject.pipe(r.startWith({query:a,options:f}),r.filter(y=>y.query===a),r.map(y=>y.options),r.distinctUntilChanged(),r.shareReplay(1)),h=c(this,ne).pipe(r.filter(y=>y.query===a)),l=a.state$.pipe(Ht,r.switchMap(y=>this.options.staleTime===1/0?r.NEVER:(this.options.staleTime??0)<=0?r.of(y).pipe(r.delay(1)):r.timer(this.options.staleTime??1)),r.takeWhile(()=>this.options.enabled??!0)),p=(y,D)=>{const T=f.notifyOnChangeProps,V=typeof T=="function"?T():T;return(Array.isArray(V)?V.length===0?()=>!0:(de,pe)=>{const ke=qe(de,V),be=qe(pe,V);return F(ke,be)}:F)(y,D)},o=h.pipe(r.switchMap(()=>a.state$),rt),m=d.pipe(r.map(({refetchInterval:y,refetchIntervalInBackground:D})=>({refetchInterval:(typeof y=="function"?y(c(this,C)):y)??!1,refetchIntervalInBackground:D})),r.distinctUntilChanged(F),r.switchMap(({refetchInterval:y,refetchIntervalInBackground:D})=>y?r.interval(y).pipe(r.tap(()=>{(D||Se.isFocused())&&this.fetch({cancelRefetch:!1}).catch(r.noop)})):r.NEVER),r.ignoreElements()),$=d.pipe(r.map(({enabled:y})=>y??!0),r.distinctUntilChanged()),b=$.pipe(r.filter(y=>!y),r.map(()=>a.state)),v=$.pipe(r.filter(y=>y),r.switchMap(()=>Se.focusRegained$),r.withLatestFrom(d),r.tap(([,y])=>{kt(a,y)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),O=b.pipe(r.map(()=>a.state)),k=y=>y.pipe(r.withLatestFrom(d),r.map(([,D])=>{const T=this.getObserverResultFromQuery({query:a,options:D,prevResult:c(this,x)});return this.updateResult({query:a,...T}),T.result})),E=r.merge(O,o,a.state$,l).pipe(k,r.distinctUntilChanged(F),r.distinctUntilChanged(p));return r.merge(m,v,E)})).pipe(xe(a=>M(this,ie,a)),r.tap({subscribe:()=>{Le(e,this.options)&&this.fetch().catch(r.noop)}})))}destroy(){}}H=new WeakMap,C=new WeakMap,ne=new WeakMap,G=new WeakMap,x=new WeakMap,X=new WeakMap,ie=new WeakMap;function Lt(s,e){return!F(s.getCurrentResult(),e)}const nt=Oe.createContext(!1),Wt=()=>Oe.useContext(nt);nt.Provider;function qt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const _t=Oe.createContext(qt()),zt=()=>Oe.useContext(_t);function Bt(s,e){return typeof s=="function"?s(...e):!!s}const Gt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Bt(t,[s.error,n]);function it(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=Ae(t),i=Wt(),u=zt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[f]=S.useState(()=>new e(n,a)),d=we(()=>f.observe()),h=A(f.getOptimisticResult(a)),l=h.current;fe(()=>d.current.pipe(r.filter(o=>!F(o,h.current))),[]),S.useEffect(()=>{f.setOptions(a)},[a,f]);const p=l.error;if(p&&Gt({result:l,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw p;return h.current}function Yt(s,e){return it(s,st,e)}function Jt(s,e){return it({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},st,e)}function Xt(s,e,t=[]){const n=e!=null&&!Array.isArray(e)?e:{},i=n.retry??!0,u=A(n.onError??(d=>{console.error(d)})),a=S.useCallback(()=>R(s),t),f=S.useCallback(()=>a().pipe(r.catchError(d=>{throw u.current(d),d}),i?r.retry():r.identity),[a,i,u]);Me(f,t)}const at=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),Zt=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(at())))):r.throwError(()=>t))))},er=({variables:s,state:e,options:t})=>{const n=e.isPaused,i=async()=>await Promise.reject(new Error("No mutationFn found")),u=t.mutationFn??i,f=r.iif(()=>n,r.of(e.context),R(()=>{var o;return((o=t.onMutate)==null?void 0:o.call(t,s))??void 0})).pipe(r.shareReplay(1)),d=(o,m,$)=>R(()=>{var v;return(v=t.onError)==null?void 0:v.call(t,o,s,m)}).pipe(r.catchError(()=>r.of(o)),r.map(()=>({failureCount:$,error:o,failureReason:o,context:m,status:"error"}))),h=f.pipe(r.switchMap(o=>{const $=(typeof u=="function"?R(()=>u(s)):u).pipe(r.map(b=>({result:{data:b},error:null,context:o})),Zt,Fe({...t,retry:(b,v)=>{const O=t.retry??0;return typeof O=="function"?O(b,v):typeof O=="boolean"?O:b<O},caughtError:(b,v)=>r.of({failureCount:b,failureReason:v}),catchError:(b,v)=>d(v,o,b).pipe(r.map(O=>({...O,result:void 0})))}),r.takeWhile(({result:b,error:v})=>(b==null?void 0:b.data)===void 0&&v===void 0,!0));return _.isOnline()||t.networkMode==="offlineFirst"||t.networkMode==="always"?$:$.pipe(at())})),l=r.of({...e,variables:s,status:"pending",isPaused:!1,failureCount:0,failureReason:null,submittedAt:e.submittedAt??new Date().getTime()});return r.merge(l,f.pipe(r.map(o=>({context:o}))),h.pipe(r.switchMap(({result:o,error:m,...$})=>{if(!o&&!m)return r.of({...$});const b=m?r.of(null):R(()=>{var U;return(U=t.onSuccess)==null?void 0:U.call(t,o==null?void 0:o.data,s,$.context)}),O=R(()=>{var U;return(U=t.onSettled)==null?void 0:U.call(t,o==null?void 0:o.data,m,s,$.context)}).pipe(r.catchError(U=>o?r.of(o):r.of(U)));return r.concat(b,O).pipe(r.toArray(),r.map(()=>m?{error:m,data:void 0,variables:s,...$}:{status:"success",error:m,data:o==null?void 0:o.data,variables:s,failureCount:0,failureReason:null,...$}),r.catchError(U=>d(U,$.context,0).pipe(r.map(E=>({...E,data:void 0})))))}))).pipe(r.scan((o,m)=>({...o,...m,data:m.data??o.data,error:m.error??o.error}),z()),r.distinctUntilChanged(({data:o,...m},{data:$,...b})=>F(m,b)&&F(o,$)))};var ae,q,Z;class tr{constructor({options:e,mutationCache:t,state:n}){w(this,ae,new r.BehaviorSubject(0));w(this,q,new r.Subject);w(this,Z,new r.Subject);g(this,"state",z());g(this,"state$");g(this,"options");g(this,"observerCount$",c(this,ae).asObservable());g(this,"cancelled$",c(this,q).asObservable());this.options=e,this.state=n??this.state;const i=c(this,Z).pipe(r.switchMap(u=>er({options:{...this.options,onMutate:a=>{const f=R(()=>{var p,o;return(o=(p=t.config).onMutate)==null?void 0:o.call(p,a,this)}),h=R(()=>{var p,o;return(o=(p=this.options).onMutate)==null?void 0:o.call(p,a)});return f.pipe(r.mergeMap(()=>h))},onError:(a,f,d)=>{const h=R(()=>{var p,o;return(o=(p=t.config).onError)==null?void 0:o.call(p,a,f,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onError)==null?void 0:o.call(p,a,f,d)});return r.concat(h,l).pipe(r.toArray())},onSettled:(a,f,d,h)=>{const l=R(()=>{var o,m;return(m=(o=t.config).onSettled)==null?void 0:m.call(o,a,f,d,h,this)}),p=R(()=>{var o,m;return(m=(o=this.options).onSettled)==null?void 0:m.call(o,a,f,d,h)});return r.concat(l,p).pipe(r.toArray())},onSuccess:(a,f,d)=>{const h=R(()=>{var p,o;return(o=(p=t.config).onSuccess)==null?void 0:o.call(p,a,f,d,this)}),l=R(()=>{var p,o;return(o=(p=this.options).onSuccess)==null?void 0:o.call(p,a,f,d)});return r.concat(h,l).pipe(r.toArray())}},state:this.state,variables:u}).pipe(r.takeUntil(c(this,q)))));this.state$=r.merge(i,r.NEVER).pipe(r.startWith(this.state),r.tap(u=>{this.state={...this.state,...u}}),r.takeUntil(c(this,q)),r.shareReplay({bufferSize:1,refCount:!1}),xe(u=>{c(this,ae).next(u)}))}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,q).next(),c(this,q).complete()}}ae=new WeakMap,q=new WeakMap,Z=new WeakMap;const Be=({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 ut{constructor(){g(this,"entriesSubject",new r.BehaviorSubject([]));g(this,"changeSubject",new r.Subject);g(this,"entries$",this.entriesSubject.pipe(r.share()));g(this,"added$",this.changeSubject.pipe(r.filter(({type:e})=>e==="added"),r.map(({entity:e})=>e),r.share()));g(this,"removed$",this.changeSubject.pipe(r.filter(({type:e})=>e==="removed"),r.map(({entity:e})=>e),r.share()));g(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 ct{constructor(e={}){w(this,P,new ut);this.config=e}build(e,t,n){const i=new tr({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=Be(t);return c(this,P).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Be(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;const rr=typeof window>"u"||"Deno"in window;function sr(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 nr=s=>r.defer(()=>Se.isFocused()?s:Se.focusRegained$.pipe(r.mergeMap(()=>s))),ir=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))}},ar=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))},ur=s=>{const e=async()=>await Promise.reject(new Error("No query found"));let t=!1;const n=s.queryFn??e,i=new AbortController,u={meta:s.meta,queryKey:s.queryKey};(l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(s.onSignalConsumed(),i.signal)})})(u);const d=(typeof n=="function"?R(()=>n(u)):n).pipe(ar(s.observers$),r.tap({complete:()=>{t=!0}}),r.map(l=>({data:l})),ir(s),Fe({...s,retryAfter:()=>r.of(!0).pipe(nr),catchError:(l,p)=>r.of({status:"error",fetchStatus:"idle",fetchFailureCount:l,fetchFailureReason:p,error:p}),caughtError:(l,p)=>r.of({fetchFailureCount:l,fetchFailureReason:p})}),r.mergeMap(l=>"data"in l?r.of({...l,status:"success",fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null,dataUpdatedAt:new Date().getTime()}).pipe(r.delay(1),r.map(p=>t?p:{...p,fetchStatus:"fetching"})):r.of(l)),r.endWith({fetchStatus:"idle"}),r.share()),h=r.of({status:"pending",fetchStatus:_.isOnline()?"fetching":"paused"});return{state$:r.merge(h,d).pipe(r.share()),abortController:i}};class cr{constructor(e){g(this,"revert");g(this,"silent");this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}}const or={backgroundColor:"transparent",color:"inherit"};function ot(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ot();return i.namespaces.push({name:t,style:n??or}),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 lr=ot();var ue,Y;class fr{constructor(e){g(this,"queryKey");g(this,"queryHash");g(this,"gcTime");g(this,"options");w(this,ue,void 0);w(this,Y,void 0);g(this,"state");g(this,"executeSubject",new r.Subject);g(this,"cancelSubject",new r.Subject);g(this,"setDataSubject",new r.Subject);g(this,"invalidatedSubject",new r.Subject);g(this,"resetSubject",new r.Subject);g(this,"destroySubject",new r.Subject);g(this,"observersSubject",new r.BehaviorSubject([]));g(this,"abortSignalConsumed",!1);g(this,"observerCount$",this.observersSubject.asObservable().pipe(r.map(e=>e.length)));g(this,"observers$",this.observersSubject.asObservable());g(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??sr(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 cr(t)}}))),this.executeSubject.pipe(r.mergeMap(()=>{let t=!1;const n=this.executeSubject.pipe(r.filter(h=>(h==null?void 0:h.cancelRefetch)!==!1)),i=this.observers$.pipe(r.pairwise(),r.tap(([h,l])=>{l.length===0&&h.length>0?t=!0:t=!1}),r.ignoreElements()),{state$:u,abortController:a}=ur({...this.options,observers$:this.observerCount$,queryKey:this.queryKey,retry:(h,l)=>{const p=this.options.retry??!0;return typeof p=="function"?p(h,l):typeof p=="boolean"?p:h<p},retryAfterDelay:()=>!t,onSignalConsumed:()=>{this.abortSignalConsumed=!0}}),f=this.observerCount$.pipe(r.filter(h=>h===0&&this.abortSignalConsumed),r.tap(()=>{this.cancelSubject.next({revert:!0})})),d=r.merge(this.cancelSubject,n,this.resetSubject,f).pipe(r.tap(()=>{this.abortSignalConsumed&&a.abort()}));return r.merge(u,i).pipe(r.map(h=>({command:"execute",state:h})),r.takeUntil(d))})),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(Tt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,Y)),r.distinctUntilChanged(F),r.tap(t=>{this.state=t}),r.catchError(t=>{throw lr.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(F),r.filter(({status:e})=>e==="success"))}get error$(){return this.state$.pipe(r.map(({error:e,status:t})=>({error:e,status:t})),r.distinctUntilChanged(F),r.filter(({status:e})=>e==="error"))}get settled$(){return this.state$.pipe(r.map(({status:e})=>({status:e})),r.distinctUntilChanged(F),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??(rr?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||!It(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(rt,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=ye(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 lt{constructor(e={}){w(this,ce,new r.Subject);w(this,N,new ut);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=>ze(e,n)):t}build(e,t,n){const i=t.queryKey??[Ue()],u=t.queryHash??Pe(i,t);let a=this.get(u);return a||(a=new fr({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(Kt,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=>ze(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 J,j,oe,le,ee;class hr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){w(this,J,void 0);w(this,j,void 0);w(this,oe,new Map);w(this,le,new Map);w(this,ee,void 0);M(this,J,e??new ct),M(this,j,t??new lt),M(this,ee,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,J)}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!=null&&e._defaulted)return e;const t={...c(this,ee).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Pe(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),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=c(this,j).find({queryKey:e}),u=i==null?void 0:i.state.data,a=Dt(t,u);if(typeof a>"u")return;const f=this.defaultQueryOptions({queryKey:e});return c(this,j).build(this,f).setData(a,{...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=>{$e(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,J).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,J).clear()}}J=new WeakMap,j=new WeakMap,oe=new WeakMap,le=new WeakMap,ee=new WeakMap;exports.MutationCache=ct;exports.QueryCache=lt;exports.QueryClient=hr;exports.QueryClientProvider=Ft;exports.SIGNAL_RESET=Ge;exports.createLocalStorageAdapter=Ye;exports.createLocalforageAdapter=vt;exports.exponentialBackoffDelay=Xe;exports.getDelay=Je;exports.isDefined=ge;exports.retryBackoff=Fe;exports.signal=yt;exports.useBehaviorSubject=Re;exports.useForeverQuery=Jt;exports.useLiveRef=A;exports.useMutation=xt;exports.useObservableState=mt;exports.useObserve=fe;exports.useObserveCallback=gt;exports.usePersistSignals=Ct;exports.useQuery=Yt;exports.useQueryClient=Ae;exports.useSignalValue=St;exports.useSubject=je;exports.useSubscribe=Me;exports.useSubscribeEffect=Xt;exports.useUnmountObservable=Et;
1
+ "use strict";var pt=Object.defineProperty;var bt=(s,e,t)=>e in s?pt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var y=(s,e,t)=>(bt(s,typeof e!="symbol"?e+"":e,t),t),Te=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var c=(s,e,t)=>(Te(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)=>(Te(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"),De=require("react/jsx-runtime");function gt(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 Oe=gt(v),A=s=>{const e=v.useRef(s);return v.useMemo(()=>{e.current=s},[s]),e};function mt(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(mt),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 Ke(s){return s instanceof Promise||s&&typeof s.then=="function"&&typeof s.catch=="function"}function F(s){if(r.isObservable(s))return s;if(Ke(s))return r.from(s);if(typeof s!="function")return r.of(s);const e=s;return r.defer(()=>{const t=e();return Ke(t)?r.from(t):r.isObservable(t)?t:r.of(t)})}function je(s,e=[]){const t=A(s);v.useEffect(()=>{const n=F(t.current).subscribe();return()=>{n.unsubscribe()}},[...e,t])}const we=s=>{const e=v.useRef();return e.current||(e.current=s()),v.useEffect(()=>{process.env.NODE_ENV},[]),e},Fe=({onBeforeComplete:s,completeOnUnmount:e=!0}={})=>{const t=we(()=>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},yt=()=>{const s=Fe(),e=A(s.current.asObservable()),t=v.useCallback(n=>{s.current.next(n)},[]);return[e.current,t]},Re=s=>{const e=we(()=>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},St=s=>{const e=Re(s),t=A(e.current.asObservable()),n=v.useCallback(i=>{e.current.next(i)},[e.current]);return[t.current,n,e.current.getValue()]},Ye=Symbol("SIGNAL_RESET");function vt(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===Ye){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 Ot(s,e){const n=e??(()=>s.getValue());return he(()=>s.subject.pipe(r.map(u=>n(u)),r.distinctUntilChanged()),{defaultValue:n(s.getValue())},[])}const wt=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()=>{}}),Ce=s=>{if(!(!s||typeof s!="object"))return s},$t=({adapter:s,key:e})=>({clear:async()=>await s.removeItem(e),removeItem:async t=>{const n=await s.getItem(e),{[t]:i,...u}=Ce(n)??{};await s.setItem(e,u)},getItem:async t=>{const n=await s.getItem(e),i=Ce(n)??{};if(t in i)return i[t]},setItem:async(t,n)=>{const i=await s.getItem(e),u=Ce(i)??{};await s.setItem(e,{...u,[t]:n})}}),Je=({key:s}={})=>s?$t({adapter:Je(),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",Ct=s=>{if(typeof s=="object"&&s!==null&&re in s&&s[re]===re)return s};function ge(s){return s!=null}const Ne=s=>{const e=Re(s);return v.useEffect(()=>{e.current.next(s)},[s,e]),e},qe=({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))))},Et=({adapter:s,version:e,signal:t})=>r.from(s.getItem(t.config.key)).pipe(r.switchMap(n=>{const i=Ct(n);return!i||i.migrationVersion!==void 0&&e>i.migrationVersion||t.setValue(i.value),r.of(n)})),Mt=({entries:s=[],onReady:e,adapter:t})=>{const n=A(s),i=A(e),u=Ne(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})=>Et({adapter:f,signal:b,version:d}).pipe(r.mergeMap(()=>qe({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=Ne(a);return je(()=>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(qe({adapter:h,signal:f,version:o})))))))),[l,u]),{isHydrated:a}},jt=()=>{const s=Fe({onBeforeComplete:()=>{s.current.next()}});return s};function Xe(s,e){return Math.min(s,e)}function Ze(s,e){return Math.pow(2,s)*e}function Ue(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=Ze}=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(P=>r.merge(r.of(P),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(Xe(b(w,l),f)).pipe(K.mergeMap(P=>n&&!n(w,O)?r.throwError(()=>O):r.of(P))):r.throwError(()=>O)))}))),K.catchError(m=>{if(s.catchError)return s.catchError(p,m);throw m}),K.tap(()=>{o&&(p=0)}))})}function He(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ee(s){if(!He(s))return!1;const e=s.constructor;if(typeof e>"u")return!0;const t=e.prototype;return!(!He(t)||!t.hasOwnProperty("isPrototypeOf"))}const te=s=>JSON.stringify(s,(e,t)=>Ee(t)?Object.keys(t).sort().reduce((n,i)=>(n[i]=t[i],n),{}):t),xe=(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 Ae(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 Ft{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}),Ae(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 $e(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?!Object.keys(e).some(t=>!$e(s[t],e[t])):!1}const me=(s,e,{exact:t=!1}={})=>t?te(s)===te(e):$e(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 et=s=>s.pipe(r.distinctUntilChanged(({data:e,...t},{data:n,...i})=>R(t,i)&&R(e,n)));var z,I;class Rt{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)??[xe()],M(this,z,n??new Ft(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(et),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 tt=v.createContext(void 0),Ut=({client:s})=>(v.useEffect(()=>(s.mount(),()=>{s.unmount()}),[s]),null),xt=v.memo(({children:s,client:e})=>{const t=v.useMemo(()=>e,[e]);return De.jsxs(tt.Provider,{value:t,children:[De.jsx(Ut,{client:e}),s]})}),Qe=s=>{const e=v.useContext(tt);if(s)return s;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e};function At(){}function Qt(s,e){const t=Qe(e),n=A(s),i=we(()=>[xe()]),u=te(s.mutationKey??i.current),[a]=v.useState(()=>new Rt(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(At)},[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)}))}class Pt{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(r.fromEvent(window,"offline").pipe(r.map(()=>!1)),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 Pt;function ke(s,e){return s.isStaleByTime(e.staleTime)}function Vt(s,e){return e.enabled!==!1&&!s.state.dataUpdatedAt&&!(s.state.status==="error"&&e.retryOnMount===!1)&&s.state.fetchStatus!=="fetching"}function Le(s,e){return Vt(s,e)||s.state.dataUpdatedAt>0&&rt(s,e,e.refetchOnMount)}function We(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 It(s,e){return rt(s,e,e.refetchOnWindowFocus)}function rt(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 Tt(s){return(s??"online")==="online"?_.isOnline():!0}function _e(s,e){return e.reduce((t,n)=>n in s?{...t,[n]:s[n]}:t,{})}function ze(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function st(s,e){if(s===e)return s;const t=ze(s)&&ze(e);if(t||Ee(s)&&Ee(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]=st(s[o],e[o]),l[o]===s[o]&&s[o]!==void 0&&h++)}return i===a&&h===i?s:l}return e}function Pe(s,e){return((e==null?void 0:e.queryKeyHashFn)??te)(s)}function Be(s,e){const{type:t="all",exact:n,fetchStatus:i,predicate:u,queryKey:a,stale:l}=s;if(a){if(n){if(e.queryHash!==Pe(a,e.options))return!1}else if(!$e(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 Dt(s,e){return Math.max(s+(e??0)-Date.now(),0)}function Kt(s,e){return typeof s=="function"?s(e):s}function ye(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?st(s,e):e}const Me=Symbol(),Nt=({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?ye(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,P=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,...P&&{status:i.status}}},t)),qt=s=>s.pipe(r.map(({status:e,fetchStatus:t})=>t==="idle"&&(e==="success"||e==="error"))),nt=s=>s.pipe(r.takeWhile(e=>e.fetchStatus!=="idle",!0));var ve,L;class Ht{constructor(){$(this,ve,r.merge(r.fromEvent(document,"visibilitychange"),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,ve).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"))}}ve=new WeakMap,L=new WeakMap;const Se=new Ht,Lt=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 it{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:P}=o;if(n){const Q=!!c(this,ie),Ie=!Q&&Le(t,e),dt=Q&&We(t,d,e,p);(Ie||dt)&&(w=Tt(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=ye(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&&(P=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=ye(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:P,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 Wt(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}])=>{We(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(Lt,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 Ve=_e(de,V),be=_e(pe,V);return R(Ve,be)}:R)(S,T)},d=f.pipe(r.switchMap(()=>a.state$),nt),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||Se.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(()=>Se.focusRegained$),r.withLatestFrom(h),r.tap(([,S])=>{It(a,S)&&this.fetch({cancelRefetch:!1}).catch(r.noop)}),r.ignoreElements()),w=m.pipe(r.map(()=>a.state)),P=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(P,r.distinctUntilChanged(R),r.distinctUntilChanged(b));return r.merge(p,O,E)})).pipe(Ae(a=>M(this,ie,a)),r.tap({subscribe:()=>{Le(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 Wt(s,e){return!R(s.getCurrentResult(),e)}const at=Oe.createContext(!1),_t=()=>Oe.useContext(at);at.Provider;function zt(){let s=!1;return{clearReset:()=>{s=!1},reset:()=>{s=!0},isReset:()=>s}}const Bt=Oe.createContext(zt()),Gt=()=>Oe.useContext(Bt);function Yt(s,e){return typeof s=="function"?s(...e):!!s}const Jt=({result:s,errorResetBoundary:e,throwOnError:t,query:n})=>s.isError&&!e.isReset()&&!s.isFetching&&n&&Yt(t,[s.error,n]);function ut(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=Qe(t),i=_t(),u=Gt(),a=n.defaultQueryOptions(s);a._optimisticResults=i?"isRestoring":"optimistic";const[l]=v.useState(()=>new e(n,a)),h=we(()=>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&&Jt({result:o,errorResetBoundary:u,throwOnError:a.throwOnError,query:n.getQueryCache().get(a.queryHash)}))throw b;return f.current}function Xt(s,e){return ut(s,it,e)}function Zt(s,e){return ut({refetchOnMount:"idle",refetchOnReconnect:!1,refetchInterval:!1,refetchOnWindowFocus:!1,...s},it,e)}function er(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]);je(l,t)}const ct=()=>s=>r.merge(r.of({isPaused:!0}),_.backToOnline$.pipe(r.mergeMap(()=>r.merge(r.of({isPaused:!1}),s)))),tr=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(ct())))):r.throwError(()=>t))))},rr=({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})),tr,Ue({...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(ct())})),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 sr{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=>rr({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),et,r.tap(l=>{this.state=l}),r.shareReplay(1),Ae(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 ot{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 k;class lt{constructor(e={}){$(this,k,new ot);this.config=e}build(e,t,n){const i=new sr({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,k).add(i),i}getAll(){return this.findAll()}remove(e){const t=c(this,k).getValues().find(n=>n===e);t==null||t.cancel(),c(this,k).remove(e)}find(e){const t={exact:!0,...e},n=Ge(t);return c(this,k).getValues().find(i=>n(i))}findAll(e={}){const t={exact:!0,...e},n=Ge(t);return c(this,k).getValues().filter(i=>n(i)).map(i=>i)}observe(){return c(this,k).stateChange$.pipe(r.startWith())}subscribe(e){const t=r.merge(c(this,k).added$.pipe(r.tap(n=>{e({type:"added",mutation:n})})),c(this,k).removed$.pipe(r.tap(n=>{e({type:"removed",mutation:n})})),c(this,k).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)})}}k=new WeakMap;const nr=typeof window>"u"||"Deno"in window;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(()=>Se.isFocused()?s:Se.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===Me&&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!==Me?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),Ue({...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 ht(s){const e={namespaces:[{name:"@reactjrx",style:{backgroundColor:"#d02f4e",color:"white"}}],namespace(t,n){const i=ht();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=ht();var ue,G;class dr{constructor(e){y(this,"queryKey");y(this,"queryHash");y(this,"gcTime");y(this,"options");$(this,ue,void 0);$(this,G,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,G,e.state??ir(this.options)),this.state=c(this,G),this.gcTime=this.updateGcTime(this.options.gcTime),this.state$=r.merge(this.resetSubject.pipe(r.map(()=>({command:"reset",state:c(this,G)}))),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(Nt({initialState:this.state,getOptions:()=>this.options,getState:()=>this.state}),r.startWith(c(this,G)),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??(nr?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||!Dt(this.state.dataUpdatedAt,e)}async getFetchResultAsPromise(){return await new Promise((e,t)=>{this.state$.pipe(nt,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=ye(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,G=new WeakMap;var ce,N;class ft{constructor(e={}){$(this,ce,new r.Subject);$(this,N,new ot);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=>Be(e,n)):t}build(e,t,n){const i=t.queryKey??[xe()],u=t.queryHash??Pe(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(qt,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=>Be(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 Y,j,oe,le,ee;class pr{constructor({mutationCache:e,queryCache:t,defaultOptions:n}={}){$(this,Y,void 0);$(this,j,void 0);$(this,oe,new Map);$(this,le,new Map);$(this,ee,void 0);M(this,Y,e??new lt),M(this,j,t??new ft),M(this,ee,n??{})}mount(){}unmount(){}getMutationCache(){return c(this,Y)}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=Pe(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===Me&&(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=Kt(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=>{$e(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,Y).resumePausedMutations())}isFetching(e){return c(this,j).findAll({...e,fetchStatus:"fetching"}).length}clear(){c(this,j).clear(),c(this,Y).clear()}}Y=new WeakMap,j=new WeakMap,oe=new WeakMap,le=new WeakMap,ee=new WeakMap;exports.MutationCache=lt;exports.QueryCache=ft;exports.QueryClient=pr;exports.QueryClientProvider=xt;exports.SIGNAL_RESET=Ye;exports.createLocalStorageAdapter=Je;exports.createLocalforageAdapter=wt;exports.exponentialBackoffDelay=Ze;exports.getDelay=Xe;exports.isDefined=ge;exports.retryBackoff=Ue;exports.signal=vt;exports.useBehaviorSubject=Re;exports.useForeverQuery=Zt;exports.useLiveRef=A;exports.useMutation=Qt;exports.useObservableState=St;exports.useObserve=he;exports.useObserveCallback=yt;exports.usePersistSignals=Mt;exports.useQuery=Xt;exports.useQueryClient=Qe;exports.useSignalValue=Ot;exports.useSubject=Fe;exports.useSubscribe=je;exports.useSubscribeEffect=er;exports.useUnmountObservable=jt;