@fluixi/reactive 1.0.0-alpha.78 → 1.0.0-alpha.80

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.
@@ -1 +1 @@
1
- "use strict";var Me=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var zn=Object.prototype.hasOwnProperty;var Hn=(e,n)=>{for(var t in n)Me(e,t,{get:n[t],enumerable:!0})},Yn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Wn(n))!zn.call(e,r)&&r!==t&&Me(e,r,{get:()=>n[r],enumerable:!(o=$n(n,r))||o.enumerable});return e};var Jn=e=>Yn(Me({},"__esModule",{value:!0}),e);var or={};Hn(or,{$MEMO:()=>Fn,$PROXY:()=>Ze,$RESOURCE:()=>Un,$SIGNAL:()=>De,__DEV__:()=>pe,batch:()=>k,clearAllCachedResources:()=>er,clearCachedResourceNamespace:()=>Zt,combineSignal:()=>It,combineSignals:()=>Nt,createCachedResource:()=>Qt,createComputed:()=>gt,createContext:()=>on,createDebounce:()=>Rn,createDeferred:()=>On,createEffect:()=>ne,createMemo:()=>ht,createProvider:()=>Bn,createRenderEffect:()=>Vn,createResource:()=>yt,createRoot:()=>vt,createSelector:()=>gn,createSignal:()=>U,debounceSignal:()=>Wt,distinctSignal:()=>Mt,everySignal:()=>Dt,filterSignal:()=>kt,findSignal:()=>Ft,flush:()=>xt,getOwner:()=>bt,getServerData:()=>Ye,getSharedConfig:()=>dt,getSuspenseContext:()=>sn,getSuspenseListContext:()=>Ot,guardSignal:()=>$t,indexArray:()=>rr,isComponent:()=>fn,isMemo:()=>cn,isProvider:()=>pn,isResource:()=>ln,isSignal:()=>ge,isSuspense:()=>dn,keyArray:()=>tr,makeArrayFlat:()=>Le,mapArray:()=>nr,mapSignal:()=>Et,mergeSignal:()=>Lt,nextResourceId:()=>Je,omitSignal:()=>Gt,on:()=>wt,onCleanup:()=>me,onResolve:()=>At,pickSignal:()=>Vt,readChildren:()=>Ke,readSignal:()=>Ht,reduceSignal:()=>Pt,reportResourceData:()=>Xe,resumeEffects:()=>Rt,runWithOwner:()=>mt,selectSignal:()=>jt,setOwner:()=>ft,setResourceDataSink:()=>En,setResourceIdSource:()=>_n,setResourceTracker:()=>An,setScheduler:()=>Ct,setServerDataGetter:()=>Cn,sharedConfig:()=>Ue,someSignal:()=>Ut,sortSignal:()=>qt,startTransition:()=>jn,throttleSignal:()=>zt,trackPromise:()=>_t,trackResourcePromise:()=>ye,untrack:()=>L,useContext:()=>I,useTransition:()=>St,whenSignal:()=>Kt,zipSignal:()=>Bt});module.exports=Jn(or);function Ie(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function an(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var de=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(Ie(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(an(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(Ie(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var we=class extends de{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ne=class extends we{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends de{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof we?r=n:r=new Ne(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var pe=!1,Xn=Symbol.for("signal"),Qn=Symbol.for("memo"),Zn=Symbol.for("resource");function ge(e){return typeof e=="function"&&e[Xn]===!0}function cn(e){return typeof e=="function"&&e[Qn]===!0}function ln(e){return typeof e=="function"&&e[Zn]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function pn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Le(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Le(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var et="__fluixi_signal_next_state__",nt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[et]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:nt,onSuspend:null,onError:null};var Tn=0,hn=1,Te=2,Oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},Re=class extends Oe{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(Te);Be(this)}}peek(){return this._value}},ue=class extends Oe{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=Te;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===hn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===Te)break}(this.state===Te||!this._initialized)&&this.recompute(),this.state=Tn}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(Te);Be(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Tn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(hn);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var Ae=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function vn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function yn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function bn(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function Ve(){return c.owner}function _e(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Ce(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ce(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function he(e){let n=yn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Ce(n))}finally{c.owner=t}}function mn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function tt(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ge)))}function Ge(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function xn(){c.batchDepth===0&&Ge()}var je=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=yn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ue(()=>{Ce(this.owner,!1),_e(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new Ae(()=>tt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ce(this.owner))}};function Sn(e){let n=new je(e);return()=>n.dispose()}function rt(e){return!!e&&typeof e.then=="function"}mn(()=>{});var wn=Symbol.for("signal"),ot=Symbol.for("memo"),st=Symbol.for("signal-node");function N(e,n){let t=new Re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),xn(),u});return Object.defineProperty(o,wn,{value:!0,enumerable:!0}),Object.defineProperty(o,st,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=Ve(),s=new ue(()=>_e(r,()=>{try{return o=e(o)}catch(a){if(rt(a))return bn(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,wn,{value:!0,enumerable:!0}),Object.defineProperty(u,ot,{value:!0,enumerable:!0}),u}function ve(e,n){let t=n;return Sn(()=>{t=e(t)})}function Ee(e){return vn(e)}function gn(e,n=(t,o)=>t===o){let t=new Map;return ve(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=N(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function On(e,n){let[t,o]=N(e(),n);return ve(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Rn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function ke(e){if(typeof e=="function"&&!e.length){let n=e();return ge(n)?n:ke(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ke(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ke(e){let n=x(e);return x(()=>ke(n()))}var $e=null;function An(e){$e=e}function ye(e){$e&&$e(e)}var We=null;function Cn(e){We=e}function Ye(e){return We?We(e):void 0}var ze=null;function _n(e){ze=e}function Je(){return ze?ze():void 0}var He=null;function En(e){He=e}function Xe(e,n){He&&He(e,n)}var De=Symbol.for("signal"),Fn=Symbol.for("memo"),Un=Symbol.for("resource"),Ze=Symbol("fluixi-proxy"),Dn=Symbol.for("signal-node"),K=0,be=1,W=2,$=3,f=null,v=null,l=null,Pe=null,Fe=0,it=!1,Qe=!1,ae=0,ut=1e6,F=new WeakMap,M=null;var at=null,ct=new Map,lt=0,Ue={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function ft(e){f=e,Ue.owner=e,Ue.context=e}function dt(){return Ue}function pt(){return`node_${++lt}_${Date.now()}`}function Tt(e){!1}function qn(e,n,t){let o={id:pt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Tt(o),o}function Mn(e,n){return e===n}function tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var en=null,nn=null;function In(){if(!en){let[e,n]=U(!1);en=e,nn=n}}function Nn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)xe(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;qe(o),l=r}}}function kn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function U(e,n){let t=e;typeof t=="object"&&t&&Ze in t&&delete t[Ze];let o=qn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];F.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=F.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||Mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=F.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===$&&p===v)){if(b&&!p.pure){C===K&&(p.state=be,it&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=W,C===K||C===be?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let P=F.get(p.accessor);P&&kn(Array.from(P),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;kn(S,E);for(let p of g)Nn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ne(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,De,{value:!0,enumerable:!0}),Object.defineProperty(u,Dn,{value:o,enumerable:!1}),r}function ne(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),rn(o,n),()=>J(o)}function rn(e,n){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,Fe++,Fe>ut)throw Fe=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=$;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=t,f=o}}function xe(e){if(!(e.disposed||!e.fn||e.state===K)&&(e.state===W||e.state===be||e.state===$)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)J(e.owned[n]);e.owned=null}e.renderEffect?Gn(e):rn(e,e.value)}}function J(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=F.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)J(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function ht(e,n,t){let o=qn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;F.has(a)||F.set(a,new Set);let i=F.get(a);i&&i.add(v)}if(r.state!==K){if(r.sources){for(let d of r.sources){let y=F.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)J(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=$;try{let d=r.fn(r.value),y=o.equals||Mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=F.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let P=b.state;if(P!==$){if(C&&!b.pure){P===K&&(b.state=be,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=W,P===K||P===be?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=F.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Nn(b)}}r.state===$&&(r.state=K)}catch(d){if(fe(d)){let y=O&&I(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}tn(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,F.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ne(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,De,{value:!0,enumerable:!0}),Object.defineProperty(s,Fn,{value:!0,enumerable:!0}),Object.defineProperty(s,Dn,{value:o,enumerable:!1}),s}function qe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=F.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&xe(r)}function k(e){if(l&&ae>0)return e();if(l&&ae===0){let n=l,t=[];l=t,ae++;let o;try{o=e()}finally{ae--,l=n}let r=l;return qe(t),l=r,o}ae++,l=[],Pe=[];try{return e()}finally{ae--,Ln()}}function Ln(){if(!Qe){Qe=!0,Fe=0;try{for(;l&&l.length>0;){let e=l;l=null,qe(e)}if(l=null,Pe){let e=Pe;Pe=null;for(let n=0;n<e.length;n++)xe(e[n])}}finally{Qe=!1}}}function vt(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)J(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function L(e){let n=v;v=null;try{return e()}finally{v=n}}function me(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function yt(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:Je(),i=a!==void 0?Ye(a):void 0,d=i!==void 0,[y,T]=U(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=U(void 0,{equals:!1}),[g,m]=U(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),P=Symbol(),_=P,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(B){console.error(`Failed to save resource to cache (${u}):`,B)}},ce=ne(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=P,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let B=z;if(z=!1,_!==P&&A===_&&!B)return;if(_=A,d){d=!1;return}let j=!1;me(()=>j=!0);let le=L(g),oe=L(y),Q=le==="ready"||le==="refreshing";k(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let V=r(A,{value:oe,refetching:Q});if(fe(V)){p(V),ye(V),V.then(h=>{j||(a!==void 0&&Xe(a,h),k(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{j||k(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{j||k(()=>{S(h),m("errored"),p(void 0)})});let Se=O&&I(O);Se&&(Se.increment(),V.finally(()=>Se.decrement()))}else{if(j)return;k(()=>{T(()=>V),m("ready"),p(void 0)})}}catch(V){if(j)return;k(()=>{S(V),m("errored"),p(void 0)})}});me(ce);let X=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(X()){let B=E();if(B)throw B}return y()});return Object.defineProperty(Y,Un,{value:!0,enumerable:!0}),Object.defineProperty(Y,De,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>X()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function bt(){return f}function mt(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function on(e){let n=Symbol("context"),t=Bn(n);return{id:n,Provider:t,defaultValue:e}}function Bn(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Vn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ke(()=>n.children)})}),o}}function I(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function xt(){return new Promise(e=>{queueMicrotask(()=>{Ln(),e()})})}function jn(e){if(M&&M.running)return e(),M.done;In();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(nn(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,nn(!1),r.length&&k(()=>{for(let s of r)s.state=W,xe(s)}),n()}),t):(M=null,n(),t)}function St(){return In(),[en,jn]}function wt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):L(()=>n(u,s))}}function Vn(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),Gn(o),()=>J(o)}function Gn(e){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=$;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;qe(r),l=s}}}function gt(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):rn(o,n)}var O;function sn(){return O||(O=on())}var Pn;function Ot(){return Pn||(Pn=on())}function Rt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=W,xe(t)}function At(e){let n=O&&I(O);n&&n.inFallback()?ne(()=>{n.inFallback()||e()}):e()}function Ct(e){at=e}function _t(e){let n=O&&I(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function Et(e,n,t){return x(()=>n(e()),void 0,t)}function kt(e,n,t){return x(()=>e().filter(n),void 0,t)}function Pt(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function Ft(e,n,t){return x(()=>e().find(n),void 0,t)}function Ut(e,n,t){return x(()=>e().some(n),void 0,t)}function Dt(e,n,t){return x(()=>e().every(n),void 0,t)}function qt(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function Mt(e,n){return x(()=>[...new Set(e())],void 0,n)}function It(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function Nt(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):ve(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function Lt(e,n,t){return x(()=>e()||n(),void 0,t)}function Bt(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function jt(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function Vt(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function Gt(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function Kt(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function $t(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function Wt(e,n,t){let[o,r]=N(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function zt(e,n,t){let[o,r]=N(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Ht(e){let n=e;for(;typeof n=="function";)n=n();return n}var re=new Map,te=new Map,Yt=0,Jt=Symbol.for("signal"),Xt=Symbol.for("resource");function Qt(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${Yt++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=U(void 0,{equals:!1}),[g,m]=U("unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),[P,_]=U(!1),[z,H]=U(0,{equals:!1}),ce=Symbol("unset"),X=ce,Y=!1,A=!1;function B(h,D,q,G){if(te.has(D)){te.get(D).then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)}),q||C(te.get(D));return}let se=Promise.resolve(r(h)).then(R=>(re.set(D,{value:R,timestamp:Date.now()}),te.delete(D),R),R=>{throw te.delete(D),R});if(te.set(D,se),!q){ye(se),C(se);let R=oe&&I(oe);R&&(R.increment(),se.finally(()=>R.decrement()))}se.then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)})}function j(h,D){k(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){k(()=>{p(h),m("errored"),C(void 0)})}let oe;ne(()=>{oe===void 0&&(oe=sn());let h=o();if(z(),h===!1||h===null||h===void 0){X=ce,k(()=>{m("unresolved"),C(void 0),p(void 0)});return}let D=Y,q=A;Y=!1,A=!1;let G=y(h);q&&re.delete(G);let se=X===ce||h!==X;X=h;let R=!1;me(()=>{R=!0});let ie=re.get(G);if(ie&&T(ie)&&!D&&!q){(L(g)!=="ready"||L(w)!==ie.value)&&k(()=>{S(()=>ie.value),m("ready"),_(!1),p(void 0)});return}if(ie&&i&&!q){k(()=>{S(()=>ie.value),m("ready"),_(!0),p(void 0),C(void 0)}),B(h,G,!0,()=>R);return}let un=L(g),Kn=un==="ready"||un==="refreshing";k(()=>{m(Kn?"refreshing":"pending"),p(void 0),_(!1)}),B(h,G,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let q=b();if(q)throw q}return w()});return Object.defineProperty(Q,Xt,{value:!0,enumerable:!0}),Object.defineProperty(Q,Jt,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:P}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=L(o);h!=null&&h!==!1&&re.delete(y(h)),A=!0,H(D=>D+1)}}]}function Zt(e){let n=`${e}:`;for(let t of re.keys())t.startsWith(n)&&re.delete(t)}function er(){re.clear(),te.clear()}function nr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;he(m=>{S=m;let[E,p]=N(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function tr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ee(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;he(p=>{E=p;let[b,C]=N(T);m=C;let P=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(P,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function rr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];he(S=>{T=S;let[g,m]=N(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}
1
+ "use strict";var Me=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var zn=Object.prototype.hasOwnProperty;var Hn=(e,n)=>{for(var t in n)Me(e,t,{get:n[t],enumerable:!0})},Yn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Wn(n))!zn.call(e,r)&&r!==t&&Me(e,r,{get:()=>n[r],enumerable:!(o=$n(n,r))||o.enumerable});return e};var Xn=e=>Yn(Me({},"__esModule",{value:!0}),e);var sr={};Hn(sr,{$MEMO:()=>Fn,$PROXY:()=>Ze,$RESOURCE:()=>Un,$SIGNAL:()=>De,__DEV__:()=>pe,batch:()=>k,clearAllCachedResources:()=>nr,clearCachedResourceNamespace:()=>er,combineSignal:()=>Nt,combineSignals:()=>Lt,createCachedResource:()=>Zt,createComputed:()=>Ot,createContext:()=>on,createDebounce:()=>Rn,createDeferred:()=>On,createEffect:()=>ne,createMemo:()=>vt,createProvider:()=>Bn,createRenderEffect:()=>Vn,createResource:()=>bt,createRoot:()=>yt,createSelector:()=>gn,createSignal:()=>U,debounceSignal:()=>zt,distinctSignal:()=>It,everySignal:()=>qt,filterSignal:()=>Pt,findSignal:()=>Ut,flush:()=>St,getOwner:()=>mt,getServerData:()=>Ye,getSharedConfig:()=>pt,getSuspenseContext:()=>sn,getSuspenseListContext:()=>Rt,guardSignal:()=>Wt,indexArray:()=>or,isComponent:()=>fn,isMemo:()=>cn,isProvider:()=>pn,isResource:()=>ln,isSignal:()=>ge,isSuspense:()=>dn,keyArray:()=>rr,makeArrayFlat:()=>Le,mapArray:()=>tr,mapSignal:()=>kt,mergeSignal:()=>Bt,nextResourceId:()=>Xe,omitSignal:()=>Kt,on:()=>gt,onCleanup:()=>me,onResolve:()=>Ct,pickSignal:()=>Gt,readChildren:()=>Ke,readSignal:()=>Yt,reduceSignal:()=>Ft,reportResourceData:()=>Je,resumeEffects:()=>At,runWithOwner:()=>xt,selectSignal:()=>Vt,setOwner:()=>dt,setResourceDataSink:()=>En,setResourceIdSource:()=>_n,setResourceTracker:()=>An,setScheduler:()=>_t,setServerDataGetter:()=>Cn,sharedConfig:()=>Ue,someSignal:()=>Dt,sortSignal:()=>Mt,startTransition:()=>jn,throttleSignal:()=>Ht,trackPromise:()=>Et,trackResourcePromise:()=>ye,untrack:()=>L,useContext:()=>I,useTransition:()=>wt,whenSignal:()=>$t,zipSignal:()=>jt});module.exports=Xn(sr);function Ie(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function an(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var de=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(Ie(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(an(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(Ie(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var we=class extends de{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ne=class extends we{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends de{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof we?r=n:r=new Ne(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var Jn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,pe=typeof process>"u"?Jn:!1,Qn=Symbol.for("signal"),Zn=Symbol.for("memo"),et=Symbol.for("resource");function ge(e){return typeof e=="function"&&e[Qn]===!0}function cn(e){return typeof e=="function"&&e[Zn]===!0}function ln(e){return typeof e=="function"&&e[et]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function pn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Le(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Le(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt="__fluixi_signal_next_state__",tt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[nt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:tt,onSuspend:null,onError:null};var Tn=0,hn=1,Te=2,Oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},Re=class extends Oe{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(Te);Be(this)}}peek(){return this._value}},ue=class extends Oe{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=Te;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===hn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===Te)break}(this.state===Te||!this._initialized)&&this.recompute(),this.state=Tn}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(Te);Be(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Tn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(hn);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var Ae=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function vn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function yn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function bn(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function Ve(){return c.owner}function _e(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Ce(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ce(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function he(e){let n=yn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Ce(n))}finally{c.owner=t}}function mn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function rt(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ge)))}function Ge(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function xn(){c.batchDepth===0&&Ge()}var je=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=yn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ue(()=>{Ce(this.owner,!1),_e(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new Ae(()=>rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ce(this.owner))}};function Sn(e){let n=new je(e);return()=>n.dispose()}function ot(e){return!!e&&typeof e.then=="function"}mn(()=>{});var wn=Symbol.for("signal"),st=Symbol.for("memo"),it=Symbol.for("signal-node");function N(e,n){let t=new Re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),xn(),u});return Object.defineProperty(o,wn,{value:!0,enumerable:!0}),Object.defineProperty(o,it,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=Ve(),s=new ue(()=>_e(r,()=>{try{return o=e(o)}catch(a){if(ot(a))return bn(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,wn,{value:!0,enumerable:!0}),Object.defineProperty(u,st,{value:!0,enumerable:!0}),u}function ve(e,n){let t=n;return Sn(()=>{t=e(t)})}function Ee(e){return vn(e)}function gn(e,n=(t,o)=>t===o){let t=new Map;return ve(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=N(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function On(e,n){let[t,o]=N(e(),n);return ve(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Rn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function ke(e){if(typeof e=="function"&&!e.length){let n=e();return ge(n)?n:ke(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ke(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ke(e){let n=x(e);return pe?x(()=>ke(n()),void 0,{name:"children"}):x(()=>ke(n()))}var $e=null;function An(e){$e=e}function ye(e){$e&&$e(e)}var We=null;function Cn(e){We=e}function Ye(e){return We?We(e):void 0}var ze=null;function _n(e){ze=e}function Xe(){return ze?ze():void 0}var He=null;function En(e){He=e}function Je(e,n){He&&He(e,n)}var De=Symbol.for("signal"),Fn=Symbol.for("memo"),Un=Symbol.for("resource"),Ze=Symbol("fluixi-proxy"),Dn=Symbol.for("signal-node"),K=0,be=1,W=2,$=3,f=null,v=null,l=null,Pe=null,Fe=0,ut=!1,Qe=!1,ae=0,at=1e6,F=new WeakMap,M=null;var ct=null,lt=new Map,ft=0,Ue={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function dt(e){f=e,Ue.owner=e,Ue.context=e}function pt(){return Ue}function Tt(){return`node_${++ft}_${Date.now()}`}function ht(e){pe&&lt.set(e.id,new WeakRef(e))}function qn(e,n,t){let o={id:Tt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return ht(o),o}function Mn(e,n){return e===n}function tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var en=null,nn=null;function In(){if(!en){let[e,n]=U(!1);en=e,nn=n}}function Nn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)xe(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;qe(o),l=r}}}function kn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function U(e,n){let t=e;typeof t=="object"&&t&&Ze in t&&delete t[Ze];let o=qn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];F.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=F.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||Mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=F.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===$&&p===v)){if(b&&!p.pure){C===K&&(p.state=be,ut&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=W,C===K||C===be?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let P=F.get(p.accessor);P&&kn(Array.from(P),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;kn(S,E);for(let p of g)Nn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ne(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,De,{value:!0,enumerable:!0}),Object.defineProperty(u,Dn,{value:o,enumerable:!1}),r}function ne(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),rn(o,n),()=>X(o)}function rn(e,n){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)X(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,Fe++,Fe>at)throw Fe=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=$;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=t,f=o}}function xe(e){if(!(e.disposed||!e.fn||e.state===K)&&(e.state===W||e.state===be||e.state===$)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)X(e.owned[n]);e.owned=null}e.renderEffect?Gn(e):rn(e,e.value)}}function X(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=F.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)X(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function vt(e,n,t){let o=qn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;F.has(a)||F.set(a,new Set);let i=F.get(a);i&&i.add(v)}if(r.state!==K){if(r.sources){for(let d of r.sources){let y=F.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)X(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=$;try{let d=r.fn(r.value),y=o.equals||Mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=F.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let P=b.state;if(P!==$){if(C&&!b.pure){P===K&&(b.state=be,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=W,P===K||P===be?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=F.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Nn(b)}}r.state===$&&(r.state=K)}catch(d){if(fe(d)){let y=O&&I(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}tn(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,F.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ne(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,De,{value:!0,enumerable:!0}),Object.defineProperty(s,Fn,{value:!0,enumerable:!0}),Object.defineProperty(s,Dn,{value:o,enumerable:!1}),s}function qe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=F.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&xe(r)}function k(e){if(l&&ae>0)return e();if(l&&ae===0){let n=l,t=[];l=t,ae++;let o;try{o=e()}finally{ae--,l=n}let r=l;return qe(t),l=r,o}ae++,l=[],Pe=[];try{return e()}finally{ae--,Ln()}}function Ln(){if(!Qe){Qe=!0,Fe=0;try{for(;l&&l.length>0;){let e=l;l=null,qe(e)}if(l=null,Pe){let e=Pe;Pe=null;for(let n=0;n<e.length;n++)xe(e[n])}}finally{Qe=!1}}}function yt(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)X(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function L(e){let n=v;v=null;try{return e()}finally{v=n}}function me(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function bt(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:Xe(),i=a!==void 0?Ye(a):void 0,d=i!==void 0,[y,T]=U(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=U(void 0,{equals:!1}),[g,m]=U(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),P=Symbol(),_=P,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(B){console.error(`Failed to save resource to cache (${u}):`,B)}},ce=ne(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=P,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let B=z;if(z=!1,_!==P&&A===_&&!B)return;if(_=A,d){d=!1;return}let j=!1;me(()=>j=!0);let le=L(g),oe=L(y),Q=le==="ready"||le==="refreshing";k(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let V=r(A,{value:oe,refetching:Q});if(fe(V)){p(V),ye(V),V.then(h=>{j||(a!==void 0&&Je(a,h),k(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{j||k(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{j||k(()=>{S(h),m("errored"),p(void 0)})});let Se=O&&I(O);Se&&(Se.increment(),V.finally(()=>Se.decrement()))}else{if(j)return;k(()=>{T(()=>V),m("ready"),p(void 0)})}}catch(V){if(j)return;k(()=>{S(V),m("errored"),p(void 0)})}});me(ce);let J=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(J()){let B=E();if(B)throw B}return y()});return Object.defineProperty(Y,Un,{value:!0,enumerable:!0}),Object.defineProperty(Y,De,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>J()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function mt(){return f}function xt(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function on(e){let n=Symbol("context"),t=Bn(n);return{id:n,Provider:t,defaultValue:e}}function Bn(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Vn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ke(()=>n.children)})}),o}}function I(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function St(){return new Promise(e=>{queueMicrotask(()=>{Ln(),e()})})}function jn(e){if(M&&M.running)return e(),M.done;In();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(nn(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,nn(!1),r.length&&k(()=>{for(let s of r)s.state=W,xe(s)}),n()}),t):(M=null,n(),t)}function wt(){return In(),[en,jn]}function gt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):L(()=>n(u,s))}}function Vn(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),Gn(o),()=>X(o)}function Gn(e){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)X(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=$;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;qe(r),l=s}}}function Ot(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):rn(o,n)}var O;function sn(){return O||(O=on())}var Pn;function Rt(){return Pn||(Pn=on())}function At(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=W,xe(t)}function Ct(e){let n=O&&I(O);n&&n.inFallback()?ne(()=>{n.inFallback()||e()}):e()}function _t(e){ct=e}function Et(e){let n=O&&I(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function kt(e,n,t){return x(()=>n(e()),void 0,t)}function Pt(e,n,t){return x(()=>e().filter(n),void 0,t)}function Ft(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function Ut(e,n,t){return x(()=>e().find(n),void 0,t)}function Dt(e,n,t){return x(()=>e().some(n),void 0,t)}function qt(e,n,t){return x(()=>e().every(n),void 0,t)}function Mt(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function It(e,n){return x(()=>[...new Set(e())],void 0,n)}function Nt(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function Lt(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):ve(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function Bt(e,n,t){return x(()=>e()||n(),void 0,t)}function jt(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function Vt(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function Gt(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function Kt(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function $t(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function Wt(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function zt(e,n,t){let[o,r]=N(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function Ht(e,n,t){let[o,r]=N(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Yt(e){let n=e;for(;typeof n=="function";)n=n();return n}var re=new Map,te=new Map,Xt=0,Jt=Symbol.for("signal"),Qt=Symbol.for("resource");function Zt(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${Xt++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=U(void 0,{equals:!1}),[g,m]=U("unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),[P,_]=U(!1),[z,H]=U(0,{equals:!1}),ce=Symbol("unset"),J=ce,Y=!1,A=!1;function B(h,D,q,G){if(te.has(D)){te.get(D).then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)}),q||C(te.get(D));return}let se=Promise.resolve(r(h)).then(R=>(re.set(D,{value:R,timestamp:Date.now()}),te.delete(D),R),R=>{throw te.delete(D),R});if(te.set(D,se),!q){ye(se),C(se);let R=oe&&I(oe);R&&(R.increment(),se.finally(()=>R.decrement()))}se.then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)})}function j(h,D){k(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){k(()=>{p(h),m("errored"),C(void 0)})}let oe;ne(()=>{oe===void 0&&(oe=sn());let h=o();if(z(),h===!1||h===null||h===void 0){J=ce,k(()=>{m("unresolved"),C(void 0),p(void 0)});return}let D=Y,q=A;Y=!1,A=!1;let G=y(h);q&&re.delete(G);let se=J===ce||h!==J;J=h;let R=!1;me(()=>{R=!0});let ie=re.get(G);if(ie&&T(ie)&&!D&&!q){(L(g)!=="ready"||L(w)!==ie.value)&&k(()=>{S(()=>ie.value),m("ready"),_(!1),p(void 0)});return}if(ie&&i&&!q){k(()=>{S(()=>ie.value),m("ready"),_(!0),p(void 0),C(void 0)}),B(h,G,!0,()=>R);return}let un=L(g),Kn=un==="ready"||un==="refreshing";k(()=>{m(Kn?"refreshing":"pending"),p(void 0),_(!1)}),B(h,G,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let q=b();if(q)throw q}return w()});return Object.defineProperty(Q,Qt,{value:!0,enumerable:!0}),Object.defineProperty(Q,Jt,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:P}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=L(o);h!=null&&h!==!1&&re.delete(y(h)),A=!0,H(D=>D+1)}}]}function er(e){let n=`${e}:`;for(let t of re.keys())t.startsWith(n)&&re.delete(t)}function nr(){re.clear(),te.clear()}function tr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;he(m=>{S=m;let[E,p]=N(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function rr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ee(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;he(p=>{E=p;let[b,C]=N(T);m=C;let P=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(P,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function or(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];he(S=>{T=S;let[g,m]=N(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}
@@ -1 +1 @@
1
- function Ue(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Qe(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var de=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(Ue(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Qe(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(Ue(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var me=class extends de{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},De=class extends me{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends de{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof me?r=n:r=new De(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var xe=!1,Cn=Symbol.for("signal"),_n=Symbol.for("memo"),En=Symbol.for("resource");function qe(e){return typeof e=="function"&&e[Cn]===!0}function kn(e){return typeof e=="function"&&e[_n]===!0}function Pn(e){return typeof e=="function"&&e[En]===!0}function Fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Un(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ze(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ze(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var qn="__fluixi_signal_next_state__",Mn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[qn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Mn,onSuspend:null,onError:null};var en=0,nn=1,pe=2,Se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},we=class extends Se{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(pe);Me(this)}}peek(){return this._value}},ie=class extends Se{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=pe;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===nn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===pe)break}(this.state===pe||!this._initialized)&&this.recompute(),this.state=en}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(pe);Me(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===en;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(nn);Me(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Me(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var ge=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function tn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function rn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function on(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function Ne(){return c.owner}function Re(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Oe(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Oe(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function Te(e){let n=rn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Oe(n))}finally{c.owner=t}}function sn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function In(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Le)))}function Le(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function un(){c.batchDepth===0&&Le()}var Ie=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=rn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ie(()=>{Oe(this.owner,!1),Re(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new ge(()=>In(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Oe(this.owner))}};function an(e){let n=new Ie(e);return()=>n.dispose()}function Nn(e){return!!e&&typeof e.then=="function"}sn(()=>{});var cn=Symbol.for("signal"),Ln=Symbol.for("memo"),Bn=Symbol.for("signal-node");function I(e,n){let t=new we(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),un(),u});return Object.defineProperty(o,cn,{value:!0,enumerable:!0}),Object.defineProperty(o,Bn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=Ne(),s=new ie(()=>Re(r,()=>{try{return o=e(o)}catch(a){if(Nn(a))return on(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,cn,{value:!0,enumerable:!0}),Object.defineProperty(u,Ln,{value:!0,enumerable:!0}),u}function he(e,n){let t=n;return an(()=>{t=e(t)})}function Ae(e){return tn(e)}function jn(e,n=(t,o)=>t===o){let t=new Map;return he(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=I(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function Vn(e,n){let[t,o]=I(e(),n);return he(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Gn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function Ce(e){if(typeof e=="function"&&!e.length){let n=e();return qe(n)?n:Ce(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=Ce(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function ln(e){let n=x(e);return x(()=>Ce(n()))}var Be=null;function Kn(e){Be=e}function _e(e){Be&&Be(e)}var je=null;function $n(e){je=e}function fn(e){return je?je(e):void 0}var Ve=null;function Wn(e){Ve=e}function dn(){return Ve?Ve():void 0}var Ge=null;function zn(e){Ge=e}function pn(e,n){Ge&&Ge(e,n)}var He=Symbol.for("signal"),Hn=Symbol.for("memo"),Yn=Symbol.for("resource"),Tn=Symbol("fluixi-proxy"),yn=Symbol.for("signal-node"),G=0,ve=1,$=2,K=3,f=null,v=null,l=null,Ee=null,ke=0,Jn=!1,Ke=!1,ue=0,Xn=1e6,P=new WeakMap,M=null;var Qn=null,Zn=new Map,et=0,$e={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function Bt(e){f=e,$e.owner=e,$e.context=e}function jt(){return $e}function nt(){return`node_${++et}_${Date.now()}`}function tt(e){!1}function bn(e,n,t){let o={id:nt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return tt(o),o}function mn(e,n){return e===n}function Ye(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var We=null,ze=null;function xn(){if(!We){let[e,n]=q(!1);We=e,ze=n}}function Sn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)ye(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;Fe(o),l=r}}}function hn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function q(e,n){let t=e;typeof t=="object"&&t&&Tn in t&&delete t[Tn];let o=bn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];P.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=P.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=P.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===K&&p===v)){if(b&&!p.pure){C===G&&(p.state=ve,Jn&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=$,C===G||C===ve?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let k=P.get(p.accessor);k&&hn(Array.from(k),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;hn(S,E);for(let p of g)Sn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ae(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,He,{value:!0,enumerable:!0}),Object.defineProperty(u,yn,{value:o,enumerable:!1}),r}function ae(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&N(O);return r&&(o.suspense=r),Je(o,n),()=>J(o)}function Je(e,n){if(e.sources){for(let r of e.sources){let s=P.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,ke++,ke>Xn)throw ke=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=K;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===K&&(e.state=G)}catch(r){if(fe(r)){let s=O&&N(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ye(r)}finally{v=t,f=o}}function ye(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===$||e.state===ve||e.state===K)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)J(e.owned[n]);e.owned=null}e.renderEffect?On(e):Je(e,e.value)}}function J(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=P.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)J(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function Gt(e,n,t){let o=bn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;P.has(a)||P.set(a,new Set);let i=P.get(a);i&&i.add(v)}if(r.state!==G){if(r.sources){for(let d of r.sources){let y=P.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)J(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=K;try{let d=r.fn(r.value),y=o.equals||mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=P.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let k=b.state;if(k!==K){if(C&&!b.pure){k===G&&(b.state=ve,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=$,k===G||k===ve?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=P.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Sn(b)}}r.state===K&&(r.state=G)}catch(d){if(fe(d)){let y=O&&N(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}Ye(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,P.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ae(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,He,{value:!0,enumerable:!0}),Object.defineProperty(s,Hn,{value:!0,enumerable:!0}),Object.defineProperty(s,yn,{value:o,enumerable:!1}),s}function Fe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=P.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&ye(r)}function F(e){if(l&&ue>0)return e();if(l&&ue===0){let n=l,t=[];l=t,ue++;let o;try{o=e()}finally{ue--,l=n}let r=l;return Fe(t),l=r,o}ue++,l=[],Ee=[];try{return e()}finally{ue--,wn()}}function wn(){if(!Ke){Ke=!0,ke=0;try{for(;l&&l.length>0;){let e=l;l=null,Fe(e)}if(l=null,Ee){let e=Ee;Ee=null;for(let n=0;n<e.length;n++)ye(e[n])}}finally{Ke=!1}}}function Kt(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)J(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function W(e){let n=v;v=null;try{return e()}finally{v=n}}function Pe(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function $t(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:dn(),i=a!==void 0?fn(a):void 0,d=i!==void 0,[y,T]=q(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=q(void 0,{equals:!1}),[g,m]=q(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=q(void 0,{equals:!1}),[b,C]=q(void 0,{equals:!1}),k=Symbol(),_=k,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${u}):`,L)}},ce=ae(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=k,F(()=>{m("unresolved"),p(void 0),S(void 0)});return}let L=z;if(z=!1,_!==k&&A===_&&!L)return;if(_=A,d){d=!1;return}let B=!1;Pe(()=>B=!0);let le=W(g),re=W(y),Q=le==="ready"||le==="refreshing";F(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let j=r(A,{value:re,refetching:Q});if(fe(j)){p(j),_e(j),j.then(h=>{B||(a!==void 0&&pn(a,h),F(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{B||F(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{B||F(()=>{S(h),m("errored"),p(void 0)})});let be=O&&N(O);be&&(be.increment(),j.finally(()=>be.decrement()))}else{if(B)return;F(()=>{T(()=>j),m("ready"),p(void 0)})}}catch(j){if(B)return;F(()=>{S(j),m("errored"),p(void 0)})}});Pe(ce);let X=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(X()){let L=E();if(L)throw L}return y()});return Object.defineProperty(Y,Yn,{value:!0,enumerable:!0}),Object.defineProperty(Y,He,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>X()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function Wt(){return f}function zt(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function gn(e){let n=Symbol("context"),t=rt(n);return{id:n,Provider:t,defaultValue:e}}function rt(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return st(()=>{o=W(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),ln(()=>n.children)})}),o}}function N(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Ht(){return new Promise(e=>{queueMicrotask(()=>{wn(),e()})})}function ot(e){if(M&&M.running)return e(),M.done;xn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(ze(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,ze(!1),r.length&&F(()=>{for(let s of r)s.state=$,ye(s)}),n()}),t):(M=null,n(),t)}function Yt(){return xn(),[We,ot]}function Jt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):W(()=>n(u,s))}}function st(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&N(O);return r&&(o.suspense=r),On(o),()=>J(o)}function On(e){if(e.sources){for(let r of e.sources){let s=P.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=K;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===K&&(e.state=G)}catch(r){if(fe(r)){let s=O&&N(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ye(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;Fe(r),l=s}}}function Xt(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):Je(o,n)}var O;function Rn(){return O||(O=gn())}var vn;function Qt(){return vn||(vn=gn())}function Zt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=$,ye(t)}function er(e){let n=O&&N(O);n&&n.inFallback()?ae(()=>{n.inFallback()||e()}):e()}function nr(e){Qn=e}function tr(e){let n=O&&N(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function ir(e,n,t){return x(()=>n(e()),void 0,t)}function ur(e,n,t){return x(()=>e().filter(n),void 0,t)}function ar(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function cr(e,n,t){return x(()=>e().find(n),void 0,t)}function lr(e,n,t){return x(()=>e().some(n),void 0,t)}function fr(e,n,t){return x(()=>e().every(n),void 0,t)}function dr(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function pr(e,n){return x(()=>[...new Set(e())],void 0,n)}function Tr(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function hr(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):he(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function vr(e,n,t){return x(()=>e()||n(),void 0,t)}function yr(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function br(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function mr(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function xr(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function Sr(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function wr(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function gr(e,n,t){let[o,r]=I(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function Or(e,n,t){let[o,r]=I(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Rr(e){let n=e;for(;typeof n=="function";)n=n();return n}var te=new Map,ne=new Map,it=0,ut=Symbol.for("signal"),at=Symbol.for("resource");function _r(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${it++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=q(void 0,{equals:!1}),[g,m]=q("unresolved",{equals:!1}),[E,p]=q(void 0,{equals:!1}),[b,C]=q(void 0,{equals:!1}),[k,_]=q(!1),[z,H]=q(0,{equals:!1}),ce=Symbol("unset"),X=ce,Y=!1,A=!1;function L(h,U,D,V){if(ne.has(U)){ne.get(U).then(R=>{V()||B(R,D)},R=>{!V()&&!D&&le(R)}),D||C(ne.get(U));return}let oe=Promise.resolve(r(h)).then(R=>(te.set(U,{value:R,timestamp:Date.now()}),ne.delete(U),R),R=>{throw ne.delete(U),R});if(ne.set(U,oe),!D){_e(oe),C(oe);let R=re&&N(re);R&&(R.increment(),oe.finally(()=>R.decrement()))}oe.then(R=>{V()||B(R,D)},R=>{!V()&&!D&&le(R)})}function B(h,U){F(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){F(()=>{p(h),m("errored"),C(void 0)})}let re;ae(()=>{re===void 0&&(re=Rn());let h=o();if(z(),h===!1||h===null||h===void 0){X=ce,F(()=>{m("unresolved"),C(void 0),p(void 0)});return}let U=Y,D=A;Y=!1,A=!1;let V=y(h);D&&te.delete(V);let oe=X===ce||h!==X;X=h;let R=!1;Pe(()=>{R=!0});let se=te.get(V);if(se&&T(se)&&!U&&!D){(W(g)!=="ready"||W(w)!==se.value)&&F(()=>{S(()=>se.value),m("ready"),_(!1),p(void 0)});return}if(se&&i&&!D){F(()=>{S(()=>se.value),m("ready"),_(!0),p(void 0),C(void 0)}),L(h,V,!0,()=>R);return}let Xe=W(g),An=Xe==="ready"||Xe==="refreshing";F(()=>{m(An?"refreshing":"pending"),p(void 0),_(!1)}),L(h,V,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let D=b();if(D)throw D}return w()});return Object.defineProperty(Q,at,{value:!0,enumerable:!0}),Object.defineProperty(Q,ut,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:k}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=W(o);h!=null&&h!==!1&&te.delete(y(h)),A=!0,H(U=>U+1)}}]}function Er(e){let n=`${e}:`;for(let t of te.keys())t.startsWith(n)&&te.delete(t)}function kr(){te.clear(),ne.clear()}function Ur(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ae(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;Te(m=>{S=m;let[E,p]=I(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function Dr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ae(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;Te(p=>{E=p;let[b,C]=I(T);m=C;let k=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(k,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function qr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ae(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];Te(S=>{T=S;let[g,m]=I(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}export{Hn as $MEMO,Tn as $PROXY,Yn as $RESOURCE,He as $SIGNAL,xe as __DEV__,F as batch,kr as clearAllCachedResources,Er as clearCachedResourceNamespace,Tr as combineSignal,hr as combineSignals,_r as createCachedResource,Xt as createComputed,gn as createContext,Gn as createDebounce,Vn as createDeferred,ae as createEffect,Gt as createMemo,rt as createProvider,st as createRenderEffect,$t as createResource,Kt as createRoot,jn as createSelector,q as createSignal,gr as debounceSignal,pr as distinctSignal,fr as everySignal,ur as filterSignal,cr as findSignal,Ht as flush,Wt as getOwner,fn as getServerData,jt as getSharedConfig,Rn as getSuspenseContext,Qt as getSuspenseListContext,wr as guardSignal,qr as indexArray,Fn as isComponent,kn as isMemo,Dn as isProvider,Pn as isResource,qe as isSignal,Un as isSuspense,Dr as keyArray,Ze as makeArrayFlat,Ur as mapArray,ir as mapSignal,vr as mergeSignal,dn as nextResourceId,xr as omitSignal,Jt as on,Pe as onCleanup,er as onResolve,mr as pickSignal,ln as readChildren,Rr as readSignal,ar as reduceSignal,pn as reportResourceData,Zt as resumeEffects,zt as runWithOwner,br as selectSignal,Bt as setOwner,zn as setResourceDataSink,Wn as setResourceIdSource,Kn as setResourceTracker,nr as setScheduler,$n as setServerDataGetter,$e as sharedConfig,lr as someSignal,dr as sortSignal,ot as startTransition,Or as throttleSignal,tr as trackPromise,_e as trackResourcePromise,W as untrack,N as useContext,Yt as useTransition,Sr as whenSignal,yr as zipSignal};
1
+ function Ue(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Qe(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var de=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(Ue(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Qe(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(Ue(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var me=class extends de{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},De=class extends me{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends de{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof me?r=n:r=new De(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var Cn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,xe=typeof process>"u"?Cn:!1,_n=Symbol.for("signal"),En=Symbol.for("memo"),kn=Symbol.for("resource");function qe(e){return typeof e=="function"&&e[_n]===!0}function Pn(e){return typeof e=="function"&&e[En]===!0}function Fn(e){return typeof e=="function"&&e[kn]===!0}function Un(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function qn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ze(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ze(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Mn="__fluixi_signal_next_state__",In=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[Mn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:In,onSuspend:null,onError:null};var en=0,nn=1,pe=2,Se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},we=class extends Se{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(pe);Me(this)}}peek(){return this._value}},ie=class extends Se{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=pe;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===nn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===pe)break}(this.state===pe||!this._initialized)&&this.recompute(),this.state=en}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(pe);Me(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===en;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(nn);Me(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Me(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var ge=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function tn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function rn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function on(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function Ne(){return c.owner}function Re(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Oe(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Oe(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function Te(e){let n=rn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Oe(n))}finally{c.owner=t}}function sn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Nn(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Le)))}function Le(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function un(){c.batchDepth===0&&Le()}var Ie=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=rn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ie(()=>{Oe(this.owner,!1),Re(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new ge(()=>Nn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Oe(this.owner))}};function an(e){let n=new Ie(e);return()=>n.dispose()}function Ln(e){return!!e&&typeof e.then=="function"}sn(()=>{});var cn=Symbol.for("signal"),Bn=Symbol.for("memo"),jn=Symbol.for("signal-node");function I(e,n){let t=new we(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),un(),u});return Object.defineProperty(o,cn,{value:!0,enumerable:!0}),Object.defineProperty(o,jn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=Ne(),s=new ie(()=>Re(r,()=>{try{return o=e(o)}catch(a){if(Ln(a))return on(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,cn,{value:!0,enumerable:!0}),Object.defineProperty(u,Bn,{value:!0,enumerable:!0}),u}function he(e,n){let t=n;return an(()=>{t=e(t)})}function Ae(e){return tn(e)}function Vn(e,n=(t,o)=>t===o){let t=new Map;return he(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=I(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function Gn(e,n){let[t,o]=I(e(),n);return he(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Kn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function Ce(e){if(typeof e=="function"&&!e.length){let n=e();return qe(n)?n:Ce(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=Ce(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function ln(e){let n=x(e);return xe?x(()=>Ce(n()),void 0,{name:"children"}):x(()=>Ce(n()))}var Be=null;function $n(e){Be=e}function _e(e){Be&&Be(e)}var je=null;function Wn(e){je=e}function fn(e){return je?je(e):void 0}var Ve=null;function zn(e){Ve=e}function dn(){return Ve?Ve():void 0}var Ge=null;function Hn(e){Ge=e}function pn(e,n){Ge&&Ge(e,n)}var He=Symbol.for("signal"),Yn=Symbol.for("memo"),Xn=Symbol.for("resource"),Tn=Symbol("fluixi-proxy"),yn=Symbol.for("signal-node"),G=0,ve=1,$=2,K=3,f=null,v=null,l=null,Ee=null,ke=0,Jn=!1,Ke=!1,ue=0,Qn=1e6,P=new WeakMap,M=null;var Zn=null,et=new Map,nt=0,$e={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function jt(e){f=e,$e.owner=e,$e.context=e}function Vt(){return $e}function tt(){return`node_${++nt}_${Date.now()}`}function rt(e){xe&&et.set(e.id,new WeakRef(e))}function bn(e,n,t){let o={id:tt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return rt(o),o}function mn(e,n){return e===n}function Ye(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var We=null,ze=null;function xn(){if(!We){let[e,n]=q(!1);We=e,ze=n}}function Sn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)ye(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;Fe(o),l=r}}}function hn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function q(e,n){let t=e;typeof t=="object"&&t&&Tn in t&&delete t[Tn];let o=bn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];P.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=P.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=P.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===K&&p===v)){if(b&&!p.pure){C===G&&(p.state=ve,Jn&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=$,C===G||C===ve?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let k=P.get(p.accessor);k&&hn(Array.from(k),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;hn(S,E);for(let p of g)Sn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ae(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,He,{value:!0,enumerable:!0}),Object.defineProperty(u,yn,{value:o,enumerable:!1}),r}function ae(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&N(O);return r&&(o.suspense=r),Xe(o,n),()=>X(o)}function Xe(e,n){if(e.sources){for(let r of e.sources){let s=P.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)X(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,ke++,ke>Qn)throw ke=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=K;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===K&&(e.state=G)}catch(r){if(fe(r)){let s=O&&N(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ye(r)}finally{v=t,f=o}}function ye(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===$||e.state===ve||e.state===K)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)X(e.owned[n]);e.owned=null}e.renderEffect?On(e):Xe(e,e.value)}}function X(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=P.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)X(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function Kt(e,n,t){let o=bn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;P.has(a)||P.set(a,new Set);let i=P.get(a);i&&i.add(v)}if(r.state!==G){if(r.sources){for(let d of r.sources){let y=P.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)X(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=K;try{let d=r.fn(r.value),y=o.equals||mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=P.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let k=b.state;if(k!==K){if(C&&!b.pure){k===G&&(b.state=ve,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=$,k===G||k===ve?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=P.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Sn(b)}}r.state===K&&(r.state=G)}catch(d){if(fe(d)){let y=O&&N(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}Ye(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,P.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ae(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,He,{value:!0,enumerable:!0}),Object.defineProperty(s,Yn,{value:!0,enumerable:!0}),Object.defineProperty(s,yn,{value:o,enumerable:!1}),s}function Fe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=P.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&ye(r)}function F(e){if(l&&ue>0)return e();if(l&&ue===0){let n=l,t=[];l=t,ue++;let o;try{o=e()}finally{ue--,l=n}let r=l;return Fe(t),l=r,o}ue++,l=[],Ee=[];try{return e()}finally{ue--,wn()}}function wn(){if(!Ke){Ke=!0,ke=0;try{for(;l&&l.length>0;){let e=l;l=null,Fe(e)}if(l=null,Ee){let e=Ee;Ee=null;for(let n=0;n<e.length;n++)ye(e[n])}}finally{Ke=!1}}}function $t(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)X(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function W(e){let n=v;v=null;try{return e()}finally{v=n}}function Pe(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function Wt(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:dn(),i=a!==void 0?fn(a):void 0,d=i!==void 0,[y,T]=q(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=q(void 0,{equals:!1}),[g,m]=q(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=q(void 0,{equals:!1}),[b,C]=q(void 0,{equals:!1}),k=Symbol(),_=k,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${u}):`,L)}},ce=ae(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=k,F(()=>{m("unresolved"),p(void 0),S(void 0)});return}let L=z;if(z=!1,_!==k&&A===_&&!L)return;if(_=A,d){d=!1;return}let B=!1;Pe(()=>B=!0);let le=W(g),re=W(y),Q=le==="ready"||le==="refreshing";F(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let j=r(A,{value:re,refetching:Q});if(fe(j)){p(j),_e(j),j.then(h=>{B||(a!==void 0&&pn(a,h),F(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{B||F(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{B||F(()=>{S(h),m("errored"),p(void 0)})});let be=O&&N(O);be&&(be.increment(),j.finally(()=>be.decrement()))}else{if(B)return;F(()=>{T(()=>j),m("ready"),p(void 0)})}}catch(j){if(B)return;F(()=>{S(j),m("errored"),p(void 0)})}});Pe(ce);let J=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(J()){let L=E();if(L)throw L}return y()});return Object.defineProperty(Y,Xn,{value:!0,enumerable:!0}),Object.defineProperty(Y,He,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>J()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function zt(){return f}function Ht(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function gn(e){let n=Symbol("context"),t=ot(n);return{id:n,Provider:t,defaultValue:e}}function ot(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return it(()=>{o=W(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),ln(()=>n.children)})}),o}}function N(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Yt(){return new Promise(e=>{queueMicrotask(()=>{wn(),e()})})}function st(e){if(M&&M.running)return e(),M.done;xn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(ze(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,ze(!1),r.length&&F(()=>{for(let s of r)s.state=$,ye(s)}),n()}),t):(M=null,n(),t)}function Xt(){return xn(),[We,st]}function Jt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):W(()=>n(u,s))}}function it(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&N(O);return r&&(o.suspense=r),On(o),()=>X(o)}function On(e){if(e.sources){for(let r of e.sources){let s=P.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)X(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=K;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===K&&(e.state=G)}catch(r){if(fe(r)){let s=O&&N(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ye(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;Fe(r),l=s}}}function Qt(e,n,t){let o={fn:e,state:$,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):Xe(o,n)}var O;function Rn(){return O||(O=gn())}var vn;function Zt(){return vn||(vn=gn())}function er(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=$,ye(t)}function nr(e){let n=O&&N(O);n&&n.inFallback()?ae(()=>{n.inFallback()||e()}):e()}function tr(e){Zn=e}function rr(e){let n=O&&N(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function ur(e,n,t){return x(()=>n(e()),void 0,t)}function ar(e,n,t){return x(()=>e().filter(n),void 0,t)}function cr(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function lr(e,n,t){return x(()=>e().find(n),void 0,t)}function fr(e,n,t){return x(()=>e().some(n),void 0,t)}function dr(e,n,t){return x(()=>e().every(n),void 0,t)}function pr(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function Tr(e,n){return x(()=>[...new Set(e())],void 0,n)}function hr(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function vr(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):he(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function yr(e,n,t){return x(()=>e()||n(),void 0,t)}function br(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function mr(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function xr(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function Sr(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function wr(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function gr(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function Or(e,n,t){let[o,r]=I(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function Rr(e,n,t){let[o,r]=I(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Ar(e){let n=e;for(;typeof n=="function";)n=n();return n}var te=new Map,ne=new Map,ut=0,at=Symbol.for("signal"),ct=Symbol.for("resource");function Er(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${ut++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=q(void 0,{equals:!1}),[g,m]=q("unresolved",{equals:!1}),[E,p]=q(void 0,{equals:!1}),[b,C]=q(void 0,{equals:!1}),[k,_]=q(!1),[z,H]=q(0,{equals:!1}),ce=Symbol("unset"),J=ce,Y=!1,A=!1;function L(h,U,D,V){if(ne.has(U)){ne.get(U).then(R=>{V()||B(R,D)},R=>{!V()&&!D&&le(R)}),D||C(ne.get(U));return}let oe=Promise.resolve(r(h)).then(R=>(te.set(U,{value:R,timestamp:Date.now()}),ne.delete(U),R),R=>{throw ne.delete(U),R});if(ne.set(U,oe),!D){_e(oe),C(oe);let R=re&&N(re);R&&(R.increment(),oe.finally(()=>R.decrement()))}oe.then(R=>{V()||B(R,D)},R=>{!V()&&!D&&le(R)})}function B(h,U){F(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){F(()=>{p(h),m("errored"),C(void 0)})}let re;ae(()=>{re===void 0&&(re=Rn());let h=o();if(z(),h===!1||h===null||h===void 0){J=ce,F(()=>{m("unresolved"),C(void 0),p(void 0)});return}let U=Y,D=A;Y=!1,A=!1;let V=y(h);D&&te.delete(V);let oe=J===ce||h!==J;J=h;let R=!1;Pe(()=>{R=!0});let se=te.get(V);if(se&&T(se)&&!U&&!D){(W(g)!=="ready"||W(w)!==se.value)&&F(()=>{S(()=>se.value),m("ready"),_(!1),p(void 0)});return}if(se&&i&&!D){F(()=>{S(()=>se.value),m("ready"),_(!0),p(void 0),C(void 0)}),L(h,V,!0,()=>R);return}let Je=W(g),An=Je==="ready"||Je==="refreshing";F(()=>{m(An?"refreshing":"pending"),p(void 0),_(!1)}),L(h,V,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let D=b();if(D)throw D}return w()});return Object.defineProperty(Q,ct,{value:!0,enumerable:!0}),Object.defineProperty(Q,at,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:k}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=W(o);h!=null&&h!==!1&&te.delete(y(h)),A=!0,H(U=>U+1)}}]}function kr(e){let n=`${e}:`;for(let t of te.keys())t.startsWith(n)&&te.delete(t)}function Pr(){te.clear(),ne.clear()}function Dr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ae(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;Te(m=>{S=m;let[E,p]=I(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function qr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ae(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;Te(p=>{E=p;let[b,C]=I(T);m=C;let k=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(k,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function Mr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ae(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];Te(S=>{T=S;let[g,m]=I(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}export{Yn as $MEMO,Tn as $PROXY,Xn as $RESOURCE,He as $SIGNAL,xe as __DEV__,F as batch,Pr as clearAllCachedResources,kr as clearCachedResourceNamespace,hr as combineSignal,vr as combineSignals,Er as createCachedResource,Qt as createComputed,gn as createContext,Kn as createDebounce,Gn as createDeferred,ae as createEffect,Kt as createMemo,ot as createProvider,it as createRenderEffect,Wt as createResource,$t as createRoot,Vn as createSelector,q as createSignal,Or as debounceSignal,Tr as distinctSignal,dr as everySignal,ar as filterSignal,lr as findSignal,Yt as flush,zt as getOwner,fn as getServerData,Vt as getSharedConfig,Rn as getSuspenseContext,Zt as getSuspenseListContext,gr as guardSignal,Mr as indexArray,Un as isComponent,Pn as isMemo,qn as isProvider,Fn as isResource,qe as isSignal,Dn as isSuspense,qr as keyArray,Ze as makeArrayFlat,Dr as mapArray,ur as mapSignal,yr as mergeSignal,dn as nextResourceId,Sr as omitSignal,Jt as on,Pe as onCleanup,nr as onResolve,xr as pickSignal,ln as readChildren,Ar as readSignal,cr as reduceSignal,pn as reportResourceData,er as resumeEffects,Ht as runWithOwner,mr as selectSignal,jt as setOwner,Hn as setResourceDataSink,zn as setResourceIdSource,$n as setResourceTracker,tr as setScheduler,Wn as setServerDataGetter,$e as sharedConfig,fr as someSignal,pr as sortSignal,st as startTransition,Rr as throttleSignal,rr as trackPromise,_e as trackResourcePromise,W as untrack,N as useContext,Xt as useTransition,wr as whenSignal,br as zipSignal};
@@ -1 +1 @@
1
- "use strict";var se=Object.defineProperty;var an=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var dn=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},fn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of cn(n))!ln.call(e,o)&&o!==t&&se(e,o,{get:()=>n[o],enumerable:!(r=an(n,o))||r.enumerable});return e};var pn=e=>fn(se({},"__esModule",{value:!0}),e);var qn={};dn(qn,{$PROXY:()=>En,$SIGNAL:()=>An,Signal:()=>on,SuspenseContext:()=>oe,__DEV__:()=>X,batch:()=>b,createChildOwner:()=>Re,createComputed:()=>Ie,createContext:()=>q,createDebounce:()=>Qe,createDebouncedResource:()=>Xe,createDebouncedSignal:()=>me,createDeferred:()=>Ye,createEffect:()=>g,createErrorBoundary:()=>tn,createMemo:()=>S,createRenderEffect:()=>Me,createResource:()=>U,createRoot:()=>A,createSelector:()=>Ke,createSignal:()=>d,createSuspenseBoundary:()=>Ze,disposeScope:()=>ke,effect:()=>Pn,flush:()=>Fe,getOwner:()=>L,getServerData:()=>ee,indexArray:()=>gn,isComponent:()=>Ve,isMemo:()=>je,isOwnerDisposed:()=>Oe,isProvider:()=>Le,isResource:()=>Ne,isSignal:()=>J,isSuspense:()=>He,keyArray:()=>xn,makeArrayFlat:()=>de,mapArray:()=>wn,memo:()=>Dn,nextResourceId:()=>ne,on:()=>Be,onCleanup:()=>v,provide:()=>I,provideErrorBoundary:()=>rn,provideSuspense:()=>en,readChildren:()=>Je,reportResourceData:()=>te,resource:()=>sn,runWithOwner:()=>M,setOwner:()=>ae,setResourceDataSink:()=>$e,setResourceIdSource:()=>ze,setResourceTracker:()=>Ge,setServerDataGetter:()=>We,signal:()=>Cn,startTransition:()=>le,trackResourcePromise:()=>Z,untrack:()=>w,useContext:()=>_e,useTransition:()=>Ue});module.exports=pn(qn);var hn="__fluixi_signal_next_state__",Tn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[hn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Tn,onSuspend:null,onError:null};var we=0,xe=1,j=2,K=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let n=s.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends K{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(j);ie(this)}}peek(){return this._value}},k=class extends K{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=j;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===xe&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===j)break}(this.state===j||!this._initialized)&&this.recompute(),this.state=we}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=s.consumer,r=s.untracked;s.consumer=this,s.untracked=!1;let o,u=!1,a;try{o=this._fn()}catch(i){u=!0,a=i,o=this._value}finally{s.consumer=t,s.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=u,this._error=a,this._value=o,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(j);ie(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===we;if(this.state=t,r){if(this.observers)for(let o of[...this.observers])o.markDirty(xe);ie(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ie(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function N(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function ge(){return s.consumer}function be(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Re(e){let n=H(e);return e&&(e.owned??=[]).push(n),n}function ke(e,n=!0){V(e,n)}function Oe(e){return!!e&&e.disposed===!0}function H(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let o=s.owner,u=H(o);(u.contexts=new Map).set(n,r.value),o&&(o.owned??=[]).push(u),s.owner=u;try{return r.children}finally{s.owner=o}}}}function _e(e){let n=s.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function Y(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function I(e,n,t){let r=H(s.owner);(r.contexts=new Map).set(e.id,n),s.owner&&(s.owner.owned??=[]).push(r);let o=s.owner;s.owner=r;try{return t()}finally{s.owner=o}}function Ae(e){s.onSuspend=e}function Ee(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function Ce(e){s.onError=e}function L(){return s.owner}function ae(e){let n=s.owner;return s.owner=e,n}function M(e,n){let t=s.owner;s.owner=e;try{return n()}finally{s.owner=t}}function v(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function A(e){let n=H(s.owner);s.owner&&(s.owner.owned??=[]).push(n);let t=s.owner;s.owner=n;try{return e(()=>V(n))}finally{s.owner=t}}function De(e){s.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function yn(e){e.queued||(e.queued=!0,s.queue.push(e),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(G)))}function G(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=s.queue;s.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function Pe(){s.batchDepth===0&&G()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&G()}}var ue=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=H(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new P(()=>yn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&s.onSuspend){s.onSuspend(n,this.owner);return}if(s.onError&&s.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Q(e){let n=new ue(e);return()=>n.dispose()}function mn(e){return!!e&&typeof e.then=="function"}De(()=>{});var qe=Symbol.for("signal"),vn=Symbol.for("memo"),Sn=Symbol.for("signal-node");function d(e,n){let t=new D(e,{equals:n?.equals}),r=(()=>t.get()),o=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Pe(),a});return Object.defineProperty(r,qe,{value:!0,enumerable:!0}),Object.defineProperty(r,Sn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,o]}function S(e,n,t){let r=n,o=L(),u=new k(()=>M(o,()=>{try{return r=e(r)}catch(c){if(mn(c))return Ee(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,qe,{value:!0,enumerable:!0}),Object.defineProperty(a,vn,{value:!0,enumerable:!0}),a}function g(e,n){let t=n;return Q(()=>{t=e(t)})}function Ie(e,n){let t=n;Q(()=>{t=e(t)})}function Me(e,n){let t=n;return Q(()=>{t=e(t)})}function b(e){return ce(e)}function w(e){return N(e)}function le(e){return ce(e),Promise.resolve()}function Ue(){return[()=>!1,le]}function Fe(){return G(),Promise.resolve()}function Be(e,n,t){let r=Array.isArray(e),o,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,o=c;return}let i=N(()=>n(c,o,a));return o=c,i}}function wn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<o.length;i++){let f=o[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;A(y=>{T=y;let[E,F]=d(i);p=F,l=n(f,E)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function xn(e,n,t,r){let o=[],u=[];return v(()=>{for(let a of u)a.dispose();o=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return o=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,E;A(F=>{E=F;let[O,B]=d(l);y=B;let W=S(C=>{let R=(e()||[])[O()];return R??C},a[l]);x=t(W,O)}),i.push({rendered:x,dispose:E,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return o=f,u=i,i.map(l=>l.rendered)})})}function gn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),S(()=>{let o=e()||[];return w(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=o.length;for(let i=u;i<a;i++){let f,h,l,p=o[i];A(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(o[i]);return r.map(i=>i.rendered)})})}var X=!1,bn=Symbol.for("signal"),Rn=Symbol.for("memo"),kn=Symbol.for("resource");function J(e){return typeof e=="function"&&e[bn]===!0}function je(e){return typeof e=="function"&&e[Rn]===!0}function Ne(e){return typeof e=="function"&&e[kn]===!0}function Ve(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function He(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Le(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function de(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?de(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var fe=null;function Ge(e){fe=e}function Z(e){fe&&fe(e)}var pe=null;function We(e){pe=e}function ee(e){return pe?pe(e):void 0}var he=null;function ze(e){he=e}function ne(){return he?he():void 0}var Te=null;function $e(e){Te=e}function te(e,n){Te&&Te(e,n)}function Ke(e,n=(t,r)=>t===r){let t=new Map;return g(()=>{let r=e();for(let[o,u]of t){let[a,c]=u,i=n(o,r);a()!==i&&c(i)}}),r=>{let o=t.get(r);if(!o){let[u,a]=d(!1);o=[u,a],t.set(r,o);let c=e();a(n(r,c))}return o[0]()}}function Ye(e,n){let[t,r]=d(e(),n);return g(()=>{let o=e();n?.timeoutMs?setTimeout(()=>r(()=>o),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),t}function Qe(e,n){let t,r=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function On(e){return!!e&&typeof e.then=="function"}var ye=Symbol();function U(e,n,t={}){let r,o;typeof n=="function"?(r=typeof e=="function"?e:()=>e,o=n):(r=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ne(),a=u!==void 0?ee(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[E,F]=d(void 0,{equals:!1}),O=ye,B=!1;g(()=>{let m=r();if(E(),m===!1||m===null||m===void 0){O=ye,b(()=>{T("unresolved"),y(void 0),l(void 0)});return}let R=B;if(B=!1,O!==ye&&m===O&&!R)return;if(O=m,c){c=!1;return}let z=!1;v(()=>z=!0);let ve=w(p),un=w(i),Se=ve==="ready"||ve==="refreshing";b(()=>{T(Se?"refreshing":"pending"),l(void 0)});try{let _=o(m,{value:un,refetching:Se});On(_)?(y(_),Z(_),_.then($=>{z||(u!==void 0&&te(u,$),b(()=>{f(()=>$),T("ready"),y(void 0)}))},$=>{z||b(()=>{l($),T("errored"),y(void 0)})})):b(()=>{f(()=>_),T("ready"),y(void 0)})}catch(_){if(z)return;b(()=>{l(_),T("errored"),y(void 0)})}});let W=()=>{let m=p();return m==="pending"||m==="refreshing"},C=(()=>{let m=h();if(m)throw m;if(W()){let R=x();if(R)throw R}return i()});return Object.defineProperties(C,{state:{get:p},loading:{get:W},error:{get:h},latest:{get:i}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:f,refetch:()=>{B=!0,F(void 0)}}]}function me(e,n=300){let[t,r]=d(e),[o,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(w(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[o,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function _n(e){return e!=null&&e!==""}function Xe(e,n,t={}){let{delay:r=300,initialValue:o,shouldFetch:u=_n}=t,[a,c,i]=me(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=U(f,n,o===void 0?{}:{initialValue:o});return[h,{...i,query:a,setQuery:c,refetch:l}]}function re(e){if(typeof e=="function"&&!e.length){let n=e();return J(n)?n:re(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=re(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function Je(e){let n=S(e);return S(()=>re(n()))}var oe=q();Ae((e,n)=>{let t=Y(n,oe);t&&(t.increment(),e.finally(()=>t.decrement()))});function Ze(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function en(e,n){return I(oe,e,n)}var nn=q();Ce((e,n)=>{let t=Y(n,nn);return t?(t.setError(e),!0):!1});function tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function rn(e,n){return I(nn,e,n)}var on={State:D,Computed:k,subtle:{Watcher:P,untrack:N,currentComputed:ge,hasSinks:be}};var An=Symbol.for("signal"),En=Symbol.for("fluixi-proxy");function Cn(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function Dn(e,n,t){return S(e,n,t)}function Pn(e,n){return g(e,n)}function sn(...e){let[n,t]=U(...e);return Object.assign(n,t)}
1
+ "use strict";var se=Object.defineProperty;var an=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var dn=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},fn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of cn(n))!ln.call(e,o)&&o!==t&&se(e,o,{get:()=>n[o],enumerable:!(r=an(n,o))||r.enumerable});return e};var pn=e=>fn(se({},"__esModule",{value:!0}),e);var In={};dn(In,{$PROXY:()=>Cn,$SIGNAL:()=>En,Signal:()=>on,SuspenseContext:()=>oe,__DEV__:()=>X,batch:()=>b,createChildOwner:()=>Re,createComputed:()=>Ie,createContext:()=>q,createDebounce:()=>Qe,createDebouncedResource:()=>Xe,createDebouncedSignal:()=>me,createDeferred:()=>Ye,createEffect:()=>g,createErrorBoundary:()=>tn,createMemo:()=>w,createRenderEffect:()=>Me,createResource:()=>U,createRoot:()=>A,createSelector:()=>Ke,createSignal:()=>d,createSuspenseBoundary:()=>Ze,disposeScope:()=>ke,effect:()=>qn,flush:()=>Fe,getOwner:()=>H,getServerData:()=>ee,indexArray:()=>gn,isComponent:()=>Ve,isMemo:()=>je,isOwnerDisposed:()=>_e,isProvider:()=>He,isResource:()=>Ne,isSignal:()=>J,isSuspense:()=>Le,keyArray:()=>xn,makeArrayFlat:()=>de,mapArray:()=>Sn,memo:()=>Pn,nextResourceId:()=>ne,on:()=>Be,onCleanup:()=>v,provide:()=>I,provideErrorBoundary:()=>rn,provideSuspense:()=>en,readChildren:()=>Je,reportResourceData:()=>te,resource:()=>sn,runWithOwner:()=>M,setOwner:()=>ae,setResourceDataSink:()=>$e,setResourceIdSource:()=>ze,setResourceTracker:()=>We,setServerDataGetter:()=>Ge,signal:()=>Dn,startTransition:()=>le,trackResourcePromise:()=>Z,untrack:()=>S,useContext:()=>Oe,useTransition:()=>Ue});module.exports=pn(In);var hn="__fluixi_signal_next_state__",Tn=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},s=globalThis[hn]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Tn,onSuspend:null,onError:null};var Se=0,xe=1,j=2,K=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(s.untracked)return;let n=s.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends K{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(j);ie(this)}}peek(){return this._value}},k=class extends K{constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=j;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(s.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===xe&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===j)break}(this.state===j||!this._initialized)&&this.recompute(),this.state=Se}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=s.consumer,r=s.untracked;s.consumer=this,s.untracked=!1;let o,u=!1,a;try{o=this._fn()}catch(i){u=!0,a=i,o=this._value}finally{s.consumer=t,s.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=u,this._error=a,this._value=o,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(j);ie(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Se;if(this.state=t,r){if(this.observers)for(let o of[...this.observers])o.markDirty(xe);ie(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ie(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var P=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function N(e){if(s.untracked)return e();s.untracked=!0;try{return e()}finally{s.untracked=!1}}function ge(){return s.consumer}function be(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Re(e){let n=L(e);return e&&(e.owned??=[]).push(n),n}function ke(e,n=!0){V(e,n)}function _e(e){return!!e&&e.disposed===!0}function L(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let o=s.owner,u=L(o);(u.contexts=new Map).set(n,r.value),o&&(o.owned??=[]).push(u),s.owner=u;try{return r.children}finally{s.owner=o}}}}function Oe(e){let n=s.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function Y(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function I(e,n,t){let r=L(s.owner);(r.contexts=new Map).set(e.id,n),s.owner&&(s.owner.owned??=[]).push(r);let o=s.owner;s.owner=r;try{return t()}finally{s.owner=o}}function Ae(e){s.onSuspend=e}function Ee(e){return s.onSuspend?(s.onSuspend(e,s.owner),!0):!1}function Ce(e){s.onError=e}function H(){return s.owner}function ae(e){let n=s.owner;return s.owner=e,n}function M(e,n){let t=s.owner;s.owner=e;try{return n()}finally{s.owner=t}}function v(e){if(s.owner){if(s.owner.disposed){e();return}(s.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function A(e){let n=L(s.owner);s.owner&&(s.owner.owned??=[]).push(n);let t=s.owner;s.owner=n;try{return e(()=>V(n))}finally{s.owner=t}}function De(e){s.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function yn(e){e.queued||(e.queued=!0,s.queue.push(e),!s.scheduled&&s.batchDepth===0&&(s.scheduled=!0,s.hostSchedule(W)))}function W(){if(s.scheduled=!1,s.flushing)return;s.flushing=!0;let e=0;try{for(;s.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=s.queue;s.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{s.flushing=!1}}function Pe(){s.batchDepth===0&&W()}function ce(e){s.batchDepth++;try{return e()}finally{--s.batchDepth===0&&W()}}var ue=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=L(s.owner),s.owner&&(s.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new k(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new P(()=>yn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&s.onSuspend){s.onSuspend(n,this.owner);return}if(s.onError&&s.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Q(e){let n=new ue(e);return()=>n.dispose()}function mn(e){return!!e&&typeof e.then=="function"}De(()=>{});var qe=Symbol.for("signal"),vn=Symbol.for("memo"),wn=Symbol.for("signal-node");function d(e,n){let t=new D(e,{equals:n?.equals}),r=(()=>t.get()),o=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Pe(),a});return Object.defineProperty(r,qe,{value:!0,enumerable:!0}),Object.defineProperty(r,wn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,o]}function w(e,n,t){let r=n,o=H(),u=new k(()=>M(o,()=>{try{return r=e(r)}catch(c){if(mn(c))return Ee(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,qe,{value:!0,enumerable:!0}),Object.defineProperty(a,vn,{value:!0,enumerable:!0}),a}function g(e,n){let t=n;return Q(()=>{t=e(t)})}function Ie(e,n){let t=n;Q(()=>{t=e(t)})}function Me(e,n){let t=n;return Q(()=>{t=e(t)})}function b(e){return ce(e)}function S(e){return N(e)}function le(e){return ce(e),Promise.resolve()}function Ue(){return[()=>!1,le]}function Fe(){return W(),Promise.resolve()}function Be(e,n,t){let r=Array.isArray(e),o,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,o=c;return}let i=N(()=>n(c,o,a));return o=c,i}}function Sn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),w(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<o.length;i++){let f=o[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;A(y=>{T=y;let[E,F]=d(i);p=F,l=n(f,E)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function xn(e,n,t,r){let o=[],u=[];return v(()=>{for(let a of u)a.dispose();o=[],u=[]}),w(()=>{let a=e()||[];return S(()=>{if(a.length===0){for(let l of u)l.dispose();return o=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,E;A(F=>{E=F;let[_,B]=d(l);y=B;let G=w(C=>{let R=(e()||[])[_()];return R??C},a[l]);x=t(G,_)}),i.push({rendered:x,dispose:E,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return o=f,u=i,i.map(l=>l.rendered)})})}function gn(e,n,t){let r=[];return v(()=>{for(let o of r)o.dispose();r=[]}),w(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=o.length;for(let i=u;i<a;i++){let f,h,l,p=o[i];A(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(o[i]);return r.map(i=>i.rendered)})})}var bn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,X=typeof process>"u"?bn:!1,Rn=Symbol.for("signal"),kn=Symbol.for("memo"),_n=Symbol.for("resource");function J(e){return typeof e=="function"&&e[Rn]===!0}function je(e){return typeof e=="function"&&e[kn]===!0}function Ne(e){return typeof e=="function"&&e[_n]===!0}function Ve(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Le(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function He(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function de(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?de(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var fe=null;function We(e){fe=e}function Z(e){fe&&fe(e)}var pe=null;function Ge(e){pe=e}function ee(e){return pe?pe(e):void 0}var he=null;function ze(e){he=e}function ne(){return he?he():void 0}var Te=null;function $e(e){Te=e}function te(e,n){Te&&Te(e,n)}function Ke(e,n=(t,r)=>t===r){let t=new Map;return g(()=>{let r=e();for(let[o,u]of t){let[a,c]=u,i=n(o,r);a()!==i&&c(i)}}),r=>{let o=t.get(r);if(!o){let[u,a]=d(!1);o=[u,a],t.set(r,o);let c=e();a(n(r,c))}return o[0]()}}function Ye(e,n){let[t,r]=d(e(),n);return g(()=>{let o=e();n?.timeoutMs?setTimeout(()=>r(()=>o),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>o)):Promise.resolve().then(()=>r(()=>o))}),t}function Qe(e,n){let t,r=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function On(e){return!!e&&typeof e.then=="function"}var ye=Symbol();function U(e,n,t={}){let r,o;typeof n=="function"?(r=typeof e=="function"?e:()=>e,o=n):(r=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ne(),a=u!==void 0?ee(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[E,F]=d(void 0,{equals:!1}),_=ye,B=!1;g(()=>{let m=r();if(E(),m===!1||m===null||m===void 0){_=ye,b(()=>{T("unresolved"),y(void 0),l(void 0)});return}let R=B;if(B=!1,_!==ye&&m===_&&!R)return;if(_=m,c){c=!1;return}let z=!1;v(()=>z=!0);let ve=S(p),un=S(i),we=ve==="ready"||ve==="refreshing";b(()=>{T(we?"refreshing":"pending"),l(void 0)});try{let O=o(m,{value:un,refetching:we});On(O)?(y(O),Z(O),O.then($=>{z||(u!==void 0&&te(u,$),b(()=>{f(()=>$),T("ready"),y(void 0)}))},$=>{z||b(()=>{l($),T("errored"),y(void 0)})})):b(()=>{f(()=>O),T("ready"),y(void 0)})}catch(O){if(z)return;b(()=>{l(O),T("errored"),y(void 0)})}});let G=()=>{let m=p();return m==="pending"||m==="refreshing"},C=(()=>{let m=h();if(m)throw m;if(G()){let R=x();if(R)throw R}return i()});return Object.defineProperties(C,{state:{get:p},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:f,refetch:()=>{B=!0,F(void 0)}}]}function me(e,n=300){let[t,r]=d(e),[o,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=S(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(S(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[o,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function An(e){return e!=null&&e!==""}function Xe(e,n,t={}){let{delay:r=300,initialValue:o,shouldFetch:u=An}=t,[a,c,i]=me(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=U(f,n,o===void 0?{}:{initialValue:o});return[h,{...i,query:a,setQuery:c,refetch:l}]}function re(e){if(typeof e=="function"&&!e.length){let n=e();return J(n)?n:re(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=re(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function Je(e){let n=w(e);return X?w(()=>re(n()),void 0,{name:"children"}):w(()=>re(n()))}var oe=q();Ae((e,n)=>{let t=Y(n,oe);t&&(t.increment(),e.finally(()=>t.decrement()))});function Ze(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function en(e,n){return I(oe,e,n)}var nn=q();Ce((e,n)=>{let t=Y(n,nn);return t?(t.setError(e),!0):!1});function tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function rn(e,n){return I(nn,e,n)}var on={State:D,Computed:k,subtle:{Watcher:P,untrack:N,currentComputed:ge,hasSinks:be}};var En=Symbol.for("signal"),Cn=Symbol.for("fluixi-proxy");function Dn(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function Pn(e,n,t){return w(e,n,t)}function qn(e,n){return g(e,n)}function sn(...e){let[n,t]=U(...e);return Object.assign(n,t)}
@@ -1 +1 @@
1
- var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var Te=0,ye=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);J(this)}}peek(){return this._value}},b=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===ye&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=Te}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);J(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Te;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(ye);J(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function J(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var D=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function N(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function Se(e){o.onSuspend=e}function we(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function Y(){return o.owner}function ge(e){let n=o.owner;return o.owner=e,n}function V(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function P(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function be(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(H)))}function H(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function Re(){o.batchDepth===0&&H()}function ee(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&H()}}var Z=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{F(this.owner,!1),V(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new D(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Q(e){let n=new Z(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}be(()=>{});var ke=Symbol.for("signal"),je=Symbol.for("memo"),Ne=Symbol.for("signal-node");function d(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Re(),a});return Object.defineProperty(r,ke,{value:!0,enumerable:!0}),Object.defineProperty(r,Ne,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function S(e,n,t){let r=n,s=Y(),u=new b(()=>V(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return we(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,ke,{value:!0,enumerable:!0}),Object.defineProperty(a,je,{value:!0,enumerable:!0}),a}function R(e,n){let t=n;return Q(()=>{t=e(t)})}function Ve(e,n){let t=n;Q(()=>{t=e(t)})}function He(e,n){let t=n;return Q(()=>{t=e(t)})}function k(e){return ee(e)}function w(e){return U(e)}function Oe(e){return ee(e),Promise.resolve()}function Le(){return[()=>!1,Oe]}function Ge(){return H(),Promise.resolve()}function We(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function En(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let f=s[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;P(y=>{T=y;let[A,q]=d(i);p=q,l=n(f,A)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Cn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),S(()=>{let a=e()||[];return w(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,A;P(q=>{A=q;let[O,I]=d(l);y=I;let G=S(E=>{let g=(e()||[])[O()];return g??E},a[l]);x=t(G,O)}),i.push({rendered:x,dispose:A,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return s=f,u=i,i.map(l=>l.rendered)})})}function Dn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),S(()=>{let s=e()||[];return w(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let f,h,l,p=s[i];P(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ne=!1,ze=Symbol.for("signal"),$e=Symbol.for("memo"),Ke=Symbol.for("resource");function te(e){return typeof e=="function"&&e[ze]===!0}function Ye(e){return typeof e=="function"&&e[$e]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function _e(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?_e(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var re=null;function en(e){re=e}function ue(e){re&&re(e)}var oe=null;function nn(e){oe=e}function ae(e){return oe?oe(e):void 0}var se=null;function tn(e){se=e}function ce(){return se?se():void 0}var ie=null;function rn(e){ie=e}function le(e,n){ie&&ie(e,n)}function on(e,n=(t,r)=>t===r){let t=new Map;return R(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=d(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function sn(e,n){let[t,r]=d(e(),n);return R(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function un(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function an(e){return!!e&&typeof e.then=="function"}var de=Symbol();function L(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ce(),a=u!==void 0?ae(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[A,q]=d(void 0,{equals:!1}),O=de,I=!1;R(()=>{let m=r();if(A(),m===!1||m===null||m===void 0){O=de,k(()=>{T("unresolved"),y(void 0),l(void 0)});return}let g=I;if(I=!1,O!==de&&m===O&&!g)return;if(O=m,c){c=!1;return}let W=!1;v(()=>W=!0);let pe=w(p),Ce=w(i),he=pe==="ready"||pe==="refreshing";k(()=>{T(he?"refreshing":"pending"),l(void 0)});try{let _=s(m,{value:Ce,refetching:he});an(_)?(y(_),ue(_),_.then(z=>{W||(u!==void 0&&le(u,z),k(()=>{f(()=>z),T("ready"),y(void 0)}))},z=>{W||k(()=>{l(z),T("errored"),y(void 0)})})):k(()=>{f(()=>_),T("ready"),y(void 0)})}catch(_){if(W)return;k(()=>{l(_),T("errored"),y(void 0)})}});let G=()=>{let m=p();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(G()){let g=x();if(g)throw g}return i()});return Object.defineProperties(E,{state:{get:p},loading:{get:G},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:f,refetch:()=>{I=!0,q(void 0)}}]}function Ae(e,n=300){let[t,r]=d(e),[s,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=w(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(w(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function cn(e){return e!=null&&e!==""}function ln(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=cn}=t,[a,c,i]=Ae(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=L(f,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function X(e){if(typeof e=="function"&&!e.length){let n=e();return te(n)?n:X(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=X(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function dn(e){let n=S(e);return S(()=>X(n()))}var fe=j();Se((e,n)=>{let t=K(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function fn(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function pn(e,n){return N(fe,e,n)}var Ee=j();xe((e,n)=>{let t=K(n,Ee);return t?(t.setError(e),!0):!1});function hn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function Tn(e,n){return N(Ee,e,n)}var yn={State:C,Computed:b,subtle:{Watcher:D,untrack:U,currentComputed:me,hasSinks:ve}};var et=Symbol.for("signal"),nt=Symbol.for("fluixi-proxy");function yt(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function mt(e,n,t){return S(e,n,t)}function vt(e,n){return R(e,n)}function mn(...e){let[n,t]=L(...e);return Object.assign(n,t)}export{nt as $PROXY,et as $SIGNAL,yn as Signal,fe as SuspenseContext,ne as __DEV__,k as batch,qe as createChildOwner,Ve as createComputed,j as createContext,un as createDebounce,ln as createDebouncedResource,Ae as createDebouncedSignal,sn as createDeferred,R as createEffect,hn as createErrorBoundary,S as createMemo,He as createRenderEffect,L as createResource,P as createRoot,on as createSelector,d as createSignal,fn as createSuspenseBoundary,Ie as disposeScope,vt as effect,Ge as flush,Y as getOwner,ae as getServerData,Dn as indexArray,Xe as isComponent,Ye as isMemo,Me as isOwnerDisposed,Ze as isProvider,Qe as isResource,te as isSignal,Je as isSuspense,Cn as keyArray,_e as makeArrayFlat,En as mapArray,mt as memo,ce as nextResourceId,We as on,v as onCleanup,N as provide,Tn as provideErrorBoundary,pn as provideSuspense,dn as readChildren,le as reportResourceData,mn as resource,V as runWithOwner,ge as setOwner,rn as setResourceDataSink,tn as setResourceIdSource,en as setResourceTracker,nn as setServerDataGetter,yt as signal,Oe as startTransition,ue as trackResourcePromise,w as untrack,Ue as useContext,Le as useTransition};
1
+ var De="__fluixi_signal_next_state__",Pe=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},o=globalThis[De]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pe,onSuspend:null,onError:null};var Te=0,ye=1,M=2,$=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(o.untracked)return;let n=o.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},C=class extends ${constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(M);J(this)}}peek(){return this._value}},b=class extends ${constructor(t,r){super();this._threw=!1;this._initialized=!1;this.state=M;this.sources=null;this._fn=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(o.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===ye&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===M)break}(this.state===M||!this._initialized)&&this.recompute(),this.state=Te}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=o.consumer,r=o.untracked;o.consumer=this,o.untracked=!1;let s,u=!1,a;try{s=this._fn()}catch(i){u=!0,a=i,s=this._value}finally{o.consumer=t,o.untracked=r}let c=!this._initialized||this._threw!==u||(u?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=u,this._error=a,this._value=s,c){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(M);J(this)}}markDirty(t){if(this.state>=t)return;let r=this.state===Te;if(this.state=t,r){if(this.observers)for(let s of[...this.observers])s.markDirty(ye);J(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function J(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var D=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function U(e){if(o.untracked)return e();o.untracked=!0;try{return e()}finally{o.untracked=!1}}function me(){return o.consumer}function ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function qe(e){let n=B(e);return e&&(e.owned??=[]).push(n),n}function Ie(e,n=!0){F(e,n)}function Me(e){return!!e&&e.disposed===!0}function B(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e){let n=Symbol("context");return{id:n,defaultValue:e,Provider:r=>{let s=o.owner,u=B(s);(u.contexts=new Map).set(n,r.value),s&&(s.owned??=[]).push(u),o.owner=u;try{return r.children}finally{o.owner=s}}}}function Ue(e){let n=o.owner;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.parent}return e.defaultValue}function K(e,n){let t=e;for(;t;){if(t.contexts&&t.contexts.has(n.id))return t.contexts.get(n.id);t=t.parent}return n.defaultValue}function N(e,n,t){let r=B(o.owner);(r.contexts=new Map).set(e.id,n),o.owner&&(o.owner.owned??=[]).push(r);let s=o.owner;o.owner=r;try{return t()}finally{o.owner=s}}function we(e){o.onSuspend=e}function Se(e){return o.onSuspend?(o.onSuspend(e,o.owner),!0):!1}function xe(e){o.onError=e}function Y(){return o.owner}function ge(e){let n=o.owner;return o.owner=e,n}function V(e,n){let t=o.owner;o.owner=e;try{return n()}finally{o.owner=t}}function v(e){if(o.owner){if(o.owner.disposed){e();return}(o.owner.cleanups??=[]).push(e)}}function F(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)F(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function P(e){let n=B(o.owner);o.owner&&(o.owner.owned??=[]).push(n);let t=o.owner;o.owner=n;try{return e(()=>F(n))}finally{o.owner=t}}function be(e){o.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Fe(e){e.queued||(e.queued=!0,o.queue.push(e),!o.scheduled&&o.batchDepth===0&&(o.scheduled=!0,o.hostSchedule(L)))}function L(){if(o.scheduled=!1,o.flushing)return;o.flushing=!0;let e=0;try{for(;o.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=o.queue;o.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{o.flushing=!1}}function Re(){o.batchDepth===0&&L()}function ee(e){o.batchDepth++;try{return e()}finally{--o.batchDepth===0&&L()}}var Z=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=B(o.owner),o.owner&&(o.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new b(()=>{F(this.owner,!1),V(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new D(()=>Fe(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&o.onSuspend){o.onSuspend(n,this.owner);return}if(o.onError&&o.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),F(this.owner))}};function Q(e){let n=new Z(e);return()=>n.dispose()}function Be(e){return!!e&&typeof e.then=="function"}be(()=>{});var ke=Symbol.for("signal"),je=Symbol.for("memo"),Ne=Symbol.for("signal-node");function d(e,n){let t=new C(e,{equals:n?.equals}),r=(()=>t.get()),s=(u=>{let a=typeof u=="function"?u(t.peek()):u;return t.set(a),Re(),a});return Object.defineProperty(r,ke,{value:!0,enumerable:!0}),Object.defineProperty(r,Ne,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[r,s]}function w(e,n,t){let r=n,s=Y(),u=new b(()=>V(s,()=>{try{return r=e(r)}catch(c){if(Be(c))return Se(c),r;throw c}}),{equals:t?.equals}),a=(()=>u.get());return Object.defineProperty(a,ke,{value:!0,enumerable:!0}),Object.defineProperty(a,je,{value:!0,enumerable:!0}),a}function R(e,n){let t=n;return Q(()=>{t=e(t)})}function Ve(e,n){let t=n;Q(()=>{t=e(t)})}function Le(e,n){let t=n;return Q(()=>{t=e(t)})}function k(e){return ee(e)}function S(e){return U(e)}function _e(e){return ee(e),Promise.resolve()}function He(){return[()=>!1,_e]}function We(){return L(),Promise.resolve()}function Ge(e,n,t){let r=Array.isArray(e),s,u=t?.defer??!1;return a=>{let c=r?e.map(f=>f()):e();if(u){u=!1,s=c;return}let i=U(()=>n(c,s,a));return s=c,i}}function Cn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),w(()=>{let s=e()||[];return S(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=new Map;for(let i of r)u.has(i.item)||u.set(i.item,i);let a=[],c=new Set;for(let i=0;i<s.length;i++){let f=s[i],h=u.get(f);if(h&&!c.has(h))h.setIndex(i),a.push(h),c.add(h);else{let l,p,T;P(y=>{T=y;let[A,q]=d(i);p=q,l=n(f,A)});let x={item:f,rendered:l,dispose:T,setIndex:p};a.push(x),c.add(x)}}for(let i of r)c.has(i)||i.dispose();return r=a,a.map(i=>i.rendered)})})}function Dn(e,n,t,r){let s=[],u=[];return v(()=>{for(let a of u)a.dispose();s=[],u=[]}),w(()=>{let a=e()||[];return S(()=>{if(a.length===0){for(let l of u)l.dispose();return s=[],u=[],r?.fallback?r.fallback():[]}let c=new Map;for(let l=0;l<s.length;l++)c.set(s[l],u[l]);let i=[],f=[],h=new Set;for(let l=0;l<a.length;l++){let p=n(a[l]),T=c.get(p);if(T&&!h.has(p))T.setIndex(l),i.push(T);else{let x,y,A;P(q=>{A=q;let[_,I]=d(l);y=I;let W=w(E=>{let g=(e()||[])[_()];return g??E},a[l]);x=t(W,_)}),i.push({rendered:x,dispose:A,setIndex:y})}f.push(p),h.add(p)}for(let[l,p]of c)h.has(l)||p.dispose();return s=f,u=i,i.map(l=>l.rendered)})})}function Pn(e,n,t){let r=[];return v(()=>{for(let s of r)s.dispose();r=[]}),w(()=>{let s=e()||[];return S(()=>{if(s.length===0){for(let i of r)i.dispose();return r=[],t?.fallback?t.fallback():[]}let u=r.length,a=s.length;for(let i=u;i<a;i++){let f,h,l,p=s[i];P(T=>{l=T;let[x,y]=d(p);h=y,f=n(x,i)}),r.push({rendered:f,setItem:h,dispose:l})}for(let i=a;i<u;i++)r[i].dispose();a<u&&(r=r.slice(0,a));let c=Math.min(u,a);for(let i=0;i<c;i++)r[i].setItem(s[i]);return r.map(i=>i.rendered)})})}var ze=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,ne=typeof process>"u"?ze:!1,$e=Symbol.for("signal"),Ke=Symbol.for("memo"),Ye=Symbol.for("resource");function te(e){return typeof e=="function"&&e[$e]===!0}function Qe(e){return typeof e=="function"&&e[Ke]===!0}function Xe(e){return typeof e=="function"&&e[Ye]===!0}function Je(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Oe(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Oe(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var re=null;function nn(e){re=e}function ue(e){re&&re(e)}var oe=null;function tn(e){oe=e}function ae(e){return oe?oe(e):void 0}var se=null;function rn(e){se=e}function ce(){return se?se():void 0}var ie=null;function on(e){ie=e}function le(e,n){ie&&ie(e,n)}function sn(e,n=(t,r)=>t===r){let t=new Map;return R(()=>{let r=e();for(let[s,u]of t){let[a,c]=u,i=n(s,r);a()!==i&&c(i)}}),r=>{let s=t.get(r);if(!s){let[u,a]=d(!1);s=[u,a],t.set(r,s);let c=e();a(n(r,c))}return s[0]()}}function un(e,n){let[t,r]=d(e(),n);return R(()=>{let s=e();n?.timeoutMs?setTimeout(()=>r(()=>s),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>r(()=>s)):Promise.resolve().then(()=>r(()=>s))}),t}function an(e,n){let t,r=(...s)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...s)},n)};return v(()=>{t!==void 0&&clearTimeout(t)}),r}function cn(e){return!!e&&typeof e.then=="function"}var de=Symbol();function H(e,n,t={}){let r,s;typeof n=="function"?(r=typeof e=="function"?e:()=>e,s=n):(r=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let u=t.transport===!1?void 0:ce(),a=u!==void 0?ae(u):void 0,c=a!==void 0,[i,f]=d(a!==void 0?a.value:t.initialValue,{equals:!1}),[h,l]=d(void 0,{equals:!1}),[p,T]=d(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,y]=d(void 0,{equals:!1}),[A,q]=d(void 0,{equals:!1}),_=de,I=!1;R(()=>{let m=r();if(A(),m===!1||m===null||m===void 0){_=de,k(()=>{T("unresolved"),y(void 0),l(void 0)});return}let g=I;if(I=!1,_!==de&&m===_&&!g)return;if(_=m,c){c=!1;return}let G=!1;v(()=>G=!0);let pe=S(p),Ce=S(i),he=pe==="ready"||pe==="refreshing";k(()=>{T(he?"refreshing":"pending"),l(void 0)});try{let O=s(m,{value:Ce,refetching:he});cn(O)?(y(O),ue(O),O.then(z=>{G||(u!==void 0&&le(u,z),k(()=>{f(()=>z),T("ready"),y(void 0)}))},z=>{G||k(()=>{l(z),T("errored"),y(void 0)})})):k(()=>{f(()=>O),T("ready"),y(void 0)})}catch(O){if(G)return;k(()=>{l(O),T("errored"),y(void 0)})}});let W=()=>{let m=p();return m==="pending"||m==="refreshing"},E=(()=>{let m=h();if(m)throw m;if(W()){let g=x();if(g)throw g}return i()});return Object.defineProperties(E,{state:{get:p},loading:{get:W},error:{get:h},latest:{get:i}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:f,refetch:()=>{I=!0,q(void 0)}}]}function Ae(e,n=300){let[t,r]=d(e),[s,u]=d(e),[a,c]=d(!1),i,f=()=>{i!==void 0&&(clearTimeout(i),i=void 0)},h=()=>{f();let p=S(t);return u(()=>p),c(!1),p},l=(p=>{let T=typeof p=="function"?p(S(t)):p;return r(()=>T),c(!0),f(),i=setTimeout(h,n),T});return v(f),[s,l,{immediate:t,pending:a,flush:h,cancel:()=>{f(),c(!1)}}]}function ln(e){return e!=null&&e!==""}function dn(e,n,t={}){let{delay:r=300,initialValue:s,shouldFetch:u=ln}=t,[a,c,i]=Ae(e,r),f=()=>u(a())?a():!1,[h,{refetch:l}]=H(f,n,s===void 0?{}:{initialValue:s});return[h,{...i,query:a,setQuery:c,refetch:l}]}function X(e){if(typeof e=="function"&&!e.length){let n=e();return te(n)?n:X(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let r=X(e[t]);Array.isArray(r)?n.push.apply(n,r):n.push(r)}return n}return e}function fn(e){let n=w(e);return ne?w(()=>X(n()),void 0,{name:"children"}):w(()=>X(n()))}var fe=j();we((e,n)=>{let t=K(n,fe);t&&(t.increment(),e.finally(()=>t.decrement()))});function pn(){let[e,n]=d(0),t=0;return{increment:()=>n(t+=1),decrement:()=>n(t-=1),inFallback:()=>e()>0}}function hn(e,n){return N(fe,e,n)}var Ee=j();xe((e,n)=>{let t=K(n,Ee);return t?(t.setError(e),!0):!1});function Tn(){let[e,n]=d(void 0,{equals:!1});return{error:e,reset:()=>n(()=>{}),setError:r=>n(()=>r)}}function yn(e,n){return N(Ee,e,n)}var mn={State:C,Computed:b,subtle:{Watcher:D,untrack:U,currentComputed:me,hasSinks:ve}};var nt=Symbol.for("signal"),tt=Symbol.for("fluixi-proxy");function mt(e,n){let[t,r]=d(e,n);return Object.assign(t,{set:r})}function vt(e,n,t){return w(e,n,t)}function wt(e,n){return R(e,n)}function vn(...e){let[n,t]=H(...e);return Object.assign(n,t)}export{tt as $PROXY,nt as $SIGNAL,mn as Signal,fe as SuspenseContext,ne as __DEV__,k as batch,qe as createChildOwner,Ve as createComputed,j as createContext,an as createDebounce,dn as createDebouncedResource,Ae as createDebouncedSignal,un as createDeferred,R as createEffect,Tn as createErrorBoundary,w as createMemo,Le as createRenderEffect,H as createResource,P as createRoot,sn as createSelector,d as createSignal,pn as createSuspenseBoundary,Ie as disposeScope,wt as effect,We as flush,Y as getOwner,ae as getServerData,Pn as indexArray,Je as isComponent,Qe as isMemo,Me as isOwnerDisposed,en as isProvider,Xe as isResource,te as isSignal,Ze as isSuspense,Dn as keyArray,Oe as makeArrayFlat,Cn as mapArray,vt as memo,ce as nextResourceId,Ge as on,v as onCleanup,N as provide,yn as provideErrorBoundary,hn as provideSuspense,fn as readChildren,le as reportResourceData,vn as resource,V as runWithOwner,ge as setOwner,on as setResourceDataSink,rn as setResourceIdSource,nn as setResourceTracker,tn as setServerDataGetter,mt as signal,_e as startTransition,ue as trackResourcePromise,S as untrack,Ue as useContext,He as useTransition};
@@ -1 +1 @@
1
- "use strict";var Te=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Hn=Object.prototype.hasOwnProperty;var Yn=(e,n)=>{for(var t in n)Te(e,t,{get:n[t],enumerable:!0})},Kn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of zn(n))!Hn.call(e,r)&&r!==t&&Te(e,r,{get:()=>n[r],enumerable:!(o=Wn(n,r))||o.enumerable});return e};var Xn=e=>Kn(Te({},"__esModule",{value:!0}),e);var bt={};Yn(bt,{$MEMO:()=>bn,$PROXY:()=>Le,$RESOURCE:()=>yn,$SIGNAL:()=>de,__DEV__:()=>K,batch:()=>_,createComputed:()=>Nn,createContext:()=>he,createDebounce:()=>cn,createDeferred:()=>ln,createEffect:()=>$,createMemo:()=>On,createProvider:()=>En,createRenderEffect:()=>We,createResource:()=>_n,createRoot:()=>Rn,createSelector:()=>Ae,createSignal:()=>U,default:()=>Tt,flush:()=>kn,getOwner:()=>An,getServerData:()=>Ne,getSharedConfig:()=>pt,getSuspenseContext:()=>Un,getSuspenseListContext:()=>In,isComponent:()=>Qe,isMemo:()=>Xe,isProvider:()=>en,isResource:()=>Je,isSignal:()=>X,isSuspense:()=>Ze,makeArrayFlat:()=>me,nextResourceId:()=>Ue,on:()=>Dn,onCleanup:()=>fe,onResolve:()=>Ln,readChildren:()=>Fe,reportResourceData:()=>Ie,resumeEffects:()=>Mn,runWithOwner:()=>Fn,setOwner:()=>dt,setResourceDataSink:()=>hn,setResourceIdSource:()=>pn,setResourceTracker:()=>fn,setScheduler:()=>Bn,setServerDataGetter:()=>dn,sharedConfig:()=>ce,startTransition:()=>$e,trackPromise:()=>jn,trackResourcePromise:()=>qe,untrack:()=>V,useContext:()=>A,useTransition:()=>Pn});module.exports=Xn(bt);function be(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ke(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function z(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var H=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(be(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ke(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(be(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var ne=class extends H{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ye=class extends ne{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends H{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof ne?r=n:r=new ye(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var K=!1,Jn=Symbol.for("signal"),Qn=Symbol.for("memo"),Zn=Symbol.for("resource");function X(e){return typeof e=="function"&&e[Jn]===!0}function Xe(e){return typeof e=="function"&&e[Qn]===!0}function Je(e){return typeof e=="function"&&e[Zn]===!0}function Qe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function me(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?me(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var et="__fluixi_signal_next_state__",nt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[et]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:nt,onSuspend:null,onError:null};var nn=0,tn=1,J=2,te=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},re=class extends te{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(J);we(this)}}peek(){return this._value}},j=class extends te{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===tn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=nn}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked;a.consumer=this,a.untracked=!1;let r,s=!1,l;try{r=this._fn()}catch(f){s=!0,l=f,r=this._value}finally{a.consumer=t,a.untracked=o}let c=!this._initialized||this._threw!==s||(s?l!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=l,this._value=r,c){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(J);we(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===nn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(tn);we(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function we(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var oe=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function tt(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function rn(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Se(){return a.owner}function se(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function Oe(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function xe(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)xe(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function on(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Ce)))}function Ce(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=a.queue;a.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function sn(){a.batchDepth===0&&Ce()}var ge=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=tt(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{xe(this.owner,!1),se(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new oe(()=>rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&a.onSuspend){a.onSuspend(n,this.owner);return}if(a.onError&&a.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),xe(this.owner))}};function un(e){let n=new ge(e);return()=>n.dispose()}function ot(e){return!!e&&typeof e.then=="function"}on(()=>{});var an=Symbol.for("signal"),st=Symbol.for("memo"),it=Symbol.for("signal-node");function Re(e,n){let t=new re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),sn(),l});return Object.defineProperty(o,an,{value:!0,enumerable:!0}),Object.defineProperty(o,it,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function ie(e,n,t){let o=n,r=Se(),s=new j(()=>se(r,()=>{try{return o=e(o)}catch(c){if(ot(c))return rn(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,an,{value:!0,enumerable:!0}),Object.defineProperty(l,st,{value:!0,enumerable:!0}),l}function _e(e,n){let t=n;return un(()=>{t=e(t)})}function Ae(e,n=(t,o)=>t===o){let t=new Map;return _e(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,f=n(r,o);l()!==f&&c(f)}}),o=>{let r=t.get(o);if(!r){let[s,l]=Re(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function ln(e,n){let[t,o]=Re(e(),n);return _e(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function cn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return Oe(()=>{t!==void 0&&clearTimeout(t)}),o}function ue(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:ue(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ue(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Fe(e){let n=ie(e);return ie(()=>ue(n()))}var Ee=null;function fn(e){Ee=e}function qe(e){Ee&&Ee(e)}var ke=null;function dn(e){ke=e}function Ne(e){return ke?ke(e):void 0}var Pe=null;function pn(e){Pe=e}function Ue(){return Pe?Pe():void 0}var De=null;function hn(e){De=e}function Ie(e,n){De&&De(e,n)}var de=Symbol.for("signal"),bn=Symbol.for("memo"),yn=Symbol.for("resource"),Le=Symbol("fluixi-proxy"),mn=Symbol.for("signal-node"),F=0,Q=1,k=2,E=3,u=null,d=null,i=null,ae=null,le=0,ut=!1,Me=!1,G=0,at=1e6,m=new WeakMap,g=null;var lt=null,ct=new Map,ft=0,ce={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function dt(e){u=e,ce.owner=e,ce.context=e}function pt(){return ce}function ht(){return`node_${++ft}_${Date.now()}`}function vt(e){!1}function wn(e,n,t){let o={id:ht(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return vt(o),o}function xn(e,n){return e===n}function Ge(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var Be=null,je=null;function gn(){if(!Be){let[e,n]=U(!1);Be=e,je=n}}function Sn(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)Z(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=i;d=null,i=[],e.accessor(),d=n;let o=i;if(i=t,o.length>0){let r=i;pe(o),i=r}}}function vn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function U(e,n){let t=e;typeof t=="object"&&t&&Le in t&&delete t[Le];let o=wn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];m.set(r,new Set);let s;function l(){let f=d;if(f){f.sources?f.sources.indexOf(r)===-1&&f.sources.push(r):f.sources=[r];let p=m.get(r);p&&!p.has(f)&&p.add(f)}return t}function c(f){let p=typeof f=="function"?f(t):f,b=o.equals||xn;if(n?.equals===!1||!b(t,p)){t=p,o.value=p,o.version++,o.updated=Date.now();let P=m.get(r);if(P&&P.size>0){let D=function(h,v=!1){let q=h.state;if(!(q===E&&h===d)){if(v&&!h.pure){q===F&&(h.state=Q,ut&&(i!==null&&i.indexOf(h)===-1?i.push(h):C.push(h)));return}if(!w.has(h)&&(w.add(h),h.state=k,q===F||q===Q?C.push(h):!h.pure&&i!==null&&i.indexOf(h)===-1&&i.push(h),h.pure&&h.accessor)){let O=m.get(h.accessor);O&&vn(Array.from(O),R=>D(R,!0))}}};var x=D;let S=Array.from(P),C=[],w=new Set;vn(S,D);for(let h of C)Sn(h)}}}return l.toObservable=()=>new Y(f=>{let p=!0;return $(()=>{let x=l();p?p=!1:f.next(x)})}),Object.defineProperty(l,de,{value:!0,enumerable:!0}),Object.defineProperty(l,mn,{value:o,enumerable:!1}),r}function $(e,n,t){let o={fn:e,state:k,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),Ve(o,n),()=>I(o)}function Ve(e,n){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let t=d,o=u;if(d=e,u=e,le++,le>at)throw le=0,d=t,u=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=E;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=t,u=o}}function Z(e){if(!(e.disposed||!e.fn||e.state===F)&&(e.state===k||e.state===Q||e.state===E)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)I(e.owned[n]);e.owned=null}e.renderEffect?qn(e):Ve(e,e.value)}}function I(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=m.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)I(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function On(e,n,t){let o=wn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:k,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};u&&(u.owned?u.owned.push(r):u.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;m.has(c)||m.set(c,new Set);let f=m.get(c);f&&f.add(d)}if(r.state!==F){if(r.sources){for(let p of r.sources){let b=m.get(p);b&&b.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let p=0;p<r.cleanups.length;p++)r.cleanups[p]();r.cleanups=null}if(r.owned){for(let p=0;p<r.owned.length;p++)I(r.owned[p]);r.owned=null}let c=d,f=u;d=r,u=r,r.state=E;try{let p=r.fn(r.value),b=o.equals||xn;if(t?.equals===!1||!b(r.value,p)){r.value=p,o.value=p,o.version++,o.updated=Date.now();let P=s,S=m.get(P);if(S&&S.size>0){let h=function(v,q=!1){if(v===r)return;let O=v.state;if(O!==E){if(q&&!v.pure){O===F&&(v.state=Q,i!==null&&i.indexOf(v)===-1?i.push(v):w.push(v));return}if(!D.has(v)&&(D.add(v),v.state=k,O===F||O===Q?w.push(v):!v.pure&&i!==null&&i.indexOf(v)===-1&&i.push(v),v.pure&&v.accessor)){let R=m.get(v.accessor);if(R&&R.size>0)for(let W of Array.from(R))h(W,!0)}}};var l=h;let C=Array.from(S),w=[],D=new Set;for(let v=0;v<C.length;v++)h(C[v]);for(let v of w)Sn(v)}}r.state===E&&(r.state=F)}catch(p){if(z(p)){let b=T&&A(T);if(!b&&T){let x=f;for(;x;){if(x.contexts?.has(T.id)){b=x.contexts.get(T.id);break}x=x.owner}}return b&&(b.increment(),p.finally(()=>b.decrement())),r.value}Ge(p)}finally{d=c,u=f}}return r.value};return r.accessor=s,m.set(s,new Set),s.toObservable=()=>new Y(l=>{let c=!0;return $(()=>{let p=s();c?c=!1:l.next(p)})}),Object.defineProperty(s,de,{value:!0,enumerable:!0}),Object.defineProperty(s,bn,{value:!0,enumerable:!0}),Object.defineProperty(s,mn,{value:o,enumerable:!1}),s}function pe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=m.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=i.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?n.indexOf(c)===-1&&n.push(c):(c.computed||!c.pure)&&t.indexOf(c)===-1&&t.push(c)}i=null;for(let r of t)(r.computed||!r.pure)&&Z(r)}function _(e){if(i&&G>0)return e();if(i&&G===0){let n=i,t=[];i=t,G++;let o;try{o=e()}finally{G--,i=n}let r=i;return pe(t),i=r,o}G++,i=[],ae=[];try{return e()}finally{G--,Cn()}}function Cn(){if(!Me){Me=!0,le=0;try{for(;i&&i.length>0;){let e=i;i=null,pe(e)}if(i=null,ae){let e=ae;ae=null;for(let n=0;n<e.length;n++)Z(e[n])}}finally{Me=!1}}}function Rn(e){let n={owned:null,cleanups:null,contexts:null,owner:u},t=d;d=null;let o=u;u=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)I(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{u=o,d=t}}function V(e){let n=d;d=null;try{return e()}finally{d=n}}function fe(e){u&&(u.cleanups?u.cleanups.push(e):u.cleanups=[e])}function _n(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:l}=t,c=t.transport===!1?void 0:Ue(),f=c!==void 0?Ne(c):void 0,p=f!==void 0,[b,x]=U(f!==void 0?f.value:t.initialValue,{equals:!1}),[P,S]=U(void 0,{equals:!1}),[C,w]=U(f!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,h]=U(void 0,{equals:!1}),[v,q]=U(void 0,{equals:!1}),O=Symbol(),R=O,W=!1,Gn=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},Vn=$(()=>{let y=o?o():e;if(v(),y===!1||y===null||y===void 0){R=O,_(()=>{w("unresolved"),h(void 0),S(void 0)});return}let L=W;if(W=!1,R!==O&&y===R&&!L)return;if(R=y,p){p=!1;return}let B=!1;fe(()=>B=!0);let He=V(C),$n=V(b),Ye=He==="ready"||He==="refreshing";_(()=>{w(Ye?"refreshing":"pending"),S(void 0)});try{let N=r(y,{value:$n,refetching:Ye});if(z(N)){h(N),qe(N),N.then(M=>{B||(c!==void 0&&Ie(c,M),_(()=>{x(()=>M),Gn(M),w("ready"),h(void 0)}))},M=>{B||_(()=>{S(M),w("errored"),h(void 0)})}).catch(M=>{B||_(()=>{S(M),w("errored"),h(void 0)})});let ve=T&&A(T);ve&&(ve.increment(),N.finally(()=>ve.decrement()))}else{if(B)return;_(()=>{x(()=>N),w("ready"),h(void 0)})}}catch(N){if(B)return;_(()=>{S(N),w("errored"),h(void 0)})}});fe(Vn);let ze=()=>{let y=C();return y==="pending"||y==="refreshing"},ee=(()=>{let y=P();if(y)throw y;if(ze()){let L=D();if(L)throw L}return b()});return Object.defineProperty(ee,yn,{value:!0,enumerable:!0}),Object.defineProperty(ee,de,{value:!0,enumerable:!0}),Object.defineProperties(ee,{state:{get:C},loading:{get:()=>ze()},error:{get:P},latest:{get:b}}),[ee,{mutate:x,refetch:()=>{W=!0,q(void 0)}}]}function An(){return u}function Fn(e,n){let t=u,o=d;u=e,d=null;try{return n()}finally{u=t,d=o}}function he(e){let n=Symbol("context"),t=En(n);return{id:n,Provider:t,defaultValue:e}}function En(e){return n=>{let t=u;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return We(()=>{o=V(()=>{let r=u;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Fe(()=>n.children)})}),o}}function A(e){let n=u;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function kn(){return new Promise(e=>{queueMicrotask(()=>{Cn(),e()})})}function $e(e){if(g&&g.running)return e(),g.done;gn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};g=o;try{e()}finally{o.running=!1}return o.effects.length?(je(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,je(!1),r.length&&_(()=>{for(let s of r)s.state=k,Z(s)}),n()}),t):(g=null,n(),t)}function Pn(){return gn(),[Be,$e]}function Dn(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):V(()=>n(l,s))}}function We(e,n,t){let o={fn:e,state:k,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),qn(o),()=>I(o)}function qn(e){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let n=d,t=u,o=i;d=e,u=e,i===null&&(i=[]),e.state=E;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=n,u=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;pe(r),i=s}}}function Nn(e,n,t){let o={fn:e,state:k,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,computed:!0,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]),g&&g.running?(i||(i=[]),i.indexOf(o)===-1&&i.push(o)):i?i.indexOf(o)===-1&&i.push(o):Ve(o,n)}var T;function Un(){return T||(T=he())}var Tn;function In(){return Tn||(Tn=he())}function Mn(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=k,Z(t)}function Ln(e){let n=T&&A(T);n&&n.inFallback()?$(()=>{n.inFallback()||e()}):e()}function Bn(e){lt=e}function jn(e){let n=T&&A(T);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var Tt={createSignal:U,createEffect:$,createMemo:On,createComputed:Nn,createRoot:Rn,createSelector:Ae,createResource:_n,batch:_,untrack:V,onCleanup:fe,getOwner:An,runWithOwner:Fn,createContext:he,useContext:A,flush:kn,startTransition:$e,useTransition:Pn,isSignal:X,on:Dn,createRenderEffect:We,getSuspenseContext:Un,getSuspenseListContext:In,resumeEffects:Mn,onResolve:Ln,setScheduler:Bn,trackPromise:jn};
1
+ "use strict";var Te=Object.defineProperty;var Wn=Object.getOwnPropertyDescriptor;var zn=Object.getOwnPropertyNames;var Hn=Object.prototype.hasOwnProperty;var Yn=(e,n)=>{for(var t in n)Te(e,t,{get:n[t],enumerable:!0})},Kn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of zn(n))!Hn.call(e,r)&&r!==t&&Te(e,r,{get:()=>n[r],enumerable:!(o=Wn(n,r))||o.enumerable});return e};var Xn=e=>Kn(Te({},"__esModule",{value:!0}),e);var yt={};Yn(yt,{$MEMO:()=>bn,$PROXY:()=>Le,$RESOURCE:()=>yn,$SIGNAL:()=>de,__DEV__:()=>K,batch:()=>R,createComputed:()=>Un,createContext:()=>he,createDebounce:()=>cn,createDeferred:()=>ln,createEffect:()=>$,createMemo:()=>On,createProvider:()=>En,createRenderEffect:()=>We,createResource:()=>Rn,createRoot:()=>_n,createSelector:()=>Ae,createSignal:()=>N,default:()=>bt,flush:()=>Pn,getOwner:()=>An,getServerData:()=>Ue,getSharedConfig:()=>ht,getSuspenseContext:()=>Nn,getSuspenseListContext:()=>In,isComponent:()=>Qe,isMemo:()=>Xe,isProvider:()=>en,isResource:()=>Je,isSignal:()=>X,isSuspense:()=>Ze,makeArrayFlat:()=>me,nextResourceId:()=>Ne,on:()=>Dn,onCleanup:()=>fe,onResolve:()=>Ln,readChildren:()=>Fe,reportResourceData:()=>Ie,resumeEffects:()=>Mn,runWithOwner:()=>Fn,setOwner:()=>pt,setResourceDataSink:()=>hn,setResourceIdSource:()=>pn,setResourceTracker:()=>fn,setScheduler:()=>Bn,setServerDataGetter:()=>dn,sharedConfig:()=>ce,startTransition:()=>$e,trackPromise:()=>jn,trackResourcePromise:()=>qe,untrack:()=>V,useContext:()=>A,useTransition:()=>kn});module.exports=Xn(yt);function be(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Ke(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function z(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var H=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(be(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Ke(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(be(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var ne=class extends H{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ye=class extends ne{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends H{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof ne?r=n:r=new ye(n,t,o);let{_subscribe:s}=this;try{let l=s.call(this,r);l&&(typeof l=="function"||typeof l.unsubscribe=="function")&&r.add(l)}catch(l){r.error(l)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var Jn=typeof window>"u"?!1:window.__FLUIXI_PROD__===!0,K=typeof process>"u"?Jn:!1,Qn=Symbol.for("signal"),Zn=Symbol.for("memo"),et=Symbol.for("resource");function X(e){return typeof e=="function"&&e[Qn]===!0}function Xe(e){return typeof e=="function"&&e[Zn]===!0}function Je(e){return typeof e=="function"&&e[et]===!0}function Qe(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ze(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function en(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function me(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?me(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var nt="__fluixi_signal_next_state__",tt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[nt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:tt,onSuspend:null,onError:null};var nn=0,tn=1,J=2,te=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let n=a.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},re=class extends te{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(J);we(this)}}peek(){return this._value}},j=class extends te{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===tn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=nn}recompute(){if(this.sources){for(let f of this.sources)f.observers?.delete(this);this.sources.clear()}let t=a.consumer,o=a.untracked;a.consumer=this,a.untracked=!1;let r,s=!1,l;try{r=this._fn()}catch(f){s=!0,l=f,r=this._value}finally{a.consumer=t,a.untracked=o}let c=!this._initialized||this._threw!==s||(s?l!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=l,this._value=r,c){if(this.version++,this.observers)for(let f of[...this.observers])f.markDirty(J);we(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===nn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(tn);we(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function we(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var oe=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function rt(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function rn(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Se(){return a.owner}function se(e,n){let t=a.owner;a.owner=e;try{return n()}finally{a.owner=t}}function Oe(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function xe(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)xe(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function on(e){a.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ot(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Ce)))}function Ce(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=a.queue;a.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function sn(){a.batchDepth===0&&Ce()}var ge=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=rt(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new j(()=>{xe(this.owner,!1),se(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new oe(()=>ot(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&a.onSuspend){a.onSuspend(n,this.owner);return}if(a.onError&&a.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),xe(this.owner))}};function un(e){let n=new ge(e);return()=>n.dispose()}function st(e){return!!e&&typeof e.then=="function"}on(()=>{});var an=Symbol.for("signal"),it=Symbol.for("memo"),ut=Symbol.for("signal-node");function _e(e,n){let t=new re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let l=typeof s=="function"?s(t.peek()):s;return t.set(l),sn(),l});return Object.defineProperty(o,an,{value:!0,enumerable:!0}),Object.defineProperty(o,ut,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function ie(e,n,t){let o=n,r=Se(),s=new j(()=>se(r,()=>{try{return o=e(o)}catch(c){if(st(c))return rn(c),o;throw c}}),{equals:t?.equals}),l=(()=>s.get());return Object.defineProperty(l,an,{value:!0,enumerable:!0}),Object.defineProperty(l,it,{value:!0,enumerable:!0}),l}function Re(e,n){let t=n;return un(()=>{t=e(t)})}function Ae(e,n=(t,o)=>t===o){let t=new Map;return Re(()=>{let o=e();for(let[r,s]of t){let[l,c]=s,f=n(r,o);l()!==f&&c(f)}}),o=>{let r=t.get(o);if(!r){let[s,l]=_e(!1);r=[s,l],t.set(o,r);let c=e();l(n(o,c))}return r[0]()}}function ln(e,n){let[t,o]=_e(e(),n);return Re(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function cn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return Oe(()=>{t!==void 0&&clearTimeout(t)}),o}function ue(e){if(typeof e=="function"&&!e.length){let n=e();return X(n)?n:ue(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ue(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Fe(e){let n=ie(e);return K?ie(()=>ue(n()),void 0,{name:"children"}):ie(()=>ue(n()))}var Ee=null;function fn(e){Ee=e}function qe(e){Ee&&Ee(e)}var Pe=null;function dn(e){Pe=e}function Ue(e){return Pe?Pe(e):void 0}var ke=null;function pn(e){ke=e}function Ne(){return ke?ke():void 0}var De=null;function hn(e){De=e}function Ie(e,n){De&&De(e,n)}var de=Symbol.for("signal"),bn=Symbol.for("memo"),yn=Symbol.for("resource"),Le=Symbol("fluixi-proxy"),mn=Symbol.for("signal-node"),F=0,Q=1,P=2,E=3,u=null,d=null,i=null,ae=null,le=0,at=!1,Me=!1,G=0,lt=1e6,m=new WeakMap,g=null;var ct=null,ft=new Map,dt=0,ce={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function pt(e){u=e,ce.owner=e,ce.context=e}function ht(){return ce}function vt(){return`node_${++dt}_${Date.now()}`}function Tt(e){K&&ft.set(e.id,new WeakRef(e))}function wn(e,n,t){let o={id:vt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Tt(o),o}function xn(e,n){return e===n}function Ge(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var Be=null,je=null;function gn(){if(!Be){let[e,n]=N(!1);Be=e,je=n}}function Sn(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(g&&g.running&&!e.pure)g.effects.indexOf(e)===-1&&g.effects.push(e);else if(!e.pure||e.computed)Z(e);else if(e.pure&&!e.computed&&e.accessor){let n=d,t=i;d=null,i=[],e.accessor(),d=n;let o=i;if(i=t,o.length>0){let r=i;pe(o),i=r}}}function vn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function N(e,n){let t=e;typeof t=="object"&&t&&Le in t&&delete t[Le];let o=wn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[l,c];m.set(r,new Set);let s;function l(){let f=d;if(f){f.sources?f.sources.indexOf(r)===-1&&f.sources.push(r):f.sources=[r];let p=m.get(r);p&&!p.has(f)&&p.add(f)}return t}function c(f){let p=typeof f=="function"?f(t):f,b=o.equals||xn;if(n?.equals===!1||!b(t,p)){t=p,o.value=p,o.version++,o.updated=Date.now();let k=m.get(r);if(k&&k.size>0){let D=function(h,v=!1){let q=h.state;if(!(q===E&&h===d)){if(v&&!h.pure){q===F&&(h.state=Q,at&&(i!==null&&i.indexOf(h)===-1?i.push(h):C.push(h)));return}if(!w.has(h)&&(w.add(h),h.state=P,q===F||q===Q?C.push(h):!h.pure&&i!==null&&i.indexOf(h)===-1&&i.push(h),h.pure&&h.accessor)){let O=m.get(h.accessor);O&&vn(Array.from(O),_=>D(_,!0))}}};var x=D;let S=Array.from(k),C=[],w=new Set;vn(S,D);for(let h of C)Sn(h)}}}return l.toObservable=()=>new Y(f=>{let p=!0;return $(()=>{let x=l();p?p=!1:f.next(x)})}),Object.defineProperty(l,de,{value:!0,enumerable:!0}),Object.defineProperty(l,mn,{value:o,enumerable:!1}),r}function $(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),Ve(o,n),()=>I(o)}function Ve(e,n){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let t=d,o=u;if(d=e,u=e,le++,le>lt)throw le=0,d=t,u=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=E;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=t,u=o}}function Z(e){if(!(e.disposed||!e.fn||e.state===F)&&(e.state===P||e.state===Q||e.state===E)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)I(e.owned[n]);e.owned=null}e.renderEffect?qn(e):Ve(e,e.value)}}function I(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=m.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)I(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function On(e,n,t){let o=wn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};u&&(u.owned?u.owned.push(r):u.owned=[r]);let s=()=>{if(d&&d!==r){d.sources?d.sources.indexOf(s)===-1&&d.sources.push(s):d.sources=[s];let c=s;m.has(c)||m.set(c,new Set);let f=m.get(c);f&&f.add(d)}if(r.state!==F){if(r.sources){for(let p of r.sources){let b=m.get(p);b&&b.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let p=0;p<r.cleanups.length;p++)r.cleanups[p]();r.cleanups=null}if(r.owned){for(let p=0;p<r.owned.length;p++)I(r.owned[p]);r.owned=null}let c=d,f=u;d=r,u=r,r.state=E;try{let p=r.fn(r.value),b=o.equals||xn;if(t?.equals===!1||!b(r.value,p)){r.value=p,o.value=p,o.version++,o.updated=Date.now();let k=s,S=m.get(k);if(S&&S.size>0){let h=function(v,q=!1){if(v===r)return;let O=v.state;if(O!==E){if(q&&!v.pure){O===F&&(v.state=Q,i!==null&&i.indexOf(v)===-1?i.push(v):w.push(v));return}if(!D.has(v)&&(D.add(v),v.state=P,O===F||O===Q?w.push(v):!v.pure&&i!==null&&i.indexOf(v)===-1&&i.push(v),v.pure&&v.accessor)){let _=m.get(v.accessor);if(_&&_.size>0)for(let W of Array.from(_))h(W,!0)}}};var l=h;let C=Array.from(S),w=[],D=new Set;for(let v=0;v<C.length;v++)h(C[v]);for(let v of w)Sn(v)}}r.state===E&&(r.state=F)}catch(p){if(z(p)){let b=T&&A(T);if(!b&&T){let x=f;for(;x;){if(x.contexts?.has(T.id)){b=x.contexts.get(T.id);break}x=x.owner}}return b&&(b.increment(),p.finally(()=>b.decrement())),r.value}Ge(p)}finally{d=c,u=f}}return r.value};return r.accessor=s,m.set(s,new Set),s.toObservable=()=>new Y(l=>{let c=!0;return $(()=>{let p=s();c?c=!1:l.next(p)})}),Object.defineProperty(s,de,{value:!0,enumerable:!0}),Object.defineProperty(s,bn,{value:!0,enumerable:!0}),Object.defineProperty(s,mn,{value:o,enumerable:!1}),s}function pe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);i=[];let o=0;for(;o<n.length;){let r=n[o++],s=m.get(r.accessor);if(s&&s.size>0){let c=d;d=null,r.accessor(),d=c}let l=i.splice(0);for(let c of l)c.pure&&!c.computed&&c.accessor?n.indexOf(c)===-1&&n.push(c):(c.computed||!c.pure)&&t.indexOf(c)===-1&&t.push(c)}i=null;for(let r of t)(r.computed||!r.pure)&&Z(r)}function R(e){if(i&&G>0)return e();if(i&&G===0){let n=i,t=[];i=t,G++;let o;try{o=e()}finally{G--,i=n}let r=i;return pe(t),i=r,o}G++,i=[],ae=[];try{return e()}finally{G--,Cn()}}function Cn(){if(!Me){Me=!0,le=0;try{for(;i&&i.length>0;){let e=i;i=null,pe(e)}if(i=null,ae){let e=ae;ae=null;for(let n=0;n<e.length;n++)Z(e[n])}}finally{Me=!1}}}function _n(e){let n={owned:null,cleanups:null,contexts:null,owner:u},t=d;d=null;let o=u;u=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)I(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{u=o,d=t}}function V(e){let n=d;d=null;try{return e()}finally{d=n}}function fe(e){u&&(u.cleanups?u.cleanups.push(e):u.cleanups=[e])}function Rn(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:l}=t,c=t.transport===!1?void 0:Ne(),f=c!==void 0?Ue(c):void 0,p=f!==void 0,[b,x]=N(f!==void 0?f.value:t.initialValue,{equals:!1}),[k,S]=N(void 0,{equals:!1}),[C,w]=N(f!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[D,h]=N(void 0,{equals:!1}),[v,q]=N(void 0,{equals:!1}),O=Symbol(),_=O,W=!1,Gn=y=>{if(!(typeof localStorage>"u"))try{y&&localStorage.setItem("storage",JSON.stringify({data:y,timestamp:Date.now()}))}catch(L){console.error(`Failed to save resource to cache (${l}):`,L)}},Vn=$(()=>{let y=o?o():e;if(v(),y===!1||y===null||y===void 0){_=O,R(()=>{w("unresolved"),h(void 0),S(void 0)});return}let L=W;if(W=!1,_!==O&&y===_&&!L)return;if(_=y,p){p=!1;return}let B=!1;fe(()=>B=!0);let He=V(C),$n=V(b),Ye=He==="ready"||He==="refreshing";R(()=>{w(Ye?"refreshing":"pending"),S(void 0)});try{let U=r(y,{value:$n,refetching:Ye});if(z(U)){h(U),qe(U),U.then(M=>{B||(c!==void 0&&Ie(c,M),R(()=>{x(()=>M),Gn(M),w("ready"),h(void 0)}))},M=>{B||R(()=>{S(M),w("errored"),h(void 0)})}).catch(M=>{B||R(()=>{S(M),w("errored"),h(void 0)})});let ve=T&&A(T);ve&&(ve.increment(),U.finally(()=>ve.decrement()))}else{if(B)return;R(()=>{x(()=>U),w("ready"),h(void 0)})}}catch(U){if(B)return;R(()=>{S(U),w("errored"),h(void 0)})}});fe(Vn);let ze=()=>{let y=C();return y==="pending"||y==="refreshing"},ee=(()=>{let y=k();if(y)throw y;if(ze()){let L=D();if(L)throw L}return b()});return Object.defineProperty(ee,yn,{value:!0,enumerable:!0}),Object.defineProperty(ee,de,{value:!0,enumerable:!0}),Object.defineProperties(ee,{state:{get:C},loading:{get:()=>ze()},error:{get:k},latest:{get:b}}),[ee,{mutate:x,refetch:()=>{W=!0,q(void 0)}}]}function An(){return u}function Fn(e,n){let t=u,o=d;u=e,d=null;try{return n()}finally{u=t,d=o}}function he(e){let n=Symbol("context"),t=En(n);return{id:n,Provider:t,defaultValue:e}}function En(e){return n=>{let t=u;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return We(()=>{o=V(()=>{let r=u;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Fe(()=>n.children)})}),o}}function A(e){let n=u;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function Pn(){return new Promise(e=>{queueMicrotask(()=>{Cn(),e()})})}function $e(e){if(g&&g.running)return e(),g.done;gn();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};g=o;try{e()}finally{o.running=!1}return o.effects.length?(je(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);g=null,je(!1),r.length&&R(()=>{for(let s of r)s.state=P,Z(s)}),n()}),t):(g=null,n(),t)}function kn(){return gn(),[Be,$e]}function Dn(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let l=e();return o&&r?(r=!1,s):V(()=>n(l,s))}}function We(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};u&&(u.owned?u.owned.push(o):u.owned=[o]);let r=T&&A(T);return r&&(o.suspense=r),qn(o),()=>I(o)}function qn(e){if(e.sources){for(let r of e.sources){let s=m.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)I(e.owned[r]);e.owned=null}let n=d,t=u,o=i;d=e,u=e,i===null&&(i=[]),e.state=E;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===E&&(e.state=F)}catch(r){if(z(r)){let s=T&&A(T);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ge(r)}finally{d=n,u=t;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;pe(r),i=s}}}function Un(e,n,t){let o={fn:e,state:P,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:u,contexts:null,pure:!0,computed:!0,updatedAt:null};u&&(u.owned?u.owned.push(o):u.owned=[o]),g&&g.running?(i||(i=[]),i.indexOf(o)===-1&&i.push(o)):i?i.indexOf(o)===-1&&i.push(o):Ve(o,n)}var T;function Nn(){return T||(T=he())}var Tn;function In(){return Tn||(Tn=he())}function Mn(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=P,Z(t)}function Ln(e){let n=T&&A(T);n&&n.inFallback()?$(()=>{n.inFallback()||e()}):e()}function Bn(e){ct=e}function jn(e){let n=T&&A(T);return n&&(n.increment(),e.finally(()=>n.decrement())),e}var bt={createSignal:N,createEffect:$,createMemo:On,createComputed:Un,createRoot:_n,createSelector:Ae,createResource:Rn,batch:R,untrack:V,onCleanup:fe,getOwner:An,runWithOwner:Fn,createContext:he,useContext:A,flush:Pn,startTransition:$e,useTransition:kn,isSignal:X,on:Dn,createRenderEffect:We,getSuspenseContext:Nn,getSuspenseListContext:In,resumeEffects:Mn,onResolve:Ln,setScheduler:Bn,trackPromise:jn};