beercss 4.0.19 → 4.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cdn/beer.js CHANGED
@@ -1,651 +1,724 @@
1
- const _emptyNodeList = [];
2
- const _weakElements = /* @__PURE__ */ new WeakSet();
3
- const isChrome = navigator.userAgent.includes("Chrome");
4
- navigator.userAgent.includes("Firefox") && !isChrome;
5
- navigator.userAgent.includes("Safari") && !isChrome;
1
+ //#region src/cdn/utils.ts
2
+ var _emptyNodeList = [];
3
+ var _weakMap = /* @__PURE__ */ new WeakMap();
4
+ var isChrome = navigator.userAgent.includes("Chrome");
5
+ navigator.userAgent.includes("Firefox");
6
+ navigator.userAgent.includes("Safari");
6
7
  navigator.userAgent.includes("Windows");
7
- const isMac = navigator.userAgent.includes("Macintosh");
8
+ var isMac = navigator.userAgent.includes("Macintosh");
8
9
  navigator.userAgent.includes("Linux");
9
10
  navigator.userAgent.includes("Android");
10
- const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
11
+ var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
11
12
  function isDark() {
12
- return window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)").matches;
13
+ return window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches ?? false;
13
14
  }
14
15
  async function wait(milliseconds) {
15
- await new Promise((resolve) => setTimeout(resolve, milliseconds));
16
+ await new Promise((resolve) => setTimeout(resolve, milliseconds));
16
17
  }
17
18
  function guid() {
18
- return "fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
19
- const r = Math.random() * 16 | 0;
20
- const v = c === "x" ? r : r & 3 | 8;
21
- return v.toString(16);
22
- });
19
+ return "fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
20
+ const r = Math.random() * 16 | 0;
21
+ return (c === "x" ? r : r & 3 | 8).toString(16);
22
+ });
23
23
  }
24
24
  function query(selector, element) {
25
- try {
26
- return typeof selector === "string" ? (element ?? document).querySelector(selector) : selector;
27
- } catch {
28
- return null;
29
- }
25
+ try {
26
+ return typeof selector === "string" ? (element ?? document).querySelector(selector) : selector;
27
+ } catch {
28
+ return null;
29
+ }
30
30
  }
31
31
  function queryAll(selector, element) {
32
- try {
33
- return typeof selector === "string" ? (element ?? document).querySelectorAll(selector) : selector ?? _emptyNodeList;
34
- } catch {
35
- return _emptyNodeList;
36
- }
32
+ try {
33
+ return typeof selector === "string" ? (element ?? document).querySelectorAll(selector) : selector ?? _emptyNodeList;
34
+ } catch {
35
+ return _emptyNodeList;
36
+ }
37
37
  }
38
38
  function hasClass(element, name) {
39
- return (element == null ? void 0 : element.classList.contains(name)) ?? false;
39
+ return element?.classList.contains(name) ?? false;
40
40
  }
41
41
  function hasTag(element, name) {
42
- var _a;
43
- return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === name;
42
+ return element?.tagName?.toLowerCase() === name;
44
43
  }
45
44
  function hasType(element, name) {
46
- var _a;
47
- return ((_a = element == null ? void 0 : element.type) == null ? void 0 : _a.toLowerCase()) === name;
45
+ return element?.type?.toLowerCase() === name;
48
46
  }
49
47
  function addClass(element, name) {
50
- if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.add(name);
51
- else element == null ? void 0 : element.classList.add(name);
48
+ if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.add(name);
49
+ else element?.classList.add(name);
52
50
  }
53
51
  function removeClass(element, name) {
54
- if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.remove(name);
55
- else element == null ? void 0 : element.classList.remove(name);
52
+ if (element instanceof NodeList) for (let i = 0; i < element.length; i++) element[i].classList.remove(name);
53
+ else element?.classList.remove(name);
56
54
  }
57
55
  function on(element, name, callback, useCapture = true) {
58
- if (element == null ? void 0 : element.addEventListener) element.addEventListener(name, callback, useCapture);
56
+ if (element?.addEventListener) element.addEventListener(name, callback, useCapture);
59
57
  }
60
58
  function onWeak(element, name, callback, useCapture = true) {
61
- addWeakElement(element);
62
- on(element, name, callback, useCapture);
59
+ if (!element) return;
60
+ const el = element;
61
+ let events = _weakMap.get(el);
62
+ if (!events) {
63
+ events = /* @__PURE__ */ new Map();
64
+ _weakMap.set(el, events);
65
+ }
66
+ const key = name + (useCapture ? "1" : "0");
67
+ let callbacks = events.get(key);
68
+ if (!callbacks) {
69
+ callbacks = /* @__PURE__ */ new Set();
70
+ events.set(key, callbacks);
71
+ }
72
+ if (callbacks.has(callback)) return;
73
+ callbacks.add(callback);
74
+ on(element, name, callback, useCapture);
63
75
  }
64
76
  function off(element, name, callback, useCapture = true) {
65
- if (element == null ? void 0 : element.removeEventListener) element.removeEventListener(name, callback, useCapture);
77
+ if (element?.removeEventListener) element.removeEventListener(name, callback, useCapture);
66
78
  }
67
79
  function insertBefore(newElement, element) {
68
- var _a;
69
- (_a = element == null ? void 0 : element.parentNode) == null ? void 0 : _a.insertBefore(newElement, element);
80
+ element?.parentNode?.insertBefore(newElement, element);
70
81
  }
71
82
  function prev(element) {
72
- return element == null ? void 0 : element.previousElementSibling;
83
+ return element?.previousElementSibling;
73
84
  }
74
85
  function next(element) {
75
- return element == null ? void 0 : element.nextElementSibling;
86
+ return element?.nextElementSibling;
76
87
  }
77
88
  function parent(element) {
78
- return element == null ? void 0 : element.parentElement;
89
+ return element?.parentElement;
79
90
  }
80
91
  function create(htmlAttributesAsJson) {
81
- const element = document.createElement("div");
82
- for (let i = 0, keys = Object.keys(htmlAttributesAsJson), n = keys.length; i < n; i++) {
83
- const key = keys[i];
84
- const value = htmlAttributesAsJson[key];
85
- element.setAttribute(key, value);
86
- }
87
- return element;
92
+ const element = document.createElement("div");
93
+ for (let i = 0, keys = Object.keys(htmlAttributesAsJson), n = keys.length; i < n; i++) {
94
+ const key = keys[i];
95
+ const value = htmlAttributesAsJson[key];
96
+ element.setAttribute(key, value);
97
+ }
98
+ return element;
88
99
  }
