@glasshome/widget-sdk 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 an, formatSchemaError as sn } from "./schemas.js";
3
+ import { effect as W, className as R, style as oe, template as x, insert as b, createComponent as k, memo as T, setStyleProperty as X, addEventListener as G, use as xe, delegateEvents as ye } from "solid-js/web";
4
+ import { createElementSize as $e } from "@solid-primitives/resize-observer";
5
+ import { createContext as ke, useContext as ae, Show as E, onMount as Ce, createSignal as V, createMemo as L, splitProps as Se, createEffect as re, on as de, onCleanup as se } from "solid-js";
6
+ import { clsx as Me } from "clsx";
7
+ import { twMerge as De } from "tailwind-merge";
8
+ function ge(e) {
9
9
  return A.toJSONSchema(e, {
10
10
  override: (t) => {
11
11
  const i = A.globalRegistry.get(t.zodSchema);
@@ -13,17 +13,17 @@ function ce(e) {
13
13
  }
14
14
  });
15
15
  }
16
- function ke(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 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 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
- }, te = be();
36
- function At() {
37
- const e = se(te);
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 Ce = `/* 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 Ce = `/* Authoritative SDK CSS contract. Injected once on first Widget mou
211
211
  }
212
212
  }
213
213
  `;
214
- let Q = !1;
215
- function Se(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 = Ce, t.head.appendChild(i), Q = !0;
224
+ i.setAttribute("data-glasshome-tokens", ""), i.textContent = _e, t.head.appendChild(i), te = !0;
225
225
  }
226
- function H(...e) {
227
- return $e(ye(e));
226
+ function P(...e) {
227
+ return De(Me(e));
228
228
  }
229
- const Me = {
229
+ const Oe = {
230
230
  id: "classic-glass",
231
231
  name: "Classic Glass",
232
232
  description: "Default glassmorphism design with blur background and gradient",
@@ -254,7 +254,7 @@ const Me = {
254
254
  hoverScale: 1.02,
255
255
  activeScale: 0.98
256
256
  }
257
- }, De = {
257
+ }, Ee = {
258
258
  id: "minimal",
259
259
  name: "Minimal",
260
260
  description: "Clean, minimal design with no background effects",
@@ -283,7 +283,7 @@ const Me = {
283
283
  active: !1,
284
284
  focus: !0
285
285
  }
286
- }, _e = {
286
+ }, Ne = {
287
287
  id: "compact-horizontal",
288
288
  name: "Compact Horizontal",
289
289
  description: "Horizontal layout for compact widgets",
@@ -311,108 +311,108 @@ const Me = {
311
311
  hoverScale: 1.02,
312
312
  activeScale: 0.98
313
313
  }
314
- }, ze = {
315
- "classic-glass": Me,
316
- minimal: De,
317
- "compact-horizontal": _e
314
+ }, Ae = {
315
+ "classic-glass": Oe,
316
+ minimal: Ee,
317
+ "compact-horizontal": Ne
318
318
  };
319
- function Te(e) {
320
- return ze[e];
319
+ function Ve(e) {
320
+ return Ae[e];
321
321
  }
322
- var Ee = /* @__PURE__ */ b("<div>");
323
- function Ne(e) {
322
+ var We = /* @__PURE__ */ x("<div>");
323
+ function Pe(e) {
324
324
  return (() => {
325
- var t = Ee();
325
+ var t = We();
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
- "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 && 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 = 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 Oe = /* @__PURE__ */ b("<div>");
342
- function Ve(e) {
341
+ var He = /* @__PURE__ */ x("<div>");
342
+ function Re(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 = He();
345
+ return b(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 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 w(i, x(T, {
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 Ae();
358
+ return Ie();
359
359
  }
360
- }), r), w(i, x(T, {
360
+ }), r), b(i, k(E, {
361
361
  get when() {
362
362
  return t() >= 3;
363
363
  },
364
364
  get children() {
365
- return We();
365
+ return je();
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), 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 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 = 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 Re = /* @__PURE__ */ b("<p>");
379
- function Ue(e) {
378
+ var Ue = /* @__PURE__ */ x("<p>");
379
+ function Fe(e) {
380
380
  return (() => {
381
- var t = Re();
382
- return w(t, (() => {
383
- var i = D(() => !!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 = 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 = 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 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 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 w(i, () => e.children), w(t, x(T, {
397
+ var t = qe(), i = t.firstChild;
398
+ return b(i, () => e.children), b(t, k(E, {
399
399
  get when() {
400
- return D(() => 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 = je();
404
- return w(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 = 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 = 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 Le(e, t = !1) {
415
+ function Ke(e, t = !1) {
416
416
  if (e.length === 0)
417
417
  return {
418
418
  isGroup: !1,
@@ -428,62 +428,62 @@ function Le(e, t = !1) {
428
428
  };
429
429
  const i = e.length > 1;
430
430
  if (!i) {
431
- const v = e[0], S = v.state === "on", O = v.attributes?.brightness || 0, M = Math.round(O / 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: 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: 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: S ? "On" : "Off"
442
+ description: f ? "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, u = 0, d = 0, $ = 0;
446
+ const m = [];
447
+ for (const a of e)
448
+ switch (a.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++, a.attributes?.brightness !== void 0 && (d += a.attributes.brightness, $++), a.attributes?.rgb_color && m.push(a.attributes.rgb_color);
451
451
  break;
452
452
  case "off":
453
453
  n++;
454
454
  break;
455
455
  case "unknown":
456
- a++;
456
+ o++;
457
457
  break;
458
458
  case "unavailable":
459
- h++;
459
+ u++;
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 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
- 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
+ B = ue(e[0]);
472
+ let H;
473
+ return s ? H = "All on" : S ? H = "All off" : r > 0 ? H = `${r} of ${h} on` : H = "Off", {
474
474
  isGroup: i,
475
- state: f,
476
- isOn: C,
477
- isUnavailable: f === "unavailable",
478
- brightness: N,
479
- brightnessPercent: R,
480
- color: c,
475
+ state: w,
476
+ isOn: M,
477
+ isUnavailable: w === "unavailable",
478
+ brightness: z,
479
+ brightnessPercent: I,
480
+ color: B,
481
481
  onCount: r,
482
- totalCount: m,
483
- description: g
482
+ totalCount: h,
483
+ description: H
484
484
  };
485
485
  }
486
- function Fe(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,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 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: k,
502
- numericValue: Number.isNaN(l) ? null : l,
503
- isUnavailable: d.state === "unavailable",
504
- unit: d.unitOfMeasurement ?? void 0,
505
- description: k
501
+ state: S,
502
+ numericValue: Number.isNaN(s) ? null : s,
503
+ isUnavailable: g.state === "unavailable",
504
+ unit: g.unitOfMeasurement ?? void 0,
505
+ description: S
506
506
  };
507
507
  }
508
- const n = [], a = [];
509
- let h = 0, u;
510
- for (const d of e) {
511
- if (!u && d.unitOfMeasurement && (u = d.unitOfMeasurement), d.state === "unavailable") {
512
- h++, a.push({
513
- entityId: d.id,
508
+ const n = [], o = [];
509
+ let u = 0, d;
510
+ for (const g of e) {
511
+ if (!d && g.unitOfMeasurement && (d = g.unitOfMeasurement), g.state === "unavailable") {
512
+ u++, o.push({
513
+ entityId: g.id,
514
514
  value: "unavailable",
515
- friendly_name: d.friendlyName
515
+ friendly_name: g.friendlyName
516
516
  });
517
517
  continue;
518
518
  }
519
- const l = Number.parseFloat(d.state);
520
- isNaN(l) ? i || a.push({
521
- entityId: d.id,
522
- value: d.state,
523
- friendly_name: d.friendlyName
524
- }) : (n.push(l), a.push({
525
- entityId: d.id,
526
- value: l,
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 p = h === e.length, y = n.length === 0;
531
- if (p || y)
530
+ const $ = u === e.length, m = n.length === 0;
531
+ if ($ || m)
532
532
  return {
533
533
  isGroup: r,
534
- state: p ? "unavailable" : "unknown",
534
+ state: $ ? "unavailable" : "unknown",
535
535
  numericValue: null,
536
- isUnavailable: p,
537
- unit: u,
538
- description: p ? "Unavailable" : "No numeric values",
539
- memberValues: a
536
+ isUnavailable: $,
537
+ unit: d,
538
+ description: $ ? "Unavailable" : "No numeric values",
539
+ memberValues: o
540
540
  };
541
- let m, $;
541
+ let h, v;
542
542
  switch (t) {
543
543
  case "min":
544
- m = Math.min(...n), $ = "Minimum";
544
+ h = Math.min(...n), v = "Minimum";
545
545
  break;
546
546
  case "max":
547
- m = Math.max(...n), $ = "Maximum";
547
+ h = 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
+ h = n.reduce((g, s) => g + s, 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 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
- m = n.reduce((d, l) => d + l, 0), $ = "Sum";
558
+ h = n.reduce((g, s) => g + s, 0), v = "Sum";
559
559
  break;
560
560
  case "last":
561
- m = n[n.length - 1], $ = "Latest";
561
+ h = n[n.length - 1], v = "Latest";
562
562
  break;
563
563
  case "range":
564
- m = Math.max(...n) - Math.min(...n), $ = "Range";
564
+ h = 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
+ h = n.reduce((g, s) => g * s, 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 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
- m = n.reduce((d, l) => d + l, 0) / n.length, $ = "Average";
575
+ h = n.reduce((g, s) => g + s, 0) / n.length, v = "Average";
576
576
  }
577
- const E = Number.isInteger(m) ? m.toString() : m.toFixed(1);
577
+ const y = Number.isInteger(h) ? h.toString() : h.toFixed(1);
578
578
  return {
579
579
  isGroup: r,
580
- state: E,
581
- numericValue: m,
580
+ state: y,
581
+ numericValue: h,
582
582
  isUnavailable: !1,
583
- unit: u,
584
- description: `${$} of ${n.length}`,
585
- memberValues: a
583
+ unit: d,
584
+ description: `${v} of ${n.length}`,
585
+ memberValues: o
586
586
  };
587
587
  }
588
- function le(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) {
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, 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 Ge(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 Ge(e) {
609
609
  }
610
610
  return !1;
611
611
  }
612
- function Wt(e, t, i) {
612
+ function Bt(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 Ut(e) {
616
+ return e.filter(Je).length;
617
617
  }
618
- function qe(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 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, 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 Ye(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 Ke = /* @__PURE__ */ b("<div class=glasshome-widget-subtitle>"), Xe = /* @__PURE__ */ b("<div><div class=glasshome-widget-value>");
633
- function Je(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 = Xe(), i = t.firstChild;
636
- return w(i, () => qe(e.value, e.unit)), w(t, x(T, {
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 D(() => !!e.interpret)() && typeof e.value == "number";
638
+ return T(() => !!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 = et();
642
+ return b(r, () => Ze(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 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 = se(te), [i, r] = B(), n = we(i), a = {
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 = j(() => {
661
+ }, u = L(() => {
661
662
  if (e.variant)
662
- return typeof e.variant == "string" ? Te(e.variant) : e.variant;
663
- }), u = j(() => ({
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 rt(e) {
678
679
  ...e.gradient ? {
679
680
  "--widget-gradient": e.gradient
680
681
  } : {}
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);
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 x(te.Provider, {
693
- value: a,
693
+ return k(J.Provider, {
694
+ value: o,
694
695
  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, {
696
+ var s = it(), S = s.firstChild;
697
+ return G(s, "pointercancel", g), G(s, "pointerup", y), G(s, "pointermove", v), G(s, "pointerdown", h), G(s, "pointerenter", m), xe((w) => {
698
+ r(w), e.gestures?.bindElement(w);
699
+ }, s), b(S, (() => {
700
+ var w = T(() => !!e.emptyState);
701
+ return () => w() ? k(dt, {
701
702
  get icon() {
702
703
  return e.emptyState.icon;
703
704
  },
@@ -708,86 +709,88 @@ function rt(e) {
708
709
  return e.emptyState.message;
709
710
  }
710
711
  }) : e.children;
711
- })()), 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;
712
+ })()), b(s, (() => {
713
+ var w = T(() => !!e.loading);
714
+ return () => w() && (() => {
715
+ var M = rt();
716
+ return W((z) => X(M, "z-index", Y.OVERLAY)), M;
716
717
  })();
717
- })(), null), W((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;
718
+ })(), null), W((w) => {
719
+ var M = P("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", u()?.styles?.class, e.class), z = d(), I = Y.CONTENT;
720
+ return M !== w.e && R(s, w.e = M), w.t = oe(s, z, w.t), I !== w.a && X(S, "z-index", w.a = I), w;
720
721
  }, {
721
722
  e: void 0,
722
723
  t: void 0,
723
724
  a: void 0
724
- }), l;
725
+ }), s;
725
726
  }
726
727
  });
727
728
  }
728
- function ot(e) {
729
+ function dt(e) {
729
730
  return (() => {
730
- var t = et();
731
- return w(t, (() => {
732
- var i = D(() => !!e.icon);
731
+ var t = ot();
732
+ return b(t, (() => {
733
+ var i = T(() => !!e.icon);
733
734
  return () => i() && (() => {
734
- var r = tt();
735
- return w(r, () => e.icon), r;
735
+ var r = at();
736
+ return b(r, () => e.icon), r;
736
737
  })();
737
- })(), null), w(t, (() => {
738
- var i = D(() => !!e.title);
738
+ })(), null), b(t, (() => {
739
+ var i = T(() => !!e.title);
739
740
  return () => i() && (() => {
740
- var r = nt();
741
- return w(r, () => e.title), r;
741
+ var r = st();
742
+ return b(r, () => e.title), r;
742
743
  })();
743
- })(), null), w(t, (() => {
744
- var i = D(() => !!e.message);
744
+ })(), null), b(t, (() => {
745
+ var i = T(() => !!e.message);
745
746
  return () => i() && (() => {
746
- var r = it();
747
- return w(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 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) {
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(), w(t, x(T, {
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 = at();
769
- return w(i, () => e.icon), i;
769
+ var i = ut();
770
+ return b(i, () => e.icon), i;
770
771
  }
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;
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 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
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
- })), oe(ae(() => t.configSchema, (s) => {
781
- s && h(ce(s));
781
+ })), re(de(() => t.configSchema, (c) => {
782
+ c && u(ge(c));
782
783
  }));
783
- const u = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), p = (s) => {
784
- !s && 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(s);
787
- }, y = () => {
787
+ }), t.onOpenChange(c);
788
+ }, m = () => {
788
789
  t.onConfigSave?.(r());
789
- }, [m, $] = B(t.defaultTab ?? "controls"), E = () => {
790
- const s = 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,141 +799,141 @@ function Pt(e) {
796
799
  "2xl": "max-w-2xl",
797
800
  "3xl": "max-w-3xl",
798
801
  "4xl": "max-w-4xl"
799
- }[s];
800
- }, d = () => {
802
+ }[c];
803
+ }, S = () => {
801
804
  if (t.tabs) return t.tabs;
802
- const s = [];
803
- return s.push({
805
+ const c = [];
806
+ return c.push({
804
807
  id: "edit",
805
808
  label: "Edit",
806
- icon: st(),
807
- content: t.editContent ?? (i() && a() ? x(v, {
809
+ icon: ht(),
810
+ content: t.editContent ?? (i() && o() ? k(p, {
808
811
  get schema() {
809
- return a();
812
+ return o();
810
813
  },
811
814
  get data() {
812
815
  return r();
813
816
  },
814
817
  onChange: n
815
- }) : ct())
816
- }), s.push({
818
+ }) : ft())
819
+ }), c.push({
817
820
  id: "controls",
818
821
  label: "Controls",
819
- icon: dt(),
820
- content: t.controlsContent ?? ut()
821
- }), s.push({
822
+ icon: mt(),
823
+ content: t.controlsContent ?? vt()
824
+ }), c.push({
822
825
  id: "debug",
823
826
  label: "Debug",
824
- icon: gt(),
825
- content: t.debugContent ?? ht()
826
- }), s;
827
- }, l = 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 s = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
831
- await navigator.clipboard.writeText(s);
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
- }, 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, {
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: (s) => S(s),
845
+ onOpenChange: (c) => C(c),
843
846
  get children() {
844
- return x(C, {
847
+ return k(I, {
845
848
  get class() {
846
- return H(E(), t.class);
849
+ return P(s(), t.class);
847
850
  },
848
851
  get children() {
849
- return [x(N, {
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 s = ft();
854
- return w(s, x(R, {
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), w(s, x(c, {
862
+ }), null), b(c, k(a, {
860
863
  class: "sr-only",
861
864
  children: "Widget configuration dialog"
862
- }), null), s;
865
+ }), null), c;
863
866
  })(), (() => {
864
- var s = mt(), _ = s.firstChild;
865
- return w(_, () => d().map((V) => x(bt, {
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 m() === V.id;
876
+ return y() === N.id;
874
877
  },
875
- onClick: () => $(V.id)
876
- }))), w(s, x(T, {
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), s;
886
+ }), null), c;
884
887
  })()];
885
888
  }
886
889
  }), (() => {
887
- var s = vt();
888
- return w(s, k), s;
889
- })(), x(T, {
890
+ var c = yt();
891
+ return b(c, M), c;
892
+ })(), k(E, {
890
893
  get when() {
891
- return D(() => m() === "edit")() && (M() || t.onDelete) || m() === "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 s = wt();
895
- return w(s, x(T, {
897
+ var c = $t();
898
+ return b(c, k(E, {
896
899
  get when() {
897
- return D(() => m() === "edit")() && t.onDelete;
900
+ return T(() => y() === "edit")() && t.onDelete;
898
901
  },
899
902
  get children() {
900
- return x(g, {
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), w(s, x(T, {
910
+ }), null), b(c, k(E, {
908
911
  get when() {
909
- return D(() => m() === "edit")() && M();
912
+ return T(() => y() === "edit")() && D();
910
913
  },
911
914
  get children() {
912
- return x(g, {
915
+ return k(f, {
913
916
  size: "sm",
914
917
  get disabled() {
915
918
  return !O();
916
919
  },
917
- onClick: () => M()?.(),
920
+ onClick: () => D()?.(),
918
921
  children: "Save"
919
922
  });
920
923
  }
921
- }), null), w(s, x(T, {
924
+ }), null), b(c, k(E, {
922
925
  get when() {
923
- return D(() => m() === "debug")() && t.debugData !== void 0;
926
+ return T(() => y() === "debug")() && t.debugData !== void 0;
924
927
  },
925
928
  get children() {
926
- return x(g, {
929
+ return k(f, {
927
930
  size: "sm",
928
931
  variant: "outline",
929
- onClick: l,
932
+ onClick: w,
930
933
  children: "Copy"
931
934
  });
932
935
  }
933
- }), null), s;
936
+ }), null), c;
934
937
  }
935
938
  })];
936
939
  }
@@ -938,157 +941,187 @@ function Pt(e) {
938
941
  }
939
942
  });
940
943
  }
941
- ve(["click"]);
942
- function Rt(e = "edit") {
943
- const [t, i] = B(!1), [r, n] = B(e);
944
- return {
944
+ ye(["click"]);
945
+ function Gt(e) {
946
+ if (typeof IntersectionObserver > "u")
947
+ return () => !1;
948
+ const [t, i] = V(!1), r = new IntersectionObserver((n) => {
949
+ const o = n[0];
950
+ o && i(!o.isIntersecting);
951
+ });
952
+ return re(() => {
953
+ const n = e();
954
+ r.disconnect(), n && r.observe(n);
955
+ }), se(() => r.disconnect()), t;
956
+ }
957
+ function qt() {
958
+ if (typeof window > "u" || typeof window.matchMedia != "function")
959
+ return () => !1;
960
+ const e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, i] = V(e.matches), r = (n) => i(n.matches);
961
+ return e.addEventListener("change", r), se(() => e.removeEventListener("change", r)), t;
962
+ }
963
+ function Yt(e = "controls") {
964
+ const [t, i] = V(!1), [r, n] = V(e), o = (d) => {
965
+ n(d ?? e), i(!0);
966
+ }, u = ae(J);
967
+ return u?.registerDialogOpener?.(o), se(() => u?.registerDialogOpener?.(null)), {
945
968
  showDialog: t,
946
969
  setShowDialog: i,
947
- openDialog: () => i(!0),
970
+ openDialog: o,
948
971
  closeDialog: () => i(!1),
949
972
  activeTab: r,
950
- setActiveTab: n
973
+ setActiveTab: n,
974
+ dialogProps: {
975
+ get open() {
976
+ return t();
977
+ },
978
+ onOpenChange: i,
979
+ get activeTab() {
980
+ return r();
981
+ },
982
+ onActiveTabChange: n
983
+ }
951
984
  };
952
985
  }
953
- function 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(() => {
986
+ function Kt(e) {
987
+ const t = e.minEntities ?? 1, i = L(() => e.entities().length), r = L(() => i() >= t), n = L(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), o = L(() => {
955
988
  if (!r()) return;
956
- const 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);
989
+ const d = e.aggregationMode?.();
990
+ if (!d || d === "none") return;
991
+ const $ = e.entities();
992
+ if (d === "light" || d === "binary-sensor" || d === "switch")
993
+ return Ke($, e.allEntitiesMode);
994
+ if (d === "sensor") {
995
+ const m = e.sensorGroupType?.() ?? "mean";
996
+ return Xe($, m, !0);
964
997
  }
965
- }), h = j(() => r() ? void 0 : e.emptyStateConfig);
998
+ }), u = L(() => r() ? void 0 : e.emptyStateConfig);
966
999
  return {
967
1000
  entities: e.entities,
968
1001
  groupData: n,
969
- aggregatedData: a,
970
- emptyState: h,
1002
+ aggregatedData: o,
1003
+ emptyState: u,
971
1004
  hasEntities: r,
972
1005
  count: i
973
1006
  };
974
1007
  }
975
- const F = 32, o = F / 2, z = "white", K = "rgba(0,0,0,0.4)", ie = 2, X = 3;
976
- function pt(e) {
1008
+ const q = 32, l = q / 2, _ = "white", Q = "rgba(0,0,0,0.4)", le = 2, Z = 3;
1009
+ function Ct(e) {
977
1010
  return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
978
1011
  }
979
- function J(e) {
980
- 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>`;
981
1014
  }
982
- const xt = J(`
1015
+ const St = ee(`
983
1016
  <g transform="translate(6, 2)">
984
1017
  <!-- shadow -->
985
- <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">
986
1019
  <path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
987
1020
  </g>
988
1021
  <!-- main -->
989
- <g stroke="${z}" stroke-width="${ie}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1022
+ <g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
990
1023
  <path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
991
1024
  </g>
992
1025
  </g>
993
- `), yt = J(`
1026
+ `), Mt = ee(`
994
1027
  <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}"/>
1028
+ <circle cx="${l}" cy="${l}" r="8" stroke="${Q}" stroke-width="${Z}" fill="none"/>
1029
+ <circle cx="${l}" cy="${l}" r="8" stroke="${_}" stroke-width="1.5" fill="none"/>
1030
+ <circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
998
1031
  </g>
999
- `), $t = J(`
1032
+ `), Dt = ee(`
1000
1033
  <g>
1001
1034
  <!-- shadow -->
1002
- <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}"/>
1035
+ <g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1036
+ <line x1="6" y1="${l}" x2="26" y2="${l}"/>
1037
+ <polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
1038
+ <polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
1006
1039
  </g>
1007
1040
  <!-- main -->
1008
- <g stroke="${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}"/>
1041
+ <g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1042
+ <line x1="6" y1="${l}" x2="26" y2="${l}"/>
1043
+ <polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
1044
+ <polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
1012
1045
  </g>
1013
1046
  <!-- center grip dots -->
1014
- <circle cx="${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"/>
1047
+ <circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
1048
+ <circle cx="${l - 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
1049
+ <circle cx="${l + 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
1017
1050
  </g>
1018
- `), kt = J(`
1051
+ `), Tt = ee(`
1019
1052
  <g>
1020
1053
  <!-- shadow -->
1021
- <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"/>
1054
+ <g stroke="${Q}" stroke-width="${Z}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1055
+ <line x1="${l}" y1="6" x2="${l}" y2="26"/>
1056
+ <polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
1057
+ <polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
1025
1058
  </g>
1026
1059
  <!-- main -->
1027
- <g stroke="${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"/>
1060
+ <g stroke="${_}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1061
+ <line x1="${l}" y1="6" x2="${l}" y2="26"/>
1062
+ <polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
1063
+ <polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
1031
1064
  </g>
1032
1065
  <!-- center grip dots -->
1033
- <circle cx="${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"/>
1066
+ <circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
1067
+ <circle cx="${l}" cy="${l - 5}" r="1" fill="${_}" opacity="0.6"/>
1068
+ <circle cx="${l}" cy="${l + 5}" r="1" fill="${_}" opacity="0.6"/>
1036
1069
  </g>
1037
1070
  `);
1038
- function q(e, t, i) {
1039
- return { css: `${pt(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 };
1040
1073
  }
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)
1074
+ const j = {
1075
+ tap: K(St, 12, 4),
1076
+ hold: K(Mt, 16, 16),
1077
+ slideHorizontal: K(Dt, l, l),
1078
+ slideVertical: K(Tt, l, l)
1046
1079
  };
1047
- function Z() {
1080
+ function ne() {
1048
1081
  if (typeof window > "u") return null;
1049
1082
  const e = window;
1050
1083
  return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
1051
1084
  }
1052
- function ee(e) {
1085
+ function ie(e) {
1053
1086
  if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
1054
1087
  try {
1055
1088
  navigator.vibrate(e);
1056
1089
  } catch {
1057
1090
  }
1058
1091
  }
1059
- const Ct = {
1092
+ const _t = {
1060
1093
  /** Light confirmation — fires when slide gesture arms after user holds still. */
1061
1094
  tick() {
1062
- const e = Z();
1095
+ const e = ne();
1063
1096
  if (e) {
1064
1097
  e.impact({ style: "Light" }).catch(() => {
1065
1098
  });
1066
1099
  return;
1067
1100
  }
1068
- ee(8);
1101
+ ie(8);
1069
1102
  },
1070
1103
  /** Medium bump — fires when hold gesture commits (detail opening). */
1071
1104
  bump() {
1072
- const e = Z();
1105
+ const e = ne();
1073
1106
  if (e) {
1074
1107
  e.impact({ style: "Medium" }).catch(() => {
1075
1108
  });
1076
1109
  return;
1077
1110
  }
1078
- ee(20);
1111
+ ie(20);
1079
1112
  },
1080
1113
  /** Stronger pulse — reserved for edit-mode pickup (future use). */
1081
1114
  pulse() {
1082
- const e = Z();
1115
+ const e = ne();
1083
1116
  if (e) {
1084
1117
  e.impact({ style: "Heavy" }).catch(() => {
1085
1118
  });
1086
1119
  return;
1087
1120
  }
1088
- ee([0, 15, 40, 15]);
1121
+ ie([0, 15, 40, 15]);
1089
1122
  }
1090
1123
  };
1091
- function jt(e, t) {
1124
+ function Xt(e, t) {
1092
1125
  const n = {
1093
1126
  isDown: !1,
1094
1127
  isTouch: !1,
@@ -1100,99 +1133,127 @@ function jt(e, t) {
1100
1133
  holdTimer: null,
1101
1134
  element: null
1102
1135
  };
1103
- let 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 };
1136
+ let o = null, u = null, d = null;
1137
+ const [$, m] = V(null);
1138
+ function h(a) {
1139
+ a !== u && (d && d.disconnect(), d = new ResizeObserver((f) => {
1140
+ const p = f[0];
1141
+ if (p) {
1142
+ const C = p.borderBoxSize?.[0];
1143
+ C ? o = { width: C.inlineSize, height: C.blockSize } : o = { width: p.contentRect.width, height: p.contentRect.height }, m(o.height > o.width);
1110
1144
  }
1111
- }), h = c, u.observe(c), a = { width: c.clientWidth, height: c.clientHeight });
1145
+ }), u = a, d.observe(a), o = { width: a.clientWidth, height: a.clientHeight }, m(o.height > o.width));
1112
1146
  }
1113
- const y = () => {
1147
+ const v = () => {
1114
1148
  n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
1115
- }, m = () => {
1149
+ }, y = () => {
1116
1150
  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;
1151
+ }, g = (a) => {
1152
+ const p = e().slide;
1153
+ return p?.orientation === "horizontal" ? "horizontal" : p?.orientation === "vertical" ? "vertical" : a && (o || h(a), o) ? o.height > o.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
1154
+ }, s = (a) => {
1155
+ const f = e();
1156
+ if (!(!f.tap && !f.hold && !f.slide)) {
1157
+ if (n.isDown = !0, n.isTouch = a.pointerType === "touch", n.element = a.currentTarget, h(n.element), n.startX = a.clientX, n.startY = a.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, f.hold) {
1158
+ const p = f.hold.delay ?? 300;
1125
1159
  n.holdTimer = setTimeout(() => {
1126
- n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Ct.bump(), g.hold?.action(), n.isDown = !1);
1127
- }, v);
1160
+ n.holdTimer = null, !(!n.isDown || n.hasMoved) && (_t.bump(), f.hold?.action(), n.isDown = !1);
1161
+ }, p);
1128
1162
  }
1129
- if (!n.isTouch && g.slide)
1163
+ if (!n.isTouch && f.slide)
1130
1164
  try {
1131
- c.currentTarget.setPointerCapture(c.pointerId);
1165
+ a.currentTarget.setPointerCapture(a.pointerId);
1132
1166
  } catch {
1133
1167
  }
1134
1168
  }
1135
- }, d = (c) => {
1169
+ }, S = (a) => {
1136
1170
  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);
1171
+ const f = e(), p = a.clientX - n.startX, C = a.clientY - n.startY;
1172
+ if (Math.sqrt(p * p + C * C) > 10 && (v(), n.hasMoved = !0), f.slide && n.hasMoved) {
1173
+ const D = a.currentTarget, c = g(D);
1174
+ if (n.isTouch && !n.sliding) {
1175
+ const be = Math.abs(c === "vertical" ? C : p), pe = Math.abs(c === "vertical" ? p : C);
1176
+ if (be < pe) return;
1177
+ }
1140
1178
  n.sliding = !0;
1141
- const _ = 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();
1179
+ const F = f.slide.min ?? 0, N = f.slide.max ?? 100, he = N - F, fe = c === "vertical" ? -C : p, ce = o ?? { width: D.clientWidth, height: D.clientHeight }, me = c === "vertical" ? ce.height : ce.width, ve = fe / me * he, we = Math.max(F, Math.min(N, f.slide.value + ve));
1180
+ f.slide.onChange(Math.round(we)), n.startX = a.clientX, n.startY = a.clientY, a.preventDefault();
1143
1181
  }
1144
- }, 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();
1182
+ }, w = (a) => {
1183
+ const f = e(), p = n.isDown, C = Date.now() - n.startTime, O = f.hold?.delay ?? 300;
1184
+ v(), p && f.tap && !n.hasMoved && C < O && f.tap();
1147
1185
  try {
1148
- c.currentTarget.releasePointerCapture(c.pointerId);
1186
+ a.currentTarget.releasePointerCapture(a.pointerId);
1149
1187
  } catch {
1150
1188
  }
1151
- m();
1152
- }, k = (c) => {
1153
1189
  y();
1190
+ }, M = (a) => {
1191
+ v();
1154
1192
  try {
1155
- c.currentTarget.releasePointerCapture(c.pointerId);
1193
+ a.currentTarget.releasePointerCapture(a.pointerId);
1156
1194
  } catch {
1157
1195
  }
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);
1196
+ y();
1197
+ }, z = (a) => {
1198
+ const f = e();
1199
+ if (f.slide) {
1200
+ const p = f.slide.orientation;
1201
+ return p === "horizontal" ? j.slideHorizontal.css : p === "vertical" ? j.slideVertical.css : (o || h(a), o && o.height > o.width ? j.slideVertical.css : j.slideHorizontal.css);
1164
1202
  }
1165
- return g.tap ? U.tap.css : g.hold ? U.hold.css : "";
1203
+ return f.tap ? j.tap.css : f.hold ? j.hold.css : "";
1166
1204
  };
1167
1205
  return {
1168
- onPointerDown: E,
1169
- 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);
1206
+ onPointerDown: s,
1207
+ onPointerMove: S,
1208
+ onPointerUp: w,
1209
+ onPointerCancel: M,
1210
+ onPointerEnter: (a) => {
1211
+ const f = a.currentTarget;
1212
+ n.element = f, f.style.cursor = z(f);
1175
1213
  },
1176
- bindElement: (c) => {
1177
- c && (n.element = c, p(c));
1214
+ bindElement: (a) => {
1215
+ a && (n.element = a, h(a));
1178
1216
  },
1179
1217
  touchAction: () => {
1180
- const c = e();
1181
- return c.tap || c.hold || c.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";
1182
1224
  },
1183
1225
  dispose: () => {
1184
- y(), u && (u.disconnect(), u = null), h = null, a = null;
1226
+ v(), d && (d.disconnect(), d = null), u = null, o = null;
1185
1227
  }
1186
1228
  };
1187
1229
  }
1188
- const Bt = A.enum([
1230
+ const zt = {
1231
+ solar: "oklch(0.74 0.18 60)",
1232
+ grid: "oklch(0.62 0.12 245)",
1233
+ battery: "oklch(0.70 0.18 145)",
1234
+ ev: "oklch(0.70 0.14 190)",
1235
+ home: "oklch(0.68 0.06 250)",
1236
+ positive: "oklch(0.70 0.14 160)",
1237
+ // Fault red-orange; used only for faults, never normal consumption.
1238
+ negative: "oklch(0.64 0.22 27)"
1239
+ };
1240
+ function Ot(e) {
1241
+ return {
1242
+ fill: `color-mix(in oklch, ${e} 20%, transparent)`,
1243
+ stroke: e,
1244
+ solid: e
1245
+ };
1246
+ }
1247
+ const Jt = Object.fromEntries(
1248
+ Object.entries(zt).map(([e, t]) => [e, Ot(t)])
1249
+ ), Qt = A.enum([
1189
1250
  "success",
1190
1251
  "warning",
1191
1252
  "danger",
1192
1253
  "info",
1193
1254
  "neutral",
1194
1255
  "accent"
1195
- ]), It = {
1256
+ ]), Zt = {
1196
1257
  /** Optional display name override (renders as text input) */
1197
1258
  title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1198
1259
  /** Multi-select entity picker for a HA domain */
@@ -1202,37 +1263,68 @@ const Bt = A.enum([
1202
1263
  /** Area picker dropdown */
1203
1264
  areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
1204
1265
  };
1205
- function Lt() {
1266
+ function en(e) {
1267
+ if (e.length < 2) return "";
1268
+ const t = e[0], i = e[1];
1269
+ if (!t || !i) return "";
1270
+ if (e.length === 2) return `M ${t.x} ${t.y} L ${i.x} ${i.y}`;
1271
+ const r = e.length, n = [], o = [], u = [];
1272
+ for (let m = 0; m < r - 1; m++) {
1273
+ const h = e[m], v = e[m + 1];
1274
+ !h || !v || (n.push(v.x - h.x), o.push(v.y - h.y), u.push((v.y - h.y) / (v.x - h.x)));
1275
+ }
1276
+ const d = [u[0] ?? 0];
1277
+ for (let m = 1; m < r - 1; m++) {
1278
+ const h = u[m - 1] ?? 0, v = u[m] ?? 0, y = n[m - 1] ?? 0, g = n[m] ?? 0;
1279
+ h * v <= 0 ? d.push(0) : d.push(
1280
+ 3 * (y + g) / ((2 * g + y) / h + (g + 2 * y) / v)
1281
+ );
1282
+ }
1283
+ d.push(u[r - 2] ?? 0);
1284
+ let $ = `M ${t.x} ${t.y}`;
1285
+ for (let m = 0; m < r - 1; m++) {
1286
+ const h = e[m], v = e[m + 1];
1287
+ if (!h || !v) continue;
1288
+ const y = (n[m] ?? 0) / 3, g = d[m] ?? 0, s = d[m + 1] ?? 0;
1289
+ $ += ` C ${h.x + y} ${h.y + g * y}, ${v.x - y} ${v.y - s * y}, ${v.x} ${v.y}`;
1290
+ }
1291
+ return $;
1292
+ }
1293
+ function tn() {
1206
1294
  return document.documentElement.classList.contains("dark");
1207
1295
  }
1208
- const St = "0.5.0", Mt = {
1209
- version: St
1210
- }, Ft = Mt.version;
1296
+ const Et = "0.5.2", Nt = {
1297
+ version: Et
1298
+ }, nn = Nt.version;
1211
1299
  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,
1220
- 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
1300
+ nn as SDK_VERSION,
1301
+ Qt as ToneSchema,
1302
+ U as Widget,
1303
+ Re as WidgetContent,
1304
+ J as WidgetCtx,
1305
+ Ft as WidgetDialog,
1306
+ Be as WidgetIcon,
1307
+ an as WidgetManifestSchema,
1308
+ Pe as WidgetSliderFill,
1309
+ Fe as WidgetStatus,
1310
+ Ye as WidgetTitle,
1311
+ nt as WidgetValue,
1312
+ Ke as calculateLightGroup,
1313
+ Xe as calculateSensorGroup,
1314
+ Ut as countActiveEntities,
1315
+ jt as defineWidget,
1316
+ sn as formatSchemaError,
1317
+ Bt as getEntityAttribute,
1318
+ ze as injectTokens,
1319
+ tn as isDark,
1320
+ Je as isEntityActive,
1321
+ en as monotoneCubicPath,
1322
+ Jt as svgColors,
1323
+ Gt as useIntersectionPause,
1324
+ qt as useReducedMotion,
1325
+ Lt as useWidgetContext,
1326
+ Yt as useWidgetDialog,
1327
+ Kt as useWidgetEntityGroup,
1328
+ Xt as useWidgetGestures,
1329
+ Zt as widgetFields
1238
1330
  };