@camstack/addon-admin-ui 1.2.630 → 1.2.631

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 (152) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/assets/Addons-sbIN9dzZ.js +5 -0
  3. package/dist/assets/{AdminPage-jW6IDTUf.js → AdminPage-kF4jXGEV.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-f8fGddbQ.js → AdminSectionedPage-DOeE8MKI.js} +1 -1
  5. package/dist/assets/{AiProfiles-CIdJO-TD.js → AiProfiles-Bn4IcqiG.js} +2 -2
  6. package/dist/assets/{Authentication-B8-hv1JE.js → Authentication-CJ12V0Je.js} +1 -1
  7. package/dist/assets/Build-EkD5sPkJ.js +39 -0
  8. package/dist/assets/{Calendars-DGQfucVm.js → Calendars-pt8Czmz-.js} +1 -1
  9. package/dist/assets/{CameraGrids-CqSKWP-r.js → CameraGrids-DsP-lh4n.js} +1 -1
  10. package/dist/assets/Cluster-CYK2v6WW.js +1 -0
  11. package/dist/assets/CompositionBlockEditor-D083k9Ne.js +2 -0
  12. package/dist/assets/{CompositionEditorPage-DdOX4bAI.js → CompositionEditorPage-D0OWiT8y.js} +1 -1
  13. package/dist/assets/Data-CqxvMLga.js +2 -0
  14. package/dist/assets/DeviceDetail-JrORTBJj.js +2 -0
  15. package/dist/assets/{Devices-Bj3juAG-.js → Devices-nS1r0XUd.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-DLSmtcv2.js → EmbedPlayerPage-DHdkG1PL.js} +1 -1
  17. package/dist/assets/History-Ww5DCW62.js +1 -0
  18. package/dist/assets/Identity--dKVtzMe.js +1 -0
  19. package/dist/assets/{InstanceSwitchCell-OBG8GAAT.js → InstanceSwitchCell-DzUk_T9H.js} +1 -1
  20. package/dist/assets/{InstancesTable-DbKNEkch.js → InstancesTable-CIo1Qgvf.js} +1 -1
  21. package/dist/assets/IntegrationDetail-D_ncN36I.js +1 -0
  22. package/dist/assets/{IntegrationHub-BGyuGwSJ.js → IntegrationHub-DRN4EXO-.js} +1 -1
  23. package/dist/assets/Integrations-CC7nQfg8.js +1 -0
  24. package/dist/assets/Integrations-CHhaWwUD.js +2 -0
  25. package/dist/assets/{Library-BbRB8NQE.js → Library-Dc9vyWsB.js} +1 -1
  26. package/dist/assets/{Locations-9x_-rSAt.js → Locations-BgUl5Ynf.js} +2 -2
  27. package/dist/assets/{Logs-_tKPP15u.js → Logs-CmJVOSm3.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-CVaLlNDu.js → MaskShapeCanvas-BOuqsa7r.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-GFDvOaPr.js → MotionZonesSettings-B2BM3Q-r.js} +1 -1
  30. package/dist/assets/{MyAccess-B-u_E545.js → MyAccess-6fBn2VOX.js} +1 -1
  31. package/dist/assets/{Network-DFw9fYvt.js → Network-CTiufNfE.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-BNCeWOXe.js → NodeAddonsSettingsPanel-BVy0Vwlr.js} +1 -1
  33. package/dist/assets/Notifications-DcPrGeAf.js +1 -0
  34. package/dist/assets/{Pipeline-CHm2AQv8.js → Pipeline-C0TCJpbq.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-DqZ9UPD6.js → PrivacyMaskSettings-CNkVerJS.js} +1 -1
  36. package/dist/assets/Recordings-ldDzeJWt.js +1 -0
  37. package/dist/assets/{ScanSubnetEditor-ozmT3RiV.js → ScanSubnetEditor-BZ01QrG3.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-DDH5_fqB.js → SceneMonitorEditor-2hy19q2_.js} +1 -1
  39. package/dist/assets/SessionsList-B5xcpNMi.js +2 -0
  40. package/dist/assets/{Showroom-B7NOB1ED.js → Showroom-DHEIsS-I.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-D2GD6oi0.js +1 -0
  42. package/dist/assets/{System-6CUPshkX.js → System-Csx5Oxxs.js} +1 -1
  43. package/dist/assets/{Templates-CbglBYmV.js → Templates-B_RVMQqV.js} +1 -1
  44. package/dist/assets/{Terminal-DOVgd8BS.js → Terminal-lze9-Sdj.js} +3 -3
  45. package/dist/assets/{TrainingProviders-BnLTHaLi.js → TrainingProviders-DEey4yil.js} +1 -1
  46. package/dist/assets/{Viewer-DUnhgz8U.js → Viewer-CQJMsQB6.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmuxKzRL.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BNrEy7FQ.js} +1 -1
  48. package/dist/assets/action-draft-B1-8V8oA.js +1 -0
  49. package/dist/assets/{ai-page.helpers-rRn5Dnkg.js → ai-page.helpers-C6u4zCdc.js} +1 -1
  50. package/dist/assets/{archive-D8MArnbG.js → archive-YngQ2iiP.js} +1 -1
  51. package/dist/assets/{assignment-candidates-Dnb1VfY4.js → assignment-candidates-CjECnY59.js} +1 -1
  52. package/dist/assets/{authed-media-9xcpfhXC.js → authed-media-6XnuLo9S.js} +1 -1
  53. package/dist/assets/{bell-off-ENcL_pd-.js → bell-off-DptJo3xl.js} +1 -1
  54. package/dist/assets/{board-model-GGSgQppc.js → board-model-Os7eyuW-.js} +1 -1
  55. package/dist/assets/{boxes-CY55z6Ff.js → boxes-Cj6tBVL7.js} +1 -1
  56. package/dist/assets/{calendar-clock-CkAnjODE.js → calendar-clock-BYksL91j.js} +1 -1
  57. package/dist/assets/{circle-arrow-up-7gnRqxkx.js → circle-arrow-up-DzOblAwi.js} +1 -1
  58. package/dist/assets/circle-slash-B1VkIjkr.js +1 -0
  59. package/dist/assets/client-Dj0amUjL.js +839 -0
  60. package/dist/assets/command-vocab-_m2oGZgY.js +1 -0
  61. package/dist/assets/create-composition-COH4x-Nh.js +2 -0
  62. package/dist/assets/crop-DrZ_LtJV.js +1 -0
  63. package/dist/assets/{database-zap-BFdfAbfh.js → database-zap-DuoioDSz.js} +1 -1
  64. package/dist/assets/{device-integration-icon-hB_qJ4LX.js → device-integration-icon-DEMDqODG.js} +1 -1
  65. package/dist/assets/device-picker-model-CLDPsoVj.js +1 -0
  66. package/dist/assets/{dist-P-pOuOgg.js → dist-BwtLuBEX.js} +1 -1
  67. package/dist/assets/dist-UoPJIOk2.js +839 -0
  68. package/dist/assets/{eraser-CzP_4y13.js → eraser-By9SDZWa.js} +1 -1
  69. package/dist/assets/{file-up-BsyWA4t-.js → file-up-WXhyhTVY.js} +1 -1
  70. package/dist/assets/{format-DEEo-r4V.js → format-DxUZ_cy9.js} +1 -1
  71. package/dist/assets/{hard-drive-download-DC7u8rmQ.js → hard-drive-download-DnWClIdq.js} +1 -1
  72. package/dist/assets/{hostInit-C0wqD-Kv.js → hostInit-Anpehoxs.js} +1 -1
  73. package/dist/assets/i18n-CoxmD8lW.js +1 -0
  74. package/dist/assets/icons-TSl5ond7.js +1 -0
  75. package/dist/assets/index-tnya26_y.js +4 -0
  76. package/dist/assets/{key-DbnyV6ch.js → key-J_12JZIi.js} +1 -1
  77. package/dist/assets/{key-square-DzusqyCK.js → key-square-D-h5ZSZP.js} +1 -1
  78. package/dist/assets/{list-ordered-bKiX6ntt.js → languages-BhEVj7X8.js} +1 -1
  79. package/dist/assets/{layers-C11xg7Mw.js → layers-CIM2JeRs.js} +1 -1
  80. package/dist/assets/{link-2-off-DpcvRBs9.js → link-2-off-CTNCIhQ5.js} +1 -1
  81. package/dist/assets/{linked-devices-model-DI0cLsYl.js → linked-devices-model-CwHCyffS.js} +1 -1
  82. package/dist/assets/{memory-stick-D2cyx77e.js → memory-stick-CJs8Pk6Q.js} +1 -1
  83. package/dist/assets/{message-square-plus-CdJ0WtpV.js → message-square-plus-B8t2cL2I.js} +1 -1
  84. package/dist/assets/{mf-entry-bootstrap-0-e0956738.js → mf-entry-bootstrap-0-a07a26e2.js} +2 -2
  85. package/dist/assets/{mic-off-CnaWK1oj.js → mic-off-BhkV52Tb.js} +1 -1
  86. package/dist/assets/{monitor-off-DxkJ0Gf-.js → monitor-off-CJZit3zp.js} +1 -1
  87. package/dist/assets/{monitor-smartphone-BKN2w_Yb.js → monitor-smartphone-BS3-E-M8.js} +1 -1
  88. package/dist/assets/mount-CLDPsoVj.js +1 -0
  89. package/dist/assets/{notification-rule-status-We26Y6rE.js → notification-rule-status-Dw7qkS7_.js} +1 -1
  90. package/dist/assets/{player-overlays-By97xFtJ.js → player-overlays-Drz77ysf.js} +1 -1
  91. package/dist/assets/remoteEntry-CGEhU626.js +1 -0
  92. package/dist/assets/{ruler-BpCYrjF_.js → ruler-CArvVO3b.js} +1 -1
  93. package/dist/assets/{scan-eye-D7X92RfU.js → scan-eye-BFsLfvHh.js} +1 -1
  94. package/dist/assets/{scissors-zxnX2diN.js → scissors-BKRW12Ok.js} +1 -1
  95. package/dist/assets/{search-x-MrIacxLz.js → search-x-C_uvUV_p.js} +1 -1
  96. package/dist/assets/{send-DFRLoWOh.js → send-B66reKR2.js} +1 -1
  97. package/dist/assets/{settings-2-D2eOgrvG.js → settings-2-DQY2mF74.js} +1 -1
  98. package/dist/assets/{shapes-BBlQIwot.js → shapes-Cvq1jb1e.js} +1 -1
  99. package/dist/assets/{sigma-ys9WIVBK.js → sigma-BOqRRcPd.js} +1 -1
  100. package/dist/assets/src-DBaBrRP7.js +169 -0
  101. package/dist/assets/{sso-popup-_MJHzwa1.js → sso-popup-DmWqZ3MH.js} +1 -1
  102. package/dist/assets/{step-inspector-model-CnQtYs5K.js → step-inspector-model-bvzJIjOL.js} +1 -1
  103. package/dist/assets/{table-2-Dvlda_-j.js → table-2-bzWGDQAd.js} +1 -1
  104. package/dist/assets/{timer-reset-YI0qCtUO.js → timer-reset-BvpZqMvs.js} +1 -1
  105. package/dist/assets/{ungroup-D0l55r1N.js → ungroup-0gvBv_DA.js} +1 -1
  106. package/dist/assets/{unlink-oV2v874Q.js → unlink-De7Xkt05.js} +1 -1
  107. package/dist/assets/{usb-BPo5IU4J.js → usb-CAPt7W-T.js} +1 -1
  108. package/dist/assets/{use-scenes-feed-B3p8nBta.js → use-scenes-feed-DjeG9R8r.js} +1 -1
  109. package/dist/assets/{use-stationary-objects-CD9yR5iw.js → use-stationary-objects-Btk77OCZ.js} +1 -1
  110. package/dist/assets/{useAdminDeviceRemoval-BJFjxBC1.js → useAdminDeviceRemoval-CwyP4Q5t.js} +1 -1
  111. package/dist/assets/useEventInvalidation-CLDPsoVj.js +1 -0
  112. package/dist/assets/{useNodeUrlSelection-BJUJbpFS.js → useNodeUrlSelection-BiPNEVuL.js} +1 -1
  113. package/dist/assets/{useTemplateSave-gsMZ3x0j.js → useTemplateSave-D2-Yu9Gn.js} +1 -1
  114. package/dist/assets/user-round-BXdsdFMt.js +1 -0
  115. package/dist/assets/{user-x-BATyaO5S.js → user-x-Cj8GF5bu.js} +1 -1
  116. package/dist/assets/{variable-CRCycAGa.js → variable-1vLYtz0A.js} +1 -1
  117. package/dist/assets/{video-GbTFZB7V.js → video-C97DVbBW.js} +1 -1
  118. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BT612bVv.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B_UH75Nx.js} +2 -2
  119. package/dist/index.html +9 -9
  120. package/dist/server/addon.js +91 -141
  121. package/package.json +2 -2
  122. package/dist/assets/Addons-BPGXuKqn.js +0 -5
  123. package/dist/assets/Build-0FsPVo2P.js +0 -39
  124. package/dist/assets/Cluster-BIJyBTTf.js +0 -1
  125. package/dist/assets/CompositionBlockEditor-CW5DAeUs.js +0 -2
  126. package/dist/assets/Data-D58GSELK.js +0 -2
  127. package/dist/assets/DeviceDetail-BkpmSnL4.js +0 -2
  128. package/dist/assets/DeviceDoActionFields-Ctyt40C4.js +0 -1
  129. package/dist/assets/History-DKFMd0pT.js +0 -1
  130. package/dist/assets/Identity-CvEEcPSv.js +0 -1
  131. package/dist/assets/IntegrationDetail-BnrTyomp.js +0 -1
  132. package/dist/assets/Integrations-Bfjwk3oQ.js +0 -1
  133. package/dist/assets/Integrations-n7echpSK.js +0 -2
  134. package/dist/assets/Notifications-CdPO0iWF.js +0 -1
  135. package/dist/assets/Recordings-BK7UHyqX.js +0 -1
  136. package/dist/assets/SessionsList-NCp0Ne73.js +0 -2
  137. package/dist/assets/StorageLocationsTable-BOoJHvC_.js +0 -1
  138. package/dist/assets/circle-slash-DSDcJE7U.js +0 -1
  139. package/dist/assets/client-BH6SJ4dQ.js +0 -839
  140. package/dist/assets/create-composition-C8Q_K5CP.js +0 -2
  141. package/dist/assets/crop-VCeKRhl3.js +0 -1
  142. package/dist/assets/device-picker-model-ib8rRrH4.js +0 -1
  143. package/dist/assets/dist-iBKsH9PQ.js +0 -839
  144. package/dist/assets/i18n-BslHm0aZ.js +0 -1
  145. package/dist/assets/icons-BWbyg3wC.js +0 -1
  146. package/dist/assets/index-DiGUzfG6.js +0 -4
  147. package/dist/assets/mount-ib8rRrH4.js +0 -1
  148. package/dist/assets/remoteEntry-CO-0F-ly.js +0 -1
  149. package/dist/assets/src-DYsgso0a.js +0 -169
  150. package/dist/assets/use-device-bound-caps-DyUQjTtX.js +0 -1
  151. package/dist/assets/useEventInvalidation-ib8rRrH4.js +0 -1
  152. package/dist/assets/user-round-Cy7oCHwq.js +0 -1
