@fluixi/reactive 1.0.0-alpha.56 → 1.0.0-alpha.58

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.
Files changed (37) hide show
  1. package/dist/cdn/reactive.cjs +1 -1
  2. package/dist/cdn/reactive.global.js +1 -1
  3. package/dist/cdn/reactive.mjs +1 -1
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/lib/index.cjs +1 -1
  7. package/dist/lib/index.mjs +1 -1
  8. package/dist/lib/signal/graph/compat.cjs +1 -1
  9. package/dist/lib/signal/graph/compat.mjs +1 -1
  10. package/dist/lib/signal/graph/derived.cjs +1 -1
  11. package/dist/lib/signal/graph/derived.mjs +1 -1
  12. package/dist/lib/signal/graph/error-boundary.cjs +1 -1
  13. package/dist/lib/signal/graph/error-boundary.mjs +1 -1
  14. package/dist/lib/signal/graph/resource.cjs +1 -1
  15. package/dist/lib/signal/graph/resource.mjs +1 -1
  16. package/dist/lib/signal/graph/runtime.cjs +1 -1
  17. package/dist/lib/signal/graph/runtime.d.ts +5 -0
  18. package/dist/lib/signal/graph/runtime.d.ts.map +1 -1
  19. package/dist/lib/signal/graph/runtime.js +23 -3
  20. package/dist/lib/signal/graph/runtime.mjs +1 -1
  21. package/dist/lib/signal/graph/signal-next.cjs +1 -1
  22. package/dist/lib/signal/graph/signal-next.d.ts +1 -1
  23. package/dist/lib/signal/graph/signal-next.d.ts.map +1 -1
  24. package/dist/lib/signal/graph/signal-next.js +1 -1
  25. package/dist/lib/signal/graph/signal-next.mjs +1 -1
  26. package/dist/lib/signal/index-legacy.cjs +1 -1
  27. package/dist/lib/signal/index-legacy.mjs +1 -1
  28. package/dist/lib/signal/index.cjs +1 -1
  29. package/dist/lib/signal/index.mjs +1 -1
  30. package/dist/lib/signal/list.cjs +1 -1
  31. package/dist/lib/signal/list.mjs +1 -1
  32. package/dist/lib/signal/signal.cjs +1 -1
  33. package/dist/lib/signal/signal.mjs +1 -1
  34. package/dist/lib/signal/utilities.cjs +1 -1
  35. package/dist/lib/signal/utilities.mjs +1 -1
  36. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  37. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{isObject as bt}from"@fluixi/utils/object";import{isFunction as je}from"@fluixi/utils/functions";var N=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(bt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(je(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var q=class extends N{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends q{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function vr(e){return new q(e.next,e.error,e.complete)}var M=class extends N{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof q?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var Tt="__fluixi_signal_next_state__",mt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Tt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:mt,onSuspend:null,onError:null};var qe=0,Me=1,$=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends Q{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},w=class extends Q{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Me&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=qe}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===qe;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Me);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var F=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function $e(){return a.consumer}function Le(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function vt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=ee(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ve(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ge(e){a.onError=e}function re(){return a.owner}function We(e){let t=a.owner;return a.owner=e,t}function G(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){a.owner&&(a.owner.cleanups??=[]).push(e)}function Z(e){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Z(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}}function C(e){let t=ee(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Z(t))}finally{a.owner=r}}function He(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function St(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function ze(){a.batchDepth===0&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{Z(this.owner),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new F(()=>St(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Z(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function xt(e){return!!e&&typeof e.then=="function"}He(()=>{});var Ye=Symbol.for("signal"),wt=Symbol.for("memo"),Ot=Symbol.for("signal-node");function f(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),ze(),i});return Object.defineProperty(n,Ye,{value:!0,enumerable:!0}),Object.defineProperty(n,Ot,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=re(),s=new w(()=>G(o,()=>{try{return n=e(n)}catch(c){if(xt(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Ye,{value:!0,enumerable:!0}),Object.defineProperty(i,wt,{value:!0,enumerable:!0}),i}function I(e,t){let r=t;return ne(()=>{r=e(r)})}function gt(e,t){let r=t;ne(()=>{r=e(r)})}function At(e,t){let r=t;return ne(()=>{r=e(r)})}function O(e){return fe(e)}function g(e){return L(e)}function Xe(e){return fe(e),Promise.resolve()}function _t(){return[()=>!1,Xe]}function Rt(){return W(),Promise.resolve()}function Et(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 Dr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],d=s.get(p);if(d&&!c.has(d))d.setIndex(u),i.push(d),c.add(d);else{let l,y,h;C(b=>{h=b;let[E,B]=f(u);y=B,l=t(p,E)});let S={item:p,rendered:l,dispose:h,setIndex:y};i.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Ur(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return g(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],d=new Set;for(let l=0;l<i.length;l++){let y=t(i[l]),h=c.get(y);if(h&&!d.has(y))h.setIndex(l),u.push(h);else{let S,b,E;C(B=>{E=B;let[A,j]=f(l);b=j;let Y=v(k=>{let x=(e()||[])[A()];return x??k},i[l]);S=r(Y,A)}),u.push({rendered:S,dispose:E,setIndex:b})}p.push(y),d.add(y)}for(let[l,y]of c)d.has(l)||y.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Br(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,d,l,y=o[u];C(h=>{l=h;let[S,b]=f(y);d=b,p=t(S,u)}),n.push({rendered:p,setItem:d,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,kt=Symbol.for("signal"),Pt=Symbol.for("memo"),Ft=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[kt]===!0}function Ct(e){return typeof e=="function"&&e[Pt]===!0}function It(e){return typeof e=="function"&&e[Ft]===!0}function Dt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ut(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Bt(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 jt(e){he=e}function ve(e){he&&he(e)}var be=null;function Nt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function qt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Mt(e){me=e}function we(e,t){me&&me(e,t)}function $t(e,t=(r,n)=>r===n){let r=new Map;return I(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Lt(e,t){let[r,n]=f(e(),t);return I(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Vt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Kt(e){let t=v(e);return v(()=>oe(t()))}function Gt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function Wt(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[d,l]=f(void 0,{equals:!1}),[y,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,b]=f(void 0,{equals:!1}),[E,B]=f(void 0,{equals:!1}),A=Oe,j=!1;I(()=>{let T=n();if(E(),T===!1||T===null||T===void 0){A=Oe,O(()=>{h("unresolved"),b(void 0),l(void 0)});return}let x=j;if(j=!1,A!==Oe&&T===A&&!x)return;if(A=T,c){c=!1;return}let X=!1;m(()=>X=!0);let Ue=g(y),ht=g(u),Be=Ue==="ready"||Ue==="refreshing";O(()=>{h(Be?"refreshing":"pending"),l(void 0)});try{let _=o(T,{value:ht,refetching:Be});Gt(_)?(b(_),ve(_),_.then(J=>{X||(s!==void 0&&we(s,J),O(()=>{p(()=>J),h("ready"),b(void 0)}))},J=>{X||O(()=>{l(J),h("errored"),b(void 0)})})):O(()=>{p(()=>_),h("ready"),b(void 0)})}catch(_){if(X)return;O(()=>{l(_),h("errored"),b(void 0)})}});let Y=()=>{let T=y();return T==="pending"||T==="refreshing"},k=(()=>{let T=d();if(T)throw T;if(Y()){let x=S();if(x)throw x}return u()});return Object.defineProperties(k,{state:{get:y},loading:{get:Y},error:{get:d},latest:{get:u}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}var ge=V();Ve((e,t)=>{let r=te(t,ge);r&&(r.increment(),e.finally(()=>r.decrement()))});function Ht(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function zt(e,t){return K(ge,e,t)}var Qe=V();Ge((e,t)=>{let r=te(t,Qe);return r?(r.setError(e),!0):!1});function Yt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Xt(e,t){return K(Qe,e,t)}var Jt={State:P,Computed:w,subtle:{Watcher:F,untrack:L,currentComputed:$e,hasSinks:Le}};var rn=Symbol.for("signal"),nn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as it,createEffect as ie,createMemo as Re,createSignal as at,untrack as Qt}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),Ze=Symbol("store-has"),Ee=Symbol("store-self"),ke=Symbol("store-track"),Zt=Symbol("store-name"),er=Symbol("store-store"),et=new WeakMap,tt=new WeakMap;function ut(e){let[t,r]=at(e),n=t;return n.$=r,n}function ue(e){let t=et.get(e);return t||et.set(e,t={keys:new Map}),t}function rt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=ut(r)),n}function nt(e){let t=ue(e);(t.all||(t.all=ut()))()}function ot(e,t){e.$(typeof t=="function"?()=>t:t)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!ct(e))return e;let t=tt.get(e);if(t)return t;let r=new Proxy(e,tr);return tt.set(e,r),r}var tr={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===Ze)return i=>i in e;if(t==="__proxy")return!0;if(t===ke||t===Ee)return nt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=rt(ue(e),t,n)();return ct(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&H(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===Ze||t===Ee||t===ke?!0:(rt(ue(e),t,e[t])(),t in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function H(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&ot(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&ot(u,e.length)}i.all&&i.all.$(void 0)}function st(e,t){return typeof e=="function"?e(t):e}function Pe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Pe(o,n):H(e,r,n)}}function Ce(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function lt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)lt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,st(r,e[s]));return}H(e,o,st(r,e[o]))}function Ae(e,t,r){lt(e,Ce(t),r)}function rr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Pe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Ae(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Pe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Ae(e,`${r}.${t[1].join(".")}`,t[2]);return}Ae(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function D(e,t){let r=e;for(let n of Ce(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>it(()=>rr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(r)}select(t){return Re(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Re(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=D(this.root,t);this.set(t,n.concat(r))}pop(t){let r=D(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=D(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=D(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=D(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=D(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=at(this.state);return t.toObservable()}dispose(){}},nr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,t){for(let r of nr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function ft(e,t={immutable:!0}){let r=new R(e,t);return pt(r.set,r),[r.proxy,r.set]}function dt(e,t={}){return new R(e,{...t,immutable:!1})}function or(e,t={}){let r=new R(e(),t);return ie(()=>r.set(e())),r}function sr(e,t,r){return ie(()=>r(t(e)))}function ir(e,t,r){return Re(()=>t(e),void 0,r)}function ar(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return pt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function yt(e){return Qt(()=>z(e))}function ur(e){return Ie(e)}function cr(e){return Ie(e)?e[U]:null}function lr(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 pr(e){return e}var fr=Object.freeze({createStore:ft,createMutableStore:dt,batch:it,unwrap:z,untrackStore:yt});function De(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t={};for(let r of Object.keys(e))t[r]=De(e[r]);return t}function dr(e){return t=>{let r=De(t);return e(r),r}}function yr(e,t={}){return()=>e}export{Zt as $NAME,U as $NODE,nn as $PROXY,ae as $RAW,Ee as $SELF,rn as $SIGNAL,er as $STORE,ke as $TRACK,M as Observable,ce as SafeSubscriber,Jt as Signal,R as Store,fr as StoreAPI,Ne as Subject,q as Subscriber,N as Subscription,ge as SuspenseContext,de as __DEV__,O as batch,gt as createComputed,or as createComputedStore,V as createContext,Vt as createDebounce,Lt as createDeferred,I as createEffect,Yt as createErrorBoundary,v as createMemo,dt as createMutableStore,At as createRenderEffect,Wt as createResource,C as createRoot,$t as createSelector,f as createSignal,ft as createStore,sr as createStoreEffect,ir as createStoreMemo,Ht as createSuspenseBoundary,Rt as flush,cr as getNode,re as getOwner,Se as getServerData,lr as getStoreNode,Br as indexArray,Dt as isComponent,Ct as isMemo,Bt as isProvider,It as isResource,ye as isSignal,ur as isStore,Ie as isStoreProxy,Ut as isSuspense,Ur as keyArray,Je as makeArrayFlat,Dr as mapArray,pr as modifiable,xe as nextResourceId,Et as on,m as onCleanup,vr as operate,dr as produceUtil,K as provide,Xt as provideErrorBoundary,zt as provideSuspense,Kt as readChildren,yr as reconcileUtil,we as reportResourceData,G as runWithOwner,We as setOwner,Mt as setResourceDataSink,qt as setResourceIdSource,jt as setResourceTracker,Nt as setServerDataGetter,Xe as startTransition,ve as trackResourcePromise,g as untrack,yt as untrackStore,z as unwrap,vt as useContext,_t as useTransition,ar as wrap};
1
+ import{isObject as bt}from"@fluixi/utils/object";import{isFunction as je}from"@fluixi/utils/functions";var N=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(bt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(je(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var q=class extends N{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends q{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function Sr(e){return new q(e.next,e.error,e.complete)}var M=class extends N{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof q?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var Tt="__fluixi_signal_next_state__",mt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Tt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:mt,onSuspend:null,onError:null};var qe=0,Me=1,$=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends Q{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},w=class extends Q{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Me&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=qe}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===qe;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Me);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var F=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function $e(){return a.consumer}function Le(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function vt(e){return!!e&&e.disposed===!0}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function St(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=ee(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ve(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ge(e){a.onError=e}function re(){return a.owner}function We(e){let t=a.owner;return a.owner=e,t}function G(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=ee(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Z(t))}finally{a.owner=r}}function He(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function xt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function ze(){a.batchDepth===0&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{Z(this.owner,!1),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new F(()=>xt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Z(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function wt(e){return!!e&&typeof e.then=="function"}He(()=>{});var Ye=Symbol.for("signal"),Ot=Symbol.for("memo"),gt=Symbol.for("signal-node");function f(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),ze(),i});return Object.defineProperty(n,Ye,{value:!0,enumerable:!0}),Object.defineProperty(n,gt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=re(),s=new w(()=>G(o,()=>{try{return n=e(n)}catch(c){if(wt(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Ye,{value:!0,enumerable:!0}),Object.defineProperty(i,Ot,{value:!0,enumerable:!0}),i}function I(e,t){let r=t;return ne(()=>{r=e(r)})}function At(e,t){let r=t;ne(()=>{r=e(r)})}function _t(e,t){let r=t;return ne(()=>{r=e(r)})}function O(e){return fe(e)}function g(e){return L(e)}function Xe(e){return fe(e),Promise.resolve()}function Rt(){return[()=>!1,Xe]}function Et(){return W(),Promise.resolve()}function kt(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Ur(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],d=s.get(p);if(d&&!c.has(d))d.setIndex(u),i.push(d),c.add(d);else{let l,y,h;C(b=>{h=b;let[E,B]=f(u);y=B,l=t(p,E)});let S={item:p,rendered:l,dispose:h,setIndex:y};i.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Br(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return g(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],d=new Set;for(let l=0;l<i.length;l++){let y=t(i[l]),h=c.get(y);if(h&&!d.has(y))h.setIndex(l),u.push(h);else{let S,b,E;C(B=>{E=B;let[A,j]=f(l);b=j;let Y=v(k=>{let x=(e()||[])[A()];return x??k},i[l]);S=r(Y,A)}),u.push({rendered:S,dispose:E,setIndex:b})}p.push(y),d.add(y)}for(let[l,y]of c)d.has(l)||y.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function jr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,d,l,y=o[u];C(h=>{l=h;let[S,b]=f(y);d=b,p=t(S,u)}),n.push({rendered:p,setItem:d,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Pt=Symbol.for("signal"),Ft=Symbol.for("memo"),Ct=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Pt]===!0}function It(e){return typeof e=="function"&&e[Ft]===!0}function Dt(e){return typeof e=="function"&&e[Ct]===!0}function Ut(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Nt(e){he=e}function ve(e){he&&he(e)}var be=null;function qt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Mt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function $t(e){me=e}function we(e,t){me&&me(e,t)}function Lt(e,t=(r,n)=>r===n){let r=new Map;return I(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Vt(e,t){let[r,n]=f(e(),t);return I(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Kt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Gt(e){let t=v(e);return v(()=>oe(t()))}function Wt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function Ht(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[d,l]=f(void 0,{equals:!1}),[y,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,b]=f(void 0,{equals:!1}),[E,B]=f(void 0,{equals:!1}),A=Oe,j=!1;I(()=>{let T=n();if(E(),T===!1||T===null||T===void 0){A=Oe,O(()=>{h("unresolved"),b(void 0),l(void 0)});return}let x=j;if(j=!1,A!==Oe&&T===A&&!x)return;if(A=T,c){c=!1;return}let X=!1;m(()=>X=!0);let Ue=g(y),ht=g(u),Be=Ue==="ready"||Ue==="refreshing";O(()=>{h(Be?"refreshing":"pending"),l(void 0)});try{let _=o(T,{value:ht,refetching:Be});Wt(_)?(b(_),ve(_),_.then(J=>{X||(s!==void 0&&we(s,J),O(()=>{p(()=>J),h("ready"),b(void 0)}))},J=>{X||O(()=>{l(J),h("errored"),b(void 0)})})):O(()=>{p(()=>_),h("ready"),b(void 0)})}catch(_){if(X)return;O(()=>{l(_),h("errored"),b(void 0)})}});let Y=()=>{let T=y();return T==="pending"||T==="refreshing"},k=(()=>{let T=d();if(T)throw T;if(Y()){let x=S();if(x)throw x}return u()});return Object.defineProperties(k,{state:{get:y},loading:{get:Y},error:{get:d},latest:{get:u}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}var ge=V();Ve((e,t)=>{let r=te(t,ge);r&&(r.increment(),e.finally(()=>r.decrement()))});function zt(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Yt(e,t){return K(ge,e,t)}var Qe=V();Ge((e,t)=>{let r=te(t,Qe);return r?(r.setError(e),!0):!1});function Xt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Jt(e,t){return K(Qe,e,t)}var Qt={State:P,Computed:w,subtle:{Watcher:F,untrack:L,currentComputed:$e,hasSinks:Le}};var nn=Symbol.for("signal"),on=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as it,createEffect as ie,createMemo as Re,createSignal as at,untrack as Zt}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),Ze=Symbol("store-has"),Ee=Symbol("store-self"),ke=Symbol("store-track"),er=Symbol("store-name"),tr=Symbol("store-store"),et=new WeakMap,tt=new WeakMap;function ut(e){let[t,r]=at(e),n=t;return n.$=r,n}function ue(e){let t=et.get(e);return t||et.set(e,t={keys:new Map}),t}function rt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=ut(r)),n}function nt(e){let t=ue(e);(t.all||(t.all=ut()))()}function ot(e,t){e.$(typeof t=="function"?()=>t:t)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!ct(e))return e;let t=tt.get(e);if(t)return t;let r=new Proxy(e,rr);return tt.set(e,r),r}var rr={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===Ze)return i=>i in e;if(t==="__proxy")return!0;if(t===ke||t===Ee)return nt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=rt(ue(e),t,n)();return ct(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&H(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===Ze||t===Ee||t===ke?!0:(rt(ue(e),t,e[t])(),t in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function H(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&ot(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&ot(u,e.length)}i.all&&i.all.$(void 0)}function st(e,t){return typeof e=="function"?e(t):e}function Pe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Pe(o,n):H(e,r,n)}}function Ce(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function lt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)lt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,st(r,e[s]));return}H(e,o,st(r,e[o]))}function Ae(e,t,r){lt(e,Ce(t),r)}function nr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Pe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Ae(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Pe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Ae(e,`${r}.${t[1].join(".")}`,t[2]);return}Ae(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function D(e,t){let r=e;for(let n of Ce(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>it(()=>nr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(r)}select(t){return Re(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Re(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=D(this.root,t);this.set(t,n.concat(r))}pop(t){let r=D(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=D(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=D(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=D(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=D(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=at(this.state);return t.toObservable()}dispose(){}},or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,t){for(let r of or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function ft(e,t={immutable:!0}){let r=new R(e,t);return pt(r.set,r),[r.proxy,r.set]}function dt(e,t={}){return new R(e,{...t,immutable:!1})}function sr(e,t={}){let r=new R(e(),t);return ie(()=>r.set(e())),r}function ir(e,t,r){return ie(()=>r(t(e)))}function ar(e,t,r){return Re(()=>t(e),void 0,r)}function ur(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return pt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function yt(e){return Zt(()=>z(e))}function cr(e){return Ie(e)}function lr(e){return Ie(e)?e[U]:null}function pr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function fr(e){return e}var dr=Object.freeze({createStore:ft,createMutableStore:dt,batch:it,unwrap:z,untrackStore:yt});function De(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t={};for(let r of Object.keys(e))t[r]=De(e[r]);return t}function yr(e){return t=>{let r=De(t);return e(r),r}}function hr(e,t={}){return()=>e}export{er as $NAME,U as $NODE,on as $PROXY,ae as $RAW,Ee as $SELF,nn as $SIGNAL,tr as $STORE,ke as $TRACK,M as Observable,ce as SafeSubscriber,Qt as Signal,R as Store,dr as StoreAPI,Ne as Subject,q as Subscriber,N as Subscription,ge as SuspenseContext,de as __DEV__,O as batch,At as createComputed,sr as createComputedStore,V as createContext,Kt as createDebounce,Vt as createDeferred,I as createEffect,Xt as createErrorBoundary,v as createMemo,dt as createMutableStore,_t as createRenderEffect,Ht as createResource,C as createRoot,Lt as createSelector,f as createSignal,ft as createStore,ir as createStoreEffect,ar as createStoreMemo,zt as createSuspenseBoundary,Et as flush,lr as getNode,re as getOwner,Se as getServerData,pr as getStoreNode,jr as indexArray,Ut as isComponent,It as isMemo,vt as isOwnerDisposed,jt as isProvider,Dt as isResource,ye as isSignal,cr as isStore,Ie as isStoreProxy,Bt as isSuspense,Br as keyArray,Je as makeArrayFlat,Ur as mapArray,fr as modifiable,xe as nextResourceId,kt as on,m as onCleanup,Sr as operate,yr as produceUtil,K as provide,Jt as provideErrorBoundary,Yt as provideSuspense,Gt as readChildren,hr as reconcileUtil,we as reportResourceData,G as runWithOwner,We as setOwner,$t as setResourceDataSink,Mt as setResourceIdSource,Nt as setResourceTracker,qt as setServerDataGetter,Xe as startTransition,ve as trackResourcePromise,g as untrack,yt as untrackStore,z as unwrap,St as useContext,Rt as useTransition,ur as wrap};
@@ -1 +1 @@
1
- "use strict";var Se=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var er=Object.prototype.hasOwnProperty;var tr=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},rr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zt(t))!er.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=Qt(t,o))||n.enumerable});return e};var nr=e=>rr(Se({},"__esModule",{value:!0}),e);var Or={};tr(Or,{$NAME:()=>Dt,$NODE:()=>F,$PROXY:()=>vr,$RAW:()=>J,$SELF:()=>be,$SIGNAL:()=>mr,$STORE:()=>Ut,$TRACK:()=>Te,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>_t,Store:()=>_,StoreAPI:()=>zt,Subject:()=>we,Subscriber:()=>U,Subscription:()=>D,SuspenseContext:()=>ye,__DEV__:()=>ae,batch:()=>w,createComputed:()=>rt,createComputedStore:()=>Mt,createContext:()=>q,createDebounce:()=>mt,createDeferred:()=>Tt,createEffect:()=>P,createErrorBoundary:()=>gt,createMemo:()=>S,createMutableStore:()=>qe,createRenderEffect:()=>nt,createResource:()=>St,createRoot:()=>k,createSelector:()=>bt,createSignal:()=>d,createStore:()=>Ne,createStoreEffect:()=>$t,createStoreMemo:()=>Lt,createSuspenseBoundary:()=>xt,flush:()=>st,getNode:()=>Gt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Wt,indexArray:()=>dr,isComponent:()=>ct,isMemo:()=>at,isProvider:()=>pt,isResource:()=>ut,isSignal:()=>ue,isStore:()=>Kt,isStoreProxy:()=>ve,isSuspense:()=>lt,keyArray:()=>fr,makeArrayFlat:()=>Ee,mapArray:()=>pr,modifiable:()=>Ht,nextResourceId:()=>pe,on:()=>it,onCleanup:()=>v,operate:()=>or,produceUtil:()=>Yt,provide:()=>M,provideErrorBoundary:()=>At,provideSuspense:()=>wt,readChildren:()=>vt,reconcileUtil:()=>Xt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Ae,setResourceDataSink:()=>ht,setResourceIdSource:()=>yt,setResourceTracker:()=>ft,setServerDataGetter:()=>dt,startTransition:()=>Re,trackResourcePromise:()=>ce,untrack:()=>O,untrackStore:()=>Me,unwrap:()=>V,useContext:()=>Ye,useTransition:()=>ot,wrap:()=>Vt});module.exports=nr(Or);var Ke=require("@fluixi/utils/object"),xe=require("@fluixi/utils/functions"),D=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,xe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,Ke.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,xe.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends D{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},te=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function or(e){return new U(e.next,e.error,e.complete)}var B=class extends D{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new te(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var we=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var sr="__fluixi_signal_next_state__",ir=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[sr]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ir,onSuspend:null,onError:null};var Ge=0,We=1,W=2,re=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends re{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);Oe(this)}}peek(){return this._value}},A=class extends re{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===We&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=Ge}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);Oe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Ge;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(We);Oe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Oe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var N=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function He(){return a.consumer}function ze(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function Ye(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=oe(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Xe(e){a.onSuspend=e}function Je(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Qe(e){a.onError=e}function z(){return a.owner}function Ae(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){a.owner&&(a.owner.cleanups??=[]).push(e)}function ne(e){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)ne(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}}function k(e){let t=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function Ze(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ar(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Y)))}function Y(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function et(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var ge=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new N(()=>ar(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),ne(this.owner))}};function ie(e){let t=new ge(e);return()=>t.dispose()}function ur(e){return!!e&&typeof e.then=="function"}Ze(()=>{});var tt=Symbol.for("signal"),cr=Symbol.for("memo"),lr=Symbol.for("signal-node");function d(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),et(),i});return Object.defineProperty(n,tt,{value:!0,enumerable:!0}),Object.defineProperty(n,lr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(ur(c))return Je(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,tt,{value:!0,enumerable:!0}),Object.defineProperty(i,cr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function rt(e,t){let r=t;ie(()=>{r=e(r)})}function nt(e,t){let r=t;return ie(()=>{r=e(r)})}function w(e){return _e(e)}function O(e){return H(e)}function Re(e){return _e(e),Promise.resolve()}function ot(){return[()=>!1,Re]}function st(){return Y(),Promise.resolve()}function it(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(f=>f()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function pr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let f=o[u],y=s.get(f);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,h,b;k(T=>{b=T;let[C,K]=d(u);h=K,l=t(f,C)});let x={item:f,rendered:l,dispose:b,setIndex:h};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function fr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],f=[],y=new Set;for(let l=0;l<i.length;l++){let h=t(i[l]),b=c.get(h);if(b&&!y.has(h))b.setIndex(l),u.push(b);else{let x,T,C;k(K=>{C=K;let[R,G]=d(l);T=G;let Q=S(I=>{let g=(e()||[])[R()];return g??I},i[l]);x=r(Q,R)}),u.push({rendered:x,dispose:C,setIndex:T})}f.push(h),y.add(h)}for(let[l,h]of c)y.has(l)||h.dispose();return o=f,s=u,u.map(l=>l.rendered)})})}function dr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let f,y,l,h=o[u];k(b=>{l=b;let[x,T]=d(h);y=T,f=t(x,u)}),n.push({rendered:f,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,yr=Symbol.for("signal"),hr=Symbol.for("memo"),br=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[yr]===!0}function at(e){return typeof e=="function"&&e[hr]===!0}function ut(e){return typeof e=="function"&&e[br]===!0}function ct(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var ke=null;function ft(e){ke=e}function ce(e){ke&&ke(e)}var Pe=null;function dt(e){Pe=e}function le(e){return Pe?Pe(e):void 0}var Fe=null;function yt(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function ht(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function bt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Tt(e,t){let[r,n]=d(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function mt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function de(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:de(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=de(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function vt(e){let t=S(e);return S(()=>de(t()))}function Tr(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function St(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,f]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[h,b]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,K]=d(void 0,{equals:!1}),R=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){R=Ie,w(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,R!==Ie&&m===R&&!g)return;if(R=m,c){c=!1;return}let Z=!1;v(()=>Z=!0);let Le=O(h),Jt=O(u),Ve=Le==="ready"||Le==="refreshing";w(()=>{b(Ve?"refreshing":"pending"),l(void 0)});try{let E=o(m,{value:Jt,refetching:Ve});Tr(E)?(T(E),ce(E),E.then(ee=>{Z||(s!==void 0&&fe(s,ee),w(()=>{f(()=>ee),b("ready"),T(void 0)}))},ee=>{Z||w(()=>{l(ee),b("errored"),T(void 0)})})):w(()=>{f(()=>E),b("ready"),T(void 0)})}catch(E){if(Z)return;w(()=>{l(E),b("errored"),T(void 0)})}});let Q=()=>{let m=h();return m==="pending"||m==="refreshing"},I=(()=>{let m=y();if(m)throw m;if(Q()){let g=x();if(g)throw g}return u()});return Object.defineProperties(I,{state:{get:h},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(I,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(I,Symbol.for("signal"),{value:!0,enumerable:!0}),[I,{mutate:f,refetch:()=>{G=!0,K(void 0)}}]}var ye=q();Xe((e,t)=>{let r=se(t,ye);r&&(r.increment(),e.finally(()=>r.decrement()))});function xt(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function wt(e,t){return M(ye,e,t)}var Ot=q();Qe((e,t)=>{let r=se(t,Ot);return r?(r.setError(e),!0):!1});function gt(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function At(e,t){return M(Ot,e,t)}var _t={State:j,Computed:A,subtle:{Watcher:N,untrack:H,currentComputed:He,hasSinks:ze}};var mr=Symbol.for("signal"),vr=Symbol.for("fluixi-proxy");var p=require("@fluixi/reactive/signal"),J=Symbol("store-raw"),F=Symbol("store-node"),Rt=Symbol("store-has"),be=Symbol("store-self"),Te=Symbol("store-track"),Dt=Symbol("store-name"),Ut=Symbol("store-store"),Et=new WeakMap,kt=new WeakMap;function Bt(e){let[t,r]=(0,p.createSignal)(e),n=t;return n.$=r,n}function me(e){let t=Et.get(e);return t||Et.set(e,t={keys:new Map}),t}function Pt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=Bt(r)),n}function Ft(e){let t=me(e);(t.all||(t.all=Bt()))()}function Ct(e,t){e.$(typeof t=="function"?()=>t:t)}function jt(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(!jt(e))return e;let t=kt.get(e);if(t)return t;let r=new Proxy(e,Sr);return kt.set(e,r),r}var Sr={get(e,t,r){if(t===J||t===F)return e;if(t===p.$PROXY)return r;if(t===Rt)return i=>i in e;if(t==="__proxy")return!0;if(t===Te||t===be)return Ft(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=Pt(me(e),t,n)();return jt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===J||t===p.$PROXY||t===F||t===Rt||t===be||t===Te?!0:(Pt(me(e),t,e[t])(),t in e)},ownKeys(e){return Ft(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=me(e),c=i.keys.get(t);if(c&&Ct(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&Ct(u,e.length)}i.all&&i.all.$(void 0)}function It(e,t){return typeof e=="function"?e(t):e}function Ue(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ue(o,n):X(e,r,n)}}function je(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function Nt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let f=0;f<e.length;f++)Nt(e[f],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,It(r,e[s]));return}X(e,o,It(r,e[o]))}function De(e,t,r){Nt(e,je(t),r)}function xr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ue(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&De(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ue(e,r);return}if(Array.isArray(t[1])&&t.length>=3){De(e,`${r}.${t[1].join(".")}`,t[2]);return}De(e,String(r),t[1])}function Be(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Be);let t={};for(let r of Object.keys(e))t[r]=Be(e[r]);return t}function L(e,t){let r=e;for(let n of je(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,p.batch)(()=>xr(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of je(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,p.createMemo)(()=>t(this.state))}subscribe(t){return(0,p.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,p.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,p.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Be(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,p.createSignal)(this.state);return t.toObservable()}dispose(){}},wr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function qt(e,t){for(let r of wr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new _(e,t);return qt(r.set,r),[r.proxy,r.set]}function qe(e,t={}){return new _(e,{...t,immutable:!1})}function Mt(e,t={}){let r=new _(e(),t);return(0,p.createEffect)(()=>r.set(e())),r}function $t(e,t,r){return(0,p.createEffect)(()=>r(t(e)))}function Lt(e,t,r){return(0,p.createMemo)(()=>t(e),void 0,r)}function Vt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return qt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[J];return t!==void 0?t:e}function Me(e){return(0,p.untrack)(()=>V(e))}function Kt(e){return ve(e)}function Gt(e){return ve(e)?e[F]:null}function Wt(e){return e&&typeof e=="object"&&F in e?e[F]:null}function ve(e){return!!e&&typeof e=="object"&&(p.$PROXY in e||e.__proxy===!0)}function Ht(e){return e}var zt=Object.freeze({createStore:Ne,createMutableStore:qe,batch:p.batch,unwrap:V,untrackStore:Me});function $e(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($e);let t={};for(let r of Object.keys(e))t[r]=$e(e[r]);return t}function Yt(e){return t=>{let r=$e(t);return e(r),r}}function Xt(e,t={}){return()=>e}
1
+ "use strict";var Se=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.prototype.hasOwnProperty;var rr=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of er(t))!tr.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=Zt(t,o))||n.enumerable});return e};var or=e=>nr(Se({},"__esModule",{value:!0}),e);var gr={};rr(gr,{$NAME:()=>Ut,$NODE:()=>F,$PROXY:()=>Sr,$RAW:()=>J,$SELF:()=>be,$SIGNAL:()=>vr,$STORE:()=>Bt,$TRACK:()=>Te,Observable:()=>B,SafeSubscriber:()=>te,Signal:()=>Rt,Store:()=>_,StoreAPI:()=>Yt,Subject:()=>we,Subscriber:()=>U,Subscription:()=>D,SuspenseContext:()=>ye,__DEV__:()=>ae,batch:()=>w,createComputed:()=>nt,createComputedStore:()=>$t,createContext:()=>q,createDebounce:()=>vt,createDeferred:()=>mt,createEffect:()=>P,createErrorBoundary:()=>At,createMemo:()=>S,createMutableStore:()=>qe,createRenderEffect:()=>ot,createResource:()=>xt,createRoot:()=>k,createSelector:()=>Tt,createSignal:()=>d,createStore:()=>Ne,createStoreEffect:()=>Lt,createStoreMemo:()=>Vt,createSuspenseBoundary:()=>wt,flush:()=>it,getNode:()=>Wt,getOwner:()=>z,getServerData:()=>le,getStoreNode:()=>Ht,indexArray:()=>yr,isComponent:()=>lt,isMemo:()=>ut,isOwnerDisposed:()=>Ye,isProvider:()=>ft,isResource:()=>ct,isSignal:()=>ue,isStore:()=>Gt,isStoreProxy:()=>ve,isSuspense:()=>pt,keyArray:()=>dr,makeArrayFlat:()=>Ee,mapArray:()=>fr,modifiable:()=>zt,nextResourceId:()=>pe,on:()=>at,onCleanup:()=>v,operate:()=>sr,produceUtil:()=>Xt,provide:()=>M,provideErrorBoundary:()=>_t,provideSuspense:()=>Ot,readChildren:()=>St,reconcileUtil:()=>Jt,reportResourceData:()=>fe,runWithOwner:()=>$,setOwner:()=>Ae,setResourceDataSink:()=>bt,setResourceIdSource:()=>ht,setResourceTracker:()=>dt,setServerDataGetter:()=>yt,startTransition:()=>Re,trackResourcePromise:()=>ce,untrack:()=>O,untrackStore:()=>Me,unwrap:()=>V,useContext:()=>Xe,useTransition:()=>st,wrap:()=>Kt});module.exports=or(gr);var Ke=require("@fluixi/utils/object"),xe=require("@fluixi/utils/functions"),D=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if((0,xe.isFunction)(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if((0,Ke.isObject)(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if((0,xe.isFunction)(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var U=class extends D{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},te=class extends U{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function sr(e){return new U(e.next,e.error,e.complete)}var B=class extends D{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof U?o=t:o=new te(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var we=class extends B{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new B(n=>this.subscribe(n))}};var ir="__fluixi_signal_next_state__",ar=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[ir]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ar,onSuspend:null,onError:null};var Ge=0,We=1,W=2,re=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},j=class extends re{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty(W);Oe(this)}}peek(){return this._value}},A=class extends re{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=W;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===We&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===W)break}(this.state===W||!this._initialized)&&this.recompute(),this.state=Ge}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty(W);Oe(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===Ge;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(We);Oe(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Oe(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var N=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function H(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function He(){return a.consumer}function ze(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function Ye(e){return!!e&&e.disposed===!0}function oe(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=oe(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function Xe(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function se(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function M(e,t,r){let n=oe(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Je(e){a.onSuspend=e}function Qe(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ze(e){a.onError=e}function z(){return a.owner}function Ae(e){let t=a.owner;return a.owner=e,t}function $(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function v(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function ne(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)ne(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function k(e){let t=oe(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>ne(t))}finally{a.owner=r}}function et(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function ur(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(Y)))}function Y(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function tt(){a.batchDepth===0&&Y()}function _e(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&Y()}}var ge=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=oe(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new A(()=>{ne(this.owner,!1),$(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new N(()=>ur(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),ne(this.owner))}};function ie(e){let t=new ge(e);return()=>t.dispose()}function cr(e){return!!e&&typeof e.then=="function"}et(()=>{});var rt=Symbol.for("signal"),lr=Symbol.for("memo"),pr=Symbol.for("signal-node");function d(e,t){let r=new j(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),tt(),i});return Object.defineProperty(n,rt,{value:!0,enumerable:!0}),Object.defineProperty(n,pr,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function S(e,t,r){let n=t,o=z(),s=new A(()=>$(o,()=>{try{return n=e(n)}catch(c){if(cr(c))return Qe(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,rt,{value:!0,enumerable:!0}),Object.defineProperty(i,lr,{value:!0,enumerable:!0}),i}function P(e,t){let r=t;return ie(()=>{r=e(r)})}function nt(e,t){let r=t;ie(()=>{r=e(r)})}function ot(e,t){let r=t;return ie(()=>{r=e(r)})}function w(e){return _e(e)}function O(e){return H(e)}function Re(e){return _e(e),Promise.resolve()}function st(){return[()=>!1,Re]}function it(){return Y(),Promise.resolve()}function at(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(f=>f()):e();if(s){s=!1,o=c;return}let u=H(()=>t(c,o,i));return o=c,u}}function fr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let f=o[u],y=s.get(f);if(y&&!c.has(y))y.setIndex(u),i.push(y),c.add(y);else{let l,h,b;k(T=>{b=T;let[C,K]=d(u);h=K,l=t(f,C)});let x={item:f,rendered:l,dispose:b,setIndex:h};i.push(x),c.add(x)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function dr(e,t,r,n){let o=[],s=[];return v(()=>{for(let i of s)i.dispose();o=[],s=[]}),S(()=>{let i=e()||[];return O(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],f=[],y=new Set;for(let l=0;l<i.length;l++){let h=t(i[l]),b=c.get(h);if(b&&!y.has(h))b.setIndex(l),u.push(b);else{let x,T,C;k(K=>{C=K;let[R,G]=d(l);T=G;let Q=S(I=>{let g=(e()||[])[R()];return g??I},i[l]);x=r(Q,R)}),u.push({rendered:x,dispose:C,setIndex:T})}f.push(h),y.add(h)}for(let[l,h]of c)y.has(l)||h.dispose();return o=f,s=u,u.map(l=>l.rendered)})})}function yr(e,t,r){let n=[];return v(()=>{for(let o of n)o.dispose();n=[]}),S(()=>{let o=e()||[];return O(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let f,y,l,h=o[u];k(b=>{l=b;let[x,T]=d(h);y=T,f=t(x,u)}),n.push({rendered:f,setItem:y,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var ae=!1,hr=Symbol.for("signal"),br=Symbol.for("memo"),Tr=Symbol.for("resource");function ue(e){return typeof e=="function"&&e[hr]===!0}function ut(e){return typeof e=="function"&&e[br]===!0}function ct(e){return typeof e=="function"&&e[Tr]===!0}function lt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function pt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function ft(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Ee(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Ee(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var ke=null;function dt(e){ke=e}function ce(e){ke&&ke(e)}var Pe=null;function yt(e){Pe=e}function le(e){return Pe?Pe(e):void 0}var Fe=null;function ht(e){Fe=e}function pe(){return Fe?Fe():void 0}var Ce=null;function bt(e){Ce=e}function fe(e,t){Ce&&Ce(e,t)}function Tt(e,t=(r,n)=>r===n){let r=new Map;return P(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=d(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function mt(e,t){let[r,n]=d(e(),t);return P(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function vt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return v(()=>{r!==void 0&&clearTimeout(r)}),n}function de(e){if(typeof e=="function"&&!e.length){let t=e();return ue(t)?t:de(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=de(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function St(e){let t=S(e);return S(()=>de(t()))}function mr(e){return!!e&&typeof e.then=="function"}var Ie=Symbol();function xt(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=pe(),i=s!==void 0?le(s):void 0,c=i!==void 0,[u,f]=d(i!==void 0?i.value:r.initialValue,{equals:!1}),[y,l]=d(void 0,{equals:!1}),[h,b]=d(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[x,T]=d(void 0,{equals:!1}),[C,K]=d(void 0,{equals:!1}),R=Ie,G=!1;P(()=>{let m=n();if(C(),m===!1||m===null||m===void 0){R=Ie,w(()=>{b("unresolved"),T(void 0),l(void 0)});return}let g=G;if(G=!1,R!==Ie&&m===R&&!g)return;if(R=m,c){c=!1;return}let Z=!1;v(()=>Z=!0);let Le=O(h),Qt=O(u),Ve=Le==="ready"||Le==="refreshing";w(()=>{b(Ve?"refreshing":"pending"),l(void 0)});try{let E=o(m,{value:Qt,refetching:Ve});mr(E)?(T(E),ce(E),E.then(ee=>{Z||(s!==void 0&&fe(s,ee),w(()=>{f(()=>ee),b("ready"),T(void 0)}))},ee=>{Z||w(()=>{l(ee),b("errored"),T(void 0)})})):w(()=>{f(()=>E),b("ready"),T(void 0)})}catch(E){if(Z)return;w(()=>{l(E),b("errored"),T(void 0)})}});let Q=()=>{let m=h();return m==="pending"||m==="refreshing"},I=(()=>{let m=y();if(m)throw m;if(Q()){let g=x();if(g)throw g}return u()});return Object.defineProperties(I,{state:{get:h},loading:{get:Q},error:{get:y},latest:{get:u}}),Object.defineProperty(I,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(I,Symbol.for("signal"),{value:!0,enumerable:!0}),[I,{mutate:f,refetch:()=>{G=!0,K(void 0)}}]}var ye=q();Je((e,t)=>{let r=se(t,ye);r&&(r.increment(),e.finally(()=>r.decrement()))});function wt(){let[e,t]=d(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Ot(e,t){return M(ye,e,t)}var gt=q();Ze((e,t)=>{let r=se(t,gt);return r?(r.setError(e),!0):!1});function At(){let[e,t]=d(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function _t(e,t){return M(gt,e,t)}var Rt={State:j,Computed:A,subtle:{Watcher:N,untrack:H,currentComputed:He,hasSinks:ze}};var vr=Symbol.for("signal"),Sr=Symbol.for("fluixi-proxy");var p=require("@fluixi/reactive/signal"),J=Symbol("store-raw"),F=Symbol("store-node"),Et=Symbol("store-has"),be=Symbol("store-self"),Te=Symbol("store-track"),Ut=Symbol("store-name"),Bt=Symbol("store-store"),kt=new WeakMap,Pt=new WeakMap;function jt(e){let[t,r]=(0,p.createSignal)(e),n=t;return n.$=r,n}function me(e){let t=kt.get(e);return t||kt.set(e,t={keys:new Map}),t}function Ft(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=jt(r)),n}function Ct(e){let t=me(e);(t.all||(t.all=jt()))()}function It(e,t){e.$(typeof t=="function"?()=>t:t)}function Nt(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function he(e){if(!Nt(e))return e;let t=Pt.get(e);if(t)return t;let r=new Proxy(e,xr);return Pt.set(e,r),r}var xr={get(e,t,r){if(t===J||t===F)return e;if(t===p.$PROXY)return r;if(t===Et)return i=>i in e;if(t==="__proxy")return!0;if(t===Te||t===be)return Ct(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=Ft(me(e),t,n)();return Nt(s)?he(s):s},set(){return!0},deleteProperty(e,t){return t in e&&X(e,t,void 0),!0},has(e,t){return t===J||t===p.$PROXY||t===F||t===Et||t===be||t===Te?!0:(Ft(me(e),t,e[t])(),t in e)},ownKeys(e){return Ct(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function X(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=me(e),c=i.keys.get(t);if(c&&It(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&It(u,e.length)}i.all&&i.all.$(void 0)}function Dt(e,t){return typeof e=="function"?e(t):e}function Ue(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Ue(o,n):X(e,r,n)}}function je(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function qt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let f=0;f<e.length;f++)qt(e[f],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},X(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)X(e,s,Dt(r,e[s]));return}X(e,o,Dt(r,e[o]))}function De(e,t,r){qt(e,je(t),r)}function wr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Ue(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&De(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Ue(e,r);return}if(Array.isArray(t[1])&&t.length>=3){De(e,`${r}.${t[1].join(".")}`,t[2]);return}De(e,String(r),t[1])}function Be(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Be);let t={};for(let r of Object.keys(e))t[r]=Be(e[r]);return t}function L(e,t){let r=e;for(let n of je(t)){if(r==null)return;r=r[n]}return r}var _=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>(0,p.batch)(()=>wr(this.root,n)))}get state(){return he(this.root)}get proxy(){return he(this.root)}get accessor(){return(()=>he(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return V(this.state);let r=this.state;for(let n of je(t)){if(r==null)return;r=r[n]}return V(r)}select(t){return(0,p.createMemo)(()=>t(this.state))}subscribe(t){return(0,p.createEffect)(()=>t(this.state))}watch(t,r){let n;return(0,p.createEffect)(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return(0,p.createMemo)(()=>this.state[t])}produce(t){this.set((r=>{let n=Be(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=L(this.root,t);this.set(t,n.concat(r))}pop(t){let r=L(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=L(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=L(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=L(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=L(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=(0,p.createSignal)(this.state);return t.toObservable()}dispose(){}},Or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function Mt(e,t){for(let r of Or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function Ne(e,t={immutable:!0}){let r=new _(e,t);return Mt(r.set,r),[r.proxy,r.set]}function qe(e,t={}){return new _(e,{...t,immutable:!1})}function $t(e,t={}){let r=new _(e(),t);return(0,p.createEffect)(()=>r.set(e())),r}function Lt(e,t,r){return(0,p.createEffect)(()=>r(t(e)))}function Vt(e,t,r){return(0,p.createMemo)(()=>t(e),void 0,r)}function Kt(e,t={}){let r=new _(e,t),n=(()=>r.proxy);return Mt(n,r),n}function V(e){if(e==null||typeof e!="object")return e;let t=e[J];return t!==void 0?t:e}function Me(e){return(0,p.untrack)(()=>V(e))}function Gt(e){return ve(e)}function Wt(e){return ve(e)?e[F]:null}function Ht(e){return e&&typeof e=="object"&&F in e?e[F]:null}function ve(e){return!!e&&typeof e=="object"&&(p.$PROXY in e||e.__proxy===!0)}function zt(e){return e}var Yt=Object.freeze({createStore:Ne,createMutableStore:qe,batch:p.batch,unwrap:V,untrackStore:Me});function $e(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map($e);let t={};for(let r of Object.keys(e))t[r]=$e(e[r]);return t}function Xt(e){return t=>{let r=$e(t);return e(r),r}}function Jt(e,t={}){return()=>e}
@@ -1 +1 @@
1
- import{isObject as bt}from"@fluixi/utils/object";import{isFunction as je}from"@fluixi/utils/functions";var N=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(bt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(je(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var q=class extends N{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends q{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function vr(e){return new q(e.next,e.error,e.complete)}var M=class extends N{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof q?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var Tt="__fluixi_signal_next_state__",mt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Tt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:mt,onSuspend:null,onError:null};var qe=0,Me=1,$=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends Q{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},w=class extends Q{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Me&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=qe}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===qe;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Me);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var F=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function $e(){return a.consumer}function Le(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function vt(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=ee(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ve(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ge(e){a.onError=e}function re(){return a.owner}function We(e){let t=a.owner;return a.owner=e,t}function G(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){a.owner&&(a.owner.cleanups??=[]).push(e)}function Z(e){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Z(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}}function C(e){let t=ee(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Z(t))}finally{a.owner=r}}function He(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function St(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function ze(){a.batchDepth===0&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{Z(this.owner),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new F(()=>St(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Z(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function xt(e){return!!e&&typeof e.then=="function"}He(()=>{});var Ye=Symbol.for("signal"),wt=Symbol.for("memo"),Ot=Symbol.for("signal-node");function f(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),ze(),i});return Object.defineProperty(n,Ye,{value:!0,enumerable:!0}),Object.defineProperty(n,Ot,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=re(),s=new w(()=>G(o,()=>{try{return n=e(n)}catch(c){if(xt(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Ye,{value:!0,enumerable:!0}),Object.defineProperty(i,wt,{value:!0,enumerable:!0}),i}function I(e,t){let r=t;return ne(()=>{r=e(r)})}function gt(e,t){let r=t;ne(()=>{r=e(r)})}function At(e,t){let r=t;return ne(()=>{r=e(r)})}function O(e){return fe(e)}function g(e){return L(e)}function Xe(e){return fe(e),Promise.resolve()}function _t(){return[()=>!1,Xe]}function Rt(){return W(),Promise.resolve()}function Et(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 Dr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],d=s.get(p);if(d&&!c.has(d))d.setIndex(u),i.push(d),c.add(d);else{let l,y,h;C(b=>{h=b;let[E,B]=f(u);y=B,l=t(p,E)});let S={item:p,rendered:l,dispose:h,setIndex:y};i.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Ur(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return g(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],d=new Set;for(let l=0;l<i.length;l++){let y=t(i[l]),h=c.get(y);if(h&&!d.has(y))h.setIndex(l),u.push(h);else{let S,b,E;C(B=>{E=B;let[A,j]=f(l);b=j;let Y=v(k=>{let x=(e()||[])[A()];return x??k},i[l]);S=r(Y,A)}),u.push({rendered:S,dispose:E,setIndex:b})}p.push(y),d.add(y)}for(let[l,y]of c)d.has(l)||y.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function Br(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,d,l,y=o[u];C(h=>{l=h;let[S,b]=f(y);d=b,p=t(S,u)}),n.push({rendered:p,setItem:d,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,kt=Symbol.for("signal"),Pt=Symbol.for("memo"),Ft=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[kt]===!0}function Ct(e){return typeof e=="function"&&e[Pt]===!0}function It(e){return typeof e=="function"&&e[Ft]===!0}function Dt(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Ut(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function Bt(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 jt(e){he=e}function ve(e){he&&he(e)}var be=null;function Nt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function qt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function Mt(e){me=e}function we(e,t){me&&me(e,t)}function $t(e,t=(r,n)=>r===n){let r=new Map;return I(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Lt(e,t){let[r,n]=f(e(),t);return I(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Vt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Kt(e){let t=v(e);return v(()=>oe(t()))}function Gt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function Wt(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[d,l]=f(void 0,{equals:!1}),[y,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,b]=f(void 0,{equals:!1}),[E,B]=f(void 0,{equals:!1}),A=Oe,j=!1;I(()=>{let T=n();if(E(),T===!1||T===null||T===void 0){A=Oe,O(()=>{h("unresolved"),b(void 0),l(void 0)});return}let x=j;if(j=!1,A!==Oe&&T===A&&!x)return;if(A=T,c){c=!1;return}let X=!1;m(()=>X=!0);let Ue=g(y),ht=g(u),Be=Ue==="ready"||Ue==="refreshing";O(()=>{h(Be?"refreshing":"pending"),l(void 0)});try{let _=o(T,{value:ht,refetching:Be});Gt(_)?(b(_),ve(_),_.then(J=>{X||(s!==void 0&&we(s,J),O(()=>{p(()=>J),h("ready"),b(void 0)}))},J=>{X||O(()=>{l(J),h("errored"),b(void 0)})})):O(()=>{p(()=>_),h("ready"),b(void 0)})}catch(_){if(X)return;O(()=>{l(_),h("errored"),b(void 0)})}});let Y=()=>{let T=y();return T==="pending"||T==="refreshing"},k=(()=>{let T=d();if(T)throw T;if(Y()){let x=S();if(x)throw x}return u()});return Object.defineProperties(k,{state:{get:y},loading:{get:Y},error:{get:d},latest:{get:u}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}var ge=V();Ve((e,t)=>{let r=te(t,ge);r&&(r.increment(),e.finally(()=>r.decrement()))});function Ht(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function zt(e,t){return K(ge,e,t)}var Qe=V();Ge((e,t)=>{let r=te(t,Qe);return r?(r.setError(e),!0):!1});function Yt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Xt(e,t){return K(Qe,e,t)}var Jt={State:P,Computed:w,subtle:{Watcher:F,untrack:L,currentComputed:$e,hasSinks:Le}};var rn=Symbol.for("signal"),nn=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as it,createEffect as ie,createMemo as Re,createSignal as at,untrack as Qt}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),Ze=Symbol("store-has"),Ee=Symbol("store-self"),ke=Symbol("store-track"),Zt=Symbol("store-name"),er=Symbol("store-store"),et=new WeakMap,tt=new WeakMap;function ut(e){let[t,r]=at(e),n=t;return n.$=r,n}function ue(e){let t=et.get(e);return t||et.set(e,t={keys:new Map}),t}function rt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=ut(r)),n}function nt(e){let t=ue(e);(t.all||(t.all=ut()))()}function ot(e,t){e.$(typeof t=="function"?()=>t:t)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!ct(e))return e;let t=tt.get(e);if(t)return t;let r=new Proxy(e,tr);return tt.set(e,r),r}var tr={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===Ze)return i=>i in e;if(t==="__proxy")return!0;if(t===ke||t===Ee)return nt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=rt(ue(e),t,n)();return ct(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&H(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===Ze||t===Ee||t===ke?!0:(rt(ue(e),t,e[t])(),t in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function H(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&ot(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&ot(u,e.length)}i.all&&i.all.$(void 0)}function st(e,t){return typeof e=="function"?e(t):e}function Pe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Pe(o,n):H(e,r,n)}}function Ce(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function lt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)lt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,st(r,e[s]));return}H(e,o,st(r,e[o]))}function Ae(e,t,r){lt(e,Ce(t),r)}function rr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Pe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Ae(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Pe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Ae(e,`${r}.${t[1].join(".")}`,t[2]);return}Ae(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function D(e,t){let r=e;for(let n of Ce(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>it(()=>rr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(r)}select(t){return Re(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Re(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=D(this.root,t);this.set(t,n.concat(r))}pop(t){let r=D(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=D(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=D(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=D(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=D(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=at(this.state);return t.toObservable()}dispose(){}},nr=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,t){for(let r of nr)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function ft(e,t={immutable:!0}){let r=new R(e,t);return pt(r.set,r),[r.proxy,r.set]}function dt(e,t={}){return new R(e,{...t,immutable:!1})}function or(e,t={}){let r=new R(e(),t);return ie(()=>r.set(e())),r}function sr(e,t,r){return ie(()=>r(t(e)))}function ir(e,t,r){return Re(()=>t(e),void 0,r)}function ar(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return pt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function yt(e){return Qt(()=>z(e))}function ur(e){return Ie(e)}function cr(e){return Ie(e)?e[U]:null}function lr(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 pr(e){return e}var fr=Object.freeze({createStore:ft,createMutableStore:dt,batch:it,unwrap:z,untrackStore:yt});function De(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t={};for(let r of Object.keys(e))t[r]=De(e[r]);return t}function dr(e){return t=>{let r=De(t);return e(r),r}}function yr(e,t={}){return()=>e}export{Zt as $NAME,U as $NODE,nn as $PROXY,ae as $RAW,Ee as $SELF,rn as $SIGNAL,er as $STORE,ke as $TRACK,M as Observable,ce as SafeSubscriber,Jt as Signal,R as Store,fr as StoreAPI,Ne as Subject,q as Subscriber,N as Subscription,ge as SuspenseContext,de as __DEV__,O as batch,gt as createComputed,or as createComputedStore,V as createContext,Vt as createDebounce,Lt as createDeferred,I as createEffect,Yt as createErrorBoundary,v as createMemo,dt as createMutableStore,At as createRenderEffect,Wt as createResource,C as createRoot,$t as createSelector,f as createSignal,ft as createStore,sr as createStoreEffect,ir as createStoreMemo,Ht as createSuspenseBoundary,Rt as flush,cr as getNode,re as getOwner,Se as getServerData,lr as getStoreNode,Br as indexArray,Dt as isComponent,Ct as isMemo,Bt as isProvider,It as isResource,ye as isSignal,ur as isStore,Ie as isStoreProxy,Ut as isSuspense,Ur as keyArray,Je as makeArrayFlat,Dr as mapArray,pr as modifiable,xe as nextResourceId,Et as on,m as onCleanup,vr as operate,dr as produceUtil,K as provide,Xt as provideErrorBoundary,zt as provideSuspense,Kt as readChildren,yr as reconcileUtil,we as reportResourceData,G as runWithOwner,We as setOwner,Mt as setResourceDataSink,qt as setResourceIdSource,jt as setResourceTracker,Nt as setServerDataGetter,Xe as startTransition,ve as trackResourcePromise,g as untrack,yt as untrackStore,z as unwrap,vt as useContext,_t as useTransition,ar as wrap};
1
+ import{isObject as bt}from"@fluixi/utils/object";import{isFunction as je}from"@fluixi/utils/functions";var N=class e{constructor(t){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;t&&(this._subscriptions=[t])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:t,_subscriptions:r}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let n of t)n.remove(this);if(r){for(let n of r)if(je(n)&&!(n instanceof e))try{n()}catch(o){console.error("Error in unsubscribe function:",o)}else if(bt(n)&&typeof n.unsubscribe=="function")try{n.unsubscribe()}catch(o){console.error("Error unsubscribing child:",o)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:r,_subscriptions:n}=this;if(r){if(je(t))try{t()}catch(o){console.error("Error in unsubscribe function:",o)}else if(t.unsubscribe)try{t.unsubscribe()}catch(o){console.error("Error unsubscribing:",o)}return this}return n||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:r}=this;if(!r)return;let n=r.indexOf(t);n!==-1&&(r.splice(n,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:r}=this;r?Array.isArray(r)?r.push(t):this._parentOrParents=[r,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:r}=this;if(r===t)this._parentOrParents=null;else if(Array.isArray(r)){let n=r.indexOf(t);n!==-1&&(r.splice(n,1),r.length===1&&(this._parentOrParents=r[0]))}}};var q=class extends N{constructor(r,n,o){super();this.isStopped=!1;let s;r?typeof r=="object"?s=r:s={next:r,error:n,complete:o}:s={},this.destination=s}next(r){if(!this.isStopped&&this.destination.next)try{this.destination.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(r)}catch(n){throw n}else throw r;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(r){this.error(r);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},ce=class extends q{constructor(r,n,o,s){super(r,n,o);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(r){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(r)}catch(n){this.error(n)}}error(r){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(r)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};function Sr(e){return new q(e.next,e.error,e.complete)}var M=class extends N{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,r,n){let o;t instanceof q?o=t:o=new ce(t,r,n);let{_subscribe:s}=this;try{let i=s.call(this,o);i&&(typeof i=="function"||typeof i.unsubscribe=="function")&&o.add(i)}catch(i){o.error(i)}return o}pipe(...t){return t.length===0?this:t.reduce((r,n)=>n(r),this)}toPromise(){return new Promise((t,r)=>{let n;this.subscribe({next:o=>n=o,error:r,complete:()=>t(n)})})}};var Ne=class extends M{constructor(){super(r=>{if(this.closed)throw new Error("Subject has been closed");if(this.hasError)r.error(this.thrownError);else if(this.isStopped)r.complete();else return this.observers.push(r),()=>{let n=this.observers.indexOf(r);n!==-1&&this.observers.splice(n,1)}});this.observers=[];this.isStopped=!1;this.hasError=!1;this.thrownError=null}next(r){if(this.isStopped)return;let{observers:n}=this,o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].next?.(r)}error(r){if(this.isStopped)return;this.hasError=!0,this.thrownError=r,this.isStopped=!0;let{observers:n}=this;this.observers=[];let o=n.length,s=n.slice();for(let i=0;i<o;i++)s[i].error?.(r)}complete(){if(this.isStopped)return;this.isStopped=!0;let{observers:r}=this;this.observers=[];let n=r.length,o=r.slice();for(let s=0;s<n;s++)o[s].complete?.()}unsubscribe(){this.isStopped=!0,this.observers=[]}asObservable(){return new M(n=>this.subscribe(n))}};var Tt="__fluixi_signal_next_state__",mt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},a=globalThis[Tt]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:mt,onSuspend:null,onError:null};var qe=0,Me=1,$=2,Q=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(a.untracked)return;let t=a.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},P=class extends Q{constructor(t,r){super(),this._value=t,this._equals=r?.equals===!1?()=>!1:r?.equals??Object.is}get(){return this.track(),this._value}set(t){if(!this._equals(this._value,t)){if(this._value=t,this.version++,this.observers)for(let r of[...this.observers])r.markDirty($);le(this)}}peek(){return this._value}},w=class extends Q{constructor(r,n){super();this._threw=!1;this._initialized=!1;this.state=$;this.sources=null;this._fn=r,this._equals=n?.equals===!1?()=>!1:n?.equals??Object.is}get(){if(a.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===Me&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===$)break}(this.state===$||!this._initialized)&&this.recompute(),this.state=qe}recompute(){if(this.sources){for(let u of this.sources)u.observers?.delete(this);this.sources.clear()}let r=a.consumer,n=a.untracked;a.consumer=this,a.untracked=!1;let o,s=!1,i;try{o=this._fn()}catch(u){s=!0,i=u,o=this._value}finally{a.consumer=r,a.untracked=n}let c=!this._initialized||this._threw!==s||(s?i!==this._error:!this._equals(this._value,o));if(this._initialized=!0,this._threw=s,this._error=i,this._value=o,c){if(this.version++,this.observers)for(let u of[...this.observers])u.markDirty($);le(this)}}markDirty(r){if(this.state>=r)return;let n=this.state===qe;if(this.state=r,n){if(this.observers)for(let o of[...this.observers])o.markDirty(Me);le(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function le(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var F=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let r of t)this._watched.add(r),(r.watchers??=new Set).add(this)}unwatch(...t){for(let r of t)this._watched.delete(r),r.watchers?.delete(this),this._pending.delete(r)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let r=this._pending.size===0;this._pending.add(t),r&&this._notifyFn()}};function L(e){if(a.untracked)return e();a.untracked=!0;try{return e()}finally{a.untracked=!1}}function $e(){return a.consumer}function Le(e){return!!(e.observers&&e.observers.size)||!!(e.watchers&&e.watchers.size)}function vt(e){return!!e&&e.disposed===!0}function ee(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function V(e){let t=Symbol("context");return{id:t,defaultValue:e,Provider:n=>{let o=a.owner,s=ee(o);(s.contexts=new Map).set(t,n.value),o&&(o.owned??=[]).push(s),a.owner=s;try{return n.children}finally{a.owner=o}}}}function St(e){let t=a.owner;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function te(e,t){let r=e;for(;r;){if(r.contexts&&r.contexts.has(t.id))return r.contexts.get(t.id);r=r.parent}return t.defaultValue}function K(e,t,r){let n=ee(a.owner);(n.contexts=new Map).set(e.id,t),a.owner&&(a.owner.owned??=[]).push(n);let o=a.owner;a.owner=n;try{return r()}finally{a.owner=o}}function Ve(e){a.onSuspend=e}function Ke(e){return a.onSuspend?(a.onSuspend(e,a.owner),!0):!1}function Ge(e){a.onError=e}function re(){return a.owner}function We(e){let t=a.owner;return a.owner=e,t}function G(e,t){let r=a.owner;a.owner=e;try{return t()}finally{a.owner=r}}function m(e){if(a.owner){if(a.owner.disposed){e();return}(a.owner.cleanups??=[]).push(e)}}function Z(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)Z(e.owned[r]);e.owned=null}if(e.cleanups){for(let r=e.cleanups.length-1;r>=0;r--)e.cleanups[r]();e.cleanups=null}t&&(e.disposed=!0)}}function C(e){let t=ee(a.owner);a.owner&&(a.owner.owned??=[]).push(t);let r=a.owner;a.owner=t;try{return e(()=>Z(t))}finally{a.owner=r}}function He(e){a.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function xt(e){e.queued||(e.queued=!0,a.queue.push(e),!a.scheduled&&a.batchDepth===0&&(a.scheduled=!0,a.hostSchedule(W)))}function W(){if(a.scheduled=!1,a.flushing)return;a.flushing=!0;let e=0;try{for(;a.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=a.queue;a.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{a.flushing=!1}}function ze(){a.batchDepth===0&&W()}function fe(e){a.batchDepth++;try{return e()}finally{--a.batchDepth===0&&W()}}var pe=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=ee(a.owner),a.owner&&(a.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new w(()=>{Z(this.owner,!1),G(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new F(()=>xt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(t){if(t&&typeof t.then=="function"&&a.onSuspend){a.onSuspend(t,this.owner);return}if(a.onError&&a.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Z(this.owner))}};function ne(e){let t=new pe(e);return()=>t.dispose()}function wt(e){return!!e&&typeof e.then=="function"}He(()=>{});var Ye=Symbol.for("signal"),Ot=Symbol.for("memo"),gt=Symbol.for("signal-node");function f(e,t){let r=new P(e,{equals:t?.equals}),n=(()=>r.get()),o=(s=>{let i=typeof s=="function"?s(r.peek()):s;return r.set(i),ze(),i});return Object.defineProperty(n,Ye,{value:!0,enumerable:!0}),Object.defineProperty(n,gt,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[n,o]}function v(e,t,r){let n=t,o=re(),s=new w(()=>G(o,()=>{try{return n=e(n)}catch(c){if(wt(c))return Ke(c),n;throw c}}),{equals:r?.equals}),i=(()=>s.get());return Object.defineProperty(i,Ye,{value:!0,enumerable:!0}),Object.defineProperty(i,Ot,{value:!0,enumerable:!0}),i}function I(e,t){let r=t;return ne(()=>{r=e(r)})}function At(e,t){let r=t;ne(()=>{r=e(r)})}function _t(e,t){let r=t;return ne(()=>{r=e(r)})}function O(e){return fe(e)}function g(e){return L(e)}function Xe(e){return fe(e),Promise.resolve()}function Rt(){return[()=>!1,Xe]}function Et(){return W(),Promise.resolve()}function kt(e,t,r){let n=Array.isArray(e),o,s=r?.defer??!1;return i=>{let c=n?e.map(p=>p()):e();if(s){s=!1,o=c;return}let u=L(()=>t(c,o,i));return o=c,u}}function Ur(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=new Map;for(let u of n)s.has(u.item)||s.set(u.item,u);let i=[],c=new Set;for(let u=0;u<o.length;u++){let p=o[u],d=s.get(p);if(d&&!c.has(d))d.setIndex(u),i.push(d),c.add(d);else{let l,y,h;C(b=>{h=b;let[E,B]=f(u);y=B,l=t(p,E)});let S={item:p,rendered:l,dispose:h,setIndex:y};i.push(S),c.add(S)}}for(let u of n)c.has(u)||u.dispose();return n=i,i.map(u=>u.rendered)})})}function Br(e,t,r,n){let o=[],s=[];return m(()=>{for(let i of s)i.dispose();o=[],s=[]}),v(()=>{let i=e()||[];return g(()=>{if(i.length===0){for(let l of s)l.dispose();return o=[],s=[],n?.fallback?n.fallback():[]}let c=new Map;for(let l=0;l<o.length;l++)c.set(o[l],s[l]);let u=[],p=[],d=new Set;for(let l=0;l<i.length;l++){let y=t(i[l]),h=c.get(y);if(h&&!d.has(y))h.setIndex(l),u.push(h);else{let S,b,E;C(B=>{E=B;let[A,j]=f(l);b=j;let Y=v(k=>{let x=(e()||[])[A()];return x??k},i[l]);S=r(Y,A)}),u.push({rendered:S,dispose:E,setIndex:b})}p.push(y),d.add(y)}for(let[l,y]of c)d.has(l)||y.dispose();return o=p,s=u,u.map(l=>l.rendered)})})}function jr(e,t,r){let n=[];return m(()=>{for(let o of n)o.dispose();n=[]}),v(()=>{let o=e()||[];return g(()=>{if(o.length===0){for(let u of n)u.dispose();return n=[],r?.fallback?r.fallback():[]}let s=n.length,i=o.length;for(let u=s;u<i;u++){let p,d,l,y=o[u];C(h=>{l=h;let[S,b]=f(y);d=b,p=t(S,u)}),n.push({rendered:p,setItem:d,dispose:l})}for(let u=i;u<s;u++)n[u].dispose();i<s&&(n=n.slice(0,i));let c=Math.min(s,i);for(let u=0;u<c;u++)n[u].setItem(o[u]);return n.map(u=>u.rendered)})})}var de=!1,Pt=Symbol.for("signal"),Ft=Symbol.for("memo"),Ct=Symbol.for("resource");function ye(e){return typeof e=="function"&&e[Pt]===!0}function It(e){return typeof e=="function"&&e[Ft]===!0}function Dt(e){return typeof e=="function"&&e[Ct]===!0}function Ut(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function Bt(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function jt(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var he=null;function Nt(e){he=e}function ve(e){he&&he(e)}var be=null;function qt(e){be=e}function Se(e){return be?be(e):void 0}var Te=null;function Mt(e){Te=e}function xe(){return Te?Te():void 0}var me=null;function $t(e){me=e}function we(e,t){me&&me(e,t)}function Lt(e,t=(r,n)=>r===n){let r=new Map;return I(()=>{let n=e();for(let[o,s]of r){let[i,c]=s,u=t(o,n);i()!==u&&c(u)}}),n=>{let o=r.get(n);if(!o){let[s,i]=f(!1);o=[s,i],r.set(n,o);let c=e();i(t(n,c))}return o[0]()}}function Vt(e,t){let[r,n]=f(e(),t);return I(()=>{let o=e();t?.timeoutMs?setTimeout(()=>n(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>n(()=>o)):Promise.resolve().then(()=>n(()=>o))}),r}function Kt(e,t){let r,n=(...o)=>{r!==void 0&&clearTimeout(r),r=setTimeout(()=>{if(r=void 0,o.length>0){let s=o[o.length-1];typeof s=="object"&&s&&!s.tagName&&s.target&&s.target.tagName&&(s=s.target),s&&typeof s=="object"&&s.tagName&&(s.tagName.toLowerCase()==="input"||s.tagName.toLowerCase()==="textarea")&&s.focus()}e(...o)},t)};return m(()=>{r!==void 0&&clearTimeout(r)}),n}function oe(e){if(typeof e=="function"&&!e.length){let t=e();return ye(t)?t:oe(t)}if(Array.isArray(e)){let t=[];for(let r=0;r<e.length;r++){let n=oe(e[r]);Array.isArray(n)?t.push.apply(t,n):t.push(n)}return t}return e}function Gt(e){let t=v(e);return v(()=>oe(t()))}function Wt(e){return!!e&&typeof e.then=="function"}var Oe=Symbol();function Ht(e,t,r={}){let n,o;typeof t=="function"?(n=typeof e=="function"?e:()=>e,o=t):(n=()=>!0,o=e,t&&typeof t=="object"&&(r=t));let s=xe(),i=s!==void 0?Se(s):void 0,c=i!==void 0,[u,p]=f(i!==void 0?i.value:r.initialValue,{equals:!1}),[d,l]=f(void 0,{equals:!1}),[y,h]=f(i!==void 0||r.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[S,b]=f(void 0,{equals:!1}),[E,B]=f(void 0,{equals:!1}),A=Oe,j=!1;I(()=>{let T=n();if(E(),T===!1||T===null||T===void 0){A=Oe,O(()=>{h("unresolved"),b(void 0),l(void 0)});return}let x=j;if(j=!1,A!==Oe&&T===A&&!x)return;if(A=T,c){c=!1;return}let X=!1;m(()=>X=!0);let Ue=g(y),ht=g(u),Be=Ue==="ready"||Ue==="refreshing";O(()=>{h(Be?"refreshing":"pending"),l(void 0)});try{let _=o(T,{value:ht,refetching:Be});Wt(_)?(b(_),ve(_),_.then(J=>{X||(s!==void 0&&we(s,J),O(()=>{p(()=>J),h("ready"),b(void 0)}))},J=>{X||O(()=>{l(J),h("errored"),b(void 0)})})):O(()=>{p(()=>_),h("ready"),b(void 0)})}catch(_){if(X)return;O(()=>{l(_),h("errored"),b(void 0)})}});let Y=()=>{let T=y();return T==="pending"||T==="refreshing"},k=(()=>{let T=d();if(T)throw T;if(Y()){let x=S();if(x)throw x}return u()});return Object.defineProperties(k,{state:{get:y},loading:{get:Y},error:{get:d},latest:{get:u}}),Object.defineProperty(k,Symbol.for("resource"),{value:!0,enumerable:!0}),Object.defineProperty(k,Symbol.for("signal"),{value:!0,enumerable:!0}),[k,{mutate:p,refetch:()=>{j=!0,B(void 0)}}]}var ge=V();Ve((e,t)=>{let r=te(t,ge);r&&(r.increment(),e.finally(()=>r.decrement()))});function zt(){let[e,t]=f(0),r=0;return{increment:()=>t(r+=1),decrement:()=>t(r-=1),inFallback:()=>e()>0}}function Yt(e,t){return K(ge,e,t)}var Qe=V();Ge((e,t)=>{let r=te(t,Qe);return r?(r.setError(e),!0):!1});function Xt(){let[e,t]=f(void 0,{equals:!1});return{error:e,reset:()=>t(()=>{}),setError:n=>t(()=>n)}}function Jt(e,t){return K(Qe,e,t)}var Qt={State:P,Computed:w,subtle:{Watcher:F,untrack:L,currentComputed:$e,hasSinks:Le}};var nn=Symbol.for("signal"),on=Symbol.for("fluixi-proxy");import{$PROXY as _e,batch as it,createEffect as ie,createMemo as Re,createSignal as at,untrack as Zt}from"@fluixi/reactive/signal";var ae=Symbol("store-raw"),U=Symbol("store-node"),Ze=Symbol("store-has"),Ee=Symbol("store-self"),ke=Symbol("store-track"),er=Symbol("store-name"),tr=Symbol("store-store"),et=new WeakMap,tt=new WeakMap;function ut(e){let[t,r]=at(e),n=t;return n.$=r,n}function ue(e){let t=et.get(e);return t||et.set(e,t={keys:new Map}),t}function rt(e,t,r){let n=e.keys.get(t);return n||e.keys.set(t,n=ut(r)),n}function nt(e){let t=ue(e);(t.all||(t.all=ut()))()}function ot(e,t){e.$(typeof t=="function"?()=>t:t)}function ct(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function se(e){if(!ct(e))return e;let t=tt.get(e);if(t)return t;let r=new Proxy(e,rr);return tt.set(e,r),r}var rr={get(e,t,r){if(t===ae||t===U)return e;if(t===_e)return r;if(t===Ze)return i=>i in e;if(t==="__proxy")return!0;if(t===ke||t===Ee)return nt(e),r;let n=e[t];if(typeof n=="function"&&!Object.prototype.hasOwnProperty.call(e,t))return n;let o=Object.getOwnPropertyDescriptor(e,t);if(o&&o.get)return o.get.call(r);let s=rt(ue(e),t,n)();return ct(s)?se(s):s},set(){return!0},deleteProperty(e,t){return t in e&&H(e,t,void 0),!0},has(e,t){return t===ae||t===_e||t===U||t===Ze||t===Ee||t===ke?!0:(rt(ue(e),t,e[t])(),t in e)},ownKeys(e){return nt(e),Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e,t)}};function H(e,t,r){if(e[t]===r&&(r!==void 0||t in e))return;let o=Array.isArray(e),s=o?e.length:0;r===void 0?delete e[t]:e[t]=r;let i=ue(e),c=i.keys.get(t);if(c&&ot(c,r),o&&e.length!==s){let u=i.keys.get("length");u&&ot(u,e.length)}i.all&&i.all.$(void 0)}function st(e,t){return typeof e=="function"?e(t):e}function Pe(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];n&&typeof n=="object"&&!Array.isArray(n)&&o&&typeof o=="object"&&!Array.isArray(o)?Pe(o,n):H(e,r,n)}}function Ce(e){let t=[],r=e.replace(/\[([^\]]*)\]/g,".$1");for(let n of r.split("."))n.length&&t.push(n);return t}function lt(e,t,r){let n=t.length-1;for(let s=0;s<n;s++){let i=t[s];if(i==="*"){let u=t.slice(s+1);if(Array.isArray(e))for(let p=0;p<e.length;p++)lt(e[p],u,r);return}let c=e[i];(c==null||typeof c!="object")&&(c=/^\d+$/.test(t[s+1])?[]:{},H(e,i,c)),e=c}let o=t[n];if(o==="*"){if(Array.isArray(e))for(let s=0;s<e.length;s++)H(e,s,st(r,e[s]));return}H(e,o,st(r,e[o]))}function Ae(e,t,r){lt(e,Ce(t),r)}function nr(e,t){let r=t[0];if(typeof r=="function"&&t.length===1){let n=r(e);n&&n!==e&&Pe(e,n);return}if(Array.isArray(r)&&t.length===1){for(let n of r)Array.isArray(n)&&Ae(e,n[0],n[1]);return}if(r&&typeof r=="object"&&!Array.isArray(r)&&t.length===1){Pe(e,r);return}if(Array.isArray(t[1])&&t.length>=3){Ae(e,`${r}.${t[1].join(".")}`,t[2]);return}Ae(e,String(r),t[1])}function Fe(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Fe);let t={};for(let r of Object.keys(e))t[r]=Fe(e[r]);return t}function D(e,t){let r=e;for(let n of Ce(t)){if(r==null)return;r=r[n]}return r}var R=class{constructor(t,r={immutable:!0}){this.options=r;this.root=t,this.set=((...n)=>it(()=>nr(this.root,n)))}get state(){return se(this.root)}get proxy(){return se(this.root)}get accessor(){return(()=>se(this.root))}unwrap(){return this.root}getNode(t){return this.root&&this.root[t]}get(t){if(t==null||t==="")return z(this.state);let r=this.state;for(let n of Ce(t)){if(r==null)return;r=r[n]}return z(r)}select(t){return Re(()=>t(this.state))}subscribe(t){return ie(()=>t(this.state))}watch(t,r){let n;return ie(()=>{let o=t(this.state);Object.is(o,n)||(r(o,n),n=o)})}reactive(t){return Re(()=>this.state[t])}produce(t){this.set((r=>{let n=Fe(r);return t(n),n}))}reconcile(t,r={}){this.set(t)}push(t,...r){let n=D(this.root,t);this.set(t,n.concat(r))}pop(t){let r=D(this.root,t).slice(),n=r.pop();return this.set(t,r),n}shift(t){let r=D(this.root,t).slice(),n=r.shift();return this.set(t,r),n}splice(t,r,n,...o){let s=D(this.root,t).slice(),i=s.splice(r,n,...o);return this.set(t,s),i}insert(t,r,n){let o=D(this.root,t).slice();o.splice(r,0,n),this.set(t,o)}removeAt(t,r){let n=D(this.root,t).slice(),o=n.splice(r,1);return this.set(t,n),o}toObservable(){let[t]=at(this.state);return t.toObservable()}dispose(){}},or=["get","select","watch","subscribe","produce","reconcile","push","pop","shift","splice","insert","removeAt","unwrap","toObservable"];function pt(e,t){for(let r of or)e[r]=t[r].bind(t);e.$=t.reactive.bind(t)}function ft(e,t={immutable:!0}){let r=new R(e,t);return pt(r.set,r),[r.proxy,r.set]}function dt(e,t={}){return new R(e,{...t,immutable:!1})}function sr(e,t={}){let r=new R(e(),t);return ie(()=>r.set(e())),r}function ir(e,t,r){return ie(()=>r(t(e)))}function ar(e,t,r){return Re(()=>t(e),void 0,r)}function ur(e,t={}){let r=new R(e,t),n=(()=>r.proxy);return pt(n,r),n}function z(e){if(e==null||typeof e!="object")return e;let t=e[ae];return t!==void 0?t:e}function yt(e){return Zt(()=>z(e))}function cr(e){return Ie(e)}function lr(e){return Ie(e)?e[U]:null}function pr(e){return e&&typeof e=="object"&&U in e?e[U]:null}function Ie(e){return!!e&&typeof e=="object"&&(_e in e||e.__proxy===!0)}function fr(e){return e}var dr=Object.freeze({createStore:ft,createMutableStore:dt,batch:it,unwrap:z,untrackStore:yt});function De(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(De);let t={};for(let r of Object.keys(e))t[r]=De(e[r]);return t}function yr(e){return t=>{let r=De(t);return e(r),r}}function hr(e,t={}){return()=>e}export{er as $NAME,U as $NODE,on as $PROXY,ae as $RAW,Ee as $SELF,nn as $SIGNAL,tr as $STORE,ke as $TRACK,M as Observable,ce as SafeSubscriber,Qt as Signal,R as Store,dr as StoreAPI,Ne as Subject,q as Subscriber,N as Subscription,ge as SuspenseContext,de as __DEV__,O as batch,At as createComputed,sr as createComputedStore,V as createContext,Kt as createDebounce,Vt as createDeferred,I as createEffect,Xt as createErrorBoundary,v as createMemo,dt as createMutableStore,_t as createRenderEffect,Ht as createResource,C as createRoot,Lt as createSelector,f as createSignal,ft as createStore,ir as createStoreEffect,ar as createStoreMemo,zt as createSuspenseBoundary,Et as flush,lr as getNode,re as getOwner,Se as getServerData,pr as getStoreNode,jr as indexArray,Ut as isComponent,It as isMemo,vt as isOwnerDisposed,jt as isProvider,Dt as isResource,ye as isSignal,cr as isStore,Ie as isStoreProxy,Bt as isSuspense,Br as keyArray,Je as makeArrayFlat,Ur as mapArray,fr as modifiable,xe as nextResourceId,kt as on,m as onCleanup,Sr as operate,yr as produceUtil,K as provide,Jt as provideErrorBoundary,Yt as provideSuspense,Gt as readChildren,hr as reconcileUtil,we as reportResourceData,G as runWithOwner,We as setOwner,$t as setResourceDataSink,Mt as setResourceIdSource,Nt as setResourceTracker,qt as setServerDataGetter,Xe as startTransition,ve as trackResourcePromise,g as untrack,yt as untrackStore,z as unwrap,St as useContext,Rt as useTransition,ur as wrap};
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!G.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(o=W(t,s))||o.enumerable});return e};var F=e=>V(b({},"__esModule",{value:!0}),e);var se={};j(se,{batch:()=>ee,createComputed:()=>X,createEffect:()=>Q,createMemo:()=>J,createRenderEffect:()=>Z,createRoot:()=>A,createSignal:()=>B,flush:()=>re,flushSync:()=>d,getOwner:()=>y,on:()=>oe,onCleanup:()=>D,runWithOwner:()=>h,setOwner:()=>P,startTransition:()=>M,untrack:()=>te,useTransition:()=>ne});module.exports=F(se);var H="__fluixi_signal_next_state__",K=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},r=globalThis[H]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:K,onSuspend:null,onError:null};var k=0,O=1,f=2,p=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))}},w=class extends p{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(f);x(this)}}peek(){return this._value}},c=class extends p{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=f;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===O&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===f)break}(this.state===f||!this._initialized)&&this.recompute(),this.state=k}recompute(){if(this.sources){for(let l of this.sources)l.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(l){i=!0,u=l,s=this._value}finally{r.consumer=n,r.untracked=o}let a=!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,a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(f);x(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===k;if(this.state=n,o){if(this.observers)for(let s of[...this.observers])s.markDirty(O);x(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function x(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var v=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 S(e){if(r.untracked)return e();r.untracked=!0;try{return e()}finally{r.untracked=!1}}function q(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function C(e){return r.onSuspend?(r.onSuspend(e,r.owner),!0):!1}function y(){return r.owner}function P(e){let t=r.owner;return r.owner=e,t}function h(e,t){let n=r.owner;r.owner=e;try{return t()}finally{r.owner=n}}function D(e){r.owner&&(r.owner.cleanups??=[]).push(e)}function T(e){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)T(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}}function A(e){let t=q(r.owner);r.owner&&(r.owner.owned??=[]).push(t);let n=r.owner;r.owner=t;try{return e(()=>T(t))}finally{r.owner=n}}function E(e){r.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function L(e){e.queued||(e.queued=!0,r.queue.push(e),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(d)))}function d(){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 R(){r.batchDepth===0&&d()}function g(e){r.batchDepth++;try{return e()}finally{--r.batchDepth===0&&d()}}var _=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=q(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{T(this.owner),h(this.owner,()=>{let n=t();typeof n=="function"&&(this.owner.cleanups??=[]).push(n)})}),this.watcher=new v(()=>L(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),T(this.owner))}};function m(e){let t=new _(e);return()=>t.dispose()}function Y(e){return!!e&&typeof e.then=="function"}E(()=>{});var N=Symbol.for("signal"),$=Symbol.for("memo"),U=Symbol.for("signal-node");function B(e,t){let n=new w(e,{equals:t?.equals}),o=(()=>n.get()),s=(i=>{let u=typeof i=="function"?i(n.peek()):i;return n.set(u),R(),u});return Object.defineProperty(o,N,{value:!0,enumerable:!0}),Object.defineProperty(o,U,{value:{get value(){return n.peek()},get version(){return n.version}},enumerable:!1}),[o,s]}function J(e,t,n){let o=t,s=y(),i=new c(()=>h(s,()=>{try{return o=e(o)}catch(a){if(Y(a))return C(a),o;throw a}}),{equals:n?.equals}),u=(()=>i.get());return Object.defineProperty(u,N,{value:!0,enumerable:!0}),Object.defineProperty(u,$,{value:!0,enumerable:!0}),u}function Q(e,t){let n=t;return m(()=>{n=e(n)})}function X(e,t){let n=t;m(()=>{n=e(n)})}function Z(e,t){let n=t;return m(()=>{n=e(n)})}function ee(e){return g(e)}function te(e){return S(e)}function M(e){return g(e),Promise.resolve()}function ne(){return[()=>!1,M]}function re(){return d(),Promise.resolve()}function oe(e,t,n){let o=Array.isArray(e),s,i=n?.defer??!1;return u=>{let a=o?e.map(I=>I()):e();if(i){i=!1,s=a;return}let l=S(()=>t(a,s,u));return s=a,l}}
1
+ "use strict";var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},V=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of z(t))!G.call(e,s)&&s!==r&&b(e,s,{get:()=>t[s],enumerable:!(o=W(t,s))||o.enumerable});return e};var F=e=>V(b({},"__esModule",{value:!0}),e);var se={};j(se,{batch:()=>ee,createComputed:()=>X,createEffect:()=>Q,createMemo:()=>J,createRenderEffect:()=>Z,createRoot:()=>A,createSignal:()=>B,flush:()=>ne,flushSync:()=>d,getOwner:()=>y,on:()=>oe,onCleanup:()=>P,runWithOwner:()=>h,setOwner:()=>D,startTransition:()=>M,untrack:()=>te,useTransition:()=>re});module.exports=F(se);var H="__fluixi_signal_next_state__",K=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[H]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:K,onSuspend:null,onError:null};var k=0,O=1,f=2,p=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let t=n.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},w=class extends p{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(f);x(this)}}peek(){return this._value}},c=class extends p{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=f;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(n.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===O&&this.sources){for(let r of this.sources)if(r.updateIfNecessary(),this.state===f)break}(this.state===f||!this._initialized)&&this.recompute(),this.state=k}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked;n.consumer=this,n.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{n.consumer=r,n.untracked=o}let a=!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,a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(f);x(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===k;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(O);x(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function x(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var v=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 S(e){if(n.untracked)return e();n.untracked=!0;try{return e()}finally{n.untracked=!1}}function q(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function C(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function y(){return n.owner}function D(e){let t=n.owner;return n.owner=e,t}function h(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function P(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function T(e,t=!0){if(!e.disposed){if(e.owned){for(let r=e.owned.length-1;r>=0;r--)T(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 A(e){let t=q(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>T(t))}finally{n.owner=r}}function E(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function L(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(d)))}function d(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=n.queue;n.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{n.flushing=!1}}function R(){n.batchDepth===0&&d()}function g(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&d()}}var _=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=q(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{T(this.owner,!1),h(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new v(()=>L(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"&&n.onSuspend){n.onSuspend(t,this.owner);return}if(n.onError&&n.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),T(this.owner))}};function m(e){let t=new _(e);return()=>t.dispose()}function Y(e){return!!e&&typeof e.then=="function"}E(()=>{});var N=Symbol.for("signal"),$=Symbol.for("memo"),U=Symbol.for("signal-node");function B(e,t){let r=new w(e,{equals:t?.equals}),o=(()=>r.get()),s=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),R(),u});return Object.defineProperty(o,N,{value:!0,enumerable:!0}),Object.defineProperty(o,U,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[o,s]}function J(e,t,r){let o=t,s=y(),i=new c(()=>h(s,()=>{try{return o=e(o)}catch(a){if(Y(a))return C(a),o;throw a}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,N,{value:!0,enumerable:!0}),Object.defineProperty(u,$,{value:!0,enumerable:!0}),u}function Q(e,t){let r=t;return m(()=>{r=e(r)})}function X(e,t){let r=t;m(()=>{r=e(r)})}function Z(e,t){let r=t;return m(()=>{r=e(r)})}function ee(e){return g(e)}function te(e){return S(e)}function M(e){return g(e),Promise.resolve()}function re(){return[()=>!1,M]}function ne(){return d(),Promise.resolve()}function oe(e,t,r){let o=Array.isArray(e),s,i=r?.defer??!1;return u=>{let a=o?e.map(I=>I()):e();if(i){i=!1,s=a;return}let l=S(()=>t(a,s,u));return s=a,l}}
@@ -1 +1 @@
1
- var E="__fluixi_signal_next_state__",R=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:R,onSuspend:null,onError:null};var g=0,k=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let t=n.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}},p=class extends h{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(d);m(this)}}peek(){return this._value}},c=class extends h{constructor(r,o){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=r,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(n.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 r of this.sources)if(r.updateIfNecessary(),this.state===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=g}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let r=n.consumer,o=n.untracked;n.consumer=this,n.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{n.consumer=r,n.untracked=o}let a=!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,a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(d);m(this)}}markDirty(r){if(this.state>=r)return;let o=this.state===g;if(this.state=r,o){if(this.observers)for(let s of[...this.observers])s.markDirty(k);m(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function m(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}var w=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 b(e){if(n.untracked)return e();n.untracked=!0;try{return e()}finally{n.untracked=!1}}function O(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function S(){return n.owner}function N(e){let t=n.owner;return n.owner=e,t}function T(e,t){let r=n.owner;n.owner=e;try{return t()}finally{n.owner=r}}function M(e){n.owner&&(n.owner.cleanups??=[]).push(e)}function v(e){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}}function I(e){let t=O(n.owner);n.owner&&(n.owner.owned??=[]).push(t);let r=n.owner;n.owner=t;try{return e(()=>v(t))}finally{n.owner=r}}function C(e){n.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function W(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(f)))}function f(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=n.queue;n.queue=[];for(let r of t)r.queued=!1,r.disposed||r.run()}}finally{n.flushing=!1}}function P(){n.batchDepth===0&&f()}function _(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&f()}}var x=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=O(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{v(this.owner),T(this.owner,()=>{let r=t();typeof r=="function"&&(this.owner.cleanups??=[]).push(r)})}),this.watcher=new w(()=>W(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"&&n.onSuspend){n.onSuspend(t,this.owner);return}if(n.onError&&n.onError(t,this.owner))return;throw t}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),v(this.owner))}};function y(e){let t=new x(e);return()=>t.dispose()}function z(e){return!!e&&typeof e.then=="function"}C(()=>{});var D=Symbol.for("signal"),G=Symbol.for("memo"),j=Symbol.for("signal-node");function J(e,t){let r=new p(e,{equals:t?.equals}),o=(()=>r.get()),s=(i=>{let u=typeof i=="function"?i(r.peek()):i;return r.set(u),P(),u});return Object.defineProperty(o,D,{value:!0,enumerable:!0}),Object.defineProperty(o,j,{value:{get value(){return r.peek()},get version(){return r.version}},enumerable:!1}),[o,s]}function Q(e,t,r){let o=t,s=S(),i=new c(()=>T(s,()=>{try{return o=e(o)}catch(a){if(z(a))return q(a),o;throw a}}),{equals:r?.equals}),u=(()=>i.get());return Object.defineProperty(u,D,{value:!0,enumerable:!0}),Object.defineProperty(u,G,{value:!0,enumerable:!0}),u}function X(e,t){let r=t;return y(()=>{r=e(r)})}function Z(e,t){let r=t;y(()=>{r=e(r)})}function ee(e,t){let r=t;return y(()=>{r=e(r)})}function te(e){return _(e)}function ne(e){return b(e)}function V(e){return _(e),Promise.resolve()}function re(){return[()=>!1,V]}function oe(){return f(),Promise.resolve()}function se(e,t,r){let o=Array.isArray(e),s,i=r?.defer??!1;return u=>{let a=o?e.map(A=>A()):e();if(i){i=!1,s=a;return}let l=b(()=>t(a,s,u));return s=a,l}}export{te as batch,Z as createComputed,X as createEffect,Q as createMemo,ee as createRenderEffect,I as createRoot,J as createSignal,oe as flush,f as flushSync,S as getOwner,se as on,M as onCleanup,T as runWithOwner,N as setOwner,V as startTransition,ne as untrack,re as useTransition};
1
+ var E="__fluixi_signal_next_state__",R=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},n=globalThis[E]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:R,onSuspend:null,onError:null};var g=0,k=1,d=2,h=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let r=n.consumer;r&&((this.observers??=new Set).add(r),(r.sources??=new Set).add(this))}},p=class extends h{constructor(r,t){super(),this._value=r,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(r){if(!this._equals(this._value,r)){if(this._value=r,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(d);m(this)}}peek(){return this._value}},c=class extends h{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=d;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(n.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===d)break}(this.state===d||!this._initialized)&&this.recompute(),this.state=g}recompute(){if(this.sources){for(let l of this.sources)l.observers?.delete(this);this.sources.clear()}let t=n.consumer,o=n.untracked;n.consumer=this,n.untracked=!1;let s,i=!1,u;try{s=this._fn()}catch(l){i=!0,u=l,s=this._value}finally{n.consumer=t,n.untracked=o}let a=!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,a){if(this.version++,this.observers)for(let l of[...this.observers])l.markDirty(d);m(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===g;if(this.state=t,o){if(this.observers)for(let s of[...this.observers])s.markDirty(k);m(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function m(e){if(e.watchers)for(let r of[...e.watchers])r._notify(e)}var w=class{constructor(r){this._watched=new Set;this._pending=new Set;this._notifyFn=r}watch(...r){for(let t of r)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...r){for(let t of r)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let r=[...this._pending];return this._pending.clear(),r}_notify(r){if(!this._watched.has(r)||this._pending.has(r))return;let t=this._pending.size===0;this._pending.add(r),t&&this._notifyFn()}};function b(e){if(n.untracked)return e();n.untracked=!0;try{return e()}finally{n.untracked=!1}}function O(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function q(e){return n.onSuspend?(n.onSuspend(e,n.owner),!0):!1}function S(){return n.owner}function N(e){let r=n.owner;return n.owner=e,r}function T(e,r){let t=n.owner;n.owner=e;try{return r()}finally{n.owner=t}}function M(e){if(n.owner){if(n.owner.disposed){e();return}(n.owner.cleanups??=[]).push(e)}}function v(e,r=!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}r&&(e.disposed=!0)}}function I(e){let r=O(n.owner);n.owner&&(n.owner.owned??=[]).push(r);let t=n.owner;n.owner=r;try{return e(()=>v(r))}finally{n.owner=t}}function C(e){n.hostSchedule=e??(r=>{Promise.resolve().then(r)})}function W(e){e.queued||(e.queued=!0,n.queue.push(e),!n.scheduled&&n.batchDepth===0&&(n.scheduled=!0,n.hostSchedule(f)))}function f(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let e=0;try{for(;n.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let r=n.queue;n.queue=[];for(let t of r)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function D(){n.batchDepth===0&&f()}function _(e){n.batchDepth++;try{return e()}finally{--n.batchDepth===0&&f()}}var x=class{constructor(r){this.queued=!1;this.disposed=!1;this.owner=O(n.owner),n.owner&&(n.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new c(()=>{v(this.owner,!1),T(this.owner,()=>{let t=r();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new w(()=>W(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(r){if(r&&typeof r.then=="function"&&n.onSuspend){n.onSuspend(r,this.owner);return}if(n.onError&&n.onError(r,this.owner))return;throw r}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),v(this.owner))}};function y(e){let r=new x(e);return()=>r.dispose()}function z(e){return!!e&&typeof e.then=="function"}C(()=>{});var P=Symbol.for("signal"),G=Symbol.for("memo"),j=Symbol.for("signal-node");function J(e,r){let t=new p(e,{equals:r?.equals}),o=(()=>t.get()),s=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),D(),u});return Object.defineProperty(o,P,{value:!0,enumerable:!0}),Object.defineProperty(o,j,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}function Q(e,r,t){let o=r,s=S(),i=new c(()=>T(s,()=>{try{return o=e(o)}catch(a){if(z(a))return q(a),o;throw a}}),{equals:t?.equals}),u=(()=>i.get());return Object.defineProperty(u,P,{value:!0,enumerable:!0}),Object.defineProperty(u,G,{value:!0,enumerable:!0}),u}function X(e,r){let t=r;return y(()=>{t=e(t)})}function Z(e,r){let t=r;y(()=>{t=e(t)})}function ee(e,r){let t=r;return y(()=>{t=e(t)})}function te(e){return _(e)}function re(e){return b(e)}function V(e){return _(e),Promise.resolve()}function ne(){return[()=>!1,V]}function oe(){return f(),Promise.resolve()}function se(e,r,t){let o=Array.isArray(e),s,i=t?.defer??!1;return u=>{let a=o?e.map(A=>A()):e();if(i){i=!1,s=a;return}let l=b(()=>r(a,s,u));return s=a,l}}export{te as batch,Z as createComputed,X as createEffect,Q as createMemo,ee as createRenderEffect,I as createRoot,J as createSignal,oe as flush,f as flushSync,S as getOwner,se as on,M as onCleanup,T as runWithOwner,N as setOwner,V as startTransition,re as untrack,ne as useTransition};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var E=(n,e)=>{for(var t in e)w(n,t,{get:e[t],enumerable:!0})},N=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!A.call(n,o)&&o!==t&&w(n,o,{get:()=>e[o],enumerable:!(s=D(e,o))||s.enumerable});return n};var R=n=>N(w({},"__esModule",{value:!0}),n);var H={};E(H,{createDebounce:()=>V,createDeferred:()=>L,createSelector:()=>U});module.exports=R(H);var M="__fluixi_signal_next_state__",I=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},r=globalThis[M]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:I,onSuspend:null,onError:null};var _=0,k=1,c=2,f=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let e=r.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},p=class extends f{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(c);v(this)}}peek(){return this._value}},d=class extends f{constructor(t,s){super();this._threw=!1;this._initialized=!1;this.state=c;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===c)break}(this.state===c||!this._initialized)&&this.recompute(),this.state=_}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(c);v(this)}}markDirty(t){if(this.state>=t)return;let s=this.state===_;if(this.state=t,s){if(this.observers)for(let o of[...this.observers])o.markDirty(k);v(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function v(n){if(n.watchers)for(let e of[...n.watchers])e._notify(n)}var h=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let t of e)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...e){for(let t of e)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let t=this._pending.size===0;this._pending.add(e),t&&this._notifyFn()}};function j(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function y(n,e){let t=r.owner;r.owner=n;try{return e()}finally{r.owner=t}}function b(n){r.owner&&(r.owner.cleanups??=[]).push(n)}function T(n){if(n.owned){for(let e=n.owned.length-1;e>=0;e--)T(n.owned[e]);n.owned=null}if(n.cleanups){for(let e=n.cleanups.length-1;e>=0;e--)n.cleanups[e]();n.cleanups=null}}function O(n){r.hostSchedule=n??(e=>{Promise.resolve().then(e)})}function W(n){n.queued||(n.queued=!0,r.queue.push(n),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(g)))}function g(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let n=0;try{for(;r.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=r.queue;r.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function q(){r.batchDepth===0&&g()}var m=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=j(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new d(()=>{T(this.owner),y(this.owner,()=>{let t=e();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new h(()=>W(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&r.onSuspend){r.onSuspend(e,this.owner);return}if(r.onError&&r.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),T(this.owner))}};function C(n){let e=new m(n);return()=>e.dispose()}O(()=>{});var G=Symbol.for("signal");var F=Symbol.for("signal-node");function x(n,e){let t=new p(n,{equals:e?.equals}),s=(()=>t.get()),o=(i=>{let u=typeof i=="function"?i(t.peek()):i;return t.set(u),q(),u});return Object.defineProperty(s,G,{value:!0,enumerable:!0}),Object.defineProperty(s,F,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[s,o]}function S(n,e){let t=e;return C(()=>{t=n(t)})}function U(n,e=(t,s)=>t===s){let t=new Map;return S(()=>{let s=n();for(let[o,i]of t){let[u,l]=i,a=e(o,s);u()!==a&&l(a)}}),s=>{let o=t.get(s);if(!o){let[i,u]=x(!1);o=[i,u],t.set(s,o);let l=n();u(e(s,l))}return o[0]()}}function L(n,e){let[t,s]=x(n(),e);return S(()=>{let o=n();e?.timeoutMs?setTimeout(()=>s(()=>o),e.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>s(()=>o)):Promise.resolve().then(()=>s(()=>o))}),t}function V(n,e){let t,s=(...o)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{if(t=void 0,o.length>0){let i=o[o.length-1];typeof i=="object"&&i&&!i.tagName&&i.target&&i.target.tagName&&(i=i.target),i&&typeof i=="object"&&i.tagName&&(i.tagName.toLowerCase()==="input"||i.tagName.toLowerCase()==="textarea")&&i.focus()}n(...o)},e)};return b(()=>{t!==void 0&&clearTimeout(t)}),s}
1
+ "use strict";var w=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var e in t)w(n,e,{get:t[e],enumerable:!0})},N=(n,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of P(t))!A.call(n,o)&&o!==e&&w(n,o,{get:()=>t[o],enumerable:!(s=D(t,o))||s.enumerable});return n};var R=n=>N(w({},"__esModule",{value:!0}),n);var H={};E(H,{createDebounce:()=>V,createDeferred:()=>L,createSelector:()=>U});module.exports=R(H);var M="__fluixi_signal_next_state__",I=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},r=globalThis[M]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:I,onSuspend:null,onError:null};var _=0,k=1,c=2,f=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))}},p=class extends f{constructor(t,e){super(),this._value=t,this._equals=e?.equals===!1?()=>!1:e?.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 e of[...this.observers])e.markDirty(c);v(this)}}peek(){return this._value}},d=class extends f{constructor(e,s){super();this._threw=!1;this._initialized=!1;this.state=c;this.sources=null;this._fn=e,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 e of this.sources)if(e.updateIfNecessary(),this.state===c)break}(this.state===c||!this._initialized)&&this.recompute(),this.state=_}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let e=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=e,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(c);v(this)}}markDirty(e){if(this.state>=e)return;let s=this.state===_;if(this.state=e,s){if(this.observers)for(let o of[...this.observers])o.markDirty(k);v(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function v(n){if(n.watchers)for(let t of[...n.watchers])t._notify(n)}var h=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let e of t)this._watched.add(e),(e.watchers??=new Set).add(this)}unwatch(...t){for(let e of t)this._watched.delete(e),e.watchers?.delete(this),this._pending.delete(e)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let e=this._pending.size===0;this._pending.add(t),e&&this._notifyFn()}};function j(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function y(n,t){let e=r.owner;r.owner=n;try{return t()}finally{r.owner=e}}function b(n){if(r.owner){if(r.owner.disposed){n();return}(r.owner.cleanups??=[]).push(n)}}function T(n,t=!0){if(!n.disposed){if(n.owned){for(let e=n.owned.length-1;e>=0;e--)T(n.owned[e]);n.owned=null}if(n.cleanups){for(let e=n.cleanups.length-1;e>=0;e--)n.cleanups[e]();n.cleanups=null}t&&(n.disposed=!0)}}function O(n){r.hostSchedule=n??(t=>{Promise.resolve().then(t)})}function W(n){n.queued||(n.queued=!0,r.queue.push(n),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(g)))}function g(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let n=0;try{for(;r.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let e of t)e.queued=!1,e.disposed||e.run()}}finally{r.flushing=!1}}function q(){r.batchDepth===0&&g()}var m=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=j(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new d(()=>{T(this.owner,!1),y(this.owner,()=>{let e=t();typeof e=="function"&&(this.owner.cleanups??=[]).push(e)})}),this.watcher=new h(()=>W(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),T(this.owner))}};function C(n){let t=new m(n);return()=>t.dispose()}O(()=>{});var G=Symbol.for("signal");var F=Symbol.for("signal-node");function x(n,t){let e=new p(n,{equals:t?.equals}),s=(()=>e.get()),o=(i=>{let u=typeof i=="function"?i(e.peek()):i;return e.set(u),q(),u});return Object.defineProperty(s,G,{value:!0,enumerable:!0}),Object.defineProperty(s,F,{value:{get value(){return e.peek()},get version(){return e.version}},enumerable:!1}),[s,o]}function S(n,t){let e=t;return C(()=>{e=n(e)})}function U(n,t=(e,s)=>e===s){let e=new Map;return S(()=>{let s=n();for(let[o,i]of e){let[u,l]=i,a=t(o,s);u()!==a&&l(a)}}),s=>{let o=e.get(s);if(!o){let[i,u]=x(!1);o=[i,u],e.set(s,o);let l=n();u(t(s,l))}return o[0]()}}function L(n,t){let[e,s]=x(n(),t);return S(()=>{let o=n();t?.timeoutMs?setTimeout(()=>s(()=>o),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>s(()=>o)):Promise.resolve().then(()=>s(()=>o))}),e}function V(n,t){let e,s=(...o)=>{e!==void 0&&clearTimeout(e),e=setTimeout(()=>{if(e=void 0,o.length>0){let i=o[o.length-1];typeof i=="object"&&i&&!i.tagName&&i.target&&i.target.tagName&&(i=i.target),i&&typeof i=="object"&&i.tagName&&(i.tagName.toLowerCase()==="input"||i.tagName.toLowerCase()==="textarea")&&i.focus()}n(...o)},t)};return b(()=>{e!==void 0&&clearTimeout(e)}),s}
@@ -1 +1 @@
1
- var C="__fluixi_signal_next_state__",D=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},r=globalThis[C]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var S=0,_=1,c=2,f=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(r.untracked)return;let e=r.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},p=class extends f{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(c);w(this)}}peek(){return this._value}},d=class extends f{constructor(t,s){super();this._threw=!1;this._initialized=!1;this.state=c;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===_&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===c)break}(this.state===c||!this._initialized)&&this.recompute(),this.state=S}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 i,o=!1,u;try{i=this._fn()}catch(a){o=!0,u=a,i=this._value}finally{r.consumer=t,r.untracked=s}let l=!this._initialized||this._threw!==o||(o?u!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=o,this._error=u,this._value=i,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(c);w(this)}}markDirty(t){if(this.state>=t)return;let s=this.state===S;if(this.state=t,s){if(this.observers)for(let i of[...this.observers])i.markDirty(_);w(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function w(n){if(n.watchers)for(let e of[...n.watchers])e._notify(n)}var h=class{constructor(e){this._watched=new Set;this._pending=new Set;this._notifyFn=e}watch(...e){for(let t of e)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...e){for(let t of e)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let e=[...this._pending];return this._pending.clear(),e}_notify(e){if(!this._watched.has(e)||this._pending.has(e))return;let t=this._pending.size===0;this._pending.add(e),t&&this._notifyFn()}};function P(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function m(n,e){let t=r.owner;r.owner=n;try{return e()}finally{r.owner=t}}function y(n){r.owner&&(r.owner.cleanups??=[]).push(n)}function v(n){if(n.owned){for(let e=n.owned.length-1;e>=0;e--)v(n.owned[e]);n.owned=null}if(n.cleanups){for(let e=n.cleanups.length-1;e>=0;e--)n.cleanups[e]();n.cleanups=null}}function k(n){r.hostSchedule=n??(e=>{Promise.resolve().then(e)})}function A(n){n.queued||(n.queued=!0,r.queue.push(n),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(b)))}function b(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let n=0;try{for(;r.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=r.queue;r.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{r.flushing=!1}}function O(){r.batchDepth===0&&b()}var T=class{constructor(e){this.queued=!1;this.disposed=!1;this.owner=P(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new d(()=>{v(this.owner),m(this.owner,()=>{let t=e();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new h(()=>A(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(e){if(e&&typeof e.then=="function"&&r.onSuspend){r.onSuspend(e,this.owner);return}if(r.onError&&r.onError(e,this.owner))return;throw e}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),v(this.owner))}};function q(n){let e=new T(n);return()=>e.dispose()}k(()=>{});var N=Symbol.for("signal");var R=Symbol.for("signal-node");function g(n,e){let t=new p(n,{equals:e?.equals}),s=(()=>t.get()),i=(o=>{let u=typeof o=="function"?o(t.peek()):o;return t.set(u),O(),u});return Object.defineProperty(s,N,{value:!0,enumerable:!0}),Object.defineProperty(s,R,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[s,i]}function x(n,e){let t=e;return q(()=>{t=n(t)})}function Q(n,e=(t,s)=>t===s){let t=new Map;return x(()=>{let s=n();for(let[i,o]of t){let[u,l]=o,a=e(i,s);u()!==a&&l(a)}}),s=>{let i=t.get(s);if(!i){let[o,u]=g(!1);i=[o,u],t.set(s,i);let l=n();u(e(s,l))}return i[0]()}}function X(n,e){let[t,s]=g(n(),e);return x(()=>{let i=n();e?.timeoutMs?setTimeout(()=>s(()=>i),e.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>s(()=>i)):Promise.resolve().then(()=>s(()=>i))}),t}function Z(n,e){let t,s=(...i)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{if(t=void 0,i.length>0){let o=i[i.length-1];typeof o=="object"&&o&&!o.tagName&&o.target&&o.target.tagName&&(o=o.target),o&&typeof o=="object"&&o.tagName&&(o.tagName.toLowerCase()==="input"||o.tagName.toLowerCase()==="textarea")&&o.focus()}n(...i)},e)};return y(()=>{t!==void 0&&clearTimeout(t)}),s}export{Z as createDebounce,X as createDeferred,Q as createSelector};
1
+ var C="__fluixi_signal_next_state__",D=n=>{typeof queueMicrotask=="function"?queueMicrotask(n):Promise.resolve().then(n)},r=globalThis[C]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:D,onSuspend:null,onError:null};var S=0,_=1,c=2,f=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))}},p=class extends f{constructor(t,e){super(),this._value=t,this._equals=e?.equals===!1?()=>!1:e?.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 e of[...this.observers])e.markDirty(c);w(this)}}peek(){return this._value}},d=class extends f{constructor(e,s){super();this._threw=!1;this._initialized=!1;this.state=c;this.sources=null;this._fn=e,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===_&&this.sources){for(let e of this.sources)if(e.updateIfNecessary(),this.state===c)break}(this.state===c||!this._initialized)&&this.recompute(),this.state=S}recompute(){if(this.sources){for(let a of this.sources)a.observers?.delete(this);this.sources.clear()}let e=r.consumer,s=r.untracked;r.consumer=this,r.untracked=!1;let i,o=!1,u;try{i=this._fn()}catch(a){o=!0,u=a,i=this._value}finally{r.consumer=e,r.untracked=s}let l=!this._initialized||this._threw!==o||(o?u!==this._error:!this._equals(this._value,i));if(this._initialized=!0,this._threw=o,this._error=u,this._value=i,l){if(this.version++,this.observers)for(let a of[...this.observers])a.markDirty(c);w(this)}}markDirty(e){if(this.state>=e)return;let s=this.state===S;if(this.state=e,s){if(this.observers)for(let i of[...this.observers])i.markDirty(_);w(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function w(n){if(n.watchers)for(let t of[...n.watchers])t._notify(n)}var h=class{constructor(t){this._watched=new Set;this._pending=new Set;this._notifyFn=t}watch(...t){for(let e of t)this._watched.add(e),(e.watchers??=new Set).add(this)}unwatch(...t){for(let e of t)this._watched.delete(e),e.watchers?.delete(this),this._pending.delete(e)}getPending(){let t=[...this._pending];return this._pending.clear(),t}_notify(t){if(!this._watched.has(t)||this._pending.has(t))return;let e=this._pending.size===0;this._pending.add(t),e&&this._notifyFn()}};function P(n){return{cleanups:null,owned:null,parent:n,contexts:null}}function m(n,t){let e=r.owner;r.owner=n;try{return t()}finally{r.owner=e}}function y(n){if(r.owner){if(r.owner.disposed){n();return}(r.owner.cleanups??=[]).push(n)}}function v(n,t=!0){if(!n.disposed){if(n.owned){for(let e=n.owned.length-1;e>=0;e--)v(n.owned[e]);n.owned=null}if(n.cleanups){for(let e=n.cleanups.length-1;e>=0;e--)n.cleanups[e]();n.cleanups=null}t&&(n.disposed=!0)}}function k(n){r.hostSchedule=n??(t=>{Promise.resolve().then(t)})}function A(n){n.queued||(n.queued=!0,r.queue.push(n),!r.scheduled&&r.batchDepth===0&&(r.scheduled=!0,r.hostSchedule(b)))}function b(){if(r.scheduled=!1,r.flushing)return;r.flushing=!0;let n=0;try{for(;r.queue.length;){if(++n>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let t=r.queue;r.queue=[];for(let e of t)e.queued=!1,e.disposed||e.run()}}finally{r.flushing=!1}}function O(){r.batchDepth===0&&b()}var T=class{constructor(t){this.queued=!1;this.disposed=!1;this.owner=P(r.owner),r.owner&&(r.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new d(()=>{v(this.owner,!1),m(this.owner,()=>{let e=t();typeof e=="function"&&(this.owner.cleanups??=[]).push(e)})}),this.watcher=new h(()=>A(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),v(this.owner))}};function q(n){let t=new T(n);return()=>t.dispose()}k(()=>{});var N=Symbol.for("signal");var R=Symbol.for("signal-node");function g(n,t){let e=new p(n,{equals:t?.equals}),s=(()=>e.get()),i=(o=>{let u=typeof o=="function"?o(e.peek()):o;return e.set(u),O(),u});return Object.defineProperty(s,N,{value:!0,enumerable:!0}),Object.defineProperty(s,R,{value:{get value(){return e.peek()},get version(){return e.version}},enumerable:!1}),[s,i]}function x(n,t){let e=t;return q(()=>{e=n(e)})}function Q(n,t=(e,s)=>e===s){let e=new Map;return x(()=>{let s=n();for(let[i,o]of e){let[u,l]=o,a=t(i,s);u()!==a&&l(a)}}),s=>{let i=e.get(s);if(!i){let[o,u]=g(!1);i=[o,u],e.set(s,i);let l=n();u(t(s,l))}return i[0]()}}function X(n,t){let[e,s]=g(n(),t);return x(()=>{let i=n();t?.timeoutMs?setTimeout(()=>s(()=>i),t.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>s(()=>i)):Promise.resolve().then(()=>s(()=>i))}),e}function Z(n,t){let e,s=(...i)=>{e!==void 0&&clearTimeout(e),e=setTimeout(()=>{if(e=void 0,i.length>0){let o=i[i.length-1];typeof o=="object"&&o&&!o.tagName&&o.target&&o.target.tagName&&(o=o.target),o&&typeof o=="object"&&o.tagName&&(o.tagName.toLowerCase()==="input"||o.tagName.toLowerCase()==="textarea")&&o.focus()}n(...i)},t)};return y(()=>{e!==void 0&&clearTimeout(e)}),s}export{Z as createDebounce,X as createDeferred,Q as createSelector};
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},g=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!_.call(r,s)&&s!==t&&a(r,s,{get:()=>e[s],enumerable:!(o=x(e,s))||o.enumerable});return r};var O=r=>g(a({},"__esModule",{value:!0}),r);var I={};k(I,{ErrorContext:()=>c,createErrorBoundary:()=>R,provideErrorBoundary:()=>N});module.exports=O(I);var q="__fluixi_signal_next_state__",E=r=>{typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)},n=globalThis[q]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:E,onSuspend:null,onError:null};var C=2,l=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let e=n.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},u=class extends l{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(C);P(this)}}peek(){return this._value}};function P(r){if(r.watchers)for(let e of[...r.watchers])e._notify(r)}function f(r){return{cleanups:null,owned:null,parent:r,contexts:null}}function h(r){let e=Symbol("context");return{id:e,defaultValue:r,Provider:o=>{let s=n.owner,i=f(s);(i.contexts=new Map).set(e,o.value),s&&(s.owned??=[]).push(i),n.owner=i;try{return o.children}finally{n.owner=s}}}}function p(r,e){let t=r;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function w(r,e,t){let o=f(n.owner);(o.contexts=new Map).set(r.id,e),n.owner&&(n.owner.owned??=[]).push(o);let s=n.owner;n.owner=o;try{return t()}finally{n.owner=s}}function v(r){n.onError=r}function T(r){n.hostSchedule=r??(e=>{Promise.resolve().then(e)})}function y(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let r=0;try{for(;n.queue.length;){if(++r>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=n.queue;n.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function m(){n.batchDepth===0&&y()}T(()=>{});var D=Symbol.for("signal");var A=Symbol.for("signal-node");function b(r,e){let t=new u(r,{equals:e?.equals}),o=(()=>t.get()),s=(i=>{let d=typeof i=="function"?i(t.peek()):i;return t.set(d),m(),d});return Object.defineProperty(o,D,{value:!0,enumerable:!0}),Object.defineProperty(o,A,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}var c=h();v((r,e)=>{let t=p(e,c);return t?(t.setError(r),!0):!1});function R(){let[r,e]=b(void 0,{equals:!1});return{error:r,reset:()=>e(()=>{}),setError:o=>e(()=>o)}}function N(r,e){return w(c,r,e)}
1
+ "use strict";var a=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var k=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},g=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!_.call(r,s)&&s!==t&&a(r,s,{get:()=>e[s],enumerable:!(o=x(e,s))||o.enumerable});return r};var O=r=>g(a({},"__esModule",{value:!0}),r);var I={};k(I,{ErrorContext:()=>c,createErrorBoundary:()=>R,provideErrorBoundary:()=>N});module.exports=O(I);var q="__fluixi_signal_next_state__",E=r=>{typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)},n=globalThis[q]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:E,onSuspend:null,onError:null};var C=2,l=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let e=n.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},u=class extends l{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(C);D(this)}}peek(){return this._value}};function D(r){if(r.watchers)for(let e of[...r.watchers])e._notify(r)}function f(r){return{cleanups:null,owned:null,parent:r,contexts:null}}function p(r){let e=Symbol("context");return{id:e,defaultValue:r,Provider:o=>{let s=n.owner,i=f(s);(i.contexts=new Map).set(e,o.value),s&&(s.owned??=[]).push(i),n.owner=i;try{return o.children}finally{n.owner=s}}}}function h(r,e){let t=r;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function w(r,e,t){let o=f(n.owner);(o.contexts=new Map).set(r.id,e),n.owner&&(n.owner.owned??=[]).push(o);let s=n.owner;n.owner=o;try{return t()}finally{n.owner=s}}function v(r){n.onError=r}function T(r){n.hostSchedule=r??(e=>{Promise.resolve().then(e)})}function y(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let r=0;try{for(;n.queue.length;){if(++r>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=n.queue;n.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function m(){n.batchDepth===0&&y()}T(()=>{});var P=Symbol.for("signal");var A=Symbol.for("signal-node");function b(r,e){let t=new u(r,{equals:e?.equals}),o=(()=>t.get()),s=(i=>{let d=typeof i=="function"?i(t.peek()):i;return t.set(d),m(),d});return Object.defineProperty(o,P,{value:!0,enumerable:!0}),Object.defineProperty(o,A,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}var c=p();v((r,e)=>{let t=h(e,c);return t?(t.setError(r),!0):!1});function R(){let[r,e]=b(void 0,{equals:!1});return{error:r,reset:()=>e(()=>{}),setError:o=>e(()=>o)}}function N(r,e){return w(c,r,e)}
@@ -1 +1 @@
1
- var b="__fluixi_signal_next_state__",x=r=>{typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)},n=globalThis[b]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:x,onSuspend:null,onError:null};var S=2,a=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let e=n.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},u=class extends a{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(S);_(this)}}peek(){return this._value}};function _(r){if(r.watchers)for(let e of[...r.watchers])e._notify(r)}function c(r){return{cleanups:null,owned:null,parent:r,contexts:null}}function d(r){let e=Symbol("context");return{id:e,defaultValue:r,Provider:o=>{let s=n.owner,i=c(s);(i.contexts=new Map).set(e,o.value),s&&(s.owned??=[]).push(i),n.owner=i;try{return o.children}finally{n.owner=s}}}}function f(r,e){let t=r;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function h(r,e,t){let o=c(n.owner);(o.contexts=new Map).set(r.id,e),n.owner&&(n.owner.owned??=[]).push(o);let s=n.owner;n.owner=o;try{return t()}finally{n.owner=s}}function p(r){n.onError=r}function w(r){n.hostSchedule=r??(e=>{Promise.resolve().then(e)})}function v(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let r=0;try{for(;n.queue.length;){if(++r>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=n.queue;n.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function T(){n.batchDepth===0&&v()}w(()=>{});var k=Symbol.for("signal");var g=Symbol.for("signal-node");function y(r,e){let t=new u(r,{equals:e?.equals}),o=(()=>t.get()),s=(i=>{let l=typeof i=="function"?i(t.peek()):i;return t.set(l),T(),l});return Object.defineProperty(o,k,{value:!0,enumerable:!0}),Object.defineProperty(o,g,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}var m=d();p((r,e)=>{let t=f(e,m);return t?(t.setError(r),!0):!1});function H(){let[r,e]=y(void 0,{equals:!1});return{error:r,reset:()=>e(()=>{}),setError:o=>e(()=>o)}}function V(r,e){return h(m,r,e)}export{m as ErrorContext,H as createErrorBoundary,V as provideErrorBoundary};
1
+ var b="__fluixi_signal_next_state__",x=r=>{typeof queueMicrotask=="function"?queueMicrotask(r):Promise.resolve().then(r)},n=globalThis[b]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:x,onSuspend:null,onError:null};var S=2,a=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(n.untracked)return;let e=n.consumer;e&&((this.observers??=new Set).add(e),(e.sources??=new Set).add(this))}},u=class extends a{constructor(e,t){super(),this._value=e,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(e){if(!this._equals(this._value,e)){if(this._value=e,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(S);_(this)}}peek(){return this._value}};function _(r){if(r.watchers)for(let e of[...r.watchers])e._notify(r)}function c(r){return{cleanups:null,owned:null,parent:r,contexts:null}}function d(r){let e=Symbol("context");return{id:e,defaultValue:r,Provider:o=>{let s=n.owner,i=c(s);(i.contexts=new Map).set(e,o.value),s&&(s.owned??=[]).push(i),n.owner=i;try{return o.children}finally{n.owner=s}}}}function f(r,e){let t=r;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.parent}return e.defaultValue}function p(r,e,t){let o=c(n.owner);(o.contexts=new Map).set(r.id,e),n.owner&&(n.owner.owned??=[]).push(o);let s=n.owner;n.owner=o;try{return t()}finally{n.owner=s}}function h(r){n.onError=r}function w(r){n.hostSchedule=r??(e=>{Promise.resolve().then(e)})}function v(){if(n.scheduled=!1,n.flushing)return;n.flushing=!0;let r=0;try{for(;n.queue.length;){if(++r>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let e=n.queue;n.queue=[];for(let t of e)t.queued=!1,t.disposed||t.run()}}finally{n.flushing=!1}}function T(){n.batchDepth===0&&v()}w(()=>{});var k=Symbol.for("signal");var g=Symbol.for("signal-node");function y(r,e){let t=new u(r,{equals:e?.equals}),o=(()=>t.get()),s=(i=>{let l=typeof i=="function"?i(t.peek()):i;return t.set(l),T(),l});return Object.defineProperty(o,k,{value:!0,enumerable:!0}),Object.defineProperty(o,g,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,s]}var m=d();h((r,e)=>{let t=f(e,m);return t?(t.setError(r),!0):!1});function H(){let[r,e]=y(void 0,{equals:!1});return{error:r,reset:()=>e(()=>{}),setError:o=>e(()=>o)}}function V(r,e){return p(m,r,e)}export{m as ErrorContext,H as createErrorBoundary,V as provideErrorBoundary};