89
100
  function blurActiveElement() {
90
- var _a;
91
- (_a = document.activeElement) == null ? void 0 : _a.blur();
101
+ document.activeElement?.blur();
92
102
  }
93
103
  function queryAllDataUi(id) {
94
- return queryAll('[data-ui="#' + id + '"]');
104
+ return queryAll("[data-ui=\"#" + id + "\"]");
95
105
  }
96
106
  function queryDataUi(id) {
97
- return query('[data-ui="#' + id + '"]');
107
+ return query("[data-ui=\"#" + id + "\"]");
98
108
  }
99
109
  function updateAllClickable(element) {
100
- if (element.id && hasClass(element, "page")) element = queryDataUi(element.id) ?? element;
101
- const container = parent(element);
102
- if (!hasClass(container, "tabs") && !hasClass(container, "tabbed") && !hasTag(container, "nav")) return;
103
- const as = queryAll("a", container);
104
- for (let i = 0; i < as.length; i++) removeClass(as[i], "active");
105
- if (!hasTag(element, "button") && !hasClass(element, "button") && !hasClass(element, "chip")) addClass(element, "active");
106
- }
107
- function addWeakElement(element) {
108
- if (_weakElements.has(element)) return;
109
- _weakElements.add(element);
110
+ if (element.id && hasClass(element, "page")) element = queryDataUi(element.id) ?? element;
111
+ const container = parent(element);
112
+ if (!hasClass(container, "tabs") && !hasClass(container, "tabbed") && !hasTag(container, "nav")) return;
113
+ const as = queryAll("a", container);
114
+ for (let i = 0; i < as.length; i++) removeClass(as[i], "active");
115
+ if (!hasTag(element, "button") && !hasClass(element, "button") && !hasClass(element, "chip")) addClass(element, "active");
110
116
  }
111
117
  function rootSizeInPixels() {
112
- const size = getComputedStyle(document.documentElement).getPropertyValue("--size") || "16px";
113
- if (size.includes("%")) return parseInt(size) * 16 / 100;
114
- if (size.includes("em")) return parseInt(size) * 16;
115
- return parseInt(size);
118
+ const size = getComputedStyle(document.documentElement).getPropertyValue("--size") || "16px";
119
+ if (size.includes("%")) return parseInt(size) * 16 / 100;
120
+ if (size.includes("em")) return parseInt(size) * 16;
121
+ return parseInt(size);
116
122
  }
123
+ //#endregion
124
+ //#region src/cdn/elements/fields.ts
117
125
  function updatePlaceholder(element) {
118
- if (!element.placeholder) element.placeholder = " ";
126
+ if (!element.placeholder) element.placeholder = " ";
119
127
  }
120
128
  function onClickLabel(e) {
121
- const label = e.currentTarget;
122
- const field = parent(label);
123
- const input = query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea", field);
124
- if (input) input.focus();
129
+ const label = e.currentTarget;
130
+ const input = query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea", parent(label));
131
+ if (input) input.focus();
125
132
  }
126
133
  function onFocusInput(e) {
127
- const input = e.currentTarget;
128
- updateInput(input);
134
+ const input = e.currentTarget;
135
+ updateInput(input);
129
136
  }
130
137
  function onBlurInput(e) {
131
- const input = e.currentTarget;
132
- updateInput(input);
138
+ const input = e.currentTarget;
139
+ updateInput(input);
133
140
  }
134
141
  function onChangeFile(e) {
135
- const input = e.currentTarget;
136
- updateFile(input);
142
+ const input = e.currentTarget;
143
+ updateFile(input);
137
144
  }
138
145
  function onChangeColor(e) {
139
- const input = e.currentTarget;
140
- updateColor(input);
146
+ const input = e.currentTarget;
147
+ updateColor(input);
141
148
  }
142
149
  function onKeydownFile(e) {
143
- const input = e.currentTarget;
144
- updateFile(input, e);
150
+ const input = e.currentTarget;
151
+ updateFile(input, e);
145
152
  }
146
153
  function onKeydownColor(e) {
147
- const input = e.currentTarget;
148
- updateColor(input, e);
154
+ const input = e.currentTarget;
155
+ updateColor(input, e);
149
156
  }
150
157
  function onPasswordIconClick(e) {
151
- var _a;
152
- const icon = e.currentTarget;
153
- const input = query("input", parent(icon));
154
- if (input && ((_a = icon.textContent) == null ? void 0 : _a.includes("visibility"))) {
155
- if (input.type === "password") {
156
- input.type = "text";
157
- icon.textContent = "visibility_off";
158
- } else {
159
- input.type = "password";
160
- icon.textContent = "visibility";
161
- }
162
- }
158
+ const icon = e.currentTarget;
159
+ const input = query("input", parent(icon));
160
+ if (input && icon.textContent?.includes("visibility")) if (input.type === "password") {
161
+ input.type = "text";
162
+ icon.textContent = "visibility_off";
163
+ } else {
164
+ input.type = "password";
165
+ icon.textContent = "visibility";
166
+ }
163
167
  }
164
168
  function onInputTextarea(e) {
165
- const textarea = e.currentTarget;
166
- updateTextarea(textarea);
169
+ const textarea = e.currentTarget;
170
+ updateTextarea(textarea);
171
+ }
172
+ function onClickLabelDelegation(e) {
173
+ const from = e.target.closest(".field > label");
174
+ if (!from) return;
175
+ Object.defineProperty(e, "currentTarget", {
176
+ value: from,
177
+ configurable: true
178
+ });
179
+ onClickLabel(e);
167
180
  }
168
181
  function updateAllLabels() {
169
- const labels = queryAll(".field > label");
170
- for (let i = 0; i < labels.length; i++) {
171
- onWeak(labels[i], "click", onClickLabel);
172
- }
182
+ const body = document.body;
183
+ if (!body) return;
184
+ onWeak(body, "click", onClickLabelDelegation);
173
185
  }
174
186
  function updateAllInputs() {
175
- const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
176
- for (let i = 0; i < inputs.length; i++) {
177
- onWeak(inputs[i], "focus", onFocusInput);
178
- onWeak(inputs[i], "blur", onBlurInput);
179
- updateInput(inputs[i]);
180
- }
187
+ const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
188
+ for (let i = 0; i < inputs.length; i++) {
189
+ onWeak(inputs[i], "focus", onFocusInput);
190
+ onWeak(inputs[i], "blur", onBlurInput);
191
+ updateInput(inputs[i]);
192
+ }
181
193
  }
