beercss 3.13.1 → 3.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +328 -322
  3. package/custom-element/index.d.ts +18 -18
  4. package/custom-element/index.js +7 -7
  5. package/dist/cdn/arch.svg +3 -3
  6. package/dist/cdn/arrow.svg +3 -3
  7. package/dist/cdn/beer.css +4792 -4789
  8. package/dist/cdn/beer.custom-element.js +38 -38
  9. package/dist/cdn/beer.custom-element.min.js +1 -1
  10. package/dist/cdn/beer.js +635 -635
  11. package/dist/cdn/beer.min.css +1 -1
  12. package/dist/cdn/beer.min.js +1 -1
  13. package/dist/cdn/beer.scoped.css +4793 -4790
  14. package/dist/cdn/beer.scoped.min.css +1 -1
  15. package/dist/cdn/boom.svg +3 -3
  16. package/dist/cdn/bun.svg +3 -3
  17. package/dist/cdn/burst.svg +3 -3
  18. package/dist/cdn/circle.svg +3 -3
  19. package/dist/cdn/clamshell.svg +3 -3
  20. package/dist/cdn/diamond.svg +3 -3
  21. package/dist/cdn/fan.svg +3 -3
  22. package/dist/cdn/flower.svg +3 -3
  23. package/dist/cdn/gem.svg +3 -3
  24. package/dist/cdn/ghost-ish.svg +3 -3
  25. package/dist/cdn/heart.svg +3 -3
  26. package/dist/cdn/leaf-clover4.svg +3 -3
  27. package/dist/cdn/leaf-clover8.svg +3 -3
  28. package/dist/cdn/loading-indicator.svg +18 -18
  29. package/dist/cdn/oval.svg +3 -3
  30. package/dist/cdn/pentagon.svg +3 -3
  31. package/dist/cdn/pill.svg +3 -3
  32. package/dist/cdn/pixel-circle.svg +3 -3
  33. package/dist/cdn/pixel-triangle.svg +3 -3
  34. package/dist/cdn/puffy-diamond.svg +3 -3
  35. package/dist/cdn/puffy.svg +3 -3
  36. package/dist/cdn/semicircle.svg +3 -3
  37. package/dist/cdn/sided-cookie12.svg +3 -3
  38. package/dist/cdn/sided-cookie4.svg +3 -3
  39. package/dist/cdn/sided-cookie6.svg +3 -3
  40. package/dist/cdn/sided-cookie7.svg +3 -3
  41. package/dist/cdn/sided-cookie9.svg +3 -3
  42. package/dist/cdn/slanted.svg +3 -3
  43. package/dist/cdn/soft-boom.svg +3 -3
  44. package/dist/cdn/soft-burst.svg +3 -3
  45. package/dist/cdn/square.svg +3 -3
  46. package/dist/cdn/sunny.svg +3 -3
  47. package/dist/cdn/triangle.svg +3 -3
  48. package/dist/cdn/very-sunny.svg +3 -3
  49. package/dist/cdn/wavy-circle.svg +3 -3
  50. package/dist/cdn/wavy.svg +4 -4
  51. package/index.d.ts +18 -18
  52. package/index.js +6 -6
  53. package/package.json +76 -76
  54. package/scoped/index.d.ts +18 -18
  55. package/scoped/index.js +6 -6
  56. package/src/cdn/beer.css +52 -52
  57. package/src/cdn/beer.ts +120 -120
  58. package/src/cdn/customElement.js +38 -38
  59. package/src/cdn/elements/badges.css +74 -74
  60. package/src/cdn/elements/bars.css +91 -91
  61. package/src/cdn/elements/buttons.css +106 -106
  62. package/src/cdn/elements/cards.css +26 -26
  63. package/src/cdn/elements/chips.css +38 -38
  64. package/src/cdn/elements/dialogs.css +151 -151
  65. package/src/cdn/elements/dialogs.ts +69 -69
  66. package/src/cdn/elements/dividers.css +48 -48
  67. package/src/cdn/elements/expansions.css +10 -10
  68. package/src/cdn/elements/fields.css +439 -439
  69. package/src/cdn/elements/fields.ts +165 -164
  70. package/src/cdn/elements/grids.css +171 -171
  71. package/src/cdn/elements/icons.css +77 -77
  72. package/src/cdn/elements/layouts.css +35 -35
  73. package/src/cdn/elements/lists.css +71 -71
  74. package/src/cdn/elements/mainLayouts.css +57 -57
  75. package/src/cdn/elements/media.css +112 -112
  76. package/src/cdn/elements/menus.css +294 -294
  77. package/src/cdn/elements/menus.ts +40 -40
  78. package/src/cdn/elements/navigations.css +462 -460
  79. package/src/cdn/elements/overlays.css +31 -31
  80. package/src/cdn/elements/pages.css +41 -41
  81. package/src/cdn/elements/pages.ts +6 -6
  82. package/src/cdn/elements/progress.css +207 -207
  83. package/src/cdn/elements/progress.ts +34 -34
  84. package/src/cdn/elements/selections.css +256 -256
  85. package/src/cdn/elements/shapes.css +258 -258
  86. package/src/cdn/elements/sliders.css +357 -357
  87. package/src/cdn/elements/sliders.ts +74 -74
  88. package/src/cdn/elements/snackbars.css +47 -47
  89. package/src/cdn/elements/snackbars.ts +26 -26
  90. package/src/cdn/elements/tables.css +65 -65
  91. package/src/cdn/elements/tabs.css +52 -52
  92. package/src/cdn/elements/tooltips.css +131 -131
  93. package/src/cdn/helpers/alignments.css +29 -29
  94. package/src/cdn/helpers/blurs.css +21 -21
  95. package/src/cdn/helpers/colors.css +930 -930
  96. package/src/cdn/helpers/directions.css +28 -28
  97. package/src/cdn/helpers/elevates.css +16 -16
  98. package/src/cdn/helpers/forms.css +75 -75
  99. package/src/cdn/helpers/margins.css +49 -49
  100. package/src/cdn/helpers/opacities.css +19 -19
  101. package/src/cdn/helpers/paddings.css +45 -45
  102. package/src/cdn/helpers/positions.css +45 -45
  103. package/src/cdn/helpers/reset.css +94 -93
  104. package/src/cdn/helpers/responsive.css +22 -22
  105. package/src/cdn/helpers/ripples.css +33 -33
  106. package/src/cdn/helpers/ripples.ts +30 -30
  107. package/src/cdn/helpers/scrolls.css +8 -8
  108. package/src/cdn/helpers/shadows.css +23 -23
  109. package/src/cdn/helpers/sizes.css +45 -45
  110. package/src/cdn/helpers/spaces.css +19 -19
  111. package/src/cdn/helpers/theme.css +186 -186
  112. package/src/cdn/helpers/theme.ts +83 -83
  113. package/src/cdn/helpers/typography.css +225 -225
  114. package/src/cdn/helpers/waves.css +43 -43
  115. package/src/cdn/helpers/zoom.css +19 -19
  116. package/src/cdn/interfaces.ts +3 -3
  117. package/src/cdn/settings/dark.css +38 -38
  118. package/src/cdn/settings/fonts.css +35 -35
  119. package/src/cdn/settings/globals.css +18 -18
  120. package/src/cdn/settings/light.css +39 -39
  121. package/src/cdn/shapes/arch.svg +3 -3
  122. package/src/cdn/shapes/arrow.svg +3 -3
  123. package/src/cdn/shapes/boom.svg +3 -3
  124. package/src/cdn/shapes/bun.svg +3 -3
  125. package/src/cdn/shapes/burst.svg +3 -3
  126. package/src/cdn/shapes/circle.svg +3 -3
  127. package/src/cdn/shapes/clamshell.svg +3 -3
  128. package/src/cdn/shapes/diamond.svg +3 -3
  129. package/src/cdn/shapes/fan.svg +3 -3
  130. package/src/cdn/shapes/flower.svg +3 -3
  131. package/src/cdn/shapes/gem.svg +3 -3
  132. package/src/cdn/shapes/ghost-ish.svg +3 -3
  133. package/src/cdn/shapes/heart.svg +3 -3
  134. package/src/cdn/shapes/leaf-clover4.svg +3 -3
  135. package/src/cdn/shapes/leaf-clover8.svg +3 -3
  136. package/src/cdn/shapes/loading-indicator.svg +18 -18
  137. package/src/cdn/shapes/oval.svg +3 -3
  138. package/src/cdn/shapes/pentagon.svg +3 -3
  139. package/src/cdn/shapes/pill.svg +3 -3
  140. package/src/cdn/shapes/pixel-circle.svg +3 -3
  141. package/src/cdn/shapes/pixel-triangle.svg +3 -3
  142. package/src/cdn/shapes/puffy-diamond.svg +3 -3
  143. package/src/cdn/shapes/puffy.svg +3 -3
  144. package/src/cdn/shapes/semicircle.svg +3 -3
  145. package/src/cdn/shapes/sided-cookie12.svg +3 -3
  146. package/src/cdn/shapes/sided-cookie4.svg +3 -3
  147. package/src/cdn/shapes/sided-cookie6.svg +3 -3
  148. package/src/cdn/shapes/sided-cookie7.svg +3 -3
  149. package/src/cdn/shapes/sided-cookie9.svg +3 -3
  150. package/src/cdn/shapes/slanted.svg +3 -3
  151. package/src/cdn/shapes/soft-boom.svg +3 -3
  152. package/src/cdn/shapes/soft-burst.svg +3 -3
  153. package/src/cdn/shapes/square.svg +3 -3
  154. package/src/cdn/shapes/sunny.svg +3 -3
  155. package/src/cdn/shapes/triangle.svg +3 -3
  156. package/src/cdn/shapes/very-sunny.svg +3 -3
  157. package/src/cdn/shapes/wavy-circle.svg +3 -3
  158. package/src/cdn/shapes/wavy.svg +4 -4
  159. package/src/cdn/utils.ts +154 -154
