reactjrx 4.0.6 → 4.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{c as e}from"react/compiler-runtime";import{createContext as t,memo as r,useCallback as n,useContext as o,useEffect as s,useLayoutEffect as c,useRef as a,useState as i,useSyncExternalStore as u}from"react";import{BehaviorSubject as l,EMPTY as f,NEVER as p,Observable as d,Subscription as v,asyncScheduler as g,catchError as m,defaultIfEmpty as y,defer as b,distinctUntilChanged as h,finalize as w,first as S,from as I,fromEvent as x,ignoreElements as V,isObservable as E,map as O,merge as j,of as A,retry as F,scan as k,share as D,skip as _,switchMap as q,take as C,tap as N,throttleTime as T,throwError as $,timer as P}from"rxjs";import{catchError as M,first as H,mergeMap as J,retry as K,tap as U}from"rxjs/operators";import{CancelledError as L,skipToken as R,useMutation as Y,useQueries as z,useQuery as G}from"@tanstack/react-query";import{jsx as Q}from"react/jsx-runtime";var W=Symbol("UNSET"),B=e=>{const t=a(W);return t.current===W&&(t.current=e()),t},X=e=>B(e).current,Z=t=>{const r=e(6);let n;r[0]!==t?(n=()=>new l(t),r[0]=t,r[1]=n):n=r[1];const o=X(n);let c,a;return r[2]!==t||r[3]!==o?(c=()=>{Object.is(o.getValue(),t)||o.next(t)},a=[t,o],r[2]=t,r[3]=o,r[4]=c,r[5]=a):(c=r[4],a=r[5]),s(c,a),o},ee=t=>{const r=e(12);let n;r[0]!==t?(n=()=>new l(t),r[0]=t,r[1]=n):n=r[1];const o=X(n);let s;r[2]!==o?(s=e=>{const t="function"==typeof(r=e)?r(o.getValue()):r;var r;t!==o.getValue()&&o.next(t)},r[2]=o,r[3]=s):s=r[3];const c=s;let a;r[4]!==o?(a=e=>{const t=o.pipe(_(1)).subscribe(e);return()=>{t.unsubscribe()}},r[4]=o,r[5]=a):a=r[5];const i=a;let f;r[6]!==o?(f=()=>o.getValue(),r[6]=o,r[7]=f):f=r[7];const p=u(i,f,f);let d;return r[8]!==c||r[9]!==o||r[10]!==p?(d=[p,c,o],r[8]=c,r[9]=o,r[10]=p,r[11]=d):d=r[11],d},te=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};function re(e){return null!=e}function ne(e){return e instanceof Promise||e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then&&"catch"in e&&"function"==typeof e.catch}var oe="undefined"==typeof window||"Deno"in window;function se(e,t){return Math.min(e,t)}function ce(e,t){return 2**e*t}function ae(e){const{retry:t=()=>!0,retryAfterDelay:r,retryAfter:n=()=>A(!0),initialInterval:o=100,maxInterval:s=Number.POSITIVE_INFINITY,resetOnSuccess:c=!1,backoffDelay:a=ce}=e;return i=>b(()=>{let u=0;return i.pipe(M(r=>{if(u++,!t(u-1,r))throw r;const n=e.caughtError?.(u,r);if(!n)throw r;return n.pipe(J(e=>j(A(e),$(()=>r))))}),K({delay:e=>{const c=u-1;return n().pipe(H(),J(()=>t(c,e)?P(se(a(c,o),s)).pipe(J(t=>r&&!r(c,e)?$(()=>e):A(t))):$(()=>e)))}}),M(t=>{if(e.catchError)return e.catchError(u,t);throw t}),U(()=>{c&&(u=0)}))})}var ie=t=>{const r=e(3),n=a(t);let o,s;return r[0]!==t?(o=()=>{n.current=t},s=[t],r[0]=t,r[1]=o,r[2]=s):(o=r[1],s=r[2]),c(o,s),n},ue=(e,t,r={})=>{const{cancelOnUnmount:o=!1}=r,c=ie(e),i=ie(o),u=a(null),l=n(e=>{null!==u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c.current(e),t)},[c,t]);return s(()=>()=>{i.current&&null!==u.current&&clearTimeout(u.current)},[i]),l},le=t=>{const r=e(1);let n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],r[0]=n):n=r[0],s(t,n)},fe=(e,t)=>{const r=a({value:e}),n=r.current.value,o=Object.is(e,n)||t(e,n)?n:e;return c(()=>{r.current={value:o}},[o]),o},pe=t=>{const r=e(2);let n;r[0]!==t?(n=()=>{t()},r[0]=t,r[1]=n):n=r[1],le(n)},de=t=>{const r=e(2),n=ie(t);let o;r[0]!==n?(o=()=>()=>n.current(),r[0]=n,r[1]=o):o=r[1],le(o)};function ve(e,t){if(null==e||void 0===t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(e.constructor!==t?.constructor)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(!t.hasOwnProperty(o)||e[o]!==t[o])return!1;return!0}var ge=class{state;source$;sub;constructor({source$:e,defaultValue:t,compareFn:r}){const n="function"==typeof e?e():e,o=void 0===n;if(this.state={data:n instanceof l?n.value:t,status:o?"success":"pending",observableState:o?"complete":"live",error:void 0},o)return this.source$=p,void(this.sub=v.EMPTY);this.source$=n.pipe(h(r),N({complete:()=>{this.state={...this.state,status:"success",observableState:"complete"}},error:e=>{this.state={...this.state,observableState:"error",status:"error",error:e}},next:e=>{this.state={...this.state,data:e}}}),D()),this.sub=this.source$.subscribe({error:()=>{}})}subscribe=e=>{if("live"!==this.state.observableState)return()=>{};const t=this.source$.subscribe({complete:e,error:e,next:e});return()=>{t.unsubscribe()}};getSnapshot=()=>this.state};function me(t,r,n){const o=e(6);let c;o[0]!==r?(c=null==r||Array.isArray(r)?{defaultValue:void 0,compareFn:void 0}:r,o[0]=r,o[1]=c):c=o[1];const i=c;let l;o[2]!==n||o[3]!==r||o[4]!==t?(l=!n&&Array.isArray(r)?r:"function"==typeof t?n??[]:[t],o[2]=n,o[3]=r,o[4]=t,o[5]=l):l=o[5];const f=((e,t,r)=>{const n=ie(t),o=a(void 0);if(!o.current||!te(r,o.current.deps)){let s=!0;const c=new ge({source$:e,defaultValue:t.defaultValue,compareFn:(e,r)=>{const{compareFn:o}=s?t:n.current;return o?.(e,r)??e===r}});s=!1,o.current={deps:r,store:c}}const c=o.current.store;return s(()=>()=>{c.sub.unsubscribe()},[c]),c})(t,i,l);return u(f.subscribe,f.getSnapshot,f.getSnapshot)}function ye(e){if(E(e))return()=>e;if(ne(e))return()=>I(e);if("function"!=typeof e)return()=>A(e);const t=e;return e=>b(()=>{const r=t(e);return ne(r)?I(r):E(r)?r:A(r)})}function be(t){const r=e(3);let n,o;r[0]!==t?(n=()=>{const e=ye(t)().subscribe();return()=>{e.unsubscribe()}},o=[t],r[0]=t,r[1]=n,r[2]=o):(n=r[1],o=r[2]),s(n,o)}var he=e=>se(ce(e,1e3),3e4);function we(e,t){const r=ie(t);be(n(()=>ye(e)().pipe(N({error:e=>{r.current?.onError?.(e)}}),F({resetOnSuccess:!0,delay:(e,t)=>{const n=t-1,{retry:o,retryDelay:s=he}=r.current??{};return((e,t,r)=>"function"==typeof e?e(t,r):"number"==typeof e?t<e:!0===e)(o,n,e)?P("function"==typeof s?s(n,e):s):$(()=>e)}})),[e,r]))}var Se={staleTime:0,refetchOnMount:"always"},Ie=/* @__PURE__ */new WeakMap;function xe(e){return e===R||void 0===e?e:t=>new Promise((r,n)=>{const o=t.client.getQueryCache(),s=o.getAll().find(e=>e.queryKey===t.queryKey),c=b(()=>"function"==typeof e?e(t):e),a={resolve:r,reject:n};if(!s)return void function(e,t,{resolve:r,reject:n}){const o=e.pipe(C(1)).subscribe({next:r,error:n,complete:()=>n(new L)});t.addEventListener("abort",()=>{o.unsubscribe(),n(new L)},{once:!0})}(c,t.signal,a);const i=Ie.get(s);i?.isStartingFollow?(i.isStartingFollow=!1,function(e,t){e.fetch=t,e.error?(t.reject(e.error.value),e.stop()):e.isComplete&&(t.resolve(e.last?.value),e.stop())}(i,a)):(i?.stop(),function(e,t,r,n){const o=new v;let s=!1;const c={phase:"loading",last:void 0,uncommitted:void 0,error:void 0,isComplete:!1,fetch:n,isStartingFollow:!1,stop:()=>{s||(s=!0,o.unsubscribe(),u(),Ie.get(e)===c&&Ie.delete(e))}},a=e=>{o.unsubscribe(),c.error={value:e},"resolved"===c.phase||c.isStartingFollow||(c.fetch?.reject(e),c.stop())},i=()=>{c.phase="live",c.fetch=void 0,c.uncommitted&&(e.setData(c.uncommitted.value,{manual:!0}),c.uncommitted=void 0),c.isComplete&&!c.error?c.stop():c.error||e.isActive()?(c.isStartingFollow=!0,e.fetch().catch(()=>{}),c.isStartingFollow&&e.promise?.catch(()=>{c.isStartingFollow&&c.stop()})):c.stop()},u=t.subscribe(t=>{t.query===e&&("updated"!==t.type||"resolved"!==c.phase||"success"!==t.action.type||t.action.manual||i(),("observerOptionsUpdated"===t.type||"observerRemoved"===t.type)&&"live"===c.phase&&e.getObserversCount()>0&&!e.isActive()&&(e.cancel({revert:!0}),c.stop()),("observerRemoved"===t.type&&!c.fetch&&0===e.getObserversCount()||"removed"===t.type)&&c.stop())});Ie.set(e,c),o.add(r.subscribe({next:t=>{if(void 0!==t){if(c.last={value:t},"loading"===c.phase)return c.phase="resolved",void c.fetch?.resolve(t);e.setData(t,{manual:!0}),"resolved"===c.phase&&(c.uncommitted={value:t})}else a(/* @__PURE__ */new Error(`${JSON.stringify(e.queryKey)} data is undefined`))},error:a,complete:()=>{c.isComplete=!0,"resolved"===c.phase||c.isStartingFollow||(c.last?c.fetch?.resolve(c.last.value):(console.warn(`cancelled due to stream completing without data for query ${JSON.stringify(e.queryKey)}`),c.fetch?.reject(new L)),c.stop())}}))}(s,o,c,a));const u=Ie.get(s);u?.fetch===a&&function(e,t,r){r.addEventListener("abort",()=>{e.fetch===t&&(t.reject(new L),e.stop())},{once:!0})}(u,a,t.signal)})}function Ve(t,r){const n=e(9);let o,s,c;n[0]!==t?(({queries:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=s.map(Ee),n[3]=s,n[4]=c):c=n[4];const a=c,i=o.combine;let u;return n[5]!==o.subscribed||n[6]!==a||n[7]!==i?(u={queries:a,combine:i,subscribed:o.subscribed},n[5]=o.subscribed,n[6]=a,n[7]=i,n[8]=u):u=n[8],z(u,r)}function Ee(e){return{...e,queryFn:xe(e.queryFn)}}function Oe(t,r){const n=e(8);let o,s,c;n[0]!==t?(({queries:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=s.map(je),n[3]=s,n[4]=c):c=n[4];const a=c;let i;return n[5]!==o||n[6]!==a?(i={...o,queries:a},n[5]=o,n[6]=a,n[7]=i):i=n[7],Ve(i,r)}function je(e){return{...e,...Se}}function Ae(t,r){const n=e(8);let o,s,c,a;return n[0]!==t?(({queryFn:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=xe(s),n[3]=s,n[4]=c):c=n[4],n[5]!==o||n[6]!==c?(a={...o,queryFn:c},n[5]=o,n[6]=c,n[7]=a):a=n[7],G(a,r)}function Fe(t,r){const n=e(2);let o;return n[0]!==t?(o={...t,...Se},n[0]=t,n[1]=o):o=n[1],Ae(o,r)}function ke(e,t){return"function"==typeof e?e(t):e}function De(t,r){const n=e(16),o=X(_e);let c,a;n[0]!==t?(c=e=>{let r;return new Promise((n,o)=>{ke(t.mutationFn,e).pipe(C(1)).subscribe({next:e=>{r={value:e}},error:e=>{o(e)},complete:()=>{if(void 0===r)return o(/* @__PURE__ */new Error("Stream completed without any data"));n(r.value)}})})},n[0]=t,n[1]=c):c=n[1],n[2]!==t||n[3]!==c?(a={...t,mutationFn:c},n[2]=t,n[3]=c,n[4]=a):a=n[4];const i=Y(a,r),{status:u,isPending:l,isError:f,isSuccess:p,isIdle:d}=i;let v,g,m;return n[5]!==f||n[6]!==d||n[7]!==l||n[8]!==p||n[9]!==o||n[10]!==u?(v=()=>{o.next({status:u,isPending:l,isError:f,isSuccess:p,isIdle:d})},g=[u,l,f,p,d,o],n[5]=f,n[6]=d,n[7]=l,n[8]=p,n[9]=o,n[10]=u,n[11]=v,n[12]=g):(v=n[11],g=n[12]),s(v,g),n[13]!==i||n[14]!==o?(m={...i,state$:o},n[13]=i,n[14]=o,n[15]=m):m=n[15],m}function _e(){return new l({status:"idle",isPending:!1,isError:!1,isSuccess:!1,isIdle:!0})}var qe=class extends Error{constructor(e="Mutation canceled"){super(e),this.name="SwitchMutationCancelError"}};function Ce(t,r){const n=e(20),{mutationFn:o,...s}=t,c=B(Te);let a;n[0]!==o?(a=e=>{const{variables:t,abort:r}=e;if(r.aborted)throw new qe;const n=ke(o,t);return j(n.pipe(y(null)),x(r,"abort").pipe(N(Ne),V())).pipe(S())},n[0]=o,n[1]=a):a=n[1];const i=a,u=function({onMutate:e,onSuccess:t,onError:r,onSettled:n}){return{onMutate:e?({variables:t},...r)=>e(t,...r):void 0,onSuccess:(e,{variables:r},...n)=>t?.(e,r,...n),onError:(e,{variables:t},...n)=>r?.(e,t,...n),onSettled:(e,t,{variables:r},...o)=>n?.(e,t,r,...o)}}(s);let l;n[2]!==s||n[3]!==i||n[4]!==u?(l={...s,mutationFn:i,...u},n[2]=s,n[3]=i,n[4]=u,n[5]=l):l=n[5];const f=De(l,r);let p,d,v,g;n[6]!==f?(({mutate:p,mutateAsync:d,...v}=f),n[6]=f,n[7]=p,n[8]=d,n[9]=v):(p=n[7],d=n[8],v=n[9]),n[10]!==p||n[11]!==c?(g=e=>(c.current.abort(),c.current=new AbortController,p({variables:e,abort:c.current.signal})),n[10]=p,n[11]=c,n[12]=g):g=n[12];const m=g;let b;n[13]!==d||n[14]!==c?(b=e=>(c.current.abort(),c.current=new AbortController,d({variables:e,abort:c.current.signal})),n[13]=d,n[14]=c,n[15]=b):b=n[15];const h=b;let w;return n[16]!==h||n[17]!==m||n[18]!==v?(w={...v,mutate:m,mutateAsync:h},n[16]=h,n[17]=m,n[18]=v,n[19]=w):w=n[19],w}function Ne(){throw new qe}function Te(){return new AbortController}var $e=Symbol("SIGNAL_RESET"),Pe=e=>{if(e)try{return JSON.parse(e)}catch{return}},Me=e=>({getItem:async t=>Pe(await e.getItem(t)),setItem:async(t,r)=>{await e.setItem(t,JSON.stringify(r))},removeItem:async e=>{},clear:async()=>{}}),He=e=>{const t=Pe(localStorage.getItem(e));return"object"==typeof(r=t)&&null!==r?t:{};var r},Je=(e,t)=>{localStorage.setItem(e,JSON.stringify(t))},Ke=({key:e}={})=>e?(e=>({clear:async()=>{localStorage.removeItem(e)},removeItem:async t=>{const{[t]:r,...n}=He(e);Je(e,n)},getItem:async t=>{const r=He(e);return Object.hasOwn(r,t)?r[t]:void 0},setItem:async(t,r)=>{Je(e,{...He(e),[t]:r})}}))(e):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>Pe(localStorage.getItem(e)),setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},Ue=class extends l{config;constructor(e){super(e.default),this.config=e}update=e=>{if(e===$e)super.next(this.config.default);else if("function"==typeof e){const t=e;super.next(t(this.value))}else super.next(e)};get key(){return this.config.key}},Le=class{config;constructor(e){this.config=e}};function Re(e={}){return new Ue({key:void 0,default:void 0,...e})}function Ye(e){return new Le(e)}var ze=class{signals=new l(/* @__PURE__ */new Map);isDestroyed=!1;getOrCreateSignal(e){const t=this.signals.value.get(e);if(t)return t;const r=new Ue({...e.config,key:void 0});return this.signals.value.set(e,r),this.signals.next(this.signals.value),r}destroy(){this.signals.value.forEach(e=>{e.complete()}),this.signals.value.clear(),this.signals.complete(),this.isDestroyed=!0}},Ge=t(new ze),Qe=r(({children:e})=>{const t=B(()=>new ze),r=t.current,[n,o]=i(!1);n&&(t.current=new ze,o(!1));const c=r;return s(()=>()=>{t.current?.destroy(),o(!0)},[t]),/* @__PURE__ */Q(Ge.Provider,{value:c,children:e})}),We=()=>o(Ge),Be=t=>{const r=e(3),n=We();let o;return r[0]!==n||r[1]!==t?(o=t?n.getOrCreateSignal(t):void 0,r[0]=n,r[1]=t,r[2]=o):o=r[2],o},Xe="__reactjrx";var Ze=({adapter:e,entry:t,resetToDefault:r,onHydrated:n})=>{const{signal:o}=t.config;let s;const c=()=>(s=o.getValue(),(({adapter:e,config:t})=>{const{signal:r,version:n}=t,o={value:r.getValue(),[Xe]:Xe,migrationVersion:n};return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Persist value",o,`for signal ${r.config.key}`),I(e.setItem(r.config.key,o)).pipe(m(e=>(console.error(e),A(null))))})({adapter:e,config:t.config}));return function({adapter:e,config:t,resetToDefault:r=!1}){const{hydrate:n=({value:e})=>e,signal:o,version:s}=t,c=e=>(r&&o.update($e),A(e));return I(e.getItem(o.config.key)).pipe(q(e=>{const t=(e=>{if("object"==typeof e&&null!==e&&"__reactjrx"in e&&"__reactjrx"===e.__reactjrx)return e})(e);if(!t)return c(e);const r="number"!=typeof t.migrationVersion,a=void 0!==t.migrationVersion&&s>t.migrationVersion;if(r||a||void 0===t.value)return c(e);const i=t.value;return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Hydrate value",t,`for signal ${o.config.key}`),o.next(n({value:i,version:s})),A(e)}))}({adapter:e,config:t.config,resetToDefault:r}).pipe(m(e=>(console.error(`Unable to hydrate signal ${o.config.key}`,e),f)),N(n),q(()=>o.pipe(T(500,g,{trailing:!0}),q(()=>c()),w(()=>{o.getValue()!==s&&c().subscribe()}))))};function et({entries:e=[],onHydrated:t,adapter:r}){const n=ie(t),o=Z(r),s=Z(e);return me(()=>o.pipe(k((e,t)=>{const r=e.firstAdapter??t;return{adapter:t,firstAdapter:r,replacesAnother:e.replacesAnother||!!t&&t!==r}},{adapter:void 0,firstAdapter:void 0,replacesAnother:!1}),q(({adapter:e,replacesAnother:t})=>e?j(A({type:"reset"}),function({entries$:e,onHydrated:t,adapter:r,resetToDefault:n=!1}){return new d(o=>{const s=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set;let a=!1,i=!1;const u=()=>{i||a||c.size>0||(i=!0,t?.(),o.next({type:"hydrated"}))},l=e=>{const t={config:e,subscription:new v};s.set(e.signal,t),c.add(e.signal),t.subscription.add(Ze({adapter:r,entry:t,resetToDefault:n,onHydrated:()=>{c.delete(e.signal),u()}}).subscribe())},f=e=>{const t=s.get(e);t&&(s.delete(e),c.delete(e),t.subscription.unsubscribe())},p=e.subscribe({next:e=>{a=!0;const t=new Set(e.map(({signal:e})=>e));for(const r of[...s.keys()])t.has(r)||f(r);for(const r of e){const e=s.get(r.signal);e?e.config=r:l(r)}a=!1,u()},error:e=>o.error(e)});return()=>{p.unsubscribe();for(const e of[...s.keys()])f(e)}})}({adapter:e,entries$:s,resetToDefault:t,onHydrated:()=>{n.current?.()}})):A({type:"reset"})),O(e=>({isHydrated:"hydrated"===e.type}))),{defaultValue:{isHydrated:!1},compareFn:ve},[o,s]).data}function tt(t){const r=e(3),n=We();if(t instanceof Le&&!n)throw new Error("useSignalValue must be used within a SignalContextProvider");let o;return r[0]!==t||r[1]!==n?(o=t instanceof Le?n.getOrCreateSignal(t):t,r[0]=t,r[1]=n,r[2]=o):o=r[2],o}function rt(e){return tt(e).update}var nt=Object.is;function ot(t,r,n){const o=e(7),s=void 0===n?nt:n,c=tt(t);let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i={hasValue:!1,signal:void 0,selector:void 0,sourceValue:void 0,value:void 0},o[0]=i):i=o[0];const l=a(i);let f;o[1]!==c?(f=e=>{const t=c.pipe(_(1)).subscribe(()=>{e()});return()=>{t.unsubscribe()}},o[1]=c,o[2]=f):f=o[2];const p=f;let d;o[3]!==s||o[4]!==c||o[5]!==r?(d=()=>{const e=l.current,t=c.value;if(e.hasValue&&e.signal===c&&e.selector===r&&e.sourceValue===t)return e.value;const n=r?r(t):t;return e.hasValue&&e.signal===c&&s(e.value,n)?(l.current={hasValue:!0,signal:c,selector:r,sourceValue:t,value:e.value},e.value):(l.current={hasValue:!0,signal:c,selector:r,sourceValue:t,value:n},n)},o[3]=s,o[4]=c,o[5]=r,o[6]=d):d=o[6];return u(p,d,d)}function st(t){const r=e(4),n=tt(t),o=ot(n),s=rt(n);let c;return r[0]!==n||r[1]!==s||r[2]!==o?(c=[o,s,n],r[0]=n,r[1]=s,r[2]=o,r[3]=c):c=r[3],c}var ct=t=>{const r=e(3),n=X(t),o=ot(n);let s;return r[0]!==n||r[1]!==o?(s=[o,n],r[0]=n,r[1]=o,r[2]=s):s=r[2],s};export{$e as SIGNAL_RESET,Ue as Signal,Qe as SignalContextProvider,Ge as SignalReactContext,qe as SwitchMutationCancelError,Le as VirtualSignal,te as arrayEqual,Ke as createLocalStorageAdapter,Me as createLocalforageAdapter,ce as exponentialBackoffDelay,se as getDelay,re as isDefined,ne as isPromiseLike,oe as isServer,ve as isShallowEqual,ae as retryBackoff,Re as signal,X as useConstant,ue as useDebounced,le as useEffectOnce,Z as useLiveBehaviorSubject,Oe as useLiveQueries$,Fe as useLiveQuery$,ie as useLiveRef,Be as useMakeOrRetrieveSignal,fe as useMemoCompare,pe as useMount,De as useMutation$,ee as useObservableState,me as useObserve,et as usePersistSignals,Ve as useQueries$,Ae as useQuery$,B as useRefOnce,rt as useSetSignal,st as useSignal,We as useSignalContext,ct as useSignalState,ot as useSignalValue,be as useSubscribe,we as useSubscribeEffect,Ce as useSwitchMutation$,de as useUnmount,Ye as virtualSignal};
1
+ import{c as e}from"react/compiler-runtime";import{createContext as t,memo as r,useCallback as n,useContext as o,useEffect as s,useLayoutEffect as c,useRef as a,useState as i,useSyncExternalStore as u}from"react";import{BehaviorSubject as l,EMPTY as f,NEVER as p,Observable as d,Subscription as v,asyncScheduler as g,catchError as y,defaultIfEmpty as m,defer as b,distinctUntilChanged as h,finalize as w,first as S,from as I,fromEvent as x,ignoreElements as V,isObservable as O,map as E,merge as j,of as A,retry as F,scan as k,share as D,skip as _,switchMap as q,take as C,tap as N,throttleTime as T,throwError as $,timer as P}from"rxjs";import{catchError as M,first as H,mergeMap as J,retry as K,tap as U}from"rxjs/operators";import{CancelledError as L,skipToken as R,useMutation as Y,useQueries as z,useQuery as G,useQueryClient as Q}from"@tanstack/react-query";import{jsx as W}from"react/jsx-runtime";var B=Symbol("UNSET"),X=e=>{const t=a(B);return t.current===B&&(t.current=e()),t},Z=e=>X(e).current,ee=t=>{const r=e(6);let n;r[0]!==t?(n=()=>new l(t),r[0]=t,r[1]=n):n=r[1];const o=Z(n);let c,a;return r[2]!==t||r[3]!==o?(c=()=>{Object.is(o.getValue(),t)||o.next(t)},a=[t,o],r[2]=t,r[3]=o,r[4]=c,r[5]=a):(c=r[4],a=r[5]),s(c,a),o},te=t=>{const r=e(12);let n;r[0]!==t?(n=()=>new l(t),r[0]=t,r[1]=n):n=r[1];const o=Z(n);let s;r[2]!==o?(s=e=>{const t="function"==typeof(r=e)?r(o.getValue()):r;var r;t!==o.getValue()&&o.next(t)},r[2]=o,r[3]=s):s=r[3];const c=s;let a;r[4]!==o?(a=e=>{const t=o.pipe(_(1)).subscribe(e);return()=>{t.unsubscribe()}},r[4]=o,r[5]=a):a=r[5];const i=a;let f;r[6]!==o?(f=()=>o.getValue(),r[6]=o,r[7]=f):f=r[7];const p=u(i,f,f);let d;return r[8]!==c||r[9]!==o||r[10]!==p?(d=[p,c,o],r[8]=c,r[9]=o,r[10]=p,r[11]=d):d=r[11],d},re=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};function ne(e){return null!=e}function oe(e){return e instanceof Promise||e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then&&"catch"in e&&"function"==typeof e.catch}var se="undefined"==typeof window||"Deno"in window;function ce(e,t){return Math.min(e,t)}function ae(e,t){return 2**e*t}function ie(e){const{retry:t=()=>!0,retryAfterDelay:r,retryAfter:n=()=>A(!0),initialInterval:o=100,maxInterval:s=Number.POSITIVE_INFINITY,resetOnSuccess:c=!1,backoffDelay:a=ae}=e;return i=>b(()=>{let u=0;return i.pipe(M(r=>{if(u++,!t(u-1,r))throw r;const n=e.caughtError?.(u,r);if(!n)throw r;return n.pipe(J(e=>j(A(e),$(()=>r))))}),K({delay:e=>{const c=u-1;return n().pipe(H(),J(()=>t(c,e)?P(ce(a(c,o),s)).pipe(J(t=>r&&!r(c,e)?$(()=>e):A(t))):$(()=>e)))}}),M(t=>{if(e.catchError)return e.catchError(u,t);throw t}),U(()=>{c&&(u=0)}))})}var ue=t=>{const r=e(3),n=a(t);let o,s;return r[0]!==t?(o=()=>{n.current=t},s=[t],r[0]=t,r[1]=o,r[2]=s):(o=r[1],s=r[2]),c(o,s),n},le=(e,t,r={})=>{const{cancelOnUnmount:o=!1}=r,c=ue(e),i=ue(o),u=a(null),l=n(e=>{null!==u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c.current(e),t)},[c,t]);return s(()=>()=>{i.current&&null!==u.current&&clearTimeout(u.current)},[i]),l},fe=t=>{const r=e(1);let n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],r[0]=n):n=r[0],s(t,n)},pe=(e,t)=>{const r=a({value:e}),n=r.current.value,o=Object.is(e,n)||t(e,n)?n:e;return c(()=>{r.current={value:o}},[o]),o},de=t=>{const r=e(2);let n;r[0]!==t?(n=()=>{t()},r[0]=t,r[1]=n):n=r[1],fe(n)},ve=t=>{const r=e(2),n=ue(t);let o;r[0]!==n?(o=()=>()=>n.current(),r[0]=n,r[1]=o):o=r[1],fe(o)};function ge(e,t){if(null==e||void 0===t)return e===t;if("object"!=typeof e||"object"!=typeof t)return e===t;if(e.constructor!==t?.constructor)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(!t.hasOwnProperty(o)||e[o]!==t[o])return!1;return!0}var ye=class{state;source$;sub;constructor({source$:e,defaultValue:t,compareFn:r}){const n="function"==typeof e?e():e,o=void 0===n;if(this.state={data:n instanceof l?n.value:t,status:o?"success":"pending",observableState:o?"complete":"live",error:void 0},o)return this.source$=p,void(this.sub=v.EMPTY);this.source$=n.pipe(h(r),N({complete:()=>{this.state={...this.state,status:"success",observableState:"complete"}},error:e=>{this.state={...this.state,observableState:"error",status:"error",error:e}},next:e=>{this.state={...this.state,data:e}}}),D()),this.sub=this.source$.subscribe({error:()=>{}})}subscribe=e=>{if("live"!==this.state.observableState)return()=>{};const t=this.source$.subscribe({complete:e,error:e,next:e});return()=>{t.unsubscribe()}};getSnapshot=()=>this.state};function me(t,r,n){const o=e(6);let c;o[0]!==r?(c=null==r||Array.isArray(r)?{defaultValue:void 0,compareFn:void 0}:r,o[0]=r,o[1]=c):c=o[1];const i=c;let l;o[2]!==n||o[3]!==r||o[4]!==t?(l=!n&&Array.isArray(r)?r:"function"==typeof t?n??[]:[t],o[2]=n,o[3]=r,o[4]=t,o[5]=l):l=o[5];const f=((e,t,r)=>{const n=ue(t),o=a(void 0);if(!o.current||!re(r,o.current.deps)){let s=!0;const c=new ye({source$:e,defaultValue:t.defaultValue,compareFn:(e,r)=>{const{compareFn:o}=s?t:n.current;return o?.(e,r)??e===r}});s=!1,o.current={deps:r,store:c}}const c=o.current.store;return s(()=>()=>{c.sub.unsubscribe()},[c]),c})(t,i,l);return u(f.subscribe,f.getSnapshot,f.getSnapshot)}function be(e){if(O(e))return()=>e;if(oe(e))return()=>I(e);if("function"!=typeof e)return()=>A(e);const t=e;return e=>b(()=>{const r=t(e);return oe(r)?I(r):O(r)?r:A(r)})}function he(t){const r=e(3);let n,o;r[0]!==t?(n=()=>{const e=be(t)().subscribe();return()=>{e.unsubscribe()}},o=[t],r[0]=t,r[1]=n,r[2]=o):(n=r[1],o=r[2]),s(n,o)}var we=(e,t,r)=>"function"==typeof e?e(t,r):"number"==typeof e?t<e:!0===e,Se=e=>ce(ae(e,1e3),3e4);function Ie(e,t){const r=ue(t);he(n(()=>be(e)().pipe(N({error:e=>{r.current?.onError?.(e)}}),F({resetOnSuccess:!0,delay:(e,t)=>{const n=t-1,{retry:o,retryDelay:s=Se}=r.current??{};return we(o,n,e)?P("function"==typeof s?s(n,e):s):$(()=>e)}})),[e,r]))}var xe={staleTime:0,refetchOnMount:"always"},Ve=/* @__PURE__ */new WeakMap;function Oe(e){return e===R||void 0===e?e:t=>new Promise((r,n)=>{const o=t.client.getQueryCache(),s=o.getAll().find(e=>e.queryKey===t.queryKey),c=b(()=>"function"==typeof e?e(t):e),a={resolve:r,reject:n};if(!s)return void function(e,t,{resolve:r,reject:n}){const o=e.pipe(C(1)).subscribe({next:r,error:n,complete:()=>n(new L)});t.addEventListener("abort",()=>{o.unsubscribe(),n(new L)},{once:!0})}(c,t.signal,a);const i=Ve.get(s);i?.isStartingFollow?(i.isStartingFollow=!1,function(e,t){e.fetch=t,e.error?(t.reject(e.error.value),e.stop()):e.isComplete&&(t.resolve(e.last?.value),e.stop())}(i,a)):(i?.stop(),function(e,t,r,n){const o=new v;let s=!1;const c={phase:"loading",last:void 0,uncommitted:void 0,error:void 0,isComplete:!1,fetch:n,isStartingFollow:!1,stop:()=>{s||(s=!0,o.unsubscribe(),u(),Ve.get(e)===c&&Ve.delete(e))}},a=e=>{o.unsubscribe(),c.error={value:e},"resolved"===c.phase||c.isStartingFollow||(c.fetch?.reject(e),c.stop())},i=()=>{c.phase="live",c.fetch=void 0,c.uncommitted&&(e.setData(c.uncommitted.value,{manual:!0}),c.uncommitted=void 0),c.isComplete&&!c.error?c.stop():c.error||e.isActive()?(c.isStartingFollow=!0,e.fetch().catch(()=>{}),c.isStartingFollow&&e.promise?.catch(()=>{c.isStartingFollow&&c.stop()})):c.stop()},u=t.subscribe(t=>{t.query===e&&("updated"!==t.type||"resolved"!==c.phase||"success"!==t.action.type||t.action.manual||i(),("observerOptionsUpdated"===t.type||"observerRemoved"===t.type)&&"live"===c.phase&&e.getObserversCount()>0&&!e.isActive()&&(e.cancel({revert:!0}),c.stop()),("observerRemoved"===t.type&&!c.fetch&&0===e.getObserversCount()||"removed"===t.type)&&c.stop())});Ve.set(e,c),o.add(r.subscribe({next:t=>{if(void 0!==t){if(c.last={value:t},"loading"===c.phase)return c.phase="resolved",void c.fetch?.resolve(t);e.setData(t,{manual:!0}),"resolved"===c.phase&&(c.uncommitted={value:t})}else a(/* @__PURE__ */new Error(`${JSON.stringify(e.queryKey)} data is undefined`))},error:a,complete:()=>{c.isComplete=!0,"resolved"===c.phase||c.isStartingFollow||(c.last?c.fetch?.resolve(c.last.value):(console.warn(`cancelled due to stream completing without data for query ${JSON.stringify(e.queryKey)}`),c.fetch?.reject(new L)),c.stop())}}))}(s,o,c,a));const u=Ve.get(s);u?.fetch===a&&function(e,t,r){r.addEventListener("abort",()=>{e.fetch===t&&(t.reject(new L),e.stop())},{once:!0})}(u,a,t.signal)})}function Ee(t,r){const n=e(9);let o,s,c;n[0]!==t?(({queries:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=s.map(je),n[3]=s,n[4]=c):c=n[4];const a=c,i=o.combine;let u;return n[5]!==o.subscribed||n[6]!==a||n[7]!==i?(u={queries:a,combine:i,subscribed:o.subscribed},n[5]=o.subscribed,n[6]=a,n[7]=i,n[8]=u):u=n[8],z(u,r)}function je(e){return{...e,queryFn:Oe(e.queryFn)}}function Ae(t,r){const n=e(8);let o,s,c;n[0]!==t?(({queries:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=s.map(Fe),n[3]=s,n[4]=c):c=n[4];const a=c;let i;return n[5]!==o||n[6]!==a?(i={...o,queries:a},n[5]=o,n[6]=a,n[7]=i):i=n[7],Ee(i,r)}function Fe(e){return{...e,...xe}}function ke(t,r){const n=e(8);let o,s,c,a;return n[0]!==t?(({queryFn:s,...o}=t),n[0]=t,n[1]=o,n[2]=s):(o=n[1],s=n[2]),n[3]!==s?(c=Oe(s),n[3]=s,n[4]=c):c=n[4],n[5]!==o||n[6]!==c?(a={...o,queryFn:c},n[5]=o,n[6]=c,n[7]=a):a=n[7],G(a,r)}function De(t,r){const n=e(2);let o;return n[0]!==t?(o={...t,...xe},n[0]=t,n[1]=o):o=n[1],ke(o,r)}function _e(e,t){return"function"==typeof e?e(t):e}function qe(t,r){const n=e(16),o=Z(Ce);let c,a;n[0]!==t?(c=e=>{let r;return new Promise((n,o)=>{_e(t.mutationFn,e).pipe(C(1)).subscribe({next:e=>{r={value:e}},error:e=>{o(e)},complete:()=>{if(void 0===r)return o(/* @__PURE__ */new Error("Stream completed without any data"));n(r.value)}})})},n[0]=t,n[1]=c):c=n[1],n[2]!==t||n[3]!==c?(a={...t,mutationFn:c},n[2]=t,n[3]=c,n[4]=a):a=n[4];const i=Y(a,r),{status:u,isPending:l,isError:f,isSuccess:p,isIdle:d}=i;let v,g,y;return n[5]!==f||n[6]!==d||n[7]!==l||n[8]!==p||n[9]!==o||n[10]!==u?(v=()=>{o.next({status:u,isPending:l,isError:f,isSuccess:p,isIdle:d})},g=[u,l,f,p,d,o],n[5]=f,n[6]=d,n[7]=l,n[8]=p,n[9]=o,n[10]=u,n[11]=v,n[12]=g):(v=n[11],g=n[12]),s(v,g),n[13]!==i||n[14]!==o?(y={...i,state$:o},n[13]=i,n[14]=o,n[15]=y):y=n[15],y}function Ce(){return new l({status:"idle",isPending:!1,isError:!1,isSuccess:!1,isIdle:!0})}var Ne=class extends Error{constructor(e="Mutation canceled"){super(e),this.name="SwitchMutationCancelError"}};function Te(t,r){const n=e(20),{mutationFn:o,...s}=t,c=X(Pe),a=Q(r);let i;n[0]!==o?(i=e=>{const{variables:t,abort:r}=e;if(r.aborted)throw new Ne;const n=_e(o,t);return j(n.pipe(m(null)),x(r,"abort").pipe(N($e),V())).pipe(S())},n[0]=o,n[1]=i):i=n[1];const u=i,l=function(e,t){const{onMutate:r,onSuccess:n,onError:o,onSettled:s,retry:c}=e.defaultMutationOptions(t);return{onMutate:r&&(({variables:e},...t)=>r(e,...t)),onSuccess:n&&((e,{variables:t},...r)=>n(e,t,...r)),onError:o&&((e,{variables:t},...r)=>o(e,t,...r)),onSettled:s&&((e,t,{variables:r},...n)=>s(e,t,r,...n)),retry:(e,t)=>!(t instanceof Ne)&&we(c,e,t)}}(a,s);let f;n[2]!==s||n[3]!==u||n[4]!==l?(f={...s,mutationFn:u,...l},n[2]=s,n[3]=u,n[4]=l,n[5]=f):f=n[5];const p=qe(f,a);let d,v,g,y;n[6]!==p?(({mutate:d,mutateAsync:v,...g}=p),n[6]=p,n[7]=d,n[8]=v,n[9]=g):(d=n[7],v=n[8],g=n[9]),n[10]!==d||n[11]!==c?(y=e=>(c.current.abort(),c.current=new AbortController,d({variables:e,abort:c.current.signal})),n[10]=d,n[11]=c,n[12]=y):y=n[12];const b=y;let h;n[13]!==v||n[14]!==c?(h=e=>(c.current.abort(),c.current=new AbortController,v({variables:e,abort:c.current.signal})),n[13]=v,n[14]=c,n[15]=h):h=n[15];const w=h;let I;return n[16]!==w||n[17]!==b||n[18]!==g?(I={...g,mutate:b,mutateAsync:w},n[16]=w,n[17]=b,n[18]=g,n[19]=I):I=n[19],I}function $e(){throw new Ne}function Pe(){return new AbortController}var Me=Symbol("SIGNAL_RESET"),He=e=>{if(e)try{return JSON.parse(e)}catch{return}},Je=e=>({getItem:async t=>He(await e.getItem(t)),setItem:async(t,r)=>{await e.setItem(t,JSON.stringify(r))},removeItem:async e=>{},clear:async()=>{}}),Ke=e=>{const t=He(localStorage.getItem(e));return"object"==typeof(r=t)&&null!==r?t:{};var r},Ue=(e,t)=>{localStorage.setItem(e,JSON.stringify(t))},Le=({key:e}={})=>e?(e=>({clear:async()=>{localStorage.removeItem(e)},removeItem:async t=>{const{[t]:r,...n}=Ke(e);Ue(e,n)},getItem:async t=>{const r=Ke(e);return Object.hasOwn(r,t)?r[t]:void 0},setItem:async(t,r)=>{Ue(e,{...Ke(e),[t]:r})}}))(e):{clear:async()=>{localStorage.clear()},removeItem:async e=>{localStorage.removeItem(e)},getItem:async e=>He(localStorage.getItem(e)),setItem:async(e,t)=>{localStorage.setItem(e,JSON.stringify(t))}},Re=class extends l{config;constructor(e){super(e.default),this.config=e}update=e=>{if(e===Me)super.next(this.config.default);else if("function"==typeof e){const t=e;super.next(t(this.value))}else super.next(e)};get key(){return this.config.key}},Ye=class{config;constructor(e){this.config=e}};function ze(e={}){return new Re({key:void 0,default:void 0,...e})}function Ge(e){return new Ye(e)}var Qe=class{signals=new l(/* @__PURE__ */new Map);isDestroyed=!1;getOrCreateSignal(e){const t=this.signals.value.get(e);if(t)return t;const r=new Re({...e.config,key:void 0});return this.signals.value.set(e,r),this.signals.next(this.signals.value),r}destroy(){this.signals.value.forEach(e=>{e.complete()}),this.signals.value.clear(),this.signals.complete(),this.isDestroyed=!0}},We=t(new Qe),Be=r(({children:e})=>{const t=X(()=>new Qe),r=t.current,[n,o]=i(!1);n&&(t.current=new Qe,o(!1));const c=r;return s(()=>()=>{t.current?.destroy(),o(!0)},[t]),/* @__PURE__ */W(We.Provider,{value:c,children:e})}),Xe=()=>o(We),Ze=t=>{const r=e(3),n=Xe();let o;return r[0]!==n||r[1]!==t?(o=t?n.getOrCreateSignal(t):void 0,r[0]=n,r[1]=t,r[2]=o):o=r[2],o},et="__reactjrx";var tt=({adapter:e,entry:t,resetToDefault:r,onHydrated:n})=>{const{signal:o}=t.config;let s;const c=()=>(s=o.getValue(),(({adapter:e,config:t})=>{const{signal:r,version:n}=t,o={value:r.getValue(),[et]:et,migrationVersion:n};return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Persist value",o,`for signal ${r.config.key}`),I(e.setItem(r.config.key,o)).pipe(y(e=>(console.error(e),A(null))))})({adapter:e,config:t.config}));return function({adapter:e,config:t,resetToDefault:r=!1}){const{hydrate:n=({value:e})=>e,signal:o,version:s}=t,c=e=>(r&&o.update(Me),A(e));return I(e.getItem(o.config.key)).pipe(q(e=>{const t=(e=>{if("object"==typeof e&&null!==e&&"__reactjrx"in e&&"__reactjrx"===e.__reactjrx)return e})(e);if(!t)return c(e);const r="number"!=typeof t.migrationVersion,a=void 0!==t.migrationVersion&&s>t.migrationVersion;if(r||a||void 0===t.value)return c(e);const i=t.value;return"development"===process.env.NODE_ENV&&console.log("[reactjrx][state][persistance]:","Hydrate value",t,`for signal ${o.config.key}`),o.next(n({value:i,version:s})),A(e)}))}({adapter:e,config:t.config,resetToDefault:r}).pipe(y(e=>(console.error(`Unable to hydrate signal ${o.config.key}`,e),f)),N(n),q(()=>o.pipe(T(500,g,{trailing:!0}),q(()=>c()),w(()=>{o.getValue()!==s&&c().subscribe()}))))};function rt({entries:e=[],onHydrated:t,adapter:r}){const n=ue(t),o=ee(r),s=ee(e);return me(()=>o.pipe(k((e,t)=>{const r=e.firstAdapter??t;return{adapter:t,firstAdapter:r,replacesAnother:e.replacesAnother||!!t&&t!==r}},{adapter:void 0,firstAdapter:void 0,replacesAnother:!1}),q(({adapter:e,replacesAnother:t})=>e?j(A({type:"reset"}),function({entries$:e,onHydrated:t,adapter:r,resetToDefault:n=!1}){return new d(o=>{const s=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set;let a=!1,i=!1;const u=()=>{i||a||c.size>0||(i=!0,t?.(),o.next({type:"hydrated"}))},l=e=>{const t={config:e,subscription:new v};s.set(e.signal,t),c.add(e.signal),t.subscription.add(tt({adapter:r,entry:t,resetToDefault:n,onHydrated:()=>{c.delete(e.signal),u()}}).subscribe())},f=e=>{const t=s.get(e);t&&(s.delete(e),c.delete(e),t.subscription.unsubscribe())},p=e.subscribe({next:e=>{a=!0;const t=new Set(e.map(({signal:e})=>e));for(const r of[...s.keys()])t.has(r)||f(r);for(const r of e){const e=s.get(r.signal);e?e.config=r:l(r)}a=!1,u()},error:e=>o.error(e)});return()=>{p.unsubscribe();for(const e of[...s.keys()])f(e)}})}({adapter:e,entries$:s,resetToDefault:t,onHydrated:()=>{n.current?.()}})):A({type:"reset"})),E(e=>({isHydrated:"hydrated"===e.type}))),{defaultValue:{isHydrated:!1},compareFn:ge},[o,s]).data}function nt(t){const r=e(3),n=Xe();if(t instanceof Ye&&!n)throw new Error("useSignalValue must be used within a SignalContextProvider");let o;return r[0]!==t||r[1]!==n?(o=t instanceof Ye?n.getOrCreateSignal(t):t,r[0]=t,r[1]=n,r[2]=o):o=r[2],o}function ot(e){return nt(e).update}var st=Object.is;function ct(t,r,n){const o=e(7),s=void 0===n?st:n,c=nt(t);let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i={hasValue:!1,signal:void 0,selector:void 0,sourceValue:void 0,value:void 0},o[0]=i):i=o[0];const l=a(i);let f;o[1]!==c?(f=e=>{const t=c.pipe(_(1)).subscribe(()=>{e()});return()=>{t.unsubscribe()}},o[1]=c,o[2]=f):f=o[2];const p=f;let d;o[3]!==s||o[4]!==c||o[5]!==r?(d=()=>{const e=l.current,t=c.value;if(e.hasValue&&e.signal===c&&e.selector===r&&e.sourceValue===t)return e.value;const n=r?r(t):t;return e.hasValue&&e.signal===c&&s(e.value,n)?(l.current={hasValue:!0,signal:c,selector:r,sourceValue:t,value:e.value},e.value):(l.current={hasValue:!0,signal:c,selector:r,sourceValue:t,value:n},n)},o[3]=s,o[4]=c,o[5]=r,o[6]=d):d=o[6];return u(p,d,d)}function at(t){const r=e(4),n=nt(t),o=ct(n),s=ot(n);let c;return r[0]!==n||r[1]!==s||r[2]!==o?(c=[o,s,n],r[0]=n,r[1]=s,r[2]=o,r[3]=c):c=r[3],c}var it=t=>{const r=e(3),n=Z(t),o=ct(n);let s;return r[0]!==n||r[1]!==o?(s=[o,n],r[0]=n,r[1]=o,r[2]=s):s=r[2],s};export{Me as SIGNAL_RESET,Re as Signal,Be as SignalContextProvider,We as SignalReactContext,Ne as SwitchMutationCancelError,Ye as VirtualSignal,re as arrayEqual,Le as createLocalStorageAdapter,Je as createLocalforageAdapter,ae as exponentialBackoffDelay,ce as getDelay,ne as isDefined,oe as isPromiseLike,se as isServer,ge as isShallowEqual,ie as retryBackoff,ze as signal,Z as useConstant,le as useDebounced,fe as useEffectOnce,ee as useLiveBehaviorSubject,Ae as useLiveQueries$,De as useLiveQuery$,ue as useLiveRef,Ze as useMakeOrRetrieveSignal,pe as useMemoCompare,de as useMount,qe as useMutation$,te as useObservableState,me as useObserve,rt as usePersistSignals,Ee as useQueries$,ke as useQuery$,X as useRefOnce,ot as useSetSignal,at as useSignal,Xe as useSignalContext,it as useSignalState,ct as useSignalValue,he as useSubscribe,Ie as useSubscribeEffect,Te as useSwitchMutation$,ve as useUnmount,Ge as virtualSignal};
2
2
  //# sourceMappingURL=index.js.map