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

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.
@@ -1,4 +1,5 @@
1
1
  import { error } from '@estjs/shared';
2
+ import { effectScope } from '@estjs/signals';
2
3
 
3
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
@@ -41,8 +42,10 @@ function getActiveScope() {
41
42
  return activeScope;
42
43
  }
43
44
  function createScope(parent = activeScope) {
45
+ const reactiveScope = parent ? parent.effectScope.run(() => effectScope()) : effectScope(true);
44
46
  const scope = {
45
47
  id: ++scopeId,
48
+ effectScope: reactiveScope,
46
49
  parent,
47
50
  children: null,
48
51
  // Lazy initialized
@@ -71,7 +74,7 @@ function runWithScope(scope, fn) {
71
74
  const prevScope = activeScope;
72
75
  activeScope = scope;
73
76
  try {
74
- return fn();
77
+ return scope.effectScope.run(fn);
75
78
  } finally {
76
79
  activeScope = prevScope;
77
80
  }
@@ -91,15 +94,13 @@ function disposeScope(scope) {
91
94
  }
92
95
  scope.children.clear();
93
96
  }
94
- const prevScope = activeScope;
95
- activeScope = scope;
96
- try {
97
+ runWithScope(scope, () => {
97
98
  if (scope.onDestroy) {
98
99
  for (let i = 0; i < scope.onDestroy.length; i++) {
99
100
  try {
100
101
  scope.onDestroy[i]();
101
102
  } catch (error_) {
102
- if (true) {
103
+ {
103
104
  error(`Scope(${scope.id}): Error in destroy hook:`, error_);
104
105
  }
105
106
  }
@@ -111,16 +112,15 @@ function disposeScope(scope) {
111
112
  try {
112
113
  scope.cleanup[i]();
113
114
  } catch (error_) {
114
- if (true) {
115
+ {
115
116
  error(`Scope(${scope.id}): Error in cleanup:`, error_);
116
117
  }
117
118
  }
118
119
  }
119
120
  scope.cleanup = null;
120
121
  }
121
- } finally {
122
- activeScope = prevScope;
123
- }
122
+ });
123
+ scope.effectScope.stop();
124
124
  if ((_a = scope.parent) == null ? void 0 : _a.children) {
125
125
  scope.parent.children.delete(scope);
126
126
  }
@@ -148,5 +148,5 @@ function onCleanup(fn) {
148
148
  }
149
149
 
150
150
  export { __async, __objRest, createScope, disposeScope, getActiveScope, onCleanup, runWithScope };
151
- //# sourceMappingURL=chunk-3E4EK64L.dev.esm.js.map
152
- //# sourceMappingURL=chunk-3E4EK64L.dev.esm.js.map
151
+ //# sourceMappingURL=chunk-JT6RSDKI.dev.esm.js.map
152
+ //# sourceMappingURL=chunk-JT6RSDKI.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;AAoBO,SAAS,WAAA,CAAY,SAAuB,WAAA,EAAoB;AACrE,EAAA,MAAM,aAAA,GAAgB,MAAA,GAAS,MAAA,CAAO,WAAA,CAAY,GAAA,CAAI,MAAM,WAAA,EAAa,CAAA,GAAK,WAAA,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,GAA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AAA,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-JT6RSDKI.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"]}
@@ -0,0 +1,2 @@
1
+ import'@estjs/shared';import {effectScope}from'@estjs/signals';var d=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var _=(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 m=(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,v=0;function w(){return t}function T(e=t){let r=e?e.effectScope.run(()=>effectScope()):effectScope(true),n={id:++v,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 h(e,r){let n=t;t=e;try{return e.effectScope.run(r)}finally{t=n;}}function s(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,s(n));e.children.clear();}h(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 k(e){let r=t;r&&(r.cleanup||(r.cleanup=[]),r.cleanup.push(e));}export{_ as a,m as b,w as c,T as d,h as e,s as f,k as g};//# sourceMappingURL=chunk-WWGSC3TY.esm.js.map
2
+ //# sourceMappingURL=chunk-WWGSC3TY.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scope.ts"],"names":["activeScope","scopeId","getActiveScope","createScope","parent","reactiveScope","effectScope","scope","runWithScope","fn","prevScope","disposeScope","_a","child","i","error_","onCleanup"],"mappings":"+DAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA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AM,QAAA,CAAW,IAAA,CAAA,CAEnBA,CAAAA,CAAM,OAAA,CAAU,IAAA,CAChBA,CAAAA,CAAM,QAAA,CAAW,IAAA,CACjBA,CAAAA,CAAM,QAAA,CAAW,IAAA,CAGjBA,CAAAA,CAAM,MAAA,CAAS,KAAA,CACjB,CAQO,SAASS,CAAAA,CAAUP,CAAAA,CAAsB,CAC9C,IAAMF,CAAAA,CAAQP,CAAAA,CAETO,CAAAA,GAQAA,CAAAA,CAAM,OAAA,GACTA,CAAAA,CAAM,OAAA,CAAU,EAAC,CAAA,CAGnBA,CAAAA,CAAM,OAAA,CAAQ,IAAA,CAAKE,CAAE,CAAA,EACvB","file":"chunk-WWGSC3TY.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"]}
@@ -1,3 +1,5 @@
1
+ import { EffectScope } from '@estjs/signals';
2
+
1
3
  /**
2
4
  * InjectionKey is a unique identifier for provided values.
3
5
  * Using Symbol ensures type safety and prevents key collisions.
@@ -30,6 +32,8 @@ declare function inject<T>(key: InjectionKey<T> | string | number, defaultValue?
30
32
  interface Scope {
31
33
  /** Unique identifier for debugging */
32
34
  readonly id: number;
35
+ /** Reactive effect scope tied to this template scope */
36
+ readonly effectScope: EffectScope;
33
37
  /** Parent scope in the hierarchy */
34
38
  parent: Scope | null;
35
39
  /** Child scopes (lazy initialized) */
@@ -1,3 +1,5 @@
1
+ import { EffectScope } from '@estjs/signals';
2
+
1
3
  /**
2
4
  * InjectionKey is a unique identifier for provided values.
3
5
  * Using Symbol ensures type safety and prevents key collisions.
@@ -30,6 +32,8 @@ declare function inject<T>(key: InjectionKey<T> | string | number, defaultValue?
30
32
  interface Scope {
31
33
  /** Unique identifier for debugging */
32
34
  readonly id: number;
35
+ /** Reactive effect scope tied to this template scope */
36
+ readonly effectScope: EffectScope;
33
37
  /** Parent scope in the hierarchy */
34
38
  parent: Scope | null;
35
39
  /** Child scopes (lazy initialized) */
@@ -1,2 +1,2 @@
1
- 'use strict';require('@estjs/shared');var r=null,c=0;function d(){return r}function p(e=r){let o={id:++c,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(o)),o}function a(e,o){let l=r;r=e;try{return o()}finally{r=l;}}function i(e){var l;if(!e||e.isDestroyed)return;if(e.isDestroyed=true,e.children&&e.children.size>0){for(let n of e.children)n&&(n.parent=null,i(n));e.children.clear();}let o=r;r=e;try{if(e.onDestroy){for(let n=0;n<e.onDestroy.length;n++)try{e.onDestroy[n]();}catch(t){}e.onDestroy=null;}if(e.cleanup){for(let n=0;n<e.cleanup.length;n++)try{e.cleanup[n]();}catch(t){}e.cleanup=null;}}finally{r=o;}(l=e.parent)!=null&&l.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=p;exports.disposeScope=i;exports.getActiveScope=d;exports.runWithScope=a;//# sourceMappingURL=internal.cjs.js.map
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
2
  //# sourceMappingURL=internal.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scope.ts"],"names":["activeScope","scopeId","getActiveScope","createScope","parent","scope","runWithScope","fn","prevScope","disposeScope","_a","child","i","error_"],"mappings":"sCAwCA,IAAIA,CAAAA,CAA4B,IAAA,CAG5BC,EAAU,CAAA,CAOP,SAASC,CAAAA,EAA+B,CAC7C,OAAOF,CACT,CAmBO,SAASG,CAAAA,CAAYC,CAAAA,CAAuBJ,CAAAA,CAAoB,CACrE,IAAMK,EAAe,CACnB,EAAA,CAAI,EAAEJ,CAAAA,CACN,MAAA,CAAAG,CAAAA,CACA,SAAU,IAAA,CACV,QAAA,CAAU,KACV,OAAA,CAAS,IA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,CACjB,QAASO,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIP,CAAAA,CAAM,OAAA,CAAQ,MAAA,CAAQO,IACxC,GAAI,CACFP,EAAM,OAAA,CAAQO,CAAC,IACjB,CAAA,MAASC,CAAAA,CAAQ,CAIjB,CAEFR,CAAAA,CAAM,QAAU,KAClB,CACF,CAAA,OAAE,CACAL,CAAAA,CAAcQ,EAChB,EAGIE,CAAAA,CAAAL,CAAAA,CAAM,MAAA,GAAN,IAAA,EAAAK,CAAAA,CAAc,QAAA,EAChBL,EAAM,MAAA,CAAO,QAAA,CAAS,MAAA,CAAOA,CAAK,CAAA,CAIhCA,CAAAA,CAAM,WACRA,CAAAA,CAAM,QAAA,CAAS,KAAA,EAAM,CACrBA,CAAAA,CAAM,QAAA,CAAW,MAEnBA,CAAAA,CAAM,OAAA,CAAU,IAAA,CAChBA,CAAAA,CAAM,QAAA,CAAW,IAAA,CACjBA,EAAM,QAAA,CAAW,IAAA,CAGjBA,CAAAA,CAAM,MAAA,CAAS,KACjB","file":"internal.cjs.js","sourcesContent":["import { error } from '@estjs/shared';\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 /** 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}\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 scope: Scope = {\n id: ++scopeId,\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 fn();\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 // We inline the scope-switching instead of calling `runWithScope()` to avoid\n // an extra function frame on the teardown hot path (disposeScope is called\n // recursively for every child scope in the tree).\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 const prevScope = activeScope;\n activeScope = scope;\n try {\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 } finally {\n activeScope = prevScope;\n }\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":["activeScope","scopeId","getActiveScope","createScope","parent","reactiveScope","effectScope","scope","runWithScope","fn","prevScope","disposeScope","_a","child","i","error_"],"mappings":"4EA4CA,IAAIA,CAAAA,CAA4B,IAAA,CAG5BC,CAAAA,CAAU,CAAA,CAOP,SAASC,CAAAA,EAA+B,CAC7C,OAAOF,CACT,CAoBO,SAASG,CAAAA,CAAYC,CAAAA,CAAuBJ,CAAAA,CAAoB,CACrE,IAAMK,CAAAA,CAAgBD,CAAAA,CAASA,CAAAA,CAAO,YAAY,GAAA,CAAI,IAAME,mBAAAA,EAAa,CAAA,CAAKA,mBAAAA,CAAY,IAAI,CAAA,CACxFC,CAAAA,CAAe,CACnB,EAAA,CAAI,EAAEN,CAAAA,CACN,WAAA,CAAaI,EACb,MAAA,CAAAD,CAAAA,CACA,QAAA,CAAU,IAAA,CACV,QAAA,CAAU,IAAA,CACV,OAAA,CAAS,IAAA,CACT,OAAA,CAAS,IAAA,CACT,QAAA,CAAU,IAAA,CACV,SAAA,CAAW,IAAA,CACX,UAAW,KAAA,CACX,WAAA,CAAa,KACf,CAAA,CAGA,OAAIA,CAAAA,GACGA,CAAAA,CAAO,QAAA,GACVA,CAAAA,CAAO,QAAA,CAAW,IAAI,GAAA,CAAA,CAExBA,CAAAA,CAAO,QAAA,CAAS,IAAIG,CAAK,CAAA,CAAA,CAGpBA,CACT,CAUO,SAASC,CAAAA,CAAgBD,CAAAA,CAAcE,CAAAA,CAAgB,CAC5D,IAAMC,CAAAA,CAAYV,CAAAA,CAClBA,CAAAA,CAAcO,CAAAA,CAEd,GAAI,CACF,OAAOA,CAAAA,CAAM,WAAA,CAAY,GAAA,CAAIE,CAAE,CACjC,CAAA,OAAE,CAEAT,CAAAA,CAAcU,EAChB,CACF,CASO,SAASC,EAAaJ,CAAAA,CAAoB,CAlIjD,IAAAK,CAAAA,CAoIE,GAAI,EAAA,CAACL,CAAAA,EAASA,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,CAAM,SAAW,IAAA,CAAA,CAEnBA,CAAAA,CAAM,OAAA,CAAU,IAAA,CAChBA,CAAAA,CAAM,QAAA,CAAW,IAAA,CACjBA,CAAAA,CAAM,QAAA,CAAW,IAAA,CAGjBA,CAAAA,CAAM,MAAA,CAAS,KAAA,CACjB","file":"internal.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 +1,2 @@
1
- export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-Bz6h0aPa.cjs';
1
+ export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-DSKAj-zW.cjs';
2
+ import '@estjs/signals';
@@ -1 +1,2 @@
1
- export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-Bz6h0aPa.js';
1
+ export { S as Scope, c as createScope, d as disposeScope, g as getActiveScope, r as runWithScope } from './internal-DSKAj-zW.js';
2
+ import '@estjs/signals';
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var shared = require('@estjs/shared');
4
+ var signals = require('@estjs/signals');
4
5
 
5
6
  // src/scope.ts
6
7
  var activeScope = null;
@@ -9,8 +10,10 @@ function getActiveScope() {
9
10
  return activeScope;
10
11
  }
11
12
  function createScope(parent = activeScope) {
13
+ const reactiveScope = parent ? parent.effectScope.run(() => signals.effectScope()) : signals.effectScope(true);
12
14
  const scope = {
13
15
  id: ++scopeId,
16
+ effectScope: reactiveScope,
14
17
  parent,
15
18
  children: null,
16
19
  // Lazy initialized
@@ -39,7 +42,7 @@ function runWithScope(scope, fn) {
39
42
  const prevScope = activeScope;
40
43
  activeScope = scope;
41
44
  try {
42
- return fn();
45
+ return scope.effectScope.run(fn);
43
46
  } finally {
44
47
  activeScope = prevScope;
45
48
  }
@@ -59,15 +62,13 @@ function disposeScope(scope) {
59
62
  }
60
63
  scope.children.clear();
61
64
  }
62
- const prevScope = activeScope;
63
- activeScope = scope;
64
- try {
65
+ runWithScope(scope, () => {
65
66
  if (scope.onDestroy) {
66
67
  for (let i = 0; i < scope.onDestroy.length; i++) {
67
68
  try {
68
69
  scope.onDestroy[i]();
69
70
  } catch (error_) {
70
- if (true) {
71
+ {
71
72
  shared.error(`Scope(${scope.id}): Error in destroy hook:`, error_);
72
73
  }
73
74
  }
@@ -79,16 +80,15 @@ function disposeScope(scope) {
79
80
  try {
80
81
  scope.cleanup[i]();
81
82
  } catch (error_) {
82
- if (true) {
83
+ {
83
84
  shared.error(`Scope(${scope.id}): Error in cleanup:`, error_);
84
85
  }
85
86
  }
86
87
  }
87
88
  scope.cleanup = null;
88
89
  }
89
- } finally {
90
- activeScope = prevScope;
91
- }
90
+ });
91
+ scope.effectScope.stop();
92
92
  if ((_a = scope.parent) == null ? void 0 : _a.children) {
93
93
  scope.parent.children.delete(scope);
94
94
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/scope.ts"],"names":["error"],"mappings":";;;;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IAAA;AAAA,IAClB;AAAA,EACF,CAAA,SAAE;AACA,IAAA,WAAA,GAAc,SAAA;AAAA,EAChB;AAGA,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 { 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 /** 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}\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 scope: Scope = {\n id: ++scopeId,\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 fn();\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 // We inline the scope-switching instead of calling `runWithScope()` to avoid\n // an extra function frame on the teardown hot path (disposeScope is called\n // recursively for every child scope in the tree).\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 const prevScope = activeScope;\n activeScope = scope;\n try {\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 } finally {\n activeScope = prevScope;\n }\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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,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,3 +1,3 @@
1
- export { createScope, disposeScope, getActiveScope, runWithScope } from './chunk-3E4EK64L.dev.esm.js';
1
+ export { createScope, disposeScope, getActiveScope, runWithScope } from './chunk-JT6RSDKI.dev.esm.js';
2
2
  //# sourceMappingURL=internal.dev.esm.js.map
3
3
  //# sourceMappingURL=internal.dev.esm.js.map
@@ -1,2 +1,2 @@
1
- export{d as createScope,f as disposeScope,c as getActiveScope,e as runWithScope}from'./chunk-IRDMO5MX.esm.js';//# sourceMappingURL=internal.esm.js.map
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
2
  //# sourceMappingURL=internal.esm.js.map
@@ -1,3 +1,3 @@
1
- 'use strict';var shared=require('@estjs/shared'),signals=require('@estjs/signals');var Be=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,St=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&&St.call(e,o)&&(n[o]=e[o]);return n};var Ce=(e,t,n)=>new Promise((o,r)=>{var l=i=>{try{c(n.next(i));}catch(a){r(a);}},s=i=>{try{c(n.throw(i));}catch(a){r(a);}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(l,s);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 H=null,Et=0;function C(){return H}function O(e=H){let t={id:++Et,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(t)),t}function A(e,t){let n=H;H=e;try{return t()}finally{H=n;}}function P(e){var n;if(!e||e.isDestroyed)return;if(e.isDestroyed=true,e.children&&e.children.size>0){for(let o of e.children)o&&(o.parent=null,P(o));e.children.clear();}let t=H;H=e;try{if(e.onDestroy){for(let o=0;o<e.onDestroy.length;o++)try{e.onDestroy[o]();}catch(r){}e.onDestroy=null;}if(e.cleanup){for(let o=0;o<e.cleanup.length;o++)try{e.cleanup[o]();}catch(r){}e.cleanup=null;}}finally{H=t;}(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;}function k(e){let t=H;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,p=shared.isObject(o)?o:null;if(f)for(let h in f)h!==ue&&(!p||!(h in p))&&G(e,h,f[h],null);if(p)for(let h in p)h!==ue&&G(e,h,f==null?void 0:f[h],p[h]);return}let r=(e==null?void 0:e.namespaceURI)===Xe,l=r&&t.startsWith("xlink:"),s=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 i=t.toLowerCase();if(i==="innerhtml"||i==="srcdoc")return;if(o==null){if(l)e.removeAttributeNS(we,t.slice(6));else if(s){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((i==="href"||i==="src"||i==="xlink:href"||i==="action"||i==="formaction"||i==="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(s){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 Ye=/\s*!important$/,Dt=["Webkit","Moz","ms"],ke={};function me(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 s=l[1].trim();s&&n&&shared.isObject(n)&&n[s]==null&&J(o,s,"");}}if(n&&!shared.isString(n)){let r=n;for(let l in r){let s=r[l];(!t||shared.isString(t)||t[l]!==s)&&s!=null&&J(o,l,s);}}}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=Mt(e,t);shared.isString(n)&&Ye.test(n)?e.setProperty(shared.camelCase(o),n.replace(Ye,""),"important"):e[o]=n;}function Mt(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 Dt){let l=r+o;if(l in e)return ke[t]=l}return t}var Te=0;function Qe(){return String(Te++)}function It(){Te=0;}var z=false;function le(){return z}var Q=new Map;function Ht(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 Ot(){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){z=true,Te=0,Q.clear(),ye.length=0,se.clear(),Ht(e),Ot();}function Le(){z=false,Q.clear(),ye.length=0,se.clear();}function Vt(e){if(!shared.isBrowser())return ()=>{throw new Error("[essor] getRenderedElement called in non-browser environment")};let t=null;return ()=>{if(!z)return t||(t=pe(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=pe(e)),t())}}function jt(e,t,n,o){z||fe(e,t,n,o);}function Kt(e,t,n,o){z||G(e,t,n,o);}function Ut(e,t,n){z||me(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),l=t.length,s=n.length;if(l===0&&s===0)return n;if(l===0){for(let d=0;d<s;d++)M(e,n[d],r);return n}if(s===0){for(let d=0;d<l;d++)K(t[d]);return []}let c=0,i=l-1,a=s-1;for(;c<=i&&c<=a&&t[c]===n[c];)c++;for(;i>=c&&a>=c&&t[i]===n[a];)i--,a--;if(c>i){if(c<=a){let d=a+1,f=Fe(e,d<s?n[d]:r);for(let p=c;p<=a;p++)M(e,n[p],f);}}else if(c>a)for(let d=c;d<=i;d++)K(t[d]);else $t(e,t,n,c,i,a,r);return n}function $t(e,t,n,o,r,l,s){let c=l-o+1,i=new Map;for(let m=o;m<=l;m++)i.set(n[m],m);let a=new Int32Array(c);a.fill(0);let d=0,f=false,p=0;for(let m=o;m<=r;m++){let g=t[m];if(d>=c){K(g);continue}let u=i.get(g);u===void 0?K(g):(a[u-o]=m+1,u>=p?p=u:f=true,d++);}let h=f?Ie(a):[],S=h.length-1;for(let m=c-1;m>=0;m--){let g=o+m,u=n[g],y=Fe(e,g+1<n.length?n[g+1]:s);a[m]===0?M(e,u,y):f&&(S<0||m!==h[S]?M(e,u,y):S--);}}function Ie(e){let t=new Int32Array(e.length),n=[0],o=e.length,r,l,s,c,i;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(s=0,c=n.length-1;s<c;)i=s+c>>1,e[n[i]]<a?s=i+1:c=i;a<e[n[s]]&&(s>0&&(t[r]=n[s-1]),n[s]=r);}}for(s=n.length,c=n[s-1];s-- >0;)n[s]=c,c=t[c];return n}function K(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 B(e,t,n){if(!e)return;let o=C(),r=[],l=true,s=i=>{if(i instanceof Node)return [i];if(L(i))return [i];let a=typeof i;return i==null||a==="string"||a==="number"||a==="boolean"?[Z(i)]:shared.coerceArray(i).map(d=>shared.isFunction(d)?d():d).flatMap(d=>d).map(Z)},c=signals.effect(()=>{let i=()=>{let a=shared.isFunction(t)?t():t,d=s(a);if(l&&le()&&d.every(f=>f instanceof Node&&f.parentNode===e)){r=d,l=false;return}r=Ze(e,r,d,n),l=false;};o&&!o.isDestroyed?A(o,i):i();});return k(()=>{c.stop();for(let i of r)K(i);r=[];}),r}function Wt(e){return (e==null?void 0:e.firstChild)||null}function Xt(e,t=1){for(;e&&t>0;)e=e.nextSibling,t--;return e||null}function qt(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);},i=o,{delegate:s}=i,c=We(i,["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 nt(e,t,n){let o=e.length;if(o===0)return;let r;for(let l=0;l<o;l++)try{let s=e[l]();if(shared.isPromise(s)){let c=s.catch(i=>{});(r||(r=[])).push(c);}}catch(s){}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 Gt(e){let t=C();t&&He(t,"onUpdate",e);}function te(e){let t=C();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=A(e,()=>nt(t,e.id,"mount"));return t.length=0,e.isMounted=true,n}function rt(e){if(!(e.isDestroyed||!e.onUpdate||e.onUpdate.length===0))return A(e,()=>nt(e.onUpdate,e.id,"update"))}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 Zt(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=C();let o={};st(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 s of this.renderedNodes)M(t,s,n);return this.state=2,this.renderedNodes}let o=O((l=this.parentScope)!=null?l:C());this.scope=o;let r=A(o,()=>{var c;let s=this.component(this.reactiveProps);return shared.isFunction(s)&&(s=s(this.reactiveProps)),(signals.isSignal(s)||signals.isComputed(s))&&(s=s.value),(c=B(t,s,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)K(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=Zt(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.value;return t.value=n,()=>{t.value===n&&(t.value=o);}}}};function L(e){return !!e&&!!e.normal}function he(e,t){return L(e)?e:new ne(e,t)}function pe(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 en(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;n.innerHTML&&(n.innerHTML="");let r=O(),l;try{A(r,()=>{let s=he(e);L(s)&&(l=s,M(n,s));});}catch(s){throw P(r),s}return {root:l,unmount:()=>{P(r),l==null||l.destroy();}}}function tn(e,t){let n=shared.isString(t)?document.querySelector(t):t;if(!n)return;Me(n);let o=O(),r;try{A(o,()=>{let l=he(e);L(l)&&(r=l,B(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 ut(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 i=t[`${n}Data`];if(i?c.call(t,i,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},s=()=>{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 i=0;i<c.length-2&&(t=c[i],!!l());i++){if(t._$host){t=t._$host,s();break}if(t.parentNode===r)break}}else s();Ke(e,o);}var ge=Symbol("_$EVENTS");function on(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 rn(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);C()&&k(r);}function Ue(e,t){let n=e,o=t==null?"":String(t);n.value!==o&&(n.value=o);}var an={event:"change",forceChange:true,read:e=>e.checked,write(e,t){let n=e,o=!!t;n.checked!==o&&(n.checked=o);}},un={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);}},dn={event:"change",forceChange:true,read:e=>e.files,write(){}},fn={event:"input",ime:true,read:e=>e.value,write:Ue},mn={event:"input",ime:true,read:e=>e.value,write:Ue},pn={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 yn(e,t){switch(e.nodeName){case "INPUT":return t==="checked"?e.type==="radio"?un:an:t==="files"?dn:fn;case "SELECT":return pn;case "TEXTAREA":return mn;default:return {event:"input",read:n=>n[t],write(n,o){n[t]=o;}}}}function hn(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 gn(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:s,write:c,forceChange:i,ime:a}=yn(e,t),d=r.trim===true,f=r.number===true,p=r.lazy===true,h=(d||f)&&t!=="files",S=shared.isFunction(n)?n:()=>n,m=h?N=>hn(N,d,f):N=>N,g=false,u=p||i?"change":l,y=()=>{if(g)return;let N=s(e);if(N===void 0)return;let x=m(N);Object.is(S(),x)||o(x);};oe(e,u,y),!p&&h&&u!=="change"&&oe(e,"change",()=>c(e,m(s(e)))),a&&!p&&(oe(e,"compositionstart",()=>{g=true;}),oe(e,"compositionend",()=>{g&&(g=false,y());}));let E=signals.effect(()=>{let N=S();a&&!p&&gn(e)&&(g||Object.is(m(s(e)),N))||c(e,N);});C()&&k(()=>E.stop());}function Sn(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 dt(e){return !e||e.children==null?null:e.children}dt[Ae]=true;function En(e){return !!e&&!!e[Ae]}function ve(e){let t=shared.isFunction(e.target)?e.target():e.target;return t==null?null:shared.isString(t)?document.querySelector(t):t}function Se(e){return shared.isFunction(e.disabled)?!!e.disabled():!!e.disabled}function mt(e){if(le()){let d=_n(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=O(o),A(r,()=>{B(d,()=>n,f);});},s=()=>{r&&(P(r),r=null);},c=(d,f)=>{if(s(),d){let p=t.parentNode;if(!p)return;l(p,t);return}f&&l(f);},i=false,a=signals.effect(()=>{let d=Se(e),f=d?null:ve(e);i&&c(d,f);});return Oe(()=>{i=!0;let d=Se(e),f=d?null:ve(e);if(d||f){c(d,f);return}queueMicrotask(()=>{t.parentNode&&c(Se(e),ve(e));});}),k(()=>{a.stop(),s();}),t}mt[ie]=true;function _n(e){if(Se(e))return null;let t=Re();if(!t)return null;let n=ve(e);return !n||!De(n)?null:(t[ie]=true,t)}function Cn(e){return !!e&&!!e[ie]}function Ne(e){for(;e.firstChild;)e.removeChild(e.firstChild);}function pt(e){let t=e;for(;shared.isFunction(t);)t=t();return signals.isSignal(t)||signals.isComputed(t)?pt(t.value):t}var ae=Symbol("SuspenseContext");function yt(e){var S;if(!shared.isBrowser())return (S=e.fallback)!=null?S:"";let t=document.createElement("div");t.style.display="contents";let n=true,o=0,r=false,l=null,s=m=>{let g=pt(m);if(shared.isArray(g)){let u=[];for(let y of g){let E=s(y);shared.isArray(E)?u.push(...E):u.push(E);}return u}return Z(g)},c=m=>{let g=s(m),u=shared.isArray(g)?g:[g];for(let y of u)y!=null&&M(t,y);},i=()=>{Ne(t),e.fallback!=null&&c(e.fallback);},a=()=>{r||(r=true,i());},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=m=>{if(r||(Ne(t),m==null))return;let g=shared.isArray(m)?m:[m];for(let u of g)u!=null&&c(u);r&&i();},p={register:m=>{o++,a(),m.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,p);let h=e.children;return shared.isPromise(h)?(h.then(m=>{l=m;}).catch(()=>{}),p.register(h)):h!=null?f(h):a(),te(()=>{n=false,o=0,l=null,Ne(t),t.remove();}),t}yt[Pe]=true;function kn(e){return !!e&&!!e[Pe]}function Tn(e,t){let n=signals.signal(t==null?void 0:t.initialValue),o=signals.signal(true),r=signals.signal(null),l=signals.signal("pending"),s=0,c=null,i=false,a=ce(ae,null),d=()=>Ce(null,null,function*(){let h=++s;o.value=true,l.value="pending",r.value=null,i=false,a&&a.increment();try{let S=e();c=S,S.catch(()=>{});let m=yield S;h===s&&(n.value=m,l.value="ready",o.value=!1);}catch(S){h===s&&(r.value=S instanceof Error?S:new Error(String(S)),l.value="errored",o.value=false);}finally{a&&a.decrement();}});d();let f=(()=>(!i&&o.value&&c&&a&&(i=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 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 Dn(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 p=null,h=null,S=()=>h||(h=e().then(g=>{p=ht(g);}).catch(()=>{}),h);S();let m=g=>p?p(g):"";return m.__asyncLoader=S,m.__asyncResolved=()=>p,m}let s=null,c=null,i="pending",a=null;function d(){return a||(a=e().then(p=>{s=ht(p),i="resolved";}).catch(p=>{c=p instanceof Error?p:new Error(String(p)),i="errored",a=null;}),a)}d();function f(p){var W;if(i==="resolved"&&s){let b=document.createElement("div");b.style.display="contents";let F=ze(b,s,p);return k(()=>F.destroy()),b}if(i==="errored"&&c){let b=document.createElement("div");if(b.style.display="contents",t.error){let F=true,R=null,U=(q,v)=>{F&&(R==null||R.destroy(),R=ze(b,q,v));},X=()=>{a=null,i="pending",c=null,t.loading&&U(t.loading),d().then(()=>{F&&(i==="resolved"&&s?U(s,p):i==="errored"&&c&&t.error&&U(t.error,{error:c,retry:X}));});};U(t.error,{error:c,retry:X}),te(()=>{F=false,R==null||R.destroy(),R=null;});}return b}let h=document.createElement("div");h.style.display="contents";let S=true,m=null,g=null,u=null,y=(b,F)=>{S&&(m==null||m.destroy(),m=ze(h,b,F));},E=b=>()=>{a=null,i="pending",c=null,t.loading&&y(t.loading),d().then(()=>{i==="resolved"&&s?y(s,b):i==="errored"&&c&&t.error&&y(t.error,{error:c,retry:E(b)});});};te(()=>{S=false,m==null||m.destroy(),m=null,g!=null&&clearTimeout(g),u!=null&&clearTimeout(u);});let N=(W=ce(ae))!=null?W:null,x=b=>y(b,p),T=b=>{t.error&&y(t.error,{error:b,retry:E(p)});},V=()=>{t.loading&&y(t.loading);},j=d().then(()=>{S&&(i==="resolved"&&s?x(s):i==="errored"&&c&&(T(c),l&&l(c,E(p))),g!=null&&clearTimeout(g),u!=null&&clearTimeout(u));});return N&&N.register(j),n>0?g=setTimeout(()=>{S&&i==="pending"&&V();},n):t.loading&&V(),o!=null&&(u=setTimeout(()=>{if(S&&i==="pending"){let b=new Error(`[defineAsyncComponent] Timeout after ${o}ms`);c=b,i="errored",T(b),l&&l(b,E(p));}},o)),h}return f.__asyncLoader=d,f.__asyncResolved=()=>s,f}function gt(e){let t=document.createDocumentFragment(),n=document.createComment("");t.appendChild(n);let o=[],r=[],l=e.key,s=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:[]},i=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 x of N)E?y.insertBefore(x,E):y.appendChild(x);return N},f=(u,y)=>{if(!e.fallback)return;r=d(e.fallback(),u,y);},p=()=>{for(let u of r)u.parentNode&&u.parentNode.removeChild(u);r=[];},h=(u,y,E,N)=>{let x=C(),T=O(x),V=[];return A(T,()=>{V=d(s(u,y),E,N);}),{key:i(u),item:u,nodes:V,scope:T}},S=u=>{P(u.scope);for(let y of u.nodes)y.parentNode&&y.parentNode.removeChild(y);},m=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 v=0;v<E;v++)S(o[v]);o=[],e.fallback&&r.length===0&&f(u,n);return}if(E===0||r.length>0){r.length>0&&p(),o=new Array(N);let v=document.createDocumentFragment();for(let w=0;w<N;w++)o[w]=h(y[w],w,v,null);u.insertBefore(v,n);return}let x=new Map;for(let v=0;v<E;v++){let w=o[v],I=x.get(w.key),$=[w,v];I?I.push($):x.set(w.key,[$]);}let T=new Array(N),V=[],j=null,W=new Int32Array(N),b=false,F=0,R=new Array(N);for(let v=0;v<N;v++)R[v]=i(y[v]);for(let v=0;v<N;v++){let w=y[v],I=R[v],$=x.get(I);if($&&$.length>0){let[re,D]=$.shift();Object.is(re.item,w)?(re.item=w,T[v]=re,W[v]=D+1,D<F?b=true:F=D):(j||(j=document.createDocumentFragment()),S(re),T[v]=h(w,v,j,null));}else j||(j=document.createDocumentFragment()),T[v]=h(w,v,j,null);}for(let v of x.values())for(let[w]of v)V.push(w);for(let v of V)S(v);let U=b?Ie(W):[],X=U.length-1,q=n;for(let v=N-1;v>=0;v--){let I=T[v].nodes;if(!(W[v]===0)&&b&&X>=0&&v===U[X]){X--;for(let D=I.length-1;D>=0;D--)q=I[D];continue}for(let D=I.length-1;D>=0;D--){let _e=I[D];_e.nextSibling!==q&&u.insertBefore(_e,q),q=_e;}}o=T;}return k(()=>{m.stop();for(let u of o)S(u);o=[],p(),n.parentNode&&n.parentNode.removeChild(n);}),t}gt[qe]=true;
2
- exports.Component=ne;exports.For=gt;exports.Fragment=dt;exports.Portal=mt;exports.Suspense=yt;exports.addEvent=ee;exports.addEventListener=oe;exports.beginHydration=Me;exports.bindElement=vn;exports.child=Wt;exports.clearDelegatedEvents=rn;exports.consumeTeleportAnchor=Re;exports.consumeTeleportBlock=De;exports.createApp=en;exports.createComponent=he;exports.createResource=Tn;exports.defineAsyncComponent=Dn;exports.delegateEvents=on;exports.endHydration=Le;exports.getHydrationKey=Qe;exports.getRenderedElement=Vt;exports.hydrate=tn;exports.inject=ce;exports.insert=B;exports.isComponent=L;exports.isFragment=En;exports.isHydrating=le;exports.isPortal=Cn;exports.isSuspense=kn;exports.next=Xt;exports.normalizeClass=de;exports.nthChild=qt;exports.omitProps=Sn;exports.onDestroy=te;exports.onMount=Oe;exports.onUpdate=Gt;exports.patchAttr=G;exports.patchAttrHydrate=Kt;exports.patchClass=fe;exports.patchClassHydrate=jt;exports.patchStyle=me;exports.patchStyleHydrate=Ut;exports.provide=je;exports.resetHydrationKey=It;exports.setStyle=J;exports.template=pe;//# sourceMappingURL=template.cjs.js.map
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
3
  //# sourceMappingURL=template.cjs.js.map