@glasshome/widget-sdk 0.5.1 → 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/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { z as A } from "zod";
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) {
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 de(e) {
13
13
  }
14
14
  });
15
15
  }
16
- function Ce(e) {
16
+ function Te(e) {
17
17
  try {
18
18
  return e.parse({});
19
19
  } catch {
20
20
  return {};
21
21
  }
22
22
  }
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;
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 G = {
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
- }, ne = pe();
36
- function Ht() {
37
- const e = le(ne);
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 Se = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
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 Se = `/* Authoritative SDK CSS contract. Injected once on first Widget mou
211
211
  }
212
212
  }
213
213
  `;
214
- let Q = !1;
215
- function Me(e) {
216
- if (Q) return;
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
- Q = !0;
220
+ te = !0;
221
221
  return;
222
222
  }
223
223
  const i = t.createElement("style");
224
- i.setAttribute("data-glasshome-tokens", ""), i.textContent = Se, t.head.appendChild(i), Q = !0;
224
+ i.setAttribute("data-glasshome-tokens", ""), i.textContent = _e, t.head.appendChild(i), te = !0;
225
225
  }
226
226
  function P(...e) {
227
- return ke($e(e));
227
+ return De(Me(e));
228
228
  }
229
- const De = {
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 De = {
254
254
  hoverScale: 1.02,
255
255
  activeScale: 0.98
256
256
  }
257
- }, _e = {
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 De = {
283
283
  active: !1,
284
284
  focus: !0
285
285
  }
286
- }, ze = {
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 De = {
311
311
  hoverScale: 1.02,
312
312
  activeScale: 0.98
313
313
  }
314
- }, Te = {
315
- "classic-glass": De,
316
- minimal: _e,
317
- "compact-horizontal": ze
314
+ }, Ae = {
315
+ "classic-glass": Oe,
316
+ minimal: Ee,
317
+ "compact-horizontal": Ne
318
318
  };
319
- function Ee(e) {
320
- return Te[e];
319
+ function Ve(e) {
320
+ return Ae[e];
321
321
  }
322
- var Oe = /* @__PURE__ */ x("<div>");
323
- function Ne(e) {
322
+ var We = /* @__PURE__ */ x("<div>");
323
+ function Pe(e) {
324
324
  return (() => {
325
- var t = Oe();
325
+ var t = We();
326
326
  return W((i) => {
327
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": G.BACKGROUND,
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 && R(t, i.e = r), i.t = ie(t, n, i.t), i;
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 Ve = /* @__PURE__ */ x("<div>");
342
- function Ae(e) {
341
+ var He = /* @__PURE__ */ x("<div>");
342
+ function Re(e) {
343
343
  return (() => {
344
- var t = Ve();
345
- return p(t, () => e.children), W(() => R(t, P("glasshome-widget-content", e.class))), t;
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 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) {
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 = He(), r = i.firstChild;
353
- return p(i, $(E, {
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 We();
358
+ return Ie();
359
359
  }
360
- }), r), p(i, $(E, {
360
+ }), r), b(i, k(E, {
361
361
  get when() {
362
362
  return t() >= 3;
363
363
  },
364
364
  get children() {
365
- return Pe();
365
+ return je();
366
366
  }
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 ? {
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 o !== n.e && R(i, n.e = o), n.t = ie(i, h, n.t), n;
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 Ie = /* @__PURE__ */ x("<p>");
379
- function je(e) {
378
+ var Ue = /* @__PURE__ */ x("<p>");
379
+ function Fe(e) {
380
380
  return (() => {
381
- var t = Ie();
382
- return p(t, (() => {
383
- var i = _(() => !!e.isUnavailable);
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 = 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;
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 Le = /* @__PURE__ */ x('<span class="glasshome-widget-badge shrink-0">'), Be = /* @__PURE__ */ x("<div><h3 class=glasshome-widget-title>");
395
- function Ue(e) {
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 = Be(), i = t.firstChild;
398
- return p(i, () => e.children), p(t, $(E, {
397
+ var t = qe(), i = t.firstChild;
398
+ return b(i, () => e.children), b(t, k(E, {
399
399
  get when() {
400
- return _(() => e.badge !== void 0)() && e.badge > 0;
400
+ return T(() => e.badge !== void 0)() && e.badge > 0;
401
401
  },
402
402
  get children() {
403
- var r = Le();
404
- return p(r, () => e.badge), r;
403
+ var r = Ge();
404
+ return b(r, () => e.badge), r;
405
405
  }
406
406
  }), null), W((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;
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 Fe(e, t = !1) {
415
+ function Ke(e, t = !1) {
416
416
  if (e.length === 0)
417
417
  return {
418
418
  isGroup: !1,
@@ -428,26 +428,26 @@ function Fe(e, t = !1) {
428
428
  };
429
429
  const i = e.length > 1;
430
430
  if (!i) {
431
- const b = e[0], M = b.state === "on", N = b.attributes?.brightness || 0, D = Math.round(N / 255 * 100);
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: 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,
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: M ? "On" : "Off"
442
+ description: f ? "On" : "Off"
443
443
  };
444
444
  }
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) {
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++, b.attributes?.brightness !== void 0 && (g += b.attributes.brightness, y++), b.attributes?.rgb_color && f.push(b.attributes.rgb_color);
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++;
@@ -456,34 +456,34 @@ function Fe(e, t = !1) {
456
456
  o++;
457
457
  break;
458
458
  case "unavailable":
459
- h++;
459
+ u++;
460
460
  break;
461
461
  }
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)})`;
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
- 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", {
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
475
  state: w,
476
- isOn: S,
476
+ isOn: M,
477
477
  isUnavailable: w === "unavailable",
478
- brightness: O,
478
+ brightness: z,
479
479
  brightnessPercent: I,
480
- color: u,
480
+ color: B,
481
481
  onCount: r,
482
- totalCount: c,
483
- description: m
482
+ totalCount: h,
483
+ description: H
484
484
  };
485
485
  }
486
- function Ge(e, t = "mean", i = !0) {
486
+ function Xe(e, t = "mean", i = !0) {
487
487
  if (e.length === 0)
488
488
  return {
489
489
  isGroup: !1,
@@ -494,98 +494,98 @@ function Ge(e, t = "mean", i = !0) {
494
494
  };
495
495
  const r = e.length > 1;
496
496
  if (!r) {
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)), {
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: C,
502
- numericValue: Number.isNaN(a) ? null : a,
503
- isUnavailable: d.state === "unavailable",
504
- unit: d.unitOfMeasurement ?? void 0,
505
- description: C
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
508
  const n = [], o = [];
509
- let h = 0, g;
510
- for (const d of e) {
511
- if (!g && d.unitOfMeasurement && (g = d.unitOfMeasurement), d.state === "unavailable") {
512
- h++, o.push({
513
- entityId: d.id,
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: d.friendlyName
515
+ friendly_name: g.friendlyName
516
516
  });
517
517
  continue;
518
518
  }
519
- const a = Number.parseFloat(d.state);
520
- isNaN(a) ? i || o.push({
521
- entityId: d.id,
522
- value: d.state,
523
- friendly_name: d.friendlyName
524
- }) : (n.push(a), o.push({
525
- entityId: d.id,
526
- value: a,
527
- friendly_name: d.friendlyName
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 y = h === e.length, f = n.length === 0;
531
- if (y || f)
530
+ const $ = u === e.length, m = n.length === 0;
531
+ if ($ || m)
532
532
  return {
533
533
  isGroup: r,
534
- state: y ? "unavailable" : "unknown",
534
+ state: $ ? "unavailable" : "unknown",
535
535
  numericValue: null,
536
- isUnavailable: y,
537
- unit: g,
538
- description: y ? "Unavailable" : "No numeric values",
536
+ isUnavailable: $,
537
+ unit: d,
538
+ description: $ ? "Unavailable" : "No numeric values",
539
539
  memberValues: o
540
540
  };
541
- let c, v;
541
+ let h, v;
542
542
  switch (t) {
543
543
  case "min":
544
- c = Math.min(...n), v = "Minimum";
544
+ h = Math.min(...n), v = "Minimum";
545
545
  break;
546
546
  case "max":
547
- c = Math.max(...n), v = "Maximum";
547
+ h = Math.max(...n), v = "Maximum";
548
548
  break;
549
549
  case "mean":
550
- c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
550
+ h = n.reduce((g, s) => g + s, 0) / n.length, v = "Average";
551
551
  break;
552
552
  case "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";
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
- c = n.reduce((d, a) => d + a, 0), v = "Sum";
558
+ h = n.reduce((g, s) => g + s, 0), v = "Sum";
559
559
  break;
560
560
  case "last":
561
- c = n[n.length - 1], v = "Latest";
561
+ h = n[n.length - 1], v = "Latest";
562
562
  break;
563
563
  case "range":
564
- c = Math.max(...n) - Math.min(...n), v = "Range";
564
+ h = Math.max(...n) - Math.min(...n), v = "Range";
565
565
  break;
566
566
  case "product":
567
- c = n.reduce((d, a) => d * a, 1), v = "Product";
567
+ h = n.reduce((g, s) => g * s, 1), v = "Product";
568
568
  break;
569
569
  case "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";
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
- c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
575
+ h = n.reduce((g, s) => g + s, 0) / n.length, v = "Average";
576
576
  }
577
- const k = Number.isInteger(c) ? c.toString() : c.toFixed(1);
577
+ const y = Number.isInteger(h) ? h.toString() : h.toFixed(1);
578
578
  return {
579
579
  isGroup: r,
580
- state: k,
581
- numericValue: c,
580
+ state: y,
581
+ numericValue: h,
582
582
  isUnavailable: !1,
583
- unit: g,
583
+ unit: d,
584
584
  description: `${v} of ${n.length}`,
585
585
  memberValues: o
586
586
  };
587
587
  }
588
- function se(e) {
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) {
@@ -594,12 +594,12 @@ function se(e) {
594
594
  }
595
595
  if (e.attributes?.color_temp) {
596
596
  const n = 1e6 / e.attributes.color_temp / 100;
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)})`;
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 qe(e) {
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 qe(e) {
609
609
  }
610
610
  return !1;
611
611
  }
612
- function Rt(e, t, i) {
612
+ function Bt(e, t, i) {
613
613
  return e?.attributes ? e.attributes[t] ?? i : i;
614
614
  }
615
- function It(e) {
616
- return e.filter(qe).length;
615
+ function Ut(e) {
616
+ return e.filter(Je).length;
617
617
  }
618
- function Ye(e, t, i) {
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 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;
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 Ke(e, t) {
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 Xe = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), Je = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
633
- function Qe(e) {
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 = Je(), i = t.firstChild;
636
- return p(i, () => Ye(e.value, e.unit)), p(t, $(E, {
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 _(() => !!e.interpret)() && typeof e.value == "number";
638
+ return T(() => !!e.interpret)() && typeof e.value == "number";
639
639
  },
640
640
  get children() {
641
- var r = Xe();
642
- return p(r, () => Ke(e.value, e.unit)), r;
641
+ var r = et();
642
+ return b(r, () => Ze(e.value, e.unit)), r;
643
643
  }
644
644
  }), null), W(() => R(t, P("flex flex-col", e.class))), t;
645
645
  })();
646
646
  }
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();
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 = le(ne), [i, r] = H(), n = be(i), o = {
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
- }, h = L(() => {
661
+ }, u = L(() => {
661
662
  if (e.variant)
662
- return typeof e.variant == "string" ? Ee(e.variant) : e.variant;
663
- }), g = L(() => ({
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
- ...h()?.styles?.container,
668
- ...h()?.styles?.cssVars || {},
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 ot(e) {
678
679
  ...e.gradient ? {
679
680
  "--widget-gradient": e.gradient
680
681
  } : {}
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);
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 $(ne.Provider, {
693
+ return k(J.Provider, {
693
694
  value: o,
694
695
  get children() {
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) => {
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) => {
697
698
  r(w), e.gestures?.bindElement(w);
698
- }, a), p(C, (() => {
699
- var w = _(() => !!e.emptyState);
700
- return () => w() ? $(at, {
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 ot(e) {
708
709
  return e.emptyState.message;
709
710
  }
710
711
  }) : e.children;
711
- })()), p(a, (() => {
712
- var w = _(() => !!e.loading);
712
+ })()), b(s, (() => {
713
+ var w = T(() => !!e.loading);
713
714
  return () => w() && (() => {
714
- var S = et();
715
- return W((O) => Y(S, "z-index", G.OVERLAY)), S;
715
+ var M = rt();
716
+ return W((z) => X(M, "z-index", Y.OVERLAY)), M;
716
717
  })();
717
718
  })(), 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;
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
- }), a;
725
+ }), s;
725
726
  }
726
727
  });
727
728
  }
728
- function at(e) {
729
+ function dt(e) {
729
730
  return (() => {
730
- var t = tt();
731
- return p(t, (() => {
732
- var i = _(() => !!e.icon);
731
+ var t = ot();
732
+ return b(t, (() => {
733
+ var i = T(() => !!e.icon);
733
734
  return () => i() && (() => {
734
- var r = nt();
735
- return p(r, () => e.icon), r;
735
+ var r = at();
736
+ return b(r, () => e.icon), r;
736
737
  })();
737
- })(), null), p(t, (() => {
738
- var i = _(() => !!e.title);
738
+ })(), null), b(t, (() => {
739
+ var i = T(() => !!e.title);
739
740
  return () => i() && (() => {
740
- var r = it();
741
- return p(r, () => e.title), r;
741
+ var r = st();
742
+ return b(r, () => e.title), r;
742
743
  })();
743
- })(), null), p(t, (() => {
744
- var i = _(() => !!e.message);
744
+ })(), null), b(t, (() => {
745
+ var i = T(() => !!e.message);
745
746
  return () => i() && (() => {
746
- var r = rt();
747
- return p(r, () => e.message), r;
747
+ var r = lt();
748
+ return b(r, () => e.message), r;
748
749
  })();
749
750
  })(), null), t;
750
751
  })();
751
752
  }
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) {
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 = lt();
763
- return t.$$click = () => e.onClick(), p(t, $(E, {
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 = st();
769
- return p(i, () => e.icon), i;
769
+ var i = ut();
770
+ return b(i, () => e.icon), i;
770
771
  }
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
+ }), 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 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
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
- })), te(ae(() => t.configSchema, (l) => {
781
- l && h(de(l));
781
+ })), re(de(() => t.configSchema, (c) => {
782
+ c && u(ge(c));
782
783
  }));
783
- const g = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), y = (l) => {
784
- !l && t.config && n({
784
+ const d = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), $ = (c) => {
785
+ !c && t.config && n({
785
786
  ...t.config
786
- }), t.onOpenChange(l);
787
- }, f = () => {
787
+ }), t.onOpenChange(c);
788
+ }, m = () => {
788
789
  t.onConfigSave?.(r());
789
- }, [c, v] = H(t.defaultTab ?? "controls"), k = () => {
790
- const l = t.maxWidth ?? "3xl";
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,15 +799,15 @@ function jt(e) {
796
799
  "2xl": "max-w-2xl",
797
800
  "3xl": "max-w-3xl",
798
801
  "4xl": "max-w-4xl"
799
- }[l];
800
- }, d = () => {
802
+ }[c];
803
+ }, S = () => {
801
804
  if (t.tabs) return t.tabs;
802
- const l = [];
803
- return l.push({
805
+ const c = [];
806
+ return c.push({
804
807
  id: "edit",
805
808
  label: "Edit",
806
- icon: ct(),
807
- content: t.editContent ?? (i() && o() ? $(b, {
809
+ icon: ht(),
810
+ content: t.editContent ?? (i() && o() ? k(p, {
808
811
  get schema() {
809
812
  return o();
810
813
  },
@@ -812,125 +815,125 @@ function jt(e) {
812
815
  return r();
813
816
  },
814
817
  onChange: n
815
- }) : dt())
816
- }), l.push({
818
+ }) : ft())
819
+ }), c.push({
817
820
  id: "controls",
818
821
  label: "Controls",
819
- icon: ut(),
820
- content: t.controlsContent ?? gt()
821
- }), l.push({
822
+ icon: mt(),
823
+ content: t.controlsContent ?? vt()
824
+ }), c.push({
822
825
  id: "debug",
823
826
  label: "Debug",
824
- icon: ht(),
825
- content: t.debugContent ?? ft()
826
- }), l;
827
- }, a = async () => {
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 l = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
831
- await navigator.clipboard.writeText(l);
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
- }, 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, {
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: (l) => M(l),
845
+ onOpenChange: (c) => C(c),
843
846
  get children() {
844
- return $(S, {
847
+ return k(I, {
845
848
  get class() {
846
- return P(k(), t.class);
849
+ return P(s(), t.class);
847
850
  },
848
851
  get children() {
849
- return [$(O, {
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 l = mt();
854
- return p(l, $(I, {
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), p(l, $(u, {
862
+ }), null), b(c, k(a, {
860
863
  class: "sr-only",
861
864
  children: "Widget configuration dialog"
862
- }), null), l;
865
+ }), null), c;
863
866
  })(), (() => {
864
- var l = vt(), z = l.firstChild;
865
- return p(z, () => d().map((V) => $(pt, {
867
+ var c = xt(), F = c.firstChild;
868
+ return b(F, () => S().map((N) => k(kt, {
866
869
  get icon() {
867
- return V.icon;
870
+ return N.icon;
868
871
  },
869
872
  get label() {
870
- return V.label;
873
+ return N.label;
871
874
  },
872
875
  get isActive() {
873
- return c() === V.id;
876
+ return y() === N.id;
874
877
  },
875
- onClick: () => v(V.id)
876
- }))), p(l, $(E, {
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), l;
886
+ }), null), c;
884
887
  })()];
885
888
  }
886
889
  }), (() => {
887
- var l = wt();
888
- return p(l, C), l;
889
- })(), $(E, {
890
+ var c = yt();
891
+ return b(c, M), c;
892
+ })(), k(E, {
890
893
  get when() {
891
- return _(() => c() === "edit")() && (D() || t.onDelete) || c() === "debug" && t.debugData !== void 0;
894
+ return T(() => y() === "edit")() && (D() || t.onDelete) || y() === "debug" && t.debugData !== void 0;
892
895
  },
893
896
  get children() {
894
- var l = bt();
895
- return p(l, $(E, {
897
+ var c = $t();
898
+ return b(c, k(E, {
896
899
  get when() {
897
- return _(() => c() === "edit")() && t.onDelete;
900
+ return T(() => y() === "edit")() && t.onDelete;
898
901
  },
899
902
  get children() {
900
- return $(m, {
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), p(l, $(E, {
910
+ }), null), b(c, k(E, {
908
911
  get when() {
909
- return _(() => c() === "edit")() && D();
912
+ return T(() => y() === "edit")() && D();
910
913
  },
911
914
  get children() {
912
- return $(m, {
915
+ return k(f, {
913
916
  size: "sm",
914
917
  get disabled() {
915
- return !N();
918
+ return !O();
916
919
  },
917
920
  onClick: () => D()?.(),
918
921
  children: "Save"
919
922
  });
920
923
  }
921
- }), null), p(l, $(E, {
924
+ }), null), b(c, k(E, {
922
925
  get when() {
923
- return _(() => c() === "debug")() && t.debugData !== void 0;
926
+ return T(() => y() === "debug")() && t.debugData !== void 0;
924
927
  },
925
928
  get children() {
926
- return $(m, {
929
+ return k(f, {
927
930
  size: "sm",
928
931
  variant: "outline",
929
- onClick: a,
932
+ onClick: w,
930
933
  children: "Copy"
931
934
  });
932
935
  }
933
- }), null), l;
936
+ }), null), c;
934
937
  }
935
938
  })];
936
939
  }
@@ -938,175 +941,187 @@ function jt(e) {
938
941
  }
939
942
  });
940
943
  }
941
- we(["click"]);
942
- function Lt(e) {
944
+ ye(["click"]);
945
+ function Gt(e) {
943
946
  if (typeof IntersectionObserver > "u")
944
947
  return () => !1;
945
- const [t, i] = H(!1), r = new IntersectionObserver((n) => {
948
+ const [t, i] = V(!1), r = new IntersectionObserver((n) => {
946
949
  const o = n[0];
947
950
  o && i(!o.isIntersecting);
948
951
  });
949
- return te(() => {
952
+ return re(() => {
950
953
  const n = e();
951
954
  r.disconnect(), n && r.observe(n);
952
- }), ce(() => r.disconnect()), t;
955
+ }), se(() => r.disconnect()), t;
953
956
  }
954
- function Bt() {
957
+ function qt() {
955
958
  if (typeof window > "u" || typeof window.matchMedia != "function")
956
959
  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;
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;
959
962
  }
960
- function Ut(e = "edit") {
961
- const [t, i] = H(!1), [r, n] = H(e);
962
- return {
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)), {
963
968
  showDialog: t,
964
969
  setShowDialog: i,
965
- openDialog: () => i(!0),
970
+ openDialog: o,
966
971
  closeDialog: () => i(!1),
967
972
  activeTab: r,
968
- 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
+ }
969
984
  };
970
985
  }
971
- function Ft(e) {
986
+ function Kt(e) {
972
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(() => {
973
988
  if (!r()) return;
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);
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);
982
997
  }
983
- }), h = L(() => r() ? void 0 : e.emptyStateConfig);
998
+ }), u = L(() => r() ? void 0 : e.emptyStateConfig);
984
999
  return {
985
1000
  entities: e.entities,
986
1001
  groupData: n,
987
1002
  aggregatedData: o,
988
- emptyState: h,
1003
+ emptyState: u,
989
1004
  hasEntities: r,
990
1005
  count: i
991
1006
  };
992
1007
  }
993
- const F = 32, s = F / 2, T = "white", K = "rgba(0,0,0,0.4)", re = 2, X = 3;
994
- function xt(e) {
1008
+ const q = 32, l = q / 2, _ = "white", Q = "rgba(0,0,0,0.4)", le = 2, Z = 3;
1009
+ function Ct(e) {
995
1010
  return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
996
1011
  }
997
- function J(e) {
998
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${F}" height="${F}" viewBox="0 0 ${F} ${F}">${e}</svg>`;
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>`;
999
1014
  }
1000
- const yt = J(`
1015
+ const St = ee(`
1001
1016
  <g transform="translate(6, 2)">
1002
1017
  <!-- shadow -->
1003
- <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1018
+ <g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1004
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"/>
1005
1020
  </g>
1006
1021
  <!-- main -->
1007
- <g stroke="${T}" stroke-width="${re}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1022
+ <g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1008
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"/>
1009
1024
  </g>
1010
1025
  </g>
1011
- `), $t = J(`
1026
+ `), Mt = ee(`
1012
1027
  <g>
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}"/>
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="${_}"/>
1016
1031
  </g>
1017
- `), kt = J(`
1032
+ `), Dt = ee(`
1018
1033
  <g>
1019
1034
  <!-- shadow -->
1020
- <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
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}"/>
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}"/>
1024
1039
  </g>
1025
1040
  <!-- main -->
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}"/>
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}"/>
1030
1045
  </g>
1031
1046
  <!-- center grip dots -->
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"/>
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"/>
1035
1050
  </g>
1036
- `), Ct = J(`
1051
+ `), Tt = ee(`
1037
1052
  <g>
1038
1053
  <!-- shadow -->
1039
- <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
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"/>
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"/>
1043
1058
  </g>
1044
1059
  <!-- main -->
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"/>
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"/>
1049
1064
  </g>
1050
1065
  <!-- center grip dots -->
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"/>
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"/>
1054
1069
  </g>
1055
1070
  `);
1056
- function q(e, t, i) {
1057
- return { css: `${xt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1071
+ function K(e, t, i) {
1072
+ return { css: `${Ct(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1058
1073
  }
1059
1074
  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)
1075
+ tap: K(St, 12, 4),
1076
+ hold: K(Mt, 16, 16),
1077
+ slideHorizontal: K(Dt, l, l),
1078
+ slideVertical: K(Tt, l, l)
1064
1079
  };
1065
- function Z() {
1080
+ function ne() {
1066
1081
  if (typeof window > "u") return null;
1067
1082
  const e = window;
1068
1083
  return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
1069
1084
  }
1070
- function ee(e) {
1085
+ function ie(e) {
1071
1086
  if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
1072
1087
  try {
1073
1088
  navigator.vibrate(e);
1074
1089
  } catch {
1075
1090
  }
1076
1091
  }
1077
- const St = {
1092
+ const _t = {
1078
1093
  /** Light confirmation — fires when slide gesture arms after user holds still. */
1079
1094
  tick() {
1080
- const e = Z();
1095
+ const e = ne();
1081
1096
  if (e) {
1082
1097
  e.impact({ style: "Light" }).catch(() => {
1083
1098
  });
1084
1099
  return;
1085
1100
  }
1086
- ee(8);
1101
+ ie(8);
1087
1102
  },
1088
1103
  /** Medium bump — fires when hold gesture commits (detail opening). */
1089
1104
  bump() {
1090
- const e = Z();
1105
+ const e = ne();
1091
1106
  if (e) {
1092
1107
  e.impact({ style: "Medium" }).catch(() => {
1093
1108
  });
1094
1109
  return;
1095
1110
  }
1096
- ee(20);
1111
+ ie(20);
1097
1112
  },
1098
1113
  /** Stronger pulse — reserved for edit-mode pickup (future use). */
1099
1114
  pulse() {
1100
- const e = Z();
1115
+ const e = ne();
1101
1116
  if (e) {
1102
1117
  e.impact({ style: "Heavy" }).catch(() => {
1103
1118
  });
1104
1119
  return;
1105
1120
  }
1106
- ee([0, 15, 40, 15]);
1121
+ ie([0, 15, 40, 15]);
1107
1122
  }
1108
1123
  };
1109
- function Gt(e, t) {
1124
+ function Xt(e, t) {
1110
1125
  const n = {
1111
1126
  isDown: !1,
1112
1127
  isTouch: !1,
@@ -1118,92 +1133,101 @@ function Gt(e, t) {
1118
1133
  holdTimer: null,
1119
1134
  element: null
1120
1135
  };
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 };
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);
1128
1144
  }
1129
- }), h = u, g.observe(u), o = { width: u.clientWidth, height: u.clientHeight });
1145
+ }), u = a, d.observe(a), o = { width: a.clientWidth, height: a.clientHeight }, m(o.height > o.width));
1130
1146
  }
1131
- const f = () => {
1147
+ const v = () => {
1132
1148
  n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
1133
- }, c = () => {
1149
+ }, y = () => {
1134
1150
  n.isDown = !1, n.hasMoved = !1, n.sliding = !1;
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;
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;
1143
1159
  n.holdTimer = setTimeout(() => {
1144
- n.holdTimer = null, !(!n.isDown || n.hasMoved) && (St.bump(), m.hold?.action(), n.isDown = !1);
1145
- }, b);
1160
+ n.holdTimer = null, !(!n.isDown || n.hasMoved) && (_t.bump(), f.hold?.action(), n.isDown = !1);
1161
+ }, p);
1146
1162
  }
1147
- if (!n.isTouch && m.slide)
1163
+ if (!n.isTouch && f.slide)
1148
1164
  try {
1149
- u.currentTarget.setPointerCapture(u.pointerId);
1165
+ a.currentTarget.setPointerCapture(a.pointerId);
1150
1166
  } catch {
1151
1167
  }
1152
1168
  }
1153
- }, d = (u) => {
1169
+ }, S = (a) => {
1154
1170
  if (!n.isDown) return;
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);
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
+ }
1158
1178
  n.sliding = !0;
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();
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();
1161
1181
  }
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();
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();
1165
1185
  try {
1166
- u.currentTarget.releasePointerCapture(u.pointerId);
1186
+ a.currentTarget.releasePointerCapture(a.pointerId);
1167
1187
  } catch {
1168
1188
  }
1169
- c();
1170
- }, C = (u) => {
1171
- f();
1189
+ y();
1190
+ }, M = (a) => {
1191
+ v();
1172
1192
  try {
1173
- u.currentTarget.releasePointerCapture(u.pointerId);
1193
+ a.currentTarget.releasePointerCapture(a.pointerId);
1174
1194
  } catch {
1175
1195
  }
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);
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);
1182
1202
  }
1183
- return m.tap ? j.tap.css : m.hold ? j.hold.css : "";
1203
+ return f.tap ? j.tap.css : f.hold ? j.hold.css : "";
1184
1204
  };
1185
1205
  return {
1186
- onPointerDown: k,
1187
- onPointerMove: d,
1188
- onPointerUp: a,
1189
- onPointerCancel: C,
1190
- onPointerEnter: (u) => {
1191
- const m = u.currentTarget;
1192
- n.element = m, m.style.cursor = w(m);
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);
1193
1213
  },
1194
- bindElement: (u) => {
1195
- u && (n.element = u, y(u));
1214
+ bindElement: (a) => {
1215
+ a && (n.element = a, h(a));
1196
1216
  },
1197
1217
  touchAction: () => {
1198
- const u = e();
1199
- return u.tap || u.hold || u.slide ? "manipulation" : "auto";
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";
1200
1224
  },
1201
1225
  dispose: () => {
1202
- f(), g && (g.disconnect(), g = null), h = null, o = null;
1226
+ v(), d && (d.disconnect(), d = null), u = null, o = null;
1203
1227
  }
1204
1228
  };
1205
1229
  }
1206
- const Mt = {
1230
+ const zt = {
1207
1231
  solar: "oklch(0.74 0.18 60)",
1208
1232
  grid: "oklch(0.62 0.12 245)",
1209
1233
  battery: "oklch(0.70 0.18 145)",
@@ -1213,23 +1237,23 @@ const Mt = {
1213
1237
  // Fault red-orange; used only for faults, never normal consumption.
1214
1238
  negative: "oklch(0.64 0.22 27)"
1215
1239
  };
1216
- function Dt(e) {
1240
+ function Ot(e) {
1217
1241
  return {
1218
1242
  fill: `color-mix(in oklch, ${e} 20%, transparent)`,
1219
1243
  stroke: e,
1220
1244
  solid: e
1221
1245
  };
1222
1246
  }
1223
- const qt = Object.fromEntries(
1224
- Object.entries(Mt).map(([e, t]) => [e, Dt(t)])
1225
- ), Yt = A.enum([
1247
+ const Jt = Object.fromEntries(
1248
+ Object.entries(zt).map(([e, t]) => [e, Ot(t)])
1249
+ ), Qt = A.enum([
1226
1250
  "success",
1227
1251
  "warning",
1228
1252
  "danger",
1229
1253
  "info",
1230
1254
  "neutral",
1231
1255
  "accent"
1232
- ]), Kt = {
1256
+ ]), Zt = {
1233
1257
  /** Optional display name override (renders as text input) */
1234
1258
  title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1235
1259
  /** Multi-select entity picker for a HA domain */
@@ -1239,68 +1263,68 @@ const qt = Object.fromEntries(
1239
1263
  /** Area picker dropdown */
1240
1264
  areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
1241
1265
  };
1242
- function Xt(e) {
1266
+ function en(e) {
1243
1267
  if (e.length < 2) return "";
1244
1268
  const t = e[0], i = e[1];
1245
1269
  if (!t || !i) return "";
1246
1270
  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)));
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)));
1251
1275
  }
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)
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)
1257
1281
  );
1258
1282
  }
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}`;
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}`;
1266
1290
  }
1267
- return y;
1291
+ return $;
1268
1292
  }
1269
- function Jt() {
1293
+ function tn() {
1270
1294
  return document.documentElement.classList.contains("dark");
1271
1295
  }
1272
- const _t = "0.5.1", zt = {
1273
- version: _t
1274
- }, Qt = zt.version;
1296
+ const Et = "0.5.2", Nt = {
1297
+ version: Et
1298
+ }, nn = Nt.version;
1275
1299
  export {
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,
1284
- Ne as WidgetSliderFill,
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
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
1306
1330
  };