@glasshome/widget-sdk 0.4.2 → 0.5.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,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 Yt, formatSchemaError as Kt } from "./schemas.js";
3
+ import { effect as W, className as P, style as ne, template as b, insert as w, createComponent as x, memo as D, setStyleProperty as Y, addEventListener as L, use as me, delegateEvents as ve } from "solid-js/web";
4
+ import { createElementSize as we } from "@solid-primitives/resize-observer";
5
+ import { createContext as be, useContext as se, Show as T, onMount as pe, createSignal as B, createMemo as j, splitProps as xe, createEffect as oe, on as ae } from "solid-js";
6
+ import { clsx as ye } from "clsx";
7
+ import { twMerge as $e } from "tailwind-merge";
8
+ function ce(e) {
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 ke(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 Vt(e) {
24
+ return e.configSchema && (e.manifest.schema || (e.manifest.schema = ce(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = ke(e.configSchema))), e;
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
+ }, te = be();
36
+ function At() {
37
+ const e = se(te);
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 Ce = `/* 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 Se(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 = Ce, t.head.appendChild(i), Q = !0;
150
225
  }
151
- function E(...e) {
152
- return ze(De(e));
226
+ function H(...e) {
227
+ return $e(ye(e));
153
228
  }
154
- const Oe = {
229
+ const Me = {
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
+ }, De = {
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
+ }, _e = {
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
+ }, ze = {
315
+ "classic-glass": Me,
316
+ minimal: De,
317
+ "compact-horizontal": _e
243
318
  };
244
- function We(e) {
245
- return Pe[e];
319
+ function Te(e) {
320
+ return ze[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 Ee = /* @__PURE__ */ b("<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 = Ee();
326
+ return W((i) => {
327
+ var r = H("glasshome-widget-slider-fill pointer-events-none absolute inset-0", e.isDragging ? "duration-0" : "transition-all duration-300 ease-out", e.class), n = {
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 && P(t, i.e = r), i.t = ne(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 Oe = /* @__PURE__ */ b("<div>");
342
+ function Ve(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 = Oe();
345
+ return w(t, () => e.children), W(() => P(t, H("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 Ae = /* @__PURE__ */ b('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2">'), We = /* @__PURE__ */ b('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3">'), He = /* @__PURE__ */ b('<div><div class="glasshome-widget-icon-glyph flex items-center justify-center">');
349
+ function Pe(e) {
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 w(i, x(T, {
354
+ get when() {
355
+ return t() >= 2;
356
+ },
357
+ get children() {
358
+ return Ae();
359
+ }
360
+ }), r), w(i, x(T, {
361
+ get when() {
362
+ return t() >= 3;
363
+ },
364
+ get children() {
365
+ return We();
366
+ }
367
+ }), r), w(r, () => e.icon), W((n) => {
368
+ var a = H("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center pointer-events-none transition-all", e.dimmed && "opacity-50", e.class), h = e.color ? {
369
+ "--widget-icon-color": e.color
370
+ } : void 0;
371
+ return a !== n.e && P(i, n.e = a), n.t = ne(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 Re = /* @__PURE__ */ b("<p>");
379
+ function Ue(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 = Re();
382
+ return w(t, (() => {
383
+ var i = D(() => !!e.isUnavailable);
384
+ return () => i() ? "Unavailable" : e.children;
385
+ })()), W((i) => {
386
+ var r = H("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), n = G.ACTIONS;
387
+ return r !== i.e && P(t, i.e = r), n !== i.t && Y(t, "z-index", i.t = n), i;
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 je = /* @__PURE__ */ b('<span class="glasshome-widget-badge shrink-0">'), Be = /* @__PURE__ */ b("<div><h3 class=glasshome-widget-title>");
395
+ function Ie(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 w(i, () => e.children), w(t, x(T, {
399
+ get when() {
400
+ return D(() => e.badge !== void 0)() && e.badge > 0;
401
+ },
402
+ get children() {
403
+ var r = je();
404
+ return w(r, () => e.badge), r;
405
+ }
406
+ }), null), W((r) => {
407
+ var n = H("relative flex items-center gap-2", e.class), a = G.ACTIONS;
408
+ return n !== r.e && P(t, r.e = n), a !== r.t && Y(t, "z-index", r.t = a), r;
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 Le(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 v = e[0], S = v.state === "on", O = v.attributes?.brightness || 0, M = Math.round(O / 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: v.state,
435
+ isOn: S,
436
+ isUnavailable: v.state === "unavailable",
437
+ brightness: O,
438
+ brightnessPercent: M,
439
+ color: le(v),
440
+ onCount: S ? 1 : 0,
589
441
  totalCount: 1,
590
- description: l ? "On" : "Off"
442
+ description: S ? "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, a = 0, h = 0, u = 0, p = 0;
446
+ const y = [];
447
+ for (const v of e)
448
+ switch (v.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++, v.attributes?.brightness !== void 0 && (u += v.attributes.brightness, p++), v.attributes?.rgb_color && y.push(v.attributes.rgb_color);
599
451
  break;
600
452
  case "off":
601
453
  n++;
602
454
  break;
603
455
  case "unknown":
604
- i++;
456
+ a++;
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);
614
- 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)})`;
462
+ const m = e.length, $ = h === m, E = a + h === m, d = r > 0, l = r === m, k = n === m;
463
+ let f, C;
464
+ t ? $ ? (f = "unavailable", C = !1) : a > 0 || h > 0 ? (f = "unknown", C = !1) : n > 0 ? (f = "off", C = !1) : (f = "on", C = !0) : $ ? (f = "unavailable", C = !1) : E ? (f = "unknown", C = !1) : d ? (f = "on", C = !0) : (f = "off", C = !1);
465
+ const N = p > 0 ? Math.round(u / p) : 0, R = Math.round(N / 255 * 100);
466
+ let c;
467
+ if (y.length > 0) {
468
+ const v = Math.round(y.reduce((s, _) => s + _[0], 0) / y.length), S = Math.round(y.reduce((s, _) => s + _[1], 0) / y.length), O = Math.round(y.reduce((s, _) => s + _[2], 0) / y.length), M = N / 255;
469
+ c = `rgb(${Math.round(v * M)}, ${Math.round(S * M)}, ${Math.round(O * M)})`;
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: $,
471
+ c = le(e[0]);
472
+ let g;
473
+ return l ? g = "All on" : k ? g = "All off" : r > 0 ? g = `${r} of ${m} on` : g = "Off", {
474
+ isGroup: i,
475
+ state: f,
624
476
  isOn: C,
625
- isUnavailable: $ === "unavailable",
626
- brightness: I,
627
- brightnessPercent: B,
628
- color: u,
629
- onCount: o,
630
- totalCount: v,
631
- description: h
477
+ isUnavailable: f === "unavailable",
478
+ brightness: N,
479
+ brightnessPercent: R,
480
+ color: c,
481
+ onCount: r,
482
+ totalCount: m,
483
+ description: g
632
484
  };
633
485
  }
634
- function Je(e, t = "mean", r = !0) {
486
+ function Fe(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], l = Number.parseFloat(d.state);
498
+ let k = d.state;
499
+ return Number.isNaN(l) || (k = Number.isInteger(l) ? l.toString() : l.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: k,
502
+ numericValue: Number.isNaN(l) ? null : l,
503
+ isUnavailable: d.state === "unavailable",
504
+ unit: d.unitOfMeasurement ?? void 0,
505
+ description: k
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 = [], a = [];
509
+ let h = 0, u;
510
+ for (const d of e) {
511
+ if (!u && d.unitOfMeasurement && (u = d.unitOfMeasurement), d.state === "unavailable") {
512
+ h++, a.push({
513
+ entityId: d.id,
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 l = Number.parseFloat(d.state);
520
+ isNaN(l) ? i || a.push({
521
+ entityId: d.id,
522
+ value: d.state,
523
+ friendly_name: d.friendlyName
524
+ }) : (n.push(l), a.push({
525
+ entityId: d.id,
526
+ value: l,
527
+ friendly_name: d.friendlyName
676
528
  }));
677
529
  }
678
- const x = a === e.length, w = n.length === 0;
679
- if (x || w)
530
+ const p = h === e.length, y = n.length === 0;
531
+ if (p || y)
680
532
  return {
681
- isGroup: o,
682
- state: x ? "unavailable" : "unknown",
533
+ isGroup: r,
534
+ state: p ? "unavailable" : "unknown",
683
535
  numericValue: null,
684
- isUnavailable: x,
685
- unit: c,
686
- description: x ? "Unavailable" : "No numeric values",
687
- memberValues: i
536
+ isUnavailable: p,
537
+ unit: u,
538
+ description: p ? "Unavailable" : "No numeric values",
539
+ memberValues: a
688
540
  };
689
- let v, S;
541
+ let m, $;
690
542
  switch (t) {
691
543
  case "min":
692
- v = Math.min(...n), S = "Minimum";
544
+ m = Math.min(...n), $ = "Minimum";
693
545
  break;
694
546
  case "max":
695
- v = Math.max(...n), S = "Maximum";
547
+ m = Math.max(...n), $ = "Maximum";
696
548
  break;
697
549
  case "mean":
698
- v = n.reduce((g, f) => g + f, 0) / n.length, S = "Average";
550
+ m = n.reduce((d, l) => d + l, 0) / n.length, $ = "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((k, f) => k - f), l = Math.floor(d.length / 2);
554
+ m = d.length % 2 === 0 ? (d[l - 1] + d[l]) / 2 : d[l], $ = "Median";
703
555
  break;
704
556
  }
705
557
  case "sum":
706
- v = n.reduce((g, f) => g + f, 0), S = "Sum";
558
+ m = n.reduce((d, l) => d + l, 0), $ = "Sum";
707
559
  break;
708
560
  case "last":
709
- v = n[n.length - 1], S = "Latest";
561
+ m = n[n.length - 1], $ = "Latest";
710
562
  break;
711
563
  case "range":
712
- v = Math.max(...n) - Math.min(...n), S = "Range";
564
+ m = Math.max(...n) - Math.min(...n), $ = "Range";
713
565
  break;
714
566
  case "product":
715
- v = n.reduce((g, f) => g * f, 1), S = "Product";
567
+ m = n.reduce((d, l) => d * l, 1), $ = "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((k, f) => k + f, 0) / n.length, l = n.reduce((k, f) => k + (f - d) ** 2, 0) / n.length;
571
+ m = Math.sqrt(l), $ = "Std Dev";
720
572
  break;
721
573
  }
722
574
  default:
723
- v = n.reduce((g, f) => g + f, 0) / n.length, S = "Average";
575
+ m = n.reduce((d, l) => d + l, 0) / n.length, $ = "Average";
724
576
  }
725
- const W = Number.isInteger(v) ? v.toString() : v.toFixed(1);
577
+ const E = Number.isInteger(m) ? m.toString() : m.toFixed(1);
726
578
  return {
727
- isGroup: o,
728
- state: W,
729
- numericValue: v,
579
+ isGroup: r,
580
+ state: E,
581
+ numericValue: m,
730
582
  isUnavailable: !1,
731
- unit: c,
732
- description: `${S} of ${n.length}`,
733
- memberValues: i
583
+ unit: u,
584
+ description: `${$} of ${n.length}`,
585
+ memberValues: a
734
586
  };
735
587
  }
736
- function he(e) {
588
+ function le(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, a] = e.attributes.rgb_color;
593
+ return `rgb(${Math.round(r * i)}, ${Math.round(n * i)}, ${Math.round(a * 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 a, h, u;
598
+ return n <= 66 ? (a = 255, h = n <= 19 ? 0 : 99.4708025861 * Math.log(n - 10) - 161.1195681661, u = n <= 19 ? 0 : n <= 66 ? 138.5177312231 * Math.log(n - 10) - 305.0447927307 : 255) : (a = 329.698727446 * (n - 60) ** -0.1332047592, h = 288.1221695283 * (n - 60) ** -0.0755148492, u = 255), a = Math.max(0, Math.min(255, a)) * i, h = Math.max(0, Math.min(255, h)) * i, u = Math.max(0, Math.min(255, u)) * i, `rgb(${Math.round(a)}, ${Math.round(h)}, ${Math.round(u)})`;
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 Ge(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 Wt(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 Ht(e) {
616
+ return e.filter(Ge).length;
765
617
  }
766
- function Ze(e, t, r) {
767
- const { decimals: o, scale: n = !0 } = {};
618
+ function qe(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 a = e, h = t || "";
625
+ n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (a = e / 1e6, h = "MW") : e >= 1e3 ? (a = e / 1e3, h = "kW") : h = "W"), n && t && (t === "B" || t === "KB" || t === "MB" || t === "GB") && (e >= 1073741824 ? (a = e / 1073741824, h = "GB") : e >= 1048576 ? (a = e / 1048576, h = "MB") : e >= 1024 ? (a = e / 1024, h = "KB") : h = "B");
626
+ let u;
627
+ return r !== void 0 ? u = a.toFixed(r) : a !== e ? u = a.toFixed(1) : Number.isInteger(e) ? u = e.toString() : u = Number.parseFloat(e.toFixed(2)).toString(), h ? `${u}${h}` : u;
776
628
  }
777
- function et(e, t) {
629
+ function Ye(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 Ke = /* @__PURE__ */ b("<div class=glasshome-widget-subtitle>"), Xe = /* @__PURE__ */ b("<div><div class=glasshome-widget-value>");
633
+ function Je(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 = Xe(), i = t.firstChild;
636
+ return w(i, () => qe(e.value, e.unit)), w(t, x(T, {
637
+ get when() {
638
+ return D(() => !!e.interpret)() && typeof e.value == "number";
639
+ },
640
+ get children() {
641
+ var r = Ke();
642
+ return w(r, () => Ye(e.value, e.unit)), r;
643
+ }
644
+ }), null), W(() => P(t, H("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 Qe = /* @__PURE__ */ b('<div><div class="relative h-full w-full">'), Ze = /* @__PURE__ */ b('<div class="glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse">'), et = /* @__PURE__ */ b('<div class="flex h-full w-full flex-col items-center justify-center gap-2 text-center">'), tt = /* @__PURE__ */ b('<div class="flex items-center justify-center text-white/30">'), nt = /* @__PURE__ */ b('<h3 class="font-semibold text-sm text-white/60">'), it = /* @__PURE__ */ b('<p class="text-white/50 text-xs">');
648
+ function rt(e) {
649
+ pe(() => {
650
+ Se();
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 = se(te), [i, r] = B(), n = we(i), a = {
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 = j(() => {
661
+ if (e.variant)
662
+ return typeof e.variant == "string" ? Te(e.variant) : e.variant;
663
+ }), u = j(() => ({
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);
681
+ })), p = () => !!e.gestures && !e.isEditMode, y = (l) => {
682
+ p() && e.gestures?.onPointerEnter(l);
892
683
  }, m = (l) => {
893
- C() && e.gestures?.onPointerCancel(l);
684
+ p() && e.gestures?.onPointerDown(l);
685
+ }, $ = (l) => {
686
+ p() && e.gestures?.onPointerMove(l);
687
+ }, E = (l) => {
688
+ p() && e.gestures?.onPointerUp(l);
689
+ }, d = (l) => {
690
+ p() && e.gestures?.onPointerCancel(l);
894
691
  };
895
- return M(se.Provider, {
896
- value: D,
692
+ return x(te.Provider, {
693
+ value: a,
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 l = Qe(), k = l.firstChild;
696
+ return L(l, "pointercancel", d), L(l, "pointerup", E), L(l, "pointermove", $), L(l, "pointerdown", m), L(l, "pointerenter", y), me((f) => {
697
+ r(f), e.gestures?.bindElement(f);
698
+ }, l), w(k, (() => {
699
+ var f = D(() => !!e.emptyState);
700
+ return () => f() ? x(ot, {
904
701
  get icon() {
905
702
  return e.emptyState.icon;
906
703
  },
@@ -911,22 +708,15 @@ 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
+ })()), w(l, (() => {
712
+ var f = D(() => !!e.loading);
713
+ return () => f() && (() => {
714
+ var C = Ze();
715
+ return W((N) => Y(C, "z-index", G.OVERLAY)), C;
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((f) => {
718
+ var C = H("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", h()?.styles?.class, e.class), N = u(), R = G.CONTENT;
719
+ return C !== f.e && P(l, f.e = C), f.t = ne(l, N, f.t), R !== f.a && Y(k, "z-index", f.a = R), f;
930
720
  }, {
931
721
  e: void 0,
932
722
  t: void 0,
@@ -935,68 +725,68 @@ function ht(e) {
935
725
  }
936
726
  });
937
727
  }
938
- function ft(e) {
728
+ function ot(e) {
939
729
  return (() => {
940
- var t = at();
941
- return p(t, (() => {
942
- var r = _(() => !!e.icon);
943
- return () => r() && (() => {
944
- var o = st();
945
- return p(o, () => e.icon), o;
730
+ var t = et();
731
+ return w(t, (() => {
732
+ var i = D(() => !!e.icon);
733
+ return () => i() && (() => {
734
+ var r = tt();
735
+ return w(r, () => e.icon), r;
946
736
  })();
947
- })(), null), p(t, (() => {
948
- var r = _(() => !!e.title);
949
- return () => r() && (() => {
950
- var o = lt();
951
- return p(o, () => e.title), o;
737
+ })(), null), w(t, (() => {
738
+ var i = D(() => !!e.title);
739
+ return () => i() && (() => {
740
+ var r = nt();
741
+ return w(r, () => e.title), r;
952
742
  })();
953
- })(), null), p(t, (() => {
954
- var r = _(() => !!e.message);
955
- return () => r() && (() => {
956
- var o = ct();
957
- return p(o, () => e.message), o;
743
+ })(), null), w(t, (() => {
744
+ var i = D(() => !!e.message);
745
+ return () => i() && (() => {
746
+ var r = it();
747
+ return w(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 I = rt;
753
+ I.Content = Ve;
754
+ I.Icon = Pe;
755
+ I.Title = Ie;
756
+ I.Status = Ue;
757
+ I.Value = Je;
758
+ I.SliderFill = Ne;
759
+ var at = /* @__PURE__ */ b('<span class="inline-flex size-3.5 shrink-0 items-center">'), lt = /* @__PURE__ */ b("<button type=button>"), st = /* @__PURE__ */ b('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z">'), ct = /* @__PURE__ */ b('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No edit options available'), dt = /* @__PURE__ */ b('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><line x1=4 y1=21 x2=4 y2=14></line><line x1=4 y1=10 x2=4 y2=3></line><line x1=12 y1=21 x2=12 y2=12></line><line x1=12 y1=8 x2=12 y2=3></line><line x1=20 y1=21 x2=20 y2=16></line><line x1=20 y1=12 x2=20 y2=3></line><line x1=1 y1=14 x2=7 y2=14></line><line x1=9 y1=8 x2=15 y2=8></line><line x1=17 y1=16 x2=23 y2=16>'), ut = /* @__PURE__ */ b('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No additional controls'), gt = /* @__PURE__ */ b('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="m8 2 1.88 1.88"></path><path d="M14.12 3.88 16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4">'), ht = /* @__PURE__ */ b('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No debug information available'), ft = /* @__PURE__ */ b('<div class="min-w-0 shrink-0">'), mt = /* @__PURE__ */ b('<div class="flex items-center gap-2"><div class="flex h-8 items-center rounded-lg border border-border/50 bg-muted/30 p-0.5">'), vt = /* @__PURE__ */ b('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), wt = /* @__PURE__ */ b('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
760
+ function bt(e) {
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(), w(t, x(T, {
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 = at();
769
+ return w(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), w(t, () => e.label, null), W(() => P(t, H("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
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) => {
774
+ function Pt(e) {
775
+ const [t] = xe(e, ["open", "onOpenChange", "title", "onSave", "hasUnsavedChanges", "onDelete", "editContent", "controlsContent", "debugContent", "debugData", "tabs", "class", "maxWidth", "defaultTab", "headerActions", "configSchema", "config", "onConfigSave", "ResponsiveDialog", "ResponsiveDialogContent", "ResponsiveDialogHeader", "ResponsiveDialogTitle", "ResponsiveDialogDescription", "Button", "SchemaForm"]), i = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [r, n] = B({}), [a, h] = B(null);
776
+ oe(ae(() => t.config, (s) => {
987
777
  s && n({
988
778
  ...s
989
779
  });
990
- })), R(ue(() => t.configSchema, (s) => {
991
- s && a(me(s));
780
+ })), oe(ae(() => t.configSchema, (s) => {
781
+ s && h(ce(s));
992
782
  }));
993
- const c = () => r() && JSON.stringify(o()) !== JSON.stringify(t.config), x = (s) => {
783
+ const u = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), p = (s) => {
994
784
  !s && t.config && n({
995
785
  ...t.config
996
786
  }), t.onOpenChange(s);
997
- }, w = () => {
998
- t.onConfigSave?.(o());
999
- }, [v, S] = U(t.defaultTab ?? "controls"), W = () => {
787
+ }, y = () => {
788
+ t.onConfigSave?.(r());
789
+ }, [m, $] = B(t.defaultTab ?? "controls"), E = () => {
1000
790
  const s = t.maxWidth ?? "3xl";
1001
791
  return {
1002
792
  sm: "max-w-sm",
@@ -1007,83 +797,83 @@ function Ft(e) {
1007
797
  "3xl": "max-w-3xl",
1008
798
  "4xl": "max-w-4xl"
1009
799
  }[s];
1010
- }, g = () => {
800
+ }, d = () => {
1011
801
  if (t.tabs) return t.tabs;
1012
802
  const s = [];
1013
803
  return s.push({
1014
804
  id: "edit",
1015
805
  label: "Edit",
1016
- icon: xt(),
1017
- content: t.editContent ?? (r() && i() ? M(m, {
806
+ icon: st(),
807
+ content: t.editContent ?? (i() && a() ? x(v, {
1018
808
  get schema() {
1019
- return i();
809
+ return a();
1020
810
  },
1021
811
  get data() {
1022
- return o();
812
+ return r();
1023
813
  },
1024
814
  onChange: n
1025
- }) : bt())
815
+ }) : ct())
1026
816
  }), s.push({
1027
817
  id: "controls",
1028
818
  label: "Controls",
1029
- icon: pt(),
1030
- content: t.controlsContent ?? wt()
819
+ icon: dt(),
820
+ content: t.controlsContent ?? ut()
1031
821
  }), s.push({
1032
822
  id: "debug",
1033
823
  label: "Debug",
1034
- icon: yt(),
1035
- content: t.debugContent ?? $t()
824
+ icon: gt(),
825
+ content: t.debugContent ?? ht()
1036
826
  }), s;
1037
- }, f = async () => {
827
+ }, l = async () => {
1038
828
  if (t.debugData !== void 0)
1039
829
  try {
1040
830
  const s = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
1041
831
  await navigator.clipboard.writeText(s);
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
+ }, k = () => {
835
+ const s = d();
836
+ return s.find((V) => V.id === m())?.content ?? s[0]?.content;
837
+ }, f = t.ResponsiveDialog, C = t.ResponsiveDialogContent, N = t.ResponsiveDialogHeader, R = t.ResponsiveDialogTitle, c = t.ResponsiveDialogDescription, g = t.Button, v = t.SchemaForm, S = (s) => i() ? p(s) : t.onOpenChange(s), O = () => i() ? u() : t.hasUnsavedChanges, M = () => i() ? y : t.onSave;
838
+ return x(f, {
1049
839
  get open() {
1050
840
  return t.open;
1051
841
  },
1052
- onOpenChange: (s) => l(s),
842
+ onOpenChange: (s) => S(s),
1053
843
  get children() {
1054
- return M(C, {
844
+ return x(C, {
1055
845
  get class() {
1056
- return E(W(), t.class);
846
+ return H(E(), t.class);
1057
847
  },
1058
848
  get children() {
1059
- return [M(I, {
849
+ return [x(N, {
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 s = ft();
854
+ return w(s, x(R, {
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), w(s, x(c, {
1070
860
  class: "sr-only",
1071
861
  children: "Widget configuration dialog"
1072
862
  }), null), s;
1073
863
  })(), (() => {
1074
- var s = kt(), z = s.firstChild;
1075
- return p(z, () => g().map((O) => M(Dt, {
864
+ var s = mt(), _ = s.firstChild;
865
+ return w(_, () => d().map((V) => x(bt, {
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 m() === V.id;
1084
874
  },
1085
- onClick: () => S(O.id)
1086
- }))), p(s, M(j, {
875
+ onClick: () => $(V.id)
876
+ }))), w(s, x(T, {
1087
877
  get when() {
1088
878
  return t.headerActions;
1089
879
  },
@@ -1094,49 +884,49 @@ function Ft(e) {
1094
884
  })()];
1095
885
  }
1096
886
  }), (() => {
1097
- var s = Ct();
1098
- return p(s, D), s;
1099
- })(), M(j, {
887
+ var s = vt();
888
+ return w(s, k), s;
889
+ })(), x(T, {
1100
890
  get when() {
1101
- return _(() => v() === "edit")() && (b() || t.onDelete) || v() === "debug" && t.debugData !== void 0;
891
+ return D(() => m() === "edit")() && (M() || t.onDelete) || m() === "debug" && t.debugData !== void 0;
1102
892
  },
1103
893
  get children() {
1104
- var s = Mt();
1105
- return p(s, M(j, {
894
+ var s = wt();
895
+ return w(s, x(T, {
1106
896
  get when() {
1107
- return _(() => v() === "edit")() && t.onDelete;
897
+ return D(() => m() === "edit")() && t.onDelete;
1108
898
  },
1109
899
  get children() {
1110
- return M(h, {
900
+ return x(g, {
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), w(s, x(T, {
1118
908
  get when() {
1119
- return _(() => v() === "edit")() && b();
909
+ return D(() => m() === "edit")() && M();
1120
910
  },
1121
911
  get children() {
1122
- return M(h, {
912
+ return x(g, {
1123
913
  size: "sm",
1124
914
  get disabled() {
1125
- return !k();
915
+ return !O();
1126
916
  },
1127
- onClick: () => b()?.(),
917
+ onClick: () => M()?.(),
1128
918
  children: "Save"
1129
919
  });
1130
920
  }
1131
- }), null), p(s, M(j, {
921
+ }), null), w(s, x(T, {
1132
922
  get when() {
1133
- return _(() => v() === "debug")() && t.debugData !== void 0;
923
+ return D(() => m() === "debug")() && t.debugData !== void 0;
1134
924
  },
1135
925
  get children() {
1136
- return M(h, {
926
+ return x(g, {
1137
927
  size: "sm",
1138
928
  variant: "outline",
1139
- onClick: f,
929
+ onClick: l,
1140
930
  children: "Copy"
1141
931
  });
1142
932
  }
@@ -1148,157 +938,157 @@ 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
+ ve(["click"]);
942
+ function Rt(e = "edit") {
943
+ const [t, i] = B(!1), [r, n] = B(e);
1154
944
  return {
1155
945
  showDialog: t,
1156
- setShowDialog: r,
1157
- openDialog: () => r(!0),
1158
- closeDialog: () => r(!1),
1159
- activeTab: o,
946
+ setShowDialog: i,
947
+ openDialog: () => i(!0),
948
+ closeDialog: () => i(!1),
949
+ activeTab: r,
1160
950
  setActiveTab: n
1161
951
  };
1162
952
  }
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);
953
+ function Ut(e) {
954
+ const t = e.minEntities ?? 1, i = j(() => e.entities().length), r = j(() => i() >= t), n = j(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), a = j(() => {
955
+ if (!r()) return;
956
+ const u = e.aggregationMode?.();
957
+ if (!u || u === "none") return;
958
+ const p = e.entities();
959
+ if (u === "light" || u === "binary-sensor" || u === "switch")
960
+ return Le(p, e.allEntitiesMode);
961
+ if (u === "sensor") {
962
+ const y = e.sensorGroupType?.() ?? "mean";
963
+ return Fe(p, y, !0);
1174
964
  }
1175
- }), a = V(() => o() ? void 0 : e.emptyStateConfig);
965
+ }), h = j(() => r() ? void 0 : e.emptyStateConfig);
1176
966
  return {
1177
967
  entities: e.entities,
1178
968
  groupData: n,
1179
- aggregatedData: i,
1180
- emptyState: a,
1181
- hasEntities: o,
1182
- count: r
969
+ aggregatedData: a,
970
+ emptyState: h,
971
+ hasEntities: r,
972
+ count: i
1183
973
  };
1184
974
  }
1185
- const J = 32, d = J / 2, P = "white", te = "rgba(0,0,0,0.4)", le = 2, ne = 3;
1186
- function zt(e) {
975
+ const F = 32, o = F / 2, z = "white", K = "rgba(0,0,0,0.4)", ie = 2, X = 3;
976
+ function pt(e) {
1187
977
  return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
1188
978
  }
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>`;
979
+ function J(e) {
980
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${F}" height="${F}" viewBox="0 0 ${F} ${F}">${e}</svg>`;
1191
981
  }
1192
- const _t = re(`
982
+ const xt = J(`
1193
983
  <g transform="translate(6, 2)">
1194
984
  <!-- shadow -->
1195
- <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
985
+ <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1196
986
  <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
987
  </g>
1198
988
  <!-- main -->
1199
- <g stroke="${P}" stroke-width="${le}" fill="none" stroke-linecap="round" stroke-linejoin="round">
989
+ <g stroke="${z}" stroke-width="${ie}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1200
990
  <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
991
  </g>
1202
992
  </g>
1203
- `), Tt = re(`
993
+ `), yt = J(`
1204
994
  <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}"/>
995
+ <circle cx="${o}" cy="${o}" r="8" stroke="${K}" stroke-width="${X}" fill="none"/>
996
+ <circle cx="${o}" cy="${o}" r="8" stroke="${z}" stroke-width="1.5" fill="none"/>
997
+ <circle cx="${o}" cy="${o}" r="1.5" fill="${z}"/>
1208
998
  </g>
1209
- `), Et = re(`
999
+ `), $t = J(`
1210
1000
  <g>
1211
1001
  <!-- 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}"/>
1002
+ <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1003
+ <line x1="6" y1="${o}" x2="26" y2="${o}"/>
1004
+ <polyline points="10,${o - 4} 6,${o} 10,${o + 4}"/>
1005
+ <polyline points="22,${o - 4} 26,${o} 22,${o + 4}"/>
1216
1006
  </g>
1217
1007
  <!-- 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}"/>
1008
+ <g stroke="${z}" stroke-width="${ie}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1009
+ <line x1="6" y1="${o}" x2="26" y2="${o}"/>
1010
+ <polyline points="10,${o - 4} 6,${o} 10,${o + 4}"/>
1011
+ <polyline points="22,${o - 4} 26,${o} 22,${o + 4}"/>
1222
1012
  </g>
1223
1013
  <!-- 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"/>
1014
+ <circle cx="${o}" cy="${o}" r="1.5" fill="${z}"/>
1015
+ <circle cx="${o - 5}" cy="${o}" r="1" fill="${z}" opacity="0.6"/>
1016
+ <circle cx="${o + 5}" cy="${o}" r="1" fill="${z}" opacity="0.6"/>
1227
1017
  </g>
1228
- `), Ot = re(`
1018
+ `), kt = J(`
1229
1019
  <g>
1230
1020
  <!-- 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"/>
1021
+ <g stroke="${K}" stroke-width="${X}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1022
+ <line x1="${o}" y1="6" x2="${o}" y2="26"/>
1023
+ <polyline points="${o - 4},10 ${o},6 ${o + 4},10"/>
1024
+ <polyline points="${o - 4},22 ${o},26 ${o + 4},22"/>
1235
1025
  </g>
1236
1026
  <!-- 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"/>
1027
+ <g stroke="${z}" stroke-width="${ie}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1028
+ <line x1="${o}" y1="6" x2="${o}" y2="26"/>
1029
+ <polyline points="${o - 4},10 ${o},6 ${o + 4},10"/>
1030
+ <polyline points="${o - 4},22 ${o},26 ${o + 4},22"/>
1241
1031
  </g>
1242
1032
  <!-- 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"/>
1033
+ <circle cx="${o}" cy="${o}" r="1.5" fill="${z}"/>
1034
+ <circle cx="${o}" cy="${o - 5}" r="1" fill="${z}" opacity="0.6"/>
1035
+ <circle cx="${o}" cy="${o + 5}" r="1" fill="${z}" opacity="0.6"/>
1246
1036
  </g>
1247
1037
  `);
1248
- function ee(e, t, r) {
1249
- return { css: `${zt(e)} ${t} ${r}, auto`, hotspotX: t, hotspotY: r };
1038
+ function q(e, t, i) {
1039
+ return { css: `${pt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1250
1040
  }
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)
1041
+ const U = {
1042
+ tap: q(xt, 12, 4),
1043
+ hold: q(yt, 16, 16),
1044
+ slideHorizontal: q($t, o, o),
1045
+ slideVertical: q(kt, o, o)
1256
1046
  };
1257
- function oe() {
1047
+ function Z() {
1258
1048
  if (typeof window > "u") return null;
1259
1049
  const e = window;
1260
1050
  return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
1261
1051
  }
1262
- function ae(e) {
1052
+ function ee(e) {
1263
1053
  if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
1264
1054
  try {
1265
1055
  navigator.vibrate(e);
1266
1056
  } catch {
1267
1057
  }
1268
1058
  }
1269
- const Nt = {
1059
+ const Ct = {
1270
1060
  /** Light confirmation — fires when slide gesture arms after user holds still. */
1271
1061
  tick() {
1272
- const e = oe();
1062
+ const e = Z();
1273
1063
  if (e) {
1274
1064
  e.impact({ style: "Light" }).catch(() => {
1275
1065
  });
1276
1066
  return;
1277
1067
  }
1278
- ae(8);
1068
+ ee(8);
1279
1069
  },
1280
1070
  /** Medium bump — fires when hold gesture commits (detail opening). */
1281
1071
  bump() {
1282
- const e = oe();
1072
+ const e = Z();
1283
1073
  if (e) {
1284
1074
  e.impact({ style: "Medium" }).catch(() => {
1285
1075
  });
1286
1076
  return;
1287
1077
  }
1288
- ae(20);
1078
+ ee(20);
1289
1079
  },
1290
1080
  /** Stronger pulse — reserved for edit-mode pickup (future use). */
1291
1081
  pulse() {
1292
- const e = oe();
1082
+ const e = Z();
1293
1083
  if (e) {
1294
1084
  e.impact({ style: "Heavy" }).catch(() => {
1295
1085
  });
1296
1086
  return;
1297
1087
  }
1298
- ae([0, 15, 40, 15]);
1088
+ ee([0, 15, 40, 15]);
1299
1089
  }
1300
1090
  };
1301
- function qt(e, t) {
1091
+ function jt(e, t) {
1302
1092
  const n = {
1303
1093
  isDown: !1,
1304
1094
  isTouch: !1,
@@ -1310,139 +1100,139 @@ function qt(e, t) {
1310
1100
  holdTimer: null,
1311
1101
  element: null
1312
1102
  };
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 };
1103
+ let a = null, h = null, u = null;
1104
+ function p(c) {
1105
+ c !== h && (u && u.disconnect(), u = new ResizeObserver((g) => {
1106
+ const v = g[0];
1107
+ if (v) {
1108
+ const S = v.borderBoxSize?.[0];
1109
+ S ? a = { width: S.inlineSize, height: S.blockSize } : a = { width: v.contentRect.width, height: v.contentRect.height };
1320
1110
  }
1321
- }), a = u, c.observe(u), i = { width: u.clientWidth, height: u.clientHeight });
1111
+ }), h = c, u.observe(c), a = { width: c.clientWidth, height: c.clientHeight });
1322
1112
  }
1323
- const w = () => {
1113
+ const y = () => {
1324
1114
  n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
1325
- }, v = () => {
1115
+ }, m = () => {
1326
1116
  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;
1117
+ }, $ = (c) => {
1118
+ const v = e().slide;
1119
+ return v?.orientation === "horizontal" ? "horizontal" : v?.orientation === "vertical" ? "vertical" : c && (a || p(c), a) ? a.height > a.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
1120
+ }, E = (c) => {
1121
+ const g = e();
1122
+ if (!(!g.tap && !g.hold && !g.slide)) {
1123
+ if (n.isDown = !0, n.isTouch = c.pointerType === "touch", n.element = c.currentTarget, p(n.element), n.startX = c.clientX, n.startY = c.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, g.hold) {
1124
+ const v = g.hold.delay ?? 500;
1335
1125
  n.holdTimer = setTimeout(() => {
1336
- n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Nt.bump(), h.hold?.action(), n.isDown = !1);
1337
- }, m);
1126
+ n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Ct.bump(), g.hold?.action(), n.isDown = !1);
1127
+ }, v);
1338
1128
  }
1339
- if (!n.isTouch && h.slide)
1129
+ if (!n.isTouch && g.slide)
1340
1130
  try {
1341
- u.currentTarget.setPointerCapture(u.pointerId);
1131
+ c.currentTarget.setPointerCapture(c.pointerId);
1342
1132
  } catch {
1343
1133
  }
1344
1134
  }
1345
- }, g = (u) => {
1135
+ }, d = (c) => {
1346
1136
  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);
1137
+ const g = e(), v = c.clientX - n.startX, S = c.clientY - n.startY;
1138
+ if (Math.sqrt(v * v + S * S) > 10 && (y(), n.hasMoved = !0), !n.isTouch && g.slide && n.hasMoved) {
1139
+ const M = c.currentTarget, s = $(M);
1350
1140
  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();
1141
+ const _ = g.slide.min ?? 0, V = g.slide.max ?? 100, de = V - _, ue = s === "vertical" ? -S : v, re = a ?? { width: M.clientWidth, height: M.clientHeight }, ge = s === "vertical" ? re.height : re.width, he = ue / ge * de, fe = Math.max(_, Math.min(V, g.slide.value + he));
1142
+ g.slide.onChange(Math.round(fe)), n.startX = c.clientX, n.startY = c.clientY, c.preventDefault();
1353
1143
  }
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();
1144
+ }, l = (c) => {
1145
+ const g = e(), v = n.isDown, S = Date.now() - n.startTime, O = g.hold?.delay ?? 500;
1146
+ y(), v && g.tap && !n.hasMoved && S < O && g.tap();
1357
1147
  try {
1358
- u.currentTarget.releasePointerCapture(u.pointerId);
1148
+ c.currentTarget.releasePointerCapture(c.pointerId);
1359
1149
  } catch {
1360
1150
  }
1361
- v();
1362
- }, D = (u) => {
1363
- w();
1151
+ m();
1152
+ }, k = (c) => {
1153
+ y();
1364
1154
  try {
1365
- u.currentTarget.releasePointerCapture(u.pointerId);
1155
+ c.currentTarget.releasePointerCapture(c.pointerId);
1366
1156
  } catch {
1367
1157
  }
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);
1158
+ m();
1159
+ }, f = (c) => {
1160
+ const g = e();
1161
+ if (g.slide) {
1162
+ const v = g.slide.orientation;
1163
+ return v === "horizontal" ? U.slideHorizontal.css : v === "vertical" ? U.slideVertical.css : (a || p(c), a && a.height > a.width ? U.slideVertical.css : U.slideHorizontal.css);
1374
1164
  }
1375
- return h.tap ? G.tap.css : h.hold ? G.hold.css : "";
1165
+ return g.tap ? U.tap.css : g.hold ? U.hold.css : "";
1376
1166
  };
1377
1167
  return {
1378
- onPointerDown: W,
1379
- onPointerMove: g,
1380
- onPointerUp: f,
1381
- onPointerCancel: D,
1382
- onPointerEnter: (u) => {
1383
- const h = u.currentTarget;
1384
- n.element = h, h.style.cursor = $(h);
1168
+ onPointerDown: E,
1169
+ onPointerMove: d,
1170
+ onPointerUp: l,
1171
+ onPointerCancel: k,
1172
+ onPointerEnter: (c) => {
1173
+ const g = c.currentTarget;
1174
+ n.element = g, g.style.cursor = f(g);
1385
1175
  },
1386
- bindElement: (u) => {
1387
- u && (n.element = u, x(u));
1176
+ bindElement: (c) => {
1177
+ c && (n.element = c, p(c));
1388
1178
  },
1389
1179
  touchAction: () => {
1390
- const u = e();
1391
- return u.tap || u.hold || u.slide ? "manipulation" : "auto";
1180
+ const c = e();
1181
+ return c.tap || c.hold || c.slide ? "manipulation" : "auto";
1392
1182
  },
1393
1183
  dispose: () => {
1394
- w(), c && (c.disconnect(), c = null), a = null, i = null;
1184
+ y(), u && (u.disconnect(), u = null), h = null, a = null;
1395
1185
  }
1396
1186
  };
1397
1187
  }
1398
- const Xt = L.enum([
1188
+ const Bt = A.enum([
1399
1189
  "success",
1400
1190
  "warning",
1401
1191
  "danger",
1402
1192
  "info",
1403
1193
  "neutral",
1404
1194
  "accent"
1405
- ]), Jt = {
1195
+ ]), It = {
1406
1196
  /** Optional display name override (renders as text input) */
1407
- title: () => L.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1197
+ title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1408
1198
  /** Multi-select entity picker for a HA domain */
1409
- entityIds: (e) => L.array(L.string()).default([]).meta({ domain: e, title: "Entities" }),
1199
+ entityIds: (e) => A.array(A.string()).default([]).meta({ domain: e, title: "Entities" }),
1410
1200
  /** Single-select entity picker for a HA domain */
1411
- singleEntity: (e) => L.array(L.string()).default([]).meta({ domain: e, title: "Entity", singleSelect: !0 }),
1201
+ singleEntity: (e) => A.array(A.string()).default([]).meta({ domain: e, title: "Entity", singleSelect: !0 }),
1412
1202
  /** Area picker dropdown */
1413
- areaId: () => L.string().optional().meta({ formType: "area-picker", title: "Area" })
1203
+ areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
1414
1204
  };
1415
- function Qt() {
1205
+ function Lt() {
1416
1206
  return document.documentElement.classList.contains("dark");
1417
1207
  }
1418
- const Vt = "0.4.2", Pt = {
1419
- version: Vt
1420
- }, Zt = Pt.version;
1208
+ const St = "0.5.0", Mt = {
1209
+ version: St
1210
+ }, Ft = Mt.version;
1421
1211
  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
1212
+ Ft as SDK_VERSION,
1213
+ Bt as ToneSchema,
1214
+ I as Widget,
1215
+ Ve as WidgetContent,
1216
+ te as WidgetCtx,
1217
+ Pt as WidgetDialog,
1218
+ Pe as WidgetIcon,
1219
+ Yt as WidgetManifestSchema,
1220
+ Ne as WidgetSliderFill,
1221
+ Ue as WidgetStatus,
1222
+ Ie as WidgetTitle,
1223
+ Je as WidgetValue,
1224
+ Le as calculateLightGroup,
1225
+ Fe as calculateSensorGroup,
1226
+ Ht as countActiveEntities,
1227
+ Vt as defineWidget,
1228
+ Kt as formatSchemaError,
1229
+ Wt as getEntityAttribute,
1230
+ Se as injectTokens,
1231
+ Lt as isDark,
1232
+ Ge as isEntityActive,
1233
+ At as useWidgetContext,
1234
+ Rt as useWidgetDialog,
1235
+ Ut as useWidgetEntityGroup,
1236
+ jt as useWidgetGestures,
1237
+ It as widgetFields
1448
1238
  };