@koppajs/koppajs-core 3.0.1 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -22,6 +22,44 @@ Changes will only appear here when they:
22
22
 
23
23
  ---
24
24
 
25
+ ## [3.0.3] — Tooling Baseline And Ecosystem Cleanup
26
+
27
+ **2026-03-26**
28
+
29
+ Patch release to tighten repository quality workflow, align ecosystem-facing
30
+ docs, and harden a small helper type contract. No intentional breaking runtime
31
+ changes.
32
+
33
+ ### Added
34
+
35
+ - Added repository meta-layer documents, ADR/spec directories, and explicit
36
+ contributor workflow guidance
37
+
38
+ ### Changed
39
+
40
+ - Tightened `setValueByPath(...)` typing without widening runtime behavior
41
+ - Split source and test TypeScript checks and hardened coverage thresholds
42
+ - Simplified lint, format, hook, and CI workflow configuration around the
43
+ current repository baseline
44
+ - Updated README ecosystem links to point at the released starter/tooling
45
+ surface
46
+
47
+ ---
48
+
49
+ ## [3.0.2] — Public API Cleanup
50
+
51
+ **2026-03-11**
52
+
53
+ Patch release to tighten the public root API surface.
54
+ Runtime initialization behavior remains unchanged.
55
+
56
+ ### Changed
57
+
58
+ - Removed the unintended root export `initDomEnvironment`
59
+ - DOM environment initialization continues to happen through `Core()`
60
+
61
+ ---
62
+
25
63
  ## [3.0.1] — Badge & CI Fixes
26
64
 
27
65
  **2026-03-01**
package/README.md CHANGED
@@ -1,81 +1,131 @@
1
1
  <a id="readme-top"></a>
2
2
 
3
- <!-- PROJECT LOGO -->
4
3
  <div align="center">
5
4
  <img src="https://public-assets-1b57ca06-687a-4142-a525-0635f7649a5c.s3.eu-central-1.amazonaws.com/koppajs/koppajs-logo-text-900x226.png" width="500" alt="KoppaJS Logo">
6
5
  </div>
7
6
 
8
7
  <br>
9
8
 
10
- <!-- PROJECT SHIELDS -->
11
9
  <div align="center">
12
- <a href="https://www.npmjs.com/package/@koppajs/koppajs-core"><img src="https://img.shields.io/npm/v/@koppajs/koppajs-core?style=flat-square" alt="npm version"></a> <a href="https://github.com/koppajs/koppajs-core/actions"><img src="https://img.shields.io/github/actions/workflow/status/koppajs/koppajs-core/ci.yml?branch=main&style=flat-square" alt="CI Status"></a> <a href="https://www.npmjs.com/package/@koppajs/koppajs-core"><img src="https://img.shields.io/badge/gzip-13.6%20kB-blue?style=flat-square" alt="Bundle size"></a> <a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License"></a>
10
+ <a href="https://www.npmjs.com/package/@koppajs/koppajs-core"><img src="https://img.shields.io/npm/v/@koppajs/koppajs-core?style=flat-square" alt="npm version"></a>
11
+ <a href="https://github.com/koppajs/koppajs-core/actions"><img src="https://img.shields.io/github/actions/workflow/status/koppajs/koppajs-core/ci.yml?branch=main&style=flat-square" alt="CI Status"></a>
12
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License"></a>
13
13
  </div>
14
14
 
15
15
  <br>
16
16
 
17
- <!-- ELEVATOR PITCH -->
18
17
  <div align="center">
19
- <h1 align="center">KoppaJS – Pragmatic frontend made modular</h1>
20
- <h3 align="center">Build fast, simple, and growable – without the noise of modern frameworks.</h3>
21
- <p align="center">
22
- <i align="center">A quiet rebellion against complexity – and a wish that building can still feel good.</i>
23
- </p>
18
+ <h1 align="center">@koppajs/koppajs-core</h1>
19
+ <h3 align="center">Core runtime and component model for KoppaJS</h3>
20
+ <p align="center">
21
+ <i>Reactive components, explicit lifecycle seams, and a small runtime without virtual DOM overhead.</i>
22
+ </p>
24
23
  </div>
25
24
 
26
25
  <br>
27
26
 
28
- <!-- IMPORTANT LINKS -->
29
27
  <div align="center">
30
- <p align="center">
31
- <a href="https://github.com/koppajs/koppajs-documentation">Documentation</a>
32
- &middot;
33
- <a href="https://github.com/koppajs/koppajs-example">Example Project</a>
34
- &middot;
35
- <a href="https://github.com/koppajs/koppajs-core/issues">Issues</a>
36
- </p>
28
+ <p align="center">
29
+ <a href="https://github.com/koppajs/koppajs-documentation">Documentation</a>
30
+ &middot;
31
+ <a href="https://github.com/koppajs/create-koppajs">create-koppajs</a>
32
+ &middot;
33
+ <a href="https://github.com/koppajs/koppajs-vite-plugin">Vite Plugin</a>
34
+ &middot;
35
+ <a href="https://github.com/koppajs/koppajs-router">Router</a>
36
+ &middot;
37
+ <a href="https://github.com/koppajs/koppajs-core/issues">Issues</a>
38
+ </p>
37
39
  </div>
38
40
 
39
41
  <br>
40
42
 
41
- <!-- TABLE OF CONTENTS -->
42
43
  <details>
43
44
  <summary>Table of Contents</summary>
44
- <ol>
45
- <li><a href="#what-is-koppajs">What is KoppaJS?</a></li>
46
- <li><a href="#features">Features</a></li>
47
- <li><a href="#getting-started">Getting Started</a></li>
48
- <li><a href="#roadmap">Roadmap</a></li>
49
- <li><a href="#support">Support</a></li>
50
- <li><a href="#community--contribution">Community & Contribution</a></li>
51
- </ol>
45
+ <ol>
46
+ <li><a href="#what-is-koppajs-core">What is KoppaJS Core?</a></li>
47
+ <li><a href="#features">Features</a></li>
48
+ <li><a href="#installation">Installation</a></li>
49
+ <li><a href="#requirements">Requirements</a></li>
50
+ <li><a href="#getting-started">Getting Started</a></li>
51
+ <li><a href="#runtime-model">Runtime Model</a></li>
52
+ <li><a href="#roadmap">Roadmap</a></li>
53
+ <li><a href="#architecture--governance">Architecture & Governance</a></li>
54
+ <li><a href="#community--contribution">Community & Contribution</a></li>
55
+ <li><a href="#license">License</a></li>
56
+ </ol>
52
57
  </details>
53
58
 
54
59
  ---
55
60
 
56
- ## What is KoppaJS?
61
+ ## What is KoppaJS Core?
57
62
 
58
- KoppaJS is a lightweight, modular frontend framework designed to simplify development without sacrificing flexibility. It provides a pragmatic approach to building modern web applications, focusing on:
63
+ `@koppajs/koppajs-core` is the runtime package at the center of the KoppaJS
64
+ stack.
59
65
 
60
- - **Simplicity:** Minimal boilerplate and intuitive APIs.
61
- - **Performance:** Optimized for speed and scalability.
62
- - **Modularity:** Build only what you need, when you need it.
66
+ It owns the public bootstrap surface, component registration, DOM runtime
67
+ setup, lifecycle coordination, and the stable contracts that other KoppaJS
68
+ packages build on top of.
69
+
70
+ In practice that means:
71
+
72
+ - applications register components through `Core.take(...)`
73
+ - the runtime boots once through `Core()`
74
+ - the Vite plugin handles `.kpa` transformation, while core stays focused on
75
+ runtime behavior
63
76
 
64
77
  ---
65
78
 
66
79
  ## Features
67
80
 
68
- - **Declarative Components:** Define components with `.kpa` files.
69
- - **Reactive State Management:** Built-in reactivity for seamless updates.
70
- - **Lifecycle Hooks:** Control component behavior with hooks like `mounted`, `updated`, and `beforeUpdate`.
71
- - **Integration-Friendly:** Works with existing tools and libraries.
72
- - **TypeScript Support:** First-class TypeScript support for safer, more maintainable code.
81
+ - component registration via the stable `Core.take(...)` API
82
+ - one-time runtime bootstrap through `Core()`
83
+ - reactive component model with explicit methods, refs, props, and lifecycle
84
+ hooks
85
+ - modular extension surface for plugins and modules
86
+ - no virtual DOM dependency
87
+ - published package with ESM, CommonJS, and TypeScript types
88
+
89
+ ---
90
+
91
+ ## Installation
92
+
93
+ ```bash
94
+ pnpm add @koppajs/koppajs-core
95
+ pnpm add -D @koppajs/koppajs-vite-plugin vite typescript
96
+ ```
97
+
98
+ ```bash
99
+ npm install @koppajs/koppajs-core
100
+ npm install -D @koppajs/koppajs-vite-plugin vite typescript
101
+ ```
102
+
103
+ The fastest path for most users is still the official starter:
104
+
105
+ ```bash
106
+ pnpm create koppajs my-app
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Requirements
112
+
113
+ For package consumers:
114
+
115
+ - a browser-based application environment
116
+ - a build pipeline that can consume KoppaJS components, typically Vite plus
117
+ `@koppajs/koppajs-vite-plugin`
118
+
119
+ For local repository work:
120
+
121
+ - Node.js >= 20
122
+ - pnpm >= 10.24.0
73
123
 
74
124
  ---
75
125
 
76
126
  ## Getting Started
77
127
 
78
- The fastest way to start a new KoppaJS project:
128
+ Recommended bootstrap path:
79
129
 
80
130
  ```bash
81
131
  pnpm create koppajs my-app
@@ -84,69 +134,77 @@ pnpm install
84
134
  pnpm dev
85
135
  ```
86
136
 
87
- This scaffolds a ready-to-run project with Vite, TypeScript, and two sample components.
137
+ Manual registration with the public core API:
88
138
 
89
- You can also use npm or npx:
139
+ ```ts
140
+ import { Core } from '@koppajs/koppajs-core'
90
141
 
91
- ```bash
92
- npm create koppajs my-app
93
- npx create-koppajs my-app
142
+ import appView from './app-view.kpa'
143
+ import counterComponent from './counter-component.kpa'
144
+
145
+ Core.take(appView, 'app-view')
146
+ Core.take(counterComponent, 'counter-component')
147
+ Core()
94
148
  ```
95
149
 
96
- ### Manual Setup
150
+ This mirrors the bootstrap used in the official example project.
97
151
 
