@camstack/addon-training 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/assets/training/icon.svg +5 -0
  2. package/assets/training-modal/icon.svg +4 -0
  3. package/dist/MaskShapeCanvas-BokARvOj.mjs +13806 -0
  4. package/dist/MotionZonesSettings-aj085Nrn.mjs +310 -0
  5. package/dist/PrivacyMaskSettings-BwYjIkQR.mjs +377 -0
  6. package/dist/SceneMonitorEditor-BBfow3Lm.mjs +831 -0
  7. package/dist/_stub.js +17613 -0
  8. package/dist/_virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-CspLU0I2.mjs +156 -0
  9. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.js-ZeT4eUYy.mjs +25 -0
  10. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BkKuzhOJ.mjs +26 -0
  11. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CaB1jnkt.mjs +25 -0
  12. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-B3rryujf.mjs +25 -0
  13. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-nL4MGFRP.mjs +26 -0
  14. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare__react__loadShare__.js-BT_wL8s3.mjs +70 -0
  15. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DDBEvLdo.mjs +26 -0
  16. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare__react_mf_2_dom__loadShare__.js-i_pnGDxd.mjs +25 -0
  17. package/dist/_virtual_mf___mfe_internal__addon_training_page__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-gTIQrhKs.mjs +25 -0
  18. package/dist/addon-training.css +3 -0
  19. package/dist/dist-BnT7Wsvm.mjs +52556 -0
  20. package/dist/dist-WGwGDX6_.js +52708 -0
  21. package/dist/hostInit-Dl0wFDad.mjs +129 -0
  22. package/dist/index.js +205 -0
  23. package/dist/index.mjs +201 -0
  24. package/dist/orchestrator/training.addon.js +1712 -0
  25. package/dist/orchestrator/training.addon.mjs +1710 -0
  26. package/dist/player-overlays-wE5IcDiI.mjs +44 -0
  27. package/dist/providers/modal/training-modal.addon.js +88499 -0
  28. package/dist/providers/modal/training-modal.addon.mjs +88527 -0
  29. package/dist/remoteEntry.js +2 -0
  30. package/dist/remoteEntry.ssr.js +33 -0
  31. package/dist/responsive-D17kMsm1.mjs +122 -0
  32. package/dist/rolldown-runtime-HEgqtunE.mjs +20 -0
  33. package/dist/scene-monitor-copy-LjlvhSRM.mjs +187 -0
  34. package/dist/square-JGDHhLlY.mjs +45 -0
  35. package/dist/trash-2-zeFnLJvf.mjs +25 -0
  36. package/dist/virtualExposes-0m8NqEDE.mjs +27 -0
  37. package/dist/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-iFB6fGI7.mjs +2857 -0
  38. package/dist/virtual_mf-exposes-ssr___mfe_internal__addon_training_page__remoteEntry_js-BbeHzLhl.mjs +10 -0
  39. package/package.json +116 -4
  40. package/README.md +0 -3
