@camstack/addon-model-studio 1.0.4 → 1.0.5
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-C4g96eMz.mjs +13806 -0
- package/dist/MotionZonesSettings-B8ishTpw.mjs +309 -0
- package/dist/PrivacyMaskSettings-P06be0E2.mjs +290 -0
- package/dist/_stub.js +8968 -0
- package/dist/_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-CI4Ho-xh.mjs +156 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.js-ZNPquRb4.mjs +25 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-cUKFrqHE.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-B-9Pn2K0.mjs +25 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-nybV3Y4f.mjs +25 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-BvzT760A.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react__loadShare__.js-DJDHChgO.mjs +70 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-ds_Ehzaa.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react_mf_2_dom__loadShare__.js-Dh0QbaoP.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-BjUy5evk.mjs +25 -0
- package/dist/addon-model-studio.css +3 -0
- package/dist/hostInit-I8461iVN.mjs +129 -0
- package/dist/model-studio.addon.js +56 -5
- package/dist/model-studio.addon.mjs +56 -5
- package/dist/player-overlays-CeF0YjKF.mjs +163 -0
- package/dist/remoteEntry.js +2 -0
- package/dist/remoteEntry.ssr.js +33 -0
- package/dist/rolldown-runtime-HEgqtunE.mjs +20 -0
- package/dist/trash-2-Ct7_ZXVk.mjs +49 -0
- package/dist/virtualExposes-CWSi4E_g.mjs +27 -0
- package/dist/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-C-Qc_p47.mjs +2857 -0
- package/dist/virtual_mf-exposes-ssr___mfe_internal__addon_model_studio_page__remoteEntry_js-BoA99BYM.mjs +10 -0
- package/package.json +30 -3
- package/python/convert_lib.py +38 -3
- package/python/requirements.txt +10 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { c as e, h as t, m as n, p as r, u as i, y as a } from "./_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react__loadShare__.js-DJDHChgO.mjs";
|
|
2
|
+
import { n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-ds_Ehzaa.mjs";
|
|
3
|
+
import { a as l, l as u, n as ee, r as d, s as f, t as p, u as m } from "./player-overlays-CeF0YjKF.mjs";
|
|
4
|
+
import { MaskShapeCanvas as h } from "./MaskShapeCanvas-C4g96eMz.mjs";
|
|
5
|
+
var te = f("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
|
+
a();
|
|
26
|
+
var ne = 110, g = "motion-zones", _ = 0, re = [
|
|
27
|
+
1,
|
|
28
|
+
2,
|
|
29
|
+
3
|
|
30
|
+
], v = 1, y = "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", b = "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 x(e, t, n) {
|
|
32
|
+
let r = t * n, i = Array.from({ length: r });
|
|
33
|
+
for (let t = 0; t < r; t += 1) i[t] = e[t] === !0;
|
|
34
|
+
return i;
|
|
35
|
+
}
|
|
36
|
+
function S(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 C(e, t) {
|
|
42
|
+
return Math.ceil(e / t);
|
|
43
|
+
}
|
|
44
|
+
function w(e, t, n) {
|
|
45
|
+
return Math.min(n - 1, Math.floor((e + .5) / t * n));
|
|
46
|
+
}
|
|
47
|
+
function T(e, t, n, r) {
|
|
48
|
+
let i = C(t, r), a = C(n, r), o = Array.from({ length: i * a }, () => !1);
|
|
49
|
+
for (let r = 0; r < n; r += 1) {
|
|
50
|
+
let s = w(r, n, a);
|
|
51
|
+
for (let n = 0; n < t; n += 1) e[r * t + n] === !0 && (o[s * i + w(n, t, i)] = !0);
|
|
52
|
+
}
|
|
53
|
+
return o;
|
|
54
|
+
}
|
|
55
|
+
function E(e, t, n, r) {
|
|
56
|
+
let i = C(t, r), a = C(n, r), o = Array.from({ length: t * n }, () => !1);
|
|
57
|
+
for (let r = 0; r < n; r += 1) {
|
|
58
|
+
let s = w(r, n, a);
|
|
59
|
+
for (let n = 0; n < t; n += 1) o[r * t + n] = e[s * i + w(n, t, i)] === !0;
|
|
60
|
+
}
|
|
61
|
+
return o;
|
|
62
|
+
}
|
|
63
|
+
function D({ deviceId: a }) {
|
|
64
|
+
let f = d(l().trpcClient, a), [w, D] = t(null), [O, k] = t(!1), [A, j] = t(null), [M, N] = t(null), [P, F] = t(v), [I, L] = t(!1), [R, z] = t(!1), B = n(!1);
|
|
65
|
+
i(() => {
|
|
66
|
+
if (!f) return;
|
|
67
|
+
let e = !1;
|
|
68
|
+
return B.current = !1, D(null), k(!1), j(null), N(null), F(v), z(!1), (async () => {
|
|
69
|
+
try {
|
|
70
|
+
let t = await f.motionZones?.getOptions({});
|
|
71
|
+
if (e) return;
|
|
72
|
+
if (!t) throw Error("device proxy not ready");
|
|
73
|
+
if (D(t), B.current) return;
|
|
74
|
+
let n = await f.motionZones?.getStatus({});
|
|
75
|
+
if (e) return;
|
|
76
|
+
if (!n) throw Error("device proxy not ready");
|
|
77
|
+
B.current = !0;
|
|
78
|
+
let r = n.regions.find((e) => e.shape.kind === "grid"), i = x(r ? r.shape.cells : [], t.grid.width, t.grid.height);
|
|
79
|
+
N(i), j(T(i, t.grid.width, t.grid.height, v));
|
|
80
|
+
} catch (t) {
|
|
81
|
+
if (e) return;
|
|
82
|
+
m(t) ? k(!0) : console.error("Motion Zones load failed", t);
|
|
83
|
+
}
|
|
84
|
+
})(), () => {
|
|
85
|
+
e = !0;
|
|
86
|
+
};
|
|
87
|
+
}, [f]);
|
|
88
|
+
let V = w ? w.grid.width : 0, H = w ? w.grid.height : 0, U = C(V, P), W = C(H, P), G = r(() => A && w ? E(A, V, H, P) : null, [
|
|
89
|
+
A,
|
|
90
|
+
w,
|
|
91
|
+
V,
|
|
92
|
+
H,
|
|
93
|
+
P
|
|
94
|
+
]), K = r(() => G !== null && M !== null && !S(G, M), [G, M]), q = r(() => G ? G.reduce((e, t) => t ? e + 1 : e, 0) : 0, [G]), J = V * H, Y = U * W, X = e((e) => {
|
|
95
|
+
Y > 0 && j(Array.from({ length: Y }, () => e));
|
|
96
|
+
}, [Y]), Z = e(() => {
|
|
97
|
+
j((e) => e && e.map((e) => !e));
|
|
98
|
+
}, []), ie = e(() => {
|
|
99
|
+
M && w && j(T(M, V, H, P));
|
|
100
|
+
}, [
|
|
101
|
+
M,
|
|
102
|
+
w,
|
|
103
|
+
V,
|
|
104
|
+
H,
|
|
105
|
+
P
|
|
106
|
+
]), ae = e((e) => {
|
|
107
|
+
e === P || !w || j((t) => {
|
|
108
|
+
if (!t) return F(e), t;
|
|
109
|
+
let n = T(E(t, V, H, P), V, H, e);
|
|
110
|
+
return F(e), n;
|
|
111
|
+
});
|
|
112
|
+
}, [
|
|
113
|
+
P,
|
|
114
|
+
w,
|
|
115
|
+
V,
|
|
116
|
+
H
|
|
117
|
+
]), Q = r(() => w && A ? [{
|
|
118
|
+
id: _,
|
|
119
|
+
shape: {
|
|
120
|
+
kind: "grid",
|
|
121
|
+
gridWidth: U,
|
|
122
|
+
gridHeight: W,
|
|
123
|
+
cells: [...A]
|
|
124
|
+
}
|
|
125
|
+
}] : [], [
|
|
126
|
+
w,
|
|
127
|
+
A,
|
|
128
|
+
U,
|
|
129
|
+
W
|
|
130
|
+
]), $ = e((e, t) => {
|
|
131
|
+
t.kind === "grid" && j(t.cells);
|
|
132
|
+
}, []), oe = e(async () => {
|
|
133
|
+
if (!(!f || !A || !w)) {
|
|
134
|
+
L(!0);
|
|
135
|
+
try {
|
|
136
|
+
let e = E(A, w.grid.width, w.grid.height, P), t = {
|
|
137
|
+
kind: "grid",
|
|
138
|
+
gridWidth: w.grid.width,
|
|
139
|
+
gridHeight: w.grid.height,
|
|
140
|
+
cells: e
|
|
141
|
+
};
|
|
142
|
+
await f.motionZones?.setZone({ patch: { regions: [{
|
|
143
|
+
id: _,
|
|
144
|
+
enabled: !0,
|
|
145
|
+
shape: t
|
|
146
|
+
}] } });
|
|
147
|
+
let n = await f.motionZones?.getStatus({});
|
|
148
|
+
if (n) {
|
|
149
|
+
let e = n.regions.find((e) => e.shape.kind === "grid"), t = x(e ? e.shape.cells : [], w.grid.width, w.grid.height);
|
|
150
|
+
N(t), j(T(t, w.grid.width, w.grid.height, P));
|
|
151
|
+
}
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.error("Motion Zones save failed", e);
|
|
154
|
+
} finally {
|
|
155
|
+
L(!1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, [
|
|
159
|
+
f,
|
|
160
|
+
A,
|
|
161
|
+
w,
|
|
162
|
+
P
|
|
163
|
+
]);
|
|
164
|
+
return p(r(() => R && !O && w && A ? {
|
|
165
|
+
id: g,
|
|
166
|
+
order: ne,
|
|
167
|
+
node: /* @__PURE__ */ o(h, {
|
|
168
|
+
transparent: !0,
|
|
169
|
+
items: Q,
|
|
170
|
+
supportedShapes: ["grid"],
|
|
171
|
+
grid: {
|
|
172
|
+
width: U,
|
|
173
|
+
height: W
|
|
174
|
+
},
|
|
175
|
+
selectedId: _,
|
|
176
|
+
onSelect: () => {},
|
|
177
|
+
onShapeChange: $,
|
|
178
|
+
onDrawComplete: () => {},
|
|
179
|
+
drawingKind: null
|
|
180
|
+
})
|
|
181
|
+
} : null, [
|
|
182
|
+
R,
|
|
183
|
+
O,
|
|
184
|
+
w,
|
|
185
|
+
A,
|
|
186
|
+
Q,
|
|
187
|
+
$,
|
|
188
|
+
U,
|
|
189
|
+
W
|
|
190
|
+
])), f ? /* @__PURE__ */ o(ee, {
|
|
191
|
+
title: "Motion Zones",
|
|
192
|
+
icon: /* @__PURE__ */ o(te, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
193
|
+
children: /* @__PURE__ */ o("div", {
|
|
194
|
+
className: "flex flex-col gap-3",
|
|
195
|
+
children: O ? /* @__PURE__ */ o("p", {
|
|
196
|
+
className: `${u} leading-relaxed`,
|
|
197
|
+
children: "This camera doesn't expose an on-board motion zones grid."
|
|
198
|
+
}) : !O && w !== null && A !== 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
|
+
w.grid.width,
|
|
219
|
+
"×",
|
|
220
|
+
w.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: () => z((e) => !e),
|
|
229
|
+
disabled: I,
|
|
230
|
+
"aria-pressed": R,
|
|
231
|
+
className: R ? b : y,
|
|
232
|
+
children: R ? "Done editing" : "Edit grid"
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ o("button", {
|
|
235
|
+
type: "button",
|
|
236
|
+
onClick: () => X(!0),
|
|
237
|
+
disabled: I,
|
|
238
|
+
className: y,
|
|
239
|
+
children: "All on"
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ o("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
onClick: () => X(!1),
|
|
244
|
+
disabled: I,
|
|
245
|
+
className: y,
|
|
246
|
+
children: "All off"
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ o("button", {
|
|
249
|
+
type: "button",
|
|
250
|
+
onClick: Z,
|
|
251
|
+
disabled: I,
|
|
252
|
+
className: y,
|
|
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
|
+
}), re.map((e) => /* @__PURE__ */ s("button", {
|
|
263
|
+
type: "button",
|
|
264
|
+
onClick: () => ae(e),
|
|
265
|
+
disabled: I,
|
|
266
|
+
"aria-pressed": P === e,
|
|
267
|
+
title: e === 1 ? `Camera grid ${V}×${H} (finest)` : `${C(V, e)}×${C(H, e)} painting grid · cells ×${e} bigger`,
|
|
268
|
+
className: P === e ? b : y,
|
|
269
|
+
children: ["×", e]
|
|
270
|
+
}, e))]
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ s("span", {
|
|
273
|
+
className: `${u} ml-1 tabular-nums`,
|
|
274
|
+
children: [
|
|
275
|
+
q,
|
|
276
|
+
" / ",
|
|
277
|
+
J,
|
|
278
|
+
" cells · ",
|
|
279
|
+
w.grid.width,
|
|
280
|
+
"×",
|
|
281
|
+
w.grid.height,
|
|
282
|
+
P === 1 ? "" : ` · paint ${U}×${W}`
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ o("span", { className: "flex-1" }),
|
|
286
|
+
/* @__PURE__ */ o("button", {
|
|
287
|
+
type: "button",
|
|
288
|
+
onClick: ie,
|
|
289
|
+
disabled: I || !K,
|
|
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: I || !K,
|
|
297
|
+
className: b,
|
|
298
|
+
children: I ? "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 { D as MotionZonesSettings };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { c as e, h as t, m as n, p as r, u as i, y as a } from "./_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react__loadShare__.js-DJDHChgO.mjs";
|
|
2
|
+
import { n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_model_studio_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-ds_Ehzaa.mjs";
|
|
3
|
+
import { a as l, l as u, n as ee, r as te, s as d, t as ne, u as re } from "./player-overlays-CeF0YjKF.mjs";
|
|
4
|
+
import { n as f, r as p, t as m } from "./trash-2-Ct7_ZXVk.mjs";
|
|
5
|
+
import { MaskShapeCanvas as h } from "./MaskShapeCanvas-C4g96eMz.mjs";
|
|
6
|
+
var g = d("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
|
+
a();
|
|
13
|
+
var _ = 120, v = "privacy-mask", y = "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", b = "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 x(e) {
|
|
15
|
+
return e.kind === "rect" || e.kind === "polygon" ? e : null;
|
|
16
|
+
}
|
|
17
|
+
function S(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 C(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 w({ deviceId: a }) {
|
|
28
|
+
let d = te(l().trpcClient, a), [w, T] = t(null), [E, D] = t(!1), [O, k] = t(null), [A, j] = t(null), [M, N] = t(!1), [P, F] = t(!1), [I, L] = t(null), [R, z] = t(null), B = n(!1);
|
|
29
|
+
i(() => {
|
|
30
|
+
if (!d) return;
|
|
31
|
+
let e = !1;
|
|
32
|
+
return B.current = !1, T(null), D(!1), k(null), j(null), F(!1), L(null), z(null), (async () => {
|
|
33
|
+
try {
|
|
34
|
+
let t = await d.privacyMask?.getOptions({});
|
|
35
|
+
if (e) return;
|
|
36
|
+
if (!t) throw Error("device proxy not ready");
|
|
37
|
+
if (T(t), B.current) return;
|
|
38
|
+
let n = await d.privacyMask?.getStatus({});
|
|
39
|
+
if (e) return;
|
|
40
|
+
if (!n) throw Error("device proxy not ready");
|
|
41
|
+
B.current = !0;
|
|
42
|
+
let r = {
|
|
43
|
+
enabled: n.enabled,
|
|
44
|
+
regions: n.regions
|
|
45
|
+
};
|
|
46
|
+
j(r), k(r);
|
|
47
|
+
} catch (t) {
|
|
48
|
+
if (e) return;
|
|
49
|
+
re(t) ? D(!0) : console.error("Privacy Mask load failed", t);
|
|
50
|
+
}
|
|
51
|
+
})(), () => {
|
|
52
|
+
e = !0;
|
|
53
|
+
};
|
|
54
|
+
}, [d]);
|
|
55
|
+
let V = r(() => O !== null && A !== null && (O.enabled !== A.enabled || !C(O.regions, A.regions)), [O, A]), H = O ? O.regions.length : 0, U = w ? w.maxRegions : 0, W = n(0);
|
|
56
|
+
i(() => {
|
|
57
|
+
W.current = U;
|
|
58
|
+
}, [U]);
|
|
59
|
+
let G = U > 0 && H >= U, K = e(() => {
|
|
60
|
+
k((e) => e && {
|
|
61
|
+
...e,
|
|
62
|
+
enabled: !e.enabled
|
|
63
|
+
});
|
|
64
|
+
}, []), q = e((e) => {
|
|
65
|
+
L(typeof e == "number" ? e : null);
|
|
66
|
+
}, []), J = r(() => O ? O.regions.map((e) => ({
|
|
67
|
+
id: e.id,
|
|
68
|
+
shape: e.shape,
|
|
69
|
+
enabled: e.enabled,
|
|
70
|
+
label: `Zone ${String(e.id)}`
|
|
71
|
+
})) : [], [O]), Y = e((e, t) => {
|
|
72
|
+
let n = x(t);
|
|
73
|
+
n && k((t) => t && {
|
|
74
|
+
...t,
|
|
75
|
+
regions: t.regions.map((t) => t.id === e ? {
|
|
76
|
+
...t,
|
|
77
|
+
shape: n
|
|
78
|
+
} : t)
|
|
79
|
+
});
|
|
80
|
+
}, []), X = e((e) => {
|
|
81
|
+
let t = x(e);
|
|
82
|
+
t && (z(null), k((e) => {
|
|
83
|
+
if (!e) return e;
|
|
84
|
+
let n = W.current;
|
|
85
|
+
if (n > 0 && e.regions.length >= n) return e;
|
|
86
|
+
let r = S(e.regions), i = {
|
|
87
|
+
id: r,
|
|
88
|
+
enabled: !0,
|
|
89
|
+
shape: t
|
|
90
|
+
};
|
|
91
|
+
return L(r), {
|
|
92
|
+
...e,
|
|
93
|
+
regions: [...e.regions, i]
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
}, []), Z = e((e) => {
|
|
97
|
+
F(!0), L(null), z(e);
|
|
98
|
+
}, []), ie = e((e) => {
|
|
99
|
+
F(!0), z(null), L(e);
|
|
100
|
+
}, []), ae = e((e) => {
|
|
101
|
+
L((t) => t === e ? null : t), k((t) => t && {
|
|
102
|
+
...t,
|
|
103
|
+
regions: t.regions.filter((t) => t.id !== e)
|
|
104
|
+
});
|
|
105
|
+
}, []), oe = e(() => {
|
|
106
|
+
z(null), L(null), A && k({
|
|
107
|
+
enabled: A.enabled,
|
|
108
|
+
regions: A.regions
|
|
109
|
+
});
|
|
110
|
+
}, [A]), se = e(async () => {
|
|
111
|
+
if (!(!d || !O)) {
|
|
112
|
+
N(!0);
|
|
113
|
+
try {
|
|
114
|
+
await d.privacyMask?.setMask({ patch: {
|
|
115
|
+
enabled: O.enabled,
|
|
116
|
+
regions: [...O.regions]
|
|
117
|
+
} });
|
|
118
|
+
let e = await d.privacyMask?.getStatus({});
|
|
119
|
+
if (e) {
|
|
120
|
+
let t = {
|
|
121
|
+
enabled: e.enabled,
|
|
122
|
+
regions: e.regions
|
|
123
|
+
};
|
|
124
|
+
j(t), k(t);
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error("Privacy Mask save failed", e);
|
|
128
|
+
} finally {
|
|
129
|
+
N(!1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, [d, O]), ce = e(() => {
|
|
133
|
+
F((e) => (e && (z(null), L(null)), !e));
|
|
134
|
+
}, []), Q = w?.supportedShapes ?? [];
|
|
135
|
+
ne(r(() => P && !E && w && O ? {
|
|
136
|
+
id: v,
|
|
137
|
+
order: _,
|
|
138
|
+
node: /* @__PURE__ */ o(h, {
|
|
139
|
+
transparent: !0,
|
|
140
|
+
items: J,
|
|
141
|
+
supportedShapes: Q,
|
|
142
|
+
polygonVertices: w.polygonVertices,
|
|
143
|
+
selectedId: I,
|
|
144
|
+
onSelect: q,
|
|
145
|
+
onShapeChange: Y,
|
|
146
|
+
onDrawComplete: X,
|
|
147
|
+
drawingKind: R
|
|
148
|
+
})
|
|
149
|
+
} : null, [
|
|
150
|
+
P,
|
|
151
|
+
E,
|
|
152
|
+
w,
|
|
153
|
+
O,
|
|
154
|
+
J,
|
|
155
|
+
Q,
|
|
156
|
+
I,
|
|
157
|
+
q,
|
|
158
|
+
Y,
|
|
159
|
+
X,
|
|
160
|
+
R
|
|
161
|
+
]));
|
|
162
|
+
let le = w?.supportedShapes.includes("rect") ?? !1, ue = w?.supportedShapes.includes("polygon") ?? !1, $ = w !== null && (w.maxRegions <= 0 || w.supportedShapes.length === 0);
|
|
163
|
+
return d ? /* @__PURE__ */ o(ee, {
|
|
164
|
+
title: "Privacy Mask",
|
|
165
|
+
icon: /* @__PURE__ */ o(p, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
166
|
+
children: /* @__PURE__ */ o("div", {
|
|
167
|
+
className: "flex flex-col gap-3",
|
|
168
|
+
children: E || $ ? /* @__PURE__ */ o("p", {
|
|
169
|
+
className: `${u} leading-relaxed`,
|
|
170
|
+
children: "This camera doesn't support an on-board privacy mask."
|
|
171
|
+
}) : !E && !$ && w !== null && O !== null ? /* @__PURE__ */ s(c, { children: [
|
|
172
|
+
/* @__PURE__ */ s("p", {
|
|
173
|
+
className: `${u} 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: M,
|
|
195
|
+
"aria-pressed": P,
|
|
196
|
+
className: P ? b : y,
|
|
197
|
+
children: P ? "Done editing" : "Edit mask"
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ o("button", {
|
|
200
|
+
type: "button",
|
|
201
|
+
onClick: K,
|
|
202
|
+
disabled: M,
|
|
203
|
+
"aria-pressed": O.enabled,
|
|
204
|
+
className: O.enabled ? b : y,
|
|
205
|
+
children: O.enabled ? "Mask on" : "Mask off"
|
|
206
|
+
}),
|
|
207
|
+
le && /* @__PURE__ */ o("button", {
|
|
208
|
+
type: "button",
|
|
209
|
+
onClick: () => Z("rect"),
|
|
210
|
+
disabled: M || G,
|
|
211
|
+
"aria-pressed": R === "rect",
|
|
212
|
+
className: R === "rect" ? b : y,
|
|
213
|
+
title: G ? "Maximum zones reached" : "Add a rectangle zone",
|
|
214
|
+
children: "+ Rect"
|
|
215
|
+
}),
|
|
216
|
+
ue && /* @__PURE__ */ o("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: () => Z("polygon"),
|
|
219
|
+
disabled: M || G,
|
|
220
|
+
"aria-pressed": R === "polygon",
|
|
221
|
+
className: R === "polygon" ? b : y,
|
|
222
|
+
title: G ? "Maximum zones reached" : "Add a polygon zone",
|
|
223
|
+
children: "+ Polygon"
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ s("span", {
|
|
226
|
+
className: `${u} ml-1 tabular-nums`,
|
|
227
|
+
children: [
|
|
228
|
+
H,
|
|
229
|
+
" / ",
|
|
230
|
+
U,
|
|
231
|
+
" zones"
|
|
232
|
+
]
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ o("span", { className: "flex-1" }),
|
|
235
|
+
/* @__PURE__ */ o("button", {
|
|
236
|
+
type: "button",
|
|
237
|
+
onClick: oe,
|
|
238
|
+
disabled: M || !V,
|
|
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: M || !V,
|
|
246
|
+
className: b,
|
|
247
|
+
children: M ? "Saving…" : "Save"
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
}),
|
|
251
|
+
H > 0 ? /* @__PURE__ */ o("div", {
|
|
252
|
+
className: "flex flex-col gap-1",
|
|
253
|
+
children: O.regions.map((e) => {
|
|
254
|
+
let t = I === e.id, n = e.shape.kind === "polygon" ? g : f;
|
|
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: () => ie(e.id),
|
|
260
|
+
disabled: M,
|
|
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: () => ae(e.id),
|
|
273
|
+
disabled: M,
|
|
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(m, { className: "h-3.5 w-3.5" })
|
|
278
|
+
})]
|
|
279
|
+
}, e.id);
|
|
280
|
+
})
|
|
281
|
+
}) : null
|
|
282
|
+
] }) : /* @__PURE__ */ o("p", {
|
|
283
|
+
className: `${u} leading-relaxed`,
|
|
284
|
+
children: "Loading the camera's privacy mask…"
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
}) : null;
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
export { w as PrivacyMaskSettings };
|