98
- If you prefer to add KoppaJS to an existing project:
152
+ ---
99
153
 
100
- 1. **Install the core library and Vite plugin:**
154
+ ## Runtime Model
101
155
 
102
- ```bash
103
- pnpm add @koppajs/koppajs-core
104
- pnpm add -D @koppajs/koppajs-vite-plugin
105
- ```
156
+ KoppaJS Core deliberately keeps its top-level contract small:
106
157
 
107
- 2. **Create your first component:**
158
+ - `Core.take(componentSource, name)` registers a component definition
159
+ - `Core.take(pluginOrModule)` installs an extension definition
160
+ - `Core()` initializes the DOM environment and flushes queued registrations
161
+ - repeated `Core()` calls are safe and idempotent
108
162
 
109
- ```typescript
110
- import { Core } from '@koppajs/koppajs-core'
163
+ The runtime does not own `.kpa` parsing. That stays in
164
+ `@koppajs/koppajs-vite-plugin`, which emits the component source objects that
165
+ core consumes at runtime.
111
166
 
112
- Core.take(
113
- {
114
- state: { count: 0 },
115
- methods: {
116
- increment() {
117
- this.state.count++
118
- },
119
- },
120
- },
121
- 'counter',
122
- )
167
+ ---
123
168
 
124
- Core()
125
- ```
169
+ ## Roadmap
126
170
 
127
- 3. **Run your application:**
128
- Use the KoppaJS Vite plugin to build and serve your app.
171
+ - continue hardening the stable runtime contracts
172
+ - keep the public bootstrap surface small and explicit
173
+ - deepen runtime specs and package-level governance documents
174
+ - support ecosystem packages such as the router, component library, and editor
175
+ tooling without growing hidden runtime coupling
129
176
 
130
177
  ---
131
178
 
132
- ## Roadmap
179
+ ## Architecture & Governance
180
+
181
+ Project intent, runtime constraints, and contributor rules live in the repo
182
+ meta layer:
183
+
184
+ - [AI_CONSTITUTION.md](./AI_CONSTITUTION.md)
185
+ - [ARCHITECTURE.md](./ARCHITECTURE.md)
186
+ - [DECISION_HIERARCHY.md](./DECISION_HIERARCHY.md)
187
+ - [DEVELOPMENT_RULES.md](./DEVELOPMENT_RULES.md)
188
+ - [TESTING_STRATEGY.md](./TESTING_STRATEGY.md)
189
+ - [RELEASE.md](./RELEASE.md)
190
+ - [ROADMAP.md](./ROADMAP.md)
191
+ - [docs/specs/component-runtime-contract.md](./docs/specs/component-runtime-contract.md)
192
+ - [docs/architecture/runtime-flow.md](./docs/architecture/runtime-flow.md)
133
193
 
134
- - 🌐 **Official Website** — koppajs.org with documentation, guides, and examples
135
- - 🔌 **Official Plugins**
136
- - Router
137
- - Script Loader
138
- - DSGVO / Cookie Consent Banner
139
- - 🧩 **Ecosystem Growth** — Community plugins, starter templates, and integrations
140
- - 💻 **VS Code Extension** — Syntax highlighting, IntelliSense, and tooling for `.kpa` files
194
+ Tagged releases are documented in `CHANGELOG.md`.
141
195
 
142
196
  ---
143
197
 
144
- ## Support
198
+ ## Community & Contribution
199
+
200
+ Issues and pull requests are welcome:
145
201
 
146
- For support, visit our [GitHub Issues](https://github.com/koppajs/koppajs-core/issues).
202
+ https://github.com/koppajs/koppajs-core/issues
203
+
204
+ Contributor workflow details live in [CONTRIBUTING.md](./CONTRIBUTING.md).
147
205
 
148
206
  ---
149
207
 
150
- ## Community & Contribution
208
+ ## License
151
209
 
152
- We welcome contributions! Check out our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
210
+ Apache License 2.0 — © 2026 KoppaJS, Bastian Bensch
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var me=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(me||{});const B={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class Ie{constructor(){this.level=3,this.isDevelopment=!1}init(t){this.isDevelopment=t?.isDevelopment??(typeof process<"u"&&process.env?.NODE_ENV==="development")??!1,this.level=t?.level??(this.isDevelopment?0:3)}setLevel(t){this.level=t}getLevel(){return this.level}shouldLog(t){return t>=this.level}formatMessage(t,n,o){const r=[t,n];if(o){const a=Object.entries(o).map(([i,s])=>`${i}: ${s}`).join(", ");a&&r.push(`[${a}]`)}return r.join(" ")}error(t,...n){this.shouldLog(3)&&console.error(this.formatMessage(B.ERROR,t),...n)}warn(t,...n){this.shouldLog(2)&&console.warn(this.formatMessage(B.WARN,t),...n)}info(t,...n){this.shouldLog(1)&&console.info(this.formatMessage(B.INFO,t),...n)}debug(t,...n){this.shouldLog(0)&&console.debug(this.formatMessage(B.DEBUG,t),...n)}errorWithContext(t,n,o){if(!this.shouldLog(3))return;const r=this.formatMessage(B.ERROR,t,n);o?console.error(r,o):console.error(r)}warnWithContext(t,n){this.shouldLog(2)&&console.warn(this.formatMessage(B.WARN,t,n))}}const T=new Ie;T.init();const ae=Symbol("isBounded"),ye=Symbol("isProxy"),Le=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function K(e,t){if(typeof e!="function"||e[ae])return e;const o=e.bind(t);return o[ae]=!0,o}function De(e,t){for(const n in e){const o=e[n];if(Object.prototype.hasOwnProperty.call(e,n)&&typeof o=="function")try{e[n]=K(o,t)}catch(r){T.errorWithContext(`Failed to bind method "${n}"`,{methodName:n},r)}}}function Fe(e){return/<\/?[a-z][^>]*>/i.test(e)}function ne(e,t){if(e==null||typeof t!="string")return;const n=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return n.reduce((o,r)=>{if(o!=null)return o[r]},e)}catch{return}}function We(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function ge(e){const t=e.trim();return/^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:\d+|\w+)\]|\.[a-zA-Z_$][0-9a-zA-Z_$]*)*$/.test(t)}function je(e,t,n){if(e==null||typeof e!="object"&&typeof e!="function")throw new Error("❌ setValueByPath: target must be an object.");if(typeof t!="string"||!t.trim())throw new Error("❌ setValueByPath: path must be a non-empty string.");const o=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(o.length===0)throw new Error(`❌ setValueByPath: invalid path "${t}".`);const r=(c,l)=>Object.prototype.hasOwnProperty.call(c,l),a=o.pop();let i=e;for(const c of o){if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!r(i,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const l=i[c];if(l==null||typeof l!="object"&&typeof l!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);i=l}if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!r(i,a))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${a}" does not exist.`);const s=Object.getOwnPropertyDescriptor(i,a);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${a}" is read-only.`);i[a]=n}const Ve={select:{get(){return e=>this instanceof HTMLInputElement||this instanceof HTMLTextAreaElement?(this.select(),null):this.querySelector(e)}},selectAll:{get(){return e=>this.querySelectorAll(e)}},addClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.add(t)),this)}},removeClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.remove(t)),this)}},toggleClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.toggle(t)),this)}},hasClass:{get(){return e=>this.classList.contains(e.trim())}},replaceWith:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.replaceChild(e,this):typeof e=="string"&&(this.insertAdjacentText("beforebegin",e),this.remove()))}}},siblings:{get(){return e=>{if(!this.parentNode)return[];const t=[];let n=this.parentNode.firstChild;for(;n;)n.nodeType===Node.ELEMENT_NODE&&n!==this&&n instanceof HTMLElement&&(e?.(n),t.push(n)),n=n.nextSibling;return t}}},before:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this):this.insertAdjacentHTML("beforebegin",e.toString()))}}},after:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this.nextSibling):this.insertAdjacentHTML("afterend",e.toString()))}}},attr:{get(){return(e,t)=>(t!==void 0&&this.setAttribute(e,t||"true"),this.getAttribute(e))}}},He={};function Be(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const qe=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,q=new Map,ze=1e3,le=new WeakMap;function Ue(e){const t=Object.keys(e),n=t.join("\0"),o=le.get(e);if(o&&o.fingerprint===n)return o.keys;const r=t.sort();return le.set(e,{keys:r,fingerprint:n}),r}function H(e,t={}){const n=(e??"").trim();if(n)try{if(qe.test(n))return;if(ge(n)){const i=ne(t,n);return typeof i=="function"?i.call(t):i}const o=Ue(t),r=`${n}|${o.join(",")}`;let a=q.get(r);if(!a){const i=`"use strict"; return (${n});`;if(a=new Function(...o,i),q.size>=ze){const s=q.keys().next().value;s&&q.delete(s)}q.set(r,a)}return a(...o.map(i=>t[i]))}catch(o){T.debug(`Expression evaluation failed: ${n}`,o);return}}function Xe(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var me=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE",e))(me||{});const B={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class Pe{constructor(){this.level=3,this.isDevelopment=!1}init(t){this.isDevelopment=t?.isDevelopment??(typeof process<"u"&&process.env?.NODE_ENV==="development")??!1,this.level=t?.level??(this.isDevelopment?0:3)}setLevel(t){this.level=t}getLevel(){return this.level}shouldLog(t){return t>=this.level}formatMessage(t,n,o){const r=[t,n];if(o){const a=Object.entries(o).map(([i,s])=>`${i}: ${s}`).join(", ");a&&r.push(`[${a}]`)}return r.join(" ")}error(t,...n){this.shouldLog(3)&&console.error(this.formatMessage(B.ERROR,t),...n)}warn(t,...n){this.shouldLog(2)&&console.warn(this.formatMessage(B.WARN,t),...n)}info(t,...n){this.shouldLog(1)&&console.info(this.formatMessage(B.INFO,t),...n)}debug(t,...n){this.shouldLog(0)&&console.debug(this.formatMessage(B.DEBUG,t),...n)}errorWithContext(t,n,o){if(!this.shouldLog(3))return;const r=this.formatMessage(B.ERROR,t,n);o?console.error(r,o):console.error(r)}warnWithContext(t,n){this.shouldLog(2)&&console.warn(this.formatMessage(B.WARN,t,n))}}const T=new Pe;T.init();const ae=Symbol("isBounded"),ye=Symbol("isProxy"),Ie=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function K(e,t){if(typeof e!="function"||e[ae])return e;const o=e.bind(t);return o[ae]=!0,o}function Le(e,t){for(const n in e){const o=e[n];if(Object.prototype.hasOwnProperty.call(e,n)&&typeof o=="function")try{e[n]=K(o,t)}catch(r){T.errorWithContext(`Failed to bind method "${n}"`,{methodName:n},r)}}}function Fe(e){return/<\/?[a-z][^>]*>/i.test(e)}function ne(e,t){if(e==null||typeof t!="string")return;const n=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return n.reduce((o,r)=>{if(o!=null)return o[r]},e)}catch{return}}function We(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function ge(e){const t=e.trim();return/^[a-zA-Z_$][0-9a-zA-Z_$]*(?:\[(?:\d+|\w+)\]|\.[a-zA-Z_$][0-9a-zA-Z_$]*)*$/.test(t)}function De(e,t,n){if(e==null||typeof e!="object"&&typeof e!="function")throw new Error("❌ setValueByPath: target must be an object.");if(typeof t!="string"||!t.trim())throw new Error("❌ setValueByPath: path must be a non-empty string.");const o=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(o.length===0)throw new Error(`❌ setValueByPath: invalid path "${t}".`);const r=(c,l)=>Object.prototype.hasOwnProperty.call(c,l),a=o.pop();let i=e;for(const c of o){if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!r(i,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const l=i[c];if(l==null||typeof l!="object"&&typeof l!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);i=l}if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!r(i,a))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${a}" does not exist.`);const s=Object.getOwnPropertyDescriptor(i,a);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${a}" is read-only.`);i[a]=n}const je={select:{get(){return e=>this instanceof HTMLInputElement||this instanceof HTMLTextAreaElement?(this.select(),null):this.querySelector(e)}},selectAll:{get(){return e=>this.querySelectorAll(e)}},addClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.add(t)),this)}},removeClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.remove(t)),this)}},toggleClass:{get(){return e=>(e.split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0).forEach(t=>this.classList.toggle(t)),this)}},hasClass:{get(){return e=>this.classList.contains(e.trim())}},replaceWith:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.replaceChild(e,this):typeof e=="string"&&(this.insertAdjacentText("beforebegin",e),this.remove()))}}},siblings:{get(){return e=>{if(!this.parentNode)return[];const t=[];let n=this.parentNode.firstChild;for(;n;)n.nodeType===Node.ELEMENT_NODE&&n!==this&&n instanceof HTMLElement&&(e?.(n),t.push(n)),n=n.nextSibling;return t}}},before:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this):this.insertAdjacentHTML("beforebegin",e.toString()))}}},after:{get(){return e=>{this.parentNode&&(e instanceof HTMLElement?this.parentNode.insertBefore(e,this.nextSibling):this.insertAdjacentHTML("afterend",e.toString()))}}},attr:{get(){return(e,t)=>(t!==void 0&&this.setAttribute(e,t||"true"),this.getAttribute(e))}}},Ve={};function He(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const Be=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,q=new Map,qe=1e3,le=new WeakMap;function ze(e){const t=Object.keys(e),n=t.join("\0"),o=le.get(e);if(o&&o.fingerprint===n)return o.keys;const r=t.sort();return le.set(e,{keys:r,fingerprint:n}),r}function H(e,t={}){const n=(e??"").trim();if(n)try{if(Be.test(n))return;if(ge(n)){const i=ne(t,n);return typeof i=="function"?i.call(t):i}const o=ze(t),r=`${n}|${o.join(",")}`;let a=q.get(r);if(!a){const i=`"use strict"; return (${n});`;if(a=new Function(...o,i),q.size>=qe){const s=q.keys().next().value;s&&q.delete(s)}q.set(r,a)}return a(...o.map(i=>t[i]))}catch(o){T.debug(`Expression evaluation failed: ${n}`,o);return}}function Ue(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
2
2
  `)+`
