@camstack/addon-admin-ui 1.2.440 → 1.2.441

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/assets/{AddonAssetIcon-DoCqXzAv.js → AddonAssetIcon-CCzVCA49.js} +1 -1
  2. package/dist/assets/{Addons-CrSVEbe3.js → Addons-CUPFTOFz.js} +1 -1
  3. package/dist/assets/{AdminPage-KGO_m_yt.js → AdminPage--m3xHpjx.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BiMhPKOP.js → AdminSectionedPage-D5J86Kfp.js} +1 -1
  5. package/dist/assets/{AiProfiles-D8mKo1K9.js → AiProfiles-CEZqx-Sw.js} +1 -1
  6. package/dist/assets/{BrokerForm-yx58WRgh.js → BrokerForm-Cd5z8Mk0.js} +1 -1
  7. package/dist/assets/{Build-BArewEF3.js → Build-RW9SjiCM.js} +5 -5
  8. package/dist/assets/{Calendars-BdN8ZQmv.js → Calendars-CVnE0N6y.js} +1 -1
  9. package/dist/assets/{Cluster-Bn5YZafT.js → Cluster-DdgLAQcF.js} +1 -1
  10. package/dist/assets/{ClusterStepModel-DPmlzTfm.js → ClusterStepModel-BbVbEWqh.js} +1 -1
  11. package/dist/assets/CompositionEditor-BDEQF7e9.js +1 -0
  12. package/dist/assets/{CompositionEditorPage-BwqVkeY-.js → CompositionEditorPage-D3LiFLq4.js} +1 -1
  13. package/dist/assets/{Data-BvY-zVHv.js → Data-TI1fXQ8e.js} +1 -1
  14. package/dist/assets/DeviceDetail-Ry7b522t.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-C6f9gioM.js → DeviceDoActionFields-n2-NdVST.js} +1 -1
  16. package/dist/assets/{Devices-CtivG8K9.js → Devices-BacO9x6N.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-BD-Z7zz-.js → EmbedPlayerPage-DgFNOUrt.js} +1 -1
  18. package/dist/assets/{Identity-BQNP0wku.js → Identity-BPWd0o-B.js} +1 -1
  19. package/dist/assets/{IntegrationDetail-CzEG-I4B.js → IntegrationDetail-CFsboI2-.js} +1 -1
  20. package/dist/assets/{IntegrationHub-tqxee2Rm.js → IntegrationHub-BRMnV56J.js} +1 -1
  21. package/dist/assets/{Integrations-C7Ptcn3c.js → Integrations-Bf2SzcCT.js} +1 -1
  22. package/dist/assets/{Integrations-GZm_SrQK.js → Integrations-CBqnh8t8.js} +1 -1
  23. package/dist/assets/{Library-ToUHY4O3.js → Library-yKp-qGfV.js} +1 -1
  24. package/dist/assets/{Locations-CPFCvUKd.js → Locations-BCY7diBp.js} +1 -1
  25. package/dist/assets/{Logs-Ds6SPC6o.js → Logs-DWz6dVJo.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-BoY32Qvt.js → MaskShapeCanvas-wkrQJhyN.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-DBW4jTEr.js → MotionZonesSettings-BZneggiu.js} +1 -1
  28. package/dist/assets/{MyAccess-2mSUBp14.js → MyAccess-DmuNu2nC.js} +1 -1
  29. package/dist/assets/{Network-BddKO6B1.js → Network-CMlIm20D.js} +1 -1
  30. package/dist/assets/{NodeAddonsSettingsPanel-CIISQuIL.js → NodeAddonsSettingsPanel-BxeQZ-hu.js} +1 -1
  31. package/dist/assets/Notifications-B0nD4977.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-z8P3R0fA.js → PrivacyMaskSettings-CN2hF3qR.js} +1 -1
  33. package/dist/assets/{Recordings-g1Jxg_Lr.js → Recordings-CkHyBhqh.js} +1 -1
  34. package/dist/assets/{ScanNetworkModal-D7N2aC7y.js → ScanNetworkModal-CfHHLP_k.js} +1 -1
  35. package/dist/assets/{SceneMonitorEditor-CyjEekEM.js → SceneMonitorEditor-CU-Yj4Sw.js} +1 -1
  36. package/dist/assets/{SessionsList-bmTxxIOE.js → SessionsList-DrSkZMrj.js} +1 -1
  37. package/dist/assets/{Showroom-PlFtcQrL.js → Showroom-ChGRG_dB.js} +1 -1
  38. package/dist/assets/{System-DxszqVYV.js → System-GfppoElu.js} +1 -1
  39. package/dist/assets/{Terminal-BMG2w8DZ.js → Terminal-C7azorOj.js} +1 -1
  40. package/dist/assets/{Viewer-CRLD_tt7.js → Viewer-DWdf6_8H.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GapjKGVe.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CGI8Rmb1.js} +1 -1
  42. package/dist/assets/{addon-icons-context-BrgGsfoE.js → addon-icons-context-D3LZwxs2.js} +1 -1
  43. package/dist/assets/{archive-Dx-auPAN.js → archive-BOODG6Jz.js} +1 -1
  44. package/dist/assets/{authed-media-MhMmWNH3.js → authed-media-F_SweyTm.js} +1 -1
  45. package/dist/assets/{bell-off-BQQTURVF.js → bell-off-acWBqVHX.js} +1 -1
  46. package/dist/assets/{boxes-BIK98bHo.js → boxes-U2BARjlG.js} +1 -1
  47. package/dist/assets/circle-slash-90QkMLx4.js +1 -0
  48. package/dist/assets/client-yfOXPkcm.js +358 -0
  49. package/dist/assets/{cloud-upload-FvK6xW2I.js → cloud-upload-C12rtBFh.js} +1 -1
  50. package/dist/assets/crop-BjSJZpbg.js +1 -0
  51. package/dist/assets/{device-integration-icon-ClmWzwM_.js → device-integration-icon-BeeizbXV.js} +1 -1
  52. package/dist/assets/device-picker-model-CRpYde_B.js +1 -0
  53. package/dist/assets/dist-BfR6seq4.js +358 -0
  54. package/dist/assets/{dist-CEnfZ10I.js → dist-CQud2KJs.js} +1 -1
  55. package/dist/assets/{eraser-CUAqtnBD.js → eraser-BmJjK2wc.js} +1 -1
  56. package/dist/assets/{hard-drive-download-XGtks2vE.js → hard-drive-download-DfnBSa39.js} +1 -1
  57. package/dist/assets/{history-DqvhlzWX.js → history-CNfarVY1.js} +1 -1
  58. package/dist/assets/{hostInit-DzBGXsvZ.js → hostInit-Df4MAORd.js} +1 -1
  59. package/dist/assets/{icons-DNRi-jSy.js → icons-BLn-D-gO.js} +1 -1
  60. package/dist/assets/{index-yoPG03d0.js → index-CcAR8Rlk.js} +3 -3
  61. package/dist/assets/{key-bw9xhRgT.js → key-BF4fZLz_.js} +1 -1
  62. package/dist/assets/{key-round-BngMS2dZ.js → key-round-CjE9GF4T.js} +1 -1
  63. package/dist/assets/{layers-CIl8QXpN.js → layers-b-H6nVdd.js} +1 -1
  64. package/dist/assets/{linked-devices-model-CclOXMLj.js → linked-devices-model-BMUapBfD.js} +1 -1
  65. package/dist/assets/{list-ordered-_52_xrQ7.js → list-ordered-CxtL1h3H.js} +1 -1
  66. package/dist/assets/{location-owned-usage-5eb6nny3.js → location-owned-usage-DVh3ypCw.js} +1 -1
  67. package/dist/assets/{log-in-DH9Lu6bJ.js → log-in-D4y0eEu8.js} +1 -1
  68. package/dist/assets/{memory-stick-CzaP6KiN.js → memory-stick-jw7STOQc.js} +1 -1
  69. package/dist/assets/{message-square-plus-vMywres_.js → message-square-plus-EaPlmlsM.js} +1 -1
  70. package/dist/assets/{mf-entry-bootstrap-0-54468006.js → mf-entry-bootstrap-0-8a2679ae.js} +2 -2
  71. package/dist/assets/{mic-off-Da09u2hl.js → mic-off-DiEVWn3e.js} +1 -1
  72. package/dist/assets/{monitor-off-jOOWdiSg.js → monitor-off-bCAhCbCp.js} +1 -1
  73. package/dist/assets/{monitor-smartphone-D_W4zyWO.js → monitor-smartphone-ASdELIYw.js} +1 -1
  74. package/dist/assets/mount-CRpYde_B.js +1 -0
  75. package/dist/assets/{notification-schedule-field-LytDFkpQ.js → notification-schedule-field-BKROBLSv.js} +1 -1
  76. package/dist/assets/{player-overlays-CCZE3o8q.js → player-overlays-Fx6RE6kI.js} +1 -1
  77. package/dist/assets/{recycle-BVcCaHVd.js → recycle-twm2_92b.js} +1 -1
  78. package/dist/assets/remoteEntry-D-hdlf-C.js +1 -0
  79. package/dist/assets/{scan-eye-CHwWv39K.js → scan-eye-DuyDP-FQ.js} +1 -1
  80. package/dist/assets/{scissors-BrUBwnKn.js → scissors-BJ2tjgEs.js} +1 -1
  81. package/dist/assets/{search-x-BcR2pidC.js → search-x-C9z-zNBZ.js} +1 -1
  82. package/dist/assets/{send-8R5TbxHN.js → send-C_-A97md.js} +1 -1
  83. package/dist/assets/{settings-2-C4PaSGfb.js → settings-2-A0nya3CH.js} +1 -1
  84. package/dist/assets/{speaker-CBRM7GNH.js → speaker-C8juqhRE.js} +1 -1
  85. package/dist/assets/{src-Cw4W7OtK.js → src-AhVPNkCn.js} +7 -7
  86. package/dist/assets/{timer-reset-DlfKkTg_.js → timer-reset-DHBRudwU.js} +1 -1
  87. package/dist/assets/{ungroup-BzlNECzG.js → ungroup-BLEMoVnk.js} +1 -1
  88. package/dist/assets/{unlink-HIuzqEig.js → unlink-YiKNaJO_.js} +1 -1
  89. package/dist/assets/{usb-DqboQtO8.js → usb-DzR5JdOt.js} +1 -1
  90. package/dist/assets/{use-scenes-feed-Cnl4Is6T.js → use-scenes-feed-wz6RYR34.js} +1 -1
  91. package/dist/assets/{use-stationary-objects-DmFWTPK0.js → use-stationary-objects-ByxBafUy.js} +1 -1
  92. package/dist/assets/useEventInvalidation-CRpYde_B.js +1 -0
  93. package/dist/assets/{useNodeUrlSelection-CSh6gqLc.js → useNodeUrlSelection-v_RZ_Gxk.js} +1 -1
  94. package/dist/assets/user-round-CjXCVqIf.js +1 -0
  95. package/dist/assets/{user-x-ciro8k7Z.js → user-x-CY41cwk1.js} +1 -1
  96. package/dist/assets/{video-BJUj4GaK.js → video-BRgeujOO.js} +1 -1
  97. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CwjeQPZx.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BrkS3kK7.js} +2 -2
  98. package/dist/index.html +9 -9
  99. package/dist/server/addon.js +230 -197
  100. package/package.json +1 -1
  101. package/dist/assets/CompositionEditor-BhL25d6e.js +0 -1
  102. package/dist/assets/DeviceDetail-g2esa6u-.js +0 -2
  103. package/dist/assets/Notifications-DWJcnXvV.js +0 -1
  104. package/dist/assets/circle-slash-DKE4hxbW.js +0 -1
  105. package/dist/assets/client-Cy6wyTLQ.js +0 -358
  106. package/dist/assets/crop-7vsE3Qcd.js +0 -1
  107. package/dist/assets/device-picker-model-DVvq9nYp.js +0 -1
  108. package/dist/assets/dist-BPMeH1J4.js +0 -358
  109. package/dist/assets/mount-DVvq9nYp.js +0 -1
  110. package/dist/assets/remoteEntry-BOaeaEWk.js +0 -1
  111. package/dist/assets/useEventInvalidation-DVvq9nYp.js +0 -1
  112. package/dist/assets/user-round-C4K7vDWN.js +0 -1
