@camstack/addon-agent-ui 1.2.328 → 1.2.329

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.329] - 2026-11-05
11
+
12
+ ### Changed
13
+
14
+ - Rebuilt against updated dependencies.
15
+
10
16
  ## [1.2.328] - 2026-11-05
11
17
 
12
18
  ### Changed
@@ -372,12 +372,12 @@
372
372
  "server/server/packages/types/dist/composition-pOHbTzRB.mjs": "7151b5c9763e313c8b1e1b7e8a75ba722c3d5f160fceca4f0ecc41c32b3ecbc2",
373
373
  "server/server/packages/types/dist/device-type-D1fH5kaC.mjs": "4002ae7c812789715d7a35271c91b8133511b710eaeb07fea061d285db3dc14a",
374
374
  "server/server/packages/types/dist/event-category-BmPm98n0.mjs": "3617fc3941b34f1dcc8ebd3c1360e8c302747400d43e3ab694388496c2bb568d",
375
- "server/server/packages/types/dist/index.mjs": "f8f01806a9cd053178c894511eea489291384eb64ab4472c4d4c5dca0bdf4260",
375
+ "server/server/packages/types/dist/index.mjs": "7d9f7dd6365e5053a1703a99406e7876f34ecdf54befe46d12178ee969458f2f",
376
376
  "server/server/packages/types/dist/node-color.mjs": "942e663074f0a4ed2f8643848ec139eba4b5fd16d0d01c8a23e08a4819a8843b",
377
- "server/server/packages/types/dist/sleep-9TIHFj1w.mjs": "edfa5ab0adad5a335d59095bf941d933a086ed731a88a9b21f22b2e96bed2167",
377
+ "server/server/packages/types/dist/sleep-DEZaLbiu.mjs": "13de3cffba1edfd623935e587d2a56a46149eac03c7be68ea6b553f198278420",
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
- "server/server/packages/ui-library/src/composites/cap-settings/CameraGridLayoutEditor.tsx": "bfe36ccad931ef0981fe24fa315f136d35dbc3164df221346806173447178324",
380
+ "server/server/packages/ui-library/src/composites/cap-settings/CameraGridLayoutEditor.tsx": "fae93899c4903183e1b78db39e58bd52a3dd4dc2c11ce85d64e6d2a2bab7516d",
381
381
  "server/server/packages/ui-library/src/composites/cap-settings/MaskShapeCanvas.tsx": "ca7846aa2a59e518ffcc628e84dcfafbc0c6a5986b60a78de9b7e0f14ea6d4cf",
382
382
  "server/server/packages/ui-library/src/composites/cap-settings/MotionZonesSettings.tsx": "669572b21b8dab75f04e16fc26d574ab175a91659645af0508e4b8fecbb929a2",
383
383
  "server/server/packages/ui-library/src/composites/cap-settings/privacy-mask-audio.ts": "550f16f4c60a4b7e59d358d62cc833531ad09f201c3175be16dd7be01fd86842",
@@ -385,7 +385,7 @@
385
385
  "server/server/packages/ui-library/src/composites/cap-settings/scene-monitor-copy.ts": "34f4949481bd8e5e5a63d80cbb7d786be8f2aef9657b8de1ea37791561d9508d",
386
386
  "server/server/packages/ui-library/src/composites/cap-settings/SceneMonitorEditor.tsx": "6bbdca78cd092246ed818339df3c8d10d1fc11d6ae861d0072ce904d27ab068c",
387
387
  "server/server/packages/ui-library/src/composites/cap-settings/SceneReferenceGallery.tsx": "a2d95d286044a3c79763c9822fc4852153c7d572768e11f32d762f5f84cfa164",
