@estjs/template 0.0.16-beta.3 → 0.0.16-beta.5

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.
@@ -0,0 +1 @@
1
+ import'@estjs/shared';import {setCurrentScope,effectScope}from'@estjs/signals';var d=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var m=(e,r)=>{var n={};for(var o in e)S.call(e,o)&&r.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&d)for(var o of d(e))r.indexOf(o)<0&&y.call(e,o)&&(n[o]=e[o]);return n};var D=(e,r,n)=>new Promise((o,c)=>{var p=l=>{try{i(n.next(l));}catch(u){c(u);}},a=l=>{try{i(n.throw(l));}catch(u){c(u);}},i=l=>l.done?o(l.value):Promise.resolve(l.value).then(p,a);i((n=n.apply(e,r)).next());});var t=null,h=0;function w(){return t}function T(e){t=e,setCurrentScope(e==null?void 0:e.effectScope);}function k(e=t){let r=e?e.effectScope.run(()=>effectScope()):effectScope(true),n={id:++h,effectScope:r,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(n)),n}function s(e,r){let n=t;t=e;try{return e.effectScope.run(r)}finally{t=n;}}function _(e){var r;if(!(!e||e.isDestroyed)){if(e.isDestroyed=true,e.children&&e.children.size>0){for(let n of e.children)n&&(n.parent=null,_(n));e.children.clear();}s(e,()=>{if(e.onDestroy){for(let n=0;n<e.onDestroy.length;n++)try{e.onDestroy[n]();}catch(o){}e.onDestroy=null;}if(e.cleanup){for(let n=0;n<e.cleanup.length;n++)try{e.cleanup[n]();}catch(o){}e.cleanup=null;}}),e.effectScope.stop(),(r=e.parent)!=null&&r.children&&e.parent.children.delete(e),e.provides&&(e.provides.clear(),e.provides=null),e.onMount=null,e.onUpdate=null,e.children=null,e.parent=null;}}function C(e){let r=t;r&&(r.cleanup||(r.cleanup=[]),r.cleanup.push(e));}export{m as a,D as b,w as c,T as d,k as e,s as f,_ as g,C as h};
@@ -1,5 +1,5 @@
1
1
  import { error } from '@estjs/shared';
2
- import { effectScope } from '@estjs/signals';
2
+ import { setCurrentScope, effectScope } from '@estjs/signals';
3
3
 
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -41,6 +41,10 @@ var scopeId = 0;
41
41
  function getActiveScope() {
42
42
  return activeScope;
43
43
  }
