ladrillosjs 2.0.0-rc.3 → 2.0.0-rc.4
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/dist/core/builtins/lazyElement.d.ts +10 -0
- package/dist/core/directives/directiveProcessor.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lazy.js +1 -1
- package/dist/shared-Cce5mWkr.js +2 -0
- package/dist/shared-Cce5mWkr.js.map +1 -0
- package/dist/shared-CgY9vs70.js +2 -0
- package/dist/{shared-BgAD3IVo.js.map → shared-CgY9vs70.js.map} +1 -1
- package/package.json +1 -1
- package/dist/shared-BgAD3IVo.js +0 -2
- package/dist/shared-zqkjmWU9.js +0 -2
- package/dist/shared-zqkjmWU9.js.map +0 -1
|
@@ -23,3 +23,13 @@ export declare function processLazyElement(lazyEl: Element): void;
|
|
|
23
23
|
* an empty innerHTML, breaking components that read $host.__originalHTML.
|
|
24
24
|
*/
|
|
25
25
|
export declare function scanLazyElements(host: HTMLElement | ShadowRoot | DocumentFragment): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns all detached DocumentFragments held by pending `<lazy>` placeholders
|
|
28
|
+
* inside `host`. Used by binding/event-handler/directive scanners to wire up
|
|
29
|
+
* the children of `<lazy>` elements while they are still detached from the
|
|
30
|
+
* document. Wiring done on these fragments survives the later move into the
|
|
31
|
+
* host tree when the lazy strategy fires.
|
|
32
|
+
*
|
|
33
|
+
* Returns an empty array for hosts that contain no pending lazy fragments.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getPendingLazyContent(host: HTMLElement | ShadowRoot | DocumentFragment): DocumentFragment[];
|
|
@@ -36,7 +36,7 @@ export declare function scanDirectivesWithRefs(host: HTMLElement | ShadowRoot, e
|
|
|
36
36
|
* Scans for $ref directives only and populates the refs Map.
|
|
37
37
|
* This can be called early (before scripts run) to make refs available.
|
|
38
38
|
*/
|
|
39
|
-
export declare function scanRefsOnly(host: HTMLElement | ShadowRoot, refs: RefMap): void;
|
|
39
|
+
export declare function scanRefsOnly(host: HTMLElement | ShadowRoot | DocumentFragment, refs: RefMap): void;
|
|
40
40
|
/**
|
|
41
41
|
* Renders all loops with the current state.
|
|
42
42
|
*/
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as r,r as s,e}from"./shared-
|
|
1
|
+
import{$ as r,r as s,e}from"./shared-Cce5mWkr.js";import{E as o}from"./shared-Cce5mWkr.js";import{c as a}from"./shared-CgY9vs70.js";const t={registerComponent:e,registerComponents:s,$use:r,configure:a};export{r as $use,o as ErrorCode,a as configure,t as default,e as registerComponent,s as registerComponents};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as a,a as s,b as e,c as o,d as r,$ as n,r as t,e as i,f as l}from"./shared-
|
|
1
|
+
import{l as a,a as s,b as e,c as o,d as r,$ as n,r as t,e as i,f as l}from"./shared-Cce5mWkr.js";import{E as m}from"./shared-Cce5mWkr.js";import{$ as d,a as p}from"./shared-DGGk2qBc.js";import{c as y}from"./shared-CgY9vs70.js";const f=a=>l.loadLazyComponent(a),z={registerComponent:i,registerComponents:t,$use:n,$emit:p,$listen:d,loadLazyComponent:f,configure:y,lazyOnIdle:r,lazyOnVisible:o,lazyOnMedia:e,lazyOnInteraction:s,lazyOnDelay:a};export{p as $emit,d as $listen,n as $use,m as ErrorCode,y as configure,z as default,a as lazyOnDelay,r as lazyOnIdle,s as lazyOnInteraction,e as lazyOnMedia,o as lazyOnVisible,f as loadLazyComponent,i as registerComponent,t as registerComponents};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/lazy.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as a,i as e,j as s,l as n,d as o,a as y,b as l,c as t}from"./shared-
|
|
1
|
+
import{h as a,i as e,j as s,l as n,d as o,a as y,b as l,c as t}from"./shared-Cce5mWkr.js";export{a as defaultLazyStrategy,e as forceLoadLazyComponent,s as isLazyComponent,n as lazyOnDelay,o as lazyOnIdle,y as lazyOnInteraction,l as lazyOnMedia,t as lazyOnVisible};
|
|
2
2
|
//# sourceMappingURL=lazy.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e,c as t,b as n}from"./shared-DGGk2qBc.js";const r=/{([^}]+)}/g,o=new DOMParser;async function s(e,t,n){const s=function(e){return o.parseFromString(e,"text/html")}(e),i=Array.from(s.querySelectorAll("script")),a=i.filter(e=>!e.src).map(e=>({content:(e.textContent??"").trim(),type:e.getAttribute("type")})).filter(e=>e.content.length>0),c=i.filter(e=>(e.getAttribute("src")||"").includes("html-proxy")&&"module"===e.getAttribute("type")),l=[...a,...(await Promise.all(c.map(async e=>{const t=e.getAttribute("src")||"";try{const e=await fetch(t);if(e.ok)return{content:(await e.text()).trim(),type:"module"}}catch(n){}return null}))).filter(e=>null!==e&&e.content.length>0)],u=i.filter(e=>{if(!e.src)return!1;const t=e.getAttribute("src")||"";return!t.includes("@vite/client")&&!t.includes("html-proxy")}).map(e=>{const t=e.getAttribute("type");let r=e.src;if(n)try{r=new URL(e.getAttribute("src")??e.src,n).toString()}catch{}return{src:r,type:t,external:e.hasAttribute("external")}}).filter(e=>e.src.length>0);i.forEach(e=>e.remove());const f=Array.from(s.querySelectorAll('link[rel="stylesheet"]')),p=f.map(e=>{let t=e.getAttribute("href")||"";const r=e.getAttribute("rel")||"stylesheet";if(n&&t&&!t.startsWith("http"))try{t=new URL(t,n).toString()}catch{}return{href:t,rel:r}}).filter(e=>e.href.length>0);f.forEach(e=>e.remove());const d=Array.from(s.querySelectorAll("style")),h=d.map(e=>e.textContent??"").join("\n").trim();d.forEach(e=>e.remove());const m=e=>e?Array.from(e.children).find(e=>"TEMPLATE"===e.tagName):void 0,g=m(s.body)??m(s.head);let _;if(g){const e=document.createElement("div");e.appendChild(g.content.cloneNode(!0)),_=e.innerHTML.trim()}else _=s.body.innerHTML.trim();const y=function(e){const t=/* @__PURE__ */new Set,n=function(e){const t=/* @__PURE__ */new Set,n=/<for\b[^>]*?\beach\s*=\s*["']([^"']+)["'][^>]*>/gi;let r;for(;null!==(r=n.exec(e));){const e=r[1].trim(),n=e.match(/^\(\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\)\s+in\s+/);if(n){t.add(n[1]),t.add(n[2]);continue}const o=e.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s+in\s+/);o&&t.add(o[1])}return t}(e),o=e.matchAll(r);for(const r of o){const e=r[1].trim().match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);if(e){const r=e[1];["true","false","null","undefined","new","this","typeof","instanceof","void","delete","in","of","if","else","for","while","do","switch","case","break","continue","return","throw","try","catch","finally","function","class","const","let","var","Math","Date","JSON","Array","Object","String","Number","Boolean","console","window","document"].includes(r)||n.has(r)||t.add(r)}}return Array.from(t)}(_);return{tagName:t,template:_,scripts:l,externalScripts:u,externalStyles:p,styles:h,sourcePath:n,lazy:!1,templateBindings:y}}const i=/* @__PURE__ */new Map;let a=25;const c=e=>{if(!Number.isFinite(e)||e<1)throw new Error(`[LadrillosJS] configure({ cacheSize }) requires a positive integer, got ${e}`);for(a=Math.floor(e);i.size>a;){const e=i.keys().next().value;if(!e)break;i.delete(e)}},l=(e,t)=>{if(i.has(e))i.delete(e);else if(i.size>=a){const e=i.keys().next().value;e&&i.delete(e)}i.set(e,t)};async function u(e){if(!e)throw new Error("Path cannot be null or empty");const t=(e=>{const t=i.get(e);return t&&(i.delete(e),i.set(e,t)),t})(e);if(t)return{source:t,resolvedPath:e};try{const t=await async function(e){if(e.endsWith(".html")){const t=await fetch(e);return t.ok?{path:e,response:t}:null}const t=e.endsWith("/")?e.slice(0,-1):e,n=`${t}/index.html`;try{const e=await fetch(n);if(e.ok)return{path:n,response:e}}catch{}try{const e=await fetch(t);if(e.ok&&(e.headers.get("content-type")||"").includes("text/html"))return{path:t,response:e}}catch{}return null}(e);if(!t)throw new Error(`Failed to fetch component from ${e}: Could not resolve path. Tried: ${e}${e.endsWith(".html")?"":` and ${e}/index.html`}`);const n=await t.response.text();return l(e,n),t.path!==e&&l(t.path,n),{source:n,resolvedPath:t.path}}catch(n){return}}function f(e){const t=e.trim(),n=function(e){const t=function(e){let t=0,n=0,r=0,o=!1,s=!1,i=!1,a=!1;for(let c=0;c<e.length;c++){const l=e[c];if(a)a=!1;else if("\\"!==l)if(s||i||"'"!==l)if(o||i||'"'!==l)if(o||s||"`"!==l){if(!(o||s||i)&&("("===l?t++:")"===l?t=Math.max(0,t-1):"["===l?n++:"]"===l?n=Math.max(0,n-1):"{"===l?r++:"}"===l&&(r=Math.max(0,r-1)),"("===l&&0===t&&0===n&&0===r))return c}else i=!i;else s=!s;else o=!o;else a=!0}return-1}(e);if(t<0)return null;const n=function(e,t){let n=0,r=!1,o=!1,s=!1,i=!1;for(let a=t;a<e.length;a++){const t=e[a];if(i)i=!1;else if("\\"!==t)if(o||s||"'"!==t)if(r||s||'"'!==t)if(r||o||"`"!==t){if(!(r||o||s))if("("===t)n++;else if(")"===t){if(n--,0===n)return a;if(n<0)return-1}}else s=!s;else o=!o;else r=!r;else i=!0}return-1}(e,t);if(n<0)return null;if(0!==e.slice(n+1).trim().length)return null;const r=p(e.slice(0,t).trim());if(!r)return null;return{calleePath:r,args:function(e){const t=[];let n="",r=0,o=0,s=0,i=!1,a=!1,c=!1,l=!1;for(let f=0;f<e.length;f++){const u=e[f];if(l)n+=u,l=!1;else if("\\"!==u)if(a||c||"'"!==u)if(i||c||'"'!==u)if(i||a||"`"!==u){if(!i&&!a&&!c&&("("===u?r++:")"===u?r=Math.max(0,r-1):"["===u?o++:"]"===u?o=Math.max(0,o-1):"{"===u?s++:"}"===u&&(s=Math.max(0,s-1)),","===u&&0===r&&0===o&&0===s)){const e=n.trim();e.length>0&&t.push(e),n="";continue}n+=u}else c=!c,n+=u;else a=!a,n+=u;else i=!i,n+=u;else n+=u,l=!0}const u=n.trim();return u.length>0&&t.push(u),t}(e.slice(t+1,n))}}(t);if(n)return{raw:t,path:n.calleePath,isFunction:!0,isExpression:!0,functionArgs:n.args};const r=p(t);return r?{raw:t,path:r,isFunction:!1,isExpression:!1}:{raw:t,path:[],isExpression:!0}}function p(e){return/^[$A-Z_][0-9A-Z_$]*(?:\s*\.\s*[$A-Z_][0-9A-Z_$]*)*$/i.test(e)?e.split(".").map(e=>e.trim()).filter(e=>e.length>0):null}const d=globalThis.requestIdleCallback||(e=>setTimeout(e,1)),h=globalThis.cancelIdleCallback||(e=>clearTimeout(e)),m=(e=1e4)=>t=>{const n=d(t,{timeout:e});return()=>h(n)},g=e=>(t,n)=>{if(function(e){const{top:t,left:n,bottom:r,right:o}=e.getBoundingClientRect(),{innerHeight:s,innerWidth:i}=window;return(t>0&&t<s||r>0&&r<s)&&(n>0&&n<i||o>0&&o<i)}(n))return void t();const r=new IntersectionObserver(e=>{for(const n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return r.observe(n),()=>r.disconnect()},_=e=>t=>{if(!e)return void t();const n=matchMedia(e);if(n.matches)return void t();const r=()=>t();return n.addEventListener("change",r,{once:!0}),()=>n.removeEventListener("change",r)},y=(e=["click","focusin"])=>{const t="string"==typeof e?[e]:e;return(e,n)=>{let r=!1;const o=t=>{r||(r=!0,s(),e(),queueMicrotask(()=>{t.target&&t.target instanceof Element&&t.target.dispatchEvent(new t.constructor(t.type,t))}))},s=()=>{for(const e of t)n.removeEventListener(e,o)};for(const i of t)n.addEventListener(i,o,{once:!0,passive:!0});return s}},b=(e=0)=>t=>{const n=setTimeout(t,e);return()=>clearTimeout(n)},v=g({rootMargin:"100px"});let w=null;var E=/* @__PURE__ */(e=>(e[e.EXPRESSION_EVAL_FAILED=101]="EXPRESSION_EVAL_FAILED",e[e.EXPRESSION_SYNTAX_ERROR=102]="EXPRESSION_SYNTAX_ERROR",e[e.EXPRESSION_UNDEFINED_VAR=103]="EXPRESSION_UNDEFINED_VAR",e[e.EXPRESSION_NULL_ACCESS=104]="EXPRESSION_NULL_ACCESS",e[e.SCRIPT_EXTRACT_FAILED=201]="SCRIPT_EXTRACT_FAILED",e[e.SCRIPT_EXECUTION_FAILED=202]="SCRIPT_EXECUTION_FAILED",e[e.EVENT_HANDLER_FAILED=301]="EVENT_HANDLER_FAILED",e[e.DIRECTIVE_ERROR=401]="DIRECTIVE_ERROR",e[e.LOOP_ERROR=402]="LOOP_ERROR",e[e.CONDITIONAL_ERROR=403]="CONDITIONAL_ERROR",e[e.COMPONENT_LOAD_FAILED=501]="COMPONENT_LOAD_FAILED",e[e.COMPONENT_NOT_FOUND=502]="COMPONENT_NOT_FOUND",e[e.MODULE_LOAD_FAILED=601]="MODULE_LOAD_FAILED",e[e.MODULE_EXECUTION_FAILED=602]="MODULE_EXECUTION_FAILED",e))(E||{});let A=null;function $(e){A=e}function C(e,t,n){const r=function(e,t){const n=function(e){const t=void 0!==e?e:w;if(!t)return"";const n=[];if(t.tagName&&n.push(`<${t.tagName}>`),t.sourcePath){const e=t.sourcePath.split("/").pop()||t.sourcePath;n.push(`(${e})`)}return n.length>0?` in ${n.join(" ")}`:""}(t);return`${e}${n}`}(e,t);"undefined"!=typeof window&&"undefined"!=typeof console&&console,function(e,t){if(A)try{const n=e instanceof Error?e:new Error(String(e));A(n,t??null)}catch{}}(n instanceof Error?n:new Error(r,void 0!==n?{cause:n}:void 0),t)}function S(e,t,n={}){var r;n.errorCode||(r=t)instanceof SyntaxError||r instanceof ReferenceError||r instanceof TypeError&&(r.message.includes("Cannot read properties of null")||r.message.includes("Cannot read properties of undefined")),function(e){if(e instanceof SyntaxError)return"Invalid expression syntax";if(e instanceof ReferenceError){const t=e.message.match(/(\w+) is not defined/);return t?`Undefined variable: "${t[1]}"`:"Undefined variable"}e instanceof TypeError&&(e.message.includes("Cannot read properties of null")||e.message.includes("Cannot read properties of undefined"))}(t)}function N(e){const t=e.querySelector(':scope > template[slot="placeholder"]');return t?(t.remove(),t.content.cloneNode(!0)):null}function R(e){const t=e.parentNode;if(!t)return;const n=function(e){if(e.hasAttribute("eager"))return null;if(e.hasAttribute("interaction")){const t=(e.getAttribute("interaction")||"").trim();if(!t)return y();const n=t.split(",").map(e=>e.trim()).filter(Boolean);return y(1===n.length?n[0]:n)}if(e.hasAttribute("media")){const t=e.getAttribute("media")||"";return _(t)}if(e.hasAttribute("delay")){const t=Number(e.getAttribute("delay"))||0;return b(t)}if(e.hasAttribute("idle")||e.hasAttribute("idle-timeout")){const t=e.getAttribute("idle-timeout");return t?m(Number(t)||1e4):m()}const t={},n=e.getAttribute("margin");n&&(t.rootMargin=n);const r=e.getAttribute("threshold");if(null!==r){const e=Number(r);Number.isNaN(e)||(t.threshold=e)}return Object.keys(t).length>0?g(t):v}(e),r=e.getAttribute("src"),o=e.getAttribute("component"),s=/* @__PURE__ */new Set(["eager","visible","margin","threshold","idle","idle-timeout","delay","interaction","media","src","component"]),i=document.createComment(r?` <lazy src="${r}"> `:" <lazy> ");if(t.insertBefore(i,e),e.remove(),r){const t=(o||(a=r,(a.split(/[?#]/)[0].split("/").pop()?.replace(/\.[^.]+$/,"")||a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase())).trim();if(!t.includes("-"))return;const c=N(e),l=()=>{const n=document.createElement(t);for(const t of Array.from(e.attributes))s.has(t.name)||n.setAttribute(t.name,t.value);i.parentNode?.replaceChild(n,i)};let u=null;c&&(u=document.createComment(" /lazy-placeholder "),i.parentNode?.insertBefore(u,i.nextSibling),i.parentNode?.insertBefore(c,u));const f=async()=>{try{if(customElements.get(t)||await async function(e,t){return(await Promise.resolve().then(()=>Lt)).ladrillos.registerComponent(e,t,!0,!1)}(t,r),u){let e=i.nextSibling;for(;e&&e!==u;){const t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.removeChild(u)}l()}catch(e){}};if(!n)return void f();const p=document.createElement("span");let d;p.setAttribute("data-lazy-sentinel",""),p.style.cssText="display:inline-block;width:0;height:0;padding:0;margin:0;border:0;",i.parentNode?.insertBefore(p,i.nextSibling);const h=()=>{d?.(),p.remove(),f()};return void(d=n(h,p))}var a;const c=N(e),l=document.createDocumentFragment();for(;e.firstChild;)l.appendChild(e.firstChild);const u=document.createComment(" /lazy ");i.parentNode?.insertBefore(u,i.nextSibling),c&&i.parentNode?.insertBefore(c,u);const f=()=>{let e=i.nextSibling;for(;e&&e!==u;){const t=e.nextSibling;e.parentNode?.removeChild(e),e=t}u.parentNode?.insertBefore(l,u)};if(!n)return void f();const p=document.createElement("span");let d;p.setAttribute("data-lazy-sentinel",""),p.style.cssText="display:inline-block;width:0;height:0;padding:0;margin:0;border:0;",i.parentNode?.insertBefore(p,i.nextSibling),p.__lazyContent=l,d=n(()=>{d?.(),p.remove(),f()},p)}function x(e){const t=Array.from(e.querySelectorAll("lazy"));for(const n of t)L(n)||R(n)}function L(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function T(e){const t=[],n=e.querySelectorAll("[data-lazy-sentinel]");for(const r of Array.from(n)){const e=r.__lazyContent;e&&t.push(e)}return t}function I(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let o;for(;o=n.nextNode();){if(k(o)||O(o))continue;const e=o.textContent;if(!e)continue;const n=[...e.matchAll(r)];if(n.length>0){const r=e,s=n.map(e=>f(e[1].trim()));t.push({node:o,bindings:s,original:r})}}const s=function(e){const t=[],n=["$bind","$ref","$no:bind","condition","each","key","track-by"],o=Array.from(e.querySelectorAll("*"));for(const s of o)if("FOR"!==s.tagName&&!k(s)&&!s.hasAttribute("$no:bind")&&!O(s))for(const e of Array.from(s.attributes)){if(n.includes(e.name))continue;const o=[...e.value.matchAll(r)];if(o.length>0){const n=document.createTextNode(e.value),r=o.map(e=>f(e[1].trim()));t.push({node:n,bindings:r,original:e.value,isAttribute:!0,attributeName:e.name,element:s})}}return t}(e);return t.push(...s),t}function k(e){let t=(Node,e.parentElement);for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function O(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$no:bind"))return!0;t=t.parentElement}return!1}const M=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onkeydown","onkeyup","onkeypress","onfocus","onblur","onchange","oninput","onsubmit","onreset","onscroll","onload","onerror","ontouchstart","ontouchmove","ontouchend","ontouchcancel","ondragstart","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondrop"],D=Object.freeze(["alert","confirm","prompt","console","JSON","Math","Date","Array","Object","String","Number","Boolean","Map","Set","WeakMap","WeakSet","Symbol","BigInt","Promise","Proxy","Reflect","parseInt","parseFloat","isNaN","isFinite","Infinity","NaN","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","setTimeout","clearTimeout","setInterval","clearInterval","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","queueMicrotask","fetch","AbortController","AbortSignal","Headers","Request","Response","URL","URLSearchParams","navigator","location","history","localStorage","sessionStorage","crypto","document","window","globalThis","Element","HTMLElement","Event","CustomEvent","EventTarget","TextEncoder","TextDecoder","Blob","File","FileReader","FormData","Error","TypeError","RangeError","SyntaxError","ReferenceError","atob","btoa","structuredClone"]),P=Object.freeze([]),F=/* @__PURE__ */new Set(["with","eval","arguments","constructor","prototype","break","case","catch","continue","debugger","default","delete","do","else","finally","for","function","if","in","instanceof","new","return","switch","this","throw","try","typeof","var","void","while","class","const","enum","export","extends","import","super","implements","interface","let","package","private","protected","public","static","yield","null","true","false"]),j={enter:"Enter",tab:"Tab",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",delete:"Delete",backspace:"Backspace",insert:"Insert",f1:"F1",f2:"F2",f3:"F3",f4:"F4",f5:"F5",f6:"F6",f7:"F7",f8:"F8",f9:"F9",f10:"F10",f11:"F11",f12:"F12",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},U=["ctrl","alt","shift","meta"],z=["prevent","stop","self","once","passive","capture"],W={left:0,middle:1,right:2};function B(e){if(!e.startsWith("$on:"))return null;const t=e.slice(4).split(".");if(0===t.length||!t[0])return null;const n=t[0],r=t.slice(1),o={eventName:n,keyModifiers:[],systemModifiers:[],eventModifiers:[],mouseModifier:null,exact:!1};for(const s of r){const e=s.toLowerCase();"exact"!==e?z.includes(e)?o.eventModifiers.push(e):U.includes(e)?o.systemModifiers.push(e):e in W?o.mouseModifier=e:o.keyModifiers.push(e):o.exact=!0}return o}function H(e){const t={};return e.includes("passive")&&(t.passive=!0),e.includes("capture")&&(t.capture=!0),e.includes("once")&&(t.once=!0),t}function Z(e,t){return function(n){if((!t.eventModifiers.includes("self")||n.target===n.currentTarget)&&(!(t.mouseModifier&&n instanceof MouseEvent)||function(e,t){return e.button===W[t]}(n,t.mouseModifier))&&(!(t.systemModifiers.length>0||t.exact)||!(n instanceof KeyboardEvent||n instanceof MouseEvent)||function(e,t,n){const r={ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey,meta:e.metaKey};for(const o of t)if(!r[o])return!1;if(n)for(const o of U)if(!t.includes(o)&&r[o])return!1;return!0}(n,t.systemModifiers,t.exact))){if(t.keyModifiers.length>0&&n instanceof KeyboardEvent){const e=t.keyModifiers.some(e=>function(e,t){const n=t.toLowerCase(),r=j[n];if(r)return e.key===r;if(1===n.length)return e.key.toLowerCase()===n;const o=n.split("-").map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return e.key.toLowerCase()===n||e.key.toLowerCase()===o.toLowerCase()}(n,e));if(!e)return}t.eventModifiers.includes("prevent")&&n.preventDefault(),t.eventModifiers.includes("stop")&&n.stopPropagation(),e(n)}}}function q(e){return e.startsWith("$on:")}const X=/* @__PURE__ */new Map,V=/* @__PURE__ */Symbol("reactive-array"),G=["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"];function J(e,t){return e[V]?e:new Proxy(e,{get(e,n){if(n===V)return!0;const r=e[n];return"string"==typeof n&&G.includes(n)&&"function"==typeof r?(...n)=>{const o=n.map(e=>Array.isArray(e)?J(e,t):e),s=r.apply(e,o);return t(),s}:Array.isArray(r)?J(r,t):r},set(e,n,r){const o="string"==typeof n?parseInt(n,10):NaN,s=!isNaN(o),i="length"===n,a=Array.isArray(r)?J(r,t):r;return e[n]===a||(e[n]=a,(s||i)&&t()),!0},deleteProperty(e,n){const r=delete e[n];return r&&t(),r}})}function Y(e,t){for(const n of Object.keys(e)){const r=e[n];Array.isArray(r)?e[n]=J(r,t):r&&"object"==typeof r&&!Array.isArray(r)&&Y(r,t)}return e}function K(e,t,n,r){const o=function(e,t){const n=/* @__PURE__ */new Map;for(const r of t)n.set(r,/* @__PURE__ */new Set);for(const r of e)for(const e of r.bindings)for(const o of t)Q(e.raw,o)&&n.get(o).add(r);return n}(t,Object.keys(e));Y(e,()=>{r&&r()});const s=new Proxy(e,{get:(e,t)=>e[t],set(e,s,i){const a=!(s in e);if(!a&&e[s]===i)return!0;const c=Array.isArray(i)?J(i,()=>{r&&r()}):i;return e[s]=c,a&&function(e,t,n){n.set(e,/* @__PURE__ */new Set);for(const r of t)for(const t of r.bindings)Q(t.raw,e)&&n.get(e).add(r)}(s,t,o),e.__suspendReactivity||((e,t)=>{const s=o.get(e);if(s)for(const r of s)n(r,t);r&&r()})(s,e),!0}});return s}function Q(e,t){const n=function(e){let t=X.get(e);if(!t){const n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=new RegExp(`\\b${n}\\b`),X.set(e,t)}return t}(t);return n.test(e)}function ee(e,t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e.startsWith("/")?new URL(e,window.location.origin).href:e:new URL(e,t).href}function te(e){return{registerComponent:function(t,n,r=!0,o=!1){const s=ee(n,e);return xt.registerComponent(t,s,r,o)},registerComponents:function(t){const n=Array.isArray(t)?t.map(t=>({...t,path:ee(t.path,e)})):Object.entries(t).map(([t,n])=>"string"==typeof n?{name:t,path:ee(n,e)}:{name:t,...n,path:ee(n.path,e)});return xt.registerComponents(n)},$use:function(t,n=!0,r=!1){const o=function(e){return(e.split("/").pop()?.replace(/\.[^.]+$/,"")||e).replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}(t),s=ee(t,e);return xt.registerComponent(o,s,n,r)}}}const ne=["registerComponent","registerComponents","$use"],re=te(window.location.href),oe=re.registerComponent,se=re.registerComponents,ie=re.$use,ae=e=>e instanceof ShadowRoot?e.host:e;function ce(e,t,n,r){const o=[e,...T(e)];for(const s of o){const e=Array.from(s.querySelectorAll("*"));for(const o of e)if(!ue(o)){for(const e of M){const s=o.getAttribute(e);if(s){o.removeAttribute(e);const i=e.slice(2),a=fe(s,t,n,r);a&&o.addEventListener(i,a)}}le(o,t,n,r)}}}function le(e,t,n,r){const o=Array.from(e.attributes).filter(e=>q(e.name));for(const s of o){const o=B(s.name);if(!o)continue;const i=s.value;e.removeAttribute(s.name);const a=fe(i,t,n,r);if(!a)continue;const c=Z(a,o),l=H(o.eventModifiers);e.addEventListener(o.eventName,c,l)}}function ue(e){if(e.hasAttribute("$for")||"FOR"===e.tagName)return!0;let t=e.parentElement;for(;t;){if(t.hasAttribute("$for")||"FOR"===t.tagName)return!0;t=t.parentElement}return!1}function fe(e,t,n,r){try{const o=r?.__componentUrl,s=r?.__componentId,i=ye(o,s),a=_e(),c=["event","state","$refs",...a,...i.keys],l=Object.keys(t),u=l.filter(e=>"function"==typeof t[e]),f=l.filter(e=>"function"!=typeof t[e]),p=!0===t.__hasModuleScripts,d=f.length>0?`let { ${f.join(", ")} } = state;`:"",h=p&&u.length>0?`const { ${u.join(", ")} } = state;`:"",m=function(e,t){if(!e||0===t.length)return e;const n=[];let r=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));r=r.replace(/`(?:[^`\\$]|\\.|\$(?!\{)|\$\{[^}]*\})*`/g,e=>e.replace(/\$\{([^}]+)\}/g,(e,n)=>{let r=n;for(const o of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${ge(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${ge(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(pe(n,p?u:[]),f),g=f.some(t=>new RegExp(`\\b${t}\\b`).test(e))?f.filter(t=>new RegExp(`\\b${t}\\b`).test(e)).map(e=>`state.${e} = ${e};`).join(" "):"",_=/\bawait\b/.test(e)||/\bawait\b/.test(m)||/\basync\b/.test(m),y=o||"ladrillos-event-handler",b=_?`"use strict"; ${d} ${h} ${m} try { await (async () => { ${e} })(); } finally { ${g} }\n//# sourceURL=${y}`:`"use strict"; ${d} ${h} ${m} ${e}; ${g}\n//# sourceURL=${y}`,v=Object.getPrototypeOf(async function(){}).constructor,w=_?new v(...c,b):new Function(...c,b);return e=>{try{const n=[e,t,r&&r.__refs||/* @__PURE__ */new Map,...a.map(()=>{}),...i.values],o=w(...n);o&&"function"==typeof o.catch&&o.catch(e=>{r?.tagName?.toLowerCase(),S(0,e,{errorCode:E.EVENT_HANDLER_FAILED})})}catch(n){r?.tagName?.toLowerCase(),S(0,n,{errorCode:E.EVENT_HANDLER_FAILED})}}}catch(o){return r?.tagName&&r.tagName.toLowerCase(),null}}function pe(e,t=[]){const n=[],r=/(?:async\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\([^)]*\)\s*\{/g;let o;for(;null!==(o=r.exec(e));){if(t.includes(o[1]))continue;const r=de(e,o.index);r&&n.push(r)}const s=/(?:const|let)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=\s*(?:async\s*)?\([^)]*\)\s*=>\s*\{/g;for(;null!==(o=s.exec(e));){if(t.includes(o[1]))continue;const r=o.index,s=e.indexOf("{",r+o[0].length-1),i=de(e,r,s);i&&n.push(i)}return n.map(e=>e.trim()).join(";\n")+(n.length>0?";":"")}function de(e,t,n){let r=0,o=t,s=!1,i="",a=!1;for(let c=n??t;c<e.length;c++){const t=e[c];if('"'!==t&&"'"!==t&&"`"!==t||"\\"===(c>0?e[c-1]:"")||(s?t===i&&(s=!1):(s=!0,i=t)),!s&&("{"===t&&(r++,a=!0),"}"===t&&r--,a&&0===r&&"}"===t)){o=c+1;break}}return 0!==r?null:e.slice(t,o)}function he(e,t,n,r,o,s,i=[]){try{const a=me(e),c=`\n "use strict";\n ${function(e,t){if(0===t.length)return e;const n=[];let r=e.replace(/(["'])(?:(?!\1)[^\\]|\\.)*\1/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));r=r.replace(/`(?:[^`\\$]|\\.|\$(?!\{)|\$\{[^}]*\})*`/g,e=>e.replace(/\$\{([^}]+)\}/g,(e,n)=>{let r=n;for(const o of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${ge(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`\\b(let|const|var)\\s+(${ge(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} ??=`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${ge(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(e,[.../* @__PURE__ */new Set([...a,...i])])}\n//# sourceURL=${n||"ladrillos-component"}\n `,l=ye(n,r),u=_e(),f=["__state__","$host","$refs",...u,...l.keys],p=[t,o,s,...u.map(()=>{}),...l.values];new Function(...f,c)(...p)}catch(a){}}function me(e){const t=[],n=/(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/g;let r;for(;null!==(r=n.exec(e));)t.push(r[1]);return t}function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _e(){return P.filter(e=>!F.has(e))}function ye(n,r){const o=[],s=[];for(const e of D)e in globalThis&&(o.push(e),s.push(globalThis[e]));const i=te(n||window.location.href);o.push(...ne),s.push(i.registerComponent,i.registerComponents,i.$use);const a=t(r||"anonymous");return o.push(...e),s.push(a.$emit,a.$listen),{keys:o,values:s}}function be(e,t){try{const n=Object.keys(t),r=Object.values(t),o=_e(),s=[...o,...n],i=[...o.map(()=>{}),...r];return new Function(...s,`"use strict"; return ${e};`)(...i)}catch(n){return S(0,n,{}),`{${e}}`}}function ve(e,t){let n=e.original;for(const r of e.bindings){const e=be(r.raw,t),o=String(e??"");n=n.replace(`{${r.raw}}`,o)}if(e.isAttribute&&e.attributeName){const t=e.element??e.node.parentElement;t&&t.setAttribute(e.attributeName,n)}else e.node.textContent=n}function we(e,t){for(const n of e)ve(n,t)}const Ee=/* @__PURE__ */new Map,Ae=/* @__PURE__ */new Map,$e=/(?:import|export)\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g,Ce=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,Se=[".ts",".tsx",".mts"];function Ne(e){return e.startsWith("./")||e.startsWith("../")}function Re(e){return Se.some(t=>e.endsWith(t))}function xe(e){return!(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:"))}const Le=/^(?:export\s+)?(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm,Te=["$emit","$listen","$refs","registerComponent","registerComponents","$use"];async function Ie(e,t,n){if(e.external)return document.querySelector(`script[src="${e.src}"]`)?Promise.resolve(void 0):new Promise((t,n)=>{const r=document.createElement("script");r.src=e.src,e.type&&(r.type=e.type),r.onload=()=>t(void 0),r.onerror=t=>n(new Error(`Failed to load external script: ${e.src}`)),document.head.appendChild(r)});if("module"!==e.type)return document.querySelector(`script[src="${e.src}"]`)?Promise.resolve(void 0):new Promise((t,n)=>{const r=document.createElement("script");r.src=e.src,e.type&&(r.type=e.type),r.onload=()=>t(void 0),r.onerror=t=>n(new Error(`Failed to load script: ${e.src}`)),document.head.appendChild(r)});try{const r=await fetch(e.src);if(!r.ok)throw new Error(`Failed to fetch module: ${e.src}`);const o=function(e,t){let n=e;const r=[],o=[];return n=n.replace($e,(e,n)=>{if(Ne(n)){const r=new URL(n,t).href;return Re(n)&&o.push(n),e.replace(n,r)}return xe(n)&&r.push(n),e}),n=n.replace(Ce,(e,n)=>{if(Ne(n)){const e=new URL(n,t).href;return Re(n)&&o.push(n),`import("${e}")`}return xe(n)&&r.push(n),e}),n}(await r.text(),e.src),s=function(e){const t=function(e){const t=[];let n;for(Le.lastIndex=0;null!==(n=Le.exec(e));)t.push(n[1]);const r=/^(?:export\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm;for(;null!==(n=r.exec(e));)t.includes(n[1])||t.push(n[1]);return t}(e),n=/* @__PURE__ */new Set,r=/export\s+(?:let|const|var|function)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g;let o;for(;null!==(o=r.exec(e));)n.add(o[1]);const s=/export\s*\{([^}]+)\}/g;for(;null!==(o=s.exec(e));)o[1].split(",").map(e=>e.trim().split(/\s+as\s+/)[0].trim()).forEach(e=>n.add(e));const i=t.filter(e=>!n.has(e));return 0===i.length?e:`${e}\nexport { ${i.join(", ")} };`}(function(e){const t=[];let n=e;if(n=n.replace(/import\s*\{([^}]+)\}\s*from\s*(['"][^'"]+['"])\s*;?/g,(e,n,r)=>{const o=n.split(",").map(e=>e.trim()),s=[];for(const i of o){if(!i)continue;const e=i.match(/^(\w+)\s+as\s+(\w+)$/);if(e){const[,n,r]=e,o=`__raw_${r}`;s.push(`${n} as ${o}`),t.push(`const ${r} = __wrapReactiveArray(${o}, __ladrillos_componentId);`)}else{const e=`__raw_${i}`;s.push(`${i} as ${e}`),t.push(`const ${i} = __wrapReactiveArray(${e}, __ladrillos_componentId);`)}}return`import { ${s.join(", ")} } from ${r};`}),t.length>0){const e=n.split("\n");let r=-1;for(let t=0;t<e.length;t++){const n=e[t].trim();(n.startsWith("import ")||n.startsWith("import{"))&&(r=t)}r>=0&&(e.splice(r+1,0,"","// === Reactive Import Wrappers ===",...t,"// === End Reactive Import Wrappers ===",""),n=e.join("\n"))}return n}(o)),i=function(e){const t=/* @__PURE__ */new Set;for(const n of Te){const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");new RegExp(`(?:^|[\\s,{])${r}(?:\\s+as\\b|[\\s,}=;(])|\\b(?:let|const|var|function)\\s+${r}\\b`,"m").test(e)&&t.add(n)}return t}(o),a=function(e,t,n=/* @__PURE__ */new Set){const r=(e,t)=>n.has(e)?"":t;return`\n// === LadrillosJS Framework Helpers (auto-injected) ===\nconst __ladrillos_componentId = "${e||"anonymous"}";\nconst __ladrillos_componentUrl = "${t||"unknown"}";\n\n// Global event bus (shared across all components)\nif (!globalThis.__ladrillosEventBus) {\n globalThis.__ladrillosEventBus = {\n listeners: new Map(),\n componentListeners: new Map()\n };\n}\n\n// Global state change callbacks (for reactive array updates)\nif (!globalThis.__ladrillosStateCallbacks) {\n globalThis.__ladrillosStateCallbacks = new Map();\n}\n\n// Reactive array symbol\nconst __REACTIVE_ARRAY = Symbol.for("ladrillos-reactive-array");\n\n// Array mutation methods to intercept\nconst __ARRAY_METHODS = ["push", "pop", "shift", "unshift", "splice", "sort", "reverse", "fill", "copyWithin"];\n\n// Wrap an array in a reactive proxy\nconst __wrapReactiveArray = (arr, componentId) => {\n if (!Array.isArray(arr) || arr[__REACTIVE_ARRAY]) return arr;\n \n const onMutate = () => {\n const callback = globalThis.__ladrillosStateCallbacks?.get(componentId);\n if (callback) callback();\n };\n \n return new Proxy(arr, {\n get(target, key) {\n if (key === __REACTIVE_ARRAY) return true;\n const value = target[key];\n if (typeof key === "string" && __ARRAY_METHODS.includes(key) && typeof value === "function") {\n return (...args) => {\n const result = value.apply(target, args);\n onMutate();\n return result;\n };\n }\n if (Array.isArray(value)) return __wrapReactiveArray(value, componentId);\n return value;\n },\n set(target, key, value) {\n const index = parseInt(key, 10);\n const isIndex = !isNaN(index);\n const isLength = key === "length";\n target[key] = Array.isArray(value) ? __wrapReactiveArray(value, componentId) : value;\n if (isIndex || isLength) onMutate();\n return true;\n }\n });\n};\n\nconst __ladrillos_emit = (eventName, data) => {\n const listeners = globalThis.__ladrillosEventBus.listeners.get(eventName);\n if (!listeners || listeners.size === 0) return;\n for (const registration of listeners) {\n try {\n registration.callback(data);\n } catch (error) {\n console.error(\`[LadrillosJS] Error in event listener for "\${eventName}":\`, error);\n }\n }\n};\n${r("$emit","const $emit = __ladrillos_emit;")}\n\nconst __ladrillos_listen = (eventName, callback) => {\n const bus = globalThis.__ladrillosEventBus;\n let listeners = bus.listeners.get(eventName);\n if (!listeners) {\n listeners = new Set();\n bus.listeners.set(eventName, listeners);\n }\n const registration = { callback, componentId: __ladrillos_componentId };\n listeners.add(registration);\n\n // Track by component ID for cleanup\n let componentRegs = bus.componentListeners.get(__ladrillos_componentId);\n if (!componentRegs) {\n componentRegs = new Set();\n bus.componentListeners.set(__ladrillos_componentId, componentRegs);\n }\n componentRegs.add({ event: eventName, registration });\n\n // Return unsubscribe function\n return () => {\n listeners?.delete(registration);\n if (listeners?.size === 0) bus.listeners.delete(eventName);\n const compRegs = bus.componentListeners.get(__ladrillos_componentId);\n if (compRegs) {\n for (const reg of compRegs) {\n if (reg.registration === registration) {\n compRegs.delete(reg);\n break;\n }\n }\n if (compRegs.size === 0) bus.componentListeners.delete(__ladrillos_componentId);\n }\n };\n};\n${r("$listen","const $listen = __ladrillos_listen;")}\n\n// Global refs registry (shared across all components)\n// Each component gets its own Map, keyed by component ID\nif (!globalThis.__ladrillosRefs) {\n globalThis.__ladrillosRefs = new Map();\n}\n\n// Helper to wrap refs Map in Proxy for cleaner dot notation access\nconst __createRefsProxy = (map) => new Proxy(map, {\n get(target, prop, receiver) {\n if (prop in target) {\n const value = Reflect.get(target, prop, receiver);\n return typeof value === "function" ? value.bind(target) : value;\n }\n if (typeof prop === "string") return target.get(prop);\n return undefined;\n },\n set(target, prop, value) {\n if (typeof prop === "string") { target.set(prop, value); return true; }\n return false;\n },\n has(target, prop) {\n return typeof prop === "string" ? target.has(prop) || prop in target : prop in target;\n }\n});\n\n// Get or create refs Map for this component (wrapped in Proxy)\nif (!globalThis.__ladrillosRefs.has(__ladrillos_componentId)) {\n globalThis.__ladrillosRefs.set(__ladrillos_componentId, __createRefsProxy(new Map()));\n}\n\n// $refs for this component - supports both $refs.inputEl and $refs.get("inputEl")\nconst __ladrillos_refs = globalThis.__ladrillosRefs.get(__ladrillos_componentId);\n${r("$refs","const $refs = __ladrillos_refs;")}\n\n// Helper to resolve relative paths against component URL\nconst __resolvePath = (path) => {\n if (path.startsWith("http://") || path.startsWith("https://") || path.startsWith("/")) {\n return path.startsWith("/") ? new URL(path, window.location.origin).href : path;\n }\n return new URL(path, __ladrillos_componentUrl).href;\n};\n\n// Helper to convert filename to tag name\nconst __filenameToTagName = (path) => {\n const filename = path.split("/").pop()?.replace(/\\.[^.]+$/, "") || path;\n return filename.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\\s]+/g, "-").toLowerCase();\n};\n\n// registerComponent - Register a child component\nconst __ladrillos_registerComponent = async (name, path, useShadowDOM = true) => {\n const resolvedPath = __resolvePath(path);\n return globalThis.ladrillosjs.registerComponent({ name, path: resolvedPath, useShadowDOM });\n};\n${r("registerComponent","const registerComponent = __ladrillos_registerComponent;")}\n\n// registerComponents - Register multiple components at once\nconst __ladrillos_registerComponents = async (configs) => {\n const resolvedConfigs = configs.map(config => ({\n ...config,\n path: __resolvePath(config.path)\n }));\n return globalThis.ladrillosjs.registerComponents(resolvedConfigs);\n};\n${r("registerComponents","const registerComponents = __ladrillos_registerComponents;")}\n\n// $use - Shorthand for registerComponent with auto-derived tag name\nconst __ladrillos_use = async (path, useShadowDOM = true) => {\n const tagName = __filenameToTagName(path);\n return __ladrillos_registerComponent(tagName, path, useShadowDOM);\n};\n${r("$use","const $use = __ladrillos_use;")}\n\n// === End Framework Helpers ===\n\n`}(t,n||e.src,i),c=new Blob([a+s],{type:"text/javascript"}),l=URL.createObjectURL(c);try{return await(0,eval)(`import("${l}")`)}finally{URL.revokeObjectURL(l)}}catch(r){throw r}}const ke=/* @__PURE__ */new Map;async function Oe(e){if(Ae.has(e))return Ae.get(e);const t=(async()=>{try{return await(0,eval)(`import("${e}")`)}catch(t){throw t}})();return Ae.set(e,t),t}function Me(e,t){return t&&Array.isArray(e)?J(e,t):e}async function De(n,r,o,s,i,a,c){if("module"!==n.type)throw new Error('executeModuleScriptWithReactivity only handles type="module" scripts');const l=n.content,u=await async function(e,t,n){const r=function(e){const t=[],n=/import\s+(?:(\{[^}]+\})|(\*\s+as\s+\w+)|(\w+)(?:\s*,\s*(\{[^}]+\}))?)?\s*(?:from\s+)?['"]([^'"]+)['"]/g;let r;for(;null!==(r=n.exec(e));){const[e,n,o,s,i,a]=r,c={statement:e,specifier:a,imports:[],isDefault:!1,isNamespace:!1,isSideEffect:!1};if(n||o||s||(c.isSideEffect=!0),s&&(c.isDefault=!0,c.imports.push({imported:"default",local:s})),o){c.isNamespace=!0;const e=o.replace(/\*\s+as\s+/,"").trim();c.imports.push({imported:"*",local:e})}const l=n||i;if(l){const e=l.slice(1,-1).split(",").map(e=>e.trim()).filter(Boolean);for(const t of e){const e=t.match(/(\w+)\s+as\s+(\w+)/);c.imports.push(e?{imported:e[1],local:e[2]}:{imported:t,local:t})}}t.push(c)}return t}(e),o={};for(const i of r){if(i.isSideEffect){const e=Ne(i.specifier)?new URL(i.specifier,t).href:i.specifier;await Oe(e);continue}const e=Ne(i.specifier)?new URL(i.specifier,t).href:i.specifier;try{const t=await Oe(e);for(const e of i.imports){let r;r="*"===e.imported?t:"default"===e.imported?t.default:t[e.imported],o[e.local]=Me(r,n)}}catch(s){}}return o}(l,r,a),f=function(e){return e.replace(/import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]+\})?\s+from\s+)?['"][^'"]+['"]\s*;?/g,"").trim()}(l),{variables:p,functions:d}=function(e){const t=[],n=[],r=e.replace(/`[^`]*`/g,e=>" ".repeat(e.length)).replace(/"(?:[^"\\]|\\.)*"/g,e=>" ".repeat(e.length)).replace(/'(?:[^'\\]|\\.)*'/g,e=>" ".repeat(e.length)).replace(/\/\*[\s\S]*?\*\//g,e=>" ".repeat(e.length)).replace(/\/\/[^\n]*/g,e=>" ".repeat(e.length));let o=0,s=0;for(;s<r.length;){const e=r[s];if("{"!==e)if("}"!==e){if(0===o){const e=r.slice(s).match(/^(?:async\s+)?function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(e){n.push(e[1]),s+=e[0].length;continue}const o=r.slice(s).match(/^(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(o){t.push(o[1]),s+=o[0].length;continue}}s++}else o--,s++;else o++,s++}return{variables:t,functions:n}}(f),h=function(e,t){if(0===t.length)return e;const n=[];let r=e.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g,e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`));for(const s of t){const e=new RegExp(`\\b(let|const|var)\\s+(${Pe(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} =`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${Pe(s)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`__state__.${s}`)}let o=r;for(let s=0;s<n.length;s++)o=o.replace(`__STRING_PLACEHOLDER_${s}__`,n[s]);return o}(f,p),m=Object.keys(u),g=Object.values(u),_=`\n "use strict";\n return (async () => {\n ${h}\n ${d.length>0?`return { ${d.join(", ")} };`:"return {};"}\n })();\n `;try{const n=["console","alert","Math","JSON","Date","Array","Object","String","Number","Boolean","Promise","setTimeout","setInterval","clearTimeout","clearInterval"],a=n.map(e=>globalThis[e]),l=["$refs","__state__","$host"],u=[s||/* @__PURE__ */new Map,i||{},c],f=te(r),p=[f.registerComponent,f.registerComponents,f.$use],d=t(o||"anonymous"),h=[d.$emit,d.$listen],y={...globalThis.ladrillosjs||{},registerComponent:f.registerComponent,registerComponents:f.registerComponents},b={registerComponent:f.registerComponent,registerComponents:f.registerComponents,$use:f.$use,$emit:d.$emit,$listen:d.$listen,ladrillosjs:y},v=new Set(m),w=[...m],E=m.map((e,t)=>e in b?b[e]:g[t]),A=(e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];v.has(r)||(v.add(r),w.push(r),E.push(t[n]))}};A(n,a),A(ne,p),A(e,h),A(l,u),A(["ladrillosjs"],[y]);const $=new Function(...w,_),C=await $(...E);return{...i||{},...C||{}}}catch(y){throw y}}function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Fe="$bind",je="$ref",Ue=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]+)$/,ze=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,We=/^\(|\)$/g;function Be(e){return e.replace(/\$/g,"\\$")}function He(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return e===t;if("object"!=typeof e)return e===t;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);if(o.length!==s.length)return!1;for(const i of o)if(n[i]!==r[i])return!1;return!0}function Ze(e){const t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t}function qe(e,t){const n=Array.from(e.querySelectorAll(`[${Be(je)}]`));for(const r of n){const e=r.getAttribute(je);e&&(t.refs.set(e,r),r.removeAttribute(je))}}function Xe(e,t){const n=Array.from(e.querySelectorAll("for"));for(const r of n){if(!r.parentNode)continue;if(Ge(r))continue;const n=r.getAttribute("each")||r.getAttribute("of")||"";if(!n)continue;let o=Je(n);if(!o)continue;const s=r.getAttribute("key")||r.getAttribute("track-by")||o.key,i=Ve(r);if(!i)continue;const a=document.createComment(` <for> ${n} `),c=r.parentElement||e;c.insertBefore(a,r),r.remove(),t.loops.push({template:i,expression:n,itemName:o.item,indexName:o.index,arrayName:o.array,keyAttribute:s,placeholder:a,renderedElements:[],originalParent:c})}}function Ve(e){const t=[];for(const r of Array.from(e.childNodes))(r.nodeType!==Node.TEXT_NODE||r.textContent?.trim())&&t.push(r);if(0===t.length)return null;if(1===t.length&&t[0].nodeType===Node.ELEMENT_NODE)return t[0];const n=document.createElement("span");n.style.display="contents";for(const r of Array.from(e.childNodes))n.appendChild(r);return n}function Ge(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function Je(e){const t=e.match(Ue);if(!t)return null;let n,[,r,o]=t;r=r.trim(),o=o.trim();const s=o.match(/\s+track\s+by\s+(.+)$/i);s&&(n=s[1].trim(),o=o.slice(0,s.index).trim());const i=r.replace(We,"").trim(),a=i.match(ze);let c,l,u;return a?(c=i.replace(ze,"").trim(),l=a[1]?.trim(),u=a[2]?.trim()):c=i,{item:c,index:l||u,key:n,array:o}}function Ye(e,t){const n=Array.from(e.querySelectorAll("if"));for(const r of n){if(Ge(r))continue;const n=[],o=Ze(r.getAttribute("condition")||""),s=document.createComment(` <if> ${o} `),i=r.parentElement||e,a=r.nextSibling;i.insertBefore(s,r),n.push(Ke(r,o,"if",s,i,a));let c=r.nextElementSibling;for(;c;){const e=c.tagName;if("ELSE-IF"!==e){if("ELSE"===e){n.push(Ke(c,"","else",s,i,c.nextSibling)),c.remove();break}break}{const e=Ze(c.getAttribute("condition")||""),t=c.nextElementSibling;n.push(Ke(c,e,"else-if",s,i,c.nextSibling)),c.remove(),c=t}}r.remove();for(const e of n)e.group=n;t.conditionals.push(n)}}function Ke(e,t,n,r,o,s){return e.removeAttribute("condition"),e.style.display="contents",{element:e,condition:t,type:n,placeholder:r,group:[],originalParent:o,nextSibling:s}}function Qe(e,t){const n=Array.from(e.querySelectorAll("show"));for(const r of n){if(!r.parentNode)continue;if(Ge(r))continue;const e=Ze(r.getAttribute("condition")||""),n=r;n.style.display="contents",t.showElements.push({element:n,expression:e,originalDisplay:"contents"}),r.removeAttribute("condition")}}function et(e,t){const n=Array.from(e.querySelectorAll(`[${Be(Fe)}]`));for(const r of n){const e=r.getAttribute(Fe);if(!e)continue;if(tt(r))continue;const n=e.split("."),o=r.hasAttribute("contenteditable");t.twoWayBindings.push({element:r,path:n,raw:e,isContentEditable:o}),r.removeAttribute(Fe)}}function tt(e,t){return Ge(e)}function nt(e,t,n){const r=n(e.arrayName,t);if(!r||null==(o=r)||!Array.isArray(o)&&"function"!=typeof o[Symbol.iterator]&&"object"!=typeof o){for(const t of e.renderedElements)t.remove();return e.renderedElements=[],void(e.previousItems=[])}var o;const s=Array.from(r),i=e.previousItems||[],a=e.renderedElements;e.keyGetter||(e.keyGetter=function(e,t){if(!e)return(e,t)=>t;const n=e.startsWith(t+".")?e.slice(t.length+1).split("."):e.split(".");return e=>{let t=e;for(const r of n){if(null==t)return;t=t[r]}return t}}(e.keyAttribute,e.itemName));const c=(r,o)=>{const s=e.template.cloneNode(!0);return st(s,rt(t,e,r,o),n),s};if(e.keyAttribute){const r=function(e,t,n){const r=[],o=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(let f=0;f<e.length;f++)o.set(n(e[f],f),f);for(let f=0;f<t.length;f++)s.set(n(t[f],f),f);const i=/* @__PURE__ */new Set;for(let f=0;f<e.length;f++){const t=n(e[f],f);s.has(t)||r.push({type:"remove",oldIndex:f,key:t,item:e[f]})}for(let f=0;f<t.length;f++){const e=n(t[f],f);o.has(e)||(r.push({type:"insert",newIndex:f,key:e,item:t[f]}),i.add(f))}const a=[];for(let f=0;f<e.length;f++){const t=n(e[f],f),r=s.get(t);void 0!==r&&a.push(r)}const c=function(e){if(0===e.length)return[];const t=e.length,n=new Array(t).fill(1),r=new Array(t).fill(-1);let o=1,s=0;for(let c=1;c<t;c++){for(let t=0;t<c;t++)e[t]<e[c]&&n[t]+1>n[c]&&(n[c]=n[t]+1,r[c]=t);n[c]>o&&(o=n[c],s=c)}const i=[];let a=s;for(;-1!==a;)i.unshift(a),a=r[a];return i}(a),l=new Set(c.map(e=>a[e]));let u=0;for(const f of a){for(;u<e.length&&!s.has(n(e[u],u));)u++;if(u<e.length){const t=n(e[u],u),o=u,i=s.get(t);l.has(i)||r.push({type:"move",oldIndex:o,newIndex:i,key:t,item:e[o]}),u++}}for(let f=0;f<t.length;f++){const s=n(t[f],f),i=o.get(s);if(void 0!==i){const n=t[f];He(e[i],n)||r.push({type:"update",oldIndex:i,newIndex:f,key:s,item:n})}}return r}(i,s,e.keyGetter),o=/* @__PURE__ */new Map;for(let t=0;t<i.length;t++){const n=e.keyGetter(i[t],t);a[t]&&o.set(n,a[t])}const l=new Array(s.length);for(const e of r)if("remove"===e.type&&void 0!==e.key){const t=o.get(e.key);t&&(t.remove(),o.delete(e.key))}for(let i=0;i<s.length;i++){const r=s[i],a=e.keyGetter(r,i),u=o.get(a);u?(ot(u,rt(t,e,r,i),n),l[i]=u):l[i]=c(r,i)}const u=document.createDocumentFragment();for(const e of l)u.appendChild(e);e.placeholder.parentNode?.insertBefore(u,e.placeholder.nextSibling),e.renderedElements=l}else{const r=Math.min(i.length,s.length);for(let i=0;i<r;i++){const r=rt(t,e,s[i],i);ot(a[i],r,n)}for(let e=s.length;e<i.length;e++)a[e]?.remove();const o=document.createDocumentFragment();for(let e=i.length;e<s.length;e++){const t=c(s[e],e);o.appendChild(t),a[e]=t}if(o.childNodes.length>0){const t=a[r-1]?.nextSibling||e.placeholder.nextSibling;e.placeholder.parentNode?.insertBefore(o,t)}e.renderedElements=a.slice(0,s.length)}e.previousItems=[...s]}function rt(e,t,n,r){const o=e.__scriptContent,s={...e,[t.itemName]:n,__reactiveState__:e,__scriptContent__:o||"",__componentUrl__:e.__componentUrl||""};return t.indexName&&(s[t.indexName]=r),s}function ot(e,t,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let o;for(;o=r.nextNode();){const e=o.__originalTemplate;e&&(o.textContent=e.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return String(o??"")}))}for(const s of Array.from(e.attributes)){const e=s.__originalTemplate;e&&(s.value=e.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return null!==o&&"object"==typeof o?JSON.stringify(o):String(o??"")}))}for(const s of Array.from(e.children))ot(s,t,n)}function st(e,t,n){for(const i of Array.from(e.attributes))if(i.value.includes("{")){i.__originalTemplate=i.value;const e=i.value.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return null!==o&&"object"==typeof o?JSON.stringify(o):String(o??"")});i.value=e}!function(e,t){for(const n of M){const r=e.getAttribute(n);if(r){e.removeAttribute(n);const o=n.slice(2),s=it(r,t);s&&e.addEventListener(o,s)}}!function(e,t){const n=Array.from(e.attributes).filter(e=>q(e.name));for(const r of n){const n=B(r.name);if(!n)continue;const o=r.value;e.removeAttribute(r.name);const s=it(o,t);if(!s)continue;const i=Z(s,n),a=H(n.eventModifiers);e.addEventListener(n.eventName,i,a)}}(e,t)}(e,t);const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=[];let s;for(;s=r.nextNode();)s.textContent?.includes("{")&&o.push(s);for(const i of o)i.__originalTemplate=i.textContent,i.textContent=i.textContent.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return String(o??"")});for(const i of Array.from(e.children))st(i,t,n)}function it(e,n){try{const r=n.__reactiveState__,o=n.__scriptContent__||"",s=Object.keys(n).filter(e=>!e.startsWith("__")),i=r?Object.keys(r).filter(e=>!e.startsWith("__")&&"function"!=typeof r[e]):[],a=s.filter(e=>!i.includes(e)&&"function"!=typeof n[e]),c=o.trim().length>0,l=s.filter(e=>"function"==typeof n[e]),u=r&&!0===r.__hasModuleScripts;let f="",p="";u?p=l.length>0?`const { ${l.join(", ")} } = context;`:"":c?f=pe(o,[]):p=l.length>0?`const { ${l.join(", ")} } = context;`:"";const d=a.length>0?`const { ${a.join(", ")} } = context;`:"",h=r&&i.length>0?"reactiveState":"context",m=i.length>0?`let { ${i.join(", ")} } = ${h};`:"",g=!u&&r&&i.length>0?i.map(e=>`reactiveState.${e} = ${e};`).join(" "):"",_=t(n.__componentId__||r?.__componentId||"anonymous"),y=new Function("event","context","reactiveState","$emit","$listen",`"use strict";\n ${d}\n ${m}\n ${p}\n ${f}\n ${e};\n ${g}`);return t=>{try{y(t,n,r,_.$emit,_.$listen)}catch(o){C(`Error in loop event handler: ${e}`,null,o)}}}catch(r){return null}}function at(e,t,n){for(const r of e)r.element.parentNode&&r.element.remove();for(const r of e){let e=!1;if("else"===r.type)e=!0;else{const o=n(r.condition,t);e=Boolean(o)}if(e){r.placeholder.parentNode?.insertBefore(r.element,r.placeholder.nextSibling);break}}}function ct(e,t,n,r){const o=e.element,{raw:s,path:i,isContentEditable:a}=e,c=n(s,t);lt(o,c,a);const l=i[0];r.has(l)||r.set(l,[]),r.get(l).push({element:o,path:i,isContentEditable:a}),s===l||r.has(s)||r.set(s,[]),s!==l&&r.get(s).push({element:o,path:i,isContentEditable:a});const u=function(e){if(e instanceof HTMLSelectElement)return"change";if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();if("checkbox"===t||"radio"===t)return"change"}return"input"}(o);let f=!1;o.__isUpdatingFromState=()=>f,o.__setUpdatingFromState=e=>{f=e},o.addEventListener(u,()=>{if(f)return;const e=function(e,t){if(t)return e.textContent||"";if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();return"checkbox"===t?e.checked:"number"===t||"range"===t?e.valueAsNumber:e.value}return e instanceof HTMLSelectElement?e.multiple?Array.from(e.selectedOptions).map(e=>e.value):e.value:e instanceof HTMLTextAreaElement?e.value:e.value??""}(o,a);!function(e,t,n){let r=e;for(let o=0;o<t.length-1;o++){const e=t[o];e in r&&"object"==typeof r[e]||(r[e]={}),r=r[e]}r[t[t.length-1]]=n}(t,i,e)})}function lt(e,t,n){if(n)e.textContent=String(t??"");else{if(e instanceof HTMLInputElement)return void("checkbox"===e.type.toLowerCase()?e.checked=Boolean(t):e.value=String(t??""));e.value=e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?String(t??""):t}}const ut=[],ft=/* @__PURE__ */new Set;let pt=!1,dt=!1,ht=0;const mt=Promise.resolve();function gt(){dt=!1,pt=!0,ut.sort((e,t)=>(e.id??0)-(t.id??0));try{for(const t of ut)if(!1!==t.active)try{t()}catch(e){C("Error in scheduled update",null,e)}}finally{ut.length=0,ft.clear(),pt=!1}}const _t=/* @__PURE__ */new Map;function yt(e,t){const{tagName:r,template:o,scripts:s,externalScripts:i,externalStyles:a,styles:c,sourcePath:l,templateBindings:u=[]}=e,f=me(s.map(e=>e.content).join("\n")),p=[.../* @__PURE__ */new Set([...f,...u])];class d extends HTMLElement{static get observedAttributes(){return p}state={};_root=null;_initialized=!1;_componentId=`${r}-${Math.random().toString(36).slice(2)}`;_directives=null;_evaluator=null;_updateBoundInputs=null;constructor(){super()}async connectedCallback(){if(this._initialized)return;this._initialized=!0,w={tagName:r,sourcePath:l,instanceId:this._componentId};const e=this.innerHTML,n=document.createDocumentFragment();for(;this.firstChild;)n.appendChild(this.firstChild);this.__originalHTML=e,this.__originalChildren=n,this._root=t?this.shadowRoot??this.attachShadow({mode:"open"}):this;const{bindings:f}=((e,t)=>{const n=document.createElement("template");n.innerHTML=t,x(n.content),e.innerHTML="",e.appendChild(n.content);const r=I(e);for(const o of T(e))r.push(...I(o));return{bindings:r}})(this._root,o);((e,t,n)=>{if(!t)return;const r=document.createElement("style");r.textContent=t,n?e.appendChild(r):document.head.appendChild(r)})(this._root,c,t);const p=this._getAttributeOverrides(),d=s.filter(e=>"module"!==e.type),h=s.some(e=>"module"===e.type),m=new Proxy(/* @__PURE__ */new Map,{get(e,t,n){if(t in e){const r=Reflect.get(e,t,n);return"function"==typeof r?r.bind(e):r}if("string"==typeof t)return e.get(t)},set:(e,t,n)=>"string"==typeof t&&(e.set(t,n),!0),has:(e,t)=>"string"==typeof t&&e.has(t)||t in e});if(function(e,t){const n=Array.from(e.querySelectorAll(`[${Be(je)}]`));for(const r of n){const e=r.getAttribute(je);e&&t.set(e,r)}}(this._root,m),a&&a.length>0&&await async function(e,t,n){for(const o of e)if(n&&t)try{let e=ke.get(o.href);if(!e){const t=await fetch(o.href);if(!t.ok)continue;e=await t.text(),ke.set(o.href,e)}const n=document.createElement("style");n.textContent=e,n.setAttribute("data-external-href",o.href),t.insertBefore(n,t.firstChild)}catch(r){}else{if(document.querySelector(`link[href="${o.href}"]`))continue;await new Promise(e=>{const t=document.createElement("link");t.rel=o.rel||"stylesheet",t.href=o.href,t.onload=()=>e(),t.onerror=()=>{e()},document.head.appendChild(t)})}}(a,this._root,t),i.length>0&&await async function(e){const t=e.filter(e=>e.external);for(const r of t)try{await Ie(r)}catch(n){}}(i),this.state=await async function(e,t,n,r={},o,s=!1,i,a,c,l=[]){const u=ae(e),f={},p=t.map(e=>e.content).join("\n");for(const[h,m]of Object.entries(r))f[h]=m;f.__scriptContent=p,f.__componentUrl=i,f.__componentId=a;const d=K(f,n,(e,t)=>ve(e,t),o);for(const h of t)he(h.content,d,i,a,u,c,l);return u.__state=d,u.__scriptContent=p,u.__componentUrl=i,u.__componentId=a,s||(ce(e,d,p,u),we(n,d)),d}(this._root,d,f,p,()=>this._updateDirectives(),h,l,this._componentId,m,u),"undefined"!=typeof globalThis&&(globalThis.__ladrillosStateCallbacks||(globalThis.__ladrillosStateCallbacks=/* @__PURE__ */new Map),globalThis.__ladrillosStateCallbacks.set(this._componentId,()=>this._updateDirectives())),l){this.state.__suspendReactivity=!0;try{const e=await async function(e,t,n,r,o,s,i,a){const c={},l=e.filter(e=>"module"===e.type),u=t.filter(e=>"module"===e.type),f=t.filter(e=>"module"!==e.type);for(const d of f)try{await Ie(d,r,n)}catch(p){}for(const d of u)try{const e=await Ie(d,r,n);if(e&&"object"==typeof e)for(const[t,n]of Object.entries(e))"default"!==t&&(c[t]=n,s&&(s[t]=n))}catch(p){}for(const d of l)try{const e=await De(d,n,r,o,s,i,a);Object.assign(c,e)}catch(p){}return c}(s,i,l,this._componentId,m,this.state,()=>this._updateDirectives(),this);(h||i.length>0)&&(this.state.__hasModuleScripts=!0);for(const[t,n]of Object.entries(e))"function"==typeof n&&(this.state[t]=n)}finally{this.state.__suspendReactivity=!1}}if(h&&function(e,t,n){const r=ae(e);ce(e,n,r.__scriptContent||"",r),we(t,n)}(this._root,f,this.state),this._evaluator=be,this._directives=function(e,t){const n={loops:[],conditionals:[],twoWayBindings:[],refs:t,showElements:[]},r=[e,...T(e)];for(const o of r)qe(o,n),Xe(o,n),Qe(o,n),et(o,n),Ye(o,n);return x(e),n}(this._root,m),"undefined"!=typeof globalThis){globalThis.__ladrillosRefs||(globalThis.__ladrillosRefs=/* @__PURE__ */new Map);let e=globalThis.__ladrillosRefs.get(this._componentId);e||(e=/* @__PURE__ */new Map,globalThis.__ladrillosRefs.set(this._componentId,e));for(const[t,n]of this._directives.refs)e.set(t,n)}this.refs=this._directives.refs,this.__refs=this._directives.refs,this._updateDirectives(),this._directives.twoWayBindings.length>0&&(this._updateBoundInputs=function(e,t,n){const r=/* @__PURE__ */new Map;for(const o of e)ct(o,t,n,r);return e=>{!function(e,t,n,r){const o=r?[r]:Array.from(e.keys());for(const s of o){const r=e.get(s);if(r)for(const e of r){const{element:r,path:o,isContentEditable:s}=e,i=n(o.join("."),t),a=r.__setUpdatingFromState;a&&a(!0),lt(r,i,s),a&&queueMicrotask(()=>a(!1))}}}(r,t,n,e)}}(this._directives.twoWayBindings,this.state,this._evaluator)),this.dispatchEvent(new CustomEvent("ladrillos:ready",{bubbles:!0,composed:!0,detail:{state:this.state,refs:this._directives.refs}}))}disconnectedCallback(){!function(e){const t=Ee.get(e);if(t){for(const e of t)URL.revokeObjectURL(e);Ee.delete(e)}}(this._componentId),n(this._componentId),function(e){const t=_t.get(e);t&&(t.active=!1,_t.delete(e))}(this._componentId),"undefined"!=typeof globalThis&&globalThis.__ladrillosStateCallbacks?.delete(this._componentId),this._initialized=!1}attributeChangedCallback(e,t,n){if(t===n)return;if(!this._initialized)return;const r=this._parseAttributeValue(n);this.state[e]=r}adoptedCallback(){}_updateDirectives(){this._directives&&this._evaluator&&function(e,t){let n=_t.get(e);n||(n=function(){const e=()=>{t()};return e.id=++ht,e.active=!0,e}(),_t.set(e,n)),function(e){void 0===e.id&&(e.id=++ht),ft.has(e.id)||(ft.add(e.id),ut.push(e),pt||dt||(dt=!0,mt.then(gt)))}(n)}(this._componentId,()=>{this._performDirectiveUpdates()})}_performDirectiveUpdates(){this._directives&&this._evaluator&&(this._directives.loops.length>0&&function(e,t,n){for(const r of e)nt(r,t,n)}(this._directives.loops,this.state,this._evaluator),this._directives.conditionals.length>0&&function(e,t,n){for(const r of e)at(r,t,n)}(this._directives.conditionals,this.state,this._evaluator),this._directives.showElements.length>0&&function(e,t,n){for(const r of e){const e=n(r.expression,t),o=Boolean(e);r.element.style.display=o?r.originalDisplay:"none"}}(this._directives.showElements,this.state,this._evaluator),this._updateBoundInputs&&this._updateBoundInputs())}_getAttributeOverrides(){const e={},t=[];for(const r of Array.from(this.attributes))this._isReservedAttribute(r.name)?r.value&&""!==r.value.trim()&&t.push(r.name):e[r.name]=this._parseAttributeValue(r.value);const n=t.filter(e=>!u.includes(e));return n.length>0&&n.map(e=>{const t={title:"heading",class:"className",style:"customStyle",id:"componentId",hidden:"isHidden"}[e]||`my${e.charAt(0).toUpperCase()}${e.slice(1)}`;return`"${e}" → try "${t}"`}),e}_isReservedAttribute(e){return!u.includes(e)&&(["id","class","style","slot","part","is","tabindex","title","lang","dir","hidden","draggable","contenteditable"].includes(e.toLowerCase())||e.startsWith("data-"))}_parseAttributeValue(e){if(null===e)return null;if(""===e)return!0;if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);if(!isNaN(t)&&""!==e.trim())return t;try{const t=e.trim();if(t.startsWith("[")||t.startsWith("{"))return JSON.parse(t)}catch{}return e}get root(){return this._root}}return d}function bt(e,t){const{tagName:n}=e;if(!customElements.get(n)){const r=yt(e,t);customElements.define(n,r)}}const vt=/* @__PURE__ */new Map;let wt;const Et=/* @__PURE__ */new Map,At=/* @__PURE__ */new Set,$t=/* @__PURE__ */new Map;function Ct(e,t,n,r){var o;$t.set(e,{name:e,absolutePath:t,useShadowDOM:n,strategy:r}),customElements.get(e)||customElements.define(e,(o=e,class extends HTMLElement{teardown;isLoading=!1;isUpgraded=!1;connectedCallback(){if(this.hasAttribute("eager"))return void this.triggerLoad();const e=$t.get(o);e?this.teardown=e.strategy(()=>this.triggerLoad(),this):this.triggerLoad()}disconnectedCallback(){this.teardown?.(),this.teardown=void 0}async triggerLoad(){if(!this.isLoading&&!this.isUpgraded){this.isLoading=!0,this.teardown?.(),this.teardown=void 0;try{const e=await St(o);this.isUpgraded=!0,this.upgradeToRealComponent(e)}catch(e){C(`Failed to load lazy component "<${o}>"`,{tagName:o}),this.isLoading=!1}}}upgradeToRealComponent(e){const t=document.createElement(e);for(const n of Array.from(this.attributes))"eager"!==n.name&&"tabindex"!==n.name&&t.setAttribute(n.name,n.value);for(;this.firstChild;)t.appendChild(this.firstChild);this.parentNode?this.parentNode.replaceChild(t,this):C("No parent node for placeholder - cannot upgrade lazy component",{tagName:o})}}))}async function St(e){const t=function(e){return`${e}--loaded`}(e);if(At.has(e))return t;if(vt.has(e))return await vt.get(e),t;const n=$t.get(e);if(!n)throw new Error(`Lazy component "${e}" not registered`);const r=(async()=>{const r=await u(n.absolutePath);if(!r)throw new Error(`Failed to fetch component source for "${e}"`);const o=await s(r.source,e,r.resolvedPath);wt[e]=o;const i=yt(o,n.useShadowDOM);return customElements.get(t)||customElements.define(t,i),At.add(e),Et.set(e,{component:o,useShadowDOM:n.useShadowDOM}),o})();vt.set(e,r);try{return await r,t}finally{vt.delete(e)}}function Nt(e){return $t.has(e)||At.has(e)}async function Rt(e){return $t.has(e)&&await St(e),wt[e]}const xt=new class{components;constructor(){this.components={},wt=this.components}async registerComponent(e,t,n=!0,r=!1){if(this.components[e])return;const o=new URL(t,window.location.href).href;if(r)Ct(e,o,n,!0===r?v:r);else try{const t=await u(o);if(!t)throw new Error(`Failed to fetch component source from ${o}`);const r=await s(t.source,e,t.resolvedPath);this.components[e]=r,bt(r,n)}catch(i){C(`Error registering component "<${e}>"`,{tagName:e,sourcePath:t},i)}}async registerComponents(e){const t=Array.isArray(e)?e:Object.entries(e).map(([e,t])=>"string"==typeof t?{name:e,path:t}:{name:e,...t}),n={success:[],failed:[],skipped:[]},r=[],o=[];for(const s of t){if(this.components[s.name]){n.skipped.push(s.name);continue}const e=new URL(s.path,window.location.href).href,t={...s,absolutePath:e};s.lazy?r.push(t):o.push(t)}for(const s of r)try{Ct(s.name,s.absolutePath,s.useShadowDOM??!0,!0===s.lazy?v:s.lazy),n.success.push(s.name)}catch(c){n.failed.push({name:s.name,error:c instanceof Error?c:new Error(String(c))})}if(0===o.length)return n;const i=await Promise.allSettled(o.map(async e=>({config:e,result:await u(e.absolutePath)}))),a=await Promise.allSettled(i.map(async(e,t)=>{if("rejected"===e.status)throw e.reason;const{config:n,result:r}=e.value;if(!r)throw new Error(`Failed to fetch component source from ${n.absolutePath}`);return{config:n,component:await s(r.source,n.name,r.resolvedPath)}}));for(let s=0;s<a.length;s++){const e=a[s],t=o[s];if("rejected"===e.status){n.failed.push({name:t.name,error:e.reason instanceof Error?e.reason:new Error(String(e.reason))}),C(`Error registering component "${t.name}"`,{tagName:t.name,sourcePath:t.path},e.reason);continue}const{component:r}=e.value,i=t.useShadowDOM??!0;this.components[t.name]=r;try{bt(r,i),n.success.push(t.name)}catch(c){n.failed.push({name:t.name,error:c instanceof Error?c:new Error(String(c))}),delete this.components[t.name]}}return n}async loadLazyComponent(e){return Rt(e)}},Lt=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,ladrillos:xt},Symbol.toStringTag,{value:"Module"}));export{ie as $,E,y as a,_ as b,g as c,m as d,oe as e,xt as f,$ as g,v as h,Rt as i,Nt as j,b as l,se as r,c as s};
|
|
2
|
+
//# sourceMappingURL=shared-Cce5mWkr.js.map
|