@koppajs/koppajs-core 3.0.8 → 3.0.10

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
@@ -16,6 +16,48 @@ This section is intentionally empty.
16
16
 
17
17
  ---
18
18
 
19
+ ## [3.0.10] — Local First-Presentation Protection
20
+
21
+ **2026-10-16**
22
+
23
+ Patch release to prevent raw slot content from painting outside its unfinished
24
+ first template. Navigation remains immediate; no router readiness barrier or new
25
+ public API is introduced.
26
+
27
+ ### Fixed
28
+
29
+ - Protect original slot content locally during asynchronous first rendering so it is
30
+ not painted outside the finished template. Preserve connected nodes and author
31
+ presentation declarations without delaying router replacement or waiting for children.
32
+ - Emit first mount and resolve readiness only after a successful render, including
33
+ replacement renders after an aborted first attempt.
34
+ - Preserve tracked listeners when synchronous slot transfers reconnect original nodes
35
+ before the global removal observer runs.
36
+
37
+ ---
38
+
39
+ ## [3.0.9] — Native CommonJS Package Entrypoint
40
+
41
+ **2026-10-16**
42
+
43
+ Patch release to correct native CommonJS loading of the published package.
44
+ ESM imports and the named runtime API remain unchanged.
45
+
46
+ ### Fixed
47
+
48
+ - Correct the CommonJS bundle extension to `dist/index.cjs` and align `main` and
49
+ `exports.require` so native Node consumers receive the named `Core` function
50
+ under the existing `"type": "module"` package scope. Keep the ESM path unchanged.
51
+
52
+ ### Changed
53
+
54
+ - Rebuild ordinary pack/publish output through `prepack` and validate actual
55
+ tarballs with native ESM, CommonJS and legacy-main consumers before release.
56
+ - Add the packed-package consumer gate to CI on Node 22 and 24 and to local
57
+ `pnpm validate`.
58
+
59
+ ---
60
+
19
61
  ## [3.0.8] — Connected Styles And Slot Preservation
20
62
 
21
63
  **2026-10-16**
package/README.md CHANGED
@@ -100,6 +100,24 @@ npm install @koppajs/koppajs-core
100
100
  npm install -D @koppajs/koppajs-vite-plugin vite typescript