182
194
  function updateAllSelects() {
183
- const selects = queryAll(".field > select");
184
- for (let i = 0; i < selects.length; i++) {
185
- onWeak(selects[i], "focus", onFocusInput);
186
- onWeak(selects[i], "blur", onBlurInput);
187
- }
195
+ const selects = queryAll(".field > select");
196
+ for (let i = 0; i < selects.length; i++) {
197
+ onWeak(selects[i], "focus", onFocusInput);
198
+ onWeak(selects[i], "blur", onBlurInput);
199
+ }
188
200
  }
189
201
  function updateAllFiles() {
190
- const files = queryAll(".field > input[type=file]");
191
- for (let i = 0; i < files.length; i++) {
192
- onWeak(files[i], "change", onChangeFile);
193
- updateFile(files[i]);
194
- }
202
+ const files = queryAll(".field > input[type=file]");
203
+ for (let i = 0; i < files.length; i++) {
204
+ onWeak(files[i], "change", onChangeFile);
205
+ updateFile(files[i]);
206
+ }
195
207
  }
196
208
  function updateAllColors() {
197
- const colors = queryAll(".field > input[type=color]");
198
- for (let i = 0; i < colors.length; i++) {
199
- onWeak(colors[i], "change", onChangeColor);
200
- updateColor(colors[i]);
201
- }
209
+ const colors = queryAll(".field > input[type=color]");
210
+ for (let i = 0; i < colors.length; i++) {
211
+ onWeak(colors[i], "change", onChangeColor);
212
+ updateColor(colors[i]);
213
+ }
202
214
  }
203
215
  function updateAllTextareas() {
204
- const textareas = queryAll(".field > textarea");
205
- for (let i = 0; i < textareas.length; i++) {
206
- onWeak(textareas[i], "focus", onFocusInput);
207
- onWeak(textareas[i], "blur", onBlurInput);
208
- updatePlaceholder(textareas[i]);
209
- if (isChrome && !isMac && !isIOS) continue;
210
- onWeak(textareas[i], "input", onInputTextarea);
211
- updateTextarea(textareas[i]);
212
- }
216
+ const textareas = queryAll(".field > textarea");
217
+ for (let i = 0; i < textareas.length; i++) {
218
+ onWeak(textareas[i], "focus", onFocusInput);
219
+ onWeak(textareas[i], "blur", onBlurInput);
220
+ updatePlaceholder(textareas[i]);
221
+ if (isChrome && !isMac && !isIOS) continue;
222
+ onWeak(textareas[i], "input", onInputTextarea);
223
+ updateTextarea(textareas[i]);
224
+ }
213
225
  }
214
226
  function updateAllPasswordIcons() {
215
- const icons = queryAll(".field:has(> input[type=password]) > i, a");
216
- for (let i = 0; i < icons.length; i++) onWeak(icons[i], "click", onPasswordIconClick);
227
+ const icons = queryAll(".field:has(> input[type=password]) > i, a");
228
+ for (let i = 0; i < icons.length; i++) onWeak(icons[i], "click", onPasswordIconClick);
217
229
  }
218
230
  function updateInput(input) {
219
- if (hasType(input, "number") && !input.value) input.value = "";
220
- updatePlaceholder(input);
231
+ if (hasType(input, "number") && !input.value) input.value = "";
232
+ updatePlaceholder(input);
221
233
  }
222
234
  function updateFile(input, e) {
223
- if ((e == null ? void 0 : e.key) === "Enter") {
224
- const previousInput = prev(input);
225
- if (!hasType(previousInput, "file")) return;
226
- previousInput.click();
227
- return;
228
- }
229
- const nextInput = next(input);
230
- if (!hasType(nextInput, "text")) return;
231
- nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
232
- nextInput.readOnly = true;
233
- onWeak(nextInput, "keydown", onKeydownFile, false);
234
- updateInput(nextInput);
235
+ if (e?.key === "Enter") {
236
+ const previousInput = prev(input);
237
+ if (!hasType(previousInput, "file")) return;
238
+ previousInput.click();
239
+ return;
240
+ }
241
+ const nextInput = next(input);
242
+ if (!hasType(nextInput, "text")) return;
243
+ nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
244
+ nextInput.readOnly = true;
245
+ onWeak(nextInput, "keydown", onKeydownFile, false);
246
+ updateInput(nextInput);
235
247
  }
236
248
  function updateColor(input, e) {
237
- if ((e == null ? void 0 : e.key) === "Enter") {
238
- const previousInput = prev(input);
239
- if (!hasType(previousInput, "color")) return;
240
- previousInput.click();
241
- return;
242
- }
243
- const nextInput = next(input);
244
- if (!hasType(nextInput, "text")) return;
245
- nextInput.readOnly = true;
246
- nextInput.value = input.value;
247
- onWeak(nextInput, "keydown", onKeydownColor, false);
248
- updateInput(nextInput);
249
+ if (e?.key === "Enter") {
250
+ const previousInput = prev(input);
251
+ if (!hasType(previousInput, "color")) return;
252
+ previousInput.click();
253
+ return;
254
+ }
255
+ const nextInput = next(input);
256
+ if (!hasType(nextInput, "text")) return;
257
+ nextInput.readOnly = true;
258
+ nextInput.value = input.value;
259
+ onWeak(nextInput, "keydown", onKeydownColor, false);
260
+ updateInput(nextInput);
249
261
  }
250
262
  function updateTextarea(textarea) {
251
- updatePlaceholder(textarea);
252
- if (textarea.hasAttribute("rows")) return;
253
- const rootSize = rootSizeInPixels();
254
- textarea.style.blockSize = "auto";
255
- textarea.style.blockSize = `${textarea.scrollHeight - rootSize}px`;
263
+ updatePlaceholder(textarea);
264
+ if (textarea.hasAttribute("rows")) return;
265
+ const rootSize = rootSizeInPixels();
266
+ textarea.style.blockSize = "auto";
267
+ textarea.style.blockSize = `${textarea.scrollHeight - rootSize}px`;
256
268
  }