@@ -5890,7 +5890,7 @@ var ZodIssueCode = {
5890
5890
  var ZodFirstPartyTypeKind;
5891
5891
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5892
5892
  //#endregion
5893
- //#region ../types/dist/sleep-B36hHDDz.mjs
5893
+ //#region ../types/dist/sleep-VrfKAAGN.mjs
5894
5894
  /**
5895
5895
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5896
5896
  * window to float samples (D455).
@@ -9167,15 +9167,52 @@ var PeerBytesTicketSchema = object({
9167
9167
  */
9168
9168
  declaredBytes: number$1().int().nonnegative().nullable()
9169
9169
  });
9170
- discriminatedUnion("kind", [object({
9171
- kind: literal("action"),
9172
- actionId: string(),
9173
- runId: string(),
9174
- automationId: string().optional()
9175
- }), object({
9176
- kind: literal("scheduler"),
9177
- schedulerId: string()
9178
- })]);
9170
+ /**
9171
+ * The match a notification rule fired on (D705). Carried as a command origin so an
9172
+ * Action the rule starts can press `alarm-panel.trigger` as that match, not as an
9173
+ * anonymous press (D735). The same fields a rule fire ref freezes.
9174
+ */
9175
+ var RuleFireOriginSchema = object({
9176
+ ruleId: string(),
9177
+ ruleName: string(),
9178
+ deviceId: number$1().int(),
9179
+ sourceDeviceId: number$1().int().optional(),
9180
+ recordId: string(),
9181
+ timestamp: number$1(),
9182
+ trackId: string().optional(),
9183
+ eventId: string().optional(),
9184
+ className: string().optional(),
9185
+ label: string().optional(),
9186
+ zones: array(string()).optional(),
9187
+ confidence: number$1().optional(),
9188
+ sensorChange: object({
9189
+ name: string(),
9190
+ kind: string(),
9191
+ state: string()
9192
+ }).optional(),
9193
+ extraStills: array(object({
9194
+ ownerId: string(),
9195
+ cameraId: number$1().int()
9196
+ })).optional()
9197
+ });
9198
+ discriminatedUnion("kind", [
9199
+ object({
9200
+ kind: literal("action"),
9201
+ actionId: string(),
9202
+ runId: string(),
9203
+ automationId: string().optional(),
9204
+ /** The rule fire that started this run, when one did (D705). */
9205
+ ruleFire: RuleFireOriginSchema.optional()
9206
+ }),
9207
+ object({
9208
+ kind: literal("scheduler"),
9209
+ schedulerId: string()
9210
+ }),
9211
+ object({
9212
+ kind: literal("rule"),
9213
+ fire: RuleFireOriginSchema
9214
+ })
9215
+ ]);
9179
9216
  /**
9180
9217
  * One recorded device transition (D1022): a status field of a device went from
9181
9218
  * one value to another, with who or what asked for it.
@@ -43268,30 +43305,21 @@ function convertLegacyWhen(half) {
43268
43305
  * (instants) and state leaves (durations). It replaces the flat trigger list
43269
43306
  * plus the separate condition tree; the firing rule is in that file and in
43270
43307
  * ADR "one tree".
43271
- * - **Actions** — `NcRuleActionSchema`'s two steps, plus the `{kind:'code'}`
43272
- * fragment of §3.2.2. See {@link AutomationActionSchema} for the ONE place
43273
- * this had to diverge from "verbatim", and why.
43308
+ * - **Actions** — the `wait` and `cap` steps, plus the `{kind:'code'}`
43309
+ * fragment of §3.2.2. See {@link AutomationActionSchema}.
43274
43310
  *
43275
43311
  * A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
43276
43312
  * {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
43277
43313
  */
