@fluixi/reactive 1.0.0-alpha.76 → 1.0.0-alpha.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -220
- package/dist/cdn/reactive.cjs +1 -1
- package/dist/cdn/reactive.global.js +1 -1
- package/dist/cdn/reactive.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.mjs +1 -1
- package/dist/lib/observable/index.cjs +1 -1
- package/dist/lib/observable/index.mjs +1 -1
- package/dist/lib/observable/observable.cjs +1 -1
- package/dist/lib/observable/observable.mjs +1 -1
- package/dist/lib/observable/subscription.cjs +1 -1
- package/dist/lib/observable/subscription.d.ts.map +1 -1
- package/dist/lib/observable/subscription.js +1 -2
- package/dist/lib/observable/subscription.mjs +1 -1
- package/dist/lib/predicates.cjs +1 -0
- package/dist/lib/predicates.d.ts +37 -0
- package/dist/lib/predicates.d.ts.map +1 -0
- package/dist/lib/predicates.js +62 -0
- package/dist/lib/predicates.mjs +1 -0
- package/dist/lib/signal/cached-resource.cjs +1 -1
- package/dist/lib/signal/cached-resource.mjs +1 -1
- package/dist/lib/signal/graph/signal-next.d.ts +6 -6
- package/dist/lib/signal/index-legacy.cjs +1 -1
- package/dist/lib/signal/index-legacy.mjs +1 -1
- package/dist/lib/signal/signal.cjs +1 -1
- package/dist/lib/signal/signal.d.ts.map +1 -1
- package/dist/lib/signal/signal.js +16 -1
- package/dist/lib/signal/signal.mjs +1 -1
- package/dist/lib/signal/utilities.cjs +1 -1
- package/dist/lib/signal/utilities.mjs +1 -1
- package/dist/lib/store/setter.types.d.ts +1 -1
- package/dist/lib/store/setter.types.d.ts.map +1 -1
- package/dist/lib/subject.cjs +1 -1
- package/dist/lib/subject.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/version.generated.mjs +1 -1
- package/package.json +16 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var b=(i,r)=>{for(var n in r)e(i,n,{get:r[n],enumerable:!0})},p=(i,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of a(r))!l.call(i,t)&&t!==n&&e(i,t,{get:()=>r[t],enumerable:!(s=u(r,t))||s.enumerable});return i};var h=i=>p(e({},"__esModule",{value:!0}),i);var d={};b(d,{Subscription:()=>c});module.exports=h(d);function o(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function f(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var c=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:n}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let s of r)s.remove(this);if(n){for(let s of n)if(o(s)&&!(s instanceof i))try{s()}catch(t){console.error("Error in unsubscribe function:",t)}else if(f(s)&&typeof s.unsubscribe=="function")try{s.unsubscribe()}catch(t){console.error("Error unsubscribing child:",t)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:n,_subscriptions:s}=this;if(n){if(o(r))try{r()}catch(t){console.error("Error in unsubscribe function:",t)}else if(r.unsubscribe)try{r.unsubscribe()}catch(t){console.error("Error unsubscribing:",t)}return this}return s||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:n}=this;if(!n)return;let s=n.indexOf(r);s!==-1&&(n.splice(s,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(r):this._parentOrParents=[n,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:n}=this;if(n===r)this._parentOrParents=null;else if(Array.isArray(n)){let s=n.indexOf(r);s!==-1&&(n.splice(s,1),n.length===1&&(this._parentOrParents=n[0]))}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/lib/observable/subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/lib/observable/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAiB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAa,YAAW,gBAAgB;IACnD,eAAe,CAAC,OAAO,CAAC,OAAO,CAAS;IACxC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAGxB;IAChB,eAAe,CAAC,OAAO,CAAC,cAAc,CAEtB;IAEhB;;;;OAIG;gBACS,WAAW,CAAC,EAAE,cAAc;IAMxC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;OAKG;IACH,WAAW,IAAI,IAAI;IAuCnB;;;;;;;;OAQG;IACH,GAAG,CAAC,YAAY,EAAE,gBAAgB,GAAG,cAAc,GAAG,IAAI;IA8C1D;;;;;OAKG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAexC,eAAe;IACf,OAAO,CAAC,UAAU;IAWlB,eAAe;IACf,OAAO,CAAC,aAAa;CActB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isObject } from '
|
|
2
|
-
import { isFunction } from '@fluixi/utils/functions';
|
|
1
|
+
import { isObject, isFunction } from '../predicates.js';
|
|
3
2
|
/**
|
|
4
3
|
* Represents a disposable resource, such as the execution of an Observable.
|
|
5
4
|
* This is the primary mechanism for cleaning up Observable executions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(i){return typeof i=="function"&&!/^class\s/.test(Function.prototype.toString.call(i))}function o(i){return i==null||Array.isArray(i)||typeof i=="function"||i instanceof Date||i instanceof RegExp||i instanceof Map||i instanceof Set||i instanceof Error?!1:typeof i=="object"}var c=class i{constructor(r){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;r&&(this._subscriptions=[r])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:r,_subscriptions:n}=this;if(r instanceof i)r.remove(this);else if(r!==null)for(let s of r)s.remove(this);if(n){for(let s of n)if(e(s)&&!(s instanceof i))try{s()}catch(t){console.error("Error in unsubscribe function:",t)}else if(o(s)&&typeof s.unsubscribe=="function")try{s.unsubscribe()}catch(t){console.error("Error unsubscribing child:",t)}this._subscriptions=null}}add(r){if(!r||r===this)return this;if(r.closed)return this;let{_closed:n,_subscriptions:s}=this;if(n){if(e(r))try{r()}catch(t){console.error("Error in unsubscribe function:",t)}else if(r.unsubscribe)try{r.unsubscribe()}catch(t){console.error("Error unsubscribing:",t)}return this}return s||(this._subscriptions=[]),this._subscriptions.push(r),r instanceof i&&r._addParent(this),this}remove(r){let{_subscriptions:n}=this;if(!n)return;let s=n.indexOf(r);s!==-1&&(n.splice(s,1),r._removeParent(this))}_addParent(r){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(r):this._parentOrParents=[n,r]:this._parentOrParents=r}_removeParent(r){let{_parentOrParents:n}=this;if(n===r)this._parentOrParents=null;else if(Array.isArray(n)){let s=n.indexOf(r);s!==-1&&(n.splice(s,1),n.length===1&&(this._parentOrParents=n[0]))}}};export{c as Subscription};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(n,t)=>{for(var r in t)e(n,r,{get:t[r],enumerable:!0})},p=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s(t))!c.call(n,o)&&o!==r&&e(n,o,{get:()=>t[o],enumerable:!(i=f(t,o))||i.enumerable});return n};var a=n=>p(e({},"__esModule",{value:!0}),n);var x={};u(x,{isFunction:()=>y,isObject:()=>k,isPromise:()=>w});module.exports=a(x);function y(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function k(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}function w(n){return n instanceof Promise||!!n&&(typeof n=="object"||typeof n=="function")&&"then"in n}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type predicates this package needs, inlined.
|
|
3
|
+
*
|
|
4
|
+
* They came from `@fluixi/utils`, and the import was the only thing standing between
|
|
5
|
+
* this package and being installable on its own — a signals library that drags a
|
|
6
|
+
* framework's utility package behind it reads as a framework component, whatever the
|
|
7
|
+
* README says. Three predicates are not worth a dependency.
|
|
8
|
+
*
|
|
9
|
+
* These match the `@fluixi/utils` originals exactly, including the parts that look
|
|
10
|
+
* incidental. Each of those exclusions is load-bearing here.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A callable, excluding classes.
|
|
14
|
+
*
|
|
15
|
+
* The class check matters: a signal's setter accepts an updater function, and
|
|
16
|
+
* `set(SomeClass)` means "store this class", not "call it with the previous value".
|
|
17
|
+
* Without the exclusion the constructor would be invoked.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isFunction<T extends Function = Function>(value: unknown): value is T;
|
|
20
|
+
/**
|
|
21
|
+
* A plain-ish object: not null, not an array, not a function, and not one of the
|
|
22
|
+
* built-ins with their own identity.
|
|
23
|
+
*
|
|
24
|
+
* Date, RegExp, Map, Set and Error are excluded because a store must treat them as
|
|
25
|
+
* opaque values rather than walking into them — proxying a Date's internals produces
|
|
26
|
+
* an object that fails every method call on it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isObject(value: unknown): value is Record<string | symbol, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Thenable, rather than `instanceof Promise`.
|
|
31
|
+
*
|
|
32
|
+
* A resource fetcher may return a promise from another realm or another
|
|
33
|
+
* implementation, and those are still awaitable. Functions are included because a
|
|
34
|
+
* thenable function is legal, if unusual.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
37
|
+
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/lib/predicates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAKpF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAUlF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAO1E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type predicates this package needs, inlined.
|
|
3
|
+
*
|
|
4
|
+
* They came from `@fluixi/utils`, and the import was the only thing standing between
|
|
5
|
+
* this package and being installable on its own — a signals library that drags a
|
|
6
|
+
* framework's utility package behind it reads as a framework component, whatever the
|
|
7
|
+
* README says. Three predicates are not worth a dependency.
|
|
8
|
+
*
|
|
9
|
+
* These match the `@fluixi/utils` originals exactly, including the parts that look
|
|
10
|
+
* incidental. Each of those exclusions is load-bearing here.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A callable, excluding classes.
|
|
14
|
+
*
|
|
15
|
+
* The class check matters: a signal's setter accepts an updater function, and
|
|
16
|
+
* `set(SomeClass)` means "store this class", not "call it with the previous value".
|
|
17
|
+
* Without the exclusion the constructor would be invoked.
|
|
18
|
+
*/
|
|
19
|
+
export function isFunction(value) {
|
|
20
|
+
return (typeof value === 'function' &&
|
|
21
|
+
!/^class\s/.test(Function.prototype.toString.call(value)));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A plain-ish object: not null, not an array, not a function, and not one of the
|
|
25
|
+
* built-ins with their own identity.
|
|
26
|
+
*
|
|
27
|
+
* Date, RegExp, Map, Set and Error are excluded because a store must treat them as
|
|
28
|
+
* opaque values rather than walking into them — proxying a Date's internals produces
|
|
29
|
+
* an object that fails every method call on it.
|
|
30
|
+
*/
|
|
31
|
+
export function isObject(value) {
|
|
32
|
+
if (value == null)
|
|
33
|
+
return false;
|
|
34
|
+
if (Array.isArray(value))
|
|
35
|
+
return false;
|
|
36
|
+
if (typeof value === 'function')
|
|
37
|
+
return false;
|
|
38
|
+
if (value instanceof Date)
|
|
39
|
+
return false;
|
|
40
|
+
if (value instanceof RegExp)
|
|
41
|
+
return false;
|
|
42
|
+
if (value instanceof Map)
|
|
43
|
+
return false;
|
|
44
|
+
if (value instanceof Set)
|
|
45
|
+
return false;
|
|
46
|
+
if (value instanceof Error)
|
|
47
|
+
return false;
|
|
48
|
+
return typeof value === 'object';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thenable, rather than `instanceof Promise`.
|
|
52
|
+
*
|
|
53
|
+
* A resource fetcher may return a promise from another realm or another
|
|
54
|
+
* implementation, and those are still awaitable. Functions are included because a
|
|
55
|
+
* thenable function is legal, if unusual.
|
|
56
|
+
*/
|
|
57
|
+
export function isPromise(value) {
|
|
58
|
+
return (value instanceof Promise ||
|
|
59
|
+
(!!value &&
|
|
60
|
+
(typeof value === 'object' || typeof value === 'function') &&
|
|
61
|
+
'then' in value));
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(n){return typeof n=="function"&&!/^class\s/.test(Function.prototype.toString.call(n))}function o(n){return n==null||Array.isArray(n)||typeof n=="function"||n instanceof Date||n instanceof RegExp||n instanceof Map||n instanceof Set||n instanceof Error?!1:typeof n=="object"}function r(n){return n instanceof Promise||!!n&&(typeof n=="object"||typeof n=="function")&&"then"in n}export{t as isFunction,o as isObject,r as isPromise};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var le=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!He.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Je=e=>Ye(le({},"__esModule",{value:!0}),e);var Ot={};Ke(Ot,{clearAllCachedResources:()=>gt,clearCachedResourceNamespace:()=>St,createCachedResource:()=>xt});module.exports=Je(Ot);var Oe=require("@fluixi/utils/object"),ce=require("@fluixi/utils/functions"),G=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:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if((0,ce.isFunction)(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if((0,Oe.isObject)(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if((0,ce.isFunction)(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends G{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},fe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends G{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new fe(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var Te=require("@fluixi/utils");var Xe=Symbol.for("signal");function Ce(e){return typeof e=="function"&&e[Xe]===!0}var Qe="__fluixi_signal_next_state__",Ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Qe]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ze,onSuspend:null,onError:null};var Re=0,_e=1,J=2,de=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends de{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===_e&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Re}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ae(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Re;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(_e);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Pe(){return h.owner}function Fe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function ke(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function et(e){return!!e&&typeof e.then=="function"}ke(()=>{});var tt=Symbol.for("signal"),nt=Symbol.for("memo");function Q(e,t,n){let o=t,r=Pe(),s=new X(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(et(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,tt,{value:!0,enumerable:!0}),Object.defineProperty(a,nt,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Ce(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Q(e);return Q(()=>Z(t()))}var Ne=null;function pe(e){Ne&&Ne(e)}var rt=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),ot=Symbol.for("signal-node"),V=0,ve=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,st=!1,he=!1,N=0,it=1e6,O=new WeakMap,ee=null;var ut=new Map,at=0;function lt(){return`node_${++at}_${Date.now()}`}function ct(e){!1}function ft(e,t,n){let o={id:lt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ct(o),o}function dt(e,t){return e===t}function Le(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function pt(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)be(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ue(e,t){for(let n=0;n<e.length;n++)t(e[n])}function R(e,t){let n=e;typeof n=="object"&&n&&Ie in n&&delete n[Ie];let o=ft("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||dt;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let C=O.get(r);if(C&&C.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=ve,st&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===V||m===ve?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(C),x=[],S=new Set;Ue(P,F);for(let l of x)pt(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return ye(()=>{let j=a();b?b=!1:d.next(j)})}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),Object.defineProperty(a,ot,{value:o,enumerable:!1}),r}function ye(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Me(o,t),()=>U(o)}function Me(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>it)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if((0,Te.isPromise)(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=n,c=o}}function be(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===re||e.state===ve||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Ge(e):Me(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&be(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ht()}}function ht(){if(!he){he=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)be(e[t])}}finally{he=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Be(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function vt(e){let t=Symbol("context"),n=Tt(t);return{id:t,Provider:n,defaultValue:e}}function Tt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return yt(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),qe(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function yt(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ge(o),()=>U(o)}function Ge(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=V)}catch(r){if((0,Te.isPromise)(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Le(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Ve(){return w||(w=vt())}var E=new Map,A=new Map,bt=0,mt=Symbol.for("signal"),wt=Symbol.for("resource");function xt(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${bt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[C,P]=R(void 0,{equals:!1}),[x,S]=R("unresolved",{equals:!1}),[F,l]=R(void 0,{equals:!1}),[se,m]=R(void 0,{equals:!1}),[$,k]=R(!1),[je,me]=R(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function we(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){pe(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)})}function xe(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Se(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;ye(()=>{z===void 0&&(z=Ve());let u=o();if(je(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=E.get(g);if(q&&j(q)&&!T&&!y){(L(x)!=="ready"||L(C)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),we(u,g,!0,()=>p);return}let ge=L(x),$e=ge==="ready"||ge==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),we(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return C()});return Object.defineProperty(H,wt,{value:!0,enumerable:!0}),Object.defineProperty(H,mt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:C},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,me(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,me(T=>T+1)}}]}function St(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function gt(){E.clear(),A.clear()}
|
|
1
|
+
"use strict";var le=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!He.call(e,r)&&r!==n&&le(e,r,{get:()=>t[r],enumerable:!(o=We(t,r))||o.enumerable});return e};var Je=e=>Ye(le({},"__esModule",{value:!0}),e);var Ot={};Ke(Ot,{clearAllCachedResources:()=>gt,clearCachedResourceNamespace:()=>St,createCachedResource:()=>xt});module.exports=Je(Ot);function ce(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function Oe(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=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:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(ce(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(Oe(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(ce(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},de=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new de(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var Xe=Symbol.for("signal");function Re(e){return typeof e=="function"&&e[Xe]===!0}var Qe="__fluixi_signal_next_state__",Ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[Qe]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:Ze,onSuspend:null,onError:null};var Ce=0,_e=1,J=2,pe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends pe{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===_e&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Ce}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ae(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Ce;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(_e);Ae(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ae(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ee(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Pe(){return h.owner}function Fe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function ke(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function et(e){return!!e&&typeof e.then=="function"}ke(()=>{});var tt=Symbol.for("signal"),nt=Symbol.for("memo");function Q(e,t,n){let o=t,r=Pe(),s=new X(()=>Fe(r,()=>{try{return o=e(o)}catch(f){if(et(f))return Ee(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,tt,{value:!0,enumerable:!0}),Object.defineProperty(a,nt,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Re(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function qe(e){let t=Q(e);return Q(()=>Z(t()))}var Ne=null;function he(e){Ne&&Ne(e)}var rt=Symbol.for("signal");var Ie=Symbol("fluixi-proxy"),ot=Symbol.for("signal-node"),G=0,Te=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,st=!1,ve=!1,N=0,it=1e6,O=new WeakMap,ee=null;var ut=new Map,at=0;function lt(){return`node_${++at}_${Date.now()}`}function ct(e){!1}function ft(e,t,n){let o={id:lt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return ct(o),o}function dt(e,t){return e===t}function Me(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function pt(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)be(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ue(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ie in n&&delete n[Ie];let o=ft("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||dt;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===G&&(l.state=Te,st&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===G||m===Te?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ue(Array.from($),k=>F(k,!0))}}};var V=F;let P=Array.from(R),x=[],S=new Set;Ue(P,F);for(let l of x)pt(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return ye(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,rt,{value:!0,enumerable:!0}),Object.defineProperty(a,ot,{value:o,enumerable:!1}),r}function ye(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Le(o,t),()=>U(o)}function Le(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>it)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Me(r)}finally{v=n,c=o}}function be(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===re||e.state===Te||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?je(e):Le(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&be(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ht()}}function ht(){if(!ve){ve=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)be(e[t])}}finally{ve=!1}}}function M(e){let t=v;v=null;try{return e()}finally{v=t}}function Be(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function vt(e){let t=Symbol("context"),n=Tt(t);return{id:t,Provider:n,defaultValue:e}}function Tt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return yt(()=>{o=M(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),qe(()=>t.children)})}),o}}function L(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function yt(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),je(o),()=>U(o)}function je(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(fe(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Me(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Ge(){return w||(w=vt())}var E=new Map,A=new Map,bt=0,mt=Symbol.for("signal"),wt=Symbol.for("resource");function xt(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${bt++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ve,me]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function we(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){he(D),m(D);let p=z&&L(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||xe(p,y)},p=>{!g()&&!y&&Se(p)})}function xe(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function Se(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;ye(()=>{z===void 0&&(z=Ge());let u=o();if(Ve(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Be(()=>{p=!0});let q=E.get(g);if(q&&V(q)&&!T&&!y){(M(x)!=="ready"||M(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),we(u,g,!0,()=>p);return}let ge=M(x),$e=ge==="ready"||ge==="refreshing";_(()=>{S($e?"refreshing":"pending"),l(void 0),k(!1)}),we(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,wt,{value:!0,enumerable:!0}),Object.defineProperty(H,mt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,me(u=>u+1)},invalidate:()=>{let u=M(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,me(T=>T+1)}}]}function St(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function gt(){E.clear(),A.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as je}from"@fluixi/utils/object";import{isFunction as xe}from"@fluixi/utils/functions";var G=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:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(xe(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(je(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(xe(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends G{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},le=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends G{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new le(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};import{isPromise as Ne}from"@fluixi/utils";var $e=Symbol.for("signal");function Se(e){return typeof e=="function"&&e[$e]===!0}var We="__fluixi_signal_next_state__",ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[We]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ze,onSuspend:null,onError:null};var ge=0,Oe=1,J=2,ce=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends ce{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===Oe&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=ge}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);Ce(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===ge;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Oe);Ce(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Ce(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Re(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function _e(){return h.owner}function Ae(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function Ee(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function He(e){return!!e&&typeof e.then=="function"}Ee(()=>{});var Ke=Symbol.for("signal"),Ye=Symbol.for("memo");function Q(e,t,n){let o=t,r=_e(),s=new X(()=>Ae(r,()=>{try{return o=e(o)}catch(f){if(He(f))return Re(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ke,{value:!0,enumerable:!0}),Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Se(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function Fe(e){let t=Q(e);return Q(()=>Z(t()))}var ke=null;function fe(e){ke&&ke(e)}var Je=Symbol.for("signal");var De=Symbol("fluixi-proxy"),Xe=Symbol.for("signal-node"),V=0,pe=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,Qe=!1,de=!1,N=0,Ze=1e6,O=new WeakMap,ee=null;var et=new Map,tt=0;function nt(){return`node_${++tt}_${Date.now()}`}function rt(e){!1}function ot(e,t,n){let o={id:nt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return rt(o),o}function st(e,t){return e===t}function Ie(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function it(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)ve(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function qe(e,t){for(let n=0;n<e.length;n++)t(e[n])}function R(e,t){let n=e;typeof n=="object"&&n&&De in n&&delete n[De];let o=ot("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||st;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let C=O.get(r);if(C&&C.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===V&&(l.state=pe,Qe&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===V||m===pe?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&qe(Array.from($),k=>F(k,!0))}}};var j=F;let P=Array.from(C),x=[],S=new Set;qe(P,F);for(let l of x)it(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return he(()=>{let j=a();b?b=!1:d.next(j)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:o,enumerable:!1}),r}function he(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Ue(o,t),()=>U(o)}function Ue(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>Ze)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{v=n,c=o}}function ve(e){if(!(e.disposed||!e.fn||e.state===V)&&(e.state===re||e.state===pe||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Me(e):Ue(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&ve(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ut()}}function ut(){if(!de){de=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)ve(e[t])}}finally{de=!1}}}function L(e){let t=v;v=null;try{return e()}finally{v=t}}function Le(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function at(e){let t=Symbol("context"),n=lt(t);return{id:t,Provider:n,defaultValue:e}}function lt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return ct(()=>{o=L(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),Fe(()=>t.children)})}),o}}function M(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function ct(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&M(w);return r&&(o.suspense=r),Me(o),()=>U(o)}function Me(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=V)}catch(r){if(Ne(r)){let s=w&&M(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ie(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function Be(){return w||(w=at())}var E=new Map,A=new Map,ft=0,dt=Symbol.for("signal"),pt=Symbol.for("resource");function en(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${ft++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,j=u=>a===1/0||Date.now()-u.timestamp<=a,[C,P]=R(void 0,{equals:!1}),[x,S]=R("unresolved",{equals:!1}),[F,l]=R(void 0,{equals:!1}),[se,m]=R(void 0,{equals:!1}),[$,k]=R(!1),[Ge,Te]=R(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function ye(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){fe(D),m(D);let p=z&&M(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||be(p,y)},p=>{!g()&&!y&&me(p)})}function be(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function me(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;he(()=>{z===void 0&&(z=Be());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Le(()=>{p=!0});let q=E.get(g);if(q&&j(q)&&!T&&!y){(L(x)!=="ready"||L(C)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),ye(u,g,!0,()=>p);return}let we=L(x),Ve=we==="ready"||we==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),ye(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return C()});return Object.defineProperty(H,pt,{value:!0,enumerable:!0}),Object.defineProperty(H,dt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:C},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,Te(u=>u+1)},invalidate:()=>{let u=L(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,Te(T=>T+1)}}]}function tn(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function nn(){E.clear(),A.clear()}export{nn as clearAllCachedResources,tn as clearCachedResourceNamespace,en as createCachedResource};
|
|
1
|
+
function le(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function ge(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function ce(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var j=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:n}=this;if(t instanceof e)t.remove(this);else if(t!==null)for(let o of t)o.remove(this);if(n){for(let o of n)if(le(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(ge(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(t){if(!t||t===this)return this;if(t.closed)return this;let{_closed:n,_subscriptions:o}=this;if(n){if(le(t))try{t()}catch(r){console.error("Error in unsubscribe function:",r)}else if(t.unsubscribe)try{t.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(t),t instanceof e&&t._addParent(this),this}remove(t){let{_subscriptions:n}=this;if(!n)return;let o=n.indexOf(t);o!==-1&&(n.splice(o,1),t._removeParent(this))}_addParent(t){let{_parentOrParents:n}=this;n?Array.isArray(n)?n.push(t):this._parentOrParents=[n,t]:this._parentOrParents=t}_removeParent(t){let{_parentOrParents:n}=this;if(n===t)this._parentOrParents=null;else if(Array.isArray(n)){let o=n.indexOf(t);o!==-1&&(n.splice(o,1),n.length===1&&(this._parentOrParents=n[0]))}}};var K=class extends j{constructor(n,o,r){super();this.isStopped=!1;let s;n?typeof n=="object"?s=n:s={next:n,error:o,complete:r}:s={},this.destination=s}next(n){if(!this.isStopped&&this.destination.next)try{this.destination.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(n)}catch(o){throw o}else throw n;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(n){this.error(n);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},fe=class extends K{constructor(n,o,r,s){super(n,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(n){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(n)}catch(o){this.error(o)}}error(n){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(n)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Y=class extends j{constructor(t){if(super(),t)this._subscribe=t;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(t,n,o){let r;t instanceof K?r=t:r=new fe(t,n,o);let{_subscribe:s}=this;try{let a=s.call(this,r);a&&(typeof a=="function"||typeof a.unsubscribe=="function")&&r.add(a)}catch(a){r.error(a)}return r}pipe(...t){return t.length===0?this:t.reduce((n,o)=>o(n),this)}toPromise(){return new Promise((t,n)=>{let o;this.subscribe({next:r=>o=r,error:n,complete:()=>t(o)})})}};var $e=Symbol.for("signal");function Oe(e){return typeof e=="function"&&e[$e]===!0}var We="__fluixi_signal_next_state__",ze=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},h=globalThis[We]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:ze,onSuspend:null,onError:null};var Re=0,Ce=1,J=2,de=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(h.untracked)return;let t=h.consumer;t&&((this.observers??=new Set).add(t),(t.sources??=new Set).add(this))}};var X=class extends de{constructor(n,o){super();this._threw=!1;this._initialized=!1;this.state=J;this.sources=null;this._fn=n,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(h.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===Ce&&this.sources){for(let n of this.sources)if(n.updateIfNecessary(),this.state===J)break}(this.state===J||!this._initialized)&&this.recompute(),this.state=Re}recompute(){if(this.sources){for(let d of this.sources)d.observers?.delete(this);this.sources.clear()}let n=h.consumer,o=h.untracked;h.consumer=this,h.untracked=!1;let r,s=!1,a;try{r=this._fn()}catch(d){s=!0,a=d,r=this._value}finally{h.consumer=n,h.untracked=o}let f=!this._initialized||this._threw!==s||(s?a!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=a,this._value=r,f){if(this.version++,this.observers)for(let d of[...this.observers])d.markDirty(J);_e(this)}}markDirty(n){if(this.state>=n)return;let o=this.state===Re;if(this.state=n,o){if(this.observers)for(let r of[...this.observers])r.markDirty(Ce);_e(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function _e(e){if(e.watchers)for(let t of[...e.watchers])t._notify(e)}function Ae(e){return h.onSuspend?(h.onSuspend(e,h.owner),!0):!1}function Ee(){return h.owner}function Pe(e,t){let n=h.owner;h.owner=e;try{return t()}finally{h.owner=n}}function Fe(e){h.hostSchedule=e??(t=>{Promise.resolve().then(t)})}function He(e){return!!e&&typeof e.then=="function"}Fe(()=>{});var Ke=Symbol.for("signal"),Ye=Symbol.for("memo");function Q(e,t,n){let o=t,r=Ee(),s=new X(()=>Pe(r,()=>{try{return o=e(o)}catch(f){if(He(f))return Ae(f),o;throw f}}),{equals:n?.equals}),a=(()=>s.get());return Object.defineProperty(a,Ke,{value:!0,enumerable:!0}),Object.defineProperty(a,Ye,{value:!0,enumerable:!0}),a}function Z(e){if(typeof e=="function"&&!e.length){let t=e();return Oe(t)?t:Z(t)}if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let o=Z(e[n]);Array.isArray(o)?t.push.apply(t,o):t.push(o)}return t}return e}function De(e){let t=Q(e);return Q(()=>Z(t()))}var qe=null;function pe(e){qe&&qe(e)}var Je=Symbol.for("signal");var Ne=Symbol("fluixi-proxy"),Xe=Symbol.for("signal-node"),G=0,ve=1,re=2,I=3,c=null,v=null,i=null,te=null,ne=0,Qe=!1,he=!1,N=0,Ze=1e6,O=new WeakMap,ee=null;var et=new Map,tt=0;function nt(){return`node_${++tt}_${Date.now()}`}function rt(e){!1}function ot(e,t,n){let o={id:nt(),type:e,value:t,version:0,equals:n?.equals,name:n?.name,created:Date.now(),updated:Date.now()};return rt(o),o}function st(e,t){return e===t}function Ue(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}function it(e){if(i)i.indexOf(e)===-1&&i.push(e);else if(ee&&ee.running&&!e.pure)ee.effects.indexOf(e)===-1&&ee.effects.push(e);else if(!e.pure||e.computed)ye(e);else if(e.pure&&!e.computed&&e.accessor){let t=v,n=i;v=null,i=[],e.accessor(),v=t;let o=i;if(i=n,o.length>0){let r=i;oe(o),i=r}}}function Ie(e,t){for(let n=0;n<e.length;n++)t(e[n])}function C(e,t){let n=e;typeof n=="object"&&n&&Ne in n&&delete n[Ne];let o=ot("signal",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r=[a,f];O.set(r,new Set);let s;function a(){let d=v;if(d){d.sources?d.sources.indexOf(r)===-1&&d.sources.push(r):d.sources=[r];let b=O.get(r);b&&!b.has(d)&&b.add(d)}return n}function f(d){let b=typeof d=="function"?d(n):d,B=o.equals||st;if(t?.equals===!1||!B(n,b)){n=b,o.value=b,o.version++,o.updated=Date.now();let R=O.get(r);if(R&&R.size>0){let F=function(l,se=!1){let m=l.state;if(!(m===I&&l===v)){if(se&&!l.pure){m===G&&(l.state=ve,Qe&&(i!==null&&i.indexOf(l)===-1?i.push(l):x.push(l)));return}if(!S.has(l)&&(S.add(l),l.state=re,m===G||m===ve?x.push(l):!l.pure&&i!==null&&i.indexOf(l)===-1&&i.push(l),l.pure&&l.accessor)){let $=O.get(l.accessor);$&&Ie(Array.from($),k=>F(k,!0))}}};var V=F;let P=Array.from(R),x=[],S=new Set;Ie(P,F);for(let l of x)it(l)}}}return a.toObservable=()=>new Y(d=>{let b=!0;return Te(()=>{let V=a();b?b=!1:d.next(V)})}),Object.defineProperty(a,Je,{value:!0,enumerable:!0}),Object.defineProperty(a,Xe,{value:o,enumerable:!1}),r}function Te(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Me(o,t),()=>U(o)}function Me(e,t){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let n=v,o=c;if(v=e,c=e,ne++,ne>Ze)throw ne=0,v=n,c=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=I;let r=e.fn(t);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===I&&(e.state=G)}catch(r){if(ce(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=n,c=o}}function ye(e){if(!(e.disposed||!e.fn||e.state===G)&&(e.state===re||e.state===ve||e.state===I)){if(e.cleanups){for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();e.cleanups=null}if(e.owned){for(let t=0;t<e.owned.length;t++)U(e.owned[t]);e.owned=null}e.renderEffect?Be(e):Me(e,e.value)}}function U(e){if(e.disposed=!0,e.sources)for(let t of e.sources){let n=O.get(t);n&&n.delete(e)}if(e.cleanups)for(let t=0;t<e.cleanups.length;t++)e.cleanups[t]();if(e.owned)for(let t=0;t<e.owned.length;t++)U(e.owned[t]);if(e.owner&&e.owner.owned){let t=e.owner.owned.indexOf(e);t!==-1&&e.owner.owned.splice(t,1)}}function oe(e){let t=[],n=[];for(let r of e)r.pure&&!r.computed&&r.accessor?t.indexOf(r)===-1&&t.push(r):(r.computed||!r.pure)&&n.indexOf(r)===-1&&n.push(r);i=[];let o=0;for(;o<t.length;){let r=t[o++],s=O.get(r.accessor);if(s&&s.size>0){let f=v;v=null,r.accessor(),v=f}let a=i.splice(0);for(let f of a)f.pure&&!f.computed&&f.accessor?t.indexOf(f)===-1&&t.push(f):(f.computed||!f.pure)&&n.indexOf(f)===-1&&n.push(f)}i=null;for(let r of n)(r.computed||!r.pure)&&ye(r)}function _(e){if(i&&N>0)return e();if(i&&N===0){let t=i,n=[];i=n,N++;let o;try{o=e()}finally{N--,i=t}let r=i;return oe(n),i=r,o}N++,i=[],te=[];try{return e()}finally{N--,ut()}}function ut(){if(!he){he=!0,ne=0;try{for(;i&&i.length>0;){let e=i;i=null,oe(e)}if(i=null,te){let e=te;te=null;for(let t=0;t<e.length;t++)ye(e[t])}}finally{he=!1}}}function M(e){let t=v;v=null;try{return e()}finally{v=t}}function Le(e){c&&(c.cleanups?c.cleanups.push(e):c.cleanups=[e])}function at(e){let t=Symbol("context"),n=lt(t);return{id:t,Provider:n,defaultValue:e}}function lt(e){return t=>{let n=c;for(;n;)n.contexts||(n.contexts=new Map),n.contexts.has(e)||n.contexts.set(e,t.value),n=n.owner;let o;return ct(()=>{o=M(()=>{let r=c;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,t.value)),De(()=>t.children)})}),o}}function L(e){let t=c;for(;t;){if(t.contexts&&t.contexts.has(e.id))return t.contexts.get(e.id);t=t.owner}if(e)return e.defaultValue}function ct(e,t,n){let o={fn:e,state:re,sources:null,sourceSlots:null,value:t,owned:null,cleanups:null,owner:c,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};c&&(c.owned?c.owned.push(o):c.owned=[o]);let r=w&&L(w);return r&&(o.suspense=r),Be(o),()=>U(o)}function Be(e){if(e.sources){for(let r of e.sources){let s=O.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)U(e.owned[r]);e.owned=null}let t=v,n=c,o=i;v=e,c=e,i===null&&(i=[]),e.state=I;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===I&&(e.state=G)}catch(r){if(ce(r)){let s=w&&L(w);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}Ue(r)}finally{v=t,c=n;let r=i;if(i=o,r!==o&&r&&r.length>0){let s=i;oe(r),i=s}}}var w;function je(){return w||(w=at())}var E=new Map,A=new Map,ft=0,dt=Symbol.for("signal"),pt=Symbol.for("resource");function tn(e,t,n={}){let o,r,s;typeof t=="function"?(o=e,r=t,s=n):(o=()=>!0,r=e,s=t??n);let{ttl:a=1/0,name:f=`_auto_${ft++}`,staleWhileRevalidate:d=!0}=s,b=f,B=u=>`${b}:${JSON.stringify(u)}`,V=u=>a===1/0||Date.now()-u.timestamp<=a,[R,P]=C(void 0,{equals:!1}),[x,S]=C("unresolved",{equals:!1}),[F,l]=C(void 0,{equals:!1}),[se,m]=C(void 0,{equals:!1}),[$,k]=C(!1),[Ge,be]=C(0,{equals:!1}),ie=Symbol("unset"),W=ie,ue=!1,ae=!1;function me(u,T,y,g){if(A.has(T)){A.get(T).then(p=>{g()||we(p,y)},p=>{!g()&&!y&&xe(p)}),y||m(A.get(T));return}let D=Promise.resolve(r(u)).then(p=>(E.set(T,{value:p,timestamp:Date.now()}),A.delete(T),p),p=>{throw A.delete(T),p});if(A.set(T,D),!y){pe(D),m(D);let p=z&&L(z);p&&(p.increment(),D.finally(()=>p.decrement()))}D.then(p=>{g()||we(p,y)},p=>{!g()&&!y&&xe(p)})}function we(u,T){_(()=>{P(()=>u),S("ready"),k(!1),m(void 0),l(void 0)})}function xe(u){_(()=>{l(u),S("errored"),m(void 0)})}let z;Te(()=>{z===void 0&&(z=je());let u=o();if(Ge(),u===!1||u===null||u===void 0){W=ie,_(()=>{S("unresolved"),m(void 0),l(void 0)});return}let T=ue,y=ae;ue=!1,ae=!1;let g=B(u);y&&E.delete(g);let D=W===ie||u!==W;W=u;let p=!1;Le(()=>{p=!0});let q=E.get(g);if(q&&V(q)&&!T&&!y){(M(x)!=="ready"||M(R)!==q.value)&&_(()=>{P(()=>q.value),S("ready"),k(!1),l(void 0)});return}if(q&&d&&!y){_(()=>{P(()=>q.value),S("ready"),k(!0),l(void 0),m(void 0)}),me(u,g,!0,()=>p);return}let Se=M(x),Ve=Se==="ready"||Se==="refreshing";_(()=>{S(Ve?"refreshing":"pending"),l(void 0),k(!1)}),me(u,g,!1,()=>p)});let H=(()=>{let u=F();if(u)throw u;if(x()==="pending"){let y=se();if(y)throw y}return R()});return Object.defineProperty(H,pt,{value:!0,enumerable:!0}),Object.defineProperty(H,dt,{value:!0,enumerable:!0}),Object.defineProperties(H,{state:{get:x},loading:{get:()=>{let u=x();return u==="pending"||u==="refreshing"}},error:{get:F},latest:{get:R},stale:{get:$}}),[H,{mutate:P,refetch:()=>{ue=!0,be(u=>u+1)},invalidate:()=>{let u=M(o);u!=null&&u!==!1&&E.delete(B(u)),ae=!0,be(T=>T+1)}}]}function nn(e){let t=`${e}:`;for(let n of E.keys())n.startsWith(t)&&E.delete(n)}function rn(){E.clear(),A.clear()}export{rn as clearAllCachedResources,nn as clearCachedResourceNamespace,tn as createCachedResource};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Signals core (L0 graph + L1 runtime), as a drop-in for `@fluixi/reactive/signal`.
|
|
2
|
+
* The complete reactive API running on the TC39 Signals core (L0 graph + L1 runtime).
|
|
4
3
|
*
|
|
5
|
-
* This is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* This is what `@fluixi/reactive/signal` re-exports, so it is the default and not an
|
|
5
|
+
* opt-in. It had its own `signal-next` subpath during the migration, when the legacy
|
|
6
|
+
* implementation was still the default; that subpath is gone, having ended up with no
|
|
7
|
+
* export `./signal` did not already have. When the native `globalThis.Signal` ships,
|
|
8
|
+
* L0 becomes a thin polyfill swap underneath this same surface.
|
|
9
9
|
*
|
|
10
10
|
* Coverage: signals, memos, effects, computed, render effects, roots, ownership,
|
|
11
11
|
* batch, untrack, on, transitions (minimal), context, resources (+ SSR seeding),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Me=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var zn=Object.prototype.hasOwnProperty;var Hn=(e,n)=>{for(var t in n)Me(e,t,{get:n[t],enumerable:!0})},Yn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Wn(n))!zn.call(e,r)&&r!==t&&Me(e,r,{get:()=>n[r],enumerable:!(o=$n(n,r))||o.enumerable});return e};var Jn=e=>Yn(Me({},"__esModule",{value:!0}),e);var or={};Hn(or,{$MEMO:()=>Fn,$PROXY:()=>Ze,$RESOURCE:()=>Un,$SIGNAL:()=>De,__DEV__:()=>de,batch:()=>k,clearAllCachedResources:()=>er,clearCachedResourceNamespace:()=>Zt,combineSignal:()=>It,combineSignals:()=>Nt,createCachedResource:()=>Qt,createComputed:()=>gt,createContext:()=>on,createDebounce:()=>Rn,createDeferred:()=>On,createEffect:()=>ne,createMemo:()=>ht,createProvider:()=>Bn,createRenderEffect:()=>jn,createResource:()=>yt,createRoot:()=>vt,createSelector:()=>gn,createSignal:()=>U,debounceSignal:()=>Wt,distinctSignal:()=>Mt,everySignal:()=>Dt,filterSignal:()=>kt,findSignal:()=>Ft,flush:()=>xt,getOwner:()=>bt,getServerData:()=>Ye,getSharedConfig:()=>dt,getSuspenseContext:()=>sn,getSuspenseListContext:()=>Ot,guardSignal:()=>$t,indexArray:()=>rr,isComponent:()=>fn,isMemo:()=>cn,isProvider:()=>pn,isResource:()=>ln,isSignal:()=>ge,isSuspense:()=>dn,keyArray:()=>tr,makeArrayFlat:()=>Le,mapArray:()=>nr,mapSignal:()=>Et,mergeSignal:()=>Lt,nextResourceId:()=>Je,omitSignal:()=>Gt,on:()=>wt,onCleanup:()=>be,onResolve:()=>At,pickSignal:()=>jt,readChildren:()=>Ke,readSignal:()=>Ht,reduceSignal:()=>Pt,reportResourceData:()=>Xe,resumeEffects:()=>Rt,runWithOwner:()=>mt,selectSignal:()=>Vt,setOwner:()=>ft,setResourceDataSink:()=>En,setResourceIdSource:()=>_n,setResourceTracker:()=>An,setScheduler:()=>Ct,setServerDataGetter:()=>Cn,sharedConfig:()=>Ue,someSignal:()=>Ut,sortSignal:()=>qt,startTransition:()=>Vn,throttleSignal:()=>zt,trackPromise:()=>_t,trackResourcePromise:()=>ve,untrack:()=>L,useContext:()=>I,useTransition:()=>St,whenSignal:()=>Kt,zipSignal:()=>Bt});module.exports=Jn(or);var an=require("@fluixi/utils/object"),Ie=require("@fluixi/utils/functions"),fe=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if((0,Ie.isFunction)(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if((0,an.isObject)(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if((0,Ie.isFunction)(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var we=class extends fe{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ne=class extends we{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends fe{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof we?r=n:r=new Ne(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var me=require("@fluixi/utils");var de=!1,Xn=Symbol.for("signal"),Qn=Symbol.for("memo"),Zn=Symbol.for("resource");function ge(e){return typeof e=="function"&&e[Xn]===!0}function cn(e){return typeof e=="function"&&e[Qn]===!0}function ln(e){return typeof e=="function"&&e[Zn]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function pn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Le(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Le(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var et="__fluixi_signal_next_state__",nt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[et]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:nt,onSuspend:null,onError:null};var Tn=0,hn=1,pe=2,Oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},Re=class extends Oe{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(pe);Be(this)}}peek(){return this._value}},ue=class extends Oe{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=pe;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===hn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===pe)break}(this.state===pe||!this._initialized)&&this.recompute(),this.state=Tn}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(pe);Be(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Tn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(hn);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var Ae=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function vn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function yn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function bn(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function je(){return c.owner}function _e(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Ce(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ce(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function Te(e){let n=yn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Ce(n))}finally{c.owner=t}}function mn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function tt(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ge)))}function Ge(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function xn(){c.batchDepth===0&&Ge()}var Ve=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=yn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ue(()=>{Ce(this.owner,!1),_e(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new Ae(()=>tt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ce(this.owner))}};function Sn(e){let n=new Ve(e);return()=>n.dispose()}function rt(e){return!!e&&typeof e.then=="function"}mn(()=>{});var wn=Symbol.for("signal"),ot=Symbol.for("memo"),st=Symbol.for("signal-node");function N(e,n){let t=new Re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),xn(),u});return Object.defineProperty(o,wn,{value:!0,enumerable:!0}),Object.defineProperty(o,st,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=je(),s=new ue(()=>_e(r,()=>{try{return o=e(o)}catch(a){if(rt(a))return bn(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,wn,{value:!0,enumerable:!0}),Object.defineProperty(u,ot,{value:!0,enumerable:!0}),u}function he(e,n){let t=n;return Sn(()=>{t=e(t)})}function Ee(e){return vn(e)}function gn(e,n=(t,o)=>t===o){let t=new Map;return he(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=N(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function On(e,n){let[t,o]=N(e(),n);return he(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Rn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function ke(e){if(typeof e=="function"&&!e.length){let n=e();return ge(n)?n:ke(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ke(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ke(e){let n=x(e);return x(()=>ke(n()))}var $e=null;function An(e){$e=e}function ve(e){$e&&$e(e)}var We=null;function Cn(e){We=e}function Ye(e){return We?We(e):void 0}var ze=null;function _n(e){ze=e}function Je(){return ze?ze():void 0}var He=null;function En(e){He=e}function Xe(e,n){He&&He(e,n)}var De=Symbol.for("signal"),Fn=Symbol.for("memo"),Un=Symbol.for("resource"),Ze=Symbol("fluixi-proxy"),Dn=Symbol.for("signal-node"),K=0,ye=1,W=2,$=3,f=null,v=null,l=null,Pe=null,Fe=0,it=!1,Qe=!1,ae=0,ut=1e6,F=new WeakMap,M=null;var at=null,ct=new Map,lt=0,Ue={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function ft(e){f=e,Ue.owner=e,Ue.context=e}function dt(){return Ue}function pt(){return`node_${++lt}_${Date.now()}`}function Tt(e){!1}function qn(e,n,t){let o={id:pt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Tt(o),o}function Mn(e,n){return e===n}function tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var en=null,nn=null;function In(){if(!en){let[e,n]=U(!1);en=e,nn=n}}function Nn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)xe(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;qe(o),l=r}}}function kn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function U(e,n){let t=e;typeof t=="object"&&t&&Ze in t&&delete t[Ze];let o=qn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];F.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=F.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||Mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=F.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===$&&p===v)){if(b&&!p.pure){C===K&&(p.state=ye,it&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=W,C===K||C===ye?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let P=F.get(p.accessor);P&&kn(Array.from(P),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;kn(S,E);for(let p of g)Nn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ne(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,De,{value:!0,enumerable:!0}),Object.defineProperty(u,Dn,{value:o,enumerable:!1}),r}function ne(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),rn(o,n),()=>J(o)}function rn(e,n){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,Fe++,Fe>ut)throw Fe=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=$;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===$&&(e.state=K)}catch(r){if((0,me.isPromise)(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=t,f=o}}function xe(e){if(!(e.disposed||!e.fn||e.state===K)&&(e.state===W||e.state===ye||e.state===$)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)J(e.owned[n]);e.owned=null}e.renderEffect?Gn(e):rn(e,e.value)}}function J(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=F.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)J(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function ht(e,n,t){let o=qn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;F.has(a)||F.set(a,new Set);let i=F.get(a);i&&i.add(v)}if(r.state!==K){if(r.sources){for(let d of r.sources){let y=F.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)J(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=$;try{let d=r.fn(r.value),y=o.equals||Mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=F.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let P=b.state;if(P!==$){if(C&&!b.pure){P===K&&(b.state=ye,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=W,P===K||P===ye?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=F.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Nn(b)}}r.state===$&&(r.state=K)}catch(d){if((0,me.isPromise)(d)){let y=O&&I(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}tn(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,F.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ne(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,De,{value:!0,enumerable:!0}),Object.defineProperty(s,Fn,{value:!0,enumerable:!0}),Object.defineProperty(s,Dn,{value:o,enumerable:!1}),s}function qe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=F.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&xe(r)}function k(e){if(l&&ae>0)return e();if(l&&ae===0){let n=l,t=[];l=t,ae++;let o;try{o=e()}finally{ae--,l=n}let r=l;return qe(t),l=r,o}ae++,l=[],Pe=[];try{return e()}finally{ae--,Ln()}}function Ln(){if(!Qe){Qe=!0,Fe=0;try{for(;l&&l.length>0;){let e=l;l=null,qe(e)}if(l=null,Pe){let e=Pe;Pe=null;for(let n=0;n<e.length;n++)xe(e[n])}}finally{Qe=!1}}}function vt(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)J(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function L(e){let n=v;v=null;try{return e()}finally{v=n}}function be(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function yt(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:Je(),i=a!==void 0?Ye(a):void 0,d=i!==void 0,[y,T]=U(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=U(void 0,{equals:!1}),[g,m]=U(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),P=Symbol(),_=P,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(B){console.error(`Failed to save resource to cache (${u}):`,B)}},ce=ne(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=P,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let B=z;if(z=!1,_!==P&&A===_&&!B)return;if(_=A,d){d=!1;return}let V=!1;be(()=>V=!0);let le=L(g),oe=L(y),Q=le==="ready"||le==="refreshing";k(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let j=r(A,{value:oe,refetching:Q});if((0,me.isPromise)(j)){p(j),ve(j),j.then(h=>{V||(a!==void 0&&Xe(a,h),k(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{V||k(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{V||k(()=>{S(h),m("errored"),p(void 0)})});let Se=O&&I(O);Se&&(Se.increment(),j.finally(()=>Se.decrement()))}else{if(V)return;k(()=>{T(()=>j),m("ready"),p(void 0)})}}catch(j){if(V)return;k(()=>{S(j),m("errored"),p(void 0)})}});be(ce);let X=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(X()){let B=E();if(B)throw B}return y()});return Object.defineProperty(Y,Un,{value:!0,enumerable:!0}),Object.defineProperty(Y,De,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>X()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function bt(){return f}function mt(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function on(e){let n=Symbol("context"),t=Bn(n);return{id:n,Provider:t,defaultValue:e}}function Bn(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return jn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ke(()=>n.children)})}),o}}function I(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function xt(){return new Promise(e=>{queueMicrotask(()=>{Ln(),e()})})}function Vn(e){if(M&&M.running)return e(),M.done;In();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(nn(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,nn(!1),r.length&&k(()=>{for(let s of r)s.state=W,xe(s)}),n()}),t):(M=null,n(),t)}function St(){return In(),[en,Vn]}function wt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):L(()=>n(u,s))}}function jn(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),Gn(o),()=>J(o)}function Gn(e){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=$;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===$&&(e.state=K)}catch(r){if((0,me.isPromise)(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;qe(r),l=s}}}function gt(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):rn(o,n)}var O;function sn(){return O||(O=on())}var Pn;function Ot(){return Pn||(Pn=on())}function Rt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=W,xe(t)}function At(e){let n=O&&I(O);n&&n.inFallback()?ne(()=>{n.inFallback()||e()}):e()}function Ct(e){at=e}function _t(e){let n=O&&I(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function Et(e,n,t){return x(()=>n(e()),void 0,t)}function kt(e,n,t){return x(()=>e().filter(n),void 0,t)}function Pt(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function Ft(e,n,t){return x(()=>e().find(n),void 0,t)}function Ut(e,n,t){return x(()=>e().some(n),void 0,t)}function Dt(e,n,t){return x(()=>e().every(n),void 0,t)}function qt(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function Mt(e,n){return x(()=>[...new Set(e())],void 0,n)}function It(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function Nt(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):he(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function Lt(e,n,t){return x(()=>e()||n(),void 0,t)}function Bt(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function Vt(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function jt(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function Gt(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function Kt(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function $t(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function Wt(e,n,t){let[o,r]=N(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function zt(e,n,t){let[o,r]=N(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Ht(e){let n=e;for(;typeof n=="function";)n=n();return n}var re=new Map,te=new Map,Yt=0,Jt=Symbol.for("signal"),Xt=Symbol.for("resource");function Qt(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${Yt++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=U(void 0,{equals:!1}),[g,m]=U("unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),[P,_]=U(!1),[z,H]=U(0,{equals:!1}),ce=Symbol("unset"),X=ce,Y=!1,A=!1;function B(h,D,q,G){if(te.has(D)){te.get(D).then(R=>{G()||V(R,q)},R=>{!G()&&!q&&le(R)}),q||C(te.get(D));return}let se=Promise.resolve(r(h)).then(R=>(re.set(D,{value:R,timestamp:Date.now()}),te.delete(D),R),R=>{throw te.delete(D),R});if(te.set(D,se),!q){ve(se),C(se);let R=oe&&I(oe);R&&(R.increment(),se.finally(()=>R.decrement()))}se.then(R=>{G()||V(R,q)},R=>{!G()&&!q&&le(R)})}function V(h,D){k(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){k(()=>{p(h),m("errored"),C(void 0)})}let oe;ne(()=>{oe===void 0&&(oe=sn());let h=o();if(z(),h===!1||h===null||h===void 0){X=ce,k(()=>{m("unresolved"),C(void 0),p(void 0)});return}let D=Y,q=A;Y=!1,A=!1;let G=y(h);q&&re.delete(G);let se=X===ce||h!==X;X=h;let R=!1;be(()=>{R=!0});let ie=re.get(G);if(ie&&T(ie)&&!D&&!q){(L(g)!=="ready"||L(w)!==ie.value)&&k(()=>{S(()=>ie.value),m("ready"),_(!1),p(void 0)});return}if(ie&&i&&!q){k(()=>{S(()=>ie.value),m("ready"),_(!0),p(void 0),C(void 0)}),B(h,G,!0,()=>R);return}let un=L(g),Kn=un==="ready"||un==="refreshing";k(()=>{m(Kn?"refreshing":"pending"),p(void 0),_(!1)}),B(h,G,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let q=b();if(q)throw q}return w()});return Object.defineProperty(Q,Xt,{value:!0,enumerable:!0}),Object.defineProperty(Q,Jt,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:P}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=L(o);h!=null&&h!==!1&&re.delete(y(h)),A=!0,H(D=>D+1)}}]}function Zt(e){let n=`${e}:`;for(let t of re.keys())t.startsWith(n)&&re.delete(t)}function er(){re.clear(),te.clear()}function nr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;Te(m=>{S=m;let[E,p]=N(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function tr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ee(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;Te(p=>{E=p;let[b,C]=N(T);m=C;let P=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(P,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function rr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];Te(S=>{T=S;let[g,m]=N(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}
|
|
1
|
+
"use strict";var Me=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Wn=Object.getOwnPropertyNames;var zn=Object.prototype.hasOwnProperty;var Hn=(e,n)=>{for(var t in n)Me(e,t,{get:n[t],enumerable:!0})},Yn=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Wn(n))!zn.call(e,r)&&r!==t&&Me(e,r,{get:()=>n[r],enumerable:!(o=$n(n,r))||o.enumerable});return e};var Jn=e=>Yn(Me({},"__esModule",{value:!0}),e);var or={};Hn(or,{$MEMO:()=>Fn,$PROXY:()=>Ze,$RESOURCE:()=>Un,$SIGNAL:()=>De,__DEV__:()=>pe,batch:()=>k,clearAllCachedResources:()=>er,clearCachedResourceNamespace:()=>Zt,combineSignal:()=>It,combineSignals:()=>Nt,createCachedResource:()=>Qt,createComputed:()=>gt,createContext:()=>on,createDebounce:()=>Rn,createDeferred:()=>On,createEffect:()=>ne,createMemo:()=>ht,createProvider:()=>Bn,createRenderEffect:()=>Vn,createResource:()=>yt,createRoot:()=>vt,createSelector:()=>gn,createSignal:()=>U,debounceSignal:()=>Wt,distinctSignal:()=>Mt,everySignal:()=>Dt,filterSignal:()=>kt,findSignal:()=>Ft,flush:()=>xt,getOwner:()=>bt,getServerData:()=>Ye,getSharedConfig:()=>dt,getSuspenseContext:()=>sn,getSuspenseListContext:()=>Ot,guardSignal:()=>$t,indexArray:()=>rr,isComponent:()=>fn,isMemo:()=>cn,isProvider:()=>pn,isResource:()=>ln,isSignal:()=>ge,isSuspense:()=>dn,keyArray:()=>tr,makeArrayFlat:()=>Le,mapArray:()=>nr,mapSignal:()=>Et,mergeSignal:()=>Lt,nextResourceId:()=>Je,omitSignal:()=>Gt,on:()=>wt,onCleanup:()=>me,onResolve:()=>At,pickSignal:()=>Vt,readChildren:()=>Ke,readSignal:()=>Ht,reduceSignal:()=>Pt,reportResourceData:()=>Xe,resumeEffects:()=>Rt,runWithOwner:()=>mt,selectSignal:()=>jt,setOwner:()=>ft,setResourceDataSink:()=>En,setResourceIdSource:()=>_n,setResourceTracker:()=>An,setScheduler:()=>Ct,setServerDataGetter:()=>Cn,sharedConfig:()=>Ue,someSignal:()=>Ut,sortSignal:()=>qt,startTransition:()=>jn,throttleSignal:()=>zt,trackPromise:()=>_t,trackResourcePromise:()=>ye,untrack:()=>L,useContext:()=>I,useTransition:()=>St,whenSignal:()=>Kt,zipSignal:()=>Bt});module.exports=Jn(or);function Ie(e){return typeof e=="function"&&!/^class\s/.test(Function.prototype.toString.call(e))}function an(e){return e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object"}function fe(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}var de=class e{constructor(n){this._closed=!1;this._parentOrParents=null;this._subscriptions=null;n&&(this._subscriptions=[n])}get closed(){return this._closed}unsubscribe(){if(this._closed)return;this._closed=!0;let{_parentOrParents:n,_subscriptions:t}=this;if(n instanceof e)n.remove(this);else if(n!==null)for(let o of n)o.remove(this);if(t){for(let o of t)if(Ie(o)&&!(o instanceof e))try{o()}catch(r){console.error("Error in unsubscribe function:",r)}else if(an(o)&&typeof o.unsubscribe=="function")try{o.unsubscribe()}catch(r){console.error("Error unsubscribing child:",r)}this._subscriptions=null}}add(n){if(!n||n===this)return this;if(n.closed)return this;let{_closed:t,_subscriptions:o}=this;if(t){if(Ie(n))try{n()}catch(r){console.error("Error in unsubscribe function:",r)}else if(n.unsubscribe)try{n.unsubscribe()}catch(r){console.error("Error unsubscribing:",r)}return this}return o||(this._subscriptions=[]),this._subscriptions.push(n),n instanceof e&&n._addParent(this),this}remove(n){let{_subscriptions:t}=this;if(!t)return;let o=t.indexOf(n);o!==-1&&(t.splice(o,1),n._removeParent(this))}_addParent(n){let{_parentOrParents:t}=this;t?Array.isArray(t)?t.push(n):this._parentOrParents=[t,n]:this._parentOrParents=n}_removeParent(n){let{_parentOrParents:t}=this;if(t===n)this._parentOrParents=null;else if(Array.isArray(t)){let o=t.indexOf(n);o!==-1&&(t.splice(o,1),t.length===1&&(this._parentOrParents=t[0]))}}};var we=class extends de{constructor(t,o,r){super();this.isStopped=!1;let s;t?typeof t=="object"?s=t:s={next:t,error:o,complete:r}:s={},this.destination=s}next(t){if(!this.isStopped&&this.destination.next)try{this.destination.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped){if(this.isStopped=!0,this.destination.error)try{this.destination.error(t)}catch(o){throw o}else throw t;this.unsubscribe()}}complete(){if(!this.isStopped){if(this.isStopped=!0,this.destination.complete)try{this.destination.complete()}catch(t){this.error(t);return}this.unsubscribe()}}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}},Ne=class extends we{constructor(t,o,r,s){super(t,o,r);this._isUnsubscribing=!1;this._parentSubscriber=null;this._parentSubscriber=s||null}next(t){if(!this.isStopped&&!this._isUnsubscribing)try{super.next(t)}catch(o){this.error(o)}}error(t){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.error(t)}finally{this._isUnsubscribing=!1}}}complete(){if(!this.isStopped&&!this._isUnsubscribing){this._isUnsubscribing=!0;try{super.complete()}finally{this._isUnsubscribing=!1}}}unsubscribe(){this.closed||(this._isUnsubscribing=!0,super.unsubscribe(),this._isUnsubscribing=!1)}};var Z=class extends de{constructor(n){if(super(),n)this._subscribe=n;else throw new TypeError("Observable constructor requires a subscribe function")}subscribe(n,t,o){let r;n instanceof we?r=n:r=new Ne(n,t,o);let{_subscribe:s}=this;try{let u=s.call(this,r);u&&(typeof u=="function"||typeof u.unsubscribe=="function")&&r.add(u)}catch(u){r.error(u)}return r}pipe(...n){return n.length===0?this:n.reduce((t,o)=>o(t),this)}toPromise(){return new Promise((n,t)=>{let o;this.subscribe({next:r=>o=r,error:t,complete:()=>n(o)})})}};var pe=!1,Xn=Symbol.for("signal"),Qn=Symbol.for("memo"),Zn=Symbol.for("resource");function ge(e){return typeof e=="function"&&e[Xn]===!0}function cn(e){return typeof e=="function"&&e[Qn]===!0}function ln(e){return typeof e=="function"&&e[Zn]===!0}function fn(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}function dn(e){return typeof e=="function"&&e[Symbol.for("fluixi-suspense")]===!0}function pn(e){return typeof e=="function"&&e[Symbol.for("fluixi-provider")]===!0}function Le(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?Le(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}var et="__fluixi_signal_next_state__",nt=e=>{typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e)},c=globalThis[et]??={consumer:null,untracked:!1,owner:null,queue:[],scheduled:!1,flushing:!1,batchDepth:0,hostSchedule:nt,onSuspend:null,onError:null};var Tn=0,hn=1,Te=2,Oe=class{constructor(){this.observers=null;this.watchers=null;this.version=0}updateIfNecessary(){}track(){if(c.untracked)return;let n=c.consumer;n&&((this.observers??=new Set).add(n),(n.sources??=new Set).add(this))}},Re=class extends Oe{constructor(n,t){super(),this._value=n,this._equals=t?.equals===!1?()=>!1:t?.equals??Object.is}get(){return this.track(),this._value}set(n){if(!this._equals(this._value,n)){if(this._value=n,this.version++,this.observers)for(let t of[...this.observers])t.markDirty(Te);Be(this)}}peek(){return this._value}},ue=class extends Oe{constructor(t,o){super();this._threw=!1;this._initialized=!1;this.state=Te;this.sources=null;this._fn=t,this._equals=o?.equals===!1?()=>!1:o?.equals??Object.is}get(){if(c.consumer===this)throw new Error("Signal.Computed cannot read itself");if(this.track(),this.updateIfNecessary(),this._threw)throw this._error;return this._value}updateIfNecessary(){if(this.state===hn&&this.sources){for(let t of this.sources)if(t.updateIfNecessary(),this.state===Te)break}(this.state===Te||!this._initialized)&&this.recompute(),this.state=Tn}recompute(){if(this.sources){for(let i of this.sources)i.observers?.delete(this);this.sources.clear()}let t=c.consumer,o=c.untracked;c.consumer=this,c.untracked=!1;let r,s=!1,u;try{r=this._fn()}catch(i){s=!0,u=i,r=this._value}finally{c.consumer=t,c.untracked=o}let a=!this._initialized||this._threw!==s||(s?u!==this._error:!this._equals(this._value,r));if(this._initialized=!0,this._threw=s,this._error=u,this._value=r,a){if(this.version++,this.observers)for(let i of[...this.observers])i.markDirty(Te);Be(this)}}markDirty(t){if(this.state>=t)return;let o=this.state===Tn;if(this.state=t,o){if(this.observers)for(let r of[...this.observers])r.markDirty(hn);Be(this)}}peek(){if(this.updateIfNecessary(),this._threw)throw this._error;return this._value}};function Be(e){if(e.watchers)for(let n of[...e.watchers])n._notify(e)}var Ae=class{constructor(n){this._watched=new Set;this._pending=new Set;this._notifyFn=n}watch(...n){for(let t of n)this._watched.add(t),(t.watchers??=new Set).add(this)}unwatch(...n){for(let t of n)this._watched.delete(t),t.watchers?.delete(this),this._pending.delete(t)}getPending(){let n=[...this._pending];return this._pending.clear(),n}_notify(n){if(!this._watched.has(n)||this._pending.has(n))return;let t=this._pending.size===0;this._pending.add(n),t&&this._notifyFn()}};function vn(e){if(c.untracked)return e();c.untracked=!0;try{return e()}finally{c.untracked=!1}}function yn(e){return{cleanups:null,owned:null,parent:e,contexts:null}}function bn(e){return c.onSuspend?(c.onSuspend(e,c.owner),!0):!1}function Ve(){return c.owner}function _e(e,n){let t=c.owner;c.owner=e;try{return n()}finally{c.owner=t}}function ee(e){if(c.owner){if(c.owner.disposed){e();return}(c.owner.cleanups??=[]).push(e)}}function Ce(e,n=!0){if(!e.disposed){if(e.owned){for(let t=e.owned.length-1;t>=0;t--)Ce(e.owned[t]);e.owned=null}if(e.cleanups){for(let t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}n&&(e.disposed=!0)}}function he(e){let n=yn(c.owner);c.owner&&(c.owner.owned??=[]).push(n);let t=c.owner;c.owner=n;try{return e(()=>Ce(n))}finally{c.owner=t}}function mn(e){c.hostSchedule=e??(n=>{Promise.resolve().then(n)})}function tt(e){e.queued||(e.queued=!0,c.queue.push(e),!c.scheduled&&c.batchDepth===0&&(c.scheduled=!0,c.hostSchedule(Ge)))}function Ge(){if(c.scheduled=!1,c.flushing)return;c.flushing=!0;let e=0;try{for(;c.queue.length;){if(++e>1e5)throw new Error("[fluixi] effect flush did not settle (cycle?)");let n=c.queue;c.queue=[];for(let t of n)t.queued=!1,t.disposed||t.run()}}finally{c.flushing=!1}}function xn(){c.batchDepth===0&&Ge()}var je=class{constructor(n){this.queued=!1;this.disposed=!1;this.owner=yn(c.owner),c.owner&&(c.owner.cleanups??=[]).push(()=>this.dispose()),this.computed=new ue(()=>{Ce(this.owner,!1),_e(this.owner,()=>{let t=n();typeof t=="function"&&(this.owner.cleanups??=[]).push(t)})}),this.watcher=new Ae(()=>tt(this)),this.run(),this.watcher.watch(this.computed)}run(){if(!this.disposed){this.watcher.getPending();try{this.computed.get()}catch(n){if(n&&typeof n.then=="function"&&c.onSuspend){c.onSuspend(n,this.owner);return}if(c.onError&&c.onError(n,this.owner))return;throw n}}}dispose(){this.disposed||(this.disposed=!0,this.watcher.unwatch(this.computed),Ce(this.owner))}};function Sn(e){let n=new je(e);return()=>n.dispose()}function rt(e){return!!e&&typeof e.then=="function"}mn(()=>{});var wn=Symbol.for("signal"),ot=Symbol.for("memo"),st=Symbol.for("signal-node");function N(e,n){let t=new Re(e,{equals:n?.equals}),o=(()=>t.get()),r=(s=>{let u=typeof s=="function"?s(t.peek()):s;return t.set(u),xn(),u});return Object.defineProperty(o,wn,{value:!0,enumerable:!0}),Object.defineProperty(o,st,{value:{get value(){return t.peek()},get version(){return t.version}},enumerable:!1}),[o,r]}function x(e,n,t){let o=n,r=Ve(),s=new ue(()=>_e(r,()=>{try{return o=e(o)}catch(a){if(rt(a))return bn(a),o;throw a}}),{equals:t?.equals}),u=(()=>s.get());return Object.defineProperty(u,wn,{value:!0,enumerable:!0}),Object.defineProperty(u,ot,{value:!0,enumerable:!0}),u}function ve(e,n){let t=n;return Sn(()=>{t=e(t)})}function Ee(e){return vn(e)}function gn(e,n=(t,o)=>t===o){let t=new Map;return ve(()=>{let o=e();for(let[r,s]of t){let[u,a]=s,i=n(r,o);u()!==i&&a(i)}}),o=>{let r=t.get(o);if(!r){let[s,u]=N(!1);r=[s,u],t.set(o,r);let a=e();u(n(o,a))}return r[0]()}}function On(e,n){let[t,o]=N(e(),n);return ve(()=>{let r=e();n?.timeoutMs?setTimeout(()=>o(()=>r),n.timeoutMs):typeof requestIdleCallback=="function"?requestIdleCallback(()=>o(()=>r)):Promise.resolve().then(()=>o(()=>r))}),t}function Rn(e,n){let t,o=(...r)=>{t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e(...r)},n)};return ee(()=>{t!==void 0&&clearTimeout(t)}),o}function ke(e){if(typeof e=="function"&&!e.length){let n=e();return ge(n)?n:ke(n)}if(Array.isArray(e)){let n=[];for(let t=0;t<e.length;t++){let o=ke(e[t]);Array.isArray(o)?n.push.apply(n,o):n.push(o)}return n}return e}function Ke(e){let n=x(e);return x(()=>ke(n()))}var $e=null;function An(e){$e=e}function ye(e){$e&&$e(e)}var We=null;function Cn(e){We=e}function Ye(e){return We?We(e):void 0}var ze=null;function _n(e){ze=e}function Je(){return ze?ze():void 0}var He=null;function En(e){He=e}function Xe(e,n){He&&He(e,n)}var De=Symbol.for("signal"),Fn=Symbol.for("memo"),Un=Symbol.for("resource"),Ze=Symbol("fluixi-proxy"),Dn=Symbol.for("signal-node"),K=0,be=1,W=2,$=3,f=null,v=null,l=null,Pe=null,Fe=0,it=!1,Qe=!1,ae=0,ut=1e6,F=new WeakMap,M=null;var at=null,ct=new Map,lt=0,Ue={context:null,owner:null,routeData:new Map,matchedRoute:new Map};function ft(e){f=e,Ue.owner=e,Ue.context=e}function dt(){return Ue}function pt(){return`node_${++lt}_${Date.now()}`}function Tt(e){!1}function qn(e,n,t){let o={id:pt(),type:e,value:n,version:0,equals:t?.equals,name:t?.name,created:Date.now(),updated:Date.now()};return Tt(o),o}function Mn(e,n){return e===n}function tn(e){throw typeof console<"u"&&console.error("Reactive error:",e),e}var en=null,nn=null;function In(){if(!en){let[e,n]=U(!1);en=e,nn=n}}function Nn(e){if(l)l.indexOf(e)===-1&&l.push(e);else if(M&&M.running&&!e.pure)M.effects.indexOf(e)===-1&&M.effects.push(e);else if(!e.pure||e.computed)xe(e);else if(e.pure&&!e.computed&&e.accessor){let n=v,t=l;v=null,l=[],e.accessor(),v=n;let o=l;if(l=t,o.length>0){let r=l;qe(o),l=r}}}function kn(e,n){for(let t=0;t<e.length;t++)n(e[t])}function U(e,n){let t=e;typeof t=="object"&&t&&Ze in t&&delete t[Ze];let o=qn("signal",t,{equals:n?.equals===!1?void 0:n?.equals,name:n?.name}),r=[u,a];F.set(r,new Set);let s;function u(){let i=v;if(i){i.sources?i.sources.indexOf(r)===-1&&i.sources.push(r):i.sources=[r];let d=F.get(r);d&&!d.has(i)&&d.add(i)}return t}function a(i){let d=typeof i=="function"?i(t):i,y=o.equals||Mn;if(n?.equals===!1||!y(t,d)){t=d,o.value=d,o.version++,o.updated=Date.now();let w=F.get(r);if(w&&w.size>0){let E=function(p,b=!1){let C=p.state;if(!(C===$&&p===v)){if(b&&!p.pure){C===K&&(p.state=be,it&&(l!==null&&l.indexOf(p)===-1?l.push(p):g.push(p)));return}if(!m.has(p)&&(m.add(p),p.state=W,C===K||C===be?g.push(p):!p.pure&&l!==null&&l.indexOf(p)===-1&&l.push(p),p.pure&&p.accessor)){let P=F.get(p.accessor);P&&kn(Array.from(P),_=>E(_,!0))}}};var T=E;let S=Array.from(w),g=[],m=new Set;kn(S,E);for(let p of g)Nn(p)}}}return u.toObservable=()=>new Z(i=>{let d=!0;return ne(()=>{let T=u();d?d=!1:i.next(T)})}),Object.defineProperty(u,De,{value:!0,enumerable:!0}),Object.defineProperty(u,Dn,{value:o,enumerable:!1}),r}function ne(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),rn(o,n),()=>J(o)}function rn(e,n){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let t=v,o=f;if(v=e,f=e,Fe++,Fe>ut)throw Fe=0,v=t,f=o,new Error("Potential infinite loop detected. Exceeded maximum iterations.");try{e.state=$;let r=e.fn(n);typeof r=="function"&&(e.cleanups?e.cleanups.push(r):e.cleanups=[r]),e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=t,f=o}}function xe(e){if(!(e.disposed||!e.fn||e.state===K)&&(e.state===W||e.state===be||e.state===$)){if(e.cleanups){for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();e.cleanups=null}if(e.owned){for(let n=0;n<e.owned.length;n++)J(e.owned[n]);e.owned=null}e.renderEffect?Gn(e):rn(e,e.value)}}function J(e){if(e.disposed=!0,e.sources)for(let n of e.sources){let t=F.get(n);t&&t.delete(e)}if(e.cleanups)for(let n=0;n<e.cleanups.length;n++)e.cleanups[n]();if(e.owned)for(let n=0;n<e.owned.length;n++)J(e.owned[n]);if(e.owner&&e.owner.owned){let n=e.owner.owned.indexOf(e);n!==-1&&e.owner.owned.splice(n,1)}}function ht(e,n,t){let o=qn("memo",n,{equals:t?.equals===!1?void 0:t?.equals,name:t?.name}),r={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,updatedAt:null,node:o,accessor:void 0};f&&(f.owned?f.owned.push(r):f.owned=[r]);let s=()=>{if(v&&v!==r){v.sources?v.sources.indexOf(s)===-1&&v.sources.push(s):v.sources=[s];let a=s;F.has(a)||F.set(a,new Set);let i=F.get(a);i&&i.add(v)}if(r.state!==K){if(r.sources){for(let d of r.sources){let y=F.get(d);y&&y.delete(r)}r.sources=null,r.sourceSlots=null}if(r.cleanups){for(let d=0;d<r.cleanups.length;d++)r.cleanups[d]();r.cleanups=null}if(r.owned){for(let d=0;d<r.owned.length;d++)J(r.owned[d]);r.owned=null}let a=v,i=f;v=r,f=r,r.state=$;try{let d=r.fn(r.value),y=o.equals||Mn;if(t?.equals===!1||!y(r.value,d)){r.value=d,o.value=d,o.version++,o.updated=Date.now();let w=s,S=F.get(w);if(S&&S.size>0){let p=function(b,C=!1){if(b===r)return;let P=b.state;if(P!==$){if(C&&!b.pure){P===K&&(b.state=be,l!==null&&l.indexOf(b)===-1?l.push(b):m.push(b));return}if(!E.has(b)&&(E.add(b),b.state=W,P===K||P===be?m.push(b):!b.pure&&l!==null&&l.indexOf(b)===-1&&l.push(b),b.pure&&b.accessor)){let _=F.get(b.accessor);if(_&&_.size>0)for(let z of Array.from(_))p(z,!0)}}};var u=p;let g=Array.from(S),m=[],E=new Set;for(let b=0;b<g.length;b++)p(g[b]);for(let b of m)Nn(b)}}r.state===$&&(r.state=K)}catch(d){if(fe(d)){let y=O&&I(O);if(!y&&O){let T=i;for(;T;){if(T.contexts?.has(O.id)){y=T.contexts.get(O.id);break}T=T.owner}}return y&&(y.increment(),d.finally(()=>y.decrement())),r.value}tn(d)}finally{v=a,f=i}}return r.value};return r.accessor=s,F.set(s,new Set),s.toObservable=()=>new Z(u=>{let a=!0;return ne(()=>{let d=s();a?a=!1:u.next(d)})}),Object.defineProperty(s,De,{value:!0,enumerable:!0}),Object.defineProperty(s,Fn,{value:!0,enumerable:!0}),Object.defineProperty(s,Dn,{value:o,enumerable:!1}),s}function qe(e){let n=[],t=[];for(let r of e)r.pure&&!r.computed&&r.accessor?n.indexOf(r)===-1&&n.push(r):(r.computed||!r.pure)&&t.indexOf(r)===-1&&t.push(r);l=[];let o=0;for(;o<n.length;){let r=n[o++],s=F.get(r.accessor);if(s&&s.size>0){let a=v;v=null,r.accessor(),v=a}let u=l.splice(0);for(let a of u)a.pure&&!a.computed&&a.accessor?n.indexOf(a)===-1&&n.push(a):(a.computed||!a.pure)&&t.indexOf(a)===-1&&t.push(a)}l=null;for(let r of t)(r.computed||!r.pure)&&xe(r)}function k(e){if(l&&ae>0)return e();if(l&&ae===0){let n=l,t=[];l=t,ae++;let o;try{o=e()}finally{ae--,l=n}let r=l;return qe(t),l=r,o}ae++,l=[],Pe=[];try{return e()}finally{ae--,Ln()}}function Ln(){if(!Qe){Qe=!0,Fe=0;try{for(;l&&l.length>0;){let e=l;l=null,qe(e)}if(l=null,Pe){let e=Pe;Pe=null;for(let n=0;n<e.length;n++)xe(e[n])}}finally{Qe=!1}}}function vt(e){let n={owned:null,cleanups:null,contexts:null,owner:f},t=v;v=null;let o=f;f=n;try{return e(()=>{if(n.owned)for(let r=0;r<n.owned.length;r++)J(n.owned[r]);if(n.cleanups)for(let r=0;r<n.cleanups.length;r++)n.cleanups[r]()})}finally{f=o,v=t}}function L(e){let n=v;v=null;try{return e()}finally{v=n}}function me(e){f&&(f.cleanups?f.cleanups.push(e):f.cleanups=[e])}function yt(e,n,t={}){let o,r;typeof n=="function"?(o=typeof e=="function"?e:()=>e,r=n):(o=()=>!0,r=e,n&&typeof n=="object"&&(t=n));let{initialValue:s,name:u}=t,a=t.transport===!1?void 0:Je(),i=a!==void 0?Ye(a):void 0,d=i!==void 0,[y,T]=U(i!==void 0?i.value:t.initialValue,{equals:!1}),[w,S]=U(void 0,{equals:!1}),[g,m]=U(i!==void 0||t.initialValue!==void 0?"ready":"unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),P=Symbol(),_=P,z=!1,H=A=>{if(!(typeof localStorage>"u"))try{A&&localStorage.setItem("storage",JSON.stringify({data:A,timestamp:Date.now()}))}catch(B){console.error(`Failed to save resource to cache (${u}):`,B)}},ce=ne(()=>{let A=o?o():e;if(b(),A===!1||A===null||A===void 0){_=P,k(()=>{m("unresolved"),p(void 0),S(void 0)});return}let B=z;if(z=!1,_!==P&&A===_&&!B)return;if(_=A,d){d=!1;return}let j=!1;me(()=>j=!0);let le=L(g),oe=L(y),Q=le==="ready"||le==="refreshing";k(()=>{m(Q?"refreshing":"pending"),S(void 0)});try{let V=r(A,{value:oe,refetching:Q});if(fe(V)){p(V),ye(V),V.then(h=>{j||(a!==void 0&&Xe(a,h),k(()=>{T(()=>h),H(h),m("ready"),p(void 0)}))},h=>{j||k(()=>{S(h),m("errored"),p(void 0)})}).catch(h=>{j||k(()=>{S(h),m("errored"),p(void 0)})});let Se=O&&I(O);Se&&(Se.increment(),V.finally(()=>Se.decrement()))}else{if(j)return;k(()=>{T(()=>V),m("ready"),p(void 0)})}}catch(V){if(j)return;k(()=>{S(V),m("errored"),p(void 0)})}});me(ce);let X=()=>{let A=g();return A==="pending"||A==="refreshing"},Y=(()=>{let A=w();if(A)throw A;if(X()){let B=E();if(B)throw B}return y()});return Object.defineProperty(Y,Un,{value:!0,enumerable:!0}),Object.defineProperty(Y,De,{value:!0,enumerable:!0}),Object.defineProperties(Y,{state:{get:g},loading:{get:()=>X()},error:{get:w},latest:{get:y}}),[Y,{mutate:T,refetch:()=>{z=!0,C(void 0)}}]}function bt(){return f}function mt(e,n){let t=f,o=v;f=e,v=null;try{return n()}finally{f=t,v=o}}function on(e){let n=Symbol("context"),t=Bn(n);return{id:n,Provider:t,defaultValue:e}}function Bn(e){return n=>{let t=f;for(;t;)t.contexts||(t.contexts=new Map),t.contexts.has(e)||t.contexts.set(e,n.value),t=t.owner;let o;return Vn(()=>{o=L(()=>{let r=f;return r&&(r.contexts||(r.contexts=new Map),r.contexts.set(e,n.value)),Ke(()=>n.children)})}),o}}function I(e){let n=f;for(;n;){if(n.contexts&&n.contexts.has(e.id))return n.contexts.get(e.id);n=n.owner}if(e)return e.defaultValue}function xt(){return new Promise(e=>{queueMicrotask(()=>{Ln(),e()})})}function jn(e){if(M&&M.running)return e(),M.done;In();let n,t=new Promise(r=>n=r),o={running:!0,effects:[],resolve:n,done:t};M=o;try{e()}finally{o.running=!1}return o.effects.length?(nn(!0),Promise.resolve().then(()=>{let r=o.effects.splice(0);M=null,nn(!1),r.length&&k(()=>{for(let s of r)s.state=W,xe(s)}),n()}),t):(M=null,n(),t)}function St(){return In(),[en,jn]}function wt(e,n,t){let o=t?.defer??!1,r=!0;return s=>{let u=e();return o&&r?(r=!1,s):L(()=>n(u,s))}}function Vn(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!1,updatedAt:null,renderEffect:!0};f&&(f.owned?f.owned.push(o):f.owned=[o]);let r=O&&I(O);return r&&(o.suspense=r),Gn(o),()=>J(o)}function Gn(e){if(e.sources){for(let r of e.sources){let s=F.get(r);s&&s.delete(e)}e.sources=null,e.sourceSlots=null}if(e.cleanups){for(let r=0;r<e.cleanups.length;r++)e.cleanups[r]();e.cleanups=null}if(e.owned){for(let r=0;r<e.owned.length;r++)J(e.owned[r]);e.owned=null}let n=v,t=f,o=l;v=e,f=e,l===null&&(l=[]),e.state=$;try{let r=e.fn(e.value);typeof r=="function"&&(e.cleanups||(e.cleanups=[]),e.cleanups.push(r)),e.value=r,e.state===$&&(e.state=K)}catch(r){if(fe(r)){let s=O&&I(O);s&&(s.increment(),r.finally(()=>s.decrement()),e.suspense&&s.effects.push(e));return}tn(r)}finally{v=n,f=t;let r=l;if(l=o,r!==o&&r&&r.length>0){let s=l;qe(r),l=s}}}function gt(e,n,t){let o={fn:e,state:W,sources:null,sourceSlots:null,value:n,owned:null,cleanups:null,owner:f,contexts:null,pure:!0,computed:!0,updatedAt:null};f&&(f.owned?f.owned.push(o):f.owned=[o]),M&&M.running?(l||(l=[]),l.indexOf(o)===-1&&l.push(o)):l?l.indexOf(o)===-1&&l.push(o):rn(o,n)}var O;function sn(){return O||(O=on())}var Pn;function Ot(){return Pn||(Pn=on())}function Rt(e){if(!e.length)return;let n=e.slice();e.length=0;for(let t of n)t.state=W,xe(t)}function At(e){let n=O&&I(O);n&&n.inFallback()?ne(()=>{n.inFallback()||e()}):e()}function Ct(e){at=e}function _t(e){let n=O&&I(O);return n&&(n.increment(),e.finally(()=>n.decrement())),e}function Et(e,n,t){return x(()=>n(e()),void 0,t)}function kt(e,n,t){return x(()=>e().filter(n),void 0,t)}function Pt(e,n,t,o){return x(()=>e().reduce(n,t),void 0,o)}function Ft(e,n,t){return x(()=>e().find(n),void 0,t)}function Ut(e,n,t){return x(()=>e().some(n),void 0,t)}function Dt(e,n,t){return x(()=>e().every(n),void 0,t)}function qt(e,n,t){return x(()=>[...e()].sort(n),void 0,t)}function Mt(e,n){return x(()=>[...new Set(e())],void 0,n)}function It(e,n,t){return x(()=>{let o=e.map(r=>r());return n(o)},void 0,t)}function Nt(...e){return new Z(n=>{let t=()=>e.map(r=>typeof r=="function"?r():r.get()),o=e.map(r=>typeof r=="function"&&r.subscribe?r.subscribe(()=>{n.next(t())}):typeof r!="function"?r.subscribe(()=>{n.next(t())}):ve(()=>{n.next(t())}));return()=>{o.forEach(r=>{typeof r=="function"?r():r&&typeof r.unsubscribe=="function"&&r.unsubscribe()})}})}function Lt(e,n,t){return x(()=>e()||n(),void 0,t)}function Bt(e,n,t,o){return x(()=>t(e(),n()),void 0,o)}function jt(e,n,t){return x(()=>n(e()),void 0,{equals:t,internal:!0})}function Vt(e,n,t){return x(()=>{let o=e(),r={};for(let s of n)r[s]=o[s];return r},void 0,t)}function Gt(e,n,t){return x(()=>{let r={...e()};for(let s of n)delete r[s];return r},void 0,t)}function Kt(e,n,t,o){return x(()=>e()?n():t(),void 0,o)}function $t(e,n,t){return x(()=>e()?n():void 0,void 0,t)}function Wt(e,n,t){let[o,r]=N(e()),s;return x(()=>{let u=e();clearTimeout(s),s=setTimeout(()=>r(()=>u),n)}),o}function zt(e,n,t){let[o,r]=N(e()),s=0,u;return x(()=>{let a=e(),i=Date.now();i-s>=n?(s=i,r(()=>a)):(clearTimeout(u),u=setTimeout(()=>{s=Date.now(),r(()=>a)},n-(i-s)))}),o}function Ht(e){let n=e;for(;typeof n=="function";)n=n();return n}var re=new Map,te=new Map,Yt=0,Jt=Symbol.for("signal"),Xt=Symbol.for("resource");function Qt(e,n,t={}){let o,r,s;typeof n=="function"?(o=e,r=n,s=t):(o=()=>!0,r=e,s=n??t);let{ttl:u=1/0,name:a=`_auto_${Yt++}`,staleWhileRevalidate:i=!0}=s,d=a,y=h=>`${d}:${JSON.stringify(h)}`,T=h=>u===1/0||Date.now()-h.timestamp<=u,[w,S]=U(void 0,{equals:!1}),[g,m]=U("unresolved",{equals:!1}),[E,p]=U(void 0,{equals:!1}),[b,C]=U(void 0,{equals:!1}),[P,_]=U(!1),[z,H]=U(0,{equals:!1}),ce=Symbol("unset"),X=ce,Y=!1,A=!1;function B(h,D,q,G){if(te.has(D)){te.get(D).then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)}),q||C(te.get(D));return}let se=Promise.resolve(r(h)).then(R=>(re.set(D,{value:R,timestamp:Date.now()}),te.delete(D),R),R=>{throw te.delete(D),R});if(te.set(D,se),!q){ye(se),C(se);let R=oe&&I(oe);R&&(R.increment(),se.finally(()=>R.decrement()))}se.then(R=>{G()||j(R,q)},R=>{!G()&&!q&&le(R)})}function j(h,D){k(()=>{S(()=>h),m("ready"),_(!1),C(void 0),p(void 0)})}function le(h){k(()=>{p(h),m("errored"),C(void 0)})}let oe;ne(()=>{oe===void 0&&(oe=sn());let h=o();if(z(),h===!1||h===null||h===void 0){X=ce,k(()=>{m("unresolved"),C(void 0),p(void 0)});return}let D=Y,q=A;Y=!1,A=!1;let G=y(h);q&&re.delete(G);let se=X===ce||h!==X;X=h;let R=!1;me(()=>{R=!0});let ie=re.get(G);if(ie&&T(ie)&&!D&&!q){(L(g)!=="ready"||L(w)!==ie.value)&&k(()=>{S(()=>ie.value),m("ready"),_(!1),p(void 0)});return}if(ie&&i&&!q){k(()=>{S(()=>ie.value),m("ready"),_(!0),p(void 0),C(void 0)}),B(h,G,!0,()=>R);return}let un=L(g),Kn=un==="ready"||un==="refreshing";k(()=>{m(Kn?"refreshing":"pending"),p(void 0),_(!1)}),B(h,G,!1,()=>R)});let Q=(()=>{let h=E();if(h)throw h;if(g()==="pending"){let q=b();if(q)throw q}return w()});return Object.defineProperty(Q,Xt,{value:!0,enumerable:!0}),Object.defineProperty(Q,Jt,{value:!0,enumerable:!0}),Object.defineProperties(Q,{state:{get:g},loading:{get:()=>{let h=g();return h==="pending"||h==="refreshing"}},error:{get:E},latest:{get:w},stale:{get:P}}),[Q,{mutate:S,refetch:()=>{Y=!0,H(h=>h+1)},invalidate:()=>{let h=L(o);h!=null&&h!==!1&&re.delete(y(h)),A=!0,H(D=>D+1)}}]}function Zt(e){let n=`${e}:`;for(let t of re.keys())t.startsWith(n)&&re.delete(t)}function er(){re.clear(),te.clear()}function nr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=new Map;for(let i of o)s.has(i.item)||s.set(i.item,i);let u=[],a=new Set;for(let i=0;i<r.length;i++){let d=r[i],y=s.get(d);if(y&&!a.has(y))y.setIndex(i),u.push(y),a.add(y);else{let T,w,S;he(m=>{S=m;let[E,p]=N(i);w=p,T=n(d,E)});let g={item:d,rendered:T,dispose:S,setIndex:w};u.push(g),a.add(g)}}for(let i of o)a.has(i)||i.dispose();return o=u,u.map(i=>i.rendered)})})}function tr(e,n,t,o){let r=[],s=[];return ee(()=>{for(let u of s)u.dispose();r=[],s=[]}),x(()=>{let u=e()||[];return Ee(()=>{if(u.length===0){for(let T of s)T.dispose();return r=[],s=[],o?.fallback?o.fallback():[]}let a=new Map;for(let T=0;T<r.length;T++)a.set(r[T],s[T]);let i=[],d=[],y=new Set;for(let T=0;T<u.length;T++){let w=n(u[T]),S=a.get(w);if(S&&!y.has(w))S.setIndex(T),i.push(S);else{let g,m,E;he(p=>{E=p;let[b,C]=N(T);m=C;let P=x(_=>{let H=(e()||[])[b()];return H??_},u[T]);g=t(P,b)}),i.push({rendered:g,dispose:E,setIndex:m})}d.push(w),y.add(w)}for(let[T,w]of a)y.has(T)||w.dispose();return r=d,s=i,i.map(T=>T.rendered)})})}function rr(e,n,t){let o=[];return ee(()=>{for(let r of o)r.dispose();o=[]}),x(()=>{let r=e()||[];return Ee(()=>{if(r.length===0){for(let i of o)i.dispose();return o=[],t?.fallback?t.fallback():[]}let s=o.length,u=r.length;for(let i=s;i<u;i++){let d,y,T,w=r[i];he(S=>{T=S;let[g,m]=N(w);y=m,d=n(g,i)}),o.push({rendered:d,setItem:y,dispose:T})}for(let i=u;i<s;i++)o[i].dispose();u<s&&(o=o.slice(0,u));let a=Math.min(s,u);for(let i=0;i<a;i++)o[i].setItem(r[i]);return o.map(i=>i.rendered)})})}
|