@glasshome/widget-sdk 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,29 @@
1
- import { z as L } from "zod";
2
- import { WidgetManifestSchema as nn, formatSchemaError as rn } from "./schemas.js";
3
- import { effect as T, className as N, style as Q, template as y, insert as p, setStyleProperty as A, memo as _, createComponent as M, addEventListener as q, use as ye, delegateEvents as $e } from "solid-js/web";
4
- import { createElementSize as Se } from "@solid-primitives/resize-observer";
5
- import { createContext as ke, useContext as fe, onMount as Ce, createSignal as U, createEffect as R, untrack as de, createMemo as V, splitProps as Me, on as ue, Show as j } from "solid-js";
6
- import { clsx as De } from "clsx";
7
- import { twMerge as ze } from "tailwind-merge";
8
- function me(e) {
9
- return L.toJSONSchema(e, {
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) {
9
+ return A.toJSONSchema(e, {
10
10
  override: (t) => {
11
- const r = L.globalRegistry.get(t.zodSchema);
12
- return r && typeof r == "object" && Object.keys(r).length > 0 ? { ...t.jsonSchema, ...r } : t.jsonSchema;
11
+ const i = A.globalRegistry.get(t.zodSchema);
12
+ return i && typeof i == "object" && Object.keys(i).length > 0 ? { ...t.jsonSchema, ...i } : t.jsonSchema;
13
13
  }
14
14
  });
15
15
  }
16
- function _e(e) {
16
+ function Ce(e) {
17
17
  try {
18
18
  return e.parse({});
19
19
  } catch {
20
20
  return {};
21
21
  }
22
22
  }
23
- function Ut(e) {
24
- return e.configSchema && (e.manifest.schema || (e.manifest.schema = me(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = _e(e.configSchema))), e;
23
+ function Pt(e) {
24
+ return e.configSchema && (e.manifest.schema || (e.manifest.schema = de(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = Ce(e.configSchema))), e;
25
25
  }
26
- const F = {
26
+ const G = {
27
27
  /** Background layer (gradients, images, glows) */
28
28
  BACKGROUND: 0,
29
29
  /** Main content layer (icon, title, text) */
@@ -32,68 +32,72 @@ const F = {
32
32
  OVERLAY: 20,
33
33
  /** Action layer (buttons, edit controls) */
34
34
  ACTIONS: 30
35
- }, se = ke();
36
- function Y() {
37
- const e = fe(se);
35
+ }, ne = pe();
36
+ function Ht() {
37
+ const e = le(ne);
38
38
  if (!e)
39
39
  throw new Error("useWidgetContext must be used within a Widget component");
40
40
  return e;
41
41
  }
42
- const Te = `/* packages/public/widget-sdk/src/framework/theming/tokens.css
42
+ const Se = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
43
+ * via framework/theming/tokens.ts.
43
44
  *
44
- * Phase 25: Channel Core + Tone Tokens
45
- * Authoritative SDK CSS contract. Injected once on first Widget mount
46
- * via framework/theming/tokens.ts. Final palette tuned in Phase 29.
45
+ * All widget-internal visual scale is driven from CSS custom properties +
46
+ * container queries on the \`.glasshome-widget\` shell (\`container-type: size\`).
47
+ * No JS classifier, no size tier enum.
47
48
  */
48
49
 
49
- /* Tone palette (VIS-C01) -- Phase 29 retune (VIS-P05).
50
- Hand-tuned against apps/dash/src/routes/dev.palette-tune.tsx so each
51
- tone reads vibrant at the 20% composition stop on both #fafaf9 (light)
52
- and #0c0a09 (dark) without overpowering the calm-confidence aesthetic. */
53
50
  :root {
54
- --tone-success: oklch(0.70 0.18 145); /* deeper L vs placeholder lifts chroma at 20% on light bg without going neon */
55
- --tone-warning: oklch(0.80 0.17 75); /* keeps amber readable at 22%/11% gradient stops without yellowing the shell */
56
- --tone-danger: oklch(0.64 0.22 27); /* anchors red just below midline so 20% alpha stays unambiguous on light bg */
57
- --tone-info: oklch(0.66 0.20 245); /* +0.01 chroma so info-blue keeps presence in 30%/40% slider fill against light */
58
- --tone-neutral: oklch(0.65 0.02 250); /* pinned literal -- matches @property --widget-color initial-value (tokens.test) */
59
- --tone-accent: oklch(0.74 0.18 60); /* +0.02 chroma for warm-amber accent so glow reads at 50% on light icon bg */
51
+ --tone-success: oklch(0.70 0.18 145);
52
+ --tone-warning: oklch(0.80 0.17 75);
53
+ --tone-danger: oklch(0.64 0.22 27);
54
+ --tone-info: oklch(0.66 0.20 245);
55
+ --tone-neutral: oklch(0.65 0.02 250);
56
+ --tone-accent: oklch(0.74 0.18 60);
60
57
 
61
- /* Envelope vars (VIS-C03), light mode -- retained from Phase 25 baseline */
62
58
  --widget-grad-strength: 1;
63
59
  --widget-glow-default: 0.4;
64
60
  --widget-border-highlight: oklch(0.98 0 0 / 0.4);
65
61
  }
66
62
 
67
63
  .dark {
68
- --tone-success: oklch(0.74 0.18 145); /* +0.04 L lifts chroma at 20% alpha against #0c0a09 so green isn't muddy */
69
- --tone-warning: oklch(0.82 0.17 75); /* +0.02 L only -- amber already bright on dark bg, more would wash the gradient */
70
- --tone-danger: oklch(0.68 0.22 27); /* +0.04 L preserves red identity without dipping into maroon at low alpha */
71
- --tone-info: oklch(0.70 0.20 245); /* +0.04 L plus chroma parity with light keeps info-blue vibrant at 30%/40% on dark */
72
- --tone-neutral: oklch(0.69 0.02 250); /* +0.04 L vs light, chroma parity -- defaults read calm on dark widget surfaces */
73
- --tone-accent: oklch(0.78 0.18 60); /* +0.04 L matches accent glow envelope so 50% icon glow stays warm on dark */
64
+ --tone-success: oklch(0.74 0.18 145);
65
+ --tone-warning: oklch(0.82 0.17 75);
66
+ --tone-danger: oklch(0.68 0.22 27);
67
+ --tone-info: oklch(0.70 0.20 245);
68
+ --tone-neutral: oklch(0.69 0.02 250);
69
+ --tone-accent: oklch(0.78 0.18 60);
74
70
 
75
71
  --widget-grad-strength: 1.1;
76
72
  --widget-glow-default: 0.5;
77
73
  --widget-border-highlight: oklch(1 0 0 / 0.08);
78
74
  }
79
75
 
80
- /* @property declaration for animatable channel base (VIS-C04, D-11)
81
- initial-value must be a literal <color>; cannot reference var(). */
82
76
  @property --widget-color {
83
77
  syntax: "<color>";
84
78
  inherits: true;
85
79
  initial-value: oklch(0.65 0.02 250);
86
80
  }
87
81
 
88
- /* Channel defaults on the Widget root (VIS-C02, D-08) */
82
+ /* === Widget shell ===
83
+ * Fluid scale tokens — tied to the shell's own container box (cqmin/cqi/cqb).
84
+ * Same input box → same output, so two widgets at the same grid cell match
85
+ * exactly. Tune multipliers / clamps to adjust density. */
89
86
  .glasshome-widget {
90
87
  --widget-color: var(--tone-neutral);
91
88
  --widget-glow-strength: var(--widget-glow-default);
92
- }
93
89
 
94
- /* === Phase 26 additions === */
90
+ --widget-icon-box: clamp(28px, 22cqmin, 64px);
91
+ --widget-icon-glyph: clamp(16px, 13cqmin, 36px);
92
+ --widget-pad: clamp(8px, 4cqmin, 24px);
93
+ --widget-gap: clamp(6px, 2cqmin, 16px);
94
+ --widget-title-size: clamp(12px, 2cqi, 18px);
95
+ --widget-subtitle: clamp(12px, 2.5cqi, 20px);
96
+ --widget-status-size: clamp(14px, 5cqi, 36px);
97
+ --widget-value-size: clamp(18px, 7cqi, 48px);
98
+ --widget-badge-size: clamp(11px, 1.6cqi, 14px);
99
+ }
95
100
 
96
- /* VIS-P01 shell gradient + VIS-P02 inset highlight (D-02, D-03, D-06) */
97
101
  .glasshome-widget {
98
102
  background: var(--widget-gradient,
99
103
  linear-gradient(135deg,
@@ -104,54 +108,125 @@ const Te = `/* packages/public/widget-sdk/src/framework/theming/tokens.css
104
108
  box-shadow: inset 0 1px 0 var(--widget-border-highlight);
105
109
  }
106
110
 
107
- /* VIS-P03 icon channel rendering (D-16) */
111
+ /* === Slot: content layout === */
112
+ /* Default: column. Flip to row only on wide-and-short widgets (matches the
113
+ * old contentLayout heuristic: aspect > 1 AND height < 150px). */
114
+ .glasshome-widget-content {
115
+ position: relative;
116
+ display: flex;
117
+ flex-direction: column;
118
+ justify-content: space-between;
119
+ width: 100%;
120
+ height: 100%;
121
+ padding: var(--widget-pad);
122
+ gap: var(--widget-gap);
123
+ overflow: hidden;
124
+ }
125
+ @container widget (min-aspect-ratio: 1) and (max-height: 149px) {
126
+ .glasshome-widget-content {
127
+ flex-direction: row;
128
+ align-items: center;
129
+ justify-content: flex-start;
130
+ }
131
+ }
132
+ .glasshome-widget-content [class*="ml-auto"] {
133
+ position: relative;
134
+ z-index: 30;
135
+ }
136
+
137
+ /* === Slot: icon === */
108
138
  .glasshome-widget-icon {
139
+ width: var(--widget-icon-box);
140
+ height: var(--widget-icon-box);
141
+ border-radius: var(--radius-sm, 12px);
109
142
  background: var(--widget-icon-color, var(--widget-color));
110
143
  box-shadow: 0 0 calc(var(--widget-glow-strength) * 30px)
111
144
  color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 50%, transparent);
112
- /* Glyph keeps icon-bg hue but flips to L extreme via sign() step + damps chroma.
113
- bg L > 0.5 -> glyph L=0.09 (dark); bg L < 0.5 -> glyph L=0.95 (light).
114
- Chroma 0.2x of bg keeps subtle hue tint without competing with bg saturation.
115
- Requires CSS relative color (Chromium 119+, Safari 16.4+, Firefox 128+) and
116
- sign() (Chromium 111+, Safari 18.2+, Firefox 118+). */
117
145
  color: oklch(from var(--widget-icon-color, var(--widget-color)) calc(0.52 + sign(0.5 - l) * 0.43) calc(c * 0.2) h);
118
146
  }
147
+ .glasshome-widget-icon-glyph {
148
+ font-size: var(--widget-icon-glyph);
149
+ line-height: 1;
150
+ }
151
+ .glasshome-widget-icon-stack {
152
+ position: absolute;
153
+ width: 102%;
154
+ height: 102%;
155
+ border-radius: var(--radius-sm, 12px);
156
+ }
157
+ .glasshome-widget-icon-stack-2 { bottom: -14%; right: -10%; opacity: 0.45; z-index: -2; }
158
+ .glasshome-widget-icon-stack-3 { bottom: -28%; right: -20%; opacity: 0.20; z-index: -3; }
159
+
160
+ /* === Slot: text === */
161
+ .glasshome-widget-title {
162
+ font-size: var(--widget-title-size);
163
+ line-height: 1.2;
164
+ color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);
165
+ overflow: hidden;
166
+ text-overflow: ellipsis;
167
+ white-space: nowrap;
168
+ }
169
+ .glasshome-widget-subtitle {
170
+ font-size: var(--widget-subtitle);
171
+ color: color-mix(in oklch, var(--color-foreground, currentColor) 60%, transparent);
172
+ }
173
+ .glasshome-widget-status {
174
+ font-size: var(--widget-status-size);
175
+ font-weight: 700;
176
+ color: var(--color-foreground, currentColor);
177
+ line-height: 1.1;
178
+ }
179
+ .glasshome-widget-value {
180
+ font-size: var(--widget-value-size);
181
+ font-weight: 700;
182
+ color: var(--color-foreground, currentColor);
183
+ line-height: 1.05;
184
+ }
185
+ .glasshome-widget-badge {
186
+ font-size: var(--widget-badge-size);
187
+ font-weight: 500;
188
+ padding: 0.125rem 0.5rem;
189
+ border-radius: 9999px;
190
+ background: color-mix(in oklch, var(--color-foreground, currentColor) 20%, transparent);
191
+ color: var(--color-foreground, currentColor);
192
+ }
119
193
 
120
- /* D-13 loading overlay tint */
121
194
  .glasshome-widget-loading {
122
195
  background: color-mix(in oklch, var(--widget-color) 20%, transparent);
123
196
  }
124
197
 
125
- /* === Phase 27 additions === */
126
-
127
- /* VIS-P04 slider fill channel rendering (D-05, D-06, D-08).
128
- Mirrors .glasshome-widget-icon precedent: --widget-icon-color override
129
- with --widget-color fallback. Glow rendered via box-shadow on the same
130
- fill element (D-07). 30% bg opacity preserves prior 0.3 default; 40px
131
- blur approximates prior blur-2xl on the deleted glow div; glow radius
132
- modulated by --widget-glow-strength to track the per-mode envelope. */
198
+ /* === Slider fill ===
199
+ * Value flows in via --widget-fill-value (0-100). Vertical orientation auto-
200
+ * detected via container query. */
133
201
  .glasshome-widget-slider-fill {
202
+ --widget-fill-value: 0;
134
203
  background: color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 30%, transparent);
135
204
  box-shadow: 0 0 calc(var(--widget-glow-strength) * 40px)
136
205
  color-mix(in oklch, var(--widget-icon-color, var(--widget-color)) 40%, transparent);
206
+ clip-path: inset(0 calc((100 - var(--widget-fill-value)) * 1%) 0 0);
207
+ }
208
+ @container widget (max-aspect-ratio: 1) {
209
+ .glasshome-widget-slider-fill {
210
+ clip-path: inset(calc((100 - var(--widget-fill-value)) * 1%) 0 0 0);
211
+ }
137
212
  }
138
213
  `;
139
- let ie = !1;
140
- function Ee(e) {
141
- if (ie) return;
214
+ let Q = !1;
215
+ function Me(e) {
216
+ if (Q) return;
142
217
  const t = e ?? (typeof document > "u" ? void 0 : document);
143
218
  if (!t) return;
144
219
  if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
145
- ie = !0;
220
+ Q = !0;
146
221
  return;
147
222
  }
148
- const r = t.createElement("style");
149
- r.setAttribute("data-glasshome-tokens", ""), r.textContent = Te, t.head.appendChild(r), ie = !0;
223
+ const i = t.createElement("style");
224
+ i.setAttribute("data-glasshome-tokens", ""), i.textContent = Se, t.head.appendChild(i), Q = !0;
150
225
  }
151
- function E(...e) {
152
- return ze(De(e));
226
+ function P(...e) {
227
+ return ke($e(e));
153
228
  }
154
- const Oe = {
229
+ const De = {
155
230
  id: "classic-glass",
156
231
  name: "Classic Glass",
157
232
  description: "Default glassmorphism design with blur background and gradient",
@@ -179,7 +254,7 @@ const Oe = {
179
254
  hoverScale: 1.02,
180
255
  activeScale: 0.98
181
256
  }
182
- }, Ne = {
257
+ }, _e = {
183
258
  id: "minimal",
184
259
  name: "Minimal",
185
260
  description: "Clean, minimal design with no background effects",
@@ -208,7 +283,7 @@ const Oe = {
208
283
  active: !1,
209
284
  focus: !0
210
285
  }
211
- }, Ve = {
286
+ }, ze = {
212
287
  id: "compact-horizontal",
213
288
  name: "Compact Horizontal",
214
289
  description: "Horizontal layout for compact widgets",
@@ -236,331 +311,108 @@ const Oe = {
236
311
  hoverScale: 1.02,
237
312
  activeScale: 0.98
238
313
  }
239
- }, Pe = {
240
- "classic-glass": Oe,
241
- minimal: Ne,
242
- "compact-horizontal": Ve
314
+ }, Te = {
315
+ "classic-glass": De,
316
+ minimal: _e,
317
+ "compact-horizontal": ze
243
318
  };
244
- function We(e) {
245
- return Pe[e];
319
+ function Ee(e) {
320
+ return Te[e];
246
321
  }
247
- var He = /* @__PURE__ */ y("<div>");
248
- function Le(e) {
249
- const t = Y(), r = () => t.orientation() === "vertical" ? `inset(${100 - e.value}% 0 0 0)` : `inset(0 ${100 - e.value}% 0 0)`, o = () => {
250
- const n = {
251
- "clip-path": r(),
252
- "z-index": F.BACKGROUND
253
- };
254
- return e.color && (n["--widget-icon-color"] = e.color), n;
255
- };
322
+ var Oe = /* @__PURE__ */ x("<div>");
323
+ function Ne(e) {
256
324
  return (() => {
257
- var n = He();
258
- return T((i) => {
259
- var a = E("glasshome-widget-slider-fill pointer-events-none absolute inset-0", e.isDragging ? "duration-0" : "transition-all duration-300 ease-out", e.class), c = o();
260
- return a !== i.e && N(n, i.e = a), i.t = Q(n, c, i.t), i;
325
+ var t = Oe();
326
+ 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 = {
328
+ "--widget-fill-value": e.value,
329
+ "z-index": G.BACKGROUND,
330
+ ...e.color ? {
331
+ "--widget-icon-color": e.color
332
+ } : {}
333
+ };
334
+ return r !== i.e && R(t, i.e = r), i.t = ie(t, n, i.t), i;
261
335
  }, {
262
336
  e: void 0,
263
337
  t: void 0
264
- }), n;
338
+ }), t;
265
339
  })();
266
340
  }
267
- const X = {
268
- S1: { xs: 4, sm: 4, md: 6, lg: 6, xl: 8 },
269
- S2: { xs: 6, sm: 8, md: 10, lg: 12, xl: 14 },
270
- S3: { xs: 8, sm: 10, md: 12, lg: 14, xl: 16 },
271
- S4: { xs: 12, sm: 14, md: 16, lg: 18, xl: 20 }
272
- }, H = {
273
- /** Extra small spacing (4-8px) */
274
- S1: (e) => `${X.S1[e]}px`,
275
- /** Small spacing (6-14px) - default for most layouts */
276
- S2: (e) => `${X.S2[e]}px`,
277
- /** Medium spacing (8-16px) */
278
- S3: (e) => `${X.S3[e]}px`,
279
- /** Large spacing (12-20px) */
280
- S4: (e) => `${X.S4[e]}px`,
281
- /** Icon container size in pixels */
282
- icon: (e) => ({
283
- xs: 32,
284
- // 1x1, 1x2 widgets
285
- sm: 40,
286
- // 2x1, 2x2 widgets (current WidgetIcon default)
287
- md: 48,
288
- // 2x3, 2x4 widgets
289
- lg: 52,
290
- // 2x6, 3x6, 4x2 widgets
291
- xl: 56
292
- // 4x4 widgets
293
- })[e],
294
- /** Icon stroke size for lucide icons */
295
- iconSize: (e) => ({
296
- xs: 18,
297
- // Smaller stroke for tiny widgets
298
- sm: 20,
299
- // Current WidgetIcon default (size-5 = 20px)
300
- md: 24,
301
- // Medium widgets
302
- lg: 26,
303
- // Large widgets
304
- xl: 28
305
- // Extra large widgets
306
- })[e],
307
- /** Spacing between icon and title */
308
- iconToTitle: (e) => ({
309
- xs: "8px",
310
- // Tight spacing for small widgets
311
- sm: "10px",
312
- // Slightly more room
313
- md: "12px",
314
- // Current pattern from LockWidget (@[300px]:mt-3 = 12px)
315
- lg: "14px",
316
- // More breathing room
317
- xl: "16px"
318
- // Maximum spacing (@[400px]:mt-4 = 16px)
319
- })[e],
320
- /** Container padding */
321
- container: (e) => ({
322
- xs: "8px",
323
- // Minimal padding for tiny widgets
324
- sm: "16px",
325
- // Current BaseWidget default (p-4 = 16px)
326
- md: "16px",
327
- lg: "20px",
328
- // More padding for larger widgets
329
- xl: "20px"
330
- })[e]
331
- }, Ae = {
332
- 4: "gap-1",
333
- 6: "gap-1.5",
334
- 8: "gap-2",
335
- 10: "gap-2.5",
336
- 12: "gap-3",
337
- 14: "gap-3.5",
338
- 16: "gap-4",
339
- 18: "gap-[18px]",
340
- 20: "gap-5"
341
- };
342
- function Ie(e, t) {
343
- const r = X[e][t];
344
- return Ae[r] || `gap-[${r}px]`;
345
- }
346
- var Re = /* @__PURE__ */ y("<div>");
347
- function Ge(e) {
348
- const t = Y();
341
+ var Ve = /* @__PURE__ */ x("<div>");
342
+ function Ae(e) {
349
343
  return (() => {
350
- var r = Re();
351
- return p(r, () => e.children), T((o) => {
352
- var n = E(
353
- "relative flex h-full w-full overflow-hidden",
354
- // Ensure controls (ml-auto divs) are above other content
355
- "[&_div.ml-auto]:relative [&_div.ml-auto]:z-30",
356
- t.contentLayout() === "horizontal" ? "flex-row items-center" : "flex-col justify-between",
357
- Ie("S3", t.size()),
358
- e.class
359
- ), i = H.container(t.size()), a = F.CONTENT;
360
- return n !== o.e && N(r, o.e = n), i !== o.t && A(r, "padding", o.t = i), a !== o.a && A(r, "z-index", o.a = a), o;
361
- }, {
362
- e: void 0,
363
- t: void 0,
364
- a: void 0
365
- }), r;
344
+ var t = Ve();
345
+ return p(t, () => e.children), W(() => R(t, P("glasshome-widget-content", e.class))), t;
366
346
  })();
367
347
  }
368
- var Ue = /* @__PURE__ */ y('<div><div class="flex items-center justify-center">'), ge = /* @__PURE__ */ y('<div class="glasshome-widget-icon absolute">');
369
- function Be(e) {
370
- const t = Y(), r = () => {
371
- const n = {
372
- width: `${H.icon(t.size())}px`,
373
- height: `${H.icon(t.size())}px`,
374
- "border-radius": "var(--radius-sm, 12px)"
375
- };
376
- return e.color && (n["--widget-icon-color"] = e.color), n;
377
- }, o = (n, i, a) => ({
378
- width: `${H.icon(t.size()) * 1.02}px`,
379
- height: `${H.icon(t.size()) * 1.02}px`,
380
- "border-radius": "var(--radius-sm, 12px)",
381
- bottom: `${-H.icon(t.size()) * n}px`,
382
- right: `${-H.icon(t.size()) * (n * 0.71)}px`,
383
- "z-index": i,
384
- opacity: a
385
- });
348
+ var We = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2">'), Pe = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3">'), He = /* @__PURE__ */ x('<div><div class="glasshome-widget-icon-glyph flex items-center justify-center">');
349
+ function Re(e) {
350
+ const t = () => e.entityCount ?? 1;
386
351
  return (() => {
387
- var n = Ue(), i = n.firstChild;
388
- return p(n, (() => {
389
- var a = _(() => (e.entityCount ?? 1) >= 2);
390
- return () => a() && (() => {
391
- var c = ge();
392
- return T((x) => Q(c, o(0.14, -2, 0.45), x)), c;
393
- })();
394
- })(), i), p(n, (() => {
395
- var a = _(() => (e.entityCount ?? 1) >= 3);
396
- return () => a() && (() => {
397
- var c = ge();
398
- return T((x) => Q(c, o(0.28, -3, 0.2), x)), c;
399
- })();
400
- })(), i), p(i, () => e.icon), T((a) => {
401
- var c = E("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center transition-all", "pointer-events-none", e.dimmed && "opacity-50", e.class), x = r(), w = `${H.iconSize(t.size())}px`;
402
- return c !== a.e && N(n, a.e = c), a.t = Q(n, x, a.t), w !== a.a && A(i, "font-size", a.a = w), a;
352
+ var i = He(), r = i.firstChild;
353
+ return p(i, $(E, {
354
+ get when() {
355
+ return t() >= 2;
356
+ },
357
+ get children() {
358
+ return We();
359
+ }
360
+ }), r), p(i, $(E, {
361
+ get when() {
362
+ return t() >= 3;
363
+ },
364
+ get children() {
365
+ return Pe();
366
+ }
367
+ }), r), p(r, () => e.icon), W((n) => {
368
+ var o = P("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center pointer-events-none transition-all", e.dimmed && "opacity-50", e.class), h = e.color ? {
369
+ "--widget-icon-color": e.color
370
+ } : void 0;
371
+ return o !== n.e && R(i, n.e = o), n.t = ie(i, h, n.t), n;
403
372
  }, {
404
373
  e: void 0,
405
- t: void 0,
406
- a: void 0
407
- }), n;
374
+ t: void 0
375
+ }), i;
408
376
  })();
409
377
  }
410
- const Z = {
411
- /** Container base text sizing */
412
- container: (e) => ({
413
- xs: "text-xs",
414
- // Smallest widgets
415
- sm: "text-sm",
416
- // Small widgets
417
- md: "text-base",
418
- // Medium widgets
419
- lg: "text-base",
420
- // Large widgets
421
- xl: "text-lg"
422
- // Extra large widgets
423
- })[e],
424
- /** Title text sizing (main heading) */
425
- title: (e) => ({
426
- xs: "text-xs",
427
- // 12px - Very compact
428
- sm: "text-xs",
429
- // 12px - Stay small
430
- md: "text-sm",
431
- // 14px - More readable (@[300px] equivalent)
432
- lg: "text-sm",
433
- // 14px - Maintain size
434
- xl: "text-sm"
435
- // 14px - Don't go too large for secondary text
436
- })[e],
437
- /** Subtitle/secondary text sizing */
438
- subtitle: (e) => ({
439
- xs: "text-xs",
440
- // 12px - Very compact
441
- sm: "text-sm",
442
- // 12px - Stay small
443
- md: "text-base",
444
- // 14px - More readable (@[300px] equivalent)
445
- lg: "text-base",
446
- // 14px - Maintain size
447
- xl: "text-base"
448
- // 14px - Don't go too large for secondary text
449
- })[e],
450
- /** Value display text sizing (large numbers) */
451
- value: (e) => ({
452
- xs: "text-lg",
453
- // 18px - Still readable on small widgets
454
- sm: "text-xl",
455
- // 20px - Slightly larger
456
- md: "text-2xl",
457
- // 24px - Prominent
458
- lg: "text-3xl",
459
- // 30px - Very prominent
460
- xl: "text-4xl"
461
- // 36px - Maximum impact
462
- })[e],
463
- /** Badge text sizing (entity count badges) */
464
- badge: (e) => ({
465
- xs: "text-xs",
466
- // 12px - Compact badge
467
- sm: "text-xs",
468
- // 12px - Keep small
469
- md: "text-xs",
470
- // 12px - Badges should stay small
471
- lg: "text-sm",
472
- // 14px - Slightly larger for readability
473
- xl: "text-sm"
474
- // 14px - Maximum badge size
475
- })[e],
476
- /** Metric label text sizing */
477
- metricLabel: (e) => ({
478
- xs: "text-xs",
479
- // 12px - Compact labels
480
- sm: "text-xs",
481
- // 12px
482
- md: "text-xs",
483
- // 12px - Labels stay small
484
- lg: "text-sm",
485
- // 14px - More readable on large widgets
486
- xl: "text-sm"
487
- // 14px
488
- })[e],
489
- /** Metric value text sizing */
490
- metricValue: (e) => ({
491
- xs: "text-sm",
492
- // 14px - Readable metric values
493
- sm: "text-sm",
494
- // 14px
495
- md: "text-sm",
496
- // 14px - Keep metrics compact
497
- lg: "text-base",
498
- // 16px - Slightly larger
499
- xl: "text-base"
500
- // 16px
501
- })[e],
502
- /** Status text (same as subtitle but semantic) */
503
- status: (e) => ({
504
- xs: "text-md",
505
- sm: "text-xl",
506
- md: "text-2xl",
507
- lg: "text-3xl",
508
- xl: "text-3xl"
509
- })[e],
510
- /** Empty state message text */
511
- emptyState: (e) => ({
512
- xs: "text-xs",
513
- // 12px
514
- sm: "text-sm",
515
- // 14px
516
- md: "text-sm",
517
- // 14px
518
- lg: "text-base",
519
- // 16px
520
- xl: "text-base"
521
- // 16px
522
- })[e]
523
- };
524
- var je = /* @__PURE__ */ y("<p>");
525
- function Fe(e) {
526
- const t = Y();
378
+ var Ie = /* @__PURE__ */ x("<p>");
379
+ function je(e) {
527
380
  return (() => {
528
- var r = je();
529
- return p(r, (() => {
530
- var o = _(() => !!e.isUnavailable);
531
- return () => o() ? "Unavailable" : e.children;
532
- })()), T((o) => {
533
- var n = E("relative font-bold text-foreground", e.dimmed && "opacity-40", Z.status(t.size()), e.class), i = F.ACTIONS;
534
- return n !== o.e && N(r, o.e = n), i !== o.t && A(r, "z-index", o.t = i), o;
381
+ var t = Ie();
382
+ return p(t, (() => {
383
+ var i = _(() => !!e.isUnavailable);
384
+ return () => i() ? "Unavailable" : e.children;
385
+ })()), W((i) => {
386
+ var r = P("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), n = G.ACTIONS;
387
+ return r !== i.e && R(t, i.e = r), n !== i.t && Y(t, "z-index", i.t = n), i;
535
388
  }, {
536
389
  e: void 0,
537
390
  t: void 0
538
- }), r;
391
+ }), t;
539
392
  })();
540
393
  }
541
- var Ye = /* @__PURE__ */ y("<div><h3>"), Ke = /* @__PURE__ */ y("<span>");
542
- function qe(e) {
543
- const t = Y();
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) {
544
396
  return (() => {
545
- var r = Ye(), o = r.firstChild;
546
- return p(o, () => e.children), p(r, (() => {
547
- var n = _(() => e.badge !== void 0 && e.badge > 0);
548
- return () => n() && (() => {
549
- var i = Ke();
550
- return p(i, () => e.badge), T(() => N(i, E("shrink-0 rounded-full bg-foreground/20 px-2 py-0.5 font-medium text-foreground", Z.badge(t.size())))), i;
551
- })();
552
- })(), null), T((n) => {
553
- var i = E("relative flex items-center", e.class), a = H.S1(t.size()), c = F.ACTIONS, x = E("truncate text-foreground/60", Z.title(t.size()));
554
- return i !== n.e && N(r, n.e = i), a !== n.t && A(r, "gap", n.t = a), c !== n.a && A(r, "z-index", n.a = c), x !== n.o && N(o, n.o = x), n;
397
+ var t = Be(), i = t.firstChild;
398
+ return p(i, () => e.children), p(t, $(E, {
399
+ get when() {
400
+ return _(() => e.badge !== void 0)() && e.badge > 0;
401
+ },
402
+ get children() {
403
+ var r = Le();
404
+ return p(r, () => e.badge), r;
405
+ }
406
+ }), null), W((r) => {
407
+ var n = P("relative flex items-center gap-2", e.class), o = G.ACTIONS;
408
+ return n !== r.e && R(t, r.e = n), o !== r.t && Y(t, "z-index", r.t = o), r;
555
409
  }, {
556
410
  e: void 0,
557
- t: void 0,
558
- a: void 0,
559
- o: void 0
560
- }), r;
411
+ t: void 0
412
+ }), t;
561
413
  })();
562
414
  }
563
- function Xe(e, t = !1) {
415
+ function Fe(e, t = !1) {
564
416
  if (e.length === 0)
565
417
  return {
566
418
  isGroup: !1,
@@ -574,64 +426,64 @@ function Xe(e, t = !1) {
574
426
  totalCount: 0,
575
427
  description: "No entities"
576
428
  };
577
- const r = e.length > 1;
578
- if (!r) {
579
- const m = e[0], l = m.state === "on", k = m.attributes?.brightness || 0, b = Math.round(k / 255 * 100);
429
+ const i = e.length > 1;
430
+ if (!i) {
431
+ const b = e[0], M = b.state === "on", N = b.attributes?.brightness || 0, D = Math.round(N / 255 * 100);
580
432
  return {
581
433
  isGroup: !1,
582
- state: m.state,
583
- isOn: l,
584
- isUnavailable: m.state === "unavailable",
585
- brightness: k,
586
- brightnessPercent: b,
587
- color: he(m),
588
- onCount: l ? 1 : 0,
434
+ state: b.state,
435
+ isOn: M,
436
+ isUnavailable: b.state === "unavailable",
437
+ brightness: N,
438
+ brightnessPercent: D,
439
+ color: se(b),
440
+ onCount: M ? 1 : 0,
589
441
  totalCount: 1,
590
- description: l ? "On" : "Off"
442
+ description: M ? "On" : "Off"
591
443
  };
592
444
  }
593
- let o = 0, n = 0, i = 0, a = 0, c = 0, x = 0;
594
- const w = [];
595
- for (const m of e)
596
- switch (m.state) {
445
+ let r = 0, n = 0, o = 0, h = 0, g = 0, y = 0;
446
+ const f = [];
447
+ for (const b of e)
448
+ switch (b.state) {
597
449
  case "on":
598
- o++, m.attributes?.brightness !== void 0 && (c += m.attributes.brightness, x++), m.attributes?.rgb_color && w.push(m.attributes.rgb_color);
450
+ r++, b.attributes?.brightness !== void 0 && (g += b.attributes.brightness, y++), b.attributes?.rgb_color && f.push(b.attributes.rgb_color);
599
451
  break;
600
452
  case "off":
601
453
  n++;
602
454
  break;
603
455
  case "unknown":
604
- i++;
456
+ o++;
605
457
  break;
606
458
  case "unavailable":
607
- a++;
459
+ h++;
608
460
  break;
609
461
  }
610
- const v = e.length, S = a === v, W = i + a === v, g = o > 0, f = o === v, D = n === v;
611
- let $, C;
612
- t ? S ? ($ = "unavailable", C = !1) : i > 0 || a > 0 ? ($ = "unknown", C = !1) : n > 0 ? ($ = "off", C = !1) : ($ = "on", C = !0) : S ? ($ = "unavailable", C = !1) : W ? ($ = "unknown", C = !1) : g ? ($ = "on", C = !0) : ($ = "off", C = !1);
613
- const I = x > 0 ? Math.round(c / x) : 0, B = Math.round(I / 255 * 100);
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);
614
466
  let u;
615
- if (w.length > 0) {
616
- const m = Math.round(w.reduce((s, z) => s + z[0], 0) / w.length), l = Math.round(w.reduce((s, z) => s + z[1], 0) / w.length), k = Math.round(w.reduce((s, z) => s + z[2], 0) / w.length), b = I / 255;
617
- u = `rgb(${Math.round(m * b)}, ${Math.round(l * b)}, ${Math.round(k * b)})`;
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)})`;
618
470
  } else
619
- u = he(e[0]);
620
- let h;
621
- return f ? h = "All on" : D ? h = "All off" : o > 0 ? h = `${o} of ${v} on` : h = "Off", {
622
- isGroup: r,
623
- state: $,
624
- isOn: C,
625
- isUnavailable: $ === "unavailable",
626
- brightness: I,
627
- brightnessPercent: B,
471
+ u = se(e[0]);
472
+ let m;
473
+ return a ? m = "All on" : C ? m = "All off" : r > 0 ? m = `${r} of ${c} on` : m = "Off", {
474
+ isGroup: i,
475
+ state: w,
476
+ isOn: S,
477
+ isUnavailable: w === "unavailable",
478
+ brightness: O,
479
+ brightnessPercent: I,
628
480
  color: u,
629
- onCount: o,
630
- totalCount: v,
631
- description: h
481
+ onCount: r,
482
+ totalCount: c,
483
+ description: m
632
484
  };
633
485
  }
634
- function Je(e, t = "mean", r = !0) {
486
+ function Ge(e, t = "mean", i = !0) {
635
487
  if (e.length === 0)
636
488
  return {
637
489
  isGroup: !1,
@@ -640,114 +492,114 @@ function Je(e, t = "mean", r = !0) {
640
492
  isUnavailable: !0,
641
493
  description: "No entities"
642
494
  };
643
- const o = e.length > 1;
644
- if (!o) {
645
- const g = e[0], f = Number.parseFloat(g.state);
646
- let D = g.state;
647
- return Number.isNaN(f) || (D = Number.isInteger(f) ? f.toString() : f.toFixed(1)), {
495
+ const r = e.length > 1;
496
+ if (!r) {
497
+ const d = e[0], a = Number.parseFloat(d.state);
498
+ let C = d.state;
499
+ return Number.isNaN(a) || (C = Number.isInteger(a) ? a.toString() : a.toFixed(1)), {
648
500
  isGroup: !1,
649
- state: D,
650
- numericValue: Number.isNaN(f) ? null : f,
651
- isUnavailable: g.state === "unavailable",
652
- unit: g.unitOfMeasurement ?? void 0,
653
- description: D
501
+ state: C,
502
+ numericValue: Number.isNaN(a) ? null : a,
503
+ isUnavailable: d.state === "unavailable",
504
+ unit: d.unitOfMeasurement ?? void 0,
505
+ description: C
654
506
  };
655
507
  }
656
- const n = [], i = [];
657
- let a = 0, c;
658
- for (const g of e) {
659
- if (!c && g.unitOfMeasurement && (c = g.unitOfMeasurement), g.state === "unavailable") {
660
- a++, i.push({
661
- entityId: g.id,
508
+ const n = [], o = [];
509
+ let h = 0, g;
510
+ for (const d of e) {
511
+ if (!g && d.unitOfMeasurement && (g = d.unitOfMeasurement), d.state === "unavailable") {
512
+ h++, o.push({
513
+ entityId: d.id,
662
514
  value: "unavailable",
663
- friendly_name: g.friendlyName
515
+ friendly_name: d.friendlyName
664
516
  });
665
517
  continue;
666
518
  }
667
- const f = Number.parseFloat(g.state);
668
- isNaN(f) ? r || i.push({
669
- entityId: g.id,
670
- value: g.state,
671
- friendly_name: g.friendlyName
672
- }) : (n.push(f), i.push({
673
- entityId: g.id,
674
- value: f,
675
- friendly_name: g.friendlyName
519
+ const a = Number.parseFloat(d.state);
520
+ isNaN(a) ? i || o.push({
521
+ entityId: d.id,
522
+ value: d.state,
523
+ friendly_name: d.friendlyName
524
+ }) : (n.push(a), o.push({
525
+ entityId: d.id,
526
+ value: a,
527
+ friendly_name: d.friendlyName
676
528
  }));
677
529
  }
678
- const x = a === e.length, w = n.length === 0;
679
- if (x || w)
530
+ const y = h === e.length, f = n.length === 0;
531
+ if (y || f)
680
532
  return {
681
- isGroup: o,
682
- state: x ? "unavailable" : "unknown",
533
+ isGroup: r,
534
+ state: y ? "unavailable" : "unknown",
683
535
  numericValue: null,
684
- isUnavailable: x,
685
- unit: c,
686
- description: x ? "Unavailable" : "No numeric values",
687
- memberValues: i
536
+ isUnavailable: y,
537
+ unit: g,
538
+ description: y ? "Unavailable" : "No numeric values",
539
+ memberValues: o
688
540
  };
689
- let v, S;
541
+ let c, v;
690
542
  switch (t) {
691
543
  case "min":
692
- v = Math.min(...n), S = "Minimum";
544
+ c = Math.min(...n), v = "Minimum";
693
545
  break;
694
546
  case "max":
695
- v = Math.max(...n), S = "Maximum";
547
+ c = Math.max(...n), v = "Maximum";
696
548
  break;
697
549
  case "mean":
698
- v = n.reduce((g, f) => g + f, 0) / n.length, S = "Average";
550
+ c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
699
551
  break;
700
552
  case "median": {
701
- const g = [...n].sort((D, $) => D - $), f = Math.floor(g.length / 2);
702
- v = g.length % 2 === 0 ? (g[f - 1] + g[f]) / 2 : g[f], S = "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";
703
555
  break;
704
556
  }
705
557
  case "sum":
706
- v = n.reduce((g, f) => g + f, 0), S = "Sum";
558
+ c = n.reduce((d, a) => d + a, 0), v = "Sum";
707
559
  break;
708
560
  case "last":
709
- v = n[n.length - 1], S = "Latest";
561
+ c = n[n.length - 1], v = "Latest";
710
562
  break;
711
563
  case "range":
712
- v = Math.max(...n) - Math.min(...n), S = "Range";
564
+ c = Math.max(...n) - Math.min(...n), v = "Range";
713
565
  break;
714
566
  case "product":
715
- v = n.reduce((g, f) => g * f, 1), S = "Product";
567
+ c = n.reduce((d, a) => d * a, 1), v = "Product";
716
568
  break;
717
569
  case "std_dev": {
718
- const g = n.reduce((D, $) => D + $, 0) / n.length, f = n.reduce((D, $) => D + ($ - g) ** 2, 0) / n.length;
719
- v = Math.sqrt(f), S = "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";
720
572
  break;
721
573
  }
722
574
  default:
723
- v = n.reduce((g, f) => g + f, 0) / n.length, S = "Average";
575
+ c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
724
576
  }
725
- const W = Number.isInteger(v) ? v.toString() : v.toFixed(1);
577
+ const k = Number.isInteger(c) ? c.toString() : c.toFixed(1);
726
578
  return {
727
- isGroup: o,
728
- state: W,
729
- numericValue: v,
579
+ isGroup: r,
580
+ state: k,
581
+ numericValue: c,
730
582
  isUnavailable: !1,
731
- unit: c,
732
- description: `${S} of ${n.length}`,
733
- memberValues: i
583
+ unit: g,
584
+ description: `${v} of ${n.length}`,
585
+ memberValues: o
734
586
  };
735
587
  }
736
- function he(e) {
588
+ function se(e) {
737
589
  if (e.state !== "on") return "rgb(100, 100, 100)";
738
- const r = (e.attributes?.brightness ?? 255) / 255;
590
+ const i = (e.attributes?.brightness ?? 255) / 255;
739
591
  if (e.attributes?.rgb_color) {
740
- const [o, n, i] = e.attributes.rgb_color;
741
- return `rgb(${Math.round(o * r)}, ${Math.round(n * r)}, ${Math.round(i * r)})`;
592
+ const [r, n, o] = e.attributes.rgb_color;
593
+ return `rgb(${Math.round(r * i)}, ${Math.round(n * i)}, ${Math.round(o * i)})`;
742
594
  }
743
595
  if (e.attributes?.color_temp) {
744
596
  const n = 1e6 / e.attributes.color_temp / 100;
745
- let i, a, c;
746
- return n <= 66 ? (i = 255, a = n <= 19 ? 0 : 99.4708025861 * Math.log(n - 10) - 161.1195681661, c = n <= 19 ? 0 : n <= 66 ? 138.5177312231 * Math.log(n - 10) - 305.0447927307 : 255) : (i = 329.698727446 * (n - 60) ** -0.1332047592, a = 288.1221695283 * (n - 60) ** -0.0755148492, c = 255), i = Math.max(0, Math.min(255, i)) * r, a = Math.max(0, Math.min(255, a)) * r, c = Math.max(0, Math.min(255, c)) * r, `rgb(${Math.round(i)}, ${Math.round(a)}, ${Math.round(c)})`;
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)})`;
747
599
  }
748
- return `rgb(${Math.round(255 * r)}, ${Math.round(220 * r)}, ${Math.round(180 * r)})`;
600
+ return `rgb(${Math.round(255 * i)}, ${Math.round(220 * i)}, ${Math.round(180 * i)})`;
749
601
  }
750
- function Qe(e) {
602
+ function qe(e) {
751
603
  if (!e) return !1;
752
604
  if (["on", "open", "locked", "home", "playing", "active"].includes(e.state))
753
605
  return !0;
@@ -757,118 +609,63 @@ function Qe(e) {
757
609
  }
758
610
  return !1;
759
611
  }
760
- function Bt(e, t, r) {
761
- return e?.attributes ? e.attributes[t] ?? r : r;
612
+ function Rt(e, t, i) {
613
+ return e?.attributes ? e.attributes[t] ?? i : i;
762
614
  }
763
- function jt(e) {
764
- return e.filter(Qe).length;
615
+ function It(e) {
616
+ return e.filter(qe).length;
765
617
  }
766
- function Ze(e, t, r) {
767
- const { decimals: o, scale: n = !0 } = {};
618
+ function Ye(e, t, i) {
619
+ const { decimals: r, scale: n = !0 } = {};
768
620
  if (typeof e == "string")
769
621
  return t ? `${e}${t}` : e;
770
622
  if (e == null || Number.isNaN(e))
771
623
  return t ? `--${t}` : "--";
772
- let i = e, a = t || "";
773
- n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (i = e / 1e6, a = "MW") : e >= 1e3 ? (i = e / 1e3, a = "kW") : a = "W"), n && t && (t === "B" || t === "KB" || t === "MB" || t === "GB") && (e >= 1073741824 ? (i = e / 1073741824, a = "GB") : e >= 1048576 ? (i = e / 1048576, a = "MB") : e >= 1024 ? (i = e / 1024, a = "KB") : a = "B");
774
- let c;
775
- return o !== void 0 ? c = i.toFixed(o) : i !== e ? c = i.toFixed(1) : Number.isInteger(e) ? c = e.toString() : c = Number.parseFloat(e.toFixed(2)).toString(), a ? `${c}${a}` : c;
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;
776
628
  }
777
- function et(e, t) {
629
+ function Ke(e, t) {
778
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;
779
631
  }
780
- var tt = /* @__PURE__ */ y("<div><div>"), nt = /* @__PURE__ */ y("<div>");
781
- function rt(e) {
782
- const t = Y();
632
+ var Xe = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), Je = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
633
+ function Qe(e) {
783
634
  return (() => {
784
- var r = tt(), o = r.firstChild;
785
- return p(o, () => Ze(e.value, e.unit)), p(r, (() => {
786
- var n = _(() => !!(e.interpret && typeof e.value == "number"));
787
- return () => n() && (() => {
788
- var i = nt();
789
- return p(i, () => et(e.value, e.unit)), T((a) => {
790
- var c = E("text-foreground/60", Z.subtitle(t.size())), x = H.S1(t.size());
791
- return c !== a.e && N(i, a.e = c), x !== a.t && A(i, "margin-top", a.t = x), a;
792
- }, {
793
- e: void 0,
794
- t: void 0
795
- }), i;
796
- })();
797
- })(), null), T((n) => {
798
- var i = E("flex flex-col", e.class), a = E("font-bold text-foreground", Z.value(t.size()));
799
- return i !== n.e && N(r, n.e = i), a !== n.t && N(o, n.t = a), n;
800
- }, {
801
- e: void 0,
802
- t: void 0
803
- }), r;
635
+ var t = Je(), i = t.firstChild;
636
+ return p(i, () => Ye(e.value, e.unit)), p(t, $(E, {
637
+ get when() {
638
+ return _(() => !!e.interpret)() && typeof e.value == "number";
639
+ },
640
+ get children() {
641
+ var r = Xe();
642
+ return p(r, () => Ke(e.value, e.unit)), r;
643
+ }
644
+ }), null), W(() => R(t, P("flex flex-col", e.class))), t;
804
645
  })();
805
646
  }
806
- var it = /* @__PURE__ */ y('<div><div class="relative h-full w-full">'), ot = /* @__PURE__ */ y('<div class="glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse">'), at = /* @__PURE__ */ y('<div class="flex h-full w-full flex-col items-center justify-center gap-2 text-center">'), st = /* @__PURE__ */ y('<div class="flex items-center justify-center text-white/30">'), lt = /* @__PURE__ */ y('<h3 class="font-semibold text-sm text-white/60">'), ct = /* @__PURE__ */ y('<p class="text-white/50 text-xs">');
807
- function dt(e, t) {
808
- const r = e * t;
809
- return r <= 2 ? "xs" : r <= 4 ? "sm" : r <= 8 ? "md" : r <= 18 ? "lg" : "xl";
810
- }
811
- function ut(e, t) {
812
- return e > t ? "horizontal" : t > e ? "vertical" : "square";
813
- }
814
- function gt(e, t) {
815
- return t >= 150 ? "vertical" : e > t ? "horizontal" : t > e ? "vertical" : "square";
816
- }
817
- function ht(e) {
818
- Ce(() => {
819
- Ee();
820
- });
821
- let t;
822
- const r = Se(() => t), o = 2, [n, i] = U(0), [a, c] = U(0);
823
- R(() => {
824
- const l = Math.round(r.width ?? 0), k = Math.round(r.height ?? 0), b = de(n), s = de(a);
825
- (Math.abs(l - b) > o || Math.abs(k - s) > o) && (i(l), c(k));
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();
826
651
  });
827
- const x = V(() => {
828
- if (e.variant)
829
- return typeof e.variant == "string" ? We(e.variant) : e.variant;
830
- }), w = V(() => ({
831
- width: n(),
832
- height: a(),
833
- gridWidth: Math.max(1, Math.round(n() / 150)),
834
- gridHeight: Math.max(1, Math.round(a() / 75))
835
- }), void 0, {
836
- equals: (l, k) => l.width === k.width && l.height === k.height && l.gridWidth === k.gridWidth && l.gridHeight === k.gridHeight
837
- }), v = V(() => {
838
- const l = w();
839
- return dt(l.gridWidth, l.gridHeight);
840
- }), S = V(() => {
841
- const l = w();
842
- return ut(l.width, l.height);
843
- }), W = V(() => {
844
- const l = w();
845
- return gt(l.width, l.height);
846
- }), g = fe(se), f = g;
847
- f?._isStub?.() && f._bridge && (R(() => {
848
- f._bridge.setSize(v());
849
- }), R(() => {
850
- f._bridge.setOrientation(S());
851
- }), R(() => {
852
- f._bridge.setContentLayout(W());
853
- }), R(() => {
854
- f._bridge.setDimensions(w());
855
- }), R(() => {
856
- f._bridge.setIsStub(!1);
857
- }));
858
- const D = {
859
- size: v,
860
- orientation: S,
861
- contentLayout: W,
862
- dimensions: w,
652
+ const t = le(ne), [i, r] = H(), n = be(i), o = {
863
653
  isEditMode: () => e.isEditMode ?? !1,
864
- updateConfig: g?.updateConfig ?? (() => {
654
+ updateConfig: t?.updateConfig ?? (() => {
655
+ }),
656
+ dimensions: () => ({
657
+ width: n.width ?? 0,
658
+ height: n.height ?? 0
865
659
  })
866
- }, $ = V(() => ({
660
+ }, h = L(() => {
661
+ if (e.variant)
662
+ return typeof e.variant == "string" ? Ee(e.variant) : e.variant;
663
+ }), g = L(() => ({
867
664
  "container-type": "size",
868
665
  "container-name": "widget",
869
666
  "touch-action": e.gestures && !e.isEditMode ? e.gestures.touchAction() : void 0,
870
- ...x()?.styles?.container,
871
- ...x()?.styles?.cssVars || {},
667
+ ...h()?.styles?.container,
668
+ ...h()?.styles?.cssVars || {},
872
669
  ...e.tone ? {
873
670
  "--widget-color": `var(--tone-${e.tone})`
874
671
  } : {},
@@ -881,26 +678,26 @@ function ht(e) {
881
678
  ...e.gradient ? {
882
679
  "--widget-gradient": e.gradient
883
680
  } : {}
884
- })), C = () => !!e.gestures && !e.isEditMode, I = (l) => {
885
- C() && e.gestures?.onPointerEnter(l);
886
- }, B = (l) => {
887
- C() && e.gestures?.onPointerDown(l);
888
- }, u = (l) => {
889
- C() && e.gestures?.onPointerMove(l);
890
- }, h = (l) => {
891
- C() && e.gestures?.onPointerUp(l);
892
- }, m = (l) => {
893
- C() && e.gestures?.onPointerCancel(l);
681
+ })), y = () => !!e.gestures && !e.isEditMode, f = (a) => {
682
+ y() && e.gestures?.onPointerEnter(a);
683
+ }, c = (a) => {
684
+ y() && e.gestures?.onPointerDown(a);
685
+ }, v = (a) => {
686
+ y() && e.gestures?.onPointerMove(a);
687
+ }, k = (a) => {
688
+ y() && e.gestures?.onPointerUp(a);
689
+ }, d = (a) => {
690
+ y() && e.gestures?.onPointerCancel(a);
894
691
  };
895
- return M(se.Provider, {
896
- value: D,
692
+ return $(ne.Provider, {
693
+ value: o,
897
694
  get children() {
898
- var l = it(), k = l.firstChild;
899
- return q(l, "pointercancel", m), q(l, "pointerup", h), q(l, "pointermove", u), q(l, "pointerdown", B), q(l, "pointerenter", I), ye((b) => {
900
- t = b, e.gestures?.bindElement(b);
901
- }, l), p(k, (() => {
902
- var b = _(() => !!e.emptyState);
903
- return () => b() ? M(ft, {
695
+ var a = Ze(), C = a.firstChild;
696
+ return U(a, "pointercancel", d), U(a, "pointerup", k), U(a, "pointermove", v), U(a, "pointerdown", c), U(a, "pointerenter", f), ve((w) => {
697
+ r(w), e.gestures?.bindElement(w);
698
+ }, a), p(C, (() => {
699
+ var w = _(() => !!e.emptyState);
700
+ return () => w() ? $(at, {
904
701
  get icon() {
905
702
  return e.emptyState.icon;
906
703
  },
@@ -911,93 +708,86 @@ function ht(e) {
911
708
  return e.emptyState.message;
912
709
  }
913
710
  }) : e.children;
914
- })()), p(l, (() => {
915
- var b = _(() => !!e.loading);
916
- return () => b() && (() => {
917
- var s = ot();
918
- return T((z) => A(s, "z-index", F.OVERLAY)), s;
711
+ })()), p(a, (() => {
712
+ var w = _(() => !!e.loading);
713
+ return () => w() && (() => {
714
+ var S = et();
715
+ return W((O) => Y(S, "z-index", G.OVERLAY)), S;
919
716
  })();
920
- })(), null), T((b) => {
921
- var s = E(
922
- "glasshome-widget",
923
- "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50",
924
- // Variant styles (lowest priority)
925
- x()?.styles?.class,
926
- // Custom class (highest priority)
927
- e.class
928
- ), z = $(), O = F.CONTENT;
929
- return s !== b.e && N(l, b.e = s), b.t = Q(l, z, b.t), O !== b.a && A(k, "z-index", b.a = O), b;
717
+ })(), null), W((w) => {
718
+ var S = P("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", h()?.styles?.class, e.class), O = g(), I = G.CONTENT;
719
+ return S !== w.e && R(a, w.e = S), w.t = ie(a, O, w.t), I !== w.a && Y(C, "z-index", w.a = I), w;
930
720
  }, {
931
721
  e: void 0,
932
722
  t: void 0,
933
723
  a: void 0
934
- }), l;
724
+ }), a;
935
725
  }
936
726
  });
937
727
  }
938
- function ft(e) {
728
+ function at(e) {
939
729
  return (() => {
940
- var t = at();
730
+ var t = tt();
941
731
  return p(t, (() => {
942
- var r = _(() => !!e.icon);
943
- return () => r() && (() => {
944
- var o = st();
945
- return p(o, () => e.icon), o;
732
+ var i = _(() => !!e.icon);
733
+ return () => i() && (() => {
734
+ var r = nt();
735
+ return p(r, () => e.icon), r;
946
736
  })();
947
737
  })(), null), p(t, (() => {
948
- var r = _(() => !!e.title);
949
- return () => r() && (() => {
950
- var o = lt();
951
- return p(o, () => e.title), o;
738
+ var i = _(() => !!e.title);
739
+ return () => i() && (() => {
740
+ var r = it();
741
+ return p(r, () => e.title), r;
952
742
  })();
953
743
  })(), null), p(t, (() => {
954
- var r = _(() => !!e.message);
955
- return () => r() && (() => {
956
- var o = ct();
957
- return p(o, () => e.message), o;
744
+ var i = _(() => !!e.message);
745
+ return () => i() && (() => {
746
+ var r = rt();
747
+ return p(r, () => e.message), r;
958
748
  })();
959
749
  })(), null), t;
960
750
  })();
961
751
  }
962
- const K = ht;
963
- K.Content = Ge;
964
- K.Icon = Be;
965
- K.Title = qe;
966
- K.Status = Fe;
967
- K.Value = rt;
968
- K.SliderFill = Le;
969
- var mt = /* @__PURE__ */ y('<span class="inline-flex size-3.5 shrink-0 items-center">'), vt = /* @__PURE__ */ y("<button type=button>"), xt = /* @__PURE__ */ y('<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">'), bt = /* @__PURE__ */ y('<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__ */ y('<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>'), wt = /* @__PURE__ */ y('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No additional controls'), yt = /* @__PURE__ */ y('<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">'), $t = /* @__PURE__ */ y('<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'), St = /* @__PURE__ */ y('<div class="min-w-0 shrink-0">'), kt = /* @__PURE__ */ y('<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__ */ y('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), Mt = /* @__PURE__ */ y('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
970
- function Dt(e) {
752
+ const B = ot;
753
+ B.Content = Ae;
754
+ B.Icon = Re;
755
+ B.Title = Ue;
756
+ B.Status = je;
757
+ B.Value = Qe;
758
+ B.SliderFill = Ne;
759
+ var st = /* @__PURE__ */ x('<span class="inline-flex size-3.5 shrink-0 items-center">'), lt = /* @__PURE__ */ x("<button type=button>"), ct = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z">'), dt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No edit options available'), ut = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><line x1=4 y1=21 x2=4 y2=14></line><line x1=4 y1=10 x2=4 y2=3></line><line x1=12 y1=21 x2=12 y2=12></line><line x1=12 y1=8 x2=12 y2=3></line><line x1=20 y1=21 x2=20 y2=16></line><line x1=20 y1=12 x2=20 y2=3></line><line x1=1 y1=14 x2=7 y2=14></line><line x1=9 y1=8 x2=15 y2=8></line><line x1=17 y1=16 x2=23 y2=16>'), gt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No additional controls'), ht = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="m8 2 1.88 1.88"></path><path d="M14.12 3.88 16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4">'), ft = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No debug information available'), mt = /* @__PURE__ */ x('<div class="min-w-0 shrink-0">'), vt = /* @__PURE__ */ x('<div class="flex items-center gap-2"><div class="flex h-8 items-center rounded-lg border border-border/50 bg-muted/30 p-0.5">'), wt = /* @__PURE__ */ x('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), bt = /* @__PURE__ */ x('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
760
+ function pt(e) {
971
761
  return (() => {
972
- var t = vt();
973
- return t.$$click = () => e.onClick(), p(t, M(j, {
762
+ var t = lt();
763
+ return t.$$click = () => e.onClick(), p(t, $(E, {
974
764
  get when() {
975
765
  return e.isActive;
976
766
  },
977
767
  get children() {
978
- var r = mt();
979
- return p(r, () => e.icon), r;
768
+ var i = st();
769
+ return p(i, () => e.icon), i;
980
770
  }
981
- }), null), p(t, () => e.label, null), T(() => N(t, E("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
771
+ }), null), p(t, () => e.label, null), W(() => R(t, P("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
982
772
  })();
983
773
  }
984
- function Ft(e) {
985
- const [t] = Me(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"]), r = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [o, n] = U({}), [i, a] = U(null);
986
- R(ue(() => t.config, (s) => {
987
- s && n({
988
- ...s
774
+ function jt(e) {
775
+ const [t] = ye(e, ["open", "onOpenChange", "title", "onSave", "hasUnsavedChanges", "onDelete", "editContent", "controlsContent", "debugContent", "debugData", "tabs", "class", "maxWidth", "defaultTab", "headerActions", "configSchema", "config", "onConfigSave", "ResponsiveDialog", "ResponsiveDialogContent", "ResponsiveDialogHeader", "ResponsiveDialogTitle", "ResponsiveDialogDescription", "Button", "SchemaForm"]), i = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [r, n] = H({}), [o, h] = H(null);
776
+ te(ae(() => t.config, (l) => {
777
+ l && n({
778
+ ...l
989
779
  });
990
- })), R(ue(() => t.configSchema, (s) => {
991
- s && a(me(s));
780
+ })), te(ae(() => t.configSchema, (l) => {
781
+ l && h(de(l));
992
782
  }));
993
- const c = () => r() && JSON.stringify(o()) !== JSON.stringify(t.config), x = (s) => {
994
- !s && t.config && n({
783
+ const g = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), y = (l) => {
784
+ !l && t.config && n({
995
785
  ...t.config
996
- }), t.onOpenChange(s);
997
- }, w = () => {
998
- t.onConfigSave?.(o());
999
- }, [v, S] = U(t.defaultTab ?? "controls"), W = () => {
1000
- const s = t.maxWidth ?? "3xl";
786
+ }), t.onOpenChange(l);
787
+ }, f = () => {
788
+ t.onConfigSave?.(r());
789
+ }, [c, v] = H(t.defaultTab ?? "controls"), k = () => {
790
+ const l = t.maxWidth ?? "3xl";
1001
791
  return {
1002
792
  sm: "max-w-sm",
1003
793
  md: "max-w-md",
@@ -1006,141 +796,141 @@ function Ft(e) {
1006
796
  "2xl": "max-w-2xl",
1007
797
  "3xl": "max-w-3xl",
1008
798
  "4xl": "max-w-4xl"
1009
- }[s];
1010
- }, g = () => {
799
+ }[l];
800
+ }, d = () => {
1011
801
  if (t.tabs) return t.tabs;
1012
- const s = [];
1013
- return s.push({
802
+ const l = [];
803
+ return l.push({
1014
804
  id: "edit",
1015
805
  label: "Edit",
1016
- icon: xt(),
1017
- content: t.editContent ?? (r() && i() ? M(m, {
806
+ icon: ct(),
807
+ content: t.editContent ?? (i() && o() ? $(b, {
1018
808
  get schema() {
1019
- return i();
809
+ return o();
1020
810
  },
1021
811
  get data() {
1022
- return o();
812
+ return r();
1023
813
  },
1024
814
  onChange: n
1025
- }) : bt())
1026
- }), s.push({
815
+ }) : dt())
816
+ }), l.push({
1027
817
  id: "controls",
1028
818
  label: "Controls",
1029
- icon: pt(),
1030
- content: t.controlsContent ?? wt()
1031
- }), s.push({
819
+ icon: ut(),
820
+ content: t.controlsContent ?? gt()
821
+ }), l.push({
1032
822
  id: "debug",
1033
823
  label: "Debug",
1034
- icon: yt(),
1035
- content: t.debugContent ?? $t()
1036
- }), s;
1037
- }, f = async () => {
824
+ icon: ht(),
825
+ content: t.debugContent ?? ft()
826
+ }), l;
827
+ }, a = async () => {
1038
828
  if (t.debugData !== void 0)
1039
829
  try {
1040
- const s = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
1041
- await navigator.clipboard.writeText(s);
830
+ const l = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
831
+ await navigator.clipboard.writeText(l);
1042
832
  } catch {
1043
833
  }
1044
- }, D = () => {
1045
- const s = g();
1046
- return s.find((O) => O.id === v())?.content ?? s[0]?.content;
1047
- }, $ = t.ResponsiveDialog, C = t.ResponsiveDialogContent, I = t.ResponsiveDialogHeader, B = t.ResponsiveDialogTitle, u = t.ResponsiveDialogDescription, h = t.Button, m = t.SchemaForm, l = (s) => r() ? x(s) : t.onOpenChange(s), k = () => r() ? c() : t.hasUnsavedChanges, b = () => r() ? w : t.onSave;
1048
- return M($, {
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, {
1049
839
  get open() {
1050
840
  return t.open;
1051
841
  },
1052
- onOpenChange: (s) => l(s),
842
+ onOpenChange: (l) => M(l),
1053
843
  get children() {
1054
- return M(C, {
844
+ return $(S, {
1055
845
  get class() {
1056
- return E(W(), t.class);
846
+ return P(k(), t.class);
1057
847
  },
1058
848
  get children() {
1059
- return [M(I, {
849
+ return [$(O, {
1060
850
  class: "flex flex-row items-center justify-between gap-3",
1061
851
  get children() {
1062
852
  return [(() => {
1063
- var s = St();
1064
- return p(s, M(B, {
853
+ var l = mt();
854
+ return p(l, $(I, {
1065
855
  class: "truncate leading-tight",
1066
856
  get children() {
1067
857
  return t.title;
1068
858
  }
1069
- }), null), p(s, M(u, {
859
+ }), null), p(l, $(u, {
1070
860
  class: "sr-only",
1071
861
  children: "Widget configuration dialog"
1072
- }), null), s;
862
+ }), null), l;
1073
863
  })(), (() => {
1074
- var s = kt(), z = s.firstChild;
1075
- return p(z, () => g().map((O) => M(Dt, {
864
+ var l = vt(), z = l.firstChild;
865
+ return p(z, () => d().map((V) => $(pt, {
1076
866
  get icon() {
1077
- return O.icon;
867
+ return V.icon;
1078
868
  },
1079
869
  get label() {
1080
- return O.label;
870
+ return V.label;
1081
871
  },
1082
872
  get isActive() {
1083
- return v() === O.id;
873
+ return c() === V.id;
1084
874
  },
1085
- onClick: () => S(O.id)
1086
- }))), p(s, M(j, {
875
+ onClick: () => v(V.id)
876
+ }))), p(l, $(E, {
1087
877
  get when() {
1088
878
  return t.headerActions;
1089
879
  },
1090
880
  get children() {
1091
881
  return t.headerActions;
1092
882
  }
1093
- }), null), s;
883
+ }), null), l;
1094
884
  })()];
1095
885
  }
1096
886
  }), (() => {
1097
- var s = Ct();
1098
- return p(s, D), s;
1099
- })(), M(j, {
887
+ var l = wt();
888
+ return p(l, C), l;
889
+ })(), $(E, {
1100
890
  get when() {
1101
- return _(() => v() === "edit")() && (b() || t.onDelete) || v() === "debug" && t.debugData !== void 0;
891
+ return _(() => c() === "edit")() && (D() || t.onDelete) || c() === "debug" && t.debugData !== void 0;
1102
892
  },
1103
893
  get children() {
1104
- var s = Mt();
1105
- return p(s, M(j, {
894
+ var l = bt();
895
+ return p(l, $(E, {
1106
896
  get when() {
1107
- return _(() => v() === "edit")() && t.onDelete;
897
+ return _(() => c() === "edit")() && t.onDelete;
1108
898
  },
1109
899
  get children() {
1110
- return M(h, {
900
+ return $(m, {
1111
901
  size: "sm",
1112
902
  variant: "destructive",
1113
903
  onClick: () => t.onDelete?.(),
1114
904
  children: "Delete"
1115
905
  });
1116
906
  }
1117
- }), null), p(s, M(j, {
907
+ }), null), p(l, $(E, {
1118
908
  get when() {
1119
- return _(() => v() === "edit")() && b();
909
+ return _(() => c() === "edit")() && D();
1120
910
  },
1121
911
  get children() {
1122
- return M(h, {
912
+ return $(m, {
1123
913
  size: "sm",
1124
914
  get disabled() {
1125
- return !k();
915
+ return !N();
1126
916
  },
1127
- onClick: () => b()?.(),
917
+ onClick: () => D()?.(),
1128
918
  children: "Save"
1129
919
  });
1130
920
  }
1131
- }), null), p(s, M(j, {
921
+ }), null), p(l, $(E, {
1132
922
  get when() {
1133
- return _(() => v() === "debug")() && t.debugData !== void 0;
923
+ return _(() => c() === "debug")() && t.debugData !== void 0;
1134
924
  },
1135
925
  get children() {
1136
- return M(h, {
926
+ return $(m, {
1137
927
  size: "sm",
1138
928
  variant: "outline",
1139
- onClick: f,
929
+ onClick: a,
1140
930
  children: "Copy"
1141
931
  });
1142
932
  }
1143
- }), null), s;
933
+ }), null), l;
1144
934
  }
1145
935
  })];
1146
936
  }
@@ -1148,157 +938,175 @@ function Ft(e) {
1148
938
  }
1149
939
  });
1150
940
  }
1151
- $e(["click"]);
1152
- function Yt(e = "edit") {
1153
- const [t, r] = U(!1), [o, n] = U(e);
941
+ we(["click"]);
942
+ function Lt(e) {
943
+ if (typeof IntersectionObserver > "u")
944
+ return () => !1;
945
+ const [t, i] = H(!1), r = new IntersectionObserver((n) => {
946
+ const o = n[0];
947
+ o && i(!o.isIntersecting);
948
+ });
949
+ return te(() => {
950
+ const n = e();
951
+ r.disconnect(), n && r.observe(n);
952
+ }), ce(() => r.disconnect()), t;
953
+ }
954
+ function Bt() {
955
+ if (typeof window > "u" || typeof window.matchMedia != "function")
956
+ return () => !1;
957
+ const e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, i] = H(e.matches), r = (n) => i(n.matches);
958
+ return e.addEventListener("change", r), ce(() => e.removeEventListener("change", r)), t;
959
+ }
960
+ function Ut(e = "edit") {
961
+ const [t, i] = H(!1), [r, n] = H(e);
1154
962
  return {
1155
963
  showDialog: t,
1156
- setShowDialog: r,
1157
- openDialog: () => r(!0),
1158
- closeDialog: () => r(!1),
1159
- activeTab: o,
964
+ setShowDialog: i,
965
+ openDialog: () => i(!0),
966
+ closeDialog: () => i(!1),
967
+ activeTab: r,
1160
968
  setActiveTab: n
1161
969
  };
1162
970
  }
1163
- function Kt(e) {
1164
- const t = e.minEntities ?? 1, r = V(() => e.entities().length), o = V(() => r() >= t), n = V(() => !o() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), i = V(() => {
1165
- if (!o()) return;
1166
- const c = e.aggregationMode?.();
1167
- if (!c || c === "none") return;
1168
- const x = e.entities();
1169
- if (c === "light" || c === "binary-sensor" || c === "switch")
1170
- return Xe(x, e.allEntitiesMode);
1171
- if (c === "sensor") {
1172
- const w = e.sensorGroupType?.() ?? "mean";
1173
- return Je(x, w, !0);
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(() => {
973
+ 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);
1174
982
  }
1175
- }), a = V(() => o() ? void 0 : e.emptyStateConfig);
983
+ }), h = L(() => r() ? void 0 : e.emptyStateConfig);
1176
984
  return {
1177
985
  entities: e.entities,
1178
986
  groupData: n,
1179
- aggregatedData: i,
1180
- emptyState: a,
1181
- hasEntities: o,
1182
- count: r
987
+ aggregatedData: o,
988
+ emptyState: h,
989
+ hasEntities: r,
990
+ count: i
1183
991
  };
1184
992
  }
1185
- const J = 32, d = J / 2, P = "white", te = "rgba(0,0,0,0.4)", le = 2, ne = 3;
1186
- function zt(e) {
993
+ const F = 32, s = F / 2, T = "white", K = "rgba(0,0,0,0.4)", re = 2, X = 3;
994
+ function xt(e) {
1187
995
  return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
1188
996
  }
1189
- function re(e) {
1190
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${J}" height="${J}" viewBox="0 0 ${J} ${J}">${e}</svg>`;
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>`;
1191
999
  }
1192
- const _t = re(`
1000
+ const yt = J(`
1193
1001
  <g transform="translate(6, 2)">
1194
1002
  <!-- shadow -->
1195
- <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1003
+ <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1196
1004
  <path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
1197
1005
  </g>
1198
1006
  <!-- main -->
1199
- <g stroke="${P}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1007
+ <g stroke="${T}" stroke-width="${re}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1200
1008
  <path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
1201
1009
  </g>
1202
1010
  </g>
1203
- `), Tt = re(`
1011
+ `), $t = J(`
1204
1012
  <g>
1205
- <circle cx="${d}" cy="${d}" r="8" stroke="${te}" stroke-width="${ne}" fill="none"/>
1206
- <circle cx="${d}" cy="${d}" r="8" stroke="${P}" stroke-width="1.5" fill="none"/>
1207
- <circle cx="${d}" cy="${d}" r="1.5" fill="${P}"/>
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}"/>
1208
1016
  </g>
1209
- `), Et = re(`
1017
+ `), kt = J(`
1210
1018
  <g>
1211
1019
  <!-- shadow -->
1212
- <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1213
- <line x1="6" y1="${d}" x2="26" y2="${d}"/>
1214
- <polyline points="10,${d - 4} 6,${d} 10,${d + 4}"/>
1215
- <polyline points="22,${d - 4} 26,${d} 22,${d + 4}"/>
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}"/>
1216
1024
  </g>
1217
1025
  <!-- main -->
1218
- <g stroke="${P}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1219
- <line x1="6" y1="${d}" x2="26" y2="${d}"/>
1220
- <polyline points="10,${d - 4} 6,${d} 10,${d + 4}"/>
1221
- <polyline points="22,${d - 4} 26,${d} 22,${d + 4}"/>
1026
+ <g stroke="${T}" stroke-width="${re}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1027
+ <line x1="6" y1="${s}" x2="26" y2="${s}"/>
1028
+ <polyline points="10,${s - 4} 6,${s} 10,${s + 4}"/>
1029
+ <polyline points="22,${s - 4} 26,${s} 22,${s + 4}"/>
1222
1030
  </g>
1223
1031
  <!-- center grip dots -->
1224
- <circle cx="${d}" cy="${d}" r="1.5" fill="${P}"/>
1225
- <circle cx="${d - 5}" cy="${d}" r="1" fill="${P}" opacity="0.6"/>
1226
- <circle cx="${d + 5}" cy="${d}" r="1" fill="${P}" opacity="0.6"/>
1032
+ <circle cx="${s}" cy="${s}" r="1.5" fill="${T}"/>
1033
+ <circle cx="${s - 5}" cy="${s}" r="1" fill="${T}" opacity="0.6"/>
1034
+ <circle cx="${s + 5}" cy="${s}" r="1" fill="${T}" opacity="0.6"/>
1227
1035
  </g>
1228
- `), Ot = re(`
1036
+ `), Ct = J(`
1229
1037
  <g>
1230
1038
  <!-- shadow -->
1231
- <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1232
- <line x1="${d}" y1="6" x2="${d}" y2="26"/>
1233
- <polyline points="${d - 4},10 ${d},6 ${d + 4},10"/>
1234
- <polyline points="${d - 4},22 ${d},26 ${d + 4},22"/>
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"/>
1235
1043
  </g>
1236
1044
  <!-- main -->
1237
- <g stroke="${P}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1238
- <line x1="${d}" y1="6" x2="${d}" y2="26"/>
1239
- <polyline points="${d - 4},10 ${d},6 ${d + 4},10"/>
1240
- <polyline points="${d - 4},22 ${d},26 ${d + 4},22"/>
1045
+ <g stroke="${T}" stroke-width="${re}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1046
+ <line x1="${s}" y1="6" x2="${s}" y2="26"/>
1047
+ <polyline points="${s - 4},10 ${s},6 ${s + 4},10"/>
1048
+ <polyline points="${s - 4},22 ${s},26 ${s + 4},22"/>
1241
1049
  </g>
1242
1050
  <!-- center grip dots -->
1243
- <circle cx="${d}" cy="${d}" r="1.5" fill="${P}"/>
1244
- <circle cx="${d}" cy="${d - 5}" r="1" fill="${P}" opacity="0.6"/>
1245
- <circle cx="${d}" cy="${d + 5}" r="1" fill="${P}" opacity="0.6"/>
1051
+ <circle cx="${s}" cy="${s}" r="1.5" fill="${T}"/>
1052
+ <circle cx="${s}" cy="${s - 5}" r="1" fill="${T}" opacity="0.6"/>
1053
+ <circle cx="${s}" cy="${s + 5}" r="1" fill="${T}" opacity="0.6"/>
1246
1054
  </g>
1247
1055
  `);
1248
- function ee(e, t, r) {
1249
- return { css: `${zt(e)} ${t} ${r}, auto`, hotspotX: t, hotspotY: r };
1056
+ function q(e, t, i) {
1057
+ return { css: `${xt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1250
1058
  }
1251
- const G = {
1252
- tap: ee(_t, 12, 4),
1253
- hold: ee(Tt, 16, 16),
1254
- slideHorizontal: ee(Et, d, d),
1255
- slideVertical: ee(Ot, d, d)
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)
1256
1064
  };
1257
- function oe() {
1065
+ function Z() {
1258
1066
  if (typeof window > "u") return null;
1259
1067
  const e = window;
1260
1068
  return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
1261
1069
  }
1262
- function ae(e) {
1070
+ function ee(e) {
1263
1071
  if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
1264
1072
  try {
1265
1073
  navigator.vibrate(e);
1266
1074
  } catch {
1267
1075
  }
1268
1076
  }
1269
- const Nt = {
1077
+ const St = {
1270
1078
  /** Light confirmation — fires when slide gesture arms after user holds still. */
1271
1079
  tick() {
1272
- const e = oe();
1080
+ const e = Z();
1273
1081
  if (e) {
1274
1082
  e.impact({ style: "Light" }).catch(() => {
1275
1083
  });
1276
1084
  return;
1277
1085
  }
1278
- ae(8);
1086
+ ee(8);
1279
1087
  },
1280
1088
  /** Medium bump — fires when hold gesture commits (detail opening). */
1281
1089
  bump() {
1282
- const e = oe();
1090
+ const e = Z();
1283
1091
  if (e) {
1284
1092
  e.impact({ style: "Medium" }).catch(() => {
1285
1093
  });
1286
1094
  return;
1287
1095
  }
1288
- ae(20);
1096
+ ee(20);
1289
1097
  },
1290
1098
  /** Stronger pulse — reserved for edit-mode pickup (future use). */
1291
1099
  pulse() {
1292
- const e = oe();
1100
+ const e = Z();
1293
1101
  if (e) {
1294
1102
  e.impact({ style: "Heavy" }).catch(() => {
1295
1103
  });
1296
1104
  return;
1297
1105
  }
1298
- ae([0, 15, 40, 15]);
1106
+ ee([0, 15, 40, 15]);
1299
1107
  }
1300
1108
  };
1301
- function qt(e, t) {
1109
+ function Gt(e, t) {
1302
1110
  const n = {
1303
1111
  isDown: !1,
1304
1112
  isTouch: !1,
@@ -1310,139 +1118,189 @@ function qt(e, t) {
1310
1118
  holdTimer: null,
1311
1119
  element: null
1312
1120
  };
1313
- let i = null, a = null, c = null;
1314
- function x(u) {
1315
- u !== a && (c && c.disconnect(), c = new ResizeObserver((h) => {
1316
- const m = h[0];
1317
- if (m) {
1318
- const l = m.borderBoxSize?.[0];
1319
- l ? i = { width: l.inlineSize, height: l.blockSize } : i = { width: m.contentRect.width, height: m.contentRect.height };
1121
+ let o = null, h = null, g = null;
1122
+ function y(u) {
1123
+ u !== h && (g && g.disconnect(), g = new ResizeObserver((m) => {
1124
+ const b = m[0];
1125
+ if (b) {
1126
+ const M = b.borderBoxSize?.[0];
1127
+ M ? o = { width: M.inlineSize, height: M.blockSize } : o = { width: b.contentRect.width, height: b.contentRect.height };
1320
1128
  }
1321
- }), a = u, c.observe(u), i = { width: u.clientWidth, height: u.clientHeight });
1129
+ }), h = u, g.observe(u), o = { width: u.clientWidth, height: u.clientHeight });
1322
1130
  }
1323
- const w = () => {
1131
+ const f = () => {
1324
1132
  n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
1325
- }, v = () => {
1133
+ }, c = () => {
1326
1134
  n.isDown = !1, n.hasMoved = !1, n.sliding = !1;
1327
- }, S = (u) => {
1328
- const m = e().slide;
1329
- return m?.orientation === "horizontal" ? "horizontal" : m?.orientation === "vertical" ? "vertical" : u && (i || x(u), i) ? i.height > i.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
1330
- }, W = (u) => {
1331
- const h = e();
1332
- if (!(!h.tap && !h.hold && !h.slide)) {
1333
- if (n.isDown = !0, n.isTouch = u.pointerType === "touch", n.element = u.currentTarget, x(n.element), n.startX = u.clientX, n.startY = u.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, h.hold) {
1334
- const m = h.hold.delay ?? 500;
1135
+ }, v = (u) => {
1136
+ const b = e().slide;
1137
+ return b?.orientation === "horizontal" ? "horizontal" : b?.orientation === "vertical" ? "vertical" : u && (o || y(u), o) ? o.height > o.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
1138
+ }, k = (u) => {
1139
+ const m = e();
1140
+ if (!(!m.tap && !m.hold && !m.slide)) {
1141
+ if (n.isDown = !0, n.isTouch = u.pointerType === "touch", n.element = u.currentTarget, y(n.element), n.startX = u.clientX, n.startY = u.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, m.hold) {
1142
+ const b = m.hold.delay ?? 500;
1335
1143
  n.holdTimer = setTimeout(() => {
1336
- n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Nt.bump(), h.hold?.action(), n.isDown = !1);
1337
- }, m);
1144
+ n.holdTimer = null, !(!n.isDown || n.hasMoved) && (St.bump(), m.hold?.action(), n.isDown = !1);
1145
+ }, b);
1338
1146
  }
1339
- if (!n.isTouch && h.slide)
1147
+ if (!n.isTouch && m.slide)
1340
1148
  try {
1341
1149
  u.currentTarget.setPointerCapture(u.pointerId);
1342
1150
  } catch {
1343
1151
  }
1344
1152
  }
1345
- }, g = (u) => {
1153
+ }, d = (u) => {
1346
1154
  if (!n.isDown) return;
1347
- const h = e(), m = u.clientX - n.startX, l = u.clientY - n.startY;
1348
- if (Math.sqrt(m * m + l * l) > 10 && (w(), n.hasMoved = !0), !n.isTouch && h.slide && n.hasMoved) {
1349
- const b = u.currentTarget, s = S(b);
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);
1350
1158
  n.sliding = !0;
1351
- const z = h.slide.min ?? 0, O = h.slide.max ?? 100, ve = O - z, xe = s === "vertical" ? -l : m, ce = i ?? { width: b.clientWidth, height: b.clientHeight }, be = s === "vertical" ? ce.height : ce.width, pe = xe / be * ve, we = Math.max(z, Math.min(O, h.slide.value + pe));
1352
- h.slide.onChange(Math.round(we)), n.startX = u.clientX, n.startY = u.clientY, u.preventDefault();
1159
+ const z = m.slide.min ?? 0, V = m.slide.max ?? 100, ue = V - z, ge = l === "vertical" ? -M : b, oe = o ?? { width: D.clientWidth, height: D.clientHeight }, he = l === "vertical" ? oe.height : oe.width, fe = ge / he * ue, me = Math.max(z, Math.min(V, m.slide.value + fe));
1160
+ m.slide.onChange(Math.round(me)), n.startX = u.clientX, n.startY = u.clientY, u.preventDefault();
1353
1161
  }
1354
- }, f = (u) => {
1355
- const h = e(), m = n.isDown, l = Date.now() - n.startTime, k = h.hold?.delay ?? 500;
1356
- w(), m && h.tap && !n.hasMoved && l < k && h.tap();
1162
+ }, a = (u) => {
1163
+ const m = e(), b = n.isDown, M = Date.now() - n.startTime, N = m.hold?.delay ?? 500;
1164
+ f(), b && m.tap && !n.hasMoved && M < N && m.tap();
1357
1165
  try {
1358
1166
  u.currentTarget.releasePointerCapture(u.pointerId);
1359
1167
  } catch {
1360
1168
  }
1361
- v();
1362
- }, D = (u) => {
1363
- w();
1169
+ c();
1170
+ }, C = (u) => {
1171
+ f();
1364
1172
  try {
1365
1173
  u.currentTarget.releasePointerCapture(u.pointerId);
1366
1174
  } catch {
1367
1175
  }
1368
- v();
1369
- }, $ = (u) => {
1370
- const h = e();
1371
- if (h.slide) {
1372
- const m = h.slide.orientation;
1373
- return m === "horizontal" ? G.slideHorizontal.css : m === "vertical" ? G.slideVertical.css : (i || x(u), i && i.height > i.width ? G.slideVertical.css : G.slideHorizontal.css);
1176
+ c();
1177
+ }, w = (u) => {
1178
+ const m = e();
1179
+ if (m.slide) {
1180
+ const b = m.slide.orientation;
1181
+ return b === "horizontal" ? j.slideHorizontal.css : b === "vertical" ? j.slideVertical.css : (o || y(u), o && o.height > o.width ? j.slideVertical.css : j.slideHorizontal.css);
1374
1182
  }
1375
- return h.tap ? G.tap.css : h.hold ? G.hold.css : "";
1183
+ return m.tap ? j.tap.css : m.hold ? j.hold.css : "";
1376
1184
  };
1377
1185
  return {
1378
- onPointerDown: W,
1379
- onPointerMove: g,
1380
- onPointerUp: f,
1381
- onPointerCancel: D,
1186
+ onPointerDown: k,
1187
+ onPointerMove: d,
1188
+ onPointerUp: a,
1189
+ onPointerCancel: C,
1382
1190
  onPointerEnter: (u) => {
1383
- const h = u.currentTarget;
1384
- n.element = h, h.style.cursor = $(h);
1191
+ const m = u.currentTarget;
1192
+ n.element = m, m.style.cursor = w(m);
1385
1193
  },
1386
1194
  bindElement: (u) => {
1387
- u && (n.element = u, x(u));
1195
+ u && (n.element = u, y(u));
1388
1196
  },
1389
1197
  touchAction: () => {
1390
1198
  const u = e();
1391
1199
  return u.tap || u.hold || u.slide ? "manipulation" : "auto";
1392
1200
  },
1393
1201
  dispose: () => {
1394
- w(), c && (c.disconnect(), c = null), a = null, i = null;
1202
+ f(), g && (g.disconnect(), g = null), h = null, o = null;
1395
1203
  }
1396
1204
  };
1397
1205
  }
1398
- const Xt = L.enum([
1206
+ const Mt = {
1207
+ solar: "oklch(0.74 0.18 60)",
1208
+ grid: "oklch(0.62 0.12 245)",
1209
+ battery: "oklch(0.70 0.18 145)",
1210
+ ev: "oklch(0.70 0.14 190)",
1211
+ home: "oklch(0.68 0.06 250)",
1212
+ positive: "oklch(0.70 0.14 160)",
1213
+ // Fault red-orange; used only for faults, never normal consumption.
1214
+ negative: "oklch(0.64 0.22 27)"
1215
+ };
1216
+ function Dt(e) {
1217
+ return {
1218
+ fill: `color-mix(in oklch, ${e} 20%, transparent)`,
1219
+ stroke: e,
1220
+ solid: e
1221
+ };
1222
+ }
1223
+ const qt = Object.fromEntries(
1224
+ Object.entries(Mt).map(([e, t]) => [e, Dt(t)])
1225
+ ), Yt = A.enum([
1399
1226
  "success",
1400
1227
  "warning",
1401
1228
  "danger",
1402
1229
  "info",
1403
1230
  "neutral",
1404
1231
  "accent"
1405
- ]), Jt = {
1232
+ ]), Kt = {
1406
1233
  /** Optional display name override (renders as text input) */
1407
- title: () => L.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1234
+ title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1408
1235
  /** Multi-select entity picker for a HA domain */
1409
- entityIds: (e) => L.array(L.string()).default([]).meta({ domain: e, title: "Entities" }),
1236
+ entityIds: (e) => A.array(A.string()).default([]).meta({ domain: e, title: "Entities" }),
1410
1237
  /** Single-select entity picker for a HA domain */
1411
- singleEntity: (e) => L.array(L.string()).default([]).meta({ domain: e, title: "Entity", singleSelect: !0 }),
1238
+ singleEntity: (e) => A.array(A.string()).default([]).meta({ domain: e, title: "Entity", singleSelect: !0 }),
1412
1239
  /** Area picker dropdown */
1413
- areaId: () => L.string().optional().meta({ formType: "area-picker", title: "Area" })
1240
+ areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
1414
1241
  };
1415
- function Qt() {
1242
+ function Xt(e) {
1243
+ if (e.length < 2) return "";
1244
+ const t = e[0], i = e[1];
1245
+ if (!t || !i) return "";
1246
+ if (e.length === 2) return `M ${t.x} ${t.y} L ${i.x} ${i.y}`;
1247
+ const r = e.length, n = [], o = [], h = [];
1248
+ for (let f = 0; f < r - 1; f++) {
1249
+ const c = e[f], v = e[f + 1];
1250
+ !c || !v || (n.push(v.x - c.x), o.push(v.y - c.y), h.push((v.y - c.y) / (v.x - c.x)));
1251
+ }
1252
+ const g = [h[0] ?? 0];
1253
+ for (let f = 1; f < r - 1; f++) {
1254
+ const c = h[f - 1] ?? 0, v = h[f] ?? 0, k = n[f - 1] ?? 0, d = n[f] ?? 0;
1255
+ c * v <= 0 ? g.push(0) : g.push(
1256
+ 3 * (k + d) / ((2 * d + k) / c + (d + 2 * k) / v)
1257
+ );
1258
+ }
1259
+ g.push(h[r - 2] ?? 0);
1260
+ let y = `M ${t.x} ${t.y}`;
1261
+ for (let f = 0; f < r - 1; f++) {
1262
+ const c = e[f], v = e[f + 1];
1263
+ if (!c || !v) continue;
1264
+ const k = (n[f] ?? 0) / 3, d = g[f] ?? 0, a = g[f + 1] ?? 0;
1265
+ y += ` C ${c.x + k} ${c.y + d * k}, ${v.x - k} ${v.y - a * k}, ${v.x} ${v.y}`;
1266
+ }
1267
+ return y;
1268
+ }
1269
+ function Jt() {
1416
1270
  return document.documentElement.classList.contains("dark");
1417
1271
  }
1418
- const Vt = "0.4.2", Pt = {
1419
- version: Vt
1420
- }, Zt = Pt.version;
1272
+ const _t = "0.5.1", zt = {
1273
+ version: _t
1274
+ }, Qt = zt.version;
1421
1275
  export {
1422
- Zt as SDK_VERSION,
1423
- Xt as ToneSchema,
1424
- K as Widget,
1425
- Ge as WidgetContent,
1426
- se as WidgetCtx,
1427
- Ft as WidgetDialog,
1428
- Be as WidgetIcon,
1429
- nn as WidgetManifestSchema,
1430
- Le as WidgetSliderFill,
1431
- Fe as WidgetStatus,
1432
- qe as WidgetTitle,
1433
- rt as WidgetValue,
1434
- Xe as calculateLightGroup,
1435
- Je as calculateSensorGroup,
1436
- jt as countActiveEntities,
1437
- Ut as defineWidget,
1438
- rn as formatSchemaError,
1439
- Bt as getEntityAttribute,
1440
- Ee as injectTokens,
1441
- Qt as isDark,
1442
- Qe as isEntityActive,
1443
- Y as useWidgetContext,
1444
- Yt as useWidgetDialog,
1445
- Kt as useWidgetEntityGroup,
1446
- qt as useWidgetGestures,
1447
- Jt as widgetFields
1276
+ Qt as SDK_VERSION,
1277
+ Yt as ToneSchema,
1278
+ B as Widget,
1279
+ Ae as WidgetContent,
1280
+ ne as WidgetCtx,
1281
+ jt as WidgetDialog,
1282
+ Re as WidgetIcon,
1283
+ tn as WidgetManifestSchema,
1284
+ Ne as WidgetSliderFill,
1285
+ je as WidgetStatus,
1286
+ Ue as WidgetTitle,
1287
+ Qe as WidgetValue,
1288
+ Fe as calculateLightGroup,
1289
+ Ge as calculateSensorGroup,
1290
+ It as countActiveEntities,
1291
+ Pt as defineWidget,
1292
+ nn as formatSchemaError,
1293
+ Rt as getEntityAttribute,
1294
+ Me as injectTokens,
1295
+ Jt as isDark,
1296
+ qe as isEntityActive,
1297
+ Xt as monotoneCubicPath,
1298
+ qt as svgColors,
1299
+ Lt as useIntersectionPause,
1300
+ Bt as useReducedMotion,
1301
+ Ht as useWidgetContext,
1302
+ Ut as useWidgetDialog,
1303
+ Ft as useWidgetEntityGroup,
1304
+ Gt as useWidgetGestures,
1305
+ Kt as widgetFields
1448
1306
  };