43278
43314
  /**
43279
- * One action step.
43315
+ * One action step: `wait`, or a `cap` call.
43280
43316
  *
43281
- * `wait` and `cap` are `NcRuleActionSchema`'s two members, kept structurally
43282
- * identical so `NcRuleActionRunner` runs them unchanged — its device-scope
43283
- * check, stop-at-first-failure and per-sequence throttle are the whole reason
43284
- * to reuse it, and none of them are re-implemented here.
43285
- *
43286
- * **The one divergence, and it is forced.** `NcRuleActionSchema.cap.deviceId` is
43287
- * a literal `z.number().int()`, and the NC runner's own `RunSequencesInput`
43288
- * documents its subject device as *"for the log tag, never for routing"*. So an
43289
- * NC action can never target the device that triggered it — which is fine for
43290
- * the NC (its rules already scope to a device) and fatal for an automation
43291
- * ("sound the siren of the camera that saw the person"). `deviceId` therefore
43292
- * also accepts `{ $var }`, resolved from the run's `vars` bag BEFORE the runner
43293
- * is called. The runner still receives a number and is untouched; the
43294
- * resolution is the recipe's job, not the runner's.
43317
+ * A cap step's target is who it acts on (D983: `devices`, a `domain`, or a
43318
+ * `{ $var }` resolved from the run's variables); the legacy `deviceId` is still
43319
+ * READ, never written. The step runner (`runSteps`) owns the device-scope
43320
+ * check, the stop-at-first-failure and the variable substitution, once, for
43321
+ * every caller — automations, Actions, and the notification centre, which runs
43322
+ * only Actions (planning#473).
43295
43323
  */