44
+ function setActiveScope(scope) {
45
+ activeScope = scope;
46
+ setCurrentScope(scope == null ? void 0 : scope.effectScope);
47
+ }
44
48
  function createScope(parent = activeScope) {
45
49
  const reactiveScope = parent ? parent.effectScope.run(() => effectScope()) : effectScope(true);
46
50
  const scope = {
@@ -147,6 +151,6 @@ function onCleanup(fn) {
147
151
  scope.cleanup.push(fn);
148
152
  }
149
153
 
150
- export { __async, __objRest, createScope, disposeScope, getActiveScope, onCleanup, runWithScope };
151
- //# sourceMappingURL=chunk-JT6RSDKI.dev.esm.js.map
152
- //# sourceMappingURL=chunk-JT6RSDKI.dev.esm.js.map
154
+ export { __async, __objRest, createScope, disposeScope, getActiveScope, onCleanup, runWithScope, setActiveScope };
155
+ //# sourceMappingURL=chunk-OEKE4VTS.dev.esm.js.map
156
+ //# sourceMappingURL=chunk-OEKE4VTS.dev.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAI,WAAA,GAA4B,IAAA;AAGhC,IAAI,OAAA,GAAU,CAAA;AAOP,SAAS,cAAA,GAA+B;AAC7C,EAAA,OAAO,WAAA;AACT;AAQO,SAAS,eAAe,KAAA,EAA2B;AACxD,EAAA,WAAA,GAAc,KAAA;AACd,EAAA,eAAA,CAAgB,+BAAO,WAAW,CAAA;AACpC;AASO,SAAS,WAAA,CAAY,SAAuB,WAAA,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EAAA,KAAA,CAAM,YAAY,IAAA,EAAK;AAGvB,EAAA,IAAA,CAAI,EAAA,GAAA,KAAA,CAAM,MAAA,KAAN,IAAA,GAAA,MAAA,GAAA,EAAA,CAAc,QAAA,EAAU;AAC1B,IAAA,KAAA,CAAM,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,KAAK,CAAA;AAAA,EACpC;AAGA,EAAA,IAAI,MAAM,QAAA,EAAU;AAClB,IAAA,KAAA,CAAM,SAAS,KAAA,EAAM;AACrB,IAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AAAA,EACnB;AACA,EAAA,KAAA,CAAM,OAAA,GAAU,IAAA;AAChB,EAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AACjB,EAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AAGjB,EAAA,KAAA,CAAM,MAAA,GAAS,IAAA;AACjB;AAQO,SAAS,UAAU,EAAA,EAAsB;AAC9C,EAAA,MAAM,KAAA,GAAQ,WAAA;AAEd,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAa;AACX,MAAA,KAAA,CAAM,2CAA2C,CAAA;AAAA,IACnD;AACA,IAAA;AAAA,EACF;AAGA,EAAA,IAAI,CAAC,MAAM,OAAA,EAAS;AAClB,IAAA,KAAA,CAAM,UAAU,EAAC;AAAA,EACnB;AAEA,EAAA,KAAA,CAAM,OAAA,CAAQ,KAAK,EAAE,CAAA;AACvB","file":"chunk-OEKE4VTS.dev.esm.js","sourcesContent":["import { error } from '@estjs/shared';\nimport { type EffectScope, effectScope, setCurrentScope } from '@estjs/signals';\nimport type { InjectionKey } from './provide';\n\n/**\n * Scope represents an execution context in the component tree.\n * It manages provides, cleanup functions, and lifecycle hooks.\n */\nexport interface Scope {\n /** Unique identifier for debugging */\n readonly id: number;\n\n /** Reactive effect scope tied to this template scope */\n readonly effectScope: EffectScope;\n\n /** Parent scope in the hierarchy */\n parent: Scope | null;\n\n /** Child scopes (lazy initialized) */\n children: Set<Scope> | null;\n\n /** Provided values (lazy initialized) */\n provides: Map<InjectionKey<unknown> | string | number | symbol, unknown> | null;\n\n /** Cleanup functions (lazy initialized) */\n cleanup: Array<() => void> | null;\n\n /** Mount lifecycle hooks (lazy initialized) */\n onMount: Array<() => void | Promise<void>> | null;\n\n /** Update lifecycle hooks (lazy initialized) */\n onUpdate: Array<() => void | Promise<void>> | null;\n\n /** Destroy lifecycle hooks (lazy initialized) */\n onDestroy: Array<() => void | Promise<void>> | null;\n\n /** Whether the scope has been mounted */\n isMounted: boolean;\n\n /** Whether the scope has been destroyed */\n isDestroyed: boolean;\n}\n\n/** Currently active scope */\nlet activeScope: Scope | null = null;\n\n/** Scope ID counter for unique identification */\nlet scopeId = 0;\n\n/**\n * Get the currently active scope.\n *\n * @returns The active scope or null if none is active.\n */\nexport function getActiveScope(): Scope | null {\n return activeScope;\n}\n\n/**\n * Set the active scope (internal use).\n *\n * @param scope - The scope to set as active.\n * @returns {void}\n */\nexport function setActiveScope(scope: Scope | null): void {\n activeScope = scope;\n setCurrentScope(scope?.effectScope);\n}\n\n/**\n * Create a new scope with optional parent.\n * If no parent is provided, uses the current active scope as parent.\n *\n * @param parent - Optional parent scope (defaults to active scope).\n * @returns A new scope instance.\n */\nexport function createScope(parent: Scope | null = activeScope): Scope {\n const reactiveScope = parent ? parent.effectScope.run(() => effectScope())! : effectScope(true);\n const scope: Scope = {\n id: ++scopeId,\n effectScope: reactiveScope,\n parent,\n children: null, // Lazy initialized\n provides: null, // Lazy initialized\n cleanup: null, // Lazy initialized\n onMount: null, // Lazy initialized\n onUpdate: null, // Lazy initialized\n onDestroy: null, // Lazy initialized\n isMounted: false,\n isDestroyed: false,\n };\n\n // Establish parent-child relationship\n if (parent) {\n if (!parent.children) {\n parent.children = new Set();\n }\n parent.children.add(scope);\n }\n\n return scope;\n}\n\n/**\n * Run a function within a scope, ensuring proper cleanup.\n * The previous active scope is restored even if the function throws.\n *\n * @param scope - The scope to run within.\n * @param fn - The function to execute.\n * @returns The return value of the function.\n */\nexport function runWithScope<T>(scope: Scope, fn: () => T): T {\n const prevScope = activeScope;\n activeScope = scope;\n\n try {\n return scope.effectScope.run(fn) as T;\n } finally {\n // Restore previous scope directly\n activeScope = prevScope;\n }\n}\n\n/**\n * Dispose a scope and all its children.\n * Children are disposed first (depth-first), then the scope itself.\n *\n * @param scope - The scope to dispose.\n * @returns {void}\n */\nexport function disposeScope(scope: Scope): void {\n // Idempotent: already destroyed\n if (!scope || scope.isDestroyed) {\n return;\n }\n\n // Mark destroyed immediately to block re-entrant disposeScope calls\n // (e.g. an onDestroy hook that accidentally disposes the same scope again).\n scope.isDestroyed = true;\n\n // Dispose children first (depth-first)\n // Iterate directly safely by unlinking parent reference to prevent mutation during iteration\n if (scope.children && scope.children.size > 0) {\n for (const child of scope.children) {\n if (child) {\n child.parent = null;\n disposeScope(child);\n }\n }\n scope.children.clear();\n }\n\n // Execute destroy lifecycle hooks and cleanup functions within the scope's\n // context so that inject/provide/getActiveScope work correctly in callbacks.\n //\n // NOTE: `scope.isDestroyed` is already `true` at this point — this is\n // intentional to prevent re-entrant `disposeScope()` calls from within\n // hooks. Callbacks that inspect `getActiveScope()?.isDestroyed` should\n // be aware of this.\n runWithScope(scope, () => {\n // Execute destroy lifecycle hooks\n if (scope.onDestroy) {\n for (let i = 0; i < scope.onDestroy.length; i++) {\n try {\n scope.onDestroy[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in destroy hook:`, error_);\n }\n }\n }\n scope.onDestroy = null;\n }\n\n // Execute cleanup functions\n if (scope.cleanup) {\n for (let i = 0; i < scope.cleanup.length; i++) {\n try {\n scope.cleanup[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in cleanup:`, error_);\n }\n }\n }\n scope.cleanup = null;\n }\n });\n\n scope.effectScope.stop();\n\n // Remove from parent's children\n if (scope.parent?.children) {\n scope.parent.children.delete(scope);\n }\n\n // Clear all internal collections to prevent memory leaks\n if (scope.provides) {\n scope.provides.clear();\n scope.provides = null;\n }\n scope.onMount = null;\n scope.onUpdate = null;\n scope.children = null;\n\n // Break parent reference to prevent memory leaks\n scope.parent = null;\n}\n\n/**\n * Register a cleanup function in the current scope.\n * The function will be called when the scope is disposed.\n *\n * @param fn - The cleanup function.\n */\nexport function onCleanup(fn: () => void): void {\n const scope = activeScope;\n\n if (!scope) {\n if (__DEV__) {\n error('onCleanup() must be called within a scope');\n }\n return;\n }\n\n // Lazy initialize cleanup array\n if (!scope.cleanup) {\n scope.cleanup = [];\n }\n\n scope.cleanup.push(fn);\n}\n"]}
@@ -59,6 +59,13 @@ interface Scope {
59
59
  * @returns The active scope or null if none is active.
60
60
  */
61
61
  declare function getActiveScope(): Scope | null;
62
+ /**
63
+ * Set the active scope (internal use).
64
+ *
65
+ * @param scope - The scope to set as active.
66
+ * @returns {void}
67
+ */
68
+ declare function setActiveScope(scope: Scope | null): void;
62
69
  /**
63
70
  * Create a new scope with optional parent.
64
71
  * If no parent is provided, uses the current active scope as parent.
@@ -85,4 +92,4 @@ declare function runWithScope<T>(scope: Scope, fn: () => T): T;
85
92
  */
86
93
  declare function disposeScope(scope: Scope): void;
87
94
 
88
- export { type InjectionKey as I, type Scope as S, createScope as c, disposeScope as d, getActiveScope as g, inject as i, provide as p, runWithScope as r };
95
+ export { type InjectionKey as I, type Scope as S, createScope as c, disposeScope as d, getActiveScope as g, inject as i, provide as p, runWithScope as r, setActiveScope as s };
@@ -59,6 +59,13 @@ interface Scope {
59
59
  * @returns The active scope or null if none is active.
60
60
  */
61
61
  declare function getActiveScope(): Scope | null;
62
+ /**
63
+ * Set the active scope (internal use).
64
+ *
65
+ * @param scope - The scope to set as active.
66
+ * @returns {void}
67
+ */
68
+ declare function setActiveScope(scope: Scope | null): void;
62
69
  /**
63
70
  * Create a new scope with optional parent.
64
71
  * If no parent is provided, uses the current active scope as parent.
@@ -85,4 +92,4 @@ declare function runWithScope<T>(scope: Scope, fn: () => T): T;
85
92
  */
86
93
  declare function disposeScope(scope: Scope): void;
87
94
 
88
- export { type InjectionKey as I, type Scope as S, createScope as c, disposeScope as d, getActiveScope as g, inject as i, provide as p, runWithScope as r };
95
+ export { type InjectionKey as I, type Scope as S, createScope as c, disposeScope as d, getActiveScope as g, inject as i, provide as p, runWithScope as r, setActiveScope as s };
@@ -1,2 +1 @@
1
- 'use strict';require('@estjs/shared');var signals=require('@estjs/signals');var o=null,d=0;function p(){return o}function f(e=o){let n=e?e.effectScope.run(()=>signals.effectScope()):signals.effectScope(true),r={id:++d,effectScope:n,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(r)),r}function t(e,n){let r=o;o=e;try{return e.effectScope.run(n)}finally{o=r;}}function i(e){var n;if(!(!e||e.isDestroyed)){if(e.isDestroyed=true,e.children&&e.children.size>0){for(let r of e.children)r&&(r.parent=null,i(r));e.children.clear();}t(e,()=>{if(e.onDestroy){for(let r=0;r<e.onDestroy.length;r++)try{e.onDestroy[r]();}catch(c){}e.onDestroy=null;}if(e.cleanup){for(let r=0;r<e.cleanup.length;r++)try{e.cleanup[r]();}catch(c){}e.cleanup=null;}}),e.effectScope.stop(),(n=e.parent)!=null&&n.children&&e.parent.children.delete(e),e.provides&&(e.provides.clear(),e.provides=null),e.onMount=null,e.onUpdate=null,e.children=null,e.parent=null;}}exports.createScope=f;exports.disposeScope=i;exports.getActiveScope=p;exports.runWithScope=t;//# sourceMappingURL=internal.cjs.js.map
2
- //# sourceMappingURL=internal.cjs.js.map
1
+ 'use strict';require('@estjs/shared');var signals=require('@estjs/signals');var o=null,p=0;function f(){return o}function a(e){o=e,signals.setCurrentScope(e==null?void 0:e.effectScope);}function S(e=o){let n=e?e.effectScope.run(()=>signals.effectScope()):signals.effectScope(true),r={id:++p,effectScope:n,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(r)),r}function t(e,n){let r=o;o=e;try{return e.effectScope.run(n)}finally{o=r;}}function i(e){var n;if(!(!e||e.isDestroyed)){if(e.isDestroyed=true,e.children&&e.children.size>0){for(let r of e.children)r&&(r.parent=null,i(r));e.children.clear();}t(e,()=>{if(e.onDestroy){for(let r=0;r<e.onDestroy.length;r++)try{e.onDestroy[r]();}catch(c){}e.onDestroy=null;}if(e.cleanup){for(let r=0;r<e.cleanup.length;r++)try{e.cleanup[r]();}catch(c){}e.cleanup=null;}}),e.effectScope.stop(),(n=e.parent)!=null&&n.children&&e.parent.children.delete(e),e.provides&&(e.provides.clear(),e.provides=null),e.onMount=null,e.onUpdate=null,e.children=null,e.parent=null;}}exports.createScope=S;exports.disposeScope=i;exports.getActiveScope=f;exports.runWithScope=t;exports.setActiveScope=a;
@@ -1,2 +1,2 @@
1
- export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-DSKAj-zW.cjs';
1
+ export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope, s as setActiveScope } from './internal-DR5pJGCO.cjs';
2
2
  import '@estjs/signals';
@@ -1,2 +1,2 @@
1
- export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-DSKAj-zW.js';
1
+ export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope, s as setActiveScope } from './internal-DR5pJGCO.js';
2
2
  import '@estjs/signals';
@@ -9,6 +9,10 @@ var scopeId = 0;
9
9
  function getActiveScope() {
10
10
  return activeScope;
11
11
  }
12
+ function setActiveScope(scope) {
13
+ activeScope = scope;
14
+ signals.setCurrentScope(scope == null ? void 0 : scope.effectScope);
15
+ }
12
16
  function createScope(parent = activeScope) {
13
17
  const reactiveScope = parent ? parent.effectScope.run(() => signals.effectScope()) : signals.effectScope(true);
14
18
  const scope = {
@@ -106,5 +110,6 @@ exports.createScope = createScope;
106
110
  exports.disposeScope = disposeScope;
107
111
  exports.getActiveScope = getActiveScope;
108
112
  exports.runWithScope = runWithScope;
113
+ exports.setActiveScope = setActiveScope;
109
114
  //# sourceMappingURL=internal.dev.cjs.js.map
110
115
  //# sourceMappingURL=internal.dev.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scope.ts"],"names":["effectScope","error"],"mappings":";;;;;;AA4CA,IAAI,WAAA,GAA4B,IAAA;AAGhC,IAAI,OAAA,GAAU,CAAA;AAOP,SAAS,cAAA,GAA+B;AAC7C,EAAA,OAAO,WAAA;AACT;AAoBO,SAAS,WAAA,CAAY,SAAuB,WAAA,EAAoB;AACrE,EAAA,MAAM,aAAA,GAAgB,MAAA,GAAS,MAAA,CAAO,WAAA,CAAY,GAAA,CAAI,MAAMA,mBAAA,EAAa,CAAA,GAAKA,mBAAA,CAAY,IAAI,CAAA;AAC9F,EAAA,MAAM,KAAA,GAAe;AAAA,IACnB,IAAI,EAAE,OAAA;AAAA,IACN,WAAA,EAAa,aAAA;AAAA,IACb,MAAA;AAAA,IACA,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,OAAA,EAAS,IAAA;AAAA;AAAA,IACT,OAAA,EAAS,IAAA;AAAA;AAAA,IACT,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,SAAA,EAAW,IAAA;AAAA;AAAA,IACX,SAAA,EAAW,KAAA;AAAA,IACX,WAAA,EAAa;AAAA,GACf;AAGA,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,IAAI,CAAC,OAAO,QAAA,EAAU;AACpB,MAAA,MAAA,CAAO,QAAA,uBAAe,GAAA,EAAI;AAAA,IAC5B;AACA,IAAA,MAAA,CAAO,QAAA,CAAS,IAAI,KAAK,CAAA;AAAA,EAC3B;AAEA,EAAA,OAAO,KAAA;AACT;AAUO,SAAS,YAAA,CAAgB,OAAc,EAAA,EAAgB;AAC5D,EAAA,MAAM,SAAA,GAAY,WAAA;AAClB,EAAA,WAAA,GAAc,KAAA;AAEd,EAAA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,CAAQ,QAAQ,CAAA,EAAA,EAAK;AAC7C,QAAA,IAAI;AACF,UAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAE;AAAA,QACnB,SAAS,MAAA,EAAQ;AACf,UAAa;AACX,YAAAA,YAAA,CAAM,CAAA,MAAA,EAAS,KAAA,CAAM,EAAE,CAAA,oBAAA,CAAA,EAAwB,MAAM,CAAA;AAAA,UACvD;AAAA,QACF;AAAA,MACF;AACA,MAAA,KAAA,CAAM,OAAA,GAAU,IAAA;AAAA,IAClB;AAAA,EACF,CAAC,CAAA;AAED,EAAA,KAAA,CAAM,YAAY,IAAA,EAAK;AAGvB,EAAA,IAAA,CAAI,EAAA,GAAA,KAAA,CAAM,MAAA,KAAN,IAAA,GAAA,MAAA,GAAA,EAAA,CAAc,QAAA,EAAU;AAC1B,IAAA,KAAA,CAAM,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,KAAK,CAAA;AAAA,EACpC;AAGA,EAAA,IAAI,MAAM,QAAA,EAAU;AAClB,IAAA,KAAA,CAAM,SAAS,KAAA,EAAM;AACrB,IAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AAAA,EACnB;AACA,EAAA,KAAA,CAAM,OAAA,GAAU,IAAA;AAChB,EAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AACjB,EAAA,KAAA,CAAM,QAAA,GAAW,IAAA;AAGjB,EAAA,KAAA,CAAM,MAAA,GAAS,IAAA;AACjB","file":"internal.dev.cjs.js","sourcesContent":["import { error } from '@estjs/shared';\nimport { type EffectScope, effectScope, setCurrentScope } from '@estjs/signals';\nimport type { InjectionKey } from './provide';\n\n/**\n * Scope represents an execution context in the component tree.\n * It manages provides, cleanup functions, and lifecycle hooks.\n */\nexport interface Scope {\n /** Unique identifier for debugging */\n readonly id: number;\n\n /** Reactive effect scope tied to this template scope */\n readonly effectScope: EffectScope;\n\n /** Parent scope in the hierarchy */\n parent: Scope | null;\n\n /** Child scopes (lazy initialized) */\n children: Set<Scope> | null;\n\n /** Provided values (lazy initialized) */\n provides: Map<InjectionKey<unknown> | string | number | symbol, unknown> | null;\n\n /** Cleanup functions (lazy initialized) */\n cleanup: Array<() => void> | null;\n\n /** Mount lifecycle hooks (lazy initialized) */\n onMount: Array<() => void | Promise<void>> | null;\n\n /** Update lifecycle hooks (lazy initialized) */\n onUpdate: Array<() => void | Promise<void>> | null;\n\n /** Destroy lifecycle hooks (lazy initialized) */\n onDestroy: Array<() => void | Promise<void>> | null;\n\n /** Whether the scope has been mounted */\n isMounted: boolean;\n\n /** Whether the scope has been destroyed */\n isDestroyed: boolean;\n}\n\n/** Currently active scope */\nlet activeScope: Scope | null = null;\n\n/** Scope ID counter for unique identification */\nlet scopeId = 0;\n\n/**\n * Get the currently active scope.\n *\n * @returns The active scope or null if none is active.\n */\nexport function getActiveScope(): Scope | null {\n return activeScope;\n}\n\n/**\n * Set the active scope (internal use).\n *\n * @param scope - The scope to set as active.\n * @returns {void}\n */\nexport function setActiveScope(scope: Scope | null): void {\n activeScope = scope;\n setCurrentScope(scope?.effectScope);\n}\n\n/**\n * Create a new scope with optional parent.\n * If no parent is provided, uses the current active scope as parent.\n *\n * @param parent - Optional parent scope (defaults to active scope).\n * @returns A new scope instance.\n */\nexport function createScope(parent: Scope | null = activeScope): Scope {\n const reactiveScope = parent ? parent.effectScope.run(() => effectScope())! : effectScope(true);\n const scope: Scope = {\n id: ++scopeId,\n effectScope: reactiveScope,\n parent,\n children: null, // Lazy initialized\n provides: null, // Lazy initialized\n cleanup: null, // Lazy initialized\n onMount: null, // Lazy initialized\n onUpdate: null, // Lazy initialized\n onDestroy: null, // Lazy initialized\n isMounted: false,\n isDestroyed: false,\n };\n\n // Establish parent-child relationship\n if (parent) {\n if (!parent.children) {\n parent.children = new Set();\n }\n parent.children.add(scope);\n }\n\n return scope;\n}\n\n/**\n * Run a function within a scope, ensuring proper cleanup.\n * The previous active scope is restored even if the function throws.\n *\n * @param scope - The scope to run within.\n * @param fn - The function to execute.\n * @returns The return value of the function.\n */\nexport function runWithScope<T>(scope: Scope, fn: () => T): T {\n const prevScope = activeScope;\n activeScope = scope;\n\n try {\n return scope.effectScope.run(fn) as T;\n } finally {\n // Restore previous scope directly\n activeScope = prevScope;\n }\n}\n\n/**\n * Dispose a scope and all its children.\n * Children are disposed first (depth-first), then the scope itself.\n *\n * @param scope - The scope to dispose.\n * @returns {void}\n */\nexport function disposeScope(scope: Scope): void {\n // Idempotent: already destroyed\n if (!scope || scope.isDestroyed) {\n return;\n }\n\n // Mark destroyed immediately to block re-entrant disposeScope calls\n // (e.g. an onDestroy hook that accidentally disposes the same scope again).\n scope.isDestroyed = true;\n\n // Dispose children first (depth-first)\n // Iterate directly safely by unlinking parent reference to prevent mutation during iteration\n if (scope.children && scope.children.size > 0) {\n for (const child of scope.children) {\n if (child) {\n child.parent = null;\n disposeScope(child);\n }\n }\n scope.children.clear();\n }\n\n // Execute destroy lifecycle hooks and cleanup functions within the scope's\n // context so that inject/provide/getActiveScope work correctly in callbacks.\n //\n // NOTE: `scope.isDestroyed` is already `true` at this point — this is\n // intentional to prevent re-entrant `disposeScope()` calls from within\n // hooks. Callbacks that inspect `getActiveScope()?.isDestroyed` should\n // be aware of this.\n runWithScope(scope, () => {\n // Execute destroy lifecycle hooks\n if (scope.onDestroy) {\n for (let i = 0; i < scope.onDestroy.length; i++) {\n try {\n scope.onDestroy[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in destroy hook:`, error_);\n }\n }\n }\n scope.onDestroy = null;\n }\n\n // Execute cleanup functions\n if (scope.cleanup) {\n for (let i = 0; i < scope.cleanup.length; i++) {\n try {\n scope.cleanup[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in cleanup:`, error_);\n }\n }\n }\n scope.cleanup = null;\n }\n });\n\n scope.effectScope.stop();\n\n // Remove from parent's children\n if (scope.parent?.children) {\n scope.parent.children.delete(scope);\n }\n\n // Clear all internal collections to prevent memory leaks\n if (scope.provides) {\n scope.provides.clear();\n scope.provides = null;\n }\n scope.onMount = null;\n scope.onUpdate = null;\n scope.children = null;\n\n // Break parent reference to prevent memory leaks\n scope.parent = null;\n}\n\n/**\n * Register a cleanup function in the current scope.\n * The function will be called when the scope is disposed.\n *\n * @param fn - The cleanup function.\n */\nexport function onCleanup(fn: () => void): void {\n const scope = activeScope;\n\n if (!scope) {\n if (__DEV__) {\n error('onCleanup() must be called within a scope');\n }\n return;\n }\n\n // Lazy initialize cleanup array\n if (!scope.cleanup) {\n scope.cleanup = [];\n }\n\n scope.cleanup.push(fn);\n}\n"]}
1
+ {"version":3,"sources":["../src/scope.ts"],"names":["setCurrentScope","effectScope","error"],"mappings":";;;;;;AA4CA,IAAI,WAAA,GAA4B,IAAA;AAGhC,IAAI,OAAA,GAAU,CAAA;AAOP,SAAS,cAAA,GAA+B;AAC7C,EAAA,OAAO,WAAA;AACT;AAQO,SAAS,eAAe,KAAA,EAA2B;AACxD,EAAA,WAAA,GAAc,KAAA;AACd,EAAAA,uBAAA,CAAgB,+BAAO,WAAW,CAAA;AACpC;AASO,SAAS,WAAA,CAAY,SAAuB,WAAA,EAAoB;AACrE,EAAA,MAAM,aAAA,GAAgB,MAAA,GAAS,MAAA,CAAO,WAAA,CAAY,GAAA,CAAI,MAAMC,mBAAA,EAAa,CAAA,GAAKA,mBAAA,CAAY,IAAI,CAAA;AAC9F,EAAA,MAAM,KAAA,GAAe;AAAA,IACnB,IAAI,EAAE,OAAA;AAAA,IACN,WAAA,EAAa,aAAA;AAAA,IACb,MAAA;AAAA,IACA,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,OAAA,EAAS,IAAA;AAAA;AAAA,IACT,OAAA,EAAS,IAAA;AAAA;AAAA,IACT,QAAA,EAAU,IAAA;AAAA;AAAA,IACV,SAAA,EAAW,IAAA;AAAA;AAAA,IACX,SAAA,EAAW,KAAA;AAAA,IACX,WAAA,EAAa;AAAA,GACf;AA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GAAS,IAAA;AACjB","file":"internal.dev.cjs.js","sourcesContent":["import { error } from '@estjs/shared';\nimport { type EffectScope, effectScope, setCurrentScope } from '@estjs/signals';\nimport type { InjectionKey } from './provide';\n\n/**\n * Scope represents an execution context in the component tree.\n * It manages provides, cleanup functions, and lifecycle hooks.\n */\nexport interface Scope {\n /** Unique identifier for debugging */\n readonly id: number;\n\n /** Reactive effect scope tied to this template scope */\n readonly effectScope: EffectScope;\n\n /** Parent scope in the hierarchy */\n parent: Scope | null;\n\n /** Child scopes (lazy initialized) */\n children: Set<Scope> | null;\n\n /** Provided values (lazy initialized) */\n provides: Map<InjectionKey<unknown> | string | number | symbol, unknown> | null;\n\n /** Cleanup functions (lazy initialized) */\n cleanup: Array<() => void> | null;\n\n /** Mount lifecycle hooks (lazy initialized) */\n onMount: Array<() => void | Promise<void>> | null;\n\n /** Update lifecycle hooks (lazy initialized) */\n onUpdate: Array<() => void | Promise<void>> | null;\n\n /** Destroy lifecycle hooks (lazy initialized) */\n onDestroy: Array<() => void | Promise<void>> | null;\n\n /** Whether the scope has been mounted */\n isMounted: boolean;\n\n /** Whether the scope has been destroyed */\n isDestroyed: boolean;\n}\n\n/** Currently active scope */\nlet activeScope: Scope | null = null;\n\n/** Scope ID counter for unique identification */\nlet scopeId = 0;\n\n/**\n * Get the currently active scope.\n *\n * @returns The active scope or null if none is active.\n */\nexport function getActiveScope(): Scope | null {\n return activeScope;\n}\n\n/**\n * Set the active scope (internal use).\n *\n * @param scope - The scope to set as active.\n * @returns {void}\n */\nexport function setActiveScope(scope: Scope | null): void {\n activeScope = scope;\n setCurrentScope(scope?.effectScope);\n}\n\n/**\n * Create a new scope with optional parent.\n * If no parent is provided, uses the current active scope as parent.\n *\n * @param parent - Optional parent scope (defaults to active scope).\n * @returns A new scope instance.\n */\nexport function createScope(parent: Scope | null = activeScope): Scope {\n const reactiveScope = parent ? parent.effectScope.run(() => effectScope())! : effectScope(true);\n const scope: Scope = {\n id: ++scopeId,\n effectScope: reactiveScope,\n parent,\n children: null, // Lazy initialized\n provides: null, // Lazy initialized\n cleanup: null, // Lazy initialized\n onMount: null, // Lazy initialized\n onUpdate: null, // Lazy initialized\n onDestroy: null, // Lazy initialized\n isMounted: false,\n isDestroyed: false,\n };\n\n // Establish parent-child relationship\n if (parent) {\n if (!parent.children) {\n parent.children = new Set();\n }\n parent.children.add(scope);\n }\n\n return scope;\n}\n\n/**\n * Run a function within a scope, ensuring proper cleanup.\n * The previous active scope is restored even if the function throws.\n *\n * @param scope - The scope to run within.\n * @param fn - The function to execute.\n * @returns The return value of the function.\n */\nexport function runWithScope<T>(scope: Scope, fn: () => T): T {\n const prevScope = activeScope;\n activeScope = scope;\n\n try {\n return scope.effectScope.run(fn) as T;\n } finally {\n // Restore previous scope directly\n activeScope = prevScope;\n }\n}\n\n/**\n * Dispose a scope and all its children.\n * Children are disposed first (depth-first), then the scope itself.\n *\n * @param scope - The scope to dispose.\n * @returns {void}\n */\nexport function disposeScope(scope: Scope): void {\n // Idempotent: already destroyed\n if (!scope || scope.isDestroyed) {\n return;\n }\n\n // Mark destroyed immediately to block re-entrant disposeScope calls\n // (e.g. an onDestroy hook that accidentally disposes the same scope again).\n scope.isDestroyed = true;\n\n // Dispose children first (depth-first)\n // Iterate directly safely by unlinking parent reference to prevent mutation during iteration\n if (scope.children && scope.children.size > 0) {\n for (const child of scope.children) {\n if (child) {\n child.parent = null;\n disposeScope(child);\n }\n }\n scope.children.clear();\n }\n\n // Execute destroy lifecycle hooks and cleanup functions within the scope's\n // context so that inject/provide/getActiveScope work correctly in callbacks.\n //\n // NOTE: `scope.isDestroyed` is already `true` at this point — this is\n // intentional to prevent re-entrant `disposeScope()` calls from within\n // hooks. Callbacks that inspect `getActiveScope()?.isDestroyed` should\n // be aware of this.\n runWithScope(scope, () => {\n // Execute destroy lifecycle hooks\n if (scope.onDestroy) {\n for (let i = 0; i < scope.onDestroy.length; i++) {\n try {\n scope.onDestroy[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in destroy hook:`, error_);\n }\n }\n }\n scope.onDestroy = null;\n }\n\n // Execute cleanup functions\n if (scope.cleanup) {\n for (let i = 0; i < scope.cleanup.length; i++) {\n try {\n scope.cleanup[i]();\n } catch (error_) {\n if (__DEV__) {\n error(`Scope(${scope.id}): Error in cleanup:`, error_);\n }\n }\n }\n scope.cleanup = null;\n }\n });\n\n scope.effectScope.stop();\n\n // Remove from parent's children\n if (scope.parent?.children) {\n scope.parent.children.delete(scope);\n }\n\n // Clear all internal collections to prevent memory leaks\n if (scope.provides) {\n scope.provides.clear();\n scope.provides = null;\n }\n scope.onMount = null;\n scope.onUpdate = null;\n scope.children = null;\n\n // Break parent reference to prevent memory leaks\n scope.parent = null;\n}\n\n/**\n * Register a cleanup function in the current scope.\n * The function will be called when the scope is disposed.\n *\n * @param fn - The cleanup function.\n */\nexport function onCleanup(fn: () => void): void {\n const scope = activeScope;\n\n if (!scope) {\n if (__DEV__) {\n error('onCleanup() must be called within a scope');\n }\n return;\n }\n\n // Lazy initialize cleanup array\n if (!scope.cleanup) {\n scope.cleanup = [];\n }\n\n scope.cleanup.push(fn);\n}\n"]}
@@ -1,3 +1,3 @@
1
- export { createScope, disposeScope, getActiveScope, runWithScope } from './chunk-JT6RSDKI.dev.esm.js';
1
+ export { createScope, disposeScope, getActiveScope, runWithScope, setActiveScope } from './chunk-OEKE4VTS.dev.esm.js';
2
2
  //# sourceMappingURL=internal.dev.esm.js.map
3
3
  //# sourceMappingURL=internal.dev.esm.js.map
@@ -1,2 +1 @@
1
- export{d as createScope,f as disposeScope,c as getActiveScope,e as runWithScope}from'./chunk-WWGSC3TY.esm.js';//# sourceMappingURL=internal.esm.js.map
2
- //# sourceMappingURL=internal.esm.js.map
1
+ export{e as createScope,g as disposeScope,c as getActiveScope,f as runWithScope,d as setActiveScope}from'./chunk-IA4OZ7NW.esm.js';
@@ -1,3 +1,2 @@
1
- 'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');var Be=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var We=(e,t)=>{var n={};for(var o in e)vt.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&Be)for(var o of Be(e))t.indexOf(o)<0&&Et.call(e,o)&&(n[o]=e[o]);return n};var Ce=(e,t,n)=>new Promise((o,r)=>{var l=s=>{try{c(n.next(s));}catch(a){r(a);}},i=s=>{try{c(n.throw(s));}catch(a){r(a);}},c=s=>s.done?o(s.value):Promise.resolve(s.value).then(l,i);c((n=n.apply(e,t)).next());});var ue="_$spread$";var Xe="http://www.w3.org/2000/svg",we="http://www.w3.org/2000/xlink",xe="http://www.w3.org/2000/xmlns/";var Ae=Symbol(""),ie=Symbol(""),Pe=Symbol(""),qe=Symbol("");var q=null,Nt=0;function C(){return q}function H(e=q){let t=e?e.effectScope.run(()=>signals.effectScope()):signals.effectScope(true),n={id:++Nt,effectScope:t,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(n)),n}function x(e,t){let n=q;q=e;try{return e.effectScope.run(t)}finally{q=n;}}function P(e){var t;if(!(!e||e.isDestroyed)){if(e.isDestroyed=true,e.children&&e.children.size>0){for(let n of e.children)n&&(n.parent=null,P(n));e.children.clear();}x(e,()=>{if(e.onDestroy){for(let n=0;n<e.onDestroy.length;n++)try{e.onDestroy[n]();}catch(o){}e.onDestroy=null;}if(e.cleanup){for(let n=0;n<e.cleanup.length;n++)try{e.cleanup[n]();}catch(o){}e.cleanup=null;}}),e.effectScope.stop(),(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),e.provides&&(e.provides.clear(),e.provides=null),e.onMount=null,e.onUpdate=null,e.children=null,e.parent=null;}}function k(e){let t=q;t&&(t.cleanup||(t.cleanup=[]),t.cleanup.push(e));}function G(e,t,n,o){if(t==="key"){o==null?e.removeAttribute(t):e.setAttribute(t,String(o));return}if(t===ue){let f=shared.isObject(n)?n:null,m=shared.isObject(o)?o:null;if(f)for(let h in f)h!==ue&&(!m||!(h in m))&&G(e,h,f[h],null);if(m)for(let h in m)h!==ue&&G(e,h,f==null?void 0:f[h],m[h]);return}let r=(e==null?void 0:e.namespaceURI)===Xe,l=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(n===o||t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110)return;let s=t.toLowerCase();if(s==="innerhtml"||s==="srcdoc")return;if(o==null){if(l)e.removeAttributeNS(we,t.slice(6));else if(i){let f=t.slice(6);e.removeAttributeNS(xe,f);}else e.removeAttribute(t);return}if(c){shared.includeBooleanAttr(o)?e.setAttribute(t,""):e.removeAttribute(t);return}let a=shared.isSymbol(o)?String(o):o;if((s==="href"||s==="src"||s==="xlink:href"||s==="action"||s==="formaction"||s==="poster")&&shared.isString(a)){let f=a.trim().toLowerCase();if(f.startsWith("javascript:")||f.startsWith("data:"))return}if(l){e.setAttributeNS(we,t,String(a));return}if(i){e.setAttributeNS(xe,t,String(a));return}if(r)e.setAttribute(t,String(a));else if(t in e)try{e[t]=a;}catch(f){e.setAttribute(t,String(a));}else e.setAttribute(t,String(a));}function fe(e,t,n,o=false){if(t===n)return;let r=de(n);if(!r){e.removeAttribute("class");return}(shared.isString(t)?t:de(t))!==r&&(o?e.setAttribute("class",r):e.className=r);}var de=shared.normalizeClassName;var Je=/\s*!important$/,Mt=["Webkit","Moz","ms"],ke={};function pe(e,t,n){let o=e.style;if(n&&shared.isString(n)){t!==n&&(o.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t)){let r=t;for(let l in r)(!n||n[l]==null)&&J(o,l,"");}else if(t&&shared.isString(t)){let r=/(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi,l;for(;(l=r.exec(t))!==null;){let i=l[1].trim();i&&n&&shared.isObject(n)&&n[i]==null&&J(o,i,"");}}if(n&&!shared.isString(n)){let r=n;for(let l in r){let i=r[l];(!t||shared.isString(t)||t[l]!==i)&&i!=null&&J(o,l,i);}}}function J(e,t,n){if(shared.isArray(n)){for(let r of n)J(e,t,r);return}if((n==null||n==="")&&(n=""),t.startsWith("--")){e.setProperty(t,n);return}let o=Lt(e,t);shared.isString(n)&&Je.test(n)?e.setProperty(shared.camelCase(o),n.replace(Je,""),"important"):e[o]=n;}function Lt(e,t){let n=ke[t];if(n)return n;let o=shared.camelCase(t);if(o!=="filter"&&o in e)return ke[t]=o;o=shared.capitalize(o);for(let r of Mt){let l=r+o;if(l in e)return ke[t]=l}return t}var Te=0;function Ze(){return String(Te++)}function Ht(){Te=0;}var $=false;function le(){return $}var Q=new Map;function Ot(e){let t=e.querySelectorAll("[data-hk]");for(let n of t){let o=n.dataset.hk;o!=null&&!Q.has(o)&&Q.set(o,n);}}var ye=[],se=new Map;function Vt(){if(typeof document=="undefined")return;let e=document.createNodeIterator(document.body,NodeFilter.SHOW_COMMENT),t;for(;t=e.nextNode();){let n=t.data;if(n==="teleport-anchor")ye.push(t);else if(n==="teleport-start"){let o=t.parentElement;if(!o)continue;let r=se.get(o);r||(r=[],se.set(o,r)),r.push(t);}}}function Re(){var e;return (e=ye.shift())!=null?e:null}function De(e){let t=se.get(e),n=t==null?void 0:t.shift();if(!n)return null;let o=[],r=n.nextSibling;for(;r;){if(r.nodeType===Node.COMMENT_NODE&&r.data==="teleport-end")return {start:n,end:r,nodes:o};o.push(r),r=r.nextSibling;}return null}function Me(e){$=true,Te=0,Q.clear(),ye.length=0,se.clear(),Ot(e),Vt();}function Le(){$=false,Q.clear(),ye.length=0,se.clear();}function jt(e){if(!shared.isBrowser())return ()=>{throw new Error("[essor] getRenderedElement called in non-browser environment")};let t=null;return ()=>{if(!$)return t||(t=me(e)),t();let n=Ze(),o=Q.get(n);return o?(Q.delete(n),o):(shared.warn(`[essor] hydration mismatch: no SSR element for key "${n}"`),t||(t=me(e)),t())}}function Kt(e,t,n,o){$||fe(e,t,n,o);}function Ut(e,t,n,o){$||G(e,t,n,o);}function $t(e,t,n){$||pe(e,t,n);}function Fe(e,t){return t&&t.parentNode===e?t:null}function et(e,t,n,o){let r=Fe(e,o),l=t.length,i=n.length;if(l===0&&i===0)return n;if(l===0){for(let d=0;d<i;d++)M(e,n[d],r);return n}if(i===0){for(let d=0;d<l;d++)j(t[d]);return []}let c=0,s=l-1,a=i-1;for(;c<=s&&c<=a&&t[c]===n[c];)c++;for(;s>=c&&a>=c&&t[s]===n[a];)s--,a--;if(c>s){if(c<=a){let d=a+1,f=Fe(e,d<i?n[d]:r);for(let m=c;m<=a;m++)M(e,n[m],f);}}else if(c>a)for(let d=c;d<=s;d++)j(t[d]);else zt(e,t,n,c,s,a,r);return n}function zt(e,t,n,o,r,l,i){let c=l-o+1,s=new Map;for(let p=o;p<=l;p++)s.set(n[p],p);let a=new Int32Array(c);a.fill(0);let d=0,f=false,m=0;for(let p=o;p<=r;p++){let g=t[p];if(d>=c){j(g);continue}let u=s.get(g);u===void 0?j(g):(a[u-o]=p+1,u>=m?m=u:f=true,d++);}let h=f?Ie(a):[],v=h.length-1;for(let p=c-1;p>=0;p--){let g=o+p,u=n[g],y=Fe(e,g+1<n.length?n[g+1]:i);a[p]===0?M(e,u,y):f&&(v<0||p!==h[v]?M(e,u,y):v--);}}function Ie(e){let t=new Int32Array(e.length),n=[0],o=e.length,r,l,i,c,s;for(r=0;r<o;r++){let a=e[r];if(a!==0){if(l=n[n.length-1],e[l]<a){t[r]=l,n.push(r);continue}for(i=0,c=n.length-1;i<c;)s=i+c>>1,e[n[s]]<a?i=s+1:c=s;a<e[n[i]]&&(i>0&&(t[r]=n[i-1]),n[i]=r);}}for(i=n.length,c=n[i-1];i-- >0;)n[i]=c,c=t[c];return n}function j(e){if(e)if(L(e))e.destroy();else {let t=e;t.parentNode&&t.remove();}}function M(e,t,n){if(!e||!t)return;let o=L(n)?n.firstChild:n;if(L(t)){t.mount(e,o);return}o?e.insertBefore(t,o):e.appendChild(t);}function Z(e){if(e instanceof Node||L(e))return e;let t=typeof e;return e==null||t==="string"||t==="number"||t==="boolean"||t==="symbol"?document.createTextNode(e===false||e==null?"":String(e)):document.createTextNode(String(e))}function z(e,t,n){if(!e)return;let o=C(),r=[],l=true,i=s=>{if(s instanceof Node)return [s];if(L(s))return [s];let a=typeof s;return s==null||a==="string"||a==="number"||a==="boolean"?[Z(s)]:shared.coerceArray(s).map(d=>shared.isFunction(d)?d():d).flatMap(d=>d).map(Z)},c=signals.effect(()=>{let s=()=>{let a=shared.isFunction(t)?t():t,d=i(a);if(l&&le()&&d.every(f=>f instanceof Node&&f.parentNode===e)){r=d,l=false;return}r=et(e,r,d,n),l=false;};o&&!o.isDestroyed?x(o,s):s();});return k(()=>{c.stop();for(let s of r)j(s);r=[];}),r}function Xt(e){return (e==null?void 0:e.firstChild)||null}function qt(e,t=1){for(;e&&t>0;)e=e.nextSibling,t--;return e||null}function Gt(e,t){if(!e||t<0)return null;let n=e.firstChild;for(;n&&t>0;)n=n.nextSibling,t--;return n||null}function ee(e,t,n,o){if(!(o!=null&&o.delegate))return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o);let r=o.delegate,l=a=>{let d=a.target;(d.matches(r)||d.closest(r))&&n.call(e,a);},s=o,{delegate:i}=s,c=We(s,["delegate"]);return e.addEventListener(t,l,c),()=>{e.removeEventListener(t,l,c);}}function He(e,t,n){let o=e[t];o||(o=[],e[t]=o),o.push(n);}function ot(e,t,n){let o=e.length;if(o===0)return;let r;for(let l=0;l<o;l++)try{let i=e[l]();if(shared.isPromise(i)){let c=i.catch(s=>{});(r||(r=[])).push(c);}}catch(i){}if(r)return Promise.all(r).then(()=>{})}function Oe(e){let t=C();if(t){if(t.isMounted){try{let n=e();shared.isPromise(n)&&n.catch(o=>{});}catch(n){}return}He(t,"onMount",e);}}function Yt(e){let t=C();t&&He(t,"onUpdate",e);}function te(e){let t=C();t&&He(t,"onDestroy",e);}function rt(e){if(e.isDestroyed)return;if(!e.onMount||e.onMount.length===0){e.isMounted=true;return}let t=e.onMount,n=x(e,()=>ot(t,e.id));return t.length=0,e.isMounted=true,n}function it(e){if(!(e.isDestroyed||!e.onUpdate||e.onUpdate.length===0))return x(e,()=>ot(e.onUpdate,e.id))}function lt(e,t,n=false){let o=n?new Set:null;for(let r of Object.getOwnPropertyNames(t))o==null||o.add(r),Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));if(o)for(let r of Object.getOwnPropertyNames(e))o.has(r)||delete e[r];}function en(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return n.get?n.get.call(e):n.value}var ct;ct="normal";var ne=class{constructor(t,n={}){this.component=t;this.props=n;this[ct]=true;this.scope=null;this.state=0;this.beforeNode=void 0;this.renderedNodes=[];this.firstChild=void 0;this.parentNode=void 0;this.rootEventCleanups=[];this.parentScope=C();let o={};lt(o,n),this.reactiveProps=signals.shallowReactive(o);}mount(t,n){var l;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)M(t,i,n);return this.state=2,this.renderedNodes}let o=H((l=this.parentScope)!=null?l:C());this.scope=o;let r=x(o,()=>{var c;let i=this.component(this.reactiveProps);return shared.isFunction(i)&&(i=i(this.reactiveProps)),(signals.isSignal(i)||signals.isComputed(i))&&(i=i.value),(c=z(t,i,n))!=null?c:[]});return this.renderedNodes=r,this.firstChild=r[0],this.syncSpecialProps(this.props),this.state=2,rt(o),this.renderedNodes}update(t){this.props=t;let n=this.scope;!n||n.isDestroyed||(lt(this.reactiveProps,t!=null?t:{},true),this.syncSpecialProps(t),it(n));}forceUpdate(){if(!this.parentNode)return;let t=this.parentNode,n=this.beforeNode;this.destroy(),this.mount(t,n);}destroy(){let t=this.scope;if(!(!t||t.isDestroyed)){this.scope=null,this.releaseSpecialProps(),P(t);for(let n of this.renderedNodes)j(n);this.renderedNodes=[],this.firstChild=void 0,this.parentNode=void 0;}}syncSpecialProps(t){if(!t)return;let n=this.firstChild;if(n){this.releaseSpecialProps();for(let o of Object.getOwnPropertyNames(t)){let r=en(t,o);if(o==="ref"){this.rootRefCleanup=this.bindRootRef(r,n);continue}if(shared.isOn(o)&&shared.isFunction(r)){let l=o.slice(2).toLowerCase();this.rootEventCleanups.push(ee(n,l,r));}}}}releaseSpecialProps(){for(let t of this.rootEventCleanups)t();this.rootEventCleanups.length=0,this.rootRefCleanup&&(this.rootRefCleanup(),this.rootRefCleanup=void 0);}bindRootRef(t,n){if(shared.isFunction(t))return t(n),()=>t(null);if(signals.isSignal(t)){let o=t,r=o.value;return o.value=n,()=>{o.value===n&&(o.value=r);}}}};function L(e){return !!e&&!!e.normal}function he(e,t){return L(e)?e:new ne(e,t)}function me(e){let t,n=()=>{let o=document.createElement("template");o.innerHTML=e;let r=o.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=n())).cloneNode(true)}function tn(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;n.innerHTML&&(n.innerHTML="");let r=H(),l;try{x(r,()=>{let i=he(e);L(i)&&(l=i,M(n,i));});}catch(i){throw P(r),i}return {root:l,unmount:()=>{P(r),l==null||l.destroy();}}}function nn(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;Me(n);let o=H(),r;try{x(o,()=>{let l=he(e);L(l)&&(r=l,z(n,l));});}catch(l){throw P(o),l}finally{Le();}return {root:r,unmount:()=>{P(o),r==null||r.destroy();}}}function je(e,t){let n=C();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function ce(e,t){let n=C();if(!n)return t;let o=n;for(;o;){if(o.provides&&o.provides.has(e))return o.provides.get(e);o=o.parent;}return t}function Ke(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function dt(e){let t=e.target,n=e.type,o=e.target,r=e.currentTarget,l=()=>{let c=t[`_$${n}`];if(c&&shared.isFunction(c)&&!t.disabled){let s=t[`${n}Data`];if(s?c.call(t,s,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!shared.isString(t.host)&&!t.host._$host&&shared.isFunction(t.contains)&&t.contains(e.target)&&Ke(e,t.host),true},i=()=>{for(;l()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();Ke(e,c[0]);for(let s=0;s<c.length-2&&(t=c[s],!!l());s++){if(t._$host){t=t._$host,i();break}if(t.parentNode===r)break}}else i();Ke(e,o);}var ge=Symbol("_$EVENTS");function rn(e,t=window.document){let n=t,o=n[ge]||(n[ge]=new Set);for(let r of e)o.has(r)||(o.add(r),t.addEventListener(r,dt));}function sn(e=window.document){let t=e,n=t[ge];if(n){for(let o of n.keys())e.removeEventListener(o,dt);delete t[ge];}}function oe(e,t,n,o){let r=ee(e,t,n,o);C()&&k(r);}function Ue(e,t){let n=e,o=t==null?"":String(t);n.value!==o&&(n.value=o);}var un={event:"change",forceChange:true,read:e=>e.checked,write(e,t){let n=e,o=!!t;n.checked!==o&&(n.checked=o);}},dn={event:"change",forceChange:true,read(e){let t=e;return t.checked?t.value:""},write(e,t){let n=e,o=String(t)===n.value;n.checked!==o&&(n.checked=o);}},fn={event:"change",forceChange:true,read:e=>e.files,write(){}},pn={event:"input",ime:true,read:e=>e.value,write:Ue},mn={event:"input",ime:true,read:e=>e.value,write:Ue},yn={event:"change",forceChange:true,read(e){let t=e;return t.multiple?Array.from(t.selectedOptions,n=>n.value):t.value},write(e,t){let n=e;if(n.multiple){let o=new Set((Array.isArray(t)?t:[]).map(String));for(let r of Array.from(n.options))r.selected=o.has(r.value);}else Ue(e,t);}};function hn(e,t){switch(e.nodeName){case "INPUT":return t==="checked"?e.type==="radio"?dn:un:t==="files"?fn:pn;case "SELECT":return yn;case "TEXTAREA":return mn;default:return {event:"input",read:n=>n[t],write(n,o){n[t]=o;}}}}function gn(e,t,n){if(!shared.isString(e))return e;let o=e;if(t&&(o=o.trim()),n&&o!==""){let r=Number(o);if(!Number.isNaN(r))return r}return o}function Sn(e){let t=e.getRootNode();return (t instanceof Document||t instanceof ShadowRoot)&&t.activeElement===e}function vn(e,t,n,o,r={}){if(!e)return;let{event:l,read:i,write:c,forceChange:s,ime:a}=hn(e,t),d=r.trim===true,f=r.number===true,m=r.lazy===true,h=(d||f)&&t!=="files",v=shared.isFunction(n)?n:()=>n,p=h?N=>gn(N,d,f):N=>N,g=false,u=m||s?"change":l,y=()=>{if(g)return;let N=i(e);if(N===void 0)return;let A=p(N);Object.is(v(),A)||o(A);};oe(e,u,y),!m&&h&&u!=="change"&&oe(e,"change",()=>c(e,p(i(e)))),a&&!m&&(oe(e,"compositionstart",()=>{g=true;}),oe(e,"compositionend",()=>{g&&(g=false,y());}));let E=signals.effect(()=>{let N=v();a&&!m&&Sn(e)&&(g||Object.is(p(i(e)),N))||c(e,N);});C()&&k(()=>E.stop());}function En(e,t){let n=new Set(t);return new Proxy(e,{get(o,r){if(!n.has(r))return Reflect.get(o,r)},ownKeys(o){return Reflect.ownKeys(o).filter(r=>!n.has(r))},getOwnPropertyDescriptor(o,r){if(!n.has(r))return Reflect.getOwnPropertyDescriptor(o,r)},has(o,r){return n.has(r)?false:Reflect.has(o,r)}})}function ft(e){return !e||e.children==null?null:e.children}ft[Ae]=true;function Nn(e){return !!e&&!!e[Ae]}function Se(e){let t=shared.isFunction(e.target)?e.target():e.target;return t==null?null:shared.isString(t)?document.querySelector(t):t}function ve(e){return shared.isFunction(e.disabled)?!!e.disabled():!!e.disabled}function mt(e){if(le()){let d=Cn(e);if(d)return d}let t=document.createComment("portal");t[ie]=true;let{children:n}=e;if(n==null)return t;let o=C(),r=null,l=(d,f)=>{r=H(o),x(r,()=>{z(d,()=>n,f);});},i=()=>{r&&(P(r),r=null);},c=(d,f)=>{if(i(),d){let m=t.parentNode;if(!m)return;l(m,t);return}f&&l(f);},s=false,a=signals.effect(()=>{let d=ve(e),f=d?null:Se(e);s&&c(d,f);});return Oe(()=>{s=!0;let d=ve(e),f=d?null:Se(e);if(d||f){c(d,f);return}queueMicrotask(()=>{t.parentNode&&c(ve(e),Se(e));});}),k(()=>{a.stop(),i();}),t}mt[ie]=true;function Cn(e){if(ve(e))return null;let t=Re();if(!t)return null;let n=Se(e);return !n||!De(n)?null:(t[ie]=true,t)}function wn(e){return !!e&&!!e[ie]}function Ne(e){for(;e.firstChild;)e.removeChild(e.firstChild);}function yt(e){let t=e;for(;shared.isFunction(t);)t=t();return signals.isSignal(t)||signals.isComputed(t)?yt(t.value):t}var ae=Symbol("SuspenseContext");function ht(e){var v;if(!shared.isBrowser())return (v=e.fallback)!=null?v:"";let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,l=null,i=p=>{let g=yt(p);if(shared.isArray(g)){let u=[];for(let y of g){let E=i(y);shared.isArray(E)?u.push(...E):u.push(E);}return u}return Z(g)},c=p=>{let g=i(p),u=shared.isArray(g)?g:[g];for(let y of u)y!=null&&M(t,y);},s=()=>{Ne(t),e.fallback!=null&&c(e.fallback);},a=()=>{r||(r=true,s());},d=()=>{!r||!(l||e.children!=null&&!shared.isPromise(e.children))||(r=false,Ne(t),l?f(l):e.children!=null&&!shared.isPromise(e.children)&&f(e.children));},f=p=>{if(r||(Ne(t),p==null))return;let g=shared.isArray(p)?p:[p];for(let u of g)u!=null&&c(u);r&&s();},m={register:p=>{o++,a(),p.then(()=>{n&&(o--,o===0&&d());}).catch(g=>{n&&(o--,o===0&&d());});},increment:()=>{o++,a();},decrement:()=>{o=Math.max(0,o-1),o===0&&d();}};je(ae,m);let h=e.children;return shared.isPromise(h)?(h.then(p=>{l=p;}).catch(()=>{}),m.register(h)):h!=null?f(h):a(),te(()=>{n=false,o=0,l=null,Ne(t),t.remove();}),t}ht[Pe]=true;function Tn(e){return !!e&&!!e[Pe]}function Rn(e,t){let n=signals.signal(t==null?void 0:t.initialValue),o=signals.signal(true),r=signals.signal(null),l=signals.signal("pending"),i=0,c=null,s=false,a=ce(ae,null),d=()=>Ce(null,null,function*(){let h=++i;o.value=true,l.value="pending",r.value=null,s=false,a&&a.increment();try{let v=e();c=v,v.catch(()=>{});let p=yield v;h===i&&(n.value=p,l.value="ready",o.value=!1);}catch(v){h===i&&(r.value=v instanceof Error?v:new Error(String(v)),l.value="errored",o.value=false);}finally{a&&a.decrement();}});d();let f=(()=>(!s&&o.value&&c&&a&&(s=true,a.register(c)),n.value));return f.loading=o,f.error=r,f.state=l,[f,{mutate:h=>{n.value=h,l.value="ready",o.value=false,r.value=null;},refetch:()=>Ce(null,null,function*(){yield d();})}]}function gt(e){return shared.isFunction(e)?e:e.default}function ze(e,t,n){let o=new ne(t,n);return o.mount(e),o}function Mn(e,t={}){let{delay:n=200,timeout:o,ssr:r="blocking",onError:l}=t;if(typeof window=="undefined"){if(r==="client-only"){let g=()=>"";return g.__asyncLoader=e,g.__asyncResolved=()=>null,g}let m=null,h=null,v=()=>h||(h=e().then(g=>{m=gt(g);}).catch(()=>{}),h);v();let p=g=>m?m(g):"";return p.__asyncLoader=v,p.__asyncResolved=()=>m,p}let i=null,c=null,s="pending",a=null;function d(){return a||(a=e().then(m=>{i=gt(m),s="resolved";}).catch(m=>{c=m instanceof Error?m:new Error(String(m)),s="errored",a=null;}),a)}d();function f(m){var B;if(s==="resolved"&&i){let b=document.createElement("div");b.style.display="contents";let F=ze(b,i,m);return k(()=>F.destroy()),b}if(s==="errored"&&c){let b=document.createElement("div");if(b.style.display="contents",t.error){let F=true,R=null,K=(X,S)=>{F&&(R==null||R.destroy(),R=ze(b,X,S));},W=()=>{a=null,s="pending",c=null,t.loading&&K(t.loading),d().then(()=>{F&&(s==="resolved"&&i?K(i,m):s==="errored"&&c&&t.error&&K(t.error,{error:c,retry:W}));});};K(t.error,{error:c,retry:W}),te(()=>{F=false,R==null||R.destroy(),R=null;});}return b}let h=document.createElement("div");h.style.display="contents";let v=true,p=null,g=null,u=null,y=(b,F)=>{v&&(p==null||p.destroy(),p=ze(h,b,F));},E=b=>()=>{a=null,s="pending",c=null,t.loading&&y(t.loading),d().then(()=>{s==="resolved"&&i?y(i,b):s==="errored"&&c&&t.error&&y(t.error,{error:c,retry:E(b)});});};te(()=>{v=false,p==null||p.destroy(),p=null,g!=null&&clearTimeout(g),u!=null&&clearTimeout(u);});let N=(B=ce(ae))!=null?B:null,A=b=>y(b,m),T=b=>{t.error&&y(t.error,{error:b,retry:E(m)});},O=()=>{t.loading&&y(t.loading);},V=d().then(()=>{v&&(s==="resolved"&&i?A(i):s==="errored"&&c&&(T(c),l&&l(c,E(m))),g!=null&&clearTimeout(g),u!=null&&clearTimeout(u));});return N&&N.register(V),n>0?g=setTimeout(()=>{v&&s==="pending"&&O();},n):t.loading&&O(),o!=null&&(u=setTimeout(()=>{if(v&&s==="pending"){let b=new Error(`[defineAsyncComponent] Timeout after ${o}ms`);c=b,s="errored",T(b),l&&l(b,E(m));}},o)),h}return f.__asyncLoader=d,f.__asyncResolved=()=>i,f}function St(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=[],l=e.key,i=e.children,c=()=>{var y,E;let u=e.each;return signals.isSignal(u)?(y=u.value)!=null?y:[]:shared.isFunction(u)?(E=u())!=null?E:[]:u!=null?u:[]},s=u=>l?l(u):u,a=u=>{if(Array.isArray(u)){let y=[];for(let E of u)y.push(...a(E));return y}return [Z(u)]},d=(u,y,E)=>{let N=a(u);for(let A of N)E?y.insertBefore(A,E):y.appendChild(A);return N},f=(u,y)=>{if(!e.fallback)return;r=d(e.fallback(),u,y);},m=()=>{for(let u of r)u.parentNode&&u.parentNode.removeChild(u);r=[];},h=(u,y,E,N)=>{let A=C(),T=H(A),O=[];return x(T,()=>{O=d(i(u,y),E,N);}),{key:s(u),item:u,nodes:O,scope:T}},v=u=>{P(u.scope);for(let y of u.nodes)y.parentNode&&y.parentNode.removeChild(y);},p=signals.effect(()=>{let u=c(),y=n.parentNode;if(!y){if(u.length===0)f(t,n);else {o=new Array(u.length);let E=0;for(let N of u)o[E]=h(N,E,t,n),E++;}return}g(y,u);});function g(u,y){let E=o.length,N=y.length;if(N===0){for(let S=0;S<E;S++)v(o[S]);o=[],e.fallback&&r.length===0&&f(u,n);return}if(E===0||r.length>0){r.length>0&&m(),o=new Array(N);let S=document.createDocumentFragment();for(let w=0;w<N;w++)o[w]=h(y[w],w,S,null);u.insertBefore(S,n);return}let A=new Map;for(let S=0;S<E;S++){let w=o[S],I=A.get(w.key),U=[w,S];I?I.push(U):A.set(w.key,[U]);}let T=new Array(N),O=[],V=null,B=new Int32Array(N),b=false,F=0,R=new Array(N);for(let S=0;S<N;S++)R[S]=s(y[S]);for(let S=0;S<N;S++){let w=y[S],I=R[S],U=A.get(I);if(U&&U.length>0){let[re,D]=U.shift();Object.is(re.item,w)?(re.item=w,T[S]=re,B[S]=D+1,D<F?b=true:F=D):(V||(V=document.createDocumentFragment()),v(re),T[S]=h(w,S,V,null));}else V||(V=document.createDocumentFragment()),T[S]=h(w,S,V,null);}for(let S of A.values())for(let[w]of S)O.push(w);for(let S of O)v(S);let K=b?Ie(B):[],W=K.length-1,X=n;for(let S=N-1;S>=0;S--){let I=T[S].nodes;if(!(B[S]===0)&&b&&W>=0&&S===K[W]){W--;for(let D=I.length-1;D>=0;D--)X=I[D];continue}for(let D=I.length-1;D>=0;D--){let _e=I[D];_e.nextSibling!==X&&u.insertBefore(_e,X),X=_e;}}o=T;}return k(()=>{p.stop();for(let u of o)v(u);o=[],m(),n.parentNode&&n.parentNode.removeChild(n);}),t}St[qe]=true;
2
- exports.Component=ne;exports.For=St;exports.Fragment=ft;exports.Portal=mt;exports.Suspense=ht;exports.addEvent=ee;exports.addEventListener=oe;exports.beginHydration=Me;exports.bindElement=vn;exports.child=Xt;exports.clearDelegatedEvents=sn;exports.consumeTeleportAnchor=Re;exports.consumeTeleportBlock=De;exports.createApp=tn;exports.createComponent=he;exports.createResource=Rn;exports.defineAsyncComponent=Mn;exports.delegateEvents=rn;exports.endHydration=Le;exports.getHydrationKey=Ze;exports.getRenderedElement=jt;exports.hydrate=nn;exports.inject=ce;exports.insert=z;exports.isComponent=L;exports.isFragment=Nn;exports.isHydrating=le;exports.isPortal=wn;exports.isSuspense=Tn;exports.next=qt;exports.normalizeClass=de;exports.nthChild=Gt;exports.omitProps=En;exports.onDestroy=te;exports.onMount=Oe;exports.onUpdate=Yt;exports.patchAttr=G;exports.patchAttrHydrate=Ut;exports.patchClass=fe;exports.patchClassHydrate=Kt;exports.patchStyle=pe;exports.patchStyleHydrate=$t;exports.provide=je;exports.resetHydrationKey=Ht;exports.setStyle=J;exports.template=me;//# sourceMappingURL=template.cjs.js.map
3
- //# sourceMappingURL=template.cjs.js.map
1
+ 'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');var We=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var Be=(e,t)=>{var n={};for(var o in e)St.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&We)for(var o of We(e))t.indexOf(o)<0&&vt.call(e,o)&&(n[o]=e[o]);return n};var _e=(e,t,n)=>new Promise((o,r)=>{var s=l=>{try{c(n.next(l));}catch(a){r(a);}},i=l=>{try{c(n.throw(l));}catch(a){r(a);}},c=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,i);c((n=n.apply(e,t)).next());});var ue="_$spread$";var Xe="http://www.w3.org/2000/svg",we="http://www.w3.org/2000/xlink",xe="http://www.w3.org/2000/xmlns/";var Ae=Symbol(""),ie=Symbol(""),Pe=Symbol(""),qe=Symbol("");var q=null,Et=0;function _(){return q}function H(e=q){let t=e?e.effectScope.run(()=>signals.effectScope()):signals.effectScope(true),n={id:++Et,effectScope:t,parent:e,children:null,provides:null,cleanup:null,onMount:null,onUpdate:null,onDestroy:null,isMounted:false,isDestroyed:false};return e&&(e.children||(e.children=new Set),e.children.add(n)),n}function x(e,t){let n=q;q=e;try{return e.effectScope.run(t)}finally{q=n;}}function P(e){var t;if(!(!e||e.isDestroyed)){if(e.isDestroyed=true,e.children&&e.children.size>0){for(let n of e.children)n&&(n.parent=null,P(n));e.children.clear();}x(e,()=>{if(e.onDestroy){for(let n=0;n<e.onDestroy.length;n++)try{e.onDestroy[n]();}catch(o){}e.onDestroy=null;}if(e.cleanup){for(let n=0;n<e.cleanup.length;n++)try{e.cleanup[n]();}catch(o){}e.cleanup=null;}}),e.effectScope.stop(),(t=e.parent)!=null&&t.children&&e.parent.children.delete(e),e.provides&&(e.provides.clear(),e.provides=null),e.onMount=null,e.onUpdate=null,e.children=null,e.parent=null;}}function k(e){let t=q;t&&(t.cleanup||(t.cleanup=[]),t.cleanup.push(e));}function G(e,t,n,o){if(t==="key"){o==null?e.removeAttribute(t):e.setAttribute(t,String(o));return}if(t===ue){let d=shared.isObject(n)?n:null,m=shared.isObject(o)?o:null;if(d)for(let h in d)h!==ue&&(!m||!(h in m))&&G(e,h,d[h],null);if(m)for(let h in m)h!==ue&&G(e,h,d==null?void 0:d[h],m[h]);return}let r=(e==null?void 0:e.namespaceURI)===Xe,s=r&&t.startsWith("xlink:"),i=r&&t.startsWith("xmlns:"),c=shared.isSpecialBooleanAttr(t)||shared.isBooleanAttr(t);if(n===o||t.length>2&&t.charCodeAt(0)===111&&t.charCodeAt(1)===110)return;let l=t.toLowerCase();if(l==="innerhtml"||l==="srcdoc")return;if(o==null){if(s)e.removeAttributeNS(we,t.slice(6));else if(i){let d=t.slice(6);e.removeAttributeNS(xe,d);}else e.removeAttribute(t);return}if(c){shared.includeBooleanAttr(o)?e.setAttribute(t,""):e.removeAttribute(t);return}let a=shared.isSymbol(o)?String(o):o;if((l==="href"||l==="src"||l==="xlink:href"||l==="action"||l==="formaction"||l==="poster")&&shared.isString(a)){let d=a.trim().toLowerCase();if(d.startsWith("javascript:")||d.startsWith("data:"))return}if(s){e.setAttributeNS(we,t,String(a));return}if(i){e.setAttributeNS(xe,t,String(a));return}if(r)e.setAttribute(t,String(a));else if(t in e)try{e[t]=a;}catch(d){e.setAttribute(t,String(a));}else e.setAttribute(t,String(a));}function de(e,t,n,o=false){if(t===n)return;let r=fe(n);if(!r){e.removeAttribute("class");return}(shared.isString(t)?t:fe(t))!==r&&(o?e.setAttribute("class",r):e.className=r);}var fe=shared.normalizeClassName;var Je=/\s*!important$/,Lt=["Webkit","Moz","ms"],ke={};function pe(e,t,n){let o=e.style;if(n&&shared.isString(n)){t!==n&&(o.cssText=n);return}if(!n){t&&e.removeAttribute("style");return}if(t&&!shared.isString(t)){let r=t;for(let s in r)(!n||n[s]==null)&&J(o,s,"");}else if(t&&shared.isString(t)){let r=/(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi,s;for(;(s=r.exec(t))!==null;){let i=s[1].trim();i&&n&&shared.isObject(n)&&n[i]==null&&J(o,i,"");}}if(n&&!shared.isString(n)){let r=n;for(let s in r){let i=r[s];(!t||shared.isString(t)||t[s]!==i)&&i!=null&&J(o,s,i);}}}function J(e,t,n){if(shared.isArray(n)){for(let s of n)J(e,t,s);return}(n==null||n==="")&&(n="");let o=shared.isString(n)&&Je.test(n)?"important":"";if(o&&(n=n.replace(Je,"")),t.startsWith("--")){o?e.setProperty(t,n,o):e.setProperty(t,n);return}let r=It(e,t);o?e.setProperty(Ft(r),n,o):e[r]=n;}function Ft(e){let t=shared.kebabCase(e);return e.startsWith("Webkit")||e.startsWith("Moz")||e.startsWith("ms")?`-${t}`:t}function It(e,t){let n=ke[t];if(n)return n;let o=shared.camelCase(t);if(o!=="filter"&&o in e)return ke[t]=o;o=shared.capitalize(o);for(let r of Lt){let s=r+o;if(s in e)return ke[t]=s}return t}var Te=0;function Qe(){return String(Te++)}function Vt(){Te=0;}var U=false;function le(){return U}var Q=new Map;function jt(e){let t=e.querySelectorAll("[data-hk]");for(let n of t){let o=n.dataset.hk;o!=null&&!Q.has(o)&&Q.set(o,n);}}var ye=[],se=new Map;function Kt(){if(typeof document=="undefined")return;let e=document.createNodeIterator(document.body,NodeFilter.SHOW_COMMENT),t;for(;t=e.nextNode();){let n=t.data;if(n==="teleport-anchor")ye.push(t);else if(n==="teleport-start"){let o=t.parentElement;if(!o)continue;let r=se.get(o);r||(r=[],se.set(o,r)),r.push(t);}}}function Re(){var e;return (e=ye.shift())!=null?e:null}function De(e){let t=se.get(e),n=t==null?void 0:t.shift();if(!n)return null;let o=[],r=n.nextSibling;for(;r;){if(r.nodeType===Node.COMMENT_NODE&&r.data==="teleport-end")return {start:n,end:r,nodes:o};o.push(r),r=r.nextSibling;}return null}function Me(e){U=true,Te=0,Q.clear(),ye.length=0,se.clear(),jt(e),Kt();}function Le(){U=false,Q.clear(),ye.length=0,se.clear();}function $t(e){if(!shared.isBrowser())return ()=>{throw new Error("[essor] getRenderedElement called in non-browser environment")};let t=null;return ()=>{if(!U)return t||(t=me(e)),t();let n=Qe(),o=Q.get(n);return o?(Q.delete(n),o):(shared.warn(`[essor] hydration mismatch: no SSR element for key "${n}"`),t||(t=me(e)),t())}}function Ut(e,t,n,o){U||de(e,t,n,o);}function zt(e,t,n,o){U||G(e,t,n,o);}function Wt(e,t,n){U||pe(e,t,n);}function Fe(e,t){return t&&t.parentNode===e?t:null}function Ze(e,t,n,o){let r=Fe(e,o),s=t.length,i=n.length;if(s===0&&i===0)return n;if(s===0){for(let f=0;f<i;f++)M(e,n[f],r);return n}if(i===0){for(let f=0;f<s;f++)j(t[f]);return []}let c=0,l=s-1,a=i-1;for(;c<=l&&c<=a&&t[c]===n[c];)c++;for(;l>=c&&a>=c&&t[l]===n[a];)l--,a--;if(c>l){if(c<=a){let f=a+1,d=Fe(e,f<i?n[f]:r);for(let m=c;m<=a;m++)M(e,n[m],d);}}else if(c>a)for(let f=c;f<=l;f++)j(t[f]);else Bt(e,t,n,c,l,a,r);return n}function Bt(e,t,n,o,r,s,i){let c=s-o+1,l=new Map;for(let p=o;p<=s;p++)l.set(n[p],p);let a=new Int32Array(c);a.fill(0);let f=0,d=false,m=0;for(let p=o;p<=r;p++){let g=t[p];if(f>=c){j(g);continue}let u=l.get(g);u===void 0?j(g):(a[u-o]=p+1,u>=m?m=u:d=true,f++);}let h=d?Ie(a):[],v=h.length-1;for(let p=c-1;p>=0;p--){let g=o+p,u=n[g],y=Fe(e,g+1<n.length?n[g+1]:i);a[p]===0?M(e,u,y):d&&(v<0||p!==h[v]?M(e,u,y):v--);}}function Ie(e){let t=new Int32Array(e.length),n=[0],o=e.length,r,s,i,c,l;for(r=0;r<o;r++){let a=e[r];if(a!==0){if(s=n[n.length-1],e[s]<a){t[r]=s,n.push(r);continue}for(i=0,c=n.length-1;i<c;)l=i+c>>1,e[n[l]]<a?i=l+1:c=l;a<e[n[i]]&&(i>0&&(t[r]=n[i-1]),n[i]=r);}}for(i=n.length,c=n[i-1];i-- >0;)n[i]=c,c=t[c];return n}function j(e){if(e)if(L(e))e.destroy();else {let t=e;t.parentNode&&t.remove();}}function M(e,t,n){if(!e||!t)return;let o=L(n)?n.firstChild:n;if(L(t)){t.mount(e,o);return}o?e.insertBefore(t,o):e.appendChild(t);}function Z(e){if(e instanceof Node||L(e))return e;let t=typeof e;return e==null||t==="string"||t==="number"||t==="boolean"||t==="symbol"?document.createTextNode(e===false||e==null?"":String(e)):document.createTextNode(String(e))}function z(e,t,n){if(!e)return;let o=_(),r=[],s=true,i=l=>{if(l instanceof Node)return [l];if(L(l))return [l];let a=typeof l;return l==null||a==="string"||a==="number"||a==="boolean"?[Z(l)]:shared.coerceArray(l).map(f=>shared.isFunction(f)?f():f).flatMap(f=>f).map(Z)},c=signals.effect(()=>{let l=()=>{let a=shared.isFunction(t)?t():t,f=i(a);if(s&&le()&&f.every(d=>d instanceof Node&&d.parentNode===e)){r=f,s=false;return}r=Ze(e,r,f,n),s=false;};o&&!o.isDestroyed?x(o,l):l();});return k(()=>{c.stop();for(let l of r)j(l);r=[];}),r}function Gt(e){return (e==null?void 0:e.firstChild)||null}function Yt(e,t=1){for(;e&&t>0;)e=e.nextSibling,t--;return e||null}function Jt(e,t){if(!e||t<0)return null;let n=e.firstChild;for(;n&&t>0;)n=n.nextSibling,t--;return n||null}function ee(e,t,n,o){if(!(o!=null&&o.delegate))return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o);let r=o.delegate,s=a=>{let f=a.target;(f.matches(r)||f.closest(r))&&n.call(e,a);},l=o,{delegate:i}=l,c=Be(l,["delegate"]);return e.addEventListener(t,s,c),()=>{e.removeEventListener(t,s,c);}}function He(e,t,n){let o=e[t];o||(o=[],e[t]=o),o.push(n);}function nt(e,t,n){let o=e.length;if(o===0)return;let r;for(let s=0;s<o;s++)try{let i=e[s]();if(shared.isPromise(i)){let c=i.catch(l=>{});(r||(r=[])).push(c);}}catch(i){}if(r)return Promise.all(r).then(()=>{})}function Oe(e){let t=_();if(t){if(t.isMounted){try{let n=e();shared.isPromise(n)&&n.catch(o=>{});}catch(n){}return}He(t,"onMount",e);}}function Qt(e){let t=_();t&&He(t,"onUpdate",e);}function te(e){let t=_();t&&He(t,"onDestroy",e);}function ot(e){if(e.isDestroyed)return;if(!e.onMount||e.onMount.length===0){e.isMounted=true;return}let t=e.onMount,n=x(e,()=>nt(t,e.id));return t.length=0,e.isMounted=true,n}function rt(e){if(!(e.isDestroyed||!e.onUpdate||e.onUpdate.length===0))return x(e,()=>nt(e.onUpdate,e.id))}function st(e,t,n=false){let o=n?new Set:null;for(let r of Object.getOwnPropertyNames(t))o==null||o.add(r),Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));if(o)for(let r of Object.getOwnPropertyNames(e))o.has(r)||delete e[r];}function nn(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return n.get?n.get.call(e):n.value}var lt;lt="normal";var ne=class{constructor(t,n={}){this.component=t;this.props=n;this[lt]=true;this.scope=null;this.state=0;this.beforeNode=void 0;this.renderedNodes=[];this.firstChild=void 0;this.parentNode=void 0;this.rootEventCleanups=[];this.parentScope=_();let o={};st(o,n),this.reactiveProps=signals.shallowReactive(o);}mount(t,n){var s;if(this.parentNode=t,this.beforeNode=n,this.state=1,this.renderedNodes.length>0){for(let i of this.renderedNodes)M(t,i,n);return this.state=2,this.renderedNodes}let o=H((s=this.parentScope)!=null?s:_());this.scope=o;let r=x(o,()=>{var c;let i=this.component(this.reactiveProps);return shared.isFunction(i)&&(i=i(this.reactiveProps)),(signals.isSignal(i)||signals.isComputed(i))&&(i=i.value),(c=z(t,i,n))!=null?c:[]});return this.renderedNodes=r,this.firstChild=r[0],this.syncSpecialProps(this.props),this.state=2,ot(o),this.renderedNodes}update(t){this.props=t;let n=this.scope;!n||n.isDestroyed||(st(this.reactiveProps,t!=null?t:{},true),this.syncSpecialProps(t),rt(n));}forceUpdate(){if(!this.parentNode)return;let t=this.parentNode,n=this.beforeNode;this.destroy(),this.mount(t,n);}destroy(){let t=this.scope;if(!(!t||t.isDestroyed)){this.scope=null,this.releaseSpecialProps(),P(t);for(let n of this.renderedNodes)j(n);this.renderedNodes=[],this.firstChild=void 0,this.parentNode=void 0;}}syncSpecialProps(t){if(!t)return;let n=this.firstChild;if(n){this.releaseSpecialProps();for(let o of Object.getOwnPropertyNames(t)){let r=nn(t,o);if(o==="ref"){this.rootRefCleanup=this.bindRootRef(r,n);continue}if(shared.isOn(o)&&shared.isFunction(r)){let s=o.slice(2).toLowerCase();this.rootEventCleanups.push(ee(n,s,r));}}}}releaseSpecialProps(){for(let t of this.rootEventCleanups)t();this.rootEventCleanups.length=0,this.rootRefCleanup&&(this.rootRefCleanup(),this.rootRefCleanup=void 0);}bindRootRef(t,n){if(shared.isFunction(t))return t(n),()=>t(null);if(signals.isSignal(t)){let o=t,r=o.value;return o.value=n,()=>{o.value===n&&(o.value=r);}}}};function L(e){return !!e&&!!e.normal}function he(e,t){return L(e)?e:new ne(e,t)}function me(e){let t,n=()=>{let o=document.createElement("template");o.innerHTML=e;let r=o.content.firstChild;if(!r)throw new Error("Invalid template: empty content");return r};return ()=>(t||(t=n())).cloneNode(true)}function on(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;n.innerHTML&&(n.innerHTML="");let r=H(),s;try{x(r,()=>{let i=he(e);L(i)&&(s=i,M(n,i));});}catch(i){throw P(r),i}return {root:s,unmount:()=>{P(r),s==null||s.destroy();}}}function rn(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;Me(n);let o=H(),r;try{x(o,()=>{let s=he(e);L(s)&&(r=s,z(n,s));});}catch(s){throw P(o),s}finally{Le();}return {root:r,unmount:()=>{P(o),r==null||r.destroy();}}}function je(e,t){let n=_();n&&(n.provides||(n.provides=new Map),n.provides.set(e,t));}function ce(e,t){let n=_();if(!n)return t;let o=n;for(;o;){if(o.provides&&o.provides.has(e))return o.provides.get(e);o=o.parent;}return t}function Ke(e,t){Object.defineProperty(e,"target",{configurable:true,value:t});}function ut(e){let t=e.target,n=e.type,o=e.target,r=e.currentTarget,s=()=>{let c=t[`_$${n}`];if(c&&shared.isFunction(c)&&!t.disabled){let l=t[`${n}Data`];if(l?c.call(t,l,e):c.call(t,e),e.cancelBubble)return false}return t.host&&!shared.isString(t.host)&&!t.host._$host&&shared.isFunction(t.contains)&&t.contains(e.target)&&Ke(e,t.host),true},i=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:true,get(){return t||document}}),e.composedPath){let c=e.composedPath();Ke(e,c[0]);for(let l=0;l<c.length-2&&(t=c[l],!!s());l++){if(t._$host){t=t._$host,i();break}if(t.parentNode===r)break}}else i();Ke(e,o);}var ge=Symbol("_$EVENTS");function ln(e,t=window.document){let n=t,o=n[ge]||(n[ge]=new Set);for(let r of e)o.has(r)||(o.add(r),t.addEventListener(r,ut));}function cn(e=window.document){let t=e,n=t[ge];if(n){for(let o of n.keys())e.removeEventListener(o,ut);delete t[ge];}}function oe(e,t,n,o){let r=ee(e,t,n,o);_()&&k(r);}function $e(e,t){let n=e,o=t==null?"":String(t);n.value!==o&&(n.value=o);}var dn={event:"change",forceChange:true,read:e=>e.checked,write(e,t){let n=e,o=!!t;n.checked!==o&&(n.checked=o);}},pn={event:"change",forceChange:true,read(e){let t=e;return t.checked?t.value:""},write(e,t){let n=e,o=String(t)===n.value;n.checked!==o&&(n.checked=o);}},mn={event:"change",forceChange:true,read:e=>e.files,write(){}},yn={event:"input",ime:true,read:e=>e.value,write:$e},hn={event:"input",ime:true,read:e=>e.value,write:$e},gn={event:"change",forceChange:true,read(e){let t=e;return t.multiple?Array.from(t.selectedOptions,n=>n.value):t.value},write(e,t){let n=e;if(n.multiple){let o=new Set((Array.isArray(t)?t:[]).map(String));for(let r of Array.from(n.options))r.selected=o.has(r.value);}else $e(e,t);}};function Sn(e,t){switch(e.nodeName){case "INPUT":return t==="checked"?e.type==="radio"?pn:dn:t==="files"?mn:yn;case "SELECT":return gn;case "TEXTAREA":return hn;default:return {event:"input",read:n=>n[t],write(n,o){n[t]=o;}}}}function vn(e,t,n){if(!shared.isString(e))return e;let o=e;if(t&&(o=o.trim()),n&&o!==""){let r=Number(o);if(!Number.isNaN(r))return r}return o}function En(e){let t=e.getRootNode();return (t instanceof Document||t instanceof ShadowRoot)&&t.activeElement===e}function Nn(e,t,n,o,r={}){if(!e)return;let{event:s,read:i,write:c,forceChange:l,ime:a}=Sn(e,t),f=r.trim===true,d=r.number===true,m=r.lazy===true,h=(f||d)&&t!=="files",v=shared.isFunction(n)?n:()=>n,p=h?N=>vn(N,f,d):N=>N,g=false,u=m||l?"change":s,y=()=>{if(g)return;let N=i(e);if(N===void 0)return;let A=p(N);Object.is(v(),A)||o(A);};oe(e,u,y),!m&&h&&u!=="change"&&oe(e,"change",()=>c(e,p(i(e)))),a&&!m&&(oe(e,"compositionstart",()=>{g=true;}),oe(e,"compositionend",()=>{g&&(g=false,y());}));let E=signals.effect(()=>{let N=v();a&&!m&&En(e)&&(g||Object.is(p(i(e)),N))||c(e,N);});_()&&k(()=>E.stop());}function bn(e,t){let n=new Set(t);return new Proxy(e,{get(o,r){if(!n.has(r))return Reflect.get(o,r)},ownKeys(o){return Reflect.ownKeys(o).filter(r=>!n.has(r))},getOwnPropertyDescriptor(o,r){if(!n.has(r))return Reflect.getOwnPropertyDescriptor(o,r)},has(o,r){return n.has(r)?false:Reflect.has(o,r)}})}function ft(e){return !e||e.children==null?null:e.children}ft[Ae]=true;function Cn(e){return !!e&&!!e[Ae]}function Se(e){let t=shared.isFunction(e.target)?e.target():e.target;return t==null?null:shared.isString(t)?document.querySelector(t):t}function ve(e){return shared.isFunction(e.disabled)?!!e.disabled():!!e.disabled}function pt(e){if(le()){let f=xn(e);if(f)return f}let t=document.createComment("portal");t[ie]=true;let{children:n}=e;if(n==null)return t;let o=_(),r=null,s=(f,d)=>{r=H(o),x(r,()=>{z(f,()=>n,d);});},i=()=>{r&&(P(r),r=null);},c=(f,d)=>{if(i(),f){let m=t.parentNode;if(!m)return;s(m,t);return}d&&s(d);},l=false,a=signals.effect(()=>{let f=ve(e),d=f?null:Se(e);l&&c(f,d);});return Oe(()=>{l=!0;let f=ve(e),d=f?null:Se(e);if(f||d){c(f,d);return}queueMicrotask(()=>{t.parentNode&&c(ve(e),Se(e));});}),k(()=>{a.stop(),i();}),t}pt[ie]=true;function xn(e){if(ve(e))return null;let t=Re();if(!t)return null;let n=Se(e);return !n||!De(n)?null:(t[ie]=true,t)}function An(e){return !!e&&!!e[ie]}function Ne(e){for(;e.firstChild;)e.removeChild(e.firstChild);}function mt(e){let t=e;for(;shared.isFunction(t);)t=t();return signals.isSignal(t)||signals.isComputed(t)?mt(t.value):t}var ae=Symbol("SuspenseContext");function yt(e){var v;if(!shared.isBrowser())return (v=e.fallback)!=null?v:"";let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,s=null,i=p=>{let g=mt(p);if(shared.isArray(g)){let u=[];for(let y of g){let E=i(y);shared.isArray(E)?u.push(...E):u.push(E);}return u}return Z(g)},c=p=>{let g=i(p),u=shared.isArray(g)?g:[g];for(let y of u)y!=null&&M(t,y);},l=()=>{Ne(t),e.fallback!=null&&c(e.fallback);},a=()=>{r||(r=true,l());},f=()=>{!r||!(s||e.children!=null&&!shared.isPromise(e.children))||(r=false,Ne(t),s?d(s):e.children!=null&&!shared.isPromise(e.children)&&d(e.children));},d=p=>{if(r||(Ne(t),p==null))return;let g=shared.isArray(p)?p:[p];for(let u of g)u!=null&&c(u);r&&l();},m={register:p=>{o++,a(),p.then(()=>{n&&(o--,o===0&&f());}).catch(g=>{n&&(o--,o===0&&f());});},increment:()=>{o++,a();},decrement:()=>{o=Math.max(0,o-1),o===0&&f();}};je(ae,m);let h=e.children;return shared.isPromise(h)?(h.then(p=>{s=p;}).catch(()=>{}),m.register(h)):h!=null?d(h):a(),te(()=>{n=false,o=0,s=null,Ne(t),t.remove();}),t}yt[Pe]=true;function Dn(e){return !!e&&!!e[Pe]}function Mn(e,t){let n=signals.signal(t==null?void 0:t.initialValue),o=signals.signal(true),r=signals.signal(null),s=signals.signal("pending"),i=0,c=null,l=false,a=ce(ae,null),f=()=>_e(null,null,function*(){let h=++i;o.value=true,s.value="pending",r.value=null,l=false,a&&a.increment();try{let v=e();c=v,v.catch(()=>{});let p=yield v;h===i&&(n.value=p,s.value="ready",o.value=!1);}catch(v){h===i&&(r.value=v instanceof Error?v:new Error(String(v)),s.value="errored",o.value=false);}finally{a&&a.decrement();}});f();let d=(()=>(!l&&o.value&&c&&a&&(l=true,a.register(c)),n.value));return d.loading=o,d.error=r,d.state=s,[d,{mutate:h=>{n.value=h,s.value="ready",o.value=false,r.value=null;},refetch:()=>_e(null,null,function*(){yield f();})}]}function ht(e){return shared.isFunction(e)?e:e.default}function ze(e,t,n){let o=new ne(t,n);return o.mount(e),o}function Fn(e,t={}){let{delay:n=200,timeout:o,ssr:r="blocking",onError:s}=t;if(typeof window=="undefined"){if(r==="client-only"){let g=()=>"";return g.__asyncLoader=e,g.__asyncResolved=()=>null,g}let m=null,h=null,v=()=>h||(h=e().then(g=>{m=ht(g);}).catch(()=>{}),h);v();let p=g=>m?m(g):"";return p.__asyncLoader=v,p.__asyncResolved=()=>m,p}let i=null,c=null,l="pending",a=null;function f(){return a||(a=e().then(m=>{i=ht(m),l="resolved";}).catch(m=>{c=m instanceof Error?m:new Error(String(m)),l="errored",a=null;}),a)}f();function d(m){var W;if(l==="resolved"&&i){let b=document.createElement("div");b.style.display="contents";let F=ze(b,i,m);return k(()=>F.destroy()),b}if(l==="errored"&&c){let b=document.createElement("div");if(b.style.display="contents",t.error){let F=true,R=null,K=(X,S)=>{F&&(R==null||R.destroy(),R=ze(b,X,S));},B=()=>{a=null,l="pending",c=null,t.loading&&K(t.loading),f().then(()=>{F&&(l==="resolved"&&i?K(i,m):l==="errored"&&c&&t.error&&K(t.error,{error:c,retry:B}));});};K(t.error,{error:c,retry:B}),te(()=>{F=false,R==null||R.destroy(),R=null;});}return b}let h=document.createElement("div");h.style.display="contents";let v=true,p=null,g=null,u=null,y=(b,F)=>{v&&(p==null||p.destroy(),p=ze(h,b,F));},E=b=>()=>{a=null,l="pending",c=null,t.loading&&y(t.loading),f().then(()=>{l==="resolved"&&i?y(i,b):l==="errored"&&c&&t.error&&y(t.error,{error:c,retry:E(b)});});};te(()=>{v=false,p==null||p.destroy(),p=null,g!=null&&clearTimeout(g),u!=null&&clearTimeout(u);});let N=(W=ce(ae))!=null?W:null,A=b=>y(b,m),T=b=>{t.error&&y(t.error,{error:b,retry:E(m)});},O=()=>{t.loading&&y(t.loading);},V=f().then(()=>{v&&(l==="resolved"&&i?A(i):l==="errored"&&c&&(T(c),s&&s(c,E(m))),g!=null&&clearTimeout(g),u!=null&&clearTimeout(u));});return N&&N.register(V),n>0?g=setTimeout(()=>{v&&l==="pending"&&O();},n):t.loading&&O(),o!=null&&(u=setTimeout(()=>{if(v&&l==="pending"){let b=new Error(`[defineAsyncComponent] Timeout after ${o}ms`);c=b,l="errored",T(b),s&&s(b,E(m));}},o)),h}return d.__asyncLoader=f,d.__asyncResolved=()=>i,d}function gt(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=[],s=e.key,i=e.children,c=()=>{var y,E;let u=e.each;return signals.isSignal(u)?(y=u.value)!=null?y:[]:shared.isFunction(u)?(E=u())!=null?E:[]:u!=null?u:[]},l=u=>s?s(u):u,a=u=>{if(Array.isArray(u)){let y=[];for(let E of u)y.push(...a(E));return y}return [Z(u)]},f=(u,y,E)=>{let N=a(u);for(let A of N)E?y.insertBefore(A,E):y.appendChild(A);return N},d=(u,y)=>{if(!e.fallback)return;r=f(e.fallback(),u,y);},m=()=>{for(let u of r)u.parentNode&&u.parentNode.removeChild(u);r=[];},h=(u,y,E,N)=>{let A=_(),T=H(A),O=[];return x(T,()=>{O=f(i(u,y),E,N);}),{key:l(u),item:u,nodes:O,scope:T}},v=u=>{P(u.scope);for(let y of u.nodes)y.parentNode&&y.parentNode.removeChild(y);},p=signals.effect(()=>{let u=c(),y=n.parentNode;if(!y){if(u.length===0)d(t,n);else {o=new Array(u.length);let E=0;for(let N of u)o[E]=h(N,E,t,n),E++;}return}g(y,u);});function g(u,y){let E=o.length,N=y.length;if(N===0){for(let S=0;S<E;S++)v(o[S]);o=[],e.fallback&&r.length===0&&d(u,n);return}if(E===0||r.length>0){r.length>0&&m(),o=new Array(N);let S=document.createDocumentFragment();for(let w=0;w<N;w++)o[w]=h(y[w],w,S,null);u.insertBefore(S,n);return}let A=new Map;for(let S=0;S<E;S++){let w=o[S],I=A.get(w.key),$=[w,S];I?I.push($):A.set(w.key,[$]);}let T=new Array(N),O=[],V=null,W=new Int32Array(N),b=false,F=0,R=new Array(N);for(let S=0;S<N;S++)R[S]=l(y[S]);for(let S=0;S<N;S++){let w=y[S],I=R[S],$=A.get(I);if($&&$.length>0){let[re,D]=$.shift();Object.is(re.item,w)?(re.item=w,T[S]=re,W[S]=D+1,D<F?b=true:F=D):(V||(V=document.createDocumentFragment()),v(re),T[S]=h(w,S,V,null));}else V||(V=document.createDocumentFragment()),T[S]=h(w,S,V,null);}for(let S of A.values())for(let[w]of S)O.push(w);for(let S of O)v(S);let K=b?Ie(W):[],B=K.length-1,X=n;for(let S=N-1;S>=0;S--){let I=T[S].nodes;if(!(W[S]===0)&&b&&B>=0&&S===K[B]){B--;for(let D=I.length-1;D>=0;D--)X=I[D];continue}for(let D=I.length-1;D>=0;D--){let Ce=I[D];Ce.nextSibling!==X&&u.insertBefore(Ce,X),X=Ce;}}o=T;}return k(()=>{p.stop();for(let u of o)v(u);o=[],m(),n.parentNode&&n.parentNode.removeChild(n);}),t}gt[qe]=true;
2
+ exports.Component=ne;exports.For=gt;exports.Fragment=ft;exports.Portal=pt;exports.Suspense=yt;exports.addEvent=ee;exports.addEventListener=oe;exports.beginHydration=Me;exports.bindElement=Nn;exports.child=Gt;exports.clearDelegatedEvents=cn;exports.consumeTeleportAnchor=Re;exports.consumeTeleportBlock=De;exports.createApp=on;exports.createComponent=he;exports.createResource=Mn;exports.defineAsyncComponent=Fn;exports.delegateEvents=ln;exports.endHydration=Le;exports.getHydrationKey=Qe;exports.getRenderedElement=$t;exports.hydrate=rn;exports.inject=ce;exports.insert=z;exports.isComponent=L;exports.isFragment=Cn;exports.isHydrating=le;exports.isPortal=An;exports.isSuspense=Dn;exports.next=Yt;exports.normalizeClass=fe;exports.nthChild=Jt;exports.omitProps=bn;exports.onDestroy=te;exports.onMount=Oe;exports.onUpdate=Qt;exports.patchAttr=G;exports.patchAttrHydrate=zt;exports.patchClass=de;exports.patchClassHydrate=Ut;exports.patchStyle=pe;exports.patchStyleHydrate=Wt;exports.provide=je;exports.resetHydrationKey=Vt;exports.setStyle=J;exports.template=me;
@@ -1,6 +1,6 @@
1
1
  import { Signal, Computed } from '@estjs/signals';
