@camstack/addon-post-analysis 0.1.14 → 0.1.16

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.
Files changed (48) hide show
  1. package/dist/embedding-encoder/index.js +1 -1
  2. package/dist/embedding-encoder/index.mjs +1 -1
  3. package/dist/enrichment-engine/index.js +75 -7
  4. package/dist/enrichment-engine/index.js.map +1 -1
  5. package/dist/enrichment-engine/index.mjs +75 -7
  6. package/dist/enrichment-engine/index.mjs.map +1 -1
  7. package/dist/{index-tm6O4bWa.mjs → index-CGAj-pkn.mjs} +531 -97
  8. package/dist/index-CGAj-pkn.mjs.map +1 -0
  9. package/dist/{index-DNpNyDJi.js → index-Dbx13pc7.js} +531 -97
  10. package/dist/index-Dbx13pc7.js.map +1 -0
  11. package/dist/pipeline-analytics/@mf-types/compiled-types/pipeline-analytics/widgets/LiveStatsTab.d.ts +5 -0
  12. package/dist/pipeline-analytics/@mf-types/compiled-types/pipeline-analytics/widgets/index.d.ts +2 -0
  13. package/dist/pipeline-analytics/@mf-types.zip +0 -0
  14. package/dist/pipeline-analytics/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-d8PmLbO2.mjs +19 -0
  15. package/dist/pipeline-analytics/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-BcWYbuKp.mjs +18 -0
  16. package/dist/pipeline-analytics/{__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs-DuO9h7li.mjs → __mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs-D-USVuHq.mjs} +4 -2
  17. package/dist/pipeline-analytics/{__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-CmqNjq44.mjs → __mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-qQCPW8pT.mjs} +1 -1
  18. package/dist/pipeline-analytics/{__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-CA8cCIEl.mjs → __mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Bv9bYz9E.mjs} +1 -1
  19. package/dist/pipeline-analytics/_stub.js +497 -431
  20. package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-C7e1vVcD.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-D_pYr5G6.mjs} +6 -6
  21. package/dist/pipeline-analytics/{client-DdXDZxzK.mjs → client-DHmQcIWy.mjs} +2990 -3217
  22. package/dist/pipeline-analytics/{hostInit-TFbPssJX.mjs → hostInit-DXmzhNK7.mjs} +12 -12
  23. package/dist/pipeline-analytics/{index-DHiJ7A5x.mjs → index-BA65ZJOW.mjs} +1 -1
  24. package/dist/pipeline-analytics/{index-BP0-1QYT.mjs → index-BCEx31Mh.mjs} +3808 -3100
  25. package/dist/pipeline-analytics/{index-kIgjN-uq.mjs → index-CHnXxMRA.mjs} +1 -1
  26. package/dist/pipeline-analytics/index-CWkKuNLr.mjs +232 -0
  27. package/dist/pipeline-analytics/{index-B4OKsa9p.mjs → index-Crs1D0Uu.mjs} +1 -1
  28. package/dist/pipeline-analytics/{index-k0CA0h_r.mjs → index-DicaGC31.mjs} +1 -1
  29. package/dist/pipeline-analytics/index-gbflFMEY.mjs +36403 -0
  30. package/dist/pipeline-analytics/{index-DyYvUfc7.mjs → index-gpelkpEE.mjs} +1 -1
  31. package/dist/pipeline-analytics/index.js +73 -22
  32. package/dist/pipeline-analytics/index.js.map +1 -1
  33. package/dist/pipeline-analytics/index.mjs +73 -22
  34. package/dist/pipeline-analytics/index.mjs.map +1 -1
  35. package/dist/pipeline-analytics/{jsx-runtime-4ro1c69i.mjs → jsx-runtime-Wcfyyyt4.mjs} +1 -1
  36. package/dist/pipeline-analytics/remoteEntry.js +1 -1
  37. package/dist/recording/index.js +2 -2
  38. package/dist/recording/index.mjs +2 -2
  39. package/dist/{recording-coordinator-BVFZsuQg.mjs → recording-coordinator-BjWd7HjD.mjs} +2 -2
  40. package/dist/{recording-coordinator-BVFZsuQg.mjs.map → recording-coordinator-BjWd7HjD.mjs.map} +1 -1
  41. package/dist/{recording-coordinator-CL3NPb1p.js → recording-coordinator-b-7Ast8s.js} +2 -2
  42. package/dist/{recording-coordinator-CL3NPb1p.js.map → recording-coordinator-b-7Ast8s.js.map} +1 -1
  43. package/package.json +5 -1
  44. package/dist/index-DNpNyDJi.js.map +0 -1
  45. package/dist/index-tm6O4bWa.mjs.map +0 -1
  46. package/dist/pipeline-analytics/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-CpCK52pE.mjs +0 -19
  47. package/dist/pipeline-analytics/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEj77u_A.mjs +0 -15
  48. package/dist/pipeline-analytics/index-BDPtaPA2.mjs +0 -20855
@@ -1,20 +1,20 @@
1
- import { _ as r, a as i, b as ae } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-BsyrX6NO.mjs";
2
- import { a as Ie, b as fe, c as K, d as H, e as ge, f as N } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs-DuO9h7li.mjs";
1
+ import { _ as n, a as i, b as ie } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-BsyrX6NO.mjs";
2
+ import { a as Ae, b as pe, c as Q, d as H, e as ye, f as k } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs-D-USVuHq.mjs";
3
3
  import { _ as le } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs";
4
- import { _ as z, a as Q, b as Be, c as ye } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEj77u_A.mjs";
4
+ import { _ as Y, a as J, b as Pe, c as ve, d as ze, e as Xe, f as B } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-BcWYbuKp.mjs";
5
5
  /**
6
6
  * @license lucide-react v0.511.0 - ISC
7
7
  *
8
8
  * This source code is licensed under the ISC license.
9
9
  * See the LICENSE file in the root directory of this source tree.
10
10
  */