257
269
  function updateAllFields() {
258
- updateAllLabels();
259
- updateAllInputs();
260
- updateAllSelects();
261
- updateAllFiles();
262
- updateAllColors();
263
- updateAllTextareas();
264
- updateAllPasswordIcons();
265
- }
270
+ updateAllLabels();
271
+ updateAllInputs();
272
+ updateAllSelects();
273
+ updateAllFiles();
274
+ updateAllColors();
275
+ updateAllTextareas();
276
+ updateAllPasswordIcons();
277
+ }
278
+ //#endregion
279
+ //#region src/cdn/elements/sliders.ts
266
280
  function onInputDocument$1(e) {
267
- const input = e.target;
268
- if (!hasTag(input, "input") && !hasTag(input, "select")) return;
269
- if (input.type === "range") {
270
- input.focus();
271
- updateRange(input);
272
- } else {
273
- updateAllRanges();
274
- }
281
+ const input = e.target;
282
+ if (!hasTag(input, "input") && !hasTag(input, "select")) return;
283
+ if (input.type === "range") {
284
+ input.focus();
285
+ updateRange(input);
286
+ } else updateAllRanges();
275
287
  }
276
288
  function onChangeInput(e) {
277
- const isCoarse = window.matchMedia("(pointer: coarse)").matches;
278
- if (!isCoarse) return;
279
- const input = e.target;
280
- input.blur();
289
+ if (!window.matchMedia("(pointer: coarse)").matches) return;
290
+ e.target.blur();
281
291
  }
282
292
  function updateAllRanges() {
283
- const body = document.body;
284
- const ranges = queryAll(".slider > input[type=range]");
285
- if (!ranges.length) off(body, "input", onInputDocument$1, false);
286
- else on(body, "input", onInputDocument$1, false);
287
- for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
293
+ const body = document.body;
294
+ const ranges = queryAll(".slider > input[type=range]");
295
+ if (!ranges.length) off(body, "input", onInputDocument$1, false);
296
+ else on(body, "input", onInputDocument$1, false);
297
+ for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
288
298
  }
289
299
  function updateRange(input) {
290
- onWeak(input, "change", onChangeInput);
291
- const label = parent(input);
292
- const bar = query("span", label);
293
- const inputs = queryAll("input", label);
294
- if (!inputs.length || !bar) return;
295
- const rootSize = rootSizeInPixels();
296
- const thumb = hasClass(label, "max") ? 0 : 0.25 * rootSize * 100 / inputs[0].offsetWidth;
297
- const percents = [];
298
- const values = [];
299
- for (let i = 0, n = inputs.length; i < n; i++) {
300
- const min = parseFloat(inputs[i].min) || 0;
301
- const max = parseFloat(inputs[i].max) || 100;
302
- const value = parseFloat(inputs[i].value) || 0;
303
- const percent2 = (value - min) * 100 / (max - min);
304
- const fix = thumb / 2 - thumb * percent2 / 100;
305
- percents.push(percent2 + fix);
306
- values.push(value);
307
- }
308
- let percent = percents[0];
309
- let start2 = 0;
310
- let end = 100 - start2 - percent;
311
- let value1 = values[0];
312
- let value2 = values[1] || 0;
313
- if (inputs.length > 1) {
314
- percent = Math.abs(percents[1] - percents[0]);
315
- start2 = percents[1] > percents[0] ? percents[0] : percents[1];
316
- end = 100 - start2 - percent;
317
- if (value2 > value1) {
318
- value1 = values[1] || 0;
319
- value2 = values[0];
320
- }
321
- }
322
- requestAnimationFrame(() => label.style.cssText = `--_start: ${start2}%; --_end: ${end}%; --_value1: '${value1}'; --_value2: '${value2}';`);
300
+ onWeak(input, "change", onChangeInput);
301
+ const label = parent(input);
302
+ const bar = query("span", label);
303
+ const inputs = queryAll("input", label);
304
+ if (!inputs.length || !bar) return;
305
+ const rootSize = rootSizeInPixels();
306
+ const thumb = hasClass(label, "max") ? 0 : .25 * rootSize * 100 / inputs[0].offsetWidth;
307
+ const percents = [];
308
+ const values = [];
309
+ for (let i = 0, n = inputs.length; i < n; i++) {
310
+ const min = parseFloat(inputs[i].min) || 0;
311
+ const max = parseFloat(inputs[i].max) || 100;
312
+ const value = parseFloat(inputs[i].value) || 0;
313
+ const percent = (value - min) * 100 / (max - min);
314
+ const fix = thumb / 2 - thumb * percent / 100;
315
+ percents.push(percent + fix);
316
+ values.push(value);
317
+ }
318
+ let percent = percents[0];
319
+ let start = 0;
320
+ let end = 100 - start - percent;
321
+ let value1 = values[0];
322
+ let value2 = values[1] || 0;
323
+ if (inputs.length > 1) {
324
+ percent = Math.abs(percents[1] - percents[0]);
325
+ start = percents[1] > percents[0] ? percents[0] : percents[1];
326
+ end = 100 - start - percent;
327
+ if (value2 > value1) {
328
+ value1 = values[1] || 0;
329
+ value2 = values[0];
330
+ }
331
+ }
332
+ requestAnimationFrame(() => label.style.cssText = `--_start: ${start}%; --_end: ${end}%; --_value1: '${value1}'; --_value2: '${value2}';`);
323
333
  }
324
334
  function updateAllSliders() {
325
- updateAllRanges();
335
+ updateAllRanges();
326
336
  }
