@camstack/addon-agent-ui 1.2.246 → 1.2.247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +230 -197
- package/dist/assets/{MotionZonesSettings-C8oVEnMF.js → MotionZonesSettings-BvVGNQfm.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-D6x2O9OH.js → PrivacyMaskSettings-CqmJRsY0.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D-GizqmN.js → SceneMonitorEditor-D9LPLGDI.js} +1 -1
- package/dist/assets/index-Ds0hKW0X.js +112 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/index-CR-n-9UK.js +0 -112
package/dist/addon.js
CHANGED
|
@@ -7797,6 +7797,12 @@ function normalizeAddonInitResult(result) {
|
|
|
7797
7797
|
if (Array.isArray(result)) return { providers: result };
|
|
7798
7798
|
return result;
|
|
7799
7799
|
}
|
|
7800
|
+
/**
|
|
7801
|
+
* The share-view scope kinds a `csv_*` share token can carry. The hub mints
|
|
7802
|
+
* and validates them (`share-token.service.ts` builds its enum from this
|
|
7803
|
+
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7804
|
+
*/
|
|
7805
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7800
7806
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7801
7807
|
var PeerBytesTicketSchema = object({
|
|
7802
7808
|
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
@@ -12399,6 +12405,229 @@ var ConvertResultSchema = object({
|
|
|
12399
12405
|
files: array(string()).readonly()
|
|
12400
12406
|
})).readonly()
|
|
12401
12407
|
});
|
|
12408
|
+
/**
|
|
12409
|
+
* Zod schemas for persisted record types.
|
|
12410
|
+
*
|
|
12411
|
+
* These schemas serve as the single source of truth for types that are
|
|
12412
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
12413
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
12414
|
+
* enabling runtime validation when reading from the backend.
|
|
12415
|
+
*
|
|
12416
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
12417
|
+
* keeps the original name for backward compatibility.
|
|
12418
|
+
*/
|
|
12419
|
+
/**
|
|
12420
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
12421
|
+
*
|
|
12422
|
+
* Two principals:
|
|
12423
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
12424
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
12425
|
+
*
|
|
12426
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
12427
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
12428
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
12429
|
+
* distinction was only ever used to route role-specific procedures
|
|
12430
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
12431
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
12432
|
+
*/
|
|
12433
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
12434
|
+
var MethodAccessSchema = _enum([
|
|
12435
|
+
"view",
|
|
12436
|
+
"create",
|
|
12437
|
+
"delete"
|
|
12438
|
+
]);
|
|
12439
|
+
/**
|
|
12440
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
12441
|
+
* semantics; the first match decides whether the call passes:
|
|
12442
|
+
*
|
|
12443
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
12444
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
12445
|
+
* automatically — adding a device cap to the codebase makes it
|
|
12446
|
+
* reachable to every user with `category:device [...]` without a
|
|
12447
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
12448
|
+
*
|
|
12449
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
12450
|
+
* useful when an integration needs to interact with one specific
|
|
12451
|
+
* addon's surface regardless of how many caps it exports.
|
|
12452
|
+
*
|
|
12453
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
12454
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
12455
|
+
* and nothing else.
|
|
12456
|
+
*
|
|
12457
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
12458
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
12459
|
+
*/
|
|
12460
|
+
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
12461
|
+
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
12462
|
+
var CapScopeSchema = _enum(["device", "system"]);
|
|
12463
|
+
/**
|
|
12464
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
12465
|
+
*
|
|
12466
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
12467
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
12468
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
12469
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
12470
|
+
*
|
|
12471
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
12472
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
12473
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
12474
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
12475
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
12476
|
+
* is NOT covered until the grant is edited.
|
|
12477
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
12478
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
12479
|
+
* re-resolves on the next request.
|
|
12480
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
12481
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
12482
|
+
* null/unset location matches NO `locations` selector.
|
|
12483
|
+
*/
|
|
12484
|
+
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
12485
|
+
object({ kind: literal("all") }),
|
|
12486
|
+
object({
|
|
12487
|
+
kind: literal("ids"),
|
|
12488
|
+
ids: array(number().int()).min(1)
|
|
12489
|
+
}),
|
|
12490
|
+
object({
|
|
12491
|
+
kind: literal("types"),
|
|
12492
|
+
types: array(_enum(DeviceType)).min(1)
|
|
12493
|
+
}),
|
|
12494
|
+
object({
|
|
12495
|
+
kind: literal("locations"),
|
|
12496
|
+
locations: array(string().min(1)).min(1)
|
|
12497
|
+
})
|
|
12498
|
+
]);
|
|
12499
|
+
var DeviceTokenScopeSchema = object({
|
|
12500
|
+
type: literal("device"),
|
|
12501
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
12502
|
+
selector: DeviceSelectorSchema,
|
|
12503
|
+
access: array(MethodAccessSchema).min(1),
|
|
12504
|
+
/**
|
|
12505
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
12506
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
12507
|
+
* Direction is parent → children ONLY.
|
|
12508
|
+
*
|
|
12509
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
12510
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
12511
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
12512
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
12513
|
+
* explicitly to override that default per grant.
|
|
12514
|
+
*/
|
|
12515
|
+
includeLinked: boolean().optional()
|
|
12516
|
+
});
|
|
12517
|
+
/**
|
|
12518
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
12519
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
12520
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
12521
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
12522
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
12523
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
12524
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
12525
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
12526
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
12527
|
+
*/
|
|
12528
|
+
function migrateLegacyTokenScope(raw) {
|
|
12529
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
12530
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
12531
|
+
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
12532
|
+
const targets = Reflect.get(raw, "targets");
|
|
12533
|
+
if (!Array.isArray(targets)) return raw;
|
|
12534
|
+
return {
|
|
12535
|
+
type: "device",
|
|
12536
|
+
selector: {
|
|
12537
|
+
kind: "ids",
|
|
12538
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
12539
|
+
},
|
|
12540
|
+
access: Reflect.get(raw, "access")
|
|
12541
|
+
};
|
|
12542
|
+
}
|
|
12543
|
+
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
12544
|
+
object({
|
|
12545
|
+
type: literal("category"),
|
|
12546
|
+
target: CapScopeSchema,
|
|
12547
|
+
access: array(MethodAccessSchema).min(1)
|
|
12548
|
+
}),
|
|
12549
|
+
object({
|
|
12550
|
+
type: literal("capability"),
|
|
12551
|
+
target: string(),
|
|
12552
|
+
access: array(MethodAccessSchema).min(1)
|
|
12553
|
+
}),
|
|
12554
|
+
object({
|
|
12555
|
+
type: literal("addon"),
|
|
12556
|
+
target: string(),
|
|
12557
|
+
access: array(MethodAccessSchema).min(1)
|
|
12558
|
+
}),
|
|
12559
|
+
DeviceTokenScopeSchema
|
|
12560
|
+
]));
|
|
12561
|
+
object({
|
|
12562
|
+
id: string(),
|
|
12563
|
+
username: string(),
|
|
12564
|
+
passwordHash: string(),
|
|
12565
|
+
/**
|
|
12566
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
12567
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
12568
|
+
* role enum collapsed onto this boolean in v2.
|
|
12569
|
+
*/
|
|
12570
|
+
isAdmin: boolean().default(false),
|
|
12571
|
+
allowedProviders: AllowedProviderSchema,
|
|
12572
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12573
|
+
/**
|
|
12574
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
12575
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
12576
|
+
* protected call.
|
|
12577
|
+
*/
|
|
12578
|
+
scopes: array(TokenScopeSchema).default([]),
|
|
12579
|
+
createdAt: number(),
|
|
12580
|
+
updatedAt: number()
|
|
12581
|
+
});
|
|
12582
|
+
object({
|
|
12583
|
+
id: string(),
|
|
12584
|
+
label: string(),
|
|
12585
|
+
isAdmin: boolean().default(false),
|
|
12586
|
+
allowedProviders: AllowedProviderSchema,
|
|
12587
|
+
allowedDevices: AllowedDevicesSchema,
|
|
12588
|
+
tokenHash: string(),
|
|
12589
|
+
tokenPrefix: string(),
|
|
12590
|
+
createdAt: number(),
|
|
12591
|
+
lastUsedAt: number().optional()
|
|
12592
|
+
});
|
|
12593
|
+
object({
|
|
12594
|
+
id: string(),
|
|
12595
|
+
userId: string(),
|
|
12596
|
+
name: string(),
|
|
12597
|
+
tokenHash: string(),
|
|
12598
|
+
tokenPrefix: string(),
|
|
12599
|
+
scopes: array(TokenScopeSchema),
|
|
12600
|
+
expiresAt: number().nullish(),
|
|
12601
|
+
lastUsedAt: number().nullish(),
|
|
12602
|
+
createdAt: number()
|
|
12603
|
+
});
|
|
12604
|
+
/** What a share-view grant lets its holder see. */
|
|
12605
|
+
var ShareViewGrantSchema = object({
|
|
12606
|
+
kind: _enum(SHARE_VIEW_KINDS),
|
|
12607
|
+
deviceIds: array(number().int().nonnegative()).min(1).max(64),
|
|
12608
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
12609
|
+
talk: boolean().optional()
|
|
12610
|
+
});
|
|
12611
|
+
var ShareViewScopeSchema = object({
|
|
12612
|
+
type: literal("share-view"),
|
|
12613
|
+
grant: ShareViewGrantSchema
|
|
12614
|
+
});
|
|
12615
|
+
var AddonRoutesScopeSchema = object({
|
|
12616
|
+
type: literal("addon-routes"),
|
|
12617
|
+
access: array(MethodAccessSchema).min(1)
|
|
12618
|
+
});
|
|
12619
|
+
var CredentialScopeSchema = union([
|
|
12620
|
+
literal("*"),
|
|
12621
|
+
ShareViewScopeSchema,
|
|
12622
|
+
AddonRoutesScopeSchema,
|
|
12623
|
+
TokenScopeSchema
|
|
12624
|
+
]);
|
|
12625
|
+
object({
|
|
12626
|
+
kind: literal("credential"),
|
|
12627
|
+
sub: string().min(1),
|
|
12628
|
+
jti: string().min(16),
|
|
12629
|
+
scopes: array(CredentialScopeSchema).min(1)
|
|
12630
|
+
});
|
|
12402
12631
|
_enum(["new-session", "step-up"]);
|
|
12403
12632
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12404
12633
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -43536,202 +43765,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
43536
43765
|
auth: "admin"
|
|
43537
43766
|
}), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
|
|
43538
43767
|
/**
|
|
43539
|
-
* Zod schemas for persisted record types.
|
|
43540
|
-
*
|
|
43541
|
-
* These schemas serve as the single source of truth for types that are
|
|
43542
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
43543
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
43544
|
-
* enabling runtime validation when reading from the backend.
|
|
43545
|
-
*
|
|
43546
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
43547
|
-
* keeps the original name for backward compatibility.
|
|
43548
|
-
*/
|
|
43549
|
-
/**
|
|
43550
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
43551
|
-
*
|
|
43552
|
-
* Two principals:
|
|
43553
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
43554
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
43555
|
-
*
|
|
43556
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
43557
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
43558
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
43559
|
-
* distinction was only ever used to route role-specific procedures
|
|
43560
|
-
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
43561
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
43562
|
-
*/
|
|
43563
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
43564
|
-
var MethodAccessSchema = _enum([
|
|
43565
|
-
"view",
|
|
43566
|
-
"create",
|
|
43567
|
-
"delete"
|
|
43568
|
-
]);
|
|
43569
|
-
/**
|
|
43570
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
43571
|
-
* semantics; the first match decides whether the call passes:
|
|
43572
|
-
*
|
|
43573
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
43574
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
43575
|
-
* automatically — adding a device cap to the codebase makes it
|
|
43576
|
-
* reachable to every user with `category:device [...]` without a
|
|
43577
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
43578
|
-
*
|
|
43579
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
43580
|
-
* useful when an integration needs to interact with one specific
|
|
43581
|
-
* addon's surface regardless of how many caps it exports.
|
|
43582
|
-
*
|
|
43583
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
43584
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
43585
|
-
* and nothing else.
|
|
43586
|
-
*
|
|
43587
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
43588
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
43589
|
-
*/
|
|
43590
|
-
var AllowedProviderSchema = union([literal("*"), array(string())]);
|
|
43591
|
-
var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
|
|
43592
|
-
var CapScopeSchema = _enum(["device", "system"]);
|
|
43593
|
-
/**
|
|
43594
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
43595
|
-
*
|
|
43596
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
43597
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
43598
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
43599
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
43600
|
-
*
|
|
43601
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
43602
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
43603
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
43604
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
43605
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
43606
|
-
* is NOT covered until the grant is edited.
|
|
43607
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
43608
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
43609
|
-
* re-resolves on the next request.
|
|
43610
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
43611
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
43612
|
-
* null/unset location matches NO `locations` selector.
|
|
43613
|
-
*/
|
|
43614
|
-
var DeviceSelectorSchema = discriminatedUnion("kind", [
|
|
43615
|
-
object({ kind: literal("all") }),
|
|
43616
|
-
object({
|
|
43617
|
-
kind: literal("ids"),
|
|
43618
|
-
ids: array(number().int()).min(1)
|
|
43619
|
-
}),
|
|
43620
|
-
object({
|
|
43621
|
-
kind: literal("types"),
|
|
43622
|
-
types: array(_enum(DeviceType)).min(1)
|
|
43623
|
-
}),
|
|
43624
|
-
object({
|
|
43625
|
-
kind: literal("locations"),
|
|
43626
|
-
locations: array(string().min(1)).min(1)
|
|
43627
|
-
})
|
|
43628
|
-
]);
|
|
43629
|
-
var DeviceTokenScopeSchema = object({
|
|
43630
|
-
type: literal("device"),
|
|
43631
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
43632
|
-
selector: DeviceSelectorSchema,
|
|
43633
|
-
access: array(MethodAccessSchema).min(1),
|
|
43634
|
-
/**
|
|
43635
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
43636
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
43637
|
-
* Direction is parent → children ONLY.
|
|
43638
|
-
*
|
|
43639
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
43640
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
43641
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
43642
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
43643
|
-
* explicitly to override that default per grant.
|
|
43644
|
-
*/
|
|
43645
|
-
includeLinked: boolean().optional()
|
|
43646
|
-
});
|
|
43647
|
-
/**
|
|
43648
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
43649
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
43650
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
43651
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
43652
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
43653
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
43654
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
43655
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
43656
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
43657
|
-
*/
|
|
43658
|
-
function migrateLegacyTokenScope(raw) {
|
|
43659
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
43660
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
43661
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
43662
|
-
const targets = Reflect.get(raw, "targets");
|
|
43663
|
-
if (!Array.isArray(targets)) return raw;
|
|
43664
|
-
return {
|
|
43665
|
-
type: "device",
|
|
43666
|
-
selector: {
|
|
43667
|
-
kind: "ids",
|
|
43668
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
43669
|
-
},
|
|
43670
|
-
access: Reflect.get(raw, "access")
|
|
43671
|
-
};
|
|
43672
|
-
}
|
|
43673
|
-
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
43674
|
-
object({
|
|
43675
|
-
type: literal("category"),
|
|
43676
|
-
target: CapScopeSchema,
|
|
43677
|
-
access: array(MethodAccessSchema).min(1)
|
|
43678
|
-
}),
|
|
43679
|
-
object({
|
|
43680
|
-
type: literal("capability"),
|
|
43681
|
-
target: string(),
|
|
43682
|
-
access: array(MethodAccessSchema).min(1)
|
|
43683
|
-
}),
|
|
43684
|
-
object({
|
|
43685
|
-
type: literal("addon"),
|
|
43686
|
-
target: string(),
|
|
43687
|
-
access: array(MethodAccessSchema).min(1)
|
|
43688
|
-
}),
|
|
43689
|
-
DeviceTokenScopeSchema
|
|
43690
|
-
]));
|
|
43691
|
-
object({
|
|
43692
|
-
id: string(),
|
|
43693
|
-
username: string(),
|
|
43694
|
-
passwordHash: string(),
|
|
43695
|
-
/**
|
|
43696
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
43697
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
43698
|
-
* role enum collapsed onto this boolean in v2.
|
|
43699
|
-
*/
|
|
43700
|
-
isAdmin: boolean().default(false),
|
|
43701
|
-
allowedProviders: AllowedProviderSchema,
|
|
43702
|
-
allowedDevices: AllowedDevicesSchema,
|
|
43703
|
-
/**
|
|
43704
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
43705
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
43706
|
-
* protected call.
|
|
43707
|
-
*/
|
|
43708
|
-
scopes: array(TokenScopeSchema).default([]),
|
|
43709
|
-
createdAt: number(),
|
|
43710
|
-
updatedAt: number()
|
|
43711
|
-
});
|
|
43712
|
-
object({
|
|
43713
|
-
id: string(),
|
|
43714
|
-
label: string(),
|
|
43715
|
-
isAdmin: boolean().default(false),
|
|
43716
|
-
allowedProviders: AllowedProviderSchema,
|
|
43717
|
-
allowedDevices: AllowedDevicesSchema,
|
|
43718
|
-
tokenHash: string(),
|
|
43719
|
-
tokenPrefix: string(),
|
|
43720
|
-
createdAt: number(),
|
|
43721
|
-
lastUsedAt: number().optional()
|
|
43722
|
-
});
|
|
43723
|
-
object({
|
|
43724
|
-
id: string(),
|
|
43725
|
-
userId: string(),
|
|
43726
|
-
name: string(),
|
|
43727
|
-
tokenHash: string(),
|
|
43728
|
-
tokenPrefix: string(),
|
|
43729
|
-
scopes: array(TokenScopeSchema),
|
|
43730
|
-
expiresAt: number().nullish(),
|
|
43731
|
-
lastUsedAt: number().nullish(),
|
|
43732
|
-
createdAt: number()
|
|
43733
|
-
});
|
|
43734
|
-
/**
|
|
43735
43768
|
* `oauth-integration` — a collection cap by which an addon declares
|
|
43736
43769
|
* itself a linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
43737
43770
|
* Each provider returns a static descriptor; the core enumerates them
|
|
@@ -74086,7 +74119,7 @@ var AgentUIAddon = class extends BaseAddon {
|
|
|
74086
74119
|
capability: adminUiCapability,
|
|
74087
74120
|
provider: {
|
|
74088
74121
|
getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
|
|
74089
|
-
getVersion: async () => ({ version: "1.2.
|
|
74122
|
+
getVersion: async () => ({ version: "1.2.247" })
|
|
74090
74123
|
}
|
|
74091
74124
|
}];
|
|
74092
74125
|
}
|
|
@@ -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 a,c as o,d as s,h as c,l,p as u,t as ee}from"./index-
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,c as o,d as s,h as c,l,p as u,t as ee}from"./index-Ds0hKW0X.js";import{MaskShapeCanvas as d}from"./MaskShapeCanvas-BTvl6Rin.js";var f=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`}]]),p=n(i(),1),m=n(e(),1),h=110,g=`motion-zones`,_=0,te=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(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 S(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 C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:e}){let n=t(),i=s(c().trpcClient,e),[a,w]=(0,p.useState)(null),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(null),[N,P]=(0,p.useState)(v),[F,I]=(0,p.useState)(!1),[L,R]=(0,p.useState)(!1),z=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,w(null),O(!1),A(null),M(null),P(v),R(!1),(async()=>{try{let t=await i.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(w(t),z.current)return;let n=await i.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);z.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),a=x(r?r.shape.cells:[],t.grid.width,t.grid.height);M(a),A(T(a,t.grid.width,t.grid.height,v))}catch(t){if(e)return;l(t)?O(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[i]);let B=a?a.grid.width:0,V=a?a.grid.height:0,H=C(B,N),U=C(V,N),W=(0,p.useMemo)(()=>k&&a?E(k,B,V,N):null,[k,a,B,V,N]),G=(0,p.useMemo)(()=>W!==null&&j!==null&&!S(W,j),[W,j]),K=(0,p.useMemo)(()=>W?W.reduce((e,t)=>t?e+1:e,0):0,[W]),q=B*V,J=H*U,Y=(0,p.useCallback)(e=>{J>0&&A(Array.from({length:J},()=>e))},[J]),X=(0,p.useCallback)(()=>{A(e=>e&&e.map(e=>!e))},[]),Z=(0,p.useCallback)(()=>{j&&a&&A(T(j,B,V,N))},[j,a,B,V,N]),ne=(0,p.useCallback)(e=>{e===N||!a||A(t=>{if(!t)return P(e),t;let n=T(E(t,B,V,N),B,V,e);return P(e),n})},[N,a,B,V]),Q=(0,p.useMemo)(()=>a&&k?[{id:_,shape:{kind:`grid`,gridWidth:H,gridHeight:U,cells:[...k]}}]:[],[a,k,H,U]),$=(0,p.useCallback)((e,t)=>{t.kind===`grid`&&A(t.cells)},[]),re=(0,p.useCallback)(async()=>{if(!(!i||!k||!a)){I(!0);try{let e=E(k,a.grid.width,a.grid.height,N),t={kind:`grid`,gridWidth:a.grid.width,gridHeight:a.grid.height,cells:e};await i.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await i.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],a.grid.width,a.grid.height);M(t),A(T(t,a.grid.width,a.grid.height,N))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{I(!1)}}},[i,k,a,N]);ee((0,p.useMemo)(()=>L&&!D&&a&&k?{id:g,order:h,node:(0,m.jsx)(d,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:H,height:U},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[L,D,a,k,Q,$,H,U]));let ie=!D&&a!==null&&k!==null;return i?(0,m.jsx)(u,{title:n(`uiLibrary.motionZones.title`,`Motion Zones`),icon:(0,m.jsx)(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,m.jsx)(`div`,{className:`flex flex-col gap-3`,children:D?(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ie?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,m.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,m.jsx)(`strong`,{className:`text-foreground`},`e`),(0,m.jsx)(`strong`,{className:`text-foreground`},`s`),(0,m.jsx)(`strong`,{className:`text-foreground`},`c`)],values:{width:a.grid.width,height:a.grid.height}})}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),disabled:F,"aria-pressed":L,className:L?b:y,children:L?n(`uiLibrary.motionZones.doneEditing`,`Done editing`):n(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>Y(!0),disabled:F,className:y,children:n(`uiLibrary.motionZones.allOn`,`All on`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>Y(!1),disabled:F,className:y,children:n(`uiLibrary.motionZones.allOff`,`All off`)}),(0,m.jsx)(`button`,{type:`button`,onClick:X,disabled:F,className:y,children:n(`uiLibrary.motionZones.invert`,`Invert`)}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":n(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[(0,m.jsx)(`span`,{className:`${o} mr-0.5`,children:n(`uiLibrary.motionZones.cellSize`,`Cell size`)}),te.map(e=>(0,m.jsxs)(`button`,{type:`button`,onClick:()=>ne(e),disabled:F,"aria-pressed":N===e,title:e===1?n(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:B,height:V}):n(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(B,e),height:C(V,e),factor:e}),className:N===e?b:y,children:[`×`,e]},e))]}),(0,m.jsxs)(`span`,{className:`${o} ml-1 tabular-nums`,children:[n(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:K,total:q,width:a.grid.width,height:a.grid.height}),N===1?``:n(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:H,height:U})]}),(0,m.jsx)(`span`,{className:`flex-1`}),(0,m.jsx)(`button`,{type:`button`,onClick:Z,disabled:F||!G,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,m.jsx)(`button`,{type:`button`,onClick:()=>void re(),disabled:F||!G,className:b,children:F?n(`uiLibrary.motionZones.saving`,`Saving…`):n(`uiLibrary.motionZones.save`,`Save`)})]})]}):(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D 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 a,_ as ee,c as o,d as te,g as ne,h as s,l as c,p as re,t as l,x as u,y as d}from"./index-CR-n-9UK.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=te(s().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;c(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??[];l((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)(re,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(u,{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:ee;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)(ne,{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)(d,{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 a,_ as ee,c as o,d as te,g as ne,h as s,l as c,p as re,t as l,x as u,y as d}from"./index-Ds0hKW0X.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=te(s().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;c(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??[];l((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)(re,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(u,{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:ee;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)(ne,{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)(d,{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};
|