388
- "server/server/packages/ui-library/src/composites/cap-settings/SceneSettingsForm.tsx": "8d50ae84a493d41bdf3986385814e40cefb76d2ab639759e724092a8d6cac3b8",
388
+ "server/server/packages/ui-library/src/composites/cap-settings/SceneSettingsForm.tsx": "16dc5e056c5838fcb05a402963c1239ea4b67b1ae8c8734c5705a08126f6e143",
389
389
  "server/server/packages/ui-library/src/composites/charts/chart-data.ts": "e2fabbcc28141d31a639ea416cd38628947e76b9625b8b696fc8efbcf53dbc79",
390
390
  "server/server/packages/ui-library/src/composites/config-secret-field.tsx": "10ae35353b5146401f6a04708275b79e80f86608dc1d289433a74077f0a005d8",
391
391
  "server/server/packages/ui-library/src/composites/confirm-action-button.tsx": "a68d08d5c2529f0400b6a92b51148c0572976a090bbac77cd91ca83917bfc1ea",
@@ -394,27 +394,27 @@
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": "95eed70361fc89d91b48371f1a014988a6dcc5cd9a58ed32dc1e4337f8f3495a",
397
+ "server/server/packages/ui-library/src/composites/data-table.tsx": "590fb29d4810ca52b372e98f221cbf03a1e592bd1301433c50dbb8fef9f3d627",
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
- "server/server/packages/ui-library/src/composites/device-controls/ac-panel.tsx": "113a529cdb5ba8df3998d7f23836bff87918d853eca52721d8d6ac71b44cdce0",
401
- "server/server/packages/ui-library/src/composites/device-controls/alarm-hero-card.tsx": "c7fbb844d05dd34cf3e9aa155fbd761abb026b1473b9e5588897d9ceef68a0c2",
400
+ "server/server/packages/ui-library/src/composites/device-controls/ac-panel.tsx": "72eeed188d98bd98421271ff83b6e5ba274edba8a516fd14a6e671f7fbd77b6b",
401
+ "server/server/packages/ui-library/src/composites/device-controls/alarm-hero-card.tsx": "70e80e12af8ea3dc0354a7cf97cd2bfac6f40caeffc64ec76a54c1b33261dbe2",
402
402
  "server/server/packages/ui-library/src/composites/device-controls/appliance-control.tsx": "e745821fb0aa6fcc778aa779cae6c54c76a9db9cfc8dbe78efe077aae435137a",
403
403
  "server/server/packages/ui-library/src/composites/device-controls/atoms.tsx": "c17c3e2e4671e8ff34bb2c84b2fb99dc7725adf48914e349ccefe6926211b62a",
404
404
  "server/server/packages/ui-library/src/composites/device-controls/brightness-panel.tsx": "01df55644ef07e2cfbe907749230f490761dac3e943ae7e750978146f0070523",
405
405
  "server/server/packages/ui-library/src/composites/device-controls/button-control.tsx": "23eacecd2ace64d0c0f73218ca6e395cc1b147c442313a49ff534cfcf1515d77",
406
- "server/server/packages/ui-library/src/composites/device-controls/climate-panel.tsx": "483d37e1ff92d4bfd0b368c89970b56969dac6f1d15953499eeafe92ca6be186",
407
- "server/server/packages/ui-library/src/composites/device-controls/control-panel.tsx": "bda95749815c5169072de0418e8a97b3888937394bfff34ba3c032a6088716af",
406
+ "server/server/packages/ui-library/src/composites/device-controls/climate-panel.tsx": "7505302f38db3fba0aaa8ac3d21b273df1a657b165c200060fc45055416279c2",
407
+ "server/server/packages/ui-library/src/composites/device-controls/control-panel.tsx": "8f40bcf16572d8643fbdfc677054a77e8b288a2be4252d3f8658fb43739c8247",
408
408
  "server/server/packages/ui-library/src/composites/device-controls/control-registry.tsx": "8018386c7a8575ee91d4955946a26041ee983a227f6c0f62a563b4e81f848662",
