@glasshome/widget-sdk 0.5.0 → 0.5.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.
- package/dist/framework/dialogs/WidgetDialog.d.ts +3 -0
- package/dist/framework/gestures/use-widget-gestures.d.ts +5 -22
- package/dist/framework/hooks/index.d.ts +2 -0
- package/dist/framework/hooks/use-intersection-pause.d.ts +7 -0
- package/dist/framework/hooks/use-reduced-motion.d.ts +7 -0
- package/dist/framework/hooks/use-widget-context.d.ts +3 -0
- package/dist/framework/hooks/use-widget-dialog.d.ts +17 -9
- package/dist/framework/index.d.ts +2 -2
- package/dist/framework/theming/index.d.ts +1 -0
- package/dist/framework/theming/svg-colors.d.ts +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +560 -468
- package/dist/shared/spline.d.ts +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z as A } from "zod";
|
|
2
|
-
import { WidgetManifestSchema as
|
|
3
|
-
import { effect as W, className as
|
|
4
|
-
import { createElementSize as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { clsx as
|
|
7
|
-
import { twMerge as
|
|
8
|
-
function
|
|
2
|
+
import { WidgetManifestSchema as an, formatSchemaError as sn } from "./schemas.js";
|
|
3
|
+
import { effect as W, className as R, style as oe, template as x, insert as b, createComponent as k, memo as T, setStyleProperty as X, addEventListener as G, use as xe, delegateEvents as ye } from "solid-js/web";
|
|
4
|
+
import { createElementSize as $e } from "@solid-primitives/resize-observer";
|
|
5
|
+
import { createContext as ke, useContext as ae, Show as E, onMount as Ce, createSignal as V, createMemo as L, splitProps as Se, createEffect as re, on as de, onCleanup as se } from "solid-js";
|
|
6
|
+
import { clsx as Me } from "clsx";
|
|
7
|
+
import { twMerge as De } from "tailwind-merge";
|
|
8
|
+
function ge(e) {
|
|
9
9
|
return A.toJSONSchema(e, {
|
|
10
10
|
override: (t) => {
|
|
11
11
|
const i = A.globalRegistry.get(t.zodSchema);
|
|
@@ -13,17 +13,17 @@ function ce(e) {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function Te(e) {
|
|
17
17
|
try {
|
|
18
18
|
return e.parse({});
|
|
19
19
|
} catch {
|
|
20
20
|
return {};
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return e.configSchema && (e.manifest.schema || (e.manifest.schema =
|
|
23
|
+
function jt(e) {
|
|
24
|
+
return e.configSchema && (e.manifest.schema || (e.manifest.schema = ge(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = Te(e.configSchema))), e;
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const Y = {
|
|
27
27
|
/** Background layer (gradients, images, glows) */
|
|
28
28
|
BACKGROUND: 0,
|
|
29
29
|
/** Main content layer (icon, title, text) */
|
|
@@ -32,14 +32,14 @@ const G = {
|
|
|
32
32
|
OVERLAY: 20,
|
|
33
33
|
/** Action layer (buttons, edit controls) */
|
|
34
34
|
ACTIONS: 30
|
|
35
|
-
},
|
|
36
|
-
function
|
|
37
|
-
const e =
|
|
35
|
+
}, J = ke();
|
|
36
|
+
function Lt() {
|
|
37
|
+
const e = ae(J);
|
|
38
38
|
if (!e)
|
|
39
39
|
throw new Error("useWidgetContext must be used within a Widget component");
|
|
40
40
|
return e;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const _e = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
|
|
43
43
|
* via framework/theming/tokens.ts.
|
|
44
44
|
*
|
|
45
45
|
* All widget-internal visual scale is driven from CSS custom properties +
|
|
@@ -211,22 +211,22 @@ const Ce = `/* Authoritative SDK CSS contract. Injected once on first Widget mou
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
`;
|
|
214
|
-
let
|
|
215
|
-
function
|
|
216
|
-
if (
|
|
214
|
+
let te = !1;
|
|
215
|
+
function ze(e) {
|
|
216
|
+
if (te) return;
|
|
217
217
|
const t = e ?? (typeof document > "u" ? void 0 : document);
|
|
218
218
|
if (!t) return;
|
|
219
219
|
if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
|
|
220
|
-
|
|
220
|
+
te = !0;
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
const i = t.createElement("style");
|
|
224
|
-
i.setAttribute("data-glasshome-tokens", ""), i.textContent =
|
|
224
|
+
i.setAttribute("data-glasshome-tokens", ""), i.textContent = _e, t.head.appendChild(i), te = !0;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
227
|
-
return
|
|
226
|
+
function P(...e) {
|
|
227
|
+
return De(Me(e));
|
|
228
228
|
}
|
|
229
|
-
const
|
|
229
|
+
const Oe = {
|
|
230
230
|
id: "classic-glass",
|
|
231
231
|
name: "Classic Glass",
|
|
232
232
|
description: "Default glassmorphism design with blur background and gradient",
|
|
@@ -254,7 +254,7 @@ const Me = {
|
|
|
254
254
|
hoverScale: 1.02,
|
|
255
255
|
activeScale: 0.98
|
|
256
256
|
}
|
|
257
|
-
},
|
|
257
|
+
}, Ee = {
|
|
258
258
|
id: "minimal",
|
|
259
259
|
name: "Minimal",
|
|
260
260
|
description: "Clean, minimal design with no background effects",
|
|
@@ -283,7 +283,7 @@ const Me = {
|
|
|
283
283
|
active: !1,
|
|
284
284
|
focus: !0
|
|
285
285
|
}
|
|
286
|
-
},
|
|
286
|
+
}, Ne = {
|
|
287
287
|
id: "compact-horizontal",
|
|
288
288
|
name: "Compact Horizontal",
|
|
289
289
|
description: "Horizontal layout for compact widgets",
|
|
@@ -311,108 +311,108 @@ const Me = {
|
|
|
311
311
|
hoverScale: 1.02,
|
|
312
312
|
activeScale: 0.98
|
|
313
313
|
}
|
|
314
|
-
},
|
|
315
|
-
"classic-glass":
|
|
316
|
-
minimal:
|
|
317
|
-
"compact-horizontal":
|
|
314
|
+
}, Ae = {
|
|
315
|
+
"classic-glass": Oe,
|
|
316
|
+
minimal: Ee,
|
|
317
|
+
"compact-horizontal": Ne
|
|
318
318
|
};
|
|
319
|
-
function
|
|
320
|
-
return
|
|
319
|
+
function Ve(e) {
|
|
320
|
+
return Ae[e];
|
|
321
321
|
}
|
|
322
|
-
var
|
|
323
|
-
function
|
|
322
|
+
var We = /* @__PURE__ */ x("<div>");
|
|
323
|
+
function Pe(e) {
|
|
324
324
|
return (() => {
|
|
325
|
-
var t =
|
|
325
|
+
var t = We();
|
|
326
326
|
return W((i) => {
|
|
327
|
-
var r =
|
|
327
|
+
var r = P("glasshome-widget-slider-fill pointer-events-none absolute inset-0", e.isDragging ? "duration-0" : "transition-all duration-300 ease-out", e.class), n = {
|
|
328
328
|
"--widget-fill-value": e.value,
|
|
329
|
-
"z-index":
|
|
329
|
+
"z-index": Y.BACKGROUND,
|
|
330
330
|
...e.color ? {
|
|
331
331
|
"--widget-icon-color": e.color
|
|
332
332
|
} : {}
|
|
333
333
|
};
|
|
334
|
-
return r !== i.e &&
|
|
334
|
+
return r !== i.e && R(t, i.e = r), i.t = oe(t, n, i.t), i;
|
|
335
335
|
}, {
|
|
336
336
|
e: void 0,
|
|
337
337
|
t: void 0
|
|
338
338
|
}), t;
|
|
339
339
|
})();
|
|
340
340
|
}
|
|
341
|
-
var
|
|
342
|
-
function
|
|
341
|
+
var He = /* @__PURE__ */ x("<div>");
|
|
342
|
+
function Re(e) {
|
|
343
343
|
return (() => {
|
|
344
|
-
var t =
|
|
345
|
-
return
|
|
344
|
+
var t = He();
|
|
345
|
+
return b(t, () => e.children), W(() => R(t, P("glasshome-widget-content", e.class))), t;
|
|
346
346
|
})();
|
|
347
347
|
}
|
|
348
|
-
var
|
|
349
|
-
function
|
|
348
|
+
var Ie = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2">'), je = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3">'), Le = /* @__PURE__ */ x('<div><div class="glasshome-widget-icon-glyph flex items-center justify-center">');
|
|
349
|
+
function Be(e) {
|
|
350
350
|
const t = () => e.entityCount ?? 1;
|
|
351
351
|
return (() => {
|
|
352
|
-
var i =
|
|
353
|
-
return
|
|
352
|
+
var i = Le(), r = i.firstChild;
|
|
353
|
+
return b(i, k(E, {
|
|
354
354
|
get when() {
|
|
355
355
|
return t() >= 2;
|
|
356
356
|
},
|
|
357
357
|
get children() {
|
|
358
|
-
return
|
|
358
|
+
return Ie();
|
|
359
359
|
}
|
|
360
|
-
}), r),
|
|
360
|
+
}), r), b(i, k(E, {
|
|
361
361
|
get when() {
|
|
362
362
|
return t() >= 3;
|
|
363
363
|
},
|
|
364
364
|
get children() {
|
|
365
|
-
return
|
|
365
|
+
return je();
|
|
366
366
|
}
|
|
367
|
-
}), r),
|
|
368
|
-
var
|
|
367
|
+
}), r), b(r, () => e.icon), W((n) => {
|
|
368
|
+
var o = P("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center pointer-events-none transition-all", e.dimmed && "opacity-50", e.class), u = e.color ? {
|
|
369
369
|
"--widget-icon-color": e.color
|
|
370
370
|
} : void 0;
|
|
371
|
-
return
|
|
371
|
+
return o !== n.e && R(i, n.e = o), n.t = oe(i, u, n.t), n;
|
|
372
372
|
}, {
|
|
373
373
|
e: void 0,
|
|
374
374
|
t: void 0
|
|
375
375
|
}), i;
|
|
376
376
|
})();
|
|
377
377
|
}
|
|
378
|
-
var
|
|
379
|
-
function
|
|
378
|
+
var Ue = /* @__PURE__ */ x("<p>");
|
|
379
|
+
function Fe(e) {
|
|
380
380
|
return (() => {
|
|
381
|
-
var t =
|
|
382
|
-
return
|
|
383
|
-
var i =
|
|
381
|
+
var t = Ue();
|
|
382
|
+
return b(t, (() => {
|
|
383
|
+
var i = T(() => !!e.isUnavailable);
|
|
384
384
|
return () => i() ? "Unavailable" : e.children;
|
|
385
385
|
})()), W((i) => {
|
|
386
|
-
var r =
|
|
387
|
-
return r !== i.e &&
|
|
386
|
+
var r = P("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), n = Y.ACTIONS;
|
|
387
|
+
return r !== i.e && R(t, i.e = r), n !== i.t && X(t, "z-index", i.t = n), i;
|
|
388
388
|
}, {
|
|
389
389
|
e: void 0,
|
|
390
390
|
t: void 0
|
|
391
391
|
}), t;
|
|
392
392
|
})();
|
|
393
393
|
}
|
|
394
|
-
var
|
|
395
|
-
function
|
|
394
|
+
var Ge = /* @__PURE__ */ x('<span class="glasshome-widget-badge shrink-0">'), qe = /* @__PURE__ */ x("<div><h3 class=glasshome-widget-title>");
|
|
395
|
+
function Ye(e) {
|
|
396
396
|
return (() => {
|
|
397
|
-
var t =
|
|
398
|
-
return
|
|
397
|
+
var t = qe(), i = t.firstChild;
|
|
398
|
+
return b(i, () => e.children), b(t, k(E, {
|
|
399
399
|
get when() {
|
|
400
|
-
return
|
|
400
|
+
return T(() => e.badge !== void 0)() && e.badge > 0;
|
|
401
401
|
},
|
|
402
402
|
get children() {
|
|
403
|
-
var r =
|
|
404
|
-
return
|
|
403
|
+
var r = Ge();
|
|
404
|
+
return b(r, () => e.badge), r;
|
|
405
405
|
}
|
|
406
406
|
}), null), W((r) => {
|
|
407
|
-
var n =
|
|
408
|
-
return n !== r.e &&
|
|
407
|
+
var n = P("relative flex items-center gap-2", e.class), o = Y.ACTIONS;
|
|
408
|
+
return n !== r.e && R(t, r.e = n), o !== r.t && X(t, "z-index", r.t = o), r;
|
|
409
409
|
}, {
|
|
410
410
|
e: void 0,
|
|
411
411
|
t: void 0
|
|
412
412
|
}), t;
|
|
413
413
|
})();
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Ke(e, t = !1) {
|
|
416
416
|
if (e.length === 0)
|
|
417
417
|
return {
|
|
418
418
|
isGroup: !1,
|
|
@@ -428,62 +428,62 @@ function Le(e, t = !1) {
|
|
|
428
428
|
};
|
|
429
429
|
const i = e.length > 1;
|
|
430
430
|
if (!i) {
|
|
431
|
-
const
|
|
431
|
+
const a = e[0], f = a.state === "on", p = a.attributes?.brightness || 0, C = Math.round(p / 255 * 100);
|
|
432
432
|
return {
|
|
433
433
|
isGroup: !1,
|
|
434
|
-
state:
|
|
435
|
-
isOn:
|
|
436
|
-
isUnavailable:
|
|
437
|
-
brightness:
|
|
438
|
-
brightnessPercent:
|
|
439
|
-
color:
|
|
440
|
-
onCount:
|
|
434
|
+
state: a.state,
|
|
435
|
+
isOn: f,
|
|
436
|
+
isUnavailable: a.state === "unavailable",
|
|
437
|
+
brightness: p,
|
|
438
|
+
brightnessPercent: C,
|
|
439
|
+
color: ue(a),
|
|
440
|
+
onCount: f ? 1 : 0,
|
|
441
441
|
totalCount: 1,
|
|
442
|
-
description:
|
|
442
|
+
description: f ? "On" : "Off"
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
let r = 0, n = 0,
|
|
446
|
-
const
|
|
447
|
-
for (const
|
|
448
|
-
switch (
|
|
445
|
+
let r = 0, n = 0, o = 0, u = 0, d = 0, $ = 0;
|
|
446
|
+
const m = [];
|
|
447
|
+
for (const a of e)
|
|
448
|
+
switch (a.state) {
|
|
449
449
|
case "on":
|
|
450
|
-
r++,
|
|
450
|
+
r++, a.attributes?.brightness !== void 0 && (d += a.attributes.brightness, $++), a.attributes?.rgb_color && m.push(a.attributes.rgb_color);
|
|
451
451
|
break;
|
|
452
452
|
case "off":
|
|
453
453
|
n++;
|
|
454
454
|
break;
|
|
455
455
|
case "unknown":
|
|
456
|
-
|
|
456
|
+
o++;
|
|
457
457
|
break;
|
|
458
458
|
case "unavailable":
|
|
459
|
-
|
|
459
|
+
u++;
|
|
460
460
|
break;
|
|
461
461
|
}
|
|
462
|
-
const
|
|
463
|
-
let
|
|
464
|
-
t ?
|
|
465
|
-
const
|
|
466
|
-
let
|
|
467
|
-
if (
|
|
468
|
-
const
|
|
469
|
-
|
|
462
|
+
const h = e.length, v = u === h, y = o + u === h, g = r > 0, s = r === h, S = n === h;
|
|
463
|
+
let w, M;
|
|
464
|
+
t ? v ? (w = "unavailable", M = !1) : o > 0 || u > 0 ? (w = "unknown", M = !1) : n > 0 ? (w = "off", M = !1) : (w = "on", M = !0) : v ? (w = "unavailable", M = !1) : y ? (w = "unknown", M = !1) : g ? (w = "on", M = !0) : (w = "off", M = !1);
|
|
465
|
+
const z = $ > 0 ? Math.round(d / $) : 0, I = Math.round(z / 255 * 100);
|
|
466
|
+
let B;
|
|
467
|
+
if (m.length > 0) {
|
|
468
|
+
const a = Math.round(m.reduce((O, D) => O + D[0], 0) / m.length), f = Math.round(m.reduce((O, D) => O + D[1], 0) / m.length), p = Math.round(m.reduce((O, D) => O + D[2], 0) / m.length), C = z / 255;
|
|
469
|
+
B = `rgb(${Math.round(a * C)}, ${Math.round(f * C)}, ${Math.round(p * C)})`;
|
|
470
470
|
} else
|
|
471
|
-
|
|
472
|
-
let
|
|
473
|
-
return
|
|
471
|
+
B = ue(e[0]);
|
|
472
|
+
let H;
|
|
473
|
+
return s ? H = "All on" : S ? H = "All off" : r > 0 ? H = `${r} of ${h} on` : H = "Off", {
|
|
474
474
|
isGroup: i,
|
|
475
|
-
state:
|
|
476
|
-
isOn:
|
|
477
|
-
isUnavailable:
|
|
478
|
-
brightness:
|
|
479
|
-
brightnessPercent:
|
|
480
|
-
color:
|
|
475
|
+
state: w,
|
|
476
|
+
isOn: M,
|
|
477
|
+
isUnavailable: w === "unavailable",
|
|
478
|
+
brightness: z,
|
|
479
|
+
brightnessPercent: I,
|
|
480
|
+
color: B,
|
|
481
481
|
onCount: r,
|
|
482
|
-
totalCount:
|
|
483
|
-
description:
|
|
482
|
+
totalCount: h,
|
|
483
|
+
description: H
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Xe(e, t = "mean", i = !0) {
|
|
487
487
|
if (e.length === 0)
|
|
488
488
|
return {
|
|
489
489
|
isGroup: !1,
|
|
@@ -494,112 +494,112 @@ function Fe(e, t = "mean", i = !0) {
|
|
|
494
494
|
};
|
|
495
495
|
const r = e.length > 1;
|
|
496
496
|
if (!r) {
|
|
497
|
-
const
|
|
498
|
-
let
|
|
499
|
-
return Number.isNaN(
|
|
497
|
+
const g = e[0], s = Number.parseFloat(g.state);
|
|
498
|
+
let S = g.state;
|
|
499
|
+
return Number.isNaN(s) || (S = Number.isInteger(s) ? s.toString() : s.toFixed(1)), {
|
|
500
500
|
isGroup: !1,
|
|
501
|
-
state:
|
|
502
|
-
numericValue: Number.isNaN(
|
|
503
|
-
isUnavailable:
|
|
504
|
-
unit:
|
|
505
|
-
description:
|
|
501
|
+
state: S,
|
|
502
|
+
numericValue: Number.isNaN(s) ? null : s,
|
|
503
|
+
isUnavailable: g.state === "unavailable",
|
|
504
|
+
unit: g.unitOfMeasurement ?? void 0,
|
|
505
|
+
description: S
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
|
-
const n = [],
|
|
509
|
-
let
|
|
510
|
-
for (const
|
|
511
|
-
if (!
|
|
512
|
-
|
|
513
|
-
entityId:
|
|
508
|
+
const n = [], o = [];
|
|
509
|
+
let u = 0, d;
|
|
510
|
+
for (const g of e) {
|
|
511
|
+
if (!d && g.unitOfMeasurement && (d = g.unitOfMeasurement), g.state === "unavailable") {
|
|
512
|
+
u++, o.push({
|
|
513
|
+
entityId: g.id,
|
|
514
514
|
value: "unavailable",
|
|
515
|
-
friendly_name:
|
|
515
|
+
friendly_name: g.friendlyName
|
|
516
516
|
});
|
|
517
517
|
continue;
|
|
518
518
|
}
|
|
519
|
-
const
|
|
520
|
-
isNaN(
|
|
521
|
-
entityId:
|
|
522
|
-
value:
|
|
523
|
-
friendly_name:
|
|
524
|
-
}) : (n.push(
|
|
525
|
-
entityId:
|
|
526
|
-
value:
|
|
527
|
-
friendly_name:
|
|
519
|
+
const s = Number.parseFloat(g.state);
|
|
520
|
+
isNaN(s) ? i || o.push({
|
|
521
|
+
entityId: g.id,
|
|
522
|
+
value: g.state,
|
|
523
|
+
friendly_name: g.friendlyName
|
|
524
|
+
}) : (n.push(s), o.push({
|
|
525
|
+
entityId: g.id,
|
|
526
|
+
value: s,
|
|
527
|
+
friendly_name: g.friendlyName
|
|
528
528
|
}));
|
|
529
529
|
}
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
530
|
+
const $ = u === e.length, m = n.length === 0;
|
|
531
|
+
if ($ || m)
|
|
532
532
|
return {
|
|
533
533
|
isGroup: r,
|
|
534
|
-
state:
|
|
534
|
+
state: $ ? "unavailable" : "unknown",
|
|
535
535
|
numericValue: null,
|
|
536
|
-
isUnavailable:
|
|
537
|
-
unit:
|
|
538
|
-
description:
|
|
539
|
-
memberValues:
|
|
536
|
+
isUnavailable: $,
|
|
537
|
+
unit: d,
|
|
538
|
+
description: $ ? "Unavailable" : "No numeric values",
|
|
539
|
+
memberValues: o
|
|
540
540
|
};
|
|
541
|
-
let
|
|
541
|
+
let h, v;
|
|
542
542
|
switch (t) {
|
|
543
543
|
case "min":
|
|
544
|
-
|
|
544
|
+
h = Math.min(...n), v = "Minimum";
|
|
545
545
|
break;
|
|
546
546
|
case "max":
|
|
547
|
-
|
|
547
|
+
h = Math.max(...n), v = "Maximum";
|
|
548
548
|
break;
|
|
549
549
|
case "mean":
|
|
550
|
-
|
|
550
|
+
h = n.reduce((g, s) => g + s, 0) / n.length, v = "Average";
|
|
551
551
|
break;
|
|
552
552
|
case "median": {
|
|
553
|
-
const
|
|
554
|
-
|
|
553
|
+
const g = [...n].sort((S, w) => S - w), s = Math.floor(g.length / 2);
|
|
554
|
+
h = g.length % 2 === 0 ? (g[s - 1] + g[s]) / 2 : g[s], v = "Median";
|
|
555
555
|
break;
|
|
556
556
|
}
|
|
557
557
|
case "sum":
|
|
558
|
-
|
|
558
|
+
h = n.reduce((g, s) => g + s, 0), v = "Sum";
|
|
559
559
|
break;
|
|
560
560
|
case "last":
|
|
561
|
-
|
|
561
|
+
h = n[n.length - 1], v = "Latest";
|
|
562
562
|
break;
|
|
563
563
|
case "range":
|
|
564
|
-
|
|
564
|
+
h = Math.max(...n) - Math.min(...n), v = "Range";
|
|
565
565
|
break;
|
|
566
566
|
case "product":
|
|
567
|
-
|
|
567
|
+
h = n.reduce((g, s) => g * s, 1), v = "Product";
|
|
568
568
|
break;
|
|
569
569
|
case "std_dev": {
|
|
570
|
-
const
|
|
571
|
-
|
|
570
|
+
const g = n.reduce((S, w) => S + w, 0) / n.length, s = n.reduce((S, w) => S + (w - g) ** 2, 0) / n.length;
|
|
571
|
+
h = Math.sqrt(s), v = "Std Dev";
|
|
572
572
|
break;
|
|
573
573
|
}
|
|
574
574
|
default:
|
|
575
|
-
|
|
575
|
+
h = n.reduce((g, s) => g + s, 0) / n.length, v = "Average";
|
|
576
576
|
}
|
|
577
|
-
const
|
|
577
|
+
const y = Number.isInteger(h) ? h.toString() : h.toFixed(1);
|
|
578
578
|
return {
|
|
579
579
|
isGroup: r,
|
|
580
|
-
state:
|
|
581
|
-
numericValue:
|
|
580
|
+
state: y,
|
|
581
|
+
numericValue: h,
|
|
582
582
|
isUnavailable: !1,
|
|
583
|
-
unit:
|
|
584
|
-
description: `${
|
|
585
|
-
memberValues:
|
|
583
|
+
unit: d,
|
|
584
|
+
description: `${v} of ${n.length}`,
|
|
585
|
+
memberValues: o
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function ue(e) {
|
|
589
589
|
if (e.state !== "on") return "rgb(100, 100, 100)";
|
|
590
590
|
const i = (e.attributes?.brightness ?? 255) / 255;
|
|
591
591
|
if (e.attributes?.rgb_color) {
|
|
592
|
-
const [r, n,
|
|
593
|
-
return `rgb(${Math.round(r * i)}, ${Math.round(n * i)}, ${Math.round(
|
|
592
|
+
const [r, n, o] = e.attributes.rgb_color;
|
|
593
|
+
return `rgb(${Math.round(r * i)}, ${Math.round(n * i)}, ${Math.round(o * i)})`;
|
|
594
594
|
}
|
|
595
595
|
if (e.attributes?.color_temp) {
|
|
596
596
|
const n = 1e6 / e.attributes.color_temp / 100;
|
|
597
|
-
let
|
|
598
|
-
return n <= 66 ? (
|
|
597
|
+
let o, u, d;
|
|
598
|
+
return n <= 66 ? (o = 255, u = n <= 19 ? 0 : 99.4708025861 * Math.log(n - 10) - 161.1195681661, d = n <= 19 ? 0 : n <= 66 ? 138.5177312231 * Math.log(n - 10) - 305.0447927307 : 255) : (o = 329.698727446 * (n - 60) ** -0.1332047592, u = 288.1221695283 * (n - 60) ** -0.0755148492, d = 255), o = Math.max(0, Math.min(255, o)) * i, u = Math.max(0, Math.min(255, u)) * i, d = Math.max(0, Math.min(255, d)) * i, `rgb(${Math.round(o)}, ${Math.round(u)}, ${Math.round(d)})`;
|
|
599
599
|
}
|
|
600
600
|
return `rgb(${Math.round(255 * i)}, ${Math.round(220 * i)}, ${Math.round(180 * i)})`;
|
|
601
601
|
}
|
|
602
|
-
function
|
|
602
|
+
function Je(e) {
|
|
603
603
|
if (!e) return !1;
|
|
604
604
|
if (["on", "open", "locked", "home", "playing", "active"].includes(e.state))
|
|
605
605
|
return !0;
|
|
@@ -609,63 +609,64 @@ function Ge(e) {
|
|
|
609
609
|
}
|
|
610
610
|
return !1;
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function Bt(e, t, i) {
|
|
613
613
|
return e?.attributes ? e.attributes[t] ?? i : i;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
return e.filter(
|
|
615
|
+
function Ut(e) {
|
|
616
|
+
return e.filter(Je).length;
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function Qe(e, t, i) {
|
|
619
619
|
const { decimals: r, scale: n = !0 } = {};
|
|
620
620
|
if (typeof e == "string")
|
|
621
621
|
return t ? `${e}${t}` : e;
|
|
622
622
|
if (e == null || Number.isNaN(e))
|
|
623
623
|
return t ? `--${t}` : "--";
|
|
624
|
-
let
|
|
625
|
-
n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (
|
|
626
|
-
let
|
|
627
|
-
return r !== void 0 ?
|
|
624
|
+
let o = e, u = t || "";
|
|
625
|
+
n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (o = e / 1e6, u = "MW") : e >= 1e3 ? (o = e / 1e3, u = "kW") : u = "W"), n && t && (t === "B" || t === "KB" || t === "MB" || t === "GB") && (e >= 1073741824 ? (o = e / 1073741824, u = "GB") : e >= 1048576 ? (o = e / 1048576, u = "MB") : e >= 1024 ? (o = e / 1024, u = "KB") : u = "B");
|
|
626
|
+
let d;
|
|
627
|
+
return r !== void 0 ? d = o.toFixed(r) : o !== e ? d = o.toFixed(1) : Number.isInteger(e) ? d = e.toString() : d = Number.parseFloat(e.toFixed(2)).toString(), u ? `${d}${u}` : d;
|
|
628
628
|
}
|
|
629
|
-
function
|
|
629
|
+
function Ze(e, t) {
|
|
630
630
|
return e == null || isNaN(e) ? null : t === "°C" ? e < 10 ? "Cold" : e < 18 ? "Cool" : e < 24 ? "Comfortable" : e < 28 ? "Warm" : "Hot" : t === "°F" ? e < 50 ? "Cold" : e < 64 ? "Cool" : e < 75 ? "Comfortable" : e < 82 ? "Warm" : "Hot" : t === "%" ? e < 20 ? "Very Low" : e < 40 ? "Low" : e < 60 ? "Medium" : e < 80 ? "High" : "Very High" : t === "ppm" ? e < 400 ? "Excellent" : e < 600 ? "Good" : e < 1e3 ? "Acceptable" : e < 1500 ? "Mediocre" : "Poor" : t === "lx" ? e < 50 ? "Dark" : e < 200 ? "Dim" : e < 500 ? "Moderate" : e < 1e3 ? "Bright" : "Very Bright" : t === "AQI" ? e <= 50 ? "Good" : e <= 100 ? "Moderate" : e <= 150 ? "Unhealthy for Sensitive" : e <= 200 ? "Unhealthy" : e <= 300 ? "Very Unhealthy" : "Hazardous" : t === "dB" ? e < 30 ? "Very Quiet" : e < 50 ? "Quiet" : e < 70 ? "Moderate" : e < 85 ? "Loud" : "Very Loud" : null;
|
|
631
631
|
}
|
|
632
|
-
var
|
|
633
|
-
function
|
|
632
|
+
var et = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), tt = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
|
|
633
|
+
function nt(e) {
|
|
634
634
|
return (() => {
|
|
635
|
-
var t =
|
|
636
|
-
return
|
|
635
|
+
var t = tt(), i = t.firstChild;
|
|
636
|
+
return b(i, () => Qe(e.value, e.unit)), b(t, k(E, {
|
|
637
637
|
get when() {
|
|
638
|
-
return
|
|
638
|
+
return T(() => !!e.interpret)() && typeof e.value == "number";
|
|
639
639
|
},
|
|
640
640
|
get children() {
|
|
641
|
-
var r =
|
|
642
|
-
return
|
|
641
|
+
var r = et();
|
|
642
|
+
return b(r, () => Ze(e.value, e.unit)), r;
|
|
643
643
|
}
|
|
644
|
-
}), null), W(() =>
|
|
644
|
+
}), null), W(() => R(t, P("flex flex-col", e.class))), t;
|
|
645
645
|
})();
|
|
646
646
|
}
|
|
647
|
-
var
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
647
|
+
var it = /* @__PURE__ */ x('<div><div class="relative h-full w-full">'), rt = /* @__PURE__ */ x('<div class="glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse">'), ot = /* @__PURE__ */ x('<div class="flex h-full w-full flex-col items-center justify-center gap-2 text-center">'), at = /* @__PURE__ */ x('<div class="flex items-center justify-center text-white/30">'), st = /* @__PURE__ */ x('<h3 class="font-semibold text-sm text-white/60">'), lt = /* @__PURE__ */ x('<p class="text-white/50 text-xs">');
|
|
648
|
+
function ct(e) {
|
|
649
|
+
Ce(() => {
|
|
650
|
+
ze();
|
|
651
651
|
});
|
|
652
|
-
const t =
|
|
652
|
+
const t = ae(J), [i, r] = V(), n = $e(i), o = {
|
|
653
653
|
isEditMode: () => e.isEditMode ?? !1,
|
|
654
654
|
updateConfig: t?.updateConfig ?? (() => {
|
|
655
655
|
}),
|
|
656
|
+
registerDialogOpener: t?.registerDialogOpener,
|
|
656
657
|
dimensions: () => ({
|
|
657
658
|
width: n.width ?? 0,
|
|
658
659
|
height: n.height ?? 0
|
|
659
660
|
})
|
|
660
|
-
},
|
|
661
|
+
}, u = L(() => {
|
|
661
662
|
if (e.variant)
|
|
662
|
-
return typeof e.variant == "string" ?
|
|
663
|
-
}),
|
|
663
|
+
return typeof e.variant == "string" ? Ve(e.variant) : e.variant;
|
|
664
|
+
}), d = L(() => ({
|
|
664
665
|
"container-type": "size",
|
|
665
666
|
"container-name": "widget",
|
|
666
667
|
"touch-action": e.gestures && !e.isEditMode ? e.gestures.touchAction() : void 0,
|
|
667
|
-
...
|
|
668
|
-
...
|
|
668
|
+
...u()?.styles?.container,
|
|
669
|
+
...u()?.styles?.cssVars || {},
|
|
669
670
|
...e.tone ? {
|
|
670
671
|
"--widget-color": `var(--tone-${e.tone})`
|
|
671
672
|
} : {},
|
|
@@ -678,26 +679,26 @@ function rt(e) {
|
|
|
678
679
|
...e.gradient ? {
|
|
679
680
|
"--widget-gradient": e.gradient
|
|
680
681
|
} : {}
|
|
681
|
-
})),
|
|
682
|
-
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
},
|
|
686
|
-
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
},
|
|
690
|
-
|
|
682
|
+
})), $ = () => !!e.gestures && !e.isEditMode, m = (s) => {
|
|
683
|
+
$() && e.gestures?.onPointerEnter(s);
|
|
684
|
+
}, h = (s) => {
|
|
685
|
+
$() && e.gestures?.onPointerDown(s);
|
|
686
|
+
}, v = (s) => {
|
|
687
|
+
$() && e.gestures?.onPointerMove(s);
|
|
688
|
+
}, y = (s) => {
|
|
689
|
+
$() && e.gestures?.onPointerUp(s);
|
|
690
|
+
}, g = (s) => {
|
|
691
|
+
$() && e.gestures?.onPointerCancel(s);
|
|
691
692
|
};
|
|
692
|
-
return
|
|
693
|
-
value:
|
|
693
|
+
return k(J.Provider, {
|
|
694
|
+
value: o,
|
|
694
695
|
get children() {
|
|
695
|
-
var
|
|
696
|
-
return
|
|
697
|
-
r(
|
|
698
|
-
},
|
|
699
|
-
var
|
|
700
|
-
return () =>
|
|
696
|
+
var s = it(), S = s.firstChild;
|
|
697
|
+
return G(s, "pointercancel", g), G(s, "pointerup", y), G(s, "pointermove", v), G(s, "pointerdown", h), G(s, "pointerenter", m), xe((w) => {
|
|
698
|
+
r(w), e.gestures?.bindElement(w);
|
|
699
|
+
}, s), b(S, (() => {
|
|
700
|
+
var w = T(() => !!e.emptyState);
|
|
701
|
+
return () => w() ? k(dt, {
|
|
701
702
|
get icon() {
|
|
702
703
|
return e.emptyState.icon;
|
|
703
704
|
},
|
|
@@ -708,86 +709,88 @@ function rt(e) {
|
|
|
708
709
|
return e.emptyState.message;
|
|
709
710
|
}
|
|
710
711
|
}) : e.children;
|
|
711
|
-
})()),
|
|
712
|
-
var
|
|
713
|
-
return () =>
|
|
714
|
-
var
|
|
715
|
-
return W((
|
|
712
|
+
})()), b(s, (() => {
|
|
713
|
+
var w = T(() => !!e.loading);
|
|
714
|
+
return () => w() && (() => {
|
|
715
|
+
var M = rt();
|
|
716
|
+
return W((z) => X(M, "z-index", Y.OVERLAY)), M;
|
|
716
717
|
})();
|
|
717
|
-
})(), null), W((
|
|
718
|
-
var
|
|
719
|
-
return
|
|
718
|
+
})(), null), W((w) => {
|
|
719
|
+
var M = P("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", u()?.styles?.class, e.class), z = d(), I = Y.CONTENT;
|
|
720
|
+
return M !== w.e && R(s, w.e = M), w.t = oe(s, z, w.t), I !== w.a && X(S, "z-index", w.a = I), w;
|
|
720
721
|
}, {
|
|
721
722
|
e: void 0,
|
|
722
723
|
t: void 0,
|
|
723
724
|
a: void 0
|
|
724
|
-
}),
|
|
725
|
+
}), s;
|
|
725
726
|
}
|
|
726
727
|
});
|
|
727
728
|
}
|
|
728
|
-
function
|
|
729
|
+
function dt(e) {
|
|
729
730
|
return (() => {
|
|
730
|
-
var t =
|
|
731
|
-
return
|
|
732
|
-
var i =
|
|
731
|
+
var t = ot();
|
|
732
|
+
return b(t, (() => {
|
|
733
|
+
var i = T(() => !!e.icon);
|
|
733
734
|
return () => i() && (() => {
|
|
734
|
-
var r =
|
|
735
|
-
return
|
|
735
|
+
var r = at();
|
|
736
|
+
return b(r, () => e.icon), r;
|
|
736
737
|
})();
|
|
737
|
-
})(), null),
|
|
738
|
-
var i =
|
|
738
|
+
})(), null), b(t, (() => {
|
|
739
|
+
var i = T(() => !!e.title);
|
|
739
740
|
return () => i() && (() => {
|
|
740
|
-
var r =
|
|
741
|
-
return
|
|
741
|
+
var r = st();
|
|
742
|
+
return b(r, () => e.title), r;
|
|
742
743
|
})();
|
|
743
|
-
})(), null),
|
|
744
|
-
var i =
|
|
744
|
+
})(), null), b(t, (() => {
|
|
745
|
+
var i = T(() => !!e.message);
|
|
745
746
|
return () => i() && (() => {
|
|
746
|
-
var r =
|
|
747
|
-
return
|
|
747
|
+
var r = lt();
|
|
748
|
+
return b(r, () => e.message), r;
|
|
748
749
|
})();
|
|
749
750
|
})(), null), t;
|
|
750
751
|
})();
|
|
751
752
|
}
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
var
|
|
760
|
-
function
|
|
753
|
+
const U = ct;
|
|
754
|
+
U.Content = Re;
|
|
755
|
+
U.Icon = Be;
|
|
756
|
+
U.Title = Ye;
|
|
757
|
+
U.Status = Fe;
|
|
758
|
+
U.Value = nt;
|
|
759
|
+
U.SliderFill = Pe;
|
|
760
|
+
var ut = /* @__PURE__ */ x('<span class="inline-flex size-3.5 shrink-0 items-center">'), gt = /* @__PURE__ */ x("<button type=button>"), ht = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z">'), ft = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No edit options available'), mt = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><line x1=4 y1=21 x2=4 y2=14></line><line x1=4 y1=10 x2=4 y2=3></line><line x1=12 y1=21 x2=12 y2=12></line><line x1=12 y1=8 x2=12 y2=3></line><line x1=20 y1=21 x2=20 y2=16></line><line x1=20 y1=12 x2=20 y2=3></line><line x1=1 y1=14 x2=7 y2=14></line><line x1=9 y1=8 x2=15 y2=8></line><line x1=17 y1=16 x2=23 y2=16>'), vt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No additional controls'), wt = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="m8 2 1.88 1.88"></path><path d="M14.12 3.88 16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4">'), bt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No debug information available'), pt = /* @__PURE__ */ x('<div class="min-w-0 shrink-0">'), xt = /* @__PURE__ */ x('<div class="flex items-center gap-2"><div class="flex h-8 items-center rounded-lg border border-border/50 bg-muted/30 p-0.5">'), yt = /* @__PURE__ */ x('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), $t = /* @__PURE__ */ x('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
|
|
761
|
+
function kt(e) {
|
|
761
762
|
return (() => {
|
|
762
|
-
var t =
|
|
763
|
-
return t.$$click = () => e.onClick(),
|
|
763
|
+
var t = gt();
|
|
764
|
+
return t.$$click = () => e.onClick(), b(t, k(E, {
|
|
764
765
|
get when() {
|
|
765
766
|
return e.isActive;
|
|
766
767
|
},
|
|
767
768
|
get children() {
|
|
768
|
-
var i =
|
|
769
|
-
return
|
|
769
|
+
var i = ut();
|
|
770
|
+
return b(i, () => e.icon), i;
|
|
770
771
|
}
|
|
771
|
-
}), null),
|
|
772
|
+
}), null), b(t, () => e.label, null), W(() => R(t, P("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
|
|
772
773
|
})();
|
|
773
774
|
}
|
|
774
|
-
function
|
|
775
|
-
const [t] =
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
...
|
|
775
|
+
function Ft(e) {
|
|
776
|
+
const [t] = Se(e, ["open", "onOpenChange", "title", "onSave", "hasUnsavedChanges", "onDelete", "editContent", "controlsContent", "debugContent", "debugData", "tabs", "class", "maxWidth", "defaultTab", "activeTab", "onActiveTabChange", "headerActions", "configSchema", "config", "onConfigSave", "ResponsiveDialog", "ResponsiveDialogContent", "ResponsiveDialogHeader", "ResponsiveDialogTitle", "ResponsiveDialogDescription", "Button", "SchemaForm"]), i = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [r, n] = V({}), [o, u] = V(null);
|
|
777
|
+
re(de(() => t.config, (c) => {
|
|
778
|
+
c && n({
|
|
779
|
+
...c
|
|
779
780
|
});
|
|
780
|
-
})),
|
|
781
|
-
|
|
781
|
+
})), re(de(() => t.configSchema, (c) => {
|
|
782
|
+
c && u(ge(c));
|
|
782
783
|
}));
|
|
783
|
-
const
|
|
784
|
-
!
|
|
784
|
+
const d = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), $ = (c) => {
|
|
785
|
+
!c && t.config && n({
|
|
785
786
|
...t.config
|
|
786
|
-
}), t.onOpenChange(
|
|
787
|
-
},
|
|
787
|
+
}), t.onOpenChange(c);
|
|
788
|
+
}, m = () => {
|
|
788
789
|
t.onConfigSave?.(r());
|
|
789
|
-
}, [
|
|
790
|
-
|
|
790
|
+
}, [h, v] = V(t.defaultTab ?? "controls"), y = () => t.activeTab ?? h(), g = (c) => {
|
|
791
|
+
t.onActiveTabChange ? t.onActiveTabChange(c) : v(c);
|
|
792
|
+
}, s = () => {
|
|
793
|
+
const c = t.maxWidth ?? "3xl";
|
|
791
794
|
return {
|
|
792
795
|
sm: "max-w-sm",
|
|
793
796
|
md: "max-w-md",
|
|
@@ -796,141 +799,141 @@ function Pt(e) {
|
|
|
796
799
|
"2xl": "max-w-2xl",
|
|
797
800
|
"3xl": "max-w-3xl",
|
|
798
801
|
"4xl": "max-w-4xl"
|
|
799
|
-
}[
|
|
800
|
-
},
|
|
802
|
+
}[c];
|
|
803
|
+
}, S = () => {
|
|
801
804
|
if (t.tabs) return t.tabs;
|
|
802
|
-
const
|
|
803
|
-
return
|
|
805
|
+
const c = [];
|
|
806
|
+
return c.push({
|
|
804
807
|
id: "edit",
|
|
805
808
|
label: "Edit",
|
|
806
|
-
icon:
|
|
807
|
-
content: t.editContent ?? (i() &&
|
|
809
|
+
icon: ht(),
|
|
810
|
+
content: t.editContent ?? (i() && o() ? k(p, {
|
|
808
811
|
get schema() {
|
|
809
|
-
return
|
|
812
|
+
return o();
|
|
810
813
|
},
|
|
811
814
|
get data() {
|
|
812
815
|
return r();
|
|
813
816
|
},
|
|
814
817
|
onChange: n
|
|
815
|
-
}) :
|
|
816
|
-
}),
|
|
818
|
+
}) : ft())
|
|
819
|
+
}), c.push({
|
|
817
820
|
id: "controls",
|
|
818
821
|
label: "Controls",
|
|
819
|
-
icon:
|
|
820
|
-
content: t.controlsContent ??
|
|
821
|
-
}),
|
|
822
|
+
icon: mt(),
|
|
823
|
+
content: t.controlsContent ?? vt()
|
|
824
|
+
}), c.push({
|
|
822
825
|
id: "debug",
|
|
823
826
|
label: "Debug",
|
|
824
|
-
icon:
|
|
825
|
-
content: t.debugContent ??
|
|
826
|
-
}),
|
|
827
|
-
},
|
|
827
|
+
icon: wt(),
|
|
828
|
+
content: t.debugContent ?? bt()
|
|
829
|
+
}), c;
|
|
830
|
+
}, w = async () => {
|
|
828
831
|
if (t.debugData !== void 0)
|
|
829
832
|
try {
|
|
830
|
-
const
|
|
831
|
-
await navigator.clipboard.writeText(
|
|
833
|
+
const c = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
|
|
834
|
+
await navigator.clipboard.writeText(c);
|
|
832
835
|
} catch {
|
|
833
836
|
}
|
|
834
|
-
},
|
|
835
|
-
const
|
|
836
|
-
return
|
|
837
|
-
},
|
|
838
|
-
return
|
|
837
|
+
}, M = () => {
|
|
838
|
+
const c = S();
|
|
839
|
+
return c.find((N) => N.id === y())?.content ?? c[0]?.content;
|
|
840
|
+
}, z = t.ResponsiveDialog, I = t.ResponsiveDialogContent, B = t.ResponsiveDialogHeader, H = t.ResponsiveDialogTitle, a = t.ResponsiveDialogDescription, f = t.Button, p = t.SchemaForm, C = (c) => i() ? $(c) : t.onOpenChange(c), O = () => i() ? d() : t.hasUnsavedChanges, D = () => i() ? m : t.onSave;
|
|
841
|
+
return k(z, {
|
|
839
842
|
get open() {
|
|
840
843
|
return t.open;
|
|
841
844
|
},
|
|
842
|
-
onOpenChange: (
|
|
845
|
+
onOpenChange: (c) => C(c),
|
|
843
846
|
get children() {
|
|
844
|
-
return
|
|
847
|
+
return k(I, {
|
|
845
848
|
get class() {
|
|
846
|
-
return
|
|
849
|
+
return P(s(), t.class);
|
|
847
850
|
},
|
|
848
851
|
get children() {
|
|
849
|
-
return [
|
|
852
|
+
return [k(B, {
|
|
850
853
|
class: "flex flex-row items-center justify-between gap-3",
|
|
851
854
|
get children() {
|
|
852
855
|
return [(() => {
|
|
853
|
-
var
|
|
854
|
-
return
|
|
856
|
+
var c = pt();
|
|
857
|
+
return b(c, k(H, {
|
|
855
858
|
class: "truncate leading-tight",
|
|
856
859
|
get children() {
|
|
857
860
|
return t.title;
|
|
858
861
|
}
|
|
859
|
-
}), null),
|
|
862
|
+
}), null), b(c, k(a, {
|
|
860
863
|
class: "sr-only",
|
|
861
864
|
children: "Widget configuration dialog"
|
|
862
|
-
}), null),
|
|
865
|
+
}), null), c;
|
|
863
866
|
})(), (() => {
|
|
864
|
-
var
|
|
865
|
-
return
|
|
867
|
+
var c = xt(), F = c.firstChild;
|
|
868
|
+
return b(F, () => S().map((N) => k(kt, {
|
|
866
869
|
get icon() {
|
|
867
|
-
return
|
|
870
|
+
return N.icon;
|
|
868
871
|
},
|
|
869
872
|
get label() {
|
|
870
|
-
return
|
|
873
|
+
return N.label;
|
|
871
874
|
},
|
|
872
875
|
get isActive() {
|
|
873
|
-
return
|
|
876
|
+
return y() === N.id;
|
|
874
877
|
},
|
|
875
|
-
onClick: () =>
|
|
876
|
-
}))),
|
|
878
|
+
onClick: () => g(N.id)
|
|
879
|
+
}))), b(c, k(E, {
|
|
877
880
|
get when() {
|
|
878
881
|
return t.headerActions;
|
|
879
882
|
},
|
|
880
883
|
get children() {
|
|
881
884
|
return t.headerActions;
|
|
882
885
|
}
|
|
883
|
-
}), null),
|
|
886
|
+
}), null), c;
|
|
884
887
|
})()];
|
|
885
888
|
}
|
|
886
889
|
}), (() => {
|
|
887
|
-
var
|
|
888
|
-
return
|
|
889
|
-
})(),
|
|
890
|
+
var c = yt();
|
|
891
|
+
return b(c, M), c;
|
|
892
|
+
})(), k(E, {
|
|
890
893
|
get when() {
|
|
891
|
-
return
|
|
894
|
+
return T(() => y() === "edit")() && (D() || t.onDelete) || y() === "debug" && t.debugData !== void 0;
|
|
892
895
|
},
|
|
893
896
|
get children() {
|
|
894
|
-
var
|
|
895
|
-
return
|
|
897
|
+
var c = $t();
|
|
898
|
+
return b(c, k(E, {
|
|
896
899
|
get when() {
|
|
897
|
-
return
|
|
900
|
+
return T(() => y() === "edit")() && t.onDelete;
|
|
898
901
|
},
|
|
899
902
|
get children() {
|
|
900
|
-
return
|
|
903
|
+
return k(f, {
|
|
901
904
|
size: "sm",
|
|
902
905
|
variant: "destructive",
|
|
903
906
|
onClick: () => t.onDelete?.(),
|
|
904
907
|
children: "Delete"
|
|
905
908
|
});
|
|
906
909
|
}
|
|
907
|
-
}), null),
|
|
910
|
+
}), null), b(c, k(E, {
|
|
908
911
|
get when() {
|
|
909
|
-
return
|
|
912
|
+
return T(() => y() === "edit")() && D();
|
|
910
913
|
},
|
|
911
914
|
get children() {
|
|
912
|
-
return
|
|
915
|
+
return k(f, {
|
|
913
916
|
size: "sm",
|
|
914
917
|
get disabled() {
|
|
915
918
|
return !O();
|
|
916
919
|
},
|
|
917
|
-
onClick: () =>
|
|
920
|
+
onClick: () => D()?.(),
|
|
918
921
|
children: "Save"
|
|
919
922
|
});
|
|
920
923
|
}
|
|
921
|
-
}), null),
|
|
924
|
+
}), null), b(c, k(E, {
|
|
922
925
|
get when() {
|
|
923
|
-
return
|
|
926
|
+
return T(() => y() === "debug")() && t.debugData !== void 0;
|
|
924
927
|
},
|
|
925
928
|
get children() {
|
|
926
|
-
return
|
|
929
|
+
return k(f, {
|
|
927
930
|
size: "sm",
|
|
928
931
|
variant: "outline",
|
|
929
|
-
onClick:
|
|
932
|
+
onClick: w,
|
|
930
933
|
children: "Copy"
|
|
931
934
|
});
|
|
932
935
|
}
|
|
933
|
-
}), null),
|
|
936
|
+
}), null), c;
|
|
934
937
|
}
|
|
935
938
|
})];
|
|
936
939
|
}
|
|
@@ -938,157 +941,187 @@ function Pt(e) {
|
|
|
938
941
|
}
|
|
939
942
|
});
|
|
940
943
|
}
|
|
941
|
-
|
|
942
|
-
function
|
|
943
|
-
|
|
944
|
-
|
|
944
|
+
ye(["click"]);
|
|
945
|
+
function Gt(e) {
|
|
946
|
+
if (typeof IntersectionObserver > "u")
|
|
947
|
+
return () => !1;
|
|
948
|
+
const [t, i] = V(!1), r = new IntersectionObserver((n) => {
|
|
949
|
+
const o = n[0];
|
|
950
|
+
o && i(!o.isIntersecting);
|
|
951
|
+
});
|
|
952
|
+
return re(() => {
|
|
953
|
+
const n = e();
|
|
954
|
+
r.disconnect(), n && r.observe(n);
|
|
955
|
+
}), se(() => r.disconnect()), t;
|
|
956
|
+
}
|
|
957
|
+
function qt() {
|
|
958
|
+
if (typeof window > "u" || typeof window.matchMedia != "function")
|
|
959
|
+
return () => !1;
|
|
960
|
+
const e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, i] = V(e.matches), r = (n) => i(n.matches);
|
|
961
|
+
return e.addEventListener("change", r), se(() => e.removeEventListener("change", r)), t;
|
|
962
|
+
}
|
|
963
|
+
function Yt(e = "controls") {
|
|
964
|
+
const [t, i] = V(!1), [r, n] = V(e), o = (d) => {
|
|
965
|
+
n(d ?? e), i(!0);
|
|
966
|
+
}, u = ae(J);
|
|
967
|
+
return u?.registerDialogOpener?.(o), se(() => u?.registerDialogOpener?.(null)), {
|
|
945
968
|
showDialog: t,
|
|
946
969
|
setShowDialog: i,
|
|
947
|
-
openDialog:
|
|
970
|
+
openDialog: o,
|
|
948
971
|
closeDialog: () => i(!1),
|
|
949
972
|
activeTab: r,
|
|
950
|
-
setActiveTab: n
|
|
973
|
+
setActiveTab: n,
|
|
974
|
+
dialogProps: {
|
|
975
|
+
get open() {
|
|
976
|
+
return t();
|
|
977
|
+
},
|
|
978
|
+
onOpenChange: i,
|
|
979
|
+
get activeTab() {
|
|
980
|
+
return r();
|
|
981
|
+
},
|
|
982
|
+
onActiveTabChange: n
|
|
983
|
+
}
|
|
951
984
|
};
|
|
952
985
|
}
|
|
953
|
-
function
|
|
954
|
-
const t = e.minEntities ?? 1, i =
|
|
986
|
+
function Kt(e) {
|
|
987
|
+
const t = e.minEntities ?? 1, i = L(() => e.entities().length), r = L(() => i() >= t), n = L(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), o = L(() => {
|
|
955
988
|
if (!r()) return;
|
|
956
|
-
const
|
|
957
|
-
if (!
|
|
958
|
-
const
|
|
959
|
-
if (
|
|
960
|
-
return
|
|
961
|
-
if (
|
|
962
|
-
const
|
|
963
|
-
return
|
|
989
|
+
const d = e.aggregationMode?.();
|
|
990
|
+
if (!d || d === "none") return;
|
|
991
|
+
const $ = e.entities();
|
|
992
|
+
if (d === "light" || d === "binary-sensor" || d === "switch")
|
|
993
|
+
return Ke($, e.allEntitiesMode);
|
|
994
|
+
if (d === "sensor") {
|
|
995
|
+
const m = e.sensorGroupType?.() ?? "mean";
|
|
996
|
+
return Xe($, m, !0);
|
|
964
997
|
}
|
|
965
|
-
}),
|
|
998
|
+
}), u = L(() => r() ? void 0 : e.emptyStateConfig);
|
|
966
999
|
return {
|
|
967
1000
|
entities: e.entities,
|
|
968
1001
|
groupData: n,
|
|
969
|
-
aggregatedData:
|
|
970
|
-
emptyState:
|
|
1002
|
+
aggregatedData: o,
|
|
1003
|
+
emptyState: u,
|
|
971
1004
|
hasEntities: r,
|
|
972
1005
|
count: i
|
|
973
1006
|
};
|
|
974
1007
|
}
|
|
975
|
-
const
|
|
976
|
-
function
|
|
1008
|
+
const q = 32, l = q / 2, _ = "white", Q = "rgba(0,0,0,0.4)", le = 2, Z = 3;
|
|
1009
|
+
function Ct(e) {
|
|
977
1010
|
return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
|
|
978
1011
|
}
|
|
979
|
-
function
|
|
980
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
1012
|
+
function ee(e) {
|
|
1013
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${q}" height="${q}" viewBox="0 0 ${q} ${q}">${e}</svg>`;
|
|
981
1014
|
}
|
|
982
|
-
const
|
|
1015
|
+
const St = ee(`
|
|
983
1016
|
<g transform="translate(6, 2)">
|
|
984
1017
|
<!-- shadow -->
|
|
985
|
-
<g stroke="${
|
|
1018
|
+
<g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
986
1019
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
987
1020
|
</g>
|
|
988
1021
|
<!-- main -->
|
|
989
|
-
<g stroke="${
|
|
1022
|
+
<g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
990
1023
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
991
1024
|
</g>
|
|
992
1025
|
</g>
|
|
993
|
-
`),
|
|
1026
|
+
`), Mt = ee(`
|
|
994
1027
|
<g>
|
|
995
|
-
<circle cx="${
|
|
996
|
-
<circle cx="${
|
|
997
|
-
<circle cx="${
|
|
1028
|
+
<circle cx="${l}" cy="${l}" r="8" stroke="${Q}" stroke-width="${Z}" fill="none"/>
|
|
1029
|
+
<circle cx="${l}" cy="${l}" r="8" stroke="${_}" stroke-width="1.5" fill="none"/>
|
|
1030
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
998
1031
|
</g>
|
|
999
|
-
`),
|
|
1032
|
+
`), Dt = ee(`
|
|
1000
1033
|
<g>
|
|
1001
1034
|
<!-- shadow -->
|
|
1002
|
-
<g stroke="${
|
|
1003
|
-
<line x1="6" y1="${
|
|
1004
|
-
<polyline points="10,${
|
|
1005
|
-
<polyline points="22,${
|
|
1035
|
+
<g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1036
|
+
<line x1="6" y1="${l}" x2="26" y2="${l}"/>
|
|
1037
|
+
<polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
|
|
1038
|
+
<polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
|
|
1006
1039
|
</g>
|
|
1007
1040
|
<!-- main -->
|
|
1008
|
-
<g stroke="${
|
|
1009
|
-
<line x1="6" y1="${
|
|
1010
|
-
<polyline points="10,${
|
|
1011
|
-
<polyline points="22,${
|
|
1041
|
+
<g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1042
|
+
<line x1="6" y1="${l}" x2="26" y2="${l}"/>
|
|
1043
|
+
<polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
|
|
1044
|
+
<polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
|
|
1012
1045
|
</g>
|
|
1013
1046
|
<!-- center grip dots -->
|
|
1014
|
-
<circle cx="${
|
|
1015
|
-
<circle cx="${
|
|
1016
|
-
<circle cx="${
|
|
1047
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
1048
|
+
<circle cx="${l - 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
|
|
1049
|
+
<circle cx="${l + 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
|
|
1017
1050
|
</g>
|
|
1018
|
-
`),
|
|
1051
|
+
`), Tt = ee(`
|
|
1019
1052
|
<g>
|
|
1020
1053
|
<!-- shadow -->
|
|
1021
|
-
<g stroke="${
|
|
1022
|
-
<line x1="${
|
|
1023
|
-
<polyline points="${
|
|
1024
|
-
<polyline points="${
|
|
1054
|
+
<g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1055
|
+
<line x1="${l}" y1="6" x2="${l}" y2="26"/>
|
|
1056
|
+
<polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
|
|
1057
|
+
<polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
|
|
1025
1058
|
</g>
|
|
1026
1059
|
<!-- main -->
|
|
1027
|
-
<g stroke="${
|
|
1028
|
-
<line x1="${
|
|
1029
|
-
<polyline points="${
|
|
1030
|
-
<polyline points="${
|
|
1060
|
+
<g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1061
|
+
<line x1="${l}" y1="6" x2="${l}" y2="26"/>
|
|
1062
|
+
<polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
|
|
1063
|
+
<polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
|
|
1031
1064
|
</g>
|
|
1032
1065
|
<!-- center grip dots -->
|
|
1033
|
-
<circle cx="${
|
|
1034
|
-
<circle cx="${
|
|
1035
|
-
<circle cx="${
|
|
1066
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
1067
|
+
<circle cx="${l}" cy="${l - 5}" r="1" fill="${_}" opacity="0.6"/>
|
|
1068
|
+
<circle cx="${l}" cy="${l + 5}" r="1" fill="${_}" opacity="0.6"/>
|
|
1036
1069
|
</g>
|
|
1037
1070
|
`);
|
|
1038
|
-
function
|
|
1039
|
-
return { css: `${
|
|
1071
|
+
function K(e, t, i) {
|
|
1072
|
+
return { css: `${Ct(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
|
|
1040
1073
|
}
|
|
1041
|
-
const
|
|
1042
|
-
tap:
|
|
1043
|
-
hold:
|
|
1044
|
-
slideHorizontal:
|
|
1045
|
-
slideVertical:
|
|
1074
|
+
const j = {
|
|
1075
|
+
tap: K(St, 12, 4),
|
|
1076
|
+
hold: K(Mt, 16, 16),
|
|
1077
|
+
slideHorizontal: K(Dt, l, l),
|
|
1078
|
+
slideVertical: K(Tt, l, l)
|
|
1046
1079
|
};
|
|
1047
|
-
function
|
|
1080
|
+
function ne() {
|
|
1048
1081
|
if (typeof window > "u") return null;
|
|
1049
1082
|
const e = window;
|
|
1050
1083
|
return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
|
|
1051
1084
|
}
|
|
1052
|
-
function
|
|
1085
|
+
function ie(e) {
|
|
1053
1086
|
if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
|
|
1054
1087
|
try {
|
|
1055
1088
|
navigator.vibrate(e);
|
|
1056
1089
|
} catch {
|
|
1057
1090
|
}
|
|
1058
1091
|
}
|
|
1059
|
-
const
|
|
1092
|
+
const _t = {
|
|
1060
1093
|
/** Light confirmation — fires when slide gesture arms after user holds still. */
|
|
1061
1094
|
tick() {
|
|
1062
|
-
const e =
|
|
1095
|
+
const e = ne();
|
|
1063
1096
|
if (e) {
|
|
1064
1097
|
e.impact({ style: "Light" }).catch(() => {
|
|
1065
1098
|
});
|
|
1066
1099
|
return;
|
|
1067
1100
|
}
|
|
1068
|
-
|
|
1101
|
+
ie(8);
|
|
1069
1102
|
},
|
|
1070
1103
|
/** Medium bump — fires when hold gesture commits (detail opening). */
|
|
1071
1104
|
bump() {
|
|
1072
|
-
const e =
|
|
1105
|
+
const e = ne();
|
|
1073
1106
|
if (e) {
|
|
1074
1107
|
e.impact({ style: "Medium" }).catch(() => {
|
|
1075
1108
|
});
|
|
1076
1109
|
return;
|
|
1077
1110
|
}
|
|
1078
|
-
|
|
1111
|
+
ie(20);
|
|
1079
1112
|
},
|
|
1080
1113
|
/** Stronger pulse — reserved for edit-mode pickup (future use). */
|
|
1081
1114
|
pulse() {
|
|
1082
|
-
const e =
|
|
1115
|
+
const e = ne();
|
|
1083
1116
|
if (e) {
|
|
1084
1117
|
e.impact({ style: "Heavy" }).catch(() => {
|
|
1085
1118
|
});
|
|
1086
1119
|
return;
|
|
1087
1120
|
}
|
|
1088
|
-
|
|
1121
|
+
ie([0, 15, 40, 15]);
|
|
1089
1122
|
}
|
|
1090
1123
|
};
|
|
1091
|
-
function
|
|
1124
|
+
function Xt(e, t) {
|
|
1092
1125
|
const n = {
|
|
1093
1126
|
isDown: !1,
|
|
1094
1127
|
isTouch: !1,
|
|
@@ -1100,99 +1133,127 @@ function jt(e, t) {
|
|
|
1100
1133
|
holdTimer: null,
|
|
1101
1134
|
element: null
|
|
1102
1135
|
};
|
|
1103
|
-
let
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1136
|
+
let o = null, u = null, d = null;
|
|
1137
|
+
const [$, m] = V(null);
|
|
1138
|
+
function h(a) {
|
|
1139
|
+
a !== u && (d && d.disconnect(), d = new ResizeObserver((f) => {
|
|
1140
|
+
const p = f[0];
|
|
1141
|
+
if (p) {
|
|
1142
|
+
const C = p.borderBoxSize?.[0];
|
|
1143
|
+
C ? o = { width: C.inlineSize, height: C.blockSize } : o = { width: p.contentRect.width, height: p.contentRect.height }, m(o.height > o.width);
|
|
1110
1144
|
}
|
|
1111
|
-
}),
|
|
1145
|
+
}), u = a, d.observe(a), o = { width: a.clientWidth, height: a.clientHeight }, m(o.height > o.width));
|
|
1112
1146
|
}
|
|
1113
|
-
const
|
|
1147
|
+
const v = () => {
|
|
1114
1148
|
n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
|
|
1115
|
-
},
|
|
1149
|
+
}, y = () => {
|
|
1116
1150
|
n.isDown = !1, n.hasMoved = !1, n.sliding = !1;
|
|
1117
|
-
},
|
|
1118
|
-
const
|
|
1119
|
-
return
|
|
1120
|
-
},
|
|
1121
|
-
const
|
|
1122
|
-
if (!(!
|
|
1123
|
-
if (n.isDown = !0, n.isTouch =
|
|
1124
|
-
const
|
|
1151
|
+
}, g = (a) => {
|
|
1152
|
+
const p = e().slide;
|
|
1153
|
+
return p?.orientation === "horizontal" ? "horizontal" : p?.orientation === "vertical" ? "vertical" : a && (o || h(a), o) ? o.height > o.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
|
|
1154
|
+
}, s = (a) => {
|
|
1155
|
+
const f = e();
|
|
1156
|
+
if (!(!f.tap && !f.hold && !f.slide)) {
|
|
1157
|
+
if (n.isDown = !0, n.isTouch = a.pointerType === "touch", n.element = a.currentTarget, h(n.element), n.startX = a.clientX, n.startY = a.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, f.hold) {
|
|
1158
|
+
const p = f.hold.delay ?? 300;
|
|
1125
1159
|
n.holdTimer = setTimeout(() => {
|
|
1126
|
-
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (
|
|
1127
|
-
},
|
|
1160
|
+
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (_t.bump(), f.hold?.action(), n.isDown = !1);
|
|
1161
|
+
}, p);
|
|
1128
1162
|
}
|
|
1129
|
-
if (!n.isTouch &&
|
|
1163
|
+
if (!n.isTouch && f.slide)
|
|
1130
1164
|
try {
|
|
1131
|
-
|
|
1165
|
+
a.currentTarget.setPointerCapture(a.pointerId);
|
|
1132
1166
|
} catch {
|
|
1133
1167
|
}
|
|
1134
1168
|
}
|
|
1135
|
-
},
|
|
1169
|
+
}, S = (a) => {
|
|
1136
1170
|
if (!n.isDown) return;
|
|
1137
|
-
const
|
|
1138
|
-
if (Math.sqrt(
|
|
1139
|
-
const
|
|
1171
|
+
const f = e(), p = a.clientX - n.startX, C = a.clientY - n.startY;
|
|
1172
|
+
if (Math.sqrt(p * p + C * C) > 10 && (v(), n.hasMoved = !0), f.slide && n.hasMoved) {
|
|
1173
|
+
const D = a.currentTarget, c = g(D);
|
|
1174
|
+
if (n.isTouch && !n.sliding) {
|
|
1175
|
+
const be = Math.abs(c === "vertical" ? C : p), pe = Math.abs(c === "vertical" ? p : C);
|
|
1176
|
+
if (be < pe) return;
|
|
1177
|
+
}
|
|
1140
1178
|
n.sliding = !0;
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1179
|
+
const F = f.slide.min ?? 0, N = f.slide.max ?? 100, he = N - F, fe = c === "vertical" ? -C : p, ce = o ?? { width: D.clientWidth, height: D.clientHeight }, me = c === "vertical" ? ce.height : ce.width, ve = fe / me * he, we = Math.max(F, Math.min(N, f.slide.value + ve));
|
|
1180
|
+
f.slide.onChange(Math.round(we)), n.startX = a.clientX, n.startY = a.clientY, a.preventDefault();
|
|
1143
1181
|
}
|
|
1144
|
-
},
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1182
|
+
}, w = (a) => {
|
|
1183
|
+
const f = e(), p = n.isDown, C = Date.now() - n.startTime, O = f.hold?.delay ?? 300;
|
|
1184
|
+
v(), p && f.tap && !n.hasMoved && C < O && f.tap();
|
|
1147
1185
|
try {
|
|
1148
|
-
|
|
1186
|
+
a.currentTarget.releasePointerCapture(a.pointerId);
|
|
1149
1187
|
} catch {
|
|
1150
1188
|
}
|
|
1151
|
-
m();
|
|
1152
|
-
}, k = (c) => {
|
|
1153
1189
|
y();
|
|
1190
|
+
}, M = (a) => {
|
|
1191
|
+
v();
|
|
1154
1192
|
try {
|
|
1155
|
-
|
|
1193
|
+
a.currentTarget.releasePointerCapture(a.pointerId);
|
|
1156
1194
|
} catch {
|
|
1157
1195
|
}
|
|
1158
|
-
|
|
1159
|
-
},
|
|
1160
|
-
const
|
|
1161
|
-
if (
|
|
1162
|
-
const
|
|
1163
|
-
return
|
|
1196
|
+
y();
|
|
1197
|
+
}, z = (a) => {
|
|
1198
|
+
const f = e();
|
|
1199
|
+
if (f.slide) {
|
|
1200
|
+
const p = f.slide.orientation;
|
|
1201
|
+
return p === "horizontal" ? j.slideHorizontal.css : p === "vertical" ? j.slideVertical.css : (o || h(a), o && o.height > o.width ? j.slideVertical.css : j.slideHorizontal.css);
|
|
1164
1202
|
}
|
|
1165
|
-
return
|
|
1203
|
+
return f.tap ? j.tap.css : f.hold ? j.hold.css : "";
|
|
1166
1204
|
};
|
|
1167
1205
|
return {
|
|
1168
|
-
onPointerDown:
|
|
1169
|
-
onPointerMove:
|
|
1170
|
-
onPointerUp:
|
|
1171
|
-
onPointerCancel:
|
|
1172
|
-
onPointerEnter: (
|
|
1173
|
-
const
|
|
1174
|
-
n.element =
|
|
1206
|
+
onPointerDown: s,
|
|
1207
|
+
onPointerMove: S,
|
|
1208
|
+
onPointerUp: w,
|
|
1209
|
+
onPointerCancel: M,
|
|
1210
|
+
onPointerEnter: (a) => {
|
|
1211
|
+
const f = a.currentTarget;
|
|
1212
|
+
n.element = f, f.style.cursor = z(f);
|
|
1175
1213
|
},
|
|
1176
|
-
bindElement: (
|
|
1177
|
-
|
|
1214
|
+
bindElement: (a) => {
|
|
1215
|
+
a && (n.element = a, h(a));
|
|
1178
1216
|
},
|
|
1179
1217
|
touchAction: () => {
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1218
|
+
const a = e();
|
|
1219
|
+
if (a.slide) {
|
|
1220
|
+
const f = a.slide.orientation;
|
|
1221
|
+
return f === "vertical" || f !== "horizontal" && ($() ?? (t?.() ?? "horizontal") !== "horizontal") ? "pan-x" : "pan-y";
|
|
1222
|
+
}
|
|
1223
|
+
return a.tap || a.hold ? "manipulation" : "auto";
|
|
1182
1224
|
},
|
|
1183
1225
|
dispose: () => {
|
|
1184
|
-
|
|
1226
|
+
v(), d && (d.disconnect(), d = null), u = null, o = null;
|
|
1185
1227
|
}
|
|
1186
1228
|
};
|
|
1187
1229
|
}
|
|
1188
|
-
const
|
|
1230
|
+
const zt = {
|
|
1231
|
+
solar: "oklch(0.74 0.18 60)",
|
|
1232
|
+
grid: "oklch(0.62 0.12 245)",
|
|
1233
|
+
battery: "oklch(0.70 0.18 145)",
|
|
1234
|
+
ev: "oklch(0.70 0.14 190)",
|
|
1235
|
+
home: "oklch(0.68 0.06 250)",
|
|
1236
|
+
positive: "oklch(0.70 0.14 160)",
|
|
1237
|
+
// Fault red-orange; used only for faults, never normal consumption.
|
|
1238
|
+
negative: "oklch(0.64 0.22 27)"
|
|
1239
|
+
};
|
|
1240
|
+
function Ot(e) {
|
|
1241
|
+
return {
|
|
1242
|
+
fill: `color-mix(in oklch, ${e} 20%, transparent)`,
|
|
1243
|
+
stroke: e,
|
|
1244
|
+
solid: e
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
const Jt = Object.fromEntries(
|
|
1248
|
+
Object.entries(zt).map(([e, t]) => [e, Ot(t)])
|
|
1249
|
+
), Qt = A.enum([
|
|
1189
1250
|
"success",
|
|
1190
1251
|
"warning",
|
|
1191
1252
|
"danger",
|
|
1192
1253
|
"info",
|
|
1193
1254
|
"neutral",
|
|
1194
1255
|
"accent"
|
|
1195
|
-
]),
|
|
1256
|
+
]), Zt = {
|
|
1196
1257
|
/** Optional display name override (renders as text input) */
|
|
1197
1258
|
title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
|
|
1198
1259
|
/** Multi-select entity picker for a HA domain */
|
|
@@ -1202,37 +1263,68 @@ const Bt = A.enum([
|
|
|
1202
1263
|
/** Area picker dropdown */
|
|
1203
1264
|
areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
|
|
1204
1265
|
};
|
|
1205
|
-
function
|
|
1266
|
+
function en(e) {
|
|
1267
|
+
if (e.length < 2) return "";
|
|
1268
|
+
const t = e[0], i = e[1];
|
|
1269
|
+
if (!t || !i) return "";
|
|
1270
|
+
if (e.length === 2) return `M ${t.x} ${t.y} L ${i.x} ${i.y}`;
|
|
1271
|
+
const r = e.length, n = [], o = [], u = [];
|
|
1272
|
+
for (let m = 0; m < r - 1; m++) {
|
|
1273
|
+
const h = e[m], v = e[m + 1];
|
|
1274
|
+
!h || !v || (n.push(v.x - h.x), o.push(v.y - h.y), u.push((v.y - h.y) / (v.x - h.x)));
|
|
1275
|
+
}
|
|
1276
|
+
const d = [u[0] ?? 0];
|
|
1277
|
+
for (let m = 1; m < r - 1; m++) {
|
|
1278
|
+
const h = u[m - 1] ?? 0, v = u[m] ?? 0, y = n[m - 1] ?? 0, g = n[m] ?? 0;
|
|
1279
|
+
h * v <= 0 ? d.push(0) : d.push(
|
|
1280
|
+
3 * (y + g) / ((2 * g + y) / h + (g + 2 * y) / v)
|
|
1281
|
+
);
|
|
1282
|
+
}
|
|
1283
|
+
d.push(u[r - 2] ?? 0);
|
|
1284
|
+
let $ = `M ${t.x} ${t.y}`;
|
|
1285
|
+
for (let m = 0; m < r - 1; m++) {
|
|
1286
|
+
const h = e[m], v = e[m + 1];
|
|
1287
|
+
if (!h || !v) continue;
|
|
1288
|
+
const y = (n[m] ?? 0) / 3, g = d[m] ?? 0, s = d[m + 1] ?? 0;
|
|
1289
|
+
$ += ` C ${h.x + y} ${h.y + g * y}, ${v.x - y} ${v.y - s * y}, ${v.x} ${v.y}`;
|
|
1290
|
+
}
|
|
1291
|
+
return $;
|
|
1292
|
+
}
|
|
1293
|
+
function tn() {
|
|
1206
1294
|
return document.documentElement.classList.contains("dark");
|
|
1207
1295
|
}
|
|
1208
|
-
const
|
|
1209
|
-
version:
|
|
1210
|
-
},
|
|
1296
|
+
const Et = "0.5.2", Nt = {
|
|
1297
|
+
version: Et
|
|
1298
|
+
}, nn = Nt.version;
|
|
1211
1299
|
export {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1300
|
+
nn as SDK_VERSION,
|
|
1301
|
+
Qt as ToneSchema,
|
|
1302
|
+
U as Widget,
|
|
1303
|
+
Re as WidgetContent,
|
|
1304
|
+
J as WidgetCtx,
|
|
1305
|
+
Ft as WidgetDialog,
|
|
1306
|
+
Be as WidgetIcon,
|
|
1307
|
+
an as WidgetManifestSchema,
|
|
1308
|
+
Pe as WidgetSliderFill,
|
|
1309
|
+
Fe as WidgetStatus,
|
|
1310
|
+
Ye as WidgetTitle,
|
|
1311
|
+
nt as WidgetValue,
|
|
1312
|
+
Ke as calculateLightGroup,
|
|
1313
|
+
Xe as calculateSensorGroup,
|
|
1314
|
+
Ut as countActiveEntities,
|
|
1315
|
+
jt as defineWidget,
|
|
1316
|
+
sn as formatSchemaError,
|
|
1317
|
+
Bt as getEntityAttribute,
|
|
1318
|
+
ze as injectTokens,
|
|
1319
|
+
tn as isDark,
|
|
1320
|
+
Je as isEntityActive,
|
|
1321
|
+
en as monotoneCubicPath,
|
|
1322
|
+
Jt as svgColors,
|
|
1323
|
+
Gt as useIntersectionPause,
|
|
1324
|
+
qt as useReducedMotion,
|
|
1325
|
+
Lt as useWidgetContext,
|
|
1326
|
+
Yt as useWidgetDialog,
|
|
1327
|
+
Kt as useWidgetEntityGroup,
|
|
1328
|
+
Xt as useWidgetGestures,
|
|
1329
|
+
Zt as widgetFields
|
|
1238
1330
|
};
|