11
- const Pe = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ze = (e) => e.replace(
11
+ const Ye = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), qe = (e) => e.replace(
12
12
  /^([A-Z])|[\s-_]+(\w)/g,
13
- (t, o, n) => n ? n.toUpperCase() : o.toLowerCase()
14
- ), Ne = (e) => {
15
- const t = ze(e);
13
+ (t, o, r) => r ? r.toUpperCase() : o.toLowerCase()
14
+ ), Me = (e) => {
15
+ const t = qe(e);
16
16
  return t.charAt(0).toUpperCase() + t.slice(1);
17
- }, Ae = (...e) => e.filter((t, o, n) => !!t && t.trim() !== "" && n.indexOf(t) === o).join(" ").trim(), Xe = (e) => {
17
+ }, Fe = (...e) => e.filter((t, o, r) => !!t && t.trim() !== "" && r.indexOf(t) === o).join(" ").trim(), Ge = (e) => {
18
18
  for (const t in e)
19
19
  if (t.startsWith("aria-") || t === "role" || t === "title")
20
20
  return !0;
@@ -25,7 +25,7 @@ const Pe = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ze = (
25
25
  * This source code is licensed under the ISC license.
26
26
  * See the LICENSE file in the root directory of this source tree.
27
27
  */
28
- var Ye = {
28
+ var Ue = {
29
29
  xmlns: "http://www.w3.org/2000/svg",
30
30
  width: 24,
31
31
  height: 24,
@@ -42,31 +42,31 @@ var Ye = {
42
42
  * This source code is licensed under the ISC license.
43
43
  * See the LICENSE file in the root directory of this source tree.
44
44
  */
45
- const qe = Ie(
45
+ const Ve = Ae(
46
46
  ({
47
47
  color: e = "currentColor",
48
48
  size: t = 24,
49
49
  strokeWidth: o = 2,
50
- absoluteStrokeWidth: n,
50
+ absoluteStrokeWidth: r,
51
51
  className: a = "",
52
52
  children: s,
53
53
  iconNode: d,
54
54
  ...l
55
- }, f) => fe(
55
+ }, f) => pe(
56
56
  "svg",
57
57
  {
58
58
  ref: f,
59
- ...Ye,
59
+ ...Ue,
60
60
  width: t,
61
61
  height: t,
62
62
  stroke: e,
63
- strokeWidth: n ? Number(o) * 24 / Number(t) : o,
64
- className: Ae("lucide", a),
65
- ...!s && !Xe(l) && { "aria-hidden": "true" },
63
+ strokeWidth: r ? Number(o) * 24 / Number(t) : o,
64
+ className: Fe("lucide", a),
65
+ ...!s && !Ge(l) && { "aria-hidden": "true" },
66
66
  ...l
67
67
  },
68
68
  [
69
- ...d.map(([u, k]) => fe(u, k)),
69
+ ...d.map(([u, N]) => pe(u, N)),
70
70
  ...Array.isArray(s) ? s : [s]
71
71
  ]
72
72
  )
@@ -77,20 +77,20 @@ const qe = Ie(
77
77
  * This source code is licensed under the ISC license.
78
78
  * See the LICENSE file in the root directory of this source tree.
79
79
  */
80
- const W = (e, t) => {
81
- const o = Ie(
82
- ({ className: n, ...a }, s) => fe(qe, {
80
+ const j = (e, t) => {
81
+ const o = Ae(
82
+ ({ className: r, ...a }, s) => pe(Ve, {
83
83
  ref: s,
84
84
  iconNode: t,
85
- className: Ae(
86
- `lucide-${Pe(Ne(e))}`,
85
+ className: Fe(
86
+ `lucide-${Ye(Me(e))}`,
87
87
  `lucide-${e}`,
88
- n
88
+ r
89
89
  ),
90
90
  ...a
91
91
  })
92
92
  );
93
- return o.displayName = Ne(e), o;
93
+ return o.displayName = Me(e), o;
94
94
  };
95
95
  /**
96
96
  * @license lucide-react v0.511.0 - ISC
@@ -98,7 +98,7 @@ const W = (e, t) => {
98
98
  * This source code is licensed under the ISC license.
99
99
  * See the LICENSE file in the root directory of this source tree.
100
100
  */
101
- const Ge = [
101
+ const Ze = [
102
102
  [
103
103
  "path",
104
104
  {
@@ -106,14 +106,14 @@ const Ge = [
106
106
  key: "169zse"
107
107
  }
108
108
  ]
109
- ], Z = W("activity", Ge);
109
+ ], K = j("activity", Ze);
110
110
  /**
111
111
  * @license lucide-react v0.511.0 - ISC
112
112
  *
113
113
  * This source code is licensed under the ISC license.
114
114
  * See the LICENSE file in the root directory of this source tree.
115
115
  */
116
- const Ue = [
116
+ const Ke = [
117
117
  [
118
118
  "path",
119
119
  {
@@ -144,14 +144,14 @@ const Ue = [
144
144
  ["path", { d: "M12 8 7.26 5.15", key: "1vbdud" }],
145
145
  ["path", { d: "m12 8 4.74-2.85", key: "3rx089" }],
146
146
  ["path", { d: "M12 13.5V8", key: "1io7kd" }]
147
- ], Ve = W("boxes", Ue);
147
+ ], Qe = j("boxes", Ke);
148
148
  /**
149
149
  * @license lucide-react v0.511.0 - ISC
150
150
  *
151
151
  * This source code is licensed under the ISC license.
152
152
  * See the LICENSE file in the root directory of this source tree.
153
153
  */
154
- const Ze = [
154
+ const Je = [
155
155
  [
156
156
  "path",
157
157
  {
@@ -160,14 +160,14 @@ const Ze = [
160
160
  }
161
161
  ],
162
162
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
163
- ], Ke = W("eye", Ze);
163
+ ], et = j("eye", Je);
164
164
  /**
165
165
  * @license lucide-react v0.511.0 - ISC
166
166
  *
167
167
  * This source code is licensed under the ISC license.
168
168
  * See the LICENSE file in the root directory of this source tree.
169
169
  */
170
- const Qe = [
170
+ const tt = [
171
171
  [
172
172
  "path",
173
173
  {
@@ -189,14 +189,14 @@ const Qe = [
189
189
  key: "kqbvx6"
190
190
  }
191
191
  ]
192
- ], re = W("layers", Qe);
192
+ ], oe = j("layers", tt);
193
193
  /**
194
194
  * @license lucide-react v0.511.0 - ISC
195
195
  *
196
196
  * This source code is licensed under the ISC license.
197
197
  * See the LICENSE file in the root directory of this source tree.
198
198
  */
199
- const Je = [
199
+ const nt = [
200
200
  ["path", { d: "M12.75 7.09a3 3 0 0 1 2.16 2.16", key: "1d4wjd" }],
201
201
  [
202
202
  "path",
@@ -208,54 +208,54 @@ const Je = [
208
208
  ["path", { d: "m2 2 20 20", key: "1ooewy" }],
209
209
  ["path", { d: "M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533", key: "lhrkcz" }],
210
210
  ["path", { d: "M9.13 9.13a3 3 0 0 0 3.74 3.74", key: "13wojd" }]
211
- ], et = W("map-pin-off", Je);
211
+ ], rt = j("map-pin-off", nt);
212
212
  /**
213
213
  * @license lucide-react v0.511.0 - ISC
214
214
  *
215
215
  * This source code is licensed under the ISC license.
216
216
  * See the LICENSE file in the root directory of this source tree.
217
217
  */
218
- const tt = [
218
+ const ot = [
219
219
  ["line", { x1: "2", x2: "22", y1: "2", y2: "22", key: "a6p6uj" }],
220
220
  ["path", { d: "M18.89 13.23A7.12 7.12 0 0 0 19 12v-2", key: "80xlxr" }],
221
221
  ["path", { d: "M5 10v2a7 7 0 0 0 12 5", key: "p2k8kg" }],
222
222
  ["path", { d: "M15 9.34V5a3 3 0 0 0-5.68-1.33", key: "1gzdoj" }],
223
223
  ["path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12", key: "r2i35w" }],
224
224
  ["line", { x1: "12", x2: "12", y1: "19", y2: "22", key: "x3vr5v" }]
225
- ], nt = W("mic-off", tt);
225
+ ], st = j("mic-off", ot);
226
226
  /**
227
227
  * @license lucide-react v0.511.0 - ISC
228
228
  *
229
229
  * This source code is licensed under the ISC license.
230
230
  * See the LICENSE file in the root directory of this source tree.
231
231
  */
232
- const rt = [
232
+ const at = [
233
233
  ["path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z", key: "131961" }],
234
234
  ["path", { d: "M19 10v2a7 7 0 0 1-14 0v-2", key: "1vc78b" }],
235
235
  ["line", { x1: "12", x2: "12", y1: "19", y2: "22", key: "x3vr5v" }]
236
- ], ot = W("mic", rt);
237
- function ie({
236
+ ], it = j("mic", at);
237
+ function ce({
238
238
  presets: e,
239
239
  value: t,
240
240
  onChange: o
241
241
  }) {
242
- return /* @__PURE__ */ r("div", { className: "flex items-center gap-1 border border-border rounded-md p-0.5 bg-background", children: e.map(({ id: n, label: a }) => /* @__PURE__ */ r(
242
+ return /* @__PURE__ */ n("div", { className: "flex items-center gap-1 border border-border rounded-md p-0.5 bg-background", children: e.map(({ id: r, label: a }) => /* @__PURE__ */ n(
243
243
  "button",
244
244
  {
245
245
  type: "button",
246
- onClick: () => o(n),
247
- className: `px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${t === n ? "bg-primary/10 text-primary" : "text-foreground-subtle hover:text-foreground"}`,
246
+ onClick: () => o(r),
247
+ className: `px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${t === r ? "bg-primary/10 text-primary" : "text-foreground-subtle hover:text-foreground"}`,
248
248
  children: a
249
249
  },
250
- n
250
+ r
251
251
  )) });
252
252
  }
253
- function ce(e = 0) {
254
- const t = K(null), [o, n] = H(0);
255
- return ge(() => {
253
+ function de(e = 0) {
254
+ const t = Q(null), [o, r] = H(0);
255
+ return ye(() => {
256
256
  const a = t.current;
257
257
  if (!a) return;
258
- const s = (l) => n(Math.max(e, Math.floor(l)));
258
+ const s = (l) => r(Math.max(e, Math.floor(l)));
259
259
  s(a.clientWidth);
260
260
  const d = new ResizeObserver((l) => {
261
261
  const f = l[0];
@@ -264,30 +264,30 @@ function ce(e = 0) {
264
264
  return d.observe(a), () => d.disconnect();
265
265
  }, [e]), [t, o];
266
266
  }
267
- function st(e, t) {
268
- const o = new Date(e), n = String(o.getHours()).padStart(2, "0"), a = String(o.getMinutes()).padStart(2, "0");
269
- if (t <= 1440 * 60 * 1e3) return `${n}:${a}`;
267
+ function lt(e, t) {
268
+ const o = new Date(e), r = String(o.getHours()).padStart(2, "0"), a = String(o.getMinutes()).padStart(2, "0");
269
+ if (t <= 1440 * 60 * 1e3) return `${r}:${a}`;
270
270
  const s = String(o.getDate()).padStart(2, "0"), d = String(o.getMonth() + 1).padStart(2, "0");
271
- return `${s}/${d} ${n}:${a}`;
271
+ return `${s}/${d} ${r}:${a}`;
272
272
  }
273
- function Fe(e, t, o, n, a) {
274
- if (t <= 1) return n;
275
- const s = o - n - a;
276
- return n + e / (t - 1) * s;
273
+ function Te(e, t, o, r, a) {
274
+ if (t <= 1) return r;
275
+ const s = o - r - a;
276
+ return r + e / (t - 1) * s;
277
277
  }
278
- function ve(e, t, o, n, a, s) {
278
+ function we(e, t, o, r, a, s) {
279
279
  if (t <= e) return [];
280
- const d = t - e, l = [], f = o - n - a;
280
+ const d = t - e, l = [], f = o - r - a;
281
281
  for (let u = 0; u < s; u++) {
282
- const k = u / Math.max(1, s - 1), $ = e + d * k;
282
+ const N = u / Math.max(1, s - 1), $ = e + d * N;
283
283
  l.push({
284
- x: n + k * f,
285
- label: st($, d)
284
+ x: r + N * f,
285
+ label: lt($, d)
286
286
  });
287
287
  }
288
288
  return l;
289
289
  }
290
- const Me = [
290
+ const $e = [
291
291
  "#3b82f6",
292
292
  // blue-500
293
293
  "#a855f7",
@@ -305,16 +305,16 @@ const Me = [
305
305
  "#ef4444"
306
306
  // red-500
307
307
  ];
308
- function pe(e) {
309
- return Me[e % Me.length] ?? "#64748b";
308
+ function be(e) {
309
+ return $e[e % $e.length] ?? "#64748b";
310
310
  }
311
- function de() {
311
+ function ue() {
312
312
  const [e, t] = H(null);
313
313
  return { state: e, bindHover: t };
314
314
  }
315
- function ue({ state: e, containerWidth: t }) {
315
+ function he({ state: e, containerWidth: t }) {
316
316
  if (!e) return null;
317
- const n = 220 / 2, a = n + 4, s = Math.max(a, t - n - 4), d = Math.max(a, Math.min(s, e.anchorX)), l = e.anchorX - d;
317
+ const r = 220 / 2, a = r + 4, s = Math.max(a, t - r - 4), d = Math.max(a, Math.min(s, e.anchorX)), l = e.anchorX - d;
318
318
  return /* @__PURE__ */ i(
319
319
  "div",
320
320
  {
@@ -328,15 +328,15 @@ function ue({ state: e, containerWidth: t }) {
328
328
  },
329
329
  className: "z-10 rounded-md border border-border bg-surface shadow-lg px-2.5 py-1.5 text-[10px] text-foreground min-w-[140px] max-w-[240px]",
330
330
  children: [
331
- /* @__PURE__ */ r("div", { className: "font-semibold mb-1 truncate", children: e.title }),
332
- /* @__PURE__ */ r("div", { className: "space-y-0.5", children: e.rows.map((f, u) => /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2", children: [
331
+ /* @__PURE__ */ n("div", { className: "font-semibold mb-1 truncate", children: e.title }),
332
+ /* @__PURE__ */ n("div", { className: "space-y-0.5", children: e.rows.map((f, u) => /* @__PURE__ */ i("div", { className: "flex items-center justify-between gap-2", children: [
333
333
  /* @__PURE__ */ i("span", { className: "flex items-center gap-1 text-foreground-subtle truncate", children: [
334
- f.colour && /* @__PURE__ */ r("span", { className: "inline-block h-1.5 w-1.5 rounded-sm flex-shrink-0", style: { backgroundColor: f.colour } }),
335
- /* @__PURE__ */ r("span", { className: "truncate", children: f.label })
334
+ f.colour && /* @__PURE__ */ n("span", { className: "inline-block h-1.5 w-1.5 rounded-sm flex-shrink-0", style: { backgroundColor: f.colour } }),
335
+ /* @__PURE__ */ n("span", { className: "truncate", children: f.label })
336
336
  ] }),
337
- /* @__PURE__ */ r("span", { className: "tabular-nums", children: f.value })
337
+ /* @__PURE__ */ n("span", { className: "tabular-nums", children: f.value })
338
338
  ] }, u)) }),
339
- /* @__PURE__ */ r(
339
+ /* @__PURE__ */ n(
340
340
  "span",
341
341
  {
342
342
  "aria-hidden": !0,
@@ -348,15 +348,15 @@ function ue({ state: e, containerWidth: t }) {
348
348
  }
349
349
  );
350
350
  }
351
- const J = {
351
+ const ee = {
352
352
  "5m": { label: "5 min", windowSec: 300, sampleEveryMs: 1e3, pollIntervalMs: 5e3 },
353
353
  "1h": { label: "1 h", windowSec: 3600, sampleEveryMs: 5e3, pollIntervalMs: 3e4 },
354
354
  "24h": { label: "24 h", windowSec: 1440 * 60, sampleEveryMs: 6e4, pollIntervalMs: 3e5 }
355
- }, at = [
356
- { id: "5m", label: J["5m"].label },
357
- { id: "1h", label: J["1h"].label },
358
- { id: "24h", label: J["24h"].label }
359
- ], G = 140, S = { top: 16, right: 12, bottom: 24, left: 38 }, lt = {
355
+ }, ct = [
356
+ { id: "5m", label: ee["5m"].label },
357
+ { id: "1h", label: ee["1h"].label },
358
+ { id: "24h", label: ee["24h"].label }
359
+ ], U = 140, S = { top: 16, right: 12, bottom: 24, left: 38 }, dt = {
360
360
  speech: "#3b82f6",
361
361
  music: "#a855f7",
362
362
  dog_bark: "#ec4899",
@@ -364,17 +364,17 @@ const J = {
364
364
  alarm: "#f59e0b",
365
365
  baby_cry: "#10b981"
366
366
  };
367
- function $e(e) {
368
- return e ? lt[e.toLowerCase()] ?? "#6366f1" : "#71717a";
367
+ function Ce(e) {
368
+ return e ? dt[e.toLowerCase()] ?? "#6366f1" : "#71717a";
369
369
  }
370
- function it({ deviceId: e }) {
371
- const t = z(), o = Q(t.trpcClient, e), [n, a] = H("5m"), s = J[n], [d, l] = ce(), f = de(), u = K(null), k = (m) => {
370
+ function ut({ deviceId: e }) {
371
+ const t = Y(), o = J(t.trpcClient, e), [r, a] = H("5m"), s = ee[r], [d, l] = de(), f = ue(), u = Q(null), N = (m) => {
372
372
  const h = u.current;
373
373
  if (!h) return m;
374
374
  const g = h.getBoundingClientRect();
375
375
  return g.width === 0 ? m : m / l * g.width;
376
376
  }, $ = le({
377
- queryKey: ["audio-metrics", e, "history", n],
377
+ queryKey: ["audio-metrics", e, "history", r],
378
378
  queryFn: async () => o ? await o.audioMetrics?.getHistory({
379
379
  windowSec: s.windowSec,
380
380
  sampleEveryMs: s.sampleEveryMs
@@ -382,17 +382,17 @@ function it({ deviceId: e }) {
382
382
  enabled: !!o,
383
383
  refetchInterval: s.pollIntervalMs,
384
384
  staleTime: Math.max(1e3, s.pollIntervalMs / 2)
385
- }), F = $.data, b = F?.points ?? [], x = N(() => ut(b), [b]), C = N(() => ct(b, l, x), [b, l, x]), y = N(() => dt(b, l, x), [b, l, x]), L = N(() => ht(x), [x]), D = N(() => mt(b, l), [b, l]);
385
+ }), F = $.data, b = F?.points ?? [], x = k(() => ft(b), [b]), C = k(() => ht(b, l, x), [b, l, x]), y = k(() => mt(b, l, x), [b, l, x]), L = k(() => pt(x), [x]), D = k(() => bt(b, l), [b, l]);
386
386
  return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface overflow-hidden", children: [
387
387
  /* @__PURE__ */ i("div", { className: "border-b border-border px-4 py-2 flex items-center justify-between gap-3", children: [
388
388
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
389
- /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
390
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Audio Level History" })
389
+ /* @__PURE__ */ n(K, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
390
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Audio Level History" })
391
391
  ] }),
392
- /* @__PURE__ */ r(ie, { presets: at, value: n, onChange: a })
392
+ /* @__PURE__ */ n(ce, { presets: ct, value: r, onChange: a })
393
393
  ] }),
394
394
  /* @__PURE__ */ i("div", { ref: d, className: "p-3 min-w-0 relative", children: [
395
- b.length === 0 ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: $.isLoading ? "Loading…" : "No audio history yet — analytics pipeline must be active." }) : l === 0 ? /* @__PURE__ */ r("div", { className: "h-32" }) : /* @__PURE__ */ i(ae, { children: [
395
+ b.length === 0 ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: $.isLoading ? "Loading…" : "No audio history yet — analytics pipeline must be active." }) : l === 0 ? /* @__PURE__ */ n("div", { className: "h-32" }) : /* @__PURE__ */ i(ie, { children: [
396
396
  /* @__PURE__ */ i(
397
397
  "svg",
398
398
  {
@@ -400,29 +400,29 @@ function it({ deviceId: e }) {
400
400
  role: "img",
401
401
  "aria-label": "Audio dBFS history",
402
402
  width: "100%",
403
- height: G,
404
- viewBox: `0 0 ${l} ${G}`,
403
+ height: U,
404
+ viewBox: `0 0 ${l} ${U}`,
405
405
  preserveAspectRatio: "none",
406
406
  className: "block",
407
407
  onMouseLeave: () => f.bindHover(null),
408
408
  children: [
409
409
  L.map(({ y: m, label: h }, g) => /* @__PURE__ */ i("g", { children: [
410
- /* @__PURE__ */ r("line", { x1: S.left, x2: l - S.right, y1: m, y2: m, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
411
- /* @__PURE__ */ r("text", { x: S.left - 6, y: m + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: h })
410
+ /* @__PURE__ */ n("line", { x1: S.left, x2: l - S.right, y1: m, y2: m, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
411
+ /* @__PURE__ */ n("text", { x: S.left - 6, y: m + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: h })
412
412
  ] }, `y-${g}`)),
413
- D.map(({ x: m, label: h }, g) => /* @__PURE__ */ r("text", { x: m, y: G - S.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: h }, `x-${g}`)),
414
- y && /* @__PURE__ */ r("path", { d: y, fill: "none", stroke: "currentColor", strokeOpacity: 0.25, strokeWidth: 1, strokeDasharray: "3 2" }),
415
- C && /* @__PURE__ */ r("path", { d: C, fill: "none", stroke: "currentColor", className: "text-primary", strokeWidth: 1.5 }),
413
+ D.map(({ x: m, label: h }, g) => /* @__PURE__ */ n("text", { x: m, y: U - S.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: h }, `x-${g}`)),
414
+ y && /* @__PURE__ */ n("path", { d: y, fill: "none", stroke: "currentColor", strokeOpacity: 0.25, strokeWidth: 1, strokeDasharray: "3 2" }),
415
+ C && /* @__PURE__ */ n("path", { d: C, fill: "none", stroke: "currentColor", className: "text-primary", strokeWidth: 1.5 }),
416
416
  b.map((m, h) => {
417
417
  if (m.topClass === null) return null;
418
- const g = oe(h, b.length, l), _ = be(m.dbfs, x);
419
- return /* @__PURE__ */ r(
418
+ const g = se(h, b.length, l), _ = xe(m.dbfs, x);
419
+ return /* @__PURE__ */ n(
420
420
  "circle",
421
421
  {
422
422
  cx: g,
423
423
  cy: _,
424
424
  r: 3,
425
- fill: $e(m.topClass),
425
+ fill: Ce(m.topClass),
426
426
  stroke: "#000",
427
427
  strokeOpacity: 0.3,
428
428
  strokeWidth: 0.5
@@ -431,8 +431,8 @@ function it({ deviceId: e }) {
431
431
  );
432
432
  }),
433
433
  b.map((m, h) => {
434
- const g = oe(h, b.length, l), _ = be(m.dbfs, x), p = G - S.top - S.bottom, v = b.length > 1 ? (l - S.left - S.right) / (b.length - 1) : 24;
435
- return /* @__PURE__ */ r(
434
+ const g = se(h, b.length, l), _ = xe(m.dbfs, x), p = U - S.top - S.bottom, v = b.length > 1 ? (l - S.left - S.right) / (b.length - 1) : 24;
435
+ return /* @__PURE__ */ n(
436
436
  "rect",
437
437
  {
438
438
  x: g - v / 2,
@@ -442,16 +442,16 @@ function it({ deviceId: e }) {
442
442
  fill: "transparent",
443
443
  onMouseEnter: () => {
444
444
  f.bindHover({
445
- anchorX: k(g),
445
+ anchorX: N(g),
446
446
  anchorY: _,
447
- title: `${Te(m.ts)} · ${m.dbfs?.toFixed(1) ?? "—"} dB`,
447
+ title: `${Le(m.ts)} · ${m.dbfs?.toFixed(1) ?? "—"} dB`,
448
448
  rows: [
449
449
  { label: "peak (window)", value: `${m.peakDbfs.toFixed(1)} dB` },
450
450
  { label: "avg (window)", value: `${m.avgDbfs.toFixed(1)} dB` },
451
451
  ...m.topClass !== null ? [{
452
452
  label: m.topClass,
453
453
  value: m.topScore != null ? `${(m.topScore * 100).toFixed(0)}%` : "—",
454
- colour: $e(m.topClass)
454
+ colour: Ce(m.topClass)
455
455
  }] : []
456
456
  ]
457
457
  });
@@ -463,7 +463,7 @@ function it({ deviceId: e }) {
463
463
  ]
464
464
  }
465
465
  ),
466
- /* @__PURE__ */ r(ue, { state: f.state, containerWidth: l })
466
+ /* @__PURE__ */ n(he, { state: f.state, containerWidth: l })
467
467
  ] }),
468
468
  b.length > 0 && /* @__PURE__ */ i("div", { className: "flex items-center justify-between text-[10px] text-foreground-subtle mt-1", children: [
469
469
  /* @__PURE__ */ i("span", { children: [
@@ -481,125 +481,125 @@ function it({ deviceId: e }) {
481
481
  ] })
482
482
  ] });
483
483
  }
484
- function oe(e, t, o) {
484
+ function se(e, t, o) {
485
485
  if (t <= 1) return S.left;
486
- const n = o - S.left - S.right;
487
- return S.left + e / (t - 1) * n;
486
+ const r = o - S.left - S.right;
487
+ return S.left + e / (t - 1) * r;
488
488
  }
489
- function be(e, t) {
490
- return e === null || !Number.isFinite(e) ? se(t.min, t) : se(Math.max(t.min, Math.min(t.max, e)), t);
489
+ function xe(e, t) {
490
+ return e === null || !Number.isFinite(e) ? ae(t.min, t) : ae(Math.max(t.min, Math.min(t.max, e)), t);
491
491
  }
492
- function se(e, t) {
493
- const o = G - S.top - S.bottom, n = Math.max(1, t.max - t.min), a = (e - t.min) / n;
492
+ function ae(e, t) {
493
+ const o = U - S.top - S.bottom, r = Math.max(1, t.max - t.min), a = (e - t.min) / r;
494
494
  return S.top + (1 - a) * o;
495
495
  }
496
- function ct(e, t, o) {
496
+ function ht(e, t, o) {
497
497
  if (e.length === 0) return null;
498
- const n = [];
498
+ const r = [];
499
499
  for (let a = 0; a < e.length; a++) {
500
- const s = oe(a, e.length, t), d = be(e[a].dbfs, o);
501
- n.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
500
+ const s = se(a, e.length, t), d = xe(e[a].dbfs, o);
501
+ r.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
502
502
  }
503
- return n.join(" ");
503
+ return r.join(" ");
504
504
  }
505
- function dt(e, t, o) {
505
+ function mt(e, t, o) {
506
506
  if (e.length === 0) return null;
507
- const n = [];
507
+ const r = [];
508
508
  for (let a = 0; a < e.length; a++) {
509
- const s = oe(a, e.length, t), d = se(Math.max(o.min, Math.min(o.max, e[a].peakDbfs)), o);
510
- n.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
509
+ const s = se(a, e.length, t), d = ae(Math.max(o.min, Math.min(o.max, e[a].peakDbfs)), o);
510
+ r.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
511
511
  }
512
- return n.join(" ");
512
+ return r.join(" ");
513
513
  }
514
- function ut(e) {
514
+ function ft(e) {
515
515
  if (e.length === 0) return { min: -80, max: -40 };
516
516
  let t = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
517
517
  for (const s of e)
518
518
  s.dbfs !== null && Number.isFinite(s.dbfs) && (t = Math.min(t, s.dbfs), o = Math.max(o, s.dbfs)), Number.isFinite(s.peakDbfs) && (t = Math.min(t, s.peakDbfs), o = Math.max(o, s.peakDbfs));
519
519
  if (!Number.isFinite(t) || !Number.isFinite(o)) return { min: -80, max: -40 };
520
- let n = Math.max(-100, Math.floor(t - 1)), a = Math.min(0, Math.ceil(o));
521
- return a - n < 5 && (n = Math.max(-100, a - 5)), { min: n, max: a };
520
+ let r = Math.max(-100, Math.floor(t - 1)), a = Math.min(0, Math.ceil(o));
521
+ return a - r < 5 && (r = Math.max(-100, a - 5)), { min: r, max: a };
522
522
  }
523
- function ht(e) {
523
+ function pt(e) {
524
524
  const t = [];
525
525
  for (let o = 0; o < 4; o++) {
526
- const n = o / 3, a = e.min + (e.max - e.min) * n;
526
+ const r = o / 3, a = e.min + (e.max - e.min) * r;
527
527
  t.push({
528
- y: se(a, e),
528
+ y: ae(a, e),
529
529
  label: `${Math.round(a)}`
530
530
  });
531
531
  }
532
532
  return t;
533
533
  }
534
- function mt(e, t) {
534
+ function bt(e, t) {
535
535
  if (e.length === 0) return [];
536
- const o = e[0], n = e[e.length - 1], a = [], s = Math.min(5, e.length);
536
+ const o = e[0], r = e[e.length - 1], a = [], s = Math.min(5, e.length);
537
537
  for (let d = 0; d < s; d++) {
538
- const l = d / Math.max(1, s - 1), f = o.ts + (n.ts - o.ts) * l;
538
+ const l = d / Math.max(1, s - 1), f = o.ts + (r.ts - o.ts) * l;
539
539
  a.push({
540
540
  x: S.left + l * (t - S.left - S.right),
541
- label: Te(f)
541
+ label: Le(f)
542
542
  });
543
543
  }
544
544
  return a;
545
545
  }
546
- function Te(e) {
547
- const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), n = String(t.getMinutes()).padStart(2, "0");
548
- return `${o}:${n}`;
546
+ function Le(e) {
547
+ const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0");
548
+ return `${o}:${r}`;
549
549
  }
550
- function xe(e) {
550
+ function ge(e) {
551
551
  return !Number.isFinite(e) || e <= 0 ? 60 : e > 600 ? Math.round(e / 1e3) : Math.round(e);
552
552
  }
553
- function ft({
553
+ function xt({
554
554
  dev: e,
555
555
  deviceId: t,
556
556
  title: o = "Audio Metrics",
557
- variant: n = "full"
557
+ variant: r = "full"
558
558
  }) {
559
- const a = z(), s = Be(
559
+ const a = Y(), s = Pe(
560
560
  a.trpcClient,
561
561
  e === void 0 && t !== void 0 ? t : null,
562
562
  (f) => f.audioMetrics
563
- ), d = ye(
563
+ ), d = ve(
564
564
  e ? e.state.audioMetrics : void 0
565
565
  ), l = e !== void 0 ? d : s;
566
- return l ? /* @__PURE__ */ r(Ce, { title: o, variant: n, ts: l.ts, children: /* @__PURE__ */ i("div", { className: n === "compact" ? "space-y-2" : "grid grid-cols-1 2xl:grid-cols-3 gap-3", children: [
567
- /* @__PURE__ */ r(bt, { snapshot: l }),
568
- /* @__PURE__ */ r(xt, { snapshot: l }),
569
- /* @__PURE__ */ r(gt, { snapshot: l })
570
- ] }) }) : /* @__PURE__ */ r(Ce, { title: o, variant: n, children: /* @__PURE__ */ r(
571
- pt,
566
+ return l ? /* @__PURE__ */ n(_e, { title: o, variant: r, ts: l.ts, children: /* @__PURE__ */ i("div", { className: r === "compact" ? "space-y-2" : "grid grid-cols-1 2xl:grid-cols-3 gap-3", children: [
567
+ /* @__PURE__ */ n(yt, { snapshot: l }),
568
+ /* @__PURE__ */ n(vt, { snapshot: l }),
569
+ /* @__PURE__ */ n(wt, { snapshot: l })
570
+ ] }) }) : /* @__PURE__ */ n(_e, { title: o, variant: r, children: /* @__PURE__ */ n(
571
+ gt,
572
572
  {
573
- icon: /* @__PURE__ */ r(nt, { className: "h-5 w-5 mb-2 opacity-30" }),
573
+ icon: /* @__PURE__ */ n(st, { className: "h-5 w-5 mb-2 opacity-30" }),
574
574
  message: e || t !== void 0 ? "No audio data yet — analytics pipeline must be active and audio enabled for this device." : "Resolving device…"
575
575
  }
576
576
  ) });
577
577
  }
578
- function Ce({ title: e, variant: t, ts: o, children: n }) {
578
+ function _e({ title: e, variant: t, ts: o, children: r }) {
579
579
  const a = o ? Math.max(0, Math.floor((Date.now() - o) / 1e3)) : null;
580
580
  return /* @__PURE__ */ i("div", { className: t === "compact" ? "rounded-md border border-border/60 bg-surface/60 p-3" : "rounded-lg border border-border bg-surface overflow-hidden", children: [
581
581
  /* @__PURE__ */ i("div", { className: t === "compact" ? "flex items-center justify-between mb-2" : "border-b border-border px-4 py-2 flex items-center justify-between", children: [
582
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: e }),
583
- a !== null && /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle", children: a === 0 ? "just now" : `${a}s ago` })
582
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: e }),
583
+ a !== null && /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle", children: a === 0 ? "just now" : `${a}s ago` })
584
584
  ] }),
585
- /* @__PURE__ */ r("div", { className: t === "compact" ? "" : "p-3", children: n })
585
+ /* @__PURE__ */ n("div", { className: t === "compact" ? "" : "p-3", children: r })
586
586
  ] });
587
587
  }
588
- function pt({ icon: e, message: t }) {
588
+ function gt({ icon: e, message: t }) {
589
589
  return /* @__PURE__ */ i("div", { className: "px-4 py-6 flex flex-col items-center text-center text-foreground-subtle", children: [
590
590
  e,
591
- /* @__PURE__ */ r("p", { className: "text-[11px]", children: t })
591
+ /* @__PURE__ */ n("p", { className: "text-[11px]", children: t })
592
592
  ] });
593
593
  }
594
- function bt({ snapshot: e }) {
595
- const { dbfs: t } = e.level, o = Number.isFinite(t) ? t : -80, n = Math.max(-80, Math.min(0, o)), a = (n + 80) / 80 * 100, s = n > -10 ? "bg-danger" : n > -25 ? "bg-warning" : "bg-primary";
594
+ function yt({ snapshot: e }) {
595
+ const { dbfs: t } = e.level, o = Number.isFinite(t) ? t : -80, r = Math.max(-80, Math.min(0, o)), a = (r + 80) / 80 * 100, s = r > -10 ? "bg-danger" : r > -25 ? "bg-warning" : "bg-primary";
596
596
  return /* @__PURE__ */ i("div", { className: "rounded-md border border-border/60 bg-background/40 px-3 py-2", children: [
597
597
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
598
- /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5" }),
599
- /* @__PURE__ */ r("span", { children: "Level" }),
600
- /* @__PURE__ */ r("span", { className: "ml-auto text-base font-semibold text-foreground tabular-nums normal-case tracking-normal", children: Number.isFinite(t) ? `${t.toFixed(1)} dB` : "silent" })
598
+ /* @__PURE__ */ n(K, { className: "h-3.5 w-3.5" }),
599
+ /* @__PURE__ */ n("span", { children: "Level" }),
600
+ /* @__PURE__ */ n("span", { className: "ml-auto text-base font-semibold text-foreground tabular-nums normal-case tracking-normal", children: Number.isFinite(t) ? `${t.toFixed(1)} dB` : "silent" })
601
601
  ] }),
602
- /* @__PURE__ */ r("div", { className: "h-1.5 rounded-full bg-foreground-subtle/15 overflow-hidden", children: /* @__PURE__ */ r(
602
+ /* @__PURE__ */ n("div", { className: "h-1.5 rounded-full bg-foreground-subtle/15 overflow-hidden", children: /* @__PURE__ */ n(
603
603
  "div",
604
604
  {
605
605
  className: `h-full ${s} transition-all`,
@@ -618,21 +618,21 @@ function bt({ snapshot: e }) {
618
618
  " dB"
619
619
  ] }),
620
620
  /* @__PURE__ */ i("span", { children: [
621
- xe(e.windowSec),
621
+ ge(e.windowSec),
622
622
  "s window"
623
623
  ] })
624
624
  ] })
625
625
  ] });
626
626
  }
627
- function xt({ snapshot: e }) {
627
+ function vt({ snapshot: e }) {
628
628
  const { current: t } = e;
629
629
  return /* @__PURE__ */ i("div", { className: "rounded-md border border-border/60 bg-background/40 px-3 py-2", children: [
630
630
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
631
- /* @__PURE__ */ r(ot, { className: "h-3.5 w-3.5" }),
632
- /* @__PURE__ */ r("span", { children: "Now" })
631
+ /* @__PURE__ */ n(it, { className: "h-3.5 w-3.5" }),
632
+ /* @__PURE__ */ n("span", { children: "Now" })
633
633
  ] }),
634
634
  t ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-1", children: [
635
- /* @__PURE__ */ r("span", { className: "text-sm font-semibold text-foreground", children: t.className }),
635
+ /* @__PURE__ */ n("span", { className: "text-sm font-semibold text-foreground", children: t.className }),
636
636
  /* @__PURE__ */ i("span", { className: "text-[10px] text-foreground-subtle tabular-nums", children: [
637
637
  "score ",
638
638
  (t.score * 100).toFixed(0),
@@ -640,32 +640,32 @@ function xt({ snapshot: e }) {
640
640
  Math.max(0, Math.floor((Date.now() - t.timestamp) / 1e3)),
641
641
  "s ago"
642
642
  ] })
643
- ] }) : /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle italic", children: "silence / unclassified" })
643
+ ] }) : /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle italic", children: "silence / unclassified" })
644
644
  ] });
645
645
  }
646
- function gt({ snapshot: e }) {
646
+ function wt({ snapshot: e }) {
647
647
  return e.byClass.length === 0 ? /* @__PURE__ */ i("div", { className: "rounded-md border border-border/40 bg-background/20 px-3 py-2", children: [
648
648
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
649
- /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5" }),
649
+ /* @__PURE__ */ n(K, { className: "h-3.5 w-3.5" }),
650
650
  /* @__PURE__ */ i("span", { children: [
651
651
  "Last ",
652
- xe(e.windowSec),
652
+ ge(e.windowSec),
653
653
  "s"
654
654
  ] })
655
655
  ] }),
656
- /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle italic", children: "no classified audio" })
656
+ /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle italic", children: "no classified audio" })
657
657
  ] }) : /* @__PURE__ */ i("div", { className: "rounded-md border border-border/60 bg-background/40", children: [
658
658
  /* @__PURE__ */ i("div", { className: "px-3 py-1.5 border-b border-border/40 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
659
- /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5" }),
659
+ /* @__PURE__ */ n(K, { className: "h-3.5 w-3.5" }),
660
660
  /* @__PURE__ */ i("span", { children: [
661
661
  "Last ",
662
- xe(e.windowSec),
662
+ ge(e.windowSec),
663
663
  "s"
664
664
  ] }),
665
- /* @__PURE__ */ r("span", { className: "ml-auto text-[10px] normal-case tracking-normal", children: e.byClass.length })
665
+ /* @__PURE__ */ n("span", { className: "ml-auto text-[10px] normal-case tracking-normal", children: e.byClass.length })
666
666
  ] }),
667
- /* @__PURE__ */ r("div", { className: "divide-y divide-border/30", children: e.byClass.slice(0, 8).map((t) => /* @__PURE__ */ i("div", { className: "px-3 py-1.5 flex items-center justify-between text-xs", children: [
668
- /* @__PURE__ */ r("span", { className: "font-medium text-foreground truncate", children: t.className }),
667
+ /* @__PURE__ */ n("div", { className: "divide-y divide-border/30", children: e.byClass.slice(0, 8).map((t) => /* @__PURE__ */ i("div", { className: "px-3 py-1.5 flex items-center justify-between text-xs", children: [
668
+ /* @__PURE__ */ n("span", { className: "font-medium text-foreground truncate", children: t.className }),
669
669
  /* @__PURE__ */ i("span", { className: "flex items-center gap-2 tabular-nums text-foreground-subtle", children: [
670
670
  /* @__PURE__ */ i("span", { children: [
671
671
  t.hits,
@@ -679,22 +679,22 @@ function gt({ snapshot: e }) {
679
679
  ] }, t.className)) })
680
680
  ] });
681
681
  }
682
- const ee = {
682
+ const te = {
683
683
  "5m": { label: "5 min", windowMs: 5 * 6e4, resolution: "minute", pollIntervalMs: 5e3 },
684
684
  "30m": { label: "30 min", windowMs: 30 * 6e4, resolution: "minute", pollIntervalMs: 15e3 },
685
685
  "1h": { label: "1 h", windowMs: 60 * 6e4, resolution: "5min", pollIntervalMs: 3e4 }
686
- }, yt = [
687
- { id: "5m", label: ee["5m"].label },
688
- { id: "30m", label: ee["30m"].label },
689
- { id: "1h", label: ee["1h"].label }
690
- ], P = 140, M = { top: 14, right: 12, bottom: 24, left: 32 }, R = "__all__";
691
- function vt({ deviceId: e }) {
692
- const t = z(), o = Q(t.trpcClient, e), [n, a] = H("5m"), [s, d] = H(R), l = ee[n], [f, u] = ce(), k = de(), $ = K(null), F = (p) => {
686
+ }, Nt = [
687
+ { id: "5m", label: te["5m"].label },
688
+ { id: "30m", label: te["30m"].label },
689
+ { id: "1h", label: te["1h"].label }
690
+ ], X = 140, M = { top: 14, right: 12, bottom: 24, left: 32 }, P = "__all__";
691
+ function kt({ deviceId: e }) {
692
+ const t = Y(), o = J(t.trpcClient, e), [r, a] = H("5m"), [s, d] = H(P), l = te[r], [f, u] = de(), N = ue(), $ = Q(null), F = (p) => {
693
693
  const v = $.current;
694
694
  if (!v) return p;
695
695
  const c = v.getBoundingClientRect();
696
696
  return c.width === 0 ? p : p / u * c.width;
697
- }, b = ye(o?.state.zoneAnalytics), x = N(() => {
697
+ }, b = ve(o?.state.zoneAnalytics), x = k(() => {
698
698
  const p = /* @__PURE__ */ new Set();
699
699
  if (b?.frame.byClass)
700
700
  for (const v of Object.keys(b.frame.byClass)) p.add(v);
@@ -703,11 +703,11 @@ function vt({ deviceId: e }) {
703
703
  for (const c of Object.keys(v.byClass)) p.add(c);
704
704
  return [...p].sort();
705
705
  }, [b]);
706
- ge(() => {
707
- s !== R && !x.includes(s) && d(R);
706
+ ye(() => {
707
+ s !== P && !x.includes(s) && d(P);
708
708
  }, [s, x]);
709
709
  const C = le({
710
- queryKey: ["zone-analytics", e, "cameraHistory", n, s],
710
+ queryKey: ["zone-analytics", e, "cameraHistory", r, s],
711
711
  queryFn: async () => {
712
712
  if (!o) return [];
713
713
  const p = Date.now();
@@ -715,28 +715,28 @@ function vt({ deviceId: e }) {
715
715
  from: p - l.windowMs,
716
716
  to: p,
717
717
  resolution: l.resolution,
718
- ...s === R ? {} : { className: s }
718
+ ...s === P ? {} : { className: s }
719
719
  }) ?? [];
720
720
  },
721
721
  enabled: !!o,
722
722
  refetchInterval: l.pollIntervalMs,
723
723
  staleTime: Math.max(1e3, l.pollIntervalMs / 2)
724
- }), y = C.data ?? [], L = C.dataUpdatedAt > 0 ? C.dataUpdatedAt : Date.now(), D = L - l.windowMs, m = N(() => {
724
+ }), y = C.data ?? [], L = C.dataUpdatedAt > 0 ? C.dataUpdatedAt : Date.now(), D = L - l.windowMs, m = k(() => {
725
725
  if (y.length === 0) return 1;
726
726
  const p = y.reduce((v, c) => Math.max(v, c.count), 0);
727
727
  return Math.max(1, Math.ceil(p * 1.15));
728
- }, [y]), h = N(
729
- () => wt(y, u, m),
728
+ }, [y]), h = k(
729
+ () => Mt(y, u, m),
730
730
  [y, u, m]
731
- ), g = N(
732
- () => ve(D, L, u, M.left, M.right, 5),
731
+ ), g = k(
732
+ () => we(D, L, u, M.left, M.right, 5),
733
733
  [D, L, u]
734
- ), _ = N(() => kt(m), [m]);
734
+ ), _ = k(() => $t(m), [m]);
735
735
  return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface overflow-hidden", children: [
736
736
  /* @__PURE__ */ i("div", { className: "border-b border-border px-4 py-2 flex items-center justify-between gap-3", children: [
737
737
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
738
- /* @__PURE__ */ r(re, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
739
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Occupancy History" })
738
+ /* @__PURE__ */ n(oe, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
739
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Occupancy History" })
740
740
  ] }),
741
741
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
742
742
  x.length > 0 && /* @__PURE__ */ i(
@@ -747,16 +747,16 @@ function vt({ deviceId: e }) {
747
747
  className: "text-[10px] px-1.5 py-0.5 rounded border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary/40",
748
748
  title: "Filter by detected class",
749
749
  children: [
750
- /* @__PURE__ */ r("option", { value: R, children: "All classes" }),
751
- x.map((p) => /* @__PURE__ */ r("option", { value: p, children: p }, p))
750
+ /* @__PURE__ */ n("option", { value: P, children: "All classes" }),
751
+ x.map((p) => /* @__PURE__ */ n("option", { value: p, children: p }, p))
752
752
  ]
753
753
  }
754
754
  ),
755
- /* @__PURE__ */ r(ie, { presets: yt, value: n, onChange: a })
755
+ /* @__PURE__ */ n(ce, { presets: Nt, value: r, onChange: a })
756
756
  ] })
757
757
  ] }),
758
758
  /* @__PURE__ */ i("div", { ref: f, className: "p-3 min-w-0 relative", children: [
759
- y.length === 0 ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: C.isLoading ? "Loading…" : "No occupancy history yet — analytics pipeline must be active." }) : u === 0 ? /* @__PURE__ */ r("div", { className: "h-32" }) : /* @__PURE__ */ i(ae, { children: [
759
+ y.length === 0 ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: C.isLoading ? "Loading…" : "No occupancy history yet — analytics pipeline must be active." }) : u === 0 ? /* @__PURE__ */ n("div", { className: "h-32" }) : /* @__PURE__ */ i(ie, { children: [
760
760
  /* @__PURE__ */ i(
761
761
  "svg",
762
762
  {
@@ -764,37 +764,37 @@ function vt({ deviceId: e }) {
764
764
  role: "img",
765
765
  "aria-label": "Frame occupancy history",
766
766
  width: "100%",
767
- height: P,
768
- viewBox: `0 0 ${u} ${P}`,
767
+ height: X,
768
+ viewBox: `0 0 ${u} ${X}`,
769
769
  preserveAspectRatio: "none",
770
770
  className: "block",
771
- onMouseLeave: () => k.bindHover(null),
771
+ onMouseLeave: () => N.bindHover(null),
772
772
  children: [
773
773
  _.map(({ y: p, label: v }, c) => /* @__PURE__ */ i("g", { children: [
774
- /* @__PURE__ */ r("line", { x1: M.left, x2: u - M.right, y1: p, y2: p, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
775
- /* @__PURE__ */ r("text", { x: M.left - 6, y: p + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: v })
774
+ /* @__PURE__ */ n("line", { x1: M.left, x2: u - M.right, y1: p, y2: p, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
775
+ /* @__PURE__ */ n("text", { x: M.left - 6, y: p + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: v })
776
776
  ] }, `y-${c}`)),
777
- g.map(({ x: p, label: v }, c) => /* @__PURE__ */ r("text", { x: p, y: P - M.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: v }, `x-${c}`)),
778
- h && /* @__PURE__ */ r("path", { d: h, fill: "none", stroke: "currentColor", className: "text-primary", strokeWidth: 1.5 }),
777
+ g.map(({ x: p, label: v }, c) => /* @__PURE__ */ n("text", { x: p, y: X - M.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: v }, `x-${c}`)),
778
+ h && /* @__PURE__ */ n("path", { d: h, fill: "none", stroke: "currentColor", className: "text-primary", strokeWidth: 1.5 }),
779
779
  y.map((p, v) => {
780
- const c = Fe(v, y.length, u, M.left, M.right), w = Le(p.count, m), I = P - M.top - M.bottom, O = y.length > 1 ? (u - M.left - M.right) / (y.length - 1) : 24;
780
+ const c = Te(v, y.length, u, M.left, M.right), w = De(p.count, m), I = X - M.top - M.bottom, R = y.length > 1 ? (u - M.left - M.right) / (y.length - 1) : 24;
781
781
  return /* @__PURE__ */ i("g", { children: [
782
- /* @__PURE__ */ r("circle", { cx: c, cy: w, r: 2, fill: "currentColor", className: "text-primary" }),
783
- /* @__PURE__ */ r(
782
+ /* @__PURE__ */ n("circle", { cx: c, cy: w, r: 2, fill: "currentColor", className: "text-primary" }),
783
+ /* @__PURE__ */ n(
784
784
  "rect",
785
785
  {
786
- x: c - O / 2,
786
+ x: c - R / 2,
787
787
  y: M.top,
788
- width: Math.max(2, O),
788
+ width: Math.max(2, R),
789
789
  height: I,
790
790
  fill: "transparent",
791
791
  onMouseEnter: () => {
792
- k.bindHover({
792
+ N.bindHover({
793
793
  anchorX: F(c),
794
794
  anchorY: w,
795
- title: `${Nt(p.ts)} · ${p.count} object${p.count === 1 ? "" : "s"}`,
795
+ title: `${Ct(p.ts)} · ${p.count} object${p.count === 1 ? "" : "s"}`,
796
796
  rows: [
797
- { label: "Class", value: s === R ? "all" : s },
797
+ { label: "Class", value: s === P ? "all" : s },
798
798
  { label: "Bucket", value: l.resolution }
799
799
  ]
800
800
  });
@@ -806,7 +806,7 @@ function vt({ deviceId: e }) {
806
806
  ]
807
807
  }
808
808
  ),
809
- /* @__PURE__ */ r(ue, { state: k.state, containerWidth: u })
809
+ /* @__PURE__ */ n(he, { state: N.state, containerWidth: u })
810
810
  ] }),
811
811
  y.length > 0 && /* @__PURE__ */ i("div", { className: "flex items-center justify-between text-[10px] text-foreground-subtle mt-1", children: [
812
812
  /* @__PURE__ */ i("span", { children: [
@@ -826,83 +826,83 @@ function vt({ deviceId: e }) {
826
826
  ] })
827
827
  ] });
828
828
  }
829
- function Le(e, t) {
830
- const o = P - M.top - M.bottom, n = Math.min(1, e / t);
831
- return M.top + (1 - n) * o;
829
+ function De(e, t) {
830
+ const o = X - M.top - M.bottom, r = Math.min(1, e / t);
831
+ return M.top + (1 - r) * o;
832
832
  }
833
- function wt(e, t, o) {
833
+ function Mt(e, t, o) {
834
834
  if (e.length === 0) return null;
835
- const n = [];
835
+ const r = [];
836
836
  for (let a = 0; a < e.length; a++) {
837
- const s = Fe(a, e.length, t, M.left, M.right), d = Le(e[a].count, o);
838
- n.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
837
+ const s = Te(a, e.length, t, M.left, M.right), d = De(e[a].count, o);
838
+ r.push(`${a === 0 ? "M" : "L"} ${s.toFixed(1)} ${d.toFixed(1)}`);
839
839
  }
840
- return n.join(" ");
840
+ return r.join(" ");
841
841
  }
842
- function kt(e) {
842
+ function $t(e) {
843
843
  const t = [];
844
844
  for (let o = 0; o < 4; o++) {
845
- const n = o / 3, a = Math.round(e * n), s = P - M.top - M.bottom;
845
+ const r = o / 3, a = Math.round(e * r), s = X - M.top - M.bottom;
846
846
  t.push({
847
- y: M.top + (1 - n) * s,
847
+ y: M.top + (1 - r) * s,
848
848
  label: `${a}`
849
849
  });
850
850
  }
851
851
  return t;
852
852
  }
853
- function Nt(e) {
854
- const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), n = String(t.getMinutes()).padStart(2, "0");
855
- return `${o}:${n}`;
853
+ function Ct(e) {
854
+ const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0");
855
+ return `${o}:${r}`;
856
856
  }
857
- const te = {
857
+ const ne = {
858
858
  "1h": { label: "1 h", windowMs: 60 * 6e4, bucketMs: 6e4, pollIntervalMs: 15e3 },
859
859
  "6h": { label: "6 h", windowMs: 360 * 6e4, bucketMs: 5 * 6e4, pollIntervalMs: 6e4 },
860
860
  "24h": { label: "24 h", windowMs: 1440 * 6e4, bucketMs: 15 * 6e4, pollIntervalMs: 3e5 }
861
- }, Mt = [
862
- { id: "1h", label: te["1h"].label },
863
- { id: "6h", label: te["6h"].label },
864
- { id: "24h", label: te["24h"].label }
865
- ], $t = 5e3, U = 140, T = { top: 14, right: 12, bottom: 24, left: 32 };
866
- function Ct({ deviceId: e }) {
867
- const t = z(), o = Q(t.trpcClient, e), [n, a] = H("1h"), s = te[n], [d, l] = ce(), f = de(), u = K(null), k = (h) => {
861
+ }, _t = [
862
+ { id: "1h", label: ne["1h"].label },
863
+ { id: "6h", label: ne["6h"].label },
864
+ { id: "24h", label: ne["24h"].label }
865
+ ], St = 5e3, V = 140, T = { top: 14, right: 12, bottom: 24, left: 32 };
866
+ function It({ deviceId: e }) {
867
+ const t = Y(), o = J(t.trpcClient, e), [r, a] = H("1h"), s = ne[r], [d, l] = de(), f = ue(), u = Q(null), N = (h) => {
868
868
  const g = u.current;
869
869
  if (!g) return h;
870
870
  const _ = g.getBoundingClientRect();
871
871
  return _.width === 0 ? h : h / l * _.width;
872
872
  }, $ = le({
873
- queryKey: ["pipeline-analytics", e, "motionEvents", n],
873
+ queryKey: ["pipeline-analytics", e, "motionEvents", r],
874
874
  queryFn: async () => {
875
875
  if (!o) return [];
876
876
  const h = Date.now() - s.windowMs;
877
877
  return await o.pipelineAnalytics?.getMotionEvents({
878
878
  since: h,
879
- limit: $t
879
+ limit: St
880
880
  }) ?? [];
881
881
  },
882
882
  enabled: !!o,
883
883
  refetchInterval: s.pollIntervalMs,
884
884
  staleTime: Math.max(1e3, s.pollIntervalMs / 2)
885
- }), F = $.data ?? [], b = $.dataUpdatedAt > 0 ? $.dataUpdatedAt : Date.now(), x = b - s.windowMs, C = N(
886
- () => _t(F, x, b, s.bucketMs),
885
+ }), F = $.data ?? [], b = $.dataUpdatedAt > 0 ? $.dataUpdatedAt : Date.now(), x = b - s.windowMs, C = k(
886
+ () => At(F, x, b, s.bucketMs),
887
887
  [F, x, b, s.bucketMs]
888
- ), y = N(() => {
888
+ ), y = k(() => {
889
889
  if (C.length === 0) return 1;
890
890
  const h = C.reduce((g, _) => Math.max(g, _.count), 0);
891
891
  return Math.max(1, Math.ceil(h * 1.15));
892
- }, [C]), L = N(
893
- () => ve(x, b, l, T.left, T.right, 5),
892
+ }, [C]), L = k(
893
+ () => we(x, b, l, T.left, T.right, 5),
894
894
  [x, b, l]
895
- ), D = N(() => It(y), [y]), m = F.length;
895
+ ), D = k(() => Tt(y), [y]), m = F.length;
896
896
  return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface overflow-hidden", children: [
897
897
  /* @__PURE__ */ i("div", { className: "border-b border-border px-4 py-2 flex items-center justify-between gap-3", children: [
898
898
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
899
- /* @__PURE__ */ r(Z, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
900
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Motion History" })
899
+ /* @__PURE__ */ n(K, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
900
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Motion History" })
901
901
  ] }),
902
- /* @__PURE__ */ r(ie, { presets: Mt, value: n, onChange: a })
902
+ /* @__PURE__ */ n(ce, { presets: _t, value: r, onChange: a })
903
903
  ] }),
904
904
  /* @__PURE__ */ i("div", { ref: d, className: "p-3 min-w-0 relative", children: [
905
- m === 0 ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: $.isLoading ? "Loading…" : "No motion events in the selected window." }) : l === 0 ? /* @__PURE__ */ r("div", { className: "h-32" }) : /* @__PURE__ */ i(ae, { children: [
905
+ m === 0 ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: $.isLoading ? "Loading…" : "No motion events in the selected window." }) : l === 0 ? /* @__PURE__ */ n("div", { className: "h-32" }) : /* @__PURE__ */ i(ie, { children: [
906
906
  /* @__PURE__ */ i(
907
907
  "svg",
908
908
  {
@@ -910,21 +910,21 @@ function Ct({ deviceId: e }) {
910
910
  role: "img",
911
911
  "aria-label": "Motion event histogram",
912
912
  width: "100%",
913
- height: U,
914
- viewBox: `0 0 ${l} ${U}`,
913
+ height: V,
914
+ viewBox: `0 0 ${l} ${V}`,
915
915
  preserveAspectRatio: "none",
916
916
  className: "block",
917
917
  onMouseLeave: () => f.bindHover(null),
918
918
  children: [
919
919
  D.map(({ y: h, label: g }, _) => /* @__PURE__ */ i("g", { children: [
920
- /* @__PURE__ */ r("line", { x1: T.left, x2: l - T.right, y1: h, y2: h, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
921
- /* @__PURE__ */ r("text", { x: T.left - 6, y: h + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: g })
920
+ /* @__PURE__ */ n("line", { x1: T.left, x2: l - T.right, y1: h, y2: h, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
921
+ /* @__PURE__ */ n("text", { x: T.left - 6, y: h + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: g })
922
922
  ] }, `y-${_}`)),
923
- L.map(({ x: h, label: g }, _) => /* @__PURE__ */ r("text", { x: h, y: U - T.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: g }, `x-${_}`)),
923
+ L.map(({ x: h, label: g }, _) => /* @__PURE__ */ n("text", { x: h, y: V - T.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: g }, `x-${_}`)),
924
924
  C.map((h, g) => {
925
- const { x: _, w: p } = St(h.bucketStart, s.bucketMs, x, b, l), v = U - T.top - T.bottom, c = h.count / y * v, w = T.top + (v - c), I = h.bucketStart + s.bucketMs;
925
+ const { x: _, w: p } = Ft(h.bucketStart, s.bucketMs, x, b, l), v = V - T.top - T.bottom, c = h.count / y * v, w = T.top + (v - c), I = h.bucketStart + s.bucketMs;
926
926
  return /* @__PURE__ */ i("g", { children: [
927
- h.count > 0 && /* @__PURE__ */ r(
927
+ h.count > 0 && /* @__PURE__ */ n(
928
928
  "rect",
929
929
  {
930
930
  x: _,
@@ -936,7 +936,7 @@ function Ct({ deviceId: e }) {
936
936
  opacity: 0.85
937
937
  }
938
938
  ),
939
- /* @__PURE__ */ r(
939
+ /* @__PURE__ */ n(
940
940
  "rect",
941
941
  {
942
942
  x: _,
@@ -946,11 +946,11 @@ function Ct({ deviceId: e }) {
946
946
  fill: "transparent",
947
947
  onMouseEnter: () => {
948
948
  f.bindHover({
949
- anchorX: k(_ + p / 2),
949
+ anchorX: N(_ + p / 2),
950
950
  anchorY: w,
951
- title: `${At(h.bucketStart, I)} · ${h.count} event${h.count === 1 ? "" : "s"}`,
951
+ title: `${Lt(h.bucketStart, I)} · ${h.count} event${h.count === 1 ? "" : "s"}`,
952
952
  rows: [
953
- { label: "Bucket", value: _e(s.bucketMs) },
953
+ { label: "Bucket", value: Se(s.bucketMs) },
954
954
  { label: "Count", value: `${h.count}` }
955
955
  ]
956
956
  });
@@ -962,7 +962,7 @@ function Ct({ deviceId: e }) {
962
962
  ]
963
963
  }
964
964
  ),
965
- /* @__PURE__ */ r(ue, { state: f.state, containerWidth: l })
965
+ /* @__PURE__ */ n(he, { state: f.state, containerWidth: l })
966
966
  ] }),
967
967
  m > 0 && /* @__PURE__ */ i("div", { className: "flex items-center justify-between text-[10px] text-foreground-subtle mt-1", children: [
968
968
  /* @__PURE__ */ i("span", { children: [
@@ -970,7 +970,7 @@ function Ct({ deviceId: e }) {
970
970
  " event",
971
971
  m === 1 ? "" : "s",
972
972
  " · ",
973
- _e(s.bucketMs),
973
+ Se(s.bucketMs),
974
974
  " buckets"
975
975
  ] }),
976
976
  /* @__PURE__ */ i("span", { children: [
@@ -982,90 +982,90 @@ function Ct({ deviceId: e }) {
982
982
  ] })
983
983
  ] });
984
984
  }
985
- function _t(e, t, o, n) {
985
+ function At(e, t, o, r) {
986
986
  if (o <= t) return [];
987
- const a = Math.floor(t / n) * n, s = Math.floor(o / n) * n, d = /* @__PURE__ */ new Map();
988
- for (let l = a; l <= s; l += n)
987
+ const a = Math.floor(t / r) * r, s = Math.floor(o / r) * r, d = /* @__PURE__ */ new Map();
988
+ for (let l = a; l <= s; l += r)
989
989
  d.set(l, 0);
990
990
  for (const l of e) {
991
991
  if (l.timestamp < t || l.timestamp > o) continue;
992
- const f = Math.floor(l.timestamp / n) * n;
992
+ const f = Math.floor(l.timestamp / r) * r;
993
993
  d.set(f, (d.get(f) ?? 0) + 1);
994
994
  }
995
995
  return [...d.entries()].sort(([l], [f]) => l - f).map(([l, f]) => ({ bucketStart: l, count: f }));
996
996
  }
997
- function St(e, t, o, n, a) {
998
- const s = Math.max(1, n - o), d = a - T.left - T.right, l = T.left + (e - o) / s * d, f = t / s * d;
997
+ function Ft(e, t, o, r, a) {
998
+ const s = Math.max(1, r - o), d = a - T.left - T.right, l = T.left + (e - o) / s * d, f = t / s * d;
999
999
  return { x: l, w: f };
1000
1000
  }
1001
- function It(e) {
1001
+ function Tt(e) {
1002
1002
  const t = [];
1003
1003
  for (let o = 0; o < 4; o++) {
1004
- const n = o / 3, a = Math.round(e * n), s = U - T.top - T.bottom;
1004
+ const r = o / 3, a = Math.round(e * r), s = V - T.top - T.bottom;
1005
1005
  t.push({
1006
- y: T.top + (1 - n) * s,
1006
+ y: T.top + (1 - r) * s,
1007
1007
  label: `${a}`
1008
1008
  });
1009
1009
  }
1010
1010
  return t;
1011
1011
  }
1012
- function At(e, t) {
1013
- const o = (n) => {
1014
- const a = new Date(n), s = String(a.getHours()).padStart(2, "0"), d = String(a.getMinutes()).padStart(2, "0");
1012
+ function Lt(e, t) {
1013
+ const o = (r) => {
1014
+ const a = new Date(r), s = String(a.getHours()).padStart(2, "0"), d = String(a.getMinutes()).padStart(2, "0");
1015
1015
  return `${s}:${d}`;
1016
1016
  };
1017
1017
  return `${o(e)}–${o(t)}`;
1018
1018
  }
1019
- function _e(e) {
1019
+ function Se(e) {
1020
1020
  return e >= 60 * 6e4 ? `${Math.round(e / 6e4 / 60)}h` : e >= 6e4 ? `${Math.round(e / 6e4)}m` : `${Math.round(e / 1e3)}s`;
1021
1021
  }
1022
- const ne = {
1022
+ const re = {
1023
1023
  "1h": { label: "1 h", windowMs: 60 * 6e4, bucketMs: 6e4, pollIntervalMs: 15e3 },
1024
1024
  "6h": { label: "6 h", windowMs: 360 * 6e4, bucketMs: 5 * 6e4, pollIntervalMs: 6e4 },
1025
1025
  "24h": { label: "24 h", windowMs: 1440 * 6e4, bucketMs: 15 * 6e4, pollIntervalMs: 3e5 }
1026
- }, Ft = [
1027
- { id: "1h", label: ne["1h"].label },
1028
- { id: "6h", label: ne["6h"].label },
1029
- { id: "24h", label: ne["24h"].label }
1030
- ], Tt = 5e3, Lt = 4, j = "__other__", B = "__all__", V = 160, A = { top: 14, right: 12, bottom: 24, left: 32 };
1031
- function Dt({ deviceId: e }) {
1032
- const t = z(), o = Q(t.trpcClient, e), [n, a] = H("1h"), [s, d] = H(B), l = ne[n], [f, u] = ce(), k = de(), $ = K(null), F = le({
1033
- queryKey: ["pipeline-analytics", e, "objectEvents", n],
1026
+ }, Dt = [
1027
+ { id: "1h", label: re["1h"].label },
1028
+ { id: "6h", label: re["6h"].label },
1029
+ { id: "24h", label: re["24h"].label }
1030
+ ], Et = 5e3, Ht = 4, W = "__other__", z = "__all__", Z = 160, A = { top: 14, right: 12, bottom: 24, left: 32 };
1031
+ function Wt({ deviceId: e }) {
1032
+ const t = Y(), o = J(t.trpcClient, e), [r, a] = H("1h"), [s, d] = H(z), l = re[r], [f, u] = de(), N = ue(), $ = Q(null), F = le({
1033
+ queryKey: ["pipeline-analytics", e, "objectEvents", r],
1034
1034
  queryFn: async () => {
1035
1035
  if (!o) return [];
1036
1036
  const c = Date.now() - l.windowMs;
1037
1037
  return await o.pipelineAnalytics?.getObjectEvents({
1038
1038
  since: c,
1039
- limit: Tt
1039
+ limit: Et
1040
1040
  }) ?? [];
1041
1041
  },
1042
1042
  enabled: !!o,
1043
1043
  refetchInterval: l.pollIntervalMs,
1044
1044
  staleTime: Math.max(1e3, l.pollIntervalMs / 2)
1045
- }), b = F.data ?? [], x = N(
1046
- () => s === B ? b : b.filter((c) => c.className === s),
1045
+ }), b = F.data ?? [], x = k(
1046
+ () => s === z ? b : b.filter((c) => c.className === s),
1047
1047
  [b, s]
1048
- ), C = F.dataUpdatedAt > 0 ? F.dataUpdatedAt : Date.now(), y = C - l.windowMs, L = N(() => {
1048
+ ), C = F.dataUpdatedAt > 0 ? F.dataUpdatedAt : Date.now(), y = C - l.windowMs, L = k(() => {
1049
1049
  const c = /* @__PURE__ */ new Set();
1050
1050
  for (const w of b) c.add(w.className);
1051
- return s !== B && c.add(s), [...c].sort();
1051
+ return s !== z && c.add(s), [...c].sort();
1052
1052
  }, [b, s]);
1053
- ge(() => {
1054
- s !== B && b.length > 0 && !L.includes(s) && d(B);
1053
+ ye(() => {
1054
+ s !== z && b.length > 0 && !L.includes(s) && d(z);
1055
1055
  }, [s, b, L]);
1056
- const D = N(() => Et(x, Lt), [x]), m = N(
1057
- () => Ht(x, y, C, l.bucketMs, D),
1056
+ const D = k(() => jt(x, Ht), [x]), m = k(
1057
+ () => Ot(x, y, C, l.bucketMs, D),
1058
1058
  [x, y, C, l.bucketMs, D]
1059
- ), h = N(() => {
1059
+ ), h = k(() => {
1060
1060
  if (m.length === 0) return 1;
1061
1061
  const c = m.reduce((w, I) => Math.max(w, I.total), 0);
1062
1062
  return Math.max(1, Math.ceil(c * 1.15));
1063
- }, [m]), g = N(
1064
- () => ve(y, C, u, A.left, A.right, 5),
1063
+ }, [m]), g = k(
1064
+ () => we(y, C, u, A.left, A.right, 5),
1065
1065
  [y, C, u]
1066
- ), _ = N(() => Wt(h), [h]), p = N(() => {
1066
+ ), _ = k(() => Bt(h), [h]), p = k(() => {
1067
1067
  const c = D.map((w) => w.className);
1068
- return x.some((w) => !D.some((I) => I.className === w.className)) && c.push(j), c;
1068
+ return x.some((w) => !D.some((I) => I.className === w.className)) && c.push(W), c;
1069
1069
  }, [x, D]), v = (c) => {
1070
1070
  const w = $.current;
1071
1071
  if (!w) return c;
@@ -1075,8 +1075,8 @@ function Dt({ deviceId: e }) {
1075
1075
  return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface overflow-hidden", children: [
1076
1076
  /* @__PURE__ */ i("div", { className: "border-b border-border px-4 py-2 flex items-center justify-between gap-3", children: [
1077
1077
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
1078
- /* @__PURE__ */ r(Ke, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
1079
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Detection History" })
1078
+ /* @__PURE__ */ n(et, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
1079
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: "Detection History" })
1080
1080
  ] }),
1081
1081
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1082
1082
  L.length > 0 && /* @__PURE__ */ i(
@@ -1087,16 +1087,16 @@ function Dt({ deviceId: e }) {
1087
1087
  className: "text-[10px] px-1.5 py-0.5 rounded border border-border bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary/40",
1088
1088
  title: "Filter by detected class",
1089
1089
  children: [
1090
- /* @__PURE__ */ r("option", { value: B, children: "All classes" }),
1091
- L.map((c) => /* @__PURE__ */ r("option", { value: c, children: c }, c))
1090
+ /* @__PURE__ */ n("option", { value: z, children: "All classes" }),
1091
+ L.map((c) => /* @__PURE__ */ n("option", { value: c, children: c }, c))
1092
1092
  ]
1093
1093
  }
1094
1094
  ),
1095
- /* @__PURE__ */ r(ie, { presets: Ft, value: n, onChange: a })
1095
+ /* @__PURE__ */ n(ce, { presets: Dt, value: r, onChange: a })
1096
1096
  ] })
1097
1097
  ] }),
1098
1098
  /* @__PURE__ */ i("div", { ref: f, className: "p-3 min-w-0 relative", children: [
1099
- x.length === 0 ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: F.isLoading ? "Loading…" : "No detection events in the selected window." }) : u === 0 ? /* @__PURE__ */ r("div", { className: "h-32" }) : /* @__PURE__ */ i(ae, { children: [
1099
+ x.length === 0 ? /* @__PURE__ */ n("div", { className: "flex items-center justify-center h-32 text-[11px] text-foreground-subtle italic", children: F.isLoading ? "Loading…" : "No detection events in the selected window." }) : u === 0 ? /* @__PURE__ */ n("div", { className: "h-32" }) : /* @__PURE__ */ i(ie, { children: [
1100
1100
  /* @__PURE__ */ i(
1101
1101
  "svg",
1102
1102
  {
@@ -1104,61 +1104,61 @@ function Dt({ deviceId: e }) {
1104
1104
  role: "img",
1105
1105
  "aria-label": "Detection event histogram",
1106
1106
  width: "100%",
1107
- height: V,
1108
- viewBox: `0 0 ${u} ${V}`,
1107
+ height: Z,
1108
+ viewBox: `0 0 ${u} ${Z}`,
1109
1109
  preserveAspectRatio: "none",
1110
1110
  className: "block",
1111
- onMouseLeave: () => k.bindHover(null),
1111
+ onMouseLeave: () => N.bindHover(null),
1112
1112
  children: [
1113
1113
  _.map(({ y: c, label: w }, I) => /* @__PURE__ */ i("g", { children: [
1114
- /* @__PURE__ */ r("line", { x1: A.left, x2: u - A.right, y1: c, y2: c, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
1115
- /* @__PURE__ */ r("text", { x: A.left - 6, y: c + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: w })
1114
+ /* @__PURE__ */ n("line", { x1: A.left, x2: u - A.right, y1: c, y2: c, stroke: "currentColor", strokeOpacity: 0.08, strokeWidth: 0.5 }),
1115
+ /* @__PURE__ */ n("text", { x: A.left - 6, y: c + 3, textAnchor: "end", className: "text-[9px] fill-foreground-subtle", children: w })
1116
1116
  ] }, `y-${I}`)),
1117
- g.map(({ x: c, label: w }, I) => /* @__PURE__ */ r("text", { x: c, y: V - A.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: w }, `x-${I}`)),
1117
+ g.map(({ x: c, label: w }, I) => /* @__PURE__ */ n("text", { x: c, y: Z - A.bottom + 12, textAnchor: "middle", className: "text-[9px] fill-foreground-subtle", children: w }, `x-${I}`)),
1118
1118
  m.map((c, w) => {
1119
1119
  if (c.total === 0) return null;
1120
- const { x: I, w: O } = jt(c.bucketStart, l.bucketMs, y, C, u), Y = V - A.top - A.bottom, Ee = c.total / h * Y, He = A.top + (Y - Ee);
1120
+ const { x: I, w: R } = Rt(c.bucketStart, l.bucketMs, y, C, u), q = Z - A.top - A.bottom, He = c.total / h * q, We = A.top + (q - He);
1121
1121
  let ke = 0;
1122
- const je = p.map((E, he) => {
1123
- const q = c.byClass[E] ?? 0;
1124
- if (q === 0) return null;
1125
- const me = q / h * Y, Oe = A.top + (Y - ke - me);
1126
- ke += me;
1127
- const Re = E === j ? "#94a3b8" : pe(he);
1128
- return /* @__PURE__ */ r(
1122
+ const je = p.map((E, me) => {
1123
+ const G = c.byClass[E] ?? 0;
1124
+ if (G === 0) return null;
1125
+ const fe = G / h * q, Re = A.top + (q - ke - fe);
1126
+ ke += fe;
1127
+ const Be = E === W ? "#94a3b8" : be(me);
1128
+ return /* @__PURE__ */ n(
1129
1129
  "rect",
1130
1130
  {
1131
1131
  x: I,
1132
- y: Oe,
1133
- width: Math.max(1, O - 1),
1134
- height: Math.max(1, me),
1135
- fill: Re,
1132
+ y: Re,
1133
+ width: Math.max(1, R - 1),
1134
+ height: Math.max(1, fe),
1135
+ fill: Be,
1136
1136
  opacity: 0.9
1137
1137
  },
1138
1138
  `${c.bucketStart}-${E}`
1139
1139
  );
1140
- }).filter((E) => E !== null), We = c.bucketStart + l.bucketMs;
1140
+ }).filter((E) => E !== null), Oe = c.bucketStart + l.bucketMs;
1141
1141
  return /* @__PURE__ */ i("g", { children: [
1142
1142
  je,
1143
- /* @__PURE__ */ r(
1143
+ /* @__PURE__ */ n(
1144
1144
  "rect",
1145
1145
  {
1146
1146
  x: I,
1147
1147
  y: A.top,
1148
- width: Math.max(2, O),
1149
- height: Y,
1148
+ width: Math.max(2, R),
1149
+ height: q,
1150
1150
  fill: "transparent",
1151
1151
  onMouseEnter: () => {
1152
- k.bindHover({
1153
- anchorX: v(I + O / 2),
1154
- anchorY: He,
1155
- title: `${Ot(c.bucketStart, We, l.bucketMs)} · ${c.total} detection${c.total === 1 ? "" : "s"}`,
1156
- rows: p.map((E, he) => {
1157
- const q = c.byClass[E] ?? 0;
1158
- return q === 0 ? null : {
1159
- label: E === j ? "other" : E,
1160
- value: `${q}`,
1161
- colour: E === j ? "#94a3b8" : pe(he)
1152
+ N.bindHover({
1153
+ anchorX: v(I + R / 2),
1154
+ anchorY: We,
1155
+ title: `${Pt(c.bucketStart, Oe, l.bucketMs)} · ${c.total} detection${c.total === 1 ? "" : "s"}`,
1156
+ rows: p.map((E, me) => {
1157
+ const G = c.byClass[E] ?? 0;
1158
+ return G === 0 ? null : {
1159
+ label: E === W ? "other" : E,
1160
+ value: `${G}`,
1161
+ colour: E === W ? "#94a3b8" : be(me)
1162
1162
  };
1163
1163
  }).filter((E) => E !== null)
1164
1164
  });
@@ -1170,8 +1170,8 @@ function Dt({ deviceId: e }) {
1170
1170
  ]
1171
1171
  }
1172
1172
  ),
1173
- /* @__PURE__ */ r(ue, { state: k.state, containerWidth: u }),
1174
- /* @__PURE__ */ r(Bt, { stackOrder: p })
1173
+ /* @__PURE__ */ n(he, { state: N.state, containerWidth: u }),
1174
+ /* @__PURE__ */ n(Xt, { stackOrder: p })
1175
1175
  ] }),
1176
1176
  x.length > 0 && /* @__PURE__ */ i("div", { className: "flex items-center justify-between text-[10px] text-foreground-subtle mt-1", children: [
1177
1177
  /* @__PURE__ */ i("span", { children: [
@@ -1179,7 +1179,7 @@ function Dt({ deviceId: e }) {
1179
1179
  " detection",
1180
1180
  x.length === 1 ? "" : "s",
1181
1181
  " · ",
1182
- Rt(l.bucketMs),
1182
+ zt(l.bucketMs),
1183
1183
  " buckets"
1184
1184
  ] }),
1185
1185
  /* @__PURE__ */ i("span", { children: [
@@ -1191,102 +1191,102 @@ function Dt({ deviceId: e }) {
1191
1191
  ] })
1192
1192
  ] });
1193
1193
  }
1194
- function Et(e, t) {
1194
+ function jt(e, t) {
1195
1195
  const o = /* @__PURE__ */ new Map();
1196
- for (const n of e)
1197
- o.set(n.className, (o.get(n.className) ?? 0) + 1);
1198
- return [...o.entries()].sort(([, n], [, a]) => a - n).slice(0, t).map(([n, a]) => ({ className: n, count: a }));
1196
+ for (const r of e)
1197
+ o.set(r.className, (o.get(r.className) ?? 0) + 1);
1198
+ return [...o.entries()].sort(([, r], [, a]) => a - r).slice(0, t).map(([r, a]) => ({ className: r, count: a }));
1199
1199
  }
1200
- function Ht(e, t, o, n, a) {
1200
+ function Ot(e, t, o, r, a) {
1201
1201
  if (o <= t) return [];
1202
- const s = new Set(a.map((u) => u.className)), d = Math.floor(t / n) * n, l = Math.floor(o / n) * n, f = /* @__PURE__ */ new Map();
1203
- for (let u = d; u <= l; u += n)
1202
+ const s = new Set(a.map((u) => u.className)), d = Math.floor(t / r) * r, l = Math.floor(o / r) * r, f = /* @__PURE__ */ new Map();
1203
+ for (let u = d; u <= l; u += r)
1204
1204
  f.set(u, { total: 0, byClass: {} });
1205
1205
  for (const u of e) {
1206
1206
  if (u.timestamp < t || u.timestamp > o) continue;
1207
- const k = Math.floor(u.timestamp / n) * n, $ = f.get(k);
1207
+ const N = Math.floor(u.timestamp / r) * r, $ = f.get(N);
1208
1208
  if (!$) continue;
1209
1209
  $.total += 1;
1210
- const F = s.has(u.className) ? u.className : j;
1210
+ const F = s.has(u.className) ? u.className : W;
1211
1211
  $.byClass[F] = ($.byClass[F] ?? 0) + 1;
1212
1212
  }
1213
- return [...f.entries()].sort(([u], [k]) => u - k).map(([u, k]) => ({
1213
+ return [...f.entries()].sort(([u], [N]) => u - N).map(([u, N]) => ({
1214
1214
  bucketStart: u,
1215
- total: k.total,
1216
- byClass: k.byClass
1215
+ total: N.total,
1216
+ byClass: N.byClass
1217
1217
  }));
1218
1218
  }
1219
- function jt(e, t, o, n, a) {
1220
- const s = Math.max(1, n - o), d = a - A.left - A.right, l = A.left + (e - o) / s * d, f = t / s * d;
1219
+ function Rt(e, t, o, r, a) {
1220
+ const s = Math.max(1, r - o), d = a - A.left - A.right, l = A.left + (e - o) / s * d, f = t / s * d;
1221
1221
  return { x: l, w: f };
1222
1222
  }
1223
- function Wt(e) {
1223
+ function Bt(e) {
1224
1224
  const t = [];
1225
1225
  for (let o = 0; o < 4; o++) {
1226
- const n = o / 3, a = Math.round(e * n), s = V - A.top - A.bottom;
1226
+ const r = o / 3, a = Math.round(e * r), s = Z - A.top - A.bottom;
1227
1227
  t.push({
1228
- y: A.top + (1 - n) * s,
1228
+ y: A.top + (1 - r) * s,
1229
1229
  label: `${a}`
1230
1230
  });
1231
1231
  }
1232
1232
  return t;
1233
1233
  }
1234
- function Ot(e, t, o) {
1235
- const n = (a) => {
1234
+ function Pt(e, t, o) {
1235
+ const r = (a) => {
1236
1236
  const s = String(a.getHours()).padStart(2, "0"), d = String(a.getMinutes()).padStart(2, "0");
1237
1237
  return `${s}:${d}`;
1238
1238
  };
1239
- return o >= 60 * 6e4 ? `${n(new Date(e))}–${n(new Date(t))}` : `${n(new Date(e))}–${n(new Date(t))}`;
1239
+ return o >= 60 * 6e4 ? `${r(new Date(e))}–${r(new Date(t))}` : `${r(new Date(e))}–${r(new Date(t))}`;
1240
1240
  }
1241
- function Rt(e) {
1241
+ function zt(e) {
1242
1242
  return e >= 60 * 6e4 ? `${Math.round(e / 6e4 / 60)}h` : e >= 6e4 ? `${Math.round(e / 6e4)}m` : `${Math.round(e / 1e3)}s`;
1243
1243
  }
1244
- function Bt({ stackOrder: e }) {
1245
- return e.length === 0 ? null : /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-2 mt-2 px-1", children: e.map((t, o) => {
1246
- const n = t === j ? "#94a3b8" : pe(o);
1244
+ function Xt({ stackOrder: e }) {
1245
+ return e.length === 0 ? null : /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-2 mt-2 px-1", children: e.map((t, o) => {
1246
+ const r = t === W ? "#94a3b8" : be(o);
1247
1247
  return /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 text-[10px] text-foreground-subtle", children: [
1248
- /* @__PURE__ */ r("span", { className: "inline-block h-2 w-2 rounded-sm", style: { backgroundColor: n } }),
1249
- /* @__PURE__ */ r("span", { children: t === j ? "other" : t })
1248
+ /* @__PURE__ */ n("span", { className: "inline-block h-2 w-2 rounded-sm", style: { backgroundColor: r } }),
1249
+ /* @__PURE__ */ n("span", { children: t === W ? "other" : t })
1250
1250
  ] }, t);
1251
1251
  }) });
1252
1252
  }
1253
- function Pt({
1253
+ function Yt({
1254
1254
  dev: e,
1255
1255
  deviceId: t,
1256
1256
  title: o = "Live Occupancy",
1257
- variant: n = "full"
1257
+ variant: r = "full"
1258
1258
  }) {
1259
- const a = z(), s = Q(
1259
+ const a = Y(), s = J(
1260
1260
  a.trpcClient,
1261
1261
  e === void 0 && t !== void 0 ? t : null
1262
- ), d = e ?? s, l = ye(d?.state.zoneAnalytics);
1263
- return l ? /* @__PURE__ */ r(Se, { title: o, variant: n, ts: l.ts, children: /* @__PURE__ */ i("div", { className: n === "compact" ? "space-y-2" : "grid grid-cols-1 2xl:grid-cols-3 gap-3", children: [
1264
- /* @__PURE__ */ r(Xt, { frame: l.frame }),
1265
- /* @__PURE__ */ r(qt, { snapshot: l }),
1266
- /* @__PURE__ */ r(Yt, { unzoned: l.unzoned })
1267
- ] }) }) : /* @__PURE__ */ r(Se, { title: o, variant: n, children: /* @__PURE__ */ r(zt, { message: d ? "No occupancy data yet — analytics pipeline must be active for this device." : "Resolving device…" }) });
1262
+ ), d = e ?? s, l = ve(d?.state.zoneAnalytics);
1263
+ return l ? /* @__PURE__ */ n(Ie, { title: o, variant: r, ts: l.ts, children: /* @__PURE__ */ i("div", { className: r === "compact" ? "space-y-2" : "grid grid-cols-1 2xl:grid-cols-3 gap-3", children: [
1264
+ /* @__PURE__ */ n(Gt, { frame: l.frame }),
1265
+ /* @__PURE__ */ n(Vt, { snapshot: l }),
1266
+ /* @__PURE__ */ n(Ut, { unzoned: l.unzoned })
1267
+ ] }) }) : /* @__PURE__ */ n(Ie, { title: o, variant: r, children: /* @__PURE__ */ n(qt, { message: d ? "No occupancy data yet — analytics pipeline must be active for this device." : "Resolving device…" }) });
1268
1268
  }
1269
- function Se({ title: e, variant: t, ts: o, children: n }) {
1269
+ function Ie({ title: e, variant: t, ts: o, children: r }) {
1270
1270
  const a = o ? Math.max(0, Math.floor((Date.now() - o) / 1e3)) : null;
1271
1271
  return /* @__PURE__ */ i("div", { className: t === "compact" ? "rounded-md border border-border/60 bg-surface/60 p-3" : "rounded-lg border border-border bg-surface overflow-hidden", children: [
1272
1272
  /* @__PURE__ */ i("div", { className: t === "compact" ? "flex items-center justify-between mb-2" : "border-b border-border px-4 py-2 flex items-center justify-between", children: [
1273
- /* @__PURE__ */ r("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: e }),
1274
- a !== null && /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle", children: a === 0 ? "just now" : `${a}s ago` })
1273
+ /* @__PURE__ */ n("h2", { className: "text-xs font-semibold text-foreground uppercase tracking-wider", children: e }),
1274
+ a !== null && /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle", children: a === 0 ? "just now" : `${a}s ago` })
1275
1275
  ] }),
1276
- /* @__PURE__ */ r("div", { className: t === "compact" ? "" : "p-3", children: n })
1276
+ /* @__PURE__ */ n("div", { className: t === "compact" ? "" : "p-3", children: r })
1277
1277
  ] });
1278
1278
  }
1279
- function zt({ message: e }) {
1279
+ function qt({ message: e }) {
1280
1280
  return /* @__PURE__ */ i("div", { className: "px-4 py-6 flex flex-col items-center text-center text-foreground-subtle", children: [
1281
- /* @__PURE__ */ r(re, { className: "h-5 w-5 mb-2 opacity-30" }),
1282
- /* @__PURE__ */ r("p", { className: "text-[11px]", children: e })
1281
+ /* @__PURE__ */ n(oe, { className: "h-5 w-5 mb-2 opacity-30" }),
1282
+ /* @__PURE__ */ n("p", { className: "text-[11px]", children: e })
1283
1283
  ] });
1284
1284
  }
1285
- function Xt({ frame: e }) {
1286
- return /* @__PURE__ */ r(
1287
- we,
1285
+ function Gt({ frame: e }) {
1286
+ return /* @__PURE__ */ n(
1287
+ Ne,
1288
1288
  {
1289
- icon: /* @__PURE__ */ r(Ve, { className: "h-3.5 w-3.5" }),
1289
+ icon: /* @__PURE__ */ n(Qe, { className: "h-3.5 w-3.5" }),
1290
1290
  label: "Frame total",
1291
1291
  total: e.totalObjects,
1292
1292
  byClass: e.byClass,
@@ -1294,11 +1294,11 @@ function Xt({ frame: e }) {
1294
1294
  }
1295
1295
  );
1296
1296
  }
1297
- function Yt({ unzoned: e }) {
1298
- return /* @__PURE__ */ r(
1299
- we,
1297
+ function Ut({ unzoned: e }) {
1298
+ return /* @__PURE__ */ n(
1299
+ Ne,
1300
1300
  {
1301
- icon: /* @__PURE__ */ r(et, { className: "h-3.5 w-3.5" }),
1301
+ icon: /* @__PURE__ */ n(rt, { className: "h-3.5 w-3.5" }),
1302
1302
  label: "Outside any zone",
1303
1303
  total: e.totalObjects,
1304
1304
  byClass: e.byClass,
@@ -1306,11 +1306,11 @@ function Yt({ unzoned: e }) {
1306
1306
  }
1307
1307
  );
1308
1308
  }
1309
- function qt({ snapshot: e }) {
1310
- return e.zones.length === 0 ? /* @__PURE__ */ r(
1311
- we,
1309
+ function Vt({ snapshot: e }) {
1310
+ return e.zones.length === 0 ? /* @__PURE__ */ n(
1311
+ Ne,
1312
1312
  {
1313
- icon: /* @__PURE__ */ r(re, { className: "h-3.5 w-3.5" }),
1313
+ icon: /* @__PURE__ */ n(oe, { className: "h-3.5 w-3.5" }),
1314
1314
  label: "Per-zone",
1315
1315
  total: 0,
1316
1316
  byClass: {},
@@ -1319,79 +1319,145 @@ function qt({ snapshot: e }) {
1319
1319
  }
1320
1320
  ) : /* @__PURE__ */ i("div", { className: "rounded-md border border-border/60 bg-background/40", children: [
1321
1321
  /* @__PURE__ */ i("div", { className: "px-3 py-1.5 border-b border-border/40 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
1322
- /* @__PURE__ */ r(re, { className: "h-3.5 w-3.5" }),
1323
- /* @__PURE__ */ r("span", { children: "Per-zone" }),
1324
- /* @__PURE__ */ r("span", { className: "ml-auto text-[10px] normal-case tracking-normal", children: e.zones.length })
1322
+ /* @__PURE__ */ n(oe, { className: "h-3.5 w-3.5" }),
1323
+ /* @__PURE__ */ n("span", { children: "Per-zone" }),
1324
+ /* @__PURE__ */ n("span", { className: "ml-auto text-[10px] normal-case tracking-normal", children: e.zones.length })
1325
1325
  ] }),
1326
- /* @__PURE__ */ r("div", { className: "divide-y divide-border/30", children: e.zones.map((t) => /* @__PURE__ */ i("div", { className: "px-3 py-2", children: [
1326
+ /* @__PURE__ */ n("div", { className: "divide-y divide-border/30", children: e.zones.map((t) => /* @__PURE__ */ i("div", { className: "px-3 py-2", children: [
1327
1327
  /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-1", children: [
1328
- /* @__PURE__ */ r("span", { className: "text-xs font-medium text-foreground truncate", children: t.zoneName }),
1329
- /* @__PURE__ */ r("span", { className: "rounded-full px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle border border-border", children: t.totalObjects })
1328
+ /* @__PURE__ */ n("span", { className: "text-xs font-medium text-foreground truncate", children: t.zoneName }),
1329
+ /* @__PURE__ */ n("span", { className: "rounded-full px-2 py-0.5 text-[10px] font-medium bg-foreground-subtle/10 text-foreground-subtle border border-border", children: t.totalObjects })
1330
1330
  ] }),
1331
- /* @__PURE__ */ r(De, { byClass: t.byClass })
1331
+ /* @__PURE__ */ n(Ee, { byClass: t.byClass })
1332
1332
  ] }, t.zoneId)) })
1333
1333
  ] });
1334
1334
  }
1335
- function we({ icon: e, label: t, total: o, byClass: n, tone: a, emptyMessage: s }) {
1336
- const d = Object.keys(n).length;
1335
+ function Ne({ icon: e, label: t, total: o, byClass: r, tone: a, emptyMessage: s }) {
1336
+ const d = Object.keys(r).length;
1337
1337
  return /* @__PURE__ */ i("div", { className: a === "muted" ? "rounded-md border border-border/40 bg-background/20 px-3 py-2" : "rounded-md border border-border/60 bg-background/40 px-3 py-2", children: [
1338
1338
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle", children: [
1339
1339
  e,
1340
- /* @__PURE__ */ r("span", { children: t }),
1341
- /* @__PURE__ */ r("span", { className: "ml-auto text-base font-semibold text-foreground tabular-nums normal-case tracking-normal", children: o })
1340
+ /* @__PURE__ */ n("span", { children: t }),
1341
+ /* @__PURE__ */ n("span", { className: "ml-auto text-base font-semibold text-foreground tabular-nums normal-case tracking-normal", children: o })
1342
1342
  ] }),
1343
- d === 0 ? /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle italic", children: s ?? "no objects" }) : /* @__PURE__ */ r(De, { byClass: n })
1343
+ d === 0 ? /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle italic", children: s ?? "no objects" }) : /* @__PURE__ */ n(Ee, { byClass: r })
1344
1344
  ] });
1345
1345
  }
1346
- function De({ byClass: e }) {
1347
- const t = N(
1348
- () => Object.entries(e).sort(([, o], [, n]) => n - o),
1346
+ function Ee({ byClass: e }) {
1347
+ const t = k(
1348
+ () => Object.entries(e).sort(([, o], [, r]) => r - o),
1349
1349
  [e]
1350
1350
  );
1351
- return t.length === 0 ? /* @__PURE__ */ r("span", { className: "text-[10px] text-foreground-subtle italic", children: "no objects" }) : /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1", children: t.map(([o, n]) => /* @__PURE__ */ i(
1351
+ return t.length === 0 ? /* @__PURE__ */ n("span", { className: "text-[10px] text-foreground-subtle italic", children: "no objects" }) : /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-1", children: t.map(([o, r]) => /* @__PURE__ */ i(
1352
1352
  "span",
1353
1353
  {
1354
1354
  className: "inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium bg-primary/10 text-primary border border-primary/20",
1355
1355
  children: [
1356
- /* @__PURE__ */ r("span", { children: o }),
1357
- /* @__PURE__ */ r("span", { className: "tabular-nums opacity-80", children: n })
1356
+ /* @__PURE__ */ n("span", { children: o }),
1357
+ /* @__PURE__ */ n("span", { className: "tabular-nums opacity-80", children: r })
1358
1358
  ]
1359
1359
  },
1360
1360
  o
1361
1361
  )) });
1362
1362
  }
1363
- function X({ name: e }) {
1363
+ function Zt({ deviceId: e }) {
1364
+ return /* @__PURE__ */ i("div", { className: ze, children: [
1365
+ /* @__PURE__ */ n("h3", { className: "text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider", children: "Live Stats" }),
1366
+ /* @__PURE__ */ i(
1367
+ "div",
1368
+ {
1369
+ className: `grid ${Xe}`,
1370
+ style: { gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 340px), 1fr))" },
1371
+ children: [
1372
+ /* @__PURE__ */ n(
1373
+ B,
1374
+ {
1375
+ widgetId: "pipeline-analytics/live-occupancy-panel",
1376
+ host: "device-tab",
1377
+ deviceId: e
1378
+ }
1379
+ ),
1380
+ /* @__PURE__ */ n(
1381
+ B,
1382
+ {
1383
+ widgetId: "pipeline-analytics/audio-metrics-panel",
1384
+ host: "device-tab",
1385
+ deviceId: e
1386
+ }
1387
+ )
1388
+ ]
1389
+ }
1390
+ ),
1391
+ /* @__PURE__ */ n(
1392
+ B,
1393
+ {
1394
+ widgetId: "pipeline-analytics/audio-history-chart",
1395
+ host: "device-tab",
1396
+ deviceId: e
1397
+ }
1398
+ ),
1399
+ /* @__PURE__ */ n(
1400
+ B,
1401
+ {
1402
+ widgetId: "pipeline-analytics/occupancy-history-chart",
1403
+ host: "device-tab",
1404
+ deviceId: e
1405
+ }
1406
+ ),
1407
+ /* @__PURE__ */ n(
1408
+ B,
1409
+ {
1410
+ widgetId: "pipeline-analytics/motion-history-chart",
1411
+ host: "device-tab",
1412
+ deviceId: e
1413
+ }
1414
+ ),
1415
+ /* @__PURE__ */ n(
1416
+ B,
1417
+ {
1418
+ widgetId: "pipeline-analytics/detection-history-chart",
1419
+ host: "device-tab",
1420
+ deviceId: e
1421
+ }
1422
+ )
1423
+ ] });
1424
+ }
1425
+ function O({ name: e }) {
1364
1426
  return /* @__PURE__ */ i("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: [
1365
1427
  e,
1366
1428
  " requires a deviceId"
1367
1429
  ] });
1368
1430
  }
1369
- function Gt(e) {
1370
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "AudioHistoryChart" }) : /* @__PURE__ */ r(it, { deviceId: e.deviceId });
1431
+ function Kt(e) {
1432
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "AudioHistoryChart" }) : /* @__PURE__ */ n(ut, { deviceId: e.deviceId });
1371
1433
  }
1372
- function Ut(e) {
1373
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "AudioMetricsPanel" }) : /* @__PURE__ */ r(ft, { deviceId: e.deviceId });
1434
+ function Qt(e) {
1435
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "AudioMetricsPanel" }) : /* @__PURE__ */ n(xt, { deviceId: e.deviceId });
1374
1436
  }
1375
- function Vt(e) {
1376
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "OccupancyHistoryChart" }) : /* @__PURE__ */ r(vt, { deviceId: e.deviceId });
1437
+ function Jt(e) {
1438
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "OccupancyHistoryChart" }) : /* @__PURE__ */ n(kt, { deviceId: e.deviceId });
1377
1439
  }
1378
- function Zt(e) {
1379
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "MotionHistoryChart" }) : /* @__PURE__ */ r(Ct, { deviceId: e.deviceId });
1440
+ function en(e) {
1441
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "MotionHistoryChart" }) : /* @__PURE__ */ n(It, { deviceId: e.deviceId });
1380
1442
  }
1381
- function Kt(e) {
1382
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "DetectionHistoryChart" }) : /* @__PURE__ */ r(Dt, { deviceId: e.deviceId });
1443
+ function tn(e) {
1444
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "DetectionHistoryChart" }) : /* @__PURE__ */ n(Wt, { deviceId: e.deviceId });
1383
1445
  }
1384
- function Qt(e) {
1385
- return e.deviceId === void 0 ? /* @__PURE__ */ r(X, { name: "LiveOccupancyPanel" }) : /* @__PURE__ */ r(Pt, { deviceId: e.deviceId });
1446
+ function nn(e) {
1447
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "LiveOccupancyPanel" }) : /* @__PURE__ */ n(Yt, { deviceId: e.deviceId });
1448
+ }
1449
+ function rn(e) {
1450
+ return e.deviceId === void 0 ? /* @__PURE__ */ n(O, { name: "LiveStats" }) : /* @__PURE__ */ n(Zt, { deviceId: e.deviceId });
1386
1451
  }
1387
- const rn = {
1388
- "audio-history-chart": Gt,
1389
- "audio-metrics-panel": Ut,
1390
- "occupancy-history-chart": Vt,
1391
- "motion-history-chart": Zt,
1392
- "detection-history-chart": Kt,
1393
- "live-occupancy-panel": Qt
1452
+ const cn = {
1453
+ "audio-history-chart": Kt,
1454
+ "audio-metrics-panel": Qt,
1455
+ "occupancy-history-chart": Jt,
1456
+ "motion-history-chart": en,
1457
+ "detection-history-chart": tn,
1458
+ "live-occupancy-panel": nn,
1459
+ "live-stats": rn
1394
1460
  };
1395
1461
  export {
1396
- rn as default
1462
+ cn as default
1397
1463
  };