@camstack/addon-pipeline-orchestrator 0.1.26 → 0.1.27

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 (38) hide show
  1. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts +1 -1
  2. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts.map +1 -1
  3. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts +1 -1
  4. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts.map +1 -1
  5. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneOverlay.d.ts.map +1 -1
  6. package/dist/@mf-types/compiled-types/widgets/zone-editor/types.d.ts +33 -0
  7. package/dist/@mf-types/compiled-types/widgets/zone-editor/types.d.ts.map +1 -0
  8. package/dist/@mf-types.zip +0 -0
  9. package/dist/{ReactKonva--rywLr1Y.mjs → ReactKonva-BpqYt5jc.mjs} +2 -2
  10. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-CP1zJ0aB.mjs +20 -0
  11. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-B1VWqPID.mjs +35 -0
  12. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-0qpbQxoV.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-ZXZUECVq.mjs} +5 -5
  13. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-DekuE8px.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-WhBt7NtJ.mjs} +1 -1
  14. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Ba_7PYkj.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-DF7SvkCe.mjs} +1 -1
  15. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-DSZIXeAx.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-BjxkVuVo.mjs} +5 -4
  16. package/dist/_stub.js +445 -777
  17. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-iOQz8pwN.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-zq9nTFza.mjs} +6 -6
  18. package/dist/{client-CzjQ3uuI.mjs → client-BOhSywdX.mjs} +2 -2
  19. package/dist/{hostInit-HZ0iFEJA.mjs → hostInit-Cn3hiNRr.mjs} +13 -13
  20. package/dist/{index-DaulYonp.mjs → index-3tmcVweY.mjs} +1 -1
  21. package/dist/{index-C1DnrJuR.mjs → index-Bx39JFVr.mjs} +1 -1
  22. package/dist/{index-BmY66bNn.mjs → index-C_khSbT0.mjs} +2 -2
  23. package/dist/{index-DOuehnyb.mjs → index-D4m79gq7.mjs} +1 -1
  24. package/dist/{index-BuYTzV_S.mjs → index-D_QOQy3W.mjs} +7138 -5661
  25. package/dist/{index-CUXiTSWS.mjs → index-Dy2V7VOm.mjs} +3775 -3279
  26. package/dist/{index-Cbqs9uJn.mjs → index-kp_mtnZv.mjs} +1 -1
  27. package/dist/index.js +753 -64
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +753 -64
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{jsx-runtime-DACJhJOv.mjs → jsx-runtime-ChcQDQxt.mjs} +1 -1
  32. package/dist/remoteEntry.js +1 -1
  33. package/dist/{schemas-ChN4Ih0h.mjs → schemas-ClCuS4qa.mjs} +151 -141
  34. package/package.json +4 -1
  35. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts +0 -60
  36. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts.map +0 -1
  37. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C4HmLg0z.mjs +0 -20
  38. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEuqbomC.mjs +0 -34
package/dist/_stub.js CHANGED
@@ -1,24 +1,23 @@
1
- import { _ as t, a as c, b as De } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs";
2
- import { _ as Te } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs";
3
- import { _ as xe, a as Oe, b as je, c as fe, d as he, e as We, f as me, g as ue, h as Be, i as ge, j as Me, k as qe, l as Ue, m as ee, n as te, o as ne, p as He, q as Ve, r as Ge, s as Ye, t as ze, u as Xe, v as Ke } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEuqbomC.mjs";
4
- import { a as Ie, b as pe, c as G, d as H, e as X, f as Se, g as se, h as T } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-0qpbQxoV.mjs";
5
- import { _ as Qe } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C4HmLg0z.mjs";
6
- import { _ as V, a as Je, b as ae, c as ie, d as et, e as tt, f as le } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-DSZIXeAx.mjs";
1
+ import { _ as t, a as i, b as X } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs";
2
+ import { _ as B } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs";
3
+ import { _ as V, a as re, b as oe, c as O, d as q, e as ae, f as U, g as P, h as se, i as z, j as J, k as ie, l as le, m as A, n as F, o as T, p as ce, q as de, r as ue, s as pe, t as me, u as fe, v as he, w as ge } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-B1VWqPID.mjs";
4
+ import { a as Y, b as K, c as Z, d as R, e as be, f as xe, g as w } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-ZXZUECVq.mjs";
5
+ import { _ as ye } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-CP1zJ0aB.mjs";
7
6
  /**
8
7
  * @license lucide-react v0.511.0 - ISC
9
8
  *
10
9
  * This source code is licensed under the ISC license.
11
10
  * See the LICENSE file in the root directory of this source tree.
12
11
  */
