@camstack/addon-benchmark 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MaskShapeCanvas-DwXCR2iE.mjs +686 -0
- package/dist/MotionZonesSettings-CkSSpN1f.mjs +309 -0
- package/dist/PrivacyMaskSettings-Cfff_PeN.mjs +290 -0
- package/dist/ReactKonva-xvRRqI5S.mjs +5416 -0
- package/dist/_stub.js +13162 -46280
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-CAP5kXP6.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-BdEJcXzG.mjs} +4 -4
- package/dist/{_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-DHm30T13.mjs → _virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-Bnj8XQnA.mjs} +1 -1
- package/dist/hls-R1zGmDT3.mjs +18476 -0
- package/dist/{hostInit-BqmNZvnz.mjs → hostInit-77398d3m.mjs} +3 -3
- package/dist/lib-CVGFTwe0.mjs +7770 -0
- package/dist/player-overlays-97shCqYZ.mjs +188 -0
- package/dist/remoteEntry.js +1 -1
- package/dist/trash-2-I9mqk3Ix.mjs +49 -0
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_benchmark_page__remoteEntry_js-CtFXNqc6.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_benchmark_page__remoteEntry_js-2Fj6lA7Z.mjs} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { b as e, c as t, h as n, m as r, p as i, u as a } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-Bnj8XQnA.mjs";
|
|
2
|
+
import { n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-SOU_VnTj.mjs";
|
|
3
|
+
import { a as l, f as u, i as d, p as f, s as ee, t as p, u as m } from "./player-overlays-97shCqYZ.mjs";
|
|
4
|
+
import { MaskShapeCanvas as h } from "./MaskShapeCanvas-DwXCR2iE.mjs";
|
|
5
|
+
var g = m("grid-2x2", [
|
|
6
|
+
["path", {
|
|
7
|
+
d: "M12 3v18",
|
|
8
|
+
key: "108xh3"
|
|
9
|
+
}],
|
|
10
|
+
["path", {
|
|
11
|
+
d: "M3 12h18",
|
|
12
|
+
key: "1i2n21"
|
|
13
|
+
}],
|
|
14
|
+
["rect", {
|
|
15
|
+
x: "3",
|
|
16
|
+
y: "3",
|
|
17
|
+
width: "18",
|
|
18
|
+
height: "18",
|
|
19
|
+
rx: "2",
|
|
20
|
+
key: "h1oib"
|
|
21
|
+
}]
|
|
22
|
+
]);
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../ui-library/src/composites/cap-settings/MotionZonesSettings.tsx
|
|
25
|
+
e();
|
|
26
|
+
var _ = 110, te = "motion-zones", v = 0, y = [
|
|
27
|
+
1,
|
|
28
|
+
2,
|
|
29
|
+
3
|
|
30
|
+
], b = 1, x = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors", S = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors";
|
|
31
|
+
function C(e, t, n) {
|
|
32
|
+
let r = t * n, i = Array(r);
|
|
33
|
+
for (let t = 0; t < r; t += 1) i[t] = e[t] === !0;
|
|
34
|
+
return i;
|
|
35
|
+
}
|
|
36
|
+
function ne(e, t) {
|
|
37
|
+
if (e.length !== t.length) return !1;
|
|
38
|
+
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
39
|
+
return !0;
|
|
40
|
+
}
|
|
41
|
+
function w(e, t) {
|
|
42
|
+
return Math.ceil(e / t);
|
|
43
|
+
}
|
|
44
|
+
function T(e, t, n) {
|
|
45
|
+
return Math.min(n - 1, Math.floor((e + .5) / t * n));
|
|
46
|
+
}
|
|
47
|
+
function E(e, t, n, r) {
|
|
48
|
+
let i = w(t, r), a = w(n, r), o = Array(i * a).fill(!1);
|
|
49
|
+
for (let r = 0; r < n; r += 1) {
|
|
50
|
+
let s = T(r, n, a);
|
|
51
|
+
for (let n = 0; n < t; n += 1) e[r * t + n] === !0 && (o[s * i + T(n, t, i)] = !0);
|
|
52
|
+
}
|
|
53
|
+
return o;
|
|
54
|
+
}
|
|
55
|
+
function D(e, t, n, r) {
|
|
56
|
+
let i = w(t, r), a = w(n, r), o = Array(t * n).fill(!1);
|
|
57
|
+
for (let r = 0; r < n; r += 1) {
|
|
58
|
+
let s = T(r, n, a);
|
|
59
|
+
for (let n = 0; n < t; n += 1) o[r * t + n] = e[s * i + T(n, t, i)] === !0;
|
|
60
|
+
}
|
|
61
|
+
return o;
|
|
62
|
+
}
|
|
63
|
+
function O({ deviceId: e }) {
|
|
64
|
+
let m = l(ee().trpcClient, e), [T, O] = n(null), [k, A] = n(!1), [j, M] = n(null), [N, P] = n(null), [F, I] = n(b), [L, R] = n(!1), [z, B] = n(!1), V = r(!1);
|
|
65
|
+
a(() => {
|
|
66
|
+
if (!m) return;
|
|
67
|
+
let e = !1;
|
|
68
|
+
return V.current = !1, O(null), A(!1), M(null), P(null), I(b), B(!1), (async () => {
|
|
69
|
+
try {
|
|
70
|
+
let t = await m.motionZones?.getOptions({});
|
|
71
|
+
if (e) return;
|
|
72
|
+
if (!t) throw Error("device proxy not ready");
|
|
73
|
+
if (O(t), V.current) return;
|
|
74
|
+
let n = await m.motionZones?.getStatus({});
|
|
75
|
+
if (e) return;
|
|
76
|
+
if (!n) throw Error("device proxy not ready");
|
|
77
|
+
V.current = !0;
|
|
78
|
+
let r = n.regions.find((e) => e.shape.kind === "grid"), i = C(r ? r.shape.cells : [], t.grid.width, t.grid.height);
|
|
79
|
+
P(i), M(E(i, t.grid.width, t.grid.height, b));
|
|
80
|
+
} catch (t) {
|
|
81
|
+
if (e) return;
|
|
82
|
+
f(t) ? A(!0) : console.error("Motion Zones load failed", t);
|
|
83
|
+
}
|
|
84
|
+
})(), () => {
|
|
85
|
+
e = !0;
|
|
86
|
+
};
|
|
87
|
+
}, [m]);
|
|
88
|
+
let H = T ? T.grid.width : 0, U = T ? T.grid.height : 0, W = w(H, F), G = w(U, F), K = i(() => j && T ? D(j, H, U, F) : null, [
|
|
89
|
+
j,
|
|
90
|
+
T,
|
|
91
|
+
H,
|
|
92
|
+
U,
|
|
93
|
+
F
|
|
94
|
+
]), q = i(() => K !== null && N !== null && !ne(K, N), [K, N]), J = i(() => K ? K.reduce((e, t) => t ? e + 1 : e, 0) : 0, [K]), Y = H * U, X = W * G, Z = t((e) => {
|
|
95
|
+
X > 0 && M(Array(X).fill(e));
|
|
96
|
+
}, [X]), re = t(() => {
|
|
97
|
+
M((e) => e && e.map((e) => !e));
|
|
98
|
+
}, []), ie = t(() => {
|
|
99
|
+
N && T && M(E(N, H, U, F));
|
|
100
|
+
}, [
|
|
101
|
+
N,
|
|
102
|
+
T,
|
|
103
|
+
H,
|
|
104
|
+
U,
|
|
105
|
+
F
|
|
106
|
+
]), ae = t((e) => {
|
|
107
|
+
e === F || !T || M((t) => {
|
|
108
|
+
if (!t) return I(e), t;
|
|
109
|
+
let n = E(D(t, H, U, F), H, U, e);
|
|
110
|
+
return I(e), n;
|
|
111
|
+
});
|
|
112
|
+
}, [
|
|
113
|
+
F,
|
|
114
|
+
T,
|
|
115
|
+
H,
|
|
116
|
+
U
|
|
117
|
+
]), Q = i(() => T && j ? [{
|
|
118
|
+
id: v,
|
|
119
|
+
shape: {
|
|
120
|
+
kind: "grid",
|
|
121
|
+
gridWidth: W,
|
|
122
|
+
gridHeight: G,
|
|
123
|
+
cells: [...j]
|
|
124
|
+
}
|
|
125
|
+
}] : [], [
|
|
126
|
+
T,
|
|
127
|
+
j,
|
|
128
|
+
W,
|
|
129
|
+
G
|
|
130
|
+
]), $ = t((e, t) => {
|
|
131
|
+
t.kind === "grid" && M(t.cells);
|
|
132
|
+
}, []), oe = t(async () => {
|
|
133
|
+
if (!(!m || !j || !T)) {
|
|
134
|
+
R(!0);
|
|
135
|
+
try {
|
|
136
|
+
let e = D(j, T.grid.width, T.grid.height, F), t = {
|
|
137
|
+
kind: "grid",
|
|
138
|
+
gridWidth: T.grid.width,
|
|
139
|
+
gridHeight: T.grid.height,
|
|
140
|
+
cells: e
|
|
141
|
+
};
|
|
142
|
+
await m.motionZones?.setZone({ patch: { regions: [{
|
|
143
|
+
id: v,
|
|
144
|
+
enabled: !0,
|
|
145
|
+
shape: t
|
|
146
|
+
}] } });
|
|
147
|
+
let n = await m.motionZones?.getStatus({});
|
|
148
|
+
if (n) {
|
|
149
|
+
let e = n.regions.find((e) => e.shape.kind === "grid"), t = C(e ? e.shape.cells : [], T.grid.width, T.grid.height);
|
|
150
|
+
P(t), M(E(t, T.grid.width, T.grid.height, F));
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.error("Motion Zones save failed", e);
|
|
154
|
+
} finally {
|
|
155
|
+
R(!1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, [
|
|
159
|
+
m,
|
|
160
|
+
j,
|
|
161
|
+
T,
|
|
162
|
+
F
|
|
163
|
+
]);
|
|
164
|
+
return p(i(() => z && !k && T && j ? {
|
|
165
|
+
id: te,
|
|
166
|
+
order: _,
|
|
167
|
+
node: /* @__PURE__ */ o(h, {
|
|
168
|
+
transparent: !0,
|
|
169
|
+
items: Q,
|
|
170
|
+
supportedShapes: ["grid"],
|
|
171
|
+
grid: {
|
|
172
|
+
width: W,
|
|
173
|
+
height: G
|
|
174
|
+
},
|
|
175
|
+
selectedId: v,
|
|
176
|
+
onSelect: () => {},
|
|
177
|
+
onShapeChange: $,
|
|
178
|
+
onDrawComplete: () => {},
|
|
179
|
+
drawingKind: null
|
|
180
|
+
})
|
|
181
|
+
} : null, [
|
|
182
|
+
z,
|
|
183
|
+
k,
|
|
184
|
+
T,
|
|
185
|
+
j,
|
|
186
|
+
Q,
|
|
187
|
+
$,
|
|
188
|
+
W,
|
|
189
|
+
G
|
|
190
|
+
])), m ? /* @__PURE__ */ o(d, {
|
|
191
|
+
title: "Motion Zones",
|
|
192
|
+
icon: /* @__PURE__ */ o(g, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
193
|
+
children: /* @__PURE__ */ o("div", {
|
|
194
|
+
className: "flex flex-col gap-3",
|
|
195
|
+
children: k ? /* @__PURE__ */ o("p", {
|
|
196
|
+
className: `${u} leading-relaxed`,
|
|
197
|
+
children: "This camera doesn't expose an on-board motion zones grid."
|
|
198
|
+
}) : !k && T !== null && j !== null ? /* @__PURE__ */ s(c, { children: [/* @__PURE__ */ s("p", {
|
|
199
|
+
className: `${u} leading-relaxed`,
|
|
200
|
+
children: [
|
|
201
|
+
"Toggle ",
|
|
202
|
+
/* @__PURE__ */ o("strong", {
|
|
203
|
+
className: "text-foreground",
|
|
204
|
+
children: "Edit grid"
|
|
205
|
+
}),
|
|
206
|
+
" to paint the region directly on the live frame, then ",
|
|
207
|
+
/* @__PURE__ */ o("strong", {
|
|
208
|
+
className: "text-foreground",
|
|
209
|
+
children: "Save"
|
|
210
|
+
}),
|
|
211
|
+
" to push the mask to the camera. Pick a bigger",
|
|
212
|
+
" ",
|
|
213
|
+
/* @__PURE__ */ o("strong", {
|
|
214
|
+
className: "text-foreground",
|
|
215
|
+
children: "Cell size"
|
|
216
|
+
}),
|
|
217
|
+
" for quicker, broad-stroke painting — it's resampled to the camera's native ",
|
|
218
|
+
T.grid.width,
|
|
219
|
+
"×",
|
|
220
|
+
T.grid.height,
|
|
221
|
+
" grid on save (×1 is the finest)."
|
|
222
|
+
]
|
|
223
|
+
}), /* @__PURE__ */ s("div", {
|
|
224
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ o("button", {
|
|
227
|
+
type: "button",
|
|
228
|
+
onClick: () => B((e) => !e),
|
|
229
|
+
disabled: L,
|
|
230
|
+
"aria-pressed": z,
|
|
231
|
+
className: z ? S : x,
|
|
232
|
+
children: z ? "Done editing" : "Edit grid"
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ o("button", {
|
|
235
|
+
type: "button",
|
|
236
|
+
onClick: () => Z(!0),
|
|
237
|
+
disabled: L,
|
|
238
|
+
className: x,
|
|
239
|
+
children: "All on"
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ o("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
onClick: () => Z(!1),
|
|
244
|
+
disabled: L,
|
|
245
|
+
className: x,
|
|
246
|
+
children: "All off"
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ o("button", {
|
|
249
|
+
type: "button",
|
|
250
|
+
onClick: re,
|
|
251
|
+
disabled: L,
|
|
252
|
+
className: x,
|
|
253
|
+
children: "Invert"
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ s("div", {
|
|
256
|
+
className: "flex items-center gap-1 ml-1",
|
|
257
|
+
role: "group",
|
|
258
|
+
"aria-label": "Cell size",
|
|
259
|
+
children: [/* @__PURE__ */ o("span", {
|
|
260
|
+
className: `${u} mr-0.5`,
|
|
261
|
+
children: "Cell size"
|
|
262
|
+
}), y.map((e) => /* @__PURE__ */ s("button", {
|
|
263
|
+
type: "button",
|
|
264
|
+
onClick: () => ae(e),
|
|
265
|
+
disabled: L,
|
|
266
|
+
"aria-pressed": F === e,
|
|
267
|
+
title: e === 1 ? `Camera grid ${H}×${U} (finest)` : `${w(H, e)}×${w(U, e)} painting grid · cells ×${e} bigger`,
|
|
268
|
+
className: F === e ? S : x,
|
|
269
|
+
children: ["×", e]
|
|
270
|
+
}, e))]
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ s("span", {
|
|
273
|
+
className: `${u} ml-1 tabular-nums`,
|
|
274
|
+
children: [
|
|
275
|
+
J,
|
|
276
|
+
" / ",
|
|
277
|
+
Y,
|
|
278
|
+
" cells · ",
|
|
279
|
+
T.grid.width,
|
|
280
|
+
"×",
|
|
281
|
+
T.grid.height,
|
|
282
|
+
F === 1 ? "" : ` · paint ${W}×${G}`
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ o("span", { className: "flex-1" }),
|
|
286
|
+
/* @__PURE__ */ o("button", {
|
|
287
|
+
type: "button",
|
|
288
|
+
onClick: ie,
|
|
289
|
+
disabled: L || !q,
|
|
290
|
+
className: "rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",
|
|
291
|
+
children: "Revert"
|
|
292
|
+
}),
|
|
293
|
+
/* @__PURE__ */ o("button", {
|
|
294
|
+
type: "button",
|
|
295
|
+
onClick: () => void oe(),
|
|
296
|
+
disabled: L || !q,
|
|
297
|
+
className: S,
|
|
298
|
+
children: L ? "Saving…" : "Save"
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
})] }) : /* @__PURE__ */ o("p", {
|
|
302
|
+
className: `${u} leading-relaxed`,
|
|
303
|
+
children: "Loading the camera's grid…"
|
|
304
|
+
})
|
|
305
|
+
})
|
|
306
|
+
}) : null;
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
export { O as MotionZonesSettings };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { b as e, c as t, h as n, m as r, p as i, u as a } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-Bnj8XQnA.mjs";
|
|
2
|
+
import { n as o, r as s, t as ee } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-SOU_VnTj.mjs";
|
|
3
|
+
import { a as te, f as c, i as ne, p as re, s as ie, t as l, u } from "./player-overlays-97shCqYZ.mjs";
|
|
4
|
+
import { n as d, r as f, t as p } from "./trash-2-I9mqk3Ix.mjs";
|
|
5
|
+
import { MaskShapeCanvas as m } from "./MaskShapeCanvas-DwXCR2iE.mjs";
|
|
6
|
+
var h = u("hexagon", [["path", {
|
|
7
|
+
d: "M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",
|
|
8
|
+
key: "yt0hxn"
|
|
9
|
+
}]]);
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../ui-library/src/composites/cap-settings/PrivacyMaskSettings.tsx
|
|
12
|
+
e();
|
|
13
|
+
var g = 120, _ = "privacy-mask", v = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors", y = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors";
|
|
14
|
+
function b(e) {
|
|
15
|
+
return e.kind === "rect" || e.kind === "polygon" ? e : null;
|
|
16
|
+
}
|
|
17
|
+
function x(e) {
|
|
18
|
+
let t = new Set(e.map((e) => e.id)), n = 0;
|
|
19
|
+
for (; t.has(n);) n += 1;
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
function S(e, t) {
|
|
23
|
+
if (e.length !== t.length) return !1;
|
|
24
|
+
for (let n = 0; n < e.length; n += 1) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
|
|
25
|
+
return !0;
|
|
26
|
+
}
|
|
27
|
+
function C({ deviceId: e }) {
|
|
28
|
+
let u = te(ie().trpcClient, e), [C, w] = n(null), [T, E] = n(!1), [D, O] = n(null), [k, A] = n(null), [j, M] = n(!1), [N, P] = n(!1), [F, I] = n(null), [L, R] = n(null), z = r(!1);
|
|
29
|
+
a(() => {
|
|
30
|
+
if (!u) return;
|
|
31
|
+
let e = !1;
|
|
32
|
+
return z.current = !1, w(null), E(!1), O(null), A(null), P(!1), I(null), R(null), (async () => {
|
|
33
|
+
try {
|
|
34
|
+
let t = await u.privacyMask?.getOptions({});
|
|
35
|
+
if (e) return;
|
|
36
|
+
if (!t) throw Error("device proxy not ready");
|
|
37
|
+
if (w(t), z.current) return;
|
|
38
|
+
let n = await u.privacyMask?.getStatus({});
|
|
39
|
+
if (e) return;
|
|
40
|
+
if (!n) throw Error("device proxy not ready");
|
|
41
|
+
z.current = !0;
|
|
42
|
+
let r = {
|
|
43
|
+
enabled: n.enabled,
|
|
44
|
+
regions: n.regions
|
|
45
|
+
};
|
|
46
|
+
A(r), O(r);
|
|
47
|
+
} catch (t) {
|
|
48
|
+
if (e) return;
|
|
49
|
+
re(t) ? E(!0) : console.error("Privacy Mask load failed", t);
|
|
50
|
+
}
|
|
51
|
+
})(), () => {
|
|
52
|
+
e = !0;
|
|
53
|
+
};
|
|
54
|
+
}, [u]);
|
|
55
|
+
let B = i(() => D !== null && k !== null && (D.enabled !== k.enabled || !S(D.regions, k.regions)), [D, k]), V = D ? D.regions.length : 0, H = C ? C.maxRegions : 0, U = r(0);
|
|
56
|
+
a(() => {
|
|
57
|
+
U.current = H;
|
|
58
|
+
}, [H]);
|
|
59
|
+
let W = H > 0 && V >= H, G = t(() => {
|
|
60
|
+
O((e) => e && {
|
|
61
|
+
...e,
|
|
62
|
+
enabled: !e.enabled
|
|
63
|
+
});
|
|
64
|
+
}, []), K = t((e) => {
|
|
65
|
+
I(typeof e == "number" ? e : null);
|
|
66
|
+
}, []), q = i(() => D ? D.regions.map((e) => ({
|
|
67
|
+
id: e.id,
|
|
68
|
+
shape: e.shape,
|
|
69
|
+
enabled: e.enabled,
|
|
70
|
+
label: `Zone ${String(e.id)}`
|
|
71
|
+
})) : [], [D]), J = t((e, t) => {
|
|
72
|
+
let n = b(t);
|
|
73
|
+
n && O((t) => t && {
|
|
74
|
+
...t,
|
|
75
|
+
regions: t.regions.map((t) => t.id === e ? {
|
|
76
|
+
...t,
|
|
77
|
+
shape: n
|
|
78
|
+
} : t)
|
|
79
|
+
});
|
|
80
|
+
}, []), Y = t((e) => {
|
|
81
|
+
let t = b(e);
|
|
82
|
+
t && (R(null), O((e) => {
|
|
83
|
+
if (!e) return e;
|
|
84
|
+
let n = U.current;
|
|
85
|
+
if (n > 0 && e.regions.length >= n) return e;
|
|
86
|
+
let r = x(e.regions), i = {
|
|
87
|
+
id: r,
|
|
88
|
+
enabled: !0,
|
|
89
|
+
shape: t
|
|
90
|
+
};
|
|
91
|
+
return I(r), {
|
|
92
|
+
...e,
|
|
93
|
+
regions: [...e.regions, i]
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
}, []), X = t((e) => {
|
|
97
|
+
P(!0), I(null), R(e);
|
|
98
|
+
}, []), ae = t((e) => {
|
|
99
|
+
P(!0), R(null), I(e);
|
|
100
|
+
}, []), Z = t((e) => {
|
|
101
|
+
I((t) => t === e ? null : t), O((t) => t && {
|
|
102
|
+
...t,
|
|
103
|
+
regions: t.regions.filter((t) => t.id !== e)
|
|
104
|
+
});
|
|
105
|
+
}, []), oe = t(() => {
|
|
106
|
+
R(null), I(null), k && O({
|
|
107
|
+
enabled: k.enabled,
|
|
108
|
+
regions: k.regions
|
|
109
|
+
});
|
|
110
|
+
}, [k]), se = t(async () => {
|
|
111
|
+
if (!(!u || !D)) {
|
|
112
|
+
M(!0);
|
|
113
|
+
try {
|
|
114
|
+
await u.privacyMask?.setMask({ patch: {
|
|
115
|
+
enabled: D.enabled,
|
|
116
|
+
regions: [...D.regions]
|
|
117
|
+
} });
|
|
118
|
+
let e = await u.privacyMask?.getStatus({});
|
|
119
|
+
if (e) {
|
|
120
|
+
let t = {
|
|
121
|
+
enabled: e.enabled,
|
|
122
|
+
regions: e.regions
|
|
123
|
+
};
|
|
124
|
+
A(t), O(t);
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error("Privacy Mask save failed", e);
|
|
128
|
+
} finally {
|
|
129
|
+
M(!1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, [u, D]), ce = t(() => {
|
|
133
|
+
P((e) => (e && (R(null), I(null)), !e));
|
|
134
|
+
}, []), Q = C?.supportedShapes ?? [];
|
|
135
|
+
l(i(() => N && !T && C && D ? {
|
|
136
|
+
id: _,
|
|
137
|
+
order: g,
|
|
138
|
+
node: /* @__PURE__ */ o(m, {
|
|
139
|
+
transparent: !0,
|
|
140
|
+
items: q,
|
|
141
|
+
supportedShapes: Q,
|
|
142
|
+
polygonVertices: C.polygonVertices,
|
|
143
|
+
selectedId: F,
|
|
144
|
+
onSelect: K,
|
|
145
|
+
onShapeChange: J,
|
|
146
|
+
onDrawComplete: Y,
|
|
147
|
+
drawingKind: L
|
|
148
|
+
})
|
|
149
|
+
} : null, [
|
|
150
|
+
N,
|
|
151
|
+
T,
|
|
152
|
+
C,
|
|
153
|
+
D,
|
|
154
|
+
q,
|
|
155
|
+
Q,
|
|
156
|
+
F,
|
|
157
|
+
K,
|
|
158
|
+
J,
|
|
159
|
+
Y,
|
|
160
|
+
L
|
|
161
|
+
]));
|
|
162
|
+
let le = C?.supportedShapes.includes("rect") ?? !1, ue = C?.supportedShapes.includes("polygon") ?? !1, $ = C !== null && (C.maxRegions <= 0 || C.supportedShapes.length === 0);
|
|
163
|
+
return u ? /* @__PURE__ */ o(ne, {
|
|
164
|
+
title: "Privacy Mask",
|
|
165
|
+
icon: /* @__PURE__ */ o(f, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
166
|
+
children: /* @__PURE__ */ o("div", {
|
|
167
|
+
className: "flex flex-col gap-3",
|
|
168
|
+
children: T || $ ? /* @__PURE__ */ o("p", {
|
|
169
|
+
className: `${c} leading-relaxed`,
|
|
170
|
+
children: "This camera doesn't support an on-board privacy mask."
|
|
171
|
+
}) : !T && !$ && C !== null && D !== null ? /* @__PURE__ */ s(ee, { children: [
|
|
172
|
+
/* @__PURE__ */ s("p", {
|
|
173
|
+
className: `${c} leading-relaxed`,
|
|
174
|
+
children: [
|
|
175
|
+
"Toggle ",
|
|
176
|
+
/* @__PURE__ */ o("strong", {
|
|
177
|
+
className: "text-foreground",
|
|
178
|
+
children: "Edit mask"
|
|
179
|
+
}),
|
|
180
|
+
" to draw blanked-out zones on the live frame, then ",
|
|
181
|
+
/* @__PURE__ */ o("strong", {
|
|
182
|
+
className: "text-foreground",
|
|
183
|
+
children: "Save"
|
|
184
|
+
}),
|
|
185
|
+
" to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it."
|
|
186
|
+
]
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ s("div", {
|
|
189
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ o("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
onClick: ce,
|
|
194
|
+
disabled: j,
|
|
195
|
+
"aria-pressed": N,
|
|
196
|
+
className: N ? y : v,
|
|
197
|
+
children: N ? "Done editing" : "Edit mask"
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ o("button", {
|
|
200
|
+
type: "button",
|
|
201
|
+
onClick: G,
|
|
202
|
+
disabled: j,
|
|
203
|
+
"aria-pressed": D.enabled,
|
|
204
|
+
className: D.enabled ? y : v,
|
|
205
|
+
children: D.enabled ? "Mask on" : "Mask off"
|
|
206
|
+
}),
|
|
207
|
+
le && /* @__PURE__ */ o("button", {
|
|
208
|
+
type: "button",
|
|
209
|
+
onClick: () => X("rect"),
|
|
210
|
+
disabled: j || W,
|
|
211
|
+
"aria-pressed": L === "rect",
|
|
212
|
+
className: L === "rect" ? y : v,
|
|
213
|
+
title: W ? "Maximum zones reached" : "Add a rectangle zone",
|
|
214
|
+
children: "+ Rect"
|
|
215
|
+
}),
|
|
216
|
+
ue && /* @__PURE__ */ o("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: () => X("polygon"),
|
|
219
|
+
disabled: j || W,
|
|
220
|
+
"aria-pressed": L === "polygon",
|
|
221
|
+
className: L === "polygon" ? y : v,
|
|
222
|
+
title: W ? "Maximum zones reached" : "Add a polygon zone",
|
|
223
|
+
children: "+ Polygon"
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ s("span", {
|
|
226
|
+
className: `${c} ml-1 tabular-nums`,
|
|
227
|
+
children: [
|
|
228
|
+
V,
|
|
229
|
+
" / ",
|
|
230
|
+
H,
|
|
231
|
+
" zones"
|
|
232
|
+
]
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ o("span", { className: "flex-1" }),
|
|
235
|
+
/* @__PURE__ */ o("button", {
|
|
236
|
+
type: "button",
|
|
237
|
+
onClick: oe,
|
|
238
|
+
disabled: j || !B,
|
|
239
|
+
className: "rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",
|
|
240
|
+
children: "Revert"
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ o("button", {
|
|
243
|
+
type: "button",
|
|
244
|
+
onClick: () => void se(),
|
|
245
|
+
disabled: j || !B,
|
|
246
|
+
className: y,
|
|
247
|
+
children: j ? "Saving…" : "Save"
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
}),
|
|
251
|
+
V > 0 ? /* @__PURE__ */ o("div", {
|
|
252
|
+
className: "flex flex-col gap-1",
|
|
253
|
+
children: D.regions.map((e) => {
|
|
254
|
+
let t = F === e.id, n = e.shape.kind === "polygon" ? h : d;
|
|
255
|
+
return /* @__PURE__ */ s("div", {
|
|
256
|
+
className: `flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t ? "border-primary/50 bg-primary/10" : "border-border bg-surface"}`,
|
|
257
|
+
children: [/* @__PURE__ */ s("button", {
|
|
258
|
+
type: "button",
|
|
259
|
+
onClick: () => ae(e.id),
|
|
260
|
+
disabled: j,
|
|
261
|
+
className: "flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors",
|
|
262
|
+
children: [
|
|
263
|
+
/* @__PURE__ */ o(n, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
264
|
+
/* @__PURE__ */ s("span", { children: ["Zone ", e.id] }),
|
|
265
|
+
/* @__PURE__ */ o("span", {
|
|
266
|
+
className: "text-foreground-faint capitalize",
|
|
267
|
+
children: e.shape.kind
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
}), /* @__PURE__ */ o("button", {
|
|
271
|
+
type: "button",
|
|
272
|
+
onClick: () => Z(e.id),
|
|
273
|
+
disabled: j,
|
|
274
|
+
"aria-label": `Delete zone ${String(e.id)}`,
|
|
275
|
+
title: "Delete zone",
|
|
276
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors",
|
|
277
|
+
children: /* @__PURE__ */ o(p, { className: "h-3.5 w-3.5" })
|
|
278
|
+
})]
|
|
279
|
+
}, e.id);
|
|
280
|
+
})
|
|
281
|
+
}) : null
|
|
282
|
+
] }) : /* @__PURE__ */ o("p", {
|
|
283
|
+
className: `${c} leading-relaxed`,
|
|
284
|
+
children: "Loading the camera's privacy mask…"
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
}) : null;
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
export { C as PrivacyMaskSettings };
|