@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/framework/backgrounds/WidgetSliderFill.d.ts +2 -34
- package/dist/framework/components/WidgetContent.d.ts +0 -23
- package/dist/framework/components/WidgetIcon.d.ts +1 -35
- package/dist/framework/components/WidgetStatus.d.ts +0 -18
- package/dist/framework/components/WidgetTitle.d.ts +0 -22
- package/dist/framework/components/WidgetValue.d.ts +1 -23
- package/dist/framework/core/Widget.d.ts +13 -52
- package/dist/framework/gestures/use-widget-gestures.d.ts +4 -2
- package/dist/framework/hooks/index.d.ts +3 -1
- package/dist/framework/hooks/use-intersection-pause.d.ts +7 -0
- package/dist/framework/hooks/use-reduced-motion.d.ts +7 -0
- package/dist/framework/hooks/use-widget-context.d.ts +15 -59
- package/dist/framework/index.d.ts +3 -3
- package/dist/framework/theming/index.d.ts +1 -0
- package/dist/framework/theming/svg-colors.d.ts +23 -0
- package/dist/framework/types.d.ts +1 -53
- package/dist/index.d.ts +1 -0
- package/dist/index.js +714 -856
- package/dist/shared/spline.d.ts +5 -0
- package/package.json +1 -1
- package/dist/framework/design-system/spacing.d.ts +0 -40
- package/dist/framework/design-system/typography.d.ts +0 -40
package/dist/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
import { WidgetManifestSchema as
|
|
3
|
-
import { effect as
|
|
4
|
-
import { createElementSize as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { clsx as
|
|
7
|
-
import { twMerge as
|
|
8
|
-
function
|
|
9
|
-
return
|
|
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
|
|
12
|
-
return
|
|
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
|
|
16
|
+
function Ce(e) {
|
|
17
17
|
try {
|
|
18
18
|
return e.parse({});
|
|
19
19
|
} catch {
|
|
20
20
|
return {};
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return e.configSchema && (e.manifest.schema || (e.manifest.schema =
|
|
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
|
|
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
|
-
},
|
|
36
|
-
function
|
|
37
|
-
const e =
|
|
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
|
|
42
|
+
const Se = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
|
|
43
|
+
* via framework/theming/tokens.ts.
|
|
43
44
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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);
|
|
55
|
-
--tone-warning: oklch(0.80 0.17 75);
|
|
56
|
-
--tone-danger: oklch(0.64 0.22 27);
|
|
57
|
-
--tone-info: oklch(0.66 0.20 245);
|
|
58
|
-
--tone-neutral: oklch(0.65 0.02 250);
|
|
59
|
-
--tone-accent: oklch(0.74 0.18 60);
|
|
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);
|
|
69
|
-
--tone-warning: oklch(0.82 0.17 75);
|
|
70
|
-
--tone-danger: oklch(0.68 0.22 27);
|
|
71
|
-
--tone-info: oklch(0.70 0.20 245);
|
|
72
|
-
--tone-neutral: oklch(0.69 0.02 250);
|
|
73
|
-
--tone-accent: oklch(0.78 0.18 60);
|
|
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
|
-
/*
|
|
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
|
-
|
|
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
|
-
/*
|
|
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
|
-
/* ===
|
|
126
|
-
|
|
127
|
-
|
|
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
|
|
140
|
-
function
|
|
141
|
-
if (
|
|
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
|
-
|
|
220
|
+
Q = !0;
|
|
146
221
|
return;
|
|
147
222
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
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
|
|
152
|
-
return
|
|
226
|
+
function P(...e) {
|
|
227
|
+
return ke($e(e));
|
|
153
228
|
}
|
|
154
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
240
|
-
"classic-glass":
|
|
241
|
-
minimal:
|
|
242
|
-
"compact-horizontal":
|
|
314
|
+
}, Te = {
|
|
315
|
+
"classic-glass": De,
|
|
316
|
+
minimal: _e,
|
|
317
|
+
"compact-horizontal": ze
|
|
243
318
|
};
|
|
244
|
-
function
|
|
245
|
-
return
|
|
319
|
+
function Ee(e) {
|
|
320
|
+
return Te[e];
|
|
246
321
|
}
|
|
247
|
-
var
|
|
248
|
-
function
|
|
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
|
|
258
|
-
return
|
|
259
|
-
var
|
|
260
|
-
|
|
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
|
-
}),
|
|
338
|
+
}), t;
|
|
265
339
|
})();
|
|
266
340
|
}
|
|
267
|
-
|
|
268
|
-
|
|
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
|
|
351
|
-
return p(
|
|
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
|
|
369
|
-
function
|
|
370
|
-
const t =
|
|
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
|
|
388
|
-
return p(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
-
|
|
407
|
-
}), n;
|
|
374
|
+
t: void 0
|
|
375
|
+
}), i;
|
|
408
376
|
})();
|
|
409
377
|
}
|
|
410
|
-
|
|
411
|
-
|
|
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
|
|
529
|
-
return p(
|
|
530
|
-
var
|
|
531
|
-
return () =>
|
|
532
|
-
})()),
|
|
533
|
-
var
|
|
534
|
-
return
|
|
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
|
-
}),
|
|
391
|
+
}), t;
|
|
539
392
|
})();
|
|
540
393
|
}
|
|
541
|
-
var
|
|
542
|
-
function
|
|
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
|
|
546
|
-
return p(
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
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
|
-
|
|
559
|
-
o: void 0
|
|
560
|
-
}), r;
|
|
411
|
+
t: void 0
|
|
412
|
+
}), t;
|
|
561
413
|
})();
|
|
562
414
|
}
|
|
563
|
-
function
|
|
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
|
|
578
|
-
if (!
|
|
579
|
-
const
|
|
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:
|
|
583
|
-
isOn:
|
|
584
|
-
isUnavailable:
|
|
585
|
-
brightness:
|
|
586
|
-
brightnessPercent:
|
|
587
|
-
color:
|
|
588
|
-
onCount:
|
|
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:
|
|
442
|
+
description: M ? "On" : "Off"
|
|
591
443
|
};
|
|
592
444
|
}
|
|
593
|
-
let
|
|
594
|
-
const
|
|
595
|
-
for (const
|
|
596
|
-
switch (
|
|
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
|
-
|
|
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
|
-
|
|
456
|
+
o++;
|
|
605
457
|
break;
|
|
606
458
|
case "unavailable":
|
|
607
|
-
|
|
459
|
+
h++;
|
|
608
460
|
break;
|
|
609
461
|
}
|
|
610
|
-
const
|
|
611
|
-
let
|
|
612
|
-
t ?
|
|
613
|
-
const
|
|
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 (
|
|
616
|
-
const
|
|
617
|
-
u = `rgb(${Math.round(
|
|
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 =
|
|
620
|
-
let
|
|
621
|
-
return
|
|
622
|
-
isGroup:
|
|
623
|
-
state:
|
|
624
|
-
isOn:
|
|
625
|
-
isUnavailable:
|
|
626
|
-
brightness:
|
|
627
|
-
brightnessPercent:
|
|
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:
|
|
630
|
-
totalCount:
|
|
631
|
-
description:
|
|
481
|
+
onCount: r,
|
|
482
|
+
totalCount: c,
|
|
483
|
+
description: m
|
|
632
484
|
};
|
|
633
485
|
}
|
|
634
|
-
function
|
|
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
|
|
644
|
-
if (!
|
|
645
|
-
const
|
|
646
|
-
let
|
|
647
|
-
return Number.isNaN(
|
|
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:
|
|
650
|
-
numericValue: Number.isNaN(
|
|
651
|
-
isUnavailable:
|
|
652
|
-
unit:
|
|
653
|
-
description:
|
|
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 = [],
|
|
657
|
-
let
|
|
658
|
-
for (const
|
|
659
|
-
if (!
|
|
660
|
-
|
|
661
|
-
entityId:
|
|
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:
|
|
515
|
+
friendly_name: d.friendlyName
|
|
664
516
|
});
|
|
665
517
|
continue;
|
|
666
518
|
}
|
|
667
|
-
const
|
|
668
|
-
isNaN(
|
|
669
|
-
entityId:
|
|
670
|
-
value:
|
|
671
|
-
friendly_name:
|
|
672
|
-
}) : (n.push(
|
|
673
|
-
entityId:
|
|
674
|
-
value:
|
|
675
|
-
friendly_name:
|
|
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
|
|
679
|
-
if (
|
|
530
|
+
const y = h === e.length, f = n.length === 0;
|
|
531
|
+
if (y || f)
|
|
680
532
|
return {
|
|
681
|
-
isGroup:
|
|
682
|
-
state:
|
|
533
|
+
isGroup: r,
|
|
534
|
+
state: y ? "unavailable" : "unknown",
|
|
683
535
|
numericValue: null,
|
|
684
|
-
isUnavailable:
|
|
685
|
-
unit:
|
|
686
|
-
description:
|
|
687
|
-
memberValues:
|
|
536
|
+
isUnavailable: y,
|
|
537
|
+
unit: g,
|
|
538
|
+
description: y ? "Unavailable" : "No numeric values",
|
|
539
|
+
memberValues: o
|
|
688
540
|
};
|
|
689
|
-
let
|
|
541
|
+
let c, v;
|
|
690
542
|
switch (t) {
|
|
691
543
|
case "min":
|
|
692
|
-
|
|
544
|
+
c = Math.min(...n), v = "Minimum";
|
|
693
545
|
break;
|
|
694
546
|
case "max":
|
|
695
|
-
|
|
547
|
+
c = Math.max(...n), v = "Maximum";
|
|
696
548
|
break;
|
|
697
549
|
case "mean":
|
|
698
|
-
|
|
550
|
+
c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
|
|
699
551
|
break;
|
|
700
552
|
case "median": {
|
|
701
|
-
const
|
|
702
|
-
|
|
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
|
-
|
|
558
|
+
c = n.reduce((d, a) => d + a, 0), v = "Sum";
|
|
707
559
|
break;
|
|
708
560
|
case "last":
|
|
709
|
-
|
|
561
|
+
c = n[n.length - 1], v = "Latest";
|
|
710
562
|
break;
|
|
711
563
|
case "range":
|
|
712
|
-
|
|
564
|
+
c = Math.max(...n) - Math.min(...n), v = "Range";
|
|
713
565
|
break;
|
|
714
566
|
case "product":
|
|
715
|
-
|
|
567
|
+
c = n.reduce((d, a) => d * a, 1), v = "Product";
|
|
716
568
|
break;
|
|
717
569
|
case "std_dev": {
|
|
718
|
-
const
|
|
719
|
-
|
|
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
|
-
|
|
575
|
+
c = n.reduce((d, a) => d + a, 0) / n.length, v = "Average";
|
|
724
576
|
}
|
|
725
|
-
const
|
|
577
|
+
const k = Number.isInteger(c) ? c.toString() : c.toFixed(1);
|
|
726
578
|
return {
|
|
727
|
-
isGroup:
|
|
728
|
-
state:
|
|
729
|
-
numericValue:
|
|
579
|
+
isGroup: r,
|
|
580
|
+
state: k,
|
|
581
|
+
numericValue: c,
|
|
730
582
|
isUnavailable: !1,
|
|
731
|
-
unit:
|
|
732
|
-
description: `${
|
|
733
|
-
memberValues:
|
|
583
|
+
unit: g,
|
|
584
|
+
description: `${v} of ${n.length}`,
|
|
585
|
+
memberValues: o
|
|
734
586
|
};
|
|
735
587
|
}
|
|
736
|
-
function
|
|
588
|
+
function se(e) {
|
|
737
589
|
if (e.state !== "on") return "rgb(100, 100, 100)";
|
|
738
|
-
const
|
|
590
|
+
const i = (e.attributes?.brightness ?? 255) / 255;
|
|
739
591
|
if (e.attributes?.rgb_color) {
|
|
740
|
-
const [
|
|
741
|
-
return `rgb(${Math.round(
|
|
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
|
|
746
|
-
return n <= 66 ? (
|
|
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 *
|
|
600
|
+
return `rgb(${Math.round(255 * i)}, ${Math.round(220 * i)}, ${Math.round(180 * i)})`;
|
|
749
601
|
}
|
|
750
|
-
function
|
|
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
|
|
761
|
-
return e?.attributes ? e.attributes[t] ??
|
|
612
|
+
function Rt(e, t, i) {
|
|
613
|
+
return e?.attributes ? e.attributes[t] ?? i : i;
|
|
762
614
|
}
|
|
763
|
-
function
|
|
764
|
-
return e.filter(
|
|
615
|
+
function It(e) {
|
|
616
|
+
return e.filter(qe).length;
|
|
765
617
|
}
|
|
766
|
-
function
|
|
767
|
-
const { decimals:
|
|
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
|
|
773
|
-
n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (
|
|
774
|
-
let
|
|
775
|
-
return
|
|
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
|
|
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
|
|
781
|
-
function
|
|
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
|
|
785
|
-
return p(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
|
807
|
-
function
|
|
808
|
-
|
|
809
|
-
|
|
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
|
|
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:
|
|
654
|
+
updateConfig: t?.updateConfig ?? (() => {
|
|
655
|
+
}),
|
|
656
|
+
dimensions: () => ({
|
|
657
|
+
width: n.width ?? 0,
|
|
658
|
+
height: n.height ?? 0
|
|
865
659
|
})
|
|
866
|
-
},
|
|
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
|
-
...
|
|
871
|
-
...
|
|
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
|
-
})),
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
|
|
888
|
-
},
|
|
889
|
-
|
|
890
|
-
},
|
|
891
|
-
|
|
892
|
-
},
|
|
893
|
-
|
|
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
|
|
896
|
-
value:
|
|
692
|
+
return $(ne.Provider, {
|
|
693
|
+
value: o,
|
|
897
694
|
get children() {
|
|
898
|
-
var
|
|
899
|
-
return
|
|
900
|
-
|
|
901
|
-
},
|
|
902
|
-
var
|
|
903
|
-
return () =>
|
|
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(
|
|
915
|
-
var
|
|
916
|
-
return () =>
|
|
917
|
-
var
|
|
918
|
-
return
|
|
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),
|
|
921
|
-
var
|
|
922
|
-
|
|
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
|
-
}),
|
|
724
|
+
}), a;
|
|
935
725
|
}
|
|
936
726
|
});
|
|
937
727
|
}
|
|
938
|
-
function
|
|
728
|
+
function at(e) {
|
|
939
729
|
return (() => {
|
|
940
|
-
var t =
|
|
730
|
+
var t = tt();
|
|
941
731
|
return p(t, (() => {
|
|
942
|
-
var
|
|
943
|
-
return () =>
|
|
944
|
-
var
|
|
945
|
-
return p(
|
|
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
|
|
949
|
-
return () =>
|
|
950
|
-
var
|
|
951
|
-
return p(
|
|
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
|
|
955
|
-
return () =>
|
|
956
|
-
var
|
|
957
|
-
return p(
|
|
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
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
var
|
|
970
|
-
function
|
|
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 =
|
|
973
|
-
return t.$$click = () => e.onClick(), p(t,
|
|
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
|
|
979
|
-
return p(
|
|
768
|
+
var i = st();
|
|
769
|
+
return p(i, () => e.icon), i;
|
|
980
770
|
}
|
|
981
|
-
}), null), p(t, () => e.label, null),
|
|
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
|
|
985
|
-
const [t] =
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
...
|
|
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
|
-
})),
|
|
991
|
-
|
|
780
|
+
})), te(ae(() => t.configSchema, (l) => {
|
|
781
|
+
l && h(de(l));
|
|
992
782
|
}));
|
|
993
|
-
const
|
|
994
|
-
!
|
|
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(
|
|
997
|
-
},
|
|
998
|
-
t.onConfigSave?.(
|
|
999
|
-
}, [
|
|
1000
|
-
const
|
|
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
|
-
}[
|
|
1010
|
-
},
|
|
799
|
+
}[l];
|
|
800
|
+
}, d = () => {
|
|
1011
801
|
if (t.tabs) return t.tabs;
|
|
1012
|
-
const
|
|
1013
|
-
return
|
|
802
|
+
const l = [];
|
|
803
|
+
return l.push({
|
|
1014
804
|
id: "edit",
|
|
1015
805
|
label: "Edit",
|
|
1016
|
-
icon:
|
|
1017
|
-
content: t.editContent ?? (
|
|
806
|
+
icon: ct(),
|
|
807
|
+
content: t.editContent ?? (i() && o() ? $(b, {
|
|
1018
808
|
get schema() {
|
|
1019
|
-
return
|
|
809
|
+
return o();
|
|
1020
810
|
},
|
|
1021
811
|
get data() {
|
|
1022
|
-
return
|
|
812
|
+
return r();
|
|
1023
813
|
},
|
|
1024
814
|
onChange: n
|
|
1025
|
-
}) :
|
|
1026
|
-
}),
|
|
815
|
+
}) : dt())
|
|
816
|
+
}), l.push({
|
|
1027
817
|
id: "controls",
|
|
1028
818
|
label: "Controls",
|
|
1029
|
-
icon:
|
|
1030
|
-
content: t.controlsContent ??
|
|
1031
|
-
}),
|
|
819
|
+
icon: ut(),
|
|
820
|
+
content: t.controlsContent ?? gt()
|
|
821
|
+
}), l.push({
|
|
1032
822
|
id: "debug",
|
|
1033
823
|
label: "Debug",
|
|
1034
|
-
icon:
|
|
1035
|
-
content: t.debugContent ??
|
|
1036
|
-
}),
|
|
1037
|
-
},
|
|
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
|
|
1041
|
-
await navigator.clipboard.writeText(
|
|
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
|
-
},
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1047
|
-
},
|
|
1048
|
-
return
|
|
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: (
|
|
842
|
+
onOpenChange: (l) => M(l),
|
|
1053
843
|
get children() {
|
|
1054
|
-
return
|
|
844
|
+
return $(S, {
|
|
1055
845
|
get class() {
|
|
1056
|
-
return
|
|
846
|
+
return P(k(), t.class);
|
|
1057
847
|
},
|
|
1058
848
|
get children() {
|
|
1059
|
-
return [
|
|
849
|
+
return [$(O, {
|
|
1060
850
|
class: "flex flex-row items-center justify-between gap-3",
|
|
1061
851
|
get children() {
|
|
1062
852
|
return [(() => {
|
|
1063
|
-
var
|
|
1064
|
-
return p(
|
|
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(
|
|
859
|
+
}), null), p(l, $(u, {
|
|
1070
860
|
class: "sr-only",
|
|
1071
861
|
children: "Widget configuration dialog"
|
|
1072
|
-
}), null),
|
|
862
|
+
}), null), l;
|
|
1073
863
|
})(), (() => {
|
|
1074
|
-
var
|
|
1075
|
-
return p(z, () =>
|
|
864
|
+
var l = vt(), z = l.firstChild;
|
|
865
|
+
return p(z, () => d().map((V) => $(pt, {
|
|
1076
866
|
get icon() {
|
|
1077
|
-
return
|
|
867
|
+
return V.icon;
|
|
1078
868
|
},
|
|
1079
869
|
get label() {
|
|
1080
|
-
return
|
|
870
|
+
return V.label;
|
|
1081
871
|
},
|
|
1082
872
|
get isActive() {
|
|
1083
|
-
return
|
|
873
|
+
return c() === V.id;
|
|
1084
874
|
},
|
|
1085
|
-
onClick: () =>
|
|
1086
|
-
}))), p(
|
|
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),
|
|
883
|
+
}), null), l;
|
|
1094
884
|
})()];
|
|
1095
885
|
}
|
|
1096
886
|
}), (() => {
|
|
1097
|
-
var
|
|
1098
|
-
return p(
|
|
1099
|
-
})(),
|
|
887
|
+
var l = wt();
|
|
888
|
+
return p(l, C), l;
|
|
889
|
+
})(), $(E, {
|
|
1100
890
|
get when() {
|
|
1101
|
-
return _(() =>
|
|
891
|
+
return _(() => c() === "edit")() && (D() || t.onDelete) || c() === "debug" && t.debugData !== void 0;
|
|
1102
892
|
},
|
|
1103
893
|
get children() {
|
|
1104
|
-
var
|
|
1105
|
-
return p(
|
|
894
|
+
var l = bt();
|
|
895
|
+
return p(l, $(E, {
|
|
1106
896
|
get when() {
|
|
1107
|
-
return _(() =>
|
|
897
|
+
return _(() => c() === "edit")() && t.onDelete;
|
|
1108
898
|
},
|
|
1109
899
|
get children() {
|
|
1110
|
-
return
|
|
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(
|
|
907
|
+
}), null), p(l, $(E, {
|
|
1118
908
|
get when() {
|
|
1119
|
-
return _(() =>
|
|
909
|
+
return _(() => c() === "edit")() && D();
|
|
1120
910
|
},
|
|
1121
911
|
get children() {
|
|
1122
|
-
return
|
|
912
|
+
return $(m, {
|
|
1123
913
|
size: "sm",
|
|
1124
914
|
get disabled() {
|
|
1125
|
-
return !
|
|
915
|
+
return !N();
|
|
1126
916
|
},
|
|
1127
|
-
onClick: () =>
|
|
917
|
+
onClick: () => D()?.(),
|
|
1128
918
|
children: "Save"
|
|
1129
919
|
});
|
|
1130
920
|
}
|
|
1131
|
-
}), null), p(
|
|
921
|
+
}), null), p(l, $(E, {
|
|
1132
922
|
get when() {
|
|
1133
|
-
return _(() =>
|
|
923
|
+
return _(() => c() === "debug")() && t.debugData !== void 0;
|
|
1134
924
|
},
|
|
1135
925
|
get children() {
|
|
1136
|
-
return
|
|
926
|
+
return $(m, {
|
|
1137
927
|
size: "sm",
|
|
1138
928
|
variant: "outline",
|
|
1139
|
-
onClick:
|
|
929
|
+
onClick: a,
|
|
1140
930
|
children: "Copy"
|
|
1141
931
|
});
|
|
1142
932
|
}
|
|
1143
|
-
}), null),
|
|
933
|
+
}), null), l;
|
|
1144
934
|
}
|
|
1145
935
|
})];
|
|
1146
936
|
}
|
|
@@ -1148,157 +938,175 @@ function Ft(e) {
|
|
|
1148
938
|
}
|
|
1149
939
|
});
|
|
1150
940
|
}
|
|
1151
|
-
|
|
1152
|
-
function
|
|
1153
|
-
|
|
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:
|
|
1157
|
-
openDialog: () =>
|
|
1158
|
-
closeDialog: () =>
|
|
1159
|
-
activeTab:
|
|
964
|
+
setShowDialog: i,
|
|
965
|
+
openDialog: () => i(!0),
|
|
966
|
+
closeDialog: () => i(!1),
|
|
967
|
+
activeTab: r,
|
|
1160
968
|
setActiveTab: n
|
|
1161
969
|
};
|
|
1162
970
|
}
|
|
1163
|
-
function
|
|
1164
|
-
const t = e.minEntities ?? 1,
|
|
1165
|
-
if (!
|
|
1166
|
-
const
|
|
1167
|
-
if (!
|
|
1168
|
-
const
|
|
1169
|
-
if (
|
|
1170
|
-
return
|
|
1171
|
-
if (
|
|
1172
|
-
const
|
|
1173
|
-
return
|
|
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
|
-
}),
|
|
983
|
+
}), h = L(() => r() ? void 0 : e.emptyStateConfig);
|
|
1176
984
|
return {
|
|
1177
985
|
entities: e.entities,
|
|
1178
986
|
groupData: n,
|
|
1179
|
-
aggregatedData:
|
|
1180
|
-
emptyState:
|
|
1181
|
-
hasEntities:
|
|
1182
|
-
count:
|
|
987
|
+
aggregatedData: o,
|
|
988
|
+
emptyState: h,
|
|
989
|
+
hasEntities: r,
|
|
990
|
+
count: i
|
|
1183
991
|
};
|
|
1184
992
|
}
|
|
1185
|
-
const
|
|
1186
|
-
function
|
|
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
|
|
1190
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
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
|
|
1000
|
+
const yt = J(`
|
|
1193
1001
|
<g transform="translate(6, 2)">
|
|
1194
1002
|
<!-- shadow -->
|
|
1195
|
-
<g stroke="${
|
|
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="${
|
|
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
|
-
`),
|
|
1011
|
+
`), $t = J(`
|
|
1204
1012
|
<g>
|
|
1205
|
-
<circle cx="${
|
|
1206
|
-
<circle cx="${
|
|
1207
|
-
<circle cx="${
|
|
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
|
-
`),
|
|
1017
|
+
`), kt = J(`
|
|
1210
1018
|
<g>
|
|
1211
1019
|
<!-- shadow -->
|
|
1212
|
-
<g stroke="${
|
|
1213
|
-
<line x1="6" y1="${
|
|
1214
|
-
<polyline points="10,${
|
|
1215
|
-
<polyline points="22,${
|
|
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="${
|
|
1219
|
-
<line x1="6" y1="${
|
|
1220
|
-
<polyline points="10,${
|
|
1221
|
-
<polyline points="22,${
|
|
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="${
|
|
1225
|
-
<circle cx="${
|
|
1226
|
-
<circle cx="${
|
|
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
|
-
`),
|
|
1036
|
+
`), Ct = J(`
|
|
1229
1037
|
<g>
|
|
1230
1038
|
<!-- shadow -->
|
|
1231
|
-
<g stroke="${
|
|
1232
|
-
<line x1="${
|
|
1233
|
-
<polyline points="${
|
|
1234
|
-
<polyline points="${
|
|
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="${
|
|
1238
|
-
<line x1="${
|
|
1239
|
-
<polyline points="${
|
|
1240
|
-
<polyline points="${
|
|
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="${
|
|
1244
|
-
<circle cx="${
|
|
1245
|
-
<circle cx="${
|
|
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
|
|
1249
|
-
return { css: `${
|
|
1056
|
+
function q(e, t, i) {
|
|
1057
|
+
return { css: `${xt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
|
|
1250
1058
|
}
|
|
1251
|
-
const
|
|
1252
|
-
tap:
|
|
1253
|
-
hold:
|
|
1254
|
-
slideHorizontal:
|
|
1255
|
-
slideVertical:
|
|
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
|
|
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
|
|
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
|
|
1077
|
+
const St = {
|
|
1270
1078
|
/** Light confirmation — fires when slide gesture arms after user holds still. */
|
|
1271
1079
|
tick() {
|
|
1272
|
-
const e =
|
|
1080
|
+
const e = Z();
|
|
1273
1081
|
if (e) {
|
|
1274
1082
|
e.impact({ style: "Light" }).catch(() => {
|
|
1275
1083
|
});
|
|
1276
1084
|
return;
|
|
1277
1085
|
}
|
|
1278
|
-
|
|
1086
|
+
ee(8);
|
|
1279
1087
|
},
|
|
1280
1088
|
/** Medium bump — fires when hold gesture commits (detail opening). */
|
|
1281
1089
|
bump() {
|
|
1282
|
-
const e =
|
|
1090
|
+
const e = Z();
|
|
1283
1091
|
if (e) {
|
|
1284
1092
|
e.impact({ style: "Medium" }).catch(() => {
|
|
1285
1093
|
});
|
|
1286
1094
|
return;
|
|
1287
1095
|
}
|
|
1288
|
-
|
|
1096
|
+
ee(20);
|
|
1289
1097
|
},
|
|
1290
1098
|
/** Stronger pulse — reserved for edit-mode pickup (future use). */
|
|
1291
1099
|
pulse() {
|
|
1292
|
-
const e =
|
|
1100
|
+
const e = Z();
|
|
1293
1101
|
if (e) {
|
|
1294
1102
|
e.impact({ style: "Heavy" }).catch(() => {
|
|
1295
1103
|
});
|
|
1296
1104
|
return;
|
|
1297
1105
|
}
|
|
1298
|
-
|
|
1106
|
+
ee([0, 15, 40, 15]);
|
|
1299
1107
|
}
|
|
1300
1108
|
};
|
|
1301
|
-
function
|
|
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
|
|
1314
|
-
function
|
|
1315
|
-
u !==
|
|
1316
|
-
const
|
|
1317
|
-
if (
|
|
1318
|
-
const
|
|
1319
|
-
|
|
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
|
-
}),
|
|
1129
|
+
}), h = u, g.observe(u), o = { width: u.clientWidth, height: u.clientHeight });
|
|
1322
1130
|
}
|
|
1323
|
-
const
|
|
1131
|
+
const f = () => {
|
|
1324
1132
|
n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
|
|
1325
|
-
},
|
|
1133
|
+
}, c = () => {
|
|
1326
1134
|
n.isDown = !1, n.hasMoved = !1, n.sliding = !1;
|
|
1327
|
-
},
|
|
1328
|
-
const
|
|
1329
|
-
return
|
|
1330
|
-
},
|
|
1331
|
-
const
|
|
1332
|
-
if (!(!
|
|
1333
|
-
if (n.isDown = !0, n.isTouch = u.pointerType === "touch", n.element = u.currentTarget,
|
|
1334
|
-
const
|
|
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) && (
|
|
1337
|
-
},
|
|
1144
|
+
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (St.bump(), m.hold?.action(), n.isDown = !1);
|
|
1145
|
+
}, b);
|
|
1338
1146
|
}
|
|
1339
|
-
if (!n.isTouch &&
|
|
1147
|
+
if (!n.isTouch && m.slide)
|
|
1340
1148
|
try {
|
|
1341
1149
|
u.currentTarget.setPointerCapture(u.pointerId);
|
|
1342
1150
|
} catch {
|
|
1343
1151
|
}
|
|
1344
1152
|
}
|
|
1345
|
-
},
|
|
1153
|
+
}, d = (u) => {
|
|
1346
1154
|
if (!n.isDown) return;
|
|
1347
|
-
const
|
|
1348
|
-
if (Math.sqrt(
|
|
1349
|
-
const
|
|
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 =
|
|
1352
|
-
|
|
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
|
-
},
|
|
1355
|
-
const
|
|
1356
|
-
|
|
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
|
-
|
|
1362
|
-
},
|
|
1363
|
-
|
|
1169
|
+
c();
|
|
1170
|
+
}, C = (u) => {
|
|
1171
|
+
f();
|
|
1364
1172
|
try {
|
|
1365
1173
|
u.currentTarget.releasePointerCapture(u.pointerId);
|
|
1366
1174
|
} catch {
|
|
1367
1175
|
}
|
|
1368
|
-
|
|
1369
|
-
},
|
|
1370
|
-
const
|
|
1371
|
-
if (
|
|
1372
|
-
const
|
|
1373
|
-
return
|
|
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
|
|
1183
|
+
return m.tap ? j.tap.css : m.hold ? j.hold.css : "";
|
|
1376
1184
|
};
|
|
1377
1185
|
return {
|
|
1378
|
-
onPointerDown:
|
|
1379
|
-
onPointerMove:
|
|
1380
|
-
onPointerUp:
|
|
1381
|
-
onPointerCancel:
|
|
1186
|
+
onPointerDown: k,
|
|
1187
|
+
onPointerMove: d,
|
|
1188
|
+
onPointerUp: a,
|
|
1189
|
+
onPointerCancel: C,
|
|
1382
1190
|
onPointerEnter: (u) => {
|
|
1383
|
-
const
|
|
1384
|
-
n.element =
|
|
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,
|
|
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
|
-
|
|
1202
|
+
f(), g && (g.disconnect(), g = null), h = null, o = null;
|
|
1395
1203
|
}
|
|
1396
1204
|
};
|
|
1397
1205
|
}
|
|
1398
|
-
const
|
|
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
|
-
]),
|
|
1232
|
+
]), Kt = {
|
|
1406
1233
|
/** Optional display name override (renders as text input) */
|
|
1407
|
-
title: () =>
|
|
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) =>
|
|
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) =>
|
|
1238
|
+
singleEntity: (e) => A.array(A.string()).default([]).meta({ domain: e, title: "Entity", singleSelect: !0 }),
|
|
1412
1239
|
/** Area picker dropdown */
|
|
1413
|
-
areaId: () =>
|
|
1240
|
+
areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
|
|
1414
1241
|
};
|
|
1415
|
-
function
|
|
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
|
|
1419
|
-
version:
|
|
1420
|
-
},
|
|
1272
|
+
const _t = "0.5.1", zt = {
|
|
1273
|
+
version: _t
|
|
1274
|
+
}, Qt = zt.version;
|
|
1421
1275
|
export {
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
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
|
};
|