43296
43324
  var AutomationWaitStepSchema = object({
43297
43325
  kind: literal("wait"),
@@ -43909,6 +43937,8 @@ var ActionStatusSchema = object({
43909
43937
  /** The latest run's failure; null on success or when it never ran. */
43910
43938
  lastError: string().nullable()
43911
43939
  });
43940
+ /** The throttle window of an action, in seconds; absent or 0 = no throttle. */
43941
+ var ActionMinDelaySecSchema = number$1().int().min(0).max(86400);
43912
43942
  var ActionEntrySchema = object({
43913
43943
  /** `internal:<uuid>` or `<addonId>:<localId>`. */
43914
43944
  id: string().min(3),
@@ -43921,6 +43951,14 @@ var ActionEntrySchema = object({
43921
43951
  /** Internal only: cap and wait steps. No action-in-action, so no cycles. */
43922
43952
  steps: array(ActionStepSchema).min(1).max(50).optional(),
43923
43953
  variables: array(ActionVariableSchema).max(20).optional(),
43954
+ /**
43955
+ * Internal only: the least time between two run STARTS. A run that begins
43956
+ * inside the window is skipped (`skipped-cooldown`), traced and logged. It
43957
+ * is an actuator's budget — "how often may this gate physically open" —
43958
+ * not a notification cooldown, and it is shared by every caller of the
43959
+ * action (two rules, a button, an automation).
43960
+ */
43961
+ minDelaySec: ActionMinDelaySecSchema.optional(),
43924
43962
  status: ActionStatusSchema
43925
43963
  }).superRefine((entry, ctx) => {
43926
43964
  if (entry.source === "internal") {
@@ -43951,7 +43989,8 @@ var ActionEntrySchema = object({
43951
43989
  var ActionInputSchema = object({
43952
43990
  name: string().min(1).max(120),
43953
43991
  steps: array(ActionStepSchema).min(1).max(50),
43954
- variables: array(ActionVariableSchema).max(20).optional()
43992
+ variables: array(ActionVariableSchema).max(20).optional(),
43993
+ minDelaySec: ActionMinDelaySecSchema.optional()
43955
43994
  });
43956
43995
  /** Who started a run. Absent = the operator pressed it. */
43957
43996
  var ActionRunOriginSchema = object({
@@ -65054,92 +65093,21 @@ var NcZoneConditionSchema = object({
65054
65093
  * membership lists are OR within the list (spec §2.3).
65055
65094
  */
65056
65095
  /**
65057
- * What a rule may actuate.
65058
- *
65059
- * **No hand-maintained allowlist** (operator decision, and the right one — a
65060
- * written list of methods is a third parallel map to keep aligned, and this
65061
- * repo has paid for those). The boundary instead comes from a property the
65062
- * capabilities already carry: an action may target only a **device-scoped**
65063
- * capability method.
65096
+ * What a rule or a button runs: an **Action** of the `actions` surface
65097
+ * (`internal:<uuid>` or an addon's), by id, and nothing else (planning#473).
65064
65098
  *
65065
- * That is not decoration. A rule can be authored by a NON-ADMIN — personal
65066
- * rules are a supported flow — and the executor runs with the addon's
65067
- * privileges, so an unbounded action is an arbitrary RPC channel with a
65068
- * privilege escalation attached. Restricting to device scope excludes the
65069
- * system caps (`device-manager.removeDevice` and friends) by construction,
65070
- * costs nothing to maintain, and cannot rot: a cap that stops being
65071
- * device-scoped stops being actuatable in the same change.
65072
- *
65073
- * The executor enforces it; {@link NcRuleActionSchema} carries the intent.
65099
+ * The notification centre has no step vocabulary of its own. The steps, the
65100
+ * device-scope boundary, the stop-at-first-failure, the throttle
65101
+ * (`minDelaySec`), the variables and the runs ledger all belong to the Action;
65102
+ * an operator edits them in ONE place (the Actions page) and a rule points at
65103
+ * the result. A rule can be authored by a non-admin (personal rules), which is
65104
+ * safe for the same reason: it can only name an Action an admin already wrote.
65074
65105
  */
65106
+ var NcActionIdSchema = string().min(1);
65107
+ /** Action ids one hook edge runs, in order. Capped so a slot never becomes a second editor. */
65108
+ var NcHookActionIdsSchema = array(NcActionIdSchema).max(4);
65075
65109
  /**
65076
- * One step of a sequence.
65077
- *
65078
- * `wait` is a first-class step rather than a property of the next action: it is
65079
- * what makes a sequence a SEQUENCE and not a list — "unlock, wait 5s, open"
65080
- * cannot be expressed otherwise.
65081
- */
65082
- var NcRuleActionSchema = discriminatedUnion("kind", [object({
65083
- kind: literal("wait"),
65084
- seconds: number$1().min(0).max(300)
65085
- }), object({
65086
- kind: literal("cap"),
65087
- /**
65088
- * WHO the step acts on (D983) — the only shape that is written. A sequence
65089
- * stored before D983 carries `deviceId`; the sequence store reads it as a
65090
- * `devices` target.
65091
- */
65092
- target: ActionTargetSchema.optional(),
65093
- /** The vocabulary action the step performs; required for a `domain` target. */
65094
- actionId: string().min(1).optional(),
65095
- /** @deprecated The pre-D983 single device. Read, never written. */
65096
- deviceId: number$1().int().optional(),
65097
- /** Capability name, e.g. `alarm-panel`. */
65098
- cap: string().min(1),
65099
- /** Method on it. The executor refuses a non-device-scoped cap. */
65100
- method: string().min(1),
65101
- /** Method arguments, minus `deviceId` (the executor injects it). */
65102
- args: record(string(), unknown()).optional()
65103
- }).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
65104
- message: "a cap step needs a target",
65105
- path: ["target"]
65106
- }).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
65107
- message: "a domain target needs the vocabulary action it applies to (actionId)",
65108
- path: ["actionId"]
65109
- })]);
65110
- /**
65111
- * A named, ordered run of steps shared across rules, with its own throttle.
65112
- *
65113
- * Sequences live in the notification centre's sequence store — never inline on
65114
- * a rule. A rule binds to one by id ({@link NcActionBindingSchema}), and a
65115
- * button names one the same way. `minDelaySec` exists because a noisy rule
65116
- * otherwise hammers a physical actuator — the rule's own cooldown governs
65117
- * NOTIFICATIONS, which is a different budget from "how often may this gate
65118
- * actually open". The throttle key is the sequence id, so two rules sharing
65119
- * one sequence share its budget.
65120
- */
65121
- var NcSharedSequenceSchema = object({
65122
- id: string().min(1),
65123
- name: string().min(1).max(120),
65124
- minDelaySec: number$1().int().min(0).max(86400).optional(),
65125
- actions: array(NcRuleActionSchema).min(1)
65126
- });
65127
- /** Create / update body — the id is minted by the provider. */
65128
- var NcSharedSequenceInputSchema = object({
65129
- name: string().min(1).max(120),
65130
- minDelaySec: number$1().int().min(0).max(86400).optional(),
65131
- actions: array(NcRuleActionSchema).min(1)
65132
- });
65133
- /** Bindings on one hook edge. Cap keeps a slot from becoming a second sequence editor. */
65134
- var NcHookBindingsSchema = array(discriminatedUnion("kind", [object({
65135
- kind: literal("sequence"),
65136
- sequenceId: string().min(1)
65137
- }), object({
65138
- kind: literal("do"),
65139
- action: NcRuleActionSchema
65140
- })])).max(4);
65141
- /**
65142
- * One button carried by the notification, running a shared sequence on tap.
65110
+ * One button carried by the notification, running an Action on tap.
65143
65111
  *
65144
65112
  * **Read this before adding a button that does something physical.** The tap
65145
65113
  * arrives over a link that travelled through third-party infrastructure — ntfy,
@@ -65154,9 +65122,9 @@ var NcRuleNotificationButtonSchema = object({
65154
65122
  /** Stable id — travels in the callback and identifies the button in logs. */
65155
65123
  id: string().min(1).max(64),
65156
65124
  label: string().min(1).max(40),
65157
- /** Id of a shared sequence. The dispatcher drops a button whose sequence
65158
- * does not exist rather than minting a token for nothing. */
65159
- sequenceId: string().min(1),
65125
+ /** The Action the tap runs. The dispatcher drops a button whose Action does
65126
+ * not exist rather than minting a token for nothing. */
65127
+ actionId: NcActionIdSchema,
65160
65128
  icon: NotificationActionIconSchema.optional(),
65161
65129
  destructive: boolean().optional()
65162
65130
  });
@@ -65171,25 +65139,19 @@ var NcRuleNotificationButtonSchema = object({
65171
65139
  * leave). A delivery with no clear edge never produces this hook.
65172
65140
  */
65173
65141
  var NcRuleActionsSchema = object({
65174
- onActivation: NcHookBindingsSchema.optional(),
65175
- onDeactivation: NcHookBindingsSchema.optional(),
65142
+ onActivation: NcHookActionIdsSchema.optional(),
65143
+ onDeactivation: NcHookActionIdsSchema.optional(),
65176
65144
  /** Runs on a positive / raised match. */
65177
- onTrigger: NcHookBindingsSchema.optional(),
65145
+ onTrigger: NcHookActionIdsSchema.optional(),
65178
65146
  /** Runs on a clear / leave match, when the subject carries one. */
65179
- onTriggerOff: NcHookBindingsSchema.optional(),
65147
+ onTriggerOff: NcHookActionIdsSchema.optional(),
65180
65148
  /**
65181
- * Buttons the NOTIFICATION carries, each running one shared sequence when
65182
- * tapped. Deliberately a REFERENCE — a button that could define its own
65183
- * actions would be a parallel actuation vocabulary.
65149
+ * Buttons the NOTIFICATION carries, each running one Action when tapped.
65150
+ * Deliberately a REFERENCE — a button that could define its own steps would
65151
+ * be a parallel actuation vocabulary.
65184
65152
  */
65185
65153
  buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
65186
65154
  });
65187
- object({
65188
- name: string().min(1).max(120),
65189
- enabled: boolean(),
65190
- minDelaySec: number$1().int().min(0).max(86400).optional(),
65191
- actions: array(NcRuleActionSchema).min(1)
65192
- });
65193
65155
  /**
65194
65156
  * "This rule applies only while `deviceId` is in one of `states`."
65195
65157
  *
@@ -66870,18 +66832,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
66870
66832
  }), object({ success: literal(true) }), {
66871
66833
  kind: "mutation",
66872
66834
  auth: "admin"
66873
- }), method(object({}), object({ sequences: array(NcSharedSequenceSchema) }), { auth: "admin" }), method(object({ sequenceId: string().min(1) }), object({ sequence: NcSharedSequenceSchema.nullable() }), { auth: "admin" }), method(object({ sequence: NcSharedSequenceInputSchema }), object({ sequence: NcSharedSequenceSchema }), {
66874
- kind: "mutation",
66875
- auth: "admin"
66876
- }), method(object({
66877
- sequenceId: string().min(1),
66878
- sequence: NcSharedSequenceInputSchema
66879
- }), object({ sequence: NcSharedSequenceSchema }), {
66880
- kind: "mutation",
66881
- auth: "admin"
66882
- }), method(object({ sequenceId: string().min(1) }), object({ success: literal(true) }), {
66883
- kind: "mutation",
66884
- auth: "admin"
66885
66835
  }), method(object({}), NcClipRetentionPlanSchema, { auth: "admin" }), method(object({}), object({ mutedDeviceIds: array(number$1().int()).readonly() }), { auth: "admin" }), method(object({
66886
66836
  deviceId: number$1().int(),
66887
66837
  muted: boolean()
@@ -94846,7 +94796,7 @@ var AdminUIAddon = class extends BaseAddon {
94846
94796
  capability: adminUiCapability,
94847
94797
  provider: {
94848
94798
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
94849
- getVersion: async () => ({ version: "1.2.630" })
94799
+ getVersion: async () => ({ version: "1.2.631" })
94850
94800
  }
94851
94801
  }];
94852
94802
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.630",
3
+ "version": "1.2.631",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -50,7 +50,7 @@
50
50
  }
51
51
  ],
52
52
  "requires": {
53
- "server": ">=1.2.823"
53
+ "server": ">=1.2.824"
54
54
  }
55
55
  },
56
56
  "scripts": {
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bt as d,En as f,Hi as p,Kt as m,Ni as h,On as g,Q as _,Ri as v,St as y,Ti as b,Tr as x,Vi as S,Wn as C,Yt as w,ct as ee,hn as T,kn as te,li as E,ot as ne,rr as re,ut as ie,zn as D}from"./player-overlays-By97xFtJ.js";import{zs as O}from"./client-BH6SJ4dQ.js";import{a as k,p as ae}from"./video-GbTFZB7V.js";import{Ca as oe,Da as se,Ea as A,Ei as j,Hf as M,Hr as ce,Ht as le,Jr as ue,Kr as de,Mt as N,Pi as fe,Sa as P,Ta as pe,Tn as me,Ur as he,Wr as F,Zc as I,_a as L,aa as R,ac as ge,ba as _e,ca as z,cr as ve,da as ye,dr as B,fa as be,ga as xe,gf as Se,ha as V,la as H,lr as U,ma as W,oa as G,pr as Ce,qr as we,ra as Te,sa as Ee,ua as K,ur as De,va as Oe,wn as ke,xa as Ae,zf as je}from"./src-DYsgso0a.js";import{t as q}from"./useTranslation-BJr-n0es.js";import"./mount-ib8rRrH4.js";import{Br as Me,Hr as Ne,Ir as J}from"./index-DiGUzfG6.js";import{t as Y}from"./AdminPage-jW6IDTUf.js";import{i as Pe,r as Fe,t as Ie}from"./addon-kind-filter-CEGKkC1O.js";import{t as Le}from"./framework-packages-DoBKjjer.js";import{t as X}from"./NodeAddonsSettingsPanel-BNCeWOXe.js";import{n as Re,t as ze}from"./useNodeUrlSelection-BJUJbpFS.js";function Be(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Z={queued:{icon:b,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:x,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:D,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:p,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Q({item:e}){let{t:n}=q(),r=Z[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Ve=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),He=new Set([`done`,`failed`,`skipped`]);function Ue(e){return!He.has(e.phase)&&!Ve.has(e.jobState)}function We(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ve.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Ge(){let{data:e}=V({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=M(O.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return We([...n.values()],Date.now())},[e,t])}var Ke={queued:{icon:b,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:x,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:x,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:x,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:x,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:x,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:x,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:p,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function qe({progress:e}){let{t:n}=q(),r=Ke[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Je(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Ye(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Xe(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Ye)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Ze(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var Qe={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function $e(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Qe[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var et={},tt=3e4,nt=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function rt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=q(),c=l(),u=ee(),d=ne(),f=W(et,{staleTime:tt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=Je(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=A({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:$e(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ze(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},x=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Je(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Xe(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:nt,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(w,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:nt,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ae,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function it(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function at(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!it(e))}function ot(e){return e.length-at(e,!1).length}c();function st({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:f}=q(),m=r===`upload`||r===`local`,[h,g]=s(!1),{data:_,isLoading:v,isError:b}=K({name:e}),S=_?at(_,h):[],C=_?ot(_):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:f(`addons.versionPicker.versions`,`Versions`)}),a(j,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(y,{className:`h-3 w-3`})})]}),m&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(d,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:f(`addons.versionPicker.inPlace`,{kind:r===`upload`?f(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):f(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(J,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),f(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),b&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:f(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),d=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:f(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),it(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:f(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(j,{variant:`unstyled`,type:`button`,"aria-label":f(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[d,o?a(p,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[d,a(j,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?f(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):f(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(E,{className:`h-3 w-3`})})]},e.version)})}),!v&&!b&&_&&_.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:f(`addons.versionPicker.noVersionsFound`,`No versions found`)}),C>0&&a(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>g(e=>!e),children:h?f(`addons.versionPicker.hideOlder`,`Hide older versions`):f(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:C})})]})}c();var ct=`device-export`;function lt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ct)}function ut(e){return e!==`local`&&e!==`upload`}function dt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,f=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?_(`/api/addon-assets/${r}/${i}`):null,m=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:f}`,style:u,children:m?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?re:C,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),ut(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(d,{className:`h-2.5 w-2.5 text-white`})})]})}function ft({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=q();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(x,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(E,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(S,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(S,{className:`h-3 w-3 opacity-50`})]}),u]})}function pt({addonId:e}){let t=l(),{data:n=`inherit`}=G({addonId:e}),r=P({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(j,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var mt={id:`hub`,name:`Hub`,isHub:!0};function ht({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdate:d,isUpdating:p,jobProgress:m,bundle:h,bulkItem:g,disabledByBulk:_,isSystem:b,selectedNode:x}){let{t:C}=q(),[w,ee]=s(!1),[T,E]=s(!1),[ne,ie]=s(null);o(()=>{ie(null)},[i]);let O=ne??i,[ae,oe]=s(!1),[se,A]=s(!1),[M,N]=s(`logs`),P=l(),pe=Me(),{manifest:I}=e,L=!h&&!I.protected&&I.removable!==!1,R=!!h,ge=h?.displayName??I.name,z=h?.packageName??I.packageName,ve=h?.version??I.packageVersion??I.version,B=h?.installSource??e.installSource,be=h?h.bundle?.description??h.addons[0]?.manifest.description:I.description,xe=Oe({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),Se=ye({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),V=_e({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),H=e.health,U=H?.phase===`failed`&&!H.inGracePeriod,W=U&&H?.nextRetryAt&&!H.retrying,G=Be(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${U?`border-red-500/50`:`border-border`}`,children:[U&&H&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.failedToLoad`,{attempt:H.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:H.lastError?.message??C(`addons.addonCard.unknownError`,`Unknown error`)}),W&&H.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:C(`addons.addonCard.autoRetryAt`,{time:new Date(H.nextRetryAt).toLocaleTimeString()})})]}),t(j,{variant:`unstyled`,type:`button`,disabled:V.isPending||H.retrying,onClick:e=>{e.stopPropagation(),V.mutate({packageName:z})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:C(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(D,{className:`h-3 w-3 ${V.isPending||H.retrying?`animate-spin`:``}`}),C(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(dt,{isBundle:R||!!I.components&&I.components.length>1,installSource:B,addonId:R?h.addons[0]?.manifest.id:I.id,iconPath:R?h.bundle?.icon??h.addons[0]?.manifest.icon:I.icon,color:R?h.addons[0]?.manifest.color:I.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:ge}),!r&&a(ft,{version:ve,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:p,installSource:B,disabled:_,...d&&O!==void 0?{onUpdate:()=>d(O)}:{},onOpenPicker:()=>E(e=>!e),children:T&&a(st,{packageName:z,currentVersion:ve,...B?{installSource:B}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{ie(e),E(!1)}}:{},onInstall:e=>{E(!1),Se.mutate({packageName:z,version:e})},onClose:()=>E(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[z!==ge&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:z}),R&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(re,{className:`h-3 w-3`}),h.addons.length]}),b&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:C(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(D,{className:`h-3 w-3`}),C(`addons.addonCard.system`,`System`)]}),g!=null&&a(Q,{item:g}),c!==void 0&&a(fe,{variant:`warning`,title:C(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:C(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),m!=null&&a(qe,{progress:m})]}),be&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:be}),!R&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?C(`addons.addonCard.forked`):C(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!R&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),xe.mutate({addonId:I.id})},disabled:xe.isPending||_,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(D,{className:`h-3 w-3 ${xe.isPending?`animate-spin`:``}`}),C(`addons.addonCard.restart`,`Restart`)]}),t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(te,{className:`h-3 w-3`}),C(`addons.addonCard.logs`,`Logs`)]}),!R&&t(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${se?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(f,{className:`h-3 w-3`}),C(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),L&&a(rt,{packageName:I.packageName,displayName:I.name,selectedNode:x??mt,disabled:_})]}),n&&n.nodes.length>1&&!R&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:C(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:C(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:C(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:C(`common.synced`)})]},e.nodeId))})]}),ae&&!R&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(j,{variant:`unstyled`,type:`button`,onClick:()=>N(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.logs`,`Logs`)}),a(j,{variant:`unstyled`,type:`button`,onClick:()=>N(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(j,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(y,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&a(me,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&a(ke,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),R&&t(u,{children:[a(j,{variant:`unstyled`,type:`button`,onClick:()=>ee(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(w?v:S,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),w&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:h.addons.map(e=>a(ht,{addon:e,hideVersion:!0},e.manifest.id))})]}),se&&!R&&a(ce,{open:!0,onOpenChange:e=>!e&&A(!1),children:t(F,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(we,{children:t(ue,{className:`flex items-center gap-2`,children:[a(f,{className:`h-4 w-4 text-primary`}),C(`addons.addonCard.settingsTitle`,{name:ge})]})}),t(he,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:C(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(X,{nodeId:null,addonIds:[I.id],level:`global`,fieldScope:`cluster`,emptyMessage:C(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),lt(I)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.deviceExport`,`Device export`)}),a(le,{addonId:I.id,onOpenDevice:e=>pe(`/devices/${e}`)})]}),ut(B)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(pt,{addonId:I.id})]}),I.components&&I.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.components`,{count:I.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:I.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(de,{children:a(j,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>A(!1),children:C(`common.close`,`Close`)})})]})})]})}c();var gt=`.tgz,.tar.gz,.zip`;function _t({onUploadSuccess:e}){let{t:r}=q(),[o,c]=s(!1),l=n(null),f=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(_(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(Ce,{ref:l,accept:gt,onChange:i(e=>{let t=e.target.files?.[0];t&&f(t),e.target.value=``},[f]),className:`hidden`}),t(j,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(x,{className:`w-3.5 h-3.5 animate-spin`}):a(d,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var vt=/```[^\n]*\n([\s\S]*?)```/g;function yt(e){let t=[],n=0;for(let r of e.matchAll(vt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function bt(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function xt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?bt(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function St(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:xt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:xt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=xt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Ct({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:yt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:St(e.body,`b${t}`)},`text-${t}`))})}c();function wt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Tt(e,t,n){let r=at(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function Et({pending:e,failed:n,body:r,missing:i}){let{t:o}=q();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Ct,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function Dt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=q(),[l,u]=s(e.version),[d,f]=s(!1),p=K({name:e.name}),m=H({name:e.name,version:l}),h=p.data??[],g=ot(h),_=Tt(h,l,d),v=m.data;return a(ce,{open:!0,onOpenChange:e=>!e&&i(),children:t(F,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(we,{children:a(ue,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:wt(e.name)})})}),t(he,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(ie,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:it(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(j,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(ve,{defaultValue:`readme`,children:[t(De,{children:[a(B,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(B,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(U,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(U,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(de,{children:[a(j,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(j,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(x,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var Ot=new Set([`@camstack/server`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function kt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ot.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function At({selectedNode:e}){let{t:n}=q(),{data:r}=W(et,{staleTime:tt});if(r===void 0)return null;let i=kt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(m,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(rt,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function jt({addon:e,installing:n,onInstall:r}){let{t:i}=q();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(fe,{variant:`success`,icon:a(p,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(j,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(x,{className:`h-3 w-3 animate-spin`}):a(E,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Mt({capability:e,installing:n,onInstall:r}){let{t:i}=q(),{data:o,isPending:s,isError:c}=Ae({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(jt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Nt(e){return e===`npm`||e===`dev`?e:null}var Pt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,Ft=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,It=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Lt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Rt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function zt(e){return e===`local`?`dev`:`npm`}function Bt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Vt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Ht({addons:c,clusterStatus:u,selectedNode:d,onRefresh:f,listPhase:p}){let{t:m}=q(),_=l(),[v,y]=s(``),b=e(v),[S,C]=s(!1),w=n(null);o(()=>{if(!S)return;let e=e=>{w.current&&!w.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[S]);let{data:T}=xe({nodeId:d.id}),te=r(()=>{let e=new Map;for(let t of T??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[T]),ne=r(()=>{let e=new Map;for(let t of T??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[T]),re=r(()=>(T??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[T]),[O,k]=s(()=>new Set),[ae,A]=s(()=>new Map),M=i(e=>{k(t=>new Set(t).add(e))},[]),ce=i(e=>{k(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),le=i((e,t)=>{A(n=>new Map(n).set(e,t))},[]),ue=i(e=>{A(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),de=se({onMutate:e=>{M(e.name),ue(e.name)},onSuccess:(e,t)=>{ce(t.name);let n=e;if(n&&n.success===!1){le(t.name,n.error??`Update failed (no error message returned by server)`);return}_.invalidateQueries({queryKey:[[`addons`]]}),_.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ce(t.name),le(t.name,e instanceof Error?e.message:String(e))}}),N=Ge(),fe=n(new Set);o(()=>{let e=new Set;for(let[t,n]of N)Ue(n)&&e.add(t);let t=[...fe.current].some(t=>!e.has(t));fe.current=e,t&&(_.invalidateQueries({queryKey:[[`addons`]]}),_.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,_]);let{data:P}=Ee(void 0),me=Te({onSuccess:()=>{_.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),he=oe({onSuccess:()=>{_.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:F,isFetching:I}=Ae({query:b||void 0},{enabled:S}),L=pe(),{data:R}=z(void 0),_e=R?.requestedAt,[ve,B]=s(null),[be,V]=s(!1);o(()=>{if(R?.kind===`framework-bulk-update`&&R.requestedAt!==ve){B(R.requestedAt),V(!0);let e=window.setTimeout(()=>V(!1),6e3);return()=>window.clearTimeout(e)}},[_e,ve,R]),ee();let H=i(async()=>{let e=(T??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!d.isHub){for(let t of e)await de.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await L.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,L,de]),[U,W]=s(null),[G,Ce]=s(null),we=e=>{Ce(null),W(e)},K=ye({onSuccess:()=>{W(null),Ce(null),_.invalidateQueries({queryKey:[[`addons`]]}),_.invalidateQueries({queryKey:[[`addonPages`]]}),_.invalidateQueries({queryKey:[[`capabilities`]]}),_.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{Ce(e instanceof Error?e.message:`Install failed`)}}),[De,Oe]=s(`type`),[ke,je]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Me=e=>{je(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,Y]=Ne(),X=J.get(`capability`),Re=J.get(`updatable`)===`1`,ze=J.get(`error`)===`1`,Z=Nt(J.get(`source`)),Q=Pe(J.get(Ie))===`integration`,{data:Ve}=ge(void 0,{enabled:Q}),He=r(()=>Ve===void 0?null:new Set(Ve.map(e=>e.addonId)),[Ve]),We=i(e=>{let t=new URLSearchParams(J);e?t.set(Ie,`integration`):t.delete(Ie),Y(t,{replace:!0})},[J,Y]),Ke=i(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[J,Y]),qe=i(e=>{let t=new URLSearchParams(J);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[J,Y]),Je=i(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[J,Y]),Ye=r(()=>c.filter(e=>Be(e.process)!==null).length,[c]),Xe=r(()=>{let e=c.filter(e=>!Le(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Rt(e.placement,d.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Q&&(e=[...Fe(e,He)]),Re&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&te.has(t)})),Z!==null&&(e=e.filter(e=>zt(e.installSource)===Z)),ze&&(e=e.filter(e=>Be(e.process)!==null)),e},[c,d.isHub,X,Re,Z,ze,Q,He,te]),Ze=()=>{let e=new URLSearchParams(J);e.delete(`capability`),Y(e,{replace:!0})},Qe=ke===`flat`?Xe:Vt(Xe),$e=r(()=>{let e=[...Qe];switch(De){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Qe,De]);return t(`div`,{className:`space-y-3`,children:[[...ae.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:m(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(j,{variant:`unstyled`,type:`button`,onClick:()=>ue(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:m(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.sort`,`Sort:`)}),t(ie,{wrapperClassName:`inline-block w-auto`,value:De,onChange:e=>Oe(e.target.value),children:[a(`option`,{value:`type`,children:m(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:m(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:m(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(j,{variant:`unstyled`,type:`button`,onClick:()=>Me(e),className:`px-2 py-1 transition-colors capitalize ${ke===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?m(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):m(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(D,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(j,{variant:`unstyled`,type:`button`,onClick:()=>me.mutate({channel:e}),disabled:me.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.checkEvery`,`Check every:`)}),a(ie,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:he.isPending||P===void 0,onChange:e=>{P!==void 0&&he.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:It.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),re>0&&t(j,{variant:`unstyled`,type:`button`,onClick:()=>void H(),disabled:L.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[L.isPending?a(x,{className:`w-3 h-3 animate-spin`}):a(E,{className:`w-3 h-3`}),L.isPending?m(`admin.system.addons.updating`,`Updating…`):m(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:re})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":m(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:m(`admin.system.addons.integrations`,`Integrations`),pressed:Q,toggle:()=>We(!Q)},{id:`updatable`,label:m(`admin.system.addons.updatable`,`Updatable`),pressed:Re,toggle:()=>Ke(!Re)},{id:`error`,label:m(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ye}),pressed:ze,toggle:()=>qe(!ze)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Je(Z===`npm`?null:`npm`)},{id:`dev`,label:m(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Je(Z===`dev`?null:`dev`)}].map(e=>a(j,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Pt:Ft,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:w,children:[a(Se,{type:`text`,searchHotkey:!0,value:v,onChange:e=>{y(e.target.value),C(!0)},onFocus:()=>C(!0),placeholder:m(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":m(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:L.isPending,leftSlot:a(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:I?a(x,{className:`h-3 w-3 animate-spin`}):void 0}),S&&F&&F.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[F.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:m(`systemPage.addons.npmResults`,{count:F.length})}),F&&F.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:F.map(e=>a(jt,{addon:e,installing:K.isPending,onInstall:e=>we({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(_t,{onUploadSuccess:()=>{_.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),X&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:m(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(j,{variant:`unstyled`,type:`button`,onClick:Ze,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:m(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Mt,{capability:X,installing:K.isPending,onInstall:e=>we({name:e.name,version:e.version,description:e.description})}),X&&Xe.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:m(`admin.system.addons.installed`,`Installed`)}),be&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(h,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:m(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:m(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),p===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3 w-3 animate-spin`}),m(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),p===`error`&&a(`div`,{className:`text-xs text-danger`,children:m(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),p===`ready`&&Xe.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?m(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?m(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):m(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:p===`ready`&&$e.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=te.get(t),r=ne.get(t),i=$(e)?e.representative:e,o=n?e=>de.mutate({name:t,version:e,nodeId:d.id}):void 0,s=N.get(t)??null,c=s!==null&&Ue(s);return a(ht,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},isUpdating:O.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:L.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),U!==null&&a(Dt,{target:U,installing:K.isPending,installError:G,onClose:()=>W(null),onInstall:(e,t)=>K.mutate({packageName:e,version:t})})]})}function Ut(){let{t:e}=q(),r=l(),{data:i}=I(void 0),{nodes:s}=je(),{selection:c,selectNode:u,requestedNodeId:d}=ze(s.length>0?s:[Lt]),f=c.node??Lt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=be({nodeId:p}),v=R(),y=L(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},S=n(v);S.current=v;let C=n(d??`hub`);o(()=>{S.current.mutate({nodeId:C.current})},[]);let w=(h??[]).map(Bt).filter(e=>e!==null);return t(Y,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(N,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:w.length})}),t(j,{variant:`unstyled`,type:`button`,onClick:()=>void x(),disabled:b,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(D,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Re,{staleNodeId:m,shownNodeName:f.name}),a(At,{selectedNode:f}),a(Ht,{addons:w,clusterStatus:i,selectedNode:f,onRefresh:()=>void x(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{Ut as AddonsPage};