3
- `}function Ge(e,t){const n=e.replace(/\$-\{/g,"${"),o=t?Object.keys(t):[],a=`
3
+ `}function Xe(e,t){const n=e.replace(/\$-\{/g,"${"),o=t?Object.keys(t):[],a=`
4
4
  const { $refs, $parent, $emit, $take, $handleEventFromChild, ...rest } = context;
5
5
 
6
6
  // Expose all $*-prefixed context entries (e.g. $router, $store) as local variables
@@ -13,7 +13,7 @@
13
13
  }
14
14
 
15
15
  // Inject resolved dependencies as local variables
16
- ${Xe(o)}
16
+ ${Ue(o)}
17
17
 
18
18
  return (${n});
19
- `;try{const i=t?new Function("context","__deps",a):new Function("context",a);return(c=>t?i(c,t):i(c))}catch(i){throw T.errorWithContext("Failed to compile dynamic code",{functionBody:a},i),i}}function be(){return new Map}const Ee=be();function ve(e,t,n){e==="global"&&(e=Ee),e.has(t)||e.set(t,new Set),e.get(t).add(n)}async function R(e,t,n){e==="global"&&(e=Ee);const o=Array.from(e.get(t)??[]);for(const r of o)try{await r(n)}catch(a){T.errorWithContext(`Hook "${t}" callback failed`,{hook:t},a)}}const G={modules:{},plugins:{}};function Ke(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.template=="string"&&typeof t.script=="string"&&typeof t.style=="string"}function Z(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Ze(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function Ye(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const Je=()=>{Object.defineProperties(Object.prototype,He),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,Ve)};function z(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function Qe(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>z(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const r=o.getAttribute(t);r!==null&&(Ae(o)===void 0&&Ce(o,r),o.removeAttribute(t)),o=n.nextNode()}}function fe(e,t){if(!z(e))return null;const n=e.tagName;let o=Ae(e);const r=ot(e);if(o===void 0&&t){const a=e.getAttribute(t);a!==null&&(Ce(e,a),o=a,e.removeAttribute(t))}return o===void 0?null:r!==void 0?`${n}:${String(o)}:${String(r)}`:`${n}:${String(o)}`}function et(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?!0:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!1}function Y(e,t){const n=new Set(e.getAttributeNames()),o=new Set(t.getAttributeNames());for(const r of n)!o.has(r)&&!r.startsWith("@")&&e.removeAttribute(r);for(const r of o){const a=t.getAttribute(r),i=e.getAttribute(r);a!==i&&(a===null?e.removeAttribute(r):e.setAttribute(r,a))}}function we(e,t,n){const o=Array.from(e.childNodes),r=Array.from(t.childNodes),a=new Map,i=new Set;for(const s of o){const c=fe(s,n);c!==null&&!a.has(c)&&a.set(c,s)}for(let s=0;s<r.length;s++){const c=r[s],l=o[s],m=fe(c,n);let p=null;if(m!==null&&a.has(m)&&(p=a.get(m),i.add(p)),p&&z(p)){l!==p&&(s<e.childNodes.length?e.insertBefore(p,e.childNodes[s]):e.appendChild(p)),Y(p,c);continue}if(z(c)&&m!==null){l?e.replaceChild(c,l):e.appendChild(c);continue}if(!l){e.appendChild(c);continue}if(!et(l,c)){e.replaceChild(c,l);continue}if(l.nodeType===Node.TEXT_NODE){l.textContent!==c.textContent&&(l.textContent=c.textContent);continue}if(l.nodeType===Node.COMMENT_NODE){l.textContent!==c.textContent&&(l.textContent=c.textContent);continue}if(l.nodeType===Node.ELEMENT_NODE){const N=l,x=c;if(z(N)){Y(N,x);continue}Y(N,x),we(N,x,n)}}for(;e.childNodes.length>r.length;){const s=e.lastChild;s&&e.removeChild(s)}}function tt(e,t,n,o){if(n||e.childNodes.length===0){o&&Qe(t,o),e.replaceChildren(t);return}const r=document.createElement("div");r.appendChild(t),we(e,r,o)}const oe=Symbol("STRUCT_ID"),re=Symbol("SLOT_ID");function Ne(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!1})}function Ce(e,t){Ne(e,oe,t)}function Ae(e){return Object.prototype.hasOwnProperty.call(e,oe)?e[oe]:void 0}function nt(e,t){Ne(e,re,t)}function ot(e){return Object.prototype.hasOwnProperty.call(e,re)?e[re]:void 0}function rt(e,t,n,o){if(!Array.isArray(t))return()=>{};const r=[];return t.forEach(([a,i,s])=>{if(typeof a!="string"||typeof s!="function"){T.error("Provided handler is not a function",s);return}let c=[];if(i==="window")c=[window];else if(typeof i=="string")if(i.startsWith("$refs.")){const[l,...m]=i.slice(6).split(" "),p=o[l];p&&(c=m.length?Array.from(p.querySelectorAll(m.join(" "))):[p])}else c=Array.from(n.querySelectorAll(i));else if(i instanceof Element||i instanceof Window)c=[i];else if(typeof i=="object"&&i&&"ref"in i){const{ref:l,selector:m}=i,p=o[l];p&&(c=m?Array.from(p.querySelectorAll(m)):[p])}for(const l of c){const m=K(s,e);l.addEventListener(a,m),r.push({target:l,type:a,handler:m})}}),()=>{for(const{target:a,type:i,handler:s}of r)a.removeEventListener(i,s);r.length=0}}const Te=/^on([a-z]+)$/i;function it(e,t){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let o=n.nextNode();for(;o;){for(const r of Array.from(o.attributes)){const a=r.name.match(Te);if(a){const i=a[1].toLowerCase(),s=r.value;if(s){const c=e[s];typeof c=="function"&&(o.removeAttribute(r.name),o.addEventListener(i,c))}}}o=n.nextNode()}}function st(e,t){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let o=n.nextNode();for(;o;){for(const r of Array.from(o.attributes)){const a=r.name.match(Te);if(a){const i=a[1].toLowerCase(),s=r.value;if(s){const c=e[s];typeof c=="function"&&(o.removeAttribute(r.name),o.addEventListener(i,c))}}}o=n.nextNode()}}function ct(e,t,n,o,r){if(!Array.isArray(n))return()=>{};const a=[];return n.forEach(([i,s,c])=>{if(typeof i!="string"||typeof c!="function"){T.error("Provided handler is not a function",c);return}let l=[];if(s==="window")l=[window];else if(typeof s=="string")if(s.startsWith("$refs.")){const[m,...p]=s.slice(6).split(" "),N=r[m];N&&(l=p.length?Array.from(N.querySelectorAll(p.join(" "))):[N])}else l=Array.from(o.querySelectorAll(s));else if(s instanceof Element||s instanceof Window)l=[s];else if(typeof s=="object"&&s&&"ref"in s){const{ref:m,selector:p}=s,N=r[m];N&&(l=p?Array.from(N.querySelectorAll(p)):[N])}for(const m of l){const p=K(c,t);m.addEventListener(i,p),a.push({target:m,type:i,handler:p})}}),()=>{for(const{target:i,type:s,handler:c}of a)i.removeEventListener(s,c);a.length=0}}const j=new WeakMap;let J;function at(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,n=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(o,r,a){return j.has(this)||j.set(this,new Set),j.get(this).add({type:o,listener:r,options:a}),t.call(this,o,r,a)},EventTarget.prototype.removeEventListener=function(o,r,a){const i=j.get(this);if(i){for(const s of i)if(s.type===o&&s.listener===r){i.delete(s);break}i.size===0&&j.delete(this)}return n.call(this,o,r,a)}}function lt(e){const t=j.get(e);if(t){for(const{type:n,listener:o,options:r}of t)e.removeEventListener(n,o,r);j.delete(e)}}function _e(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=e instanceof Element?e:null;for(;n;)j.has(n)&&lt(n),n=t.nextNode()}function ft(){J||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(J=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&_e(n)})}),J.observe(document.body,{childList:!0,subtree:!0}))}const Se=new WeakMap,xe=new WeakMap,U=new WeakMap;let ut=0;const V=()=>`slot-${++ut}`,F=e=>typeof e=="object"&&e!==null,Q=e=>typeof e=="symbol"?e.toString():String(e),dt=e=>{const t=Se.get(e);return t&&F(t)?t:void 0};function Oe(e){const t=xe.get(e);return t||e}const W=e=>F(e)?Reflect.get(e,ye)===!0:!1;function ht(e){const t=W(e)?Oe(e):e;return U.get(t)}const pt=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),X=e=>{let t=U.get(e);return t||(t=e.map(()=>V()),U.set(e,t)),t},ue=e=>{const t=U.get(e);if(t&&t.length!==e.length)throw new Error(`Slot sidecar invariant violation: slotIds length (${t.length}) does not match array length (${e.length})`)};function mt(e){const t=new Set,n=new WeakMap;let o=0,r=new Set;const a=new Map,i=(f,y)=>!!(f===y||f.startsWith(y+".")),s=(f,y)=>{const b=n.get(f)??"";return b?`${b}.${y}`:y};let c=!1;const l=f=>{r.add(f),o++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(y=>{try{y()}catch(b){console.error("Observer error:",b)}})}))},m=(f,y,b)=>{if(f===y)return;let w=f.length!==y.length;if(!w){for(let u=0;u<f.length;u++)if(f[u]!==y[u]){w=!0;break}}f.splice(0,f.length,...y),w&&l(b)},p=(f,y,b)=>{const w=new Set(f),u=new Set(y);let d=!1;for(const g of w)if(!u.has(g)){d=!0;break}if(!d){for(const g of u)if(!w.has(g)){d=!0;break}}d&&(f.splice(0,f.length,...y),l(b))},N=(f,y,b)=>{const w=new Set(f),u=new Set(y);f.length!==y.length||[...w].some(g=>!u.has(g))||[...u].some(g=>!w.has(g))?p(f,y,b):m(f,y,b)},x=(f,y,b)=>{if(f===y)return!1;let w=!1;for(const u of Object.keys(f))u in y||(w=!0,Reflect.deleteProperty(f,u));for(const u of Object.keys(y)){const d=f[u],g=y[u];d!==g&&(F(d)&&W(d)&&F(g)&&!W(g)?(x(d,g)&&(w=!0),d!==g&&(w=!0,Reflect.set(f,u,g))):(w=!0,Reflect.set(f,u,g)))}return w},S=(f,y,b)=>{const w=X(f);switch(y){case"push":{const u=Array.from({length:b.length},()=>V());w.push(...u);break}case"pop":{w.pop();break}case"shift":{w.shift();break}case"unshift":{const u=Array.from({length:b.length},()=>V());w.unshift(...u);break}case"splice":{const u=b[0]??0,d=b[1]!==void 0?b[1]:f.length-u,g=b.slice(2),_=Array.from({length:g.length},()=>V());w.splice(u,d,..._);break}case"reverse":{w.reverse();break}}ue(f)},v=(f,y="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=dt(f);if(b)return b;y&&n.set(f,y),Array.isArray(f)&&X(f);const w=new Proxy(f,{get:(u,d,g)=>{if(d===ye)return!0;if(d==="toJSON")return function(){return Oe(u)};if(Array.isArray(u)&&typeof d=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(d)){const O=u[d];if(typeof O=="function")return function(...I){if(d==="sort"){const k=X(u),h=u.map((C,D)=>({el:C,slotId:k[D]||V()})),E=O.apply(this,I),A=new Map;for(let C=0;C<h.length;C++){const D=h[C].el;let $=A.get(D);$||($=[],A.set(D,$)),$.push(C)}for(let C=0;C<u.length;C++){const D=u[C],$=A.get(D);if($&&$.length>0){const Pe=$.shift();k[C]=h[Pe].slotId}else k[C]=V()}return ue(u),E}else{const k=O.apply(this,I);return S(u,d,I),k}}}const _=Reflect.get(u,d,g),M=Array.isArray(u)&&typeof d=="string"&&/^\d+$/.test(d);if(F(_)&&!W(_)&&!M&&(Array.isArray(_)||!Array.isArray(u))){const L=Q(d),O=s(u,L);return v(_,O)}return _},set:(u,d,g,_)=>{const M=Reflect.get(u,d,_);if(M===g)return!0;const L=Q(d),O=s(u,L);if(Array.isArray(u)&&typeof d=="string"&&/^\d+$/.test(d)){const k=parseInt(d,10);if(k>=0&&k<u.length){const h=Reflect.set(u,d,g,_);return l(O),h}}if(Array.isArray(M)&&!pt(g)&&Array.isArray(g)){N(M,g,O);const k=M.map(()=>V());return U.set(M,k),!0}if(F(M)&&W(M)&&F(g)&&!W(g)){if(x(M,g)){let h=g;F(h)&&!W(h)&&(h=v(h,O)),Reflect.set(u,d,h,_),l(O)}return!0}const I=Reflect.set(u,d,g,_);if(F(g)&&!W(g)){const k=v(g,O);Reflect.set(u,d,k,_),Array.isArray(g)&&X(g)}return l(O),I},deleteProperty:(u,d)=>{if(d==="changedPaths")return Reflect.deleteProperty(u,d);const g=Q(d),_=s(u,g),M=Reflect.get(u,d),L=Reflect.deleteProperty(u,d);return L&&M!==void 0&&l(_),L}});return Se.set(f,w),xe.set(w,f),w};return{state:v(e),watch(f,y){let b=a.get(f);b||(b=new Set,a.set(f,b)),b.add(y);let w=!1;return()=>{if(w)return;w=!0;const u=a.get(f);u&&(u.delete(y),u.size===0&&a.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return o},hasPendingChangesFor(f){for(const y of r)for(const b of f)if(y===b||y.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(r);if(f.size>0&&a.size>0){const y=new Map;for(const[b,w]of a){const u=new Set;for(const d of f)i(d,b)&&u.add(d);if(u.size>0)for(const d of w){const g=y.get(d);if(g)for(const _ of u)g.add(_);else y.set(d,new Set(u))}}for(const[b,w]of y)b({changedPaths:w})}return r=new Set,f}}}const ee=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function yt(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const o=t.slice(1,-1).split(",").map(i=>i.trim());if(o.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[r,a]=o;if(!ee.test(r)||!ee.test(a))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:r,itemVar:a}}if(!ee.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function gt(e){const t={acceptNode(n){return n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(n.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function bt(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function Et(e,t){let n=t.nextSibling;if(!n){let o=t.parentNode;for(;o&&o!==e.root;){if(o.nextSibling){n=o.nextSibling;break}o=o.parentNode}}return n?(e.currentNode=n,n):null}function vt(e){return e==null||e===!0||e===!1?"":String(e)}function $e(e,t){return e.replace(/\{\{(.+?)\}\}/g,(n,o)=>{const r=H(o.trim(),t);return vt(r)})}async function wt(e,t,n){const o=e.getAttribute("loop");if(!o)return;e.removeAttribute("loop");const r=e.getAttribute("if");r&&e.removeAttribute("if");const a=o.match(/^(.+?)\s+in\s+(.+)$/);if(!a)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,i,s]=a,c=yt(i),l=H(s.trim(),t);if(l==null){e.remove();return}if(typeof l!="object"){T.error("State source is not iterable",{collectionExp:s,raw:l});return}const m=Array.isArray(l),p=m?l.map((f,y)=>[String(y),f]):Object.entries(l),N=p.length,x=document.createDocumentFragment(),S=m?ht(l):void 0,v={...t};let P=0;for(const[f,y]of p){if(v.index=P,v.key=f,v.isFirst=P===0,v.isLast=P===N-1,v.isEven=P%2===0,v.isOdd=P%2!==0,c.type==="single"||(v[c.keyVar]=f),v[c.itemVar]=y,r&&!H(r,v)){P++;continue}const b=e.cloneNode(!0);m&&b instanceof HTMLElement&&S&&S[P]!==void 0&&nt(b,S[P]),b instanceof HTMLElement&&(await ke(b,v,n),x.appendChild(b)),P++}x.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(x,e):e.remove()}function Nt(e,t,n){const o=e.parentNode,r=()=>{if(o)return n.get(o)},a=l=>{o&&n.set(o,l)},i=()=>{o&&n.delete(o)},s=e.getAttribute("if");if(s!==null){const l=!!H(s,t);a({hasHead:!0,resolved:l}),l?e.removeAttribute("if"):e.remove();return}const c=e.getAttribute("else-if");if(c!==null){const l=r();if(!l?.hasHead){e.remove();return}if(l.resolved){e.remove();return}const m=!!H(c,t);a({hasHead:!0,resolved:m}),m?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const l=r();if(!l?.hasHead){e.remove();return}l.resolved?e.remove():e.removeAttribute("else"),i();return}}async function Ct(e,t,n=50){const o=new WeakMap;for(let r=0;r<e.length;r+=n){const a=e.slice(r,r+n);for(const{node:i,state:s}of a){if(i instanceof HTMLElement){if(i.hasAttribute("loop")){await wt(i,s,t);continue}if(i.hasAttribute("if")||i.hasAttribute("else")||i.hasAttribute("else-if")){Nt(i,s,o);continue}continue}const c=$e(i.nodeValue,s);if(Fe(c)){const l=document.createRange().createContextualFragment(c);i.replaceWith(l)}else i.nodeValue=c}r+n<e.length&&await new Promise(requestAnimationFrame)}}async function ke(e,t,n){try{const o=gt(e),r=new Set,a=[];let i=o.currentNode;for(;i;){if(r.has(i)){i=o.nextNode();continue}if(r.add(i),i.nodeType===Node.ELEMENT_NODE&&i instanceof HTMLElement){const s=i;if(s.hasAttribute("loop")){a.push({node:s,state:t}),i=Et(o,s);continue}(s.hasAttribute("if")||s.hasAttribute("else")||s.hasAttribute("else-if"))&&a.push({node:s,state:t});for(const c of Array.from(s.attributes)){if(c.name==="ref"&&(n[c.value]=s),c.name.startsWith(":")){const l=c.name.slice(1),m=c.value.trim();try{const p=H(m,t);if(l==="class"&&typeof p=="object"&&p!==null){const N=[];for(const[x,S]of Object.entries(p))S&&N.push(x);if(N.length>0){const x=s.getAttribute("class")||"",S=x?`${x} ${N.join(" ")}`:N.join(" ");s.setAttribute("class",S)}}else p!=null&&p!==!1&&(p===!0?s.setAttribute(l,""):s.setAttribute(l,String(p)));s.removeAttribute(c.name)}catch(p){T.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:m},p)}continue}if(c.value.includes("{{"))try{let l=$e(c.value,t);c.name==="class"&&(l=l.replace(/\s+/g," ").trim()),l!==c.value&&s.setAttribute(c.name,l)}catch(l){T.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},l)}}if(s.tagName.includes("-")){i=bt(o)||o.nextNode();continue}}else if(i.nodeType===Node.TEXT_NODE&&i instanceof Text){let s=i.parentElement,c=!1;for(;s;){if(s.tagName.includes("-")){c=!0;break}s=s.parentElement}c||a.push({node:i,state:t})}i=o.nextNode()}await Ct(a,n)}catch(o){throw T.errorWithContext("Error processing template",{},o),o}}function At(e,t={}){if(!Array.isArray(e)||e.length===0)throw new Error("composeBySource: layers must be a non-empty array");if(e.some(s=>s==null||typeof s!="object"))throw new Error("composeBySource: all layers must be objects");const{defaultWriteIndex:n=e.length-1,includePrototype:o=!1}=t,r=n>=0&&n<e.length&&Number.isInteger(n)?n:e.length-1;n!==r&&T.warnWithContext(`Invalid defaultWriteIndex ${n}, using ${r}`,{defaultWriteIndex:n,validWriteIndex:r,layersLength:e.length});const a=(s,c)=>o?c in s:Object.prototype.hasOwnProperty.call(s,c),i=s=>{for(let c=0;c<e.length;c++)if(a(e[c],s))return c;return-1};return new Proxy(e[r],{get(s,c){const l=i(c);if(l!==-1)return e[l][c]},set(s,c,l){const m=i(c),p=m!==-1?m:r;return e[p][c]=l,!0},deleteProperty(s,c){const l=i(c);return l===-1?!0:delete e[l][c]},has(s,c){return i(c)!==-1},ownKeys(){const s=new Set;for(const c of e)Reflect.ownKeys(c).forEach(l=>{typeof l!="number"&&s.add(l)});return Array.from(s)},getOwnPropertyDescriptor(s,c){for(const l of e){const m=Object.getOwnPropertyDescriptor(l,c);if(m)return m}}})}function de(e){const t=e.getRootNode(),n=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(Ye(n))return n.instance}function Tt({container:e,host:t}){const n=Array.from(t.childNodes).filter(r=>r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE),o={};for(const r of n){const a=r instanceof HTMLElement&&r.hasAttribute("slot")?r.getAttribute("slot"):"default";o[a]||(o[a]=[]),o[a].push(r)}e.querySelectorAll("slot").forEach(r=>{const a=r.getAttribute("name")||"default",i=o[a];i&&i.length>0&&i.forEach(s=>{r.parentNode.insertBefore(s,r)}),r.remove()})}function te({propName:e,propValue:t,props:n}){const o=n[e],r=t??o?.default;if(!o)return!0;const a=We(o.type),i=Array.isArray(r)?"array":typeof r,s={string:i==="string",number:i==="number",boolean:i==="boolean",array:Array.isArray(r),object:i==="object"&&r!==null&&!Array.isArray(r),function:i==="function"};return(a==="unknown"?!0:s[a]??!1)?o.regex&&typeof r=="string"&&!new RegExp(o.regex).test(r)?(T.error(`Prop "${e}" does not match regex "${o.regex}".`),!1):!0:(T.error(`Prop "${e}" should be of type "${a}", but got "${i}".`,r),!1)}function he({ele:e,parent:t,props:n,state:o}){const r=Object.keys(n).length>0,a=(i,s)=>{Object.defineProperty(o,i,{enumerable:!0,configurable:!0,get(){if(t)return ne(t.state,s)},set(c){if(!(!t||!t.state))try{je(t.state,s,c)}catch(l){T.errorWithContext(`Failed to set bound prop "${i}" → "${s}"`,{propName:i,parentPath:s},l)}}})};for(const i of e.attributes){const s=i.name.startsWith(":"),c=Be(i.name.substring(s?1:0));if(s&&!t||!(!r||n[c]&&n[c]!==void 0))continue;if(!s){const N=i.value!==""?i.value:!0;(!r||te({propName:c,propValue:N,props:n}))&&(o[c]=N);continue}const m=i.value?.trim()??"";if(m&&ge(m)){const N=ne(t.state,m);(!r||te({propName:c,propValue:N,props:n}))&&a(c,m);continue}const p=m?H(m,t.state):void 0;(!r||te({propName:c,propValue:p,props:n}))&&(o[c]=p)}for(const[i,s]of Object.entries(n))i in o||(s.default!==void 0?o[i]=s.default:s.required&&T.error(`Required prop "${i}" is missing.`))}function _t(e,t){customElements.define(e,class extends HTMLElement{constructor(){super(),this._isDisconnected=!1,this._isMounted=!1,this._renderAborted=!1,this._pendingRender=null,this._eventCleanup=null,this.template=document.createElement("template"),this.template.innerHTML=t.template}async connectedCallback(){const n=this;if(n.instance&&this._model&&this._observerFn){const h=n.instance,E=de(n);h.$parent=E,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),this._isMounted=!0,h.props&&h.state&&he({ele:n,parent:E,props:h.props,state:h.state});return}const r=(t.type||"options")==="options",a=de(n),i=this.template.cloneNode(!0);let s;if(t.deps){s={};const h=Object.entries(t.deps),E=await Promise.all(h.map(([,A])=>A()));for(let A=0;A<h.length;A++)s[h[A][0]]=E[A]}const c=Ge(t.script,s),l={};let m=!1,p=-1;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const N=be(),x=(()=>{let h;return{promise:new Promise(A=>{h=A}),resolve:h}})();if(!document.head.querySelector(`style#style-${e}`)){const h=document.createElement("style");h.id=`style-${e}`,h.textContent=t.style,document.head.appendChild(h)}let S,v;const P=h=>{const E=G.plugins[h];if(!E||typeof E.setup!="function"){T.warnWithContext(`Plugin "${h}" not found or has no setup method`,{pluginName:h});return}try{const A=r&&v?v:S;return E.setup.call(A)}catch(A){T.errorWithContext(`Plugin "${h}" setup failed`,{pluginName:h},A);return}},f={};for(const[h,E]of Object.entries(G.modules))if(typeof E.attach=="function"){const A=E.attach.call({element:n,parent:a,core:{take:ce.take}});A&&(f[`$${h}`]=A)}const y=new Map,b=h=>{let E=y.get(h);return E||(E=`on${h.charAt(0).toUpperCase()}${h.slice(1)}`,y.set(h,E)),E},w=(h,...E)=>{const A=b(h);let C=a;for(;C;){const D=C.userContext;if(D){const $=D[A];typeof $=="function"&&$(...E)}else if(C.methods){const $=C.methods[A];typeof $=="function"&&$(...E)}C=C.$parent}},u={$refs:l,$parent:a,$emit:w,$take:P,...f},d=c(u),g=mt(d.state??{});S=g.state;const _=d.methods||{},M=d.props||{},L=d.events||[];let O=d.watchList||[];r&&(v=At([_,S])),he({ele:n,parent:a,props:M,state:S}),r&&v&&De(_,v);for(const h of Le){const E=d[h];if(typeof E=="function"){const A=r&&v?K(E,v):E;ve(N,h,async()=>{const C=A();C instanceof Promise&&await C})}}this._model=g;const I=async()=>{if(this._isDisconnected)return;if(m){this._renderAborted=!0,this._pendingRender=I;return}const h=g.getStateVersion();if(p!==h){m=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const E=i.content.cloneNode(!0);if(Tt({container:E,host:n}),await ke(E,r&&v?v:S,l),this._renderAborted){this._pendingRender=I;return}const C=r&&v?v:S;if(await R("global","processed",C),await R(N,"processed"),this._renderAborted){this._pendingRender=I;return}r&&v?(it(v,E),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=rt(v,L,E,l)):(st(_,E),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ct(_,S,L,E,l));const D=g.flushChanges();Object.defineProperty(C,"changedPaths",{value:D,writable:!0,configurable:!0,enumerable:!1});const $=!this._isMounted;if(await R("global",$?"beforeMount":"beforeUpdate",C),await R(N,$?"beforeMount":"beforeUpdate",C),this._renderAborted){delete C.changedPaths,this._pendingRender=I;return}tt(n,E,!this._isMounted,t.structAttr),this._isMounted&&(await R("global","updated",C),await R(N,"updated",C)),delete C.changedPaths,p=h,n.instance&&(n.instance._lastRenderedStateVersion=p)}catch(E){T.errorWithContext("Error during render",{componentName:e},E)}finally{const E=r&&v?v:S;if(delete E.changedPaths,m=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const A=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||A().catch(C=>{T.errorWithContext("Error during pending render",{componentName:e},C)})})}}}};n.instance={element:n,template:i,state:S,userContext:r?v:void 0,props:M,methods:_,events:L,watchList:O,$refs:l,$parent:a,$emit:w,$take:P,readyPromise:x.promise,lifecycleRegistry:N,...f,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||O&&O.length>0&&!g.hasPendingChangesFor(O))return;let h=a;for(;h;){if(h.isRendering)return;h=h.$parent}requestAnimationFrame(()=>{this._isDisconnected||I().catch(E=>{T.errorWithContext("Error during render (observer)",{componentName:e},E)})})},g.addObserver(this._observerFn);const k=r&&v?v:S;await R("global","created",k),await R(N,"created"),await I(),this._isMounted||(await R("global","mounted",k),await R(N,"mounted"),this._isMounted=!0),x.resolve()}async disconnectedCallback(){const n=this;if(!n.instance)return;this._isMounted=!1;const o=n.instance;this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this._model&&this._observerFn&&this._model.removeObserver(this._observerFn);const r=o.userContext||o.state;await R("global","beforeDestroy",r),await R(o.lifecycleRegistry,"beforeDestroy"),this._isDisconnected&&(_e(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),document.body.querySelector(this.tagName.toLowerCase())||document.head.querySelector(`style#style-${this.tagName.toLowerCase()}`)?.remove(),await R("global","destroyed",r),await R(o.lifecycleRegistry,"destroyed"),this._isDisconnected&&(this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let ie=!1,pe=!1,se=[];function Me(){pe||(pe=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(at(),Je(),ft()))}function Re(...e){const t=e[0],n=e[1];if(Ke(t)){if(!n){T.error("ComponentSource requires a component name when calling take()");return}_t(n,t);return}if(Z(t)||Ze(t)){const o={registerHook:(r,a)=>{ve("global",r,a)},take:ce.take};try{t.install(o),Z(t)?G.plugins[t.name]=t:G.modules[t.name]=t}catch(r){T.errorWithContext("Failed to install extension",{name:t.name,type:Z(t)?"plugin":"module"},r)}return}T.error("Unknown extension type",t)}function St(){ie||(ie=!0,se.forEach(e=>Re(...e)),se=[],T.info("Core initialized"))}const ce=Object.assign(()=>{Me(),St()},{take:(...t)=>{ie?Re(...t):se.push(t)}});exports.Core=ce;exports.LogLevel=me;exports.initDomEnvironment=Me;exports.logger=T;
19
+ `;try{const i=t?new Function("context","__deps",a):new Function("context",a);return(c=>t?i(c,t):i(c))}catch(i){throw T.errorWithContext("Failed to compile dynamic code",{functionBody:a},i),i}}function be(){return new Map}const Ee=be();function ve(e,t,n){e==="global"&&(e=Ee),e.has(t)||e.set(t,new Set),e.get(t).add(n)}async function R(e,t,n){e==="global"&&(e=Ee);const o=Array.from(e.get(t)??[]);for(const r of o)try{await r(n)}catch(a){T.errorWithContext(`Hook "${t}" callback failed`,{hook:t},a)}}const G={modules:{},plugins:{}};function Ge(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.template=="string"&&typeof t.script=="string"&&typeof t.style=="string"}function Z(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Ke(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function Ze(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const Ye=()=>{Object.defineProperties(Object.prototype,Ve),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,je)};function z(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function Je(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>z(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const r=o.getAttribute(t);r!==null&&(Ae(o)===void 0&&Ce(o,r),o.removeAttribute(t)),o=n.nextNode()}}function fe(e,t){if(!z(e))return null;const n=e.tagName;let o=Ae(e);const r=nt(e);if(o===void 0&&t){const a=e.getAttribute(t);a!==null&&(Ce(e,a),o=a,e.removeAttribute(t))}return o===void 0?null:r!==void 0?`${n}:${String(o)}:${String(r)}`:`${n}:${String(o)}`}function Qe(e,t){return e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?!0:e.nodeType===Node.ELEMENT_NODE?e.tagName===t.tagName:!1}function Y(e,t){const n=new Set(e.getAttributeNames()),o=new Set(t.getAttributeNames());for(const r of n)!o.has(r)&&!r.startsWith("@")&&e.removeAttribute(r);for(const r of o){const a=t.getAttribute(r),i=e.getAttribute(r);a!==i&&(a===null?e.removeAttribute(r):e.setAttribute(r,a))}}function we(e,t,n){const o=Array.from(e.childNodes),r=Array.from(t.childNodes),a=new Map,i=new Set;for(const s of o){const c=fe(s,n);c!==null&&!a.has(c)&&a.set(c,s)}for(let s=0;s<r.length;s++){const c=r[s],l=o[s],m=fe(c,n);let p=null;if(m!==null&&a.has(m)&&(p=a.get(m),i.add(p)),p&&z(p)){l!==p&&(s<e.childNodes.length?e.insertBefore(p,e.childNodes[s]):e.appendChild(p)),Y(p,c);continue}if(z(c)&&m!==null){l?e.replaceChild(c,l):e.appendChild(c);continue}if(!l){e.appendChild(c);continue}if(!Qe(l,c)){e.replaceChild(c,l);continue}if(l.nodeType===Node.TEXT_NODE){l.textContent!==c.textContent&&(l.textContent=c.textContent);continue}if(l.nodeType===Node.COMMENT_NODE){l.textContent!==c.textContent&&(l.textContent=c.textContent);continue}if(l.nodeType===Node.ELEMENT_NODE){const N=l,x=c;if(z(N)){Y(N,x);continue}Y(N,x),we(N,x,n)}}for(;e.childNodes.length>r.length;){const s=e.lastChild;s&&e.removeChild(s)}}function et(e,t,n,o){if(n||e.childNodes.length===0){o&&Je(t,o),e.replaceChildren(t);return}const r=document.createElement("div");r.appendChild(t),we(e,r,o)}const oe=Symbol("STRUCT_ID"),re=Symbol("SLOT_ID");function Ne(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!1})}function Ce(e,t){Ne(e,oe,t)}function Ae(e){return Object.prototype.hasOwnProperty.call(e,oe)?e[oe]:void 0}function tt(e,t){Ne(e,re,t)}function nt(e){return Object.prototype.hasOwnProperty.call(e,re)?e[re]:void 0}function ot(e,t,n,o){if(!Array.isArray(t))return()=>{};const r=[];return t.forEach(([a,i,s])=>{if(typeof a!="string"||typeof s!="function"){T.error("Provided handler is not a function",s);return}let c=[];if(i==="window")c=[window];else if(typeof i=="string")if(i.startsWith("$refs.")){const[l,...m]=i.slice(6).split(" "),p=o[l];p&&(c=m.length?Array.from(p.querySelectorAll(m.join(" "))):[p])}else c=Array.from(n.querySelectorAll(i));else if(i instanceof Element||i instanceof Window)c=[i];else if(typeof i=="object"&&i&&"ref"in i){const{ref:l,selector:m}=i,p=o[l];p&&(c=m?Array.from(p.querySelectorAll(m)):[p])}for(const l of c){const m=K(s,e);l.addEventListener(a,m),r.push({target:l,type:a,handler:m})}}),()=>{for(const{target:a,type:i,handler:s}of r)a.removeEventListener(i,s);r.length=0}}const Te=/^on([a-z]+)$/i;function rt(e,t){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let o=n.nextNode();for(;o;){for(const r of Array.from(o.attributes)){const a=r.name.match(Te);if(a){const i=a[1].toLowerCase(),s=r.value;if(s){const c=e[s];typeof c=="function"&&(o.removeAttribute(r.name),o.addEventListener(i,c))}}}o=n.nextNode()}}function it(e,t){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let o=n.nextNode();for(;o;){for(const r of Array.from(o.attributes)){const a=r.name.match(Te);if(a){const i=a[1].toLowerCase(),s=r.value;if(s){const c=e[s];typeof c=="function"&&(o.removeAttribute(r.name),o.addEventListener(i,c))}}}o=n.nextNode()}}function st(e,t,n,o,r){if(!Array.isArray(n))return()=>{};const a=[];return n.forEach(([i,s,c])=>{if(typeof i!="string"||typeof c!="function"){T.error("Provided handler is not a function",c);return}let l=[];if(s==="window")l=[window];else if(typeof s=="string")if(s.startsWith("$refs.")){const[m,...p]=s.slice(6).split(" "),N=r[m];N&&(l=p.length?Array.from(N.querySelectorAll(p.join(" "))):[N])}else l=Array.from(o.querySelectorAll(s));else if(s instanceof Element||s instanceof Window)l=[s];else if(typeof s=="object"&&s&&"ref"in s){const{ref:m,selector:p}=s,N=r[m];N&&(l=p?Array.from(N.querySelectorAll(p)):[N])}for(const m of l){const p=K(c,t);m.addEventListener(i,p),a.push({target:m,type:i,handler:p})}}),()=>{for(const{target:i,type:s,handler:c}of a)i.removeEventListener(s,c);a.length=0}}const j=new WeakMap;let J;function ct(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,n=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(o,r,a){return j.has(this)||j.set(this,new Set),j.get(this).add({type:o,listener:r,options:a}),t.call(this,o,r,a)},EventTarget.prototype.removeEventListener=function(o,r,a){const i=j.get(this);if(i){for(const s of i)if(s.type===o&&s.listener===r){i.delete(s);break}i.size===0&&j.delete(this)}return n.call(this,o,r,a)}}function at(e){const t=j.get(e);if(t){for(const{type:n,listener:o,options:r}of t)e.removeEventListener(n,o,r);j.delete(e)}}function _e(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=e instanceof Element?e:null;for(;n;)j.has(n)&&at(n),n=t.nextNode()}function lt(){J||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(J=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&_e(n)})}),J.observe(document.body,{childList:!0,subtree:!0}))}const Se=new WeakMap,xe=new WeakMap,U=new WeakMap;let ft=0;const V=()=>`slot-${++ft}`,W=e=>typeof e=="object"&&e!==null,Q=e=>typeof e=="symbol"?e.toString():String(e),ut=e=>{const t=Se.get(e);return t&&W(t)?t:void 0};function Oe(e){const t=xe.get(e);return t||e}const D=e=>W(e)?Reflect.get(e,ye)===!0:!1;function dt(e){const t=D(e)?Oe(e):e;return U.get(t)}const ht=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),X=e=>{let t=U.get(e);return t||(t=e.map(()=>V()),U.set(e,t)),t},ue=e=>{const t=U.get(e);if(t&&t.length!==e.length)throw new Error(`Slot sidecar invariant violation: slotIds length (${t.length}) does not match array length (${e.length})`)};function pt(e){const t=new Set,n=new WeakMap;let o=0,r=new Set;const a=new Map,i=(f,y)=>!!(f===y||f.startsWith(y+".")),s=(f,y)=>{const b=n.get(f)??"";return b?`${b}.${y}`:y};let c=!1;const l=f=>{r.add(f),o++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(y=>{try{y()}catch(b){console.error("Observer error:",b)}})}))},m=(f,y,b)=>{if(f===y)return;let w=f.length!==y.length;if(!w){for(let u=0;u<f.length;u++)if(f[u]!==y[u]){w=!0;break}}f.splice(0,f.length,...y),w&&l(b)},p=(f,y,b)=>{const w=new Set(f),u=new Set(y);let d=!1;for(const g of w)if(!u.has(g)){d=!0;break}if(!d){for(const g of u)if(!w.has(g)){d=!0;break}}d&&(f.splice(0,f.length,...y),l(b))},N=(f,y,b)=>{const w=new Set(f),u=new Set(y);f.length!==y.length||[...w].some(g=>!u.has(g))||[...u].some(g=>!w.has(g))?p(f,y,b):m(f,y,b)},x=(f,y,b)=>{if(f===y)return!1;let w=!1;for(const u of Object.keys(f))u in y||(w=!0,Reflect.deleteProperty(f,u));for(const u of Object.keys(y)){const d=f[u],g=y[u];d!==g&&(W(d)&&D(d)&&W(g)&&!D(g)?(x(d,g)&&(w=!0),d!==g&&(w=!0,Reflect.set(f,u,g))):(w=!0,Reflect.set(f,u,g)))}return w},S=(f,y,b)=>{const w=X(f);switch(y){case"push":{const u=Array.from({length:b.length},()=>V());w.push(...u);break}case"pop":{w.pop();break}case"shift":{w.shift();break}case"unshift":{const u=Array.from({length:b.length},()=>V());w.unshift(...u);break}case"splice":{const u=b[0]??0,d=b[1]!==void 0?b[1]:f.length-u,g=b.slice(2),_=Array.from({length:g.length},()=>V());w.splice(u,d,..._);break}case"reverse":{w.reverse();break}}ue(f)},v=(f,y="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=ut(f);if(b)return b;y&&n.set(f,y),Array.isArray(f)&&X(f);const w=new Proxy(f,{get:(u,d,g)=>{if(d===ye)return!0;if(d==="toJSON")return function(){return Oe(u)};if(Array.isArray(u)&&typeof d=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(d)){const O=u[d];if(typeof O=="function")return function(...I){if(d==="sort"){const k=X(u),h=u.map((C,F)=>({el:C,slotId:k[F]||V()})),E=O.apply(this,I),A=new Map;for(let C=0;C<h.length;C++){const F=h[C].el;let $=A.get(F);$||($=[],A.set(F,$)),$.push(C)}for(let C=0;C<u.length;C++){const F=u[C],$=A.get(F);if($&&$.length>0){const Re=$.shift();k[C]=h[Re].slotId}else k[C]=V()}return ue(u),E}else{const k=O.apply(this,I);return S(u,d,I),k}}}const _=Reflect.get(u,d,g),M=Array.isArray(u)&&typeof d=="string"&&/^\d+$/.test(d);if(W(_)&&!D(_)&&!M&&(Array.isArray(_)||!Array.isArray(u))){const L=Q(d),O=s(u,L);return v(_,O)}return _},set:(u,d,g,_)=>{const M=Reflect.get(u,d,_);if(M===g)return!0;const L=Q(d),O=s(u,L);if(Array.isArray(u)&&typeof d=="string"&&/^\d+$/.test(d)){const k=parseInt(d,10);if(k>=0&&k<u.length){const h=Reflect.set(u,d,g,_);return l(O),h}}if(Array.isArray(M)&&!ht(g)&&Array.isArray(g)){N(M,g,O);const k=M.map(()=>V());return U.set(M,k),!0}if(W(M)&&D(M)&&W(g)&&!D(g)){if(x(M,g)){let h=g;W(h)&&!D(h)&&(h=v(h,O)),Reflect.set(u,d,h,_),l(O)}return!0}const I=Reflect.set(u,d,g,_);if(W(g)&&!D(g)){const k=v(g,O);Reflect.set(u,d,k,_),Array.isArray(g)&&X(g)}return l(O),I},deleteProperty:(u,d)=>{if(d==="changedPaths")return Reflect.deleteProperty(u,d);const g=Q(d),_=s(u,g),M=Reflect.get(u,d),L=Reflect.deleteProperty(u,d);return L&&M!==void 0&&l(_),L}});return Se.set(f,w),xe.set(w,f),w};return{state:v(e),watch(f,y){let b=a.get(f);b||(b=new Set,a.set(f,b)),b.add(y);let w=!1;return()=>{if(w)return;w=!0;const u=a.get(f);u&&(u.delete(y),u.size===0&&a.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return o},hasPendingChangesFor(f){for(const y of r)for(const b of f)if(y===b||y.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(r);if(f.size>0&&a.size>0){const y=new Map;for(const[b,w]of a){const u=new Set;for(const d of f)i(d,b)&&u.add(d);if(u.size>0)for(const d of w){const g=y.get(d);if(g)for(const _ of u)g.add(_);else y.set(d,new Set(u))}}for(const[b,w]of y)b({changedPaths:w})}return r=new Set,f}}}const ee=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function mt(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const o=t.slice(1,-1).split(",").map(i=>i.trim());if(o.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[r,a]=o;if(!ee.test(r)||!ee.test(a))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:r,itemVar:a}}if(!ee.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function yt(e){const t={acceptNode(n){return n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(n.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function gt(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function bt(e,t){let n=t.nextSibling;if(!n){let o=t.parentNode;for(;o&&o!==e.root;){if(o.nextSibling){n=o.nextSibling;break}o=o.parentNode}}return n?(e.currentNode=n,n):null}function Et(e){return e==null||e===!0||e===!1?"":String(e)}function $e(e,t){return e.replace(/\{\{(.+?)\}\}/g,(n,o)=>{const r=H(o.trim(),t);return Et(r)})}async function vt(e,t,n){const o=e.getAttribute("loop");if(!o)return;e.removeAttribute("loop");const r=e.getAttribute("if");r&&e.removeAttribute("if");const a=o.match(/^(.+?)\s+in\s+(.+)$/);if(!a)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,i,s]=a,c=mt(i),l=H(s.trim(),t);if(l==null){e.remove();return}if(typeof l!="object"){T.error("State source is not iterable",{collectionExp:s,raw:l});return}const m=Array.isArray(l),p=m?l.map((f,y)=>[String(y),f]):Object.entries(l),N=p.length,x=document.createDocumentFragment(),S=m?dt(l):void 0,v={...t};let P=0;for(const[f,y]of p){if(v.index=P,v.key=f,v.isFirst=P===0,v.isLast=P===N-1,v.isEven=P%2===0,v.isOdd=P%2!==0,c.type==="single"||(v[c.keyVar]=f),v[c.itemVar]=y,r&&!H(r,v)){P++;continue}const b=e.cloneNode(!0);m&&b instanceof HTMLElement&&S&&S[P]!==void 0&&tt(b,S[P]),b instanceof HTMLElement&&(await ke(b,v,n),x.appendChild(b)),P++}x.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(x,e):e.remove()}function wt(e,t,n){const o=e.parentNode,r=()=>{if(o)return n.get(o)},a=l=>{o&&n.set(o,l)},i=()=>{o&&n.delete(o)},s=e.getAttribute("if");if(s!==null){const l=!!H(s,t);a({hasHead:!0,resolved:l}),l?e.removeAttribute("if"):e.remove();return}const c=e.getAttribute("else-if");if(c!==null){const l=r();if(!l?.hasHead){e.remove();return}if(l.resolved){e.remove();return}const m=!!H(c,t);a({hasHead:!0,resolved:m}),m?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const l=r();if(!l?.hasHead){e.remove();return}l.resolved?e.remove():e.removeAttribute("else"),i();return}}async function Nt(e,t,n=50){const o=new WeakMap;for(let r=0;r<e.length;r+=n){const a=e.slice(r,r+n);for(const{node:i,state:s}of a){if(i instanceof HTMLElement){if(i.hasAttribute("loop")){await vt(i,s,t);continue}if(i.hasAttribute("if")||i.hasAttribute("else")||i.hasAttribute("else-if")){wt(i,s,o);continue}continue}const c=$e(i.nodeValue,s);if(Fe(c)){const l=document.createRange().createContextualFragment(c);i.replaceWith(l)}else i.nodeValue=c}r+n<e.length&&await new Promise(requestAnimationFrame)}}async function ke(e,t,n){try{const o=yt(e),r=new Set,a=[];let i=o.currentNode;for(;i;){if(r.has(i)){i=o.nextNode();continue}if(r.add(i),i.nodeType===Node.ELEMENT_NODE&&i instanceof HTMLElement){const s=i;if(s.hasAttribute("loop")){a.push({node:s,state:t}),i=bt(o,s);continue}(s.hasAttribute("if")||s.hasAttribute("else")||s.hasAttribute("else-if"))&&a.push({node:s,state:t});for(const c of Array.from(s.attributes)){if(c.name==="ref"&&(n[c.value]=s),c.name.startsWith(":")){const l=c.name.slice(1),m=c.value.trim();try{const p=H(m,t);if(l==="class"&&typeof p=="object"&&p!==null){const N=[];for(const[x,S]of Object.entries(p))S&&N.push(x);if(N.length>0){const x=s.getAttribute("class")||"",S=x?`${x} ${N.join(" ")}`:N.join(" ");s.setAttribute("class",S)}}else p!=null&&p!==!1&&(p===!0?s.setAttribute(l,""):s.setAttribute(l,String(p)));s.removeAttribute(c.name)}catch(p){T.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:m},p)}continue}if(c.value.includes("{{"))try{let l=$e(c.value,t);c.name==="class"&&(l=l.replace(/\s+/g," ").trim()),l!==c.value&&s.setAttribute(c.name,l)}catch(l){T.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},l)}}if(s.tagName.includes("-")){i=gt(o)||o.nextNode();continue}}else if(i.nodeType===Node.TEXT_NODE&&i instanceof Text){let s=i.parentElement,c=!1;for(;s;){if(s.tagName.includes("-")){c=!0;break}s=s.parentElement}c||a.push({node:i,state:t})}i=o.nextNode()}await Nt(a,n)}catch(o){throw T.errorWithContext("Error processing template",{},o),o}}function Ct(e,t={}){if(!Array.isArray(e)||e.length===0)throw new Error("composeBySource: layers must be a non-empty array");if(e.some(s=>s==null||typeof s!="object"))throw new Error("composeBySource: all layers must be objects");const{defaultWriteIndex:n=e.length-1,includePrototype:o=!1}=t,r=n>=0&&n<e.length&&Number.isInteger(n)?n:e.length-1;n!==r&&T.warnWithContext(`Invalid defaultWriteIndex ${n}, using ${r}`,{defaultWriteIndex:n,validWriteIndex:r,layersLength:e.length});const a=(s,c)=>o?c in s:Object.prototype.hasOwnProperty.call(s,c),i=s=>{for(let c=0;c<e.length;c++)if(a(e[c],s))return c;return-1};return new Proxy(e[r],{get(s,c){const l=i(c);if(l!==-1)return e[l][c]},set(s,c,l){const m=i(c),p=m!==-1?m:r;return e[p][c]=l,!0},deleteProperty(s,c){const l=i(c);return l===-1?!0:delete e[l][c]},has(s,c){return i(c)!==-1},ownKeys(){const s=new Set;for(const c of e)Reflect.ownKeys(c).forEach(l=>{typeof l!="number"&&s.add(l)});return Array.from(s)},getOwnPropertyDescriptor(s,c){for(const l of e){const m=Object.getOwnPropertyDescriptor(l,c);if(m)return m}}})}function de(e){const t=e.getRootNode(),n=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(Ze(n))return n.instance}function At({container:e,host:t}){const n=Array.from(t.childNodes).filter(r=>r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE),o={};for(const r of n){const a=r instanceof HTMLElement&&r.hasAttribute("slot")?r.getAttribute("slot"):"default";o[a]||(o[a]=[]),o[a].push(r)}e.querySelectorAll("slot").forEach(r=>{const a=r.getAttribute("name")||"default",i=o[a];i&&i.length>0&&i.forEach(s=>{r.parentNode.insertBefore(s,r)}),r.remove()})}function te({propName:e,propValue:t,props:n}){const o=n[e],r=t??o?.default;if(!o)return!0;const a=We(o.type),i=Array.isArray(r)?"array":typeof r,s={string:i==="string",number:i==="number",boolean:i==="boolean",array:Array.isArray(r),object:i==="object"&&r!==null&&!Array.isArray(r),function:i==="function"};return(a==="unknown"?!0:s[a]??!1)?o.regex&&typeof r=="string"&&!new RegExp(o.regex).test(r)?(T.error(`Prop "${e}" does not match regex "${o.regex}".`),!1):!0:(T.error(`Prop "${e}" should be of type "${a}", but got "${i}".`,r),!1)}function he({ele:e,parent:t,props:n,state:o}){const r=Object.keys(n).length>0,a=(i,s)=>{Object.defineProperty(o,i,{enumerable:!0,configurable:!0,get(){if(t)return ne(t.state,s)},set(c){if(!(!t||!t.state))try{De(t.state,s,c)}catch(l){T.errorWithContext(`Failed to set bound prop "${i}" → "${s}"`,{propName:i,parentPath:s},l)}}})};for(const i of e.attributes){const s=i.name.startsWith(":"),c=He(i.name.substring(s?1:0));if(s&&!t||!(!r||n[c]&&n[c]!==void 0))continue;if(!s){const N=i.value!==""?i.value:!0;(!r||te({propName:c,propValue:N,props:n}))&&(o[c]=N);continue}const m=i.value?.trim()??"";if(m&&ge(m)){const N=ne(t.state,m);(!r||te({propName:c,propValue:N,props:n}))&&a(c,m);continue}const p=m?H(m,t.state):void 0;(!r||te({propName:c,propValue:p,props:n}))&&(o[c]=p)}for(const[i,s]of Object.entries(n))i in o||(s.default!==void 0?o[i]=s.default:s.required&&T.error(`Required prop "${i}" is missing.`))}function Tt(e,t){customElements.define(e,class extends HTMLElement{constructor(){super(),this._isDisconnected=!1,this._isMounted=!1,this._renderAborted=!1,this._pendingRender=null,this._eventCleanup=null,this.template=document.createElement("template"),this.template.innerHTML=t.template}async connectedCallback(){const n=this;if(n.instance&&this._model&&this._observerFn){const h=n.instance,E=de(n);h.$parent=E,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),this._isMounted=!0,h.props&&h.state&&he({ele:n,parent:E,props:h.props,state:h.state});return}const r=(t.type||"options")==="options",a=de(n),i=this.template.cloneNode(!0);let s;if(t.deps){s={};const h=Object.entries(t.deps),E=await Promise.all(h.map(([,A])=>A()));for(let A=0;A<h.length;A++)s[h[A][0]]=E[A]}const c=Xe(t.script,s),l={};let m=!1,p=-1;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const N=be(),x=(()=>{let h;return{promise:new Promise(A=>{h=A}),resolve:h}})();if(!document.head.querySelector(`style#style-${e}`)){const h=document.createElement("style");h.id=`style-${e}`,h.textContent=t.style,document.head.appendChild(h)}let S,v;const P=h=>{const E=G.plugins[h];if(!E||typeof E.setup!="function"){T.warnWithContext(`Plugin "${h}" not found or has no setup method`,{pluginName:h});return}try{const A=r&&v?v:S;return E.setup.call(A)}catch(A){T.errorWithContext(`Plugin "${h}" setup failed`,{pluginName:h},A);return}},f={};for(const[h,E]of Object.entries(G.modules))if(typeof E.attach=="function"){const A=E.attach.call({element:n,parent:a,core:{take:ce.take}});A&&(f[`$${h}`]=A)}const y=new Map,b=h=>{let E=y.get(h);return E||(E=`on${h.charAt(0).toUpperCase()}${h.slice(1)}`,y.set(h,E)),E},w=(h,...E)=>{const A=b(h);let C=a;for(;C;){const F=C.userContext;if(F){const $=F[A];typeof $=="function"&&$(...E)}else if(C.methods){const $=C.methods[A];typeof $=="function"&&$(...E)}C=C.$parent}},u={$refs:l,$parent:a,$emit:w,$take:P,...f},d=c(u),g=pt(d.state??{});S=g.state;const _=d.methods||{},M=d.props||{},L=d.events||[];let O=d.watchList||[];r&&(v=Ct([_,S])),he({ele:n,parent:a,props:M,state:S}),r&&v&&Le(_,v);for(const h of Ie){const E=d[h];if(typeof E=="function"){const A=r&&v?K(E,v):E;ve(N,h,async()=>{const C=A();C instanceof Promise&&await C})}}this._model=g;const I=async()=>{if(this._isDisconnected)return;if(m){this._renderAborted=!0,this._pendingRender=I;return}const h=g.getStateVersion();if(p!==h){m=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const E=i.content.cloneNode(!0);if(At({container:E,host:n}),await ke(E,r&&v?v:S,l),this._renderAborted){this._pendingRender=I;return}const C=r&&v?v:S;if(await R("global","processed",C),await R(N,"processed"),this._renderAborted){this._pendingRender=I;return}r&&v?(rt(v,E),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ot(v,L,E,l)):(it(_,E),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=st(_,S,L,E,l));const F=g.flushChanges();Object.defineProperty(C,"changedPaths",{value:F,writable:!0,configurable:!0,enumerable:!1});const $=!this._isMounted;if(await R("global",$?"beforeMount":"beforeUpdate",C),await R(N,$?"beforeMount":"beforeUpdate",C),this._renderAborted){delete C.changedPaths,this._pendingRender=I;return}et(n,E,!this._isMounted,t.structAttr),this._isMounted&&(await R("global","updated",C),await R(N,"updated",C)),delete C.changedPaths,p=h,n.instance&&(n.instance._lastRenderedStateVersion=p)}catch(E){T.errorWithContext("Error during render",{componentName:e},E)}finally{const E=r&&v?v:S;if(delete E.changedPaths,m=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const A=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||A().catch(C=>{T.errorWithContext("Error during pending render",{componentName:e},C)})})}}}};n.instance={element:n,template:i,state:S,userContext:r?v:void 0,props:M,methods:_,events:L,watchList:O,$refs:l,$parent:a,$emit:w,$take:P,readyPromise:x.promise,lifecycleRegistry:N,...f,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||O&&O.length>0&&!g.hasPendingChangesFor(O))return;let h=a;for(;h;){if(h.isRendering)return;h=h.$parent}requestAnimationFrame(()=>{this._isDisconnected||I().catch(E=>{T.errorWithContext("Error during render (observer)",{componentName:e},E)})})},g.addObserver(this._observerFn);const k=r&&v?v:S;await R("global","created",k),await R(N,"created"),await I(),this._isMounted||(await R("global","mounted",k),await R(N,"mounted"),this._isMounted=!0),x.resolve()}async disconnectedCallback(){const n=this;if(!n.instance)return;this._isMounted=!1;const o=n.instance;this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this._model&&this._observerFn&&this._model.removeObserver(this._observerFn);const r=o.userContext||o.state;await R("global","beforeDestroy",r),await R(o.lifecycleRegistry,"beforeDestroy"),this._isDisconnected&&(_e(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),document.body.querySelector(this.tagName.toLowerCase())||document.head.querySelector(`style#style-${this.tagName.toLowerCase()}`)?.remove(),await R("global","destroyed",r),await R(o.lifecycleRegistry,"destroyed"),this._isDisconnected&&(this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let ie=!1,pe=!1,se=[];function _t(){pe||(pe=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(ct(),Ye(),lt()))}function Me(...e){const t=e[0],n=e[1];if(Ge(t)){if(!n){T.error("ComponentSource requires a component name when calling take()");return}Tt(n,t);return}if(Z(t)||Ke(t)){const o={registerHook:(r,a)=>{ve("global",r,a)},take:ce.take};try{t.install(o),Z(t)?G.plugins[t.name]=t:G.modules[t.name]=t}catch(r){T.errorWithContext("Failed to install extension",{name:t.name,type:Z(t)?"plugin":"module"},r)}return}T.error("Unknown extension type",t)}function St(){ie||(ie=!0,se.forEach(e=>Me(...e)),se=[],T.info("Core initialized"))}const ce=Object.assign(()=>{_t(),St()},{take:(...t)=>{ie?Me(...t):se.push(t)}});exports.Core=ce;exports.LogLevel=me;exports.logger=T;