@@ -0,0 +1,310 @@
1
+ import { b as e, c as t, g as n, h as r, m as i, u as a } from "./_virtual_mf___mfe_internal__addon_training_page__loadShare__react__loadShare__.js-BT_wL8s3.mjs";
2
+ import { a as o, n as s, r as c, s as l, t as u } from "./responsive-D17kMsm1.mjs";
3
+ import { n as d, t as f } from "./player-overlays-wE5IcDiI.mjs";
4
+ import { n as p, r as m, t as ee } from "./_virtual_mf___mfe_internal__addon_training_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DDBEvLdo.mjs";
5
+ import { MaskShapeCanvas as h } from "./MaskShapeCanvas-BokARvOj.mjs";
6
+ var g = l("grid-2x2", [
7
+ ["path", {
8
+ d: "M12 3v18",
9
+ key: "108xh3"
10
+ }],
11
+ ["path", {
12
+ d: "M3 12h18",
13
+ key: "1i2n21"
14
+ }],
15
+ ["rect", {
16
+ x: "3",
17
+ y: "3",
18
+ width: "18",
19
+ height: "18",
20
+ rx: "2",
21
+ key: "h1oib"
22
+ }]
23
+ ]);
24
+ //#endregion
25
+ //#region ../ui-library/src/composites/cap-settings/MotionZonesSettings.tsx
26
+ e();
27
+ var te = 110, _ = "motion-zones", v = 0, ne = [
28
+ 1,
29
+ 2,
30
+ 3
31
+ ], y = 1, b = "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", x = "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";
32
+ function S(e, t, n) {
33
+ let r = t * n, i = Array.from({ length: r });
34
+ for (let t = 0; t < r; t += 1) i[t] = e[t] === !0;
35
+ return i;
36
+ }
37
+ function re(e, t) {
38
+ if (e.length !== t.length) return !1;
39
+ for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
40
+ return !0;
41
+ }
42
+ function C(e, t) {
43
+ return Math.ceil(e / t);
44
+ }
45
+ function w(e, t, n) {
46
+ return Math.min(n - 1, Math.floor((e + .5) / t * n));
47
+ }
48
+ function T(e, t, n, r) {
49
+ let i = C(t, r), a = C(n, r), o = Array.from({ length: i * a }, () => !1);
50
+ for (let r = 0; r < n; r += 1) {
51
+ let s = w(r, n, a);
52
+ for (let n = 0; n < t; n += 1) e[r * t + n] === !0 && (o[s * i + w(n, t, i)] = !0);
53
+ }
54
+ return o;
55
+ }
56
+ function E(e, t, n, r) {
57
+ let i = C(t, r), a = C(n, r), o = Array.from({ length: t * n }, () => !1);
58
+ for (let r = 0; r < n; r += 1) {
59
+ let s = w(r, n, a);
60
+ for (let n = 0; n < t; n += 1) o[r * t + n] = e[s * i + w(n, t, i)] === !0;
61
+ }
62
+ return o;
63
+ }
64
+ function D({ deviceId: e }) {
65
+ let l = c(o().trpcClient, e), [w, D] = n(null), [O, k] = n(!1), [A, j] = n(null), [M, N] = n(null), [P, F] = n(y), [I, L] = n(!1), [R, z] = n(!1), B = r(!1);
66
+ a(() => {
67
+ if (!l) return;
68
+ let e = !1;
69
+ return B.current = !1, D(null), k(!1), j(null), N(null), F(y), z(!1), (async () => {
70
+ try {
71
+ let t = await l.motionZones?.getOptions({});
72
+ if (e) return;
73
+ if (!t) throw Error("device proxy not ready");
74
+ if (D(t), B.current) return;
75
+ let n = await l.motionZones?.getStatus({});
76
+ if (e) return;
77
+ if (!n) throw Error("device proxy not ready");
78
+ B.current = !0;
79
+ let r = n.regions.find((e) => e.shape.kind === "grid"), i = S(r ? r.shape.cells : [], t.grid.width, t.grid.height);
80
+ N(i), j(T(i, t.grid.width, t.grid.height, y));
81
+ } catch (t) {
82
+ if (e) return;
83
+ s(t) ? k(!0) : console.error("Motion Zones load failed", t);
84
+ }
85
+ })(), () => {
86
+ e = !0;
87
+ };
88
+ }, [l]);
89
+ let V = w ? w.grid.width : 0, H = w ? w.grid.height : 0, U = C(V, P), W = C(H, P), G = i(() => A && w ? E(A, V, H, P) : null, [
90
+ A,
91
+ w,
92
+ V,
93
+ H,
94
+ P
95
+ ]), K = i(() => G !== null && M !== null && !re(G, M), [G, M]), q = i(() => G ? G.reduce((e, t) => t ? e + 1 : e, 0) : 0, [G]), J = V * H, Y = U * W, X = t((e) => {
96
+ Y > 0 && j(Array.from({ length: Y }, () => e));
97
+ }, [Y]), ie = t(() => {
98
+ j((e) => e && e.map((e) => !e));
99
+ }, []), Z = t(() => {
100
+ M && w && j(T(M, V, H, P));
101
+ }, [
102
+ M,
103
+ w,
104
+ V,
105
+ H,
106
+ P
107
+ ]), ae = t((e) => {
108
+ e === P || !w || j((t) => {
109
+ if (!t) return F(e), t;
110
+ let n = T(E(t, V, H, P), V, H, e);
111
+ return F(e), n;
112
+ });
113
+ }, [
114
+ P,
115
+ w,
116
+ V,
117
+ H
118
+ ]), Q = i(() => w && A ? [{
119
+ id: v,
120
+ shape: {
121
+ kind: "grid",
122
+ gridWidth: U,
123
+ gridHeight: W,
124
+ cells: [...A]
125
+ }
126
+ }] : [], [
127
+ w,
128
+ A,
129
+ U,
130
+ W
131
+ ]), $ = t((e, t) => {
132
+ t.kind === "grid" && j(t.cells);
133
+ }, []), oe = t(async () => {
134
+ if (!(!l || !A || !w)) {
135
+ L(!0);
136
+ try {
137
+ let e = E(A, w.grid.width, w.grid.height, P), t = {
138
+ kind: "grid",
139
+ gridWidth: w.grid.width,
140
+ gridHeight: w.grid.height,
141
+ cells: e
142
+ };
143
+ await l.motionZones?.setZone({ patch: { regions: [{
144
+ id: v,
145
+ enabled: !0,
146
+ shape: t
147
+ }] } });
148
+ let n = await l.motionZones?.getStatus({});
149
+ if (n) {
150
+ let e = n.regions.find((e) => e.shape.kind === "grid"), t = S(e ? e.shape.cells : [], w.grid.width, w.grid.height);
151
+ N(t), j(T(t, w.grid.width, w.grid.height, P));
152
+ }
153
+ } catch (e) {
154
+ console.error("Motion Zones save failed", e);
155
+ } finally {
156
+ L(!1);
157
+ }
158
+ }
159
+ }, [
160
+ l,
161
+ A,
162
+ w,
163
+ P
164
+ ]);
165
+ return f(i(() => R && !O && w && A ? {
166
+ id: _,
167
+ order: te,
168
+ node: /* @__PURE__ */ p(h, {
169
+ transparent: !0,
170
+ items: Q,
171
+ supportedShapes: ["grid"],
172
+ grid: {
173
+ width: U,
174
+ height: W
175
+ },
176
+ selectedId: v,
177
+ onSelect: () => {},
178
+ onShapeChange: $,
179
+ onDrawComplete: () => {},
180
+ drawingKind: null
181
+ })
182
+ } : null, [
183
+ R,
184
+ O,
185
+ w,
186
+ A,
187
+ Q,
188
+ $,
189
+ U,
190
+ W
191
+ ])), l ? /* @__PURE__ */ p(d, {
192
+ title: "Motion Zones",
193
+ icon: /* @__PURE__ */ p(g, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
194
+ children: /* @__PURE__ */ p("div", {
195
+ className: "flex flex-col gap-3",
196
+ children: O ? /* @__PURE__ */ p("p", {
197
+ className: `${u} leading-relaxed`,
198
+ children: "This camera doesn't expose an on-board motion zones grid."
199
+ }) : !O && w !== null && A !== null ? /* @__PURE__ */ m(ee, { children: [/* @__PURE__ */ m("p", {
200
+ className: `${u} leading-relaxed`,
201
+ children: [
202
+ "Toggle ",
203
+ /* @__PURE__ */ p("strong", {
204
+ className: "text-foreground",
205
+ children: "Edit grid"
206
+ }),
207
+ " to paint the region directly on the live frame, then ",
208
+ /* @__PURE__ */ p("strong", {
209
+ className: "text-foreground",
210
+ children: "Save"
211
+ }),
212
+ " to push the mask to the camera. Pick a bigger",
213
+ " ",
214
+ /* @__PURE__ */ p("strong", {
215
+ className: "text-foreground",
216
+ children: "Cell size"
217
+ }),
218
+ " for quicker, broad-stroke painting — it's resampled to the camera's native ",
219
+ w.grid.width,
220
+ "×",
221
+ w.grid.height,
222
+ " grid on save (×1 is the finest)."
223
+ ]
224
+ }), /* @__PURE__ */ m("div", {
225
+ className: "flex items-center gap-2 flex-wrap",
226
+ children: [
227
+ /* @__PURE__ */ p("button", {
228
+ type: "button",
229
+ onClick: () => z((e) => !e),
230
+ disabled: I,
231
+ "aria-pressed": R,
232
+ className: R ? x : b,
233
+ children: R ? "Done editing" : "Edit grid"
234
+ }),
235
+ /* @__PURE__ */ p("button", {
236
+ type: "button",
237
+ onClick: () => X(!0),
238
+ disabled: I,
239
+ className: b,
240
+ children: "All on"
241
+ }),
242
+ /* @__PURE__ */ p("button", {
243
+ type: "button",
244
+ onClick: () => X(!1),
245
+ disabled: I,
246
+ className: b,
247
+ children: "All off"
248
+ }),
249
+ /* @__PURE__ */ p("button", {
250
+ type: "button",
251
+ onClick: ie,
252
+ disabled: I,
253
+ className: b,
254
+ children: "Invert"
255
+ }),
256
+ /* @__PURE__ */ m("div", {
257
+ className: "flex items-center gap-1 ml-1",
258
+ role: "group",
259
+ "aria-label": "Cell size",
260
+ children: [/* @__PURE__ */ p("span", {
261
+ className: `${u} mr-0.5`,
262
+ children: "Cell size"
263
+ }), ne.map((e) => /* @__PURE__ */ m("button", {
264
+ type: "button",
265
+ onClick: () => ae(e),
266
+ disabled: I,
267
+ "aria-pressed": P === e,
268
+ title: e === 1 ? `Camera grid ${V}×${H} (finest)` : `${C(V, e)}×${C(H, e)} painting grid · cells ×${e} bigger`,
269
+ className: P === e ? x : b,
270
+ children: ["×", e]
271
+ }, e))]
272
+ }),
273
+ /* @__PURE__ */ m("span", {
274
+ className: `${u} ml-1 tabular-nums`,
275
+ children: [
276
+ q,
277
+ " / ",
278
+ J,
279
+ " cells · ",
280
+ w.grid.width,
281
+ "×",
282
+ w.grid.height,
283
+ P === 1 ? "" : ` · paint ${U}×${W}`
284
+ ]
285
+ }),
286
+ /* @__PURE__ */ p("span", { className: "flex-1" }),
287
+ /* @__PURE__ */ p("button", {
288
+ type: "button",
289
+ onClick: Z,
290
+ disabled: I || !K,
291
+ 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",
292
+ children: "Revert"
293
+ }),
294
+ /* @__PURE__ */ p("button", {
295
+ type: "button",
296
+ onClick: () => void oe(),
297
+ disabled: I || !K,
298
+ className: x,
299
+ children: I ? "Saving…" : "Save"
300
+ })
301
+ ]
302
+ })] }) : /* @__PURE__ */ p("p", {
303
+ className: `${u} leading-relaxed`,
304
+ children: "Loading the camera's grid…"
305
+ })
306
+ })
307
+ }) : null;
308
+ }
309
+ //#endregion
310
+ export { D as MotionZonesSettings };
@@ -0,0 +1,377 @@
1
+ import { b as e, c as t, g as n, h as r, m as i, u as a } from "./_virtual_mf___mfe_internal__addon_training_page__loadShare__react__loadShare__.js-BT_wL8s3.mjs";
2
+ import { a as ee, n as te, r as ne, s as o, t as s } from "./responsive-D17kMsm1.mjs";
3
+ import { n as re, t as ie } from "./player-overlays-wE5IcDiI.mjs";
4
+ import { n as ae, r as oe, t as se } from "./square-JGDHhLlY.mjs";
5
+ import { t as c } from "./trash-2-zeFnLJvf.mjs";
6
+ import { n as l, r as u, t as ce } from "./_virtual_mf___mfe_internal__addon_training_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DDBEvLdo.mjs";
7
+ import { MaskShapeCanvas as le } from "./MaskShapeCanvas-BokARvOj.mjs";
8
+ var ue = o("hexagon", [["path", {
9
+ 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",
10
+ key: "yt0hxn"
11
+ }]]), de = o("mic-off", [
12
+ ["path", {
13
+ d: "M12 19v3",
14
+ key: "npa21l"
15
+ }],
16
+ ["path", {
17
+ d: "M15 9.34V5a3 3 0 0 0-5.68-1.33",
18
+ key: "1gzdoj"
19
+ }],
20
+ ["path", {
21
+ d: "M16.95 16.95A7 7 0 0 1 5 12v-2",
22
+ key: "cqa7eg"
23
+ }],
24
+ ["path", {
25
+ d: "M18.89 13.23A7 7 0 0 0 19 12v-2",
26
+ key: "16hl24"
27
+ }],
28
+ ["path", {
29
+ d: "m2 2 20 20",
30
+ key: "1ooewy"
31
+ }],
32
+ ["path", {
33
+ d: "M9 9v3a3 3 0 0 0 5.12 2.12",
34
+ key: "r2i35w"
35
+ }]
36
+ ]);
37
+ //#endregion
38
+ //#region ../ui-library/src/composites/cap-settings/privacy-mask-audio.ts
39
+ e();
40
+ var d = "Microphone", f = "The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.";
41
+ function p(e) {
42
+ let t = e.supportsAudioMute === !0, n = t ? e.audioEnabled : null, r = e.pendingOn ?? null;
43
+ return {
44
+ label: d,
45
+ supported: t,
46
+ on: n === null ? null : r ?? n,
47
+ available: t && n !== null,
48
+ costWhenOff: f
49
+ };
50
+ }
51
+ function m(e) {
52
+ return !e.available || e.on === null ? null : { enabled: !e.on };
53
+ }
54
+ //#endregion
55
+ //#region ../ui-library/src/composites/cap-settings/PrivacyMaskSettings.tsx
56
+ var fe = 120, pe = "privacy-mask", h = "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", g = "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";
57
+ function _(e) {
58
+ return e.kind === "rect" || e.kind === "polygon" ? e : null;
59
+ }
60
+ function me(e) {
61
+ let t = new Set(e.map((e) => e.id)), n = 0;
62
+ for (; t.has(n);) n += 1;
63
+ return n;
64
+ }
65
+ function he(e, t) {
66
+ if (e.length !== t.length) return !1;
67
+ for (let n = 0; n < e.length; n += 1) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
68
+ return !0;
69
+ }
70
+ function v({ deviceId: e }) {
71
+ let o = ne(ee().trpcClient, e), [d, f] = n(null), [v, y] = n(!1), [b, x] = n(!1), [S, C] = n(null), [w, T] = n(null), [E, D] = n(!1), [O, k] = n(!1), [A, j] = n(null), [M, N] = n(null), [ge, P] = n(null), [F, I] = n(null), [L, R] = n(null), z = r(!1);
72
+ a(() => {
73
+ if (!o) return;
74
+ let e = !1;
75
+ return z.current = !1, f(null), y(!1), x(!1), C(null), T(null), k(!1), j(null), N(null), P(null), I(null), R(null), (async () => {
76
+ try {
77
+ let t = await o.privacyMask?.getOptions({});
78
+ if (e) return;
79
+ if (!t) throw Error("device proxy not ready");
80
+ if (f(t), z.current) return;
81
+ let n = await o.privacyMask?.getStatus({});
82
+ if (e) return;
83
+ if (!n) throw Error("device proxy not ready");
84
+ if (n.regions === null) {
85
+ x(!0), P(n.audioEnabled);
86
+ return;
87
+ }
88
+ z.current = !0;
89
+ let r = {
90
+ enabled: n.enabled,
91
+ regions: n.regions
92
+ };
93
+ T(r), C(r), P(n.audioEnabled);
94
+ } catch (t) {
95
+ if (e) return;
96
+ te(t) ? y(!0) : console.error("Privacy Mask load failed", t);
97
+ }
98
+ })(), () => {
99
+ e = !0;
100
+ };
101
+ }, [o]);
102
+ let B = i(() => S !== null && w !== null && (S.enabled !== w.enabled || !he(S.regions, w.regions)), [S, w]), V = S ? S.regions.length : 0, H = d ? d.maxRegions : 0, U = r(0);
103
+ a(() => {
104
+ U.current = H;
105
+ }, [H]);
106
+ let W = H > 0 && V >= H, _e = t(() => {
107
+ C((e) => e && {
108
+ ...e,
109
+ enabled: !e.enabled
110
+ });
111
+ }, []), G = t((e) => {
112
+ j(typeof e == "number" ? e : null);
113
+ }, []), K = i(() => S ? S.regions.map((e) => ({
114
+ id: e.id,
115
+ shape: e.shape,
116
+ enabled: e.enabled,
117
+ label: `Zone ${String(e.id)}`
118
+ })) : [], [S]), q = t((e, t) => {
119
+ let n = _(t);
120
+ n && C((t) => t && {
121
+ ...t,
122
+ regions: t.regions.map((t) => t.id === e ? {
123
+ ...t,
124
+ shape: n
125
+ } : t)
126
+ });
127
+ }, []), J = t((e) => {
128
+ let t = _(e);
129
+ t && (N(null), C((e) => {
130
+ if (!e) return e;
131
+ let n = U.current;
132
+ if (n > 0 && e.regions.length >= n) return e;
133
+ let r = me(e.regions), i = {
134
+ id: r,
135
+ enabled: !0,
136
+ shape: t
137
+ };
138
+ return j(r), {
139
+ ...e,
140
+ regions: [...e.regions, i]
141
+ };
142
+ }));
143
+ }, []), Y = t((e) => {
144
+ k(!0), j(null), N(e);
145
+ }, []), ve = t((e) => {
146
+ k(!0), N(null), j(e);
147
+ }, []), X = t((e) => {
148
+ j((t) => t === e ? null : t), C((t) => t && {
149
+ ...t,
150
+ regions: t.regions.filter((t) => t.id !== e)
151
+ });
152
+ }, []), ye = t(() => {
153
+ N(null), j(null), w && C({
154
+ enabled: w.enabled,
155
+ regions: w.regions
156
+ });
157
+ }, [w]), be = t(async () => {
158
+ if (!(!o || !S)) {
159
+ D(!0);
160
+ try {
161
+ await o.privacyMask?.setMask({ patch: {
162
+ enabled: S.enabled,
163
+ regions: [...S.regions]
164
+ } });
165
+ let e = await o.privacyMask?.getStatus({});
166
+ if (e && e.regions !== null) {
167
+ let t = {
168
+ enabled: e.enabled,
169
+ regions: e.regions
170
+ };
171
+ T(t), C(t);
172
+ }
173
+ } catch (e) {
174
+ console.error("Privacy Mask save failed", e);
175
+ } finally {
176
+ D(!1);
177
+ }
178
+ }
179
+ }, [o, S]), Z = p({
180
+ supportsAudioMute: d === null ? null : d.supportsAudioMute,
181
+ audioEnabled: ge,
182
+ pendingOn: F
183
+ }), xe = t(async () => {
184
+ let e = m(Z);
185
+ if (!(!o || e === null)) {
186
+ I(e.enabled), R(null);
187
+ try {
188
+ await o.privacyMask?.setAudioEnabled(e);
189
+ let t = await o.privacyMask?.getStatus({});
190
+ t && P(t.audioEnabled);
191
+ } catch (e) {
192
+ console.error("Privacy microphone write failed — reverting", e), R(e instanceof Error ? e.message : String(e));
193
+ } finally {
194
+ I(null);
195
+ }
196
+ }
197
+ }, [o, Z]), Se = t(() => {
198
+ k((e) => (e && (N(null), j(null)), !e));
199
+ }, []), Q = d?.supportedShapes ?? [];
200
+ ie(i(() => O && !v && d && S ? {
201
+ id: pe,
202
+ order: fe,
203
+ node: /* @__PURE__ */ l(le, {
204
+ transparent: !0,
205
+ items: K,
206
+ supportedShapes: Q,
207
+ polygonVertices: d.polygonVertices,
208
+ selectedId: A,
209
+ onSelect: G,
210
+ onShapeChange: q,
211
+ onDrawComplete: J,
212
+ drawingKind: M
213
+ })
214
+ } : null, [
215
+ O,
216
+ v,
217
+ d,
218
+ S,
219
+ K,
220
+ Q,
221
+ A,
222
+ G,
223
+ q,
224
+ J,
225
+ M
226
+ ]));
227
+ let Ce = d?.supportedShapes.includes("rect") ?? !1, we = d?.supportedShapes.includes("polygon") ?? !1, $ = d !== null && (d.maxRegions <= 0 || d.supportedShapes.length === 0);
228
+ return o ? /* @__PURE__ */ l(re, {
229
+ title: "Privacy Mask",
230
+ icon: /* @__PURE__ */ l(oe, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
231
+ children: /* @__PURE__ */ u("div", {
232
+ className: "flex flex-col gap-3",
233
+ children: [v || $ ? /* @__PURE__ */ l("p", {
234
+ className: `${s} leading-relaxed`,
235
+ children: "This camera doesn't support an on-board privacy mask."
236
+ }) : b ? /* @__PURE__ */ l("p", {
237
+ className: `${s} leading-relaxed`,
238
+ children: "This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable."
239
+ }) : !v && !$ && !b && d !== null && S !== null ? /* @__PURE__ */ u(ce, { children: [
240
+ /* @__PURE__ */ u("p", {
241
+ className: `${s} leading-relaxed`,
242
+ children: [
243
+ "Toggle ",
244
+ /* @__PURE__ */ l("strong", {
245
+ className: "text-foreground",
246
+ children: "Edit mask"
247
+ }),
248
+ " to draw blanked-out zones on the live frame, then ",
249
+ /* @__PURE__ */ l("strong", {
250
+ className: "text-foreground",
251
+ children: "Save"
252
+ }),
253
+ " 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."
254
+ ]
255
+ }),
256
+ /* @__PURE__ */ u("div", {
257
+ className: "flex items-center gap-2 flex-wrap",
258
+ children: [
259
+ /* @__PURE__ */ l("button", {
260
+ type: "button",
261
+ onClick: Se,
262
+ disabled: E,
263
+ "aria-pressed": O,
264
+ className: O ? g : h,
265
+ children: O ? "Done editing" : "Edit mask"
266
+ }),
267
+ /* @__PURE__ */ l("button", {
268
+ type: "button",
269
+ onClick: _e,
270
+ disabled: E,
271
+ "aria-pressed": S.enabled,
272
+ className: S.enabled ? g : h,
273
+ children: S.enabled ? "Mask on" : "Mask off"
274
+ }),
275
+ Ce && /* @__PURE__ */ l("button", {
276
+ type: "button",
277
+ onClick: () => Y("rect"),
278
+ disabled: E || W,
279
+ "aria-pressed": M === "rect",
280
+ className: M === "rect" ? g : h,
281
+ title: W ? "Maximum zones reached" : "Add a rectangle zone",
282
+ children: "+ Rect"
283
+ }),
284
+ we && /* @__PURE__ */ l("button", {
285
+ type: "button",
286
+ onClick: () => Y("polygon"),
287
+ disabled: E || W,
288
+ "aria-pressed": M === "polygon",
289
+ className: M === "polygon" ? g : h,
290
+ title: W ? "Maximum zones reached" : "Add a polygon zone",
291
+ children: "+ Polygon"
292
+ }),
293
+ /* @__PURE__ */ u("span", {
294
+ className: `${s} ml-1 tabular-nums`,
295
+ children: [
296
+ V,
297
+ " / ",
298
+ H,
299
+ " zones"
300
+ ]
301
+ }),
302
+ /* @__PURE__ */ l("span", { className: "flex-1" }),
303
+ /* @__PURE__ */ l("button", {
304
+ type: "button",
305
+ onClick: ye,
306
+ disabled: E || !B,
307
+ 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",
308
+ children: "Revert"
309
+ }),
310
+ /* @__PURE__ */ l("button", {
311
+ type: "button",
312
+ onClick: () => void be(),
313
+ disabled: E || !B,
314
+ className: g,
315
+ children: E ? "Saving…" : "Save"
316
+ })
317
+ ]
318
+ }),
319
+ V > 0 ? /* @__PURE__ */ l("div", {
320
+ className: "flex flex-col gap-1",
321
+ children: S.regions.map((e) => {
322
+ let t = A === e.id, n = e.shape.kind === "polygon" ? ue : se;
323
+ return /* @__PURE__ */ u("div", {
324
+ 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"}`,
325
+ children: [/* @__PURE__ */ u("button", {
326
+ type: "button",
327
+ onClick: () => ve(e.id),
328
+ disabled: E,
329
+ 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",
330
+ children: [
331
+ /* @__PURE__ */ l(n, { className: "h-3.5 w-3.5 shrink-0" }),
332
+ /* @__PURE__ */ u("span", { children: ["Zone ", e.id] }),
333
+ /* @__PURE__ */ l("span", {
334
+ className: "text-foreground-faint capitalize",
335
+ children: e.shape.kind
336
+ })
337
+ ]
338
+ }), /* @__PURE__ */ l("button", {
339
+ type: "button",
340
+ onClick: () => X(e.id),
341
+ disabled: E,
342
+ "aria-label": `Delete zone ${String(e.id)}`,
343
+ title: "Delete zone",
344
+ 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",
345
+ children: /* @__PURE__ */ l(c, { className: "h-3.5 w-3.5" })
346
+ })]
347
+ }, e.id);
348
+ })
349
+ }) : null
350
+ ] }) : /* @__PURE__ */ l("p", {
351
+ className: `${s} leading-relaxed`,
352
+ children: "Loading the camera's privacy mask…"
353
+ }), Z.supported && /* @__PURE__ */ u("div", {
354
+ className: "flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2",
355
+ children: [/* @__PURE__ */ l("button", {
356
+ type: "button",
357
+ role: "switch",
358
+ "aria-label": Z.label,
359
+ "aria-checked": Z.on === !0,
360
+ disabled: !Z.available || F !== null,
361
+ onClick: () => void xe(),
362
+ title: Z.on === null ? "Microphone — state unknown; the camera did not answer." : Z.on ? `The camera is capturing sound. Turning it off: ${Z.costWhenOff}` : `The camera is silent. ${Z.costWhenOff}`,
363
+ className: Z.on === !1 || Z.on === null ? h : g,
364
+ children: /* @__PURE__ */ u("span", {
365
+ className: "inline-flex items-center gap-1.5",
366
+ children: [Z.on === !1 ? /* @__PURE__ */ l(de, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ l(ae, { className: "h-3.5 w-3.5" }), Z.on === null ? "Microphone unknown" : Z.on ? "Microphone on" : "Microphone off"]
367
+ })
368
+ }), /* @__PURE__ */ l("p", {
369
+ className: "text-[10px] text-foreground-subtle flex-1 leading-relaxed",
370
+ children: L === null ? Z.on === null ? "The camera did not report its microphone, so this state is unknown." : Z.costWhenOff : `Write failed: ${L}`
371
+ })]
372
+ })]
373
+ })
374
+ }) : null;
375
+ }
376
+ //#endregion
377
+ export { v as PrivacyMaskSettings };