@camstack/addon-agent-ui 1.2.348 → 1.2.349
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/CHANGELOG.md +6 -0
- package/dist/.bundle-modules.json +5 -5
- package/dist/addon.js +172 -48
- package/dist/assets/{MotionZonesSettings-D6F-7fqL.js → MotionZonesSettings-quRpYBiU.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DRztH0Rg.js → PrivacyMaskSettings-Cq9IU0qs.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CSSqIrdX.js → SceneMonitorEditor-Coy4dm3w.js} +1 -1
- package/dist/assets/{index-CBKk36pu.js → index-Bngw8_Yl.js} +16 -16
- package/dist/index.html +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -368,13 +368,13 @@
|
|
|
368
368
|
"server/server/packages/addon-agent-ui/src/use-pairing-status.ts": "46193a1e83a64250dfff75d417448d74ba0159465e710861b996e903b03e427a",
|
|
369
369
|
"server/server/packages/sdk/dist/index.js": "89409bfb9632c46ed63ee4882c70b7994c1ff90c67d27a5d4b86b0990c41a131",
|
|
370
370
|
"server/server/packages/types/dist/client.mjs": "2b0d99cac9848d23d5c34ab56fff1eefda7ba00945c0fb6b86dd168405a21a91",
|
|
371
|
-
"server/server/packages/types/dist/composition-
|
|
371
|
+
"server/server/packages/types/dist/composition-CXCX78IR.mjs": "3c34431544a6b88404f5f7c855c84ebbf2e5736ad300d4d4dfa2417759f30d46",
|
|
372
372
|
"server/server/packages/types/dist/convert-BAzH15HU.mjs": "baa969d99051a3b05b2620e8b8e776a6f5539ac74ee9f9dbee1cc6b6a3a892a0",
|
|
373
|
-
"server/server/packages/types/dist/device-type-
|
|
373
|
+
"server/server/packages/types/dist/device-type-CbDhVwFP.mjs": "94089ac4e225fbd1a8109ff7d5db680acff824c0745d60a1ccf52b4e2717451d",
|
|
374
374
|
"server/server/packages/types/dist/event-category-78tcBemo.mjs": "767f1bb576027d9ee79ec036367001330203d84842c2c2111fa465fa434045e2",
|
|
375
|
-
"server/server/packages/types/dist/index.mjs": "
|
|
375
|
+
"server/server/packages/types/dist/index.mjs": "b2b587eb81d6aa49b93f08908766fa76d6516b23c0110a5b6ba55f33956611d7",
|
|
376
376
|
"server/server/packages/types/dist/node-color.mjs": "942e663074f0a4ed2f8643848ec139eba4b5fd16d0d01c8a23e08a4819a8843b",
|
|
377
|
-
"server/server/packages/types/dist/sleep-
|
|
377
|
+
"server/server/packages/types/dist/sleep-CqvzKIq2.mjs": "1c57cc25803331fab405ae466ef5adfeda60e57c7dcda5fe9083d87ddf3105dc",
|
|
378
378
|
"server/server/packages/ui-library/src/composites/adaptive-downlink.ts": "6e9698e97721461b72a3750f930dd7214d049be865491bfb5a64b87c032b0e22",
|
|
379
379
|
"server/server/packages/ui-library/src/composites/camera-stream-player.tsx": "c04809229b4e091fed09e2bcfe643d6b36cb3a39e294229b49f8a095e4e6ebd3",
|
|
380
380
|
"server/server/packages/ui-library/src/composites/cap-settings/CameraGridLayoutEditor.tsx": "fae93899c4903183e1b78db39e58bd52a3dd4dc2c11ce85d64e6d2a2bab7516d",
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
"server/server/packages/ui-library/src/composites/data-table-pager.tsx": "3ffe4b0adfe333c36b65e8808fdb8c0d1c2162c3e0582b590e094c9fe1a6cc68",
|
|
395
395
|
"server/server/packages/ui-library/src/composites/data-table-pagination.ts": "ed1192495b99ba34a2b621aea4b3016971cd203adff568b31e076b5e6c0e4882",
|
|
396
396
|
"server/server/packages/ui-library/src/composites/data-table-selection.tsx": "a0ede042754de79674a224b7ac74b81e2f27f57ad2d3622811f7938fc736eaa7",
|
|
397
|
-
"server/server/packages/ui-library/src/composites/data-table.tsx": "
|
|
397
|
+
"server/server/packages/ui-library/src/composites/data-table.tsx": "f79e4de10939a561cce752c226c4a6a8fecec0ec8652186c9ec4c7b0a1ba6890",
|
|
398
398
|
"server/server/packages/ui-library/src/composites/detection-colors.ts": "6a1da1e4ed0aafdc0e90377f911e8492a849f831cfc695f0db4a30c56c20c349",
|
|
399
399
|
"server/server/packages/ui-library/src/composites/dev-shell.tsx": "c3c4102dca52080b6eab45141a2fabff11afb9fdf8919516dbf7f2b8d2c17a61",
|
|
400
400
|
"server/server/packages/ui-library/src/composites/device-controls/ac-panel.tsx": "19649d3703843779006728547128f7fe4af73d9ba9e0fe4620a202895796c6e9",
|
package/dist/addon.js
CHANGED
|
@@ -803,7 +803,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
803
803
|
return EventCategory;
|
|
804
804
|
}({});
|
|
805
805
|
//#endregion
|
|
806
|
-
//#region ../types/dist/device-type-
|
|
806
|
+
//#region ../types/dist/device-type-CbDhVwFP.mjs
|
|
807
807
|
/**
|
|
808
808
|
import { errMsg } from '@camstack/types'
|
|
809
809
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -972,6 +972,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
972
972
|
* (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
|
|
973
973
|
*/
|
|
974
974
|
DeviceFeature["TimedRun"] = "timed-run";
|
|
975
|
+
/**
|
|
976
|
+
* Device binds a plain `switch` cap. Derived from the bindings
|
|
977
|
+
* (`featuresOfBoundCaps`) for a composed device, whose switch is bound by the
|
|
978
|
+
* composition and not by a driver: an appliance (a heater behind a smart
|
|
979
|
+
* plug) has no control of its own, so a surface reads this as its on/off.
|
|
980
|
+
*/
|
|
981
|
+
DeviceFeature["Switch"] = "switch";
|
|
975
982
|
/** Light supports rgb-triplet color via `color` cap. */
|
|
976
983
|
DeviceFeature["LightColorRgb"] = "light-color-rgb";
|
|
977
984
|
/** Light supports HSV color via `color` cap. */
|
|
@@ -5873,7 +5880,7 @@ var ZodIssueCode = {
|
|
|
5873
5880
|
var ZodFirstPartyTypeKind;
|
|
5874
5881
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5875
5882
|
//#endregion
|
|
5876
|
-
//#region ../types/dist/sleep-
|
|
5883
|
+
//#region ../types/dist/sleep-CqvzKIq2.mjs
|
|
5877
5884
|
/**
|
|
5878
5885
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5879
5886
|
* window to float samples (D455).
|
|
@@ -16300,7 +16307,7 @@ object({
|
|
|
16300
16307
|
params: record(string(), union([string(), number()])).optional()
|
|
16301
16308
|
});
|
|
16302
16309
|
//#endregion
|
|
16303
|
-
//#region ../types/dist/composition-
|
|
16310
|
+
//#region ../types/dist/composition-CXCX78IR.mjs
|
|
16304
16311
|
/**
|
|
16305
16312
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
16306
16313
|
*
|
|
@@ -47840,6 +47847,90 @@ DeviceType.Control, method(object({
|
|
|
47840
47847
|
kind: "mutation",
|
|
47841
47848
|
auth: "protected"
|
|
47842
47849
|
});
|
|
47850
|
+
var IrCodecError = class extends Error {
|
|
47851
|
+
code;
|
|
47852
|
+
constructor(code, message) {
|
|
47853
|
+
super(message);
|
|
47854
|
+
this.name = "IrCodecError";
|
|
47855
|
+
this.code = code;
|
|
47856
|
+
}
|
|
47857
|
+
};
|
|
47858
|
+
/**
|
|
47859
|
+
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
47860
|
+
* alternating, no zeros, 2..1024 entries.
|
|
47861
|
+
*/
|
|
47862
|
+
var IrTimingsSchema = array(number().int()).min(2).max(1024).superRefine((timings, ctx) => {
|
|
47863
|
+
timings.forEach((value, index) => {
|
|
47864
|
+
const expectMark = index % 2 === 0;
|
|
47865
|
+
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
47866
|
+
code: "custom",
|
|
47867
|
+
message: `timing ${index} must be a non-zero ${expectMark ? "mark (positive)" : "space (negative)"}`,
|
|
47868
|
+
path: [index]
|
|
47869
|
+
});
|
|
47870
|
+
});
|
|
47871
|
+
});
|
|
47872
|
+
/** Per-command transmit options. Every key is optional; a transmitter applies what it can. */
|
|
47873
|
+
var TransmitSettingsSchema = object({
|
|
47874
|
+
carrierHz: number().int().positive().optional(),
|
|
47875
|
+
dutyCyclePercent: number().int().min(1).max(100).optional(),
|
|
47876
|
+
repeat: number().int().min(0).max(20).optional(),
|
|
47877
|
+
repeatDelayMs: number().int().min(0).optional()
|
|
47878
|
+
});
|
|
47879
|
+
/** One Pronto frequency-word unit, in microseconds, per unit of the word. */
|
|
47880
|
+
var PRONTO_CLOCK_US = .241246;
|
|
47881
|
+
var LEARNED_FORM = 0;
|
|
47882
|
+
/**
|
|
47883
|
+
* Decode a learned (0000 form) Pronto hex string. The intro burst is followed by
|
|
47884
|
+
* the repeat burst once; a different form is refused with `pronto-unsupported-form`.
|
|
47885
|
+
*/
|
|
47886
|
+
function decodePronto(code) {
|
|
47887
|
+
const words = code.trim().split(/\s+/).filter((w) => w.length > 0);
|
|
47888
|
+
if (words.length < 4) throw new IrCodecError("pronto-malformed", `Pronto code needs at least 4 words, got ${words.length}`);
|
|
47889
|
+
const values = words.map((w) => /^[0-9a-fA-F]{1,4}$/.test(w) ? parseInt(w, 16) : NaN);
|
|
47890
|
+
if (values.some((v) => Number.isNaN(v))) throw new IrCodecError("pronto-malformed", "Pronto code must be 4-digit hexadecimal words");
|
|
47891
|
+
const [form, freqWord, introCount, repeatCount] = values;
|
|
47892
|
+
if (form === void 0 || freqWord === void 0 || introCount === void 0 || repeatCount === void 0) throw new IrCodecError("pronto-malformed", "Pronto header incomplete");
|
|
47893
|
+
if (form !== LEARNED_FORM) throw new IrCodecError("pronto-unsupported-form", `Pronto form ${words[0] ?? ""} is not supported, only the learned 0000 form`);
|
|
47894
|
+
if (freqWord === 0) throw new IrCodecError("pronto-malformed", "Pronto frequency word is zero");
|
|
47895
|
+
const pairs = introCount + repeatCount;
|
|
47896
|
+
if (pairs === 0 || values.length !== 4 + pairs * 2) throw new IrCodecError("pronto-malformed", `Pronto declares ${pairs} burst pairs but carries ${(values.length - 4) / 2} word pairs`);
|
|
47897
|
+
const unitUs = freqWord * PRONTO_CLOCK_US;
|
|
47898
|
+
const timings = values.slice(4).map((count, index) => {
|
|
47899
|
+
const us = Math.max(1, Math.round(count * unitUs));
|
|
47900
|
+
return index % 2 === 0 ? us : -us;
|
|
47901
|
+
});
|
|
47902
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
47903
|
+
if (!checked.success) throw new IrCodecError("invalid-timings", `Pronto decoded to invalid timings: ${checked.error.message}`);
|
|
47904
|
+
return {
|
|
47905
|
+
timings: checked.data,
|
|
47906
|
+
carrierHz: Math.round(1e6 / unitUs)
|
|
47907
|
+
};
|
|
47908
|
+
}
|
|
47909
|
+
/** What a remote command stores: a raw pulse train, or a learned Pronto code. */
|
|
47910
|
+
var IrPayloadSchema = discriminatedUnion("kind", [object({
|
|
47911
|
+
kind: literal("raw"),
|
|
47912
|
+
timings: array(number().int()),
|
|
47913
|
+
settings: TransmitSettingsSchema.optional()
|
|
47914
|
+
}), object({
|
|
47915
|
+
kind: literal("pronto"),
|
|
47916
|
+
code: string()
|
|
47917
|
+
})]);
|
|
47918
|
+
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
47919
|
+
function toTimings(payload) {
|
|
47920
|
+
if (payload.kind === "pronto") {
|
|
47921
|
+
const decoded = decodePronto(payload.code);
|
|
47922
|
+
return {
|
|
47923
|
+
timings: decoded.timings,
|
|
47924
|
+
settings: { carrierHz: decoded.carrierHz }
|
|
47925
|
+
};
|
|
47926
|
+
}
|
|
47927
|
+
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
47928
|
+
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
47929
|
+
return {
|
|
47930
|
+
timings: checked.data,
|
|
47931
|
+
settings: payload.settings ?? {}
|
|
47932
|
+
};
|
|
47933
|
+
}
|
|
47843
47934
|
/**
|
|
47844
47935
|
* The role vocabulary of a remote (D963): what a button MEANS, independent of
|
|
47845
47936
|
* how it is wired. A layout template places buttons by role; a device binds a
|
|
@@ -47927,11 +48018,18 @@ var RemoteRoleSchema = string().refine(isRemoteRole, { message: "a role is one o
|
|
|
47927
48018
|
* a voice command or `playMedia` names.
|
|
47928
48019
|
* - `sequence`: a name and explicit steps — bound roles pressed in order
|
|
47929
48020
|
* (an input key, a menu macro such as `source, down, down, ok`).
|
|
48021
|
+
* - `ir`: a name and one infrared code of its own (raw timings or a Pronto
|
|
48022
|
+
* string), sent through a named transmitter (planning#464). It presses no
|
|
48023
|
+
* button: a source the remote's layout has no key for.
|
|
47930
48024
|
*
|
|
47931
48025
|
* The name and the number resolve to the SAME declared source. A number no
|
|
47932
48026
|
* `digits` source declares is not a channel: it is refused, never guessed.
|
|
47933
48027
|
*/
|
|
47934
|
-
var REMOTE_SOURCE_KINDS = [
|
|
48028
|
+
var REMOTE_SOURCE_KINDS = [
|
|
48029
|
+
"digits",
|
|
48030
|
+
"sequence",
|
|
48031
|
+
"ir"
|
|
48032
|
+
];
|
|
47935
48033
|
_enum(REMOTE_SOURCE_KINDS);
|
|
47936
48034
|
var REMOTE_SOURCE_ID_RE = /^[a-z0-9][a-z0-9_-]{0,47}$/;
|
|
47937
48035
|
var CHANNEL_NUMBER_RE = new RegExp(`^[0-9]{1,6}$`);
|
|
@@ -47941,19 +48039,50 @@ var sourceBase = {
|
|
|
47941
48039
|
/** What the operator calls it, and what a voice command or a picker names. */
|
|
47942
48040
|
name: string().trim().min(1).max(60)
|
|
47943
48041
|
};
|
|
47944
|
-
var RemoteSourceSchema = discriminatedUnion("kind", [
|
|
47945
|
-
|
|
47946
|
-
|
|
47947
|
-
|
|
47948
|
-
|
|
47949
|
-
|
|
47950
|
-
|
|
47951
|
-
|
|
47952
|
-
|
|
48042
|
+
var RemoteSourceSchema = discriminatedUnion("kind", [
|
|
48043
|
+
object({
|
|
48044
|
+
...sourceBase,
|
|
48045
|
+
kind: literal("digits"),
|
|
48046
|
+
number: string().regex(CHANNEL_NUMBER_RE, { message: "up to 6 digits" })
|
|
48047
|
+
}),
|
|
48048
|
+
object({
|
|
48049
|
+
...sourceBase,
|
|
48050
|
+
kind: literal("sequence"),
|
|
48051
|
+
steps: array(RemoteRoleSchema).min(1).max(16)
|
|
48052
|
+
}),
|
|
48053
|
+
object({
|
|
48054
|
+
...sourceBase,
|
|
48055
|
+
kind: literal("ir"),
|
|
48056
|
+
/** The `ir-transmitter` device the code is sent through. */
|
|
48057
|
+
transmitterId: number().int().nonnegative(),
|
|
48058
|
+
/** The code itself; whether a transmitter could send it is `irSourceProblem`. */
|
|
48059
|
+
payload: IrPayloadSchema
|
|
48060
|
+
})
|
|
48061
|
+
]);
|
|
47953
48062
|
var REMOTE_STEP_DELAY_MAX_MS = 3e3;
|
|
47954
|
-
/**
|
|
48063
|
+
/**
|
|
48064
|
+
* The roles a source presses, in order. A `digits` number is its digit roles;
|
|
48065
|
+
* an `ir` source presses none — it carries its own code.
|
|
48066
|
+
*/
|
|
47955
48067
|
function remoteSourceSteps(source) {
|
|
47956
|
-
|
|
48068
|
+
switch (source.kind) {
|
|
48069
|
+
case "sequence": return source.steps;
|
|
48070
|
+
case "digits": return Array.from(source.number, (digit) => `digit_${digit}`);
|
|
48071
|
+
case "ir": return [];
|
|
48072
|
+
}
|
|
48073
|
+
}
|
|
48074
|
+
/**
|
|
48075
|
+
* Why an `ir` source's code could not be sent (the codec's own words), or null
|
|
48076
|
+
* when it resolves to a pulse train. The schema refuses on it; the editor shows it.
|
|
48077
|
+
*/
|
|
48078
|
+
function irSourceProblem(source) {
|
|
48079
|
+
try {
|
|
48080
|
+
toTimings(source.payload);
|
|
48081
|
+
return null;
|
|
48082
|
+
} catch (err) {
|
|
48083
|
+
if (err instanceof IrCodecError) return err.message;
|
|
48084
|
+
throw err;
|
|
48085
|
+
}
|
|
47957
48086
|
}
|
|
47958
48087
|
/**
|
|
47959
48088
|
* Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
|
|
@@ -53470,8 +53599,9 @@ DeviceType.Thermostat;
|
|
|
53470
53599
|
*
|
|
53471
53600
|
* "Heat for 30 minutes", "run the fountain pump for 2 minutes": the device has
|
|
53472
53601
|
* no timer of its own, so the hub keeps one. `runFor` turns the device on and
|
|
53473
|
-
* records a deadline; `cancel`
|
|
53474
|
-
* forgets it; at the deadline
|
|
53602
|
+
* records a deadline; `cancel` switches the device off and forgets the deadline,
|
|
53603
|
+
* and the device being switched off by hand just forgets it; at the deadline
|
|
53604
|
+
* the hub issues the off once.
|
|
53475
53605
|
*
|
|
53476
53606
|
* The deadline is DURABLE: it is a row in the records store, so a hub restart
|
|
53477
53607
|
* neither loses a pending off nor leaves the device running past its time. At
|
|
@@ -54614,27 +54744,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), object({
|
|
|
54614
54744
|
deviceId: number(),
|
|
54615
54745
|
status: IntercomStatusSchema
|
|
54616
54746
|
});
|
|
54617
|
-
/**
|
|
54618
|
-
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
54619
|
-
* alternating, no zeros, 2..1024 entries.
|
|
54620
|
-
*/
|
|
54621
|
-
var IrTimingsSchema = array(number().int()).min(2).max(1024).superRefine((timings, ctx) => {
|
|
54622
|
-
timings.forEach((value, index) => {
|
|
54623
|
-
const expectMark = index % 2 === 0;
|
|
54624
|
-
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
54625
|
-
code: "custom",
|
|
54626
|
-
message: `timing ${index} must be a non-zero ${expectMark ? "mark (positive)" : "space (negative)"}`,
|
|
54627
|
-
path: [index]
|
|
54628
|
-
});
|
|
54629
|
-
});
|
|
54630
|
-
});
|
|
54631
|
-
/** Per-command transmit options. Every key is optional; a transmitter applies what it can. */
|
|
54632
|
-
var TransmitSettingsSchema = object({
|
|
54633
|
-
carrierHz: number().int().positive().optional(),
|
|
54634
|
-
dutyCyclePercent: number().int().min(1).max(100).optional(),
|
|
54635
|
-
repeat: number().int().min(0).max(20).optional(),
|
|
54636
|
-
repeatDelayMs: number().int().min(0).optional()
|
|
54637
|
-
});
|
|
54638
54747
|
/** The setting keys a transmitter may declare as settable (`getInfo.settable`). */
|
|
54639
54748
|
var TransmitSettingKeySchema = _enum([
|
|
54640
54749
|
"carrierHz",
|
|
@@ -70957,6 +71066,10 @@ function refineSources(config, ctx) {
|
|
|
70957
71066
|
if (numbers.has(source.number)) fail(`channel ${source.number} is declared twice`, "number");
|
|
70958
71067
|
numbers.add(source.number);
|
|
70959
71068
|
}
|
|
71069
|
+
if (source.kind === "ir") {
|
|
71070
|
+
const problem = irSourceProblem(source);
|
|
71071
|
+
if (problem !== null) fail(problem, "payload");
|
|
71072
|
+
}
|
|
70960
71073
|
for (const role of remoteSourceSteps(source)) if (isRemoteWidgetRole(role)) fail(`"${source.name}" presses ${role}, a layout widget, not a command`, "steps");
|
|
70961
71074
|
else if (config.bindings[role] === void 0) fail(`"${source.name}" presses ${role}, which is not bound`, "steps");
|
|
70962
71075
|
});
|
|
@@ -70978,6 +71091,14 @@ function refineSources(config, ctx) {
|
|
|
70978
71091
|
}
|
|
70979
71092
|
});
|
|
70980
71093
|
}
|
|
71094
|
+
/** A stored source that was left out of a read, and why (the UI shows it). */
|
|
71095
|
+
var RemoteRefusedSourceSchema = object({
|
|
71096
|
+
/** Position in the stored list. */
|
|
71097
|
+
index: number().int().nonnegative(),
|
|
71098
|
+
id: string().nullable(),
|
|
71099
|
+
name: string().nullable(),
|
|
71100
|
+
reason: string()
|
|
71101
|
+
});
|
|
70981
71102
|
var RemoteConfigSchema = object({
|
|
70982
71103
|
layoutTemplateId: string().min(1).nullable(),
|
|
70983
71104
|
/**
|
|
@@ -70995,7 +71116,13 @@ var RemoteConfigSchema = object({
|
|
|
70995
71116
|
sources: array(RemoteSourceSchema).max(200).default([]),
|
|
70996
71117
|
/** The pause between two steps of a source: the television's receiver, not a repeat. */
|
|
70997
71118
|
stepDelayMs: number().int().min(100).max(REMOTE_STEP_DELAY_MAX_MS).default(500),
|
|
70998
|
-
power: object({ mode: RemotePowerModeSchema })
|
|
71119
|
+
power: object({ mode: RemotePowerModeSchema }),
|
|
71120
|
+
/**
|
|
71121
|
+
* READ-ONLY: sources a stored configuration carries that no longer parse,
|
|
71122
|
+
* left out of `sources` with the reason (`readStoredRemoteConfig`). Never
|
|
71123
|
+
* stored: the store strips it on write.
|
|
71124
|
+
*/
|
|
71125
|
+
refusedSources: array(RemoteRefusedSourceSchema).optional()
|
|
70999
71126
|
}).superRefine((config, ctx) => {
|
|
71000
71127
|
const roles = Object.keys(config.bindings);
|
|
71001
71128
|
if (roles.length > 200) ctx.addIssue({
|
|
@@ -71036,6 +71163,11 @@ var RemoteConfigSchema = object({
|
|
|
71036
71163
|
}
|
|
71037
71164
|
refineSources(config, ctx);
|
|
71038
71165
|
});
|
|
71166
|
+
looseObject({ sources: array(unknown()) });
|
|
71167
|
+
object({
|
|
71168
|
+
id: string(),
|
|
71169
|
+
name: string()
|
|
71170
|
+
}).partial();
|
|
71039
71171
|
object({
|
|
71040
71172
|
power: object({
|
|
71041
71173
|
state: _enum(["on", "off"]),
|
|
@@ -76110,14 +76242,6 @@ btn("power", 0, 0, {
|
|
|
76110
76242
|
3,
|
|
76111
76243
|
4
|
|
76112
76244
|
].map((n) => btn(`app${n}`, 0, n - 1, { role: `custom:app_slot_${n}` })), btn("back", 0, 0, { role: "back" }), btn("home", 0, 1, { role: "home" }), btn("menu", 0, 2, { role: "menu" });
|
|
76113
|
-
discriminatedUnion("kind", [object({
|
|
76114
|
-
kind: literal("raw"),
|
|
76115
|
-
timings: array(number().int()),
|
|
76116
|
-
settings: TransmitSettingsSchema.optional()
|
|
76117
|
-
}), object({
|
|
76118
|
-
kind: literal("pronto"),
|
|
76119
|
-
code: string()
|
|
76120
|
-
})]);
|
|
76121
76245
|
/**
|
|
76122
76246
|
* Propose a running threshold from a device's own power history (planning#405).
|
|
76123
76247
|
*
|
|
@@ -91214,7 +91338,7 @@ var AgentUIAddon = class extends BaseAddon {
|
|
|
91214
91338
|
capability: adminUiCapability,
|
|
91215
91339
|
provider: {
|
|
91216
91340
|
getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
|
|
91217
|
-
getVersion: async () => ({ version: "1.2.
|
|
91341
|
+
getVersion: async () => ({ version: "1.2.349" })
|
|
91218
91342
|
}
|
|
91219
91343
|
}];
|
|
91220
91344
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{T as a,_ as o,c as s,d as c,l,p as u,t as d}from"./index-
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{T as a,_ as o,c as s,d as c,l,p as u,t as d}from"./index-Bngw8_Yl.js";import{MaskShapeCanvas as f}from"./MaskShapeCanvas-BTvl6Rin.js";var p=a(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),m=n(i(),1),h=n(e(),1),g=110,_=`motion-zones`,v=0,y=[1,2,3],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`;function C(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function w(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function T(e,t){return Math.ceil(e/t)}function E(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function D(e,t,n,r){let i=T(t,r),a=T(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=E(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+E(n,t,i)]=!0)}return o}function O(e,t,n,r){let i=T(t,r),a=T(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=E(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+E(n,t,i)]===!0}return o}function k({deviceId:e}){let n=t(),i=c(o().trpcClient,e),[a,E]=(0,m.useState)(null),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(null),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)(b),[L,R]=(0,m.useState)(!1),[z,B]=(0,m.useState)(!1),V=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!i)return;let e=!1;return V.current=!1,E(null),A(!1),M(null),P(null),I(b),B(!1),(async()=>{try{let t=await i.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(E(t),V.current)return;let n=await i.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);V.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),a=C(r?r.shape.cells:[],t.grid.width,t.grid.height);P(a),M(D(a,t.grid.width,t.grid.height,b))}catch(t){if(e)return;l(t)?A(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[i]);let H=a?a.grid.width:0,U=a?a.grid.height:0,W=T(H,F),G=T(U,F),K=(0,m.useMemo)(()=>j&&a?O(j,H,U,F):null,[j,a,H,U,F]),q=(0,m.useMemo)(()=>K!==null&&N!==null&&!w(K,N),[K,N]),J=(0,m.useMemo)(()=>K?K.reduce((e,t)=>t?e+1:e,0):0,[K]),Y=H*U,X=W*G,Z=(0,m.useCallback)(e=>{X>0&&M(Array.from({length:X},()=>e))},[X]),ee=(0,m.useCallback)(()=>{M(e=>e&&e.map(e=>!e))},[]),te=(0,m.useCallback)(()=>{N&&a&&M(D(N,H,U,F))},[N,a,H,U,F]),ne=(0,m.useCallback)(e=>{e===F||!a||M(t=>{if(!t)return I(e),t;let n=D(O(t,H,U,F),H,U,e);return I(e),n})},[F,a,H,U]),Q=(0,m.useMemo)(()=>a&&j?[{id:v,shape:{kind:`grid`,gridWidth:W,gridHeight:G,cells:[...j]}}]:[],[a,j,W,G]),$=(0,m.useCallback)((e,t)=>{t.kind===`grid`&&M(t.cells)},[]),re=(0,m.useCallback)(async()=>{if(!(!i||!j||!a)){R(!0);try{let e=O(j,a.grid.width,a.grid.height,F),t={kind:`grid`,gridWidth:a.grid.width,gridHeight:a.grid.height,cells:e};await i.motionZones?.setZone({patch:{regions:[{id:v,enabled:!0,shape:t}]}});let n=await i.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=C(e?e.shape.cells:[],a.grid.width,a.grid.height);P(t),M(D(t,a.grid.width,a.grid.height,F))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{R(!1)}}},[i,j,a,F]);d((0,m.useMemo)(()=>z&&!k&&a&&j?{id:_,order:g,node:(0,h.jsx)(f,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:W,height:G},selectedId:v,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[z,k,a,j,Q,$,W,G]));let ie=!k&&a!==null&&j!==null;return i?(0,h.jsx)(u,{title:n(`uiLibrary.motionZones.title`,`Motion Zones`),icon:(0,h.jsx)(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,h.jsx)(`div`,{className:`flex flex-col gap-3`,children:k?(0,h.jsx)(`p`,{className:`${s} leading-relaxed`,children:n(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ie?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`${s} leading-relaxed`,children:(0,h.jsx)(r,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[(0,h.jsx)(`strong`,{className:`text-foreground`},`e`),(0,h.jsx)(`strong`,{className:`text-foreground`},`s`),(0,h.jsx)(`strong`,{className:`text-foreground`},`c`)],values:{width:a.grid.width,height:a.grid.height}})}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>B(e=>!e),disabled:L,"aria-pressed":z,className:z?S:x,children:z?n(`uiLibrary.motionZones.doneEditing`,`Done editing`):n(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>Z(!0),disabled:L,className:x,children:n(`uiLibrary.motionZones.allOn`,`All on`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>Z(!1),disabled:L,className:x,children:n(`uiLibrary.motionZones.allOff`,`All off`)}),(0,h.jsx)(`button`,{type:`button`,onClick:ee,disabled:L,className:x,children:n(`uiLibrary.motionZones.invert`,`Invert`)}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":n(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[(0,h.jsx)(`span`,{className:`${s} mr-0.5`,children:n(`uiLibrary.motionZones.cellSize`,`Cell size`)}),y.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>ne(e),disabled:L,"aria-pressed":F===e,title:e===1?n(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:H,height:U}):n(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:T(H,e),height:T(U,e),factor:e}),className:F===e?S:x,children:[`×`,e]},e))]}),(0,h.jsxs)(`span`,{className:`${s} ml-1 tabular-nums`,children:[n(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:J,total:Y,width:a.grid.width,height:a.grid.height}),F===1?``:n(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:W,height:G})]}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(`button`,{type:`button`,onClick:te,disabled:L||!q,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`,children:n(`uiLibrary.motionZones.revert`,`Revert`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void re(),disabled:L||!q,className:S,children:L?n(`uiLibrary.motionZones.saving`,`Saving…`):n(`uiLibrary.motionZones.save`,`Save`)})]})]}):(0,h.jsx)(`p`,{className:`${s} leading-relaxed`,children:n(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{k as MotionZonesSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as ee,T as a,_ as te,c as o,d as ne,l as s,p as c,t as re,v as l,x as u,y as d}from"./index-CBKk36pu.js";import{MaskShapeCanvas as ie}from"./MaskShapeCanvas-BTvl6Rin.js";var ae=a(`hexagon`,[[`path`,{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`,key:`yt0hxn`}]]),oe=a(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),f=n(i(),1),p=`Microphone`,m=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function se(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:p,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:m}}function ce(e){return!e.available||e.on===null?null:{enabled:!e.on}}var h=n(e(),1),le=120,ue=`privacy-mask`,g=`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`,_=`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`;function v(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function de(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function fe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function y({deviceId:e}){let n=t(),i=ne(te().trpcClient,e),[a,p]=(0,f.useState)(null),[m,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[pe,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(null),z=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,p(null),y(!1),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await i.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(p(t),z.current)return;let n=await i.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){x(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;s(t)?y(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[i]);let B=(0,f.useMemo)(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!fe(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=a?a.maxRegions:0,U=(0,f.useRef)(0);(0,f.useEffect)(()=>{U.current=H},[H]);let W=H>0&&V>=H,me=(0,f.useCallback)(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=(0,f.useCallback)(e=>{j(typeof e==`number`?e:null)},[]),K=(0,f.useMemo)(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[S,n]),q=(0,f.useCallback)((e,t)=>{let n=v(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=(0,f.useCallback)(e=>{let t=v(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=de(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=(0,f.useCallback)(e=>{k(!0),j(null),N(e)},[]),he=(0,f.useCallback)(e=>{k(!0),N(null),j(e)},[]),ge=(0,f.useCallback)(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),_e=(0,f.useCallback)(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),X=(0,f.useCallback)(async()=>{if(!(!i||!S)){D(!0);try{await i.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await i.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[i,S]),Z=se({supportsAudioMute:a===null?null:a.supportsAudioMute,audioEnabled:pe,pendingOn:F}),ve=(0,f.useCallback)(async()=>{let e=ce(Z);if(!(!i||e===null)){I(e.enabled),R(null);try{await i.privacyMask?.setAudioEnabled(e);let t=await i.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[i,Z]),ye=(0,f.useCallback)(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=a?.supportedShapes??[];re((0,f.useMemo)(()=>O&&!m&&a&&S?{id:ue,order:le,node:(0,h.jsx)(ie,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:a.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,m,a,S,K,Q,A,G,q,J,M]));let be=a?.supportedShapes.includes(`rect`)??!1,xe=a?.supportedShapes.includes(`polygon`)??!1,$=a!==null&&(a.maxRegions<=0||a.supportedShapes.length===0),Se=!m&&!$&&!b&&a!==null&&S!==null;return i?(0,h.jsx)(c,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m||$?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):b?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unreadable`,`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.`)}):Se?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,h.jsx)(r,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> 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.`,components:[(0,h.jsx)(`strong`,{className:`text-foreground`},`edit`),(0,h.jsx)(`strong`,{className:`text-foreground`},`save`)]})}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:ye,disabled:E,"aria-pressed":O,className:O?_:g,children:O?n(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):n(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),(0,h.jsx)(`button`,{type:`button`,onClick:me,disabled:E,"aria-pressed":S.enabled,className:S.enabled?_:g,children:S.enabled?n(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):n(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),be&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:n(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),xe&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:n(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),(0,h.jsx)(`span`,{className:`${o} ml-1 tabular-nums`,children:n(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(`button`,{type:`button`,onClick:_e,disabled:E||!B,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`,children:n(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void X(),disabled:E||!B,className:_,children:E?n(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):n(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?(0,h.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,r=e.shape.kind===`polygon`?ae:d;return(0,h.jsxs)(`div`,{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`}`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>he(e.id),disabled:E,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`,children:[(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,h.jsx)(`span`,{children:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})}),(0,h.jsx)(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),disabled:E,"aria-label":n(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:e.id}),title:n(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),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`,children:(0,h.jsx)(l,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),Z.supported&&(0,h.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[(0,h.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||F!==null,onClick:()=>void ve(),title:Z.on===null?n(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):Z.on?n(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:Z.costWhenOff}):n(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:Z.costWhenOff}),className:Z.on===!1||Z.on===null?g:_,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?(0,h.jsx)(oe,{className:`h-3.5 w-3.5`}):(0,h.jsx)(u,{className:`h-3.5 w-3.5`}),Z.on===null?n(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):Z.on?n(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):n(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),(0,h.jsx)(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?Z.on===null?n(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):Z.costWhenOff:n(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{y as PrivacyMaskSettings};
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as ee,T as a,_ as te,c as o,d as ne,l as s,p as c,t as re,v as l,x as u,y as d}from"./index-Bngw8_Yl.js";import{MaskShapeCanvas as ie}from"./MaskShapeCanvas-BTvl6Rin.js";var ae=a(`hexagon`,[[`path`,{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`,key:`yt0hxn`}]]),oe=a(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),f=n(i(),1),p=`Microphone`,m=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function se(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:p,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:m}}function ce(e){return!e.available||e.on===null?null:{enabled:!e.on}}var h=n(e(),1),le=120,ue=`privacy-mask`,g=`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`,_=`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`;function v(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function de(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function fe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function y({deviceId:e}){let n=t(),i=ne(te().trpcClient,e),[a,p]=(0,f.useState)(null),[m,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[pe,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(null),z=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,p(null),y(!1),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await i.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(p(t),z.current)return;let n=await i.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){x(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;s(t)?y(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[i]);let B=(0,f.useMemo)(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!fe(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=a?a.maxRegions:0,U=(0,f.useRef)(0);(0,f.useEffect)(()=>{U.current=H},[H]);let W=H>0&&V>=H,me=(0,f.useCallback)(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=(0,f.useCallback)(e=>{j(typeof e==`number`?e:null)},[]),K=(0,f.useMemo)(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[S,n]),q=(0,f.useCallback)((e,t)=>{let n=v(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=(0,f.useCallback)(e=>{let t=v(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=de(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=(0,f.useCallback)(e=>{k(!0),j(null),N(e)},[]),he=(0,f.useCallback)(e=>{k(!0),N(null),j(e)},[]),ge=(0,f.useCallback)(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),_e=(0,f.useCallback)(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),X=(0,f.useCallback)(async()=>{if(!(!i||!S)){D(!0);try{await i.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await i.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[i,S]),Z=se({supportsAudioMute:a===null?null:a.supportsAudioMute,audioEnabled:pe,pendingOn:F}),ve=(0,f.useCallback)(async()=>{let e=ce(Z);if(!(!i||e===null)){I(e.enabled),R(null);try{await i.privacyMask?.setAudioEnabled(e);let t=await i.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[i,Z]),ye=(0,f.useCallback)(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=a?.supportedShapes??[];re((0,f.useMemo)(()=>O&&!m&&a&&S?{id:ue,order:le,node:(0,h.jsx)(ie,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:a.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,m,a,S,K,Q,A,G,q,J,M]));let be=a?.supportedShapes.includes(`rect`)??!1,xe=a?.supportedShapes.includes(`polygon`)??!1,$=a!==null&&(a.maxRegions<=0||a.supportedShapes.length===0),Se=!m&&!$&&!b&&a!==null&&S!==null;return i?(0,h.jsx)(c,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m||$?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):b?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unreadable`,`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.`)}):Se?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,h.jsx)(r,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> 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.`,components:[(0,h.jsx)(`strong`,{className:`text-foreground`},`edit`),(0,h.jsx)(`strong`,{className:`text-foreground`},`save`)]})}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:ye,disabled:E,"aria-pressed":O,className:O?_:g,children:O?n(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):n(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),(0,h.jsx)(`button`,{type:`button`,onClick:me,disabled:E,"aria-pressed":S.enabled,className:S.enabled?_:g,children:S.enabled?n(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):n(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),be&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:n(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),xe&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:n(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),(0,h.jsx)(`span`,{className:`${o} ml-1 tabular-nums`,children:n(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(`button`,{type:`button`,onClick:_e,disabled:E||!B,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`,children:n(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void X(),disabled:E||!B,className:_,children:E?n(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):n(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?(0,h.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,r=e.shape.kind===`polygon`?ae:d;return(0,h.jsxs)(`div`,{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`}`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>he(e.id),disabled:E,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`,children:[(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,h.jsx)(`span`,{children:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})}),(0,h.jsx)(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),disabled:E,"aria-label":n(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:e.id}),title:n(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),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`,children:(0,h.jsx)(l,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),Z.supported&&(0,h.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[(0,h.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||F!==null,onClick:()=>void ve(),title:Z.on===null?n(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):Z.on?n(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:Z.costWhenOff}):n(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:Z.costWhenOff}),className:Z.on===!1||Z.on===null?g:_,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?(0,h.jsx)(oe,{className:`h-3.5 w-3.5`}):(0,h.jsx)(u,{className:`h-3.5 w-3.5`}),Z.on===null?n(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):Z.on?n(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):n(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),(0,h.jsx)(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?Z.on===null?n(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):Z.costWhenOff:n(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{y as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{S as a,T as o,_ as s,a as c,b as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as v,o as y,r as b,s as x,u as S,v as C,w}from"./index-CBKk36pu.js";import{MaskShapeCanvas as T}from"./MaskShapeCanvas-BTvl6Rin.js";var E=o(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),D=n(i(),1),O=n(e(),1),k=_(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function P({monitor:e,disabled:n,onDelete:r}){let i=t(),a=j(e),o=M(e),s=m();return a.length===0?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:i(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):(0,O.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[x(e.condition,i),` · `,e.tiles.length]}),(0,O.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(t=>{let a=`${t.stateId}:${String(t.index)}`,c=o===1;return(0,O.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,O.jsx)(F,{reference:t.reference}),(0,O.jsx)(`span`,{className:`${u} tabular-nums`,children:I(t.reference.capturedAt)}),(0,O.jsxs)(`button`,{type:`button`,className:N,disabled:n,"aria-label":i(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:x(e.condition,i).toLowerCase(),date:I(t.reference.capturedAt)}),onClick:()=>{(async()=>{c&&!await s({title:i(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:i(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:t.stateId,index:t.index})})()},children:[(0,O.jsx)(C,{className:`mr-1 inline h-3 w-3`}),i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},a)})})]},e.condition))})}function F({reference:e}){let n=t(),[r,i]=(0,D.useState)(!1),o=e.thumbnailMediaId;return o===void 0||r?(0,O.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[(0,O.jsx)(a,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):(0,O.jsx)(`img`,{src:A(o),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>i(!0)})}function I(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var L=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,R=`text-[10px] font-medium text-foreground-subtle`,z=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,B=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,V=5,H=3600;function U(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function W(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function G(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function K({monitor:e,disabled:n,onPatch:i}){let a=t(),[o,s]=(0,D.useState)(()=>G(e)),[c,l]=(0,D.useState)(!1);(0,D.useEffect)(()=>{c||s(G(e))},[e,c]);let d=e=>{l(!1),i(e)},f=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},m=e.confirm?.enabled===!0,h=e.check.mode===`similarity`?e.check.threshold:null;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.name`,`Name`)}),(0,O.jsx)(`input`,{type:`text`,value:o.label,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,label:e.target.value})),onBlur:()=>{let t=o.label.trim();t.length>0&&t!==e.label?d({label:t}):l(!1)}})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:n,onChange:e=>d({enabled:e.target.checked})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),(0,O.jsxs)(p,{value:e.triggerMode,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&d({triggerMode:t})},children:[(0,O.jsx)(`option`,{value:`both`,children:a(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),(0,O.jsx)(`option`,{value:`periodic`,children:a(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),(0,O.jsx)(`option`,{value:`on-motion`,children:a(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),(0,O.jsx)(`p`,{className:u,children:U(e.triggerMode,a)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),(0,O.jsx)(`input`,{type:`number`,min:V,max:H,value:o.checkIntervalSec,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.checkIntervalSec,V,H);t===e.checkIntervalSec?l(!1):d({checkIntervalSec:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),e.check.mode===`similarity`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:(0,O.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[(0,O.jsx)(`span`,{className:`tabular-nums`},`value`)],values:{value:o.threshold.toFixed(2)}})}),(0,O.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:o.threshold,disabled:n,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{o.threshold===h?l(!1):d({check:f({threshold:o.threshold})})},onBlur:()=>{o.threshold===h?l(!1):d({check:f({threshold:o.threshold})})}})]}),(0,O.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),(0,O.jsx)(`input`,{type:`number`,min:1,max:10,value:o.hysteresisCount,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=q(o.hysteresisCount,1,10);t===e.check.hysteresisCount?l(!1):d({check:f({hysteresisCount:t})})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),(0,O.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.quietSeconds,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.quietSeconds,0,3600);t===e.quietSeconds?l(!1):d({quietSeconds:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),(0,O.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.minObservationSpacingSec,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?l(!1):d({minObservationSpacingSec:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),(0,O.jsxs)(p,{value:e.onUncoveredCondition,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&d({onUncoveredCondition:t})},children:[(0,O.jsx)(`option`,{value:`skip`,children:a(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),(0,O.jsx)(`option`,{value:`judge-anyway`,children:a(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),(0,O.jsx)(`p`,{className:u,children:W(e.onUncoveredCondition,a)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),(0,O.jsxs)(p,{value:e.emit,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&d({emit:t})},children:[(0,O.jsx)(`option`,{value:`latched`,children:a(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),(0,O.jsx)(`option`,{value:`live`,children:a(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:n,onChange:e=>d({autoRestore:e.target.checked})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:m,disabled:n||o.confirmPrompt.trim().length===0,onChange:e=>d(e.target.checked?{confirm:{...J(o.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),(0,O.jsx)(`input`,{type:`text`,value:o.confirmPrompt,placeholder:a(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=o.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?d({confirm:{...J(t),enabled:m}}):l(!1)}})]}),(0,O.jsx)(`p`,{className:u,children:(0,O.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[(0,O.jsx)(`strong`,{},`only`)]})})]})]})}function q(e,t,n){return Math.min(n,Math.max(t,e))}function J(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var 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`,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`,Z=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,Q={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},ee=.8,te=3;function $({deviceId:e}){let n=t(),r=d(s().trpcClient,e),i=f(r?.state.sceneMonitor),a=S(e,{width:640}),[o,p]=(0,D.useState)(null),[m,_]=(0,D.useState)(!1),[k,A]=(0,D.useState)(null),[j,M]=(0,D.useState)(null),[N,F]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[H,U]=(0,D.useState)(``),W=(0,D.useRef)(!0);(0,D.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let G=(0,D.useCallback)(async()=>{if(r)try{let e=await r.sceneMonitor?.listScenes({});if(!W.current)return;e&&p(e)}catch(e){if(!W.current)return;g(e)?_(!0):M(e instanceof Error?e.message:String(e))}},[r]);(0,D.useEffect)(()=>{p(null),_(!1),M(null),G()},[G]);let q=i?.monitors??o?.monitors??[],J=Date.now(),$=(0,D.useCallback)(async(e,t)=>{A(e),M(null);try{await t(),await G()}catch(e){W.current&&M(e instanceof Error?e.message:String(e))}finally{W.current&&A(null)}},[G]),ne=(0,D.useMemo)(()=>{let e=q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return B===null?e:[...e,{id:`__draft__`,shape:B,label:n(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[q,B,n]),re=(0,D.useCallback)((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){V(t);return}$(`roi-${String(e)}`,async()=>r?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[r,$]),ie=(0,D.useCallback)(e=>{e.kind===`rect`&&V(e)},[]),ae=(0,D.useCallback)(async()=>{B===null||H.trim().length===0||(await $(`create`,async()=>{await r?.sceneMonitor?.createScene({label:H.trim(),roi:B,check:{mode:`similarity`,threshold:ee,hysteresisCount:te}})}),V(null),U(``),z(!1))},[r,B,H,$]);return r?(0,O.jsx)(`div`,{className:`flex flex-col gap-3`,children:m?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),(0,O.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,O.jsx)(T,{items:ne,supportedShapes:[`rect`],selectedId:N??(B===null?null:`__draft__`),onSelect:e=>F(e===null?null:String(e)),onShapeChange:re,onDrawComplete:ie,drawingKind:R&&B===null?`rect`:null,backdrop:a.src===null?null:(0,O.jsx)(`img`,{src:a.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:R?X:Y,"aria-pressed":R,onClick:()=>{z(e=>!e),V(null)},disabled:k!==null,children:R?n(`uiLibrary.sceneMonitor.cancel`,`Cancel`):n(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),(0,O.jsx)(`button`,{type:`button`,className:Y,onClick:a.refresh,disabled:k!==null,children:n(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),R&&(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,O.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:B===null?n(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):n(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),B!==null&&c(B)&&(0,O.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:n(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),placeholder:n(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,O.jsx)(`button`,{type:`button`,className:X,onClick:()=>void ae(),disabled:B===null||H.trim().length===0||k!==null,children:n(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),j!==null&&(0,O.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:j}),q.length===0?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):(0,O.jsx)(`ul`,{className:`flex flex-col gap-2`,children:q.map(e=>{let t=b(e,n);return(0,O.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${N===e.id?`border-primary/50`:`border-border`}`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>F(e.id),children:e.label}),(0,O.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${Q[t.tone]}`,children:t.text})]}),(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:y(e,J,n)}),(0,O.jsx)(`p`,{className:`${u} tabular-nums`,children:h(e,n)}),(0,O.jsx)(P,{monitor:e,disabled:k!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>r.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v.map(t=>{let i=t===`ir`;return(0,O.jsxs)(`button`,{type:`button`,className:Y,disabled:k!==null,title:i?n(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):n(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:x(t,n).toLowerCase()}),onClick:()=>void $(`cap-${e.id}-${t}`,async()=>r.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[(0,O.jsx)(w,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:x(t,n).toLowerCase()}),i&&(0,O.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:n(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},t)}),(0,O.jsxs)(`button`,{type:`button`,className:X,disabled:k!==null||e.states.length===0,title:n(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${e.id}`,async()=>r.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,O.jsx)(l,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),(0,O.jsx)(`button`,{type:`button`,className:Y,disabled:k!==null,onClick:()=>void $(`check-${e.id}`,async()=>r.sceneMonitor?.recheckNow({monitorId:e.id})),children:n(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),(0,O.jsxs)(`button`,{type:`button`,className:I===e.id?X:Y,"aria-pressed":I===e.id,"aria-label":n(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:e.label}),disabled:k!==null,onClick:()=>L(t=>t===e.id?null:e.id),children:[(0,O.jsx)(E,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),(0,O.jsx)(`button`,{type:`button`,className:Z,disabled:k!==null,onClick:()=>void $(`del-${e.id}`,async()=>r.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,O.jsx)(C,{className:`h-3 w-3`})})]}),I===e.id&&(0,O.jsx)(K,{monitor:e,disabled:k!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>r.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{$ as SceneMonitorEditor};
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{S as a,T as o,_ as s,a as c,b as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as v,o as y,r as b,s as x,u as S,v as C,w}from"./index-Bngw8_Yl.js";import{MaskShapeCanvas as T}from"./MaskShapeCanvas-BTvl6Rin.js";var E=o(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),D=n(i(),1),O=n(e(),1),k=_(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function P({monitor:e,disabled:n,onDelete:r}){let i=t(),a=j(e),o=M(e),s=m();return a.length===0?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:i(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):(0,O.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,O.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,O.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[x(e.condition,i),` · `,e.tiles.length]}),(0,O.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(t=>{let a=`${t.stateId}:${String(t.index)}`,c=o===1;return(0,O.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,O.jsx)(F,{reference:t.reference}),(0,O.jsx)(`span`,{className:`${u} tabular-nums`,children:I(t.reference.capturedAt)}),(0,O.jsxs)(`button`,{type:`button`,className:N,disabled:n,"aria-label":i(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:x(e.condition,i).toLowerCase(),date:I(t.reference.capturedAt)}),onClick:()=>{(async()=>{c&&!await s({title:i(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:i(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:t.stateId,index:t.index})})()},children:[(0,O.jsx)(C,{className:`mr-1 inline h-3 w-3`}),i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},a)})})]},e.condition))})}function F({reference:e}){let n=t(),[r,i]=(0,D.useState)(!1),o=e.thumbnailMediaId;return o===void 0||r?(0,O.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[(0,O.jsx)(a,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):(0,O.jsx)(`img`,{src:A(o),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>i(!0)})}function I(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var L=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,R=`text-[10px] font-medium text-foreground-subtle`,z=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,B=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,V=5,H=3600;function U(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function W(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function G(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function K({monitor:e,disabled:n,onPatch:i}){let a=t(),[o,s]=(0,D.useState)(()=>G(e)),[c,l]=(0,D.useState)(!1);(0,D.useEffect)(()=>{c||s(G(e))},[e,c]);let d=e=>{l(!1),i(e)},f=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},m=e.confirm?.enabled===!0,h=e.check.mode===`similarity`?e.check.threshold:null;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.name`,`Name`)}),(0,O.jsx)(`input`,{type:`text`,value:o.label,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,label:e.target.value})),onBlur:()=>{let t=o.label.trim();t.length>0&&t!==e.label?d({label:t}):l(!1)}})]}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:n,onChange:e=>d({enabled:e.target.checked})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),(0,O.jsxs)(p,{value:e.triggerMode,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&d({triggerMode:t})},children:[(0,O.jsx)(`option`,{value:`both`,children:a(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),(0,O.jsx)(`option`,{value:`periodic`,children:a(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),(0,O.jsx)(`option`,{value:`on-motion`,children:a(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),(0,O.jsx)(`p`,{className:u,children:U(e.triggerMode,a)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),(0,O.jsx)(`input`,{type:`number`,min:V,max:H,value:o.checkIntervalSec,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.checkIntervalSec,V,H);t===e.checkIntervalSec?l(!1):d({checkIntervalSec:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),e.check.mode===`similarity`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:(0,O.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[(0,O.jsx)(`span`,{className:`tabular-nums`},`value`)],values:{value:o.threshold.toFixed(2)}})}),(0,O.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:o.threshold,disabled:n,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{o.threshold===h?l(!1):d({check:f({threshold:o.threshold})})},onBlur:()=>{o.threshold===h?l(!1):d({check:f({threshold:o.threshold})})}})]}),(0,O.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),(0,O.jsx)(`input`,{type:`number`,min:1,max:10,value:o.hysteresisCount,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=q(o.hysteresisCount,1,10);t===e.check.hysteresisCount?l(!1):d({check:f({hysteresisCount:t})})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),(0,O.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.quietSeconds,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.quietSeconds,0,3600);t===e.quietSeconds?l(!1):d({quietSeconds:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),(0,O.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.minObservationSpacingSec,disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=q(o.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?l(!1):d({minObservationSpacingSec:t})}})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),(0,O.jsxs)(p,{value:e.onUncoveredCondition,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&d({onUncoveredCondition:t})},children:[(0,O.jsx)(`option`,{value:`skip`,children:a(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),(0,O.jsx)(`option`,{value:`judge-anyway`,children:a(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),(0,O.jsx)(`p`,{className:u,children:W(e.onUncoveredCondition,a)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),(0,O.jsxs)(p,{value:e.emit,disabled:n,className:L,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&d({emit:t})},children:[(0,O.jsx)(`option`,{value:`latched`,children:a(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),(0,O.jsx)(`option`,{value:`live`,children:a(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:n,onChange:e=>d({autoRestore:e.target.checked})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),(0,O.jsx)(`p`,{className:u,children:a(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),(0,O.jsxs)(`div`,{className:z,children:[(0,O.jsx)(`p`,{className:B,children:a(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:m,disabled:n||o.confirmPrompt.trim().length===0,onChange:e=>d(e.target.checked?{confirm:{...J(o.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),(0,O.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,O.jsx)(`span`,{className:R,children:a(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),(0,O.jsx)(`input`,{type:`text`,value:o.confirmPrompt,placeholder:a(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:L,onFocus:()=>l(!0),onChange:e=>s(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=o.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?d({confirm:{...J(t),enabled:m}}):l(!1)}})]}),(0,O.jsx)(`p`,{className:u,children:(0,O.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[(0,O.jsx)(`strong`,{},`only`)]})})]})]})}function q(e,t,n){return Math.min(n,Math.max(t,e))}function J(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var 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`,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`,Z=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,Q={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},ee=.8,te=3;function $({deviceId:e}){let n=t(),r=d(s().trpcClient,e),i=f(r?.state.sceneMonitor),a=S(e,{width:640}),[o,p]=(0,D.useState)(null),[m,_]=(0,D.useState)(!1),[k,A]=(0,D.useState)(null),[j,M]=(0,D.useState)(null),[N,F]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(!1),[B,V]=(0,D.useState)(null),[H,U]=(0,D.useState)(``),W=(0,D.useRef)(!0);(0,D.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let G=(0,D.useCallback)(async()=>{if(r)try{let e=await r.sceneMonitor?.listScenes({});if(!W.current)return;e&&p(e)}catch(e){if(!W.current)return;g(e)?_(!0):M(e instanceof Error?e.message:String(e))}},[r]);(0,D.useEffect)(()=>{p(null),_(!1),M(null),G()},[G]);let q=i?.monitors??o?.monitors??[],J=Date.now(),$=(0,D.useCallback)(async(e,t)=>{A(e),M(null);try{await t(),await G()}catch(e){W.current&&M(e instanceof Error?e.message:String(e))}finally{W.current&&A(null)}},[G]),ne=(0,D.useMemo)(()=>{let e=q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return B===null?e:[...e,{id:`__draft__`,shape:B,label:n(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[q,B,n]),re=(0,D.useCallback)((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){V(t);return}$(`roi-${String(e)}`,async()=>r?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[r,$]),ie=(0,D.useCallback)(e=>{e.kind===`rect`&&V(e)},[]),ae=(0,D.useCallback)(async()=>{B===null||H.trim().length===0||(await $(`create`,async()=>{await r?.sceneMonitor?.createScene({label:H.trim(),roi:B,check:{mode:`similarity`,threshold:ee,hysteresisCount:te}})}),V(null),U(``),z(!1))},[r,B,H,$]);return r?(0,O.jsx)(`div`,{className:`flex flex-col gap-3`,children:m?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),(0,O.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,O.jsx)(T,{items:ne,supportedShapes:[`rect`],selectedId:N??(B===null?null:`__draft__`),onSelect:e=>F(e===null?null:String(e)),onShapeChange:re,onDrawComplete:ie,drawingKind:R&&B===null?`rect`:null,backdrop:a.src===null?null:(0,O.jsx)(`img`,{src:a.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:R?X:Y,"aria-pressed":R,onClick:()=>{z(e=>!e),V(null)},disabled:k!==null,children:R?n(`uiLibrary.sceneMonitor.cancel`,`Cancel`):n(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),(0,O.jsx)(`button`,{type:`button`,className:Y,onClick:a.refresh,disabled:k!==null,children:n(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),R&&(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,O.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:B===null?n(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):n(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),B!==null&&c(B)&&(0,O.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:n(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),placeholder:n(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,O.jsx)(`button`,{type:`button`,className:X,onClick:()=>void ae(),disabled:B===null||H.trim().length===0||k!==null,children:n(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),j!==null&&(0,O.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:j}),q.length===0?(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):(0,O.jsx)(`ul`,{className:`flex flex-col gap-2`,children:q.map(e=>{let t=b(e,n);return(0,O.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${N===e.id?`border-primary/50`:`border-border`}`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>F(e.id),children:e.label}),(0,O.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${Q[t.tone]}`,children:t.text})]}),(0,O.jsx)(`p`,{className:`${u} leading-relaxed`,children:y(e,J,n)}),(0,O.jsx)(`p`,{className:`${u} tabular-nums`,children:h(e,n)}),(0,O.jsx)(P,{monitor:e,disabled:k!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>r.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v.map(t=>{let i=t===`ir`;return(0,O.jsxs)(`button`,{type:`button`,className:Y,disabled:k!==null,title:i?n(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):n(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:x(t,n).toLowerCase()}),onClick:()=>void $(`cap-${e.id}-${t}`,async()=>r.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[(0,O.jsx)(w,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:x(t,n).toLowerCase()}),i&&(0,O.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:n(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},t)}),(0,O.jsxs)(`button`,{type:`button`,className:X,disabled:k!==null||e.states.length===0,title:n(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${e.id}`,async()=>r.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,O.jsx)(l,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),(0,O.jsx)(`button`,{type:`button`,className:Y,disabled:k!==null,onClick:()=>void $(`check-${e.id}`,async()=>r.sceneMonitor?.recheckNow({monitorId:e.id})),children:n(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),(0,O.jsxs)(`button`,{type:`button`,className:I===e.id?X:Y,"aria-pressed":I===e.id,"aria-label":n(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:e.label}),disabled:k!==null,onClick:()=>L(t=>t===e.id?null:e.id),children:[(0,O.jsx)(E,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),(0,O.jsx)(`button`,{type:`button`,className:Z,disabled:k!==null,onClick:()=>void $(`del-${e.id}`,async()=>r.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,O.jsx)(C,{className:`h-3 w-3`})})]}),I===e.id&&(0,O.jsx)(K,{monitor:e,disabled:k!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>r.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{$ as SceneMonitorEditor};
|