@fluixi/reactive 1.0.0-alpha.70 → 1.0.0-alpha.72

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 xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>ht,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>bt,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.70";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,br,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=s.get(p);if(h&&!c.has(h))h.setIndex(u),i.push(h),c.add(h);else{let l,d,b;E(T=>{b=T;let[C,K]=f(u);d=K,l=t(p,C)});let w={item:p,rendered:l,dispose:b,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],h=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),b=c.get(d);if(b&&!h.has(d))b.setIndex(l),u.push(b);else{let w,T,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),h.add(d)}for(let[l,d]of c)h.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,h,l,d=o[u];E(b=>{l=b;let[w,T]=f(d);h=T,p=t(w,u)}),n.push({rendered:p,setItem:h,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[h,l]=f(void 0,{equals:!1}),[d,b]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,_!==Ie&&m===_&&!g)return;if(_=m,c){c=!1;return}let te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{b(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),b("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),b("errored"),T(void 0)})})):O(()=>{p(()=>k),b("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),b("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=h();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:h},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let b=typeof d=="function"?d(S(r)):d;return n(()=>b),c(!0),p(),u=setTimeout(h,t),b});return v(p),[o,l,{immediate:r,pending:i,flush:h,cancel:()=>{p(),c(!1)}}]}function gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[h,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[h,{...u,query:i,setQuery:c,refetch:l}]}function ye(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=x(e);return x(()=>ye(t()))}var he=N();rt((e,t)=>{let r=se(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(he,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}
1
+ "use strict";var xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>ht,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>bt,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.72";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,br,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=s.get(p);if(h&&!c.has(h))h.setIndex(u),i.push(h),c.add(h);else{let l,d,b;E(T=>{b=T;let[C,K]=f(u);d=K,l=t(p,C)});let w={item:p,rendered:l,dispose:b,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],h=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),b=c.get(d);if(b&&!h.has(d))b.setIndex(l),u.push(b);else{let w,T,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),h.add(d)}for(let[l,d]of c)h.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,h,l,d=o[u];E(b=>{l=b;let[w,T]=f(d);h=T,p=t(w,u)}),n.push({rendered:p,setItem:h,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[h,l]=f(void 0,{equals:!1}),[d,b]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,_!==Ie&&m===_&&!g)return;if(_=m,c){c=!1;return}let te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{b(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),b("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),b("errored"),T(void 0)})})):O(()=>{p(()=>k),b("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),b("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=h();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:h},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let b=typeof d=="function"?d(S(r)):d;return n(()=>b),c(!0),p(),u=setTimeout(h,t),b});return v(p),[o,l,{immediate:r,pending:i,flush:h,cancel:()=>{p(),c(!1)}}]}function gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[h,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[h,{...u,query:i,setQuery:c,refetch:l}]}function ye(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=x(e);return x(()=>ye(t()))}var he=N();rt((e,t)=>{let r=se(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(he,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}
@@ -1 +1 @@
1
- "use strict";var Fluixi=(()=>{var xe=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var jt=(e,r)=>{for(var t in r)xe(e,t,{get:r[t],enumerable:!0})},_t=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xt(r))!kt.call(e,o)&&o!==t&&xe(e,o,{get:()=>r[o],enumerable:!(n=Ot(r,o))||n.enumerable});return e};var Pt=e=>_t(xe({},"__esModule",{value:!0}),e);var mn={};jt(mn,{$NAME:()=>st,$NODE:()=>R,$PROXY:()=>zt,$RAW:()=>re,$SELF:()=>we,$SIGNAL:()=>Kt,$STORE:()=>at,$TRACK:()=>Se,Observable:()=>F,SafeSubscriber:()=>ie,Signal:()=>Vr,Store:()=>k,StoreAPI:()=>At,Subject:()=>je,Subscriber:()=>I,Subscription:()=>D,SuspenseContext:()=>me,VERSION:()=>rr,__DEV__:()=>le,batch:()=>T,createChildOwner:()=>ur,createComputed:()=>gr,createComputedStore:()=>pt,createContext:()=>q,createDebounce:()=>Dr,createDebouncedResource:()=>Ir,createDebouncedSignal:()=>qe,createDeferred:()=>Cr,createEffect:()=>$,createErrorBoundary:()=>Ur,createMemo:()=>w,createMutableStore:()=>Ze,createRenderEffect:()=>vr,createResource:()=>he,createRoot:()=>P,createSelector:()=>Er,createSignal:()=>d,createStore:()=>Je,createStoreEffect:()=>dt,createStoreMemo:()=>yt,createSuspenseBoundary:()=>Mr,disposeScope:()=>lr,flush:()=>wr,getNode:()=>mt,getOwner:()=>Z,getServerData:()=>pe,getStoreNode:()=>gt,indexArray:()=>qt,isComponent:()=>xr,isMemo:()=>Tr,isOwnerDisposed:()=>cr,isProvider:()=>jr,isResource:()=>Or,isSignal:()=>ce,isStore:()=>bt,isStoreProxy:()=>Oe,isSuspense:()=>kr,keyArray:()=>Nt,makeArrayFlat:()=>Ce,mapArray:()=>Mt,modifiable:()=>vt,nextResourceId:()=>de,on:()=>Sr,onCleanup:()=>v,operate:()=>$t,produceUtil:()=>wt,provide:()=>U,provideErrorBoundary:()=>Br,provideSuspense:()=>Nr,readChildren:()=>Fr,reconcileUtil:()=>St,reportResourceData:()=>ye,runWithOwner:()=>B,setOwner:()=>$e,setResourceDataSink:()=>Rr,setResourceIdSource:()=>$r,setResourceTracker:()=>_r,setServerDataGetter:()=>Pr,startTransition:()=>Ee,trackResourcePromise:()=>fe,untrack:()=>A,untrackStore:()=>Ye,unwrap:()=>W,useContext:()=>fr,useTransition:()=>Ar,wrap:()=>ht});var rr="1.0.0-alpha.70";function ke(e){return typeof e=="function"&&!tr(e)}var nr=e=>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 tr(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var D=class e{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:t}=this;if(r instanceof e)r.remove(this);else if(r!==null)for(let n of r)n.remove(this);if(t){for(let n of t)if(ke(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(nr(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:t,_subscriptions:n}=this;if(t){if(ke(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof e&&r._addParent(this),this}remove(r){let{_subscriptions:t}=this;if(!t)return;let n=t.indexOf(r);n!==-1&&(t.splice(n,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(r):this._parentOrParents=[t,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:t}=this;if(t===r)this._parentOrParents=null;else if(Array.isArray(t)){let n=t.indexOf(r);n!==-1&&(t.splice(n,1),t.length===1&&(this._parentOrParents=t[0]))}}};var I=class extends D{constructor(t,n,o){super();this.isStopped=!1;let i;t?typeof t=="object"?i=t:i={next:t,error:n,complete:o}:i={},this.destination=i}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(n){throw n}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())}},ie=class extends I{constructor(t,n,o,i){super(t,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(n){this.error(n)}}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)}};function $t(e){return new I(e.next,e.error,e.complete)}var F=class extends D{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,t,n){let o;r instanceof I?o=r:o=new ie(r,t,n);let{_subscribe:i}=this;try{let s=i.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((t,n)=>n(t),this)}toPromise(){return new Promise((r,t)=>{let n;this.subscribe({next:o=>n=o,error:t,complete:()=>r(n)})})}};var je=class extends F{constructor(){super(t=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)t.error(this.thrownError);else if(this.isStopped)t.complete();else return this.observers.push(t),()=>{let n=this.observers.indexOf(t);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(t){if(this.isStopped)return;let{observers:n}=this,o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].next?.(t)}error(t){if(this.isStopped)return;this.hasError=!0,this.thrownError=t,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].error?.(t)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:t}=this;this.observers=[];let n=t.length,o=t.slice();for(let i=0;i<n;i++)o[i].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new F(n=>this.subscribe(n))}};var Rt="__fluixi_signal_next_state__",Et=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Rt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Et,onSuspend:null,onError:null};var or=0,ir=1,z=2,se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let r=a.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},M=class extends se{constructor(r,t){super(),this._value=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(z);_e(this)}}peek(){return this._value}},x=class extends se{constructor(t,n){super();this._threw=!1;this._initialized=!1;this.state=z;this.sources=null;this._fn=t,this._equals=n?.equals===!1?()=>!1:n?.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===ir&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=or}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let t=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,i=!1,s;try{o=this._fn()}catch(u){i=!0,s=u,o=this._value}finally{a.consumer=t,a.untracked=n}let c=!this._initialized||this._threw!==i||(i?s!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=s,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(z);_e(this)}}markDirty(t){if(this.state>=t)return;let n=this.state===or;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ir);_e(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _e(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var N=class{constructor(r){this._watched=new Set;this._pending=new Set;this._notifyFn=r}watch(...r){for(let t of r)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...r){for(let t of r)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let r=[...this._pending];return this._pending.clear(),r}_notify(r){if(!this._watched.has(r)||this._pending.has(r))return;let t=this._pending.size===0;this._pending.add(r),t&&this._notifyFn()}};function G(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function sr(){return a.consumer}function ar(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ur(e){let r=J(e);return e&&(e.owned??=[]).push(r),r}function lr(e,r=!0){H(e,r)}function cr(e){return!!e&&e.disposed===!0}function J(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:n=>{let o=a.owner,i=J(o);(i.contexts=new Map).set(r,n.value),o&&(o.owned??=[]).push(i),a.owner=i;try{return n.children}finally{a.owner=o}}}}function fr(e){let r=a.owner;for(;r;){if(r.contexts&&r.contexts.has(e.id))return r.contexts.get(e.id);r=r.parent}return e.defaultValue}function ae(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function U(e,r,t){let n=J(a.owner);(n.contexts=new Map).set(e.id,r),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return t()}finally{a.owner=o}}function pr(e){a.onSuspend=e}function dr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function yr(e){a.onError=e}function Z(){return a.owner}function $e(e){let r=a.owner;return a.owner=e,r}function B(e,r){let t=a.owner;a.owner=e;try{return r()}finally{a.owner=t}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function H(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)H(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}r&&(e.disposed=!0)}}function P(e){let r=J(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>H(r))}finally{a.owner=t}}function hr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function Ct(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Y)))}function Y(){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 r=a.queue;a.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function br(){a.batchDepth===0&&Y()}function Re(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var Pe=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=J(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new x(()=>{H(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>Ct(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(r){if(r&&typeof r.then=="function"&&a.onSuspend){a.onSuspend(r,this.owner);return}if(a.onError&&a.onError(r,this.owner))return;throw r}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),H(this.owner))}};function ue(e){let r=new Pe(e);return()=>r.dispose()}function Dt(e){return!!e&&typeof e.then=="function"}hr(()=>{});var mr=Symbol.for("signal"),It=Symbol.for("memo"),Ft=Symbol.for("signal-node");function d(e,r){let t=new M(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),br(),s});return Object.defineProperty(n,mr,{value:!0,enumerable:!0}),Object.defineProperty(n,Ft,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function w(e,r,t){let n=r,o=Z(),i=new x(()=>B(o,()=>{try{return n=e(n)}catch(c){if(Dt(c))return dr(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,mr,{value:!0,enumerable:!0}),Object.defineProperty(s,It,{value:!0,enumerable:!0}),s}function $(e,r){let t=r;return ue(()=>{t=e(t)})}function gr(e,r){let t=r;ue(()=>{t=e(t)})}function vr(e,r){let t=r;return ue(()=>{t=e(t)})}function T(e){return Re(e)}function A(e){return G(e)}function Ee(e){return Re(e),Promise.resolve()}function Ar(){return[()=>!1,Ee]}function wr(){return Y(),Promise.resolve()}function Sr(e,r,t){let n=Array.isArray(e),o,i=t?.defer??!1;return s=>{let c=n?e.map(p=>p()):e();if(i){i=!1,o=c;return}let u=G(()=>r(c,o,s));return o=c,u}}function Mt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),w(()=>{let o=e()||[];return A(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=new Map;for(let u of n)i.has(u.item)||i.set(u.item,u);let s=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=i.get(p);if(h&&!c.has(h))h.setIndex(u),s.push(h),c.add(h);else{let f,y,b;P(m=>{b=m;let[E,L]=d(u);y=L,f=r(p,E)});let S={item:p,rendered:f,dispose:b,setIndex:y};s.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=s,s.map(u=>u.rendered)})})}function Nt(e,r,t,n){let o=[],i=[];return v(()=>{for(let s of i)s.dispose();o=[],i=[]}),w(()=>{let s=e()||[];return A(()=>{if(s.length===0){for(let f of i)f.dispose();return o=[],i=[],n?.fallback?n.fallback():[]}let c=new Map;for(let f=0;f<o.length;f++)c.set(o[f],i[f]);let u=[],p=[],h=new Set;for(let f=0;f<s.length;f++){let y=r(s[f]),b=c.get(y);if(b&&!h.has(y))b.setIndex(f),u.push(b);else{let S,m,E;P(L=>{E=L;let[j,K]=d(f);m=K;let te=w(C=>{let O=(e()||[])[j()];return O??C},s[f]);S=t(te,j)}),u.push({rendered:S,dispose:E,setIndex:m})}p.push(y),h.add(y)}for(let[f,y]of c)h.has(f)||y.dispose();return o=p,i=u,u.map(f=>f.rendered)})})}function qt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),w(()=>{let o=e()||[];return A(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=n.length,s=o.length;for(let u=i;u<s;u++){let p,h,f,y=o[u];P(b=>{f=b;let[S,m]=d(y);h=m,p=r(S,u)}),n.push({rendered:p,setItem:h,dispose:f})}for(let u=s;u<i;u++)n[u].dispose();s<i&&(n=n.slice(0,s));let c=Math.min(i,s);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var le=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),Vt=Symbol.for("resource");function ce(e){return typeof e=="function"&&e[Ut]===!0}function Tr(e){return typeof e=="function"&&e[Bt]===!0}function Or(e){return typeof e=="function"&&e[Vt]===!0}function xr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function kr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ce(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ce(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var De=null;function _r(e){De=e}function fe(e){De&&De(e)}var Ie=null;function Pr(e){Ie=e}function pe(e){return Ie?Ie(e):void 0}var Fe=null;function $r(e){Fe=e}function de(){return Fe?Fe():void 0}var Me=null;function Rr(e){Me=e}function ye(e,r){Me&&Me(e,r)}function Er(e,r=(t,n)=>t===n){let t=new Map;return $(()=>{let n=e();for(let[o,i]of t){let[s,c]=i,u=r(o,n);s()!==u&&c(u)}}),n=>{let o=t.get(n);if(!o){let[i,s]=d(!1);o=[i,s],t.set(n,o);let c=e();s(r(n,c))}return o[0]()}}function Cr(e,r){let[t,n]=d(e(),r);return $(()=>{let o=e();r?.timeoutMs?setTimeout(()=>n(()=>o),r.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),t}function Dr(e,r){let t,n=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},r)};return v(()=>{t!==void 0&&clearTimeout(t)}),n}function Wt(e){return!!e&&typeof e.then=="function"}var Ne=Symbol();function he(e,r,t={}){let n,o;typeof r=="function"?(n=typeof e=="function"?e:()=>e,o=r):(n=()=>!0,o=e,r&&typeof r=="object"&&(t=r));let i=de(),s=i!==void 0?pe(i):void 0,c=s!==void 0,[u,p]=d(s!==void 0?s.value:t.initialValue,{equals:!1}),[h,f]=d(void 0,{equals:!1}),[y,b]=d(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,m]=d(void 0,{equals:!1}),[E,L]=d(void 0,{equals:!1}),j=Ne,K=!1;$(()=>{let g=n();if(E(),g===!1||g===null||g===void 0){j=Ne,T(()=>{b("unresolved"),m(void 0),f(void 0)});return}let O=K;if(K=!1,j!==Ne&&g===j&&!O)return;if(j=g,c){c=!1;return}let ne=!1;v(()=>ne=!0);let Xe=A(y),Tt=A(u),er=Xe==="ready"||Xe==="refreshing";T(()=>{b(er?"refreshing":"pending"),f(void 0)});try{let _=o(g,{value:Tt,refetching:er});Wt(_)?(m(_),fe(_),_.then(oe=>{ne||(i!==void 0&&ye(i,oe),T(()=>{p(()=>oe),b("ready"),m(void 0)}))},oe=>{ne||T(()=>{f(oe),b("errored"),m(void 0)})})):T(()=>{p(()=>_),b("ready"),m(void 0)})}catch(_){if(ne)return;T(()=>{f(_),b("errored"),m(void 0)})}});let te=()=>{let g=y();return g==="pending"||g==="refreshing"},C=(()=>{let g=h();if(g)throw g;if(te()){let O=S();if(O)throw O}return u()});return Object.defineProperties(C,{state:{get:y},loading:{get:te},error:{get:h},latest:{get:u}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:p,refetch:()=>{K=!0,L(void 0)}}]}function qe(e,r=300){let[t,n]=d(e),[o,i]=d(e),[s,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let y=A(t);return i(()=>y),c(!1),y},f=(y=>{let b=typeof y=="function"?y(A(t)):y;return n(()=>b),c(!0),p(),u=setTimeout(h,r),b});return v(p),[o,f,{immediate:t,pending:s,flush:h,cancel:()=>{p(),c(!1)}}]}function Lt(e){return e!=null&&e!==""}function Ir(e,r,t={}){let{delay:n=300,initialValue:o,shouldFetch:i=Lt}=t,[s,c,u]=qe(e,n),p=()=>i(s())?s():!1,[h,{refetch:f}]=he(p,r,o===void 0?{}:{initialValue:o});return[h,{...u,query:s,setQuery:c,refetch:f}]}function be(e){if(typeof e=="function"&&!e.length){let r=e();return ce(r)?r:be(r)}if(Array.isArray(e)){let r=[];for(let t=0;t<e.length;t++){let n=be(e[t]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return r}return e}function Fr(e){let r=w(e);return w(()=>be(r()))}var me=q();pr((e,r)=>{let t=ae(r,me);t&&(t.increment(),e.finally(()=>t.decrement()))});function Mr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Nr(e,r){return U(me,e,r)}var qr=q();yr((e,r)=>{let t=ae(r,qr);return t?(t.setError(e),!0):!1});function Ur(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Br(e,r){return U(qr,e,r)}var Vr={State:M,Computed:x,subtle:{Watcher:N,untrack:G,currentComputed:sr,hasSinks:ar}};var Kt=Symbol.for("signal"),zt=Symbol.for("fluixi-proxy");var Gt="__fluixi_signal_next_state__",Ht=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Gt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ht,onSuspend:null,onError:null},Wr=0,Lr=1,Q=2,Kr=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(l.untracked)return;let e=l.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},Jt=class extends Kr{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(Q);Ue(this)}}peek(){return this._value}},zr=class extends Kr{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=Q,this.sources=null,this._fn=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(l.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===Lr&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===Q)break}(this.state===Q||!this._initialized)&&this.recompute(),this.state=Wr}recompute(){if(this.sources){for(let s of this.sources)s.observers?.delete(this);this.sources.clear()}let e=l.consumer,r=l.untracked;l.consumer=this,l.untracked=!1;let t,n=!1,o;try{t=this._fn()}catch(s){n=!0,o=s,t=this._value}finally{l.consumer=e,l.untracked=r}let i=!this._initialized||this._threw!==n||(n?o!==this._error:!this._equals(this._value,t));if(this._initialized=!0,this._threw=n,this._error=o,this._value=t,i){if(this.version++,this.observers)for(let s of[...this.observers])s.markDirty(Q);Ue(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Wr;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(Lr);Ue(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ue(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var Zt=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function Yt(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Gr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Hr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Gr(n);(o.contexts=new Map).set(r,t.value),n&&(n.owned??=[]).push(o),l.owner=o;try{return t.children}finally{l.owner=n}}}}function Jr(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function Qt(e){l.onSuspend=e}function Xt(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function en(e){l.onError=e}function rn(){return l.owner}function Zr(e,r){let t=l.owner;l.owner=e;try{return r()}finally{l.owner=t}}function Be(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Be(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}r&&(e.disposed=!0)}}function tn(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function nn(e){e.queued||(e.queued=!0,l.queue.push(e),!l.scheduled&&l.batchDepth===0&&(l.scheduled=!0,l.hostSchedule(Ve)))}function Ve(){if(l.scheduled=!1,l.flushing)return;l.flushing=!0;let e=0;try{for(;l.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=l.queue;l.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{l.flushing=!1}}function on(){l.batchDepth===0&&Ve()}function sn(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&Ve()}}var an=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Gr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new zr(()=>{Be(this.owner,!1),Zr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new Zt(()=>nn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&l.onSuspend){l.onSuspend(e,this.owner);return}if(l.onError&&l.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Be(this.owner))}};function un(e){let r=new an(e);return()=>r.dispose()}function ln(e){return!!e&&typeof e.then=="function"}tn(()=>{});var Yr=Symbol.for("signal"),cn=Symbol.for("memo"),fn=Symbol.for("signal-node");function We(e,r){let t=new Jt(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),on(),s});return Object.defineProperty(n,Yr,{value:!0,enumerable:!0}),Object.defineProperty(n,fn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function ge(e,r,t){let n=r,o=rn(),i=new zr(()=>Zr(o,()=>{try{return n=e(n)}catch(c){if(ln(c))return Xt(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,Yr,{value:!0,enumerable:!0}),Object.defineProperty(s,cn,{value:!0,enumerable:!0}),s}function X(e,r){let t=r;return un(()=>{t=e(t)})}function Le(e){return sn(e)}function Qr(e){return Yt(e)}var pn=Hr();Qt((e,r)=>{let t=Jr(r,pn);t&&(t.increment(),e.finally(()=>t.decrement()))});var dn=Hr();en((e,r)=>{let t=Jr(r,dn);return t?(t.setError(e),!0):!1});var ve=Symbol.for("fluixi-proxy");var re=Symbol("store-raw"),R=Symbol("store-node"),Xr=Symbol("store-has"),we=Symbol("store-self"),Se=Symbol("store-track"),st=Symbol("store-name"),at=Symbol("store-store"),et=new WeakMap,rt=new WeakMap;function ut(e){let[r,t]=We(e),n=r;return n.$=t,n}function Te(e){let r=et.get(e);return r||et.set(e,r={keys:new Map}),r}function tt(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=ut(t)),n}function nt(e){let r=Te(e);(r.all||(r.all=ut()))()}function ot(e,r){e.$(typeof r=="function"?()=>r:r)}function lt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function Ae(e){if(!lt(e))return e;let r=rt.get(e);if(r)return r;let t=new Proxy(e,yn);return rt.set(e,t),t}var yn={get(e,r,t){if(r===re||r===R)return e;if(r===ve)return t;if(r===Xr)return s=>s in e;if(r==="__proxy")return!0;if(r===Se||r===we)return nt(e),t;let n=e[r];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,r))return n;let o=Object.getOwnPropertyDescriptor(e,r);if(o&&o.get)return o.get.call(t);let i=tt(Te(e),r,n)();return lt(i)?Ae(i):i},set(){return!0},deleteProperty(e,r){return r in e&&ee(e,r,void 0),!0},has(e,r){return r===re||r===ve||r===R||r===Xr||r===we||r===Se?!0:(tt(Te(e),r,e[r])(),r in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function ee(e,r,t){if(e[r]===t&&(t!==void 0||r in e))return;let o=Array.isArray(e),i=o?e.length:0;t===void 0?delete e[r]:e[r]=t;let s=Te(e),c=s.keys.get(r);if(c&&ot(c,t),o&&e.length!==i){let u=s.keys.get("length");u&&ot(u,e.length)}s.all&&s.all.$(void 0)}function it(e,r){return typeof e=="function"?e(r):e}function ze(e,r){for(let t of Object.keys(r)){let n=r[t],o=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?ze(o,n):ee(e,t,n)}}function He(e){let r=[],t=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of t.split("."))n.length&&r.push(n);return r}function ct(e,r,t){let n=r.length-1;for(let i=0;i<n;i++){let s=r[i];if(s==="*"){let u=r.slice(i+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ct(e[p],u,t);return}let c=e[s];(c==null||typeof c!="object")&&(c=/^\d+$/.test(r[i+1])?[]:{},ee(e,s,c)),e=c}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)ee(e,i,it(t,e[i]));return}ee(e,o,it(t,e[o]))}function Ke(e,r,t){ct(e,He(r),t)}function hn(e,r){let t=r[0];if(typeof t=="function"&&r.length===1){let n=t(e);n&&n!==e&&ze(e,n);return}if(Array.isArray(t)&&r.length===1){for(let n of t)Array.isArray(n)&&Ke(e,n[0],n[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&r.length===1){ze(e,t);return}if(Array.isArray(r[1])&&r.length>=3){Ke(e,`${t}.${r[1].join(".")}`,r[2]);return}Ke(e,String(t),r[1])}function Ge(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ge);let r={};for(let t of Object.keys(e))r[t]=Ge(e[t]);return r}function V(e,r){let t=e;for(let n of He(r)){if(t==null)return;t=t[n]}return t}var k=class{constructor(r,t={immutable:!0}){this.options=t;this.root=r,this.set=((...n)=>Le(()=>hn(this.root,n)))}get state(){return Ae(this.root)}get proxy(){return Ae(this.root)}get accessor(){return(()=>Ae(this.root))}unwrap(){return this.root}getNode(r){return this.root&&this.root[r]}get(r){if(r==null||r==="")return W(this.state);let t=this.state;for(let n of He(r)){if(t==null)return;t=t[n]}return W(t)}select(r){return ge(()=>r(this.state))}subscribe(r){return X(()=>r(this.state))}watch(r,t){let n;return X(()=>{let o=r(this.state);Object.is(o,n)||(t(o,n),n=o)})}reactive(r){return ge(()=>this.state[r])}produce(r){this.set((t=>{let n=Ge(t);return r(n),n}))}reconcile(r,t={}){this.set(r)}push(r,...t){let n=V(this.root,r);this.set(r,n.concat(t))}pop(r){let t=V(this.root,r).slice(),n=t.pop();return this.set(r,t),n}shift(r){let t=V(this.root,r).slice(),n=t.shift();return this.set(r,t),n}splice(r,t,n,...o){let i=V(this.root,r).slice(),s=i.splice(t,n,...o);return this.set(r,i),s}insert(r,t,n){let o=V(this.root,r).slice();o.splice(t,0,n),this.set(r,o)}removeAt(r,t){let n=V(this.root,r).slice(),o=n.splice(t,1);return this.set(r,n),o}toObservable(){let[r]=We(this.state);return r.toObservable()}dispose(){}},bn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function ft(e,r){for(let t of bn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function Je(e,r={immutable:!0}){let t=new k(e,r);return ft(t.set,t),[t.proxy,t.set]}function Ze(e,r={}){return new k(e,{...r,immutable:!1})}function pt(e,r={}){let t=new k(e(),r);return X(()=>t.set(e())),t}function dt(e,r,t){return X(()=>t(r(e)))}function yt(e,r,t){return ge(()=>r(e),void 0,t)}function ht(e,r={}){let t=new k(e,r),n=(()=>t.proxy);return ft(n,t),n}function W(e){if(e==null||typeof e!="object")return e;let r=e[re];return r!==void 0?r:e}function Ye(e){return Qr(()=>W(e))}function bt(e){return Oe(e)}function mt(e){return Oe(e)?e[R]:null}function gt(e){return e&&typeof e=="object"&&R in e?e[R]:null}function Oe(e){return!!e&&typeof e=="object"&&(ve in e||e.__proxy===!0)}function vt(e){return e}var At=Object.freeze({createStore:Je,createMutableStore:Ze,batch:Le,unwrap:W,untrackStore:Ye});function Qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Qe);let r={};for(let t of Object.keys(e))r[t]=Qe(e[t]);return r}function wt(e){return r=>{let t=Qe(r);return e(t),t}}function St(e,r={}){return()=>e}return Pt(mn);})();
1
+ "use strict";var Fluixi=(()=>{var xe=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var jt=(e,r)=>{for(var t in r)xe(e,t,{get:r[t],enumerable:!0})},_t=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xt(r))!kt.call(e,o)&&o!==t&&xe(e,o,{get:()=>r[o],enumerable:!(n=Ot(r,o))||n.enumerable});return e};var Pt=e=>_t(xe({},"__esModule",{value:!0}),e);var mn={};jt(mn,{$NAME:()=>st,$NODE:()=>R,$PROXY:()=>zt,$RAW:()=>re,$SELF:()=>we,$SIGNAL:()=>Kt,$STORE:()=>at,$TRACK:()=>Se,Observable:()=>F,SafeSubscriber:()=>ie,Signal:()=>Vr,Store:()=>k,StoreAPI:()=>At,Subject:()=>je,Subscriber:()=>I,Subscription:()=>D,SuspenseContext:()=>me,VERSION:()=>rr,__DEV__:()=>le,batch:()=>T,createChildOwner:()=>ur,createComputed:()=>gr,createComputedStore:()=>pt,createContext:()=>q,createDebounce:()=>Dr,createDebouncedResource:()=>Ir,createDebouncedSignal:()=>qe,createDeferred:()=>Cr,createEffect:()=>$,createErrorBoundary:()=>Ur,createMemo:()=>w,createMutableStore:()=>Ze,createRenderEffect:()=>vr,createResource:()=>he,createRoot:()=>P,createSelector:()=>Er,createSignal:()=>d,createStore:()=>Je,createStoreEffect:()=>dt,createStoreMemo:()=>yt,createSuspenseBoundary:()=>Mr,disposeScope:()=>lr,flush:()=>wr,getNode:()=>mt,getOwner:()=>Z,getServerData:()=>pe,getStoreNode:()=>gt,indexArray:()=>qt,isComponent:()=>xr,isMemo:()=>Tr,isOwnerDisposed:()=>cr,isProvider:()=>jr,isResource:()=>Or,isSignal:()=>ce,isStore:()=>bt,isStoreProxy:()=>Oe,isSuspense:()=>kr,keyArray:()=>Nt,makeArrayFlat:()=>Ce,mapArray:()=>Mt,modifiable:()=>vt,nextResourceId:()=>de,on:()=>Sr,onCleanup:()=>v,operate:()=>$t,produceUtil:()=>wt,provide:()=>U,provideErrorBoundary:()=>Br,provideSuspense:()=>Nr,readChildren:()=>Fr,reconcileUtil:()=>St,reportResourceData:()=>ye,runWithOwner:()=>B,setOwner:()=>$e,setResourceDataSink:()=>Rr,setResourceIdSource:()=>$r,setResourceTracker:()=>_r,setServerDataGetter:()=>Pr,startTransition:()=>Ee,trackResourcePromise:()=>fe,untrack:()=>A,untrackStore:()=>Ye,unwrap:()=>W,useContext:()=>fr,useTransition:()=>Ar,wrap:()=>ht});var rr="1.0.0-alpha.72";function ke(e){return typeof e=="function"&&!tr(e)}var nr=e=>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 tr(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var D=class e{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:t}=this;if(r instanceof e)r.remove(this);else if(r!==null)for(let n of r)n.remove(this);if(t){for(let n of t)if(ke(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(nr(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:t,_subscriptions:n}=this;if(t){if(ke(r))try{r()}catch(o){console.error("Error in unsubscribe function:",o)}else if(r.unsubscribe)try{r.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof e&&r._addParent(this),this}remove(r){let{_subscriptions:t}=this;if(!t)return;let n=t.indexOf(r);n!==-1&&(t.splice(n,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(r):this._parentOrParents=[t,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:t}=this;if(t===r)this._parentOrParents=null;else if(Array.isArray(t)){let n=t.indexOf(r);n!==-1&&(t.splice(n,1),t.length===1&&(this._parentOrParents=t[0]))}}};var I=class extends D{constructor(t,n,o){super();this.isStopped=!1;let i;t?typeof t=="object"?i=t:i={next:t,error:n,complete:o}:i={},this.destination=i}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(n){this.error(n)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(n){throw n}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())}},ie=class extends I{constructor(t,n,o,i){super(t,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=i||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(n){this.error(n)}}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)}};function $t(e){return new I(e.next,e.error,e.complete)}var F=class extends D{constructor(r){if(super(),r)this._subscribe=r;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(r,t,n){let o;r instanceof I?o=r:o=new ie(r,t,n);let{_subscribe:i}=this;try{let s=i.call(this,o);s&&(typeof s=="function"||typeof s.unsubscribe=="function")&&o.add(s)}catch(s){o.error(s)}return o}pipe(...r){return r.length===0?this:r.reduce((t,n)=>n(t),this)}toPromise(){return new Promise((r,t)=>{let n;this.subscribe({next:o=>n=o,error:t,complete:()=>r(n)})})}};var je=class extends F{constructor(){super(t=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)t.error(this.thrownError);else if(this.isStopped)t.complete();else return this.observers.push(t),()=>{let n=this.observers.indexOf(t);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(t){if(this.isStopped)return;let{observers:n}=this,o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].next?.(t)}error(t){if(this.isStopped)return;this.hasError=!0,this.thrownError=t,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,i=n.slice();for(let s=0;s<o;s++)i[s].error?.(t)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:t}=this;this.observers=[];let n=t.length,o=t.slice();for(let i=0;i<n;i++)o[i].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new F(n=>this.subscribe(n))}};var Rt="__fluixi_signal_next_state__",Et=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Rt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Et,onSuspend:null,onError:null};var or=0,ir=1,z=2,se=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let r=a.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},M=class extends se{constructor(r,t){super(),this._value=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(z);_e(this)}}peek(){return this._value}},x=class extends se{constructor(t,n){super();this._threw=!1;this._initialized=!1;this.state=z;this.sources=null;this._fn=t,this._equals=n?.equals===!1?()=>!1:n?.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===ir&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=or}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let t=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,i=!1,s;try{o=this._fn()}catch(u){i=!0,s=u,o=this._value}finally{a.consumer=t,a.untracked=n}let c=!this._initialized||this._threw!==i||(i?s!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=s,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(z);_e(this)}}markDirty(t){if(this.state>=t)return;let n=this.state===or;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ir);_e(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _e(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var N=class{constructor(r){this._watched=new Set;this._pending=new Set;this._notifyFn=r}watch(...r){for(let t of r)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...r){for(let t of r)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let r=[...this._pending];return this._pending.clear(),r}_notify(r){if(!this._watched.has(r)||this._pending.has(r))return;let t=this._pending.size===0;this._pending.add(r),t&&this._notifyFn()}};function G(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function sr(){return a.consumer}function ar(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ur(e){let r=J(e);return e&&(e.owned??=[]).push(r),r}function lr(e,r=!0){H(e,r)}function cr(e){return!!e&&e.disposed===!0}function J(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:n=>{let o=a.owner,i=J(o);(i.contexts=new Map).set(r,n.value),o&&(o.owned??=[]).push(i),a.owner=i;try{return n.children}finally{a.owner=o}}}}function fr(e){let r=a.owner;for(;r;){if(r.contexts&&r.contexts.has(e.id))return r.contexts.get(e.id);r=r.parent}return e.defaultValue}function ae(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function U(e,r,t){let n=J(a.owner);(n.contexts=new Map).set(e.id,r),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return t()}finally{a.owner=o}}function pr(e){a.onSuspend=e}function dr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function yr(e){a.onError=e}function Z(){return a.owner}function $e(e){let r=a.owner;return a.owner=e,r}function B(e,r){let t=a.owner;a.owner=e;try{return r()}finally{a.owner=t}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function H(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)H(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}r&&(e.disposed=!0)}}function P(e){let r=J(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>H(r))}finally{a.owner=t}}function hr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function Ct(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Y)))}function Y(){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 r=a.queue;a.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{a.flushing=!1}}function br(){a.batchDepth===0&&Y()}function Re(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var Pe=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=J(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new x(()=>{H(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>Ct(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(r){if(r&&typeof r.then=="function"&&a.onSuspend){a.onSuspend(r,this.owner);return}if(a.onError&&a.onError(r,this.owner))return;throw r}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),H(this.owner))}};function ue(e){let r=new Pe(e);return()=>r.dispose()}function Dt(e){return!!e&&typeof e.then=="function"}hr(()=>{});var mr=Symbol.for("signal"),It=Symbol.for("memo"),Ft=Symbol.for("signal-node");function d(e,r){let t=new M(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),br(),s});return Object.defineProperty(n,mr,{value:!0,enumerable:!0}),Object.defineProperty(n,Ft,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function w(e,r,t){let n=r,o=Z(),i=new x(()=>B(o,()=>{try{return n=e(n)}catch(c){if(Dt(c))return dr(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,mr,{value:!0,enumerable:!0}),Object.defineProperty(s,It,{value:!0,enumerable:!0}),s}function $(e,r){let t=r;return ue(()=>{t=e(t)})}function gr(e,r){let t=r;ue(()=>{t=e(t)})}function vr(e,r){let t=r;return ue(()=>{t=e(t)})}function T(e){return Re(e)}function A(e){return G(e)}function Ee(e){return Re(e),Promise.resolve()}function Ar(){return[()=>!1,Ee]}function wr(){return Y(),Promise.resolve()}function Sr(e,r,t){let n=Array.isArray(e),o,i=t?.defer??!1;return s=>{let c=n?e.map(p=>p()):e();if(i){i=!1,o=c;return}let u=G(()=>r(c,o,s));return o=c,u}}function Mt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),w(()=>{let o=e()||[];return A(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=new Map;for(let u of n)i.has(u.item)||i.set(u.item,u);let s=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=i.get(p);if(h&&!c.has(h))h.setIndex(u),s.push(h),c.add(h);else{let f,y,b;P(m=>{b=m;let[E,L]=d(u);y=L,f=r(p,E)});let S={item:p,rendered:f,dispose:b,setIndex:y};s.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=s,s.map(u=>u.rendered)})})}function Nt(e,r,t,n){let o=[],i=[];return v(()=>{for(let s of i)s.dispose();o=[],i=[]}),w(()=>{let s=e()||[];return A(()=>{if(s.length===0){for(let f of i)f.dispose();return o=[],i=[],n?.fallback?n.fallback():[]}let c=new Map;for(let f=0;f<o.length;f++)c.set(o[f],i[f]);let u=[],p=[],h=new Set;for(let f=0;f<s.length;f++){let y=r(s[f]),b=c.get(y);if(b&&!h.has(y))b.setIndex(f),u.push(b);else{let S,m,E;P(L=>{E=L;let[j,K]=d(f);m=K;let te=w(C=>{let O=(e()||[])[j()];return O??C},s[f]);S=t(te,j)}),u.push({rendered:S,dispose:E,setIndex:m})}p.push(y),h.add(y)}for(let[f,y]of c)h.has(f)||y.dispose();return o=p,i=u,u.map(f=>f.rendered)})})}function qt(e,r,t){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),w(()=>{let o=e()||[];return A(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],t?.fallback?t.fallback():[]}let i=n.length,s=o.length;for(let u=i;u<s;u++){let p,h,f,y=o[u];P(b=>{f=b;let[S,m]=d(y);h=m,p=r(S,u)}),n.push({rendered:p,setItem:h,dispose:f})}for(let u=s;u<i;u++)n[u].dispose();s<i&&(n=n.slice(0,s));let c=Math.min(i,s);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var le=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),Vt=Symbol.for("resource");function ce(e){return typeof e=="function"&&e[Ut]===!0}function Tr(e){return typeof e=="function"&&e[Bt]===!0}function Or(e){return typeof e=="function"&&e[Vt]===!0}function xr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function kr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ce(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ce(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var De=null;function _r(e){De=e}function fe(e){De&&De(e)}var Ie=null;function Pr(e){Ie=e}function pe(e){return Ie?Ie(e):void 0}var Fe=null;function $r(e){Fe=e}function de(){return Fe?Fe():void 0}var Me=null;function Rr(e){Me=e}function ye(e,r){Me&&Me(e,r)}function Er(e,r=(t,n)=>t===n){let t=new Map;return $(()=>{let n=e();for(let[o,i]of t){let[s,c]=i,u=r(o,n);s()!==u&&c(u)}}),n=>{let o=t.get(n);if(!o){let[i,s]=d(!1);o=[i,s],t.set(n,o);let c=e();s(r(n,c))}return o[0]()}}function Cr(e,r){let[t,n]=d(e(),r);return $(()=>{let o=e();r?.timeoutMs?setTimeout(()=>n(()=>o),r.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),t}function Dr(e,r){let t,n=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...o)},r)};return v(()=>{t!==void 0&&clearTimeout(t)}),n}function Wt(e){return!!e&&typeof e.then=="function"}var Ne=Symbol();function he(e,r,t={}){let n,o;typeof r=="function"?(n=typeof e=="function"?e:()=>e,o=r):(n=()=>!0,o=e,r&&typeof r=="object"&&(t=r));let i=de(),s=i!==void 0?pe(i):void 0,c=s!==void 0,[u,p]=d(s!==void 0?s.value:t.initialValue,{equals:!1}),[h,f]=d(void 0,{equals:!1}),[y,b]=d(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,m]=d(void 0,{equals:!1}),[E,L]=d(void 0,{equals:!1}),j=Ne,K=!1;$(()=>{let g=n();if(E(),g===!1||g===null||g===void 0){j=Ne,T(()=>{b("unresolved"),m(void 0),f(void 0)});return}let O=K;if(K=!1,j!==Ne&&g===j&&!O)return;if(j=g,c){c=!1;return}let ne=!1;v(()=>ne=!0);let Xe=A(y),Tt=A(u),er=Xe==="ready"||Xe==="refreshing";T(()=>{b(er?"refreshing":"pending"),f(void 0)});try{let _=o(g,{value:Tt,refetching:er});Wt(_)?(m(_),fe(_),_.then(oe=>{ne||(i!==void 0&&ye(i,oe),T(()=>{p(()=>oe),b("ready"),m(void 0)}))},oe=>{ne||T(()=>{f(oe),b("errored"),m(void 0)})})):T(()=>{p(()=>_),b("ready"),m(void 0)})}catch(_){if(ne)return;T(()=>{f(_),b("errored"),m(void 0)})}});let te=()=>{let g=y();return g==="pending"||g==="refreshing"},C=(()=>{let g=h();if(g)throw g;if(te()){let O=S();if(O)throw O}return u()});return Object.defineProperties(C,{state:{get:y},loading:{get:te},error:{get:h},latest:{get:u}}),Object.defineProperty(C,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(C,Symbol.for("signal"),{value:!0,enumerable:!0}),[C,{mutate:p,refetch:()=>{K=!0,L(void 0)}}]}function qe(e,r=300){let[t,n]=d(e),[o,i]=d(e),[s,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let y=A(t);return i(()=>y),c(!1),y},f=(y=>{let b=typeof y=="function"?y(A(t)):y;return n(()=>b),c(!0),p(),u=setTimeout(h,r),b});return v(p),[o,f,{immediate:t,pending:s,flush:h,cancel:()=>{p(),c(!1)}}]}function Lt(e){return e!=null&&e!==""}function Ir(e,r,t={}){let{delay:n=300,initialValue:o,shouldFetch:i=Lt}=t,[s,c,u]=qe(e,n),p=()=>i(s())?s():!1,[h,{refetch:f}]=he(p,r,o===void 0?{}:{initialValue:o});return[h,{...u,query:s,setQuery:c,refetch:f}]}function be(e){if(typeof e=="function"&&!e.length){let r=e();return ce(r)?r:be(r)}if(Array.isArray(e)){let r=[];for(let t=0;t<e.length;t++){let n=be(e[t]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return r}return e}function Fr(e){let r=w(e);return w(()=>be(r()))}var me=q();pr((e,r)=>{let t=ae(r,me);t&&(t.increment(),e.finally(()=>t.decrement()))});function Mr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Nr(e,r){return U(me,e,r)}var qr=q();yr((e,r)=>{let t=ae(r,qr);return t?(t.setError(e),!0):!1});function Ur(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Br(e,r){return U(qr,e,r)}var Vr={State:M,Computed:x,subtle:{Watcher:N,untrack:G,currentComputed:sr,hasSinks:ar}};var Kt=Symbol.for("signal"),zt=Symbol.for("fluixi-proxy");var Gt="__fluixi_signal_next_state__",Ht=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Gt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ht,onSuspend:null,onError:null},Wr=0,Lr=1,Q=2,Kr=class{constructor(){this.observers=null,this.watchers=null,this.version=0}updateIfNecessary(){}track(){if(l.untracked)return;let e=l.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},Jt=class extends Kr{constructor(e,r){super(),this._value=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(Q);Ue(this)}}peek(){return this._value}},zr=class extends Kr{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=Q,this.sources=null,this._fn=e,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){if(l.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===Lr&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===Q)break}(this.state===Q||!this._initialized)&&this.recompute(),this.state=Wr}recompute(){if(this.sources){for(let s of this.sources)s.observers?.delete(this);this.sources.clear()}let e=l.consumer,r=l.untracked;l.consumer=this,l.untracked=!1;let t,n=!1,o;try{t=this._fn()}catch(s){n=!0,o=s,t=this._value}finally{l.consumer=e,l.untracked=r}let i=!this._initialized||this._threw!==n||(n?o!==this._error:!this._equals(this._value,t));if(this._initialized=!0,this._threw=n,this._error=o,this._value=t,i){if(this.version++,this.observers)for(let s of[...this.observers])s.markDirty(Q);Ue(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Wr;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(Lr);Ue(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ue(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var Zt=class{constructor(e){this._watched=new Set,this._pending=new Set,this._notifyFn=e}watch(...e){for(let r of e)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...e){for(let r of e)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let r=this._pending.size===0;this._pending.add(e),r&&this._notifyFn()}};function Yt(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Gr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Hr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Gr(n);(o.contexts=new Map).set(r,t.value),n&&(n.owned??=[]).push(o),l.owner=o;try{return t.children}finally{l.owner=n}}}}function Jr(e,r){let t=e;for(;t;){if(t.contexts&&t.contexts.has(r.id))return t.contexts.get(r.id);t=t.parent}return r.defaultValue}function Qt(e){l.onSuspend=e}function Xt(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function en(e){l.onError=e}function rn(){return l.owner}function Zr(e,r){let t=l.owner;l.owner=e;try{return r()}finally{l.owner=t}}function Be(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Be(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}r&&(e.disposed=!0)}}function tn(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function nn(e){e.queued||(e.queued=!0,l.queue.push(e),!l.scheduled&&l.batchDepth===0&&(l.scheduled=!0,l.hostSchedule(Ve)))}function Ve(){if(l.scheduled=!1,l.flushing)return;l.flushing=!0;let e=0;try{for(;l.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=l.queue;l.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{l.flushing=!1}}function on(){l.batchDepth===0&&Ve()}function sn(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&Ve()}}var an=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Gr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new zr(()=>{Be(this.owner,!1),Zr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new Zt(()=>nn(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&l.onSuspend){l.onSuspend(e,this.owner);return}if(l.onError&&l.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Be(this.owner))}};function un(e){let r=new an(e);return()=>r.dispose()}function ln(e){return!!e&&typeof e.then=="function"}tn(()=>{});var Yr=Symbol.for("signal"),cn=Symbol.for("memo"),fn=Symbol.for("signal-node");function We(e,r){let t=new Jt(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),on(),s});return Object.defineProperty(n,Yr,{value:!0,enumerable:!0}),Object.defineProperty(n,fn,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function ge(e,r,t){let n=r,o=rn(),i=new zr(()=>Zr(o,()=>{try{return n=e(n)}catch(c){if(ln(c))return Xt(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,Yr,{value:!0,enumerable:!0}),Object.defineProperty(s,cn,{value:!0,enumerable:!0}),s}function X(e,r){let t=r;return un(()=>{t=e(t)})}function Le(e){return sn(e)}function Qr(e){return Yt(e)}var pn=Hr();Qt((e,r)=>{let t=Jr(r,pn);t&&(t.increment(),e.finally(()=>t.decrement()))});var dn=Hr();en((e,r)=>{let t=Jr(r,dn);return t?(t.setError(e),!0):!1});var ve=Symbol.for("fluixi-proxy");var re=Symbol("store-raw"),R=Symbol("store-node"),Xr=Symbol("store-has"),we=Symbol("store-self"),Se=Symbol("store-track"),st=Symbol("store-name"),at=Symbol("store-store"),et=new WeakMap,rt=new WeakMap;function ut(e){let[r,t]=We(e),n=r;return n.$=t,n}function Te(e){let r=et.get(e);return r||et.set(e,r={keys:new Map}),r}function tt(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=ut(t)),n}function nt(e){let r=Te(e);(r.all||(r.all=ut()))()}function ot(e,r){e.$(typeof r=="function"?()=>r:r)}function lt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function Ae(e){if(!lt(e))return e;let r=rt.get(e);if(r)return r;let t=new Proxy(e,yn);return rt.set(e,t),t}var yn={get(e,r,t){if(r===re||r===R)return e;if(r===ve)return t;if(r===Xr)return s=>s in e;if(r==="__proxy")return!0;if(r===Se||r===we)return nt(e),t;let n=e[r];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,r))return n;let o=Object.getOwnPropertyDescriptor(e,r);if(o&&o.get)return o.get.call(t);let i=tt(Te(e),r,n)();return lt(i)?Ae(i):i},set(){return!0},deleteProperty(e,r){return r in e&&ee(e,r,void 0),!0},has(e,r){return r===re||r===ve||r===R||r===Xr||r===we||r===Se?!0:(tt(Te(e),r,e[r])(),r in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function ee(e,r,t){if(e[r]===t&&(t!==void 0||r in e))return;let o=Array.isArray(e),i=o?e.length:0;t===void 0?delete e[r]:e[r]=t;let s=Te(e),c=s.keys.get(r);if(c&&ot(c,t),o&&e.length!==i){let u=s.keys.get("length");u&&ot(u,e.length)}s.all&&s.all.$(void 0)}function it(e,r){return typeof e=="function"?e(r):e}function ze(e,r){for(let t of Object.keys(r)){let n=r[t],o=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?ze(o,n):ee(e,t,n)}}function He(e){let r=[],t=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of t.split("."))n.length&&r.push(n);return r}function ct(e,r,t){let n=r.length-1;for(let i=0;i<n;i++){let s=r[i];if(s==="*"){let u=r.slice(i+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ct(e[p],u,t);return}let c=e[s];(c==null||typeof c!="object")&&(c=/^\d+$/.test(r[i+1])?[]:{},ee(e,s,c)),e=c}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)ee(e,i,it(t,e[i]));return}ee(e,o,it(t,e[o]))}function Ke(e,r,t){ct(e,He(r),t)}function hn(e,r){let t=r[0];if(typeof t=="function"&&r.length===1){let n=t(e);n&&n!==e&&ze(e,n);return}if(Array.isArray(t)&&r.length===1){for(let n of t)Array.isArray(n)&&Ke(e,n[0],n[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&r.length===1){ze(e,t);return}if(Array.isArray(r[1])&&r.length>=3){Ke(e,`${t}.${r[1].join(".")}`,r[2]);return}Ke(e,String(t),r[1])}function Ge(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ge);let r={};for(let t of Object.keys(e))r[t]=Ge(e[t]);return r}function V(e,r){let t=e;for(let n of He(r)){if(t==null)return;t=t[n]}return t}var k=class{constructor(r,t={immutable:!0}){this.options=t;this.root=r,this.set=((...n)=>Le(()=>hn(this.root,n)))}get state(){return Ae(this.root)}get proxy(){return Ae(this.root)}get accessor(){return(()=>Ae(this.root))}unwrap(){return this.root}getNode(r){return this.root&&this.root[r]}get(r){if(r==null||r==="")return W(this.state);let t=this.state;for(let n of He(r)){if(t==null)return;t=t[n]}return W(t)}select(r){return ge(()=>r(this.state))}subscribe(r){return X(()=>r(this.state))}watch(r,t){let n;return X(()=>{let o=r(this.state);Object.is(o,n)||(t(o,n),n=o)})}reactive(r){return ge(()=>this.state[r])}produce(r){this.set((t=>{let n=Ge(t);return r(n),n}))}reconcile(r,t={}){this.set(r)}push(r,...t){let n=V(this.root,r);this.set(r,n.concat(t))}pop(r){let t=V(this.root,r).slice(),n=t.pop();return this.set(r,t),n}shift(r){let t=V(this.root,r).slice(),n=t.shift();return this.set(r,t),n}splice(r,t,n,...o){let i=V(this.root,r).slice(),s=i.splice(t,n,...o);return this.set(r,i),s}insert(r,t,n){let o=V(this.root,r).slice();o.splice(t,0,n),this.set(r,o)}removeAt(r,t){let n=V(this.root,r).slice(),o=n.splice(t,1);return this.set(r,n),o}toObservable(){let[r]=We(this.state);return r.toObservable()}dispose(){}},bn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function ft(e,r){for(let t of bn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function Je(e,r={immutable:!0}){let t=new k(e,r);return ft(t.set,t),[t.proxy,t.set]}function Ze(e,r={}){return new k(e,{...r,immutable:!1})}function pt(e,r={}){let t=new k(e(),r);return X(()=>t.set(e())),t}function dt(e,r,t){return X(()=>t(r(e)))}function yt(e,r,t){return ge(()=>r(e),void 0,t)}function ht(e,r={}){let t=new k(e,r),n=(()=>t.proxy);return ft(n,t),n}function W(e){if(e==null||typeof e!="object")return e;let r=e[re];return r!==void 0?r:e}function Ye(e){return Qr(()=>W(e))}function bt(e){return Oe(e)}function mt(e){return Oe(e)?e[R]:null}function gt(e){return e&&typeof e=="object"&&R in e?e[R]:null}function Oe(e){return!!e&&typeof e=="object"&&(ve in e||e.__proxy===!0)}function vt(e){return e}var At=Object.freeze({createStore:Je,createMutableStore:Ze,batch:Le,unwrap:W,untrackStore:Ye});function Qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Qe);let r={};for(let t of Object.keys(e))r[t]=Qe(e[t]);return r}function wt(e){return r=>{let t=Qe(r);return e(t),t}}function St(e,r={}){return()=>e}return Pt(mn);})();
@@ -1 +1 @@
1
- var mt="1.0.0-alpha.70";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,h;C(b=>{h=b;let[k,B]=d(u);f=B,l=t(p,k)});let x={item:p,rendered:l,dispose:h,setIndex:f};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),h=c.get(f);if(h&&!y.has(f))h.setIndex(l),u.push(h);else{let x,b,k;C(B=>{k=B;let[A,j]=d(l);b=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex:b})}p.push(f),y.add(f)}for(let[l,f]of c)y.has(l)||f.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(h=>{l=h;let[x,b]=d(f);y=b,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Vt(e){he=e}function ve(e){he&&he(e)}var be=null;function Kt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[f,h]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,b]=d(void 0,{equals:!1}),[k,B]=d(void 0,{equals:!1}),A=Oe,j=!1;F(()=>{let T=n();if(k(),T===!1||T===null||T===void 0){A=Oe,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let w=j;if(j=!1,A!==Oe&&T===A&&!w)return;if(A=T,c){c=!1;return}let J=!1;m(()=>J=!0);let Be=v(f),Tt=v(u),je=Be==="ready"||Be==="refreshing";g(()=>{h(je?"refreshing":"pending"),l(void 0)});try{let R=o(T,{value:Tt,refetching:je});Xt(R)?(b(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),h("ready"),b(void 0)}))},Z=>{J||g(()=>{l(Z),h("errored"),b(void 0)})})):g(()=>{p(()=>R),h("ready"),b(void 0)})}catch(R){if(J)return;g(()=>{l(R),h("errored"),b(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let h=typeof f=="function"?f(v(r)):f;return n(()=>h),c(!0),p(),u=setTimeout(y,t),h});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),hn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function ht(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function bt(e){return sr(()=>X(e))}function hr(e){return Ie(e)}function br(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:ht,batch:ut,unwrap:X,untrackStore:bt});function Ue(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ue);let t={};for(let r of Object.keys(e))t[r]=Ue(e[r]);return t}function Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,hn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,ht as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,br as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,hr as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,bt as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
1
+ var mt="1.0.0-alpha.72";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,h;C(b=>{h=b;let[k,B]=d(u);f=B,l=t(p,k)});let x={item:p,rendered:l,dispose:h,setIndex:f};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),h=c.get(f);if(h&&!y.has(f))h.setIndex(l),u.push(h);else{let x,b,k;C(B=>{k=B;let[A,j]=d(l);b=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex:b})}p.push(f),y.add(f)}for(let[l,f]of c)y.has(l)||f.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(h=>{l=h;let[x,b]=d(f);y=b,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Vt(e){he=e}function ve(e){he&&he(e)}var be=null;function Kt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[f,h]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,b]=d(void 0,{equals:!1}),[k,B]=d(void 0,{equals:!1}),A=Oe,j=!1;F(()=>{let T=n();if(k(),T===!1||T===null||T===void 0){A=Oe,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let w=j;if(j=!1,A!==Oe&&T===A&&!w)return;if(A=T,c){c=!1;return}let J=!1;m(()=>J=!0);let Be=v(f),Tt=v(u),je=Be==="ready"||Be==="refreshing";g(()=>{h(je?"refreshing":"pending"),l(void 0)});try{let R=o(T,{value:Tt,refetching:je});Xt(R)?(b(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),h("ready"),b(void 0)}))},Z=>{J||g(()=>{l(Z),h("errored"),b(void 0)})})):g(()=>{p(()=>R),h("ready"),b(void 0)})}catch(R){if(J)return;g(()=>{l(R),h("errored"),b(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let h=typeof f=="function"?f(v(r)):f;return n(()=>h),c(!0),p(),u=setTimeout(y,t),h});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),hn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function ht(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function bt(e){return sr(()=>X(e))}function hr(e){return Ie(e)}function br(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:ht,batch:ut,unwrap:X,untrackStore:bt});function Ue(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ue);let t={};for(let r of Object.keys(e))t[r]=Ue(e[r]);return t}function Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,hn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,ht as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,br as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,hr as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,bt as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>ht,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>bt,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.70";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,br,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=s.get(p);if(h&&!c.has(h))h.setIndex(u),i.push(h),c.add(h);else{let l,d,b;E(T=>{b=T;let[C,K]=f(u);d=K,l=t(p,C)});let w={item:p,rendered:l,dispose:b,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],h=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),b=c.get(d);if(b&&!h.has(d))b.setIndex(l),u.push(b);else{let w,T,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),h.add(d)}for(let[l,d]of c)h.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,h,l,d=o[u];E(b=>{l=b;let[w,T]=f(d);h=T,p=t(w,u)}),n.push({rendered:p,setItem:h,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[h,l]=f(void 0,{equals:!1}),[d,b]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,_!==Ie&&m===_&&!g)return;if(_=m,c){c=!1;return}let te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{b(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),b("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),b("errored"),T(void 0)})})):O(()=>{p(()=>k),b("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),b("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=h();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:h},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let b=typeof d=="function"?d(S(r)):d;return n(()=>b),c(!0),p(),u=setTimeout(h,t),b});return v(p),[o,l,{immediate:r,pending:i,flush:h,cancel:()=>{p(),c(!1)}}]}function gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[h,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[h,{...u,query:i,setQuery:c,refetch:l}]}function ye(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=x(e);return x(()=>ye(t()))}var he=N();rt((e,t)=>{let r=se(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(he,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}
1
+ "use strict";var xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>ht,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>bt,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.72";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}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)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.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===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,br,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=s.get(p);if(h&&!c.has(h))h.setIndex(u),i.push(h),c.add(h);else{let l,d,b;E(T=>{b=T;let[C,K]=f(u);d=K,l=t(p,C)});let w={item:p,rendered:l,dispose:b,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],h=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),b=c.get(d);if(b&&!h.has(d))b.setIndex(l),u.push(b);else{let w,T,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),h.add(d)}for(let[l,d]of c)h.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,h,l,d=o[u];E(b=>{l=b;let[w,T]=f(d);h=T,p=t(w,u)}),n.push({rendered:p,setItem:h,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[h,l]=f(void 0,{equals:!1}),[d,b]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,_!==Ie&&m===_&&!g)return;if(_=m,c){c=!1;return}let te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{b(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),b("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),b("errored"),T(void 0)})})):O(()=>{p(()=>k),b("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),b("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=h();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:h},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let b=typeof d=="function"?d(S(r)):d;return n(()=>b),c(!0),p(),u=setTimeout(h,t),b});return v(p),[o,l,{immediate:r,pending:i,flush:h,cancel:()=>{p(),c(!1)}}]}function gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[h,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[h,{...u,query:i,setQuery:c,refetch:l}]}function ye(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=x(e);return x(()=>ye(t()))}var he=N();rt((e,t)=>{let r=se(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(he,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}