2
- import { S as Scope } from './internal-DSKAj-zW.cjs';
3
- export { I as InjectionKey, i as inject, p as provide } from './internal-DSKAj-zW.cjs';
2
+ import { S as Scope } from './internal-DR5pJGCO.cjs';
3
+ export { I as InjectionKey, i as inject, p as provide } from './internal-DR5pJGCO.cjs';
4
4
  import { normalizeClassName } from '@estjs/shared';
5
5
 
6
6
  declare enum COMPONENT_STATE {
@@ -382,7 +382,7 @@ declare function patchStyle(el: HTMLElement, prev: unknown, next?: unknown): voi
382
382
  * @param val - Style value.
383
383
  * @private
384
384
  */
385
- declare function setStyle(style: CSSStyleDeclaration, name: string, val: string | string[]): void;
385
+ declare function setStyle(style: CSSStyleDeclaration, name: string, val: string | string[] | null | undefined): void;
386
386
 
387
387
  /**
388
388
  * Supported value types for the attribute patch layer.
@@ -1,6 +1,6 @@
1
1
  import { Signal, Computed } from '@estjs/signals';
2
- import { S as Scope } from './internal-DSKAj-zW.js';
3
- export { I as InjectionKey, i as inject, p as provide } from './internal-DSKAj-zW.js';
2
+ import { S as Scope } from './internal-DR5pJGCO.js';
3
+ export { I as InjectionKey, i as inject, p as provide } from './internal-DR5pJGCO.js';
4
4
  import { normalizeClassName } from '@estjs/shared';
5
5
 
6
6
  declare enum COMPONENT_STATE {
@@ -382,7 +382,7 @@ declare function patchStyle(el: HTMLElement, prev: unknown, next?: unknown): voi
382
382
  * @param val - Style value.
383
383
  * @private
384
384
  */
385
- declare function setStyle(style: CSSStyleDeclaration, name: string, val: string | string[]): void;
385
+ declare function setStyle(style: CSSStyleDeclaration, name: string, val: string | string[] | null | undefined): void;
386
386
 
387
387
  /**
388
388
  * Supported value types for the attribute patch layer.
@@ -343,17 +343,29 @@ function setStyle(style, name, val) {
343
343
  if (val == null || val === "") {
344
344
  val = "";
345
345
  }
346
+ const priority = shared.isString(val) && importantRE.test(val) ? "important" : "";
347
+ if (priority) {
348
+ val = val.replace(importantRE, "");
349
+ }
346
350
  if (name.startsWith("--")) {
347
- style.setProperty(name, val);
351
+ if (priority) {
352
+ style.setProperty(name, val, priority);
353
+ } else {
354
+ style.setProperty(name, val);
355
+ }
348
356
  return;
349
357
  }
350
358
  const prefixed = autoPrefix(style, name);
351
- if (shared.isString(val) && importantRE.test(val)) {
352
- style.setProperty(shared.camelCase(prefixed), val.replace(importantRE, ""), "important");
359
+ if (priority) {
360
+ style.setProperty(toCssPropertyName(prefixed), val, priority);
353
361
  } else {
354
362
  style[prefixed] = val;
355
363
  }
356
364
  }
365
+ function toCssPropertyName(name) {
366
+ const hyphenated = shared.kebabCase(name);
367
+ return name.startsWith("Webkit") || name.startsWith("Moz") || name.startsWith("ms") ? `-${hyphenated}` : hyphenated;
368
+ }
357
369
  function autoPrefix(style, rawName) {
358
370
  const cached = prefixCache[rawName];
359
371
  if (cached) {