409
409
  "server/server/packages/ui-library/src/composites/device-controls/cover-hero-card.tsx": "dd32357f3a917968db7b9f96dd524c4c78f5e137a08d3fc73a2d6ee9323d60e0",
410
410
  "server/server/packages/ui-library/src/composites/device-controls/cover-inline.tsx": "dd28159f7913ffbde4cc66cd183d897c42c1ab602c50ab7ec7c24f67de1538d7",
411
- "server/server/packages/ui-library/src/composites/device-controls/dishwasher-control.tsx": "125691ffe16f8983b6d4a40740e64f5e2f5f8318cb8088d8d11e47f255676405",
411
+ "server/server/packages/ui-library/src/composites/device-controls/dishwasher-control.tsx": "385869ffb2c818b5a46aadb5373fc088a42252f8f3b1eb3eb88c5238841cd71d",
412
412
  "server/server/packages/ui-library/src/composites/device-controls/dummy-hero-card.tsx": "da22c19d858b89958a188145b951823ea1b859407d8b52122971ce091c39eac5",
413
- "server/server/packages/ui-library/src/composites/device-controls/fan-hero-card.tsx": "d239ca73cbda1f6b6ac849b0fd7fb6025c916297bfd979aa265d1853012506d4",
414
- "server/server/packages/ui-library/src/composites/device-controls/fan-panel.tsx": "081cdea3f6d5f31d964d11aaffdb96b8ebfae92548b619a1e11d7228e9fee36b",
413
+ "server/server/packages/ui-library/src/composites/device-controls/fan-hero-card.tsx": "aed188f419c28490b85e056100555dce86d27cc9b384b7111450d8d367356cd0",
414
+ "server/server/packages/ui-library/src/composites/device-controls/fan-panel.tsx": "ed4e8d335e4766062296054e79047a687987e66db010e621f24b4e0dea71bc65",
415
415
  "server/server/packages/ui-library/src/composites/device-controls/heater-control.tsx": "acf6d07cb206daf53e6188a388e4e51455e3071d3b2fb59525af2c63e05fcec3",
416
416
  "server/server/packages/ui-library/src/composites/device-controls/heating-valve-readout.tsx": "f353a9fb597f8ffbbcaab074efb70d536e4fb0f062d654344d7fe52493e7718f",
417
- "server/server/packages/ui-library/src/composites/device-controls/humidifier-control.tsx": "74e66f53be2a8587a2b6e8089a14cbaa421b2fc0c3edc155a2ce74a3f9acabc2",
417
+ "server/server/packages/ui-library/src/composites/device-controls/humidifier-control.tsx": "3f6496da4a719b27fcc8cce0fe6a3669ae873af2bd9f3e2916cafadcab6c8da7",
418
418
  "server/server/packages/ui-library/src/composites/device-controls/image-control.tsx": "e684955ab4e90e4e0b6a5bb4a0533e4e7d16c9edda8160ee5501b2742d5e3dd7",
419
419
  "server/server/packages/ui-library/src/composites/device-controls/lawn-mower-control.tsx": "0ea5963d2d4940ca7ec587e2fcfee80dc37c08460990a070330edb9f466c9056",
420
420
  "server/server/packages/ui-library/src/composites/device-controls/light-hero-card.tsx": "c502a4289ff4e07b6d4d7442dafcd2b7e64f4901bc40b64ef7708069ebbb525e",
@@ -422,7 +422,7 @@
422
422
  "server/server/packages/ui-library/src/composites/device-controls/lock-panel.tsx": "d9a67420049fa25051e020c84cf711b82617f4e086c9b1f6bae8b1e31c0ab0ec",
423
423
  "server/server/packages/ui-library/src/composites/device-controls/media-player-hero-card.tsx": "4b1dd26275c3e231491d4a6c800eac18be463d9859ae18ce14effa57a1e13052",