@@ -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
@@ -74084,7 +74117,7 @@ var AdminUIAddon = class extends BaseAddon {
74084
74117
  capability: adminUiCapability,
74085
74118
  provider: {
74086
74119
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
74087
- getVersion: async () => ({ version: "1.2.440" })
74120
+ getVersion: async () => ({ version: "1.2.441" })
74088
74121
  }
74089
74122
  }];
74090
74123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.440",
3
+ "version": "1.2.441",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{$ as e,B as t,J as n,K as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as l,O as u,V as d,oa as f,ot as p}from"./player-overlays-CCZE3o8q.js";import{Br as m,Dr as h,Er as g,Mr as _,Nr as v,Or as y,Sr as b,Tr as x,_r as S,br as C,cn as w,kr as T,ln as ee,on as te,sn as ne,un as re,wr as ie,xr as ae,yn as E,zr as D}from"./client-Cy6wyTLQ.js";import{$n as oe,Hn as O,Ka as se,Ni as ce,_a as k,ga as le,gu as ue,mu as de,nu as fe,s as pe,sr as me,zi as he,zn as A}from"./src-Cw4W7OtK.js";import{t as j}from"./i18n-B1bxeya5.js";import{t as M}from"./useTranslation-D3Is_4B6.js";e();function ge(e){return{target:{kind:`new`,type:e},name:``,features:[]}}function _e(e){return{target:{kind:`existing`,device:e},name:``,features:[]}}function N(e,t){return{target:e.target,name:t,features:e.features.flatMap(e=>e.kind===`fields`?[e]:[])}}function P(e,t,n){return{...e,features:e.features.map(e=>e.cap===t?n(e):e)}}function F(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function ve(e,t){switch(t.type){case`set-new-type`:return e.target.kind===`new`?{...e,target:{...e.target,type:t.deviceType}}:e;case`set-new-role`:{if(e.target.kind!==`new`)return e;let{role:n,...r}=e.target;return{...e,target:t.role===null?r:{...r,role:t.role}}}case`set-name`:return{...e,name:t.name};case`add-feature`:return e.features.some(e=>e.cap===t.cap)?e:{...e,features:[...e.features,{kind:`fields`,cap:t.cap,fields:{}}]};case`remove-feature`:return{...e,features:e.features.filter(e=>e.cap!==t.cap)};case`set-field`:return P(e,t.cap,e=>({...e,fields:{...e.fields,[t.path]:t.source}}));case`clear-field`:return P(e,t.cap,e=>({...e,fields:F(e.fields,t.path)}));case`remove-binding`:return P(e,t.cap,e=>{let n=e.fields[t.path];return n?.kind===`expression`?{...e,fields:{...e.fields,[t.path]:{...n,bindings:F(n.bindings,t.bindingName)}}}:e});case`copy-feature`:return P(e,t.cap,e=>({...e,fields:{...e.fields,...Object.fromEntries(t.paths.map(e=>[e,{kind:`from`,source:t.from,cap:t.sourceCap,fieldPath:e}]))}}))}}function ye(e){let t=b.safeParse({target:e.target,features:e.features});return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:t.error.issues.map(e=>`${e.path.join(`.`)||`composition`}: ${e.message}`)}}function be(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function xe(e){for(let t=1;;t++){let n=`s${t}`;if(!e.includes(n))return n}}var Se=[`room`,`converted-sensor`,`derived-binary`],I={addonId:`provider-homeassistant`,stableId:`sensor.template_source`};function Ce(){return N(ee({temperatureSources:ne,motionSources:te,occupancyWindowMs:w}),`Room`)}function we(){return N({target:{kind:`new`,type:v.Sensor},features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:{kind:`expression`,expr:`convert(v, "°C", "°F")`,bindings:{v:{kind:`from`,source:I,cap:`numeric-sensor`,fieldPath:`value`}}},unit:{kind:`expression`,expr:`"°F"`,bindings:{}},lastFetchedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Converted sensor`)}function Te(){return N({target:{kind:`new`,type:v.Sensor},features:[{kind:`fields`,cap:`binary`,fields:{on:{kind:`expression`,expr:`v > 20`,bindings:{v:{kind:`from`,source:I,cap:`temperature-sensor`,fieldPath:`celsius`}}},lastChangedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Derived binary`)}function Ee(e){switch(e){case`room`:return Ce();case`converted-sensor`:return we();case`derived-binary`:return Te()}}function De(e,t){return typeof t==`number`&&Number.isFinite(t)&&t>0?{kind:`device`,path:`/devices/${t}`}:{kind:`editor`,path:`/build/compositions/${encodeURIComponent(e)}`}}var L=`rounded-lg border border-border bg-surface p-4`,Oe=L;function ke(e){return{addonId:e.addonId,stableId:e.stableId}}function R(e){return new Map(e.map(e=>[y(ke(e)),e]))}function Ae(e,t,n){let r=e?.features??[],i=r.findIndex(e=>e.cap===n.cap);return{target:e?.target??{kind:`existing`,device:t},features:i===-1?[...r,n]:r.map((e,t)=>t===i?n:e)}}function je(e,t){let n=e.features.filter(e=>e.cap!==t);return n.length===0?null:{target:e.target,features:n}}function Me(e,t){let n=e?.features.find(e=>e.cap===t);return n!==void 0&&n.kind===`fields`?n:null}function z(e){return Array.isArray(e)?e.map(z):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,z(t)]))}function B(e){return JSON.stringify(z(e))}function Ne(e,t){return B(e)===B(t)}function V(e,t){return B(e)===B(t)}function Pe(e,t){switch(e.kind){case`pending`:return{kind:`refused`,reason:j.t(`helpers.customizationSave.notReadYet`)};case`unknown`:return{kind:`refused`,reason:`the customization could not be read: ${e.reason}`};case`not-loaded`:return{kind:`refused`,reason:`the customizations are not loaded yet: ${e.reason}`};case`none`:return t===null?{kind:`noop`}:{kind:`create`,input:{enabled:!0,composition:t}};case`present`:{let n=e.view.block.id;return t===null?{kind:`delete`,blockId:n}:B(t)===B(e.composition)?{kind:`noop`}:{kind:`update`,blockId:n,expectedUpdatedAt:e.view.block.updatedAt,composition:t}}}}function H(e,t){let n=e===`enum`?`string`:e,r=t.kind===`enum`?`string`:t.kind,i={source:t.source,cap:t.cap,fieldPath:t.fieldPath};return r===n?{kind:`from`,...i}:n===`number`&&r===`string`?{kind:`expression`,expr:`number(x)`,bindings:{x:{kind:`from`,...i}}}:null}function U(e){return{kind:`expression`,expr:e,bindings:{}}}function W(e){let t=H(`number`,e.percentage);return t===null?null:{kind:`fields`,cap:`battery`,fields:e.mode===`replace`?{percentage:t}:{percentage:t,charging:U(`"unknown"`),sleeping:U(`false`),lastUpdated:U(`now`)}}}var Fe=[`percent`,...E.options];function G(e,t){return t===`percent`?{level:e}:{"remaining.value":e,"remaining.unit":U(JSON.stringify(t))}}function Ie(e,t){let n=H(`number`,t.remaining);if(n===null||!ae.test(t.key)||t.label.trim()===``)return null;let r={label:t.label.trim(),fields:G(n,t.unit)};return{kind:`fields`,cap:`consumables`,...e?.enabled===void 0?{}:{enabled:e.enabled},fields:e?.fields??{lastChangedAt:U(`now`),lastFetchedAt:U(`now`)},items:{...e?.items,[t.key]:r}}}function Le(e){if(e.level!==void 0)return`percent`;let t=e[`remaining.unit`];if(t===void 0||t.kind!==`expression`)return null;try{let e=E.safeParse(JSON.parse(t.expr));return e.success?e.data:null}catch{return null}}function Re(e){return Object.entries(e?.items??{}).map(([e,t])=>{let n=Le(t.fields),r=K(t.fields.level??t.fields[`remaining.value`]),i=r===null?null:H(`number`,r);return n!==null&&i!==null&&Ne(G(i,n),t.fields)?{key:e,label:t.label,unit:n,source:r}:{key:e,label:t.label,unit:null,source:null}})}function ze(e,t){let n=Object.fromEntries(Object.entries(e.items??{}).filter(([e])=>e!==t));return Object.keys(n).length===0?null:{...e,items:n}}function Be(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function Ve(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=Object.entries(t.bindings).filter(([e])=>e.startsWith(`active`)).flatMap(([,e])=>e.kind===`from`?[e.source]:[]);return[...new Map(n.map(e=>[y(e),e])).values()]}function He(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=t.bindings;return Object.entries(n).flatMap(([e,t])=>{if(!e.startsWith(`active`)||t.kind!==`from`)return[];let r=n[`changed${e.slice(6)}`];return r===void 0||r.kind!==`from`?[]:[{source:t.source,cap:t.cap,activeField:t.fieldPath,changedAtField:r.fieldPath}]})}function K(e){if(e===void 0)return null;if(e.kind===`from`){let{kind:t,...n}=e;return{...n,kind:`number`}}if(e.kind!==`expression`||e.expr!==`number(x)`)return null;let t=e.bindings.x;if(t===void 0||t.kind!==`from`||Object.keys(e.bindings).length!==1)return null;let{kind:n,...r}=t;return{...r,kind:`string`}}function Ue(e,t){let n=K(e.fields.percentage);if(n===null)return!1;let r=W({percentage:n,mode:t}),{enabled:i,...a}=e;return r!==null&&V(a,r)}function q(e){return e.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,location:e.location,type:e.type}))}function We(e,t,n){let r=t.trim().toLowerCase();return r===``?[]:e.filter(e=>!n.includes(e.id)&&[e.name,e.stableId,e.location??``].some(e=>e.toLowerCase().includes(r))).toSorted((e,t)=>e.name.localeCompare(t.name)).slice(0,20)}function J(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Object.getOwnPropertyDescriptor(n,e)?.value}return n}function Ge(e,t,n,r){return r===null?{kind:`from`,source:e,cap:t,fieldPath:n.path}:H(r,{source:e,cap:t,fieldPath:n.path,kind:n.kind})}function Ke(e,t,n,r){let i={addonId:e.addonId,stableId:e.stableId};return t.caps.flatMap(e=>e.fields.filter(e=>e.item!==!0).map(t=>({cap:e.cap,path:t.path,kind:t.kind,value:n===null?void 0:J(n[e.cap],t.path),source:Ge(i,e.cap,t,r)})))}function Y(e,t){return t?e===void 0?`—`:e===null?`null`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):`…`}var qe=[];function X({title:e,targetKind:t,excludeDeviceIds:r=qe,onPick:i,onCancel:o}){let{t:s}=M(),[f,p]=n(null);return a(`aside`,{"aria-label":e,className:`${u} ${l} flex flex-col gap-2`,children:[c(`h3`,{className:d,children:e}),f===null?c(Je,{excludeDeviceIds:r,onSelect:p}):c(Z,{device:f,targetKind:t,onPick:i,onBack:()=>p(null)}),c(`div`,{children:c(O,{variant:`ghost`,size:`sm`,onClick:o,children:s(`customize.picker.cancel`)})})]})}function Je({excludeDeviceIds:e,onSelect:t}){let{t:r}=M(),[i,s]=n(``),l=k({projection:`slim`});return a(o,{children:[a(`label`,{className:`flex flex-col gap-1 text-[11px] text-foreground-subtle`,children:[r(`customize.picker.search`),c(fe,{type:`search`,"aria-label":r(`customize.picker.search`),value:i,onChange:e=>s(e.target.value)})]}),l.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(`customize.picker.loadingDevices`)}),l.status===`error`&&c(A,{title:r(`customize.picker.devicesFailed`),message:l.error?.message??``}),l.status===`success`&&c(`ul`,{className:`flex flex-col gap-1`,children:We(q(l.data),i,e).map(e=>c(`li`,{children:a(`button`,{type:`button`,className:`text-left text-[11px] hover:underline`,onClick:()=>t(e),children:[e.name,` `,a(`span`,{className:`text-foreground-subtle`,children:[`· `,e.stableId]})]})},e.id))})]})}function Z({device:e,targetKind:t,selected:n,onPick:r,onBack:i}){let{t:o}=M(),s=le({deviceId:e.id}),l=se({deviceId:e.id});if(s.status===`pending`)return c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:o(`customize.picker.loadingFields`)});if(s.status===`error`)return c(A,{title:o(`customize.picker.fieldsFailed`),message:s.error?.message??``});let u=Ke(e,s.data,l.status===`success`?l.data:null,t),d=u.filter(e=>e.source===null).length,f={addonId:e.addonId,stableId:e.stableId};return a(`div`,{className:`flex flex-col gap-1`,children:[a(`button`,{type:`button`,className:`text-left text-[11px] text-primary`,onClick:i,children:[`← `,e.name]}),l.status===`error`&&c(`p`,{role:`alert`,className:`text-[10px] text-warning`,children:o(`customize.picker.valuesFailed`,{reason:l.error?.message??``})}),c(`ul`,{role:`listbox`,"aria-label":o(`customize.picker.fields`),className:`flex flex-col gap-1`,children:u.map(t=>{let i=t.source;if(i===null)return null;let o=()=>r({device:e,ref:f,cap:t.cap,path:t.path,kind:t.kind,source:i,value:t.value});return a(`li`,{role:`option`,"aria-selected":n?.cap===t.cap&&n.path===t.path,tabIndex:0,className:`flex justify-between gap-2 text-[11px] cursor-pointer hover:bg-surface-hover rounded px-1`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o()},children:[a(`span`,{className:`font-mono`,children:[t.cap,`.`,t.path]}),c(`span`,{children:Y(t.value,l.status===`success`)})]},`${t.cap}.${t.path}`)})}),d>0&&t!==null&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:o(`customize.picker.hidden`,{count:d,kind:o(`customize.kinds.${t}`)})})]})}var Ye=`integration`;function Q(e,t){switch(e.kind){case`from`:{let n=y(e.source);return`${t.get(n)??n} · ${e.cap}.${e.fieldPath}`}case`expression`:return e.expr;case`code`:return`code`}}function Xe(e,t){if(e.kind===`unreachable`)return{kind:`unknown`,reason:e.error};if(e.state===null)return{kind:`unknown`,reason:j.t(`helpers.fieldsTableRows.composerNotReported`)};let n=e.state.fields.find(t);return n===void 0?{kind:`unknown`,reason:j.t(`helpers.fieldsTableRows.noValue`)}:n.state===`unavailable`?{kind:`unavailable`,reason:n.reason??j.t(`common.unavailable`)}:{kind:`value`,value:n.value,staleReason:n.state===`stale`?n.reason??j.t(`common.stale`):null}}function Ze(e,t,n,r){return{key:`${e.feature.cap}.${t}`,cap:e.feature.cap,field:t,origin:`composed`,mode:e.mode,from:Q(n,e.input.sourceNames),value:e.enabled?Xe(e.input.state,r):{kind:`off`}}}function Qe(e){let t=e.feature.cap;return Object.entries(e.feature.fields).map(([n,r])=>Ze(e,n,r,e=>e.cap===t&&e.path===n&&e.item===void 0))}function $e(e){let t=e.feature.cap;return Object.entries(e.feature.items??{}).flatMap(([n,r])=>Object.entries(r.fields).map(([r,i])=>Ze(e,x(C,n,r),i,e=>e.cap===t&&e.path===r&&e.item?.arrayPath===`items`&&e.item.key===n)))}function et(e,t,n){if(e===null)return{kind:`unknown`,reason:j.t(`helpers.fieldsTableRows.stateUnreadable`)};let r=J(e[t],n),i=r===void 0?void 0:D(r);return i===void 0?{kind:`unknown`,reason:j.t(`helpers.fieldsTableRows.notReported`)}:{kind:`value`,value:i,staleReason:null}}function tt(e){if(e.mode!==`replace`)return[];let t=e.feature.cap,n=new Set(Object.keys(e.feature.fields));return(e.input.nativeFields.get(t)??[]).filter(e=>!n.has(e)).map(n=>({key:`${t}.${n}`,cap:t,field:n,origin:`native`,mode:e.mode,from:Ye,value:et(e.input.snapshot,t,n)}))}function nt(e){return e.composition.features.flatMap(t=>{if(t.kind!==`fields`)return[];let n={feature:t,mode:e.nativeCaps.has(t.cap)?`replace`:`add`,enabled:ie(t),input:e};return[...Qe(n),...$e(n),...tt(n)]})}var rt={min:`min(a, b, …)`,max:`max(a, b, …)`,abs:`abs(x)`,floor:`floor(x)`,ceil:`ceil(x)`,sqrt:`sqrt(x)`,round:`round(x, digits?)`,pow:`pow(x, y)`,clamp:`clamp(x, lo, hi)`,avg:`avg(a, b, …)`,sum:`sum(a, b, …)`,coalesce:`coalesce(a, b, …)`,age:`age(now, ts)`,convert:`convert(x, "from", "to")`,any:`any(a, b, …)`,all:`all(a, b, …)`,within:`within(ts, ms)`,number:`number(x)`,latest:`latest(ts, …)`,rose:`rose(level, changedAt, debounceMs?)`,count:`count(x)`},it=/[A-Za-z_][A-Za-z0-9_]*$/;function at(e,t,n){let r=it.exec(e.slice(0,t))?.[0]??``;if(r===``)return[];let i=n.filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`binding`,label:e,insert:e,hintKey:null})),a=`now`.startsWith(r)?[{kind:`now`,label:`now`,insert:`now`,hintKey:`compositionEditor.now`}]:[],o=[...m].filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`builtin`,label:rt[e]??e,insert:`${e}(`,hintKey:`compositionEditor.builtins.${e}`}));return[...i,...a,...o].slice(0,8)}function ot(e,t,n){let r=t-(it.exec(e.slice(0,t))?.[0]??``).length;return{text:`${e.slice(0,r)}${n.insert}${e.slice(t)}`,cursor:r+n.insert.length}}e();function st({label:e,value:t,bindings:r,onChange:i}){let{t:o}=M(),l=s(null),[u,d]=n(t.length),f=at(t,u,r);return a(`div`,{className:`flex flex-col gap-1`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[e,c(`input`,{ref:l,className:`font-mono px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:t,onChange:e=>{i(e.target.value),d(e.target.selectionStart??e.target.value.length)},onSelect:e=>d(e.currentTarget.selectionStart??t.length)})]}),f.length>0&&c(`ul`,{role:`listbox`,"aria-label":o(`compositionEditor.suggestions`),className:`rounded border border-border bg-surface text-[11px]`,children:f.map(e=>a(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 px-1 cursor-pointer hover:bg-surface-hover`,onClick:()=>{let n=ot(t,u,e);i(n.text),d(n.cursor),l.current?.focus()},children:[c(`span`,{className:`font-mono`,children:e.label}),e.hintKey!==null&&c(`span`,{className:`text-foreground-subtle`,children:o(e.hintKey)})]},`${e.kind}:${e.label}`))})]})}function ct(e,t,n){if(e.kind===`code`)return{kind:`unavailable`,reason:j.t(`helpers.fieldPreview.codeFields`)};if(e.kind===`expression`&&(S(e.expr,`rose`)||S(e.expr,`count`)))return{kind:`runtime-only`};let r=T(e).filter(e=>t.get(h(e.source,e.cap))?.kind!==`value`).map(g);if(r.length>0)return{kind:`waiting`,missing:r};let i=re({source:e,now:n,read:e=>{let n=t.get(h(e.source,e.cap)),r=n?.kind===`value`?J(n.slice,e.fieldPath):void 0,i=r===void 0?void 0:D(r);return i===void 0?{state:`unavailable`,reason:j.t(`helpers.fieldPreview.notReported`,{path:`${e.cap}.${e.fieldPath}`}),fatal:!1}:{state:`fresh`,value:i}}});return i.state===`unavailable`?{kind:`unavailable`,reason:i.reason}:{kind:`value`,value:i.value,stale:i.reason}}e();function lt({sliceKey:e,deviceId:n,capName:r,onReading:i}){let a=pe(p().trpcClient,n,r);return t(()=>{i(e,a===void 0?{kind:`pending`}:{kind:`value`,slice:a})},[e,a,i]),null}function ut(e,t){return[...new Map(T(e).map(e=>[h(e.source,e.cap),e]))].map(([e,n])=>({key:e,read:n,device:t.get(y(n.source))}))}function dt({source:e}){let{t}=M(),r=k({projection:`slim`}),[o,s]=n(new Map),l=i((e,t)=>{s(n=>new Map([...n,[e,t]]))},[]),u=ut(e,R(r.status===`success`?q(r.data):[])),d=r.status===`success`?u.filter(e=>e.device===void 0).map(e=>y(e.read.source)):[];return a(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[u.map(e=>e.device===void 0?null:c(lt,{sliceKey:e.key,deviceId:e.device.id,capName:e.read.cap,onReading:l},e.key)),c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.label`)}),r.status===`error`?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.devicesFailed`,{reason:r.error?.message??``})}):d.length>0?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.unknownDevice`,{sources:d.join(`, `)})}):c(ft,{preview:ct(e,o,Date.now())})]})}function ft({preview:e}){let{t}=M();switch(e.kind){case`value`:return a(`strong`,{children:[`→ `,Y(e.value,!0),e.stale===null?``:` (${e.stale})`]});case`unavailable`:return c(`span`,{className:`text-warning`,children:e.reason});case`waiting`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.waiting`,{sources:e.missing.join(`, `)})});case`runtime-only`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.runtimeOnly`)})}}e();function pt({path:e,kind:t,required:r,source:i,onSet:s,onClear:l,onRemoveBinding:u,sourceNames:d}){let{t:f}=M(),[p,m]=n(`idle`),h=i?.kind===`expression`?i:null;return a(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono text-[11px]`,children:e}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[f(`customize.kinds.${t}`),r?` · ${f(`compositionEditor.required`)}`:``]}),c(O,{size:`sm`,variant:`outline`,onClick:()=>m(`take`),children:f(`compositionEditor.takeFrom`)}),c(O,{size:`sm`,variant:`outline`,"aria-pressed":h!==null,onClick:()=>s(h??{kind:`expression`,expr:`null`,bindings:{}}),children:f(`compositionEditor.formula`)}),i!==void 0&&c(O,{size:`sm`,variant:`ghost`,onClick:l,children:f(`compositionEditor.clear`)})]}),i?.kind===`from`&&c(`span`,{className:`text-[11px]`,children:Q(i,d)}),h!==null&&a(o,{children:[c(st,{label:f(`compositionEditor.formulaFor`,{path:e}),value:h.expr,bindings:Object.keys(h.bindings),onChange:e=>s({...h,expr:e})}),c(`ul`,{className:`text-[11px] flex flex-col gap-0.5`,children:Object.entries(h.bindings).map(([e,t])=>a(`li`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono`,children:e}),c(`span`,{children:t.kind===`from`?Q(t,d):JSON.stringify(t.value)}),c(O,{size:`sm`,variant:`ghost`,"aria-label":f(`compositionEditor.removeBinding`,{name:e}),onClick:()=>u(e),children:`×`})]},e))}),c(O,{size:`sm`,variant:`ghost`,onClick:()=>m(`add-binding`),children:f(`compositionEditor.addSource`)})]}),p!==`idle`&&c(X,{title:f(p===`take`?`compositionEditor.takeFrom`:`compositionEditor.addSource`),targetKind:p===`take`?t:null,onCancel:()=>m(`idle`),onPick:e=>{if(p===`take`)s(e.source);else if(h!==null){let t=xe(Object.keys(h.bindings));s({...h,bindings:{...h.bindings,[t]:{kind:`from`,source:e.ref,cap:e.cap,fieldPath:e.path}}})}m(`idle`)}}),i!==void 0&&c(dt,{source:i})]})}e();function mt(e){return e===null||e.kind===`known`?null:e}function ht({draft:e,deviceType:t,nativeCaps:r,targetFields:i,dispatch:s}){let{t:l}=M(),u=ce({deviceType:t}),d=k({projection:`slim`}),f=new Map([...R(d.status===`success`?q(d.data):[])].map(([e,t])=>[e,t.name])),[p,m]=n(null),h=mt(r)??mt(i),g=r?.kind===`known`?r.value:new Set,_=new Set(e.features.map(e=>e.cap)),v=u.status===`success`?u.data.caps.filter(e=>!_.has(e.cap)&&!g.has(e.cap)):[],y=[...g].filter(e=>!_.has(e)),b=e=>g.has(e)?((i?.kind===`known`?i.value.caps.find(t=>t.cap===e):void 0)?.fields??[]).filter(e=>e.item!==!0&&!e.path.includes(`.`)).map(e=>({path:e.path,kind:e.kind,required:!1})):((u.status===`success`?u.data.caps.find(t=>t.cap===e):void 0)?.fields??[]).map(e=>({path:e.path,kind:e.kind,required:e.required}));return h===null?a(o,{children:[a(`section`,{"aria-labelledby":`editor-features`,className:`${L} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),u.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.checking`)}),u.status===`error`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.unknown`,{reason:u.error?.message??``})}),a(`div`,{className:`flex flex-wrap gap-1`,children:[e.features.map(e=>a(`span`,{className:`flex items-center gap-1 rounded border border-border px-1.5 text-[11px]`,children:[e.cap,c(me,{variant:g.has(e.cap)?`default`:`info`,children:g.has(e.cap)?l(`compositionEditor.replaces`):l(`compositionEditor.added`)}),c(`button`,{type:`button`,"aria-label":l(`compositionEditor.removeFeature`,{cap:e.cap}),onClick:()=>s({type:`remove-feature`,cap:e.cap}),children:`×`})]},e.cap)),v.map(e=>a(O,{size:`sm`,variant:`outline`,onClick:()=>s({type:`add-feature`,cap:e.cap}),children:[`+ `,e.cap]},e.cap)),y.map(e=>c(O,{size:`sm`,variant:`ghost`,onClick:()=>s({type:`add-feature`,cap:e}),children:l(`compositionEditor.replaceIn`,{cap:e})},e))]})]}),e.features.map(e=>a(`section`,{"aria-label":l(`compositionEditor.steps.fieldsOf`,{cap:e.cap}),className:`${L} flex flex-col gap-2`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h2`,{className:`text-sm font-semibold`,children:l(`compositionEditor.steps.fieldsOf`,{cap:e.cap})}),c(O,{size:`sm`,variant:`outline`,onClick:()=>m(e.cap),children:l(`compositionEditor.copyFeature`)})]}),p===e.cap&&c(X,{title:l(`compositionEditor.copyFeature`),targetKind:null,onCancel:()=>m(null),onPick:t=>{s({type:`copy-feature`,cap:e.cap,from:t.ref,sourceCap:t.cap,paths:b(e.cap).map(e=>e.path)}),m(null)}}),b(e.cap).map(t=>c(pt,{path:t.path,kind:t.kind,required:t.required,source:e.fields[t.path],onSet:n=>s({type:`set-field`,cap:e.cap,path:t.path,source:n}),onClear:()=>s({type:`clear-field`,cap:e.cap,path:t.path}),onRemoveBinding:n=>s({type:`remove-binding`,cap:e.cap,path:t.path,bindingName:n}),sourceNames:f},t.path))]},e.cap))]}):a(`section`,{"aria-labelledby":`editor-features`,className:`${L} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:h.kind===`unknown`?h.reason:l(`compositionEditor.reading`)})]})}var $=`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`;function gt({draft:e,targetName:t,dispatch:n}){let r=f(),{t:i}=M(),o=e.target;return a(`section`,{"aria-labelledby":`editor-target`,className:`${L} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-target`,className:`text-sm font-semibold`,children:i(`compositionEditor.steps.target`)}),o.kind===`existing`?c(`p`,{className:`text-[11px]`,children:i(`compositionEditor.existingTarget`,{name:t??`${o.device.addonId}/${o.device.stableId}`})}):a(`div`,{className:`grid grid-cols-3 gap-2`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.targetType`),c(`select`,{className:$,value:o.type,onChange:e=>{let t=Object.values(v).find(t=>t===e.target.value);t!==void 0&&n({type:`set-new-type`,deviceType:t})},children:Object.values(v).map(e=>c(`option`,{value:e,children:ue(e,r).label},e))})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`customize.identity.role`),a(`select`,{className:$,value:o.role??``,onChange:e=>n({type:`set-new-role`,role:Object.values(_).find(t=>t===e.target.value)??null}),children:[c(`option`,{value:``,children:i(`customize.identity.noRole`)}),Object.values(_).map(e=>c(`option`,{value:e,children:de(e,r).label},e))]})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.name`),c(`input`,{className:$,value:e.name,onChange:e=>n({type:`set-name`,name:e.target.value})})]})]})]})}e();function _t({draft:e,blockId:r,saving:i,onSave:o,onCancel:s}){let{t:l}=M(),u=he(),d=ye(e),f=d.ok?JSON.stringify(d.composition):``,[p,m]=n({key:``,state:{kind:`checking`}});t(()=>{if(!d.ok)return;let e=d.composition,t=setTimeout(()=>{u.mutateAsync({composition:e,...r===null?{}:{blockId:r}}).then(e=>m({key:f,state:e.ok?{kind:`ok`}:{kind:`refused`,problems:e.problems}})).catch(e=>m({key:f,state:{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}))},500);return()=>clearTimeout(t)},[f,r]);let h=d.ok?p.key===f?p.state:{kind:`checking`}:{kind:`invalid-draft`,problems:d.problems};return a(`section`,{"aria-labelledby":`editor-verify`,className:`${L} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-verify`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.verify`)}),h.kind===`checking`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.verify.checking`)}),h.kind===`ok`&&c(`p`,{className:`text-[11px] text-success`,children:l(`compositionEditor.verify.ok`)}),h.kind===`unknown`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.verify.unknown`,{reason:h.reason})}),(h.kind===`invalid-draft`||h.kind===`refused`)&&c(`ul`,{role:`alert`,className:`flex flex-col gap-1 text-[11px] text-danger`,children:h.kind===`invalid-draft`?h.problems.map(e=>c(`li`,{children:e},e)):h.problems.map(e=>a(`li`,{children:[c(`span`,{className:`font-mono`,children:e.path}),` — `,e.message]},`${e.path}:${e.code}`))}),a(`div`,{className:`flex gap-2`,children:[c(O,{variant:`ghost`,onClick:s,children:l(`compositionEditor.cancel`)}),c(O,{disabled:h.kind!==`ok`||i||!d.ok,onClick:()=>d.ok&&o(d.composition),children:l(`compositionEditor.save`)})]})]})}e();function vt({initial:e,blockId:t,deviceType:r,targetName:i=null,nativeCaps:a,targetFields:o,save:s,onCancel:l,showTemplates:u=!1}){let[d,f]=n(e),p=`${d.name}:${d.features.map(e=>e.cap).join(`,`)}:${d.target.kind===`new`?d.target.type:`existing`}`;return c(yt,{seed:d,blockId:t,deviceType:r,targetName:i,nativeCaps:a,targetFields:o,showTemplates:u,onApplyTemplate:e=>{f(Ee(e))},save:s,onCancel:l},p)}function yt({seed:e,blockId:t,deviceType:i,targetName:o,nativeCaps:s,targetFields:l,showTemplates:u,onApplyTemplate:d,save:f,onCancel:p}){let{t:m}=M(),h=oe(),[g,_]=r(ve,e),[v,y]=n(!1),[b,x]=n(null),S=async t=>{be(e,g)&&!await h({title:m(`compositionEditor.templates.confirmTitle`),message:m(`compositionEditor.templates.confirmMessage`),confirmLabel:m(`compositionEditor.templates.confirmApply`),variant:`danger`})||d(t)},C=g.target.kind===`new`?g.target.type:i,w=async e=>{y(!0);let t=await f(e,g.name);y(!1),x(t.kind===`refused`?t.reason:null)};return a(`div`,{className:`flex flex-col gap-4`,children:[u&&g.target.kind===`new`&&a(`div`,{className:`rounded-lg border border-border bg-surface p-4 flex flex-wrap gap-2`,"data-testid":`composition-templates`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle self-center`,children:m(`compositionEditor.templates.label`)}),Se.map(e=>c(O,{size:`sm`,variant:`outline`,onClick:()=>void S(e),children:m(`compositionEditor.templates.${e}`)},e))]}),c(gt,{draft:g,targetName:o,dispatch:_}),c(ht,{draft:g,deviceType:C,nativeCaps:s,targetFields:l,dispatch:_}),c(_t,{draft:g,blockId:t,saving:v,onSave:e=>void w(e),onCancel:p}),b!==null&&c(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:b})]})}export{je as C,_e as D,N as E,ge as O,Ae as S,De as T,K as _,Z as a,Pe as b,q as c,Ie as d,Re as f,Be as g,Ue as h,nt as i,Fe as l,He as m,ct as n,Y as o,Ve as p,st as r,J as s,vt as t,W as u,ze as v,Oe as w,V as x,Me as y};