327
- const _lastTheme = {
328
- light: "",
329
- dark: ""
337
+ //#endregion
338
+ //#region src/cdn/settings/theme.ts
339
+ var _lastTheme = {
340
+ light: "",
341
+ dark: ""
330
342
  };
331
343
  function getMode() {
332
- var _a;
333
- return ((_a = document == null ? void 0 : document.body) == null ? void 0 : _a.classList.contains("dark")) ? "dark" : "light";
344
+ return document?.body?.classList.contains("dark") ? "dark" : "light";
334
345
  }
335
346
  function lastTheme() {
336
- if (_lastTheme.light && _lastTheme.dark) return _lastTheme;
337
- const body = document.body;
338
- const light = document.createElement("body");
339
- light.className = "light";
340
- body.appendChild(light);
341
- const dark = document.createElement("body");
342
- dark.className = "dark";
343
- body.appendChild(dark);
344
- const fromLight = getComputedStyle(light);
345
- const fromDark = getComputedStyle(dark);
346
- const variables = ["--primary", "--on-primary", "--primary-container", "--on-primary-container", "--secondary", "--on-secondary", "--secondary-container", "--on-secondary-container", "--tertiary", "--on-tertiary", "--tertiary-container", "--on-tertiary-container", "--error", "--on-error", "--error-container", "--on-error-container", "--background", "--on-background", "--surface", "--on-surface", "--surface-variant", "--on-surface-variant", "--outline", "--outline-variant", "--shadow", "--scrim", "--inverse-surface", "--inverse-on-surface", "--inverse-primary", "--surface-dim", "--surface-bright", "--surface-container-lowest", "--surface-container-low", "--surface-container", "--surface-container-high", "--surface-container-highest"];
347
- for (let i = 0, n = variables.length; i < n; i++) {
348
- _lastTheme.light += variables[i] + ":" + fromLight.getPropertyValue(variables[i]) + ";";
349
- _lastTheme.dark += variables[i] + ":" + fromDark.getPropertyValue(variables[i]) + ";";
350
- }
351
- body.removeChild(light);
352
- body.removeChild(dark);
353
- return _lastTheme;
347
+ if (_lastTheme.light && _lastTheme.dark) return _lastTheme;
348
+ const body = document.body;
349
+ const light = document.createElement("body");
350
+ light.className = "light";
351
+ light.style.display = "none";
352
+ body.appendChild(light);
353
+ const dark = document.createElement("body");
354
+ dark.className = "dark";
355
+ dark.style.display = "none";
356
+ body.appendChild(dark);
357
+ try {
358
+ const fromLight = getComputedStyle(light);
359
+ const fromDark = getComputedStyle(dark);
360
+ const variables = [
361
+ "--primary",
362
+ "--on-primary",
363
+ "--primary-container",
364
+ "--on-primary-container",
365
+ "--secondary",
366
+ "--on-secondary",
367
+ "--secondary-container",
368
+ "--on-secondary-container",
369
+ "--tertiary",
370
+ "--on-tertiary",
371
+ "--tertiary-container",
372
+ "--on-tertiary-container",
373
+ "--error",
374
+ "--on-error",
375
+ "--error-container",
376
+ "--on-error-container",
377
+ "--background",
378
+ "--on-background",
379
+ "--surface",
380
+ "--on-surface",
381
+ "--surface-variant",
382
+ "--on-surface-variant",
383
+ "--outline",
384
+ "--outline-variant",
385
+ "--shadow",
386
+ "--scrim",
387
+ "--inverse-surface",
388
+ "--inverse-on-surface",
389
+ "--inverse-primary",
390
+ "--surface-dim",
391
+ "--surface-bright",
392
+ "--surface-container-lowest",
393
+ "--surface-container-low",
394
+ "--surface-container",
395
+ "--surface-container-high",
396
+ "--surface-container-highest"
397
+ ];
398
+ for (let i = 0, n = variables.length; i < n; i++) {
399
+ _lastTheme.light += variables[i] + ":" + fromLight.getPropertyValue(variables[i]) + ";";
400
+ _lastTheme.dark += variables[i] + ":" + fromDark.getPropertyValue(variables[i]) + ";";
401
+ }
402
+ } finally {
403
+ body.removeChild(light);
404
+ body.removeChild(dark);
405
+ }
406
+ return _lastTheme;
354
407
  }
355
408
  async function updateTheme(source) {
356
- const context = globalThis;
357
- const body = document.body;
358
- if (!source || !context.materialDynamicColors) return lastTheme();
359
- if (source.light && source.dark) {
360
- _lastTheme.light = source.light;
361
- _lastTheme.dark = source.dark;
362
- body.setAttribute("style", source[getMode()]);
363
- return source;
364
- }
365
- return context.materialDynamicColors(source).then((theme) => {
366
- const toCss = (data) => {
367
- let style = "";
368
- for (let i = 0, keys = Object.keys(data), n = keys.length; i < n; i++) {
369
- const key = keys[i];
370
- const value = data[key];
371
- const kebabCase = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
372
- style += "--" + kebabCase + ":" + value + ";";
373
- }
374
- return style;
375
- };
376
- _lastTheme.light = toCss(theme.light);
377
- _lastTheme.dark = toCss(theme.dark);
378
- body.setAttribute("style", _lastTheme[getMode()]);
379
- return _lastTheme;
380
- });
409
+ const context = globalThis;
410
+ const body = document.body;
411
+ if (!source || !context.materialDynamicColors) return lastTheme();
412
+ if (source.light && source.dark) {
413
+ _lastTheme.light = source.light;
414
+ _lastTheme.dark = source.dark;
415
+ body.setAttribute("style", source[getMode()]);
416
+ return source;
417
+ }
418
+ return context.materialDynamicColors(source).then((theme) => {
419
+ const toCss = (data) => {
420
+ let style = "";
421
+ for (let i = 0, keys = Object.keys(data), n = keys.length; i < n; i++) {
422
+ const key = keys[i];
423
+ const value = data[key];
424
+ const kebabCase = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
425
+ style += "--" + kebabCase + ":" + value + ";";
426
+ }
427
+ return style;
428
+ };
429
+ _lastTheme.light = toCss(theme.light);
430
+ _lastTheme.dark = toCss(theme.dark);
431
+ body.setAttribute("style", _lastTheme[getMode()]);
432
+ return _lastTheme;
433
+ });
381
434
  }
382
435
  function updateMode(value) {
383
- const context = globalThis;
384
- const body = document.body;
385
- if (!body) return value;
386
- if (!value) return getMode();
387
- if (value === "auto") value = isDark() ? "dark" : "light";
388
- body.classList.remove("light", "dark");
389
- body.classList.add(value);
390
- const lastThemeStyle = value === "light" ? _lastTheme.light : _lastTheme.dark;
391
- if (context.materialDynamicColors) body.setAttribute("style", lastThemeStyle);
392
- return getMode();
393
- }
394
- const _dialogs = [];
436
+ const context = globalThis;
437
+ const body = document.body;
438
+ if (!body) return value;
439
+ if (!value) return getMode();
440
+ if (value === "auto") value = isDark() ? "dark" : "light";
441
+ body.classList.remove("light", "dark");
442
+ body.classList.add(value);
443
+ const lastThemeStyle = value === "light" ? _lastTheme.light : _lastTheme.dark;
444
+ if (context.materialDynamicColors) body.setAttribute("style", lastThemeStyle);
445
+ return getMode();
446
+ }
447
+ //#endregion
448
+ //#region src/cdn/elements/dialogs.ts
449
+ var _dialogs = [];
395
450
  function onKeydownDialog(e) {
396
- if (e.key === "Escape") {
397
- const dialog = e.currentTarget;
398
- void updateDialog(dialog, dialog);
399
- }
451
+ if (e.key === "Escape") {
452
+ const dialog = e.currentTarget;
453
+ updateDialog(dialog, dialog);
454
+ }
400
455
  }
