ladrillosjs 2.0.0-beta.3 → 2.0.0-beta.3.2

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.
@@ -1,51 +1,51 @@
1
- var W = Object.defineProperty, I = Object.defineProperties;
2
- var D = Object.getOwnPropertyDescriptors;
3
- var k = Object.getOwnPropertySymbols;
4
- var K = Object.prototype.hasOwnProperty, O = Object.prototype.propertyIsEnumerable;
5
- var _ = (t) => {
1
+ var q = Object.defineProperty, I = Object.defineProperties;
2
+ var B = Object.getOwnPropertyDescriptors;
3
+ var v = Object.getOwnPropertySymbols;
4
+ var j = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
5
+ var k = (t) => {
6
6
  throw TypeError(t);
7
7
  };
8
- var P = (t, e, r) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, m = (t, e) => {
8
+ var P = (t, e, r) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
9
9
  for (var r in e || (e = {}))
10
- K.call(e, r) && P(t, r, e[r]);
11
- if (k)
12
- for (var r of k(e))
13
- O.call(e, r) && P(t, r, e[r]);
10
+ j.call(e, r) && P(t, r, e[r]);
11
+ if (v)
12
+ for (var r of v(e))
13
+ W.call(e, r) && P(t, r, e[r]);
14
14
  return t;
15
- }, g = (t, e) => I(t, D(e));
16
- var G = (t, e, r) => e.has(t) || _("Cannot " + r);
17
- var H = (t, e, r) => e.has(t) ? _("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
18
- var S = (t, e, r) => (G(t, e, "access private method"), r);
19
- var d = (t, e, r) => new Promise((s, o) => {
20
- var n = (c) => {
15
+ }, f = (t, e) => I(t, B(e));
16
+ var D = (t, e, r) => e.has(t) || k("Cannot " + r);
17
+ var z = (t, e, r) => e.has(t) ? k("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r);
18
+ var $ = (t, e, r) => (D(t, e, "access private method"), r);
19
+ var p = (t, e, r) => new Promise((s, o) => {
20
+ var i = (c) => {
21
21
  try {
22
22
  a(r.next(c));
23
- } catch (f) {
24
- o(f);
23
+ } catch (d) {
24
+ o(d);
25
25
  }
26
26
  }, l = (c) => {
27
27
  try {
28
28
  a(r.throw(c));
29
- } catch (f) {
30
- o(f);
29
+ } catch (d) {
30
+ o(d);
31
31
  }
32
- }, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, l);
32
+ }, a = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, l);
33
33
  a((r = r.apply(t, e)).next());
34
34
  });
35
- const M = () => {
35
+ const L = () => {
36
36
  try {
37
37
  return !1;
38
38
  } catch (t) {
39
39
  return process.env.NODE_ENV === "development";
40
40
  }
41
- }, i = {
41
+ }, n = {
42
42
  /**
43
43
  * Log a message only in development mode
44
44
  * @param message - The message to log
45
45
  * @param args - Additional arguments to log
46
46
  */
47
47
  log(t, ...e) {
48
- M() && console.log(t, ...e);
48
+ L() && console.log(t, ...e);
49
49
  },
50
50
  /**
51
51
  * Log an error (always logs in both dev and production)
@@ -61,9 +61,9 @@ const M = () => {
61
61
  * @param args - Additional arguments to log
62
62
  */
63
63
  warn(t, ...e) {
64
- M() && console.warn(t, ...e);
64
+ L() && console.warn(t, ...e);
65
65
  }
66
- }, p = (t, e) => {
66
+ }, g = (t, e) => {
67
67
  const r = [t];
68
68
  return e && (e.componentName && r.push(`
69
69
  Component: <${e.componentName}>`), e.componentPath && r.push(`
@@ -73,102 +73,102 @@ const M = () => {
73
73
  Event: ${e.eventType}`), e.elementTag && r.push(`
74
74
  Element: <${e.elementTag}>`), e.lineHint && r.push(`
75
75
  Location: ${e.lineHint}`)), r.join("");
76
- }, fe = (t, e, r) => {
77
- const s = p(
76
+ }, pe = (t, e, r) => {
77
+ const s = g(
78
78
  "⚠️ Binding Error: Failed to evaluate expression",
79
- g(m({}, r), {
79
+ f(h({}, r), {
80
80
  expression: t,
81
81
  lineHint: (r == null ? void 0 : r.lineHint) || "Template binding expression"
82
82
  })
83
83
  );
84
- i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
85
- }, he = (t, e, r, s) => {
86
- const o = p(
84
+ n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
85
+ }, ue = (t, e, r, s) => {
86
+ const o = g(
87
87
  "⚠️ Event Handler Error: Failed to execute handler",
88
- g(m({}, s), {
88
+ f(h({}, s), {
89
89
  eventType: t,
90
90
  expression: e,
91
91
  lineHint: (s == null ? void 0 : s.lineHint) || `on${t} handler`
92
92
  })
93
93
  );
94
- i.error(o), i.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
95
- }, we = (t, e, r) => {
96
- const s = p(
94
+ n.error(o), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
95
+ }, ge = (t, e, r) => {
96
+ const s = g(
97
97
  "⚠️ Conditional Error: Failed to evaluate condition",
98
- g(m({}, r), {
98
+ f(h({}, r), {
99
99
  expression: t,
100
100
  lineHint: (r == null ? void 0 : r.lineHint) || "$if/$else-if condition"
101
101
  })
102
102
  );
103
- i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
104
- }, ye = (t, e, r) => {
105
- const s = p(
103
+ n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
104
+ }, he = (t, e, r) => {
105
+ const s = g(
106
106
  "⚠️ Loop Error: Failed to process loop",
107
- g(m({}, r), {
107
+ f(h({}, r), {
108
108
  expression: t,
109
109
  lineHint: (r == null ? void 0 : r.lineHint) || "$for loop expression"
110
110
  })
111
111
  );
112
- i.error(s), i.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
113
- }, x = (t, e, r) => {
114
- const s = p(
112
+ n.error(s), n.error(` Error details: ${e.message}`), e.stack && console.debug(" Stack trace:", e.stack);
113
+ }, _ = (t, e, r) => {
114
+ const s = g(
115
115
  "⚠️ Registration Error: Failed to register component",
116
116
  {
117
117
  componentName: t,
118
118
  componentPath: e
119
119
  }
120
120
  );
121
- i.error(s), i.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
122
- }, z = (t, e, r) => {
123
- const s = p(
121
+ n.error(s), n.error(` Error details: ${r.message}`), r.stack && console.debug(" Stack trace:", r.stack);
122
+ }, H = (t, e, r) => {
123
+ const s = g(
124
124
  "⚠️ Fetch Error: Failed to load resource",
125
- g(m({}, r), {
125
+ f(h({}, r), {
126
126
  componentPath: t
127
127
  })
128
128
  );
129
- i.error(s), i.error(` Error details: ${e.message}`);
130
- }, J = (t, e) => {
131
- const r = p(
129
+ n.error(s), n.error(` Error details: ${e.message}`);
130
+ }, M = (t, e) => {
131
+ const r = g(
132
132
  `⚠️ Parse Error: ${t}`,
133
133
  e
134
134
  );
135
- i.error(r);
136
- }, Ee = (t, e) => {
137
- const r = p(
135
+ n.error(r);
136
+ }, fe = (t, e) => {
137
+ const r = g(
138
138
  "⚠️ Script Error: Failed to execute component script",
139
139
  e
140
140
  );
141
- i.error(r), i.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
142
- }, Ce = (t, e, r) => {
143
- const s = p(
141
+ n.error(r), n.error(` Error details: ${t.message}`), t.stack && console.debug(" Stack trace:", t.stack);
142
+ }, me = (t, e, r) => {
143
+ const s = g(
144
144
  "⚠️ Two-Way Binding Error: Failed to setup binding",
145
- g(m({}, r), {
145
+ f(h({}, r), {
146
146
  expression: t,
147
147
  lineHint: (r == null ? void 0 : r.lineHint) || "$model binding"
148
148
  })
149
149
  );
150
- i.error(s), i.error(` Error details: ${e.message}`);
151
- }, Se = (t, e) => {
150
+ n.error(s), n.error(` Error details: ${e.message}`);
151
+ }, ye = (t, e) => {
152
152
  var r;
153
- return m({
153
+ return h({
154
154
  componentName: (t == null ? void 0 : t.tagName) || ((r = t == null ? void 0 : t.constructor) == null ? void 0 : r.name),
155
155
  componentPath: (t == null ? void 0 : t.sourcePath) || (t == null ? void 0 : t._sourcePath)
156
156
  }, e);
157
- }, u = /* @__PURE__ */ new Map(), V = 25, X = (t) => {
157
+ }, u = /* @__PURE__ */ new Map(), K = 25, O = (t) => {
158
158
  const e = u.get(t);
159
159
  return e && (u.delete(t), u.set(t, e)), e;
160
- }, Y = (t, e) => {
160
+ }, G = (t, e) => {
161
161
  if (u.has(t))
162
162
  u.delete(t);
163
- else if (u.size >= V) {
163
+ else if (u.size >= K) {
164
164
  const r = u.keys().next().value;
165
165
  r && u.delete(r);
166
166
  }
167
167
  u.set(t, e);
168
- }, N = (t) => d(null, null, function* () {
168
+ }, N = (t) => p(null, null, function* () {
169
169
  if (!t)
170
170
  throw new Error("Path cannot be null or empty");
171
- const e = X(t);
171
+ const e = O(t);
172
172
  if (e) return e;
173
173
  try {
174
174
  const r = yield fetch(t);
@@ -177,17 +177,17 @@ const M = () => {
177
177
  `Failed to fetch component from ${t}: ${r.statusText}`
178
178
  );
179
179
  const s = yield r.text();
180
- return Y(t, s), s;
180
+ return G(t, s), s;
181
181
  } catch (r) {
182
- z(t, r, { componentPath: t });
182
+ H(t, r, { componentPath: t });
183
183
  }
184
- }), Q = (t) => d(null, null, function* () {
184
+ }), J = (t) => p(null, null, function* () {
185
185
  try {
186
186
  const e = yield fetch(t);
187
187
  if (!e.ok) throw new Error(`HTTP ${e.status}`);
188
188
  return yield e.text();
189
189
  } catch (e) {
190
- return z(t, e), "";
190
+ return H(t, e), "";
191
191
  }
192
192
  }), b = {
193
193
  bindings: /{([^}]+)}/g,
@@ -196,19 +196,19 @@ const M = () => {
196
196
  css: /\/\*[\s\S]*?\*\//g,
197
197
  html: /<!--[\s\S]*?-->/g
198
198
  }
199
- }, U = new DOMParser(), T = (t, e) => d(null, null, function* () {
200
- const r = Z(t), { scripts: s, externalScripts: o } = te(r), n = yield se(r), l = r.body.innerHTML.trim();
199
+ }, V = new DOMParser(), x = (t, e) => p(null, null, function* () {
200
+ const r = X(t), { scripts: s, externalScripts: o } = Q(r), i = yield Z(r), l = r.body.innerHTML.trim();
201
201
  return {
202
202
  tagName: e,
203
203
  template: l,
204
204
  scripts: s,
205
205
  externalScripts: o,
206
- styles: n
206
+ styles: i
207
207
  };
208
- }), Z = (t) => U.parseFromString(
208
+ }), X = (t) => V.parseFromString(
209
209
  t.replace(b.comments.html, ""),
210
210
  "text/html"
211
- ), ee = (t) => [
211
+ ), Y = (t) => [
212
212
  "/@vite/",
213
213
  // Vite dev client
214
214
  "/__vite",
@@ -223,33 +223,33 @@ const M = () => {
223
223
  // Browser Sync
224
224
  "/livereload.js"
225
225
  // LiveReload
226
- ].some((r) => t.includes(r)), te = (t) => {
226
+ ].some((r) => t.includes(r)), Q = (t) => {
227
227
  var s, o;
228
228
  const e = [], r = [];
229
- for (const n of t.querySelectorAll("script")) {
230
- if (n.src) {
231
- if (ee(n.src)) {
232
- n.remove();
229
+ for (const i of t.querySelectorAll("script")) {
230
+ if (i.src) {
231
+ if (Y(i.src)) {
232
+ i.remove();
233
233
  continue;
234
234
  }
235
- const l = n.hasAttribute("external");
235
+ const l = i.hasAttribute("external");
236
236
  r.push({
237
- src: n.getAttribute("src") || n.src,
237
+ src: i.getAttribute("src") || i.src,
238
238
  // Use getAttribute to preserve relative paths
239
- type: (s = n.type) != null ? s : null,
239
+ type: (s = i.type) != null ? s : null,
240
240
  external: l
241
241
  });
242
- } else if (n.textContent) {
243
- let l = n.textContent.trim();
242
+ } else if (i.textContent) {
243
+ let l = i.textContent.trim();
244
244
  l = l.replace(b.comments.js, "").trim(), e.push({
245
245
  content: l,
246
- type: (o = n.type) != null ? o : null
246
+ type: (o = i.type) != null ? o : null
247
247
  });
248
248
  }
249
- n.remove();
249
+ i.remove();
250
250
  }
251
251
  return { scripts: e, externalScripts: r };
252
- }, re = (t) => {
252
+ }, U = (t) => {
253
253
  const e = t.match(/const __vite__css = "((?:[^"\\]|\\.)*)"/);
254
254
  if (e && e[1])
255
255
  return e[1].replace(/\\r\\n/g, `
@@ -258,47 +258,47 @@ const M = () => {
258
258
  const r = t.match(/export\s+default\s+"((?:[^"\\]|\\.)*)"/);
259
259
  return r && r[1] ? r[1].replace(/\\r\\n/g, `
260
260
  `).replace(/\\n/g, `
261
- `).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (i.warn(
261
+ `).replace(/\\t/g, " ").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : t.includes("import") || t.includes("export") ? (n.warn(
262
262
  "CSS file returned JavaScript module format. CSS may not load correctly."
263
263
  ), "") : t;
264
- }, se = (t) => d(null, null, function* () {
264
+ }, Z = (t) => p(null, null, function* () {
265
265
  let e = "";
266
266
  const r = t.querySelectorAll("style, link[rel='stylesheet']");
267
267
  for (const s of r) {
268
268
  if (s.tagName === "LINK") {
269
- const n = yield Q(s.href), l = re(n);
269
+ const i = yield J(s.href), l = U(i);
270
270
  l && (e += `
271
271
  ` + l);
272
272
  } else if (s.tagName === "STYLE") {
273
273
  const o = s;
274
274
  if (o.textContent) {
275
- let n = o.textContent.trim();
276
- n = n.replace(b.comments.css, "").trim(), e += `
277
- ` + n;
275
+ let i = o.textContent.trim();
276
+ i = i.replace(b.comments.css, "").trim(), e += `
277
+ ` + i;
278
278
  }
279
279
  }
280
280
  s.remove();
281
281
  }
282
282
  return e.trim();
283
283
  });
284
- var h, A, F;
285
- class oe {
284
+ var w, T, A;
285
+ class ee {
286
286
  constructor() {
287
- H(this, h);
288
- this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null;
287
+ z(this, w);
288
+ this.components = {}, this.lazyComponents = /* @__PURE__ */ new Set(), this.intersectionObserver = null, this.lazyLoadingInProgress = /* @__PURE__ */ new Map(), this.lazyComponentsLoaded = /* @__PURE__ */ new Set();
289
289
  }
290
290
  registerComponent(e, r, s = !0, o = !1) {
291
- return d(this, null, function* () {
291
+ return p(this, null, function* () {
292
292
  if (this.components[e]) {
293
- i.warn(`Component with name "${e}" is already registered.`);
293
+ n.warn(`Component with name "${e}" is already registered.`);
294
294
  return;
295
295
  }
296
296
  if (o) {
297
- this.lazyComponents.add(e), S(this, h, A).call(this, e, r, s), i.log(`Component ${e} registered as lazy-loaded`);
297
+ this.lazyComponents.add(e), $(this, w, T).call(this, e, r, s), n.log(`Component ${e} registered as lazy-loaded`);
298
298
  return;
299
299
  }
300
300
  try {
301
- const n = yield N(r), l = yield T(n, e);
301
+ const i = yield N(r), l = yield x(i, e);
302
302
  this.components[e] = {
303
303
  tagName: e,
304
304
  template: l.template,
@@ -307,23 +307,23 @@ class oe {
307
307
  styles: l.styles,
308
308
  sourcePath: r,
309
309
  lazy: !1
310
- }, i.log(`Component ${e} registered successfully`), yield S(this, h, F).call(this, e, s);
311
- } catch (n) {
312
- x(e, r, n);
310
+ }, n.log(`Component ${e} registered successfully`), yield $(this, w, A).call(this, e, s);
311
+ } catch (i) {
312
+ _(e, r, i);
313
313
  return;
314
314
  }
315
315
  });
316
316
  }
317
317
  }
318
- h = new WeakSet(), /**
318
+ w = new WeakSet(), /**
319
319
  * Defines a lazy-loading placeholder component
320
320
  * @param name - Component name
321
321
  * @param path - Component path
322
322
  * @param useShadowDOM - Whether to use Shadow DOM
323
323
  */
324
- A = function(e, r, s) {
324
+ T = function(e, r, s) {
325
325
  const o = this;
326
- class n extends HTMLElement {
326
+ class i extends HTMLElement {
327
327
  constructor() {
328
328
  super(), this.loaded = !1, this.observer = null, s && (this.attachShadow({ mode: "open" }), this.shadowRoot && (this.shadowRoot.innerHTML = `
329
329
  <style>
@@ -344,8 +344,8 @@ A = function(e, r, s) {
344
344
  });
345
345
  },
346
346
  {
347
- rootMargin: "50px"
348
- // Load 50px before entering viewport
347
+ rootMargin: "100px"
348
+ // Load 100px before entering viewport
349
349
  }
350
350
  ), this.observer.observe(this);
351
351
  }
@@ -354,54 +354,80 @@ A = function(e, r, s) {
354
354
  this.observer && (this.observer.disconnect(), this.observer = null);
355
355
  }
356
356
  loadComponent() {
357
- return d(this, null, function* () {
357
+ return p(this, null, function* () {
358
358
  try {
359
- i.log(`Lazy loading component: ${e}`);
360
- const a = this, c = this.parentNode, f = this.nextSibling;
361
- if (!c) {
362
- J(`Placeholder for ${e} has no parent node`, {
363
- componentName: e,
364
- componentPath: r
365
- });
359
+ if (o.lazyComponentsLoaded.has(e)) {
360
+ n.log(
361
+ `Component ${e} already loaded, upgrading placeholder...`
362
+ ), this.upgradePlaceholder();
363
+ return;
364
+ }
365
+ if (o.lazyLoadingInProgress.has(e)) {
366
+ n.log(`Component ${e} is already loading, waiting...`), yield o.lazyLoadingInProgress.get(e), this.upgradePlaceholder();
366
367
  return;
367
368
  }
368
- const q = yield N(r), y = yield T(q, e);
369
- i.log(`Component ${e} parsed successfully`), o.components[e] = {
370
- tagName: e,
371
- template: y.template,
372
- scripts: y.scripts,
373
- externalScripts: y.externalScripts,
374
- styles: y.styles,
375
- sourcePath: r,
376
- lazy: !0
377
- };
378
- const w = `${e}-real`;
379
- i.log(`Defining real component with temp name: ${w}`);
380
- const B = o.components[e].tagName;
381
- o.components[e].tagName = w;
382
- const { defineWebComponent: j } = yield import("./webcomponent-DrCSyWrI.mjs");
383
- j(o.components[e], s), i.log(`Real component ${w} defined`), o.components[e].tagName = B;
384
- const E = document.createElement(w);
385
- for (i.log(`Created real component instance: ${w}`), Array.from(a.attributes).forEach((v) => {
386
- E.setAttribute(v.name, v.value);
387
- }); a.firstChild; )
388
- E.appendChild(a.firstChild);
389
- f ? (c.insertBefore(E, f), i.log("Inserted real component before next sibling")) : (c.appendChild(E), i.log("Appended real component to parent")), c.removeChild(a), i.log("Removed placeholder element"), o.lazyComponents.delete(e), i.log(`Component ${e} lazy-loaded successfully`);
369
+ const a = this.performLoad();
370
+ o.lazyLoadingInProgress.set(e, a), yield a, o.lazyLoadingInProgress.delete(e), o.lazyComponentsLoaded.add(e), o.lazyComponents.delete(e), n.log(`Component ${e} lazy-loaded successfully`);
390
371
  } catch (a) {
391
- x(e, r, a);
372
+ o.lazyLoadingInProgress.delete(e), _(e, r, a);
373
+ }
374
+ });
375
+ }
376
+ performLoad() {
377
+ return p(this, null, function* () {
378
+ n.log(`Lazy loading component: ${e}`);
379
+ const a = this.parentNode;
380
+ if (this.nextSibling, !a) {
381
+ M(`Placeholder for ${e} has no parent node`, {
382
+ componentName: e,
383
+ componentPath: r
384
+ });
385
+ return;
392
386
  }
387
+ const c = yield N(r), d = yield x(c, e);
388
+ n.log(`Component ${e} parsed successfully`), o.components[e] = {
389
+ tagName: e,
390
+ template: d.template,
391
+ scripts: d.scripts,
392
+ externalScripts: d.externalScripts,
393
+ styles: d.styles,
394
+ sourcePath: r,
395
+ lazy: !0
396
+ };
397
+ const m = `${e}-real`;
398
+ n.log(`Defining real component with temp name: ${m}`);
399
+ const y = o.components[e].tagName;
400
+ o.components[e].tagName = m;
401
+ const { defineWebComponent: C } = yield import("./webcomponent-DT_kduma.mjs");
402
+ C(o.components[e], s), n.log(`Real component ${m} defined`), o.components[e].tagName = y, this.upgradePlaceholder();
393
403
  });
394
404
  }
405
+ upgradePlaceholder() {
406
+ const a = this, c = this.parentNode, d = this.nextSibling;
407
+ if (!c) {
408
+ M(`Placeholder for ${e} has no parent node`, {
409
+ componentName: e,
410
+ componentPath: r
411
+ });
412
+ return;
413
+ }
414
+ const m = `${e}-real`, y = document.createElement(m);
415
+ for (n.log(`Created real component instance: ${m}`), Array.from(a.attributes).forEach((C) => {
416
+ C.name !== "eager" && y.setAttribute(C.name, C.value);
417
+ }); a.firstChild; )
418
+ y.appendChild(a.firstChild);
419
+ d ? (c.insertBefore(y, d), n.log("Inserted real component before next sibling")) : (c.appendChild(y), n.log("Appended real component to parent")), c.removeChild(a), n.log("Removed placeholder element");
420
+ }
395
421
  }
396
- customElements.get(e) || customElements.define(e, n);
397
- }, F = function(e, r) {
398
- return d(this, null, function* () {
399
- const { defineWebComponent: s } = yield import("./webcomponent-DrCSyWrI.mjs");
422
+ customElements.get(e) || customElements.define(e, i);
423
+ }, A = function(e, r) {
424
+ return p(this, null, function* () {
425
+ const { defineWebComponent: s } = yield import("./webcomponent-DT_kduma.mjs");
400
426
  this.components[e] && s(this.components[e], r);
401
427
  });
402
428
  };
403
- const L = new oe();
404
- class ne {
429
+ const F = new ee();
430
+ class te {
405
431
  constructor() {
406
432
  this.listeners = /* @__PURE__ */ new Map();
407
433
  }
@@ -421,17 +447,17 @@ class ne {
421
447
  const o = this.listeners.get(e);
422
448
  if (!o || o.size === 0)
423
449
  return Promise.resolve();
424
- const n = [];
450
+ const i = [];
425
451
  return o.forEach((l) => {
426
452
  try {
427
453
  const a = l(r);
428
- a instanceof Promise && n.push(a);
454
+ a instanceof Promise && i.push(a);
429
455
  } catch (a) {
430
- i.error(
456
+ n.error(
431
457
  `⚠️ Event Bus Error: Failed to execute listener for "${e}"`
432
- ), i.error(` Error details: ${a.message}`), n.push(Promise.reject(a));
458
+ ), n.error(` Error details: ${a.message}`), i.push(Promise.reject(a));
433
459
  }
434
- }), n.length > 0 ? Promise.all(n).then(() => {
460
+ }), i.length > 0 ? Promise.all(i).then(() => {
435
461
  }) : Promise.resolve();
436
462
  }
437
463
  /**
@@ -471,38 +497,38 @@ class ne {
471
497
  return (s = (r = this.listeners.get(e)) == null ? void 0 : r.size) != null ? s : 0;
472
498
  }
473
499
  }
474
- const R = new ne(), ie = (t, e, r, s) => L.registerComponent(t, e, r, s), le = (t) => d(null, null, function* () {
500
+ const R = new te(), re = (t, e, r, s) => F.registerComponent(t, e, r, s), se = (t) => p(null, null, function* () {
475
501
  yield Promise.all(
476
502
  t.map(
477
- ({ name: e, path: r, useShadowDOM: s, lazy: o }) => L.registerComponent(e, r, s, o)
503
+ ({ name: e, path: r, useShadowDOM: s, lazy: o }) => F.registerComponent(e, r, s, o)
478
504
  )
479
505
  );
480
- }), ae = (t, e) => R.listen(t, e), ce = (t, e) => {
506
+ }), oe = (t, e) => R.listen(t, e), ne = (t, e) => {
481
507
  R.emit(t, e);
482
- }, $e = (t, e) => {
508
+ }, we = (t, e) => {
483
509
  if (e) {
484
510
  const r = e.tagName.toLowerCase();
485
511
  window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(r, { shadowRoot: t, element: e });
486
512
  }
487
- }, C = () => {
513
+ }, E = () => {
488
514
  const t = window.__ladrilloContexts;
489
515
  if (t && t.size > 0) {
490
516
  const e = Array.from(t.values());
491
517
  return e[e.length - 1];
492
518
  }
493
519
  return null;
494
- }, de = () => {
495
- const t = C();
520
+ }, ie = () => {
521
+ const t = E();
496
522
  return t && t.element ? t.element.state || {} : {};
497
- }, $ = (t) => {
498
- const e = C();
523
+ }, S = (t) => {
524
+ const e = E();
499
525
  e && e.setState && e.setState(t);
500
- }, ue = (t, e) => ($({ [t]: e }), (r) => {
501
- $({ [t]: r });
502
- }), pe = (t, e) => {
526
+ }, ae = (t, e) => (S({ [t]: e }), (r) => {
527
+ S({ [t]: r });
528
+ }), le = (t, e) => {
503
529
  if (e)
504
530
  return e.querySelector(t);
505
- const r = C();
531
+ const r = E();
506
532
  if (r) {
507
533
  const s = r.shadowRoot || r.element;
508
534
  if (s) {
@@ -511,10 +537,10 @@ const R = new ne(), ie = (t, e, r, s) => L.registerComponent(t, e, r, s), le = (
511
537
  }
512
538
  }
513
539
  return document.querySelector(t);
514
- }, me = (t, e) => {
540
+ }, ce = (t, e) => {
515
541
  if (e)
516
542
  return e.querySelectorAll(t);
517
- const r = C();
543
+ const r = E();
518
544
  if (r) {
519
545
  const s = r.shadowRoot || r.element;
520
546
  if (s) {
@@ -525,30 +551,30 @@ const R = new ne(), ie = (t, e, r, s) => L.registerComponent(t, e, r, s), le = (
525
551
  return document.querySelectorAll(t);
526
552
  };
527
553
  typeof window != "undefined" && (window.ladrillosjs = {
528
- registerComponent: ie,
529
- registerComponents: le
530
- }, window.$listen = ae, window.$emit = ce, window.$querySelector = pe, window.$querySelectorAll = me, window.$reactive = ue, window.$setState = $, window.$getState = de);
554
+ registerComponent: re,
555
+ registerComponents: se
556
+ }, window.$listen = oe, window.$emit = ne, window.$querySelector = le, window.$querySelectorAll = ce, window.$reactive = ae, window.$setState = S, window.$getState = ie);
531
557
  export {
532
- ae as $,
558
+ oe as $,
533
559
  b as R,
534
- $e as _,
535
- fe as a,
536
- ye as b,
537
- Se as c,
538
- we as d,
539
- he as e,
560
+ we as _,
561
+ pe as a,
562
+ he as b,
563
+ ye as c,
564
+ ge as d,
565
+ ue as e,
540
566
  R as f,
541
- Ee as g,
542
- i as h,
543
- Ce as i,
544
- le as j,
545
- ce as k,
546
- J as l,
547
- de as m,
548
- $ as n,
549
- ue as o,
550
- pe as p,
551
- me as q,
552
- ie as r
567
+ fe as g,
568
+ n as h,
569
+ me as i,
570
+ se as j,
571
+ ne as k,
572
+ M as l,
573
+ ie as m,
574
+ S as n,
575
+ ae as o,
576
+ le as p,
577
+ ce as q,
578
+ re as r
553
579
  };
554
- //# sourceMappingURL=index-DymB3-NG.mjs.map
580
+ //# sourceMappingURL=index-JWdjGiUA.mjs.map