@camstack/addon-admin-ui 1.2.474 → 1.2.476

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 (176) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +19 -0
  3. package/dist/assets/AddonAssetIcon-NsStjqDv.js +1 -0
  4. package/dist/assets/Addons-CC-7wyzX.js +5 -0
  5. package/dist/assets/AdminPage-BBb_f0ke.js +1 -0
  6. package/dist/assets/AdminSectionedPage-B77fFYLu.js +1 -0
  7. package/dist/assets/AiProfiles-DQ7eLKoM.js +3 -0
  8. package/dist/assets/BrokerForm-Dql4j_7g.js +1 -0
  9. package/dist/assets/Build-0VXUZTUO.js +40 -0
  10. package/dist/assets/Calendars-DDdCqGq7.js +1 -0
  11. package/dist/assets/Cluster-B8y8FoQV.js +1 -0
  12. package/dist/assets/CompositionBlockEditor-RHV08gl_.js +1 -0
  13. package/dist/assets/CompositionEditorPage-zqBIwPtu.js +1 -0
  14. package/dist/assets/Data-C8MsiGcu.js +2 -0
  15. package/dist/assets/DeviceDetail-BhhXtfQ_.js +2 -0
  16. package/dist/assets/DeviceDoActionFields-CM877gWa.js +1 -0
  17. package/dist/assets/Devices-D_p1jnJs.js +1 -0
  18. package/dist/assets/EmbedPlayerPage-n_ZfqSgX.js +1 -0
  19. package/dist/assets/HelperWizard-WGprHYSO.js +2 -0
  20. package/dist/assets/History-DP_G-ECr.js +1 -0
  21. package/dist/assets/Identity-D_ESOlFi.js +1 -0
  22. package/dist/assets/IntegrationDetail-DAaPI_ET.js +1 -0
  23. package/dist/assets/IntegrationHub-Ch94ozNN.js +1 -0
  24. package/dist/assets/Integrations-BBm9vAbT.js +1 -0
  25. package/dist/assets/Integrations-CcDZmbwS.js +1 -0
  26. package/dist/assets/Library-B6p5cMT3.js +1 -0
  27. package/dist/assets/Locations-C_Mo8QAj.js +3 -0
  28. package/dist/assets/Logs-DbUcQh4T.js +1 -0
  29. package/dist/assets/MaskShapeCanvas-UFmJUhUS.js +1 -0
  30. package/dist/assets/MotionZonesSettings-BTxe4DbF.js +1 -0
  31. package/dist/assets/MyAccess-BjgGZZmK.js +2 -0
  32. package/dist/assets/Network-DJAN2ffw.js +1 -0
  33. package/dist/assets/NodeAddonsSettingsPanel-P5f0HKwt.js +1 -0
  34. package/dist/assets/Notifications-BahnGVKD.js +1 -0
  35. package/dist/assets/Pipeline-gniN2j7S.js +1 -0
  36. package/dist/assets/PrivacyMaskSettings-D6kokNvH.js +1 -0
  37. package/dist/assets/Recordings-BK-wAC4w.js +1 -0
  38. package/dist/assets/ScanNetworkModal-D0nIF1xL.js +1 -0
  39. package/dist/assets/SceneMonitorEditor-CrDKfkgT.js +1 -0
  40. package/dist/assets/SessionsList-eAK6hNQb.js +2 -0
  41. package/dist/assets/Showroom-OGwDnxr_.js +1 -0
  42. package/dist/assets/System-CkfHfeMd.js +1 -0
  43. package/dist/assets/{Terminal-COEKXIAj.js → Terminal-puPiVrKC.js} +3 -3
  44. package/dist/assets/{Viewer-BW9JCbu_.js → Viewer-QizHE8-x.js} +1 -1
  45. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B4AOEb1R.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BIhn7NhC.js} +1 -1
  46. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js} +1 -1
  47. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js +1 -0
  48. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js +1 -0
  49. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-Cb2QlpvS.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js} +1 -1
  50. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-Cyj0Xie_.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js} +3 -3
  51. package/dist/assets/addon-icons-context-DxUCqyaH.js +1 -0
  52. package/dist/assets/{archive-BTmhmQQp.js → archive-Brq5E-qM.js} +1 -1
  53. package/dist/assets/{assignment-candidates-C4DL_rSh.js → assignment-candidates-D58mtpje.js} +1 -1
  54. package/dist/assets/authed-media-B_8ON2MT.js +1 -0
  55. package/dist/assets/{bell-off-DsAerV0u.js → bell-off-CDjOfT8K.js} +1 -1
  56. package/dist/assets/{board-model-CnpzmN9f.js → board-model-4EY3kgfH.js} +1 -1
  57. package/dist/assets/{boxes-DT6bkxUA.js → boxes-0ut2NdHU.js} +1 -1
  58. package/dist/assets/circle-slash-CaxGVwz5.js +1 -0
  59. package/dist/assets/client-DvJxGh2F.js +358 -0
  60. package/dist/assets/{cloud-upload-iGrXLaxX.js → cloud-upload-M9JxZe_d.js} +1 -1
  61. package/dist/assets/crop-eK4NEtXI.js +1 -0
  62. package/dist/assets/{device-integration-icon-XVdZ9pIS.js → device-integration-icon-C28x8nbP.js} +1 -1
  63. package/dist/assets/device-picker-model-BkHlLdb8.js +1 -0
  64. package/dist/assets/{dist-Bd_kB5yG.js → dist-B9cEBPZ1.js} +1 -1
  65. package/dist/assets/dist-Cwk0eIEi.js +358 -0
  66. package/dist/assets/{eraser-L4lKjV-e.js → eraser-Bs0PJaPY.js} +1 -1
  67. package/dist/assets/{format-BTMQLjGl.js → format-Bq6kzos8.js} +1 -1
  68. package/dist/assets/{hard-drive-download-cfcxCkzE.js → hard-drive-download-iRJR_Xj9.js} +1 -1
  69. package/dist/assets/{hostInit-BBq0iCeL.js → hostInit-EKt3RqKv.js} +1 -1
  70. package/dist/assets/i18n-l_m6iBJW.js +1 -0
  71. package/dist/assets/{icons-Cv_Dcjty.js → icons-BivKI4y9.js} +1 -1
  72. package/dist/assets/index-BFjKpxae.js +4 -0
  73. package/dist/assets/index-CU-5JpMo.css +2 -0
  74. package/dist/assets/{key-e3_N15fG.js → key-Crd8m-SP.js} +1 -1
  75. package/dist/assets/{key-round-x0Ig1rd2.js → key-round-DG341WFZ.js} +1 -1
  76. package/dist/assets/{layers-T4HoHbdn.js → layers-BnsQ5ORI.js} +1 -1
  77. package/dist/assets/{linked-devices-model-CObOrxIk.js → linked-devices-model-Cgse8lhb.js} +1 -1
  78. package/dist/assets/{list-ordered-I4dBVzRf.js → list-ordered-BIo7AnFy.js} +1 -1
  79. package/dist/assets/location-owned-usage-uS8d4cQL.js +1 -0
  80. package/dist/assets/{log-in-B1D0wNrs.js → log-in-D1BPSCDn.js} +1 -1
  81. package/dist/assets/{memory-stick-DYS3v1CU.js → memory-stick-CjPBCMfd.js} +1 -1
  82. package/dist/assets/{message-square-plus-D64e2l9L.js → message-square-plus-C4N5hy0x.js} +1 -1
  83. package/dist/assets/{mf-entry-bootstrap-0-c6a36508.js → mf-entry-bootstrap-0-99fca1f4.js} +2 -2
  84. package/dist/assets/{mic-off-hTqpFTxe.js → mic-off-CgPfA49W.js} +1 -1
  85. package/dist/assets/{monitor-off-Bj-JQM7b.js → monitor-off-Ib2v0VDF.js} +1 -1
  86. package/dist/assets/{monitor-smartphone-CyTSF3mW.js → monitor-smartphone-6w2T5Ht_.js} +1 -1
  87. package/dist/assets/mount-BkHlLdb8.js +1 -0
  88. package/dist/assets/player-overlays-Dbv95cvz.js +1 -0
  89. package/dist/assets/{recycle-BLx8Nd-6.js → recycle-DcScXiTi.js} +1 -1
  90. package/dist/assets/remoteEntry-awBSqPjf.js +1 -0
  91. package/dist/assets/{scan-eye-CrOhuNWQ.js → scan-eye-CWOvobjP.js} +1 -1
  92. package/dist/assets/{scissors-C6HYvaxr.js → scissors-NpyrGUBV.js} +1 -1
  93. package/dist/assets/{search-x-C8eiZDQW.js → search-x-CKQw--aU.js} +1 -1
  94. package/dist/assets/{send-CNzJmniJ.js → send-402PlgqT.js} +1 -1
  95. package/dist/assets/{settings-2-Ccb0AMXU.js → settings-2-BbwQVFbm.js} +1 -1
  96. package/dist/assets/{speaker-BsE4hqmg.js → speaker-DCHkSyjS.js} +1 -1
  97. package/dist/assets/src-ByunGuTZ.js +67 -0
  98. package/dist/assets/step-inspector-model-C-7jLQzL.js +1 -0
  99. package/dist/assets/{timer-reset-Tun-zcxs.js → timer-reset-DZ3bTFWu.js} +1 -1
  100. package/dist/assets/{ungroup-BdxY8QDj.js → ungroup-3fOR8xo7.js} +1 -1
  101. package/dist/assets/{unlink-BVODHZoC.js → unlink-vu-wpZmU.js} +1 -1
  102. package/dist/assets/{usb-i2JzfEjl.js → usb-CGOBq5r2.js} +1 -1
  103. package/dist/assets/{use-scenes-feed-CUQxwk-v.js → use-scenes-feed-wrd7r_Sr.js} +1 -1
  104. package/dist/assets/{use-stationary-objects-Cqmb4Ymg.js → use-stationary-objects-U-Gv-CIi.js} +1 -1
  105. package/dist/assets/useEventInvalidation-BkHlLdb8.js +1 -0
  106. package/dist/assets/useNodeUrlSelection-DZ8j6nae.js +1 -0
  107. package/dist/assets/useTranslation-BJr-n0es.js +1 -0
  108. package/dist/assets/user-round-CmncOV9r.js +1 -0
  109. package/dist/assets/{user-x-CIq05NC_.js → user-x-CjUfhy0O.js} +1 -1
  110. package/dist/assets/{video-CJw8Jnle.js → video-D7jv0spx.js} +1 -1
  111. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BWKP-Fxc.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BaETqb6x.js} +2 -2
  112. package/dist/index.html +11 -11
  113. package/dist/server/addon.js +145 -8
  114. package/package.json +4 -2
  115. package/dist/assets/AddonAssetIcon-DNTjc2uq.js +0 -1
  116. package/dist/assets/Addons-CPaW6tLw.js +0 -4
  117. package/dist/assets/AdminPage-B4QlIiKh.js +0 -1
  118. package/dist/assets/AdminSectionedPage-BIoU14zn.js +0 -1
  119. package/dist/assets/AiProfiles-FpbSg3kP.js +0 -3
  120. package/dist/assets/BrokerForm-CU4X3nL7.js +0 -1
  121. package/dist/assets/Build-C2qKCizt.js +0 -40
  122. package/dist/assets/Calendars-BRTmlFIt.js +0 -1
  123. package/dist/assets/Cluster-BvxOiIZ7.js +0 -1
  124. package/dist/assets/CompositionCreateForm-DCUy3waQ.js +0 -1
  125. package/dist/assets/CompositionEditorPage-syg6YTJF.js +0 -1
  126. package/dist/assets/Data-VG64mGmK.js +0 -2
  127. package/dist/assets/DeviceDetail-tZevLHDV.js +0 -2
  128. package/dist/assets/DeviceDoActionFields-BmEM1vFn.js +0 -1
  129. package/dist/assets/Devices-B-b5cUYn.js +0 -1
  130. package/dist/assets/EmbedPlayerPage-CI3OOtRg.js +0 -1
  131. package/dist/assets/HelperWizard-4637ctxc.js +0 -2
  132. package/dist/assets/History-BJcol9mz.js +0 -1
  133. package/dist/assets/Identity-CjEfAbi1.js +0 -1
  134. package/dist/assets/IntegrationDetail-DLncDXox.js +0 -1
  135. package/dist/assets/IntegrationHub-B1soAFk9.js +0 -1
  136. package/dist/assets/Integrations-DtQc1eDp.js +0 -1
  137. package/dist/assets/Integrations-xxkUIJ67.js +0 -1
  138. package/dist/assets/Library-DbHcY62a.js +0 -1
  139. package/dist/assets/Locations-CfYQkG2R.js +0 -3
  140. package/dist/assets/Logs-CMYLVX21.js +0 -1
  141. package/dist/assets/MaskShapeCanvas-BnMDm4ev.js +0 -1
  142. package/dist/assets/MotionZonesSettings-DKqDt4OB.js +0 -1
  143. package/dist/assets/MyAccess-CjUd-G8J.js +0 -2
  144. package/dist/assets/Network-Dudx2Fcg.js +0 -1
  145. package/dist/assets/NodeAddonsSettingsPanel-9_q0f4bE.js +0 -1
  146. package/dist/assets/Notifications-DE5Wtais.js +0 -1
  147. package/dist/assets/Pipeline-r8TFI-Fa.js +0 -1
  148. package/dist/assets/PrivacyMaskSettings-DZ2mewnu.js +0 -1
  149. package/dist/assets/Recordings-BrpMcrZw.js +0 -1
  150. package/dist/assets/ScanNetworkModal-DhahS87x.js +0 -1
  151. package/dist/assets/SceneMonitorEditor-CH7F9rZo.js +0 -1
  152. package/dist/assets/SessionsList-BbD9LSdf.js +0 -2
  153. package/dist/assets/Showroom-BX1LrKmF.js +0 -1
  154. package/dist/assets/System-CvErxLx3.js +0 -1
  155. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js +0 -1
  156. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-DPkvGqVU.js +0 -1
  157. package/dist/assets/addon-icons-context-Bus8wGvh.js +0 -1
  158. package/dist/assets/authed-media-C8FW8mvx.js +0 -1
  159. package/dist/assets/circle-slash-BFwh1Zbg.js +0 -1
  160. package/dist/assets/client-BbPYrWg7.js +0 -358
  161. package/dist/assets/crop-FX76GBoF.js +0 -1
  162. package/dist/assets/device-picker-model-B5MjkWnS.js +0 -1
  163. package/dist/assets/dist-D6Fj77pb.js +0 -358
  164. package/dist/assets/i18n-BO6gCPcC.js +0 -1
  165. package/dist/assets/index-BvsP28fN.css +0 -2
  166. package/dist/assets/index-C8XwyZGE.js +0 -4
  167. package/dist/assets/location-owned-usage-D17U3uzz.js +0 -1
  168. package/dist/assets/mount-B5MjkWnS.js +0 -1
  169. package/dist/assets/player-overlays-CvKnZb5M.js +0 -1
  170. package/dist/assets/remoteEntry-DBUvkI6n.js +0 -1
  171. package/dist/assets/src-DKc14e9G.js +0 -67
  172. package/dist/assets/step-inspector-model-BeIQx3rW.js +0 -1
  173. package/dist/assets/useEventInvalidation-B5MjkWnS.js +0 -1
  174. package/dist/assets/useNodeUrlSelection-rnUQLTfb.js +0 -1
  175. package/dist/assets/useTranslation-D3Is_4B6.js +0 -1
  176. package/dist/assets/user-round-BkFCDGbj.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- //#region ../types/dist/event-category-DHXxB8t9.mjs
