@koppajs/koppajs-core 3.0.6 → 3.0.8
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 +34 -4
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +847 -795
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -14,11 +14,41 @@ not every internal refactor.
|
|
|
14
14
|
|
|
15
15
|
This section is intentionally empty.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## [3.0.8] — Connected Styles And Slot Preservation
|
|
20
|
+
|
|
21
|
+
**2026-10-16**
|
|
22
|
+
|
|
23
|
+
Patch release to prevent unstyled component content on connection and preserve
|
|
24
|
+
live slot content during asynchronous rendering. No new public API is introduced.
|
|
25
|
+
Atomic router transitions still require the separate Router ready/commit contract.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- Insert component CSS synchronously on connection before dependency imports, while still
|
|
30
|
+
removing it when the last connected host disappears.
|
|
31
|
+
- Keep live slot content in place during asynchronous template processing and mount hooks;
|
|
32
|
+
preserve original nodes, refs, and listeners when committing the processed template.
|
|
33
|
+
- Prevent disconnected or superseded initialization from committing stale DOM or mounting.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## [3.0.7] — Release Workflow and Repository Baseline Cleanup
|
|
38
|
+
|
|
39
|
+
**2026-03-27**
|
|
40
|
+
|
|
41
|
+
Patch release to finish the repository-side cleanup around the Node.js baseline
|
|
42
|
+
update and align release automation with the maintainer default runtime. No
|
|
43
|
+
intentional runtime or public API changes.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
18
46
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
47
|
+
- Removed obsolete tracked `.vscode` defaults from the repository baseline and
|
|
48
|
+
simplified `.gitignore` to ignore editor-local settings consistently
|
|
49
|
+
- Normalized `package.json.repository.url` to the npm-compatible
|
|
50
|
+
`git+https://...git` form
|
|
51
|
+
- Switched the release workflow to read its Node.js version from `.nvmrc`
|
|
22
52
|
|
|
23
53
|
---
|
|
24
54
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var be=(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))(be||{});const q={ERROR:"❌",WARN:"⚠️",INFO:"ℹ️",DEBUG:"🔍"};class Le{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,o,n){const i=[t,o];if(n){const l=Object.entries(n).map(([r,s])=>`${r}: ${s}`).join(", ");l&&i.push(`[${l}]`)}return i.join(" ")}error(t,...o){this.shouldLog(3)&&console.error(this.formatMessage(q.ERROR,t),...o)}warn(t,...o){this.shouldLog(2)&&console.warn(this.formatMessage(q.WARN,t),...o)}info(t,...o){this.shouldLog(1)&&console.info(this.formatMessage(q.INFO,t),...o)}debug(t,...o){this.shouldLog(0)&&console.debug(this.formatMessage(q.DEBUG,t),...o)}errorWithContext(t,o,n){if(!this.shouldLog(3))return;const i=this.formatMessage(q.ERROR,t,o);n?console.error(i,n):console.error(i)}warnWithContext(t,o){this.shouldLog(2)&&console.warn(this.formatMessage(q.WARN,t,o))}}const T=new Le;T.init();const ue=Symbol("isBounded"),Ee=Symbol("isProxy"),De=["created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","processed"];function Y(e,t){if(typeof e!="function"||e[ue])return e;const n=e.bind(t);return n[ue]=!0,n}function We(e,t){for(const o in e){const n=e[o];if(Object.prototype.hasOwnProperty.call(e,o)&&typeof n=="function")try{e[o]=Y(n,t)}catch(i){T.errorWithContext(`Failed to bind method "${o}"`,{methodName:o},i)}}}function Fe(e){return/<\/?[a-z][^>]*>/i.test(e)}function re(e,t){if(e==null||typeof t!="string")return;const o=t.trim().replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean);try{return o.reduce((n,i)=>{if(n!=null)return n[i]},e)}catch{return}}function Ve(e){return typeof e=="string"?e.toLowerCase():typeof e=="function"&&typeof e.name=="string"?e.name.toLowerCase():"unknown"}function ve(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,o){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 i=(c,a)=>Object.prototype.hasOwnProperty.call(c,a),l=n.pop();let r=e;for(const c of n){if(r==null||typeof r!="object"&&typeof r!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);if(!i(r,c))throw new Error(`❌ setValueByPath: invalid path "${t}". Missing segment "${c}".`);const a=r[c];if(a==null||typeof a!="object"&&typeof a!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Segment "${c}" is not an object.`);r=a}if(r==null||typeof r!="object"&&typeof r!="function")throw new Error(`❌ setValueByPath: invalid path "${t}". Final target is not an object.`);if(!i(r,l))throw new Error(`❌ setValueByPath: invalid path "${t}". Final key "${l}" does not exist.`);const s=Object.getOwnPropertyDescriptor(r,l);if(s&&s.writable===!1&&!s.set)throw new Error(`❌ setValueByPath: cannot write "${t}". Property "${l}" is read-only.`);r[l]=o}const He={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 o=this.parentNode.firstChild;for(;o;)o.nodeType===Node.ELEMENT_NODE&&o!==this&&o instanceof HTMLElement&&(e?.(o),t.push(o)),o=o.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))}}},Be={};function qe(e){return e.replace(/-./g,t=>t[1].toUpperCase())}const ze=/(?:\bwindow\b|\bdocument\b|\bglobalThis\b|\bFunction\b|\beval\b|\bsetTimeout\b|\bsetInterval\b|\bfetch\b|\bXMLHttpRequest\b|\bimport\b|\brequire\b|\bthis\b)/,z=new Map,Ue=1e3,de=new WeakMap;function Xe(e){const t=Object.keys(e),o=t.join("\0"),n=de.get(e);if(n&&n.fingerprint===o)return n.keys;const i=t.sort();return de.set(e,{keys:i,fingerprint:o}),i}function B(e,t={}){const o=(e??"").trim();if(o)try{if(ze.test(o))return;if(ve(o)){const r=re(t,o);return typeof r=="function"?r.call(t):r}const n=Xe(t),i=`${o}|${n.join(",")}`;let l=z.get(i);if(!l){const r=`"use strict"; return (${o});`;if(l=new Function(...n,r),z.size>=Ue){const s=z.keys().next().value;s&&z.delete(s)}z.set(i,l)}return l(...n.map(r=>t[r]))}catch(n){T.debug(`Expression evaluation failed: ${o}`,n);return}}function Ge(e){return e.length===0?"":e.map(t=>`var ${t} = __deps.${t};`).join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`}function
|
|
3
|
+
`}function Ke(e,t){const o=e.replace(/\$-\{/g,"${"),n=t?Object.keys(t):[],l=`
|
|
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
|
-
${
|
|
16
|
+
${Ge(n)}
|
|
17
17
|
|
|
18
|
-
return (${
|
|
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 _.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){_.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"){_.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 _e=/^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(_e);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(_e);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"){_.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 Te(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&&Te(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),T=Array.from({length:g.length},()=>V());w.splice(u,d,...T);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 T=Reflect.get(u,d,g),M=Array.isArray(u)&&typeof d=="string"&&/^\d+$/.test(d);if(W(T)&&!D(T)&&!M&&(Array.isArray(T)||!Array.isArray(u))){const L=Q(d),O=s(u,L);return v(T,O)}return T},set:(u,d,g,T)=>{const M=Reflect.get(u,d,T);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,T);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,T),l(O)}return!0}const I=Reflect.set(u,d,g,T);if(W(g)&&!D(g)){const k=v(g,O);Reflect.set(u,d,k,T),Array.isArray(g)&&X(g)}return l(O),I},deleteProperty:(u,d)=>{if(d==="changedPaths")return Reflect.deleteProperty(u,d);const g=Q(d),T=s(u,g),M=Reflect.get(u,d),L=Reflect.deleteProperty(u,d);return L&&M!==void 0&&l(T),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 T of u)g.add(T);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"){_.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){_.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){_.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 _.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&&_.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)?(_.error(`Prop "${e}" does not match regex "${o.regex}".`),!1):!0:(_.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){_.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&&_.error(`Required prop "${i}" is missing.`))}function _t(e,t){customElements.define(e,class extends HTMLElement{template;instance;_isDisconnected=!1;_isMounted=!1;_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;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"){_.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){_.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 T=d.methods||{},M=d.props||{},L=d.events||[];let O=d.watchList||[];r&&(v=Ct([T,S])),he({ele:n,parent:a,props:M,state:S}),r&&v&&Le(T,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(T,E),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=st(T,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){_.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=>{_.errorWithContext("Error during pending render",{componentName:e},C)})})}}}};n.instance={element:n,template:i,state:S,userContext:r?v:void 0,props:M,methods:T,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=>{_.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&&(Te(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 Tt(){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){_.error("ComponentSource requires a component name when calling take()");return}_t(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){_.errorWithContext("Failed to install extension",{name:t.name,type:Z(t)?"plugin":"module"},r)}return}_.error("Unknown extension type",t)}function St(){ie||(ie=!0,se.forEach(e=>Me(...e)),se=[],_.info("Core initialized"))}const ce=Object.assign(()=>{Tt(),St()},{take:(...t)=>{ie?Me(...t):se.push(t)}});exports.Core=ce;exports.LogLevel=me;exports.logger=_;
|
|
18
|
+
return (${o});
|
|
19
|
+
`;try{const r=t?new Function("context","__deps",l):new Function("context",l);return(c=>t?r(c,t):r(c))}catch(r){throw T.errorWithContext("Failed to compile dynamic code",{functionBody:l},r),r}}function we(){return new Map}const Ne=we();function _e(e,t,o){e==="global"&&(e=Ne),e.has(t)||e.set(t,new Set),e.get(t).add(o)}async function P(e,t,o){e==="global"&&(e=Ne);const n=Array.from(e.get(t)??[]);for(const i of n)try{await i(o)}catch(l){T.errorWithContext(`Hook "${t}" callback failed`,{hook:t},l)}}const Z={modules:{},plugins:{}};function Ze(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 J(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.setup=="function"&&t.attach===void 0}function Ye(e){if(e==null||typeof e!="object")return!1;const t=e;return typeof t.attach=="function"&&t.setup===void 0}function Je(e){return e instanceof HTMLElement&&"instance"in e&&e.instance!==void 0}const Qe=()=>{Object.defineProperties(Object.prototype,Be),typeof HTMLElement<"u"&&Object.defineProperties(HTMLElement.prototype,He)};function U(e){return e.nodeType===Node.ELEMENT_NODE&&e.tagName.includes("-")}function et(e,t){const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>U(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let n=o.nextNode();for(;n;){const i=n.getAttribute(t);i!==null&&(Se(n)===void 0&&Te(n,i),n.removeAttribute(t)),n=o.nextNode()}}function he(e,t){if(!U(e))return null;const o=e.tagName;let n=Se(e);const i=rt(e);if(n===void 0&&t){const l=e.getAttribute(t);l!==null&&(Te(e,l),n=l,e.removeAttribute(t))}return n===void 0?null:i!==void 0?`${o}:${String(n)}:${String(i)}`:`${o}:${String(n)}`}function tt(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 Q(e,t){const o=new Set(e.getAttributeNames()),n=new Set(t.getAttributeNames());for(const i of o)!n.has(i)&&!i.startsWith("@")&&e.removeAttribute(i);for(const i of n){const l=t.getAttribute(i),r=e.getAttribute(i);l!==r&&(l===null?e.removeAttribute(i):e.setAttribute(i,l))}}function Ce(e,t,o){const n=Array.from(e.childNodes),i=Array.from(t.childNodes),l=new Map,r=new Set;for(const s of n){const c=he(s,o);c!==null&&!l.has(c)&&l.set(c,s)}for(let s=0;s<i.length;s++){const c=i[s],a=n[s],u=he(c,o);let d=null;if(u!==null&&l.has(u)&&(d=l.get(u),r.add(d)),d&&U(d)){a!==d&&(s<e.childNodes.length?e.insertBefore(d,e.childNodes[s]):e.appendChild(d)),Q(d,c);continue}if(U(c)&&u!==null){a?e.replaceChild(c,a):e.appendChild(c);continue}if(!a){e.appendChild(c);continue}if(!tt(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,x=c;if(U(v)){Q(v,x);continue}Q(v,x),Ce(v,x,o)}}for(;e.childNodes.length>i.length;){const s=e.lastChild;s&&e.removeChild(s)}}function nt(e,t,o,n){if(o||e.childNodes.length===0){n&&et(t,n),e.replaceChildren(t);return}const i=document.createElement("div");i.appendChild(t),Ce(e,i,n)}const ie=Symbol("STRUCT_ID"),se=Symbol("SLOT_ID");function Ae(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,configurable:!0,enumerable:!1})}function Te(e,t){Ae(e,ie,t)}function Se(e){return Object.prototype.hasOwnProperty.call(e,ie)?e[ie]:void 0}function ot(e,t){Ae(e,se,t)}function rt(e){return Object.prototype.hasOwnProperty.call(e,se)?e[se]:void 0}function it(e,t,o,n){if(!Array.isArray(t))return()=>{};const i=[];return t.forEach(([l,r,s])=>{if(typeof l!="string"||typeof s!="function"){T.error("Provided handler is not a function",s);return}let c=[];if(r==="window")c=[window];else if(typeof r=="string")if(r.startsWith("$refs.")){const[a,...u]=r.slice(6).split(" "),d=n[a];d&&(c=u.length?Array.from(d.querySelectorAll(u.join(" "))):[d])}else c=Array.from(o.querySelectorAll(r));else if(r instanceof Element||r instanceof Window)c=[r];else if(typeof r=="object"&&r&&"ref"in r){const{ref:a,selector:u}=r,d=n[a];d&&(c=u?Array.from(d.querySelectorAll(u)):[d])}for(const a of c){const u=Y(s,e);a.addEventListener(l,u),i.push({target:a,type:l,handler:u})}}),()=>{for(const{target:l,type:r,handler:s}of i)l.removeEventListener(r,s);i.length=0}}const xe=/^on([a-z]+)$/i;function st(e,t){const o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=o.nextNode();for(;n;){for(const i of Array.from(n.attributes)){const l=i.name.match(xe);if(l){const r=l[1].toLowerCase(),s=i.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(i.name),n.addEventListener(r,c))}}}n=o.nextNode()}}function ct(e,t){const o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);let n=o.nextNode();for(;n;){for(const i of Array.from(n.attributes)){const l=i.name.match(xe);if(l){const r=l[1].toLowerCase(),s=i.value;if(s){const c=e[s];typeof c=="function"&&(n.removeAttribute(i.name),n.addEventListener(r,c))}}}n=o.nextNode()}}function at(e,t,o,n,i){if(!Array.isArray(o))return()=>{};const l=[];return o.forEach(([r,s,c])=>{if(typeof r!="string"||typeof c!="function"){T.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=i[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=i[u];v&&(a=d?Array.from(v.querySelectorAll(d)):[v])}for(const u of a){const d=Y(c,t);u.addEventListener(r,d),l.push({target:u,type:r,handler:d})}}),()=>{for(const{target:r,type:s,handler:c}of l)r.removeEventListener(s,c);l.length=0}}const V=new WeakMap;let ee;function lt(){if(typeof EventTarget>"u")return;const e=globalThis;if(e.__koppajsEventTrackingPatched)return;e.__koppajsEventTrackingPatched=!0;const t=EventTarget.prototype.addEventListener,o=EventTarget.prototype.removeEventListener;EventTarget.prototype.addEventListener=function(n,i,l){return V.has(this)||V.set(this,new Set),V.get(this).add({type:n,listener:i,options:l}),t.call(this,n,i,l)},EventTarget.prototype.removeEventListener=function(n,i,l){const r=V.get(this);if(r){for(const s of r)if(s.type===n&&s.listener===i){r.delete(s);break}r.size===0&&V.delete(this)}return o.call(this,n,i,l)}}function ft(e){const t=V.get(e);if(t){for(const{type:o,listener:n,options:i}of t)e.removeEventListener(o,n,i);V.delete(e)}}function Me(e){if(typeof document>"u"||typeof NodeFilter>"u"||typeof Element>"u")return;const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let o=e instanceof Element?e:null;for(;o;)V.has(o)&&ft(o),o=t.nextNode()}function ut(){ee||typeof MutationObserver>"u"||typeof document>"u"||document.body&&(ee=new MutationObserver(e=>{for(const t of e)t.removedNodes.forEach(o=>{o.nodeType===Node.ELEMENT_NODE&&Me(o)})}),ee.observe(document.body,{childList:!0,subtree:!0}))}const Oe=new WeakMap,ke=new WeakMap,X=new WeakMap;let dt=0;const H=()=>`slot-${++dt}`,W=e=>typeof e=="object"&&e!==null,te=e=>typeof e=="symbol"?e.toString():String(e),ht=e=>{const t=Oe.get(e);return t&&W(t)?t:void 0};function $e(e){const t=ke.get(e);return t||e}const F=e=>W(e)?Reflect.get(e,Ee)===!0:!1;function pt(e){const t=F(e)?$e(e):e;return X.get(t)}const mt=e=>e!==null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="function"||typeof e>"u"),K=e=>{let t=X.get(e);return t||(t=e.map(()=>H()),X.set(e,t)),t},pe=e=>{const t=X.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 yt(e){const t=new Set,o=new WeakMap;let n=0,i=new Set;const l=new Map,r=(f,y)=>!!(f===y||f.startsWith(y+".")),s=(f,y)=>{const b=o.get(f)??"";return b?`${b}.${y}`:y};let c=!1;const a=f=>{i.add(f),n++,c||(c=!0,queueMicrotask(()=>{c=!1,t.forEach(y=>{try{y()}catch(b){console.error("Observer error:",b)}})}))},u=(f,y,b)=>{if(f===y)return;let w=f.length!==y.length;if(!w){for(let h=0;h<f.length;h++)if(f[h]!==y[h]){w=!0;break}}f.splice(0,f.length,...y),w&&a(b)},d=(f,y,b)=>{const w=new Set(f),h=new Set(y);let m=!1;for(const E of w)if(!h.has(E)){m=!0;break}if(!m){for(const E of h)if(!w.has(E)){m=!0;break}}m&&(f.splice(0,f.length,...y),a(b))},v=(f,y,b)=>{const w=new Set(f),h=new Set(y);f.length!==y.length||[...w].some(E=>!h.has(E))||[...h].some(E=>!w.has(E))?d(f,y,b):u(f,y,b)},x=(f,y,b)=>{if(f===y)return!1;let w=!1;for(const h of Object.keys(f))h in y||(w=!0,Reflect.deleteProperty(f,h));for(const h of Object.keys(y)){const m=f[h],E=y[h];m!==E&&(W(m)&&F(m)&&W(E)&&!F(E)?(x(m,E)&&(w=!0),m!==E&&(w=!0,Reflect.set(f,h,E))):(w=!0,Reflect.set(f,h,E)))}return w},M=(f,y,b)=>{const w=K(f);switch(y){case"push":{const h=Array.from({length:b.length},()=>H());w.push(...h);break}case"pop":{w.pop();break}case"shift":{w.shift();break}case"unshift":{const h=Array.from({length:b.length},()=>H());w.unshift(...h);break}case"splice":{const h=b[0]??0,m=b[1]!==void 0?b[1]:f.length-h,E=b.slice(2),S=Array.from({length:E.length},()=>H());w.splice(h,m,...S);break}case"reverse":{w.reverse();break}}pe(f)},N=(f,y="")=>{if(f instanceof Node||f instanceof Window||f instanceof Document)return f;const b=ht(f);if(b)return b;y&&o.set(f,y),Array.isArray(f)&&K(f);const w=new Proxy(f,{get:(h,m,E)=>{if(m===Ee)return!0;if(m==="toJSON")return function(){return $e(h)};if(Array.isArray(h)&&typeof m=="string"&&["push","pop","shift","unshift","splice","reverse","sort"].includes(m)){const R=h[m];if(typeof R=="function")return function(...D){if(m==="sort"){const k=K(h),$=h.map((p,_)=>({el:p,slotId:k[_]||H()})),G=R.apply(this,D),g=new Map;for(let p=0;p<$.length;p++){const _=$[p].el;let O=g.get(_);O||(O=[],g.set(_,O)),O.push(p)}for(let p=0;p<h.length;p++){const _=h[p],O=g.get(_);if(O&&O.length>0){const L=O.shift();k[p]=$[L].slotId}else k[p]=H()}return pe(h),G}else{const k=R.apply(this,D);return M(h,m,D),k}}}const S=Reflect.get(h,m,E),A=Array.isArray(h)&&typeof m=="string"&&/^\d+$/.test(m);if(W(S)&&!F(S)&&!A&&(Array.isArray(S)||!Array.isArray(h))){const I=te(m),R=s(h,I);return N(S,R)}return S},set:(h,m,E,S)=>{const A=Reflect.get(h,m,S);if(A===E)return!0;const I=te(m),R=s(h,I);if(Array.isArray(h)&&typeof m=="string"&&/^\d+$/.test(m)){const k=parseInt(m,10);if(k>=0&&k<h.length){const $=Reflect.set(h,m,E,S);return a(R),$}}if(Array.isArray(A)&&!mt(E)&&Array.isArray(E)){v(A,E,R);const k=A.map(()=>H());return X.set(A,k),!0}if(W(A)&&F(A)&&W(E)&&!F(E)){if(x(A,E)){let $=E;W($)&&!F($)&&($=N($,R)),Reflect.set(h,m,$,S),a(R)}return!0}const D=Reflect.set(h,m,E,S);if(W(E)&&!F(E)){const k=N(E,R);Reflect.set(h,m,k,S),Array.isArray(E)&&K(E)}return a(R),D},deleteProperty:(h,m)=>{if(m==="changedPaths")return Reflect.deleteProperty(h,m);const E=te(m),S=s(h,E),A=Reflect.get(h,m),I=Reflect.deleteProperty(h,m);return I&&A!==void 0&&a(S),I}});return Oe.set(f,w),ke.set(w,f),w};return{state:N(e),watch(f,y){let b=l.get(f);b||(b=new Set,l.set(f,b)),b.add(y);let w=!1;return()=>{if(w)return;w=!0;const h=l.get(f);h&&(h.delete(y),h.size===0&&l.delete(f))}},addObserver(f){t.add(f)},removeObserver(f){t.delete(f)},getStateVersion(){return n},hasPendingChangesFor(f){for(const y of i)for(const b of f)if(y===b||y.startsWith(b+"."))return!0;return!1},flushChanges(){const f=new Set(i);if(f.size>0&&l.size>0){const y=new Map;for(const[b,w]of l){const h=new Set;for(const m of f)r(m,b)&&h.add(m);if(h.size>0)for(const m of w){const E=y.get(m);if(E)for(const S of h)E.add(S);else y.set(m,new Set(h))}}for(const[b,w]of y)b({changedPaths:w})}return i=new Set,f}}}const ne=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function gt(e){const t=e.trim();if(t.startsWith("[")&&t.endsWith("]")){const n=t.slice(1,-1).split(",").map(r=>r.trim());if(n.length!==2)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[i,l]=n;if(!ne.test(i)||!ne.test(l))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"tuple",keyVar:i,itemVar:l}}if(!ne.test(t))throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");return{type:"single",itemVar:t}}function bt(e){const t={acceptNode(o){return o.nodeType===Node.ELEMENT_NODE||o.nodeType===Node.TEXT_NODE&&/\{\{(.+?)\}\}/g.test(o.nodeValue||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}};return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,t)}function Et(e){const t=e.currentNode;return t?.nextSibling?e.currentNode=t.nextSibling:e.nextNode()}function vt(e,t){let o=t.nextSibling;if(!o){let n=t.parentNode;for(;n&&n!==e.root;){if(n.nextSibling){o=n.nextSibling;break}n=n.parentNode}}return o?(e.currentNode=o,o):null}function wt(e){return e==null||e===!0||e===!1?"":String(e)}function Re(e,t){return e.replace(/\{\{(.+?)\}\}/g,(o,n)=>{const i=B(n.trim(),t);return wt(i)})}async function Nt(e,t,o){const n=e.getAttribute("loop");if(!n)return;e.removeAttribute("loop");const i=e.getAttribute("if");i&&e.removeAttribute("if");const l=n.match(/^(.+?)\s+in\s+(.+)$/);if(!l)throw new Error("Invalid loop binding: expected <id> or [<id>, <id>]");const[,r,s]=l,c=gt(r),a=B(s.trim(),t);if(a==null){e.remove();return}if(typeof a!="object"){T.error("State source is not iterable",{collectionExp:s,raw:a});return}const u=Array.isArray(a),d=u?a.map((f,y)=>[String(y),f]):Object.entries(a),v=d.length,x=document.createDocumentFragment(),M=u?pt(a):void 0,N={...t};let C=0;for(const[f,y]of d){if(N.index=C,N.key=f,N.isFirst=C===0,N.isLast=C===v-1,N.isEven=C%2===0,N.isOdd=C%2!==0,c.type==="single"||(N[c.keyVar]=f),N[c.itemVar]=y,i&&!B(i,N)){C++;continue}const b=e.cloneNode(!0);u&&b instanceof HTMLElement&&M&&M[C]!==void 0&&ot(b,M[C]),b instanceof HTMLElement&&(await Pe(b,N,o),x.appendChild(b)),C++}x.childNodes.length>0&&e.parentNode?e.parentNode.replaceChild(x,e):e.remove()}function _t(e,t,o){const n=e.parentNode,i=()=>{if(n)return o.get(n)},l=a=>{n&&o.set(n,a)},r=()=>{n&&o.delete(n)},s=e.getAttribute("if");if(s!==null){const a=!!B(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=i();if(!a?.hasHead){e.remove();return}if(a.resolved){e.remove();return}const u=!!B(c,t);l({hasHead:!0,resolved:u}),u?e.removeAttribute("else-if"):e.remove();return}if(e.hasAttribute("else")){const a=i();if(!a?.hasHead){e.remove();return}a.resolved?e.remove():e.removeAttribute("else"),r();return}}async function Ct(e,t,o=50){const n=new WeakMap;for(let i=0;i<e.length;i+=o){const l=e.slice(i,i+o);for(const{node:r,state:s}of l){if(r instanceof HTMLElement){if(r.hasAttribute("loop")){await Nt(r,s,t);continue}if(r.hasAttribute("if")||r.hasAttribute("else")||r.hasAttribute("else-if")){_t(r,s,n);continue}continue}const c=Re(r.nodeValue,s);if(Fe(c)){const a=document.createRange().createContextualFragment(c);r.replaceWith(a)}else r.nodeValue=c}i+o<e.length&&await new Promise(requestAnimationFrame)}}async function Pe(e,t,o){try{const n=bt(e),i=new Set,l=[];let r=n.currentNode;for(;r;){if(i.has(r)){r=n.nextNode();continue}if(i.add(r),r.nodeType===Node.ELEMENT_NODE&&r instanceof HTMLElement){const s=r;if(s.hasAttribute("loop")){l.push({node:s,state:t}),r=vt(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"&&(o[c.value]=s),c.name.startsWith(":")){const a=c.name.slice(1),u=c.value.trim();try{const d=B(u,t);if(a==="class"&&typeof d=="object"&&d!==null){const v=[];for(const[x,M]of Object.entries(d))M&&v.push(x);if(v.length>0){const x=s.getAttribute("class")||"",M=x?`${x} ${v.join(" ")}`:v.join(" ");s.setAttribute("class",M)}}else d!=null&&d!==!1&&(d===!0?s.setAttribute(a,""):s.setAttribute(a,String(d)));s.removeAttribute(c.name)}catch(d){T.errorWithContext(`Error evaluating dynamic attribute "${c.name}"`,{attributeName:c.name,expression:u},d)}continue}if(c.value.includes("{{"))try{let a=Re(c.value,t);c.name==="class"&&(a=a.replace(/\s+/g," ").trim()),a!==c.value&&s.setAttribute(c.name,a)}catch(a){T.errorWithContext(`Error replacing attribute "${c.name}"`,{attributeName:c.name},a)}}if(s.tagName.includes("-")){r=Et(n)||n.nextNode();continue}}else if(r.nodeType===Node.TEXT_NODE&&r instanceof Text){let s=r.parentElement,c=!1;for(;s;){if(s.tagName.includes("-")){c=!0;break}s=s.parentElement}c||l.push({node:r,state:t})}r=n.nextNode()}await Ct(l,o)}catch(n){throw T.errorWithContext("Error processing template",{},n),n}}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:o=e.length-1,includePrototype:n=!1}=t,i=o>=0&&o<e.length&&Number.isInteger(o)?o:e.length-1;o!==i&&T.warnWithContext(`Invalid defaultWriteIndex ${o}, using ${i}`,{defaultWriteIndex:o,validWriteIndex:i,layersLength:e.length});const l=(s,c)=>n?c in s:Object.prototype.hasOwnProperty.call(s,c),r=s=>{for(let c=0;c<e.length;c++)if(l(e[c],s))return c;return-1};return new Proxy(e[i],{get(s,c){const a=r(c);if(a!==-1)return e[a][c]},set(s,c,a){const u=r(c),d=u!==-1?u:i;return e[d][c]=a,!0},deleteProperty(s,c){const a=r(c);return a===-1?!0:delete e[a][c]},has(s,c){return r(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 me(e){const t=e.getRootNode(),o=e.parentElement??(t instanceof ShadowRoot?t.host:void 0);if(Je(o))return o.instance}function Tt({container:e,host:t}){const o=Array.from(t.childNodes).filter(i=>i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE),n={};for(const i of o){const l=i instanceof HTMLElement&&i.hasAttribute("slot")?i.getAttribute("slot"):"default";n[l]||(n[l]=[]),n[l].push(i)}e.querySelectorAll("slot").forEach(i=>{const l=i.getAttribute("name")||"default",r=n[l];r&&r.length>0&&r.forEach(s=>{i.parentNode.insertBefore(s,i)}),i.remove()})}function St(e,t,o){const n=new Map,i=new Map,l=()=>{for(const a of Object.keys(o)){const u=n.get(o[a]);u instanceof HTMLElement&&(o[a]=u)}};if(!e.querySelector("slot"))return{commit:()=>{},remapRefs:l};const r=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 i.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)r.appendChild(s(a));return Tt({container:e,host:r}),{commit:()=>{const a=u=>{const d=n.get(u),v=i.get(u),x=Array.from(u.childNodes),M=x.map(a);if(!d||!v)return x.forEach((N,C)=>{M[C]!==N&&N.replaceWith(M[C])}),u;if(d instanceof HTMLElement&&u instanceof HTMLElement){for(const N of v.attributes.keys())u.hasAttribute(N)||d.removeAttribute(N);for(const N of Array.from(u.attributes))v.attributes.get(N.name)!==N.value&&d.setAttribute(N.name,N.value);!d.tagName.includes("-")&&(x.length!==v.children.length||x.some((N,C)=>N!==v.children[C]))&&d.replaceChildren(...M)}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 oe({propName:e,propValue:t,props:o}){const n=o[e],i=t??n?.default;if(!n)return!0;const l=Ve(n.type),r=Array.isArray(i)?"array":typeof i,s={string:r==="string",number:r==="number",boolean:r==="boolean",array:Array.isArray(i),object:r==="object"&&i!==null&&!Array.isArray(i),function:r==="function"};return(l==="unknown"?!0:s[l]??!1)?n.regex&&typeof i=="string"&&!new RegExp(n.regex).test(i)?(T.error(`Prop "${e}" does not match regex "${n.regex}".`),!1):!0:(T.error(`Prop "${e}" should be of type "${l}", but got "${r}".`,i),!1)}function ye({ele:e,parent:t,props:o,state:n}){const i=Object.keys(o).length>0,l=(r,s)=>{Object.defineProperty(n,r,{enumerable:!0,configurable:!0,get(){if(t)return re(t.state,s)},set(c){if(!(!t||!t.state))try{je(t.state,s,c)}catch(a){T.errorWithContext(`Failed to set bound prop "${r}" → "${s}"`,{propName:r,parentPath:s},a)}}})};for(const r of e.attributes){const s=r.name.startsWith(":"),c=qe(r.name.substring(s?1:0));if(s&&!t||!(!i||o[c]&&o[c]!==void 0))continue;if(!s){const v=r.value!==""?r.value:!0;(!i||oe({propName:c,propValue:v,props:o}))&&(n[c]=v);continue}const u=r.value?.trim()??"";if(u&&ve(u)){const v=re(t.state,u);(!i||oe({propName:c,propValue:v,props:o}))&&l(c,u);continue}const d=u?B(u,t.state):void 0;(!i||oe({propName:c,propValue:d,props:o}))&&(n[c]=d)}for(const[r,s]of Object.entries(o))r in n||(s.default!==void 0?n[r]=s.default:s.required&&T.error(`Required prop "${r}" is missing.`))}function xt(e,t){const o=new Set;customElements.define(e,class extends HTMLElement{template;instance;_connectionVersion=0;_isDisconnected=!1;_isMounted=!1;_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,i=++this._connectionVersion;if(this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,o.add(this),!document.head.querySelector(`style#style-${e}`)){const g=document.createElement("style");g.id=`style-${e}`,g.textContent=t.style,document.head.appendChild(g)}if(n.instance&&this._model&&this._observerFn){const g=n.instance,p=me(n);g.$parent=p,this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null,this._model.addObserver(this._observerFn),g.props&&g.state&&ye({ele:n,parent:p,props:g.props,state:g.state});return}const r=(t.type||"options")==="options",s=me(n),c=this.template.cloneNode(!0);let a;if(t.deps){a={};const g=Object.entries(t.deps),p=await Promise.all(g.map(([,_])=>_()));for(let _=0;_<g.length;_++)a[g[_][0]]=p[_]}if(i!==this._connectionVersion||this._isDisconnected)return;const u=Ke(t.script,a),d={};let v=!1,x=-1;this._isDisconnected=!1,this._renderAborted=!1,this._pendingRender=null;const M=we(),N=(()=>{let g;return{promise:new Promise(_=>{g=_}),resolve:g}})();let C,f;const y=g=>{const p=Z.plugins[g];if(!p||typeof p.setup!="function"){T.warnWithContext(`Plugin "${g}" not found or has no setup method`,{pluginName:g});return}try{const _=r&&f?f:C;return p.setup.call(_)}catch(_){T.errorWithContext(`Plugin "${g}" setup failed`,{pluginName:g},_);return}},b={};for(const[g,p]of Object.entries(Z.modules))if(typeof p.attach=="function"){const _=p.attach.call({element:n,parent:s,core:{take:le.take}});_&&(b[`$${g}`]=_)}const w=new Map,h=g=>{let p=w.get(g);return p||(p=`on${g.charAt(0).toUpperCase()}${g.slice(1)}`,w.set(g,p)),p},m=(g,...p)=>{const _=h(g);let O=s;for(;O;){const L=O.userContext;if(L){const j=L[_];typeof j=="function"&&j(...p)}else if(O.methods){const j=O.methods[_];typeof j=="function"&&j(...p)}O=O.$parent}},E={$refs:d,$parent:s,$emit:m,$take:y,...b},S=u(E),A=yt(S.state??{});C=A.state;const I=S.methods||{},R=S.props||{},D=S.events||[];let k=S.watchList||[];r&&(f=At([I,C])),ye({ele:n,parent:s,props:R,state:C}),r&&f&&We(I,f);for(const g of De){const p=S[g];if(typeof p=="function"){const _=r&&f?Y(p,f):p;_e(M,g,async()=>{const O=_();O instanceof Promise&&await O})}}this._model=A;const $=async()=>{if(this._isDisconnected)return;if(v){this._renderAborted=!0,this._pendingRender=$;return}const g=A.getStateVersion();if(x!==g){v=!0,this._renderAborted=!1,n.instance&&(n.instance.isRendering=!0);try{const p=c.content.cloneNode(!0),_=St(p,n,d);if(await Pe(p,r&&f?f:C,d),_.remapRefs(),this._renderAborted||this._model!==A){this._pendingRender=$;return}const L=r&&f?f:C;if(await P("global","processed",L),await P(M,"processed"),this._renderAborted||this._model!==A){this._pendingRender=$;return}const j=A.flushChanges();Object.defineProperty(L,"changedPaths",{value:j,writable:!0,configurable:!0,enumerable:!1});const fe=!this._isMounted;if(await P("global",fe?"beforeMount":"beforeUpdate",L),await P(M,fe?"beforeMount":"beforeUpdate",L),this._renderAborted||this._model!==A){delete L.changedPaths,this._pendingRender=$;return}_.commit(),r&&f?(st(f,p),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=it(f,D,p,d)):(ct(I,p),this._eventCleanup&&this._eventCleanup(),this._eventCleanup=at(I,C,D,p,d)),nt(n,p,!this._isMounted,t.structAttr),this._isMounted&&(await P("global","updated",L),await P(M,"updated",L)),delete L.changedPaths,x=g,n.instance&&(n.instance._lastRenderedStateVersion=x)}catch(p){T.errorWithContext("Error during render",{componentName:e},p)}finally{const p=r&&f?f:C;if(delete p.changedPaths,v=!1,n.instance&&(n.instance.isRendering=!1),this._pendingRender&&!this._isDisconnected){const _=this._pendingRender;this._pendingRender=null,requestAnimationFrame(()=>{this._isDisconnected||_().catch(O=>{T.errorWithContext("Error during pending render",{componentName:e},O)})})}}}};n.instance={element:n,template:c,state:C,userContext:r?f:void 0,props:R,methods:I,events:D,watchList:k,$refs:d,$parent:s,$emit:m,$take:y,readyPromise:N.promise,lifecycleRegistry:M,...b,isRendering:!1},this._observerFn=()=>{if(this._isDisconnected||k&&k.length>0&&!A.hasPendingChangesFor(k))return;let g=s;for(;g;){if(g.isRendering)return;g=g.$parent}requestAnimationFrame(()=>{this._isDisconnected||$().catch(p=>{T.errorWithContext("Error during render (observer)",{componentName:e},p)})})},A.addObserver(this._observerFn);const G=r&&f?f:C;if(await P("global","created",G),await P(M,"created"),!(this._isDisconnected||this._model!==A)&&(await $(),!(this._isDisconnected||this._model!==A))){if(!this._isMounted){if(await P("global","mounted",G),this._isDisconnected||this._model!==A||(await P(M,"mounted"),this._isDisconnected||this._model!==A))return;this._isMounted=!0}N.resolve()}}async disconnectedCallback(){const n=this,i=++this._connectionVersion;if(this._isDisconnected=!0,this._renderAborted=!0,this._pendingRender=null,o.delete(this),o.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 r=l.userContext||l.state;await P("global","beforeDestroy",r),await P(l.lifecycleRegistry,"beforeDestroy"),!(!this._isDisconnected||i!==this._connectionVersion)&&(Me(this),this._eventCleanup&&(this._eventCleanup(),this._eventCleanup=null),await P("global","destroyed",r),await P(l.lifecycleRegistry,"destroyed"),!(!this._isDisconnected||i!==this._connectionVersion)&&(this._isMounted=!1,this._model=void 0,this._observerFn=void 0,this._eventCleanup=null,n.instance=void 0))}})}let ce=!1,ge=!1,ae=[];function Mt(){ge||(ge=!0,!(typeof document>"u"||typeof HTMLElement>"u")&&(lt(),Qe(),ut()))}function Ie(...e){const t=e[0],o=e[1];if(Ze(t)){if(!o){T.error("ComponentSource requires a component name when calling take()");return}xt(o,t);return}if(J(t)||Ye(t)){const n={registerHook:(i,l)=>{_e("global",i,l)},take:le.take};try{t.install(n),J(t)?Z.plugins[t.name]=t:Z.modules[t.name]=t}catch(i){T.errorWithContext("Failed to install extension",{name:t.name,type:J(t)?"plugin":"module"},i)}return}T.error("Unknown extension type",t)}function Ot(){ce||(ce=!0,ae.forEach(e=>Ie(...e)),ae=[],T.info("Core initialized"))}const le=Object.assign(()=>{Mt(),Ot()},{take:(...t)=>{ce?Ie(...t):ae.push(t)}});exports.Core=le;exports.LogLevel=be;exports.logger=T;
|