13
- const nt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), rt = (e) => e.replace(
12
+ const _e = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ve = (e) => e.replace(
14
13
  /^([A-Z])|[\s-_]+(\w)/g,
15
- (i, r, u) => u ? u.toUpperCase() : r.toLowerCase()
16
- ), _e = (e) => {
17
- const i = rt(e);
18
- return i.charAt(0).toUpperCase() + i.slice(1);
19
- }, $e = (...e) => e.filter((i, r, u) => !!i && i.trim() !== "" && u.indexOf(i) === r).join(" ").trim(), ot = (e) => {
20
- for (const i in e)
21
- if (i.startsWith("aria-") || i === "role" || i === "title")
14
+ (o, n, p) => p ? p.toUpperCase() : n.toLowerCase()
15
+ ), Q = (e) => {
16
+ const o = ve(e);
17
+ return o.charAt(0).toUpperCase() + o.slice(1);
18
+ }, ee = (...e) => e.filter((o, n, p) => !!o && o.trim() !== "" && p.indexOf(o) === n).join(" ").trim(), ke = (e) => {
19
+ for (const o in e)
20
+ if (o.startsWith("aria-") || o === "role" || o === "title")
22
21
  return !0;
23
22
  };
24
23
  /**
@@ -27,7 +26,7 @@ const nt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), rt = (
27
26
  * This source code is licensed under the ISC license.
28
27
  * See the LICENSE file in the root directory of this source tree.
29
28
  */
30
- var st = {
29
+ var we = {
31
30
  xmlns: "http://www.w3.org/2000/svg",
32
31
  width: 24,
33
32
  height: 24,
@@ -44,32 +43,32 @@ var st = {
44
43
  * This source code is licensed under the ISC license.
45
44
  * See the LICENSE file in the root directory of this source tree.
46
45
  */
47
- const at = Ie(
46
+ const Ne = Y(
48
47
  ({
49
48
  color: e = "currentColor",
50
- size: i = 24,
51
- strokeWidth: r = 2,
52
- absoluteStrokeWidth: u,
53
- className: f = "",
54
- children: s,
55
- iconNode: l,
56
- ...a
57
- }, g) => pe(
49
+ size: o = 24,
50
+ strokeWidth: n = 2,
51
+ absoluteStrokeWidth: p,
52
+ className: m = "",
53
+ children: a,
54
+ iconNode: s,
55
+ ...r
56
+ }, f) => K(
58
57
  "svg",
59
58
  {
60
- ref: g,
61
- ...st,
62
- width: i,
63
- height: i,
59
+ ref: f,
60
+ ...we,
61
+ width: o,
62
+ height: o,
64
63
  stroke: e,
65
- strokeWidth: u ? Number(r) * 24 / Number(i) : r,
66
- className: $e("lucide", f),
67
- ...!s && !ot(a) && { "aria-hidden": "true" },
68
- ...a
64
+ strokeWidth: p ? Number(n) * 24 / Number(o) : n,
65
+ className: ee("lucide", m),
66
+ ...!a && !ke(r) && { "aria-hidden": "true" },
67
+ ...r
69
68
  },
70
69
  [
71
- ...l.map(([n, F]) => pe(n, F)),
72
- ...Array.isArray(s) ? s : [s]
70
+ ...s.map(([l, k]) => K(l, k)),
71
+ ...Array.isArray(a) ? a : [a]
73
72
  ]
74
73
  )
75
74
  );
@@ -79,20 +78,20 @@ const at = Ie(
79
78
  * This source code is licensed under the ISC license.
80
79
  * See the LICENSE file in the root directory of this source tree.
81
80
  */
82
- const O = (e, i) => {
83
- const r = Ie(
84
- ({ className: u, ...f }, s) => pe(at, {
85
- ref: s,
86
- iconNode: i,
87
- className: $e(
88
- `lucide-${nt(_e(e))}`,
81
+ const v = (e, o) => {
82
+ const n = Y(
83
+ ({ className: p, ...m }, a) => K(Ne, {
84
+ ref: a,
85
+ iconNode: o,
86
+ className: ee(
87
+ `lucide-${_e(Q(e))}`,
89
88
  `lucide-${e}`,
90
- u
89
+ p
91
90
  ),
92
- ...f
91
+ ...m
93
92
  })
94
93
  );
95
- return r.displayName = _e(e), r;
94
+ return n.displayName = Q(e), n;
96
95
  };
97
96
  /**
98
97
  * @license lucide-react v0.511.0 - ISC
@@ -100,7 +99,7 @@ const O = (e, i) => {
100
99
  * This source code is licensed under the ISC license.
101
100
  * See the LICENSE file in the root directory of this source tree.
102
101
  */
103
- const it = [
102
+ const Ce = [
104
103
  [
105
104
  "path",
106
105
  {
@@ -108,21 +107,21 @@ const it = [
108
107
  key: "169zse"
109
108
  }
110
109
  ]
111
- ], lt = O("activity", it);
110
+ ], De = v("activity", Ce);
112
111
  /**
113
112
  * @license lucide-react v0.511.0 - ISC
114
113
  *
115
114
  * This source code is licensed under the ISC license.
116
115
  * See the LICENSE file in the root directory of this source tree.
117
116
  */
118
- const ct = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], dt = O("check", ct);
117
+ const Se = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Ze = v("check", Se);
119
118
  /**
120
119
  * @license lucide-react v0.511.0 - ISC
121
120
  *
122
121
  * This source code is licensed under the ISC license.
123
122
  * See the LICENSE file in the root directory of this source tree.
124
123
  */
125
- const ut = [
124
+ const $e = [
126
125
  ["path", { d: "M12 20v2", key: "1lh1kg" }],
127
126
  ["path", { d: "M12 2v2", key: "tus03m" }],
128
127
  ["path", { d: "M17 20v2", key: "1rnc9c" }],
@@ -137,14 +136,14 @@ const ut = [
137
136
  ["path", { d: "M7 2v2", key: "1i4yhu" }],
138
137
  ["rect", { x: "4", y: "4", width: "16", height: "16", rx: "2", key: "1vbyd7" }],
139
138
  ["rect", { x: "8", y: "8", width: "8", height: "8", rx: "1", key: "z9xiuo" }]
140
- ], pt = O("cpu", ut);
139
+ ], Ie = v("cpu", $e);
141
140
  /**
142
141
  * @license lucide-react v0.511.0 - ISC
143
142
  *
144
143
  * This source code is licensed under the ISC license.
145
144
  * See the LICENSE file in the root directory of this source tree.
146
145
  */
147
- const ft = [
146
+ const Me = [
148
147
  [
149
148
  "path",
150
149
  {
@@ -153,24 +152,24 @@ const ft = [
153
152
  }
154
153
  ],
155
154
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
156
- ], ht = O("eye", ft);
155
+ ], Ae = v("eye", Me);
157
156
  /**
158
157
  * @license lucide-react v0.511.0 - ISC
159
158
  *
160
159
  * This source code is licensed under the ISC license.
161
160
  * See the LICENSE file in the root directory of this source tree.
162
161
  */
163
- const mt = [
162
+ const Fe = [
164
163
  ["path", { d: "m12 14 4-4", key: "9kzdfg" }],
165
164
  ["path", { d: "M3.34 19a10 10 0 1 1 17.32 0", key: "19p75a" }]
166
- ], gt = O("gauge", mt);
165
+ ], Te = v("gauge", Fe);
167
166
  /**
168
167
  * @license lucide-react v0.511.0 - ISC
169
168
  *
170
169
  * This source code is licensed under the ISC license.
171
170
  * See the LICENSE file in the root directory of this source tree.
172
171
  */
173
- const bt = [
172
+ const Re = [
174
173
  [
175
174
  "path",
176
175
  {
@@ -178,31 +177,31 @@ const bt = [
178
177
  key: "yt0hxn"
179
178
  }
180
179
  ]
181
- ], yt = O("hexagon", bt);
180
+ ], Ee = v("hexagon", Re);
182
181
  /**
183
182
  * @license lucide-react v0.511.0 - ISC
184
183
  *
185
184
  * This source code is licensed under the ISC license.
186
185
  * See the LICENSE file in the root directory of this source tree.
187
186
  */
188
- const xt = [["path", { d: "M5 12h14", key: "1ays0h" }]], _t = O("minus", xt);
187
+ const je = [["path", { d: "M5 12h14", key: "1ays0h" }]], Le = v("minus", je);
189
188
  /**
190
189
  * @license lucide-react v0.511.0 - ISC
191
190
  *
192
191
  * This source code is licensed under the ISC license.
193
192
  * See the LICENSE file in the root directory of this source tree.
194
193
  */
195
- const vt = [
194
+ const Pe = [
196
195
  ["path", { d: "M5 12h14", key: "1ays0h" }],
197
196
  ["path", { d: "M12 5v14", key: "s699le" }]
198
- ], kt = O("plus", vt);
197
+ ], Ke = v("plus", Pe);
199
198
  /**
200
199
  * @license lucide-react v0.511.0 - ISC
201
200
  *
202
201
  * This source code is licensed under the ISC license.
203
202
  * See the LICENSE file in the root directory of this source tree.
204
203
  */
205
- const wt = [
204
+ const Oe = [
206
205
  [
207
206
  "path",
208
207
  {
@@ -212,198 +211,229 @@ const wt = [
212
211
  ],
213
212
  ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
214
213
  ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
215
- ], Nt = O("save", wt);
214
+ ], qe = v("save", Oe);
216
215
  /**
217
216
  * @license lucide-react v0.511.0 - ISC
218
217
  *
219
218
  * This source code is licensed under the ISC license.
220
219
  * See the LICENSE file in the root directory of this source tree.
221
220
  */
222
- const Ct = [
221
+ const Ue = [
223
222
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
224
223
  ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
225
224
  ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
226
225
  ["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
227
226
  ["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
228
- ], be = O("trash-2", Ct);
227
+ ], H = v("trash-2", Ue);
229
228
  /**
230
229
  * @license lucide-react v0.511.0 - ISC
231
230
  *
232
231
  * This source code is licensed under the ISC license.
233
232
  * See the LICENSE file in the root directory of this source tree.
234
233
  */
235
- const Dt = [
234
+ const ze = [
235
+ [
236
+ "path",
237
+ {
238
+ d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
239
+ key: "uqj9uw"
240
+ }
241
+ ],
242
+ ["path", { d: "M16 9a5 5 0 0 1 0 6", key: "1q6k2b" }],
243
+ ["path", { d: "M19.364 18.364a9 9 0 0 0 0-12.728", key: "ijwkga" }]
244
+ ], He = v("volume-2", ze);
245
+ /**
246
+ * @license lucide-react v0.511.0 - ISC
247
+ *
248
+ * This source code is licensed under the ISC license.
249
+ * See the LICENSE file in the root directory of this source tree.
250
+ */
251
+ const Be = [
236
252
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
237
253
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
238
- ], Ze = O("x", Dt);
239
- function Mt(e) {
240
- return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "PipelineQuickStats requires a deviceId" }) : /* @__PURE__ */ t(It, { deviceId: e.deviceId });
254
+ ], te = v("x", Be);
255
+ function Ve(e) {
256
+ return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "PipelineQuickStats requires a deviceId" }) : /* @__PURE__ */ t(Qe, { deviceId: e.deviceId });
241
257
  }
242
- function It({ deviceId: e }) {
243
- xe(
258
+ function Qe({ deviceId: e }) {
259
+ V(
244
260
  ["pipelineOrchestrator", "getPipelineAssignment"],
245
261
  ["pipeline.camera-assigned", "pipeline.camera-unassigned", "pipeline.camera-updated"]
246
- ), xe(
262
+ ), V(
247
263
  ["pipelineRunner", "getCameraMetrics"],
248
264
  ["pipeline.camera-metrics-snapshot"]
249
265
  );
250
- const { data: i } = Oe(
266
+ const { data: o } = re(
251
267
  { deviceId: e },
252
268
  { staleTime: 3e4 }
253
- ), r = i?.agentNodeId ?? null, f = typeof r == "string" && r.length > 0 && !r.startsWith("addon:") ? r : void 0, { data: s } = je(
269
+ ), n = o?.agentNodeId ?? null, m = typeof n == "string" && n.length > 0 && !n.startsWith("addon:") ? n : void 0, { data: a } = oe(
254
270
  {
255
271
  deviceId: e,
256
- ...f ? { nodeId: f } : {}
272
+ ...m ? { nodeId: m } : {}
257
273
  },
258
274
  { staleTime: 2e3, retry: !1 }
259
- ), l = fe(), a = he(l.trpcClient, e), { data: g } = Te({
275
+ ), s = O(), r = q(s.trpcClient, e), { data: f } = B({
260
276
  queryKey: ["device", e, "pipelineAnalytics.getActiveTracks"],
261
- queryFn: () => a?.pipelineAnalytics?.getActiveTracks({}) ?? [],
262
- enabled: !!a,
277
+ queryFn: () => r?.pipelineAnalytics?.getActiveTracks({}) ?? [],
278
+ enabled: !!r,
263
279
  refetchInterval: 5e3,
264
280
  retry: !1
265
- }), n = s?.phase ?? null, F = s?.detectionMode ?? null, d = Number(s?.actualFps ?? 0), $ = Number(s?.configuredFps ?? 0), b = Number(s?.avgInferenceTimeMs ?? 0), k = Number(s?.queueDepth ?? 0), Z = Number(s?.droppedFrames ?? 0), L = We(n ?? "watching"), S = g?.length ?? 0;
266
- return /* @__PURE__ */ t("div", { className: "@container", style: { containerType: "inline-size" }, children: /* @__PURE__ */ c("div", { className: "grid grid-cols-1 @[360px]:grid-cols-2 @[720px]:grid-cols-4 gap-3", children: [
281
+ }), { data: l } = B({
282
+ queryKey: ["device", e, "audioMetrics.getCurrentSnapshot"],
283
+ queryFn: () => r?.audioMetrics?.getCurrentSnapshot({}) ?? null,
284
+ enabled: !!r,
285
+ refetchInterval: 2e3,
286
+ retry: !1
287
+ }), k = a?.phase ?? null, D = a?.detectionMode ?? null, N = Number(a?.actualFps ?? 0), C = Number(a?.configuredFps ?? 0), S = Number(a?.avgInferenceTimeMs ?? 0), c = Number(a?.queueDepth ?? 0), g = Number(a?.droppedFrames ?? 0), _ = ae(k ?? "watching"), u = f?.length ?? 0, h = l?.level.dbfs ?? null, $ = typeof h == "number" ? `${h.toFixed(1)} dBFS` : "—";
288
+ return /* @__PURE__ */ i("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3", children: [
267
289
  /* @__PURE__ */ t(
268
- re,
290
+ M,
269
291
  {
270
- icon: lt,
292
+ icon: De,
271
293
  label: "Phase",
272
- value: L.label,
273
- color: L.textColor,
274
- subtext: F ?? void 0
294
+ value: _.label,
295
+ color: _.textColor,
296
+ subtext: D ?? void 0
275
297
  }
276
298
  ),
277
299
  /* @__PURE__ */ t(
278
- re,
300
+ M,
279
301
  {
280
- icon: gt,
302
+ icon: Te,
281
303
  label: "Detection FPS",
282
- value: `${d.toFixed(1)}`,
283
- subtext: $ > 0 ? `target: ${$}` : void 0
304
+ value: `${N.toFixed(1)}`,
305
+ subtext: C > 0 ? `target: ${C}` : void 0
284
306
  }
285
307
  ),
286
308
  /* @__PURE__ */ t(
287
- re,
309
+ M,
288
310
  {
289
- icon: pt,
311
+ icon: Ie,
290
312
  label: "Inference",
291
- value: `${b.toFixed(1)} ms`,
292
- subtext: k > 0 ? `queue: ${k}` : void 0
313
+ value: `${S.toFixed(1)} ms`,
314
+ subtext: c > 0 ? `queue: ${c}` : void 0
293
315
  }
294
316
  ),
295
317
  /* @__PURE__ */ t(
296
- re,
318
+ M,
297
319
  {
298
- icon: ht,
320
+ icon: Ae,
299
321
  label: "Active Tracks",
300
- value: String(S),
301
- subtext: Z > 0 ? `dropped: ${Z}` : void 0
322
+ value: String(u),
323
+ subtext: g > 0 ? `dropped: ${g}` : void 0
324
+ }
325
+ ),
326
+ /* @__PURE__ */ t(
327
+ M,
328
+ {
329
+ icon: He,
330
+ label: "Current dB",
331
+ value: $
302
332
  }
303
333
  )
304
- ] }) });
334
+ ] });
305
335
  }
306
- function re({ icon: e, label: i, value: r, subtext: u, color: f }) {
307
- return /* @__PURE__ */ c("div", { className: "rounded-lg border border-border bg-surface p-3 min-w-0", children: [
308
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 mb-1 min-w-0", children: [
336
+ function M({ icon: e, label: o, value: n, subtext: p, color: m }) {
337
+ return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface p-3 min-w-0", children: [
338
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1 min-w-0", children: [
309
339
  /* @__PURE__ */ t(e, { className: "h-3.5 w-3.5 text-foreground-subtle flex-shrink-0" }),
310
340
  /* @__PURE__ */ t(
311
341
  "span",
312
342
  {
313
343
  className: "text-[10px] text-foreground-subtle uppercase tracking-wider truncate",
314
- title: i,
315
- children: i
344
+ title: o,
345
+ children: o
316
346
  }
317
347
  )
318
348
  ] }),
319
349
  /* @__PURE__ */ t(
320
350
  "p",
321
351
  {
322
- className: `text-lg font-semibold leading-tight truncate ${f ?? "text-foreground"}`,
323
- title: r,
324
- children: r
352
+ className: `text-lg font-semibold leading-tight truncate ${m ?? "text-foreground"}`,
353
+ title: n,
354
+ children: n
325
355
  }
326
356
  ),
327
- u && /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle mt-0.5 truncate", title: u, children: u })
357
+ p && /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle mt-0.5 truncate", title: p, children: p })
328
358
  ] });
329
359
  }
330
- const St = {
360
+ const We = {
331
361
  polygon: "Polygon",
332
362
  tripwire: "Tripwire"
333
- }, $t = {
363
+ }, Ge = {
334
364
  polygon: "bg-info/10 text-info",
335
365
  tripwire: "bg-warning/10 text-warning"
336
366
  };
337
- function Zt({
367
+ function Xe({
338
368
  zones: e,
339
- selectedZoneId: i,
340
- drawingKind: r,
341
- onSelectZone: u,
342
- onDeleteZone: f,
343
- onStartDraw: s,
344
- onCancelDraw: l
369
+ selectedZoneId: o,
370
+ drawingKind: n,
371
+ onSelectZone: p,
372
+ onDeleteZone: m,
373
+ onStartDraw: a,
374
+ onCancelDraw: s
345
375
  }) {
346
- return /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: [
347
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: r ? /* @__PURE__ */ c(
376
+ return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2", children: [
377
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: n ? /* @__PURE__ */ i(
348
378
  "button",
349
379
  {
350
380
  type: "button",
351
- onClick: l,
381
+ onClick: s,
352
382
  className: "inline-flex items-center justify-center gap-1 rounded border border-amber-500/30 bg-amber-500/10 text-amber-400 hover:bg-amber-500/20 transition-colors h-8 px-3 text-[11px] font-medium",
353
383
  title: "Cancel drawing",
354
384
  children: [
355
- /* @__PURE__ */ t(Ze, { className: "h-3.5 w-3.5" }),
385
+ /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5" }),
356
386
  /* @__PURE__ */ t("span", { children: "Cancel" })
357
387
  ]
358
388
  }
359
- ) : /* @__PURE__ */ c(De, { children: [
389
+ ) : /* @__PURE__ */ i(X, { children: [
360
390
  /* @__PURE__ */ t(
361
391
  "button",
362
392
  {
363
393
  type: "button",
364
- onClick: () => s("polygon"),
394
+ onClick: () => a("polygon"),
365
395
  className: "inline-flex items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors h-8 w-8",
366
396
  title: "Add polygon zone",
367
397
  "aria-label": "Add polygon zone",
368
- children: /* @__PURE__ */ t(yt, { className: "h-4 w-4" })
398
+ children: /* @__PURE__ */ t(Ee, { className: "h-4 w-4" })
369
399
  }
370
400
  ),
371
401
  /* @__PURE__ */ t(
372
402
  "button",
373
403
  {
374
404
  type: "button",
375
- onClick: () => s("tripwire"),
405
+ onClick: () => a("tripwire"),
376
406
  className: "inline-flex items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors h-8 w-8",
377
407
  title: "Add tripwire",
378
408
  "aria-label": "Add tripwire",
379
- children: /* @__PURE__ */ t(_t, { className: "h-5 w-5 stroke-[2.5]" })
409
+ children: /* @__PURE__ */ t(Le, { className: "h-5 w-5 stroke-[2.5]" })
380
410
  }
381
411
  )
382
412
  ] }) }),
383
- e.length === 0 ? /* @__PURE__ */ t("p", { className: "text-center text-[10px] text-foreground-subtle py-3 leading-tight", children: 'No zones yet — pick "Zone" or "Tripwire" to draw.' }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: e.map((a) => {
384
- const g = a.id === i;
385
- return /* @__PURE__ */ c(
413
+ e.length === 0 ? /* @__PURE__ */ t("p", { className: "text-center text-[10px] text-foreground-subtle py-3 leading-tight", children: 'No zones yet — pick "Zone" or "Tripwire" to draw.' }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: e.map((r) => {
414
+ const f = r.id === o;
415
+ return /* @__PURE__ */ i(
386
416
  "div",
387
417
  {
388
418
  className: [
389
419
  "flex items-center gap-1.5 rounded border px-1.5 py-1 cursor-pointer transition-colors",
390
- g ? "border-primary/50 bg-primary/10" : "border-border bg-surface hover:bg-surface-hover"
420
+ f ? "border-primary/50 bg-primary/10" : "border-border bg-surface hover:bg-surface-hover"
391
421
  ].join(" "),
392
- onClick: () => u(g ? null : a.id),
422
+ onClick: () => p(f ? null : r.id),
393
423
  children: [
394
424
  /* @__PURE__ */ t(
395
425
  "div",
396
426
  {
397
427
  className: "h-2.5 w-2.5 rounded-sm flex-shrink-0",
398
- style: { backgroundColor: a.color }
428
+ style: { backgroundColor: r.color }
399
429
  }
400
430
  ),
401
- /* @__PURE__ */ t("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: a.name }),
431
+ /* @__PURE__ */ t("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: r.name }),
402
432
  /* @__PURE__ */ t(
403
433
  "span",
404
434
  {
405
- className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${$t[a.kind]}`,
406
- children: St[a.kind]
435
+ className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${Ge[r.kind]}`,
436
+ children: We[r.kind]
407
437
  }
408
438
  ),
409
439
  /* @__PURE__ */ t(
@@ -412,20 +442,20 @@ function Zt({
412
442
  type: "button",
413
443
  title: "Delete zone",
414
444
  className: "p-0.5 text-foreground-subtle hover:text-danger rounded transition-colors flex-shrink-0",
415
- onClick: (n) => {
416
- n.stopPropagation(), f(a.id);
445
+ onClick: (l) => {
446
+ l.stopPropagation(), m(r.id);
417
447
  },
418
- children: /* @__PURE__ */ t(be, { className: "h-3 w-3" })
448
+ children: /* @__PURE__ */ t(H, { className: "h-3 w-3" })
419
449
  }
420
450
  )
421
451
  ]
422
452
  },
423
- a.id
453
+ r.id
424
454
  );
425
455
  }) })
426
456
  ] });
427
457
  }
428
- const At = [
458
+ const Je = [
429
459
  "#3b82f6",
430
460
  // blue
431
461
  "#10b981",
@@ -443,10 +473,10 @@ const At = [
443
473
  "#ec4899"
444
474
  // pink
445
475
  ];
446
- function Ft({ zone: e, onSave: i, onDiscard: r, onDelete: u }) {
447
- const f = me(), s = (a) => f?.updateDraft({ name: a }), l = (a) => f?.updateDraft({ color: a });
448
- return /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: [
449
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between", children: [
476
+ function Ye({ zone: e, onSave: o, onDiscard: n, onDelete: p }) {
477
+ const m = U(), a = (r) => m?.updateDraft({ name: r }), s = (r) => m?.updateDraft({ color: r });
478
+ return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2", children: [
479
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
450
480
  /* @__PURE__ */ t("h3", { className: "text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider", children: "Editing" }),
451
481
  /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium bg-surface border border-border text-foreground-subtle", children: e.kind === "tripwire" ? "Tripwire" : "Polygon" })
452
482
  ] }),
@@ -454,101 +484,101 @@ function Ft({ zone: e, onSave: i, onDiscard: r, onDelete: u }) {
454
484
  "input",
455
485
  {
456
486
  type: "text",
457
- className: ue,
487
+ className: P,
458
488
  value: e.name,
459
489
  autoFocus: !0,
460
- onChange: (a) => s(a.target.value),
461
- onKeyDown: (a) => {
462
- a.key === "Enter" ? (a.preventDefault(), i()) : a.key === "Escape" && (a.preventDefault(), r());
490
+ onChange: (r) => a(r.target.value),
491
+ onKeyDown: (r) => {
492
+ r.key === "Enter" ? (r.preventDefault(), o()) : r.key === "Escape" && (r.preventDefault(), n());
463
493
  },
464
494
  placeholder: "Zone name"
465
495
  }
466
496
  ),
467
- /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: At.map((a) => /* @__PURE__ */ t(
497
+ /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: Je.map((r) => /* @__PURE__ */ t(
468
498
  "button",
469
499
  {
470
500
  type: "button",
471
- title: a,
501
+ title: r,
472
502
  className: [
473
503
  "h-4 w-4 rounded border-2 cursor-pointer transition-transform hover:scale-110",
474
- e.color === a ? "border-white scale-110" : "border-transparent"
504
+ e.color === r ? "border-white scale-110" : "border-transparent"
475
505
  ].join(" "),
476
- style: { backgroundColor: a },
477
- onClick: () => l(a)
506
+ style: { backgroundColor: r },
507
+ onClick: () => s(r)
478
508
  },
479
- a
509
+ r
480
510
  )) }),
481
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
511
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
482
512
  /* @__PURE__ */ t(
483
513
  "input",
484
514
  {
485
515
  type: "color",
486
516
  className: "h-6 w-6 rounded border border-border bg-background cursor-pointer p-0.5",
487
517
  value: e.color,
488
- onChange: (a) => l(a.target.value)
518
+ onChange: (r) => s(r.target.value)
489
519
  }
490
520
  ),
491
521
  /* @__PURE__ */ t(
492
522
  "input",
493
523
  {
494
524
  type: "text",
495
- className: `${ue} font-mono`,
525
+ className: `${P} font-mono`,
496
526
  value: e.color,
497
527
  placeholder: "#000000",
498
- onChange: (a) => l(a.target.value)
528
+ onChange: (r) => s(r.target.value)
499
529
  }
500
530
  )
501
531
  ] }),
502
- /* @__PURE__ */ c("p", { className: "text-[9px] text-foreground-subtle leading-tight", children: [
532
+ /* @__PURE__ */ i("p", { className: "text-[9px] text-foreground-subtle leading-tight", children: [
503
533
  e.kind === "tripwire" ? "2 points" : `${e.points.length} pts`,
504
534
  e.points.length > 0 && " · drag handles to reshape"
505
535
  ] }),
506
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
507
- /* @__PURE__ */ c(
536
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
537
+ /* @__PURE__ */ i(
508
538
  "button",
509
539
  {
510
540
  type: "button",
511
- onClick: i,
541
+ onClick: o,
512
542
  className: "inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors h-7 flex-1 text-[11px] font-medium",
513
543
  title: "Save changes (Enter)",
514
544
  children: [
515
- /* @__PURE__ */ t(dt, { className: "h-3 w-3" }),
545
+ /* @__PURE__ */ t(Ze, { className: "h-3 w-3" }),
516
546
  "Save"
517
547
  ]
518
548
  }
519
549
  ),
520
- /* @__PURE__ */ c(
550
+ /* @__PURE__ */ i(
521
551
  "button",
522
552
  {
523
553
  type: "button",
524
- onClick: r,
554
+ onClick: n,
525
555
  className: "inline-flex items-center justify-center gap-1 rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors h-7 px-3 text-[11px] font-medium",
526
556
  title: "Discard changes (Esc)",
527
557
  children: [
528
- /* @__PURE__ */ t(Ze, { className: "h-3 w-3" }),
558
+ /* @__PURE__ */ t(te, { className: "h-3 w-3" }),
529
559
  "Discard"
530
560
  ]
531
561
  }
532
562
  )
533
563
  ] }),
534
- /* @__PURE__ */ c(
564
+ /* @__PURE__ */ i(
535
565
  "button",
536
566
  {
537
567
  type: "button",
538
- onClick: u,
539
- className: `${Be} w-full`,
568
+ onClick: p,
569
+ className: `${se} w-full`,
540
570
  children: [
541
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
571
+ /* @__PURE__ */ t(H, { className: "h-3 w-3" }),
542
572
  "Delete"
543
573
  ]
544
574
  }
545
575
  )
546
576
  ] });
547
577
  }
548
- const Lt = Qe.map(
578
+ const et = ye.map(
549
579
  (e) => ({ id: e.id, label: e.name })
550
580
  );
551
- function Et(e) {
581
+ function tt(e) {
552
582
  return {
553
583
  id: e.id,
554
584
  name: e.name ?? "",
@@ -558,127 +588,127 @@ function Et(e) {
558
588
  enabled: e.enabled !== !1
559
589
  };
560
590
  }
561
- function Pt(e) {
562
- const i = {
591
+ function nt(e) {
592
+ const o = {
563
593
  id: e.id,
564
594
  zoneIds: e.zoneIds,
565
595
  mode: e.mode,
566
596
  enabled: e.enabled
567
597
  };
568
- return e.name && (i.name = e.name), e.classFilter.length > 0 && (i.classFilter = e.classFilter), i;
598
+ return e.name && (o.name = e.name), e.classFilter.length > 0 && (o.classFilter = e.classFilter), o;
569
599
  }
570
- function ve({ dev: e, stage: i, zones: r, title: u }) {
571
- const f = ge(e?.state.zoneRules), s = G(
572
- () => f?.[i] ?? [],
573
- [f, i]
574
- ), [l, a] = H([]), [g, n] = H(!1), [F, d] = H(!1), [$, b] = H(null);
575
- X(() => {
576
- g || a(s.map(Et));
577
- }, [s, g]);
578
- const k = () => {
579
- a((m) => [
580
- ...m,
600
+ function W({ dev: e, stage: o, zones: n, title: p }) {
601
+ const m = z(e?.state.zoneRules), a = Z(
602
+ () => m?.[o] ?? [],
603
+ [m, o]
604
+ ), [s, r] = R([]), [f, l] = R(!1), [k, D] = R(!1), [N, C] = R(null);
605
+ be(() => {
606
+ f || r(a.map(tt));
607
+ }, [a, f]);
608
+ const S = () => {
609
+ r((d) => [
610
+ ...d,
581
611
  {
582
612
  id: crypto.randomUUID(),
583
613
  name: "",
584
- zoneIds: r[0] ? [r[0].id] : [],
614
+ zoneIds: n[0] ? [n[0].id] : [],
585
615
  mode: "exclude",
586
616
  classFilter: [],
587
617
  enabled: !0
588
618
  }
589
- ]), n(!0);
590
- }, Z = (m, _) => {
591
- a(
592
- (w) => w.map((N, B) => {
593
- if (B !== m) return N;
594
- const o = N.classFilter.includes(_) ? N.classFilter.filter((p) => p !== _) : [...N.classFilter, _];
595
- return { ...N, classFilter: o };
619
+ ]), l(!0);
620
+ }, c = (d, y) => {
621
+ r(
622
+ (b) => b.map((x, I) => {
623
+ if (I !== d) return x;
624
+ const E = x.classFilter.includes(y) ? x.classFilter.filter((j) => j !== y) : [...x.classFilter, y];
625
+ return { ...x, classFilter: E };
596
626
  })
597
- ), n(!0);
598
- }, L = (m, _) => {
599
- a(
600
- (w) => w.map((N, B) => {
601
- if (B !== m) return N;
602
- const o = N.zoneIds.includes(_) ? N.zoneIds.filter((p) => p !== _) : [...N.zoneIds, _];
603
- return { ...N, zoneIds: o };
627
+ ), l(!0);
628
+ }, g = (d, y) => {
629
+ r(
630
+ (b) => b.map((x, I) => {
631
+ if (I !== d) return x;
632
+ const E = x.zoneIds.includes(y) ? x.zoneIds.filter((j) => j !== y) : [...x.zoneIds, y];
633
+ return { ...x, zoneIds: E };
604
634
  })
605
- ), n(!0);
606
- }, S = (m) => {
607
- a((_) => _.filter((w, N) => N !== m)), n(!0);
608
- }, y = (m, _) => {
609
- a((w) => w.map((N, B) => B === m ? { ...N, ..._ } : N)), n(!0);
635
+ ), l(!0);
636
+ }, _ = (d) => {
637
+ r((y) => y.filter((b, x) => x !== d)), l(!0);
638
+ }, u = (d, y) => {
639
+ r((b) => b.map((x, I) => I === d ? { ...x, ...y } : x)), l(!0);
610
640
  }, h = async () => {
611
641
  if (e?.zoneRules) {
612
- d(!0), b(null);
642
+ D(!0), C(null);
613
643
  try {
614
- await e.zoneRules.setRules({ stage: i, rules: l.map(Pt) }), n(!1);
615
- } catch (m) {
616
- b(m instanceof Error ? m.message : String(m));
644
+ await e.zoneRules.setRules({ stage: o, rules: s.map(nt) }), l(!1);
645
+ } catch (d) {
646
+ C(d instanceof Error ? d.message : String(d));
617
647
  } finally {
618
- d(!1);
648
+ D(!1);
619
649
  }
620
650
  }
621
- }, Y = g && !!e?.zoneRules && !F;
622
- return /* @__PURE__ */ c("div", { className: "rounded-md border border-border bg-surface/40 p-2.5", children: [
623
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between mb-2 gap-2", children: [
624
- /* @__PURE__ */ t("h3", { className: `${Me} truncate`, children: u ?? `${i === "motion" ? "Motion" : "Detection"} Rules` }),
625
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
626
- /* @__PURE__ */ c(
651
+ }, $ = f && !!e?.zoneRules && !k;
652
+ return /* @__PURE__ */ i("div", { className: "rounded-md border border-border bg-surface/40 p-2.5", children: [
653
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-2 gap-2", children: [
654
+ /* @__PURE__ */ t("h3", { className: `${J} truncate`, children: p ?? `${o === "motion" ? "Motion" : "Detection"} Rules` }),
655
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
656
+ /* @__PURE__ */ i(
627
657
  "button",
628
658
  {
629
659
  type: "button",
630
- onClick: k,
631
- disabled: r.length === 0 || !e,
632
- className: qe,
660
+ onClick: S,
661
+ disabled: n.length === 0 || !e,
662
+ className: ie,
633
663
  title: "Add rule",
634
664
  children: [
635
- /* @__PURE__ */ t(kt, { className: "h-2.5 w-2.5" }),
665
+ /* @__PURE__ */ t(Ke, { className: "h-2.5 w-2.5" }),
636
666
  " Add"
637
667
  ]
638
668
  }
639
669
  ),
640
- /* @__PURE__ */ c(
670
+ /* @__PURE__ */ i(
641
671
  "button",
642
672
  {
643
673
  type: "button",
644
674
  onClick: () => {
645
675
  h();
646
676
  },
647
- disabled: !Y,
648
- className: Ue,
677
+ disabled: !$,
678
+ className: le,
649
679
  children: [
650
- /* @__PURE__ */ t(Nt, { className: "h-2.5 w-2.5" }),
651
- F ? "…" : "Save"
680
+ /* @__PURE__ */ t(qe, { className: "h-2.5 w-2.5" }),
681
+ k ? "…" : "Save"
652
682
  ]
653
683
  }
654
684
  )
655
685
  ] })
656
686
  ] }),
657
- l.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle italic px-1 py-1.5 leading-tight", children: r.length === 0 ? "Define a zone first — rules reference zone ids." : "No rules — every detection at this stage passes through." }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: l.map((m, _) => /* @__PURE__ */ c(
687
+ s.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle italic px-1 py-1.5 leading-tight", children: n.length === 0 ? "Define a zone first — rules reference zone ids." : "No rules — every detection at this stage passes through." }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: s.map((d, y) => /* @__PURE__ */ i(
658
688
  "div",
659
689
  {
660
690
  className: "rounded border border-border/50 bg-background/40 px-2 py-1.5 flex flex-col gap-1.5 overflow-hidden",
661
691
  children: [
662
- /* @__PURE__ */ c("div", { className: "grid grid-cols-[auto_1fr_auto] items-center gap-1.5", children: [
692
+ /* @__PURE__ */ i("div", { className: "grid grid-cols-[auto_1fr_auto] items-center gap-1.5", children: [
663
693
  /* @__PURE__ */ t(
664
694
  "button",
665
695
  {
666
696
  type: "button",
667
697
  role: "switch",
668
- "aria-checked": m.enabled,
669
- "aria-label": m.enabled ? "Disable rule" : "Enable rule",
670
- title: m.enabled ? "Rule is active — click to disable" : "Rule is disabled — click to enable",
671
- onClick: () => y(_, { enabled: !m.enabled }),
698
+ "aria-checked": d.enabled,
699
+ "aria-label": d.enabled ? "Disable rule" : "Enable rule",
700
+ title: d.enabled ? "Rule is active — click to disable" : "Rule is disabled — click to enable",
701
+ onClick: () => u(y, { enabled: !d.enabled }),
672
702
  className: [
673
703
  "inline-flex items-center justify-center h-5 w-9 rounded-full border transition-colors flex-shrink-0",
674
- m.enabled ? "border-primary/50 bg-primary/20 text-primary" : "border-border bg-surface text-foreground-subtle"
704
+ d.enabled ? "border-primary/50 bg-primary/20 text-primary" : "border-border bg-surface text-foreground-subtle"
675
705
  ].join(" "),
676
706
  children: /* @__PURE__ */ t(
677
707
  "span",
678
708
  {
679
709
  className: [
680
710
  "h-3 w-3 rounded-full transition-transform",
681
- m.enabled ? "translate-x-1.5 bg-primary" : "-translate-x-1.5 bg-foreground-subtle"
711
+ d.enabled ? "translate-x-1.5 bg-primary" : "-translate-x-1.5 bg-foreground-subtle"
682
712
  ].join(" ")
683
713
  }
684
714
  )
@@ -687,10 +717,10 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
687
717
  /* @__PURE__ */ t(
688
718
  "input",
689
719
  {
690
- className: `${ue} min-w-0`,
720
+ className: `${P} min-w-0`,
691
721
  placeholder: "Rule name (optional)",
692
- value: m.name,
693
- onChange: (w) => y(_, { name: w.target.value })
722
+ value: d.name,
723
+ onChange: (b) => u(y, { name: b.target.value })
694
724
  }
695
725
  ),
696
726
  /* @__PURE__ */ t(
@@ -699,20 +729,20 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
699
729
  type: "button",
700
730
  title: "Remove rule",
701
731
  "aria-label": "Remove rule",
702
- onClick: () => S(_),
732
+ onClick: () => _(y),
703
733
  className: "flex items-center justify-center h-6 w-6 rounded text-foreground-subtle hover:text-danger hover:bg-danger/10 transition-colors flex-shrink-0",
704
- children: /* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" })
734
+ children: /* @__PURE__ */ t(H, { className: "h-3.5 w-3.5" })
705
735
  }
706
736
  )
707
737
  ] }),
708
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
738
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
709
739
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Mode" }),
710
740
  /* @__PURE__ */ t(
711
741
  "button",
712
742
  {
713
743
  type: "button",
714
- onClick: () => y(_, { mode: "include" }),
715
- className: `${ee} ${m.mode === "include" ? te : ne}`,
744
+ onClick: () => u(y, { mode: "include" }),
745
+ className: `${A} ${d.mode === "include" ? F : T}`,
716
746
  children: "Include"
717
747
  }
718
748
  ),
@@ -720,451 +750,72 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
720
750
  "button",
721
751
  {
722
752
  type: "button",
723
- onClick: () => y(_, { mode: "exclude" }),
724
- className: `${ee} ${m.mode === "exclude" ? te : ne}`,
753
+ onClick: () => u(y, { mode: "exclude" }),
754
+ className: `${A} ${d.mode === "exclude" ? F : T}`,
725
755
  children: "Exclude"
726
756
  }
727
757
  )
728
758
  ] }),
729
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
759
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
730
760
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Zones" }),
731
- r.length === 0 ? /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic", children: "none" }) : r.map((w) => {
732
- const N = m.zoneIds.includes(w.id);
733
- return /* @__PURE__ */ c(
761
+ n.length === 0 ? /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic", children: "none" }) : n.map((b) => {
762
+ const x = d.zoneIds.includes(b.id);
763
+ return /* @__PURE__ */ i(
734
764
  "button",
735
765
  {
736
766
  type: "button",
737
- onClick: () => L(_, w.id),
738
- className: `${ee} ${N ? te : ne}`,
767
+ onClick: () => g(y, b.id),
768
+ className: `${A} ${x ? F : T}`,
739
769
  children: [
740
770
  /* @__PURE__ */ t(
741
771
  "span",
742
772
  {
743
773
  className: "h-2 w-2 rounded-sm",
744
- style: { backgroundColor: w.color || "#3b82f6" }
774
+ style: { backgroundColor: b.color || "#3b82f6" }
745
775
  }
746
776
  ),
747
- /* @__PURE__ */ t("span", { className: "truncate max-w-[7rem]", children: w.name || w.id })
777
+ /* @__PURE__ */ t("span", { className: "truncate max-w-[7rem]", children: b.name || b.id })
748
778
  ]
749
779
  },
750
- w.id
780
+ b.id
751
781
  );
752
782
  })
753
783
  ] }),
754
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
784
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
755
785
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Class" }),
756
- Lt.map((w) => {
757
- const N = m.classFilter.includes(w.id);
786
+ et.map((b) => {
787
+ const x = d.classFilter.includes(b.id);
758
788
  return /* @__PURE__ */ t(
759
789
  "button",
760
790
  {
761
791
  type: "button",
762
- onClick: () => Z(_, w.id),
763
- className: `${ee} ${N ? te : ne}`,
764
- children: w.label
792
+ onClick: () => c(y, b.id),
793
+ className: `${A} ${x ? F : T}`,
794
+ children: b.label
765
795
  },
766
- w.id
796
+ b.id
767
797
  );
768
798
  }),
769
- m.classFilter.length === 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic ml-1", children: "any" })
799
+ d.classFilter.length === 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic ml-1", children: "any" })
770
800
  ] })
771
801
  ]
772
802
  },
773
- m.id
803
+ d.id
774
804
  )) }),
775
- $ && /* @__PURE__ */ t("p", { className: "mt-2 text-[10px] text-danger", children: $ })
805
+ N && /* @__PURE__ */ t("p", { className: "mt-2 text-[10px] text-danger", children: N })
776
806
  ] });
777
807
  }
778
- function z(e, i, r) {
779
- return { x: e.x * i, y: e.y * r };
780
- }
781
- function ce(e, i, r) {
782
- return { x: e.x / i, y: e.y / r };
783
- }
784
- function ke(e, i, r) {
785
- return e.flatMap((u) => [u.x * i, u.y * r]);
808
+ function rt(e) {
809
+ const o = e.kind === "tripwire" ? { kind: "line", points: e.points } : { kind: "polygon", points: e.points };
810
+ return { id: e.id, label: e.name, color: e.color, shape: o };
786
811
  }
787
- function Rt(e, i) {
788
- return e.color;
812
+ function ot(e) {
813
+ return e === "line" ? "tripwire" : "polygon";
789
814
  }
790
- const Tt = "33", Ot = "66", we = 16, Ne = 9;
791
- function jt({
792
- zones: e,
793
- selectedZoneId: i,
794
- onSelectZone: r,
795
- onZonePointsChange: u,
796
- onZoneComplete: f,
797
- drawingKind: s,
798
- backdrop: l,
799
- transparent: a = !1
800
- }) {
801
- const g = se(null), [n, F] = H({ w: 800, h: 450 }), [d, $] = H([]), [b, k] = H(null), [Z, L] = H(null), [S, y] = H(null);
802
- X(() => {
803
- if (!S) return;
804
- const o = e.find((v) => v.id === S.zoneId);
805
- if (!o) {
806
- y(null);
807
- return;
808
- }
809
- if (o.points.length !== S.points.length) return;
810
- o.points.every((v, x) => {
811
- const E = S.points[x];
812
- return Math.abs(v.x - E.x) < 1e-6 && Math.abs(v.y - E.y) < 1e-6;
813
- }) && y(null);
814
- }, [e, S]), X(() => {
815
- const o = g.current;
816
- if (!o) return;
817
- const p = new ResizeObserver((v) => {
818
- const x = v[0];
819
- if (x) {
820
- const { width: E, height: P } = x.contentRect;
821
- F(a ? { w: E, h: P } : { w: E, h: E * 9 / 16 });
822
- }
823
- });
824
- return p.observe(o), () => p.disconnect();
825
- }, [a]);
826
- const h = s !== null;
827
- X(() => {
828
- !h && b !== null && k(null);
829
- }, [h, b]);
830
- const Y = T(
831
- (o) => {
832
- if (!h) {
833
- r(null);
834
- return;
835
- }
836
- const p = o.target.getStage();
837
- if (!p) return;
838
- const v = p.getPointerPosition();
839
- if (!v) return;
840
- const x = ce(v, n.w, n.h), E = s === "tripwire";
841
- if (d.length === 0) {
842
- $([x]);
843
- return;
844
- }
845
- if (E && d.length === 1) {
846
- const P = [...d, x], q = {
847
- id: crypto.randomUUID(),
848
- name: "Tripwire",
849
- kind: "tripwire",
850
- color: "#f59e0b",
851
- points: P
852
- };
853
- f(q), $([]);
854
- return;
855
- }
856
- if (d.length >= 3 && !E) {
857
- const P = z(d[0], n.w, n.h);
858
- if (Math.hypot(v.x - P.x, v.y - P.y) < 12) {
859
- const K = {
860
- id: crypto.randomUUID(),
861
- name: "Zone",
862
- kind: "polygon",
863
- color: "#3b82f6",
864
- points: d
865
- };
866
- f(K), $([]);
867
- return;
868
- }
869
- }
870
- $((P) => [...P, x]);
871
- },
872
- [h, d, n, s, f, r]
873
- ), m = T(
874
- (o) => {
875
- if (!h || s === "tripwire" || d.length < 3) return;
876
- o.cancelBubble = !0;
877
- const p = {
878
- id: crypto.randomUUID(),
879
- name: "Zone",
880
- kind: "polygon",
881
- color: "#3b82f6",
882
- points: d
883
- };
884
- f(p), $([]);
885
- },
886
- [h, s, d, f]
887
- ), _ = se(null), w = se(null);
888
- X(() => () => {
889
- _.current !== null && cancelAnimationFrame(_.current);
890
- }, []);
891
- const N = T(
892
- (o) => {
893
- if (!h) return;
894
- const p = o.target.getStage();
895
- if (!p) return;
896
- const v = p.getPointerPosition();
897
- w.current = v ?? null, _.current === null && (_.current = requestAnimationFrame(() => {
898
- _.current = null, k(w.current);
899
- }));
900
- },
901
- [h]
902
- ), B = [];
903
- if (!a) {
904
- for (let o = 1; o < we; o++) {
905
- const p = n.w / we * o;
906
- B.push(
907
- /* @__PURE__ */ t(V, { points: [p, 0, p, n.h], stroke: "#ffffff", strokeWidth: 0.5, opacity: 0.08 }, `gv-${o}`)
908
- );
909
- }
910
- for (let o = 1; o < Ne; o++) {
911
- const p = n.h / Ne * o;
912
- B.push(
913
- /* @__PURE__ */ t(V, { points: [0, p, n.w, p], stroke: "#ffffff", strokeWidth: 0.5, opacity: 0.08 }, `gh-${o}`)
914
- );
915
- }
916
- }
917
- return /* @__PURE__ */ c(
918
- "div",
919
- {
920
- ref: g,
921
- className: a ? "absolute inset-0" : "relative w-full bg-zinc-900 rounded-lg overflow-hidden",
922
- style: { cursor: h ? "crosshair" : "default" },
923
- children: [
924
- l && !a ? /* @__PURE__ */ t(
925
- "div",
926
- {
927
- className: "absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover",
928
- style: { width: n.w, height: n.h },
929
- children: l
930
- }
931
- ) : null,
932
- /* @__PURE__ */ c(
933
- Je,
934
- {
935
- width: n.w,
936
- height: n.h,
937
- onClick: Y,
938
- onDblClick: m,
939
- onMouseMove: N,
940
- children: [
941
- /* @__PURE__ */ c(ae, { listening: !1, children: [
942
- /* @__PURE__ */ t(V, { points: [0, 0, n.w, 0, n.w, n.h, 0, n.h, 0, 0], stroke: "transparent", strokeWidth: 0 }),
943
- B
944
- ] }),
945
- /* @__PURE__ */ t(ae, { children: e.map((o) => {
946
- const p = o.id === i, v = Rt(o), x = S && S.zoneId === o.id ? S.points : o.points, E = ke(x, n.w, n.h), P = o.kind === "tripwire", q = p && !h, K = Z === o.id, Q = x.map((C) => C.x * n.w), J = x.map((C) => C.y * n.h), Ae = Q.length > 0 ? Math.min(...Q) : 0, Fe = Q.length > 0 ? Math.max(...Q) : 0, Le = J.length > 0 ? Math.min(...J) : 0, Ee = J.length > 0 ? Math.max(...J) : 0;
947
- return /* @__PURE__ */ c(
948
- ie,
949
- {
950
- onClick: (C) => {
951
- C.cancelBubble = !0, h || r(o.id);
952
- },
953
- children: [
954
- /* @__PURE__ */ c(
955
- ie,
956
- {
957
- draggable: q,
958
- dragBoundFunc: q ? (C) => ({
959
- x: Math.max(-Ae, Math.min(n.w - Fe, C.x)),
960
- y: Math.max(-Le, Math.min(n.h - Ee, C.y))
961
- }) : void 0,
962
- onDragStart: q ? () => {
963
- L(o.id);
964
- } : void 0,
965
- onDragEnd: q ? (C) => {
966
- const D = C.target, j = D.x() / n.w, U = D.y() / n.h;
967
- if (D.position({ x: 0, y: 0 }), L(null), j === 0 && U === 0) return;
968
- const W = o.points.map((I) => ({ x: I.x + j, y: I.y + U }));
969
- y({ zoneId: o.id, points: W }), u(o.id, W);
970
- } : void 0,
971
- onMouseEnter: (C) => {
972
- if (!q) return;
973
- const D = C.target.getStage();
974
- D && (D.container().style.cursor = "move");
975
- },
976
- onMouseLeave: (C) => {
977
- if (!q) return;
978
- const D = C.target.getStage();
979
- D && (D.container().style.cursor = h ? "crosshair" : "default");
980
- },
981
- children: [
982
- P ? /* @__PURE__ */ t(
983
- et,
984
- {
985
- points: E,
986
- stroke: v,
987
- strokeWidth: p ? 3 : 2,
988
- fill: v,
989
- pointerLength: 10,
990
- pointerWidth: 8,
991
- opacity: p ? 1 : 0.8
992
- }
993
- ) : /* @__PURE__ */ t(
994
- V,
995
- {
996
- points: E,
997
- closed: !0,
998
- fill: v + (p ? Ot : Tt),
999
- stroke: v,
1000
- strokeWidth: p ? 2.5 : 1.5,
1001
- opacity: p ? 1 : 0.85
1002
- }
1003
- ),
1004
- x.length > 0 && (() => {
1005
- const C = x.reduce((A, M) => A + M.x, 0), D = x.reduce((A, M) => A + M.y, 0), j = C / x.length, U = D / x.length, W = z({ x: j, y: U }, n.w, n.h), I = Math.max(40, o.name.length * 11 * 0.62);
1006
- return /* @__PURE__ */ t(
1007
- tt,
1008
- {
1009
- x: W.x - I / 2,
1010
- y: W.y - 7,
1011
- width: I,
1012
- align: "center",
1013
- text: o.name,
1014
- fontSize: 12,
1015
- fill: v,
1016
- stroke: "#000000",
1017
- strokeWidth: 3,
1018
- fillAfterStrokeEnabled: !0,
1019
- fontStyle: "bold",
1020
- listening: !1
1021
- }
1022
- );
1023
- })()
1024
- ]
1025
- }
1026
- ),
1027
- p && !K && x.map((C, D) => {
1028
- const j = z(C, n.w, n.h), U = P ? 2 : 3, W = x.length > U;
1029
- return /* @__PURE__ */ t(
1030
- le,
1031
- {
1032
- x: j.x,
1033
- y: j.y,
1034
- radius: 5,
1035
- fill: v,
1036
- stroke: "#ffffff",
1037
- strokeWidth: 1.5,
1038
- draggable: !0,
1039
- onDragMove: (I) => {
1040
- const A = ce({ x: I.target.x(), y: I.target.y() }, n.w, n.h);
1041
- y((M) => {
1042
- const oe = (M && M.zoneId === o.id ? M.points : o.points).map((Pe, Re) => Re === D ? A : Pe);
1043
- return { zoneId: o.id, points: oe };
1044
- });
1045
- },
1046
- onDragEnd: (I) => {
1047
- const A = ce({ x: I.target.x(), y: I.target.y() }, n.w, n.h), M = o.points.map((R, oe) => oe === D ? A : R);
1048
- y({ zoneId: o.id, points: M }), u(o.id, M);
1049
- },
1050
- onContextMenu: (I) => {
1051
- if (I.evt.preventDefault(), I.cancelBubble = !0, !W) return;
1052
- const A = o.points.filter((M, R) => R !== D);
1053
- u(o.id, A);
1054
- }
1055
- },
1056
- `pt-${D}`
1057
- );
1058
- }),
1059
- p && !K && !P && x.length >= 2 && x.map((C, D) => {
1060
- const j = x[(D + 1) % x.length], U = (C.x + j.x) / 2, W = (C.y + j.y) / 2, I = z({ x: U, y: W }, n.w, n.h);
1061
- return /* @__PURE__ */ t(
1062
- le,
1063
- {
1064
- x: I.x,
1065
- y: I.y,
1066
- radius: 4,
1067
- fill: "#ffffff",
1068
- stroke: v,
1069
- strokeWidth: 1.5,
1070
- opacity: 0.6,
1071
- onMouseEnter: (A) => {
1072
- const M = A.target;
1073
- M.to({ radius: 6, opacity: 1, duration: 0.1 });
1074
- const R = M.getStage();
1075
- R && (R.container().style.cursor = "copy");
1076
- },
1077
- onMouseLeave: (A) => {
1078
- const M = A.target;
1079
- M.to({ radius: 4, opacity: 0.6, duration: 0.1 });
1080
- const R = M.getStage();
1081
- R && (R.container().style.cursor = h ? "crosshair" : "default");
1082
- },
1083
- onClick: (A) => {
1084
- A.cancelBubble = !0;
1085
- const M = D + 1, R = [
1086
- ...o.points.slice(0, M),
1087
- { x: U, y: W },
1088
- ...o.points.slice(M)
1089
- ];
1090
- u(o.id, R);
1091
- }
1092
- },
1093
- `mid-${D}`
1094
- );
1095
- })
1096
- ]
1097
- },
1098
- o.id
1099
- );
1100
- }) }),
1101
- /* @__PURE__ */ t(ae, { listening: !1, children: h && d.length > 0 && /* @__PURE__ */ c(ie, { children: [
1102
- d.length >= 2 && s !== "tripwire" && /* @__PURE__ */ t(
1103
- V,
1104
- {
1105
- points: ke(d, n.w, n.h),
1106
- stroke: "#6366f1",
1107
- strokeWidth: 1.5,
1108
- dash: [6, 3],
1109
- opacity: 0.8
1110
- }
1111
- ),
1112
- d.length === 1 && s === "tripwire" && b && /* @__PURE__ */ t(
1113
- V,
1114
- {
1115
- points: [
1116
- d[0].x * n.w,
1117
- d[0].y * n.h,
1118
- b.x,
1119
- b.y
1120
- ],
1121
- stroke: "#f59e0b",
1122
- strokeWidth: 1.5,
1123
- dash: [6, 3],
1124
- opacity: 0.7
1125
- }
1126
- ),
1127
- b && d.length >= 1 && s !== "tripwire" && /* @__PURE__ */ t(
1128
- V,
1129
- {
1130
- points: [
1131
- d[d.length - 1].x * n.w,
1132
- d[d.length - 1].y * n.h,
1133
- b.x,
1134
- b.y
1135
- ],
1136
- stroke: "#6366f1",
1137
- strokeWidth: 1,
1138
- dash: [4, 4],
1139
- opacity: 0.5
1140
- }
1141
- ),
1142
- d.map((o, p) => {
1143
- const v = z(o, n.w, n.h), x = p === 0;
1144
- return /* @__PURE__ */ t(
1145
- le,
1146
- {
1147
- x: v.x,
1148
- y: v.y,
1149
- radius: x && d.length >= 3 ? 7 : 4,
1150
- fill: x && d.length >= 3 ? "#6366f1" : "#ffffff",
1151
- stroke: "#6366f1",
1152
- strokeWidth: 1.5,
1153
- opacity: 0.9
1154
- },
1155
- p
1156
- );
1157
- })
1158
- ] }) })
1159
- ]
1160
- }
1161
- ),
1162
- h ? /* @__PURE__ */ t("div", { className: "px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700", children: s === "tripwire" ? "Click to set start point, click again to complete the tripwire" : d.length < 3 ? "Click to add points (min 3). Double-click or click first point to close." : "Continue adding points. Double-click or click first point to close." }) : null
1163
- ]
1164
- }
1165
- );
815
+ function at(e) {
816
+ return e === "tripwire" ? "line" : "polygon";
1166
817
  }
1167
- const Wt = Se(jt), Bt = "#3b82f6", de = [
818
+ const st = "#3b82f6", it = ["polygon", "line"], L = [
1168
819
  "#3b82f6",
1169
820
  "#10b981",
1170
821
  "#f59e0b",
@@ -1176,22 +827,22 @@ const Wt = Se(jt), Bt = "#3b82f6", de = [
1176
827
  "#8b5cf6",
1177
828
  "#14b8a6"
1178
829
  ];
1179
- function qt(e) {
1180
- const i = new Set(e.map((r) => (r.color ?? "").toLowerCase()));
1181
- for (const r of de)
1182
- if (!i.has(r.toLowerCase())) return r;
1183
- return de[e.length % de.length];
830
+ function lt(e) {
831
+ const o = new Set(e.map((n) => (n.color ?? "").toLowerCase()));
832
+ for (const n of L)
833
+ if (!o.has(n.toLowerCase())) return n;
834
+ return L[e.length % L.length];
1184
835
  }
1185
- function Ut(e) {
836
+ function ct(e) {
1186
837
  return {
1187
838
  id: e.id,
1188
839
  name: e.name,
1189
840
  kind: e.kind,
1190
- color: e.color || Bt,
841
+ color: e.color || st,
1191
842
  points: [...e.polygon]
1192
843
  };
1193
844
  }
1194
- function Ce(e) {
845
+ function G(e) {
1195
846
  return {
1196
847
  id: e.id,
1197
848
  name: e.name,
@@ -1200,84 +851,101 @@ function Ce(e) {
1200
851
  color: e.color
1201
852
  };
1202
853
  }
1203
- function Ht({ deviceId: e }) {
1204
- const i = fe(), r = he(i.trpcClient, e), u = ge(r?.state.zones), f = G(() => u?.zones ?? [], [u]), s = me(), l = s?.drawingKind ?? null, a = s?.selectedZoneId ?? null, g = s?.editingDraft ?? null, n = G(() => f.map((b) => g && g.id === b.id ? {
1205
- id: g.id,
1206
- name: g.name,
1207
- kind: g.kind,
1208
- color: g.color,
1209
- points: [...g.points]
1210
- } : Ut(b)), [f, g]), F = T(
1211
- async (b) => {
1212
- const k = { ...b, color: qt(n) };
854
+ function dt({ deviceId: e }) {
855
+ const o = O(), n = q(o.trpcClient, e), p = z(n?.state.zones), m = Z(() => p?.zones ?? [], [p]), a = U(), s = a?.drawingKind ?? null, r = a?.selectedZoneId ?? null, f = a?.editingDraft ?? null, l = Z(() => m.map((c) => f && f.id === c.id ? {
856
+ id: f.id,
857
+ name: f.name,
858
+ kind: f.kind,
859
+ color: f.color,
860
+ points: [...f.points]
861
+ } : ct(c)), [m, f]), k = Z(() => l.map(rt), [l]), D = w(
862
+ async (c) => {
863
+ if (c.kind !== "polygon" && c.kind !== "line") return;
864
+ const g = {
865
+ id: crypto.randomUUID(),
866
+ name: "",
867
+ kind: ot(c.kind),
868
+ color: lt(l),
869
+ points: [...c.points]
870
+ };
1213
871
  try {
1214
- await r?.zones?.addZone({ zone: Ce(k) });
1215
- } catch (Z) {
1216
- console.error("zones.addZone failed", Z);
872
+ await n?.zones?.addZone({ zone: G(g) });
873
+ } catch (_) {
874
+ console.error("zones.addZone failed", _);
1217
875
  }
1218
- s?.setSelectedZoneId(k.id), s?.setDrawingKind(null);
876
+ a?.setSelectedZoneId(g.id), a?.setDrawingKind(null);
1219
877
  },
1220
- [r, n, s]
1221
- ), d = T(
1222
- async (b, k) => {
1223
- if (g && g.id === b) {
1224
- s?.updateDraft({ points: k });
878
+ [n, l, a]
879
+ ), N = w(
880
+ async (c, g) => {
881
+ const _ = g.map((h) => ({ x: h.x, y: h.y }));
882
+ if (f && f.id === c) {
883
+ a?.updateDraft({ points: _ });
1225
884
  return;
1226
885
  }
1227
- const Z = n.find((L) => L.id === b);
1228
- if (Z)
886
+ const u = l.find((h) => h.id === c);
887
+ if (u)
1229
888
  try {
1230
- await r?.zones?.updateZone({ zone: Ce({ ...Z, points: k }) });
1231
- } catch (L) {
1232
- console.error("zones.updateZone failed", L);
889
+ await n?.zones?.updateZone({ zone: G({ ...u, points: _ }) });
890
+ } catch (h) {
891
+ console.error("zones.updateZone failed", h);
1233
892
  }
1234
893
  },
1235
- [r, n, g, s]
1236
- ), $ = T(
1237
- (b) => {
1238
- if (b === null) {
1239
- s?.discardDraft(), s?.setSelectedZoneId(null);
894
+ [n, l, f, a]
895
+ ), C = w(
896
+ (c, g) => {
897
+ typeof c == "string" && (g.kind !== "polygon" && g.kind !== "line" || N(c, g.points));
898
+ },
899
+ [N]
900
+ ), S = w(
901
+ (c) => {
902
+ if (c === null) {
903
+ a?.discardDraft(), a?.setSelectedZoneId(null);
1240
904
  return;
1241
905
  }
1242
- const k = n.find((Z) => Z.id === b);
1243
- if (!k) {
1244
- s?.setSelectedZoneId(b);
906
+ if (typeof c != "string") return;
907
+ const g = l.find((_) => _.id === c);
908
+ if (!g) {
909
+ a?.setSelectedZoneId(c);
1245
910
  return;
1246
911
  }
1247
- s?.enterDraft({
1248
- id: k.id,
1249
- kind: k.kind,
1250
- name: k.name,
1251
- color: k.color,
1252
- points: k.points
912
+ a?.enterDraft({
913
+ id: g.id,
914
+ kind: g.kind,
915
+ name: g.name,
916
+ color: g.color,
917
+ points: g.points
1253
918
  });
1254
919
  },
1255
- [n, s]
920
+ [l, a]
1256
921
  );
1257
- return n.length === 0 && l === null ? null : /* @__PURE__ */ t(
1258
- Wt,
922
+ return l.length === 0 && s === null ? null : /* @__PURE__ */ t(
923
+ ce,
1259
924
  {
1260
- zones: n,
1261
- selectedZoneId: a,
1262
- onSelectZone: $,
1263
- onZonePointsChange: d,
1264
- onZoneComplete: F,
1265
- drawingKind: l,
1266
- transparent: !0
925
+ transparent: !0,
926
+ items: k,
927
+ supportedShapes: it,
928
+ selectedId: r,
929
+ onSelect: S,
930
+ onShapeChange: C,
931
+ onDrawComplete: (c) => {
932
+ D(c);
933
+ },
934
+ drawingKind: s === null ? null : at(s)
1267
935
  }
1268
936
  );
1269
937
  }
1270
- const Vt = Se(Ht), Gt = "#3b82f6";
1271
- function Yt(e) {
938
+ const ut = xe(dt), pt = "#3b82f6";
939
+ function mt(e) {
1272
940
  return {
1273
941
  id: e.id,
1274
942
  name: e.name,
1275
943
  kind: e.kind,
1276
- color: e.color || Gt,
944
+ color: e.color || pt,
1277
945
  points: [...e.polygon]
1278
946
  };
1279
947
  }
1280
- function zt(e) {
948
+ function ft(e) {
1281
949
  return {
1282
950
  id: e.id,
1283
951
  name: e.name,
@@ -1286,25 +954,25 @@ function zt(e) {
1286
954
  color: e.color
1287
955
  };
1288
956
  }
1289
- function Xt({ deviceId: e }) {
1290
- const i = fe(), r = he(i.trpcClient, e), u = ge(r?.state.zones), f = G(() => u?.zones ?? [], [u]), s = G(() => f.map(Yt), [f]), l = me(), a = l?.drawingKind ?? null, g = l?.selectedZoneId ?? null, n = l?.editingDraft ?? null, F = G(
957
+ function ht({ deviceId: e }) {
958
+ const o = O(), n = q(o.trpcClient, e), p = z(n?.state.zones), m = Z(() => p?.zones ?? [], [p]), a = Z(() => m.map(mt), [m]), s = U(), r = s?.drawingKind ?? null, f = s?.selectedZoneId ?? null, l = s?.editingDraft ?? null, k = Z(
1291
959
  () => ({
1292
960
  id: "zones",
1293
961
  order: 100,
1294
962
  // above PTZ overlay (order 0) so handles aren't occluded
1295
- node: /* @__PURE__ */ t(Vt, { deviceId: e })
963
+ node: /* @__PURE__ */ t(ut, { deviceId: e })
1296
964
  }),
1297
965
  [e]
1298
966
  );
1299
- He(F);
1300
- const d = T(
1301
- (y) => {
1302
- if (y === null) {
1303
- l?.discardDraft(), l?.setSelectedZoneId(null);
967
+ de(k);
968
+ const D = w(
969
+ (u) => {
970
+ if (u === null) {
971
+ s?.discardDraft(), s?.setSelectedZoneId(null);
1304
972
  return;
1305
973
  }
1306
- const h = s.find((Y) => Y.id === y);
1307
- h && l?.enterDraft({
974
+ const h = a.find(($) => $.id === u);
975
+ h && s?.enterDraft({
1308
976
  id: h.id,
1309
977
  kind: h.kind,
1310
978
  name: h.name,
@@ -1312,101 +980,101 @@ function Xt({ deviceId: e }) {
1312
980
  points: h.points
1313
981
  });
1314
982
  },
1315
- [s, l]
1316
- ), $ = T(async () => {
1317
- const y = l?.editingDraft;
1318
- if (y) {
983
+ [a, s]
984
+ ), N = w(async () => {
985
+ const u = s?.editingDraft;
986
+ if (u) {
1319
987
  try {
1320
- await r?.zones?.updateZone({
1321
- zone: zt({
1322
- id: y.id,
1323
- kind: y.kind,
1324
- name: y.name,
1325
- color: y.color,
1326
- points: [...y.points]
988
+ await n?.zones?.updateZone({
989
+ zone: ft({
990
+ id: u.id,
991
+ kind: u.kind,
992
+ name: u.name,
993
+ color: u.color,
994
+ points: [...u.points]
1327
995
  })
1328
996
  });
1329
997
  } catch (h) {
1330
998
  console.error("zones.updateZone failed", h);
1331
999
  }
1332
- l?.discardDraft(), l?.setSelectedZoneId(null);
1000
+ s?.discardDraft(), s?.setSelectedZoneId(null);
1333
1001
  }
1334
- }, [r, l]), b = T(() => {
1335
- l?.discardDraft(), l?.setSelectedZoneId(null);
1336
- }, [l]), k = T(
1337
- async (y) => {
1002
+ }, [n, s]), C = w(() => {
1003
+ s?.discardDraft(), s?.setSelectedZoneId(null);
1004
+ }, [s]), S = w(
1005
+ async (u) => {
1338
1006
  try {
1339
- await r?.zones?.removeZone({ zoneId: y });
1007
+ await n?.zones?.removeZone({ zoneId: u });
1340
1008
  } catch (h) {
1341
1009
  console.error("zones.removeZone failed", h);
1342
1010
  }
1343
- l?.selectedZoneId === y && l.setSelectedZoneId(null), l?.editingDraft?.id === y && l.discardDraft();
1011
+ s?.selectedZoneId === u && s.setSelectedZoneId(null), s?.editingDraft?.id === u && s.discardDraft();
1344
1012
  },
1345
- [r, l]
1346
- ), Z = T(
1347
- (y) => {
1348
- l?.startDrawing(y);
1013
+ [n, s]
1014
+ ), c = w(
1015
+ (u) => {
1016
+ s?.startDrawing(u);
1349
1017
  },
1350
- [l]
1351
- ), L = T(() => {
1352
- l?.setDrawingKind(null);
1353
- }, [l]), S = G(() => !n || !s.find((h) => h.id === n.id) ? null : {
1354
- id: n.id,
1355
- kind: n.kind,
1356
- name: n.name,
1357
- color: n.color,
1358
- points: [...n.points]
1359
- }, [s, n]);
1360
- return /* @__PURE__ */ c("div", { className: Ve, children: [
1361
- /* @__PURE__ */ c("div", { className: Ge, children: [
1362
- /* @__PURE__ */ t("div", { className: Ye, children: /* @__PURE__ */ c("div", { className: "min-w-0", children: [
1363
- /* @__PURE__ */ t("h2", { className: Me, children: "Detection Zones" }),
1364
- /* @__PURE__ */ c("p", { className: `${ze} mt-0.5 leading-tight`, children: [
1018
+ [s]
1019
+ ), g = w(() => {
1020
+ s?.setDrawingKind(null);
1021
+ }, [s]), _ = Z(() => !l || !a.find((h) => h.id === l.id) ? null : {
1022
+ id: l.id,
1023
+ kind: l.kind,
1024
+ name: l.name,
1025
+ color: l.color,
1026
+ points: [...l.points]
1027
+ }, [a, l]);
1028
+ return /* @__PURE__ */ i("div", { className: ue, children: [
1029
+ /* @__PURE__ */ i("div", { className: pe, children: [
1030
+ /* @__PURE__ */ t("div", { className: me, children: /* @__PURE__ */ i("div", { className: "min-w-0", children: [
1031
+ /* @__PURE__ */ t("h2", { className: J, children: "Detection Zones" }),
1032
+ /* @__PURE__ */ i("p", { className: `${fe} mt-0.5 leading-tight`, children: [
1365
1033
  "Pick a shape below or use the ",
1366
1034
  /* @__PURE__ */ t("strong", { className: "text-foreground", children: "Zones" }),
1367
1035
  " button on the live frame to draw new polygons or tripwires. Behaviour is set per-stage in the rules editors below — a zone with no rule is observed by analytics but never filters."
1368
1036
  ] })
1369
1037
  ] }) }),
1370
- /* @__PURE__ */ c("div", { className: `${Xe} flex flex-col gap-3`, children: [
1038
+ /* @__PURE__ */ i("div", { className: `${he} flex flex-col gap-3`, children: [
1371
1039
  /* @__PURE__ */ t(
1372
- Zt,
1040
+ Xe,
1373
1041
  {
1374
- zones: s,
1375
- selectedZoneId: g,
1376
- drawingKind: a,
1377
- onSelectZone: d,
1378
- onDeleteZone: k,
1379
- onStartDraw: Z,
1380
- onCancelDraw: L
1042
+ zones: a,
1043
+ selectedZoneId: f,
1044
+ drawingKind: r,
1045
+ onSelectZone: D,
1046
+ onDeleteZone: S,
1047
+ onStartDraw: c,
1048
+ onCancelDraw: g
1381
1049
  }
1382
1050
  ),
1383
- S && /* @__PURE__ */ c(De, { children: [
1051
+ _ && /* @__PURE__ */ i(X, { children: [
1384
1052
  /* @__PURE__ */ t("div", { className: "border-t border-border" }),
1385
1053
  /* @__PURE__ */ t(
1386
- Ft,
1054
+ Ye,
1387
1055
  {
1388
- zone: S,
1389
- onSave: $,
1390
- onDiscard: b,
1391
- onDelete: () => k(S.id)
1056
+ zone: _,
1057
+ onSave: N,
1058
+ onDiscard: C,
1059
+ onDelete: () => S(_.id)
1392
1060
  }
1393
1061
  )
1394
1062
  ] })
1395
1063
  ] })
1396
1064
  ] }),
1397
- /* @__PURE__ */ c("div", { className: `grid grid-cols-1 2xl:grid-cols-2 ${Ke}`, children: [
1398
- /* @__PURE__ */ t(ve, { dev: r, stage: "motion", zones: f }),
1399
- /* @__PURE__ */ t(ve, { dev: r, stage: "detection", zones: f })
1065
+ /* @__PURE__ */ i("div", { className: `grid grid-cols-1 2xl:grid-cols-2 ${ge}`, children: [
1066
+ /* @__PURE__ */ t(W, { dev: n, stage: "motion", zones: m }),
1067
+ /* @__PURE__ */ t(W, { dev: n, stage: "detection", zones: m })
1400
1068
  ] })
1401
1069
  ] });
1402
1070
  }
1403
- function Kt(e) {
1404
- return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "ZoneEditor requires a deviceId" }) : /* @__PURE__ */ t(Xt, { deviceId: e.deviceId });
1071
+ function gt(e) {
1072
+ return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "ZoneEditor requires a deviceId" }) : /* @__PURE__ */ t(ht, { deviceId: e.deviceId });
1405
1073
  }
1406
- const ln = {
1407
- "pipeline-quick-stats": Mt,
1408
- "zone-editor": Kt
1074
+ const kt = {
1075
+ "pipeline-quick-stats": Ve,
1076
+ "zone-editor": gt
1409
1077
  };
1410
1078
  export {
1411
- ln as default
1079
+ kt as default
1412
1080
  };