@trunkjs/browser-utils 1.0.50 → 1.0.53

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/index.js CHANGED
@@ -1,42 +1,42 @@
1
- var B = Object.defineProperty;
2
- var _ = (e) => {
3
- throw TypeError(e);
1
+ var O = Object.defineProperty;
2
+ var P = (n) => {
3
+ throw TypeError(n);
4
4
  };
5
- var O = (e, t, n) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
- var m = (e, t, n) => O(e, typeof t != "symbol" ? t + "" : t, n), T = (e, t, n) => t.has(e) || _("Cannot " + n);
7
- var l = (e, t, n) => (T(e, t, "read from private field"), n ? n.call(e) : t.get(e)), f = (e, t, n) => t.has(e) ? _("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), b = (e, t, n, i) => (T(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), w = (e, t, n) => (T(e, t, "access private method"), n);
8
- const v = [
5
+ var j = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
6
+ var f = (n, t, e) => j(n, typeof t != "symbol" ? t + "" : t, e), T = (n, t, e) => t.has(n) || P("Cannot " + e);
7
+ var l = (n, t, e) => (T(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => t.has(n) ? P("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), y = (n, t, e, i) => (T(n, t, "write to private field"), i ? i.call(n, e) : t.set(n, e), e), w = (n, t, e) => (T(n, t, "access private method"), e);
8
+ const E = [
9
9
  { name: "xs", minWidth: 0 },
10
10
  { name: "sm", minWidth: 576 },
11
11
  { name: "md", minWidth: 768 },
12
12
  { name: "lg", minWidth: 992 },
13
13
  { name: "xl", minWidth: 1200 },
14
14
  { name: "xxl", minWidth: 1400 }
15
- ], M = v.reduce(
16
- (e, t) => (e[t.name] = t.minWidth, e),
15
+ ], S = E.reduce(
16
+ (n, t) => (n[t.name] = t.minWidth, n),
17
17
  {}
18
18
  );
19
- function E(e) {
20
- if (!(e in M))
21
- throw new Error(`Unknown breakpoint: ${e}`);
22
- return M[e];
19
+ function p(n) {
20
+ if (!(n in S))
21
+ throw new Error(`Unknown breakpoint: ${n}`);
22
+ return S[n];
23
23
  }
24
- function U() {
24
+ function F() {
25
25
  return window.visualViewport ? window.visualViewport.width : window.innerWidth;
26
26
  }
27
- function j(e) {
28
- e === void 0 && (e = U());
29
- for (let t = v.length - 1; t >= 0; t--)
30
- if (e >= v[t].minWidth)
31
- return v[t].name;
27
+ function U(n) {
28
+ n === void 0 && (n = F());
29
+ for (let t = E.length - 1; t >= 0; t--)
30
+ if (n >= E[t].minWidth)
31
+ return E[t].name;
32
32
  return "xs";
33
33
  }
34
- function X(e, t = {}, n = []) {
35
- Array.isArray(n) || (n = [n]);
36
- const i = document.createElement(e);
34
+ function nt(n, t = {}, e = []) {
35
+ Array.isArray(e) || (e = [e]);
36
+ const i = document.createElement(n);
37
37
  for (const r in t)
38
38
  t[r] !== null && t[r] !== void 0 && i.setAttribute(r, t[r] !== !0 ? t[r] : "");
39
- for (const r of n)
39
+ for (const r of e)
40
40
  i.append(typeof r == "string" ? document.createTextNode(r) : r);
41
41
  return i;
42
42
  }
@@ -46,11 +46,11 @@ class C {
46
46
  * @param delay Debounce delay in milliseconds
47
47
  * @param max_delay Maximum delay in milliseconds, if false then no maximum delay is applied
48
48
  */
49
- constructor(t, n = !1) {
50
- m(this, "timeout", null);
51
- m(this, "startTimeWithMs", 0);
52
- m(this, "maxTimeout", null);
53
- this.delay = t, this.max_delay = n;
49
+ constructor(t, e = !1) {
50
+ f(this, "timeout", null);
51
+ f(this, "startTimeWithMs", 0);
52
+ f(this, "maxTimeout", null);
53
+ this.delay = t, this.max_delay = e;
54
54
  }
55
55
  async wait() {
56
56
  return this.startTimeWithMs === 0 && (this.startTimeWithMs = Date.now()), this.timeout && (this.max_delay === !1 || this.startTimeWithMs + this.max_delay > Date.now()) && (clearTimeout(this.timeout), this.timeout = null), new Promise((t) => {
@@ -64,55 +64,232 @@ class C {
64
64
  * @param callback
65
65
  */
66
66
  debounce(t) {
67
- const n = Date.now();
68
- this.startTimeWithMs === 0 && (this.startTimeWithMs = n);
67
+ const e = Date.now();
68
+ this.startTimeWithMs === 0 && (this.startTimeWithMs = e);
69
69
  const i = () => {
70
70
  this.timeout && (clearTimeout(this.timeout), this.timeout = null), this.maxTimeout && (clearTimeout(this.maxTimeout), this.maxTimeout = null), this.startTimeWithMs = 0, t();
71
71
  };
72
72
  if (this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(i, this.delay), this.max_delay !== !1 && !this.maxTimeout) {
73
- const r = n - this.startTimeWithMs, o = Math.max(0, this.max_delay - r);
74
- this.maxTimeout = setTimeout(i, o);
73
+ const r = e - this.startTimeWithMs, s = Math.max(0, this.max_delay - r);
74
+ this.maxTimeout = setTimeout(i, s);
75
75
  }
76
76
  }
77
77
  }
78
- function Q(e, t = !1) {
79
- const n = /* @__PURE__ */ new WeakMap();
78
+ function it(n, t = !1) {
79
+ const e = /* @__PURE__ */ new WeakMap();
80
80
  return function(i, r) {
81
81
  if (r.kind !== "method") return i;
82
- const o = r.name;
83
- return function(...c) {
84
- let s = n.get(this);
85
- s || (s = /* @__PURE__ */ new Map(), n.set(this, s));
86
- let a = s.get(o);
87
- a || (a = new C(e, t), s.set(o, a)), a.debounce(() => i.apply(this, c));
82
+ const s = r.name;
83
+ return function(...a) {
84
+ let o = e.get(this);
85
+ o || (o = /* @__PURE__ */ new Map(), e.set(this, o));
86
+ let u = o.get(s);
87
+ u || (u = new C(n, t), o.set(s, u)), u.debounce(() => i.apply(this, a));
88
88
  };
89
89
  };
90
90
  }
91
- function Y(e) {
92
- if (typeof e.lineNumber == "number")
91
+ const H = /* @__PURE__ */ new Set(["button", "image", "reset", "submit"]);
92
+ function z(n) {
93
+ return n.endsWith("[]") ? n.slice(0, -2) : n;
94
+ }
95
+ function L(n) {
96
+ return n instanceof HTMLInputElement ? n.type.toLowerCase() : "";
97
+ }
98
+ function G(n) {
99
+ if (n instanceof HTMLSelectElement && n.multiple)
100
+ return Array.from(n.selectedOptions, (t) => t.value);
101
+ if (n instanceof HTMLInputElement) {
102
+ if (n.type === "file")
103
+ return Array.from(n.files ?? []);
104
+ if (n.type === "checkbox")
105
+ return n.checked;
106
+ if (n.type === "radio")
107
+ return n.checked ? n.value : void 0;
108
+ }
109
+ return n.value;
110
+ }
111
+ function K(n, t) {
112
+ if (n instanceof HTMLSelectElement && n.multiple) {
113
+ const e = new Set(Array.isArray(t) ? t.map(String) : t == null ? [] : [String(t)]);
114
+ for (const i of Array.from(n.options))
115
+ i.selected = e.has(i.value);
116
+ return;
117
+ }
118
+ if (n instanceof HTMLInputElement) {
119
+ if (n.type === "file") {
120
+ (t == null || Array.isArray(t) && t.length === 0) && (n.value = "");
121
+ return;
122
+ }
123
+ if (n.type === "checkbox") {
124
+ n.checked = !!t;
125
+ return;
126
+ }
127
+ if (n.type === "radio") {
128
+ n.checked = typeof t == "boolean" ? t : n.value === String(t);
129
+ return;
130
+ }
131
+ }
132
+ n.value = t;
133
+ }
134
+ function A(n, t, e) {
135
+ if (!(e == null || e === !1)) {
136
+ if (e instanceof FormData) {
137
+ e.forEach((i, r) => n.append(r, i));
138
+ return;
139
+ }
140
+ if (Array.isArray(e)) {
141
+ e.forEach((i) => A(n, t, i));
142
+ return;
143
+ }
144
+ if (e instanceof Blob) {
145
+ n.append(t, e);
146
+ return;
147
+ }
148
+ n.append(t, String(e));
149
+ }
150
+ }
151
+ class rt {
152
+ constructor(t) {
153
+ this.root = t;
154
+ }
155
+ get entries() {
156
+ const t = [];
157
+ for (const e of Array.from(this.root.querySelectorAll("[name]"))) {
158
+ const i = this.getName(e);
159
+ !i || !this.isValueElement(e) || this.hasValueElementParent(e) || t.push({
160
+ name: i,
161
+ element: e,
162
+ get value() {
163
+ return G(e);
164
+ },
165
+ set value(r) {
166
+ K(e, r);
167
+ }
168
+ });
169
+ }
170
+ return t;
171
+ }
172
+ get data() {
173
+ const t = {};
174
+ for (const [e, i] of this.groupedEntries) {
175
+ const r = this.readGroup(i);
176
+ r !== void 0 && (t[e] = r);
177
+ }
178
+ return t;
179
+ }
180
+ set data(t) {
181
+ for (const [e, i] of this.groupedEntries)
182
+ Object.prototype.hasOwnProperty.call(t, e) && this.writeGroup(i, t[e]);
183
+ }
184
+ get formData() {
185
+ const t = new FormData();
186
+ for (const e of this.entries) {
187
+ if (this.isDisabled(e.element))
188
+ continue;
189
+ const i = L(e.element);
190
+ if (i === "checkbox" || i === "radio") {
191
+ const r = e.element;
192
+ r.checked && A(t, e.name, r.value);
193
+ continue;
194
+ }
195
+ A(t, e.name, e.value);
196
+ }
197
+ return t;
198
+ }
199
+ get groupedEntries() {
200
+ const t = /* @__PURE__ */ new Map();
201
+ for (const e of this.entries) {
202
+ const i = z(e.name), r = t.get(i) ?? [];
203
+ r.push(e), t.set(i, r);
204
+ }
205
+ return t;
206
+ }
207
+ getName(t) {
208
+ var i;
209
+ const e = "name" in t && typeof t.name == "string" ? t.name : null;
210
+ return (e == null ? void 0 : e.trim()) || ((i = t.getAttribute("name")) == null ? void 0 : i.trim()) || null;
211
+ }
212
+ isValueElement(t) {
213
+ return !("value" in t) || t instanceof HTMLButtonElement ? !1 : !(t instanceof HTMLInputElement && H.has(t.type.toLowerCase()));
214
+ }
215
+ /** A named value element owns its value, so its descendants are not collected twice. */
216
+ hasValueElementParent(t) {
217
+ let e = t.parentElement;
218
+ for (; e && e !== this.root; ) {
219
+ if (this.getName(e) && this.isValueElement(e))
220
+ return !0;
221
+ e = e.parentElement;
222
+ }
223
+ return !1;
224
+ }
225
+ isDisabled(t) {
226
+ return !!t.disabled || t.hasAttribute("disabled") || t.matches(":disabled");
227
+ }
228
+ readGroup(t) {
229
+ var r;
230
+ const e = new Set(t.map((s) => L(s.element))), i = t.some((s) => s.name.endsWith("[]"));
231
+ return e.size === 1 && e.has("radio") ? (r = t.find((s) => s.element.checked)) == null ? void 0 : r.element.value : e.size === 1 && e.has("checkbox") ? t.length === 1 && !i ? t[0].element.checked : t.filter((s) => s.element.checked).map((s) => s.element.value) : i ? t.flatMap((s) => {
232
+ const a = s.value;
233
+ return a === void 0 ? [] : Array.isArray(a) ? a : [a];
234
+ }) : t.length === 1 ? t[0].value : t.map((s) => s.value).at(-1);
235
+ }
236
+ writeGroup(t, e) {
237
+ const i = new Set(t.map((s) => L(s.element))), r = t.some((s) => s.name.endsWith("[]"));
238
+ if (i.size === 1 && i.has("radio")) {
239
+ t.forEach((s) => {
240
+ const a = s.element;
241
+ a.checked = a.value === String(e);
242
+ });
243
+ return;
244
+ }
245
+ if (i.size === 1 && i.has("checkbox")) {
246
+ if (t.length === 1 && !r && typeof e == "boolean") {
247
+ t[0].element.checked = e;
248
+ return;
249
+ }
250
+ const s = new Set((Array.isArray(e) ? e : e == null ? [] : [e]).map(String));
251
+ t.forEach((a) => {
252
+ const o = a.element;
253
+ o.checked = s.has(o.value);
254
+ });
255
+ return;
256
+ }
257
+ if (r && Array.isArray(e) && t.length > 1) {
258
+ t.forEach((s, a) => {
259
+ s.value = e[a];
260
+ });
261
+ return;
262
+ }
263
+ t.forEach((s) => {
264
+ s.value = e;
265
+ });
266
+ }
267
+ }
268
+ function st(n) {
269
+ if (typeof n.lineNumber == "number")
93
270
  return {
94
- file: e.fileName || e.sourceURL,
95
- line: e.lineNumber,
96
- column: e.columnNumber ?? void 0
271
+ file: n.fileName || n.sourceURL,
272
+ line: n.lineNumber,
273
+ column: n.columnNumber ?? void 0
97
274
  };
98
- if (typeof e.line == "number")
275
+ if (typeof n.line == "number")
99
276
  return {
100
- file: e.sourceURL,
101
- line: e.line,
102
- column: e.column
277
+ file: n.sourceURL,
278
+ line: n.line,
279
+ column: n.column
103
280
  };
104
- const n = String(e.stack || e.message || "").split(`
281
+ const e = String(n.stack || n.message || "").split(`
105
282
  `), i = /(.*?)(?:\(|@)?(.*?):(\d+):(\d+)\)?$/;
106
- for (const r of n) {
107
- const o = r.match(i);
108
- if (o)
109
- return { file: o[2], line: +o[3], column: +o[4] };
283
+ for (const r of e) {
284
+ const s = r.match(i);
285
+ if (s)
286
+ return { file: s[2], line: +s[3], column: +s[4] };
110
287
  }
111
- return { file: e.fileName || e.sourceURL };
288
+ return { file: n.fileName || n.sourceURL };
112
289
  }
113
- class V {
114
- constructor(t, n, i, r = "main") {
115
- this._debug = t, this.myTag = n, this.myElementId = i, this.instanceId = r;
290
+ class q {
291
+ constructor(t, e, i, r = "main") {
292
+ this._debug = t, this.myTag = e, this.myElementId = i, this.instanceId = r;
116
293
  }
117
294
  debug(...t) {
118
295
  this._debug && console.debug(`[DEBUG][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
@@ -127,23 +304,23 @@ class V {
127
304
  console.error(`[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
128
305
  }
129
306
  throwError(...t) {
130
- const n = `[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
131
- throw this.error(...t), new Error(n);
307
+ const e = `[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
308
+ throw this.error(...t), new Error(e);
132
309
  }
133
310
  }
134
- class Z {
135
- constructor(t, n = !0) {
136
- m(this, "label");
137
- m(this, "last");
138
- m(this, "startTime");
139
- m(this, "running", !1);
140
- m(this, "enabled");
141
- this.label = t, this.enabled = n, this.startTime = this.last = performance.now(), this.running = !0;
311
+ class ot {
312
+ constructor(t, e = !0) {
313
+ f(this, "label");
314
+ f(this, "last");
315
+ f(this, "startTime");
316
+ f(this, "running", !1);
317
+ f(this, "enabled");
318
+ this.label = t, this.enabled = e, this.startTime = this.last = performance.now(), this.running = !0;
142
319
  }
143
320
  lap(t = "") {
144
321
  if (!this.enabled) return;
145
- const n = performance.now(), i = (n - this.last) / 1e3;
146
- this.last = n, console.debug(`[${this.label}] ${t} +${i.toFixed(3)}s`);
322
+ const e = performance.now(), i = (e - this.last) / 1e3;
323
+ this.last = e, console.debug(`[${this.label}] ${t} +${i.toFixed(3)}s`);
147
324
  }
148
325
  elapsed() {
149
326
  return performance.now() - this.startTime;
@@ -161,80 +338,80 @@ class Z {
161
338
  return this.running;
162
339
  }
163
340
  }
164
- function F(e) {
165
- return typeof e == "object" && e !== null && !Array.isArray(e);
341
+ function J(n) {
342
+ return typeof n == "object" && n !== null && !Array.isArray(n);
166
343
  }
167
- function K(e) {
168
- if (e != null)
344
+ function X(n) {
345
+ if (n != null)
169
346
  try {
170
- return JSON.parse(e);
347
+ return JSON.parse(n);
171
348
  } catch {
172
349
  return;
173
350
  }
174
351
  }
175
- function P(e) {
176
- const t = JSON.stringify(e);
352
+ function _(n) {
353
+ const t = JSON.stringify(n);
177
354
  return t === void 0 ? "null" : t;
178
355
  }
179
- function z(e, t) {
180
- const n = { ...t };
181
- if (F(e))
356
+ function Q(n, t) {
357
+ const e = { ...t };
358
+ if (J(n))
182
359
  for (const i of Object.keys(t))
183
- i in e && (n[i] = e[i]);
184
- return n;
360
+ i in n && (e[i] = n[i]);
361
+ return e;
185
362
  }
186
- class A {
187
- constructor(t, n, i) {
188
- m(this, "cache");
189
- this.backend = t, this.storageKey = n, this.initialValue = i;
363
+ class I {
364
+ constructor(t, e, i) {
365
+ f(this, "cache");
366
+ this.backend = t, this.storageKey = e, this.initialValue = i;
190
367
  }
191
368
  read() {
192
369
  if (this.cache) return this.cache;
193
- const t = this.backend ? K(this.backend.getItem(this.storageKey)) : void 0, n = z(t, this.initialValue);
370
+ const t = this.backend ? X(this.backend.getItem(this.storageKey)) : void 0, e = Q(t, this.initialValue);
194
371
  if (this.backend && this.backend.getItem(this.storageKey) == null)
195
372
  try {
196
- this.backend.setItem(this.storageKey, P(n));
373
+ this.backend.setItem(this.storageKey, _(e));
197
374
  } catch {
198
375
  }
199
- return this.cache = n, n;
376
+ return this.cache = e, e;
200
377
  }
201
378
  write(t) {
202
379
  if (this.cache = t, !!this.backend)
203
380
  try {
204
- this.backend.setItem(this.storageKey, P(t));
381
+ this.backend.setItem(this.storageKey, _(t));
205
382
  } catch {
206
383
  }
207
384
  }
208
385
  asProxy() {
209
386
  const t = {
210
- get: (n, i) => {
387
+ get: (e, i) => {
211
388
  if (typeof i == "symbol")
212
389
  return i === Symbol.toStringTag ? "Storage" : void 0;
213
390
  const r = this.read();
214
391
  return i === "toJSON" ? () => ({ ...r }) : r[i];
215
392
  },
216
- set: (n, i, r) => {
393
+ set: (e, i, r) => {
217
394
  if (typeof i != "string") return !1;
218
- const c = { ...this.read() };
219
- return c[i] = r, this.write(c), !0;
395
+ const a = { ...this.read() };
396
+ return a[i] = r, this.write(a), !0;
220
397
  },
221
- deleteProperty: (n, i) => {
398
+ deleteProperty: (e, i) => {
222
399
  if (typeof i != "string") return !1;
223
400
  const r = this.read();
224
401
  if (!(i in r)) return !0;
225
- const o = { ...r };
226
- return delete o[i], this.write(o), !0;
402
+ const s = { ...r };
403
+ return delete s[i], this.write(s), !0;
227
404
  },
228
- has: (n, i) => {
405
+ has: (e, i) => {
229
406
  if (typeof i != "string") return !1;
230
407
  const r = this.read();
231
408
  return i in r;
232
409
  },
233
410
  ownKeys: () => {
234
- const n = this.read();
235
- return Reflect.ownKeys(n);
411
+ const e = this.read();
412
+ return Reflect.ownKeys(e);
236
413
  },
237
- getOwnPropertyDescriptor: (n, i) => {
414
+ getOwnPropertyDescriptor: (e, i) => {
238
415
  if (typeof i != "string") return;
239
416
  const r = this.read();
240
417
  if (i in r)
@@ -249,187 +426,187 @@ class A {
249
426
  return new Proxy({}, t);
250
427
  }
251
428
  }
252
- function W(e) {
429
+ function W(n) {
253
430
  const t = globalThis.window;
254
- return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
431
+ return (n === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
255
432
  }
256
- function tt(e, t) {
257
- return new A(W("session"), e, t).asProxy();
433
+ function at(n, t) {
434
+ return new I(W("session"), n, t).asProxy();
258
435
  }
259
- function et(e, t) {
260
- return new A(W("local"), e, t).asProxy();
436
+ function ut(n, t) {
437
+ return new I(W("local"), n, t).asProxy();
261
438
  }
262
- function L(e, t, n) {
439
+ function x(n, t, e) {
263
440
  return new Promise((i, r) => {
264
- const o = (c) => {
265
- e.removeEventListener(t, o, n), i(c);
441
+ const s = (a) => {
442
+ n.removeEventListener(t, s, e), i(a);
266
443
  };
267
- e.addEventListener(t, o, n);
444
+ n.addEventListener(t, s, e);
268
445
  });
269
446
  }
270
- function H() {
271
- return document.readyState === "loading" ? new Promise((e) => {
272
- document.addEventListener("DOMContentLoaded", () => e());
447
+ function Y() {
448
+ return document.readyState === "loading" ? new Promise((n) => {
449
+ document.addEventListener("DOMContentLoaded", () => n());
273
450
  }) : Promise.resolve();
274
451
  }
275
- function nt() {
276
- return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : L(window, "loader:ready") : x();
452
+ function ct() {
453
+ return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : x(window, "loader:ready") : M();
277
454
  }
278
- function it() {
279
- return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : L(window, "loader:pre-visual") : x();
455
+ function dt() {
456
+ return window.tj_loader_state ? window.tj_loader_state === "pre-visual" || window.tj_loader_state === "visual" ? Promise.resolve() : x(window, "loader:pre-visual") : M();
280
457
  }
281
- function rt() {
282
- return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : L(window, "loader:visual") : x();
458
+ function lt() {
459
+ return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : x(window, "loader:visual") : M();
283
460
  }
284
- function x(e = window) {
285
- return e || (e = window), e === window ? document.readyState === "complete" ? Promise.resolve() : new Promise((t) => window.addEventListener("load", () => t(), { once: !0 })) : e instanceof HTMLImageElement ? e.complete && e.naturalWidth !== 0 ? Promise.resolve() : new Promise((t, n) => {
286
- e.addEventListener("load", () => t(), { once: !0 }), e.addEventListener("error", () => n(new Error("image error")), { once: !0 });
287
- }) : e instanceof HTMLMediaElement ? e.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA ? Promise.resolve() : new Promise((t) => e.addEventListener("loadeddata", () => t(), { once: !0 })) : new Promise((t) => e.addEventListener("load", () => t(), { once: !0 }));
461
+ function M(n = window) {
462
+ return n || (n = window), n === window ? document.readyState === "complete" ? Promise.resolve() : new Promise((t) => window.addEventListener("load", () => t(), { once: !0 })) : n instanceof HTMLImageElement ? n.complete && n.naturalWidth !== 0 ? Promise.resolve() : new Promise((t, e) => {
463
+ n.addEventListener("load", () => t(), { once: !0 }), n.addEventListener("error", () => e(new Error("image error")), { once: !0 });
464
+ }) : n instanceof HTMLMediaElement ? n.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA ? Promise.resolve() : new Promise((t) => n.addEventListener("loadeddata", () => t(), { once: !0 })) : new Promise((t) => n.addEventListener("load", () => t(), { once: !0 }));
288
465
  }
289
- function st(e) {
290
- return new Promise((t) => setTimeout(t, e));
466
+ function ht(n) {
467
+ return new Promise((t) => setTimeout(t, n));
291
468
  }
292
- function ot(e) {
469
+ function ft(n) {
293
470
  return new Promise((t) => {
294
- const n = (i) => {
295
- e.removeEventListener("animationend", n), t(i);
471
+ const e = (i) => {
472
+ n.removeEventListener("animationend", e), t(i);
296
473
  };
297
- e.addEventListener("animationend", n);
474
+ n.addEventListener("animationend", e);
298
475
  });
299
476
  }
300
- function at(e) {
301
- var n, i;
302
- class t extends e {
477
+ function mt(n) {
478
+ var e, i;
479
+ class t extends n {
303
480
  constructor() {
304
481
  super(...arguments);
305
- f(this, n, new C(200, 5e3));
306
- m(this, "currentBreakPoint", null);
307
- f(this, i, async () => {
308
- var y;
309
- await l(this, n).wait(), await H();
310
- const c = this, s = window.innerWidth;
311
- let a = getComputedStyle(c).getPropertyValue("--breakpoint");
312
- if (!a || a === "")
482
+ m(this, e, new C(200, 5e3));
483
+ f(this, "currentBreakPoint", null);
484
+ m(this, i, async () => {
485
+ var b;
486
+ await l(this, e).wait(), await Y();
487
+ const a = this, o = window.innerWidth;
488
+ let u = getComputedStyle(a).getPropertyValue("--breakpoint");
489
+ if (!u || u === "")
313
490
  return;
314
- a = a.trim().replace(/^['"]|['"]$/g, "");
315
- const u = a.split(","), d = u[0].trim(), h = ((y = u[1]) == null ? void 0 : y.trim()) ?? d, g = j(s);
316
- this.currentBreakPoint !== g && (E(h) <= E(g) ? c.setAttribute("mode", "desktop") : E(d) > E(g) ? c.setAttribute("mode", "mobile") : c.setAttribute("mode", "tablet"));
491
+ u = u.trim().replace(/^['"]|['"]$/g, "");
492
+ const c = u.split(","), d = c[0].trim(), h = ((b = c[1]) == null ? void 0 : b.trim()) ?? d, g = U(o);
493
+ this.currentBreakPoint !== g && (p(h) <= p(g) ? a.setAttribute("mode", "desktop") : p(d) > p(g) ? a.setAttribute("mode", "mobile") : a.setAttribute("mode", "tablet"));
317
494
  });
318
495
  }
319
496
  connectedCallback() {
320
497
  super.connectedCallback();
321
498
  try {
322
499
  l(this, i).call(this), window.addEventListener("resize", l(this, i)), l(this, i).call(this);
323
- } catch (c) {
324
- throw console.error("Error in BreakPointMixin:", c, "in element", this), c;
500
+ } catch (a) {
501
+ throw console.error("Error in BreakPointMixin:", a, "in element", this), a;
325
502
  }
326
503
  }
327
504
  disconnectedCallback() {
328
505
  super.disconnectedCallback(), window.removeEventListener("resize", l(this, i));
329
506
  }
330
507
  }
331
- return n = new WeakMap(), i = new WeakMap(), t;
508
+ return e = new WeakMap(), i = new WeakMap(), t;
332
509
  }
333
- const p = Symbol("listenerDefs"), $ = Symbol("withEventBindings");
334
- function ut(e, t) {
335
- const n = Array.isArray(e) ? e : [e];
510
+ const k = Symbol("listenerDefs"), N = Symbol("withEventBindings");
511
+ function gt(n, t) {
512
+ const e = Array.isArray(n) ? n : [n];
336
513
  return function(i, r) {
337
514
  if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
338
515
  return r.addInitializer(function() {
339
- const o = this;
340
- (o[p] || (o[p] = [])).push({
516
+ const s = this;
517
+ (s[k] || (s[k] = [])).push({
341
518
  method: r.name,
342
- events: [...n],
519
+ events: [...e],
343
520
  opts: t
344
521
  });
345
- }), function(...o) {
346
- if (!this[$])
522
+ }), function(...s) {
523
+ if (!this[N])
347
524
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
348
- return i.apply(this, o);
525
+ return i.apply(this, s);
349
526
  };
350
527
  };
351
528
  }
352
- function G(e, t) {
353
- var n;
354
- return !t || t === "host" ? e : t === "document" ? e.ownerDocument ?? document : t === "window" ? ((n = e.ownerDocument) == null ? void 0 : n.defaultView) ?? window : t === "shadowRoot" ? e.shadowRoot ?? e : typeof t == "function" ? t(e) : t;
355
- }
356
- function dt(e) {
357
- var n, i, I;
358
- class t extends e {
359
- constructor(...s) {
360
- super(...s);
361
- f(this, i);
362
- f(this, n);
363
- this[$] = !0;
529
+ function Z(n, t) {
530
+ var e;
531
+ return !t || t === "host" ? n : t === "document" ? n.ownerDocument ?? document : t === "window" ? ((e = n.ownerDocument) == null ? void 0 : e.defaultView) ?? window : t === "shadowRoot" ? n.shadowRoot ?? n : typeof t == "function" ? t(n) : t;
532
+ }
533
+ function wt(n) {
534
+ var e, i, $;
535
+ class t extends n {
536
+ constructor(...o) {
537
+ super(...o);
538
+ m(this, i);
539
+ m(this, e);
540
+ this[N] = !0;
364
541
  }
365
542
  connectedCallback() {
366
- var s;
367
- (s = super.connectedCallback) == null || s.call(this), w(this, i, I).call(this);
543
+ var o;
544
+ (o = super.connectedCallback) == null || o.call(this), w(this, i, $).call(this);
368
545
  }
369
546
  disconnectedCallback() {
370
- var s, a;
371
- (s = l(this, n)) == null || s.abort(), (a = super.disconnectedCallback) == null || a.call(this);
547
+ var o, u;
548
+ (o = l(this, e)) == null || o.abort(), (u = super.disconnectedCallback) == null || u.call(this);
372
549
  }
373
550
  }
374
- return n = new WeakMap(), i = new WeakSet(), I = function() {
375
- var a, u, d;
376
- (a = l(this, n)) == null || a.abort(), b(this, n, new AbortController());
377
- const s = this[p] || [];
378
- for (const h of s) {
379
- const g = G(this, (u = h.opts) == null ? void 0 : u.target), y = ((d = h.opts) == null ? void 0 : d.options) ?? {}, D = this[h.method].bind(this);
551
+ return e = new WeakMap(), i = new WeakSet(), $ = function() {
552
+ var u, c, d;
553
+ (u = l(this, e)) == null || u.abort(), y(this, e, new AbortController());
554
+ const o = this[k] || [];
555
+ for (const h of o) {
556
+ const g = Z(this, (c = h.opts) == null ? void 0 : c.target), b = ((d = h.opts) == null ? void 0 : d.options) ?? {}, V = this[h.method].bind(this);
380
557
  for (const R of h.events)
381
- g.addEventListener(R, D, { ...y, signal: l(this, n).signal });
558
+ g.addEventListener(R, V, { ...b, signal: l(this, e).signal });
382
559
  }
383
560
  }, t;
384
561
  }
385
- let q = 1;
386
- function lt(e) {
387
- var n, i, r;
388
- class t extends e {
562
+ let tt = 1;
563
+ function yt(n) {
564
+ var e, i, r;
565
+ class t extends n {
389
566
  constructor() {
390
567
  super(...arguments);
391
- f(this, n, null);
392
- f(this, i, q++);
393
- f(this, r, null);
568
+ m(this, e, null);
569
+ m(this, i, tt++);
570
+ m(this, r, null);
394
571
  }
395
572
  /**
396
573
  * Clears the cached debug flag so the attribute will be checked again
397
574
  * on the next log/warn/error call.
398
575
  */
399
576
  invalidateDebugCache() {
400
- b(this, n, null);
577
+ y(this, e, null);
401
578
  }
402
579
  get _debug() {
403
- return l(this, n) !== null ? l(this, n) : (this instanceof HTMLElement && b(this, n, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), l(this, n) === !0 && console.info(
580
+ return l(this, e) !== null ? l(this, e) : (this instanceof HTMLElement && y(this, e, this.hasAttribute("debug") && !["false", "0", "off", "no"].includes(this.getAttribute("debug") || "")), l(this, e) === !0 && console.info(
404
581
  // @ts-expect-error - it says tagName is not defined -whatever
405
582
  `[DEBUG][ID:${l(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
406
583
  this
407
- ), l(this, n) ?? !1);
584
+ ), l(this, e) ?? !1);
408
585
  }
409
- getLogger(s = "main") {
410
- const a = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
411
- return l(this, r) || b(this, r, new V(this._debug, a, `${l(this, i)}`, s)), l(this, r);
586
+ getLogger(o = "main") {
587
+ const u = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
588
+ return l(this, r) || y(this, r, new q(this._debug, u, `${l(this, i)}`, o)), l(this, r);
412
589
  }
413
- debug(...s) {
414
- this.getLogger().debug(...s);
590
+ debug(...o) {
591
+ this.getLogger().debug(...o);
415
592
  }
416
- log(...s) {
417
- this.getLogger().log(...s);
593
+ log(...o) {
594
+ this.getLogger().log(...o);
418
595
  }
419
- warn(...s) {
420
- this.getLogger().warn(...s);
596
+ warn(...o) {
597
+ this.getLogger().warn(...o);
421
598
  }
422
- error(...s) {
423
- this.getLogger().error(...s);
599
+ error(...o) {
600
+ this.getLogger().error(...o);
424
601
  }
425
- throwError(...s) {
426
- return this.getLogger().throwError(...s);
602
+ throwError(...o) {
603
+ return this.getLogger().throwError(...o);
427
604
  }
428
605
  }
429
- return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
606
+ return e = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
430
607
  }
431
- function ct(e) {
432
- class t extends e {
608
+ function bt(n) {
609
+ class t extends n {
433
610
  connectedCallback() {
434
611
  this.dispatchEvent(
435
612
  new CustomEvent("init:child-waitreq", {
@@ -470,60 +647,61 @@ function ct(e) {
470
647
  }
471
648
  return t;
472
649
  }
473
- function ht(e) {
474
- var n, N, r, k, S;
475
- class t extends e {
650
+ function pt(n) {
651
+ var e, D, r, v, B;
652
+ class t extends n {
476
653
  constructor() {
477
654
  super(...arguments);
478
- f(this, n);
479
- f(this, r, (u) => {
480
- const d = u.target, h = w(this, n, k).call(this, d.assignedNodes({ flatten: !0 })), g = w(this, n, k).call(this, d.childNodes);
655
+ m(this, e);
656
+ m(this, r, (c) => {
657
+ const d = c.target, h = w(this, e, v).call(this, d.assignedNodes({ flatten: !0 })), g = w(this, e, v).call(this, d.childNodes);
481
658
  h || g ? d.classList.remove("slot-empty") : d.classList.add("slot-empty");
482
659
  });
483
660
  }
484
- firstUpdated(u) {
661
+ firstUpdated(c) {
485
662
  var d;
486
- (d = super.firstUpdated) == null || d.call(this, u), w(this, n, N).call(this);
663
+ (d = super.firstUpdated) == null || d.call(this, c), w(this, e, D).call(this);
487
664
  }
488
665
  }
489
- return n = new WeakSet(), N = function() {
666
+ return e = new WeakSet(), D = function() {
490
667
  var d;
491
- const u = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
492
- u == null || u.forEach((h) => {
493
- w(this, n, k).call(this, h.childNodes) || h.classList.add("slot-empty"), h.addEventListener("slotchange", (g) => l(this, r).call(this, g));
668
+ const c = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
669
+ c == null || c.forEach((h) => {
670
+ w(this, e, v).call(this, h.childNodes) || h.classList.add("slot-empty"), h.addEventListener("slotchange", (g) => l(this, r).call(this, g));
494
671
  });
495
- }, r = new WeakMap(), k = function(u) {
496
- return Array.from(u).some((d) => w(this, n, S).call(this, d));
497
- }, S = function(u) {
498
- return u.nodeType === Node.TEXT_NODE ? (u.textContent || "").trim().length > 0 : u.nodeType === Node.ELEMENT_NODE;
672
+ }, r = new WeakMap(), v = function(c) {
673
+ return Array.from(c).some((d) => w(this, e, B).call(this, d));
674
+ }, B = function(c) {
675
+ return c.nodeType === Node.TEXT_NODE ? (c.textContent || "").trim().length > 0 : c.nodeType === Node.ELEMENT_NODE;
499
676
  }, t;
500
677
  }
501
678
  export {
502
- at as BreakPointMixin,
679
+ mt as BreakPointMixin,
503
680
  C as Debouncer,
504
- dt as EventBindingsMixin,
505
- ut as Listen,
506
- ct as LoaderMixin,
507
- V as Logger,
508
- lt as LoggingMixin,
509
- ht as SlotVisibilityMixin,
510
- Z as Stopwatch,
511
- M as breakpointMap,
512
- v as breakpoints,
513
- X as create_element,
514
- Q as debounce,
515
- E as getBreakpointMinWidth,
516
- j as getCurrentBreakpoint,
517
- Y as getErrorLocation,
518
- U as getViewportWidth,
519
- et as local_storage,
520
- tt as session_storage,
521
- st as sleep,
522
- L as waitFor,
523
- ot as waitForAnimationEnd,
524
- H as waitForDomContentLoaded,
525
- x as waitForLoad,
526
- it as waitForPreVisual,
527
- nt as waitForReady,
528
- rt as waitForVisual
681
+ wt as EventBindingsMixin,
682
+ rt as FormDataAccessor,
683
+ gt as Listen,
684
+ bt as LoaderMixin,
685
+ q as Logger,
686
+ yt as LoggingMixin,
687
+ pt as SlotVisibilityMixin,
688
+ ot as Stopwatch,
689
+ S as breakpointMap,
690
+ E as breakpoints,
691
+ nt as create_element,
692
+ it as debounce,
693
+ p as getBreakpointMinWidth,
694
+ U as getCurrentBreakpoint,
695
+ st as getErrorLocation,
696
+ F as getViewportWidth,
697
+ ut as local_storage,
698
+ at as session_storage,
699
+ ht as sleep,
700
+ x as waitFor,
701
+ ft as waitForAnimationEnd,
702
+ Y as waitForDomContentLoaded,
703
+ M as waitForLoad,
704
+ dt as waitForPreVisual,
705
+ ct as waitForReady,
706
+ lt as waitForVisual
529
707
  };