424
424
  "server/server/packages/ui-library/src/composites/device-controls/media-player-hero-parts.tsx": "206ba5f7ddf4ecc7eea4b7d03ba886486554050d6e213d7c6c75dfc59cc54a95",
425
- "server/server/packages/ui-library/src/composites/device-controls/media-player-panel.tsx": "6708664f0ee704dadbfae1576c79492dd18789dcf04c9e9b2a9621fb5b73cbe2",
425
+ "server/server/packages/ui-library/src/composites/device-controls/media-player-panel.tsx": "e67ad33c08a426baf97204134cc4a68cdeeeef51418ac11023a9343b547e0987",
426
426
  "server/server/packages/ui-library/src/composites/device-controls/media-player-view.ts": "d2ac0d8393988afaa5de0fe0ffa2b58aa171dad8aa45b3b756d36a13fb0d644c",
427
427
  "server/server/packages/ui-library/src/composites/device-controls/panel-controls.tsx": "adefb5bcae34bf27f2858221cfaf2be6f86a84c1bf5776e5ab61987cd069116d",
428
428
  "server/server/packages/ui-library/src/composites/device-controls/pet-feeder-panel.tsx": "5d521ed27b5145cd23e36cde522457c19c5babccc00f0faa0b9b5899cc18106a",
@@ -436,12 +436,12 @@
436
436
  "server/server/packages/ui-library/src/composites/device-controls/switch-hero-card.tsx": "8d9f35e04ea98d813f810541a944d2b2682d03321993ed88cf6878f11aab98c2",
437
437
  "server/server/packages/ui-library/src/composites/device-controls/switch-panel.tsx": "60a8dc4866b94eb188b1984d2781ac6f7bcb4da484911417fb00efe61dc2f160",
438
438
  "server/server/packages/ui-library/src/composites/device-controls/tap-toggle.tsx": "b780d12cead7811b050bb4a3c82db82f1b67ffd498e690488bdeb330cf550a99",
439
- "server/server/packages/ui-library/src/composites/device-controls/thermostat-hero-card.tsx": "72a92421afab179bc773d64856526f4d06d5d14472948fbcec88c64c5fcdffde",
439
+ "server/server/packages/ui-library/src/composites/device-controls/thermostat-hero-card.tsx": "a5bba2c00ceb757f2d501edf1ab2e662a95861319f994402de7e7419dc0c9b32",
440
440
  "server/server/packages/ui-library/src/composites/device-controls/timed-run-control.tsx": "f820e32342dd753354d04aa374f54c997f577ac6851e8070fcecce851aa99072",
441
441
  "server/server/packages/ui-library/src/composites/device-controls/update-control.tsx": "2bf21ad951557a0f6db23864e6393f5a42a544e501d864db84c50be1fcb6d7db",
442
- "server/server/packages/ui-library/src/composites/device-controls/vacuum-control.tsx": "0097fc89f245eef9e4c940cd7cc70c5945307969c05a6aa25983943f41d01349",
442
+ "server/server/packages/ui-library/src/composites/device-controls/vacuum-control.tsx": "b17c6f292add8b91859c0cd1cbf4ff39ca276f5d0a12c6c52a02e063cecf03cd",
443
443
  "server/server/packages/ui-library/src/composites/device-controls/valve-control.tsx": "373f34532ac55a02db9163927a7e63be9cdbba52b5d16e9e10b71bb7802e0131",
444
- "server/server/packages/ui-library/src/composites/device-controls/water-heater-control.tsx": "4a2bad97090f2d115973c68eb60a2973c8edbb02d40a58daecdaffcd5a49b971",
444
+ "server/server/packages/ui-library/src/composites/device-controls/water-heater-control.tsx": "46e014e0dde0b0eda94d5a69720159a69d81b8ed47fa1b16512428a4c7ec3e4c",
445
445
  "server/server/packages/ui-library/src/composites/device-controls/weather-control.tsx": "46cab536e8388072e0123f7b84b1b66d837791c4216b4df0df47a7a34fbca75b",
