ladrillosjs 2.0.0-rc.7 → 2.0.0
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/README.md +171 -16
- package/dist/core/cache/expressionCache.d.ts +5 -70
- package/dist/core/component/loader.d.ts +1 -1
- package/dist/core/configure.d.ts +24 -0
- package/dist/core/diff/listDiff.d.ts +16 -0
- package/dist/core/html/controlTagEscape.d.ts +47 -0
- package/dist/core/js/moduleExecutor.d.ts +19 -0
- package/dist/core/js/scriptParser.d.ts +35 -1
- package/dist/core.d.ts +2 -2
- package/dist/core.dev.js +12 -0
- package/dist/core.dev.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/events.dev.js +2 -0
- package/dist/events.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.dev.js +22 -0
- package/dist/index.dev.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lazy.dev.js +2 -0
- package/dist/lazy.js +1 -1
- package/dist/shared-CMbR-Hhy.js +3 -0
- package/dist/shared-CMbR-Hhy.js.map +1 -0
- package/dist/shared-DqWGO1vN.js +2 -0
- package/dist/{shared-D-P0qKQY.js.map → shared-DqWGO1vN.js.map} +1 -1
- package/dist/shared-R1SSiaIW.dev.js +6785 -0
- package/dist/shared-R1SSiaIW.dev.js.map +1 -0
- package/dist/shared-Sk_U4mcq.dev.js +161 -0
- package/dist/shared-Sk_U4mcq.dev.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/utils/devWarnings.d.ts +24 -3
- package/dist/utils/directives.d.ts +10 -0
- package/dist/utils/jsevents.d.ts +5 -0
- package/dist/utils/sandbox.d.ts +11 -0
- package/dist/utils/stateTransform.d.ts +58 -0
- package/package.json +22 -8
- package/dist/core/reactivity/dependencyTracker.d.ts +0 -120
- package/dist/shared-18P4lj9w.js +0 -2
- package/dist/shared-18P4lj9w.js.map +0 -1
- package/dist/shared-D-P0qKQY.js +0 -2
- package/dist/shared-mjNRZBte.js +0 -3
- package/dist/shared-mjNRZBte.js.map +0 -1
package/dist/shared-mjNRZBte.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,i as t,r as n}from"./shared-D-P0qKQY.js";var r=Object.defineProperty,o=(e,t)=>{let n={};for(var o in e)r(n,o,{get:e[o],enumerable:!0});return t||r(n,Symbol.toStringTag,{value:"Module"}),n},s=/{([^}]+)}/g;function i(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 a(e){return{registerComponent:function(t,n,r=!0,o=!1){const s=i(n,e);return Bt.registerComponent(t,s,r,o)},registerComponents:function(t){const n=Array.isArray(t)?t.map(t=>({...t,path:i(t.path,e)})):Object.entries(t).map(([t,n])=>"string"==typeof n?{name:t,path:i(n,e)}:{name:t,...n,path:i(n.path,e)});return Bt.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=i(t,e);return Bt.registerComponent(o,s,n,r)}}}var c=["registerComponent","registerComponents","$use"],l=a(window.location.href),u=l.registerComponent,f=l.registerComponents,p=l.$use,d=null;function h(){return d}var m=/* @__PURE__ */function(e){return 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}({}),g=null;function _(e){g=e}function y(e,t,n){const r=function(e,t){return`${e}${function(e){const t=void 0!==e?e:d;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)}`}(e,t);"undefined"!=typeof window&&"undefined"!=typeof console&&console,function(e,t){if(g)try{const n=e instanceof Error?e:new Error(String(e));g(n,t??null)}catch{}}(n instanceof Error?n:new Error(r,void 0!==n?{cause:n}:void 0),t)}function b(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)}var v=/* @__PURE__ */new Map,w=Symbol("reactive-array"),E=["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"];function A(e,t){return e[w]?e:new Proxy(e,{get(e,n){if(n===w)return!0;const r=e[n];return"string"==typeof n&&E.includes(n)&&"function"==typeof r?(...n)=>{const o=n.map(e=>Array.isArray(e)?A(e,t):e),s=r.apply(e,o);return t(),s}:Array.isArray(r)?A(r,t):r},set(e,n,r){const o=!isNaN("string"==typeof n?parseInt(n,10):NaN),s="length"===n,i=Array.isArray(r)?A(r,t):r;return e[n]===i||(e[n]=i,(o||s)&&t()),!0},deleteProperty(e,n){const r=delete e[n];return r&&t(),r}})}function $(e,t){for(const n of Object.keys(e)){const r=e[n];Array.isArray(r)?e[n]=A(r,t):r&&"object"==typeof r&&!Array.isArray(r)&&$(r,t)}return e}function S(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)N(e.raw,o)&&n.get(o).add(r);return n}(t,Object.keys(e));return $(e,()=>{r&&r()}),new Proxy(e,{get:(e,t)=>e[t],set(e,s,i){const a=!(s in e);return!a&&e[s]===i||(e[s]=Array.isArray(i)?A(i,()=>{r&&r()}):i,a&&function(e,t,n){n.set(e,/* @__PURE__ */new Set);for(const r of t)for(const t of r.bindings)N(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)}})}function N(e,t){return function(e){let t=v.get(e);if(!t){const n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=new RegExp(`\\b${n}\\b`),v.set(e,t)}return t}(t).test(e)}var C=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,R=/(?:import|export)\s+(?:[\s\S]*?\s+from\s+)?['"]([^'"]+)['"]/g,L=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,I=[".ts",".tsx",".mts"];function T(e){return e.startsWith("./")||e.startsWith("../")}function k(e){return I.some(t=>e.endsWith(t))}function O(e){return!(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("blob:"))}function M(e,t){let n=e;const r=[],o=[];return n=n.replace(R,(e,n)=>{if(T(n)){const r=new URL(n,t).href;return k(n)&&o.push(n),e.replace(n,r)}return O(n)&&r.push(n),e}),n=n.replace(L,(e,n)=>{if(T(n)){const e=new URL(n,t).href;return k(n)&&o.push(n),`import("${e}")`}return O(n)&&r.push(n),e}),n}var P=/^(?:export\s+)?(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/gm,D=["$emit","$listen","$refs","registerComponent","registerComponents","$use"];async function F(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(/* @__PURE__ */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(/* @__PURE__ */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=M(await r.text(),e.src),s=function(e){const t=function(e){const t=[];let n;for(P.lastIndex=0;null!==(n=P.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 D){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)+s,c=new Blob([a],{type:"text/javascript"}),l=URL.createObjectURL(c);try{return await(0,eval)(`import("${l}")`)}finally{URL.revokeObjectURL(l)}}catch(y){throw y}}var j=/* @__PURE__ */new Map;async function U(e){if(x.has(e))return x.get(e);const t=(async()=>{try{return await(0,eval)(`import("${e}")`)}catch(y){throw y}})();return x.set(e,t),t}function z(e,t){return t&&Array.isArray(e)?A(e,t):e}async function W(n,r,o,s,i,l,u){if("module"!==n.type)throw new Error('executeModuleScriptWithReactivity only handles type="module" scripts');const f=n.content,p=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 s of r){if(s.isSideEffect){await U(T(s.specifier)?new URL(s.specifier,t).href:s.specifier);continue}const e=T(s.specifier)?new URL(s.specifier,t).href:s.specifier;try{const t=await U(e);for(const e of s.imports){let r;r="*"===e.imported?t:"default"===e.imported?t.default:t[e.imported],o[e.local]=z(r,n)}}catch(y){}}return o}(f,r,l);if(i){const t=new Set([...c,...e,"ladrillosjs","$host","$refs","event","state"]);for(const[e,n]of Object.entries(p))t.has(e)||e in i||(i[e]=n)}const d=function(e){return e.replace(/import\s+(?:(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)(?:\s*,\s*\{[^}]+\})?\s+from\s+)?['"][^'"]+['"]\s*;?/g,"").trim()}(f),{variables:h,functions:m}=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}}(d),g=B(d,h),_=Object.keys(p),b=Object.values(p),v=`\n "use strict";\n return (async () => {\n ${g}\n ${m.length>0?`return { ${m.join(", ")} };`:"return {};"}\n })();\n `;try{const n=["console","alert","Math","JSON","Date","Array","Object","String","Number","Boolean","Promise","setTimeout","setInterval","clearTimeout","clearInterval"],l=n.map(e=>globalThis[e]),f=["$refs","__state__","$host"],p=[s||/* @__PURE__ */new Map,i||{},u],d=a(r),h=[d.registerComponent,d.registerComponents,d.$use],m=t(o||"anonymous"),g=[m.$emit,m.$listen],y={...globalThis.ladrillosjs||{},registerComponent:d.registerComponent,registerComponents:d.registerComponents},w={registerComponent:d.registerComponent,registerComponents:d.registerComponents,$use:d.$use,$emit:m.$emit,$listen:m.$listen,ladrillosjs:y},E=new Set(_),A=[..._],$=_.map((e,t)=>e in w?w[e]:b[t]),S=(e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];E.has(r)||(E.add(r),A.push(r),$.push(t[n]))}};S(n,l),S(c,h),S(e,g),S(f,p),S(["ladrillosjs"],[y]);const N=await new Function(...A,v)(...$);return{...i||{},...N||{}}}catch(y){throw y}}function B(e,t){if(0===t.length)return e;const n=[],r=e=>(n.push(e),`__STRING_PLACEHOLDER_${n.length-1}__`);let o="",s=0;for(;s<e.length;){const n=e[s];if("/"===n&&"/"===e[s+1]){const t=e.indexOf("\n",s),n=-1===t?e.length:t;o+=e.slice(s,n),s=n;continue}if("/"===n&&"*"===e[s+1]){const t=e.indexOf("*/",s+2),n=-1===t?e.length:t+2;o+=e.slice(s,n),s=n;continue}if('"'===n||"'"===n){let t=s+1;for(;t<e.length&&e[t]!==n;)"\\"===e[t]?t+=2:t++;o+=r(e.slice(s,t+1)),s=t+1;continue}if("`"===n){o+="`",s++;let n=s;for(;s<e.length&&"`"!==e[s];)if("\\"!==e[s]){if("$"===e[s]&&"{"===e[s+1]){s>n&&(o+=r(e.slice(n,s))),o+="${",s+=2;const i=s;let a=1;for(;s<e.length&&a>0;){const t=e[s];if('"'!==t&&"'"!==t){if("`"===t){s++;let t=0;for(;s<e.length;)if("\\"!==e[s]){if("`"===e[s]&&0===t){s++;break}"$"!==e[s]||"{"!==e[s+1]?("}"===e[s]&&t>0&&t--,s++):(t++,s+=2)}else s+=2;continue}if("{"===t)a++;else if("}"===t&&(a--,0===a))break;s++}else{for(s++;s<e.length&&e[s]!==t;)"\\"===e[s]?s+=2:s++;s++}}o+=B(e.slice(i,s),t),"}"===e[s]&&s++,o+="}",n=s;continue}s++}else s+=2;s>n&&(o+=r(e.slice(n,s))),o+="`",s++;continue}o+=n,s++}for(const a of t){const e=new RegExp(`\\b(let|const|var)\\s+(${H(a)})\\s*=`,"g");o=o.replace(e,`__state__.${a} ??=`)}for(const a of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${H(a)}\\b(?!\\s*[:(])`,"g");o=o.replace(e,`__state__.${a}`)}let i=o;for(let a=0;a<n.length;a++)i=i.replace(`__STRING_PLACEHOLDER_${a}__`,n[a]);return i}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z=new DOMParser;async function q(e,t,n){const r=function(e){return Z.parseFromString(e,"text/html")}(e),o=Array.from(r.querySelectorAll("script")),i=o.filter(e=>!e.src).map(e=>({content:(e.textContent??"").trim(),type:e.getAttribute("type")})).filter(e=>e.content.length>0),a=o.filter(e=>(e.getAttribute("src")||"").includes("html-proxy")&&"module"===e.getAttribute("type")),c=[...i,...(await Promise.all(a.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)],l=o.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),u=l.filter(e=>!e.external),f=l.filter(e=>e.external),p=await Promise.all(u.map(async e=>{try{const t=await fetch(e.src);if(t.ok){let n=(await t.text()).trim();if(n.length>0)return"module"===e.type&&(n=M(n,e.src)),{content:n,type:e.type}}}catch{}return null}));for(const s of p)s&&c.push(s);o.forEach(e=>e.remove());const d=Array.from(r.querySelectorAll('link[rel="stylesheet"]')),h=d.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);d.forEach(e=>e.remove());const m=Array.from(r.querySelectorAll("style")),g=m.map(e=>e.textContent??"").join("\n").trim();m.forEach(e=>e.remove());const _=e=>e?Array.from(e.children).find(e=>"TEMPLATE"===e.tagName):void 0,y=_(r.body)??_(r.head);let b;if(y){const e=document.createElement("div");e.appendChild(y.content.cloneNode(!0)),b=e.innerHTML.trim()}else b=r.body.innerHTML.trim();const v=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),r=e.matchAll(s);for(const o of r){const e=o[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)}(b);return{tagName:t,template:b,scripts:c,externalScripts:f,externalStyles:h,styles:g,sourcePath:n,lazy:!1,templateBindings:v}}var X=/* @__PURE__ */new Map,V=25,G=e=>{if(!Number.isFinite(e)||e<1)throw new Error(`[LadrillosJS] configure({ cacheSize }) requires a positive integer, got ${e}`);for(V=Math.floor(e);X.size>V;){const e=X.keys().next().value;if(!e)break;X.delete(e)}},J=(e,t)=>{if(X.has(e))X.delete(e);else if(X.size>=V){const e=X.keys().next().value;e&&X.delete(e)}X.set(e,t)};async function Y(e){if(!e)throw new Error("Path cannot be null or empty");const t=(e=>{const t=X.get(e);return t&&(X.delete(e),X.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 J(e,n),t.path!==e&&J(t.path,n),{source:n,resolvedPath:t.path}}catch(y){return}}function K(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=Q(e.slice(0,t).trim());return r?{calleePath:r,args:ee(e.slice(t+1,n))}:null}(t);if(n)return{raw:t,path:n.calleePath,isFunction:!0,isExpression:!0,functionArgs:n.args};const r=Q(t);return r?{raw:t,path:r,isFunction:!1,isExpression:!1}:{raw:t,path:[],isExpression:!0}}function Q(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}function ee(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}var te=globalThis.requestIdleCallback||(e=>setTimeout(e,1)),ne=globalThis.cancelIdleCallback||(e=>clearTimeout(e)),re=(e=1e4)=>t=>{const n=te(t,{timeout:e});return()=>ne(n)},oe=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()},se=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)},ie=(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}},ae=(e=0)=>t=>{const n=setTimeout(t,e);return()=>clearTimeout(n)},ce=oe({rootMargin:"100px"});function le(e){const t=e.querySelector(':scope > template[slot="placeholder"]');return t?(t.remove(),t.content.cloneNode(!0)):null}function ue(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 ie();const n=t.split(",").map(e=>e.trim()).filter(Boolean);return ie(1===n.length?n[0]:n)}if(e.hasAttribute("media"))return se(e.getAttribute("media")||"");if(e.hasAttribute("delay"))return ae(Number(e.getAttribute("delay"))||0);if(e.hasAttribute("idle")||e.hasAttribute("idle-timeout")){const t=e.getAttribute("idle-timeout");return t?re(Number(t)||1e4):re()}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?oe(t):ce}(e),r=e.getAttribute("src"),o=e.getAttribute("component"),s=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=le(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(()=>Wt)).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=le(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 fe(e){const t=Array.from(e.querySelectorAll("lazy"));for(const n of t)pe(n)||ue(n)}function pe(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function de(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 he(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let r;for(;r=n.nextNode();){if(me(r)||ge(r))continue;const e=r.textContent;if(!e)continue;const n=[...e.matchAll(s)];if(n.length>0){const o=e,s=n.map(e=>K(e[1].trim()));t.push({node:r,bindings:s,original:o})}}const o=function(e){const t=[],n=["$bind","$ref","$no:bind","condition","each","key","track-by"],r=Array.from(e.querySelectorAll("*"));for(const o of r)if("FOR"!==o.tagName&&!me(o)&&!o.hasAttribute("$no:bind")&&!ge(o))for(const e of Array.from(o.attributes)){if(n.includes(e.name))continue;const r=[...e.value.matchAll(s)];if(r.length>0){const n=document.createTextNode(e.value),s=r.map(e=>K(e[1].trim()));t.push({node:n,bindings:s,original:e.value,isAttribute:!0,attributeName:e.name,element:o})}}return t}(e);return t.push(...o),t}function me(e){let t=(Node,e.parentElement);for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function ge(e){let t=e.parentElement;for(;t;){if(t.hasAttribute&&t.hasAttribute("$no:bind"))return!0;t=t.parentElement}return!1}var _e=["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"],ye=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"]),be=Object.freeze([]),ve=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"]),we=(Object.freeze(["registerComponent","$use"]),{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"}),Ee=["ctrl","alt","shift","meta"],Ae=["prevent","stop","self","once","passive","capture"],$e={left:0,middle:1,right:2};function Se(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?Ae.includes(e)?o.eventModifiers.push(e):Ee.includes(e)?o.systemModifiers.push(e):e in $e?o.mouseModifier=e:o.keyModifiers.push(e):o.exact=!0}return o}function Ne(e){const t={};return e.includes("passive")&&(t.passive=!0),e.includes("capture")&&(t.capture=!0),e.includes("once")&&(t.once=!0),t}function Ce(e,t){return function(n){t.eventModifiers.includes("self")&&n.target!==n.currentTarget||t.mouseModifier&&n instanceof MouseEvent&&!function(e,t){return e.button===$e[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 Ee)if(!t.includes(o)&&r[o])return!1;return!0}(n,t.systemModifiers,t.exact)||t.keyModifiers.length>0&&n instanceof KeyboardEvent&&!t.keyModifiers.some(e=>function(e,t){const n=t.toLowerCase(),r=we[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))||(t.eventModifiers.includes("prevent")&&n.preventDefault(),t.eventModifiers.includes("stop")&&n.stopPropagation(),e(n))}}function xe(e){return e.startsWith("$on:")}var Re=e=>e instanceof ShadowRoot?e.host:e;function Le(e,t,n,r){const o=[e,...de(e)];for(const s of o){const e=Array.from(s.querySelectorAll("*"));for(const o of e)if(!Te(o)){for(const e of _e){const s=o.getAttribute(e);if(s){o.removeAttribute(e);const i=e.slice(2),a=ke(s,t,n,r);a&&o.addEventListener(i,a)}}Ie(o,t,n,r)}}}function Ie(e,t,n,r){const o=Array.from(e.attributes).filter(e=>xe(e.name));for(const s of o){const o=Se(s.name);if(!o)continue;const i=s.value;e.removeAttribute(s.name);const a=ke(i,t,n,r);if(!a)continue;const c=Ce(a,o),l=Ne(o.eventModifiers);e.addEventListener(o.eventName,c,l)}}function Te(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 ke(e,t,n,r){try{const o=r?.__componentUrl,s=r?.__componentId,i=Ue(o,s),a=je(),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;`:"",g=p&&u.length>0?`const { ${u.join(", ")} } = state;`:"",_=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${Fe(o)}\\b(?!\\s*[:(])`,"g");r=r.replace(e,`state.${o}`)}return`\${${r}}`}));for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!state\\.)\\b${Fe(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}(Oe(n,p?u:[]),f),y=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(" "):"",v=/\bawait\b/.test(e)||/\bawait\b/.test(_)||/\basync\b/.test(_),w=o||"ladrillos-event-handler",E=v?`"use strict"; ${d} ${g} ${_} try { await (async () => { ${e} })(); } finally { ${y} }\n//# sourceURL=${w}`:`"use strict"; ${d} ${g} ${_} ${e}; ${y}\n//# sourceURL=${w}`,A=Object.getPrototypeOf(async function(){}).constructor,$=v?new A(...c,E):new Function(...c,E);return e=>{try{const n=$(e,t,r&&r.__refs||/* @__PURE__ */new Map,...a.map(()=>{}),...i.values);n&&"function"==typeof n.catch&&n.catch(e=>{const n={tagName:r?.tagName?.toLowerCase(),sourcePath:t.__componentUrl,instanceId:t.__componentId};b(0,e,{context:n.tagName?n:h(),errorCode:m.EVENT_HANDLER_FAILED})})}catch(n){const e={tagName:r?.tagName?.toLowerCase(),sourcePath:t.__componentUrl,instanceId:t.__componentId};b(0,n,{context:e.tagName?e:h(),errorCode:m.EVENT_HANDLER_FAILED})}}}catch(o){return r?.tagName&&r.tagName.toLowerCase(),null}}function Oe(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=Me(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=Me(e,r,e.indexOf("{",r+o[0].length-1));s&&n.push(s)}return n.map(e=>e.trim()).join(";\n")+(n.length>0?";":"")}function Me(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 Pe(e,t,n,r,o,s,i=[]){try{const a=De(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${Fe(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+(${Fe(s)})\\s*=`,"g");r=r.replace(e,`__state__.${s} ??=`)}for(const s of t){const e=new RegExp(`(?<![^.]\\.)(?<!__state__\\.)\\b${Fe(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,[...new Set([...a,...i])])}\n//# sourceURL=${n||"ladrillos-component"}\n `,l=Ue(n,r),u=je(),f=["__state__","$host","$refs",...u,...l.keys],p=[t,o,s,...u.map(()=>{}),...l.values];new Function(...f,c)(...p)}catch(a){}}function De(e){const t=function(e){const t=e.split(""),n=e.length;let r=0,o=0,s=!1;const i=[],a=()=>i.length>0,c=(e,n)=>{for(let r=e;r<n;r++){const e=t[r];"\n"!==e&&"\r"!==e&&(t[r]=" ")}},l=t=>{let r=t;for(;r<n&&"\n"!==e[r];)r++;return r},u=t=>{let r=t+2;for(;r<n-1&&("*"!==e[r]||"/"!==e[r+1]);)r++;return Math.min(n,r+2)},f=(t,r)=>{let o=t+1;for(;o<n;)if("\\"!==e[o]){if(e[o]===r)return o+1;if("\n"===e[o])return o;o++}else o+=2;return o},p=t=>{let r=t+1;for(;r<n;)if("\\"!==e[r]){if("`"===e[r])return r+1;if("$"===e[r]&&"{"===e[r+1]){r+=2;let t=1;for(;r<n&&t>0;){const n=e[r];"`"!==n?'"'!==n&&"'"!==n?"/"!==n||"/"!==e[r+1]?"/"!==n||"*"!==e[r+1]?("{"===n?t++:"}"===n&&t--,r++):r=u(r):r=l(r):r=f(r,n):r=p(r)}continue}r++}else r+=2;return r},d=t=>{let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;return n<0||!!"([{,;:!&|?=+-*%^~<>".includes(e[n])||/\b(return|typeof|delete|void|in|of|new|instanceof|throw)$/.test(e.slice(0,n+1))},h=t=>{let r=t+1,o=!1;for(;r<n;){const t=e[r];if("\\"!==t){if("["===t)o=!0;else if("]"===t)o=!1;else{if("/"===t&&!o){r++;break}if("\n"===t)break}r++}else r+=2}for(;r<n&&/[a-zA-Z]/.test(e[r]);)r++;return r};for(;r<n;){const m=e[r];if("/"===m&&"/"===e[r+1]){const e=l(r);a()&&c(r,e),r=e;continue}if("/"===m&&"*"===e[r+1]){const e=u(r);a()&&c(r,e),r=e;continue}if('"'===m||"'"===m){const e=f(r,m);a()&&c(r,e),r=e;continue}if("`"===m){const e=p(r);a()&&c(r,e),r=e;continue}if("/"===m&&d(r)){const e=h(r);a()&&c(r,e),r=e;continue}if("{"!==m)if("}"!==m)if("="!==m||">"!==e[r+1]){if(/[a-zA-Z_$]/.test(m)){const t=r;for(;r<n&&/[a-zA-Z0-9_$]/.test(e[r]);)r++;const o=e.slice(t,r);a()?c(t,r):"function"===o&&(s=!0);continue}a()&&"\n"!==m&&"\r"!==m&&(t[r]=" "),r++}else{if(a())t[r]=" ",t[r+1]=" ";else{let t=r+2;for(;t<n;){const n=e[t];if(/\s/.test(n))t++;else if("/"!==n||"/"!==e[t+1]){if("/"!==n||"*"!==e[t+1])break;t=u(t)}else t=l(t)}"{"===e[t]&&(s=!0)}r+=2}else a()&&i[i.length-1]===o?i.pop():a()&&(t[r]=" "),o--,r++;else o++,s?(i.push(o),s=!1):a()&&(t[r]=" "),r++}return t.join("")}(e),n=[],r=/(?:let|const|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/g;let o;for(;null!==(o=r.exec(t));)n.push(o[1]);return n}function Fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(){return be.filter(e=>!ve.has(e))}function Ue(n,r){const o=[],s=[];for(const e of ye)e in globalThis&&(o.push(e),s.push(globalThis[e]));const i=a(n||window.location.href);o.push(...c),s.push(i.registerComponent,i.registerComponents,i.$use);const l=t(r||"anonymous");return o.push(...e),s.push(l.$emit,l.$listen),{keys:o,values:s}}function ze(e,t){try{const n=Object.keys(t),r=Object.values(t),o=je(),s=[...o,...n],i=[...o.map(()=>{}),...r];return new Function(...s,`"use strict"; return ${e};`)(...i)}catch(n){return b(0,n,{context:h()}),`{${e}}`}}function We(e,t){if(function(e){if(!e.isAttribute||!e.attributeName)return!1;if(1!==e.bindings.length)return!1;const t=e.original.trim();return!!/^\{[\s\S]*\}$/.test(t)&&t.slice(1,-1).trim()===e.bindings[0].raw.trim()}(e)){const r=e.element??e.node.parentElement,o=ze(e.bindings[0].raw,t);return void(r&&(n=o,null===n||"object"!=typeof n&&"function"!=typeof n?r.setAttribute(e.attributeName,String(o??"")):(r.hasAttribute?.(e.attributeName)&&r.removeAttribute(e.attributeName),r[e.attributeName]=o)))}var n;let r=e.original;for(const o of e.bindings){const e=ze(o.raw,t),n=String(e??"");r=r.replace(`{${o.raw}}`,n)}if(e.isAttribute&&e.attributeName){const t=e.element??e.node.parentElement;t&&t.setAttribute(e.attributeName,r)}else e.node.textContent=r}function Be(e,t){for(const n of e)We(n,t)}var He="$bind",Ze="$ref",qe=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]+)$/,Xe=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Ve=/^\(|\)$/g;function Ge(e){return e.replace(/\$/g,"\\$")}function Je(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);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(n[s]!==r[s])return!1;return!0}var Ye="ELSE-IF",Ke="ELSE";function Qe(e){const t=e.trim();return t.startsWith("{")&&t.endsWith("}")?t.slice(1,-1).trim():t}function et(e,t){const n=Array.from(e.querySelectorAll(`[${Ge(Ze)}]`));for(const r of n){const e=r.getAttribute(Ze);e&&(t.refs.set(e,r),r.removeAttribute(Ze))}}function tt(e,t){const n=Array.from(e.querySelectorAll("for"));for(const r of n){if(!r.parentNode)continue;if(rt(r))continue;const n=r.getAttribute("each")||r.getAttribute("of")||"";if(!n)continue;let o=ot(n);if(!o)continue;const s=r.getAttribute("key")||r.getAttribute("track-by")||o.key,i=nt(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 nt(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 rt(e){let t=e.parentElement;for(;t;){if("FOR"===t.tagName)return!0;t=t.parentElement}return!1}function ot(e){const t=e.match(qe);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(Ve,"").trim(),a=i.match(Xe);let c,l,u;return a?(c=i.replace(Xe,"").trim(),l=a[1]?.trim(),u=a[2]?.trim()):c=i,{item:c,index:l||u,key:n,array:o}}function st(e,t){const n=Array.from(e.querySelectorAll("if"));for(const r of n){if(rt(r))continue;const n=[],o=Qe(r.getAttribute("condition")||""),s=document.createComment(` <if> ${o} `),i=r.parentElement||e,a=r.nextSibling;i.insertBefore(s,r),n.push(it(r,o,"if",s,i,a));let c=r.nextElementSibling;for(;c;){const e=c.tagName;if(e!==Ye){if(e===Ke){n.push(it(c,"","else",s,i,c.nextSibling)),c.remove();break}break}{const e=Qe(c.getAttribute("condition")||""),t=c.nextElementSibling;n.push(it(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 it(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 at(e,t){const n=Array.from(e.querySelectorAll("show"));for(const r of n){if(!r.parentNode)continue;if(rt(r))continue;const e=Qe(r.getAttribute("condition")||""),n=r;n.style.display="contents",t.showElements.push({element:n,expression:e,originalDisplay:"contents"}),r.removeAttribute("condition")}}function ct(e,t){const n=Array.from(e.querySelectorAll(`[${Ge(He)}]`));for(const r of n){const e=r.getAttribute(He);if(!e)continue;if(lt(r))continue;const n={element:r,path:e.split("."),raw:e,isContentEditable:r.hasAttribute("contenteditable")};t.twoWayBindings.push(n),r.removeAttribute(He)}}function lt(e,t){return rt(e)}function ut(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),i=ft(t,e,r,o);return _t(s,i,n),yt(s,i,n),s};if(e.keyAttribute){const r=function(e,t,n){const r=[],o=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map;for(let p=0;p<e.length;p++)o.set(n(e[p],p),p);for(let p=0;p<t.length;p++)s.set(n(t[p],p),p);const i=/* @__PURE__ */new Set;for(let p=0;p<e.length;p++){const t=n(e[p],p);s.has(t)||r.push({type:"remove",oldIndex:p,key:t,item:e[p]})}for(let p=0;p<t.length;p++){const e=n(t[p],p);o.has(e)||(r.push({type:"insert",newIndex:p,key:e,item:t[p]}),i.add(p))}const a=[],c=[];for(let p=0;p<e.length;p++){const t=n(e[p],p),r=s.get(t);void 0!==r&&(a.push(r),c[p]=r)}const l=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),u=new Set(l.map(e=>a[e]));let f=0;for(const p of a){for(;f<e.length&&!s.has(n(e[f],f));)f++;if(f<e.length){const t=n(e[f],f),o=f,i=s.get(t);u.has(i)||r.push({type:"move",oldIndex:o,newIndex:i,key:t,item:e[o]}),f++}}for(let p=0;p<t.length;p++){const s=n(t[p],p),i=o.get(s);if(void 0!==i){const n=t[p];Je(e[i],n)||r.push({type:"update",oldIndex:i,newIndex:p,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?(pt(u,ft(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=ft(t,e,s[i],i);pt(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 ft(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 pt(e,t,n){!function(e,t,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),o=[];let s;for(;s=r.nextNode();)s[dt]&&o.push(s);for(const i of o){const e=i[dt],r=ht(e.branches,t,n);if(r!==e.currentIndex&&(e.currentEl&&e.currentEl.parentNode&&e.currentEl.remove(),e.currentEl=null,e.currentIndex=-1,r>=0)){const o=mt(e.branches[r]);i.parentNode.insertBefore(o,i.nextSibling),e.currentIndex=r,e.currentEl=o,_t(o,t,n),yt(o,t,n)}}}(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))pt(s,t,n)}var dt="__ladrillosLoopCond";function ht(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if("else"===o.type)return r;try{if(n(o.condition,t))return r}catch{}}return-1}function mt(e){const t=document.createElement("span");return t.style.display="contents",t.appendChild(e.template.content.cloneNode(!0)),t}function gt(e,t){const n=document.createElement("template");for(const r of Array.from(e.childNodes))n.content.appendChild(r.cloneNode(!0));return{type:t,condition:"else"===t?"":Qe(e.getAttribute("condition")||""),template:n}}function _t(e,t,n){let r=1e4;for(;r-- >0;){let r=null;const o=e.querySelectorAll("IF");for(let e=0;e<o.length;e++){const t=o[e];if(t.parentNode&&!rt(t)){r=t;break}}if(!r)return;const s=[];s.push(gt(r,"if"));const i=[];let a=r.nextElementSibling;for(;a;){if(a.tagName!==Ye){if(a.tagName===Ke){s.push(gt(a,"else")),i.push(a);break}break}s.push(gt(a,"else-if")),i.push(a),a=a.nextElementSibling}const c=document.createComment(" <if> (loop) "),l={branches:s,currentIndex:-1,currentEl:null};c[dt]=l,r.parentNode.insertBefore(c,r),r.remove();for(const e of i)e.remove();const u=ht(s,t,n);if(u>=0){const e=mt(s[u]);c.parentNode.insertBefore(e,c.nextSibling),l.currentIndex=u,l.currentEl=e}}}function yt(e,t,n){for(const i of Array.from(e.attributes))i.value.includes("{")&&(i.__originalTemplate=i.value,i.value=i.value.replace(/\{([^}]+)\}/g,(e,r)=>{const o=n(r.trim(),t);return null!==o&&"object"==typeof o?JSON.stringify(o):String(o??"")}));!function(e,t){for(const n of _e){const r=e.getAttribute(n);if(r){e.removeAttribute(n);const o=n.slice(2),s=bt(r,t);s&&e.addEventListener(o,s)}}!function(e,t){const n=Array.from(e.attributes).filter(e=>xe(e.name));for(const r of n){const n=Se(r.name);if(!n)continue;const o=r.value;e.removeAttribute(r.name);const s=bt(o,t);if(!s)continue;const i=Ce(s,n),a=Ne(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))yt(i,t,n)}function bt(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=Oe(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"),b=new Function("event","context","reactiveState","$emit","$listen",`"use strict";\n ${d}\n ${m}\n ${p}\n ${f}\n ${e};\n ${g}`);return t=>{try{b(t,n,r,_.$emit,_.$listen)}catch(o){y(`Error in loop event handler: ${e}`,null,o)}}}catch(r){return null}}function vt(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 wt(e,t,n,r){const o=e.element,{raw:s,path:i,isContentEditable:a}=e;Et(o,n(s,t),a);const c=i[0];r.has(c)||r.set(c,[]),r.get(c).push({element:o,path:i,isContentEditable:a}),s===c||r.has(s)||r.set(s,[]),s!==c&&r.get(s).push({element:o,path:i,isContentEditable:a});const l=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 u=!1;o.__isUpdatingFromState=()=>u,o.__setUpdatingFromState=e=>{u=e},o.addEventListener(l,()=>{u||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,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 Et(e,t,n){n?e.textContent=String(t??""):e instanceof HTMLInputElement?"checkbox"===e.type.toLowerCase()?e.checked=Boolean(t):e.value=String(t??""):e.value=e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?String(t??""):t}var At=[],$t=/* @__PURE__ */new Set,St=!1,Nt=!1,Ct=0,xt=Promise.resolve();function Rt(){Nt=!1,St=!0,At.sort((e,t)=>(e.id??0)-(t.id??0));try{for(const t of At)if(!1!==t.active)try{t()}catch(e){y("Error in scheduled update",null,e)}}finally{At.length=0,$t.clear(),St=!1}}var Lt=/* @__PURE__ */new Map;function It(e,t){const{tagName:r,template:o,scripts:s,externalScripts:i,externalStyles:a,styles:c,sourcePath:l,templateBindings:u=[]}=e,f=De(s.map(e=>e.content).join("\n")),p=[...new Set([...f,...u])];class h 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;_pendingProps=/* @__PURE__ */new Map;_propsReady=!1;constructor(){super()}async connectedCallback(){if(this._initialized)return;this._initialized=!0,d={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,fe(n.content),e.innerHTML="",e.appendChild(n.content);const r=he(e);for(const o of de(e))r.push(...he(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 h=this._getAttributeOverrides();for(const t of p)Object.prototype.hasOwnProperty.call(this,t)&&(this._pendingProps.set(t,this[t]),delete this[t]);for(const[t,r]of this._pendingProps)h[t]=r;const m=s.filter(e=>"module"!==e.type),g=s.some(e=>"module"===e.type),_=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(`[${Ge(Ze)}]`));for(const r of n){const e=r.getAttribute(Ze);e&&t.set(e,r)}}(this._root,_),a&&a.length>0&&await async function(e,t,n){for(const r of e)if(n&&t)try{let e=j.get(r.href);if(!e){const t=await fetch(r.href);if(!t.ok)continue;e=await t.text(),j.set(r.href,e)}const n=document.createElement("style");n.textContent=e,n.setAttribute("data-external-href",r.href),t.insertBefore(n,t.firstChild)}catch(y){}else{if(document.querySelector(`link[href="${r.href}"]`))continue;await new Promise(e=>{const t=document.createElement("link");t.rel=r.rel||"stylesheet",t.href=r.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 n of t)try{await F(n)}catch(y){}}(i),this.state=await async function(e,t,n,r={},o,s=!1,i,a,c,l=[]){const u=Re(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=S(f,n,(e,t)=>We(e,t),o);for(const h of t)Pe(h.content,d,i,a,u,c,l);return u.__state=d,u.__scriptContent=p,u.__componentUrl=i,u.__componentId=a,s||(Le(e,d,p,u),Be(n,d)),d}(this._root,m,f,h,()=>this._updateDirectives(),g,l,this._componentId,_,u),this._propsReady=!0,this._pendingProps.size>0){for(const[e,t]of this._pendingProps)this.state[e]=t;this._pendingProps.clear()}if("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 p of f)try{await F(p,r,n)}catch(y){}for(const p of u)try{const e=await F(p,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(y){}for(const p of l)try{const e=await W(p,n,r,o,s,i,a);Object.assign(c,e)}catch(y){}return c}(s,i,l,this._componentId,_,this.state,()=>this._updateDirectives(),this);(g||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(g&&function(e,t,n){const r=Re(e);Le(e,n,r.__scriptContent||"",r),Be(t,n)}(this._root,f,this.state),this._evaluator=ze,this._directives=function(e,t){const n={loops:[],conditionals:[],twoWayBindings:[],refs:t,showElements:[]},r=[e,...de(e)];for(const o of r)et(o,n),tt(o,n),at(o,n),ct(o,n),st(o,n);return fe(e),n}(this._root,_),"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)wt(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),Et(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=C.get(e);if(t){for(const e of t)URL.revokeObjectURL(e);C.delete(e)}}(this._componentId),n(this._componentId),function(e){const t=Lt.get(e);t&&(t.active=!1,Lt.delete(e))}(this._componentId),"undefined"!=typeof globalThis&&globalThis.__ladrillosStateCallbacks?.delete(this._componentId),this._initialized=!1,this._propsReady=!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=Lt.get(e);n||(n=function(){const e=()=>{t()};return e.id=++Ct,e.active=!0,e}(),Lt.set(e,n)),function(e){void 0===e.id&&(e.id=++Ct),$t.has(e.id)||($t.add(e.id),At.push(e),St||Nt||(Nt=!0,xt.then(Rt)))}(n)}(this._componentId,()=>{this._performDirectiveUpdates()})}_performDirectiveUpdates(){this._directives&&this._evaluator&&(this._directives.loops.length>0&&function(e,t,n){for(const r of e)ut(r,t,n)}(this._directives.loops,this.state,this._evaluator),this._directives.conditionals.length>0&&function(e,t,n){for(const r of e)vt(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);r.element.style.display=Boolean(e)?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));if(n.length>0){const e=n.map(e=>`"${e}" → try "${{title:"heading",class:"className",style:"customStyle",id:"componentId",hidden:"isHidden"}[e]||`my${e.charAt(0).toUpperCase()}${e.slice(1)}`}"`);
|
|
2
|
-
/* @__PURE__ */n.map(e=>`"${e}"`).join(", "),e.join(", ")}return 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}}for(const n of p)n in HTMLElement.prototype||Object.prototype.hasOwnProperty.call(h.prototype,n)||Object.defineProperty(h.prototype,n,{configurable:!0,enumerable:!1,get(){return this._propsReady?this.state[n]:this._pendingProps.get(n)},set(e){this._propsReady?this.state[n]=e:this._pendingProps.set(n,e)}});return h}function Tt(e,t){const{tagName:n}=e;if(!customElements.get(n)){const r=It(e,t);customElements.define(n,r)}}var kt,Ot=/* @__PURE__ */new Map,Mt=/* @__PURE__ */new Map,Pt=/* @__PURE__ */new Set,Dt=/* @__PURE__ */new Map;function Ft(e,t,n,r){var o;Dt.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=Dt.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 jt(o);this.isUpgraded=!0,this.upgradeToRealComponent(e)}catch(e){y(`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):y("No parent node for placeholder - cannot upgrade lazy component",{tagName:o})}}))}async function jt(e){const t=function(e){return`${e}--loaded`}(e);if(Pt.has(e))return t;if(Ot.has(e))return await Ot.get(e),t;const n=Dt.get(e);if(!n)throw new Error(`Lazy component "${e}" not registered`);const r=(async()=>{const r=await Y(n.absolutePath);if(!r)throw new Error(`Failed to fetch component source for "${e}"`);const o=await q(r.source,e,r.resolvedPath);kt[e]=o;const s=It(o,n.useShadowDOM);return customElements.get(t)||customElements.define(t,s),Pt.add(e),Mt.set(e,{component:o,useShadowDOM:n.useShadowDOM}),o})();Ot.set(e,r);try{return await r,t}finally{Ot.delete(e)}}function Ut(e){return Dt.has(e)||Pt.has(e)}async function zt(e){return Dt.has(e)&&await jt(e),kt[e]}var Wt=/* @__PURE__ */o({ladrillos:()=>Bt}),Bt=new class{components;constructor(){this.components={},kt=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)Ft(e,o,n,!0===r?ce:r);else try{const t=await Y(o);if(!t)throw new Error(`Failed to fetch component source from ${o}`);const r=await q(t.source,e,t.resolvedPath);this.components[e]=r,Tt(r,n)}catch(s){y(`Error registering component "<${e}>"`,{tagName:e,sourcePath:t},s)}}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 c of t){if(this.components[c.name]){n.skipped.push(c.name);continue}const e=new URL(c.path,window.location.href).href,t={...c,absolutePath:e};c.lazy?r.push(t):o.push(t)}for(const c of r)try{Ft(c.name,c.absolutePath,c.useShadowDOM??!0,!0===c.lazy?ce:c.lazy),n.success.push(c.name)}catch(a){n.failed.push({name:c.name,error:a instanceof Error?a:new Error(String(a))})}if(0===o.length)return n;const s=await Promise.allSettled(o.map(async e=>({config:e,result:await Y(e.absolutePath)}))),i=await Promise.allSettled(s.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 q(r.source,n.name,r.resolvedPath)}}));for(let c=0;c<i.length;c++){const e=i[c],t=o[c];if("rejected"===e.status){n.failed.push({name:t.name,error:e.reason instanceof Error?e.reason:new Error(String(e.reason))}),y(`Error registering component "${t.name}"`,{tagName:t.name,sourcePath:t.path},e.reason);continue}const{component:r}=e.value,s=t.useShadowDOM??!0;this.components[t.name]=r;try{Tt(r,s),n.success.push(t.name)}catch(a){n.failed.push({name:t.name,error:a instanceof Error?a:new Error(String(a))}),delete this.components[t.name]}}return n}async loadLazyComponent(e){return zt(e)}};export{ae as a,se as c,m as d,_ as f,f as h,ce as i,oe as l,u as m,zt as n,re as o,p,Ut as r,ie as s,Bt as t,G as u};
|
|
3
|
-
//# sourceMappingURL=shared-mjNRZBte.js.map
|