3
+ //#region ../types/dist/event-category-CT-hz5Rb.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -326,6 +326,14 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
326
326
  /** The recovery edge of {@link PipelineMotionNoisy}: the motion fell back, or a detection arrived. */
327
327
  EventCategory["PipelineMotionCalm"] = "pipeline.motion-calm";
328
328
  /**
329
+ * A camera's package LLM confirm has failed closed three times in a row
330
+ * (D931, 2026-10-26). One edge per camera until
331
+ * {@link PipelinePackageLlmAnswered}.
332
+ */
333
+ EventCategory["PipelinePackageLlmSilent"] = "pipeline.package-llm-silent";
334
+ /** The recovery edge of {@link PipelinePackageLlmSilent}: a confirm returned yes or no. */
335
+ EventCategory["PipelinePackageLlmAnswered"] = "pipeline.package-llm-answered";
336
+ /**
329
337
  * Per-camera pipeline config was mutated by the orchestrator
330
338
  * (a settings change via `setAgentInferenceDevices` /
331
339
  * `setCameraStepToggle` / `setCameraStepSettings`). Orchestrator
@@ -5435,7 +5443,7 @@ var ZodIssueCode = {
5435
5443
  var ZodFirstPartyTypeKind;
5436
5444
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5437
5445
  //#endregion
5438
- //#region ../types/dist/sleep-B81gwQuR.mjs
5446
+ //#region ../types/dist/sleep-bykKrTgu.mjs
5439
5447
  /**
5440
5448
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5441
5449
  * window to float samples (D455).
@@ -8575,6 +8583,7 @@ var CAP_NAMES = Object.freeze([
8575
8583
  "filesystem-browse",
8576
8584
  "flood",
8577
8585
  "gas",
8586
+ "group-commands",
8578
8587
  "group-status",
8579
8588
  "heating-valve",
8580
8589
  "humidifier",
@@ -10739,7 +10748,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
10739
10748
  return DeviceRole;
10740
10749
  }({});
10741
10750
  //#endregion
10742
- //#region ../types/dist/composition-B85l9j1M.mjs
10751
+ //#region ../types/dist/composition-OhpuespA.mjs
10743
10752
  /**
10744
10753
  * The ffmpeg build every CamStack node downloads, per platform and arch.
10745
10754
  *
@@ -11518,7 +11527,9 @@ var GROUP_TEMPLATE_IDS = [
11518
11527
  "leak",
11519
11528
  "smoke",
11520
11529
  "occupancy",
11521
- "binary"
11530
+ "binary",
11531
+ "switch",
11532
+ "light"
11522
11533
  ];
11523
11534
  var NUMERIC_AGGREGATES = [
11524
11535
  "mean",
@@ -11528,6 +11539,8 @@ var NUMERIC_AGGREGATES = [
11528
11539
  "sum"
11529
11540
  ];
11530
11541
  var BINARY_AGGREGATES = ["any", "all"];
11542
+ /** How an actuator group decides it is on. Unknown members never count as off. */
11543
+ var ACTIVE_CRITERIA = ["at-least-one", "all"];
11531
11544
  var AGGREGATE_REDUCERS = [
11532
11545
  "mean",
11533
11546
  "median",
@@ -11539,6 +11552,7 @@ var AGGREGATE_REDUCERS = [
11539
11552
  ];
11540
11553
  var GroupTemplateIdSchema = _enum(GROUP_TEMPLATE_IDS);
11541
11554
  var AggregateReducerSchema = _enum(AGGREGATE_REDUCERS);
11555
+ var ActiveCriterionSchema = _enum(ACTIVE_CRITERIA);
11542
11556
  /** One member. The field is stored so occupancy can name motion or binary. */
11543
11557
  var HelperMemberSchema = object({
11544
11558
  source: CompositionSourceRefSchema,
@@ -11549,7 +11563,9 @@ var HelperSpecSchema = discriminatedUnion("kind", [object({
11549
11563
  kind: literal("group"),
11550
11564
  templateId: GroupTemplateIdSchema,
11551
11565
  aggregate: AggregateReducerSchema,
11552
- members: array(HelperMemberSchema).min(1).max(64)
11566
+ members: array(HelperMemberSchema).min(1).max(64),
11567
+ /** Actuator groups only. Readings leave this unset. */
11568
+ active: ActiveCriterionSchema.optional()
11553
11569
  })]);
11554
11570
  /** A composed device's stableId is this prefix plus the block id. */
11555
11571
  var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
@@ -18036,6 +18052,7 @@ function numeric(input) {
18036
18052
  family: "numeric",
18037
18053
  deviceType: DeviceType.Sensor,
18038
18054
  memberDeviceType: DeviceType.Sensor,
18055
+ commandCaps: [],
18039
18056
  baseUnit: baseUnitOf(input.quantity),
18040
18057
  aggregates: NUMERIC_AGGREGATES,
18041
18058
  accept: [{
@@ -18050,6 +18067,7 @@ function binary(input) {
18050
18067
  family: "binary",
18051
18068
  deviceType: DeviceType.Sensor,
18052
18069
  memberDeviceType: DeviceType.Sensor,
18070
+ commandCaps: [],
18053
18071
  quantity: "none",
18054
18072
  baseUnit: void 0,
18055
18073
  aggregates: BINARY_AGGREGATES,
@@ -18244,9 +18262,47 @@ var GROUP_TEMPLATES = [
18244
18262
  fieldPath: "on"
18245
18263
  }],
18246
18264
  companions: [CHANGED]
18265
+ }),
18266
+ actuator({
18267
+ id: "switch",
18268
+ summary: "On when at least one switch is on, or when all of them are. Offline and unknown members are left out of that decision, never read as off, and still receive the command.",
18269
+ deviceType: DeviceType.Switch,
18270
+ outputCap: "switch",
18271
+ commandCaps: ["switch"]
18272
+ }),
18273
+ actuator({
18274
+ id: "light",
18275
+ summary: "On when at least one light is on, or when all of them are. Brightness and colour are offered only when every member has them. A command is not sent to a member that lacks it.",
18276
+ deviceType: DeviceType.Light,
18277
+ outputCap: "switch",
18278
+ commandCaps: [
18279
+ "switch",
18280
+ "brightness",
18281
+ "color"
18282
+ ]
18247
18283
  })
18248
18284
  ];
18285
+ function actuator(input) {
18286
+ return {
18287
+ ...input,
18288
+ family: "actuator",
18289
+ role: void 0,
18290
+ memberDeviceType: input.deviceType,
18291
+ outputField: "on",
18292
+ quantity: "none",
18293
+ baseUnit: void 0,
18294
+ aggregates: BINARY_AGGREGATES,
18295
+ defaultAggregate: "any",
18296
+ empty: "offline",
18297
+ accept: [{
18298
+ cap: "switch",
18299
+ fieldPath: "on"
18300
+ }],
18301
+ companions: [CHANGED]
18302
+ };
18303
+ }
18249
18304
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
18305
+ DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
18250
18306
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
18251
18307
  /**
18252
18308
  * What a composition may BUILD on a device type (G2, D676): the caps a new
@@ -44813,6 +44869,8 @@ var NcSystemEventKindSchema = _enum([
44813
44869
  "detection-blind",
44814
44870
  "motion-noisy",
44815
44871
  "motion-calm",
44872
+ "package-llm-silent",
44873
+ "package-llm-answered",
44816
44874
  "recording-stalled",
44817
44875
  "recording-healthy",
44818
44876
  "recording-degraded",
@@ -55827,6 +55885,28 @@ var PackageVersionInfoSchema = object({
55827
55885
  deprecated: string().optional(),
55828
55886
  distTags: array(string()).readonly()
55829
55887
  });
55888
+ /**
55889
+ * One published document. `ok` is markdown from the registry. `missing` means
55890
+ * the registry answered and the file was not there. `error` is a registry or
55891
+ * tarball failure — never an empty string standing in for either.
55892
+ */
55893
+ var PackageDocBodySchema = discriminatedUnion("status", [
55894
+ object({
55895
+ status: literal("ok"),
55896
+ markdown: string()
55897
+ }),
55898
+ object({ status: literal("missing") }),
55899
+ object({
55900
+ status: literal("error"),
55901
+ message: string()
55902
+ })
55903
+ ]);
55904
+ var PackageDocsSchema = object({
55905
+ name: string(),
55906
+ version: string(),
55907
+ readme: PackageDocBodySchema,
55908
+ changelog: PackageDocBodySchema
55909
+ });
55830
55910
  var SearchResultSchema = object({
55831
55911
  name: string(),
55832
55912
  version: string(),
@@ -56045,7 +56125,10 @@ method(object({ nodeId: string().optional() }).optional(), array(AddonListItemSc
56045
56125
  }), object({ success: literal(true) }), {
56046
56126
  kind: "mutation",
56047
56127
  auth: "admin"
56048
- }), method(object({ name: string() }), array(PackageVersionInfoSchema).readonly()), method(object({ addonId: string() }), RestartAddonResultSchema, {
56128
+ }), method(object({ name: string() }), array(PackageVersionInfoSchema).readonly()), method(object({
56129
+ name: string().min(1),
56130
+ version: string().min(1).optional()
56131
+ }), PackageDocsSchema, { auth: "admin" }), method(object({ addonId: string() }), RestartAddonResultSchema, {
56049
56132
  kind: "mutation",
56050
56133
  auth: "admin"
56051
56134
  }), method(object({ packageName: string() }), object({ success: literal(true) }), {
@@ -58067,6 +58150,18 @@ object({
58067
58150
  lastChangedAt: number()
58068
58151
  });
58069
58152
  DeviceType.Sensor;
58153
+ object({
58154
+ /** One row per member that has been commanded. A later command replaces that member's row. */
58155
+ results: array(object({
58156
+ deviceId: number().int().nonnegative(),
58157
+ cap: string().min(1),
58158
+ method: string().min(1),
58159
+ ok: boolean(),
58160
+ error: string().optional(),
58161
+ /** Ms epoch of the attempt. */
58162
+ at: number()
58163
+ })) });
58164
+ DeviceType.Switch, DeviceType.Light;
58070
58165
  object({
58071
58166
  /** Members whose current value entered the aggregate. */
58072
58167
  included: number().int().nonnegative().meta(readingMeta("count", {
@@ -58084,7 +58179,7 @@ object({
58084
58179
  label: "Members"
58085
58180
  }))
58086
58181
  });
58087
- DeviceType.Sensor;
58182
+ DeviceType.Sensor, DeviceType.Switch, DeviceType.Light;
58088
58183
  object({
58089
58184
  /** Radiator valve opening 0 (closed) .. 100 (open). Null = not yet known. */
58090
58185
  position: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
@@ -65256,6 +65351,13 @@ Object.freeze({
65256
65351
  access: "view",
65257
65352
  role: "admin"
65258
65353
  },
65354
+ "addons.getPackageDocs": {
65355
+ capName: "addons",
65356
+ capScope: "system",
65357
+ addonId: null,
65358
+ access: "view",
65359
+ role: "admin"
65360
+ },
65259
65361
  "addons.getVersions": {
65260
65362
  capName: "addons",
65261
65363
  capScope: "system",
@@ -68364,6 +68466,13 @@ Object.freeze({
68364
68466
  access: "view",
68365
68467
  role: "viewer"
68366
68468
  },
68469
+ "groupCommands.getStatus": {
68470
+ capName: "group-commands",
68471
+ capScope: "device",
68472
+ addonId: null,
68473
+ access: "view",
68474
+ role: "viewer"
68475
+ },
68367
68476
  "groupStatus.getStatus": {
68368
68477
  capName: "group-status",
68369
68478
  capScope: "device",
@@ -78193,6 +78302,10 @@ var SENSOR_CAP_VOCABULARY = {
78193
78302
  icon: "flame"
78194
78303
  }]
78195
78304
  },
78305
+ "group-commands": {
78306
+ scope: "device",
78307
+ noun: t("Group command", "Comando di gruppo")
78308
+ },
78196
78309
  "group-status": {
78197
78310
  scope: "device",
78198
78311
  noun: t("Group", "Gruppo"),
@@ -79685,6 +79798,11 @@ Object.freeze({
79685
79798
  form: "single",
79686
79799
  optional: false
79687
79800
  }],
79801
+ "groupCommands.getStatus": [{
79802
+ name: "deviceId",
79803
+ form: "single",
79804
+ optional: false
79805
+ }],
79688
79806
  "groupStatus.getStatus": [{
79689
79807
  name: "deviceId",
79690
79808
  form: "single",
@@ -81674,6 +81792,8 @@ new Map(Object.entries({
81674
81792
  "detection-blind": "device-events",
81675
81793
  "motion-noisy": "device-events",
81676
81794
  "motion-calm": "device-events",
81795
+ "package-llm-silent": "device-events",
81796
+ "package-llm-answered": "device-events",
81677
81797
  "recording-stalled": "device-events",
81678
81798
  "recording-healthy": "device-events",
81679
81799
  "recording-degraded": "device-events",
@@ -81757,6 +81877,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
81757
81877
  label: "Motion without a subject",
81758
81878
  kinds: ["motion-noisy", "motion-calm"]
81759
81879
  },
81880
+ {
81881
+ id: "package-llm",
81882
+ family: "device-events",
81883
+ label: "Package confirm",
81884
+ kinds: ["package-llm-silent", "package-llm-answered"]
81885
+ },
81760
81886
  {
81761
81887
  id: "recording",
81762
81888
  family: "device-events",
@@ -81938,6 +82064,8 @@ var DEVICE_EVENTS = [
81938
82064
  "detection-blind",
81939
82065
  "motion-noisy",
81940
82066
  "motion-calm",
82067
+ "package-llm-silent",
82068
+ "package-llm-answered",
81941
82069
  "recording-stalled",
81942
82070
  "recording-healthy",
81943
82071
  "recording-degraded",
@@ -82206,6 +82334,15 @@ new Map([
82206
82334
  snapshotLabel: "Cameras with constant motion now",
82207
82335
  snapshotSection: null
82208
82336
  },
82337
+ {
82338
+ id: "package-llm-confirm",
82339
+ family: "device-events",
82340
+ label: "Package confirm (not answering / answering again)",
82341
+ bad: ["package-llm-silent"],
82342
+ recovery: ["package-llm-answered"],
82343
+ snapshotLabel: "Cameras whose package confirm is not answering",
82344
+ snapshotSection: null
82345
+ },
82209
82346
  {
82210
82347
  id: "recording-health",
82211
82348
  family: "device-events",
@@ -82803,7 +82940,7 @@ var AdminUIAddon = class extends BaseAddon {
82803
82940
  capability: adminUiCapability,
82804
82941
  provider: {
82805
82942
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
82806
- getVersion: async () => ({ version: "1.2.474" })
82943
+ getVersion: async () => ({ version: "1.2.476" })
82807
82944
  }
82808
82945
  }];
82809
82946
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.474",
3
+ "version": "1.2.476",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -15,7 +15,9 @@
15
15
  },
16
16
  "files": [
17
17
  "dist",
18
- "assets"
18
+ "assets",
19
+ "README.md",
20
+ "CHANGELOG.md"
19
21
  ],
20
22
  "exports": {
21
23
  "./server/addon": {
@@ -1 +0,0 @@
1
- import{$ as e,J as t,x as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{n as r}from"./addon-icons-context-Bus8wGvh.js";e();var i={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function a({addonId:e,fallback:a,tileClassName:o,size:s=`md`}){let[c,l]=t(!1),u=r(e),d=i[s];return n(`div`,{className:`${d.tile} flex items-center justify-center shrink-0 ${o}`,children:c||!u?n(a,{className:d.fallback,"aria-hidden":!0}):n(`img`,{src:u,alt:``,className:`${d.img} bg-white ring-1 ring-black/5`,onError:()=>l(!0)})})}export{a as t};
@@ -1,4 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{It as d,Nt as f,Ot as p,Q as m,Rn as h,Si as g,Tn as _,Wr as v,ai as y,bn as b,dt as x,fn as S,kn as C,or as w,pi as ee,pn as te,tn as T,un as E,vi as ne,xi as re}from"./player-overlays-CvKnZb5M.js";import{Da as D}from"./client-BbPYrWg7.js";import{i as O,l as ie}from"./video-CJw8Jnle.js";import{Ai as k,Ci as A,Ei as ae,Fi as oe,Gr as j,Hr as M,Ni as se,Oi as ce,Ot as le,Pi as N,Qr as P,Si as F,Ti as I,Ur as ue,Zs as L,Zu as de,_i as R,_r as z,bi as B,en as fe,fd as pe,fi as V,fr as me,gi as he,gr as ge,hd as H,hi as _e,ji as U,ki as ve,mi as W,mr as ye,pr as be,tn as xe,vi as Se,vr as Ce,wi as we,yi as Te,yt as G}from"./src-DKc14e9G.js";import{t as K}from"./useTranslation-D3Is_4B6.js";import"./mount-B5MjkWnS.js";import{fr as q,lr as J,mr as Ee}from"./index-C8XwyZGE.js";import{t as Y}from"./AdminPage-B4QlIiKh.js";import{t as X}from"./NodeAddonsSettingsPanel-9_q0f4bE.js";import{n as Z,t as De}from"./useNodeUrlSelection-rnUQLTfb.js";function Oe(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}}e();var ke={queued:{icon:y,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:w,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:b,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:g,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:O,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Ae({item:e}){let{t}=K(),n=ke[e.status],r=n.icon;return a(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${n.bg}`,title:e.error,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey)]})}var je=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Q=new Set([`done`,`failed`,`skipped`]);function Me(e){return!Q.has(e.phase)&&!je.has(e.jobState)}function Ne(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=je.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 Pe(){let{data:e}=A({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=H(D.AddonsJobProgress,e=>e.job.jobId);return n(()=>{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 Ne([...n.values()],Date.now())},[e,t])}var Fe={queued:{icon:y,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:w,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:w,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:w,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:w,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:w,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:w,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:g,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:O,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ie({progress:e}){let{t}=K(),n=Fe[e.phase],r=n.icon,i=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return a(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${n.cls}`,title:i,children:[l(r,{className:`w-2.5 h-2.5 ${n.spin?`animate-spin`:``}`}),t(n.labelKey),a(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Le(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 Re(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ze(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(Re)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Be(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 Ve={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function He(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)}: ${Ve[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 Ue={},We=3e4,Ge=`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 Ke({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:i}){let{t:o}=K(),c=s(),u=ue(),f=M(),p=F(Ue,{staleTime:We}),m=p.data?.installations??[],h=(p.data?.unreachable??[]).map(e=>e.nodeId),g=Le(m,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),v=N({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await f({title:e.success?o(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:t}):o(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:t}),message:He(e,_),variant:e.success?`default`:`danger`})},b=async n=>{try{await y(await v.mutateAsync({packageName:e,...n}))}catch(e){await f({title:o(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:t}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==n.id);await u({title:o(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:t,name:n.name}),message:Be(t,n.name,e),confirmLabel:o(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(n.isHub?{}:{nodeId:n.id})},S=async()=>{let n=(await p.refetch()).data;if(n===void 0){await f({title:o(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:o(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Le(n.installations,e);await u({title:o(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:t}),message:ze(t,r,n.unreachable.map(e=>e.nodeId)),confirmLabel:o(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||i===!0;return a(`div`,{className:`flex items-center gap-1.5`,children:[r!==!0&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:n.name}),children:[l(d,{className:`h-3 w-3`}),v.isPending?o(`addons.addonUninstallControls.removing`,`Removing...`):o(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||r===!0||h.length>0)&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:Ge,title:o(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[l(ie,{className:`h-3 w-3`}),g.length>0?o(`addons.uninstallControls.everywhereCount`,{count:g.length}):o(`addons.uninstallControls.everywhere`)]})]})}function qe({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:s,selectedVersion:c}){let{t:u}=K(),d=n===`upload`||n===`local`,{data:f,isLoading:m}=Se({name:e});return a(`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:[a(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:u(`addons.versionPicker.versions`,`Versions`)}),l(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:l(x,{className:`h-3 w-3`})})]}),d&&a(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(p,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),a(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[l(`span`,{className:`font-semibold`,children:u(`addons.versionPicker.inPlace`,{kind:n===`upload`?u(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):u(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,l(J,{i18nKey:`addons.versionPicker.reinstall`,values:{version:t},components:{mono:l(`span`,{className:`font-mono`})}})]})]}),m&&a(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(w,{className:`h-3.5 w-3.5 animate-spin`}),u(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),f&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:f.map(e=>{let n=e.version===t,i=s!==void 0&&e.version===c,d=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=a(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:d?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:u(`common.current`)}),e.distTags.map(e=>l(`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)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:u(`common.deprecated`)}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?a(`button`,{type:`button`,"aria-label":u(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,i?l(g,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?u(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):u(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:l(v,{className:`h-3 w-3`})})]},e.version)})}),f&&f.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:u(`addons.versionPicker.noVersionsFound`,`No versions found`)})]})}e();var Je=`device-export`;function Ye(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Je)}function Xe(e){return e!==`local`&&e!==`upload`}function Ze({isBundle:e,installSource:t,addonId:n,iconPath:i,color:o}){let[s,c]=r(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=n&&i?m(`/api/addon-assets/${n}/${i}`):null,g=!!f&&!s;return a(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:g?l(`img`,{src:f,alt:n,className:`h-4 w-4`,onError:()=>c(!0)}):l(e?h:_,{className:`h-3.5 w-3.5`})}),t===`local`&&l(`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`}),Xe(t)&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`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:l(p,{className:`h-2.5 w-2.5 text-white`})})]})}function Qe({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){let{t:d}=K();if(r)return a(`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:[l(w,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(t){let r=n??t;return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,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:r}),children:[l(v,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"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:r}),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:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(re,{className:`h-3 w-3`})]}),u]})}return a(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,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`,i===`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,l(re,{className:`h-3 w-3 opacity-50`})]}),u]})}function $e({addonId:e}){let t=s(),{data:n=`inherit`}=_e({addonId:e}),r=k({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{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 et={id:`hub`,name:`Hub`,isHub:!0};function tt({addon:e,agents:n=[],clusterStatus:i,hideVersion:c,availableUpdate:u,onUpdate:d,isUpdating:f,jobProgress:p,bundle:m,bulkItem:g,disabledByBulk:_,isSystem:v,selectedNode:y}){let{t:S}=K(),[w,ee]=r(!1),[T,D]=r(!1),[ie,k]=r(!1),[A,oe]=r(null);t(()=>{oe(null)},[u]);let M=A??u,[se,N]=r(!1),[P,F]=r(!1),[I,ue]=r(`logs`),L=s(),de=q(),{manifest:R}=e,B=e.installedOn??[],pe=!m&&!R.protected&&R.removable!==!1,V=!!m,he=m?.displayName??R.name,H=m?.packageName??R.packageName,_e=m?.version??R.packageVersion??R.version,U=m?.installSource??e.installSource,ve=m?m.bundle?.description??m.addons[0]?.manifest.description:R.description,W=ae({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]})}}),Se=Te({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]}),L.invalidateQueries({queryKey:[[`addonPages`]]}),L.invalidateQueries({queryKey:[[`capabilities`]]}),L.invalidateQueries({queryKey:[[`integrations`]]})}}),we=ce({onSuccess:()=>{L.invalidateQueries({queryKey:[[`addons`]]}),L.invalidateQueries({queryKey:[[`alerts`]]})}}),G=e.health,J=G?.phase===`failed`&&!G.inGracePeriod,Ee=J&&G?.nextRetryAt&&!G.retrying,Y=Oe(e.process);return a(`div`,{className:`rounded-md border bg-surface overflow-hidden ${J?`border-red-500/50`:`border-border`}`,children:[J&&G&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(O,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:S(`addons.addonCard.failedToLoad`,{attempt:G.retryCount})}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.lastError?.message??S(`addons.addonCard.unknownError`,`Unknown error`)}),Ee&&G.nextRetryAt&&l(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:S(`addons.addonCard.autoRetryAt`,{time:new Date(G.nextRetryAt).toLocaleTimeString()})})]}),a(`button`,{type:`button`,disabled:we.isPending||G.retrying,onClick:e=>{e.stopPropagation(),we.mutate({packageName:H})},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:S(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[l(b,{className:`h-3 w-3 ${we.isPending||G.retrying?`animate-spin`:``}`}),S(`addons.addonCard.retryNow`,`Retry now`)]})]}),Y!==null&&a(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(O,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),a(`div`,{className:`flex-1 min-w-0`,children:[l(`div`,{className:`text-xs font-semibold text-danger`,children:S(`addons.addonCard.processProblem.${Y.kind}`)}),Y.reason!==void 0&&l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Y.reason})]})]}),a(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[l(Ze,{isBundle:V||!!R.components&&R.components.length>1,installSource:U,addonId:V?m.addons[0]?.manifest.id:R.id,iconPath:V?m.bundle?.icon??m.addons[0]?.manifest.icon:R.icon,color:V?m.addons[0]?.manifest.color:R.color}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:he}),!c&&l(Qe,{version:_e,availableUpdate:u,...M===void 0?{}:{selectedVersion:M},isUpdating:f,installSource:U,disabled:_,...d&&M!==void 0?{onUpdate:()=>d(M)}:{},onOpenPicker:()=>k(e=>!e),children:ie&&l(qe,{packageName:H,currentVersion:_e,...U?{installSource:U}:{},...u!==void 0&&M!==void 0?{selectedVersion:M,onSelect:e=>{oe(e),k(!1)}}:{},onInstall:e=>{k(!1),Se.mutate({packageName:H,version:e})},onClose:()=>k(!1)})})]}),a(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[H!==he&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:H}),V&&a(`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:[l(h,{className:`h-3 w-3`}),m.addons.length]}),v&&a(`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:S(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[l(b,{className:`h-3 w-3`}),S(`addons.addonCard.system`,`System`)]}),g!=null&&l(Ae,{item:g}),p!=null&&l(Ie,{progress:p})]}),ve&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ve}),!V&&e.process&&a(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`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`?S(`addons.addonCard.forked`):S(`addons.addonCard.inProcess`)}),e.process.pid!=null&&a(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`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`:Y===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!V&&a(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),W.mutate({addonId:R.id})},disabled:W.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:[l(b,{className:`h-3 w-3 ${W.isPending?`animate-spin`:``}`}),S(`addons.addonCard.restart`,`Restart`)]}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),N(e=>!e)},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:[l(te,{className:`h-3 w-3`}),S(`addons.addonCard.logs`,`Logs`)]}),!V&&a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),F(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${P?`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:[l(E,{className:`h-3 w-3`}),S(`addons.addonCard.settings`,`Settings`)]}),l(`div`,{className:`flex-1`}),pe&&l(Ke,{packageName:R.packageName,displayName:R.name,selectedNode:y??et,disabled:_})]}),i&&i.nodes.length>1&&!V&&a(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:S(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),l(`div`,{className:`space-y-1`,children:i.nodes.map(e=>a(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`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`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:S(`addons.addonCard.outdated`)}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:S(`common.offline`)}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:S(`common.synced`)})]},e.nodeId))})]}),se&&!V&&a(`div`,{className:`border-t border-border`,children:[a(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[a(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>ue(`logs`),className:`px-2 py-0.5 transition-colors ${I===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:S(`addons.addonCard.logs`,`Logs`)}),l(`button`,{type:`button`,onClick:()=>ue(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${I===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:S(`addons.addonCard.events`,`Events`)})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),N(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(x,{className:`h-3.5 w-3.5`})})]}),I===`logs`&&l(xe,{addonId:R.id,maxHeight:`max-h-64`,showFilters:!1}),I===`events`&&l(fe,{addonId:R.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&a(o,{children:[l(`button`,{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:l(w?ne:re,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),w&&l(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:m.addons.map(e=>l(tt,{addon:e,agents:n,hideVersion:!0},e.manifest.id))})]}),P&&!V&&l(me,{open:!0,onOpenChange:e=>!e&&F(!1),children:a(ye,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(z,{children:a(Ce,{className:`flex items-center gap-2`,children:[l(E,{className:`h-4 w-4 text-primary`}),S(`addons.addonCard.settingsTitle`,{name:he})]})}),a(be,{className:`space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:S(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),l(X,{nodeId:null,addonIds:[R.id],level:`global`,fieldScope:`cluster`,emptyMessage:S(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),Ye(R)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:S(`addons.addonCard.deviceExport`,`Device export`)}),l(le,{addonId:R.id,onOpenDevice:e=>de(`/devices/${e}`)})]}),Xe(U)&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:S(`addons.addonCard.autoUpdate`,`Auto-Update`)}),l($e,{addonId:R.id})]}),R.components&&R.components.length>0&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:S(`addons.addonCard.components`,{count:R.components.length})}),l(`div`,{className:`flex flex-wrap gap-1`,children:R.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),n.length>=2&&a(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:S(`addons.addonCard.installedOn`,`Installed on`)}),a(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[B.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:S(`addons.addonCard.hubLocal`,`Hub (local)`)}),B.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),a(`div`,{className:`relative`,children:[a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),D(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:S(`addons.addonCard.installOnMoreAgents`,`Install on more agents`),children:[l(C,{className:`h-3 w-3`}),S(`addons.addonCard.addAgent`,`Add agent`)]}),T&&a(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[n.filter(e=>!e.isHub&&!B.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),D(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),n.filter(e=>!e.isHub&&!B.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:S(`addons.addonCard.noAvailableAgents`,`No available agents`)})]})]})]})]})]}),l(ge,{children:l(j,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>F(!1),children:S(`common.close`,`Close`)})})]})})]})}e();var nt=`.tgz,.tar.gz,.zip`;function rt({onUploadSuccess:e}){let{t}=K(),[n,s]=r(!1),u=c(null),d=i(async t=>{s(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(m(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{s(!1)}},[e]);return a(o,{children:[l(`input`,{ref:u,type:`file`,accept:nt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),a(`button`,{type:`button`,onClick:()=>u.current?.click(),disabled:n,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:[n?l(w,{className:`w-3.5 h-3.5 animate-spin`}):l(p,{className:`w-3.5 h-3.5`}),n?t(`addons.addonUploadZone.uploading`,`Uploading...`):t(`addons.addonUploadZone.upload`,`Upload`)]})]})}var it=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function at(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||it.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 ot({selectedNode:e}){let{t}=K(),{data:n}=F(Ue,{staleTime:We});if(n===void 0)return null;let r=at(n.installations,e),i=n.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return r.length===0&&i.length===0?null:a(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[a(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[l(f,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?t(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):t(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),i.length>0&&l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:i.map(e=>e.nodeId).join(`, `)})}),r.map(t=>a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[a(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-xs font-mono text-foreground break-all`,children:t.packageName}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),l(Ke,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}function st({addon:e,installing:t,onInstall:n}){let{t:r}=K();return a(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`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()}),a(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),a(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?l(P,{variant:`success`,icon:l(g,{className:`h-3 w-3`}),children:e.installedVersion??r(`system.capabilityCatalog.installed`,`Installed`)}):a(j,{size:`sm`,onClick:()=>n(e.name),disabled:t,className:`shrink-0`,children:[t?l(w,{className:`h-3 w-3 animate-spin`}):l(v,{className:`h-3 w-3`}),r(`system.capabilityCatalog.install`,`Install`)]})]})}function ct({capability:e,installing:t,onInstall:n}){let{t:r}=K(),{data:i,isPending:o,isError:s}=ve({capability:e}),c;if(s)c=l(`div`,{className:`px-3 py-2 text-xs text-danger`,children:r(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(o||i===void 0)c=a(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[l(w,{className:`h-3 w-3 animate-spin`}),r(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let a=i.filter(e=>!e.installed);c=a.length===0?l(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:i.length===0?r(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):r(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):l(`div`,{className:`divide-y divide-border`,children:a.map(e=>l(st,{addon:e,installing:t,onInstall:n},e.name))})}return a(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":r(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[l(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:r(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),c]})}e();function lt(e){return e===`npm`||e===`dev`?e:null}var ut=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,dt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,ft=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],pt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function mt(e){return e!==void 0&&pt.has(e)}var ht={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function gt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function _t(e){return e===`local`?`dev`:`npm`}function vt(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 yt(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 bt({addons:e,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let{t:m}=K(),h=s(),[g,_]=r(``),y=u(g),[x,C]=r(!1),te=c(null);t(()=>{if(!x)return;let e=e=>{te.current&&!te.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:T}=we({nodeId:d.id}),E=n(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),ne=n(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[re,D]=r(()=>new Set),[O,ie]=r(()=>new Map),k=i(e=>{D(t=>new Set(t).add(e))},[]),A=i(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),ae=i((e,t)=>{ie(n=>new Map(n).set(e,t))},[]),j=i(e=>{ie(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=oe({onMutate:e=>{k(e.name),j(e.name)},onSuccess:(e,t)=>{A(t.name);let n=e;if(n&&n.success===!1){ae(t.name,n.error??`Update failed (no error message returned by server)`);return}h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{A(t.name),ae(t.name,e instanceof Error?e.message:String(e))}}),ce=Pe(),le=c(new Set);t(()=>{let e=new Set;for(let[t,n]of ce)Me(n)&&e.add(t);let t=[...le.current].some(t=>!e.has(t));le.current=e,t&&(h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[ce,h]);let{data:N}=he(void 0),P=V({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),F=U({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:I,isFetching:L}=ve({query:y||void 0},{enabled:x}),z=se(),{data:B}=R(void 0),fe=B?.requestedAt,[pe,me]=r(null),[ge,H]=r(!1);t(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==pe){me(B.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[fe,pe,B]),ue();let _e=i(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await z.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,z,M]),W=Te({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addonPages`]]}),h.invalidateQueries({queryKey:[[`capabilities`]]}),h.invalidateQueries({queryKey:[[`integrations`]]})}}),[ye,be]=r(`type`),[xe,Se]=r(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ce=e=>{Se(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[G,q]=Ee(),J=G.get(`capability`),Y=G.get(`updatable`)===`1`,X=G.get(`error`)===`1`,Z=lt(G.get(`source`)),De=i(e=>{let t=new URLSearchParams(G);e?t.set(`updatable`,`1`):t.delete(`updatable`),q(t,{replace:!0})},[G,q]),ke=i(e=>{let t=new URLSearchParams(G);e?t.set(`error`,`1`):t.delete(`error`),q(t,{replace:!0})},[G,q]),Ae=i(e=>{let t=new URLSearchParams(G);e===null?t.delete(`source`):t.set(`source`,e),q(t,{replace:!0})},[G,q]),je=n(()=>e.filter(e=>Oe(e.process)!==null).length,[e]),Q=n(()=>{let t=e.filter(e=>!mt(e.manifest.packageName));return d.isHub||(t=t.filter(e=>gt(e.placement,d.isHub))),J&&(t=t.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===J))),Y&&(t=t.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&E.has(t)})),Z!==null&&(t=t.filter(e=>_t(e.installSource)===Z)),X&&(t=t.filter(e=>Oe(e.process)!==null)),t},[e,d.isHub,J,Y,Z,X,E]),Ne=()=>{let e=new URLSearchParams(G);e.delete(`capability`),q(e,{replace:!0})},Fe=xe===`flat`?Q:yt(Q),Ie=n(()=>{let e=[...Fe];switch(ye){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},[Fe,ye]);return a(`div`,{className:`space-y-3`,children:[[...O.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:a(`div`,{className:`flex items-start justify-between gap-3`,children:[a(`div`,{className:`space-y-0.5`,children:[l(`div`,{className:`font-medium text-danger`,children:m(`systemPage.addons.updateFailed`,{name:e})}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>j(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:m(`common.dismiss`)})]})},e)),a(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.sort`,`Sort:`)}),a(`select`,{value:ye,onChange:e=>be(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:m(`admin.system.addons.bundlesFirst`,`Bundles first`)}),l(`option`,{value:`name`,children:m(`admin.system.addons.name`,`Name`)}),l(`option`,{value:`source`,children:m(`admin.system.addons.installSource`,`Install source`)})]})]}),a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.view`,`View:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>Ce(e),className:`px-2 py-1 transition-colors capitalize ${xe===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&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(b,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>P.mutate({channel:e}),disabled:P.isPending,className:`px-2 py-1 transition-colors capitalize ${N?.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&&a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.checkEvery`,`Check every:`)}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:N?.updateCheckIntervalSeconds??21600,disabled:F.isPending||N===void 0,onChange:e=>{N!==void 0&&F.mutate({channel:N.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:ft.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ne>0&&a(`button`,{type:`button`,onClick:()=>void _e(),disabled:z.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:[z.isPending?l(w,{className:`w-3 h-3 animate-spin`}):l(v,{className:`w-3 h-3`}),z.isPending?m(`admin.system.addons.updating`,`Updating…`):m(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ne})]}),a(`button`,{type:`button`,onClick:f,disabled:p||z.isPending,className:`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`,children:[l(b,{className:`w-3 h-3 ${p?`animate-spin`:``}`}),m(`common.refresh`,`Refresh`)]})]}),a(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":m(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:m(`admin.system.addons.updatable`,`Updatable`),pressed:Y,toggle:()=>De(!Y)},{id:`error`,label:m(`admin.system.addons.inError`,`In error ({{count}})`,{count:je}),pressed:X,toggle:()=>ke(!X)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Ae(Z===`npm`?null:`npm`)},{id:`dev`,label:m(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Ae(Z===`dev`?null:`dev`)}].map(e=>l(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?ut:dt,children:e.label},e.id))]}),a(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[a(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:te,children:[l(de,{type:`text`,value:g,onChange:e=>{_(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:z.isPending,leftSlot:l(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:L?l(w,{className:`h-3 w-3 animate-spin`}):void 0}),x&&I&&I.length>0&&a(`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:[I.length>0&&l(`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:I.length})}),I&&I.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:I.map(e=>l(st,{addon:e,installing:W.isPending,onInstall:e=>W.mutate({packageName:e})},e.name))})]})]}),l(rt,{onUploadSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),J&&a(`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:[l(`span`,{className:`text-foreground-subtle`,children:m(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),l(`span`,{className:`font-mono text-primary font-semibold`,children:J}),l(`button`,{type:`button`,onClick:Ne,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:m(`admin.system.addons.clear`,`Clear`)})]}),J&&l(ct,{capability:J,installing:W.isPending,onInstall:e=>W.mutate({packageName:e})}),J&&Q.length>0&&l(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:m(`admin.system.addons.installed`,`Installed`)}),ge&&a(`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 backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(ee,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),a(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:m(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:m(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),Q.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:e.length===0?m(`admin.system.addons.noAddonsInstalled`,`No addons installed`):J?m(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:J}):m(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),l(`div`,{className:`space-y-1.5`,children:Ie.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=E.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,a=ce.get(t)??null,s=a!==null&&Me(a);return l(tt,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:re.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:z.isPending,selectedNode:d},$(e)?t:e.manifest.id)})})]})}function xt(){let{t:e}=K(),n=s(),{data:r}=L(void 0),{nodes:i}=pe(),{selection:o,selectNode:u,requestedNodeId:d}=De(i.length>0?i:[ht]),f=o.node??ht,p=f.id,m=i.length>0?o.staleNodeId:null,{data:h,isLoading:g,isError:_}=B({nodeId:p}),v=W(),y=I(),x=v.isPending||y.isPending,S=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),n.invalidateQueries({queryKey:[[`addons`]]})},C=c(v);C.current=v;let w=c(d??`hub`);t(()=>{C.current.mutate({nodeId:w.current})},[]);let ee=(h??[]).map(vt).filter(e=>e!==null);return a(Y,{children:[a(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[l(G,{selectedNodeId:p,onSelect:u}),a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&l(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:ee.length})}),a(`button`,{type:`button`,onClick:()=>void S(),disabled:x,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:[l(b,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),l(Z,{staleNodeId:m,shownNodeName:f.name}),l(ot,{selectedNode:f}),g&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:e(`common.loading`,`Loading…`)}),_&&l(`div`,{className:`text-xs text-danger`,children:e(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),!g&&!_&&l(bt,{addons:ee,clusterStatus:r,selectedNode:f,onRefresh:()=>void S(),isRefreshing:x})]})}export{xt as AddonsPage};
@@ -1 +0,0 @@
1
- import{b as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{vt as n}from"./src-DKc14e9G.js";function r({icon:r,title:i,subtitle:a,actions:o,nav:s,embedded:c=!1,children:l}){return c?t(e,{children:l}):t(n,{icon:r,title:i,subtitle:a,actions:o,nav:s,children:l})}export{r as t};
@@ -1 +0,0 @@
1
- import{$ as e,L as t,x as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{gt as r}from"./src-DKc14e9G.js";import{mr as i}from"./index-C8XwyZGE.js";e();function a({paramName:e=`tab`,defaultSection:a,sections:o,...s}){let[c,l]=i(),u=a??o[0]?.id??``,d=c.get(e),f=o.some(e=>e.id===d)?d??u:u,p=t((t,n)=>{l(r=>{let i=new URLSearchParams(r);for(let e of n)i.delete(e);return i.set(e,t),i},{replace:!0})},[e,l]);return n(r,{...s,paramName:e,defaultSection:a,sections:o,activeSection:f,onSectionChange:p})}export{a as t};
@@ -1,3 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,a as o,b as s,q as c,t 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-CEHpkaJP.js";import{$r as d,D as f,Di as p,Fn as m,G as h,It as g,L as _,Mi as v,On as y,Or as b,Q as x,Wr as S,Xi as C,Xr as w,Yt as T,Zt as E,bn as D,dn as ee,dt as O,fn as k,ji as A,kn as j,or as M,ot as N}from"./player-overlays-CvKnZb5M.js";import{Ar as P,kr as F,wa as I}from"./client-BbPYrWg7.js";import{n as L,t as R}from"./send-CNzJmniJ.js";import{t as te}from"./message-square-plus-D64e2l9L.js";import{$n as z,Cn as B,Dr as V,Er as H,Gn as U,Gr as W,Ku as ne,Or as re,Qr as G,Qu as ie,St as K,Un as q,Ur as ae,Zu as J,ht as oe,kr as Y,pt as se,rt as ce,sr as le,uo as ue,wn as de,xn as X,xt as fe}from"./src-DKc14e9G.js";import{t as Z}from"./i18n-BO6gCPcC.js";import{t as Q}from"./useTranslation-D3Is_4B6.js";import"./mount-B5MjkWnS.js";import{mr as pe,x as me}from"./index-C8XwyZGE.js";import{t as he}from"./AdminSectionedPage-BIoU14zn.js";import{t as ge}from"./AdminPage-B4QlIiKh.js";e();var _e=`__redacted__`,ve=[`llm`,`listProfiles`],ye=[`llm`,`listProfileKinds`],be=[`llm`,`getDefaults`],xe=[`llm`,`listRuntimeNodes`],Se=[`llm`,`listModelCatalog`],Ce=[`llm`,`getUsage`],we=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],Te=new Map([[`cloud`,d],[`plug`,y],[`cpu`,w],[`server`,ee],[`sparkles`,E]]);function Ee(e){return Te.get(e)??v}function De(e){return typeof e==`string`&&e.length>0?e:void 0}function Oe(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function ke(e){return e===!0}function Ae(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var je={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Me(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:Z.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:Z.t(`ai.appleAvailable`),detail:Z.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=je[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:Z.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:Z.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Ne={ready:`success`,downloading:`info`,starting:`info`,stopped:`danger`,crashed:`danger`,failed:`danger`};function Pe(e){return e.reachable?e.status===void 0?`success`:Ne[e.status.state]:`danger`}function Fe(e){if(!e.reachable)return[];let t=[],n=e.apple;if(n?.state===`available`)t.push({id:`apple`,labelKey:`ai.featureApple`,tone:`success`,detail:Me(e).detail}),n.imageInput&&t.push({id:`apple-images`,labelKey:`ai.featureAppleImages`,tone:`success`,detail:null});else if(n?.state===`unavailable`){let n=Me(e);t.push({id:`apple`,labelKey:`ai.featureApple`,tone:n.tone,detail:n.labelDefault})}let r=e.status?.vramBytes;return r!==void 0&&r>0&&t.push({id:`gpu`,labelKey:`ai.featureGpu`,tone:`info`,detail:null}),t}function Ie(){return{temperature:[{type:`slider`,key:`temperature`,label:Z.t(`helpers.aiProfileForm.temperature`),min:0,max:2,step:.1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`,description:Z.t(`helpers.aiProfileForm.temperatureHint`)}],topP:[{type:`slider`,key:`topP`,label:Z.t(`helpers.aiProfileForm.topP`),min:0,max:1,step:.05,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`}],topK:[{type:`number`,key:`topK`,label:Z.t(`helpers.aiProfileForm.topK`),min:1}],maxTokens:[{type:`number`,key:`maxTokens`,label:Z.t(`helpers.aiProfileForm.maxTokens`),min:1}],contextLength:[{type:`number`,key:`contextLength`,label:Z.t(`helpers.aiProfileForm.contextLength`),min:512,unit:`tokens`,description:Z.t(`helpers.aiProfileForm.contextLengthHint`)}],systemPrompt:[{type:`textarea`,key:`systemPrompt`,label:Z.t(`helpers.aiProfileForm.systemPrompt`),rows:4,maxLength:4e3,span:2,description:Z.t(`helpers.aiProfileForm.systemPromptHint`)}],timeoutMs:[{type:`number`,key:`timeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutTotal`),min:1e3,default:P.totalMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutTotalHint`)}],connectTimeoutMs:[{type:`number`,key:`connectTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutConnect`),min:500,default:P.connectMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutConnectHint`)}],firstTokenTimeoutMs:[{type:`number`,key:`firstTokenTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutFirstToken`),min:1e3,default:P.firstTokenMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutFirstTokenHint`)}],idleTimeoutMs:[{type:`number`,key:`idleTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutIdle`),min:1e3,default:P.idleMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutIdleHint`)}],retry:[{type:`boolean`,key:`retryEnabled`,label:Z.t(`helpers.aiProfileForm.retry`),description:Z.t(`helpers.aiProfileForm.retryHint`)},{type:`number`,key:`retryMaxAttempts`,label:Z.t(`helpers.aiProfileForm.retryMaxAttempts`),min:1,max:5,default:1,showWhen:{field:`retryEnabled`,equals:!0}}],toolsEnabled:[{type:`boolean`,key:`toolsEnabled`,label:Z.t(`helpers.aiProfileForm.toolsEnabled`),description:Z.t(`helpers.aiProfileForm.toolsEnabledHint`)}]}}var Le=[`temperature`,`topP`,`topK`,`maxTokens`,`contextLength`,`systemPrompt`],Re=[`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`];function ze(e,t){let n=Ie();return t.filter(t=>e.includes(t)).flatMap(e=>n[e])}function Be(e){let t=ze(e,Le);return t.length===0?null:{sections:[{id:`generation`,title:Z.t(`helpers.aiProfileForm.generation`),fields:t}]}}function Ve(e){let t=ze(e,Re);return t.length===0?null:{sections:[{id:`bounds`,title:Z.t(`helpers.aiProfileForm.bounds`),fields:t}]}}function He(e){return e===null?{}:{temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled}}function Ue(e,t){return{...e.features,...t?.features}}function We(e,t){return t===null?e.modelCatalog===`static`?e.staticModels??[]:[]:t}function Ge(e,t,n){let r=e.profileFields,i=n.common,a=(e,t,n)=>r.includes(e)?Oe(i[e])??t:n??t,o=e=>r.includes(e)?Oe(i[e]):t?.[e],s=o(`temperature`),c=o(`topP`),l=o(`topK`),u=o(`maxTokens`),d=o(`contextLength`),f=r.includes(`systemPrompt`)?De(i.systemPrompt):t?.systemPrompt;return{id:t?.id??crypto.randomUUID(),name:n.name,kind:e.kind,addonId:e.addonId.length>0?e.addonId:`ai`,enabled:t?.enabled??!0,model:n.model,supportsVision:n.supportsVision,timeoutMs:a(`timeoutMs`,P.totalMs,t?.timeoutMs),connectTimeoutMs:a(`connectTimeoutMs`,P.connectMs,t?.connectTimeoutMs),firstTokenTimeoutMs:a(`firstTokenTimeoutMs`,P.firstTokenMs,t?.firstTokenTimeoutMs),idleTimeoutMs:a(`idleTimeoutMs`,P.idleMs,t?.idleTimeoutMs),retry:r.includes(`retry`)?{enabled:ke(i.retryEnabled),maxAttempts:Oe(i.retryMaxAttempts)??1}:t?.retry??{enabled:!1,maxAttempts:1},toolsEnabled:r.includes(`toolsEnabled`)?ke(i.toolsEnabled):t?.toolsEnabled??!1,...s===void 0?{}:{temperature:s},...c===void 0?{}:{topP:c},...l===void 0?{}:{topK:l},...u===void 0?{}:{maxTokens:u},...d===void 0?{}:{contextLength:d},...f===void 0?{}:{systemPrompt:f},providerConfig:n.providerConfig}}var Ke=2e3;function $(e){return Z.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function qe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Je({nodeId:e,value:t,onChange:i}){let{t:s}=Q(),c=N(),[d,f]=r(``),[p,m]=r(null),[h,g]=r(!1),_=o({queryKey:Se,queryFn:()=>c.trpcClient.llm.listModelCatalog.query({})}),v=o({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>c.trpcClient.llm.listNodeModels.query({nodeId:e})}),y=l({mutationFn:e=>c.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{m(e),g(!1),e.ok&&i({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),b=l({mutationFn:t=>c.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{g(!0),v.refetch()}}),x=o({queryKey:xe,enabled:b.isPending,refetchInterval:b.isPending?Ke:!1,queryFn:()=>c.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,C=n(()=>{let t=(_.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(v.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:s(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:$(t.sizeBytes),node:e})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:s(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[_.data,v.data,p,e,s]),w=e=>{if(e===``){i(null);return}if(e===`custom`){if(p?.ok!==!0)return;i({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=_.data?.find(e=>e.id===t);i({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=v.data?.find(e=>e.file===t);n?.path!==void 0&&i({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},T=e=>{d.trim()!==``&&y.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return a(`div`,{className:`space-y-3`,children:[u(K,{label:s(`ai.model`,`Model`),required:!0,children:u(ne,{id:`ai-model`,"aria-label":s(`ai.model`,`Model`),value:qe(t),options:C,onChange:e=>w(e.target.value)})}),u(K,{label:s(`ai.hfTitle`,`Add a model from Hugging Face`),description:s(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:a(`div`,{className:`flex gap-2`,children:[u(J,{"aria-label":s(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:s(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())}}),a(W,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||y.isPending,onClick:()=>T(),children:[y.isPending?u(M,{className:`h-3.5 w-3.5 animate-spin`}):u(k,{className:`h-3.5 w-3.5`}),s(`ai.hfCheck`,`Check`)]})]})}),y.isError&&u(H,{message:y.error instanceof Error?y.error.message:s(`common.error`,`Error`)}),p?.ok===!1&&u(H,{message:p.message,action:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>u(W,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),y.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&u(W,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>T(p.requiredBytes),children:s(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]})}),p?.ok===!0&&a(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[a(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[u(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),u(G,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),u(G,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&u(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),a(`div`,{className:`flex items-center gap-2`,children:[a(W,{size:`sm`,type:`button`,disabled:b.isPending||h,onClick:()=>b.mutate(p.model),children:[b.isPending?u(M,{className:`h-3.5 w-3.5 animate-spin`}):u(S,{className:`h-3.5 w-3.5`}),h?s(`ai.hfInstalled`,`Downloaded`):s(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),x!==void 0&&u(`span`,{className:`text-[10px] text-foreground-subtle`,children:x.phase===`verifying`?s(`ai.hfVerifying`,`verifying {{file}}…`,{file:x.file}):s(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:x.file,index:x.fileIndex,count:x.fileCount,done:$(x.downloadedBytes),total:x.totalBytes===void 0?``:` / ${$(x.totalBytes)}`})})]}),b.isError&&u(H,{message:b.error instanceof Error?b.error.message:s(`common.error`,`Error`)})]})]})}function Ye({value:e,onChange:t}){let{t:n}=Q(),r=N(),i=o({queryKey:xe,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})});return a(`div`,{children:[u(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),i.isPending&&a(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[u(M,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),i.isError&&u(`p`,{className:`text-[11px] text-danger`,children:i.error instanceof Error?i.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),i.isSuccess&&i.data.length===0&&u(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),i.isSuccess&&i.data.length>0&&u(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:i.data.map(r=>{let i=Me(r),o=i.nodeId===e;return a(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!i.selectable&&!o,onClick:()=>t(i.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block font-medium text-foreground`,children:i.nodeId}),i.detail!==null&&u(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:i.detail})]}),u(G,{variant:i.tone,children:n(i.labelKey,i.labelDefault)})]},i.nodeId)})}),u(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function Xe(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Ze({providerConfig:e,onProviderConfigChange:t}){return u(Ye,{value:Xe(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Qe({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let i=F.safeParse(e.model),a=i.success?{model:i.data,modelId:n.id,supportsVision:n.supportsVision}:null;return u(Je,{nodeId:Xe(e,`nodeId`)??`hub`,value:a,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var $e=new Map([[`ai/apple-node`,Ze],[`ai/managed-model`,Qe]]);function et(e){return $e.get(e)??null}e();function tt({kind:e,className:t}){return u(Ee(e.icon),{className:t,"aria-hidden":!0})}function nt({kinds:e,onPick:t,onCancel:r}){let{t:i}=Q(),a=n(()=>Ae(e),[e]),o=n(()=>new Map(e.map(e=>[`${e.addonId}:${e.kind}`,e])),[e]);return u(oe,{open:!0,onClose:r,title:i(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:u(fe,{emptyMessage:i(`ai.noKinds`,`No AI provider is installed.`),onPick:e=>{let n=o.get(e);n!==void 0&&t(n)},groups:a.map(e=>({id:e.addonId,label:e.addonId,tiles:e.kinds.map(t=>({key:`${e.addonId}:${t.kind}`,label:t.label,testId:`ai-kind-${t.kind}`,icon:u(tt,{kind:t,className:`h-5 w-5 text-foreground-subtle`})}))}))})})}function rt(e){return(e?.sections??[]).flatMap(e=>e.fields)}function it(...e){let t={};for(let n of e)for(let e of rt(n))`default`in e&&e.default!==void 0&&(t[e.key]=e.default);return t}function at(e){return e==null?!1:typeof e==`string`?e.trim().length>0:!0}function ot(e,t){return rt(e).filter(e=>`required`in e&&e.required===!0&&!at(t[e.key])).map(e=>`label`in e&&typeof e.label==`string`?e.label:e.key)}var st={auth:{key:`ai.listAuth`,fallback:`Credentials refused`},network:{key:`ai.listNetwork`,fallback:`Endpoint unreachable`},unsupported:{key:`ai.listUnsupported`,fallback:`No model list`},invalid:{key:`ai.listInvalid`,fallback:`Connection incomplete`}};function ct(e,t){if(t!==null)return{id:t.model,supportsVision:t.supportsVision};let n=e.modelCatalog===`static`&&e.staticModels?.length===1?e.staticModels?.[0]:void 0;return{id:n?.id??``,supportsVision:Ue(e,n).vision}}function lt({kind:e,existing:t,onSave:i,onCancel:o,onChangeKind:c,saving:d,error:p}){let{t:m}=Q(),h=N(),[g,v]=r(t?.name??e.label),[y,b]=r(()=>t===null?it(e.connectionSchema,e.advancedSchema):{...t.providerConfig}),[x,S]=r(()=>He(t)),[w,T]=r(()=>ct(e,t)),[E,ee]=r(!1),O=e.providerWidgets??[],k=O.filter(e=>e.placement===`connection`),A=O.find(e=>e.placement===`model`)??null,j=n(()=>[...I(e.connectionSchema)].some(e=>t?.providerConfig[e]===_e),[t,e.connectionSchema]),P=l({mutationFn:()=>h.trpcClient.llm.listModels.mutate({addonId:e.addonId,kind:e.kind,connection:y,...t===null?{}:{profileId:t.id}}),onSuccess:t=>{t.ok&&T(n=>{let r=t.models.find(e=>e.id===n.id);return r===void 0?n:{id:n.id,supportsVision:Ue(e,r).vision}})}}),F=We(e,P.data?.ok===!0?P.data.models:null),L=F.find(e=>e.id===w.id),R=Ue(e,L),te=Be(e.profileFields),B=Ve(e.profileFields),V=ot(e.connectionSchema,y),U=O.some(e=>(e.requires??[]).some(e=>!at(y[e]))),re=e.modelCatalog===`fetch`&&A===null,ie=rt(e.connectionSchema).length>0||k.length>0,ae=t=>{T({id:t,supportsVision:Ue(e,F.find(e=>e.id===t)).vision})},Y=d||g.trim()===``||w.id.trim()===``||V.length>0||U,se=()=>{i(Ge(e,t,{name:g.trim(),model:w.id.trim(),supportsVision:e.visionEditable?w.supportsVision:!1,common:x,providerConfig:y}))},ce=t===null?m(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):m(`ai.editProfile`,`Edit {{name}}`,{name:t.name}),ue=t=>{let n=et(t);return n===null?u(H,{variant:`warning`,message:m(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:t})}):u(n,{descriptor:e,providerConfig:y,onProviderConfigChange:b,model:w,onModelChange:T},t)};return u(oe,{open:!0,onClose:o,title:ce,error:p,width:`lg`,testId:`ai-profile-editor`,footer:a(s,{children:[V.length>0&&u(G,{variant:`warning`,children:m(`ai.missingRequired`,`required: {{fields}}`,{fields:V.join(`, `)})}),V.length===0&&U&&u(G,{variant:`warning`,children:m(`ai.completeProvider`,`complete the provider settings`)}),V.length===0&&!U&&w.id.trim()===``&&u(G,{variant:`warning`,children:m(`ai.pickModelFirst`,`pick a model`)}),a(W,{size:`sm`,type:`button`,disabled:Y,onClick:se,children:[d&&u(M,{className:`h-3.5 w-3.5 animate-spin`}),t===null?m(`ai.createProfile`,`Create profile`):m(`ai.saveChanges`,`Save changes`)]})]}),children:a(`div`,{className:_,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`ai-editor-provider`,children:[u(tt,{kind:e,className:`h-4 w-4 text-foreground-subtle`}),u(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),u(G,{variant:`neutral`,children:e.addonId}),c!==void 0&&a(W,{size:`sm`,variant:`ghost`,type:`button`,onClick:c,children:[u(C,{className:`h-3.5 w-3.5`}),m(`ai.changeKind`,`Change type`)]})]}),u(K,{label:m(`ai.name`,`Name`),required:!0,children:u(J,{id:`ai-profile-name`,"aria-label":m(`ai.name`,`Name`),value:g,onChange:e=>v(e.target.value),placeholder:e.label})}),ie&&u(X,{headingId:`ai-editor-connection`,title:m(`ai.sectionConnection`,`Connection`),actions:re?a(W,{size:`sm`,variant:`secondary`,type:`button`,disabled:P.isPending,onClick:()=>P.mutate(),"data-testid":`ai-verify-models`,children:[P.isPending?u(M,{className:`h-3.5 w-3.5 animate-spin`}):u(D,{className:`h-3.5 w-3.5`}),m(`ai.verifyModels`,`Verify & load models`)]}):void 0,children:a(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[rt(e.connectionSchema).length>0&&u(le,{bare:!0,schema:e.connectionSchema,values:y,onChange:b}),k.map(e=>ue(e.id)),j&&u(`p`,{className:`text-[10px] text-foreground-subtle`,children:m(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)}),P.data?.ok===!0&&u(G,{variant:`success`,"data-testid":`ai-models-found`,children:m(`ai.modelsFound`,`{{count}} models found`,{count:P.data.models.length})}),P.data?.ok===!1&&u(H,{title:m(st[P.data.code]?.key??`ai.listNetwork`,st[P.data.code]?.fallback??`Endpoint unreachable`),message:P.data.message}),P.isError&&u(H,{message:P.error instanceof Error?P.error.message:m(`common.error`,`Error`)})]})}),u(X,{headingId:`ai-editor-model`,title:m(`ai.sectionModel`,`Model`),children:a(`div`,{className:`${f} space-y-3`,children:[A===null?a(s,{children:[F.length>0&&u(ne,{id:`ai-model-pick`,"aria-label":m(`ai.selectModel`,`Select a model…`),value:L===void 0?``:L.id,options:[{value:``,label:m(`ai.selectModel`,`Select a model…`)},...F.map(e=>({value:e.id,label:e.label??e.id}))],onChange:e=>{e.target.value!==``&&ae(e.target.value)}}),u(K,{label:m(`ai.customModel`,`Model id`),description:m(`ai.customModelHint`,`Pick one from the list, or type any model id the provider accepts.`),required:!0,children:u(J,{id:`ai-model-id`,"aria-label":m(`ai.customModel`,`Model id`),value:w.id,onChange:e=>T({...w,id:e.target.value}),placeholder:F[0]?.id??`model-id`})})]}):ue(A.id),a(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`ai-model-features`,children:[(w.supportsVision||!e.visionEditable&&R.vision)&&u(G,{variant:`info`,children:m(`ai.featureVision`,`vision`)}),R.tools&&u(G,{variant:`neutral`,children:m(`ai.featureTools`,`tools`)}),R.streaming&&u(G,{variant:`neutral`,children:m(`ai.featureStreaming`,`streaming`)})]}),e.visionEditable&&u(K,{orientation:`horizontal`,label:m(`ai.supportsVision`,`Supports vision`),description:m(`ai.supportsVisionHint`,`A vision call against a text-only profile is refused, never downgraded.`),children:u(q,{checked:w.supportsVision,onCheckedChange:e=>T({...w,supportsVision:e}),"aria-label":m(`ai.supportsVision`,`Supports vision`)})})]})}),te!==null&&u(X,{headingId:`ai-editor-generation`,title:m(`ai.sectionGeneration`,`Generation`),children:u(`div`,{className:`p-2 sm:p-3 lg:p-4`,children:u(le,{bare:!0,schema:te,values:x,onChange:S})})}),(B!==null||e.advancedSchema!==void 0)&&u(z,{expanded:E,onExpandedChange:ee,header:u(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:m(`ai.sectionAdvanced`,`Advanced`)}),children:a(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[B!==null&&u(le,{bare:!0,schema:B,values:x,onChange:S}),e.advancedSchema!==void 0&&u(le,{bare:!0,schema:e.advancedSchema,values:y,onChange:b})]})})]})})}e();function ut(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return a(`span`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?u(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):u(tt,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),a(`span`,{className:`min-w-0`,children:[u(`span`,{className:`block truncate font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&u(`span`,{className:`block truncate ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>u(`span`,{className:`text-foreground-muted`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?u(G,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):u(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>typeof e.providerConfig.nodeId==`string`?u(G,{variant:`default`,children:e.providerConfig.nodeId}):u(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>u(q,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":Z.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:t.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>a(`span`,{className:`flex items-center justify-end gap-1`,children:[u(W,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),"aria-label":e.t(`ai.test`,`Test`),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?u(M,{className:`h-3.5 w-3.5 animate-spin`}):u(R,{className:`h-3.5 w-3.5`})}),u(W,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),"aria-label":e.t(`common.edit`,`Edit`),title:e.t(`common.edit`,`Edit`),children:u(m,{className:`h-3.5 w-3.5`})}),u(W,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),"aria-label":e.t(`common.delete`,`Delete`),title:e.t(`common.delete`,`Delete`),children:u(g,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function dt(){let{t:e}=Q(),s=N(),{state:c,openEdit:d,close:p}=se(),m=ae(),[h,g]=r(null),[v,y]=r(null),[b,x]=r(null),S=o({queryKey:ve,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),C=o({queryKey:ye,queryFn:async()=>(await s.trpcClient.llm.listProfileKinds.query({})).map(({connectionSchema:e,advancedSchema:t,...n})=>({...n,connectionSchema:e,...t===void 0?{}:{advancedSchema:t}}))}),w=()=>{S.refetch()},T=i(()=>{g(null),x(null),p()},[p]);t(()=>{c.mode===`closed`&&g(null)},[c.mode]);let D=l({mutationFn:e=>s.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{T(),w()},onError:t=>x(t instanceof Error?t.message:e(`ai.saveFailed`,`Save failed`))}),ee=l({mutationFn:e=>s.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),O=l({mutationFn:e=>s.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>y({id:t.id,ok:e.ok,text:e.ok?Z.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),k=S.data??[],A=n(()=>C.data??[],[C.data]),j=n(()=>{let e=new Map;for(let t of A)e.set(t.kind,t);return e},[A]),M=c.mode===`edit`?k.find(e=>e.id===c.id)??null:null,P=M===null?null:j.get(M.kind)??null,F=c.mode===`new`&&h===null,I=c.mode===`new`?h:P,L=c.mode===`edit`?M:null,R=I!==null&&(c.mode===`new`||L!==null),te=async t=>{await m({title:e(`ai.deleteProfileTitle`,`Delete profile?`),message:e(`ai.deleteProfileMessage`,`Delete "{{name}}". Features that name it will no longer get an answer from it.`,{name:t.name}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&ee.mutate(t)};return a(`div`,{className:_,children:[u(ft,{profiles:k}),u(X,{headingId:`ai-profiles-list`,title:e(`ai.profilesList`,`Profiles`),children:S.isPending?a(`div`,{className:`${f} space-y-2`,"data-testid":`ai-profiles-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):S.isError?u(`div`,{className:f,children:u(H,{title:e(`ai.loadFailed`,`Failed to load profiles`),message:S.error instanceof Error?S.error.message:e(`common.error`,`Error`),onRetry:()=>void S.refetch()})}):k.length===0?u(V,{icon:E,title:e(`ai.noProfilesTitle`,`No AI profiles yet`),description:e(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}):u(B,{columns:ut({kindByName:j,testResult:v,testingId:O.isPending?O.variables?.id??null:null,t:e,onToggle:e=>D.mutate({...e,enabled:!e.enabled}),onTest:e=>O.mutate(e),onEdit:e=>{j.has(e.kind)&&(x(null),g(null),d(e.id))},onDelete:e=>void te(e)}),rows:k,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:de})}),F&&u(nt,{kinds:A,onCancel:T,onPick:e=>{x(null),g(e)}}),R&&I!==null&&u(lt,{kind:I,existing:L,saving:D.isPending,error:b,onSave:e=>D.mutate(e),onCancel:T,...c.mode===`new`?{onChangeKind:()=>{x(null),g(null)}}:{}})]})}function ft({profiles:e}){let{t}=Q(),n=N(),r=o({queryKey:be,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),i=l({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{r.refetch()}}),s=e=>(r.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,c=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return u(X,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:u(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:we.map(({purpose:n,visionOnly:r})=>{let o=r?e.filter(e=>e.supportsVision):e,l=s(n),d=e.find(e=>e.id===l);return a(`div`,{children:[u(U,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:c(n)}),u(ne,{id:`llm-default-${n}`,"aria-label":c(n),value:l,onChange:e=>i.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...l!==``&&!o.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...o.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&u(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&u(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),i.error!=null&&u(`p`,{className:`mt-1 text-xs text-danger`,children:String(i.error)})]},n)})})})}e();var pt=5e3;function mt(e){return Z.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function ht(){let{t:e}=Q(),t=N(),r=o({queryKey:xe,refetchInterval:pt,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),i=n(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>u(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>a(`span`,{className:`flex items-center gap-1.5`,children:[u(G,{variant:Pe(t),children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&u(G,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>u(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:mt(e.disk.modelsBytes)})},{key:`features`,header:e(`ai.colFeatures`,`Features`),render:t=>{let n=Fe(t);if(n.length===0)return u(`span`,{className:`text-foreground-subtle`,children:`—`});let r=n.flatMap(e=>e.detail===null?[]:[e.detail]);return a(`span`,{className:`flex flex-col items-start gap-0.5`,children:[u(`span`,{className:`flex flex-wrap gap-1`,children:n.map(t=>u(G,{variant:t.tone,children:e(t.labelKey)},t.id))}),r.length>0&&u(`span`,{className:`text-foreground-subtle`,children:r.join(` · `)})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?u(`span`,{className:`text-foreground-subtle`,children:`—`}):u(`span`,{className:`text-danger`,children:e.error})}],[e]),s=r.data??[];return u(X,{headingId:`ai-runtimes-list`,title:e(`ai.runtimesList`,`Nodes`),children:r.isPending?a(`div`,{className:`${f} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):r.isError?u(`div`,{className:f,children:u(H,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:r.error instanceof Error?r.error.message:e(`common.error`,`Error`),onRetry:()=>void r.refetch()})}):s.length===0?u(V,{icon:ee,title:e(`ai.noRuntimesTitle`,`No runtime nodes`),description:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):u(B,{columns:i,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:de})})}var gt=x(`/addon/ai/test-chat`),_t=x(`/addon/ai/test-chat/chats`),vt=6e5;function yt(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),vt)}function bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xt(e){if(!bt(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var St=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ct(e){let t;try{t=JSON.parse(e)}catch{return null}if(!bt(t))return null;switch(t.kind){case`status`:{let e=St.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:xt(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:Z.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*wt(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Ct(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Ct(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Tt(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Et(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Dt(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function Ot(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function kt(e,t){switch(e){case`resolving-image`:return Z.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return Z.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?Z.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):Z.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return Z.t(`helpers.aiTestChat.phaseAnswering`)}}e();var At=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],jt=360*60*1e3,Mt=40,Nt=160,Pt={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Ft(){let{t:e}=Q(),s=N(),[l,d]=r(``),[m,h]=r(``),[v,y]=r(``),[b,x]=r([]),[S,C]=r(null),[w,E]=r(`none`),[D,ee]=r(`throwaway`),[k,j]=r(null),[M,P]=r([]),[F,I]=r(null),[L,z]=r(null),B=c(null);t(()=>()=>B.current?.abort(),[]);let V=i(async()=>{let e=await fetch(_t,{credentials:`same-origin`});e.ok&&P((await e.json()).chats??[])},[]);t(()=>{D===`persistent`&&V()},[D,V]);let re=o({queryKey:ve,queryFn:()=>s.trpcClient.llm.listProfiles.query({})}),G=n(()=>(re.data??[]).filter(e=>e.enabled),[re.data]),K=G.find(e=>e.id===l)??null,q=L!==null,ae=i(async(t,n)=>{let r=new AbortController;B.current=r,I(null);let i=yt(K??{});z({...Pt,firstTokenTimeoutMs:i??0});let a=``,o=null,s,c=null,u=null,d;try{let e=await fetch(gt,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:l,messages:t,...m.trim()===``?{}:{system:m.trim()},...n===void 0?{}:{attachment:n},...i===void 0?{}:{firstTokenTimeoutMs:i},...D===`persistent`?{persist:!0,...k===null?{}:{conversationId:k}}:{}})});if(!e.ok||e.body===null){let t=await e.text().catch(()=>``);throw Error(t.length>0?t:`HTTP ${String(e.status)}`)}for await(let t of wt(e.body))switch(t.kind){case`status`:z(e=>({...e??Pt,phase:t.phase}));break;case`meta`:o=t.mediaSent,s=t.model,z(e=>({...e??Pt,firstTokenTimeoutMs:t.firstTokenTimeoutMs,mediaSent:t.mediaSent}));break;case`token`:a+=t.text,z(e=>({...e??Pt,text:a}));break;case`done`:u={outputTokens:t.outputTokens,latencyMs:t.latencyMs},d=t.conversationId;break;case`error`:c=`${t.code}: ${t.message}`;break}}catch(t){r.signal.aborted||I(t instanceof Error?t.message:e(`common.error`,`Error`))}finally{B.current=null,z(null)}d!==void 0&&(j(d),V());let f=r.signal.aborted&&a.length>0;c===null&&a.length===0&&!f||x(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:c??a,...c===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&c===null?{model:s}:{},...u===null?{}:u}])},[D,k,K,l,V,m,e]),oe=i(()=>{let e=v.trim();if(e===``||l===``||q)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...S===null?{}:{attachmentLabel:S.label,attachmentKind:S.ref.kind}},n=[...b,t];x(n),y(``);let r=S?.ref;C(null),E(`none`),ae(D===`persistent`&&k!==null?[{role:`user`,content:e}]:Tt(n),r)},[D,k,v,S,l,ae,q,b]),Y=()=>B.current?.abort(),se=()=>{B.current?.abort(),x([]),C(null),y(``),I(null),z(null),j(null)},le=async e=>{B.current?.abort();let t=await fetch(`${_t}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();j(e),x(Dt(n)),z(null),I(null)};return a(`div`,{className:_,children:[u(X,{headingId:`ai-test-setup`,title:e(`ai.testSetup`,`Setup`),children:a(`div`,{className:`${f} space-y-3`,children:[a(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[a(`div`,{children:[u(U,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:e(`ai.profile`,`Profile`)}),u(ne,{id:`ai-test-profile`,value:l,onChange:e=>d(e.target.value),options:[{value:``,label:e(`ai.selectProfile`,`Select a profile…`)},...G.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),G.length===0&&!re.isLoading&&u(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:e(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),a(`div`,{children:[u(U,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:e(`ai.systemPrompt`,`System prompt (optional)`)}),u(J,{id:`ai-test-system`,value:m,onChange:e=>h(e.target.value),placeholder:e(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),u(ce,{label:e(`ai.chatMode`,`Conversation mode`),value:D,options:[{value:`throwaway`,label:e(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:e(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{ee(e),e===`throwaway`&&j(null)}}),D===`persistent`&&a(`div`,{className:`space-y-2`,children:[u(`p`,{className:`text-xs text-foreground-subtle`,children:e(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),a(W,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[u(te,{className:`h-3.5 w-3.5`}),e(`ai.newChat`,`New chat`)]}),M.length>0&&u(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:M.map(e=>u(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===k?`bg-primary/10`:``}`,children:u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),u(`p`,{className:`text-xs text-foreground-subtle`,children:e(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),K!==null&&!K.supportsVision&&u(`p`,{className:`text-xs text-warning`,children:e(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),F!==null&&u(H,{title:e(`ai.chatFailed`,`The test call failed`),message:F}),a(X,{headingId:`ai-test-conversation`,title:e(`ai.testConversation`,`Conversation`),actions:a(W,{size:`sm`,variant:`ghost`,type:`button`,disabled:b.length===0&&S===null,onClick:se,children:[u(g,{className:`h-3.5 w-3.5`}),e(`ai.clearChat`,`Clear`)]}),children:[u(It,{turns:b,live:L}),a(`div`,{className:`${f} space-y-2 border-t border-border`,children:[S!==null&&a(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[S.ref.kind===`snapshot`?u(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}):u(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:S.label}),u(ie,{size:`sm`,variant:`ghost`,type:`button`,icon:O,"aria-label":e(`ai.removeAttachment`,`Remove attachment`),onClick:()=>C(null)})]}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(W,{size:`sm`,variant:w===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>E(w===`snapshot`?`none`:`snapshot`),children:[u(p,{className:`h-3.5 w-3.5`}),e(`ai.attachSnapshot`,`Camera snapshot`)]}),a(W,{size:`sm`,variant:w===`track`?`primary`:`outline`,type:`button`,onClick:()=>E(w===`track`?`none`:`track`),children:[u(A,{className:`h-3.5 w-3.5`}),e(`ai.attachTrack`,`Recent track`)]})]}),w===`snapshot`&&u(zt,{onPick:t=>{C({ref:{kind:`snapshot`,deviceId:t.id},label:e(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t.name})}),E(`none`)}}),w===`track`&&u(Vt,{onPick:(t,n)=>{C({ref:{kind:`track`,trackId:t.trackId,deviceId:t.deviceId},label:e(`ai.trackOf`,`{{class}} on {{name}}`,{class:t.label??t.className,name:n})}),E(`none`)}}),a(`div`,{className:`flex items-center gap-2`,children:[u(J,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),oe())},placeholder:e(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":e(`ai.message`,`Message`)}),q?a(W,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[u(T,{className:`h-3.5 w-3.5`}),e(`ai.stop`,`Stop`)]}):a(W,{size:`sm`,type:`button`,disabled:v.trim()===``||l===``,onClick:oe,children:[u(R,{className:`h-3.5 w-3.5`}),e(`ai.send`,`Send`)]})]})]})]})]})}function It({turns:e,live:t}){let{t:n}=Q();return e.length===0&&t===null?u(V,{icon:L,title:n(`ai.chatEmptyTitle`,`No messages yet`),description:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):a(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${f}`,children:[e.map(e=>u(Lt,{turn:e},e.id)),t!==null&&a(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&u(Rt,{attachment:t.mediaSent}),t.text.length>0&&u(Lt,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[u(M,{className:`h-3.5 w-3.5 animate-spin`}),kt(t.phase,t.firstTokenTimeoutMs)]})]})]})}function Lt({turn:e,streaming:t=!1}){let{t:n}=Q(),r=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return u(`div`,{className:`flex ${r?`justify-end`:`justify-start`}`,children:a(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${r?`border-primary/40 bg-primary/10`:i}`,children:[a(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&u(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&u(Rt,{attachment:e.attachment}),e.attachmentLabel!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?u(A,{className:`h-3 w-3`}):u(p,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&a(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?u(p,{className:`h-3 w-3`}):u(A,{className:`h-3 w-3`}),Ot(e.attachment)]}),e.model!==void 0&&u(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:e.model,value2:String(e.outputTokens??0),value3:String(e.latencyMs??0)})})]})})}function Rt({attachment:e}){let{t}=Q(),n=Et(e);return n===null?null:u(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function zt({onPick:e}){let{t}=Q(),n=ue({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?u(M,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):u(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>u(Bt,{device:t,onPick:e},t.id))})}function Bt({device:e,onPick:t}){let{t:n}=Q(),{src:r}=h(e.id,{width:Nt});return a(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[u(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:r!==null&&u(`img`,{src:r,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),a(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&u(G,{variant:`warning`,children:n(`common.off`)}),u(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function Vt({onPick:e}){let{t}=Q(),r=N(),i=ue({isCamera:!0,projection:`slim`}),s=n(()=>(i.data??[]).map(e=>e.id),[i.data]),c=n(()=>{let e=new Map;for(let t of i.data??[])e.set(t.id,t.name);return e},[i.data]),l=o({queryKey:[...At,s.length],enabled:s.length>0,queryFn:()=>r.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-jt,limit:Mt,projection:`slim`})});if(i.isLoading||l.isLoading)return u(M,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=l.data?.tracks??[];return d.length===0?u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):u(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>a(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[u(A,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),u(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),u(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}e();var Ht=1440*60*1e3,Ut=[1,7,30,90];function Wt(){let{t:e}=Q(),t=N(),[i,s]=r(7),c=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(i-1)*Ht},[i]),l=o({queryKey:ve,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=o({queryKey:[...Ce,i],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),p=n(()=>{let e=new Map;for(let t of l.data??[])e.set(t.id,t.name);return e},[l.data]),m=n(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>u(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>u(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>u(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,e]),h=d.data??[],g=u(`div`,{className:`w-36`,children:u(ne,{"aria-label":e(`ai.window`,`Window`),value:String(i),options:Ut.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>s(Number(e.target.value))})});return u(X,{headingId:`ai-usage-list`,title:e(`ai.usageList`,`Rollup`),actions:g,children:d.isPending?a(`div`,{className:`${f} space-y-2`,"data-testid":`ai-usage-loading`,children:[u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`}),u(Y,{className:`h-8 w-full`})]}):d.isError?u(`div`,{className:f,children:u(H,{title:e(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:e(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?u(V,{icon:b,title:e(`ai.noUsage`,`No AI calls in this window.`)}):u(B,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:de})})}var Gt=`llm`,Kt=[`profiles`,`runtimes`,`usage`,`test`],qt=[`new`,`edit`];function Jt(e){return Kt.some(t=>t===e)}function Yt(){let{t:e}=Q(),t=re(Gt),[n]=pe(),{openNew:r}=se(),i=me(`/system/ai`,{t:e,isAdmin:!0})??{icon:E,title:e(`system.ai`,`AI`)};if(t!==`present`)return u(ge,{icon:i.icon,title:i.title,children:u(Xt,{presence:t})});let o=n.get(`tab`),s=Jt(o)?o:`profiles`,c={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:e(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)},l=s===`profiles`?a(W,{size:`sm`,type:`button`,"data-testid":`ai-add-profile`,onClick:r,children:[u(j,{className:`h-3.5 w-3.5`}),e(`ai.addProfile`,`Add profile`)]}):void 0;return u(he,{icon:i.icon,title:i.title,subtitle:c[s],actions:l,defaultSection:`profiles`,sectionsLabel:`${i.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:u(dt,{}),ownedParams:qt},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:u(ht,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:u(Wt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:u(Ft,{})}]})}function Xt({presence:e}){let{t}=Q();return e===`pending`?a(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[u(Y,{className:`h-8 w-64`}),u(Y,{className:`h-40 w-full`})]}):e===`unknown`?u(H,{title:t(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:t(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):u(V,{icon:E,title:t(`ai.absentTitle`,`AI is not installed`),description:t(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{Yt as AiProfilesPage,Yt as default};
@@ -1 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,S as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{or as o}from"./player-overlays-CvKnZb5M.js";import{_a as s}from"./client-BbPYrWg7.js";import{Gr as c,lr as l,ma as u,sa as d}from"./src-DKc14e9G.js";import{t as f}from"./useTranslation-D3Is_4B6.js";import{P as p,lr as m}from"./index-C8XwyZGE.js";e();function h(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}function g(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||l(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function _({kind:e,addonId:l,brokerId:_,initialValues:v,onSubmit:y,onCancel:b,submitLabel:x,disabled:S}){let{t:C}=f(),[w,T]=r(v??{}),[E,D]=r(null),O=d({kind:e,...l===void 0?{}:{addonId:l}}),k=n(()=>{let e=O.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return s(_===void 0?t:h(t,_),w)}},[O.data,_,w]);t(()=>{v!==void 0&&T(v)},[v]);let A=u(),j=async()=>{D(null);let t=g(k,w);try{let n=await A.mutateAsync({kind:e,settings:t,...l===void 0?{}:{addonId:l}});D(n.ok?{ok:!0}:{ok:!1,error:n.error})}catch(e){D({ok:!1,error:e instanceof Error?e.message:String(e)})}};return i(`div`,{className:`space-y-3`,children:[O.isLoading&&i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(o,{className:`h-3.5 w-3.5 animate-spin`}),` `,C(`brokers.brokerForm.loadingSchema`)]}),k&&a(p,{schema:k,values:w,onChange:T}),O.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[C(`brokers.brokerForm.failedToLoadSettingsSchema`,`Failed to load settings schema:`),` `,O.error instanceof Error?O.error.message:C(`brokers.brokerForm.unknownError`,`Unknown error`)]}),!k&&!O.isLoading&&!O.isError&&a(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:a(m,{i18nKey:`brokers.brokerForm.noSchema`,values:{kind:e},components:{code:a(`code`,{className:`font-mono`})}})}),E&&a(`div`,{className:`rounded border px-3 py-2 text-[11px] ${E.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:E.ok?C(`brokers.brokerForm.connectionOk`,`Connection OK.`):C(`brokers.brokerForm.testFailed`,`Test failed: {{value1}}`,{value1:E.error??`unknown error`})}),i(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[a(c,{variant:`outline`,size:`sm`,onClick:b,children:C(`common.cancel`,`Cancel`)}),i(`div`,{className:`flex items-center gap-2`,children:[a(c,{variant:`outline`,size:`sm`,onClick:()=>{j()},disabled:A.isPending||!k,children:A.isPending?C(`brokers.brokerForm.testing`,`Testing…`):C(`brokers.brokerForm.testConnection`,`Test connection`)}),a(c,{variant:`primary`,size:`sm`,onClick:()=>{let{_calendarCatalog:e,...t}=g(k,w);y(t)},disabled:!k||S,children:x??C(`common.save`,`Save`)})]})]})]})}export{_ as t};