401
456
  function focusOnDialogOrElement(dialog) {
402
- const element = query("[autofocus]", dialog) ?? dialog;
403
- element.focus();
457
+ (query("[autofocus]", dialog) ?? dialog).focus();
404
458
  }
405
459
  function closeDialog(dialog, overlay) {
406
- removeClass(queryAllDataUi(dialog.id), "active");
407
- removeClass(dialog, "active");
408
- removeClass(overlay, "active");
409
- dialog.close();
410
- _dialogs.pop();
411
- const previousDialog = _dialogs[_dialogs.length - 1];
412
- if (previousDialog) previousDialog.focus();
460
+ removeClass(queryAllDataUi(dialog.id), "active");
461
+ removeClass(dialog, "active");
462
+ removeClass(overlay, "active");
463
+ dialog.close();
464
+ _dialogs.pop();
465
+ const previousDialog = _dialogs[_dialogs.length - 1];
466
+ if (previousDialog) previousDialog.focus();
413
467
  }
414
468
  async function openDialog(dialog, overlay, isModal, from) {
415
- if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
416
- addClass(overlay, "active");
417
- addClass(dialog, "active");
418
- if (isModal) dialog.showModal();
419
- else dialog.show();
420
- await wait(90);
421
- if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
422
- _dialogs.push(dialog);
423
- focusOnDialogOrElement(dialog);
469
+ if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
470
+ addClass(overlay, "active");
471
+ addClass(dialog, "active");
472
+ if (isModal) dialog.showModal();
473
+ else dialog.show();
474
+ await wait(90);
475
+ if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
476
+ _dialogs.push(dialog);
477
+ focusOnDialogOrElement(dialog);
424
478
  }
425
479
  function onClickOverlay(e) {
426
- const overlay = e.currentTarget;
427
- const dialog = next(overlay);
428
- if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
480
+ const overlay = e.currentTarget;
481
+ const dialog = next(overlay);
482
+ if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
429
483
  }
430
484
  async function updateDialog(from, dialog) {
431
- blurActiveElement();
432
- let overlay = prev(dialog);
433
- const isActive = hasClass(dialog, "active") || dialog.open;
434
- const isModal = hasClass(dialog, "modal");
435
- if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
436
- if (!hasClass(overlay, "overlay")) {
437
- overlay = create({ class: "overlay" });
438
- insertBefore(overlay, dialog);
439
- await wait(90);
440
- }
441
- if (!isModal) onWeak(overlay, "click", onClickOverlay, false);
442
- if (isActive) closeDialog(dialog, overlay);
443
- else void openDialog(dialog, overlay, isModal, from);
444
- }
445
- let _timeoutMenu;
485
+ blurActiveElement();
486
+ let overlay = prev(dialog);
487
+ const isActive = hasClass(dialog, "active") || dialog.open;
488
+ const isModal = hasClass(dialog, "modal");
489
+ if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
490
+ if (!hasClass(overlay, "overlay")) {
491
+ overlay = create({ class: "overlay" });
492
+ insertBefore(overlay, dialog);
493
+ await wait(90);
494
+ }
495
+ if (!isModal) onWeak(overlay, "click", onClickOverlay, false);
496
+ if (isActive) closeDialog(dialog, overlay);
497
+ else openDialog(dialog, overlay, isModal, from);
498
+ }
499
+ //#endregion
500
+ //#region src/cdn/elements/menus.ts
501
+ var _timeoutMenu;
446
502
  function onClickDocument(e) {
447
- off(document.body, "click", onClickDocument);
448
- const body = e.target;
449
- const menus = queryAll("menu.active");
450
- for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
503
+ off(document.body, "click", onClickDocument);
504
+ const body = e.target;
505
+ const menus = queryAll("menu.active");
506
+ for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
451
507
  }
452
508
  function focusOnMenuOrInput(menu) {
453
- setTimeout(() => {
454
- const input = query(".field > input", menu);
455
- if (input) input.focus();
456
- else menu.focus();
457
- }, 90);
509
+ setTimeout(() => {
510
+ const input = query(".field > input", menu);
511
+ if (input) input.focus();
512
+ else menu.focus();
513
+ }, 90);
458
514
  }
459
515
  function updateMenu(from, menu, e) {
460
- if (_timeoutMenu) clearTimeout(_timeoutMenu);
461
- _timeoutMenu = setTimeout(() => {
462
- on(document.body, "click", onClickDocument);
463
- if (!hasTag(document.activeElement, "input")) blurActiveElement();
464
- const isActive = hasClass(menu, "active");
465
- const isEvent = (e == null ? void 0 : e.target) === from;
466
- const isChild = !!from.closest("menu");
467
- if (!isActive && isChild || isActive && isEvent) {
468
- removeClass(menu, "active");
469
- return;
470
- }
471
- removeClass(queryAll("menu.active"), "active");
472
- addClass(menu, "active");
473
- focusOnMenuOrInput(menu);
474
- }, 90);
475
- }
476
- let _timeoutSnackbar;
516
+ if (_timeoutMenu) clearTimeout(_timeoutMenu);
517
+ _timeoutMenu = setTimeout(() => {
518
+ on(document.body, "click", onClickDocument);
519
+ if (!hasTag(document.activeElement, "input")) blurActiveElement();
520
+ const isActive = hasClass(menu, "active");
521
+ const isEvent = e?.target === from;
522
+ const isChild = !!from.closest("menu");
523
+ if (!isActive && isChild || isActive && isEvent) {
524
+ removeClass(menu, "active");
525
+ return;
526
+ }
527
+ removeClass(queryAll("menu.active"), "active");
528
+ addClass(menu, "active");
529
+ focusOnMenuOrInput(menu);
530
+ }, 90);
531
+ }
532
+ //#endregion
533
+ //#region src/cdn/elements/snackbars.ts
534
+ var _timeoutSnackbar;
477
535
  function onClickSnackbar(e) {
478
- const snackbar = e.currentTarget;
479
- removeClass(snackbar, "active");
480
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
536
+ const snackbar = e.currentTarget;
537
+ removeClass(snackbar, "active");
538
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
481
539
  }
