@glasshome/widget-sdk 0.5.0 → 0.5.1

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