@trunkjs/browser-utils 1.0.50 → 1.0.52

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 S = (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) || S("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) ? S("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
+ ], _ = 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 _))
21
+ throw new Error(`Unknown breakpoint: ${n}`);
22
+ return _[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,222 @@ 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) || 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
+ isDisabled(t) {
216
+ return !!t.disabled || t.hasAttribute("disabled") || t.matches(":disabled");
217
+ }
218
+ readGroup(t) {
219
+ var r;
220
+ const e = new Set(t.map((s) => L(s.element))), i = t.some((s) => s.name.endsWith("[]"));
221
+ 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) => {
222
+ const a = s.value;
223
+ return a === void 0 ? [] : Array.isArray(a) ? a : [a];
224
+ }) : t.length === 1 ? t[0].value : t.map((s) => s.value).at(-1);
225
+ }
226
+ writeGroup(t, e) {
227
+ const i = new Set(t.map((s) => L(s.element))), r = t.some((s) => s.name.endsWith("[]"));
228
+ if (i.size === 1 && i.has("radio")) {
229
+ t.forEach((s) => {
230
+ const a = s.element;
231
+ a.checked = a.value === String(e);
232
+ });
233
+ return;
234
+ }
235
+ if (i.size === 1 && i.has("checkbox")) {
236
+ if (t.length === 1 && !r && typeof e == "boolean") {
237
+ t[0].element.checked = e;
238
+ return;
239
+ }
240
+ const s = new Set((Array.isArray(e) ? e : e == null ? [] : [e]).map(String));
241
+ t.forEach((a) => {
242
+ const o = a.element;
243
+ o.checked = s.has(o.value);
244
+ });
245
+ return;
246
+ }
247
+ if (r && Array.isArray(e) && t.length > 1) {
248
+ t.forEach((s, a) => {
249
+ s.value = e[a];
250
+ });
251
+ return;
252
+ }
253
+ t.forEach((s) => {
254
+ s.value = e;
255
+ });
256
+ }
257
+ }
258
+ function st(n) {
259
+ if (typeof n.lineNumber == "number")
93
260
  return {
94
- file: e.fileName || e.sourceURL,
95
- line: e.lineNumber,
96
- column: e.columnNumber ?? void 0
261
+ file: n.fileName || n.sourceURL,
262
+ line: n.lineNumber,
263
+ column: n.columnNumber ?? void 0
97
264
  };
98
- if (typeof e.line == "number")
265
+ if (typeof n.line == "number")
99
266
  return {
100
- file: e.sourceURL,
101
- line: e.line,
102
- column: e.column
267
+ file: n.sourceURL,
268
+ line: n.line,
269
+ column: n.column
103
270
  };
104
- const n = String(e.stack || e.message || "").split(`
271
+ const e = String(n.stack || n.message || "").split(`
105
272
  `), 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] };
273
+ for (const r of e) {
274
+ const s = r.match(i);
275
+ if (s)
276
+ return { file: s[2], line: +s[3], column: +s[4] };
110
277
  }
111
- return { file: e.fileName || e.sourceURL };
278
+ return { file: n.fileName || n.sourceURL };
112
279
  }
113
- class V {
114
- constructor(t, n, i, r = "main") {
115
- this._debug = t, this.myTag = n, this.myElementId = i, this.instanceId = r;
280
+ class q {
281
+ constructor(t, e, i, r = "main") {
282
+ this._debug = t, this.myTag = e, this.myElementId = i, this.instanceId = r;
116
283
  }
117
284
  debug(...t) {
118
285
  this._debug && console.debug(`[DEBUG][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
@@ -127,23 +294,23 @@ class V {
127
294
  console.error(`[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}]`, ...t);
128
295
  }
129
296
  throwError(...t) {
130
- const n = `[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
131
- throw this.error(...t), new Error(n);
297
+ const e = `[ERROR][${this.myTag}:${this.myElementId}:${this.instanceId}] ${t.join(" ")}`;
298
+ throw this.error(...t), new Error(e);
132
299
  }
133
300
  }
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;
301
+ class ot {
302
+ constructor(t, e = !0) {
303
+ f(this, "label");
304
+ f(this, "last");
305
+ f(this, "startTime");
306
+ f(this, "running", !1);
307
+ f(this, "enabled");
308
+ this.label = t, this.enabled = e, this.startTime = this.last = performance.now(), this.running = !0;
142
309
  }
143
310
  lap(t = "") {
144
311
  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`);
312
+ const e = performance.now(), i = (e - this.last) / 1e3;
313
+ this.last = e, console.debug(`[${this.label}] ${t} +${i.toFixed(3)}s`);
147
314
  }
148
315
  elapsed() {
149
316
  return performance.now() - this.startTime;
@@ -161,42 +328,42 @@ class Z {
161
328
  return this.running;
162
329
  }
163
330
  }
164
- function F(e) {
165
- return typeof e == "object" && e !== null && !Array.isArray(e);
331
+ function J(n) {
332
+ return typeof n == "object" && n !== null && !Array.isArray(n);
166
333
  }
167
- function K(e) {
168
- if (e != null)
334
+ function X(n) {
335
+ if (n != null)
169
336
  try {
170
- return JSON.parse(e);
337
+ return JSON.parse(n);
171
338
  } catch {
172
339
  return;
173
340
  }
174
341
  }
175
- function P(e) {
176
- const t = JSON.stringify(e);
342
+ function P(n) {
343
+ const t = JSON.stringify(n);
177
344
  return t === void 0 ? "null" : t;
178
345
  }
179
- function z(e, t) {
180
- const n = { ...t };
181
- if (F(e))
346
+ function Q(n, t) {
347
+ const e = { ...t };
348
+ if (J(n))
182
349
  for (const i of Object.keys(t))
183
- i in e && (n[i] = e[i]);
184
- return n;
350
+ i in n && (e[i] = n[i]);
351
+ return e;
185
352
  }
186
- class A {
187
- constructor(t, n, i) {
188
- m(this, "cache");
189
- this.backend = t, this.storageKey = n, this.initialValue = i;
353
+ class I {
354
+ constructor(t, e, i) {
355
+ f(this, "cache");
356
+ this.backend = t, this.storageKey = e, this.initialValue = i;
190
357
  }
191
358
  read() {
192
359
  if (this.cache) return this.cache;
193
- const t = this.backend ? K(this.backend.getItem(this.storageKey)) : void 0, n = z(t, this.initialValue);
360
+ const t = this.backend ? X(this.backend.getItem(this.storageKey)) : void 0, e = Q(t, this.initialValue);
194
361
  if (this.backend && this.backend.getItem(this.storageKey) == null)
195
362
  try {
196
- this.backend.setItem(this.storageKey, P(n));
363
+ this.backend.setItem(this.storageKey, P(e));
197
364
  } catch {
198
365
  }
199
- return this.cache = n, n;
366
+ return this.cache = e, e;
200
367
  }
201
368
  write(t) {
202
369
  if (this.cache = t, !!this.backend)
@@ -207,34 +374,34 @@ class A {
207
374
  }
208
375
  asProxy() {
209
376
  const t = {
210
- get: (n, i) => {
377
+ get: (e, i) => {
211
378
  if (typeof i == "symbol")
212
379
  return i === Symbol.toStringTag ? "Storage" : void 0;
213
380
  const r = this.read();
214
381
  return i === "toJSON" ? () => ({ ...r }) : r[i];
215
382
  },
216
- set: (n, i, r) => {
383
+ set: (e, i, r) => {
217
384
  if (typeof i != "string") return !1;
218
- const c = { ...this.read() };
219
- return c[i] = r, this.write(c), !0;
385
+ const a = { ...this.read() };
386
+ return a[i] = r, this.write(a), !0;
220
387
  },
221
- deleteProperty: (n, i) => {
388
+ deleteProperty: (e, i) => {
222
389
  if (typeof i != "string") return !1;
223
390
  const r = this.read();
224
391
  if (!(i in r)) return !0;
225
- const o = { ...r };
226
- return delete o[i], this.write(o), !0;
392
+ const s = { ...r };
393
+ return delete s[i], this.write(s), !0;
227
394
  },
228
- has: (n, i) => {
395
+ has: (e, i) => {
229
396
  if (typeof i != "string") return !1;
230
397
  const r = this.read();
231
398
  return i in r;
232
399
  },
233
400
  ownKeys: () => {
234
- const n = this.read();
235
- return Reflect.ownKeys(n);
401
+ const e = this.read();
402
+ return Reflect.ownKeys(e);
236
403
  },
237
- getOwnPropertyDescriptor: (n, i) => {
404
+ getOwnPropertyDescriptor: (e, i) => {
238
405
  if (typeof i != "string") return;
239
406
  const r = this.read();
240
407
  if (i in r)
@@ -249,187 +416,187 @@ class A {
249
416
  return new Proxy({}, t);
250
417
  }
251
418
  }
252
- function W(e) {
419
+ function W(n) {
253
420
  const t = globalThis.window;
254
- return (e === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
421
+ return (n === "session" ? t == null ? void 0 : t.sessionStorage : t == null ? void 0 : t.localStorage) ?? void 0;
255
422
  }
256
- function tt(e, t) {
257
- return new A(W("session"), e, t).asProxy();
423
+ function at(n, t) {
424
+ return new I(W("session"), n, t).asProxy();
258
425
  }
259
- function et(e, t) {
260
- return new A(W("local"), e, t).asProxy();
426
+ function ut(n, t) {
427
+ return new I(W("local"), n, t).asProxy();
261
428
  }
262
- function L(e, t, n) {
429
+ function x(n, t, e) {
263
430
  return new Promise((i, r) => {
264
- const o = (c) => {
265
- e.removeEventListener(t, o, n), i(c);
431
+ const s = (a) => {
432
+ n.removeEventListener(t, s, e), i(a);
266
433
  };
267
- e.addEventListener(t, o, n);
434
+ n.addEventListener(t, s, e);
268
435
  });
269
436
  }
270
- function H() {
271
- return document.readyState === "loading" ? new Promise((e) => {
272
- document.addEventListener("DOMContentLoaded", () => e());
437
+ function Y() {
438
+ return document.readyState === "loading" ? new Promise((n) => {
439
+ document.addEventListener("DOMContentLoaded", () => n());
273
440
  }) : Promise.resolve();
274
441
  }
275
- function nt() {
276
- return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : L(window, "loader:ready") : x();
442
+ function ct() {
443
+ return window.tj_loader_state ? window.tj_loader_state !== "loading" ? Promise.resolve() : x(window, "loader:ready") : M();
277
444
  }
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();
445
+ function dt() {
446
+ 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
447
  }
281
- function rt() {
282
- return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : L(window, "loader:visual") : x();
448
+ function lt() {
449
+ return window.tj_loader_state ? window.tj_loader_state === "visual" ? Promise.resolve() : x(window, "loader:visual") : M();
283
450
  }
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 }));
451
+ function M(n = window) {
452
+ 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) => {
453
+ n.addEventListener("load", () => t(), { once: !0 }), n.addEventListener("error", () => e(new Error("image error")), { once: !0 });
454
+ }) : 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
455
  }
289
- function st(e) {
290
- return new Promise((t) => setTimeout(t, e));
456
+ function ht(n) {
457
+ return new Promise((t) => setTimeout(t, n));
291
458
  }
292
- function ot(e) {
459
+ function ft(n) {
293
460
  return new Promise((t) => {
294
- const n = (i) => {
295
- e.removeEventListener("animationend", n), t(i);
461
+ const e = (i) => {
462
+ n.removeEventListener("animationend", e), t(i);
296
463
  };
297
- e.addEventListener("animationend", n);
464
+ n.addEventListener("animationend", e);
298
465
  });
299
466
  }
300
- function at(e) {
301
- var n, i;
302
- class t extends e {
467
+ function mt(n) {
468
+ var e, i;
469
+ class t extends n {
303
470
  constructor() {
304
471
  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 === "")
472
+ m(this, e, new C(200, 5e3));
473
+ f(this, "currentBreakPoint", null);
474
+ m(this, i, async () => {
475
+ var b;
476
+ await l(this, e).wait(), await Y();
477
+ const a = this, o = window.innerWidth;
478
+ let u = getComputedStyle(a).getPropertyValue("--breakpoint");
479
+ if (!u || u === "")
313
480
  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"));
481
+ u = u.trim().replace(/^['"]|['"]$/g, "");
482
+ const c = u.split(","), d = c[0].trim(), h = ((b = c[1]) == null ? void 0 : b.trim()) ?? d, g = U(o);
483
+ this.currentBreakPoint !== g && (p(h) <= p(g) ? a.setAttribute("mode", "desktop") : p(d) > p(g) ? a.setAttribute("mode", "mobile") : a.setAttribute("mode", "tablet"));
317
484
  });
318
485
  }
319
486
  connectedCallback() {
320
487
  super.connectedCallback();
321
488
  try {
322
489
  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;
490
+ } catch (a) {
491
+ throw console.error("Error in BreakPointMixin:", a, "in element", this), a;
325
492
  }
326
493
  }
327
494
  disconnectedCallback() {
328
495
  super.disconnectedCallback(), window.removeEventListener("resize", l(this, i));
329
496
  }
330
497
  }
331
- return n = new WeakMap(), i = new WeakMap(), t;
498
+ return e = new WeakMap(), i = new WeakMap(), t;
332
499
  }
333
- const p = Symbol("listenerDefs"), $ = Symbol("withEventBindings");
334
- function ut(e, t) {
335
- const n = Array.isArray(e) ? e : [e];
500
+ const k = Symbol("listenerDefs"), $ = Symbol("withEventBindings");
501
+ function gt(n, t) {
502
+ const e = Array.isArray(n) ? n : [n];
336
503
  return function(i, r) {
337
504
  if (r.kind !== "method") throw new Error("@Listen nur für Methoden");
338
505
  return r.addInitializer(function() {
339
- const o = this;
340
- (o[p] || (o[p] = [])).push({
506
+ const s = this;
507
+ (s[k] || (s[k] = [])).push({
341
508
  method: r.name,
342
- events: [...n],
509
+ events: [...e],
343
510
  opts: t
344
511
  });
345
- }), function(...o) {
512
+ }), function(...s) {
346
513
  if (!this[$])
347
514
  throw new Error("[EventBindings] @Listen - decorator requires EventBindingMixin.");
348
- return i.apply(this, o);
515
+ return i.apply(this, s);
349
516
  };
350
517
  };
351
518
  }
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);
519
+ function Z(n, t) {
520
+ var e;
521
+ 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;
522
+ }
523
+ function wt(n) {
524
+ var e, i, N;
525
+ class t extends n {
526
+ constructor(...o) {
527
+ super(...o);
528
+ m(this, i);
529
+ m(this, e);
363
530
  this[$] = !0;
364
531
  }
365
532
  connectedCallback() {
366
- var s;
367
- (s = super.connectedCallback) == null || s.call(this), w(this, i, I).call(this);
533
+ var o;
534
+ (o = super.connectedCallback) == null || o.call(this), w(this, i, N).call(this);
368
535
  }
369
536
  disconnectedCallback() {
370
- var s, a;
371
- (s = l(this, n)) == null || s.abort(), (a = super.disconnectedCallback) == null || a.call(this);
537
+ var o, u;
538
+ (o = l(this, e)) == null || o.abort(), (u = super.disconnectedCallback) == null || u.call(this);
372
539
  }
373
540
  }
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);
380
- for (const R of h.events)
381
- g.addEventListener(R, D, { ...y, signal: l(this, n).signal });
541
+ return e = new WeakMap(), i = new WeakSet(), N = function() {
542
+ var u, c, d;
543
+ (u = l(this, e)) == null || u.abort(), y(this, e, new AbortController());
544
+ const o = this[k] || [];
545
+ for (const h of o) {
546
+ const g = Z(this, (c = h.opts) == null ? void 0 : c.target), b = ((d = h.opts) == null ? void 0 : d.options) ?? {}, R = this[h.method].bind(this);
547
+ for (const V of h.events)
548
+ g.addEventListener(V, R, { ...b, signal: l(this, e).signal });
382
549
  }
383
550
  }, t;
384
551
  }
385
- let q = 1;
386
- function lt(e) {
387
- var n, i, r;
388
- class t extends e {
552
+ let tt = 1;
553
+ function yt(n) {
554
+ var e, i, r;
555
+ class t extends n {
389
556
  constructor() {
390
557
  super(...arguments);
391
- f(this, n, null);
392
- f(this, i, q++);
393
- f(this, r, null);
558
+ m(this, e, null);
559
+ m(this, i, tt++);
560
+ m(this, r, null);
394
561
  }
395
562
  /**
396
563
  * Clears the cached debug flag so the attribute will be checked again
397
564
  * on the next log/warn/error call.
398
565
  */
399
566
  invalidateDebugCache() {
400
- b(this, n, null);
567
+ y(this, e, null);
401
568
  }
402
569
  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(
570
+ 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
571
  // @ts-expect-error - it says tagName is not defined -whatever
405
572
  `[DEBUG][ID:${l(this, i)}] LoggingMixin: Debug mode is enabled for <${this.tagName}>`,
406
573
  this
407
- ), l(this, n) ?? !1);
574
+ ), l(this, e) ?? !1);
408
575
  }
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);
576
+ getLogger(o = "main") {
577
+ const u = "<" + (this.tagName || this.constructor.name || "UnknownElement") + ">";
578
+ return l(this, r) || y(this, r, new q(this._debug, u, `${l(this, i)}`, o)), l(this, r);
412
579
  }
413
- debug(...s) {
414
- this.getLogger().debug(...s);
580
+ debug(...o) {
581
+ this.getLogger().debug(...o);
415
582
  }
416
- log(...s) {
417
- this.getLogger().log(...s);
583
+ log(...o) {
584
+ this.getLogger().log(...o);
418
585
  }
419
- warn(...s) {
420
- this.getLogger().warn(...s);
586
+ warn(...o) {
587
+ this.getLogger().warn(...o);
421
588
  }
422
- error(...s) {
423
- this.getLogger().error(...s);
589
+ error(...o) {
590
+ this.getLogger().error(...o);
424
591
  }
425
- throwError(...s) {
426
- return this.getLogger().throwError(...s);
592
+ throwError(...o) {
593
+ return this.getLogger().throwError(...o);
427
594
  }
428
595
  }
429
- return n = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
596
+ return e = new WeakMap(), i = new WeakMap(), r = new WeakMap(), t;
430
597
  }
431
- function ct(e) {
432
- class t extends e {
598
+ function bt(n) {
599
+ class t extends n {
433
600
  connectedCallback() {
434
601
  this.dispatchEvent(
435
602
  new CustomEvent("init:child-waitreq", {
@@ -470,60 +637,61 @@ function ct(e) {
470
637
  }
471
638
  return t;
472
639
  }
473
- function ht(e) {
474
- var n, N, r, k, S;
475
- class t extends e {
640
+ function pt(n) {
641
+ var e, D, r, v, B;
642
+ class t extends n {
476
643
  constructor() {
477
644
  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);
645
+ m(this, e);
646
+ m(this, r, (c) => {
647
+ 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
648
  h || g ? d.classList.remove("slot-empty") : d.classList.add("slot-empty");
482
649
  });
483
650
  }
484
- firstUpdated(u) {
651
+ firstUpdated(c) {
485
652
  var d;
486
- (d = super.firstUpdated) == null || d.call(this, u), w(this, n, N).call(this);
653
+ (d = super.firstUpdated) == null || d.call(this, c), w(this, e, D).call(this);
487
654
  }
488
655
  }
489
- return n = new WeakSet(), N = function() {
656
+ return e = new WeakSet(), D = function() {
490
657
  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));
658
+ const c = (d = this.shadowRoot) == null ? void 0 : d.querySelectorAll("slot");
659
+ c == null || c.forEach((h) => {
660
+ w(this, e, v).call(this, h.childNodes) || h.classList.add("slot-empty"), h.addEventListener("slotchange", (g) => l(this, r).call(this, g));
494
661
  });
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;
662
+ }, r = new WeakMap(), v = function(c) {
663
+ return Array.from(c).some((d) => w(this, e, B).call(this, d));
664
+ }, B = function(c) {
665
+ return c.nodeType === Node.TEXT_NODE ? (c.textContent || "").trim().length > 0 : c.nodeType === Node.ELEMENT_NODE;
499
666
  }, t;
500
667
  }
501
668
  export {
502
- at as BreakPointMixin,
669
+ mt as BreakPointMixin,
503
670
  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
671
+ wt as EventBindingsMixin,
672
+ rt as FormDataAccessor,
673
+ gt as Listen,
674
+ bt as LoaderMixin,
675
+ q as Logger,
676
+ yt as LoggingMixin,
677
+ pt as SlotVisibilityMixin,
678
+ ot as Stopwatch,
679
+ _ as breakpointMap,
680
+ E as breakpoints,
681
+ nt as create_element,
682
+ it as debounce,
683
+ p as getBreakpointMinWidth,
684
+ U as getCurrentBreakpoint,
685
+ st as getErrorLocation,
686
+ F as getViewportWidth,
687
+ ut as local_storage,
688
+ at as session_storage,
689
+ ht as sleep,
690
+ x as waitFor,
691
+ ft as waitForAnimationEnd,
692
+ Y as waitForDomContentLoaded,
693
+ M as waitForLoad,
694
+ dt as waitForPreVisual,
695
+ ct as waitForReady,
696
+ lt as waitForVisual
529
697
  };