@ironflock/widget-toolbar 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,1331 @@
1
+ import { css as bt, LitElement as gt, nothing as c, html as l } from "lit";
2
+ import { property as B, state as z, query as j, customElement as vt } from "lit/decorators.js";
3
+ import { repeat as X } from "lit/directives/repeat.js";
4
+ import { live as K } from "lit/directives/live.js";
5
+ import { styleMap as N } from "lit/directives/style-map.js";
6
+ import "@material/web/switch/switch.js";
7
+ import "@material/web/icon/icon.js";
8
+ const xt = ["button", "switch", "slider", "choice", "dropdown", "label", "separator", "spacer"], wt = ["filled", "tonal", "outlined", "text"], W = (t) => t === "button" || t === "switch" || t === "slider" || t === "choice" || t === "dropdown", st = "true", y = (t) => typeof t == "string" ? t : typeof t == "number" && Number.isFinite(t) ? String(t) : "", V = (t) => t == null || typeof t == "string" && t.trim() === "", q = (t) => {
9
+ if (t == null || t === "" || typeof t == "boolean") return;
10
+ const e = typeof t == "number" ? t : Number(String(t).trim());
11
+ return Number.isFinite(e) ? e : void 0;
12
+ };
13
+ function E(t) {
14
+ if (!t || typeof t != "object") return;
15
+ const e = t, r = e.swarm_app_databackend_key, i = typeof r == "number" && Number.isFinite(r) || typeof r == "string" && r.trim() !== "", s = (n) => typeof n == "string" && n.trim() !== "";
16
+ if (!(!i || !s(e.tablename) || !s(e.column)))
17
+ return {
18
+ swarm_app_databackend_key: r,
19
+ tablename: e.tablename,
20
+ column: e.column,
21
+ dataType: typeof e.dataType == "string" ? e.dataType : void 0
22
+ };
23
+ }
24
+ const yt = (t, e) => String(t.swarm_app_databackend_key) === String(e.swarm_app_databackend_key) && t.tablename === e.tablename;
25
+ function I(t, e) {
26
+ if (t == null) return null;
27
+ if (e === "boolean") {
28
+ if (typeof t == "boolean") return t;
29
+ if (typeof t == "number") return t !== 0;
30
+ const r = String(t).trim().toLowerCase();
31
+ return r === "true" || r === "1" ? !0 : r === "false" || r === "0" ? !1 : t;
32
+ }
33
+ if (e === "numeric" || e === "bigint") {
34
+ if (typeof t == "boolean") return t ? 1 : 0;
35
+ if (typeof t == "number") return t;
36
+ const r = String(t).trim(), i = Number(r);
37
+ return r === "" || !Number.isFinite(i) ? t : e === "bigint" && !Number.isSafeInteger(i) ? r : i;
38
+ }
39
+ return e === "string" && (typeof t == "boolean" || typeof t == "number") ? String(t) : t;
40
+ }
41
+ const Y = (t) => {
42
+ if (typeof t == "boolean") return t;
43
+ const e = String(t).trim().toLowerCase();
44
+ if (e === "true" || e === "1") return !0;
45
+ if (e === "false" || e === "0") return !1;
46
+ };
47
+ function L(t, e, r) {
48
+ if (V(t) || V(e)) return V(t) && V(e);
49
+ const i = I(t, r), s = I(e, r);
50
+ if (typeof i == "boolean" || typeof s == "boolean") {
51
+ const n = Y(i), a = Y(s);
52
+ if (n !== void 0 && a !== void 0) return n === a;
53
+ }
54
+ if (r !== "string") {
55
+ const n = q(i), a = q(s);
56
+ if (n !== void 0 && a !== void 0) return n === a;
57
+ }
58
+ return String(i).trim() === String(s).trim();
59
+ }
60
+ function at(t) {
61
+ if (typeof t != "string") return new URLSearchParams();
62
+ const e = t.indexOf("?");
63
+ return new URLSearchParams(e < 0 ? "" : t.slice(e + 1));
64
+ }
65
+ const J = (t) => {
66
+ const e = t?.tools;
67
+ return Array.isArray(e) ? e.map((r) => r && typeof r == "object" ? r : void 0) : [];
68
+ }, ot = (t) => {
69
+ const e = t.control;
70
+ return xt.includes(e) ? e : "button";
71
+ }, ct = (t, e) => `${t}:${e}`;
72
+ function lt(t, e) {
73
+ return J(t).flatMap((r, i) => {
74
+ if (!r) return [];
75
+ const s = ot(r);
76
+ if (!W(s)) return [];
77
+ const n = ct(i, s), a = y(r.parameterKey).trim();
78
+ return a ? [{ key: n, source: "url", reported: e.get(a) ?? void 0 }] : r.value !== void 0 && r.value !== null ? [{ key: n, source: "data", reported: r.value, dataType: E(r.targetColumn)?.dataType }] : [{ key: n, source: "local", reported: void 0 }];
79
+ });
80
+ }
81
+ function kt(t, e) {
82
+ return t.source === "local" ? !1 : e.timer === void 0 ? !0 : L(t.reported, e.expected, t.source === "data" ? t.dataType : void 0);
83
+ }
84
+ const $t = (t) => {
85
+ const [, e = ""] = String(t).split(".");
86
+ return Math.min(e.length, 6);
87
+ }, St = (t) => {
88
+ if (!Array.isArray(t)) return [];
89
+ const e = /* @__PURE__ */ new Set();
90
+ return t.flatMap((r) => {
91
+ if (!r || typeof r != "object") return [];
92
+ const i = r, s = y(i.value);
93
+ if (e.has(s)) return [];
94
+ e.add(s);
95
+ const n = y(i.label) || s, a = y(i.icon).trim() || void 0;
96
+ return !n && !a ? [] : [{ label: n, value: s, icon: a }];
97
+ });
98
+ };
99
+ function Ct(t, e) {
100
+ const r = t?.sharedColumns;
101
+ return Array.isArray(r) ? r.flatMap((i) => {
102
+ const s = E(i?.targetColumn);
103
+ return s && yt(s, e) ? [{ ref: s, value: i?.value }] : [];
104
+ }) : [];
105
+ }
106
+ function At(t) {
107
+ return Array.isArray(t.extraColumns) ? t.extraColumns.flatMap((e) => {
108
+ const r = E(e?.targetColumn);
109
+ return r ? [{ ref: r, value: e.value }] : [];
110
+ }) : [];
111
+ }
112
+ const tt = (t, e) => ({
113
+ swarm_app_databackend_key: t.swarm_app_databackend_key,
114
+ table_name: t.tablename,
115
+ column_name: t.column,
116
+ value: I(e, t.dataType)
117
+ });
118
+ function dt(t, e, r) {
119
+ const i = E(e.targetColumn);
120
+ if (!i) return;
121
+ const s = [...Ct(t, i), ...At(e)];
122
+ if (!s.some((n) => V(n.value)))
123
+ return [...s.map((n) => tt(n.ref, n.value)), tt(i, r)];
124
+ }
125
+ function Mt(t, e, r) {
126
+ const i = at(e), s = new Map(lt(t, i).map((n) => [n.key, n]));
127
+ return J(t).flatMap((n, a) => {
128
+ if (!n) return [];
129
+ const o = ot(n), h = ct(a, o), d = y(n.label).trim(), b = y(n.icon).trim() || void 0, _ = typeof n.color == "string" && n.color.trim() ? n.color.trim() : void 0, P = s.get(h), A = r.get(h), m = P?.source ?? "local", g = A ? A.expected : P?.reported, p = E(n.targetColumn), f = y(n.parameterKey).trim() || void 0, k = m === "data" ? p?.dataType : void 0, x = p ? dt(t, n, !0) !== void 0 : !1, u = W(o) && (p ? !x : !f), w = y(n.buttonValue), S = y(n.onValue).trim() || (m === "url" ? st : !0);
130
+ let C = q(n.min) ?? 0, M = q(n.max) ?? 100;
131
+ M > C || (M = C + 100);
132
+ let O = q(n.step) ?? 1;
133
+ O > 0 || (O = 1), O > M - C && (O = M - C);
134
+ const ut = $t(O), Z = q(g), ht = Z === void 0 ? C : Math.min(M, Math.max(C, Z)), Q = St(n.options), mt = o === "choice" || o === "dropdown" ? Q.findIndex((ft) => L(g, ft.value, k)) : -1;
135
+ return [
136
+ {
137
+ key: h,
138
+ index: a,
139
+ control: o,
140
+ label: d,
141
+ icon: b,
142
+ variant: wt.includes(n.variant) ? n.variant : "filled",
143
+ color: _,
144
+ source: m,
145
+ state: g,
146
+ disabled: u,
147
+ confirmText: y(n.confirmText).trim() || void 0,
148
+ parameterKey: f,
149
+ target: p,
150
+ buttonValue: w,
151
+ active: o === "button" && w.trim() !== "" && L(g, w, k),
152
+ on: o === "switch" && L(g, S, k),
153
+ min: C,
154
+ max: M,
155
+ step: O,
156
+ decimals: ut,
157
+ unit: y(n.unit),
158
+ sliderValue: ht,
159
+ options: Q,
160
+ selected: mt
161
+ }
162
+ ];
163
+ });
164
+ }
165
+ function _t(t, e, r) {
166
+ if (!W(e.control) || e.disabled) return;
167
+ const i = J(t)[e.index];
168
+ if (!i) return;
169
+ let s, n;
170
+ switch (e.control) {
171
+ case "button": {
172
+ const d = e.buttonValue.trim() === "" ? void 0 : e.buttonValue;
173
+ s = d, n = d ?? !0;
174
+ break;
175
+ }
176
+ case "switch": {
177
+ const d = y(i.onValue).trim(), b = y(i.offValue).trim();
178
+ r ? (s = d || st, n = d || !0) : (s = b || void 0, n = b || !1);
179
+ break;
180
+ }
181
+ case "slider": {
182
+ const d = q(r) ?? e.sliderValue, b = Number(Math.min(e.max, Math.max(e.min, d)).toFixed(e.decimals));
183
+ s = String(b), n = b;
184
+ break;
185
+ }
186
+ default: {
187
+ const d = y(r);
188
+ s = d.trim() === "" ? void 0 : d, n = d.trim() === "" ? null : d;
189
+ }
190
+ }
191
+ const a = e.target ? dt(t, i, n) : void 0;
192
+ if (e.target && !a) return;
193
+ const o = e.parameterKey ? { [e.parameterKey]: s } : void 0, h = e.parameterKey ? s : e.target ? I(n, e.target.dataType) : n;
194
+ return { params: o, items: a, expected: h };
195
+ }
196
+ function H(t, e, r) {
197
+ const i = e.filter((a) => r || t[a].kind !== "spacer"), s = [];
198
+ let n = "none";
199
+ return i.forEach((a, o) => {
200
+ const h = t[a].kind;
201
+ if (h === "separator") {
202
+ const d = i.slice(o + 1).some((b) => t[b].kind === "tool");
203
+ if (n !== "tool" || !d) return;
204
+ n = "separator";
205
+ } else h === "tool" && (n = "tool");
206
+ s.push(a);
207
+ }), s;
208
+ }
209
+ function Tt(t) {
210
+ const { items: e, available: r, gap: i, more: s, checkCross: n } = t, a = (p) => !n || p.cross <= r.cross, o = e.map(
211
+ (p) => p.kind !== "tool" || a(p.full) ? "full" : a(p.compact) ? "compact" : void 0
212
+ ), h = e.map(
213
+ (p) => p.kind !== "tool" || a(p.compact) ? "compact" : void 0
214
+ ), d = (p, f, k) => {
215
+ const x = H(e, f, !0), u = H(e, k, !1), w = u.some((S) => e[S].kind === "tool");
216
+ return {
217
+ visible: x,
218
+ compact: x.filter((S) => e[S].kind === "tool" && p[S] === "compact"),
219
+ overflow: w ? u : []
220
+ };
221
+ }, b = (p, f) => f.reduce((k, x, u) => k + e[x][p[x] ?? "compact"].main + (u > 0 ? i : 0), 0);
222
+ if (!o.some((p) => p === void 0)) {
223
+ const p = H(e, e.map((u, w) => w), !0), f = [...o], k = p.filter((u) => e[u].kind === "tool" && f[u] === "full").map((u) => ({ i: u, saving: e[u].full.main - e[u].compact.main })).filter(({ saving: u }) => u > 0).sort((u, w) => w.saving - u.saving || u.i - w.i);
224
+ let x = b(f, p);
225
+ for (const { i: u, saving: w } of k) {
226
+ if (x <= r.main) break;
227
+ f[u] = "compact", x -= w;
228
+ }
229
+ if (x <= r.main) return d(f, p, []);
230
+ }
231
+ const _ = r.main - s.main - i, P = (p) => {
232
+ const f = [], k = [];
233
+ let x = 0, u = !1;
234
+ return e.forEach((w, S) => {
235
+ const C = p[S];
236
+ if (C === void 0) {
237
+ k.push(S);
238
+ return;
239
+ }
240
+ const M = (f.length > 0 ? i : 0) + w[C].main;
241
+ !u && x + M <= _ ? (f.push(S), x += M) : (u = !0, k.push(S));
242
+ }), { visible: f, overflow: k };
243
+ }, A = P(o), m = P(h), g = (p) => p.filter((f) => e[f].kind === "tool").length;
244
+ return g(A.visible) >= g(m.visible) ? d(o, A.visible, A.overflow) : d(h, m.visible, m.overflow);
245
+ }
246
+ let T;
247
+ const pt = (t) => {
248
+ if (T ??= document.createElement("canvas").getContext("2d"), !T) return [0, 0, 0, 0];
249
+ for (const e of [t, `color-mix(in srgb, ${t} 100%, transparent)`]) {
250
+ T.fillStyle = "#000", T.fillStyle = e;
251
+ const r = String(T.fillStyle);
252
+ if (T.fillStyle = "#fff", T.fillStyle = e, String(T.fillStyle) !== r) continue;
253
+ let i = /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/.exec(r);
254
+ if (i) return [...i.slice(1).map((s) => parseInt(s, 16)), 1];
255
+ if (i = /^rgba\((\d+), (\d+), (\d+), ([\d.]+)\)$/.exec(r), i) return i.slice(1).map(Number);
256
+ if (i = /^color\(srgb (\S+) (\S+) (\S+)(?: \/ (\S+))?\)$/.exec(r), i) {
257
+ const [s, n, a] = i.slice(1, 4).map((o) => Math.min(Math.max(Number(o) || 0, 0), 1) * 255);
258
+ return [s, n, a, Number(i[4] ?? 1) || 0];
259
+ }
260
+ }
261
+ return [0, 0, 0, 0];
262
+ }, F = /* @__PURE__ */ new Map(), G = (t) => {
263
+ const e = JSON.stringify(t), r = F.get(e);
264
+ if (r !== void 0) return r;
265
+ let i = [255, 255, 255];
266
+ for (const n of t) {
267
+ const [a, o, h, d] = pt(n);
268
+ i = [a, o, h].map((b, _) => b * d + i[_] * (1 - d));
269
+ }
270
+ const s = "#" + i.map((n) => Math.round(n).toString(16).padStart(2, "0")).join("");
271
+ return F.size > 200 && F.clear(), F.set(e, s), s;
272
+ }, et = (t) => {
273
+ const [e, r, i] = [1, 3, 5].map((s) => {
274
+ const n = parseInt(t.slice(s, s + 2), 16) / 255;
275
+ return n <= 0.03928 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4;
276
+ });
277
+ return 0.2126 * e + 0.7152 * r + 0.0722 * i;
278
+ }, U = (t, e) => {
279
+ const [r, i] = [et(t), et(e)].sort((s, n) => n - s);
280
+ return (r + 0.05) / (i + 0.05);
281
+ }, Pt = 3, rt = (t) => typeof t == "string" && t.trim() !== "" && pt(t)[3] > 0, it = (t, e, r, i) => rt(t) ? t.trim() : rt(e) && U(G([r, e]), r) >= Pt ? e : i, qt = (t, e) => {
282
+ const r = G([e, t]);
283
+ return U(r, "#ffffff") >= U(r, "#000000") ? "#ffffff" : "#000000";
284
+ };
285
+ var Ot = Object.defineProperty, Vt = Object.getOwnPropertyDescriptor, $ = (t, e, r, i) => {
286
+ for (var s = i > 1 ? void 0 : i ? Vt(e, r) : e, n = t.length - 1, a; n >= 0; n--)
287
+ (a = t[n]) && (s = (i ? a(e, r, s) : a(s)) || s);
288
+ return i && s && Ot(e, r, s), s;
289
+ };
290
+ const zt = 1e4, Et = 2e3, Nt = ["horizontal", "vertical"], Ft = ["small", "normal", "big"], Dt = ["round", "rounded", "square"], Rt = { start: "flex-start", center: "center", end: "flex-end" }, D = (t, e, r) => e.includes(t) ? t : r, nt = /* @__PURE__ */ new Map(), R = (t, e) => {
291
+ let r = nt.get(e);
292
+ return r || (r = new Intl.NumberFormat(void 0, {
293
+ minimumFractionDigits: e,
294
+ maximumFractionDigits: e
295
+ }), nt.set(e, r)), r.format(t);
296
+ }, Lt = (t, e, r) => JSON.stringify([
297
+ e,
298
+ r,
299
+ t.map((i) => [
300
+ i.control,
301
+ i.label,
302
+ i.buttonValue,
303
+ i.icon,
304
+ i.variant,
305
+ i.unit,
306
+ i.min,
307
+ i.max,
308
+ i.decimals,
309
+ i.options.map((s) => [s.label, s.icon])
310
+ ])
311
+ ]);
312
+ let v = class extends gt {
313
+ constructor() {
314
+ super(...arguments), this.requestsVersion = 0, this.version = "1.0.0", this.tools = [], this.signature = "", this.requests = /* @__PURE__ */ new Map(), this.observer = new ResizeObserver(() => this.scheduleMeasure()), this.observed = [], this.measureFrame = 0, this.popupFrame = 0, this.popupRect = "", this.surface = "#ffffff", this.accentDefault = "#5470c6", this.onOutsidePointer = (t) => {
315
+ const e = t.composedPath();
316
+ this.popupEl && e.includes(this.popupEl) || this.popupAnchor && e.includes(this.popupAnchor) || this.closePopup();
317
+ }, this.onPopupKey = (t) => {
318
+ if (t.key !== "Escape") return;
319
+ const e = this.popupAnchor;
320
+ this.closePopup(), e?.focus({ preventScroll: !0 });
321
+ }, this.trackPopup = () => {
322
+ const t = this.popupAnchor, e = this.popupEl;
323
+ if (!t || !e || !this.popup) return;
324
+ const r = t.getBoundingClientRect();
325
+ if (!t.isConnected || r.width === 0 && r.height === 0) {
326
+ this.closePopup();
327
+ return;
328
+ }
329
+ const i = [r.left, r.top, r.width, r.height, innerWidth, innerHeight].join();
330
+ i !== this.popupRect && (this.popupRect = i, this.positionPopup(e, r)), this.popupFrame = requestAnimationFrame(this.trackPopup);
331
+ };
332
+ }
333
+ connectedCallback() {
334
+ if (super.connectedCallback(), !this.hasUpdated) return;
335
+ this.observeLayout(!0);
336
+ const t = this.dialog;
337
+ this.confirm && t?.open && (t.close(), this.showDialog());
338
+ }
339
+ disconnectedCallback() {
340
+ super.disconnectedCallback(), this.observer.disconnect(), this.observed = [], cancelAnimationFrame(this.measureFrame), this.measureFrame = 0, this.closePopup();
341
+ for (const [t, e] of this.requests)
342
+ e.timer !== void 0 && (clearTimeout(e.timer), this.requests.delete(t));
343
+ setTimeout(() => {
344
+ !this.isConnected && this.confirm && this.endConfirm(!1);
345
+ });
346
+ }
347
+ willUpdate(t) {
348
+ (t.has("inputData") || t.has("route") || t.has("requestsVersion")) && this.settleRequests(), this.tools = Mt(this.inputData, this.route, this.requests), this.signature = Lt(this.tools, this.orientation, this.size);
349
+ }
350
+ updated() {
351
+ this.shadowRoot?.querySelectorAll("md-switch").forEach((t) => {
352
+ const e = t.shadowRoot?.querySelector("input");
353
+ e && e.checked !== t.selected && (e.checked = t.selected);
354
+ }), this.observeLayout(!1), this.signature !== this.measuredSignature && this.scheduleMeasure();
355
+ }
356
+ get orientation() {
357
+ return D(this.inputData?.orientation, Nt, "horizontal");
358
+ }
359
+ get size() {
360
+ return D(this.inputData?.size, Ft, "normal");
361
+ }
362
+ get shape() {
363
+ return D(this.inputData?.shape, Dt, "round");
364
+ }
365
+ // ---------------------------------------------------------------- state --
366
+ /** Drop the held values whose source now agrees, or whose tool is gone. */
367
+ settleRequests() {
368
+ if (!this.requests.size) return;
369
+ const t = new Map(lt(this.inputData, at(this.route)).map((e) => [e.key, e]));
370
+ for (const [e, r] of this.requests) {
371
+ const i = t.get(e);
372
+ (!i || kt(i, r)) && (clearTimeout(r.timer), this.requests.delete(e));
373
+ }
374
+ }
375
+ /** An operator moved a tool to `next`. Writes it, after the confirmation if one is set. */
376
+ interact(t, e) {
377
+ const r = _t(this.inputData, t, e);
378
+ if (!r) {
379
+ this.requestUpdate();
380
+ return;
381
+ }
382
+ if (t.confirmText) {
383
+ this.closePopup();
384
+ const { accent: i, onAccent: s } = this.toolColors(t);
385
+ this.confirmAction = () => this.apply(t, r), this.confirm = { message: t.confirmText, accent: i, onAccent: s }, this.updateComplete.then(() => this.showDialog());
386
+ return;
387
+ }
388
+ this.apply(t, r);
389
+ }
390
+ apply(t, e) {
391
+ const { key: r } = t;
392
+ if (clearTimeout(this.requests.get(r)?.timer), this.requests.delete(r), !(t.control === "button" && t.source === "local")) {
393
+ const i = t.source === "url" ? Et : t.source === "data" ? zt : void 0, s = i === void 0 ? void 0 : setTimeout(() => {
394
+ this.requests.delete(r), this.requestsVersion++;
395
+ }, i);
396
+ this.requests.set(r, { expected: e.expected, timer: s });
397
+ }
398
+ this.requestsVersion++, e.items && this.dispatchEvent(new CustomEvent("data-submit", { detail: e.items, bubbles: !1, composed: !1 })), e.params && this.dispatchEvent(
399
+ new CustomEvent("param-submit", { detail: { params: e.params }, bubbles: !0, composed: !0 })
400
+ );
401
+ }
402
+ // ------------------------------------------------------------ confirm --
403
+ showDialog() {
404
+ const t = this.dialog;
405
+ if (!(!t || !this.isConnected || t.open || !this.confirm)) {
406
+ t.returnValue = "";
407
+ try {
408
+ t.showModal();
409
+ } catch {
410
+ this.endConfirm(!1);
411
+ }
412
+ }
413
+ }
414
+ onDialogClose() {
415
+ const t = this.dialog;
416
+ !t || t.open || !this.confirm || this.endConfirm(t.returnValue === "ok");
417
+ }
418
+ endConfirm(t) {
419
+ const e = this.confirmAction;
420
+ this.confirmAction = void 0, this.confirm = void 0, this.dialog?.open && this.dialog.close(), t ? e?.() : this.requestUpdate();
421
+ }
422
+ // ------------------------------------------------------------- layout --
423
+ /** Observe the host and every ruler slot; re-observe when the slots changed. */
424
+ observeLayout(t) {
425
+ const e = this.ruler ? [...this.ruler.children] : [];
426
+ !t && e.length === this.observed.length && e.every((r, i) => r === this.observed[i]) || (this.observer.disconnect(), this.observer.observe(this), e.forEach((r) => this.observer.observe(r)), this.observed = e, this.scheduleMeasure());
427
+ }
428
+ // A ResizeObserver callback that changes what it observes would loop:
429
+ // measure in the next frame instead.
430
+ scheduleMeasure() {
431
+ this.measureFrame || !this.isConnected || (this.measureFrame = requestAnimationFrame(() => {
432
+ this.measureFrame = 0, this.measure();
433
+ }));
434
+ }
435
+ measure() {
436
+ const t = this.bar, e = this.ruler;
437
+ if (!t || !e || !this.isConnected) return;
438
+ const r = t.getBoundingClientRect();
439
+ if (r.width === 0 || r.height === 0) return;
440
+ const i = [...e.children], s = this.tools;
441
+ if (i.length !== s.length * 2 + 1) return;
442
+ const n = this.orientation === "vertical", a = (m) => {
443
+ const g = m.getBoundingClientRect();
444
+ return n ? { main: g.height, cross: g.width } : { main: g.width, cross: g.height };
445
+ }, o = s.map((m, g) => ({
446
+ kind: m.control === "separator" ? "separator" : m.control === "spacer" ? "spacer" : "tool",
447
+ full: a(i[2 * g]),
448
+ compact: a(i[2 * g + 1])
449
+ }));
450
+ if (o.some((m) => m.kind === "tool" && m.full.main === 0)) return;
451
+ const h = getComputedStyle(t), d = (m) => parseFloat(m) || 0, b = r.width - d(h.paddingLeft) - d(h.paddingRight), _ = r.height - d(h.paddingTop) - d(h.paddingBottom), P = Tt({
452
+ items: o,
453
+ available: n ? { main: _, cross: b } : { main: b, cross: _ },
454
+ gap: d(n ? h.rowGap : h.columnGap),
455
+ more: a(i[i.length - 1]),
456
+ checkCross: n
457
+ });
458
+ this.measuredSignature = this.signature;
459
+ const A = { placement: P, signature: this.signature };
460
+ JSON.stringify(A) !== JSON.stringify(this.placement) && (this.placement = A);
461
+ }
462
+ // -------------------------------------------------------------- popup --
463
+ async togglePopup(t, e) {
464
+ const r = this.popup, i = r?.kind === t.kind && (t.kind === "menu" || r.kind === "dropdown" && r.key === t.key);
465
+ if (r && this.closePopup(), i) return;
466
+ this.popupAnchor = e, this.popup = t, await this.updateComplete;
467
+ const s = this.popupEl;
468
+ if (!s || !this.isConnected || this.popup !== t) return;
469
+ try {
470
+ s.matches(":popover-open") || s.showPopover();
471
+ } catch {
472
+ this.closePopup();
473
+ return;
474
+ }
475
+ this.popupRect = "", this.trackPopup(), window.addEventListener("pointerdown", this.onOutsidePointer, !0), window.addEventListener("keydown", this.onPopupKey, !0), (s.querySelector("button[data-current]") ?? s.querySelector("button:not(:disabled), input:not(:disabled), md-switch:not([disabled])"))?.focus({ preventScroll: !0 });
476
+ }
477
+ closePopup() {
478
+ cancelAnimationFrame(this.popupFrame), this.popupFrame = 0, window.removeEventListener("pointerdown", this.onOutsidePointer, !0), window.removeEventListener("keydown", this.onPopupKey, !0);
479
+ try {
480
+ this.popupEl?.matches(":popover-open") && this.popupEl.hidePopover();
481
+ } catch {
482
+ }
483
+ this.popup = void 0, this.popupAnchor = void 0;
484
+ }
485
+ positionPopup(t, e) {
486
+ t.style.minWidth = this.popup?.kind === "dropdown" ? `${e.width}px` : "", t.style.maxHeight = `${Math.max(0, innerHeight - 8)}px`;
487
+ const i = t.offsetWidth, s = t.offsetHeight;
488
+ let n = e.bottom + 4;
489
+ n + s > innerHeight - 4 && e.top - 4 - s >= 4 && (n = e.top - 4 - s), n = Math.min(Math.max(n, 4), Math.max(4, innerHeight - 4 - s));
490
+ let a = this.popup?.kind === "menu" ? e.right - i : e.left;
491
+ a = Math.min(Math.max(a, 4), Math.max(4, innerWidth - 4 - i)), t.style.top = `${n}px`, t.style.left = `${a}px`;
492
+ }
493
+ // -------------------------------------------------------------- colours --
494
+ /**
495
+ * The colours that have to be real colours, resolved at render and never
496
+ * cached across renders: the opaque surface of the menu and the dialog
497
+ * (the tile is usually translucent), and the accent with the text colour
498
+ * on it. Text itself uses var() chains, which follow a board style edit
499
+ * without a render.
500
+ */
501
+ resolveColors() {
502
+ const t = getComputedStyle(this), e = t.getPropertyValue("--re-tile-background-color").trim(), r = t.getPropertyValue("--re-background-color").trim(), i = String(this.theme?.theme_object?.backgroundColor ?? "");
503
+ this.surface = G(r ? [r, e || i] : [i, e]);
504
+ const s = t.getPropertyValue("--re-text-color").trim() || this.theme?.theme_object?.title?.textStyle?.color || t.color || "#333333";
505
+ this.accentDefault = it(
506
+ this.inputData?.accentColor,
507
+ this.theme?.theme_object?.color?.[0],
508
+ this.surface,
509
+ s
510
+ );
511
+ }
512
+ toolColors(t) {
513
+ const e = it(t.color, void 0, this.surface, this.accentDefault);
514
+ return { accent: e, onAccent: qt(e, this.surface) };
515
+ }
516
+ toolStyle(t) {
517
+ const { accent: e, onAccent: r } = this.toolColors(t);
518
+ return N({ "--accent": e, "--on-accent": r });
519
+ }
520
+ render() {
521
+ this.resolveColors();
522
+ const t = this.tools, e = this.orientation, r = e === "vertical", i = D(this.inputData?.alignment, ["start", "center", "end"], "start"), s = this.placement && this.placement.signature === this.signature ? this.placement.placement : { visible: t.map((o, h) => h), compact: [], overflow: [] }, n = this.theme?.theme_object?.title?.textStyle?.color, a = `var(--re-text-color, ${typeof n == "string" && n ? n : "inherit"})`;
523
+ return l`
524
+ <div
525
+ class="root"
526
+ data-orientation=${e}
527
+ data-size=${this.size}
528
+ data-shape=${this.shape}
529
+ style=${N({ "--text": a, "--surface": this.surface })}
530
+ >
531
+ <div
532
+ class="bar"
533
+ role="toolbar"
534
+ aria-orientation=${e}
535
+ style=${N({ justifyContent: Rt[i] })}
536
+ >
537
+ ${X(
538
+ s.visible.filter((o) => t[o]),
539
+ (o) => t[o].key,
540
+ (o) => this.renderTool(t[o], s.compact.includes(o) ? "compact" : "full")
541
+ )}
542
+ ${s.overflow.length ? this.renderMore(r, this.popup?.kind === "menu") : c}
543
+ </div>
544
+ <div class="ruler" inert aria-hidden="true">
545
+ ${X(
546
+ t,
547
+ (o) => o.key,
548
+ (o) => l`
549
+ <div class="slot">${this.renderTool(o, "full", !0)}</div>
550
+ <div class="slot">${this.renderTool(o, "compact", !0)}</div>
551
+ `
552
+ )}
553
+ <div class="slot">${this.renderMore(r, !1)}</div>
554
+ </div>
555
+ <div class="popup" popover="manual" role=${this.popup?.kind === "dropdown" ? "listbox" : c}>
556
+ ${this.renderPopup(s)}
557
+ </div>
558
+ <dialog
559
+ class="confirm"
560
+ @close=${this.onDialogClose}
561
+ @cancel=${(o) => {
562
+ o.preventDefault(), this.endConfirm(!1);
563
+ }}
564
+ >
565
+ ${this.confirm ? l`
566
+ <p>${this.confirm.message}</p>
567
+ <form method="dialog" class="actions">
568
+ <button class="button" value="cancel">Cancel</button>
569
+ <button
570
+ class="button"
571
+ data-variant="filled"
572
+ value="ok"
573
+ autofocus
574
+ style=${N({
575
+ "--accent": this.confirm.accent,
576
+ "--on-accent": this.confirm.onAccent
577
+ })}
578
+ >
579
+ OK
580
+ </button>
581
+ </form>
582
+ ` : c}
583
+ </dialog>
584
+ </div>
585
+ `;
586
+ }
587
+ renderMore(t, e) {
588
+ return l`
589
+ <button
590
+ class="button icon-only more"
591
+ aria-label="More tools"
592
+ aria-haspopup="true"
593
+ aria-expanded=${e ? "true" : "false"}
594
+ @click=${(r) => this.togglePopup({ kind: "menu" }, r.currentTarget)}
595
+ >
596
+ <md-icon aria-hidden="true">${t ? "more_horiz" : "more_vert"}</md-icon>
597
+ </button>
598
+ `;
599
+ }
600
+ icon(t) {
601
+ return t ? l`<md-icon aria-hidden="true">${t}</md-icon>` : c;
602
+ }
603
+ /** One tool in the bar, or with `ruler` its measured copy. */
604
+ renderTool(t, e, r = !1) {
605
+ const i = e === "compact", s = !!t.label && !(i && t.icon);
606
+ switch (t.control) {
607
+ case "separator":
608
+ return l`<span class="separator" role="separator"></span>`;
609
+ case "spacer":
610
+ return l`<span class="spacer"></span>`;
611
+ case "label":
612
+ return l`<span class="tool label">${this.icon(t.icon)}<span class="text">${t.label}</span></span>`;
613
+ case "button": {
614
+ const n = t.label || t.buttonValue, a = !!t.icon && (!n || i);
615
+ return l`
616
+ <button
617
+ class="button ${a ? "icon-only" : ""}"
618
+ data-variant=${t.variant}
619
+ ?data-active=${t.active}
620
+ aria-pressed=${t.buttonValue.trim() ? t.active ? "true" : "false" : c}
621
+ aria-label=${n || c}
622
+ title=${a && n ? n : c}
623
+ ?disabled=${t.disabled}
624
+ style=${this.toolStyle(t)}
625
+ @click=${r ? c : () => this.interact(t)}
626
+ >
627
+ ${this.icon(t.icon)}${a ? c : l`<span class="text">${n}</span>`}
628
+ </button>
629
+ `;
630
+ }
631
+ case "switch":
632
+ return l`
633
+ <label class="tool switch" ?data-disabled=${t.disabled} style=${this.toolStyle(t)}>
634
+ ${this.icon(t.icon)}${s ? l`<span class="text">${t.label}</span>` : c}
635
+ <md-switch
636
+ aria-label=${t.label || c}
637
+ .selected=${K(t.on)}
638
+ ?disabled=${t.disabled}
639
+ @change=${r ? c : (n) => this.interact(t, n.target.selected)}
640
+ ></md-switch>
641
+ </label>
642
+ `;
643
+ case "slider":
644
+ return l`
645
+ <div
646
+ class="tool slider ${i ? "compact" : ""}"
647
+ ?data-disabled=${t.disabled}
648
+ style=${this.toolStyle(t)}
649
+ >
650
+ ${this.icon(t.icon)}${s ? l`<span class="text">${t.label}</span>` : c}
651
+ ${this.renderRange(t, r)}
652
+ </div>
653
+ `;
654
+ case "choice":
655
+ return l`
656
+ <div
657
+ class="tool choice"
658
+ role="radiogroup"
659
+ aria-label=${t.label || c}
660
+ style=${this.toolStyle(t)}
661
+ >
662
+ ${t.label && !i ? l`<span class="text">${t.label}</span>` : c}
663
+ <div class="segments">
664
+ ${t.options.map((n, a) => {
665
+ const o = i && !!n.icon;
666
+ return l`
667
+ <button
668
+ class="segment ${o ? "icon-only" : ""}"
669
+ role="radio"
670
+ aria-checked=${a === t.selected ? "true" : "false"}
671
+ aria-label=${n.label || c}
672
+ title=${o && n.label ? n.label : c}
673
+ ?disabled=${t.disabled}
674
+ @click=${r ? c : () => this.pick(t, a)}
675
+ >
676
+ ${this.icon(n.icon)}${o ? c : n.label}
677
+ </button>
678
+ `;
679
+ })}
680
+ </div>
681
+ </div>
682
+ `;
683
+ case "dropdown": {
684
+ const n = !r && this.popup?.kind === "dropdown" && this.popup.key === t.key;
685
+ return l`
686
+ <div class="tool dropdown" style=${this.toolStyle(t)}>
687
+ ${t.label && !i ? l`<span class="text">${t.label}</span>` : c}
688
+ <button
689
+ class="button trigger"
690
+ data-variant="outlined"
691
+ aria-haspopup="listbox"
692
+ aria-expanded=${n ? "true" : "false"}
693
+ aria-label=${t.label || c}
694
+ ?disabled=${t.disabled}
695
+ @click=${r ? c : (a) => this.togglePopup({ kind: "dropdown", key: t.key }, a.currentTarget)}
696
+ >
697
+ ${this.icon(t.icon)}
698
+ <span class="stack">
699
+ ${t.options.map(
700
+ (a, o) => l`<span ?data-current=${o === t.selected}>${a.label}</span>`
701
+ )}
702
+ <span ?data-current=${t.selected < 0}>–</span>
703
+ </span>
704
+ <md-icon aria-hidden="true">arrow_drop_down</md-icon>
705
+ </button>
706
+ </div>
707
+ `;
708
+ }
709
+ }
710
+ }
711
+ /** A slider's range input and its value, in a width that never depends on the value. */
712
+ renderRange(t, e) {
713
+ const i = (!e && this.dragging?.key === t.key ? this.dragging.value : void 0) ?? t.sliderValue;
714
+ return l`
715
+ <input
716
+ type="range"
717
+ min=${t.min}
718
+ max=${t.max}
719
+ step=${t.step}
720
+ .value=${K(String(i))}
721
+ aria-label=${t.label || c}
722
+ aria-valuetext=${`${R(i, t.decimals)}${t.unit ? " " + t.unit : ""}`}
723
+ ?disabled=${t.disabled}
724
+ @input=${e ? c : (s) => {
725
+ this.dragging = { key: t.key, value: Number(s.target.value) };
726
+ }}
727
+ @change=${e ? c : (s) => {
728
+ this.dragging = void 0, this.interact(t, Number(s.target.value));
729
+ }}
730
+ />
731
+ <span class="readout"
732
+ ><span class="stack"
733
+ ><span>${R(t.min, t.decimals)}</span
734
+ ><span>${R(t.max, t.decimals)}</span
735
+ ><span data-current>${R(i, t.decimals)}</span></span
736
+ >${t.unit ? ` ${t.unit}` : c}</span
737
+ >
738
+ `;
739
+ }
740
+ pick(t, e) {
741
+ if (e === t.selected) return;
742
+ const r = t.options[e];
743
+ r && this.interact(t, r.value);
744
+ }
745
+ /** The open popup's content: the ⋮ menu's tools, or a dropdown's options. */
746
+ renderPopup(t) {
747
+ const e = this.popup;
748
+ if (!e) return c;
749
+ if (e.kind === "dropdown") {
750
+ const r = this.tools.find((i) => i.key === e.key);
751
+ return r ? l`<div style=${this.toolStyle(r)}>${this.renderChoices(r, "option")}</div>` : c;
752
+ }
753
+ return t.overflow.map((r) => this.tools[r] ? this.renderMenuTool(this.tools[r]) : c);
754
+ }
755
+ renderChoices(t, e) {
756
+ return t.options.map(
757
+ (r, i) => l`
758
+ <button
759
+ class="menu-item"
760
+ role=${e}
761
+ aria-checked=${e === "radio" ? i === t.selected ? "true" : "false" : c}
762
+ aria-selected=${e === "option" ? i === t.selected ? "true" : "false" : c}
763
+ ?data-current=${i === t.selected}
764
+ ?disabled=${t.disabled}
765
+ @click=${() => {
766
+ this.closePopup(), this.pick(t, i);
767
+ }}
768
+ >
769
+ ${this.icon(r.icon)}<span class="text">${r.label}</span>
770
+ <md-icon
771
+ class="check"
772
+ aria-hidden="true"
773
+ style=${i === t.selected ? "visibility: visible" : c}
774
+ >check</md-icon
775
+ >
776
+ </button>
777
+ `
778
+ );
779
+ }
780
+ /** A tool as a row of the ⋮ menu. */
781
+ renderMenuTool(t) {
782
+ const e = this.toolStyle(t);
783
+ switch (t.control) {
784
+ case "separator":
785
+ return l`<hr />`;
786
+ case "spacer":
787
+ return c;
788
+ case "label":
789
+ return l`<div class="menu-heading">${this.icon(t.icon)}${t.label}</div>`;
790
+ case "button": {
791
+ const r = t.label || t.buttonValue;
792
+ return l`
793
+ <button
794
+ class="menu-item"
795
+ ?data-active=${t.active}
796
+ aria-pressed=${t.buttonValue.trim() ? t.active ? "true" : "false" : c}
797
+ ?disabled=${t.disabled}
798
+ style=${e}
799
+ @click=${() => {
800
+ this.closePopup(), this.interact(t);
801
+ }}
802
+ >
803
+ ${this.icon(t.icon)}<span class="text">${r}</span>
804
+ </button>
805
+ `;
806
+ }
807
+ case "switch":
808
+ return l`
809
+ <label class="menu-item" ?data-disabled=${t.disabled} style=${e}>
810
+ ${this.icon(t.icon)}<span class="text">${t.label}</span>
811
+ <md-switch
812
+ aria-label=${t.label || c}
813
+ .selected=${K(t.on)}
814
+ ?disabled=${t.disabled}
815
+ @change=${(r) => this.interact(t, r.target.selected)}
816
+ ></md-switch>
817
+ </label>
818
+ `;
819
+ case "slider":
820
+ return l`
821
+ <div class="menu-item column" ?data-disabled=${t.disabled} style=${e}>
822
+ <div class="row">${this.icon(t.icon)}<span class="text">${t.label}</span></div>
823
+ <div class="row">${this.renderRange(t, !1)}</div>
824
+ </div>
825
+ `;
826
+ case "choice":
827
+ case "dropdown":
828
+ return l`
829
+ <div role="radiogroup" aria-label=${t.label || c} style=${e}>
830
+ ${t.label ? l`<div class="menu-heading">${this.icon(t.icon)}${t.label}</div>` : c}
831
+ ${this.renderChoices(t, "radio")}
832
+ </div>
833
+ `;
834
+ }
835
+ }
836
+ };
837
+ v.styles = bt`
838
+ :host {
839
+ display: block;
840
+ box-sizing: border-box;
841
+ /* clip, not hidden: the ruler is taller than the tile, and a
842
+ hidden overflow can still be scrolled (focus, scrollIntoView),
843
+ which shifted the bar out of the tile. */
844
+ overflow: clip;
845
+ position: relative;
846
+ font-family: Roboto, 'Helvetica Neue', Arial, sans-serif;
847
+ }
848
+
849
+ .root {
850
+ height: 100%;
851
+ width: 100%;
852
+ color: var(--text);
853
+ --h: 36px;
854
+ --font: 14px;
855
+ --icon: 20px;
856
+ --gap: 12px;
857
+ --pad: 6px;
858
+ --slider: 140px;
859
+ --slider-compact: 88px;
860
+ --switch-scale: 0.8;
861
+ /* Corner radius as a share of the control's height, so a shape
862
+ holds at every size: 0.5 makes pill-shaped ends. */
863
+ --round: 0.5;
864
+ }
865
+ .root[data-shape='rounded'] {
866
+ --round: 0.2;
867
+ }
868
+ .root[data-shape='square'] {
869
+ --round: 0;
870
+ }
871
+ .root[data-size='small'] {
872
+ --h: 28px;
873
+ --font: 12px;
874
+ --icon: 18px;
875
+ --gap: 8px;
876
+ --pad: 4px;
877
+ --slider: 110px;
878
+ --slider-compact: 72px;
879
+ --switch-scale: 0.65;
880
+ }
881
+ .root[data-size='big'] {
882
+ --h: 48px;
883
+ --font: 18px;
884
+ --icon: 26px;
885
+ --gap: 16px;
886
+ --pad: 8px;
887
+ --slider: 180px;
888
+ --slider-compact: 110px;
889
+ --switch-scale: 1.1;
890
+ }
891
+
892
+ .bar {
893
+ box-sizing: border-box;
894
+ height: 100%;
895
+ width: 100%;
896
+ display: flex;
897
+ align-items: center;
898
+ gap: var(--gap);
899
+ padding: var(--pad) calc(var(--pad) * 2);
900
+ overflow: clip;
901
+ }
902
+ .root[data-orientation='vertical'] .bar {
903
+ flex-direction: column;
904
+ align-items: stretch;
905
+ padding: calc(var(--pad) * 2) var(--pad);
906
+ }
907
+ .bar > * {
908
+ flex: none;
909
+ }
910
+ .bar > .spacer {
911
+ flex: 1 1 0;
912
+ }
913
+
914
+ /* A copy of every tool at both densities, measured, never seen. */
915
+ .ruler {
916
+ position: absolute;
917
+ top: 0;
918
+ left: 0;
919
+ width: max-content;
920
+ display: flex;
921
+ flex-direction: column;
922
+ align-items: flex-start;
923
+ visibility: hidden;
924
+ pointer-events: none;
925
+ z-index: -1;
926
+ }
927
+ .slot {
928
+ display: flex;
929
+ width: max-content;
930
+ }
931
+
932
+ md-icon {
933
+ --md-icon-size: var(--icon);
934
+ flex: none;
935
+ }
936
+
937
+ .text {
938
+ overflow: hidden;
939
+ text-overflow: ellipsis;
940
+ white-space: nowrap;
941
+ min-width: 0;
942
+ }
943
+
944
+ button {
945
+ font: inherit;
946
+ color: inherit;
947
+ }
948
+ button:focus-visible,
949
+ input:focus-visible {
950
+ outline: 2px solid var(--accent, currentColor);
951
+ outline-offset: 2px;
952
+ }
953
+
954
+ /* Buttons, and the dropdown trigger and ⋮, which look like them. */
955
+ .button {
956
+ box-sizing: border-box;
957
+ display: inline-flex;
958
+ align-items: center;
959
+ justify-content: center;
960
+ gap: 0.4em;
961
+ height: var(--h);
962
+ min-width: var(--h);
963
+ padding: 0 calc(var(--h) * 0.42);
964
+ border: 1px solid transparent;
965
+ border-radius: calc(var(--h) * var(--round));
966
+ font-size: var(--font);
967
+ font-weight: 500;
968
+ line-height: 1;
969
+ white-space: nowrap;
970
+ cursor: pointer;
971
+ background: transparent;
972
+ }
973
+ .button.icon-only {
974
+ padding: 0;
975
+ width: var(--h);
976
+ }
977
+ .button[data-variant='filled'] {
978
+ background-color: var(--accent);
979
+ color: var(--on-accent);
980
+ }
981
+ .button[data-variant='tonal'] {
982
+ background-color: color-mix(in srgb, var(--accent) 22%, transparent);
983
+ }
984
+ .button[data-variant='outlined'] {
985
+ border-color: color-mix(in srgb, currentColor 45%, transparent);
986
+ }
987
+ .button[data-variant='text'] {
988
+ color: var(--accent);
989
+ }
990
+ .button:hover:not(:disabled),
991
+ .segment:hover:not(:disabled),
992
+ .menu-item:hover:not(:disabled) {
993
+ background-image: linear-gradient(
994
+ color-mix(in srgb, currentColor 10%, transparent),
995
+ color-mix(in srgb, currentColor 10%, transparent)
996
+ );
997
+ }
998
+ /* A button whose value is the current one, as in a mode selector. */
999
+ .button[data-active] {
1000
+ box-shadow: inset 0 0 0 2px var(--accent);
1001
+ }
1002
+ .button[data-active]:not([data-variant='filled']) {
1003
+ background-color: color-mix(in srgb, var(--accent) 28%, transparent);
1004
+ }
1005
+ .button[data-active][data-variant='filled'] {
1006
+ box-shadow:
1007
+ inset 0 0 0 2px var(--accent),
1008
+ inset 0 0 0 4px var(--on-accent);
1009
+ }
1010
+
1011
+ button:disabled,
1012
+ input:disabled,
1013
+ [data-disabled] {
1014
+ cursor: default;
1015
+ opacity: 0.4;
1016
+ }
1017
+
1018
+ .tool {
1019
+ display: inline-flex;
1020
+ align-items: center;
1021
+ gap: 0.5em;
1022
+ font-size: var(--font);
1023
+ white-space: nowrap;
1024
+ min-width: 0;
1025
+ }
1026
+ /* In a strip the label takes the row, so a switch sits at its end.
1027
+ A dropdown, choice group or slider takes the rest of the row
1028
+ instead. Every basis is the content's own width, never 0: with
1029
+ flex: 1 the label and the control split the row in half, and the
1030
+ control was cut off below the width the ruler measured. Only the
1031
+ label gives way (with an ellipsis) when the row is short. */
1032
+ .root[data-orientation='vertical'] .bar > .tool > .text {
1033
+ flex: 1 1 auto;
1034
+ }
1035
+ .root[data-orientation='vertical'] .bar > .tool:is(.dropdown, .choice, .slider) > .text {
1036
+ flex: 0 1 auto;
1037
+ }
1038
+
1039
+ md-switch {
1040
+ --md-switch-track-width: calc(52px * var(--switch-scale));
1041
+ --md-switch-track-height: calc(32px * var(--switch-scale));
1042
+ --md-switch-handle-width: calc(16px * var(--switch-scale));
1043
+ --md-switch-handle-height: calc(16px * var(--switch-scale));
1044
+ --md-switch-selected-handle-width: calc(24px * var(--switch-scale));
1045
+ --md-switch-selected-handle-height: calc(24px * var(--switch-scale));
1046
+ --md-switch-pressed-handle-width: calc(28px * var(--switch-scale));
1047
+ --md-switch-pressed-handle-height: calc(28px * var(--switch-scale));
1048
+ --md-switch-state-layer-size: calc(40px * var(--switch-scale));
1049
+ /* The button shape: the track by its height, the handle by its own size. */
1050
+ --md-switch-track-shape: calc(32px * var(--switch-scale) * var(--round));
1051
+ --md-switch-handle-shape: calc(var(--round) * 100%);
1052
+ --md-switch-selected-handle-color: var(--accent);
1053
+ --md-switch-selected-hover-handle-color: var(--accent);
1054
+ --md-switch-selected-focus-handle-color: var(--accent);
1055
+ --md-switch-selected-pressed-handle-color: var(--accent);
1056
+ --md-switch-selected-track-color: color-mix(in srgb, var(--accent) 40%, transparent);
1057
+ --md-switch-selected-hover-track-color: color-mix(in srgb, var(--accent) 50%, transparent);
1058
+ --md-switch-selected-focus-track-color: color-mix(in srgb, var(--accent) 50%, transparent);
1059
+ --md-switch-selected-pressed-track-color: color-mix(in srgb, var(--accent) 50%, transparent);
1060
+ /* OFF: Material 2.4.1 names these without "unselected". */
1061
+ --switch-off-track: color-mix(in srgb, var(--text) 20%, transparent);
1062
+ --md-switch-handle-color: var(--text);
1063
+ --md-switch-hover-handle-color: var(--text);
1064
+ --md-switch-focus-handle-color: var(--text);
1065
+ --md-switch-pressed-handle-color: var(--text);
1066
+ --md-switch-track-color: var(--switch-off-track);
1067
+ --md-switch-hover-track-color: var(--switch-off-track);
1068
+ --md-switch-focus-track-color: var(--switch-off-track);
1069
+ --md-switch-pressed-track-color: var(--switch-off-track);
1070
+ --md-switch-track-outline-color: var(--text);
1071
+ --md-switch-hover-track-outline-color: var(--text);
1072
+ --md-switch-focus-track-outline-color: var(--text);
1073
+ --md-switch-pressed-track-outline-color: var(--text);
1074
+ /* Material's disabled colours are its light scheme's near-black,
1075
+ which vanishes on a dark tile. */
1076
+ --md-switch-disabled-handle-color: var(--text);
1077
+ --md-switch-disabled-track-outline-color: var(--text);
1078
+ --md-switch-disabled-selected-track-color: var(--text);
1079
+ --md-switch-disabled-selected-handle-color: var(--text);
1080
+ flex: none;
1081
+ }
1082
+
1083
+ input[type='range'] {
1084
+ accent-color: var(--accent);
1085
+ width: var(--slider);
1086
+ margin: 0;
1087
+ min-width: 0;
1088
+ cursor: pointer;
1089
+ }
1090
+ .compact input[type='range'] {
1091
+ width: var(--slider-compact);
1092
+ }
1093
+ .root[data-orientation='vertical'] .bar input[type='range'] {
1094
+ flex: 1 0 auto;
1095
+ }
1096
+ .readout {
1097
+ font-variant-numeric: tabular-nums;
1098
+ white-space: nowrap;
1099
+ }
1100
+
1101
+ /* Several texts in one grid cell, only one visible: the cell is as
1102
+ wide as the widest, so a changing value never changes the width. */
1103
+ .stack {
1104
+ display: inline-grid;
1105
+ text-align: end;
1106
+ }
1107
+ .stack > * {
1108
+ grid-area: 1 / 1;
1109
+ }
1110
+ .stack > :not([data-current]) {
1111
+ visibility: hidden;
1112
+ }
1113
+ /* In a strip the trigger is wider than its text: the text takes the
1114
+ room, so it starts after the icon and the arrow stays at the end. */
1115
+ .trigger .stack {
1116
+ flex: 1 1 auto;
1117
+ text-align: start;
1118
+ }
1119
+
1120
+ .segments {
1121
+ display: inline-flex;
1122
+ height: var(--h);
1123
+ box-sizing: border-box;
1124
+ border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
1125
+ border-radius: calc(var(--h) * var(--round));
1126
+ overflow: hidden;
1127
+ }
1128
+ .root[data-orientation='vertical'] .bar .segments {
1129
+ flex: 1 0 auto;
1130
+ }
1131
+ .segment {
1132
+ display: inline-flex;
1133
+ align-items: center;
1134
+ justify-content: center;
1135
+ gap: 0.35em;
1136
+ flex: 1 0 auto;
1137
+ padding: 0 0.85em;
1138
+ border: none;
1139
+ background: transparent;
1140
+ font-size: var(--font);
1141
+ cursor: pointer;
1142
+ white-space: nowrap;
1143
+ }
1144
+ .segment.icon-only {
1145
+ padding: 0 0.5em;
1146
+ }
1147
+ .segment + .segment {
1148
+ border-left: 1px solid color-mix(in srgb, currentColor 40%, transparent);
1149
+ }
1150
+ .segment[aria-checked='true'] {
1151
+ background-color: var(--accent);
1152
+ color: var(--on-accent);
1153
+ }
1154
+
1155
+ .trigger {
1156
+ justify-content: space-between;
1157
+ padding: 0 0.3em 0 0.8em;
1158
+ }
1159
+ .root[data-orientation='vertical'] .bar .trigger {
1160
+ flex: 1 0 auto;
1161
+ }
1162
+
1163
+ .label {
1164
+ opacity: 0.85;
1165
+ }
1166
+
1167
+ .separator {
1168
+ align-self: center;
1169
+ width: 1px;
1170
+ height: calc(var(--h) * 0.7);
1171
+ background: color-mix(in srgb, currentColor 30%, transparent);
1172
+ }
1173
+ .root[data-orientation='vertical'] .separator {
1174
+ width: auto;
1175
+ height: 1px;
1176
+ align-self: stretch;
1177
+ }
1178
+ .spacer {
1179
+ min-width: 0;
1180
+ min-height: 0;
1181
+ }
1182
+
1183
+ /* The menu and dropdown lists live in the top layer: the tile clips. */
1184
+ .popup {
1185
+ position: fixed;
1186
+ inset: auto;
1187
+ margin: 0;
1188
+ box-sizing: border-box;
1189
+ min-width: 180px;
1190
+ max-width: min(340px, calc(100vw - 8px));
1191
+ padding: 6px 0;
1192
+ overflow: auto;
1193
+ border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
1194
+ border-radius: 10px;
1195
+ background: var(--surface);
1196
+ color: var(--text);
1197
+ box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
1198
+ font-size: 14px;
1199
+ --h: 36px;
1200
+ --font: 14px;
1201
+ --icon: 20px;
1202
+ --switch-scale: 0.8;
1203
+ }
1204
+ .menu-item {
1205
+ box-sizing: border-box;
1206
+ display: flex;
1207
+ align-items: center;
1208
+ gap: 12px;
1209
+ width: 100%;
1210
+ min-height: 40px;
1211
+ padding: 4px 16px;
1212
+ border: none;
1213
+ background: transparent;
1214
+ text-align: start;
1215
+ font-size: 14px;
1216
+ cursor: pointer;
1217
+ }
1218
+ .menu-item .text {
1219
+ flex: 1;
1220
+ }
1221
+ .menu-item.column {
1222
+ flex-direction: column;
1223
+ align-items: stretch;
1224
+ gap: 4px;
1225
+ cursor: default;
1226
+ }
1227
+ .menu-item.column > .row {
1228
+ display: flex;
1229
+ align-items: center;
1230
+ gap: 12px;
1231
+ }
1232
+ .menu-item input[type='range'] {
1233
+ flex: 1;
1234
+ width: auto;
1235
+ }
1236
+ .menu-item[aria-checked='true'],
1237
+ .menu-item[data-active] {
1238
+ background-color: color-mix(in srgb, var(--accent) 18%, transparent);
1239
+ }
1240
+ .menu-heading {
1241
+ display: flex;
1242
+ align-items: center;
1243
+ gap: 12px;
1244
+ padding: 8px 16px 2px;
1245
+ font-size: 12px;
1246
+ opacity: 0.75;
1247
+ }
1248
+ .check {
1249
+ visibility: hidden;
1250
+ color: var(--accent);
1251
+ }
1252
+ [aria-checked='true'] > .check {
1253
+ visibility: visible;
1254
+ }
1255
+ .popup hr {
1256
+ margin: 6px 0;
1257
+ border: none;
1258
+ border-top: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
1259
+ }
1260
+
1261
+ dialog.confirm {
1262
+ box-sizing: border-box;
1263
+ max-width: min(380px, calc(100vw - 32px));
1264
+ padding: 20px 24px 16px;
1265
+ border: none;
1266
+ border-radius: 14px;
1267
+ background: var(--surface);
1268
+ color: var(--text);
1269
+ box-shadow: 0 8px 28px rgb(0 0 0 / 0.3);
1270
+ font-size: 15px;
1271
+ line-height: 1.4;
1272
+ }
1273
+ dialog.confirm::backdrop {
1274
+ background: rgb(0 0 0 / 0.32);
1275
+ }
1276
+ dialog.confirm p {
1277
+ margin: 0;
1278
+ overflow-wrap: anywhere;
1279
+ }
1280
+ dialog.confirm .actions {
1281
+ display: flex;
1282
+ justify-content: flex-end;
1283
+ gap: 8px;
1284
+ margin-top: 20px;
1285
+ --h: 36px;
1286
+ --font: 14px;
1287
+ }
1288
+ `;
1289
+ $([
1290
+ B({ type: Object })
1291
+ ], v.prototype, "inputData", 2);
1292
+ $([
1293
+ B({ type: Object })
1294
+ ], v.prototype, "theme", 2);
1295
+ $([
1296
+ B({ type: String })
1297
+ ], v.prototype, "route", 2);
1298
+ $([
1299
+ z()
1300
+ ], v.prototype, "placement", 2);
1301
+ $([
1302
+ z()
1303
+ ], v.prototype, "popup", 2);
1304
+ $([
1305
+ z()
1306
+ ], v.prototype, "confirm", 2);
1307
+ $([
1308
+ z()
1309
+ ], v.prototype, "dragging", 2);
1310
+ $([
1311
+ z()
1312
+ ], v.prototype, "requestsVersion", 2);
1313
+ $([
1314
+ j(".bar")
1315
+ ], v.prototype, "bar", 2);
1316
+ $([
1317
+ j(".ruler")
1318
+ ], v.prototype, "ruler", 2);
1319
+ $([
1320
+ j(".popup")
1321
+ ], v.prototype, "popupEl", 2);
1322
+ $([
1323
+ j("dialog.confirm")
1324
+ ], v.prototype, "dialog", 2);
1325
+ v = $([
1326
+ vt("widget-toolbar-1.0.0")
1327
+ ], v);
1328
+ export {
1329
+ v as WidgetToolbar
1330
+ };
1331
+ //# sourceMappingURL=widget-toolbar.js.map