446
446
  "server/server/packages/ui-library/src/composites/device-export-panel.tsx": "4b6879f7a3205cab31e757af8d171c6c174c4c958a8db6018c33aa8df40759a4",
447
447
  "server/server/packages/ui-library/src/composites/device-history/history-selection.ts": "472d8a88d824218318707fbc017f5bcce3a777e88c2d7c59c0563ae88530aa8b",
@@ -528,7 +528,7 @@
528
528
  "server/server/packages/ui-library/src/primitives/popover.tsx": "f9ba386cb8ce82780a791667fa4f1e35d0d7a435ab9e323012a6753316a8d636",
529
529
  "server/server/packages/ui-library/src/primitives/radio.tsx": "bbb7e67e2e5a07e60c0d0545d4a8fa6f02f80758be8b820b6963760ff7f0561d",
530
530
  "server/server/packages/ui-library/src/primitives/scroll-area.tsx": "681c6f6852b294808b946689e276457baa6cd3ed4b0b943ab51d637863d8d58e",
531
- "server/server/packages/ui-library/src/primitives/select.tsx": "b88105f1bfccd1e62e78cb07badfcca423b3447f39ac39770237ff7b9724d819",
531
+ "server/server/packages/ui-library/src/primitives/select.tsx": "1e6c6b2e3e7b8a448c651078fbf54e1e1f672c4ce39c4b872bda4b04f808b483",
532
532
  "server/server/packages/ui-library/src/primitives/separator.tsx": "a619d82e35635e269d1ac9799c8e3846bd9a13481804e7ff69efb734184c3f6c",
533
533
  "server/server/packages/ui-library/src/primitives/skeleton.tsx": "039478c8d7d6741a30cae85650ec2798d0dd1e41b772de42be896471df082e50",
534
534
  "server/server/packages/ui-library/src/primitives/slider.tsx": "6d931092aaa4923c1b2f31aea78aac78b9ca4f7a68425ad6f973a8f1389dbd10",