482
540
  function updateSnackbar(snackbar, milliseconds) {
483
- blurActiveElement();
484
- const activeSnackbars = queryAll(".snackbar.active");
485
- for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
486
- addClass(snackbar, "active");
487
- onWeak(snackbar, "click", onClickSnackbar);
488
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
489
- if (milliseconds === -1) return;
490
- _timeoutSnackbar = setTimeout(() => {
491
- removeClass(snackbar, "active");
492
- }, milliseconds ?? 6e3);
493
- }
541
+ blurActiveElement();
542
+ const activeSnackbars = queryAll(".snackbar.active");
543
+ for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
544
+ addClass(snackbar, "active");
545
+ onWeak(snackbar, "click", onClickSnackbar);
546
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
547
+ if (milliseconds === -1) return;
548
+ _timeoutSnackbar = setTimeout(() => {
549
+ removeClass(snackbar, "active");
550
+ }, milliseconds ?? 6e3);
551
+ }
552
+ //#endregion
553
+ //#region src/cdn/elements/pages.ts
494
554
  function updatePage(page) {
495
- const container = parent(page);
496
- if (container) removeClass(queryAll(":scope > .page", container), "active");
497
- addClass(page, "active");
498
- }
499
- function onMousedownRipple(e) {
500
- updateRipple(e);
501
- }
502
- function onKeydownRipple(e) {
503
- if ((e == null ? void 0 : e.key) === " ") updateRipple(e);
555
+ const container = parent(page);
556
+ if (container) removeClass(queryAll(":scope > .page", container), "active");
557
+ addClass(page, "active");
504
558
  }
559
+ //#endregion
560
+ //#region src/cdn/helpers/ripples.ts
505
561
  function updateRipple(e) {
506
- const isMouseEvent = e instanceof MouseEvent;
507
- const element = e.currentTarget;
508
- const rect = element.getBoundingClientRect();
509
- const diameter = Math.max(rect.width, rect.height);
510
- const radius = diameter / 2;
511
- const x = isMouseEvent ? e.clientX - rect.left - radius : rect.width / 2 - radius;
512
- const y = isMouseEvent ? e.clientY - rect.top - radius : rect.height / 2 - radius;
513
- const rippleContainer = document.createElement("div");
514
- rippleContainer.className = "ripple-js";
515
- const ripple = document.createElement("div");
516
- ripple.style.inlineSize = ripple.style.blockSize = `${diameter}px`;
517
- ripple.style.left = `${x}px`;
518
- ripple.style.top = `${y}px`;
519
- onWeak(ripple, "animationend", () => {
520
- rippleContainer.remove();
521
- });
522
- rippleContainer.appendChild(ripple);
523
- element.appendChild(rippleContainer);
562
+ const isMouseEvent = e instanceof MouseEvent;
563
+ const element = e.currentTarget;
564
+ const rect = element.getBoundingClientRect();
565
+ const diameter = Math.max(rect.width, rect.height);
566
+ const radius = diameter / 2;
567
+ const x = isMouseEvent ? e.clientX - rect.left - radius : rect.width / 2 - radius;
568
+ const y = isMouseEvent ? e.clientY - rect.top - radius : rect.height / 2 - radius;
569
+ const rippleContainer = document.createElement("div");
570
+ rippleContainer.className = "ripple-js";
571
+ const ripple = document.createElement("div");
572
+ ripple.style.inlineSize = ripple.style.blockSize = `${diameter}px`;
573
+ ripple.style.left = `${x}px`;
574
+ ripple.style.top = `${y}px`;
575
+ onWeak(ripple, "animationend", () => {
576
+ rippleContainer.remove();
577
+ });
578
+ rippleContainer.appendChild(ripple);
579
+ element.appendChild(rippleContainer);
580
+ }
581
+ function onMousedownRippleDelegation(e) {
582
+ const from = e.target.closest(".slow-ripple, .ripple, .fast-ripple");
583
+ if (!from) return;
584
+ Object.defineProperty(e, "currentTarget", {
585
+ value: from,
586
+ configurable: true
587
+ });
588
+ updateRipple(e);
589
+ }
590
+ function onKeydownRippleDelegation(e) {
591
+ const from = e.target.closest(".slow-ripple, .ripple, .fast-ripple");
592
+ if (!from || e.key !== " ") return;
593
+ Object.defineProperty(e, "currentTarget", {
594
+ value: from,
595
+ configurable: true
596
+ });
597
+ updateRipple(e);
524
598
  }
525
599
  function updateAllRipples() {
526
- const ripples = queryAll(".slow-ripple, .ripple, .fast-ripple");
527
- for (let i = 0; i < ripples.length; i++) {
528
- onWeak(ripples[i], "mousedown", onMousedownRipple);
529
- onWeak(ripples[i], "keydown", onKeydownRipple);
530
- }
600
+ const body = document.body;
601
+ if (!body) return;
602
+ onWeak(body, "mousedown", onMousedownRippleDelegation);
603
+ onWeak(body, "keydown", onKeydownRippleDelegation);
531
604
  }
605
+ //#endregion
606
+ //#region src/cdn/elements/progress.ts
532
607
  function onInputDocument(e) {
533
- const progress = e.target;
534
- if (hasTag(progress, "progress")) {
535
- updateProgress(progress);
536
- } else {
537
- updateAllProgress();
538
- }
608
+ const progress = e.target;
609
+ if (hasTag(progress, "progress")) updateProgress(progress);
610
+ else updateAllProgress();
539
611
  }
540
612
  function updateProgress(progress) {
541
- requestAnimationFrame(() => {
542
- if (!progress.hasAttribute("value") && !progress.hasAttribute("max")) {
543
- const value = hasClass(progress, "circle") ? "50" : "100";
544
- progress.style.setProperty("--_value", value);
545
- progress.setAttribute("value", value);
546
- progress.setAttribute("max", "100");
547
- progress.classList.add("indeterminate");
548
- } else {
549
- progress.style.setProperty("--_value", String(progress.value));
550
- }
551
- });
613
+ requestAnimationFrame(() => {
614
+ if (!progress.hasAttribute("value") && !progress.hasAttribute("max")) {
615
+ const value = hasClass(progress, "circle") ? "50" : "100";
616
+ progress.style.setProperty("--_value", value);
617
+ progress.setAttribute("value", value);
618
+ progress.setAttribute("max", "100");
619
+ progress.classList.add("indeterminate");
620
+ } else progress.style.setProperty("--_value", String(progress.value));
621
+ });
552
622
  }