package/dist/cdn/beer.js CHANGED
@@ -1,635 +1,635 @@
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;
6
- navigator.userAgent.includes("Windows");
7
- const isMac = navigator.userAgent.includes("Macintosh");
8
- navigator.userAgent.includes("Linux");
9
- navigator.userAgent.includes("Android");
10
- const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
11
- function isDark() {
12
- return window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)").matches;
13
- }
14
- async function wait(milliseconds) {
15
- await new Promise((resolve) => setTimeout(resolve, milliseconds));
16
- }
17
- 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
- });
23
- }
24
- function query(selector, element) {
25
- try {
26
- return typeof selector === "string" ? (element ?? document).querySelector(selector) : selector;
27
- } catch {
28
- return null;
29
- }
30
- }
31
- function queryAll(selector, element) {
32
- try {
33
- return typeof selector === "string" ? (element ?? document).querySelectorAll(selector) : selector ?? _emptyNodeList;
34
- } catch {
35
- return _emptyNodeList;
36
- }
37
- }
38
- function hasClass(element, name) {
39
- return (element == null ? void 0 : element.classList.contains(name)) ?? false;
40
- }
41
- function hasTag(element, name) {
42
- var _a;
43
- return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === name;
44
- }
45
- function hasType(element, name) {
46
- var _a;
47
- return ((_a = element == null ? void 0 : element.type) == null ? void 0 : _a.toLowerCase()) === name;
48
- }
49
- 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);
52
- }
53
- 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);
56
- }
57
- function on(element, name, callback, useCapture = true) {
58
- if (element == null ? void 0 : element.addEventListener) element.addEventListener(name, callback, useCapture);
59
- }
60
- function onWeak(element, name, callback, useCapture = true) {
61
- addWeakElement(element);
62
- on(element, name, callback, useCapture);
63
- }
64
- function off(element, name, callback, useCapture = true) {
65
- if (element == null ? void 0 : element.removeEventListener) element.removeEventListener(name, callback, useCapture);
66
- }
67
- function insertBefore(newElement, element) {
68
- var _a;
69
- (_a = element == null ? void 0 : element.parentNode) == null ? void 0 : _a.insertBefore(newElement, element);
70
- }
71
- function prev(element) {
72
- return element == null ? void 0 : element.previousElementSibling;
73
- }
74
- function next(element) {
75
- return element == null ? void 0 : element.nextElementSibling;
76
- }
77
- function parent(element) {
78
- return element == null ? void 0 : element.parentElement;
79
- }
80
- 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;
88
- }
89
- function blurActiveElement() {
90
- var _a;
91
- (_a = document.activeElement) == null ? void 0 : _a.blur();
92
- }
93
- function queryAllDataUi(id) {
94
- return queryAll('[data-ui="#' + id + '"]');
95
- }
96
- function queryDataUi(id) {
97
- return query('[data-ui="#' + id + '"]');
98
- }
99
- 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
- }
111
- 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);
116
- }
117
- function updatePlaceholder(element) {
118
- if (!element.placeholder) element.placeholder = " ";
119
- }
120
- 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();
125
- }
126
- function onFocusInput(e) {
127
- const input = e.currentTarget;
128
- updateInput(input);
129
- }
130
- function onBlurInput(e) {
131
- const input = e.currentTarget;
132
- updateInput(input);
133
- }
134
- function onChangeFile(e) {
135
- const input = e.currentTarget;
136
- updateFile(input);
137
- }
138
- function onChangeColor(e) {
139
- const input = e.currentTarget;
140
- updateColor(input);
141
- }
142
- function onKeydownFile(e) {
143
- const input = e.currentTarget;
144
- updateFile(input, e);
145
- }
146
- function onKeydownColor(e) {
147
- const input = e.currentTarget;
148
- updateColor(input, e);
149
- }
150
- 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"))) input.type = input.type === "password" ? "text" : "password";
155
- }
156
- function onInputTextarea(e) {
157
- const textarea = e.currentTarget;
158
- updateTextarea(textarea);
159
- }
160
- function updateAllLabels() {
161
- const labels = queryAll(".field > label");
162
- for (let i = 0; i < labels.length; i++) {
163
- onWeak(labels[i], "click", onClickLabel);
164
- }
165
- }
166
- function updateAllInputs() {
167
- const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
168
- for (let i = 0; i < inputs.length; i++) {
169
- onWeak(inputs[i], "focus", onFocusInput);
170
- onWeak(inputs[i], "blur", onBlurInput);
171
- updateInput(inputs[i]);
172
- }
173
- }
174
- function updateAllSelects() {
175
- const selects = queryAll(".field > select");
176
- for (let i = 0; i < selects.length; i++) {
177
- onWeak(selects[i], "focus", onFocusInput);
178
- onWeak(selects[i], "blur", onBlurInput);
179
- }
180
- }
181
- function updateAllFiles() {
182
- const files = queryAll(".field > input[type=file]");
183
- for (let i = 0; i < files.length; i++) {
184
- onWeak(files[i], "change", onChangeFile);
185
- updateFile(files[i]);
186
- }
187
- }
188
- function updateAllColors() {
189
- const colors = queryAll(".field > input[type=color]");
190
- for (let i = 0; i < colors.length; i++) {
191
- onWeak(colors[i], "change", onChangeColor);
192
- updateColor(colors[i]);
193
- }
194
- }
195
- function updateAllTextareas() {
196
- if (isChrome && !isMac && !isIOS) return;
197
- const textareas = queryAll(".field > textarea");
198
- for (let i = 0; i < textareas.length; i++) {
199
- onWeak(textareas[i], "focus", onFocusInput);
200
- onWeak(textareas[i], "blur", onBlurInput);
201
- onWeak(textareas[i], "input", onInputTextarea);
202
- updateTextarea(textareas[i]);
203
- }
204
- }
205
- function updateAllPasswordIcons() {
206
- const icons = queryAll("input[type=password] ~ :is(i, a)");
207
- for (let i = 0; i < icons.length; i++) onWeak(icons[i], "click", onPasswordIconClick);
208
- }
209
- function updateInput(input) {
210
- if (hasType(input, "number") && !input.value) input.value = "";
211
- updatePlaceholder(input);
212
- }
213
- function updateFile(input, e) {
214
- if ((e == null ? void 0 : e.key) === "Enter") {
215
- const previousInput = prev(input);
216
- if (!hasType(previousInput, "file")) return;
217
- previousInput.click();
218
- return;
219
- }
220
- const nextInput = next(input);
221
- if (!hasType(nextInput, "text")) return;
222
- nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
223
- nextInput.readOnly = true;
224
- onWeak(nextInput, "keydown", onKeydownFile, false);
225
- updateInput(nextInput);
226
- }
227
- function updateColor(input, e) {
228
- if ((e == null ? void 0 : e.key) === "Enter") {
229
- const previousInput = prev(input);
230
- if (!hasType(previousInput, "color")) return;
231
- previousInput.click();
232
- return;
233
- }
234
- const nextInput = next(input);
235
- if (!hasType(nextInput, "text")) return;
236
- nextInput.readOnly = true;
237
- nextInput.value = input.value;
238
- onWeak(nextInput, "keydown", onKeydownColor, false);
239
- updateInput(nextInput);
240
- }
241
- function updateTextarea(textarea) {
242
- updatePlaceholder(textarea);
243
- if (textarea.hasAttribute("rows")) return;
244
- const rootSize = rootSizeInPixels();
245
- textarea.style.blockSize = "auto";
246
- textarea.style.blockSize = `${textarea.scrollHeight - rootSize}px`;
247
- }
248
- function updateAllFields() {
249
- updateAllLabels();
250
- updateAllInputs();
251
- updateAllSelects();
252
- updateAllFiles();
253
- updateAllColors();
254
- updateAllTextareas();
255
- updateAllPasswordIcons();
256
- }
257
- function onInputDocument$1(e) {
258
- const input = e.target;
259
- if (!hasTag(input, "input") && !hasTag(input, "select")) return;
260
- if (input.type === "range") {
261
- input.focus();
262
- updateRange(input);
263
- } else {
264
- updateAllRanges();
265
- }
266
- }
267
- function onChangeInput(e) {
268
- const input = e.target;
269
- requestAnimationFrame(() => input.blur());
270
- }
271
- function updateAllRanges() {
272
- const body = document.body;
273
- const ranges = queryAll(".slider > input[type=range]");
274
- if (!ranges.length) off(body, "input", onInputDocument$1, false);
275
- else on(body, "input", onInputDocument$1, false);
276
- for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
277
- }
278
- function updateRange(input) {
279
- onWeak(input, "change", onChangeInput);
280
- const label = parent(input);
281
- const bar = query("span", label);
282
- const inputs = queryAll("input", label);
283
- if (!inputs.length || !bar) return;
284
- const rootSize = rootSizeInPixels();
285
- const thumb = hasClass(label, "max") ? 0 : 0.25 * rootSize * 100 / inputs[0].offsetWidth;
286
- const percents = [];
287
- const values = [];
288
- for (let i = 0, n = inputs.length; i < n; i++) {
289
- const min = parseFloat(inputs[i].min) || 0;
290
- const max = parseFloat(inputs[i].max) || 100;
291
- const value = parseFloat(inputs[i].value) || 0;
292
- const percent2 = (value - min) * 100 / (max - min);
293
- const fix = thumb / 2 - thumb * percent2 / 100;
294
- percents.push(percent2 + fix);
295
- values.push(value);
296
- }
297
- let percent = percents[0];
298
- let start2 = 0;
299
- let end = 100 - start2 - percent;
300
- let value1 = values[0];
301
- let value2 = values[1] || 0;
302
- if (inputs.length > 1) {
303
- percent = Math.abs(percents[1] - percents[0]);
304
- start2 = percents[1] > percents[0] ? percents[0] : percents[1];
305
- end = 100 - start2 - percent;
306
- if (value2 > value1) {
307
- value1 = values[1] || 0;
308
- value2 = values[0];
309
- }
310
- }
311
- label.style.setProperty("--_start", `${start2}%`);
312
- label.style.setProperty("--_end", `${end}%`);
313
- label.style.setProperty("--_value1", `'${value1}'`);
314
- label.style.setProperty("--_value2", `'${value2}'`);
315
- }
316
- function updateAllSliders() {
317
- updateAllRanges();
318
- }
319
- const _lastTheme = {
320
- light: "",
321
- dark: ""
322
- };
323
- function getMode() {
324
- var _a;
325
- return ((_a = document == null ? void 0 : document.body) == null ? void 0 : _a.classList.contains("dark")) ? "dark" : "light";
326
- }
327
- function lastTheme() {
328
- if (_lastTheme.light && _lastTheme.dark) return _lastTheme;
329
- const body = document.body;
330
- const light = document.createElement("body");
331
- light.className = "light";
332
- body.appendChild(light);
333
- const dark = document.createElement("body");
334
- dark.className = "dark";
335
- body.appendChild(dark);
336
- const fromLight = getComputedStyle(light);
337
- const fromDark = getComputedStyle(dark);
338
- 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"];
339
- for (let i = 0, n = variables.length; i < n; i++) {
340
- _lastTheme.light += variables[i] + ":" + fromLight.getPropertyValue(variables[i]) + ";";
341
- _lastTheme.dark += variables[i] + ":" + fromDark.getPropertyValue(variables[i]) + ";";
342
- }
343
- body.removeChild(light);
344
- body.removeChild(dark);
345
- return _lastTheme;
346
- }
347
- function updateTheme(source) {
348
- const context = globalThis;
349
- const body = document.body;
350
- if (!source || !context.materialDynamicColors) return lastTheme();
351
- const mode = getMode();
352
- if (source.light && source.dark) {
353
- _lastTheme.light = source.light;
354
- _lastTheme.dark = source.dark;
355
- body.setAttribute("style", source[mode]);
356
- return source;
357
- }
358
- return context.materialDynamicColors(source).then((theme) => {
359
- const toCss = (data) => {
360
- let style = "";
361
- for (let i = 0, keys = Object.keys(data), n = keys.length; i < n; i++) {
362
- const key = keys[i];
363
- const value = data[key];
364
- const kebabCase = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
365
- style += "--" + kebabCase + ":" + value + ";";
366
- }
367
- return style;
368
- };
369
- _lastTheme.light = toCss(theme.light);
370
- _lastTheme.dark = toCss(theme.dark);
371
- body.setAttribute("style", _lastTheme[mode]);
372
- return _lastTheme;
373
- });
374
- }
375
- function updateMode(value) {
376
- const context = globalThis;
377
- const body = document.body;
378
- if (!body) return value;
379
- if (!value) return getMode();
380
- if (value === "auto") value = isDark() ? "dark" : "light";
381
- body.classList.remove("light", "dark");
382
- body.classList.add(value);
383
- const lastThemeStyle = value === "light" ? _lastTheme.light : _lastTheme.dark;
384
- if (context.materialDynamicColors) body.setAttribute("style", lastThemeStyle);
385
- return getMode();
386
- }
387
- const _dialogs = [];
388
- function onKeydownDialog(e) {
389
- if (e.key === "Escape") {
390
- const dialog = e.currentTarget;
391
- void updateDialog(dialog, dialog);
392
- }
393
- }
394
- function focusOnDialogOrElement(dialog) {
395
- const element = query("[autofocus]", dialog) ?? dialog;
396
- element.focus();
397
- }
398
- function closeDialog(dialog, overlay) {
399
- removeClass(queryAllDataUi(dialog.id), "active");
400
- removeClass(dialog, "active");
401
- removeClass(overlay, "active");
402
- dialog.close();
403
- _dialogs.pop();
404
- const previousDialog = _dialogs[_dialogs.length - 1];
405
- if (previousDialog) previousDialog.focus();
406
- }
407
- async function openDialog(dialog, overlay, isModal, from) {
408
- if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
409
- addClass(overlay, "active");
410
- addClass(dialog, "active");
411
- if (isModal) dialog.showModal();
412
- else dialog.show();
413
- await wait(90);
414
- if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
415
- _dialogs.push(dialog);
416
- focusOnDialogOrElement(dialog);
417
- }
418
- function onClickOverlay(e) {
419
- const overlay = e.currentTarget;
420
- const dialog = next(overlay);
421
- if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
422
- }
423
- async function updateDialog(from, dialog) {
424
- blurActiveElement();
425
- let overlay = prev(dialog);
426
- const isActive = hasClass(dialog, "active") || dialog.open;
427
- const isModal = hasClass(dialog, "modal");
428
- if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
429
- if (!hasClass(overlay, "overlay")) {
430
- overlay = create({ class: "overlay" });
431
- insertBefore(overlay, dialog);
432
- await wait(90);
433
- }
434
- if (!isModal) onWeak(overlay, "click", onClickOverlay, false);
435
- if (isActive) closeDialog(dialog, overlay);
436
- else void openDialog(dialog, overlay, isModal, from);
437
- }
438
- let _timeoutMenu;
439
- function onClickDocument(e) {
440
- off(document.body, "click", onClickDocument);
441
- const body = e.target;
442
- const menus = queryAll("menu.active");
443
- for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
444
- }
445
- function focusOnMenuOrInput(menu) {
446
- setTimeout(() => {
447
- const input = query(".field > input", menu);
448
- if (input) input.focus();
449
- else menu.focus();
450
- }, 90);
451
- }
452
- function updateMenu(from, menu, e) {
453
- if (_timeoutMenu) clearTimeout(_timeoutMenu);
454
- _timeoutMenu = setTimeout(() => {
455
- on(document.body, "click", onClickDocument);
456
- if (!hasTag(document.activeElement, "input")) blurActiveElement();
457
- const isActive = hasClass(menu, "active");
458
- const isEvent = (e == null ? void 0 : e.target) === from;
459
- const isChild = !!from.closest("menu");
460
- if (!isActive && isChild || isActive && isEvent) {
461
- removeClass(menu, "active");
462
- return;
463
- }
464
- removeClass(queryAll("menu.active"), "active");
465
- addClass(menu, "active");
466
- focusOnMenuOrInput(menu);
467
- }, 90);
468
- }
469
- let _timeoutSnackbar;
470
- function onClickSnackbar(e) {
471
- const snackbar = e.currentTarget;
472
- removeClass(snackbar, "active");
473
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
474
- }
475
- function updateSnackbar(snackbar, milliseconds) {
476
- blurActiveElement();
477
- const activeSnackbars = queryAll(".snackbar.active");
478
- for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
479
- addClass(snackbar, "active");
480
- onWeak(snackbar, "click", onClickSnackbar);
481
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
482
- if (milliseconds === -1) return;
483
- _timeoutSnackbar = setTimeout(() => {
484
- removeClass(snackbar, "active");
485
- }, milliseconds ?? 6e3);
486
- }
487
- function updatePage(page) {
488
- const container = parent(page);
489
- if (container) removeClass(queryAll(":scope > .page", container), "active");
490
- addClass(page, "active");
491
- }
492
- function onPointerDownRipple(e) {
493
- updateRipple(e);
494
- }
495
- function updateRipple(e) {
496
- const element = e.currentTarget;
497
- const rect = element.getBoundingClientRect();
498
- const diameter = Math.max(rect.width, rect.height);
499
- const radius = diameter / 2;
500
- const x = e.clientX - rect.left - radius;
501
- const y = e.clientY - rect.top - radius;
502
- const rippleContainer = document.createElement("div");
503
- rippleContainer.className = "ripple-js";
504
- const ripple = document.createElement("div");
505
- ripple.style.inlineSize = ripple.style.blockSize = `${diameter}px`;
506
- ripple.style.left = `${x}px`;
507
- ripple.style.top = `${y}px`;
508
- ripple.addEventListener("animationend", () => {
509
- rippleContainer.remove();
510
- });
511
- rippleContainer.appendChild(ripple);
512
- element.appendChild(rippleContainer);
513
- }
514
- function updateAllRipples() {
515
- const ripples = queryAll(".slow-ripple, .ripple, .fast-ripple");
516
- for (let i = 0; i < ripples.length; i++) onWeak(ripples[i], "pointerdown", onPointerDownRipple);
517
- }
518
- function onInputDocument(e) {
519
- const progress = e.target;
520
- if (hasTag(progress, "progress")) {
521
- updateProgress(progress);
522
- } else {
523
- updateAllProgress();
524
- }
525
- }
526
- function updateProgress(progress) {
527
- if (!progress.hasAttribute("value") && !progress.hasAttribute("max")) {
528
- const value = hasClass(progress, "circle") ? "50" : "100";
529
- progress.style.setProperty("--_value", value);
530
- progress.setAttribute("value", value);
531
- progress.setAttribute("max", "100");
532
- progress.classList.add("indeterminate");
533
- } else {
534
- progress.style.setProperty("--_value", String(progress.value));
535
- }
536
- }
537
- function updateAllProgress() {
538
- if (isChrome && !isMac && !isIOS) return;
539
- const body = document.body;
540
- const progresses = queryAll("progress");
541
- if (!progresses.length) off(body, "input", onInputDocument, false);
542
- else on(body, "input", onInputDocument, false);
543
- for (let i = 0; i < progresses.length; i++) updateProgress(progresses[i]);
544
- }
545
- const _context = globalThis;
546
- let _timeoutMutation;
547
- let _mutation;
548
- function onMutation() {
549
- if (_timeoutMutation) clearTimeout(_timeoutMutation);
550
- _timeoutMutation = setTimeout(async () => await _ui(), 180);
551
- }
552
- async function run(from, to, options, e) {
553
- if (!to) {
554
- to = query(from.getAttribute("data-ui"));
555
- if (!to) {
556
- from.classList.toggle("active");
557
- return;
558
- }
559
- }
560
- updateAllClickable(from);
561
- if (hasTag(to, "dialog")) {
562
- await updateDialog(from, to);
563
- return;
564
- }
565
- if (hasTag(to, "menu")) {
566
- updateMenu(from, to, e);
567
- return;
568
- }
569
- if (hasClass(to, "snackbar")) {
570
- updateSnackbar(to, options);
571
- return;
572
- }
573
- if (hasClass(to, "page")) {
574
- updatePage(to);
575
- return;
576
- }
577
- if (hasClass(to, "active")) {
578
- removeClass(from, "active");
579
- removeClass(to, "active");
580
- return;
581
- }
582
- addClass(to, "active");
583
- }
584
- function onClickElement(e) {
585
- void run(e.currentTarget, null, null, e);
586
- }
587
- function onKeydownElement(e) {
588
- if (e.key === "Enter") void run(e.currentTarget, null, null, e);
589
- }
590
- function setup() {
591
- if (_context.ui || _mutation || !_context.MutationObserver) return;
592
- _mutation = new MutationObserver(onMutation);
593
- _mutation.observe(document.body, { childList: true, subtree: true });
594
- onMutation();
595
- }
596
- function updateAllDataUis() {
597
- const elements = queryAll("[data-ui]");
598
- for (let i = 0, n = elements.length; i < n; i++) {
599
- onWeak(elements[i], "click", onClickElement);
600
- if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) onWeak(elements[i], "keydown", onKeydownElement);
601
- }
602
- }
603
- function _ui(selector, options) {
604
- if (selector) {
605
- if (selector === "setup") {
606
- setup();
607
- return;
608
- }
609
- if (selector === "guid") return guid();
610
- if (selector === "mode") return updateMode(options);
611
- if (selector === "theme") return updateTheme(options);
612
- const to = query(selector);
613
- if (!to) return;
614
- void run(to, to, options);
615
- }
616
- updateAllDataUis();
617
- updateAllFields();
618
- updateAllSliders();
619
- updateAllRipples();
620
- updateAllProgress();
621
- }
622
- function start() {
623
- var _a;
624
- if (_context.ui) return;
625
- const body = (_a = _context.document) == null ? void 0 : _a.body;
626
- if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
627
- setup();
628
- _context.ui = _ui;
629
- }
630
- start();
631
- const ui = _context.ui;
632
- export {
633
- ui as default,
634
- ui
635
- };
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;
6
+ navigator.userAgent.includes("Windows");
7
+ const isMac = navigator.userAgent.includes("Macintosh");
8
+ navigator.userAgent.includes("Linux");
9
+ navigator.userAgent.includes("Android");
10
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
11
+ function isDark() {
12
+ return window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)").matches;
13
+ }
14
+ async function wait(milliseconds) {
15
+ await new Promise((resolve) => setTimeout(resolve, milliseconds));
16
+ }
17
+ 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
+ });
23
+ }
24
+ function query(selector, element) {
25
+ try {
26
+ return typeof selector === "string" ? (element ?? document).querySelector(selector) : selector;
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+ function queryAll(selector, element) {
32
+ try {
33
+ return typeof selector === "string" ? (element ?? document).querySelectorAll(selector) : selector ?? _emptyNodeList;
34
+ } catch {
35
+ return _emptyNodeList;
36
+ }
37
+ }
38
+ function hasClass(element, name) {
39
+ return (element == null ? void 0 : element.classList.contains(name)) ?? false;
40
+ }
41
+ function hasTag(element, name) {
42
+ var _a;
43
+ return ((_a = element == null ? void 0 : element.tagName) == null ? void 0 : _a.toLowerCase()) === name;
44
+ }
45
+ function hasType(element, name) {
46
+ var _a;
47
+ return ((_a = element == null ? void 0 : element.type) == null ? void 0 : _a.toLowerCase()) === name;
48
+ }
49
+ 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);
52
+ }
53
+ 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);
56
+ }
57
+ function on(element, name, callback, useCapture = true) {
58
+ if (element == null ? void 0 : element.addEventListener) element.addEventListener(name, callback, useCapture);
59
+ }
60
+ function onWeak(element, name, callback, useCapture = true) {
61
+ addWeakElement(element);
62
+ on(element, name, callback, useCapture);
63
+ }
64
+ function off(element, name, callback, useCapture = true) {
65
+ if (element == null ? void 0 : element.removeEventListener) element.removeEventListener(name, callback, useCapture);
66
+ }
67
+ function insertBefore(newElement, element) {
68
+ var _a;
69
+ (_a = element == null ? void 0 : element.parentNode) == null ? void 0 : _a.insertBefore(newElement, element);
70
+ }
71
+ function prev(element) {
72
+ return element == null ? void 0 : element.previousElementSibling;
73
+ }
74
+ function next(element) {
75
+ return element == null ? void 0 : element.nextElementSibling;
76
+ }
77
+ function parent(element) {
78
+ return element == null ? void 0 : element.parentElement;
79
+ }
80
+ 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;
88
+ }
89
+ function blurActiveElement() {
90
+ var _a;
91
+ (_a = document.activeElement) == null ? void 0 : _a.blur();
92
+ }
93
+ function queryAllDataUi(id) {
94
+ return queryAll('[data-ui="#' + id + '"]');
95
+ }
96
+ function queryDataUi(id) {
97
+ return query('[data-ui="#' + id + '"]');
98
+ }
99
+ 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
+ }
111
+ 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);
116
+ }
117
+ function updatePlaceholder(element) {
118
+ if (!element.placeholder) element.placeholder = " ";
119
+ }
120
+ 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();
125
+ }
126
+ function onFocusInput(e) {
127
+ const input = e.currentTarget;
128
+ updateInput(input);
129
+ }
130
+ function onBlurInput(e) {
131
+ const input = e.currentTarget;
132
+ updateInput(input);
133
+ }
134
+ function onChangeFile(e) {
135
+ const input = e.currentTarget;
136
+ updateFile(input);
137
+ }
138
+ function onChangeColor(e) {
139
+ const input = e.currentTarget;
140
+ updateColor(input);
141
+ }
142
+ function onKeydownFile(e) {
143
+ const input = e.currentTarget;
144
+ updateFile(input, e);
145
+ }
146
+ function onKeydownColor(e) {
147
+ const input = e.currentTarget;
148
+ updateColor(input, e);
149
+ }
150
+ 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"))) input.type = input.type === "password" ? "text" : "password";
155
+ }
156
+ function onInputTextarea(e) {
157
+ const textarea = e.currentTarget;
158
+ updateTextarea(textarea);
159
+ }
160
+ function updateAllLabels() {
161
+ const labels = queryAll(".field > label");
162
+ for (let i = 0; i < labels.length; i++) {
163
+ onWeak(labels[i], "click", onClickLabel);
164
+ }
165
+ }
166
+ function updateAllInputs() {
167
+ const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
168
+ for (let i = 0; i < inputs.length; i++) {
169
+ onWeak(inputs[i], "focus", onFocusInput);
170
+ onWeak(inputs[i], "blur", onBlurInput);
171
+ updateInput(inputs[i]);
172
+ }
173
+ }
174
+ function updateAllSelects() {
175
+ const selects = queryAll(".field > select");
176
+ for (let i = 0; i < selects.length; i++) {
177
+ onWeak(selects[i], "focus", onFocusInput);
178
+ onWeak(selects[i], "blur", onBlurInput);
179
+ }
180
+ }
181
+ function updateAllFiles() {
182
+ const files = queryAll(".field > input[type=file]");
183
+ for (let i = 0; i < files.length; i++) {
184
+ onWeak(files[i], "change", onChangeFile);
185
+ updateFile(files[i]);
186
+ }
187
+ }
188
+ function updateAllColors() {
189
+ const colors = queryAll(".field > input[type=color]");
190
+ for (let i = 0; i < colors.length; i++) {
191
+ onWeak(colors[i], "change", onChangeColor);
192
+ updateColor(colors[i]);
193
+ }
194
+ }
195
+ function updateAllTextareas() {
196
+ const textareas = queryAll(".field > textarea");
197
+ for (let i = 0; i < textareas.length; i++) {
198
+ onWeak(textareas[i], "focus", onFocusInput);
199
+ onWeak(textareas[i], "blur", onBlurInput);
200
+ if (isChrome && !isMac && !isIOS) continue;
201
+ onWeak(textareas[i], "input", onInputTextarea);
202
+ updateTextarea(textareas[i]);
203
+ }
204
+ }
205
+ function updateAllPasswordIcons() {
206
+ const icons = queryAll("input[type=password] ~ :is(i, a)");
207
+ for (let i = 0; i < icons.length; i++) onWeak(icons[i], "click", onPasswordIconClick);
208
+ }
209
+ function updateInput(input) {
210
+ if (hasType(input, "number") && !input.value) input.value = "";
211
+ updatePlaceholder(input);
212
+ }
213
+ function updateFile(input, e) {
214
+ if ((e == null ? void 0 : e.key) === "Enter") {
215
+ const previousInput = prev(input);
216
+ if (!hasType(previousInput, "file")) return;
217
+ previousInput.click();
218
+ return;
219
+ }
220
+ const nextInput = next(input);
221
+ if (!hasType(nextInput, "text")) return;
222
+ nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
223
+ nextInput.readOnly = true;
224
+ onWeak(nextInput, "keydown", onKeydownFile, false);
225
+ updateInput(nextInput);
226
+ }
227
+ function updateColor(input, e) {
228
+ if ((e == null ? void 0 : e.key) === "Enter") {
229
+ const previousInput = prev(input);
230
+ if (!hasType(previousInput, "color")) return;
231
+ previousInput.click();
232
+ return;
233
+ }
234
+ const nextInput = next(input);
235
+ if (!hasType(nextInput, "text")) return;
236
+ nextInput.readOnly = true;
237
+ nextInput.value = input.value;
238
+ onWeak(nextInput, "keydown", onKeydownColor, false);
239
+ updateInput(nextInput);
240
+ }
241
+ function updateTextarea(textarea) {
242
+ updatePlaceholder(textarea);
243
+ if (textarea.hasAttribute("rows")) return;
244
+ const rootSize = rootSizeInPixels();
245
+ textarea.style.blockSize = "auto";
246
+ textarea.style.blockSize = `${textarea.scrollHeight - rootSize}px`;
247
+ }
248
+ function updateAllFields() {
249
+ updateAllLabels();
250
+ updateAllInputs();
251
+ updateAllSelects();
252
+ updateAllFiles();
253
+ updateAllColors();
254
+ updateAllTextareas();
255
+ updateAllPasswordIcons();
256
+ }
257
+ function onInputDocument$1(e) {
258
+ const input = e.target;
259
+ if (!hasTag(input, "input") && !hasTag(input, "select")) return;
260
+ if (input.type === "range") {
261
+ input.focus();
262
+ updateRange(input);
263
+ } else {
264
+ updateAllRanges();
265
+ }
266
+ }
267
+ function onChangeInput(e) {
268
+ const input = e.target;
269
+ requestAnimationFrame(() => input.blur());
270
+ }
271
+ function updateAllRanges() {
272
+ const body = document.body;
273
+ const ranges = queryAll(".slider > input[type=range]");
274
+ if (!ranges.length) off(body, "input", onInputDocument$1, false);
275
+ else on(body, "input", onInputDocument$1, false);
276
+ for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
277
+ }
278
+ function updateRange(input) {
279
+ onWeak(input, "change", onChangeInput);
280
+ const label = parent(input);
281
+ const bar = query("span", label);
282
+ const inputs = queryAll("input", label);
283
+ if (!inputs.length || !bar) return;
284
+ const rootSize = rootSizeInPixels();
285
+ const thumb = hasClass(label, "max") ? 0 : 0.25 * rootSize * 100 / inputs[0].offsetWidth;
286
+ const percents = [];
287
+ const values = [];
288
+ for (let i = 0, n = inputs.length; i < n; i++) {
289
+ const min = parseFloat(inputs[i].min) || 0;
290
+ const max = parseFloat(inputs[i].max) || 100;
291
+ const value = parseFloat(inputs[i].value) || 0;
292
+ const percent2 = (value - min) * 100 / (max - min);
293
+ const fix = thumb / 2 - thumb * percent2 / 100;
294
+ percents.push(percent2 + fix);
295
+ values.push(value);
296
+ }
297
+ let percent = percents[0];
298
+ let start2 = 0;
299
+ let end = 100 - start2 - percent;
300
+ let value1 = values[0];
301
+ let value2 = values[1] || 0;
302
+ if (inputs.length > 1) {
303
+ percent = Math.abs(percents[1] - percents[0]);
304
+ start2 = percents[1] > percents[0] ? percents[0] : percents[1];
305
+ end = 100 - start2 - percent;
306
+ if (value2 > value1) {
307
+ value1 = values[1] || 0;
308
+ value2 = values[0];
309
+ }
310
+ }
311
+ label.style.setProperty("--_start", `${start2}%`);
312
+ label.style.setProperty("--_end", `${end}%`);
313
+ label.style.setProperty("--_value1", `'${value1}'`);
314
+ label.style.setProperty("--_value2", `'${value2}'`);
315
+ }
316
+ function updateAllSliders() {
317
+ updateAllRanges();
318
+ }
319
+ const _lastTheme = {
320
+ light: "",
321
+ dark: ""
322
+ };
323
+ function getMode() {
324
+ var _a;
325
+ return ((_a = document == null ? void 0 : document.body) == null ? void 0 : _a.classList.contains("dark")) ? "dark" : "light";
326
+ }
327
+ function lastTheme() {
328
+ if (_lastTheme.light && _lastTheme.dark) return _lastTheme;
329
+ const body = document.body;
330
+ const light = document.createElement("body");
331
+ light.className = "light";
332
+ body.appendChild(light);
333
+ const dark = document.createElement("body");
334
+ dark.className = "dark";
335
+ body.appendChild(dark);
336
+ const fromLight = getComputedStyle(light);
337
+ const fromDark = getComputedStyle(dark);
338
+ 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"];
339
+ for (let i = 0, n = variables.length; i < n; i++) {
340
+ _lastTheme.light += variables[i] + ":" + fromLight.getPropertyValue(variables[i]) + ";";
341
+ _lastTheme.dark += variables[i] + ":" + fromDark.getPropertyValue(variables[i]) + ";";
342
+ }
343
+ body.removeChild(light);
344
+ body.removeChild(dark);
345
+ return _lastTheme;
346
+ }
347
+ function updateTheme(source) {
348
+ const context = globalThis;
349
+ const body = document.body;
350
+ if (!source || !context.materialDynamicColors) return lastTheme();
351
+ const mode = getMode();
352
+ if (source.light && source.dark) {
353
+ _lastTheme.light = source.light;
354
+ _lastTheme.dark = source.dark;
355
+ body.setAttribute("style", source[mode]);
356
+ return source;
357
+ }
358
+ return context.materialDynamicColors(source).then((theme) => {
359
+ const toCss = (data) => {
360
+ let style = "";
361
+ for (let i = 0, keys = Object.keys(data), n = keys.length; i < n; i++) {
362
+ const key = keys[i];
363
+ const value = data[key];
364
+ const kebabCase = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
365
+ style += "--" + kebabCase + ":" + value + ";";
366
+ }
367
+ return style;
368
+ };
369
+ _lastTheme.light = toCss(theme.light);
370
+ _lastTheme.dark = toCss(theme.dark);
371
+ body.setAttribute("style", _lastTheme[mode]);
372
+ return _lastTheme;
373
+ });
374
+ }
375
+ function updateMode(value) {
376
+ const context = globalThis;
377
+ const body = document.body;
378
+ if (!body) return value;
379
+ if (!value) return getMode();
380
+ if (value === "auto") value = isDark() ? "dark" : "light";
381
+ body.classList.remove("light", "dark");
382
+ body.classList.add(value);
383
+ const lastThemeStyle = value === "light" ? _lastTheme.light : _lastTheme.dark;
384
+ if (context.materialDynamicColors) body.setAttribute("style", lastThemeStyle);
385
+ return getMode();
386
+ }
387
+ const _dialogs = [];
388
+ function onKeydownDialog(e) {
389
+ if (e.key === "Escape") {
390
+ const dialog = e.currentTarget;
391
+ void updateDialog(dialog, dialog);
392
+ }
393
+ }
394
+ function focusOnDialogOrElement(dialog) {
395
+ const element = query("[autofocus]", dialog) ?? dialog;
396
+ element.focus();
397
+ }
398
+ function closeDialog(dialog, overlay) {
399
+ removeClass(queryAllDataUi(dialog.id), "active");
400
+ removeClass(dialog, "active");
401
+ removeClass(overlay, "active");
402
+ dialog.close();
403
+ _dialogs.pop();
404
+ const previousDialog = _dialogs[_dialogs.length - 1];
405
+ if (previousDialog) previousDialog.focus();
406
+ }
407
+ async function openDialog(dialog, overlay, isModal, from) {
408
+ if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
409
+ addClass(overlay, "active");
410
+ addClass(dialog, "active");
411
+ if (isModal) dialog.showModal();
412
+ else dialog.show();
413
+ await wait(90);
414
+ if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
415
+ _dialogs.push(dialog);
416
+ focusOnDialogOrElement(dialog);
417
+ }
418
+ function onClickOverlay(e) {
419
+ const overlay = e.currentTarget;
420
+ const dialog = next(overlay);
421
+ if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
422
+ }
423
+ async function updateDialog(from, dialog) {
424
+ blurActiveElement();
425
+ let overlay = prev(dialog);
426
+ const isActive = hasClass(dialog, "active") || dialog.open;
427
+ const isModal = hasClass(dialog, "modal");
428
+ if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
429
+ if (!hasClass(overlay, "overlay")) {
430
+ overlay = create({ class: "overlay" });
431
+ insertBefore(overlay, dialog);
432
+ await wait(90);
433
+ }
434
+ if (!isModal) onWeak(overlay, "click", onClickOverlay, false);
435
+ if (isActive) closeDialog(dialog, overlay);
436
+ else void openDialog(dialog, overlay, isModal, from);
437
+ }
438
+ let _timeoutMenu;
439
+ function onClickDocument(e) {
440
+ off(document.body, "click", onClickDocument);
441
+ const body = e.target;
442
+ const menus = queryAll("menu.active");
443
+ for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
444
+ }
445
+ function focusOnMenuOrInput(menu) {
446
+ setTimeout(() => {
447
+ const input = query(".field > input", menu);
448
+ if (input) input.focus();
449
+ else menu.focus();
450
+ }, 90);
451
+ }
452
+ function updateMenu(from, menu, e) {
453
+ if (_timeoutMenu) clearTimeout(_timeoutMenu);
454
+ _timeoutMenu = setTimeout(() => {
455
+ on(document.body, "click", onClickDocument);
456
+ if (!hasTag(document.activeElement, "input")) blurActiveElement();
457
+ const isActive = hasClass(menu, "active");
458
+ const isEvent = (e == null ? void 0 : e.target) === from;
459
+ const isChild = !!from.closest("menu");
460
+ if (!isActive && isChild || isActive && isEvent) {
461
+ removeClass(menu, "active");
462
+ return;
463
+ }
464
+ removeClass(queryAll("menu.active"), "active");
465
+ addClass(menu, "active");
466
+ focusOnMenuOrInput(menu);
467
+ }, 90);
468
+ }
469
+ let _timeoutSnackbar;
470
+ function onClickSnackbar(e) {
471
+ const snackbar = e.currentTarget;
472
+ removeClass(snackbar, "active");
473
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
474
+ }
475
+ function updateSnackbar(snackbar, milliseconds) {
476
+ blurActiveElement();
477
+ const activeSnackbars = queryAll(".snackbar.active");
478
+ for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
479
+ addClass(snackbar, "active");
480
+ onWeak(snackbar, "click", onClickSnackbar);
481
+ if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
482
+ if (milliseconds === -1) return;
483
+ _timeoutSnackbar = setTimeout(() => {
484
+ removeClass(snackbar, "active");
485
+ }, milliseconds ?? 6e3);
486
+ }
487
+ function updatePage(page) {
488
+ const container = parent(page);
489
+ if (container) removeClass(queryAll(":scope > .page", container), "active");
490
+ addClass(page, "active");
491
+ }
492
+ function onPointerDownRipple(e) {
493
+ updateRipple(e);
494
+ }
495
+ function updateRipple(e) {
496
+ const element = e.currentTarget;
497
+ const rect = element.getBoundingClientRect();
498
+ const diameter = Math.max(rect.width, rect.height);
499
+ const radius = diameter / 2;
500
+ const x = e.clientX - rect.left - radius;
501
+ const y = e.clientY - rect.top - radius;
502
+ const rippleContainer = document.createElement("div");
503
+ rippleContainer.className = "ripple-js";
504
+ const ripple = document.createElement("div");
505
+ ripple.style.inlineSize = ripple.style.blockSize = `${diameter}px`;
506
+ ripple.style.left = `${x}px`;
507
+ ripple.style.top = `${y}px`;
508
+ ripple.addEventListener("animationend", () => {
509
+ rippleContainer.remove();
510
+ });
511
+ rippleContainer.appendChild(ripple);
512
+ element.appendChild(rippleContainer);
513
+ }
514
+ function updateAllRipples() {
515
+ const ripples = queryAll(".slow-ripple, .ripple, .fast-ripple");
516
+ for (let i = 0; i < ripples.length; i++) onWeak(ripples[i], "pointerdown", onPointerDownRipple);
517
+ }
518
+ function onInputDocument(e) {
519
+ const progress = e.target;
520
+ if (hasTag(progress, "progress")) {
521
+ updateProgress(progress);
522
+ } else {
523
+ updateAllProgress();
524
+ }
525
+ }
526
+ function updateProgress(progress) {
527
+ if (!progress.hasAttribute("value") && !progress.hasAttribute("max")) {
528
+ const value = hasClass(progress, "circle") ? "50" : "100";
529
+ progress.style.setProperty("--_value", value);
530
+ progress.setAttribute("value", value);
531
+ progress.setAttribute("max", "100");
532
+ progress.classList.add("indeterminate");
533
+ } else {
534
+ progress.style.setProperty("--_value", String(progress.value));
535
+ }
536
+ }
537
+ function updateAllProgress() {
538
+ if (isChrome && !isMac && !isIOS) return;
539
+ const body = document.body;
540
+ const progresses = queryAll("progress");
541
+ if (!progresses.length) off(body, "input", onInputDocument, false);
542
+ else on(body, "input", onInputDocument, false);
543
+ for (let i = 0; i < progresses.length; i++) updateProgress(progresses[i]);
544
+ }
545
+ const _context = globalThis;
546
+ let _timeoutMutation;
547
+ let _mutation;
548
+ function onMutation() {
549
+ if (_timeoutMutation) clearTimeout(_timeoutMutation);
550
+ _timeoutMutation = setTimeout(async () => await _ui(), 180);
551
+ }
552
+ async function run(from, to, options, e) {
553
+ if (!to) {
554
+ to = query(from.getAttribute("data-ui"));
555
+ if (!to) {
556
+ from.classList.toggle("active");
557
+ return;
558
+ }
559
+ }
560
+ updateAllClickable(from);
561
+ if (hasTag(to, "dialog")) {
562
+ await updateDialog(from, to);
563
+ return;
564
+ }
565
+ if (hasTag(to, "menu")) {
566
+ updateMenu(from, to, e);
567
+ return;
568
+ }
569
+ if (hasClass(to, "snackbar")) {
570
+ updateSnackbar(to, options);
571
+ return;
572
+ }
573
+ if (hasClass(to, "page")) {
574
+ updatePage(to);
575
+ return;
576
+ }
577
+ if (hasClass(to, "active")) {
578
+ removeClass(from, "active");
579
+ removeClass(to, "active");
580
+ return;
581
+ }
582
+ addClass(to, "active");
583
+ }
584
+ function onClickElement(e) {
585
+ void run(e.currentTarget, null, null, e);
586
+ }
587
+ function onKeydownElement(e) {
588
+ if (e.key === "Enter") void run(e.currentTarget, null, null, e);
589
+ }
590
+ function setup() {
591
+ if (_context.ui || _mutation || !_context.MutationObserver) return;
592
+ _mutation = new MutationObserver(onMutation);
593
+ _mutation.observe(document.body, { childList: true, subtree: true });
594
+ onMutation();
595
+ }
596
+ function updateAllDataUis() {
597
+ const elements = queryAll("[data-ui]");
598
+ for (let i = 0, n = elements.length; i < n; i++) {
599
+ onWeak(elements[i], "click", onClickElement);
600
+ if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) onWeak(elements[i], "keydown", onKeydownElement);
601
+ }
602
+ }
603
+ function _ui(selector, options) {
604
+ if (selector) {
605
+ if (selector === "setup") {
606
+ setup();
607
+ return;
608
+ }
609
+ if (selector === "guid") return guid();
610
+ if (selector === "mode") return updateMode(options);
611
+ if (selector === "theme") return updateTheme(options);
612
+ const to = query(selector);
613
+ if (!to) return;
614
+ void run(to, to, options);
615
+ }
616
+ updateAllDataUis();
617
+ updateAllFields();
618
+ updateAllSliders();
619
+ updateAllRipples();
620
+ updateAllProgress();
621
+ }
622
+ function start() {
623
+ var _a;
624
+ if (_context.ui) return;
625
+ const body = (_a = _context.document) == null ? void 0 : _a.body;
626
+ if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
627
+ setup();
628
+ _context.ui = _ui;
629
+ }
630
+ start();
631
+ const ui = _context.ui;
632
+ export {
633
+ ui as default,
634
+ ui
635
+ };