package/dist/addon.js CHANGED
@@ -5849,7 +5849,7 @@ var ZodIssueCode = {
5849
5849
  var ZodFirstPartyTypeKind;
5850
5850
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5851
5851
  //#endregion
5852
- //#region ../types/dist/sleep-9TIHFj1w.mjs
5852
+ //#region ../types/dist/sleep-DEZaLbiu.mjs
5853
5853
  /**
5854
5854
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5855
5855
  * window to float samples (D455).
@@ -6604,6 +6604,12 @@ function projectStore(store, perNodeKeys, nodeId) {
6604
6604
  }
6605
6605
  return out;
6606
6606
  }
6607
+ /** Every scope, in the order the guard and the docs list them. */
6608
+ var SCOPED_SETTINGS_SCOPES = [
6609
+ "cluster",
6610
+ "device-defaults",
6611
+ "node"
6612
+ ];
6607
6613
  var GLOBAL_SCOPE = { kind: "global" };
6608
6614
  /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6609
6615
  function globalSecretScope() {
@@ -7453,6 +7459,13 @@ var BaseAddon = class {
7453
7459
  */
7454
7460
  secretStatePaths = [];
7455
7461
  _addonSecretTree = null;
7462
+ /**
7463
+ * D986 M4: the scoped schemas this addon declared, resolved once per capability
7464
+ * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
7465
+ * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
7466
+ */
7467
+ _scopedByCap = /* @__PURE__ */ new Map();
7468
+ _nodeKeysByCap = /* @__PURE__ */ new Map();
7456
7469
  _deviceSecretTree = null;
7457
7470
  /** Refs the last resolved config pointed at — a change to one re-resolves. */
7458
7471
  _configSecretRefs = /* @__PURE__ */ new Set();
@@ -7522,6 +7535,7 @@ var BaseAddon = class {
7522
7535
  this._ctx = context;
7523
7536
  this._secretSettings = null;
7524
7537
  }
7538
+ await this.loadScopedSchemas();
7525
7539
  await this.resolveConfig();
7526
7540
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7527
7541
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -7531,6 +7545,7 @@ var BaseAddon = class {
7531
7545
  const normalized = normalizeAddonInitResult(result);
7532
7546
  const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
7533
7547
  this._registeredCapNames = providers.map((p) => p.capability.name);
7548
+ await this.loadScopedSchemas();
7534
7549
  return normalized;
7535
7550
  }
7536
7551
  /**
@@ -7619,6 +7634,16 @@ var BaseAddon = class {
7619
7634
  schema(schema) {
7620
7635
  return schema;
7621
7636
  }
7637
+ /**
7638
+ * The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
7639
+ * {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
7640
+ * `onInitialize`, when the providers it registers are not known yet: the first config resolve
7641
+ * must already know which keys are per node. Names the providers register at init are added
7642
+ * once known.
7643
+ */
7644
+ scopedSettingsCapabilities() {
7645
+ return [];
7646
+ }
7622
7647
  /** Override to provide global-level settings UI schema. */
7623
7648
  globalSettingsSchema(_cap) {
7624
7649
  return null;
@@ -7662,7 +7687,8 @@ var BaseAddon = class {
7662
7687
  return [];
7663
7688
  }
7664
7689
  async getGlobalSettings(overlay, cap, nodeId) {
7665
- const schema = this.globalSettingsSchema(cap);
7690
+ await this.loadScopedSchemas(cap);
7691
+ const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
7666
7692
  if (!schema) return { sections: [] };
7667
7693
  const projected = await this.readRawProjectedStore(nodeId, cap);
7668
7694
  return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
@@ -7793,6 +7819,7 @@ var BaseAddon = class {
7793
7819
  * resolved blob back is a no-op for every unchanged secret.
7794
7820
  */
7795
7821
  async resolveGlobalStore(nodeId, cap) {
7822
+ await this.loadScopedSchemas(cap);
7796
7823
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7797
7824
  return this.projectForNode(raw, nodeId, cap);
7798
7825
  }
@@ -7803,6 +7830,7 @@ var BaseAddon = class {
7803
7830
  }
7804
7831
  /** The PROJECTED store with its markers — the form hydrate only (D798). */
7805
7832
  async readRawProjectedStore(nodeId, cap) {
7833
+ await this.loadScopedSchemas(cap);
7806
7834
  const raw = await this.rawSettings()?.readAddonStore() ?? {};
7807
7835
  return this.projectForNode(raw, nodeId, cap);
7808
7836
  }
@@ -7905,6 +7933,7 @@ var BaseAddon = class {
7905
7933
  await this.applyGlobalPatch(patch, nodeId);
7906
7934
  }
7907
7935
  async applyGlobalPatch(barePatch, nodeId) {
7936
+ await this.loadScopedSchemas();
7908
7937
  const keys = this.perNodeKeys();
7909
7938
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7910
7939
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
@@ -7918,7 +7947,8 @@ var BaseAddon = class {
7918
7947
  await this.resolveConfig();
7919
7948
  await this.onConfigChanged();
7920
7949
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
7921
- this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
7950
+ const legacy = this.globalSettingsSchema();
7951
+ this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
7922
7952
  }
7923
7953
  /**
7924
7954
  * The set of field keys the global settings schema declares `perNode: true`
@@ -7926,14 +7956,67 @@ var BaseAddon = class {
7926
7956
  * declarations). Empty set ⇒ every per-node code path is bypassed and the
7927
7957
  * settings API behaves exactly like the legacy node-agnostic one.
7928
7958
  */
7929
- _perNodeKeysCache = /* @__PURE__ */ new Map();
7959
+ /**
7960
+ * Load the scoped schemas of every capability this addon declares (the override and the
7961
+ * providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
7962
+ * derived from the previous set. Idempotent.
7963
+ */
7964
+ async loadScopedSchemas(extraCap) {
7965
+ const caps = new Set([
7966
+ ...this.scopedSettingsCapabilities(),
7967
+ ...this._registeredCapNames,
7968
+ ...extraCap === void 0 ? [] : [extraCap]
7969
+ ]);
7970
+ let added = false;
7971
+ for (const cap of caps) {
7972
+ if (this._scopedByCap.has(cap)) continue;
7973
+ const loaded = [];
7974
+ for (const scope of SCOPED_SETTINGS_SCOPES) {
7975
+ const schema = await this.getScopedSettingsSchema(scope, cap);
7976
+ if (schema !== null) loaded.push({
7977
+ scope,
7978
+ schema
7979
+ });
7980
+ }
7981
+ this._scopedByCap.set(cap, loaded);
7982
+ added = true;
7983
+ }
7984
+ if (!added) return;
7985
+ this._nodeKeysByCap = /* @__PURE__ */ new Map();
7986
+ this._addonSecretTree = null;
7987
+ }
7988
+ /**
7989
+ * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
7990
+ * sections of its scoped schemas, so dropping the old hook does not blank the form.
7991
+ */
7992
+ scopedFormSchema(cap) {
7993
+ const byId = /* @__PURE__ */ new Map();
7994
+ for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
7995
+ return byId.size === 0 ? null : { sections: [...byId.values()] };
7996
+ }
7997
+ /** Every loaded scoped schema of `cap`, or of every loaded capability. */
7998
+ loadedScopedSchemas(cap) {
7999
+ if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
8000
+ return [...this._scopedByCap.values()].flat();
8001
+ }
8002
+ /**
8003
+ * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
8004
+ * the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
8005
+ * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
8006
+ * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
8007
+ * Call {@link loadScopedSchemas} first (the async seams do).
8008
+ */
7930
8009
  perNodeKeys(cap) {
7931
8010
  const cacheKey = cap ?? "";
7932
- const cached = this._perNodeKeysCache.get(cacheKey);
8011
+ const cached = this._nodeKeysByCap.get(cacheKey);
7933
8012
  if (cached) return cached;
7934
- const schema = this.globalSettingsSchema(cap);
7935
- const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
7936
- this._perNodeKeysCache.set(cacheKey, keys);
8013
+ const legacy = this.globalSettingsSchema(cap);
8014
+ const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
8015
+ for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
8016
+ if (scope !== "node") continue;
8017
+ for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
8018
+ }
8019
+ this._nodeKeysByCap.set(cacheKey, keys);
7937
8020
  return keys;
7938
8021
  }
7939
8022
  /**
@@ -7943,10 +8026,9 @@ var BaseAddon = class {
7943
8026
  * time to return its response before the addon is torn down and
7944
8027
  * re-initialised by `AddonRegistryService.restartAddon`.
7945
8028
  */
7946
- maybeAutoRestart(patchKeys, schema) {
7947
- if (!schema) return;
8029
+ maybeAutoRestart(patchKeys, schemas) {
7948
8030
  const restartKeys = /* @__PURE__ */ new Set();
7949
- for (const section of schema.sections) for (const field of section.fields) {
8031
+ for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
7950
8032
  if (field.type === "separator" || field.type === "info") continue;
7951
8033
  if (field.requiresRestart) restartKeys.add(field.key);
7952
8034
  }
@@ -8142,12 +8224,14 @@ var BaseAddon = class {
8142
8224
  * here, in the addon's own process, so the hub keeps no copy of it.
8143
8225
  */
8144
8226
  async getDeclaredSettingsKeys() {
8227
+ await this.loadScopedSchemas();
8145
8228
  return { keys: [...this.declaredKeySet()].toSorted() };
8146
8229
  }
8147
8230
  declaredKeySet() {
8148
8231
  const keys = new Set(Object.keys(this.defaults));
8149
8232
  const schema = this.globalSettingsSchema();
8150
8233
  if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
8234
+ for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
8151
8235
  for (const key of this._declaredStateKeys) keys.add(key);
8152
8236
  for (const path of this.secretStatePaths) {
8153
8237
  const root = path.split(/[.[]/, 1)[0];
@@ -8243,7 +8327,11 @@ var BaseAddon = class {
8243
8327
  }
8244
8328
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
8245
8329
  addonSecretTree() {
8246
- this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
8330
+ if (this._addonSecretTree === null) {
8331
+ const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
8332
+ for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
8333
+ this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
8334
+ }
8247
8335
  return this._addonSecretTree;
8248
8336
  }
8249
8337
  deviceSecretTree() {
@@ -8493,6 +8581,23 @@ function dropPerNodeFields(fields) {
8493
8581
  }
8494
8582
  return kept;
8495
8583
  }
8584
+ /** The keys of the value-holding fields, recursing into layout containers. */
8585
+ function collectValueFieldKeys(fields) {
8586
+ const collected = [];
8587
+ for (const field of fields) {
8588
+ if (field.type === "group") {
8589
+ collected.push(...collectValueFieldKeys(field.fields));
8590
+ continue;
8591
+ }
8592
+ if (field.type === "sub-tabs") {
8593
+ for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
8594
+ continue;
8595
+ }
8596
+ if (field.type === "separator" || field.type === "info") continue;
8597
+ if ("key" in field && typeof field.key === "string") collected.push(field.key);
8598
+ }
8599
+ return collected;
8600
+ }
8496
8601
  function collectFieldKeys(fields) {
8497
8602
  const collected = [];
8498
8603
  for (const field of fields) {
@@ -49642,7 +49747,14 @@ var DiscoveryCandidateSchema = object({
49642
49747
  /** `stableId` of the gateway candidate this device was found BEHIND. */
49643
49748
  parentStableId: string().optional(),
49644
49749
  /** `false` = shown for context but not pickable. Default true. */
49645
- selectable: boolean().optional()
49750
+ selectable: boolean().optional(),
49751
+ /**
49752
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
49753
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
49754
+ * admin asks for exactly these, on the creation form prefilled with
49755
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
49756
+ */
49757
+ needsParams: array(string()).optional()
49646
49758
  });
49647
49759
  /**
49648
49760
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -49701,12 +49813,18 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
49701
49813
  }), array(DiscoveryCandidateSchema), {
49702
49814
  kind: "mutation",
49703
49815
  auth: "admin"
49704
- }), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
49816
+ }), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
49817
+ candidate: DiscoveryCandidateSchema,
49818
+ /** The integration the operator adopts into; a provider with several instances needs it. */
49819
+ integrationId: string().optional()
49820
+ }), DeviceSummarySchema, {
49705
49821
  kind: "mutation",
49706
49822
  auth: "admin"
49707
49823
  }), method(object({}), boolean()), method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema), method(object({
49708
49824
  type: _enum(DeviceType),
49709
- config: record(string(), unknown())
49825
+ config: record(string(), unknown()),
49826
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
49827
+ integrationId: string().optional()
49710
49828
  }), DeviceSummarySchema, {
49711
49829
  kind: "mutation",
49712
49830
  auth: "admin"
@@ -90090,7 +90208,7 @@ var AgentUIAddon = class extends BaseAddon {
90090
90208
  capability: adminUiCapability,
90091
90209
  provider: {
90092
90210
  getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
90093
- getVersion: async () => ({ version: "1.2.328" })
90211
+ getVersion: async () => ({ version: "1.2.329" })
90094
90212
  }
90095
90213
  }];
90096
90214
  }
@@ -0,0 +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-D-AUBT8T.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};
@@ -0,0 +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-D-AUBT8T.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};
@@ -0,0 +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-D-AUBT8T.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};