553
623
  function updateAllProgress() {
554
- if (isChrome && !isMac && !isIOS) return;
555
- const body = document.body;
556
- const progresses = queryAll("progress");
557
- if (!progresses.length) off(body, "input", onInputDocument, false);
558
- else on(body, "input", onInputDocument, false);
559
- for (let i = 0; i < progresses.length; i++) updateProgress(progresses[i]);
560
- }
561
- const _context = globalThis;
562
- let _timeoutMutation;
563
- let _mutation;
624
+ if (isChrome && !isMac && !isIOS) return;
625
+ const body = document.body;
626
+ const progresses = queryAll("progress");
627
+ if (!progresses.length) off(body, "input", onInputDocument, false);
628
+ else on(body, "input", onInputDocument, false);
629
+ for (let i = 0; i < progresses.length; i++) updateProgress(progresses[i]);
630
+ }
631
+ //#endregion
632
+ //#region src/cdn/beer.ts
633
+ var _context = globalThis;
634
+ var _timeoutMutation;
635
+ var _mutation;
564
636
  function onMutation() {
565
- if (_timeoutMutation) clearTimeout(_timeoutMutation);
566
- _timeoutMutation = setTimeout(async () => await _ui(), 180);
637
+ if (_timeoutMutation) clearTimeout(_timeoutMutation);
638
+ _timeoutMutation = setTimeout(async () => await _ui(), 180);
567
639
  }
568
640
  async function run(from, to, options, e) {
569
- if (!to) {
570
- to = query(from.getAttribute("data-ui"));
571
- if (!to) {
572
- from.classList.toggle("active");
573
- return;
574
- }
575
- }
576
- updateAllClickable(from);
577
- if (hasTag(to, "dialog")) {
578
- requestAnimationFrame(() => updateDialog(from, to));
579
- return;
580
- }
581
- if (hasTag(to, "menu")) {
582
- requestAnimationFrame(() => updateMenu(from, to, e));
583
- return;
584
- }
585
- if (hasClass(to, "snackbar")) {
586
- requestAnimationFrame(() => updateSnackbar(to, options));
587
- return;
588
- }
589
- if (hasClass(to, "page")) {
590
- requestAnimationFrame(() => updatePage(to));
591
- return;
592
- }
593
- if (hasClass(to, "active")) {
594
- removeClass(from, "active");
595
- removeClass(to, "active");
596
- return;
597
- }
598
- addClass(to, "active");
599
- }
600
- function onClickElement(e) {
601
- void run(e.currentTarget, null, null, e);
602
- }
603
- function onKeydownElement(e) {
604
- if (e.key === "Enter") void run(e.currentTarget, null, null, e);
641
+ if (!to) {
642
+ to = query(from.getAttribute("data-ui"));
643
+ if (!to) {
644
+ from.classList.toggle("active");
645
+ return;
646
+ }
647
+ }
648
+ updateAllClickable(from);
649
+ if (hasTag(to, "dialog")) {
650
+ requestAnimationFrame(() => updateDialog(from, to));
651
+ return;
652
+ }
653
+ if (hasTag(to, "menu")) {
654
+ requestAnimationFrame(() => updateMenu(from, to, e));
655
+ return;
656
+ }
657
+ if (hasClass(to, "snackbar")) {
658
+ requestAnimationFrame(() => updateSnackbar(to, options));
659
+ return;
660
+ }
661
+ if (hasClass(to, "page")) {
662
+ requestAnimationFrame(() => updatePage(to));
663
+ return;
664
+ }
665
+ if (hasClass(to, "active")) {
666
+ removeClass(from, "active");
667
+ removeClass(to, "active");
668
+ return;
669
+ }
670
+ addClass(to, "active");
605
671
  }
606
672
  function setup() {
607
- if (_context.ui || _mutation || !_context.MutationObserver) return;
608
- _mutation = new MutationObserver(onMutation);
609
- _mutation.observe(document.body, { childList: true, subtree: true });
610
- onMutation();
673
+ if (_context.ui || _mutation || !_context.MutationObserver) return;
674
+ _mutation = new MutationObserver(onMutation);
675
+ _mutation.observe(document.body, {
676
+ childList: true,
677
+ subtree: true
678
+ });
679
+ onMutation();
680
+ }
681
+ function onClickDataUi(e) {
682
+ const from = e.target.closest("[data-ui]");
683
+ if (from) run(from, null, null, e);
684
+ }
685
+ function onKeydownDataUi(e) {
686
+ const from = e.target.closest("[data-ui]");
687
+ if (from && hasTag(from, "a") && !from.getAttribute("href") && e.key === "Enter") run(from, null, null, e);
611
688
  }
612
689
  function updateAllDataUis() {
613
- const elements = queryAll("[data-ui]");
614
- for (let i = 0, n = elements.length; i < n; i++) {
615
- onWeak(elements[i], "click", onClickElement);
616
- if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) onWeak(elements[i], "keydown", onKeydownElement);
617
- }
690
+ const body = document.body;
691
+ if (!body) return;
692
+ onWeak(body, "click", onClickDataUi);
693
+ onWeak(body, "keydown", onKeydownDataUi);
618
694
  }
619
695
  function _ui(selector, options) {
620
- if (selector) {
621
- if (selector === "setup") {
622
- setup();
623
- return;
624
- }
625
- if (selector === "guid") return guid();
626
- if (selector === "mode") return updateMode(options);
627
- if (selector === "theme") return updateTheme(options);
628
- const to = query(selector);
629
- if (!to) return;
630
- void run(to, to, options);
631
- }
632
- updateAllDataUis();
633
- updateAllFields();
634
- updateAllRipples();
635
- updateAllSliders();
636
- updateAllProgress();
696
+ if (selector) {
697
+ if (selector === "setup") {
698
+ setup();
699
+ return;
700
+ }
701
+ if (selector === "guid") return guid();
702
+ if (selector === "mode") return updateMode(options);
703
+ if (selector === "theme") return updateTheme(options);
704
+ const to = query(selector);
705
+ if (!to) return;
706
+ run(to, to, options);
707
+ }
708
+ updateAllDataUis();
709
+ updateAllFields();
710
+ updateAllRipples();
711
+ updateAllSliders();
712
+ updateAllProgress();
637
713
  }
638
714
  function start() {
639
- var _a;
640
- if (_context.ui) return;
641
- const body = (_a = _context.document) == null ? void 0 : _a.body;
642
- if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
643
- setup();
644
- _context.ui = _ui;
715
+ if (_context.ui) return;
716
+ const body = _context.document?.body;
717
+ if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
718
+ setup();
719
+ _context.ui = _ui;
645
720
  }
646
721
  start();
647
- const ui = _context.ui;
648
- export {
649
- ui as default,
650
- ui
651
- };
722
+ var ui = _context.ui;
723
+ //#endregion
724
+ export { ui as default, ui };