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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var mt="1.0.0-alpha.72";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,h;C(b=>{h=b;let[k,B]=d(u);f=B,l=t(p,k)});let x={item:p,rendered:l,dispose:h,setIndex:f};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),h=c.get(f);if(h&&!y.has(f))h.setIndex(l),u.push(h);else{let x,b,k;C(B=>{k=B;let[A,j]=d(l);b=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex:b})}p.push(f),y.add(f)}for(let[l,f]of c)y.has(l)||f.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(h=>{l=h;let[x,b]=d(f);y=b,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Vt(e){he=e}function ve(e){he&&he(e)}var be=null;function Kt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[f,h]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,b]=d(void 0,{equals:!1}),[k,B]=d(void 0,{equals:!1}),A=Oe,j=!1;F(()=>{let T=n();if(k(),T===!1||T===null||T===void 0){A=Oe,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let w=j;if(j=!1,A!==Oe&&T===A&&!w)return;if(A=T,c){c=!1;return}let J=!1;m(()=>J=!0);let Be=v(f),Tt=v(u),je=Be==="ready"||Be==="refreshing";g(()=>{h(je?"refreshing":"pending"),l(void 0)});try{let R=o(T,{value:Tt,refetching:je});Xt(R)?(b(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),h("ready"),b(void 0)}))},Z=>{J||g(()=>{l(Z),h("errored"),b(void 0)})})):g(()=>{p(()=>R),h("ready"),b(void 0)})}catch(R){if(J)return;g(()=>{l(R),h("errored"),b(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let h=typeof f=="function"?f(v(r)):f;return n(()=>h),c(!0),p(),u=setTimeout(y,t),h});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),hn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function ht(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function bt(e){return sr(()=>X(e))}function hr(e){return Ie(e)}function br(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:ht,batch:ut,unwrap:X,untrackStore:bt});function Ue(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ue);let t={};for(let r of Object.keys(e))t[r]=Ue(e[r]);return t}function Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,hn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,ht as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,br as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,hr as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,bt as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
1
+ var mt="1.0.0-alpha.74";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,b;C(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 Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),b=c.get(f);if(b&&!y.has(f))b.setIndex(l),u.push(b);else{let x,h,k;C(B=>{k=B;let[A,j]=d(l);h=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex: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 Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(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,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var be=null;function Vt(e){be=e}function ve(e){be&&be(e)}var he=null;function Kt(e){he=e}function Se(e){return he?he(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0: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;F(()=>{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 J=!1;m(()=>J=!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});Xt(R)?(h(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),b("ready"),h(void 0)}))},Z=>{J||g(()=>{l(Z),b("errored"),h(void 0)})})):g(()=>{p(()=>R),b("ready"),h(void 0)})}catch(R){if(J)return;g(()=>{l(R),b("errored"),h(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let 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 Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function bt(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function ht(e){return sr(()=>X(e))}function br(e){return Ie(e)}function hr(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:bt,batch:ut,unwrap:X,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 Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,bn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,bt as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,hr as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,br as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,ht as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
@@ -1 +1 @@
1
- "use strict";var xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>he,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>ht,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>bt,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.72";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,br,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,hr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],h=s.get(p);if(h&&!c.has(h))h.setIndex(u),i.push(h),c.add(h);else{let l,d,b;E(T=>{b=T;let[C,K]=f(u);d=K,l=t(p,C)});let w={item:p,rendered:l,dispose:b,setIndex:d};i.push(w),c.add(w)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],h=new Set;for(let l=0;l<i.length;l++){let d=t(i[l]),b=c.get(d);if(b&&!h.has(d))b.setIndex(l),u.push(b);else{let w,T,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),h.add(d)}for(let[l,d]of c)h.has(l)||d.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,h,l,d=o[u];E(b=>{l=b;let[w,T]=f(d);h=T,p=t(w,u)}),n.push({rendered:p,setItem:h,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[h,l]=f(void 0,{equals:!1}),[d,b]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[w,T]=f(void 0,{equals:!1}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,_!==Ie&&m===_&&!g)return;if(_=m,c){c=!1;return}let te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{b(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),b("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),b("errored"),T(void 0)})})):O(()=>{p(()=>k),b("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),b("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=h();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:h},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},h=()=>{p();let d=S(r);return s(()=>d),c(!1),d},l=(d=>{let b=typeof d=="function"?d(S(r)):d;return n(()=>b),c(!0),p(),u=setTimeout(h,t),b});return v(p),[o,l,{immediate:r,pending:i,flush:h,cancel:()=>{p(),c(!1)}}]}function gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[h,{refetch:l}]=de(p,t,o===void 0?{}:{initialValue:o});return[h,{...u,query:i,setQuery:c,refetch:l}]}function ye(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:ye(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=ye(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Rt(e){let t=x(e);return x(()=>ye(t()))}var he=N();rt((e,t)=>{let r=se(t,he);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(he,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function be(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?be(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return be(this.root)}get proxy(){return be(this.root)}get accessor(){return(()=>be(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}
1
+ "use strict";var xe=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.prototype.hasOwnProperty;var ar=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sr(t))!ir.call(e,o)&&o!==r&&xe(e,o,{get:()=>t[o],enumerable:!(n=or(t,o))||n.enumerable});return e};var cr=e=>ur(xe({},"__esModule",{value:!0}),e);var Pr={};ar(Pr,{$NAME:()=>Mt,$NODE:()=>D,$PROXY:()=>Rr,$RAW:()=>Z,$SELF:()=>Te,$SIGNAL:()=>Ar,$STORE:()=>$t,$TRACK:()=>me,Observable:()=>B,SafeSubscriber:()=>ne,Signal:()=>Ct,Store:()=>R,StoreAPI:()=>er,Subject:()=>Oe,Subscriber:()=>U,Subscription:()=>I,SuspenseContext:()=>be,VERSION:()=>We,__DEV__:()=>ae,batch:()=>O,createChildOwner:()=>Je,createComputed:()=>ut,createComputedStore:()=>Wt,createContext:()=>N,createDebounce:()=>gt,createDebouncedResource:()=>At,createDebouncedSignal:()=>Ue,createDeferred:()=>Ot,createEffect:()=>P,createErrorBoundary:()=>Pt,createMemo:()=>x,createMutableStore:()=>$e,createRenderEffect:()=>ct,createResource:()=>de,createRoot:()=>E,createSelector:()=>wt,createSignal:()=>f,createStore:()=>Me,createStoreEffect:()=>Ht,createStoreMemo:()=>zt,createSuspenseBoundary:()=>_t,disposeScope:()=>Ze,flush:()=>pt,getNode:()=>Qt,getOwner:()=>X,getServerData:()=>le,getStoreNode:()=>Jt,indexArray:()=>vr,isComponent:()=>bt,isMemo:()=>dt,isOwnerDisposed:()=>et,isProvider:()=>Tt,isResource:()=>yt,isSignal:()=>ue,isStore:()=>Xt,isStoreProxy:()=>Se,isSuspense:()=>ht,keyArray:()=>mr,makeArrayFlat:()=>Ee,mapArray:()=>Tr,modifiable:()=>Zt,nextResourceId:()=>pe,on:()=>ft,onCleanup:()=>v,operate:()=>lr,produceUtil:()=>tr,provide:()=>M,provideErrorBoundary:()=>Dt,provideSuspense:()=>kt,readChildren:()=>Rt,reconcileUtil:()=>rr,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Re,setResourceDataSink:()=>xt,setResourceIdSource:()=>St,setResourceTracker:()=>mt,setServerDataGetter:()=>vt,startTransition:()=>ke,trackResourcePromise:()=>ce,untrack:()=>S,untrackStore:()=>Le,unwrap:()=>V,useContext:()=>tt,useTransition:()=>lt,wrap:()=>Yt});module.exports=cr(Pr);var We="1.0.0-alpha.74";var He=require("@fluixi/utils/object"),we=require("@fluixi/utils/functions"),I=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,we.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,He.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,we.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends I{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ne=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function lr(e){return new U(e.next,e.error,e.complete)}var B=class extends I{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new ne(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Oe=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var pr="__fluixi_signal_next_state__",fr=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[pr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:fr,onSuspend:null,onError:null};var ze=0,Ye=1,W=2,oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends oe{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);ge(this)}}peek(){return this._value}},A=class extends oe{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Ye&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=ze}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);ge(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===ze;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Ye);ge(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function ge(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var q=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Xe(){return a.consumer}function Qe(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Je(e){let t=Y(e);return e&&(e.owned??=[]).push(t),t}function Ze(e,t=!0){z(e,t)}function et(e){return!!e&&e.disposed===!0}function Y(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=Y(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function tt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=Y(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function rt(e){a.onSuspend=e}function nt(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function ot(e){a.onError=e}function X(){return a.owner}function Re(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function E(e){let t=Y(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>z(t))}finally{a.owner=r}}function st(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function dr(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Q)))}function Q(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function it(){a.batchDepth===0&&Q()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Q()}}var Ae=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=Y(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{z(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new q(()=>dr(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),z(this.owner))}};function ie(e){let t=new Ae(e);return()=>t.dispose()}function yr(e){return!!e&&typeof e.then=="function"}st(()=>{});var at=Symbol.for("signal"),br=Symbol.for("memo"),hr=Symbol.for("signal-node");function f(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),it(),i});return Object.defineProperty(n,at,{value:!0,enumerable:!0}),Object.defineProperty(n,hr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function x(e,t,r){let n=t,o=X(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(yr(c))return nt(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,at,{value:!0,enumerable:!0}),Object.defineProperty(i,br,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function ut(e,t){let r=t;ie(()=>{r=e(r)})}function ct(e,t){let r=t;return ie(()=>{r=e(r)})}function O(e){return _e(e)}function S(e){return H(e)}function ke(e){return _e(e),Promise.resolve()}function lt(){return[()=>!1,ke]}function pt(){return Q(),Promise.resolve()}function ft(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function Tr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],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[C,K]=f(u);d=K,l=t(p,C)});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 mr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),x(()=>{let i=e()||[];return S(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],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,C;E(K=>{C=K;let[_,G]=f(l);T=G;let ee=x(F=>{let g=(e()||[])[_()];return g??F},i[l]);w=r(ee,_)}),u.push({rendered:w,dispose:C,setIndex:T})}p.push(d),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 vr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),x(()=>{let o=e()||[];return S(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,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,Sr=Symbol.for("signal"),xr=Symbol.for("memo"),wr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[Sr]===!0}function dt(e){return typeof e=="function"&&e[xr]===!0}function yt(e){return typeof e=="function"&&e[wr]===!0}function bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function ht(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Tt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var Pe=null;function mt(e){Pe=e}function ce(e){Pe&&Pe(e)}var De=null;function vt(e){De=e}function le(e){return De?De(e):void 0}var Ce=null;function St(e){Ce=e}function pe(){return Ce?Ce():void 0}var Fe=null;function xt(e){Fe=e}function fe(e,t){Fe&&Fe(e,t)}function wt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Ot(e,t){let[r,n]=f(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function gt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function Or(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function de(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0: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}),[C,K]=f(void 0,{equals:!1}),_=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){_=Ie,O(()=>{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 te=!1;v(()=>te=!0);let Ke=S(d),nr=S(u),Ge=Ke==="ready"||Ke==="refreshing";O(()=>{h(Ge?"refreshing":"pending"),l(void 0)});try{let k=o(m,{value:nr,refetching:Ge});Or(k)?(T(k),ce(k),k.then(re=>{te||(s!==void 0&&fe(s,re),O(()=>{p(()=>re),h("ready"),T(void 0)}))},re=>{te||O(()=>{l(re),h("errored"),T(void 0)})})):O(()=>{p(()=>k),h("ready"),T(void 0)})}catch(k){if(te)return;O(()=>{l(k),h("errored"),T(void 0)})}});let ee=()=>{let m=d();return m==="pending"||m==="refreshing"},F=(()=>{let m=b();if(m)throw m;if(ee()){let g=w();if(g)throw g}return u()});return Object.defineProperties(F,{state:{get:d},loading:{get:ee},error:{get:b},latest:{get:u}}),Object.defineProperty(F,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(F,Symbol.for("signal"),{value:!0,enumerable:!0}),[F,{mutate:p,refetch:()=>{G=!0,K(void 0)}}]}function Ue(e,t=300){let[r,n]=f(e),[o,s]=f(e),[i,c]=f(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},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 gr(e){return e!=null&&e!==""}function At(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=gr}=r,[i,c,u]=Ue(e,n),p=()=>s(i())?i():!1,[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 Rt(e){let t=x(e);return x(()=>ye(t()))}var be=N();rt((e,t)=>{let r=se(t,be);r&&(r.increment(),e.finally(()=>r.decrement()))});function _t(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function kt(e,t){return M(be,e,t)}var Et=N();ot((e,t)=>{let r=se(t,Et);return r?(r.setError(e),!0):!1});function Pt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Dt(e,t){return M(Et,e,t)}var Ct={State:j,Computed:A,subtle:{Watcher:q,untrack:H,currentComputed:Xe,hasSinks:Qe}};var Ar=Symbol.for("signal"),Rr=Symbol.for("fluixi-proxy");var y=require("@fluixi/reactive/signal"),Z=Symbol("store-raw"),D=Symbol("store-node"),Ft=Symbol("store-has"),Te=Symbol("store-self"),me=Symbol("store-track"),Mt=Symbol("store-name"),$t=Symbol("store-store"),It=new WeakMap,Ut=new WeakMap;function Lt(e){let[t,r]=(0,y.createSignal)(e),n=t;return n.$=r,n}function ve(e){let t=It.get(e);return t||It.set(e,t={keys:new Map}),t}function Bt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Lt(r)),n}function jt(e){let t=ve(e);(t.all||(t.all=Lt()))()}function qt(e,t){e.$(typeof t=="function"?()=>t:t)}function Vt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function he(e){if(!Vt(e))return e;let t=Ut.get(e);if(t)return t;let r=new Proxy(e,_r);return Ut.set(e,r),r}var _r={get(e,t,r){if(t===Z||t===D)return e;if(t===y.$PROXY)return r;if(t===Ft)return i=>i in e;if(t==="__proxy")return!0;if(t===me||t===Te)return jt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Bt(ve(e),t,n)();return Vt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&J(e,t,void 0),!0},has(e,t){return t===Z||t===y.$PROXY||t===D||t===Ft||t===Te||t===me?!0:(Bt(ve(e),t,e[t])(),t in e)},ownKeys(e){return jt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function J(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ve(e),c=i.keys.get(t);if(c&&qt(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&qt(u,e.length)}i.all&&i.all.$(void 0)}function Nt(e,t){return typeof e=="function"?e(t):e}function je(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?je(o,n):J(e,r,n)}}function Ne(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Kt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)Kt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},J(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)J(e,s,Nt(r,e[s]));return}J(e,o,Nt(r,e[o]))}function Be(e,t,r){Kt(e,Ne(t),r)}function kr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&je(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Be(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){je(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Be(e,`${r}.${t[1].join(".")}`,t[2]);return}Be(e,String(r),t[1])}function qe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(qe);let t={};for(let r of Object.keys(e))t[r]=qe(e[r]);return t}function L(e,t){let r=e;for(let n of Ne(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,y.batch)(()=>kr(this.root,n)))}get state(){return 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 Ne(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,y.createMemo)(()=>t(this.state))}subscribe(t){return(0,y.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,y.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,y.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=qe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,y.createSignal)(this.state);return t.toObservable()}dispose(){}},Er=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Gt(e,t){for(let r of Er)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Me(e,t={immutable:!0}){let r=new R(e,t);return Gt(r.set,r),[r.proxy,r.set]}function $e(e,t={}){return new R(e,{...t,immutable:!1})}function Wt(e,t={}){let r=new R(e(),t);return(0,y.createEffect)(()=>r.set(e())),r}function Ht(e,t,r){return(0,y.createEffect)(()=>r(t(e)))}function zt(e,t,r){return(0,y.createMemo)(()=>t(e),void 0,r)}function Yt(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return Gt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[Z];return t!==void 0?t:e}function Le(e){return(0,y.untrack)(()=>V(e))}function Xt(e){return Se(e)}function Qt(e){return Se(e)?e[D]:null}function Jt(e){return e&&typeof e=="object"&&D in e?e[D]:null}function Se(e){return!!e&&typeof e=="object"&&(y.$PROXY in e||e.__proxy===!0)}function Zt(e){return e}var er=Object.freeze({createStore:Me,createMutableStore:$e,batch:y.batch,unwrap:V,untrackStore:Le});function Ve(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ve);let t={};for(let r of Object.keys(e))t[r]=Ve(e[r]);return t}function tr(e){return t=>{let r=Ve(t);return e(r),r}}function rr(e,t={}){return()=>e}
@@ -1 +1 @@
1
- var mt="1.0.0-alpha.72";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,h;C(b=>{h=b;let[k,B]=d(u);f=B,l=t(p,k)});let x={item:p,rendered:l,dispose:h,setIndex:f};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),h=c.get(f);if(h&&!y.has(f))h.setIndex(l),u.push(h);else{let x,b,k;C(B=>{k=B;let[A,j]=d(l);b=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex:b})}p.push(f),y.add(f)}for(let[l,f]of c)y.has(l)||f.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(h=>{l=h;let[x,b]=d(f);y=b,p=t(x,u)}),n.push({rendered:p,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Vt(e){he=e}function ve(e){he&&he(e)}var be=null;function Kt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[f,h]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,b]=d(void 0,{equals:!1}),[k,B]=d(void 0,{equals:!1}),A=Oe,j=!1;F(()=>{let T=n();if(k(),T===!1||T===null||T===void 0){A=Oe,g(()=>{h("unresolved"),b(void 0),l(void 0)});return}let w=j;if(j=!1,A!==Oe&&T===A&&!w)return;if(A=T,c){c=!1;return}let J=!1;m(()=>J=!0);let Be=v(f),Tt=v(u),je=Be==="ready"||Be==="refreshing";g(()=>{h(je?"refreshing":"pending"),l(void 0)});try{let R=o(T,{value:Tt,refetching:je});Xt(R)?(b(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),h("ready"),b(void 0)}))},Z=>{J||g(()=>{l(Z),h("errored"),b(void 0)})})):g(()=>{p(()=>R),h("ready"),b(void 0)})}catch(R){if(J)return;g(()=>{l(R),h("errored"),b(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let h=typeof f=="function"?f(v(r)):f;return n(()=>h),c(!0),p(),u=setTimeout(y,t),h});return m(p),[o,l,{immediate:r,pending:i,flush:y,cancel:()=>{p(),c(!1)}}]}function Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),hn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function ht(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function bt(e){return sr(()=>X(e))}function hr(e){return Ie(e)}function br(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:ht,batch:ut,unwrap:X,untrackStore:bt});function Ue(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ue);let t={};for(let r of Object.keys(e))t[r]=Ue(e[r]);return t}function Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,hn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,ht as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,br as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,hr as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,bt as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
1
+ var mt="1.0.0-alpha.74";import{isObject as vt}from"@fluixi/utils/object";import{isFunction as qe}from"@fluixi/utils/functions";var q=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(qe(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(vt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(qe(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var N=class extends q{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends N{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function _r(e){return new N(e.next,e.error,e.complete)}var M=class extends q{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof N?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var St="__fluixi_signal_next_state__",xt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[St]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:xt,onSuspend:null,onError:null};var Me=0,$e=1,$=2,ee=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends ee{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},O=class extends ee{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===$e&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=Me}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Me;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty($e);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var D=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function Le(){return a.consumer}function Ve(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function wt(e){let t=K(e);return e&&(e.owned??=[]).push(t),t}function Ot(e,t=!0){V(e,t)}function gt(e){return!!e&&e.disposed===!0}function K(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function G(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=K(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function At(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function W(e,t,r){let n=K(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ke(e){a.onSuspend=e}function Ge(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function We(e){a.onError=e}function re(){return a.owner}function He(e){let t=a.owner;return a.owner=e,t}function H(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function V(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)V(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=K(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>V(t))}finally{a.owner=r}}function ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function Rt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(z)))}function z(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function Ye(){a.batchDepth===0&&z()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&z()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=K(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new O(()=>{V(this.owner,!1),H(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new D(()=>Rt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function _t(e){return!!e&&typeof e.then=="function"}ze(()=>{});var Xe=Symbol.for("signal"),kt=Symbol.for("memo"),Et=Symbol.for("signal-node");function d(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),Ye(),i});return Object.defineProperty(n,Xe,{value:!0,enumerable:!0}),Object.defineProperty(n,Et,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=re(),s=new O(()=>H(o,()=>{try{return n=e(n)}catch(c){if(_t(c))return Ge(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Xe,{value:!0,enumerable:!0}),Object.defineProperty(i,kt,{value:!0,enumerable:!0}),i}function F(e,t){let r=t;return ne(()=>{r=e(r)})}function Pt(e,t){let r=t;ne(()=>{r=e(r)})}function Dt(e,t){let r=t;return ne(()=>{r=e(r)})}function g(e){return fe(e)}function v(e){return L(e)}function Qe(e){return fe(e),Promise.resolve()}function Ct(){return[()=>!1,Qe]}function Ft(){return z(),Promise.resolve()}function It(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Lr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],y=s.get(p);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,f,b;C(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 Vr(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return v(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],y=new Set;for(let l=0;l<i.length;l++){let f=t(i[l]),b=c.get(f);if(b&&!y.has(f))b.setIndex(l),u.push(b);else{let x,h,k;C(B=>{k=B;let[A,j]=d(l);h=j;let Q=S(E=>{let w=(e()||[])[A()];return w??E},i[l]);x=r(Q,A)}),u.push({rendered:x,dispose:k,setIndex: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 Kr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return v(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,y,l,f=o[u];C(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,Ut=Symbol.for("signal"),Bt=Symbol.for("memo"),jt=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Ut]===!0}function qt(e){return typeof e=="function"&&e[Bt]===!0}function Nt(e){return typeof e=="function"&&e[jt]===!0}function Mt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function $t(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var be=null;function Vt(e){be=e}function ve(e){be&&be(e)}var he=null;function Kt(e){he=e}function Se(e){return he?he(e):void 0}var Te=null;function Gt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Wt(e){me=e}function we(e,t){me&&me(e,t)}function Ht(e,t=(r,n)=>r===n){let r=new Map;return F(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function zt(e,t){let[r,n]=d(e(),t);return F(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Yt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function Xt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function ge(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=r.transport===!1?void 0: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;F(()=>{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 J=!1;m(()=>J=!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});Xt(R)?(h(R),ve(R),R.then(Z=>{J||(s!==void 0&&we(s,Z),g(()=>{p(()=>Z),b("ready"),h(void 0)}))},Z=>{J||g(()=>{l(Z),b("errored"),h(void 0)})})):g(()=>{p(()=>R),b("ready"),h(void 0)})}catch(R){if(J)return;g(()=>{l(R),b("errored"),h(void 0)})}});let Q=()=>{let T=f();return T==="pending"||T==="refreshing"},E=(()=>{let T=y();if(T)throw T;if(Q()){let w=x();if(w)throw w}return u()});return Object.defineProperties(E,{state:{get:f},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(E,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(E,Symbol.for("signal"),{value:!0,enumerable:!0}),[E,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}function Ze(e,t=300){let[r,n]=d(e),[o,s]=d(e),[i,c]=d(!1),u,p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},y=()=>{p();let f=v(r);return s(()=>f),c(!1),f},l=(f=>{let 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 Qt(e){return e!=null&&e!==""}function Jt(e,t,r={}){let{delay:n=300,initialValue:o,shouldFetch:s=Qt}=r,[i,c,u]=Ze(e,n),p=()=>s(i())?i():!1,[y,{refetch:l}]=ge(p,t,o===void 0?{}:{initialValue:o});return[y,{...u,query:i,setQuery:c,refetch:l}]}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Zt(e){let t=S(e);return S(()=>oe(t()))}var Ae=G();Ke((e,t)=>{let r=te(t,Ae);r&&(r.increment(),e.finally(()=>r.decrement()))});function er(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function tr(e,t){return W(Ae,e,t)}var et=G();We((e,t)=>{let r=te(t,et);return r?(r.setError(e),!0):!1});function rr(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function nr(e,t){return W(et,e,t)}var or={State:P,Computed:O,subtle:{Watcher:D,untrack:L,currentComputed:Le,hasSinks:Ve}};var yn=Symbol.for("signal"),bn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as ut,createEffect as ie,createMemo as ke,createSignal as ct,untrack as sr}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),tt=Symbol("store-has"),Ee=Symbol("store-self"),Pe=Symbol("store-track"),ir=Symbol("store-name"),ar=Symbol("store-store"),rt=new WeakMap,nt=new WeakMap;function lt(e){let[t,r]=ct(e),n=t;return n.$=r,n}function ue(e){let t=rt.get(e);return t||rt.set(e,t={keys:new Map}),t}function ot(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=lt(r)),n}function st(e){let t=ue(e);(t.all||(t.all=lt()))()}function it(e,t){e.$(typeof t=="function"?()=>t:t)}function pt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!pt(e))return e;let t=nt.get(e);if(t)return t;let r=new Proxy(e,ur);return nt.set(e,r),r}var ur={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===tt)return i=>i in e;if(t==="__proxy")return!0;if(t===Pe||t===Ee)return st(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=ot(ue(e),t,n)();return pt(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&Y(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===tt||t===Ee||t===Pe?!0:(ot(ue(e),t,e[t])(),t in e)},ownKeys(e){return st(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function Y(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&it(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&it(u,e.length)}i.all&&i.all.$(void 0)}function at(e,t){return typeof e=="function"?e(t):e}function De(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?De(o,n):Y(e,r,n)}}function Fe(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function ft(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)ft(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},Y(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)Y(e,s,at(r,e[s]));return}Y(e,o,at(r,e[o]))}function Re(e,t,r){ft(e,Fe(t),r)}function cr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&De(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Re(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){De(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Re(e,`${r}.${t[1].join(".")}`,t[2]);return}Re(e,String(r),t[1])}function Ce(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ce);let t={};for(let r of Object.keys(e))t[r]=Ce(e[r]);return t}function I(e,t){let r=e;for(let n of Fe(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>ut(()=>cr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return X(this.state);let r=this.state;for(let n of Fe(t)){if(r==null)return;r=r[n]}return X(r)}select(t){return ke(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return ke(()=>this.state[t])}produce(t){this.set((r=>{let n=Ce(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=I(this.root,t);this.set(t,n.concat(r))}pop(t){let r=I(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=I(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=I(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=I(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=I(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=ct(this.state);return t.toObservable()}dispose(){}},lr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function dt(e,t){for(let r of lr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function yt(e,t={immutable:!0}){let r=new _(e,t);return dt(r.set,r),[r.proxy,r.set]}function bt(e,t={}){return new _(e,{...t,immutable:!1})}function pr(e,t={}){let r=new _(e(),t);return ie(()=>r.set(e())),r}function fr(e,t,r){return ie(()=>r(t(e)))}function dr(e,t,r){return ke(()=>t(e),void 0,r)}function yr(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return dt(n,r),n}function X(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function ht(e){return sr(()=>X(e))}function br(e){return Ie(e)}function hr(e){return Ie(e)?e[U]:null}function Tr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function mr(e){return e}var vr=Object.freeze({createStore:yt,createMutableStore:bt,batch:ut,unwrap:X,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 Sr(e){return t=>{let r=Ue(t);return e(r),r}}function xr(e,t={}){return()=>e}export{ir as $NAME,U as $NODE,bn as $PROXY,ae as $RAW,Ee as $SELF,yn as $SIGNAL,ar as $STORE,Pe as $TRACK,M as Observable,ce as SafeSubscriber,or as Signal,_ as Store,vr as StoreAPI,Ne as Subject,N as Subscriber,q as Subscription,Ae as SuspenseContext,mt as VERSION,de as __DEV__,g as batch,wt as createChildOwner,Pt as createComputed,pr as createComputedStore,G as createContext,Yt as createDebounce,Jt as createDebouncedResource,Ze as createDebouncedSignal,zt as createDeferred,F as createEffect,rr as createErrorBoundary,S as createMemo,bt as createMutableStore,Dt as createRenderEffect,ge as createResource,C as createRoot,Ht as createSelector,d as createSignal,yt as createStore,fr as createStoreEffect,dr as createStoreMemo,er as createSuspenseBoundary,Ot as disposeScope,Ft as flush,hr as getNode,re as getOwner,Se as getServerData,Tr as getStoreNode,Kr as indexArray,Mt as isComponent,qt as isMemo,gt as isOwnerDisposed,Lt as isProvider,Nt as isResource,ye as isSignal,br as isStore,Ie as isStoreProxy,$t as isSuspense,Vr as keyArray,Je as makeArrayFlat,Lr as mapArray,mr as modifiable,xe as nextResourceId,It as on,m as onCleanup,_r as operate,Sr as produceUtil,W as provide,nr as provideErrorBoundary,tr as provideSuspense,Zt as readChildren,xr as reconcileUtil,we as reportResourceData,H as runWithOwner,He as setOwner,Wt as setResourceDataSink,Gt as setResourceIdSource,Vt as setResourceTracker,Kt as setServerDataGetter,Qe as startTransition,ve as trackResourcePromise,v as untrack,ht as untrackStore,X as unwrap,At as useContext,Ct as useTransition,yr as wrap};
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var he=(e,n)=>{for(var t in n)I(e,t,{get:n[t],enumerable:!0})},Te=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fe(n))!pe.call(e,o)&&o!==t&&I(e,o,{get:()=>n[o],enumerable:!(s=de(n,o))||s.enumerable});return e};var ve=e=>Te(I({},"__esModule",{value:!0}),e);var Oe={};he(Oe,{createDebouncedResource:()=>Re,createDebouncedSignal:()=>ie});module.exports=ve(Oe);var we="__fluixi_signal_next_state__",me=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[we]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:me,onSuspend:null,onError:null};var H=0,K=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends q{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(b);N(this)}}peek(){return this._value}},g=class extends q{constructor(t,s){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=t,this._equals=s?.equals===!1?()=>!1:s?.equals??Object.is}get(){if(r.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===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let t=r.consumer,s=r.untracked;r.consumer=this,r.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{r.consumer=t,r.untracked=s}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);N(this)}}markDirty(t){if(this.state>=t)return;let s=this.state===H;if(this.state=t,s){if(this.observers)for(let o of[...this.observers])o.markDirty(K);N(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function N(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ye(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Se(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&A()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var j=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ye(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new C(()=>Se(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Q(e){let n=new j(e);return()=>n.dispose()}U(()=>{});var ge=Symbol.for("signal");var xe=Symbol.for("signal-node");function p(e,n){let t=new D(e,{equals:n?.equals}),s=(()=>t.get()),o=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),Y(),u});return Object.defineProperty(s,ge,{value:!0,enumerable:!0}),Object.defineProperty(s,xe,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[s,o]}function B(e,n){let t=n;return Q(()=>{t=e(t)})}function m(e){return $(e)}function S(e){return L(e)}var J=null;function ne(e){J&&J(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ke(e){return!!e&&typeof e.then=="function"}var F=Symbol();function se(e,n,t={}){let s,o;typeof n=="function"?(s=typeof e=="function"?e:()=>e,o=n):(s=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let i=re(),u=i!==void 0?te(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:t.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[ue,y]=p(void 0,{equals:!1}),[ae,ce]=p(void 0,{equals:!1}),k=F,E=!1;B(()=>{let c=s();if(ae(),c===!1||c===null||c===void 0){k=F,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==F&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let W=S(f),le=S(a),z=W==="ready"||W==="refreshing";m(()=>{h(z?"refreshing":"pending"),T(void 0)});try{let w=o(c,{value:le,refetching:z});ke(w)?(y(w),ne(w),w.then(P=>{O||(i!==void 0&&oe(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let G=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(G()){let R=ue();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:G},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ce(void 0)}}]}function ie(e,n=300){let[t,s]=p(e),[o,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(t);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(t)):f;return s(()=>h),l(!0),d(),a=setTimeout(v,n),h});return x(d),[o,T,{immediate:t,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function _e(e){return e!=null&&e!==""}function Re(e,n,t={}){let{delay:s=300,initialValue:o,shouldFetch:i=_e}=t,[u,l,a]=ie(e,s),d=()=>i(u())?u():!1,[v,{refetch:T}]=se(d,n,o===void 0?{}:{initialValue:o});return[v,{...a,query:u,setQuery:l,refetch:T}]}
1
+ "use strict";var I=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var he=(e,n)=>{for(var t in n)I(e,t,{get:n[t],enumerable:!0})},Te=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fe(n))!pe.call(e,o)&&o!==t&&I(e,o,{get:()=>n[o],enumerable:!(s=de(n,o))||s.enumerable});return e};var ve=e=>Te(I({},"__esModule",{value:!0}),e);var Oe={};he(Oe,{createDebouncedResource:()=>Re,createDebouncedSignal:()=>ie});module.exports=ve(Oe);var we="__fluixi_signal_next_state__",me=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[we]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:me,onSuspend:null,onError:null};var H=0,K=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},D=class extends q{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(b);N(this)}}peek(){return this._value}},g=class extends q{constructor(t,s){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=t,this._equals=s?.equals===!1?()=>!1:s?.equals??Object.is}get(){if(r.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===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let t=r.consumer,s=r.untracked;r.consumer=this,r.untracked=!1;let o,i=!1,u;try{o=this._fn()}catch(a){i=!0,u=a,o=this._value}finally{r.consumer=t,r.untracked=s}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=i,this._error=u,this._value=o,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);N(this)}}markDirty(t){if(this.state>=t)return;let s=this.state===H;if(this.state=t,s){if(this.observers)for(let o of[...this.observers])o.markDirty(K);N(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function N(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var C=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ye(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function M(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function V(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)V(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function Se(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&A()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var j=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ye(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{V(this.owner,!1),M(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new C(()=>Se(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),V(this.owner))}};function Q(e){let n=new j(e);return()=>n.dispose()}U(()=>{});var ge=Symbol.for("signal");var xe=Symbol.for("signal-node");function p(e,n){let t=new D(e,{equals:n?.equals}),s=(()=>t.get()),o=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),Y(),u});return Object.defineProperty(s,ge,{value:!0,enumerable:!0}),Object.defineProperty(s,xe,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[s,o]}function B(e,n){let t=n;return Q(()=>{t=e(t)})}function m(e){return $(e)}function S(e){return L(e)}var J=null;function ne(e){J&&J(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ke(e){return!!e&&typeof e.then=="function"}var F=Symbol();function se(e,n,t={}){let s,o;typeof n=="function"?(s=typeof e=="function"?e:()=>e,o=n):(s=()=>!0,o=e,n&&typeof n=="object"&&(t=n));let i=t.transport===!1?void 0:re(),u=i!==void 0?te(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:t.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[ue,y]=p(void 0,{equals:!1}),[ae,ce]=p(void 0,{equals:!1}),k=F,E=!1;B(()=>{let c=s();if(ae(),c===!1||c===null||c===void 0){k=F,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==F&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let W=S(f),le=S(a),z=W==="ready"||W==="refreshing";m(()=>{h(z?"refreshing":"pending"),T(void 0)});try{let w=o(c,{value:le,refetching:z});ke(w)?(y(w),ne(w),w.then(P=>{O||(i!==void 0&&oe(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let G=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(G()){let R=ue();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:G},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ce(void 0)}}]}function ie(e,n=300){let[t,s]=p(e),[o,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(t);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(t)):f;return s(()=>h),l(!0),d(),a=setTimeout(v,n),h});return x(d),[o,T,{immediate:t,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function _e(e){return e!=null&&e!==""}function Re(e,n,t={}){let{delay:s=300,initialValue:o,shouldFetch:i=_e}=t,[u,l,a]=ie(e,s),d=()=>i(u())?u():!1,[v,{refetch:T}]=se(d,n,o===void 0?{}:{initialValue:o});return[v,{...a,query:u,setQuery:l,refetch:T}]}
@@ -1 +1 @@
1
- var ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var z=0,H=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},D=class extends q{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.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 n of[...this.observers])n.markDirty(b);I(this)}}peek(){return this._value}},g=class extends q{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===H&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=z}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(a){i=!0,u=a,s=this._value}finally{r.consumer=n,r.untracked=o}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);I(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===z;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(H);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function N(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)N(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&A()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var V=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{N(this.owner,!1),j(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new C(()=>fe(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"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),N(this.owner))}};function $(e){let t=new V(e);return()=>t.dispose()}L(()=>{});var he=Symbol.for("signal");var Te=Symbol.for("signal-node");function p(e,t){let n=new D(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let u=typeof i=="function"?i(n.peek()):i;return n.set(u),U(),u});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,Te,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function Q(e,t){let n=t;return $(()=>{n=e(n)})}function m(e){return Y(e)}function S(e){return K(e)}var B=null;function ee(e){B&&B(e)}var J=null;function ne(e){return J?J(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function ve(e){return!!e&&typeof e.then=="function"}var M=Symbol();function oe(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=te(),u=i!==void 0?ne(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:n.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,y]=p(void 0,{equals:!1}),[ie,ue]=p(void 0,{equals:!1}),k=M,E=!1;Q(()=>{let c=o();if(ie(),c===!1||c===null||c===void 0){k=M,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==M&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let G=S(f),ae=S(a),W=G==="ready"||G==="refreshing";m(()=>{h(W?"refreshing":"pending"),T(void 0)});try{let w=s(c,{value:ae,refetching:W});ve(w)?(y(w),ee(w),w.then(P=>{O||(i!==void 0&&re(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let F=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(F()){let R=se();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:F},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ue(void 0)}}]}function we(e,t=300){let[n,o]=p(e),[s,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(n);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(n)):f;return o(()=>h),l(!0),d(),a=setTimeout(v,t),h});return x(d),[s,T,{immediate:n,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function me(e){return e!=null&&e!==""}function Me(e,t,n={}){let{delay:o=300,initialValue:s,shouldFetch:i=me}=n,[u,l,a]=we(e,o),d=()=>i(u())?u():!1,[v,{refetch:T}]=oe(d,t,s===void 0?{}:{initialValue:s});return[v,{...a,query:u,setQuery:l,refetch:T}]}export{Me as createDebouncedResource,we as createDebouncedSignal};
1
+ var ce="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ce]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var z=0,H=1,b=2,q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let t=r.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},D=class extends q{constructor(t,n){super(),this._value=t,this._equals=n?.equals===!1?()=>!1:n?.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 n of[...this.observers])n.markDirty(b);I(this)}}peek(){return this._value}},g=class extends q{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=b;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===H&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===b)break}(this.state===b||!this._initialized)&&this.recompute(),this.state=z}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let n=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(a){i=!0,u=a,s=this._value}finally{r.consumer=n,r.untracked=o}let l=!this._initialized||this._threw!==i||(i?u!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=u,this._value=s,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(b);I(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===z;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(H);I(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function I(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var C=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let n of t)this._watched.add(n),(n.watchers??=new Set).add(this)}unwatch(...t){for(let n of t)this._watched.delete(n),n.watchers?.delete(this),this._pending.delete(n)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let n=this._pending.size===0;this._pending.add(t),n&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function de(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function j(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function x(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function N(e,t=!0){if(!e.disposed){if(e.owned){for(let n=e.owned.length-1;n>=0;n--)N(e.owned[n]);e.owned=null}if(e.cleanups){for(let n=e.cleanups.length-1;n>=0;n--)e.cleanups[n]();e.cleanups=null}t&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function fe(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(A)))}function A(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let n of t)n.queued=!1,n.disposed||n.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&A()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&A()}}var V=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=de(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new g(()=>{N(this.owner,!1),j(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new C(()=>fe(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"&&r.onSuspend){r.onSuspend(t,this.owner);return}if(r.onError&&r.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),N(this.owner))}};function $(e){let t=new V(e);return()=>t.dispose()}L(()=>{});var he=Symbol.for("signal");var Te=Symbol.for("signal-node");function p(e,t){let n=new D(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let u=typeof i=="function"?i(n.peek()):i;return n.set(u),U(),u});return Object.defineProperty(o,he,{value:!0,enumerable:!0}),Object.defineProperty(o,Te,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function Q(e,t){let n=t;return $(()=>{n=e(n)})}function m(e){return Y(e)}function S(e){return K(e)}var B=null;function ee(e){B&&B(e)}var J=null;function ne(e){return J?J(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,t){Z&&Z(e,t)}function ve(e){return!!e&&typeof e.then=="function"}var M=Symbol();function oe(e,t,n={}){let o,s;typeof t=="function"?(o=typeof e=="function"?e:()=>e,s=t):(o=()=>!0,s=e,t&&typeof t=="object"&&(n=t));let i=n.transport===!1?void 0:te(),u=i!==void 0?ne(i):void 0,l=u!==void 0,[a,d]=p(u!==void 0?u.value:n.initialValue,{equals:!1}),[v,T]=p(void 0,{equals:!1}),[f,h]=p(u!==void 0||n.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,y]=p(void 0,{equals:!1}),[ie,ue]=p(void 0,{equals:!1}),k=M,E=!1;Q(()=>{let c=o();if(ie(),c===!1||c===null||c===void 0){k=M,m(()=>{h("unresolved"),y(void 0),T(void 0)});return}let R=E;if(E=!1,k!==M&&c===k&&!R)return;if(k=c,l){l=!1;return}let O=!1;x(()=>O=!0);let G=S(f),ae=S(a),W=G==="ready"||G==="refreshing";m(()=>{h(W?"refreshing":"pending"),T(void 0)});try{let w=s(c,{value:ae,refetching:W});ve(w)?(y(w),ee(w),w.then(P=>{O||(i!==void 0&&re(i,P),m(()=>{d(()=>P),h("ready"),y(void 0)}))},P=>{O||m(()=>{T(P),h("errored"),y(void 0)})})):m(()=>{d(()=>w),h("ready"),y(void 0)})}catch(w){if(O)return;m(()=>{T(w),h("errored"),y(void 0)})}});let F=()=>{let c=f();return c==="pending"||c==="refreshing"},_=(()=>{let c=v();if(c)throw c;if(F()){let R=se();if(R)throw R}return a()});return Object.defineProperties(_,{state:{get:f},loading:{get:F},error:{get:v},latest:{get:a}}),Object.defineProperty(_,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(_,Symbol.for("signal"),{value:!0,enumerable:!0}),[_,{mutate:d,refetch:()=>{E=!0,ue(void 0)}}]}function we(e,t=300){let[n,o]=p(e),[s,i]=p(e),[u,l]=p(!1),a,d=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},v=()=>{d();let f=S(n);return i(()=>f),l(!1),f},T=(f=>{let h=typeof f=="function"?f(S(n)):f;return o(()=>h),l(!0),d(),a=setTimeout(v,t),h});return x(d),[s,T,{immediate:n,pending:u,flush:v,cancel:()=>{d(),l(!1)}}]}function me(e){return e!=null&&e!==""}function Me(e,t,n={}){let{delay:o=300,initialValue:s,shouldFetch:i=me}=n,[u,l,a]=we(e,o),d=()=>i(u())?u():!1,[v,{refetch:T}]=oe(d,t,s===void 0?{}:{initialValue:s});return[v,{...a,query:u,setQuery:l,refetch:T}]}export{Me as createDebouncedResource,we as createDebouncedSignal};
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(e,n)=>{for(var t in n)C(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ce(n))!de.call(e,s)&&s!==t&&C(e,s,{get:()=>n[s],enumerable:!(o=le(n,s))||o.enumerable});return e};var he=e=>pe(C({},"__esModule",{value:!0}),e);var ke={};fe(ke,{createResource:()=>xe});module.exports=he(ke);var ve="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ve]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var H=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);A(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(l){i=!0,a=l,s=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);A(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===H;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Te(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function V(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)E(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ye(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=Te(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{E(this.owner,!1),N(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>ye(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let n=new I(e);return()=>n.dispose()}U(()=>{});var Se=Symbol.for("signal");var be=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let a=typeof i=="function"?i(t.peek()):i;return t.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,be,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function J(e,n){let t=n;return B(()=>{t=e(t)})}function d(e){return $(e)}function j(e){return L(e)}var Q=null;function ne(e){Q&&Q(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ge(e){return!!e&&typeof e.then=="function"}var M=Symbol();function xe(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=re(),a=i!==void 0?te(i):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==M&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;V(()=>g=!0);let z=j(q),ae=j(l),F=z==="ready"||z==="refreshing";d(()=>{f(F?"refreshing":"pending"),y(void 0)});try{let c=s(u,{value:ae,refetching:F});ge(c)?(p(c),ne(c),c.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=G();if(u)throw u;if(W()){let b=se();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}
1
+ "use strict";var C=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(e,n)=>{for(var t in n)C(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ce(n))!de.call(e,s)&&s!==t&&C(e,s,{get:()=>n[s],enumerable:!(o=le(n,s))||o.enumerable});return e};var he=e=>pe(C({},"__esModule",{value:!0}),e);var ke={};fe(ke,{createResource:()=>xe});module.exports=he(ke);var ve="__fluixi_signal_next_state__",we=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ve]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:we,onSuspend:null,onError:null};var H=0,K=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);A(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===K&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=H}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let s,i=!1,a;try{s=this._fn()}catch(l){i=!0,a=l,s=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==i||(i?a!==this._error:!this._equals(this._value,s));if(this._initialized=!0,this._threw=i,this._error=a,this._value=s,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);A(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===H;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(K);A(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function A(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function L(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function Te(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function N(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function V(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function E(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)E(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function U(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function ye(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function Y(){r.batchDepth===0&&O()}function $(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var I=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=Te(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{E(this.owner,!1),N(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>ye(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),E(this.owner))}};function B(e){let n=new I(e);return()=>n.dispose()}U(()=>{});var Se=Symbol.for("signal");var be=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),s=(i=>{let a=typeof i=="function"?i(t.peek()):i;return t.set(a),Y(),a});return Object.defineProperty(o,Se,{value:!0,enumerable:!0}),Object.defineProperty(o,be,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function J(e,n){let t=n;return B(()=>{t=e(t)})}function d(e){return $(e)}function j(e){return L(e)}var Q=null;function ne(e){Q&&Q(e)}var X=null;function te(e){return X?X(e):void 0}var Z=null;function re(){return Z?Z():void 0}var ee=null;function oe(e,n){ee&&ee(e,n)}function ge(e){return!!e&&typeof e.then=="function"}var M=Symbol();function xe(e,n,t={}){let o,s;typeof n=="function"?(o=typeof e=="function"?e:()=>e,s=n):(o=()=>!0,s=e,n&&typeof n=="object"&&(t=n));let i=t.transport===!1?void 0:re(),a=i!==void 0?te(i):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[G,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[se,p]=h(void 0,{equals:!1}),[ie,ue]=h(void 0,{equals:!1}),m=M,D=!1;J(()=>{let u=o();if(ie(),u===!1||u===null||u===void 0){m=M,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==M&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;V(()=>g=!0);let z=j(q),ae=j(l),F=z==="ready"||z==="refreshing";d(()=>{f(F?"refreshing":"pending"),y(void 0)});try{let c=s(u,{value:ae,refetching:F});ge(c)?(p(c),ne(c),c.then(x=>{g||(i!==void 0&&oe(i,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let W=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=G();if(u)throw u;if(W()){let b=se();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:W},error:{get:G},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ue(void 0)}}]}
@@ -28,10 +28,12 @@ export type ResourceFetcherInfo<T> = {
28
28
  export declare function createResource<T>(fetcher: (k: true, info: ResourceFetcherInfo<T>) => T | Promise<T>, options?: {
29
29
  initialValue?: T;
30
30
  name?: string;
31
+ transport?: boolean;
31
32
  }): ResourceReturn<T>;
32
33
  export declare function createResource<T, S>(source: S | false | null | undefined | (() => S | false | null | undefined), fetcher: (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>, options?: {
33
34
  initialValue?: T;
34
35
  name?: string;
36
+ transport?: boolean;
35
37
  }): ResourceReturn<T>;
36
38
  export {};
37
39
  //# sourceMappingURL=resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/resource.ts"],"names":[],"mappings":"AA6BA,KAAK,aAAa,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAMnF,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,KAAK,OAAO,CAAC;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AACD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG;QAChC,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;QACtB,KAAK,EAAE,aAAa,CAAC;KACtB;IACD,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;CAC5B,CAAC;AAIF;;;;;;;GAOG;AACH,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AACnF,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAClE,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,cAAc,CAAC,CAAC,CAAC,CAAC;AACrB,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EACjC,MAAM,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAC3E,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/D,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,cAAc,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../../src/lib/signal/graph/resource.ts"],"names":[],"mappings":"AA6BA,KAAK,aAAa,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAMnF,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,KAAK,OAAO,CAAC;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AACD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG;QAChC,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;QACtB,KAAK,EAAE,aAAa,CAAC;KACtB;IACD,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;CAC5B,CAAC;AAIF;;;;;;;GAOG;AACH,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AACnF,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAClE,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,cAAc,CAAC,CAAC,CAAC,CAAC;AACrB,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EACjC,MAAM,EAAE,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,EAC3E,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/D,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,cAAc,CAAC,CAAC,CAAC,CAAC"}
@@ -33,7 +33,17 @@ export function createResource(source, fetcherFn, options = {}) {
33
33
  options = fetcherFn;
34
34
  }
35
35
  // SSR data transport: stable id; on the client seed from server-serialized value.
36
- const ssrId = nextResourceId();
36
+ //
37
+ // `transport: false` opts out, and takes the id with it. The id is a position in
38
+ // a per-render sequence that the client re-derives by counting resources in the
39
+ // same order, so a resource that exists on one side and not the other shifts
40
+ // every id after it. `lazy()` is exactly that: on the server the first request
41
+ // for a route creates a resource for the module import and later requests find
42
+ // it cached and create none, so the page's own resource was r1 for the first
43
+ // visitor after a restart and r0 for everyone else — while the client, which
44
+ // preloads routes before hydrating, always said r0. Its value is a component
45
+ // function and was never transportable anyway.
46
+ const ssrId = options.transport === false ? undefined : nextResourceId();
37
47
  const seed = ssrId !== undefined ? getServerData(ssrId) : undefined;
38
48
  let skipFirstFetch = seed !== undefined;
39
49
  const [value, setValue] = createSignal(seed !== undefined ? seed.value : options.initialValue, { equals: false });
@@ -1 +1 @@
1
- var ae="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var F=0,H=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);C(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(l){s=!0,a=l,i=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);C(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===F;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(H);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function A(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)A(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function de(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{A(this.owner,!1),I(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>de(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),A(this.owner))}};function $(e){let n=new E(e);return()=>n.dispose()}L(()=>{});var pe=Symbol.for("signal");var he=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let a=typeof s=="function"?s(t.peek()):s;return t.set(a),U(),a});return Object.defineProperty(o,pe,{value:!0,enumerable:!0}),Object.defineProperty(o,he,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function B(e,n){let t=n;return $(()=>{t=e(t)})}function d(e){return Y(e)}function V(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function ne(e){return Q?Q(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,n){Z&&Z(e,n)}function ve(e){return!!e&&typeof e.then=="function"}var j=Symbol();function Ae(e,n,t={}){let o,i;typeof n=="function"?(o=typeof e=="function"?e:()=>e,i=n):(o=()=>!0,i=e,n&&typeof n=="object"&&(t=n));let s=te(),a=s!==void 0?ne(s):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[oe,p]=h(void 0,{equals:!1}),[se,ie]=h(void 0,{equals:!1}),m=j,D=!1;B(()=>{let u=o();if(se(),u===!1||u===null||u===void 0){m=j,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==j&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;N(()=>g=!0);let W=V(q),ue=V(l),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let c=i(u,{value:ue,refetching:z});ve(c)?(p(c),ee(c),c.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=M();if(u)throw u;if(G()){let b=oe();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ie(void 0)}}]}export{Ae as createResource};
1
+ var ae="__fluixi_signal_next_state__",le=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[ae]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:le,onSuspend:null,onError:null};var F=0,H=1,v=2,k=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let n=r.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},_=class extends k{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(v);C(this)}}peek(){return this._value}},w=class extends k{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=v;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(r.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===H&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===v)break}(this.state===v||!this._initialized)&&this.recompute(),this.state=F}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=r.consumer,o=r.untracked;r.consumer=this,r.untracked=!1;let i,s=!1,a;try{i=this._fn()}catch(l){s=!0,a=l,i=this._value}finally{r.consumer=t,r.untracked=o}let T=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=s,this._error=a,this._value=i,T){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(v);C(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===F;if(this.state=t,o){if(this.observers)for(let i of[...this.observers])i.markDirty(H);C(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function C(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var R=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function K(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function ce(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function I(e,n){let t=r.owner;r.owner=e;try{return n()}finally{r.owner=t}}function N(e){if(r.owner){if(r.owner.disposed){e();return}(r.owner.cleanups??=[]).push(e)}}function A(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)A(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function L(e){r.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function de(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(O)))}function O(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let e=0;try{for(;r.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=r.queue;r.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function U(){r.batchDepth===0&&O()}function Y(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&O()}}var E=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=ce(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{A(this.owner,!1),I(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new R(()=>de(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&r.onSuspend){r.onSuspend(n,this.owner);return}if(r.onError&&r.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),A(this.owner))}};function $(e){let n=new E(e);return()=>n.dispose()}L(()=>{});var pe=Symbol.for("signal");var he=Symbol.for("signal-node");function h(e,n){let t=new _(e,{equals:n?.equals}),o=(()=>t.get()),i=(s=>{let a=typeof s=="function"?s(t.peek()):s;return t.set(a),U(),a});return Object.defineProperty(o,pe,{value:!0,enumerable:!0}),Object.defineProperty(o,he,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,i]}function B(e,n){let t=n;return $(()=>{t=e(t)})}function d(e){return Y(e)}function V(e){return K(e)}var J=null;function ee(e){J&&J(e)}var Q=null;function ne(e){return Q?Q(e):void 0}var X=null;function te(){return X?X():void 0}var Z=null;function re(e,n){Z&&Z(e,n)}function ve(e){return!!e&&typeof e.then=="function"}var j=Symbol();function Ae(e,n,t={}){let o,i;typeof n=="function"?(o=typeof e=="function"?e:()=>e,i=n):(o=()=>!0,i=e,n&&typeof n=="object"&&(t=n));let s=t.transport===!1?void 0:te(),a=s!==void 0?ne(s):void 0,T=a!==void 0,[l,P]=h(a!==void 0?a.value:t.initialValue,{equals:!1}),[M,y]=h(void 0,{equals:!1}),[q,f]=h(a!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[oe,p]=h(void 0,{equals:!1}),[se,ie]=h(void 0,{equals:!1}),m=j,D=!1;B(()=>{let u=o();if(se(),u===!1||u===null||u===void 0){m=j,d(()=>{f("unresolved"),p(void 0),y(void 0)});return}let b=D;if(D=!1,m!==j&&u===m&&!b)return;if(m=u,T){T=!1;return}let g=!1;N(()=>g=!0);let W=V(q),ue=V(l),z=W==="ready"||W==="refreshing";d(()=>{f(z?"refreshing":"pending"),y(void 0)});try{let c=i(u,{value:ue,refetching:z});ve(c)?(p(c),ee(c),c.then(x=>{g||(s!==void 0&&re(s,x),d(()=>{P(()=>x),f("ready"),p(void 0)}))},x=>{g||d(()=>{y(x),f("errored"),p(void 0)})})):d(()=>{P(()=>c),f("ready"),p(void 0)})}catch(c){if(g)return;d(()=>{y(c),f("errored"),p(void 0)})}});let G=()=>{let u=q();return u==="pending"||u==="refreshing"},S=(()=>{let u=M();if(u)throw u;if(G()){let b=oe();if(b)throw b}return l()});return Object.defineProperties(S,{state:{get:q},loading:{get:G},error:{get:M},latest:{get:l}}),Object.defineProperty(S,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(S,Symbol.for("signal"),{value:!0,enumerable:!0}),[S,{mutate:P,refetch:()=>{D=!0,ie(void 0)}}]}export{Ae as createResource};