@glasshome/widget-sdk 0.5.1 → 1.0.0

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