@fluixi/reactive 1.0.0-alpha.63 → 1.0.0-alpha.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/signal/graph/debounced.cjs +1 -0
- package/dist/lib/signal/graph/debounced.d.ts +67 -0
- package/dist/lib/signal/graph/debounced.d.ts.map +1 -0
- package/dist/lib/signal/graph/debounced.js +92 -0
- package/dist/lib/signal/graph/debounced.mjs +1 -0
- package/dist/lib/signal/graph/derived.cjs +1 -1
- package/dist/lib/signal/graph/derived.d.ts.map +1 -1
- package/dist/lib/signal/graph/derived.js +0 -16
- package/dist/lib/signal/graph/derived.mjs +1 -1
- package/dist/lib/signal/graph/resource.d.ts +2 -1
- package/dist/lib/signal/graph/resource.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.cjs +1 -1
- package/dist/lib/signal/graph/signal-next.d.ts +1 -0
- package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
- package/dist/lib/signal/graph/signal-next.js +1 -0
- package/dist/lib/signal/graph/signal-next.mjs +1 -1
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/index.cjs +1 -1
- package/dist/lib/signal/index.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/cdn/reactive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Se=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.prototype.hasOwnProperty;var rr=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of er(t))!tr.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=Zt(t,o))||n.enumerable});return e};var or=e=>nr(Se({},"__esModule",{value:!0}),e);var gr={};rr(gr,{$NAME:()=>Ut,$NODE:()=>F,$PROXY:()=>Sr,$RAW:()=>J,$SELF:()=>be,$SIGNAL:()=>vr,$STORE:()=>Bt,$TRACK:()=>Te,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>Rt,Store:()=>_,StoreAPI:()=>Yt,Subject:()=>we,Subscriber:()=>U,Subscription:()=>D,SuspenseContext:()=>ye,__DEV__:()=>ae,batch:()=>w,createComputed:()=>nt,createComputedStore:()=>$t,createContext:()=>q,createDebounce:()=>vt,createDeferred:()=>mt,createEffect:()=>P,createErrorBoundary:()=>At,createMemo:()=>S,createMutableStore:()=>qe,createRenderEffect:()=>ot,createResource:()=>xt,createRoot:()=>k,createSelector:()=>Tt,createSignal:()=>d,createStore:()=>Ne,createStoreEffect:()=>Lt,createStoreMemo:()=>Vt,createSuspenseBoundary:()=>wt,flush:()=>it,getNode:()=>Wt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Ht,indexArray:()=>yr,isComponent:()=>lt,isMemo:()=>ut,isOwnerDisposed:()=>Ye,isProvider:()=>ft,isResource:()=>ct,isSignal:()=>ue,isStore:()=>Gt,isStoreProxy:()=>ve,isSuspense:()=>pt,keyArray:()=>dr,makeArrayFlat:()=>Ee,mapArray:()=>fr,modifiable:()=>zt,nextResourceId:()=>pe,on:()=>at,onCleanup:()=>v,operate:()=>sr,produceUtil:()=>Xt,provide:()=>M,provideErrorBoundary:()=>_t,provideSuspense:()=>Ot,readChildren:()=>St,reconcileUtil:()=>Jt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Ae,setResourceDataSink:()=>bt,setResourceIdSource:()=>ht,setResourceTracker:()=>dt,setServerDataGetter:()=>yt,startTransition:()=>Re,trackResourcePromise:()=>ce,untrack:()=>O,untrackStore:()=>Me,unwrap:()=>V,useContext:()=>Xe,useTransition:()=>st,wrap:()=>Kt});module.exports=or(gr);var Ke=require("@fluixi/utils/object"),xe=require("@fluixi/utils/functions"),D=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,xe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,Ke.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,xe.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 D{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())}},te=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 sr(e){return new U(e.next,e.error,e.complete)}var B=class extends D{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 te(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 we=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 ir="__fluixi_signal_next_state__",ar=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[ir]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ar,onSuspend:null,onError:null};var Ge=0,We=1,W=2,re=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 re{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);Oe(this)}}peek(){return this._value}},A=class extends re{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===We&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=Ge}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);Oe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Ge;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(We);Oe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Oe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var N=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 He(){return a.consumer}function ze(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ye(e){return!!e&&e.disposed===!0}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(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 Xe(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=oe(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 Je(e){a.onSuspend=e}function Qe(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ze(e){a.onError=e}function z(){return a.owner}function Ae(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 ne(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)ne(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 k(e){let t=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function et(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ur(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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function tt(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var ge=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new N(()=>ur(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),ne(this.owner))}};function ie(e){let t=new ge(e);return()=>t.dispose()}function cr(e){return!!e&&typeof e.then=="function"}et(()=>{});var rt=Symbol.for("signal"),lr=Symbol.for("memo"),pr=Symbol.for("signal-node");function d(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),tt(),i});return Object.defineProperty(n,rt,{value:!0,enumerable:!0}),Object.defineProperty(n,pr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(cr(c))return Qe(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,rt,{value:!0,enumerable:!0}),Object.defineProperty(i,lr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function nt(e,t){let r=t;ie(()=>{r=e(r)})}function ot(e,t){let r=t;return ie(()=>{r=e(r)})}function w(e){return _e(e)}function O(e){return H(e)}function Re(e){return _e(e),Promise.resolve()}function st(){return[()=>!1,Re]}function it(){return Y(),Promise.resolve()}function at(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(f=>f()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function fr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{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 f=o[u],y=s.get(f);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,h,b;k(T=>{b=T;let[C,K]=d(u);h=K,l=t(f,C)});let x={item:f,rendered:l,dispose:b,setIndex:h};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 dr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return O(()=>{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=[],f=[],y=new Set;for(let l=0;l<i.length;l++){let h=t(i[l]),b=c.get(h);if(b&&!y.has(h))b.setIndex(l),u.push(b);else{let x,T,C;k(K=>{C=K;let[R,G]=d(l);T=G;let Q=S(I=>{let g=(e()||[])[R()];return g??I},i[l]);x=r(Q,R)}),u.push({rendered:x,dispose:C,setIndex:T})}f.push(h),y.add(h)}for(let[l,h]of c)y.has(l)||h.dispose();return o=f,s=u,u.map(l=>l.rendered)})})}function yr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{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 f,y,l,h=o[u];k(b=>{l=b;let[x,T]=d(h);y=T,f=t(x,u)}),n.push({rendered:f,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 ae=!1,hr=Symbol.for("signal"),br=Symbol.for("memo"),Tr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[hr]===!0}function ut(e){return typeof e=="function"&&e[br]===!0}function ct(e){return typeof e=="function"&&e[Tr]===!0}function lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function ft(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 ke=null;function dt(e){ke=e}function ce(e){ke&&ke(e)}var Pe=null;function yt(e){Pe=e}function le(e){return Pe?Pe(e):void 0}var Fe=null;function ht(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function bt(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function Tt(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]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function mt(e,t){let[r,n]=d(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 vt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function de(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:de(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=de(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function St(e){let t=S(e);return S(()=>de(t()))}function mr(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function xt(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,f]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[h,b]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,K]=d(void 0,{equals:!1}),R=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){R=Ie,w(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,R!==Ie&&m===R&&!g)return;if(R=m,c){c=!1;return}let Z=!1;v(()=>Z=!0);let Le=O(h),Qt=O(u),Ve=Le==="ready"||Le==="refreshing";w(()=>{b(Ve?"refreshing":"pending"),l(void 0)});try{let E=o(m,{value:Qt,refetching:Ve});mr(E)?(T(E),ce(E),E.then(ee=>{Z||(s!==void 0&&fe(s,ee),w(()=>{f(()=>ee),b("ready"),T(void 0)}))},ee=>{Z||w(()=>{l(ee),b("errored"),T(void 0)})})):w(()=>{f(()=>E),b("ready"),T(void 0)})}catch(E){if(Z)return;w(()=>{l(E),b("errored"),T(void 0)})}});let Q=()=>{let m=h();return m==="pending"||m==="refreshing"},I=(()=>{let m=y();if(m)throw m;if(Q()){let g=x();if(g)throw g}return u()});return Object.defineProperties(I,{state:{get:h},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(I,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(I,Symbol.for("signal"),{value:!0,enumerable:!0}),[I,{mutate:f,refetch:()=>{G=!0,K(void 0)}}]}var ye=q();Je((e,t)=>{let r=se(t,ye);r&&(r.increment(),e.finally(()=>r.decrement()))});function wt(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Ot(e,t){return M(ye,e,t)}var gt=q();Ze((e,t)=>{let r=se(t,gt);return r?(r.setError(e),!0):!1});function At(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function _t(e,t){return M(gt,e,t)}var Rt={State:j,Computed:A,subtle:{Watcher:N,untrack:H,currentComputed:He,hasSinks:ze}};var vr=Symbol.for("signal"),Sr=Symbol.for("fluixi-proxy");var p=require("@fluixi/reactive/signal"),J=Symbol("store-raw"),F=Symbol("store-node"),Et=Symbol("store-has"),be=Symbol("store-self"),Te=Symbol("store-track"),Ut=Symbol("store-name"),Bt=Symbol("store-store"),kt=new WeakMap,Pt=new WeakMap;function jt(e){let[t,r]=(0,p.createSignal)(e),n=t;return n.$=r,n}function me(e){let t=kt.get(e);return t||kt.set(e,t={keys:new Map}),t}function Ft(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=jt(r)),n}function Ct(e){let t=me(e);(t.all||(t.all=jt()))()}function It(e,t){e.$(typeof t=="function"?()=>t:t)}function Nt(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 he(e){if(!Nt(e))return e;let t=Pt.get(e);if(t)return t;let r=new Proxy(e,xr);return Pt.set(e,r),r}var xr={get(e,t,r){if(t===J||t===F)return e;if(t===p.$PROXY)return r;if(t===Et)return i=>i in e;if(t==="__proxy")return!0;if(t===Te||t===be)return Ct(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=Ft(me(e),t,n)();return Nt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===J||t===p.$PROXY||t===F||t===Et||t===be||t===Te?!0:(Ft(me(e),t,e[t])(),t in e)},ownKeys(e){return Ct(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(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=me(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 Dt(e,t){return typeof e=="function"?e(t):e}function Ue(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)?Ue(o,n):X(e,r,n)}}function je(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function qt(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 f=0;f<e.length;f++)qt(e[f],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,Dt(r,e[s]));return}X(e,o,Dt(r,e[o]))}function De(e,t,r){qt(e,je(t),r)}function wr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ue(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&De(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ue(e,r);return}if(Array.isArray(t[1])&&t.length>=3){De(e,`${r}.${t[1].join(".")}`,t[2]);return}De(e,String(r),t[1])}function Be(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Be);let t={};for(let r of Object.keys(e))t[r]=Be(e[r]);return t}function L(e,t){let r=e;for(let n of je(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)=>(0,p.batch)(()=>wr(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(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 je(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,p.createMemo)(()=>t(this.state))}subscribe(t){return(0,p.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,p.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,p.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Be(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,p.createSignal)(this.state);return t.toObservable()}dispose(){}},Or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Mt(e,t){for(let r of Or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new _(e,t);return Mt(r.set,r),[r.proxy,r.set]}function qe(e,t={}){return new _(e,{...t,immutable:!1})}function $t(e,t={}){let r=new _(e(),t);return(0,p.createEffect)(()=>r.set(e())),r}function Lt(e,t,r){return(0,p.createEffect)(()=>r(t(e)))}function Vt(e,t,r){return(0,p.createMemo)(()=>t(e),void 0,r)}function Kt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Mt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[J];return t!==void 0?t:e}function Me(e){return(0,p.untrack)(()=>V(e))}function Gt(e){return ve(e)}function Wt(e){return ve(e)?e[F]:null}function Ht(e){return e&&typeof e=="object"&&F in e?e[F]:null}function ve(e){return!!e&&typeof e=="object"&&(p.$PROXY in e||e.__proxy===!0)}function zt(e){return e}var Yt=Object.freeze({createStore:Ne,createMutableStore:qe,batch:p.batch,unwrap:V,untrackStore:Me});function $e(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($e);let t={};for(let r of Object.keys(e))t[r]=$e(e[r]);return t}function Xt(e){return t=>{let r=$e(t);return e(r),r}}function Jt(e,t={}){return()=>e}
|
|
1
|
+
"use strict";var xe=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.prototype.hasOwnProperty;var or=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},sr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rr(t))!nr.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=tr(t,o))||n.enumerable});return e};var ir=e=>sr(xe({},"__esModule",{value:!0}),e);var _r={};or(_r,{$NAME:()=>jt,$NODE:()=>D,$PROXY:()=>Or,$RAW:()=>Q,$SELF:()=>Te,$SIGNAL:()=>wr,$STORE:()=>qt,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>Et,Store:()=>R,StoreAPI:()=>Qt,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>be,__DEV__:()=>ae,batch:()=>O,createComputed:()=>st,createComputedStore:()=>Vt,createContext:()=>M,createDebounce:()=>xt,createDebouncedResource:()=>wt,createDebouncedSignal:()=>Ue,createDeferred:()=>St,createEffect:()=>P,createErrorBoundary:()=>_t,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>it,createResource:()=>de,createRoot:()=>E,createSelector:()=>vt,createSignal:()=>f,createStore:()=>Ne,createStoreEffect:()=>Kt,createStoreMemo:()=>Gt,createSuspenseBoundary:()=>gt,flush:()=>ut,getNode:()=>zt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Yt,indexArray:()=>hr,isComponent:()=>ft,isMemo:()=>lt,isOwnerDisposed:()=>Qe,isProvider:()=>yt,isResource:()=>pt,isSignal:()=>ue,isStore:()=>Ht,isStoreProxy:()=>Se,isSuspense:()=>dt,keyArray:()=>br,makeArrayFlat:()=>Ee,mapArray:()=>yr,modifiable:()=>Xt,nextResourceId:()=>pe,on:()=>ct,onCleanup:()=>v,operate:()=>ar,produceUtil:()=>Jt,provide:()=>N,provideErrorBoundary:()=>kt,provideSuspense:()=>At,readChildren:()=>Ot,reconcileUtil:()=>Zt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>mt,setResourceIdSource:()=>Tt,setResourceTracker:()=>bt,setServerDataGetter:()=>ht,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>Je,useTransition:()=>at,wrap:()=>Wt});module.exports=ir(_r);var We=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,We.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())}},te=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 ar(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 te(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 ur="__fluixi_signal_next_state__",cr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[ur]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:cr,onSuspend:null,onError:null};var He=0,ze=1,W=2,re=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 re{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 re{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===ze&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=He}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===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ze);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 Ye(){return a.consumer}function Xe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Qe(e){return!!e&&e.disposed===!0}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(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 Je(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 N(e,t,r){let n=oe(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 Ze(e){a.onSuspend=e}function et(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function tt(e){a.onError=e}function z(){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 ne(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)ne(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=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function rt(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function lr(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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function nt(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>lr(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),ne(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function pr(e){return!!e&&typeof e.then=="function"}rt(()=>{});var ot=Symbol.for("signal"),fr=Symbol.for("memo"),dr=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),nt(),i});return Object.defineProperty(n,ot,{value:!0,enumerable:!0}),Object.defineProperty(n,dr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(pr(c))return et(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,ot,{value:!0,enumerable:!0}),Object.defineProperty(i,fr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function st(e,t){let r=t;ie(()=>{r=e(r)})}function it(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 at(){return[()=>!1,ke]}function ut(){return Y(),Promise.resolve()}function ct(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 yr(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],b=s.get(p);if(b&&!c.has(b))b.setIndex(u),i.push(b),c.add(b);else{let l,d,h;E(T=>{h=T;let[F,K]=f(u);d=K,l=t(p,F)});let w={item:p,rendered:l,dispose:h,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 br(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=[],b=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),h=c.get(d);if(h&&!b.has(d))h.setIndex(l),u.push(h);else{let w,T,F;E(K=>{F=K;let[_,G]=f(l);T=G;let J=x(C=>{let g=(e()||[])[_()];return g??C},i[l]);w=r(J,_)}),u.push({rendered:w,dispose:F,setIndex:T})}p.push(d),b.add(d)}for(let[l,d]of c)b.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function hr(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,b,l,d=o[u];E(h=>{l=h;let[w,T]=f(d);b=T,p=t(w,u)}),n.push({rendered:p,setItem:b,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,Tr=Symbol.for("signal"),mr=Symbol.for("memo"),vr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Tr]===!0}function lt(e){return typeof e=="function"&&e[mr]===!0}function pt(e){return typeof e=="function"&&e[vr]===!0}function ft(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function yt(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 bt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function ht(e){De=e}function le(e){return De?De(e):void 0}var Fe=null;function Tt(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function mt(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function vt(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 St(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 xt(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 Sr(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}),[b,l]=f(void 0,{equals:!1}),[d,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[F,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(F(),m===!1||m===null||m===void 0){_=Ie,O(()=>{h("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 Z=!1;v(()=>Z=!0);let Ke=S(d),er=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:er,refetching:Ge});Sr(k)?(T(k),ce(k),k.then(ee=>{Z||(s!==void 0&&fe(s,ee),O(()=>{p(()=>ee),h("ready"),T(void 0)}))},ee=>{Z||O(()=>{l(ee),h("errored"),T(void 0)})})):O(()=>{p(()=>k),h("ready"),T(void 0)})}catch(k){if(Z)return;O(()=>{l(k),h("errored"),T(void 0)})}});let J=()=>{let m=d();return m==="pending"||m==="refreshing"},C=(()=>{let m=b();if(m)throw m;if(J()){let g=w();if(g)throw g}return u()});return Object.defineProperties(C,{state:{get:d},loading:{get:J},error:{get:b},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:()=>{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)},b=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let h=typeof d=="function"?d(S(r)):d;return n(()=>h),c(!0),p(),u=setTimeout(b,t),h});return v(p),[o,l,{immediate:r,pending:i,flush:b,cancel:()=>{p(),c(!1)}}]}function xr(e){return e!=null&&e!==""}function wt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=xr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[b,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[b,{...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 Ot(e){let t=x(e);return x(()=>ye(t()))}var be=M();Ze((e,t)=>{let r=se(t,be);r&&(r.increment(),e.finally(()=>r.decrement()))});function gt(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function At(e,t){return N(be,e,t)}var Rt=M();tt((e,t)=>{let r=se(t,Rt);return r?(r.setError(e),!0):!1});function _t(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function kt(e,t){return N(Rt,e,t)}var Et={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Ye,hasSinks:Xe}};var wr=Symbol.for("signal"),Or=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Q=Symbol("store-raw"),D=Symbol("store-node"),Pt=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),jt=Symbol("store-name"),qt=Symbol("store-store"),Dt=new WeakMap,Ft=new WeakMap;function Mt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=Dt.get(e);return t||Dt.set(e,t={keys:new Map}),t}function Ct(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Mt(r)),n}function It(e){let t=ve(e);(t.all||(t.all=Mt()))()}function Ut(e,t){e.$(typeof t=="function"?()=>t:t)}function Nt(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 he(e){if(!Nt(e))return e;let t=Ft.get(e);if(t)return t;let r=new Proxy(e,gr);return Ft.set(e,r),r}var gr={get(e,t,r){if(t===Q||t===D)return e;if(t===y.$PROXY)return r;if(t===Pt)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return It(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=Ct(ve(e),t,n)();return Nt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===Q||t===y.$PROXY||t===D||t===Pt||t===Te||t===me?!0:(Ct(ve(e),t,e[t])(),t in e)},ownKeys(e){return It(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(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&&Ut(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Ut(u,e.length)}i.all&&i.all.$(void 0)}function Bt(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):X(e,r,n)}}function Me(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function $t(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++)$t(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,Bt(r,e[s]));return}X(e,o,Bt(r,e[o]))}function Be(e,t,r){$t(e,Me(t),r)}function Ar(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 Me(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)(()=>Ar(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(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 Me(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(){}},Rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Lt(e,t){for(let r of Rr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new R(e,t);return Lt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Vt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Kt(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function Gt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Wt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Lt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Q];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Ht(e){return Se(e)}function zt(e){return Se(e)?e[D]:null}function Yt(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 Xt(e){return e}var Qt=Object.freeze({createStore:Ne,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 Jt(e){return t=>{let r=Ve(t);return e(r),r}}function Zt(e,t={}){return()=>e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Fluixi=(()=>{var Oe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var St=(e,r)=>{for(var t in r)Oe(e,t,{get:r[t],enumerable:!0})},Tt=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of At(r))!wt.call(e,o)&&o!==t&&Oe(e,o,{get:()=>r[o],enumerable:!(n=mt(r,o))||n.enumerable});return e};var Ot=e=>Tt(Oe({},"__esModule",{value:!0}),e);var cn={};St(cn,{$NAME:()=>rt,$NODE:()=>E,$PROXY:()=>Ut,$RAW:()=>Q,$SELF:()=>Ae,$SIGNAL:()=>qt,$STORE:()=>tt,$TRACK:()=>we,Observable:()=>F,SafeSubscriber:()=>ne,Signal:()=>Mr,Store:()=>k,StoreAPI:()=>ht,Subject:()=>ke,Subscriber:()=>D,Subscription:()=>I,SuspenseContext:()=>ge,__DEV__:()=>le,batch:()=>S,createComputed:()=>dr,createComputedStore:()=>at,createContext:()=>q,createDebounce:()=>Pr,createDeferred:()=>_r,createEffect:()=>$,createErrorBoundary:()=>Dr,createMemo:()=>A,createMutableStore:()=>He,createRenderEffect:()=>yr,createResource:()=>Er,createRoot:()=>P,createSelector:()=>jr,createSignal:()=>d,createStore:()=>Ge,createStoreEffect:()=>ut,createStoreMemo:()=>lt,createSuspenseBoundary:()=>Rr,flush:()=>gr,getNode:()=>pt,getOwner:()=>H,getServerData:()=>pe,getStoreNode:()=>dt,indexArray:()=>It,isComponent:()=>Ar,isMemo:()=>vr,isOwnerDisposed:()=>ir,isProvider:()=>Sr,isResource:()=>mr,isSignal:()=>fe,isStore:()=>ct,isStoreProxy:()=>Te,isSuspense:()=>wr,keyArray:()=>Ct,makeArrayFlat:()=>Re,mapArray:()=>Rt,modifiable:()=>yt,nextResourceId:()=>de,on:()=>br,onCleanup:()=>m,operate:()=>xt,produceUtil:()=>gt,provide:()=>U,provideErrorBoundary:()=>Fr,provideSuspense:()=>Cr,readChildren:()=>$r,reconcileUtil:()=>bt,reportResourceData:()=>ye,runWithOwner:()=>B,setOwner:()=>Pe,setResourceDataSink:()=>kr,setResourceIdSource:()=>xr,setResourceTracker:()=>Tr,setServerDataGetter:()=>Or,startTransition:()=>Ee,trackResourcePromise:()=>ce,untrack:()=>T,untrackStore:()=>Je,unwrap:()=>V,useContext:()=>sr,useTransition:()=>hr,wrap:()=>ft});function xe(e){return typeof e=="function"&&!Qe(e)}var er=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 Qe(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var I=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(xe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(er(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(xe(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 D=class extends I{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())}},ne=class extends D{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 xt(e){return new D(e.next,e.error,e.complete)}var F=class extends I{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 D?o=r:o=new ne(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 ke=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 kt="__fluixi_signal_next_state__",jt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[kt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:jt,onSuspend:null,onError:null};var rr=0,tr=1,z=2,oe=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 oe{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);je(this)}}peek(){return this._value}},x=class extends oe{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===tr&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=rr}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 f=!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,f){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(z);je(this)}}markDirty(t){if(this.state>=t)return;let n=this.state===rr;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(tr);je(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function je(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 nr(){return a.consumer}function or(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ir(e){return!!e&&e.disposed===!0}function se(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=se(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 sr(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=se(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 ar(e){a.onSuspend=e}function ur(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function lr(e){a.onError=e}function H(){return a.owner}function Pe(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 m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function ie(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)ie(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=se(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>ie(r))}finally{a.owner=t}}function fr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function _t(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(J)))}function J(){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 cr(){a.batchDepth===0&&J()}function $e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&J()}}var _e=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=se(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new x(()=>{ie(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>_t(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),ie(this.owner))}};function ue(e){let r=new _e(e);return()=>r.dispose()}function Pt(e){return!!e&&typeof e.then=="function"}fr(()=>{});var pr=Symbol.for("signal"),$t=Symbol.for("memo"),Et=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),cr(),s});return Object.defineProperty(n,pr,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function A(e,r,t){let n=r,o=H(),i=new x(()=>B(o,()=>{try{return n=e(n)}catch(f){if(Pt(f))return ur(f),n;throw f}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,pr,{value:!0,enumerable:!0}),Object.defineProperty(s,$t,{value:!0,enumerable:!0}),s}function $(e,r){let t=r;return ue(()=>{t=e(t)})}function dr(e,r){let t=r;ue(()=>{t=e(t)})}function yr(e,r){let t=r;return ue(()=>{t=e(t)})}function S(e){return $e(e)}function T(e){return G(e)}function Ee(e){return $e(e),Promise.resolve()}function hr(){return[()=>!1,Ee]}function gr(){return J(),Promise.resolve()}function br(e,r,t){let n=Array.isArray(e),o,i=t?.defer??!1;return s=>{let f=n?e.map(p=>p()):e();if(i){i=!1,o=f;return}let u=G(()=>r(f,o,s));return o=f,u}}function Rt(e,r,t){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return T(()=>{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=[],f=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=i.get(p);if(y&&!f.has(y))y.setIndex(u),s.push(y),f.add(y);else{let c,h,g;P(b=>{g=b;let[R,L]=d(u);h=L,c=r(p,R)});let w={item:p,rendered:c,dispose:g,setIndex:h};s.push(w),f.add(w)}}for(let u of n)f.has(u)||u.dispose();return n=s,s.map(u=>u.rendered)})})}function Ct(e,r,t,n){let o=[],i=[];return m(()=>{for(let s of i)s.dispose();o=[],i=[]}),A(()=>{let s=e()||[];return T(()=>{if(s.length===0){for(let c of i)c.dispose();return o=[],i=[],n?.fallback?n.fallback():[]}let f=new Map;for(let c=0;c<o.length;c++)f.set(o[c],i[c]);let u=[],p=[],y=new Set;for(let c=0;c<s.length;c++){let h=r(s[c]),g=f.get(h);if(g&&!y.has(h))g.setIndex(c),u.push(g);else{let w,b,R;P(L=>{R=L;let[j,K]=d(c);b=K;let ee=A(C=>{let O=(e()||[])[j()];return O??C},s[c]);w=t(ee,j)}),u.push({rendered:w,dispose:R,setIndex:b})}p.push(h),y.add(h)}for(let[c,h]of f)y.has(c)||h.dispose();return o=p,i=u,u.map(c=>c.rendered)})})}function It(e,r,t){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),A(()=>{let o=e()||[];return T(()=>{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,y,c,h=o[u];P(g=>{c=g;let[w,b]=d(h);y=b,p=r(w,u)}),n.push({rendered:p,setItem:y,dispose:c})}for(let u=s;u<i;u++)n[u].dispose();s<i&&(n=n.slice(0,s));let f=Math.min(i,s);for(let u=0;u<f;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var le=!1,Dt=Symbol.for("signal"),Ft=Symbol.for("memo"),Mt=Symbol.for("resource");function fe(e){return typeof e=="function"&&e[Dt]===!0}function vr(e){return typeof e=="function"&&e[Ft]===!0}function mr(e){return typeof e=="function"&&e[Mt]===!0}function Ar(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function wr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Sr(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Re(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Re(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Ce=null;function Tr(e){Ce=e}function ce(e){Ce&&Ce(e)}var Ie=null;function Or(e){Ie=e}function pe(e){return Ie?Ie(e):void 0}var De=null;function xr(e){De=e}function de(){return De?De():void 0}var Fe=null;function kr(e){Fe=e}function ye(e,r){Fe&&Fe(e,r)}function jr(e,r=(t,n)=>t===n){let t=new Map;return $(()=>{let n=e();for(let[o,i]of t){let[s,f]=i,u=r(o,n);s()!==u&&f(u)}}),n=>{let o=t.get(n);if(!o){let[i,s]=d(!1);o=[i,s],t.set(n,o);let f=e();s(r(n,f))}return o[0]()}}function _r(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 Pr(e,r){let t,n=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{if(t=void 0,o.length>0){let i=o[o.length-1];typeof i=="object"&&i&&!i.tagName&&i.target&&i.target.tagName&&(i=i.target),i&&typeof i=="object"&&i.tagName&&(i.tagName.toLowerCase()==="input"||i.tagName.toLowerCase()==="textarea")&&i.focus()}e(...o)},r)};return m(()=>{t!==void 0&&clearTimeout(t)}),n}function he(e){if(typeof e=="function"&&!e.length){let r=e();return fe(r)?r:he(r)}if(Array.isArray(e)){let r=[];for(let t=0;t<e.length;t++){let n=he(e[t]);Array.isArray(n)?r.push.apply(r,n):r.push(n)}return r}return e}function $r(e){let r=A(e);return A(()=>he(r()))}function Nt(e){return!!e&&typeof e.then=="function"}var Me=Symbol();function Er(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,f=s!==void 0,[u,p]=d(s!==void 0?s.value:t.initialValue,{equals:!1}),[y,c]=d(void 0,{equals:!1}),[h,g]=d(s!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,b]=d(void 0,{equals:!1}),[R,L]=d(void 0,{equals:!1}),j=Me,K=!1;$(()=>{let v=n();if(R(),v===!1||v===null||v===void 0){j=Me,S(()=>{g("unresolved"),b(void 0),c(void 0)});return}let O=K;if(K=!1,j!==Me&&v===j&&!O)return;if(j=v,f){f=!1;return}let re=!1;m(()=>re=!0);let Ye=T(h),vt=T(u),Xe=Ye==="ready"||Ye==="refreshing";S(()=>{g(Xe?"refreshing":"pending"),c(void 0)});try{let _=o(v,{value:vt,refetching:Xe});Nt(_)?(b(_),ce(_),_.then(te=>{re||(i!==void 0&&ye(i,te),S(()=>{p(()=>te),g("ready"),b(void 0)}))},te=>{re||S(()=>{c(te),g("errored"),b(void 0)})})):S(()=>{p(()=>_),g("ready"),b(void 0)})}catch(_){if(re)return;S(()=>{c(_),g("errored"),b(void 0)})}});let ee=()=>{let v=h();return v==="pending"||v==="refreshing"},C=(()=>{let v=y();if(v)throw v;if(ee()){let O=w();if(O)throw O}return u()});return Object.defineProperties(C,{state:{get:h},loading:{get:ee},error:{get:y},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)}}]}var ge=q();ar((e,r)=>{let t=ae(r,ge);t&&(t.increment(),e.finally(()=>t.decrement()))});function Rr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Cr(e,r){return U(ge,e,r)}var Ir=q();lr((e,r)=>{let t=ae(r,Ir);return t?(t.setError(e),!0):!1});function Dr(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Fr(e,r){return U(Ir,e,r)}var Mr={State:M,Computed:x,subtle:{Watcher:N,untrack:G,currentComputed:nr,hasSinks:or}};var qt=Symbol.for("signal"),Ut=Symbol.for("fluixi-proxy");var Bt="__fluixi_signal_next_state__",Wt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Bt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Wt,onSuspend:null,onError:null},Nr=0,qr=1,Z=2,Ur=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))}},Vt=class extends Ur{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(Z);Ne(this)}}peek(){return this._value}},Br=class extends Ur{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=Z,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===qr&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===Z)break}(this.state===Z||!this._initialized)&&this.recompute(),this.state=Nr}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(Z);Ne(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Nr;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(qr);Ne(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ne(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var Lt=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 Kt(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Wr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Vr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Wr(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 Lr(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 zt(e){l.onSuspend=e}function Gt(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function Ht(e){l.onError=e}function Jt(){return l.owner}function Kr(e,r){let t=l.owner;l.owner=e;try{return r()}finally{l.owner=t}}function qe(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)qe(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 Zt(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function Yt(e){e.queued||(e.queued=!0,l.queue.push(e),!l.scheduled&&l.batchDepth===0&&(l.scheduled=!0,l.hostSchedule(Ue)))}function Ue(){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 Xt(){l.batchDepth===0&&Ue()}function Qt(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&Ue()}}var en=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Wr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new Br(()=>{qe(this.owner,!1),Kr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new Lt(()=>Yt(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),qe(this.owner))}};function rn(e){let r=new en(e);return()=>r.dispose()}function tn(e){return!!e&&typeof e.then=="function"}Zt(()=>{});var zr=Symbol.for("signal"),nn=Symbol.for("memo"),on=Symbol.for("signal-node");function Be(e,r){let t=new Vt(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),Xt(),s});return Object.defineProperty(n,zr,{value:!0,enumerable:!0}),Object.defineProperty(n,on,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function be(e,r,t){let n=r,o=Jt(),i=new Br(()=>Kr(o,()=>{try{return n=e(n)}catch(f){if(tn(f))return Gt(f),n;throw f}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,zr,{value:!0,enumerable:!0}),Object.defineProperty(s,nn,{value:!0,enumerable:!0}),s}function Y(e,r){let t=r;return rn(()=>{t=e(t)})}function We(e){return Qt(e)}function Gr(e){return Kt(e)}var sn=Vr();zt((e,r)=>{let t=Lr(r,sn);t&&(t.increment(),e.finally(()=>t.decrement()))});var an=Vr();Ht((e,r)=>{let t=Lr(r,an);return t?(t.setError(e),!0):!1});var ve=Symbol.for("fluixi-proxy");var Q=Symbol("store-raw"),E=Symbol("store-node"),Hr=Symbol("store-has"),Ae=Symbol("store-self"),we=Symbol("store-track"),rt=Symbol("store-name"),tt=Symbol("store-store"),Jr=new WeakMap,Zr=new WeakMap;function nt(e){let[r,t]=Be(e),n=r;return n.$=t,n}function Se(e){let r=Jr.get(e);return r||Jr.set(e,r={keys:new Map}),r}function Yr(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=nt(t)),n}function Xr(e){let r=Se(e);(r.all||(r.all=nt()))()}function Qr(e,r){e.$(typeof r=="function"?()=>r:r)}function ot(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 me(e){if(!ot(e))return e;let r=Zr.get(e);if(r)return r;let t=new Proxy(e,un);return Zr.set(e,t),t}var un={get(e,r,t){if(r===Q||r===E)return e;if(r===ve)return t;if(r===Hr)return s=>s in e;if(r==="__proxy")return!0;if(r===we||r===Ae)return Xr(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=Yr(Se(e),r,n)();return ot(i)?me(i):i},set(){return!0},deleteProperty(e,r){return r in e&&X(e,r,void 0),!0},has(e,r){return r===Q||r===ve||r===E||r===Hr||r===Ae||r===we?!0:(Yr(Se(e),r,e[r])(),r in e)},ownKeys(e){return Xr(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function X(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=Se(e),f=s.keys.get(r);if(f&&Qr(f,t),o&&e.length!==i){let u=s.keys.get("length");u&&Qr(u,e.length)}s.all&&s.all.$(void 0)}function et(e,r){return typeof e=="function"?e(r):e}function Le(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)?Le(o,n):X(e,t,n)}}function ze(e){let r=[],t=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of t.split("."))n.length&&r.push(n);return r}function it(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++)it(e[p],u,t);return}let f=e[s];(f==null||typeof f!="object")&&(f=/^\d+$/.test(r[i+1])?[]:{},X(e,s,f)),e=f}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)X(e,i,et(t,e[i]));return}X(e,o,et(t,e[o]))}function Ve(e,r,t){it(e,ze(r),t)}function ln(e,r){let t=r[0];if(typeof t=="function"&&r.length===1){let n=t(e);n&&n!==e&&Le(e,n);return}if(Array.isArray(t)&&r.length===1){for(let n of t)Array.isArray(n)&&Ve(e,n[0],n[1]);return}if(t&&typeof t=="object"&&!Array.isArray(t)&&r.length===1){Le(e,t);return}if(Array.isArray(r[1])&&r.length>=3){Ve(e,`${t}.${r[1].join(".")}`,r[2]);return}Ve(e,String(t),r[1])}function Ke(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ke);let r={};for(let t of Object.keys(e))r[t]=Ke(e[t]);return r}function W(e,r){let t=e;for(let n of ze(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)=>We(()=>ln(this.root,n)))}get state(){return me(this.root)}get proxy(){return me(this.root)}get accessor(){return(()=>me(this.root))}unwrap(){return this.root}getNode(r){return this.root&&this.root[r]}get(r){if(r==null||r==="")return V(this.state);let t=this.state;for(let n of ze(r)){if(t==null)return;t=t[n]}return V(t)}select(r){return be(()=>r(this.state))}subscribe(r){return Y(()=>r(this.state))}watch(r,t){let n;return Y(()=>{let o=r(this.state);Object.is(o,n)||(t(o,n),n=o)})}reactive(r){return be(()=>this.state[r])}produce(r){this.set((t=>{let n=Ke(t);return r(n),n}))}reconcile(r,t={}){this.set(r)}push(r,...t){let n=W(this.root,r);this.set(r,n.concat(t))}pop(r){let t=W(this.root,r).slice(),n=t.pop();return this.set(r,t),n}shift(r){let t=W(this.root,r).slice(),n=t.shift();return this.set(r,t),n}splice(r,t,n,...o){let i=W(this.root,r).slice(),s=i.splice(t,n,...o);return this.set(r,i),s}insert(r,t,n){let o=W(this.root,r).slice();o.splice(t,0,n),this.set(r,o)}removeAt(r,t){let n=W(this.root,r).slice(),o=n.splice(t,1);return this.set(r,n),o}toObservable(){let[r]=Be(this.state);return r.toObservable()}dispose(){}},fn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function st(e,r){for(let t of fn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function Ge(e,r={immutable:!0}){let t=new k(e,r);return st(t.set,t),[t.proxy,t.set]}function He(e,r={}){return new k(e,{...r,immutable:!1})}function at(e,r={}){let t=new k(e(),r);return Y(()=>t.set(e())),t}function ut(e,r,t){return Y(()=>t(r(e)))}function lt(e,r,t){return be(()=>r(e),void 0,t)}function ft(e,r={}){let t=new k(e,r),n=(()=>t.proxy);return st(n,t),n}function V(e){if(e==null||typeof e!="object")return e;let r=e[Q];return r!==void 0?r:e}function Je(e){return Gr(()=>V(e))}function ct(e){return Te(e)}function pt(e){return Te(e)?e[E]:null}function dt(e){return e&&typeof e=="object"&&E in e?e[E]:null}function Te(e){return!!e&&typeof e=="object"&&(ve in e||e.__proxy===!0)}function yt(e){return e}var ht=Object.freeze({createStore:Ge,createMutableStore:He,batch:We,unwrap:V,untrackStore:Je});function Ze(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ze);let r={};for(let t of Object.keys(e))r[t]=Ze(e[t]);return r}function gt(e){return r=>{let t=Ze(r);return e(t),t}}function bt(e,r={}){return()=>e}return Ot(cn);})();
|
|
1
|
+
"use strict";var Fluixi=(()=>{var xe=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var Tt=Object.prototype.hasOwnProperty;var Ot=(e,r)=>{for(var t in r)xe(e,t,{get:r[t],enumerable:!0})},xt=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of St(r))!Tt.call(e,o)&&o!==t&&xe(e,o,{get:()=>r[o],enumerable:!(n=wt(r,o))||n.enumerable});return e};var kt=e=>xt(xe({},"__esModule",{value:!0}),e);var yn={};Ot(yn,{$NAME:()=>nt,$NODE:()=>R,$PROXY:()=>Wt,$RAW:()=>X,$SELF:()=>we,$SIGNAL:()=>Vt,$STORE:()=>ot,$TRACK:()=>Se,Observable:()=>F,SafeSubscriber:()=>ne,Signal:()=>qr,Store:()=>k,StoreAPI:()=>mt,Subject:()=>je,Subscriber:()=>I,Subscription:()=>D,SuspenseContext:()=>me,__DEV__:()=>le,batch:()=>T,createComputed:()=>hr,createComputedStore:()=>lt,createContext:()=>q,createDebounce:()=>Rr,createDebouncedResource:()=>Er,createDebouncedSignal:()=>qe,createDeferred:()=>$r,createEffect:()=>$,createErrorBoundary:()=>Mr,createMemo:()=>w,createMutableStore:()=>Ze,createRenderEffect:()=>br,createResource:()=>he,createRoot:()=>P,createSelector:()=>Pr,createSignal:()=>d,createStore:()=>Je,createStoreEffect:()=>ct,createStoreMemo:()=>ft,createSuspenseBoundary:()=>Dr,flush:()=>gr,getNode:()=>yt,getOwner:()=>H,getServerData:()=>pe,getStoreNode:()=>ht,indexArray:()=>Ft,isComponent:()=>Sr,isMemo:()=>Ar,isOwnerDisposed:()=>ar,isProvider:()=>Or,isResource:()=>wr,isSignal:()=>ce,isStore:()=>dt,isStoreProxy:()=>Oe,isSuspense:()=>Tr,keyArray:()=>It,makeArrayFlat:()=>Ce,mapArray:()=>Dt,modifiable:()=>bt,nextResourceId:()=>de,on:()=>vr,onCleanup:()=>v,operate:()=>jt,produceUtil:()=>gt,provide:()=>U,provideErrorBoundary:()=>Nr,provideSuspense:()=>Ir,readChildren:()=>Cr,reconcileUtil:()=>vt,reportResourceData:()=>ye,runWithOwner:()=>B,setOwner:()=>$e,setResourceDataSink:()=>_r,setResourceIdSource:()=>jr,setResourceTracker:()=>xr,setServerDataGetter:()=>kr,startTransition:()=>Ee,trackResourcePromise:()=>fe,untrack:()=>A,untrackStore:()=>Ye,unwrap:()=>W,useContext:()=>ur,useTransition:()=>mr,wrap:()=>pt});function ke(e){return typeof e=="function"&&!rr(e)}var tr=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 rr(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(tr(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())}},ne=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 jt(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 ne(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 _t="__fluixi_signal_next_state__",Pt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[_t]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Pt,onSuspend:null,onError:null};var nr=0,or=1,z=2,oe=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 oe{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 oe{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===or&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===z)break}(this.state===z||!this._initialized)&&this.recompute(),this.state=nr}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===nr;if(this.state=t,n){if(this.observers)for(let o of[...this.observers])o.markDirty(or);_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 ir(){return a.consumer}function sr(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ar(e){return!!e&&e.disposed===!0}function se(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=se(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 ur(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=se(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 lr(e){a.onSuspend=e}function cr(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function fr(e){a.onError=e}function H(){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 ie(e,r=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)ie(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=se(a.owner);a.owner&&(a.owner.owned??=[]).push(r);let t=a.owner;a.owner=r;try{return e(()=>ie(r))}finally{a.owner=t}}function pr(e){a.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function $t(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(J)))}function J(){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 dr(){a.batchDepth===0&&J()}function Re(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&J()}}var Pe=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=se(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new x(()=>{ie(this.owner,!1),B(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new N(()=>$t(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),ie(this.owner))}};function ue(e){let r=new Pe(e);return()=>r.dispose()}function Rt(e){return!!e&&typeof e.then=="function"}pr(()=>{});var yr=Symbol.for("signal"),Et=Symbol.for("memo"),Ct=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),dr(),s});return Object.defineProperty(n,yr,{value:!0,enumerable:!0}),Object.defineProperty(n,Ct,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function w(e,r,t){let n=r,o=H(),i=new x(()=>B(o,()=>{try{return n=e(n)}catch(c){if(Rt(c))return cr(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,yr,{value:!0,enumerable:!0}),Object.defineProperty(s,Et,{value:!0,enumerable:!0}),s}function $(e,r){let t=r;return ue(()=>{t=e(t)})}function hr(e,r){let t=r;ue(()=>{t=e(t)})}function br(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 mr(){return[()=>!1,Ee]}function gr(){return J(),Promise.resolve()}function vr(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 Dt(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 It(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 ee=w(C=>{let O=(e()||[])[j()];return O??C},s[f]);S=t(ee,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 Ft(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,Mt=Symbol.for("signal"),Nt=Symbol.for("memo"),qt=Symbol.for("resource");function ce(e){return typeof e=="function"&&e[Mt]===!0}function Ar(e){return typeof e=="function"&&e[Nt]===!0}function wr(e){return typeof e=="function"&&e[qt]===!0}function Sr(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Tr(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Or(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 xr(e){De=e}function fe(e){De&&De(e)}var Ie=null;function kr(e){Ie=e}function pe(e){return Ie?Ie(e):void 0}var Fe=null;function jr(e){Fe=e}function de(){return Fe?Fe():void 0}var Me=null;function _r(e){Me=e}function ye(e,r){Me&&Me(e,r)}function Pr(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 $r(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 Rr(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 Ut(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 re=!1;v(()=>re=!0);let Xe=A(y),At=A(u),er=Xe==="ready"||Xe==="refreshing";T(()=>{b(er?"refreshing":"pending"),f(void 0)});try{let _=o(g,{value:At,refetching:er});Ut(_)?(m(_),fe(_),_.then(te=>{re||(i!==void 0&&ye(i,te),T(()=>{p(()=>te),b("ready"),m(void 0)}))},te=>{re||T(()=>{f(te),b("errored"),m(void 0)})})):T(()=>{p(()=>_),b("ready"),m(void 0)})}catch(_){if(re)return;T(()=>{f(_),b("errored"),m(void 0)})}});let ee=()=>{let g=y();return g==="pending"||g==="refreshing"},C=(()=>{let g=h();if(g)throw g;if(ee()){let O=S();if(O)throw O}return u()});return Object.defineProperties(C,{state:{get:y},loading:{get:ee},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 Bt(e){return e!=null&&e!==""}function Er(e,r,t={}){let{delay:n=300,initialValue:o,shouldFetch:i=Bt}=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 Cr(e){let r=w(e);return w(()=>be(r()))}var me=q();lr((e,r)=>{let t=ae(r,me);t&&(t.increment(),e.finally(()=>t.decrement()))});function Dr(){let[e,r]=d(0),t=0;return{increment:()=>r(t+=1),decrement:()=>r(t-=1),inFallback:()=>e()>0}}function Ir(e,r){return U(me,e,r)}var Fr=q();fr((e,r)=>{let t=ae(r,Fr);return t?(t.setError(e),!0):!1});function Mr(){let[e,r]=d(void 0,{equals:!1});return{error:e,reset:()=>r(()=>{}),setError:n=>r(()=>n)}}function Nr(e,r){return U(Fr,e,r)}var qr={State:M,Computed:x,subtle:{Watcher:N,untrack:G,currentComputed:ir,hasSinks:sr}};var Vt=Symbol.for("signal"),Wt=Symbol.for("fluixi-proxy");var Lt="__fluixi_signal_next_state__",Kt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},l=globalThis[Lt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Kt,onSuspend:null,onError:null},Ur=0,Br=1,Z=2,Vr=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))}},zt=class extends Vr{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(Z);Ue(this)}}peek(){return this._value}},Wr=class extends Vr{constructor(e,r){super(),this._threw=!1,this._initialized=!1,this.state=Z,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===Br&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===Z)break}(this.state===Z||!this._initialized)&&this.recompute(),this.state=Ur}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(Z);Ue(this)}}markDirty(e){if(this.state>=e)return;let r=this.state===Ur;if(this.state=e,r){if(this.observers)for(let t of[...this.observers])t.markDirty(Br);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 Gt=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 Ht(e){if(l.untracked)return e();l.untracked=!0;try{return e()}finally{l.untracked=!1}}function Lr(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function Kr(e){let r=Symbol("context");return{id:r,defaultValue:e,Provider:t=>{let n=l.owner,o=Lr(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 zr(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 Jt(e){l.onSuspend=e}function Zt(e){return l.onSuspend?(l.onSuspend(e,l.owner),!0):!1}function Yt(e){l.onError=e}function Qt(){return l.owner}function Gr(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 Xt(e){l.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function en(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 rn(){l.batchDepth===0&&Ve()}function tn(e){l.batchDepth++;try{return e()}finally{--l.batchDepth===0&&Ve()}}var nn=class{constructor(e){this.queued=!1,this.disposed=!1,this.owner=Lr(l.owner),l.owner&&(l.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new Wr(()=>{Be(this.owner,!1),Gr(this.owner,()=>{let r=e();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new Gt(()=>en(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 on(e){let r=new nn(e);return()=>r.dispose()}function sn(e){return!!e&&typeof e.then=="function"}Xt(()=>{});var Hr=Symbol.for("signal"),an=Symbol.for("memo"),un=Symbol.for("signal-node");function We(e,r){let t=new zt(e,{equals:r?.equals}),n=(()=>t.get()),o=(i=>{let s=typeof i=="function"?i(t.peek()):i;return t.set(s),rn(),s});return Object.defineProperty(n,Hr,{value:!0,enumerable:!0}),Object.defineProperty(n,un,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[n,o]}function ge(e,r,t){let n=r,o=Qt(),i=new Wr(()=>Gr(o,()=>{try{return n=e(n)}catch(c){if(sn(c))return Zt(c),n;throw c}}),{equals:t?.equals}),s=(()=>i.get());return Object.defineProperty(s,Hr,{value:!0,enumerable:!0}),Object.defineProperty(s,an,{value:!0,enumerable:!0}),s}function Y(e,r){let t=r;return on(()=>{t=e(t)})}function Le(e){return tn(e)}function Jr(e){return Ht(e)}var ln=Kr();Jt((e,r)=>{let t=zr(r,ln);t&&(t.increment(),e.finally(()=>t.decrement()))});var cn=Kr();Yt((e,r)=>{let t=zr(r,cn);return t?(t.setError(e),!0):!1});var ve=Symbol.for("fluixi-proxy");var X=Symbol("store-raw"),R=Symbol("store-node"),Zr=Symbol("store-has"),we=Symbol("store-self"),Se=Symbol("store-track"),nt=Symbol("store-name"),ot=Symbol("store-store"),Yr=new WeakMap,Qr=new WeakMap;function it(e){let[r,t]=We(e),n=r;return n.$=t,n}function Te(e){let r=Yr.get(e);return r||Yr.set(e,r={keys:new Map}),r}function Xr(e,r,t){let n=e.keys.get(r);return n||e.keys.set(r,n=it(t)),n}function et(e){let r=Te(e);(r.all||(r.all=it()))()}function rt(e,r){e.$(typeof r=="function"?()=>r:r)}function st(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(!st(e))return e;let r=Qr.get(e);if(r)return r;let t=new Proxy(e,fn);return Qr.set(e,t),t}var fn={get(e,r,t){if(r===X||r===R)return e;if(r===ve)return t;if(r===Zr)return s=>s in e;if(r==="__proxy")return!0;if(r===Se||r===we)return et(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=Xr(Te(e),r,n)();return st(i)?Ae(i):i},set(){return!0},deleteProperty(e,r){return r in e&&Q(e,r,void 0),!0},has(e,r){return r===X||r===ve||r===R||r===Zr||r===we||r===Se?!0:(Xr(Te(e),r,e[r])(),r in e)},ownKeys(e){return et(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){return Reflect.getOwnPropertyDescriptor(e,r)}};function Q(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&&rt(c,t),o&&e.length!==i){let u=s.keys.get("length");u&&rt(u,e.length)}s.all&&s.all.$(void 0)}function tt(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):Q(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 at(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++)at(e[p],u,t);return}let c=e[s];(c==null||typeof c!="object")&&(c=/^\d+$/.test(r[i+1])?[]:{},Q(e,s,c)),e=c}let o=r[n];if(o==="*"){if(Array.isArray(e))for(let i=0;i<e.length;i++)Q(e,i,tt(t,e[i]));return}Q(e,o,tt(t,e[o]))}function Ke(e,r,t){at(e,He(r),t)}function pn(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(()=>pn(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 Y(()=>r(this.state))}watch(r,t){let n;return Y(()=>{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(){}},dn=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function ut(e,r){for(let t of dn)e[t]=r[t].bind(r);e.$=r.reactive.bind(r)}function Je(e,r={immutable:!0}){let t=new k(e,r);return ut(t.set,t),[t.proxy,t.set]}function Ze(e,r={}){return new k(e,{...r,immutable:!1})}function lt(e,r={}){let t=new k(e(),r);return Y(()=>t.set(e())),t}function ct(e,r,t){return Y(()=>t(r(e)))}function ft(e,r,t){return ge(()=>r(e),void 0,t)}function pt(e,r={}){let t=new k(e,r),n=(()=>t.proxy);return ut(n,t),n}function W(e){if(e==null||typeof e!="object")return e;let r=e[X];return r!==void 0?r:e}function Ye(e){return Jr(()=>W(e))}function dt(e){return Oe(e)}function yt(e){return Oe(e)?e[R]:null}function ht(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 bt(e){return e}var mt=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 gt(e){return r=>{let t=Qe(r);return e(t),t}}function vt(e,r={}){return()=>e}return kt(yn);})();
|
package/dist/cdn/reactive.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as bt}from"@fluixi/utils/object";import{isFunction as je}from"@fluixi/utils/functions";var N=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(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(bt(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(je(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 q=class extends N{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 q{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 Sr(e){return new q(e.next,e.error,e.complete)}var M=class extends N{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 q?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 Tt="__fluixi_signal_next_state__",mt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Tt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:mt,onSuspend:null,onError:null};var qe=0,Me=1,$=2,Q=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 Q{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}},w=class extends Q{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===Me&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=qe}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===qe;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Me);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 F=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 $e(){return a.consumer}function Le(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function vt(e){return!!e&&e.disposed===!0}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(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 St(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 K(e,t,r){let n=ee(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 Ve(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ge(e){a.onError=e}function re(){return a.owner}function We(e){let t=a.owner;return a.owner=e,t}function G(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 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 C(e){let t=ee(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 He(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function xt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){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 ze(){a.batchDepth===0&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{Z(this.owner,!1),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new F(()=>xt(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 ne(e){let t=new pe(e);return()=>t.dispose()}function wt(e){return!!e&&typeof e.then=="function"}He(()=>{});var Ye=Symbol.for("signal"),Ot=Symbol.for("memo"),gt=Symbol.for("signal-node");function f(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),ze(),i});return Object.defineProperty(n,Ye,{value:!0,enumerable:!0}),Object.defineProperty(n,gt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=re(),s=new w(()=>G(o,()=>{try{return n=e(n)}catch(c){if(wt(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Ye,{value:!0,enumerable:!0}),Object.defineProperty(i,Ot,{value:!0,enumerable:!0}),i}function I(e,t){let r=t;return ne(()=>{r=e(r)})}function At(e,t){let r=t;ne(()=>{r=e(r)})}function _t(e,t){let r=t;return ne(()=>{r=e(r)})}function O(e){return fe(e)}function g(e){return L(e)}function Xe(e){return fe(e),Promise.resolve()}function Rt(){return[()=>!1,Xe]}function Et(){return W(),Promise.resolve()}function kt(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 Ur(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{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],d=s.get(p);if(d&&!c.has(d))d.setIndex(u),i.push(d),c.add(d);else{let l,y,h;C(b=>{h=b;let[E,B]=f(u);y=B,l=t(p,E)});let S={item:p,rendered:l,dispose:h,setIndex:y};i.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Br(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return g(()=>{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=[],d=new Set;for(let l=0;l<i.length;l++){let y=t(i[l]),h=c.get(y);if(h&&!d.has(y))h.setIndex(l),u.push(h);else{let S,b,E;C(B=>{E=B;let[A,j]=f(l);b=j;let Y=v(k=>{let x=(e()||[])[A()];return x??k},i[l]);S=r(Y,A)}),u.push({rendered:S,dispose:E,setIndex:b})}p.push(y),d.add(y)}for(let[l,y]of c)d.has(l)||y.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function jr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{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,d,l,y=o[u];C(h=>{l=h;let[S,b]=f(y);d=b,p=t(S,u)}),n.push({rendered:p,setItem:d,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,Pt=Symbol.for("signal"),Ft=Symbol.for("memo"),Ct=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Pt]===!0}function It(e){return typeof e=="function"&&e[Ft]===!0}function Dt(e){return typeof e=="function"&&e[Ct]===!0}function Ut(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 jt(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 Nt(e){he=e}function ve(e){he&&he(e)}var be=null;function qt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Mt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function $t(e){me=e}function we(e,t){me&&me(e,t)}function Lt(e,t=(r,n)=>r===n){let r=new Map;return I(()=>{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 Vt(e,t){let[r,n]=f(e(),t);return I(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Kt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}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 Gt(e){let t=v(e);return v(()=>oe(t()))}function Wt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function Ht(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]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[d,l]=f(void 0,{equals:!1}),[y,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,b]=f(void 0,{equals:!1}),[E,B]=f(void 0,{equals:!1}),A=Oe,j=!1;I(()=>{let T=n();if(E(),T===!1||T===null||T===void 0){A=Oe,O(()=>{h("unresolved"),b(void 0),l(void 0)});return}let x=j;if(j=!1,A!==Oe&&T===A&&!x)return;if(A=T,c){c=!1;return}let X=!1;m(()=>X=!0);let Ue=g(y),ht=g(u),Be=Ue==="ready"||Ue==="refreshing";O(()=>{h(Be?"refreshing":"pending"),l(void 0)});try{let _=o(T,{value:ht,refetching:Be});Wt(_)?(b(_),ve(_),_.then(J=>{X||(s!==void 0&&we(s,J),O(()=>{p(()=>J),h("ready"),b(void 0)}))},J=>{X||O(()=>{l(J),h("errored"),b(void 0)})})):O(()=>{p(()=>_),h("ready"),b(void 0)})}catch(_){if(X)return;O(()=>{l(_),h("errored"),b(void 0)})}});let Y=()=>{let T=y();return T==="pending"||T==="refreshing"},k=(()=>{let T=d();if(T)throw T;if(Y()){let x=S();if(x)throw x}return u()});return Object.defineProperties(k,{state:{get:y},loading:{get:Y},error:{get:d},latest:{get:u}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}var ge=V();Ve((e,t)=>{let r=te(t,ge);r&&(r.increment(),e.finally(()=>r.decrement()))});function zt(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Yt(e,t){return K(ge,e,t)}var Qe=V();Ge((e,t)=>{let r=te(t,Qe);return r?(r.setError(e),!0):!1});function Xt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Jt(e,t){return K(Qe,e,t)}var Qt={State:P,Computed:w,subtle:{Watcher:F,untrack:L,currentComputed:$e,hasSinks:Le}};var nn=Symbol.for("signal"),on=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as it,createEffect as ie,createMemo as Re,createSignal as at,untrack as Zt}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),Ze=Symbol("store-has"),Ee=Symbol("store-self"),ke=Symbol("store-track"),er=Symbol("store-name"),tr=Symbol("store-store"),et=new WeakMap,tt=new WeakMap;function ut(e){let[t,r]=at(e),n=t;return n.$=r,n}function ue(e){let t=et.get(e);return t||et.set(e,t={keys:new Map}),t}function rt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=ut(r)),n}function nt(e){let t=ue(e);(t.all||(t.all=ut()))()}function ot(e,t){e.$(typeof t=="function"?()=>t:t)}function ct(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(!ct(e))return e;let t=tt.get(e);if(t)return t;let r=new Proxy(e,rr);return tt.set(e,r),r}var rr={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===Ze)return i=>i in e;if(t==="__proxy")return!0;if(t===ke||t===Ee)return nt(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=rt(ue(e),t,n)();return ct(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&H(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===Ze||t===Ee||t===ke?!0:(rt(ue(e),t,e[t])(),t in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function H(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&&ot(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&ot(u,e.length)}i.all&&i.all.$(void 0)}function st(e,t){return typeof e=="function"?e(t):e}function Pe(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)?Pe(o,n):H(e,r,n)}}function Ce(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function lt(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++)lt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,st(r,e[s]));return}H(e,o,st(r,e[o]))}function Ae(e,t,r){lt(e,Ce(t),r)}function nr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Pe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Ae(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Pe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Ae(e,`${r}.${t[1].join(".")}`,t[2]);return}Ae(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function D(e,t){let r=e;for(let n of Ce(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)=>it(()=>nr(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 z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(r)}select(t){return Re(()=>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 Re(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=D(this.root,t);this.set(t,n.concat(r))}pop(t){let r=D(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=D(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=D(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=D(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=D(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=at(this.state);return t.toObservable()}dispose(){}},or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,t){for(let r of or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function ft(e,t={immutable:!0}){let r=new R(e,t);return pt(r.set,r),[r.proxy,r.set]}function dt(e,t={}){return new R(e,{...t,immutable:!1})}function sr(e,t={}){let r=new R(e(),t);return ie(()=>r.set(e())),r}function ir(e,t,r){return ie(()=>r(t(e)))}function ar(e,t,r){return Re(()=>t(e),void 0,r)}function ur(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return pt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function yt(e){return Zt(()=>z(e))}function cr(e){return Ie(e)}function lr(e){return Ie(e)?e[U]:null}function pr(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 fr(e){return e}var dr=Object.freeze({createStore:ft,createMutableStore:dt,batch:it,unwrap:z,untrackStore:yt});function De(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t={};for(let r of Object.keys(e))t[r]=De(e[r]);return t}function yr(e){return t=>{let r=De(t);return e(r),r}}function hr(e,t={}){return()=>e}export{er as $NAME,U as $NODE,on as $PROXY,ae as $RAW,Ee as $SELF,nn as $SIGNAL,tr as $STORE,ke as $TRACK,M as Observable,ce as SafeSubscriber,Qt as Signal,R as Store,dr as StoreAPI,Ne as Subject,q as Subscriber,N as Subscription,ge as SuspenseContext,de as __DEV__,O as batch,At as createComputed,sr as createComputedStore,V as createContext,Kt as createDebounce,Vt as createDeferred,I as createEffect,Xt as createErrorBoundary,v as createMemo,dt as createMutableStore,_t as createRenderEffect,Ht as createResource,C as createRoot,Lt as createSelector,f as createSignal,ft as createStore,ir as createStoreEffect,ar as createStoreMemo,zt as createSuspenseBoundary,Et as flush,lr as getNode,re as getOwner,Se as getServerData,pr as getStoreNode,jr as indexArray,Ut as isComponent,It as isMemo,vt as isOwnerDisposed,jt as isProvider,Dt as isResource,ye as isSignal,cr as isStore,Ie as isStoreProxy,Bt as isSuspense,Br as keyArray,Je as makeArrayFlat,Ur as mapArray,fr as modifiable,xe as nextResourceId,kt as on,m as onCleanup,Sr as operate,yr as produceUtil,K as provide,Jt as provideErrorBoundary,Yt as provideSuspense,Gt as readChildren,hr as reconcileUtil,we as reportResourceData,G as runWithOwner,We as setOwner,$t as setResourceDataSink,Mt as setResourceIdSource,Nt as setResourceTracker,qt as setServerDataGetter,Xe as startTransition,ve as trackResourcePromise,g as untrack,yt as untrackStore,z as unwrap,St as useContext,Rt as useTransition,ur as wrap};
|
|
1
|
+
import{isObject as mt}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(mt(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 M=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 M{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 Or(e){return new M(e.next,e.error,e.complete)}var N=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 M?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 Me=class extends N{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 N(n=>this.subscribe(n))}};var vt="__fluixi_signal_next_state__",St=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[vt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:St,onSuspend:null,onError:null};var Ne=0,$e=1,$=2,J=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 J{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 J{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=Ne}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===Ne;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 xt(e){return!!e&&e.disposed===!0}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(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 wt(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 K(e,t,r){let n=ee(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 G(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 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 F(e){let t=ee(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 ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Ot(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){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&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{Z(this.owner,!1),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Ot(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 ne(e){let t=new pe(e);return()=>t.dispose()}function gt(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),At=Symbol.for("memo"),Rt=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,Rt,{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(()=>G(o,()=>{try{return n=e(n)}catch(c){if(gt(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,At,{value:!0,enumerable:!0}),i}function C(e,t){let r=t;return ne(()=>{r=e(r)})}function _t(e,t){let r=t;ne(()=>{r=e(r)})}function kt(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 Et(){return[()=>!1,Qe]}function Pt(){return W(),Promise.resolve()}function Dt(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 qr(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,b;F(h=>{b=h;let[k,B]=d(u);f=B,l=t(p,k)});let x={item:p,rendered:l,dispose:b,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 Mr(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]),b=c.get(f);if(b&&!y.has(f))b.setIndex(l),u.push(b);else{let x,h,k;F(B=>{k=B;let[A,j]=d(l);h=j;let Y=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Y,A)}),u.push({rendered:x,dispose:k,setIndex:h})}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 Nr(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];F(b=>{l=b;let[x,h]=d(f);y=h,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,Ft=Symbol.for("signal"),Ct=Symbol.for("memo"),It=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ft]===!0}function Ut(e){return typeof e=="function"&&e[Ct]===!0}function Bt(e){return typeof e=="function"&&e[It]===!0}function jt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function qt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Mt(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 be=null;function Nt(e){be=e}function ve(e){be&&be(e)}var he=null;function $t(e){he=e}function Se(e){return he?he(e):void 0}var Te=null;function Lt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Vt(e){me=e}function we(e,t){me&&me(e,t)}function Kt(e,t=(r,n)=>r===n){let r=new Map;return C(()=>{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 Gt(e,t){let[r,n]=d(e(),t);return C(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Wt(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 Ht(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,b]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,h]=d(void 0,{equals:!1}),[k,B]=d(void 0,{equals:!1}),A=Oe,j=!1;C(()=>{let T=n();if(k(),T===!1||T===null||T===void 0){A=Oe,g(()=>{b("unresolved"),h(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 X=!1;m(()=>X=!0);let Be=v(f),Tt=v(u),je=Be==="ready"||Be==="refreshing";g(()=>{b(je?"refreshing":"pending"),l(void 0)});try{let R=o(T,{value:Tt,refetching:je});Ht(R)?(h(R),ve(R),R.then(Q=>{X||(s!==void 0&&we(s,Q),g(()=>{p(()=>Q),b("ready"),h(void 0)}))},Q=>{X||g(()=>{l(Q),b("errored"),h(void 0)})})):g(()=>{p(()=>R),b("ready"),h(void 0)})}catch(R){if(X)return;g(()=>{l(R),b("errored"),h(void 0)})}});let Y=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Y()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Y},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 b=typeof f=="function"?f(v(r)):f;return n(()=>b),c(!0),p(),u=setTimeout(y,t),b});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function zt(e){return e!=null&&e!==""}function Yt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=zt}=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 Xt(e){let t=S(e);return S(()=>oe(t()))}var Ae=V();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function Qt(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Jt(e,t){return K(Ae,e,t)}var et=V();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function Zt(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function er(e,t){return K(et,e,t)}var tr={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var ln=Symbol.for("signal"),pn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as rr}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"),nr=Symbol("store-name"),or=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,sr);return nt.set(e,r),r}var sr={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&&H(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 H(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):H(e,r,n)}}function Ce(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])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,at(r,e[s]));return}H(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Ce(t),r)}function ir(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 Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function I(e,t){let r=e;for(let n of Ce(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(()=>ir(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 z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(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=Fe(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(){}},ar=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of ar)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 bt(e,t={}){return new _(e,{...t,immutable:!1})}function ur(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function cr(e,t,r){return ie(()=>r(t(e)))}function lr(e,t,r){return ke(()=>t(e),void 0,r)}function pr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function ht(e){return rr(()=>z(e))}function fr(e){return Ie(e)}function dr(e){return Ie(e)?e[U]:null}function yr(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 br(e){return e}var hr=Object.freeze({createStore:yt,createMutableStore:bt,batch:ut,unwrap:z,untrackStore:ht});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 Tr(e){return t=>{let r=Ue(t);return e(r),r}}function mr(e,t={}){return()=>e}export{nr as $NAME,U as $NODE,pn as $PROXY,ae as $RAW,Ee as $SELF,ln as $SIGNAL,or as $STORE,Pe as $TRACK,N as Observable,ce as SafeSubscriber,tr as Signal,_ as Store,hr as StoreAPI,Me as Subject,M as Subscriber,q as Subscription,Ae as SuspenseContext,de as __DEV__,g as batch,_t as createComputed,ur as createComputedStore,V as createContext,Wt as createDebounce,Yt as createDebouncedResource,Ze as createDebouncedSignal,Gt as createDeferred,C as createEffect,Zt as createErrorBoundary,S as createMemo,bt as createMutableStore,kt as createRenderEffect,ge as createResource,F as createRoot,Kt as createSelector,d as createSignal,yt as createStore,cr as createStoreEffect,lr as createStoreMemo,Qt as createSuspenseBoundary,Pt as flush,dr as getNode,re as getOwner,Se as getServerData,yr as getStoreNode,Nr as indexArray,jt as isComponent,Ut as isMemo,xt as isOwnerDisposed,Mt as isProvider,Bt as isResource,ye as isSignal,fr as isStore,Ie as isStoreProxy,qt as isSuspense,Mr as keyArray,Je as makeArrayFlat,qr as mapArray,br as modifiable,xe as nextResourceId,Dt as on,m as onCleanup,Or as operate,Tr as produceUtil,K as provide,er as provideErrorBoundary,Jt as provideSuspense,Xt as readChildren,mr as reconcileUtil,we as reportResourceData,G as runWithOwner,He as setOwner,Vt as setResourceDataSink,Lt as setResourceIdSource,Nt as setResourceTracker,$t as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,ht as untrackStore,z as unwrap,wt as useContext,Et as useTransition,pr as wrap};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Se=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.prototype.hasOwnProperty;var rr=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of er(t))!tr.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=Zt(t,o))||n.enumerable});return e};var or=e=>nr(Se({},"__esModule",{value:!0}),e);var gr={};rr(gr,{$NAME:()=>Ut,$NODE:()=>F,$PROXY:()=>Sr,$RAW:()=>J,$SELF:()=>be,$SIGNAL:()=>vr,$STORE:()=>Bt,$TRACK:()=>Te,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>Rt,Store:()=>_,StoreAPI:()=>Yt,Subject:()=>we,Subscriber:()=>U,Subscription:()=>D,SuspenseContext:()=>ye,__DEV__:()=>ae,batch:()=>w,createComputed:()=>nt,createComputedStore:()=>$t,createContext:()=>q,createDebounce:()=>vt,createDeferred:()=>mt,createEffect:()=>P,createErrorBoundary:()=>At,createMemo:()=>S,createMutableStore:()=>qe,createRenderEffect:()=>ot,createResource:()=>xt,createRoot:()=>k,createSelector:()=>Tt,createSignal:()=>d,createStore:()=>Ne,createStoreEffect:()=>Lt,createStoreMemo:()=>Vt,createSuspenseBoundary:()=>wt,flush:()=>it,getNode:()=>Wt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Ht,indexArray:()=>yr,isComponent:()=>lt,isMemo:()=>ut,isOwnerDisposed:()=>Ye,isProvider:()=>ft,isResource:()=>ct,isSignal:()=>ue,isStore:()=>Gt,isStoreProxy:()=>ve,isSuspense:()=>pt,keyArray:()=>dr,makeArrayFlat:()=>Ee,mapArray:()=>fr,modifiable:()=>zt,nextResourceId:()=>pe,on:()=>at,onCleanup:()=>v,operate:()=>sr,produceUtil:()=>Xt,provide:()=>M,provideErrorBoundary:()=>_t,provideSuspense:()=>Ot,readChildren:()=>St,reconcileUtil:()=>Jt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Ae,setResourceDataSink:()=>bt,setResourceIdSource:()=>ht,setResourceTracker:()=>dt,setServerDataGetter:()=>yt,startTransition:()=>Re,trackResourcePromise:()=>ce,untrack:()=>O,untrackStore:()=>Me,unwrap:()=>V,useContext:()=>Xe,useTransition:()=>st,wrap:()=>Kt});module.exports=or(gr);var Ke=require("@fluixi/utils/object"),xe=require("@fluixi/utils/functions"),D=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,xe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,Ke.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,xe.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 D{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())}},te=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 sr(e){return new U(e.next,e.error,e.complete)}var B=class extends D{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 te(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 we=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 ir="__fluixi_signal_next_state__",ar=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[ir]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ar,onSuspend:null,onError:null};var Ge=0,We=1,W=2,re=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 re{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);Oe(this)}}peek(){return this._value}},A=class extends re{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===We&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=Ge}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);Oe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Ge;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(We);Oe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Oe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var N=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 He(){return a.consumer}function ze(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ye(e){return!!e&&e.disposed===!0}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(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 Xe(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=oe(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 Je(e){a.onSuspend=e}function Qe(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ze(e){a.onError=e}function z(){return a.owner}function Ae(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 ne(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)ne(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 k(e){let t=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function et(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ur(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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function tt(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var ge=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new N(()=>ur(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),ne(this.owner))}};function ie(e){let t=new ge(e);return()=>t.dispose()}function cr(e){return!!e&&typeof e.then=="function"}et(()=>{});var rt=Symbol.for("signal"),lr=Symbol.for("memo"),pr=Symbol.for("signal-node");function d(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),tt(),i});return Object.defineProperty(n,rt,{value:!0,enumerable:!0}),Object.defineProperty(n,pr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(cr(c))return Qe(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,rt,{value:!0,enumerable:!0}),Object.defineProperty(i,lr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function nt(e,t){let r=t;ie(()=>{r=e(r)})}function ot(e,t){let r=t;return ie(()=>{r=e(r)})}function w(e){return _e(e)}function O(e){return H(e)}function Re(e){return _e(e),Promise.resolve()}function st(){return[()=>!1,Re]}function it(){return Y(),Promise.resolve()}function at(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(f=>f()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function fr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{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 f=o[u],y=s.get(f);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,h,b;k(T=>{b=T;let[C,K]=d(u);h=K,l=t(f,C)});let x={item:f,rendered:l,dispose:b,setIndex:h};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 dr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return O(()=>{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=[],f=[],y=new Set;for(let l=0;l<i.length;l++){let h=t(i[l]),b=c.get(h);if(b&&!y.has(h))b.setIndex(l),u.push(b);else{let x,T,C;k(K=>{C=K;let[R,G]=d(l);T=G;let Q=S(I=>{let g=(e()||[])[R()];return g??I},i[l]);x=r(Q,R)}),u.push({rendered:x,dispose:C,setIndex:T})}f.push(h),y.add(h)}for(let[l,h]of c)y.has(l)||h.dispose();return o=f,s=u,u.map(l=>l.rendered)})})}function yr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{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 f,y,l,h=o[u];k(b=>{l=b;let[x,T]=d(h);y=T,f=t(x,u)}),n.push({rendered:f,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 ae=!1,hr=Symbol.for("signal"),br=Symbol.for("memo"),Tr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[hr]===!0}function ut(e){return typeof e=="function"&&e[br]===!0}function ct(e){return typeof e=="function"&&e[Tr]===!0}function lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function ft(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 ke=null;function dt(e){ke=e}function ce(e){ke&&ke(e)}var Pe=null;function yt(e){Pe=e}function le(e){return Pe?Pe(e):void 0}var Fe=null;function ht(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function bt(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function Tt(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]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function mt(e,t){let[r,n]=d(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 vt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function de(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:de(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=de(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function St(e){let t=S(e);return S(()=>de(t()))}function mr(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function xt(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,f]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[h,b]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,K]=d(void 0,{equals:!1}),R=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){R=Ie,w(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,R!==Ie&&m===R&&!g)return;if(R=m,c){c=!1;return}let Z=!1;v(()=>Z=!0);let Le=O(h),Qt=O(u),Ve=Le==="ready"||Le==="refreshing";w(()=>{b(Ve?"refreshing":"pending"),l(void 0)});try{let E=o(m,{value:Qt,refetching:Ve});mr(E)?(T(E),ce(E),E.then(ee=>{Z||(s!==void 0&&fe(s,ee),w(()=>{f(()=>ee),b("ready"),T(void 0)}))},ee=>{Z||w(()=>{l(ee),b("errored"),T(void 0)})})):w(()=>{f(()=>E),b("ready"),T(void 0)})}catch(E){if(Z)return;w(()=>{l(E),b("errored"),T(void 0)})}});let Q=()=>{let m=h();return m==="pending"||m==="refreshing"},I=(()=>{let m=y();if(m)throw m;if(Q()){let g=x();if(g)throw g}return u()});return Object.defineProperties(I,{state:{get:h},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(I,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(I,Symbol.for("signal"),{value:!0,enumerable:!0}),[I,{mutate:f,refetch:()=>{G=!0,K(void 0)}}]}var ye=q();Je((e,t)=>{let r=se(t,ye);r&&(r.increment(),e.finally(()=>r.decrement()))});function wt(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Ot(e,t){return M(ye,e,t)}var gt=q();Ze((e,t)=>{let r=se(t,gt);return r?(r.setError(e),!0):!1});function At(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function _t(e,t){return M(gt,e,t)}var Rt={State:j,Computed:A,subtle:{Watcher:N,untrack:H,currentComputed:He,hasSinks:ze}};var vr=Symbol.for("signal"),Sr=Symbol.for("fluixi-proxy");var p=require("@fluixi/reactive/signal"),J=Symbol("store-raw"),F=Symbol("store-node"),Et=Symbol("store-has"),be=Symbol("store-self"),Te=Symbol("store-track"),Ut=Symbol("store-name"),Bt=Symbol("store-store"),kt=new WeakMap,Pt=new WeakMap;function jt(e){let[t,r]=(0,p.createSignal)(e),n=t;return n.$=r,n}function me(e){let t=kt.get(e);return t||kt.set(e,t={keys:new Map}),t}function Ft(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=jt(r)),n}function Ct(e){let t=me(e);(t.all||(t.all=jt()))()}function It(e,t){e.$(typeof t=="function"?()=>t:t)}function Nt(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 he(e){if(!Nt(e))return e;let t=Pt.get(e);if(t)return t;let r=new Proxy(e,xr);return Pt.set(e,r),r}var xr={get(e,t,r){if(t===J||t===F)return e;if(t===p.$PROXY)return r;if(t===Et)return i=>i in e;if(t==="__proxy")return!0;if(t===Te||t===be)return Ct(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=Ft(me(e),t,n)();return Nt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===J||t===p.$PROXY||t===F||t===Et||t===be||t===Te?!0:(Ft(me(e),t,e[t])(),t in e)},ownKeys(e){return Ct(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(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=me(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 Dt(e,t){return typeof e=="function"?e(t):e}function Ue(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)?Ue(o,n):X(e,r,n)}}function je(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function qt(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 f=0;f<e.length;f++)qt(e[f],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,Dt(r,e[s]));return}X(e,o,Dt(r,e[o]))}function De(e,t,r){qt(e,je(t),r)}function wr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ue(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&De(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ue(e,r);return}if(Array.isArray(t[1])&&t.length>=3){De(e,`${r}.${t[1].join(".")}`,t[2]);return}De(e,String(r),t[1])}function Be(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Be);let t={};for(let r of Object.keys(e))t[r]=Be(e[r]);return t}function L(e,t){let r=e;for(let n of je(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)=>(0,p.batch)(()=>wr(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(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 je(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,p.createMemo)(()=>t(this.state))}subscribe(t){return(0,p.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,p.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,p.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Be(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,p.createSignal)(this.state);return t.toObservable()}dispose(){}},Or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Mt(e,t){for(let r of Or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new _(e,t);return Mt(r.set,r),[r.proxy,r.set]}function qe(e,t={}){return new _(e,{...t,immutable:!1})}function $t(e,t={}){let r=new _(e(),t);return(0,p.createEffect)(()=>r.set(e())),r}function Lt(e,t,r){return(0,p.createEffect)(()=>r(t(e)))}function Vt(e,t,r){return(0,p.createMemo)(()=>t(e),void 0,r)}function Kt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Mt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[J];return t!==void 0?t:e}function Me(e){return(0,p.untrack)(()=>V(e))}function Gt(e){return ve(e)}function Wt(e){return ve(e)?e[F]:null}function Ht(e){return e&&typeof e=="object"&&F in e?e[F]:null}function ve(e){return!!e&&typeof e=="object"&&(p.$PROXY in e||e.__proxy===!0)}function zt(e){return e}var Yt=Object.freeze({createStore:Ne,createMutableStore:qe,batch:p.batch,unwrap:V,untrackStore:Me});function $e(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($e);let t={};for(let r of Object.keys(e))t[r]=$e(e[r]);return t}function Xt(e){return t=>{let r=$e(t);return e(r),r}}function Jt(e,t={}){return()=>e}
|
|
1
|
+
"use strict";var xe=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.prototype.hasOwnProperty;var or=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},sr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rr(t))!nr.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=tr(t,o))||n.enumerable});return e};var ir=e=>sr(xe({},"__esModule",{value:!0}),e);var _r={};or(_r,{$NAME:()=>jt,$NODE:()=>D,$PROXY:()=>Or,$RAW:()=>Q,$SELF:()=>Te,$SIGNAL:()=>wr,$STORE:()=>qt,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>Et,Store:()=>R,StoreAPI:()=>Qt,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>be,__DEV__:()=>ae,batch:()=>O,createComputed:()=>st,createComputedStore:()=>Vt,createContext:()=>M,createDebounce:()=>xt,createDebouncedResource:()=>wt,createDebouncedSignal:()=>Ue,createDeferred:()=>St,createEffect:()=>P,createErrorBoundary:()=>_t,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>it,createResource:()=>de,createRoot:()=>E,createSelector:()=>vt,createSignal:()=>f,createStore:()=>Ne,createStoreEffect:()=>Kt,createStoreMemo:()=>Gt,createSuspenseBoundary:()=>gt,flush:()=>ut,getNode:()=>zt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Yt,indexArray:()=>hr,isComponent:()=>ft,isMemo:()=>lt,isOwnerDisposed:()=>Qe,isProvider:()=>yt,isResource:()=>pt,isSignal:()=>ue,isStore:()=>Ht,isStoreProxy:()=>Se,isSuspense:()=>dt,keyArray:()=>br,makeArrayFlat:()=>Ee,mapArray:()=>yr,modifiable:()=>Xt,nextResourceId:()=>pe,on:()=>ct,onCleanup:()=>v,operate:()=>ar,produceUtil:()=>Jt,provide:()=>N,provideErrorBoundary:()=>kt,provideSuspense:()=>At,readChildren:()=>Ot,reconcileUtil:()=>Zt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>mt,setResourceIdSource:()=>Tt,setResourceTracker:()=>bt,setServerDataGetter:()=>ht,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>Je,useTransition:()=>at,wrap:()=>Wt});module.exports=ir(_r);var We=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,We.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())}},te=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 ar(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 te(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 ur="__fluixi_signal_next_state__",cr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[ur]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:cr,onSuspend:null,onError:null};var He=0,ze=1,W=2,re=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 re{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 re{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===ze&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=He}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===He;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(ze);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 Ye(){return a.consumer}function Xe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Qe(e){return!!e&&e.disposed===!0}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(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 Je(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 N(e,t,r){let n=oe(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 Ze(e){a.onSuspend=e}function et(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function tt(e){a.onError=e}function z(){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 ne(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)ne(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=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function rt(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function lr(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 t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function nt(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>lr(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),ne(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function pr(e){return!!e&&typeof e.then=="function"}rt(()=>{});var ot=Symbol.for("signal"),fr=Symbol.for("memo"),dr=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),nt(),i});return Object.defineProperty(n,ot,{value:!0,enumerable:!0}),Object.defineProperty(n,dr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(pr(c))return et(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,ot,{value:!0,enumerable:!0}),Object.defineProperty(i,fr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function st(e,t){let r=t;ie(()=>{r=e(r)})}function it(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 at(){return[()=>!1,ke]}function ut(){return Y(),Promise.resolve()}function ct(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 yr(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],b=s.get(p);if(b&&!c.has(b))b.setIndex(u),i.push(b),c.add(b);else{let l,d,h;E(T=>{h=T;let[F,K]=f(u);d=K,l=t(p,F)});let w={item:p,rendered:l,dispose:h,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 br(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=[],b=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),h=c.get(d);if(h&&!b.has(d))h.setIndex(l),u.push(h);else{let w,T,F;E(K=>{F=K;let[_,G]=f(l);T=G;let J=x(C=>{let g=(e()||[])[_()];return g??C},i[l]);w=r(J,_)}),u.push({rendered:w,dispose:F,setIndex:T})}p.push(d),b.add(d)}for(let[l,d]of c)b.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function hr(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,b,l,d=o[u];E(h=>{l=h;let[w,T]=f(d);b=T,p=t(w,u)}),n.push({rendered:p,setItem:b,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,Tr=Symbol.for("signal"),mr=Symbol.for("memo"),vr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Tr]===!0}function lt(e){return typeof e=="function"&&e[mr]===!0}function pt(e){return typeof e=="function"&&e[vr]===!0}function ft(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function yt(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 bt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function ht(e){De=e}function le(e){return De?De(e):void 0}var Fe=null;function Tt(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function mt(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function vt(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 St(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 xt(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 Sr(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}),[b,l]=f(void 0,{equals:!1}),[d,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[F,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(F(),m===!1||m===null||m===void 0){_=Ie,O(()=>{h("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 Z=!1;v(()=>Z=!0);let Ke=S(d),er=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:er,refetching:Ge});Sr(k)?(T(k),ce(k),k.then(ee=>{Z||(s!==void 0&&fe(s,ee),O(()=>{p(()=>ee),h("ready"),T(void 0)}))},ee=>{Z||O(()=>{l(ee),h("errored"),T(void 0)})})):O(()=>{p(()=>k),h("ready"),T(void 0)})}catch(k){if(Z)return;O(()=>{l(k),h("errored"),T(void 0)})}});let J=()=>{let m=d();return m==="pending"||m==="refreshing"},C=(()=>{let m=b();if(m)throw m;if(J()){let g=w();if(g)throw g}return u()});return Object.defineProperties(C,{state:{get:d},loading:{get:J},error:{get:b},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:()=>{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)},b=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let h=typeof d=="function"?d(S(r)):d;return n(()=>h),c(!0),p(),u=setTimeout(b,t),h});return v(p),[o,l,{immediate:r,pending:i,flush:b,cancel:()=>{p(),c(!1)}}]}function xr(e){return e!=null&&e!==""}function wt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=xr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[b,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[b,{...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 Ot(e){let t=x(e);return x(()=>ye(t()))}var be=M();Ze((e,t)=>{let r=se(t,be);r&&(r.increment(),e.finally(()=>r.decrement()))});function gt(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function At(e,t){return N(be,e,t)}var Rt=M();tt((e,t)=>{let r=se(t,Rt);return r?(r.setError(e),!0):!1});function _t(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function kt(e,t){return N(Rt,e,t)}var Et={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Ye,hasSinks:Xe}};var wr=Symbol.for("signal"),Or=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Q=Symbol("store-raw"),D=Symbol("store-node"),Pt=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),jt=Symbol("store-name"),qt=Symbol("store-store"),Dt=new WeakMap,Ft=new WeakMap;function Mt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=Dt.get(e);return t||Dt.set(e,t={keys:new Map}),t}function Ct(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Mt(r)),n}function It(e){let t=ve(e);(t.all||(t.all=Mt()))()}function Ut(e,t){e.$(typeof t=="function"?()=>t:t)}function Nt(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 he(e){if(!Nt(e))return e;let t=Ft.get(e);if(t)return t;let r=new Proxy(e,gr);return Ft.set(e,r),r}var gr={get(e,t,r){if(t===Q||t===D)return e;if(t===y.$PROXY)return r;if(t===Pt)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return It(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=Ct(ve(e),t,n)();return Nt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===Q||t===y.$PROXY||t===D||t===Pt||t===Te||t===me?!0:(Ct(ve(e),t,e[t])(),t in e)},ownKeys(e){return It(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(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&&Ut(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Ut(u,e.length)}i.all&&i.all.$(void 0)}function Bt(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):X(e,r,n)}}function Me(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function $t(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++)$t(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,Bt(r,e[s]));return}X(e,o,Bt(r,e[o]))}function Be(e,t,r){$t(e,Me(t),r)}function Ar(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 Me(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)(()=>Ar(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(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 Me(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(){}},Rr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Lt(e,t){for(let r of Rr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new R(e,t);return Lt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Vt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Kt(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function Gt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Wt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Lt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Q];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Ht(e){return Se(e)}function zt(e){return Se(e)?e[D]:null}function Yt(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 Xt(e){return e}var Qt=Object.freeze({createStore:Ne,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 Jt(e){return t=>{let r=Ve(t);return e(r),r}}function Zt(e,t={}){return()=>e}
|