101
101
  ```
102
102
 
103
+ The package supports Node.js >= 22 for loading its runtime exports without DOM
104
+ shims. Browser APIs are still required for component rendering. Both module
105
+ formats expose the named `Core` function:
106
+
107
+ ```js
108
+ // ESM
109
+ import { Core } from '@koppajs/koppajs-core'
110
+ ```
111
+
112
+ ```js
113
+ // CommonJS
114
+ const { Core } = require('@koppajs/koppajs-core')
115
+ ```
116
+
117
+ ESM keeps `dist/index.es.js`; CommonJS uses `dist/index.cjs` via `exports.require`
118
+ and legacy `main`. Import by package name; the old `dist/index.cjs.js` filename
119
+ is not retained or exposed as a package subpath.
120
+
103
121
  The fastest path for most users is still the official starter:
104
122
 
105
123
  ```bash
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ve=(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))(ve||{});const z={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class De{level=3;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,r,n){const o=[t,r];if(n){const l=Object.entries(n).map(([i,s])=>`${i}: ${s}`).join(", ");l&&o.push(`[${l}]`)}return o.join(" ")}error(t,...r){this.shouldLog(3)&&console.error(this.formatMessage(z.ERROR,t),...r)}warn(t,...r){this.shouldLog(2)&&console.warn(this.formatMessage(z.WARN,t),...r)}info(t,...r){this.shouldLog(1)&&console.info(this.formatMessage(z.INFO,t),...r)}debug(t,...r){this.shouldLog(0)&&console.debug(this.formatMessage(z.DEBUG,t),...r)}errorWithContext(t,r,n){if(!this.shouldLog(3))return;const o=this.formatMessage(z.ERROR,t,r);n?console.error(o,n):console.error(o)}warnWithContext(t,r){this.shouldLog(2)&&console.warn(this.formatMessage(z.WARN,t,r))}}const N=new De;N.init();const de=Symbol("isBounded"),we=Symbol("isProxy"),Ve=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function Q(e,t){if(typeof e!="function"||e[de])return e;const n=e.bind(t);return n[de]=!0,n}function We(e,t){for(const r in e){const n=e[r];if(Object.prototype.hasOwnProperty.call(e,r)&&typeof n=="function")try{e[r]=Q(n,t)}catch(o){N.errorWithContext(`Failed to bind method "${r}"`,{methodName:r},o)}}}function je(e){return/<\/?[a-z][^>]*>/i.test(e)}function se(e,t){if(e==null||typeof t!="string")return;const r=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return r.reduce((n,o)=>{if(n!=null)return n[o]},e)}catch{return}}function He(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function _e(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 Be(e,t,r){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 n=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);if(n.length===0)throw new Error(`❌ setValueByPath: invalid path "${t}".`);const o=(c,a)=>Object.prototype.hasOwnProperty.call(c,a),l=n.pop();let i=e;for(const c of n){if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!o(i,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const a=i[c];if(a==null||typeof a!="object"&&typeof a!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);i=a}if(i==null||typeof i!="object"&&typeof i!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!o(i,l))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${l}" does not exist.`);const s=Object.getOwnPropertyDescriptor(i,l);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${l}" is read-only.`);i[l]=r}const qe={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 r=this.parentNode.firstChild;for(;r;)r.nodeType===Node.ELEMENT_NODE&&r!==this&&r instanceof HTMLElement&&(e?.(r),t.push(r)),r=r.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))}}},ze={};function Ue(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const Xe=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,U=new Map,Ge=1e3,he=new WeakMap;function Ke(e){const t=Object.keys(e),r=t.join("\0"),n=he.get(e);if(n&&n.fingerprint===r)return n.keys;const o=t.sort();return he.set(e,{keys:o,fingerprint:r}),o}function q(e,t={}){const r=(e??"").trim();if(r)try{if(Xe.test(r))return;if(_e(r)){const i=se(t,r);return typeof i=="function"?i.call(t):i}const n=Ke(t),o=`${r}|${n.join(",")}`;let l=U.get(o);if(!l){const i=`"use strict"; return (${r});`;if(l=new Function(...n,i),U.size>=Ge){const s=U.keys().next().value;s&&U.delete(s)}U.set(o,l)}return l(...n.map(i=>t[i]))}catch(n){N.debug(`Expression evaluation failed: ${r}`,n);return}}function Ze(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
2
+ `)+`
3
+ `}function Ye(e,t){const r=e.replace(/\$-\{/g,"${"),n=t?Object.keys(t):[],l=`
4
+ const { $refs, $parent, $emit, $take, $handleEventFromChild, ...rest } = context;
5
+
6
+ // Expose all $*-prefixed context entries (e.g. $router, $store) as local variables
7
+ for (const [key, value] of Object.entries(rest)) {
8
+ if (key.startsWith('$')) {
9
+ // NOTE: this runs inside a dynamically generated function anyway
10
+ // so using eval here does not make the environment less safe than it already is.
11
+ eval('var ' + key + ' = value');
12
+ }
13
+ }
14
+
15
+ // Inject resolved dependencies as local variables
16
+ ${Ze(n)}
17
+
18
+ return (${r});
19
+ `;try{const i=t?new Function("context","__deps",l):new Function("context",l);return(c=>t?i(c,t):i(c))}catch(i){throw N.errorWithContext("Failed to compile dynamic code",{functionBody:l},i),i}}function Ce(){return new Map}const Ne=Ce();function Ae(e,t,r){e==="global"&&(e=Ne),e.has(t)||e.set(t,new Set),e.get(t).add(r)}async function I(e,t,r){e==="global"&&(e=Ne);const n=Array.from(e.get(t)??[]);for(const o of n)try{await o(r)}catch(l){N.errorWithContext(`Hook "${t}" callback failed`,{hook:t},l)}}const J={modules:{},plugins:{}};function Je(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 ee(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Qe(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function et(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const tt=()=>{Object.defineProperties(Object.prototype,ze),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,qe)};function X(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function nt(e,t){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>X(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let n=r.nextNode();for(;n;){const o=n.getAttribute(t);o!==null&&(Pe(n)===void 0&&xe(n,o),n.removeAttribute(t)),n=r.nextNode()}}function pe(e,t){if(!X(e))return null;const r=e.tagName;let n=Pe(e);const o=st(e);if(n===void 0&&t){const l=e.getAttribute(t);l!==null&&(xe(e,l),n=l,e.removeAttribute(t))}return n===void 0?null:o!==void 0?`${r}:${String(n)}:${String(o)}`:`${r}:${String(n)}`}function rt(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 te(e,t){const r=new Set(e.getAttributeNames()),n=new Set(t.getAttributeNames());for(const o of r)!n.has(o)&&!o.startsWith("@")&&e.removeAttribute(o);for(const o of n){const l=t.getAttribute(o),i=e.getAttribute(o);l!==i&&(l===null?e.removeAttribute(o):e.setAttribute(o,l))}}function Te(e,t,r){const n=Array.from(e.childNodes),o=Array.from(t.childNodes),l=new Map,i=new Set;for(const s of n){const c=pe(s,r);c!==null&&!l.has(c)&&l.set(c,s)}for(let s=0;s<o.length;s++){const c=o[s],a=n[s],u=pe(c,r);let d=null;if(u!==null&&l.has(u)&&(d=l.get(u),i.add(d)),d&&X(d)){a!==d&&(s<e.childNodes.length?e.insertBefore(d,e.childNodes[s]):e.appendChild(d)),te(d,c);continue}if(X(c)&&u!==null){a?e.replaceChild(c,a):e.appendChild(c);continue}if(!a){e.appendChild(c);continue}if(!rt(a,c)){e.replaceChild(c,a);continue}if(a.nodeType===Node.TEXT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.COMMENT_NODE){a.textContent!==c.textContent&&(a.textContent=c.textContent);continue}if(a.nodeType===Node.ELEMENT_NODE){const v=a,A=c;if(X(v)){te(v,A);continue}te(v,A),Te(v,A,r)}}for(;e.childNodes.length>o.length;){const s=e.lastChild;s&&e.removeChild(s)}}function ot(e,t,r,n){if(r||e.childNodes.length===0){n&&nt(t,n),e.replaceChildren(t);return}const o=document.createElement("div");o.appendChild(t),Te(e,o,n)}const ce=Symbol("STRUCT_ID"),ae=Symbol("SLOT_ID");function Se(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0,enumerable:!1})}function xe(e,t){Se(e,ce,t)}function Pe(e){return Object.prototype.hasOwnProperty.call(e,ce)?e[ce]:void 0}function it(e,t){Se(e,ae,t)}function st(e){return Object.prototype.hasOwnProperty.call(e,ae)?e[ae]:void 0}function ct(e,t,r,n){if(!Array.isArray(t))return()=>{};const o=[];return t.forEach(([l,i,s])=>{if(typeof l!="string"||typeof s!="function"){N.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[a,...u]=i.slice(6).split(" "),d=n[a];d&&(c=u.length?Array.from(d.querySelectorAll(u.join(" "))):[d])}else c=Array.from(r.querySelectorAll(i));else if(i instanceof Element||i instanceof Window)c=[i];else if(typeof i=="object"&&i&&"ref"in i){const{ref:a,selector:u}=i,d=n[a];d&&(c=u?Array.from(d.querySelectorAll(u)):[d])}for(const a of c){const u=Q(s,e);a.addEventListener(l,u),o.push({target:a,type:l,handler:u})}}),()=>{for(const{target:l,type:i,handler:s}of o)l.removeEventListener(i,s);o.length=0}}const ke=/^on([a-z]+)$/i;function at(e,t){const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=r.nextNode();for(;n;){for(const o of Array.from(n.attributes)){const l=o.name.match(ke);if(l){const i=l[1].toLowerCase(),s=o.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(o.name),n.addEventListener(i,c))}}}n=r.nextNode()}}function lt(e,t){const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=r.nextNode();for(;n;){for(const o of Array.from(n.attributes)){const l=o.name.match(ke);if(l){const i=l[1].toLowerCase(),s=o.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(o.name),n.addEventListener(i,c))}}}n=r.nextNode()}}function ft(e,t,r,n,o){if(!Array.isArray(r))return()=>{};const l=[];return r.forEach(([i,s,c])=>{if(typeof i!="string"||typeof c!="function"){N.error("Provided handler is not a function",c);return}let a=[];if(s==="window")a=[window];else if(typeof s=="string")if(s.startsWith("$refs.")){const[u,...d]=s.slice(6).split(" "),v=o[u];v&&(a=d.length?Array.from(v.querySelectorAll(d.join(" "))):[v])}else a=Array.from(n.querySelectorAll(s));else if(s instanceof Element||s instanceof Window)a=[s];else if(typeof s=="object"&&s&&"ref"in s){const{ref:u,selector:d}=s,v=o[u];v&&(a=d?Array.from(v.querySelectorAll(d)):[v])}for(const u of a){const d=Q(c,t);u.addEventListener(i,d),l.push({target:u,type:i,handler:d})}}),()=>{for(const{target:i,type:s,handler:c}of l)i.removeEventListener(s,c);l.length=0}}const j=new WeakMap;let ne;function ut(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,r=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(n,o,l){return j.has(this)||j.set(this,new Set),j.get(this).add({type:n,listener:o,options:l}),t.call(this,n,o,l)},EventTarget.prototype.removeEventListener=function(n,o,l){const i=j.get(this);if(i){for(const s of i)if(s.type===n&&s.listener===o){i.delete(s);break}i.size===0&&j.delete(this)}return r.call(this,n,o,l)}}function dt(e){const t=j.get(e);if(t){for(const{type:r,listener:n,options:o}of t)e.removeEventListener(r,n,o);j.delete(e)}}function Oe(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let r=e instanceof Element?e:null;for(;r;)j.has(r)&&dt(r),r=t.nextNode()}function ht(){ne||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(ne=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||r.isConnected||Oe(r)})}),ne.observe(document.body,{childList:!0,subtree:!0}))}const Re=new WeakMap,$e=new WeakMap,G=new WeakMap;let pt=0;const B=()=>`slot-${++pt}`,L=e=>typeof e=="object"&&e!==null,re=e=>typeof e=="symbol"?e.toString():String(e),mt=e=>{const t=Re.get(e);return t&&L(t)?t:void 0};function Me(e){const t=$e.get(e);return t||e}const W=e=>L(e)?Reflect.get(e,we)===!0:!1;function yt(e){const t=W(e)?Me(e):e;return G.get(t)}const gt=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),Y=e=>{let t=G.get(e);return t||(t=e.map(()=>B()),G.set(e,t)),t},me=e=>{const t=G.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 bt(e){const t=new Set,r=new WeakMap;let n=0,o=new Set;const l=new Map,i=(f,h)=>!!(f===h||f.startsWith(h+".")),s=(f,h)=>{const b=r.get(f)??"";return b?`${b}.${h}`:h};let c=!1;const a=f=>{o.add(f),n++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(h=>{try{h()}catch(b){console.error("Observer error:",b)}})}))},u=(f,h,b)=>{if(f===h)return;let _=f.length!==h.length;if(!_){for(let p=0;p<f.length;p++)if(f[p]!==h[p]){_=!0;break}}f.splice(0,f.length,...h),_&&a(b)},d=(f,h,b)=>{const _=new Set(f),p=new Set(h);let y=!1;for(const E of _)if(!p.has(E)){y=!0;break}if(!y){for(const E of p)if(!_.has(E)){y=!0;break}}y&&(f.splice(0,f.length,...h),a(b))},v=(f,h,b)=>{const _=new Set(f),p=new Set(h);f.length!==h.length||[..._].some(E=>!p.has(E))||[...p].some(E=>!_.has(E))?d(f,h,b):u(f,h,b)},A=(f,h,b)=>{if(f===h)return!1;let _=!1;for(const p of Object.keys(f))p in h||(_=!0,Reflect.deleteProperty(f,p));for(const p of Object.keys(h)){const y=f[p],E=h[p];y!==E&&(L(y)&&W(y)&&L(E)&&!W(E)?(A(y,E)&&(_=!0),y!==E&&(_=!0,Reflect.set(f,p,E))):(_=!0,Reflect.set(f,p,E)))}return _},O=(f,h,b)=>{const _=Y(f);switch(h){case"push":{const p=Array.from({length:b.length},()=>B());_.push(...p);break}case"pop":{_.pop();break}case"shift":{_.shift();break}case"unshift":{const p=Array.from({length:b.length},()=>B());_.unshift(...p);break}case"splice":{const p=b[0]??0,y=b[1]!==void 0?b[1]:f.length-p,E=b.slice(2),S=Array.from({length:E.length},()=>B());_.splice(p,y,...S);break}case"reverse":{_.reverse();break}}me(f)},w=(f,h="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=mt(f);if(b)return b;h&&r.set(f,h),Array.isArray(f)&&Y(f);const _=new Proxy(f,{get:(p,y,E)=>{if(y===we)return!0;if(y==="toJSON")return function(){return Me(p)};if(Array.isArray(p)&&typeof y=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(y)){const k=p[y];if(typeof k=="function")return function(...D){if(y==="sort"){const R=Y(p),$=p.map((m,g)=>({el:m,slotId:R[g]||B()})),V=k.apply(this,D),K=new Map;for(let m=0;m<$.length;m++){const g=$[m].el;let C=K.get(g);C||(C=[],K.set(g,C)),C.push(m)}for(let m=0;m<p.length;m++){const g=p[m],C=K.get(g);if(C&&C.length>0){const M=C.shift();R[m]=$[M].slotId}else R[m]=B()}return me(p),V}else{const R=k.apply(this,D);return O(p,y,D),R}}}const S=Reflect.get(p,y,E),x=Array.isArray(p)&&typeof y=="string"&&/^\d+$/.test(y);if(L(S)&&!W(S)&&!x&&(Array.isArray(S)||!Array.isArray(p))){const T=re(y),k=s(p,T);return w(S,k)}return S},set:(p,y,E,S)=>{const x=Reflect.get(p,y,S);if(x===E)return!0;const T=re(y),k=s(p,T);if(Array.isArray(p)&&typeof y=="string"&&/^\d+$/.test(y)){const R=parseInt(y,10);if(R>=0&&R<p.length){const $=Reflect.set(p,y,E,S);return a(k),$}}if(Array.isArray(x)&&!gt(E)&&Array.isArray(E)){v(x,E,k);const R=x.map(()=>B());return G.set(x,R),!0}if(L(x)&&W(x)&&L(E)&&!W(E)){if(A(x,E)){let $=E;L($)&&!W($)&&($=w($,k)),Reflect.set(p,y,$,S),a(k)}return!0}const D=Reflect.set(p,y,E,S);if(L(E)&&!W(E)){const R=w(E,k);Reflect.set(p,y,R,S),Array.isArray(E)&&Y(E)}return a(k),D},deleteProperty:(p,y)=>{if(y==="changedPaths")return Reflect.deleteProperty(p,y);const E=re(y),S=s(p,E),x=Reflect.get(p,y),T=Reflect.deleteProperty(p,y);return T&&x!==void 0&&a(S),T}});return Re.set(f,_),$e.set(_,f),_};return{state:w(e),watch(f,h){let b=l.get(f);b||(b=new Set,l.set(f,b)),b.add(h);let _=!1;return()=>{if(_)return;_=!0;const p=l.get(f);p&&(p.delete(h),p.size===0&&l.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return n},hasPendingChangesFor(f){for(const h of o)for(const b of f)if(h===b||h.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(o);if(f.size>0&&l.size>0){const h=new Map;for(const[b,_]of l){const p=new Set;for(const y of f)i(y,b)&&p.add(y);if(p.size>0)for(const y of _){const E=h.get(y);if(E)for(const S of p)E.add(S);else h.set(y,new Set(p))}}for(const[b,_]of h)b({changedPaths:_})}return o=new Set,f}}}const oe=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Et(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const n=t.slice(1,-1).split(",").map(i=>i.trim());if(n.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[o,l]=n;if(!oe.test(o)||!oe.test(l))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:o,itemVar:l}}if(!oe.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function vt(e){const t={acceptNode(r){return r.nodeType===Node.ELEMENT_NODE||r.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(r.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function wt(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function _t(e,t){let r=t.nextSibling;if(!r){let n=t.parentNode;for(;n&&n!==e.root;){if(n.nextSibling){r=n.nextSibling;break}n=n.parentNode}}return r?(e.currentNode=r,r):null}function Ct(e){return e==null||e===!0||e===!1?"":String(e)}function Ie(e,t){return e.replace(/\{\{(.+?)\}\}/g,(r,n)=>{const o=q(n.trim(),t);return Ct(o)})}async function Nt(e,t,r){const n=e.getAttribute("loop");if(!n)return;e.removeAttribute("loop");const o=e.getAttribute("if");o&&e.removeAttribute("if");const l=n.match(/^(.+?)\s+in\s+(.+)$/);if(!l)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,i,s]=l,c=Et(i),a=q(s.trim(),t);if(a==null){e.remove();return}if(typeof a!="object"){N.error("State source is not iterable",{collectionExp:s,raw:a});return}const u=Array.isArray(a),d=u?a.map((f,h)=>[String(h),f]):Object.entries(a),v=d.length,A=document.createDocumentFragment(),O=u?yt(a):void 0,w={...t};let P=0;for(const[f,h]of d){if(w.index=P,w.key=f,w.isFirst=P===0,w.isLast=P===v-1,w.isEven=P%2===0,w.isOdd=P%2!==0,c.type==="single"||(w[c.keyVar]=f),w[c.itemVar]=h,o&&!q(o,w)){P++;continue}const b=e.cloneNode(!0);u&&b instanceof HTMLElement&&O&&O[P]!==void 0&&it(b,O[P]),b instanceof HTMLElement&&(await Fe(b,w,r),A.appendChild(b)),P++}A.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(A,e):e.remove()}function At(e,t,r){const n=e.parentNode,o=()=>{if(n)return r.get(n)},l=a=>{n&&r.set(n,a)},i=()=>{n&&r.delete(n)},s=e.getAttribute("if");if(s!==null){const a=!!q(s,t);l({hasHead:!0,resolved:a}),a?e.removeAttribute("if"):e.remove();return}const c=e.getAttribute("else-if");if(c!==null){const a=o();if(!a?.hasHead){e.remove();return}if(a.resolved){e.remove();return}const u=!!q(c,t);l({hasHead:!0,resolved:u}),u?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const a=o();if(!a?.hasHead){e.remove();return}a.resolved?e.remove():e.removeAttribute("else"),i();return}}async function Tt(e,t,r=50){const n=new WeakMap;for(let o=0;o<e.length;o+=r){const l=e.slice(o,o+r);for(const{node:i,state:s}of l){if(i instanceof HTMLElement){if(i.hasAttribute("loop")){await Nt(i,s,t);continue}if(i.hasAttribute("if")||i.hasAttribute("else")||i.hasAttribute("else-if")){At(i,s,n);continue}continue}const c=Ie(i.nodeValue,s);if(je(c)){const a=document.createRange().createContextualFragment(c);i.replaceWith(a)}else i.nodeValue=c}o+r<e.length&&await new Promise(requestAnimationFrame)}}async function Fe(e,t,r){try{const n=vt(e),o=new Set,l=[];let i=n.currentNode;for(;i;){if(o.has(i)){i=n.nextNode();continue}if(o.add(i),i.nodeType===Node.ELEMENT_NODE&&i instanceof HTMLElement){const s=i;if(s.hasAttribute("loop")){l.push({node:s,state:t}),i=_t(n,s);continue}(s.hasAttribute("if")||s.hasAttribute("else")||s.hasAttribute("else-if"))&&l.push({node:s,state:t});for(const c of Array.from(s.attributes)){if(c.name==="ref"&&(r[c.value]=s),c.name.startsWith(":")){const a=c.name.slice(1),u=c.value.trim();try{const d=q(u,t);if(a==="class"&&typeof d=="object"&&d!==null){const v=[];for(const[A,O]of Object.entries(d))O&&v.push(A);if(v.length>0){const A=s.getAttribute("class")||"",O=A?`${A} ${v.join(" ")}`:v.join(" ");s.setAttribute("class",O)}}else d!=null&&d!==!1&&(d===!0?s.setAttribute(a,""):s.setAttribute(a,String(d)));s.removeAttribute(c.name)}catch(d){N.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:u},d)}continue}if(c.value.includes("{{"))try{let a=Ie(c.value,t);c.name==="class"&&(a=a.replace(/\s+/g," ").trim()),a!==c.value&&s.setAttribute(c.name,a)}catch(a){N.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},a)}}if(s.tagName.includes("-")){i=wt(n)||n.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||l.push({node:i,state:t})}i=n.nextNode()}await Tt(l,r)}catch(n){throw N.errorWithContext("Error processing template",{},n),n}}function St(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:r=e.length-1,includePrototype:n=!1}=t,o=r>=0&&r<e.length&&Number.isInteger(r)?r:e.length-1;r!==o&&N.warnWithContext(`Invalid defaultWriteIndex ${r}, using ${o}`,{defaultWriteIndex:r,validWriteIndex:o,layersLength:e.length});const l=(s,c)=>n?c in s:Object.prototype.hasOwnProperty.call(s,c),i=s=>{for(let c=0;c<e.length;c++)if(l(e[c],s))return c;return-1};return new Proxy(e[o],{get(s,c){const a=i(c);if(a!==-1)return e[a][c]},set(s,c,a){const u=i(c),d=u!==-1?u:o;return e[d][c]=a,!0},deleteProperty(s,c){const a=i(c);return a===-1?!0:delete e[a][c]},has(s,c){return i(c)!==-1},ownKeys(){const s=new Set;for(const c of e)Reflect.ownKeys(c).forEach(a=>{typeof a!="number"&&s.add(a)});return Array.from(s)},getOwnPropertyDescriptor(s,c){for(const a of e){const u=Object.getOwnPropertyDescriptor(a,c);if(u)return u}}})}function ye(e){const t=e.getRootNode(),r=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(et(r))return r.instance}function xt({container:e,host:t}){const r=Array.from(t.childNodes).filter(o=>o.nodeType===Node.ELEMENT_NODE||o.nodeType===Node.TEXT_NODE),n={};for(const o of r){const l=o instanceof HTMLElement&&o.hasAttribute("slot")?o.getAttribute("slot"):"default";n[l]||(n[l]=[]),n[l].push(o)}e.querySelectorAll("slot").forEach(o=>{const l=o.getAttribute("name")||"default",i=n[l];i&&i.length>0&&i.forEach(s=>{o.parentNode.insertBefore(s,o)}),o.remove()})}function Pt(e,t,r){const n=new Map,o=new Map,l=()=>{for(const a of Object.keys(r)){const u=n.get(r[a]);u instanceof HTMLElement&&(r[a]=u)}};if(!e.querySelector("slot"))return{commit:()=>{},remapRefs:l};const i=document.createElement("div"),s=a=>{const u=a.cloneNode(!1);if(n.set(u,a),!(a instanceof HTMLElement&&a.tagName.includes("-")))for(const d of a.childNodes)u.appendChild(s(d));return o.set(u,{attributes:new Map(a instanceof HTMLElement?Array.from(a.attributes,d=>[d.name,d.value]):[]),children:Array.from(u.childNodes),value:u.nodeValue}),u};for(const a of t.childNodes)i.appendChild(s(a));return xt({container:e,host:i}),{commit:()=>{const a=u=>{const d=n.get(u),v=o.get(u),A=Array.from(u.childNodes),O=A.map(a);if(!d||!v)return A.forEach((w,P)=>{O[P]!==w&&w.replaceWith(O[P])}),u;if(d instanceof HTMLElement&&u instanceof HTMLElement){for(const w of v.attributes.keys())u.hasAttribute(w)||d.removeAttribute(w);for(const w of Array.from(u.attributes))v.attributes.get(w.name)!==w.value&&d.setAttribute(w.name,w.value);!d.tagName.includes("-")&&(A.length!==v.children.length||A.some((w,P)=>w!==v.children[P]))&&d.replaceChildren(...O)}else u.nodeValue!==v.value&&(d.nodeValue=u.nodeValue);return d};for(const u of Array.from(e.childNodes)){const d=a(u);d!==u&&u.replaceWith(d)}l()},remapRefs:l}}function ge(e){const t=["opacity","transition-property"],r=t.map(o=>({name:o,value:e.style.getPropertyValue(o),priority:e.style.getPropertyPriority(o)}));e.style.setProperty("transition-property","none","important"),e.style.setProperty("opacity","0","important");const n=t.map(o=>e.style.getPropertyPriority(o));return()=>{for(const[o,{name:l,value:i,priority:s}]of r.entries()){const c=l==="opacity"?"0":"none";e.style.getPropertyValue(l)!==c||e.style.getPropertyPriority(l)!==n[o]||(i?e.style.setProperty(l,i,s):e.style.removeProperty(l))}}}function ie({propName:e,propValue:t,props:r}){const n=r[e],o=t??n?.default;if(!n)return!0;const l=He(n.type),i=Array.isArray(o)?"array":typeof o,s={string:i==="string",number:i==="number",boolean:i==="boolean",array:Array.isArray(o),object:i==="object"&&o!==null&&!Array.isArray(o),function:i==="function"};return(l==="unknown"?!0:s[l]??!1)?n.regex&&typeof o=="string"&&!new RegExp(n.regex).test(o)?(N.error(`Prop "${e}" does not match regex "${n.regex}".`),!1):!0:(N.error(`Prop "${e}" should be of type "${l}", but got "${i}".`,o),!1)}function be({ele:e,parent:t,props:r,state:n}){const o=Object.keys(r).length>0,l=(i,s)=>{Object.defineProperty(n,i,{enumerable:!0,configurable:!0,get(){if(t)return se(t.state,s)},set(c){if(!(!t||!t.state))try{Be(t.state,s,c)}catch(a){N.errorWithContext(`Failed to set bound prop "${i}" → "${s}"`,{propName:i,parentPath:s},a)}}})};for(const i of e.attributes){const s=i.name.startsWith(":"),c=Ue(i.name.substring(s?1:0));if(s&&!t||!(!o||r[c]&&r[c]!==void 0))continue;if(!s){const v=i.value!==""?i.value:!0;(!o||ie({propName:c,propValue:v,props:r}))&&(n[c]=v);continue}const u=i.value?.trim()??"";if(u&&_e(u)){const v=se(t.state,u);(!o||ie({propName:c,propValue:v,props:r}))&&l(c,u);continue}const d=u?q(u,t.state):void 0;(!o||ie({propName:c,propValue:d,props:r}))&&(n[c]=d)}for(const[i,s]of Object.entries(r))i in n||(s.default!==void 0?n[i]=s.default:s.required&&N.error(`Required prop "${i}" is missing.`))}function kt(e,t){const r=new Set;customElements.define(e,class extends HTMLElement{template;instance;_connectionVersion=0;_isDisconnected=!1;_hasRendered=!1;_releaseFirstPresentation;_model;_observerFn;_renderAborted=!1;_pendingRender=null;_eventCleanup=null;constructor(){super(),this.template=document.createElement("template"),this.template.innerHTML=t.template}async connectedCallback(){const n=this,o=++this._connectionVersion;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,!this._hasRendered&&!this._releaseFirstPresentation&&(this._releaseFirstPresentation=ge(this));try{await this.initializeConnection(n,o)}catch(l){if(o!==this._connectionVersion||this._isDisconnected)return;this.releaseFirstPresentation(),N.errorWithContext("Error during initialization",{componentName:e},l)}}async initializeConnection(n,o){if(r.add(this),!document.head.querySelector(`style#style-${e}`)){const m=document.createElement("style");m.id=`style-${e}`,m.textContent=t.style,document.head.appendChild(m)}if(n.instance&&this._model&&this._observerFn){const m=n.instance,g=ye(n);m.$parent=g,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),m.props&&m.state&&be({ele:n,parent:g,props:m.props,state:m.state});return}const i=(t.type||"options")==="options",s=ye(n),c=this.template.cloneNode(!0);let a;if(t.deps){a={};const m=Object.entries(t.deps),g=await Promise.all(m.map(([,C])=>C()));for(let C=0;C<m.length;C++)a[m[C][0]]=g[C]}if(o!==this._connectionVersion||this._isDisconnected)return;const u=Ye(t.script,a),d={};let v=!1,A=-1,O;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const w=Ce(),P=(()=>{let m;return{promise:new Promise(C=>{m=C}),resolve:m}})();let f,h;const b=m=>{const g=J.plugins[m];if(!g||typeof g.setup!="function"){N.warnWithContext(`Plugin "${m}" not found or has no setup method`,{pluginName:m});return}try{const C=i&&h?h:f;return g.setup.call(C)}catch(C){N.errorWithContext(`Plugin "${m}" setup failed`,{pluginName:m},C);return}},_={};for(const[m,g]of Object.entries(J.modules))if(typeof g.attach=="function"){const C=g.attach.call({element:n,parent:s,core:{take:ue.take}});C&&(_[`$${m}`]=C)}const p=new Map,y=m=>{let g=p.get(m);return g||(g=`on${m.charAt(0).toUpperCase()}${m.slice(1)}`,p.set(m,g)),g},E=(m,...g)=>{const C=y(m);let M=s;for(;M;){const F=M.userContext;if(F){const H=F[C];typeof H=="function"&&H(...g)}else if(M.methods){const H=M.methods[C];typeof H=="function"&&H(...g)}M=M.$parent}},S={$refs:d,$parent:s,$emit:E,$take:b,..._},x=u(S),T=bt(x.state??{});f=T.state;const k=x.methods||{},D=x.props||{},R=x.events||[];let $=x.watchList||[];i&&(h=St([k,f])),be({ele:n,parent:s,props:D,state:f}),i&&h&&We(k,h);for(const m of Ve){const g=x[m];if(typeof g=="function"){const C=i&&h?Q(g,h):g;Ae(w,m,async()=>{const M=C();M instanceof Promise&&await M})}}this._model=T;const V=async()=>{if(this._isDisconnected)return;if(v){this._renderAborted=!0,this._pendingRender=V;return}const m=T.getStateVersion();if(A!==m){!this._hasRendered&&!this._releaseFirstPresentation&&(this._releaseFirstPresentation=ge(this)),v=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const g=c.content.cloneNode(!0),C=Pt(g,n,d);if(await Fe(g,i&&h?h:f,d),C.remapRefs(),this._renderAborted||this._model!==T){this._pendingRender=V;return}const F=i&&h?h:f;if(await I("global","processed",F),await I(w,"processed"),this._renderAborted||this._model!==T){this._pendingRender=V;return}const H=T.flushChanges();Object.defineProperty(F,"changedPaths",{value:H,writable:!0,configurable:!0,enumerable:!1});const Z=!this._hasRendered;if(await I("global",Z?"beforeMount":"beforeUpdate",F),await I(w,Z?"beforeMount":"beforeUpdate",F),this._renderAborted||this._model!==T){delete F.changedPaths,this._pendingRender=V;return}C.commit(),i&&h?(at(h,g),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ct(h,R,g,d)):(lt(k,g),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=ft(k,f,R,g,d)),ot(n,g,Z,t.structAttr),this._hasRendered=!0,this.releaseFirstPresentation(),Z||(await I("global","updated",F),await I(w,"updated",F)),delete F.changedPaths,A=m,n.instance&&(n.instance._lastRenderedStateVersion=A)}catch(g){this._model===T&&this.releaseFirstPresentation(),N.errorWithContext("Error during render",{componentName:e},g);return}finally{const g=i&&h?h:f;if(delete g.changedPaths,v=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const C=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||C().catch(M=>{N.errorWithContext("Error during pending render",{componentName:e},M)})})}}this._isDisconnected||this._model!==T||(O||(O=(async()=>{await I("global","mounted",i&&h?h:f),!(this._isDisconnected||this._model!==T)&&await I(w,"mounted")})()),await O,!(this._isDisconnected||this._model!==T)&&P.resolve())}};n.instance={element:n,template:c,state:f,userContext:i?h:void 0,props:D,methods:k,events:R,watchList:$,$refs:d,$parent:s,$emit:E,$take:b,readyPromise:P.promise,lifecycleRegistry:w,..._,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||$&&$.length>0&&!T.hasPendingChangesFor($))return;let m=s;for(;m;){if(m.isRendering)return;m=m.$parent}requestAnimationFrame(()=>{this._isDisconnected||V().catch(g=>{N.errorWithContext("Error during render (observer)",{componentName:e},g)})})},T.addObserver(this._observerFn),await I("global","created",i&&h?h:f),await I(w,"created"),!(this._isDisconnected||this._model!==T)&&await V()}releaseFirstPresentation(){this._releaseFirstPresentation?.(),this._releaseFirstPresentation=void 0}async disconnectedCallback(){const n=this,o=++this._connectionVersion;if(this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this.releaseFirstPresentation(),r.delete(this),r.size===0&&document.head.querySelector(`style#style-${e}`)?.remove(),!n.instance)return;const l=n.instance;this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,this._model&&this._observerFn&&this._model.removeObserver(this._observerFn);const i=l.userContext||l.state;await I("global","beforeDestroy",i),await I(l.lifecycleRegistry,"beforeDestroy"),!(!this._isDisconnected||o!==this._connectionVersion)&&(Oe(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),await I("global","destroyed",i),await I(l.lifecycleRegistry,"destroyed"),!(!this._isDisconnected||o!==this._connectionVersion)&&(this._hasRendered=!1,this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let le=!1,Ee=!1,fe=[];function Ot(){Ee||(Ee=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(ut(),tt(),ht()))}function Le(...e){const t=e[0],r=e[1];if(Je(t)){if(!r){N.error("ComponentSource requires a component name when calling take()");return}kt(r,t);return}if(ee(t)||Qe(t)){const n={registerHook:(o,l)=>{Ae("global",o,l)},take:ue.take};try{t.install(n),ee(t)?J.plugins[t.name]=t:J.modules[t.name]=t}catch(o){N.errorWithContext("Failed to install extension",{name:t.name,type:ee(t)?"plugin":"module"},o)}return}N.error("Unknown extension type",t)}function Rt(){le||(le=!0,fe.forEach(e=>Le(...e)),fe=[],N.info("Core initialized"))}const ue=Object.assign(()=>{Ot(),Rt()},{take:(...t)=>{le?Le(...t):fe.push(t)}});exports.Core=ue;exports.LogLevel=ve;exports.logger=N;