@camstack/addon-admin-ui 1.2.701 → 1.2.702

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 (105) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/assets/{AccessSection-CmGUVN2c.js → AccessSection-CNgvvC6Q.js} +1 -1
  3. package/dist/assets/Addons-Dtx3xcZ2.js +5 -0
  4. package/dist/assets/{AdminPage-Dvziohv2.js → AdminPage-BkxgjFWW.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-3F0XiS4h.js → AdminSectionedPage-bGVBepbw.js} +1 -1
  6. package/dist/assets/AiProfiles-BLj-ic5N.js +3 -0
  7. package/dist/assets/Archive-y1aPYCx8.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-D5_YCsD2.js → BootstrapSettingsForm-jBRoUiPn.js} +1 -1
  9. package/dist/assets/{Build-DgzW58SZ.js → Build-BoiB-nPA.js} +4 -4
  10. package/dist/assets/{Calendars-BzFF94EV.js → Calendars-BBTnm6OG.js} +1 -1
  11. package/dist/assets/Cluster-DN0Cwciw.js +1 -0
  12. package/dist/assets/{CompositionBlockEditor-BUQTd-UR.js → CompositionBlockEditor-BloGManS.js} +2 -2
  13. package/dist/assets/{CompositionEditorPage-BTvOMFXc.js → CompositionEditorPage-C5pNxu2M.js} +1 -1
  14. package/dist/assets/Data-LT-PQ05n.js +2 -0
  15. package/dist/assets/{DeviceDetail-C09lWDie.js → DeviceDetail-DAvmtNN2.js} +1 -1
  16. package/dist/assets/{Devices-DsS5GkXt.js → Devices-BJRvDHiT.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-BkW36-q-.js → EmbedDevicePage-CyKS-rmB.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-BD43fNk-.js → EmbedPlayerPage-BsxSpEcY.js} +1 -1
  19. package/dist/assets/History-BPF9alct.js +1 -0
  20. package/dist/assets/{Identity-DXfvzQIG.js → Identity-dLFVHYZR.js} +1 -1
  21. package/dist/assets/InstancesTable-LVQWfz07.js +1 -0
  22. package/dist/assets/IntegrationDetail-C_vN9X7q.js +1 -0
  23. package/dist/assets/{Integrations-BOc2LGfc.js → Integrations-BUOpFqfh.js} +1 -1
  24. package/dist/assets/{Integrations-BgRTT3i6.js → Integrations-Dpb2V2yu.js} +1 -1
  25. package/dist/assets/Library-D4-BDy54.js +1 -0
  26. package/dist/assets/Locations-DGZ_lrp3.js +3 -0
  27. package/dist/assets/Logs-CUV00qxb.js +1 -0
  28. package/dist/assets/{MaskShapeCanvas-BwjxoZHj.js → MaskShapeCanvas-D57fCIme.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-CgruOSjK.js → MotionZonesSettings-w1kFM_O4.js} +1 -1
  30. package/dist/assets/MyAccess-D87gqxHt.js +2 -0
  31. package/dist/assets/{Network-Dxm48n1Y.js → Network-L7e5c9RP.js} +1 -1
  32. package/dist/assets/{NewExportModal-DQLl3C3Q.js → NewExportModal-CHwUJ26P.js} +1 -1
  33. package/dist/assets/{NodeAddonsSettingsPanel-H8ruMWFP.js → NodeAddonsSettingsPanel-Kqe8X8RH.js} +1 -1
  34. package/dist/assets/{Notifications-B44Sd1jg.js → Notifications-CucZNxjj.js} +1 -1
  35. package/dist/assets/{PanelContent-DnT2f8Cc.js → PanelContent-PhbemYUY.js} +2 -2
  36. package/dist/assets/Pipeline-9O3YfaWk.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-B6WFh3P4.js → PrivacyMaskSettings-BS29zGkX.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-M-wzPHRE.js → SceneMonitorEditor-CosxkmPM.js} +1 -1
  39. package/dist/assets/{SessionsList-D0tv-91a.js → SessionsList-OHo3GJ72.js} +2 -2
  40. package/dist/assets/{Showroom-BlMk46Us.js → Showroom-0iJ0CCe5.js} +1 -1
  41. package/dist/assets/{StorageLocationsTable-13scCxNp.js → StorageLocationsTable-DqTWO4k1.js} +1 -1
  42. package/dist/assets/System-DZXA2QSs.js +2 -0
  43. package/dist/assets/TemplateEditorDialog-8D78AUfO.js +1 -0
  44. package/dist/assets/{Terminal-BwEVkhLM.js → Terminal-Cvw2rPrb.js} +3 -3
  45. package/dist/assets/{TrainingProviders-CPc4S7AF.js → TrainingProviders-DcThiLnE.js} +1 -1
  46. package/dist/assets/{Viewer-B4D9Uq2-.js → Viewer-BUfnqb0c.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6FI5YpS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js} +1 -1
  48. package/dist/assets/{action-draft-BIhSMudC.js → action-draft-BTVZLATm.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-BfJpXMnt.js → ai-page.helpers-qxf7BP-v.js} +1 -1
  50. package/dist/assets/{assignment-candidates-BfJhT0tz.js → assignment-candidates-d-6NU8po.js} +1 -1
  51. package/dist/assets/{authed-media-ChKbSmi3.js → authed-media-Bqh0pB9D.js} +1 -1
  52. package/dist/assets/{board-model-CyseSL_y.js → board-model-CPA2IZpg.js} +1 -1
  53. package/dist/assets/{camera-block-model-BKFq-3HR.js → camera-block-model-CJ0e2m0o.js} +1 -1
  54. package/dist/assets/client-Cng2SeYA.js +1122 -0
  55. package/dist/assets/{command-vocab-CeQ0ypHW.js → command-vocab-BzBhzE7i.js} +1 -1
  56. package/dist/assets/{device-detail-CFJoqbEo.js → device-detail-Cg2Zt8FL.js} +1 -1
  57. package/dist/assets/{device-integration-icon-BwgC8WB_.js → device-integration-icon-VMxiVsqd.js} +1 -1
  58. package/dist/assets/device-picker-model-B-FI9413.js +1 -0
  59. package/dist/assets/dist-CxrdebAP.js +1122 -0
  60. package/dist/assets/{dist-Bgy0yfXq.js → dist-D7Gew3v3.js} +1 -1
  61. package/dist/assets/{format-D9ROMB42.js → format-BopmTOzZ.js} +1 -1
  62. package/dist/assets/{hostInit-DO8vSCT5.js → hostInit-DuH1KOuD.js} +1 -1
  63. package/dist/assets/i18n--GTAj4mB.js +1 -0
  64. package/dist/assets/{icons-DrHUdyj-.js → icons-bi-mcO5N.js} +1 -1
  65. package/dist/assets/index-DbXFHmBJ.js +6 -0
  66. package/dist/assets/{linked-devices-model-bymuMeaF.js → linked-devices-model-Bnz1douR.js} +1 -1
  67. package/dist/assets/{mf-entry-bootstrap-0-dc995488.js → mf-entry-bootstrap-0-ddbe056c.js} +2 -2
  68. package/dist/assets/mount-B-FI9413.js +1 -0
  69. package/dist/assets/{notification-rule-status-CyADOgAm.js → notification-rule-status-ai5zWyzt.js} +1 -1
  70. package/dist/assets/{player-overlays-D546iNTv.js → player-overlays-fpbPSPqT.js} +1 -1
  71. package/dist/assets/remoteEntry-g0NfB_lk.js +1 -0
  72. package/dist/assets/{src-C9_yKHH3.js → src-eL0OacoB.js} +18 -18
  73. package/dist/assets/{sso-popup--gCyd56l.js → sso-popup-Za4GwQBP.js} +1 -1
  74. package/dist/assets/{step-inspector-model-B_OOCp6Z.js → step-inspector-model-BAgxIyNV.js} +1 -1
  75. package/dist/assets/{use-scenes-feed-D9kXSeA2.js → use-scenes-feed-BTNdL7JV.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-CF8lG06z.js → useAdminDeviceRemoval-COlTnaF7.js} +1 -1
  77. package/dist/assets/useEventInvalidation-B-FI9413.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-ju70FIba.js → useNodeUrlSelection-DhtJZEtx.js} +1 -1
  79. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BSgZU_Z3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js} +2 -2
  80. package/dist/index.html +8 -8
  81. package/dist/server/addon.js +205 -19
  82. package/package.json +2 -2
  83. package/dist/assets/Addons-CgCQDQsS.js +0 -5
  84. package/dist/assets/AiProfiles-BAdfHll3.js +0 -3
  85. package/dist/assets/Archive-tBDnGn2J.js +0 -1
  86. package/dist/assets/Cluster-Chna0Sjs.js +0 -1
  87. package/dist/assets/Data-Ge58RjOD.js +0 -2
  88. package/dist/assets/History-D-ERNFKB.js +0 -1
  89. package/dist/assets/InstancesTable-BzPfQPuA.js +0 -1
  90. package/dist/assets/IntegrationDetail-CEcOLviw.js +0 -1
  91. package/dist/assets/Library-DUI94NI6.js +0 -1
  92. package/dist/assets/Locations-DkcchiHh.js +0 -3
  93. package/dist/assets/Logs-DS49QhkO.js +0 -1
  94. package/dist/assets/MyAccess-TXMLevZM.js +0 -2
  95. package/dist/assets/Pipeline-XpW32I39.js +0 -1
  96. package/dist/assets/System-CkjsA5xm.js +0 -2
  97. package/dist/assets/TemplateEditorDialog-fJjZNx16.js +0 -1
  98. package/dist/assets/client-DQzHwaNb.js +0 -1122
  99. package/dist/assets/device-picker-model-CVOfqhXA.js +0 -1
  100. package/dist/assets/dist-B6zcGpdS.js +0 -1122
  101. package/dist/assets/i18n-HSlX-YO0.js +0 -1
  102. package/dist/assets/index-BN2PojUq.js +0 -6
  103. package/dist/assets/mount-CVOfqhXA.js +0 -1
  104. package/dist/assets/remoteEntry-CeXhbAxp.js +0 -1
  105. package/dist/assets/useEventInvalidation-CVOfqhXA.js +0 -1
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
5990
5990
  var ZodFirstPartyTypeKind;
5991
5991
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5992
5992
  //#endregion
5993
- //#region ../types/dist/runtime-capabilities-Bgt5QBvO.mjs
5993
+ //#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
5994
5994
  /**
5995
5995
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5996
5996
  * window to float samples (D455).
@@ -65432,6 +65432,16 @@ var IntegrationInstanceStatusSchema = object({
65432
65432
  /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
65433
65433
  label: string().optional()
65434
65434
  });
65435
+ /**
65436
+ * What "Add device" inside ONE instance offers, decided per instance by its provider. `scan`: the
65437
+ * LAN scan finds devices this instance holds; `children`: only the instance's own children, via
65438
+ * adoption (a scan would offer other hosts, which are new integrations); `none`: manual add only.
65439
+ */
65440
+ var IntegrationInstanceAddDeviceSchema = _enum([
65441
+ "scan",
65442
+ "children",
65443
+ "none"
65444
+ ]);
65435
65445
  var IntegrationInstanceSchema = object({
65436
65446
  id: IntegrationInstanceIdSchema,
65437
65447
  name: string(),
@@ -65449,7 +65459,9 @@ var IntegrationInstanceSchema = object({
65449
65459
  formValues: record(string(), unknown()),
65450
65460
  status: IntegrationInstanceStatusSchema.optional(),
65451
65461
  /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
65452
- lastCheckedAt: number$1().optional()
65462
+ lastCheckedAt: number$1().optional(),
65463
+ /** What "Add device" inside this instance offers; see {@link IntegrationInstanceAddDeviceSchema}. Absent means the caller derives it from `describe().discovery` with `defaultAddDeviceMode` (lan → scan, account → children, else none). */
65464
+ addDevice: IntegrationInstanceAddDeviceSchema.optional()
65453
65465
  });
65454
65466
  var IntegrationInstancePatchSchema = object({
65455
65467
  id: IntegrationInstanceIdSchema,
@@ -72987,7 +72999,15 @@ var RunnerInferenceDeviceSchema = object({
72987
72999
  * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
72988
73000
  * the elected device's provisioning, as before.
72989
73001
  */
72990
- steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
73002
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional(),
73003
+ /**
73004
+ * Steps switched OFF on this device (D1065, `inferenceDevices[key].steps[s]
73005
+ * .enabled === false`). The runner never runs a subtree containing one of
73006
+ * them here: it auto-jumps it to an allowed device, and when none can take
73007
+ * it the subtree is skipped (`disabled-on-device`), never run here anyway.
73008
+ * Absent ⇒ none (an orchestrator that predates D1065).
73009
+ */
73010
+ disabledSteps: array(string()).readonly().optional()
72991
73011
  });
72992
73012
  /**
72993
73013
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -78912,7 +78932,15 @@ var DeviceStepConfigSchema = object({
78912
78932
  * at a disabled/absent device on that node at save time. Absent ⇒ the runner
78913
78933
  * auto-jumps only when the effective device's format cannot run the step.
78914
78934
  */
78915
- jumpDeviceKey: string().optional()
78935
+ jumpDeviceKey: string().optional(),
78936
+ /**
78937
+ * DEVICE switch for this step (D1065). `false` = the step is never
78938
+ * provisioned on this accelerator: a detail step jumps to another enabled
78939
+ * device of the node where it is allowed, else it is skipped with reason
78940
+ * `disabled-on-device`; a root is skipped. Absent = inherit (on). Written by
78941
+ * `setDeviceStepEnabled`.
78942
+ */
78943
+ enabled: boolean().optional()
78916
78944
  });
78917
78945
  var AgentPipelineSettingsSchema = object({
78918
78946
  maxCameras: number$1().int().nonnegative().nullable().default(null),
@@ -78956,6 +78984,12 @@ var AgentPipelineSettingsSchema = object({
78956
78984
  */
78957
78985
  stepSettings: record(string(), record(string(), unknown()).readonly()).optional(),
78958
78986
  /**
78987
+ * NODE switch per step (D1065): `stepId → enabled`. `false` = the step never
78988
+ * runs on a camera whose pipeline runs on this node (skip reason
78989
+ * `disabled-on-node`). Absent = inherit. Written by `setNodeStepEnabled`.
78990
+ */
78991
+ stepEnabled: record(string(), boolean()).optional(),
78992
+ /**
78959
78993
  * Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
78960
78994
  * weight, steps}. Absent / all-disabled ⇒ the node's single default
78961
78995
  * accelerator (safe default); two+ enabled ⇒ the dispatcher balances
@@ -79277,7 +79311,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
79277
79311
  "disabled",
79278
79312
  "unavailable",
79279
79313
  "cannot-host-camera-root",
79280
- "accelerator-preferred"
79314
+ "accelerator-preferred",
79315
+ "root-switched-off"
79281
79316
  ]);
79282
79317
  var NodeInferenceDeviceSchema = object({
79283
79318
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
@@ -79363,6 +79398,75 @@ var NodeInferenceDevicesSchema = object({
79363
79398
  devices: array(NodeInferenceDeviceSchema).readonly()
79364
79399
  });
79365
79400
  /**
79401
+ * The CLUSTER switch of one pipeline step (D1065):
79402
+ * - `off` — hard off: no camera, node or device can turn it on;
79403
+ * - `on` — on by default; a camera may turn it off (`stepToggles`);
79404
+ * - `opt-in` — off by default; a camera turns it on (`stepToggles`).
79405
+ * Absent = the catalog's `enabledByDefault` (`true` → `on`, `false` → `opt-in`).
79406
+ */
79407
+ var StepClusterModeSchema = _enum([
79408
+ "off",
79409
+ "on",
79410
+ "opt-in"
79411
+ ]);
79412
+ /**
79413
+ * What one step does on one (node, device) — computed by the orchestrator with
79414
+ * the SAME placement function the attach path runs (`pipeline-resolver.ts`),
79415
+ * so a client never re-derives it. Precedence: cluster off > camera toggle
79416
+ * (else the cluster default) > node off > device off / jump.
79417
+ */
79418
+ var StepSwitchCellSchema = discriminatedUnion("kind", [
79419
+ object({ kind: literal("on") }),
79420
+ object({ kind: literal("off-cluster") }),
79421
+ object({ kind: literal("off-node") }),
79422
+ object({ kind: literal("off-device") }),
79423
+ object({
79424
+ kind: literal("jump"),
79425
+ toDeviceKey: string()
79426
+ }),
79427
+ object({
79428
+ kind: literal("skip"),
79429
+ reason: _enum(["no-compatible-model", "root-not-runnable-on-elected-device"])
79430
+ }),
79431
+ object({ kind: literal("zone-driven") }),
79432
+ object({
79433
+ kind: literal("supplied-by-root"),
79434
+ rootModelId: string()
79435
+ }),
79436
+ object({ kind: literal("opt-in-unused") })
79437
+ ]);
79438
+ var StepSwitchDeviceSchema = object({
79439
+ deviceKey: string(),
79440
+ format: _enum(MODEL_FORMATS),
79441
+ /** The device switch as stored (`inferenceDevices[key].steps[step].enabled`); `null` = inherit. */
79442
+ stepEnabled: boolean().nullable(),
79443
+ /** Whether the device is in the node's dispatch roster (enabled, available, not excluded). */
79444
+ eligible: boolean(),
79445
+ cell: StepSwitchCellSchema
79446
+ });
79447
+ var StepSwitchNodeSchema = object({
79448
+ nodeId: string(),
79449
+ /** False when the node's catalog or device probe did not answer — no cells are claimed. */
79450
+ reachable: boolean(),
79451
+ /** The node switch as stored (`stepEnabled[step]`); `null` = inherit. */
79452
+ stepEnabled: boolean().nullable(),
79453
+ devices: array(StepSwitchDeviceSchema).readonly()
79454
+ });
79455
+ var StepSwitchMatrixSchema = object({ steps: array(object({
79456
+ stepId: string(),
79457
+ name: string(),
79458
+ slot: string(),
79459
+ /** The stored cluster mode; `null` = the catalog default applies. */
79460
+ clusterMode: StepClusterModeSchema.nullable(),
79461
+ /** The mode in force (stored, else derived from `enabledByDefault`). */
79462
+ effectiveMode: StepClusterModeSchema,
79463
+ /** Cameras whose `stepToggles[step]` is `true`. */
79464
+ camerasEnabling: number$1().int().nonnegative(),
79465
+ /** Cameras whose `stepToggles[step]` is `false`. */
79466
+ camerasDisabling: number$1().int().nonnegative(),
79467
+ nodes: array(StepSwitchNodeSchema).readonly()
79468
+ })).readonly() });
79469
+ /**
79366
79470
  * Pipeline Orchestrator capability — global load balancer + camera dispatcher.
79367
79471
  *
79368
79472
  * Lives on the hub. Tracks the camera-to-agent assignment map, listens to
@@ -79533,7 +79637,28 @@ method(object({
79533
79637
  }), object({ success: literal(true) }), {
79534
79638
  kind: "mutation",
79535
79639
  auth: "admin"
79536
- }), method(object({ nodeId: string() }), NodeInferenceDevicesSchema), method(object({
79640
+ }), method(object({
79641
+ stepId: string(),
79642
+ mode: StepClusterModeSchema.nullable()
79643
+ }), object({ success: literal(true) }), {
79644
+ kind: "mutation",
79645
+ auth: "admin"
79646
+ }), method(object({
79647
+ agentNodeId: string(),
79648
+ stepId: string(),
79649
+ enabled: boolean().nullable()
79650
+ }), object({ success: literal(true) }), {
79651
+ kind: "mutation",
79652
+ auth: "admin"
79653
+ }), method(object({
79654
+ agentNodeId: string(),
79655
+ deviceKey: string(),
79656
+ stepId: string(),
79657
+ enabled: boolean().nullable()
79658
+ }), object({ success: literal(true) }), {
79659
+ kind: "mutation",
79660
+ auth: "admin"
79661
+ }), method(_void(), StepSwitchMatrixSchema), method(object({ nodeId: string() }), NodeInferenceDevicesSchema), method(object({
79537
79662
  agentNodeId: string(),
79538
79663
  deviceKey: string()
79539
79664
  }), object({ success: literal(true) }), {
@@ -88766,7 +88891,7 @@ var WorkloadPortSchema = object({
88766
88891
  hostIp: string().nullable(),
88767
88892
  protocol: WorkloadPortProtocolSchema
88768
88893
  });
88769
- object({
88894
+ var WorkloadStatusSchema = object({
88770
88895
  /** null = unknown, never stopped (D393). */
88771
88896
  state: WorkloadStateSchema.nullable().meta({ label: "State" }),
88772
88897
  /** Epoch ms the current state began (uptime while running); null when unknown. */
@@ -90156,23 +90281,56 @@ var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema,
90156
90281
  };
90157
90282
  });
90158
90283
  var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
90284
+ var pumpCycleContribution = contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
90285
+ const enabled = slice?.enabled ?? null;
90286
+ const cycle = slice?.onTime != null && slice.offTime != null ? t(`${minutesOf(slice.onTime)} min on · ${minutesOf(slice.offTime)} min off`, `${minutesOf(slice.onTime)} min acceso · ${minutesOf(slice.offTime)} min spento`) : null;
90287
+ return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
90288
+ kind: "toggle",
90289
+ id: "pump-cycle.enabled",
90290
+ label: t("Pump cycle", "Ciclo pompa"),
90291
+ on: enabled,
90292
+ turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
90293
+ turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
90294
+ }])] };
90295
+ });
90296
+ var WORKLOAD_WORDS = {
90297
+ running: {
90298
+ state: "on",
90299
+ title: t("Running", "In esecuzione")
90300
+ },
90301
+ paused: {
90302
+ state: "standby",
90303
+ title: t("Paused", "In pausa")
90304
+ },
90305
+ stopped: {
90306
+ state: "off",
90307
+ title: t("Stopped", "Fermo")
90308
+ },
90309
+ starting: {
90310
+ state: "running",
90311
+ title: t("Starting", "In avvio")
90312
+ },
90313
+ stopping: {
90314
+ state: "running",
90315
+ title: t("Stopping", "In arresto")
90316
+ },
90317
+ crashed: {
90318
+ state: "alert",
90319
+ title: t("Crashed", "Andato in errore")
90320
+ }
90321
+ };
90159
90322
  var DEVICES_FAMILY_CONTRIBUTIONS = {
90160
90323
  "fan-control": fanContribution,
90161
90324
  "vacuum-control": vacuumContribution,
90162
90325
  "lawn-mower-control": mowerContribution,
90163
90326
  "pet-feeder": feederContribution,
90164
90327
  "pet-fountain": fountainContribution,
90165
- "pump-cycle": contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
90166
- const enabled = slice?.enabled ?? null;
90167
- const cycle = slice?.onTime != null && slice.offTime != null ? t(`${minutesOf(slice.onTime)} min on · ${minutesOf(slice.offTime)} min off`, `${minutesOf(slice.onTime)} min acceso · ${minutesOf(slice.offTime)} min spento`) : null;
90168
- return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
90169
- kind: "toggle",
90170
- id: "pump-cycle.enabled",
90171
- label: t("Pump cycle", "Ciclo pompa"),
90172
- on: enabled,
90173
- turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
90174
- turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
90175
- }])] };
90328
+ "pump-cycle": pumpCycleContribution,
90329
+ workload: contribution("workload", WorkloadStatusSchema, (slice) => {
90330
+ const state = slice?.state ?? null;
90331
+ if (state === null) return { reading: reading("workload", "unknown") };
90332
+ const words = WORKLOAD_WORDS[state];
90333
+ return { reading: reading("workload", words.state, false, words.title) };
90176
90334
  })
90177
90335
  };
90178
90336
  /**
@@ -99189,6 +99347,13 @@ Object.freeze({
99189
99347
  access: "view",
99190
99348
  role: "admin"
99191
99349
  },
99350
+ "pipelineOrchestrator.getStepSwitches": {
99351
+ capName: "pipeline-orchestrator",
99352
+ capScope: "system",
99353
+ addonId: null,
99354
+ access: "view",
99355
+ role: "admin"
99356
+ },
99192
99357
  "pipelineOrchestrator.listAgentSettings": {
99193
99358
  capName: "pipeline-orchestrator",
99194
99359
  capScope: "system",
@@ -99343,6 +99508,20 @@ Object.freeze({
99343
99508
  access: "create",
99344
99509
  role: "admin"
99345
99510
  },
99511
+ "pipelineOrchestrator.setClusterStepMode": {
99512
+ capName: "pipeline-orchestrator",
99513
+ capScope: "system",
99514
+ addonId: null,
99515
+ access: "create",
99516
+ role: "admin"
99517
+ },
99518
+ "pipelineOrchestrator.setDeviceStepEnabled": {
99519
+ capName: "pipeline-orchestrator",
99520
+ capScope: "system",
99521
+ addonId: null,
99522
+ access: "create",
99523
+ role: "admin"
99524
+ },
99346
99525
  "pipelineOrchestrator.setLoadBalancingShares": {
99347
99526
  capName: "pipeline-orchestrator",
99348
99527
  capScope: "system",
@@ -99350,6 +99529,13 @@ Object.freeze({
99350
99529
  access: "create",
99351
99530
  role: "admin"
99352
99531
  },
99532
+ "pipelineOrchestrator.setNodeStepEnabled": {
99533
+ capName: "pipeline-orchestrator",
99534
+ capScope: "system",
99535
+ addonId: null,
99536
+ access: "create",
99537
+ role: "admin"
99538
+ },
99353
99539
  "pipelineOrchestrator.setNodeStepSettings": {
99354
99540
  capName: "pipeline-orchestrator",
99355
99541
  capScope: "system",
@@ -107660,7 +107846,7 @@ var AdminUIAddon = class extends BaseAddon {
107660
107846
  capability: adminUiCapability,
107661
107847
  provider: {
107662
107848
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
107663
- getVersion: async () => ({ version: "1.2.701" })
107849
+ getVersion: async () => ({ version: "1.2.702" })
107664
107850
  }
107665
107851
  }];
107666
107852
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.701",
3
+ "version": "1.2.702",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -50,7 +50,7 @@
50
50
  }
51
51
  ],
52
52
  "requires": {
53
- "server": ">=1.2.903"
53
+ "server": ">=1.2.904"
54
54
  }
55
55
  },
56
56
  "scripts": {
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,Gt as f,Hi as p,In as m,Q as h,Tn as g,Tt as _,Vn as v,Xi as y,Yn as b,Zt as x,ct as ee,er as S,ft as C,hr as te,ia as w,ot as T,sa as E,tn as D,wi as O,zr as k}from"./player-overlays-D546iNTv.js";import{ll as A}from"./client-DQzHwaNb.js";import{t as ne}from"./chevron-down-CBb-F8DT.js";import{i as j,u as M}from"./terminal-DZ5OZpgC.js";import{Eo as re,Gi as ie,Ji as ae,Kp as oe,So as se,To as ce,Ui as le,Wi as ue,Yi as de,Yp as N,_o as fe,ai as pe,ao as P,bo as me,ci as F,co as he,ct as I,do as ge,go as L,ho as _e,io as R,ka as ve,lo as z,mi as B,mo as ye,mr as be,no as xe,oi as V,oo as Se,po as H,pp as U,pr as Ce,qi as we,si as W,sl as Te,so as Ee,tu as De,uo as Oe,vt as ke,wo as Ae,xo as je,xp as Me,yo as Ne}from"./src-C9_yKHH3.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-CVOfqhXA.js";import{Si as Pe,gt as Fe,ht as Ie,vi as Le,wi as Re}from"./index-BN2PojUq.js";import{t as K}from"./NodeAddonsSettingsPanel-H8ruMWFP.js";import{t as q}from"./AdminPage-Dvziohv2.js";import{i as ze,r as Be,t as Ve}from"./addon-kind-filter-CEGKkC1O.js";import{n as J,r as He,t as Ue}from"./useNodeUrlSelection-ju70FIba.js";function We(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Y=`a singleton role: Roles & nodes is the one picker for it`,X=[{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline`,sectionIds:[`cluster-step-models`,`face-rescore`,`detail-crop`,`native-lease`,`load`,`failover`]},{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline-roles`,fieldKeys:[`ingestNode`,`audioNode`,`motionNode`],reason:Y},{cap:`face-gallery`,addonId:`pipeline-analytics`,surface:`pipeline`},{cap:`stream-broker`,addonId:`stream-broker`,surface:`pipeline`},{cap:`snapshot`,addonId:`snapshot`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline-roles`,fieldKeys:[`recordingNodeId`],reason:Y},{cap:`embedding-encoder`,addonId:`embedding-encoder`,surface:`pipeline`},{cap:`device-history`,addonId:`device-history`,surface:`history`},{cap:`alerts`,addonId:`alert-center`,surface:`notifications`},{cap:`metrics-provider`,addonId:`metrics-native`,surface:`nodes`},{cap:`login-method`,addonId:`auth-webauthn`,surface:`provider-page`},{cap:`llm`,addonId:`ai`,surface:`provider-page`},{cap:`log-destination`,addonId:`console-logging`,surface:`provider-page`},{cap:`core-blocks`,addonId:`core-blocks`,surface:`provider-page`},{cap:`custom-model-registry`,addonId:`model-studio`,surface:`addon-card`},{cap:`osd-manager`,addonId:`osd-manager`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`pipeline-roles`,fieldKeys:[`postProcessingNodeId`],reason:Y},{cap:`detection-pipeline`,addonId:`detection-pipeline`,surface:`addon-card`}],Z={pipeline:`/system/pipeline?view=nodes&node=__cluster__&ctab=settings`,"pipeline-roles":`/system/pipeline?view=nodes&node=__cluster__&ctab=roles-nodes`,history:`/system/history`,notifications:`/system/notifications?tab=settings`,nodes:`/system/nodes`};function Ge(e){return e.sectionIds===void 0&&e.fieldKeys===void 0}function Ke(e){return X.filter(t=>t.addonId===e&&Z[t.surface]!==void 0)}function qe(e){let t=X.filter(t=>t.addonId===e),n=new Set(t.filter(e=>e.surface===`addon-card`&&Ge(e)).map(e=>e.cap));return{capabilities:[...new Set(t.map(e=>e.cap))].filter(e=>!n.has(e)),fieldKeys:t.filter(e=>n.has(e.cap)&&e.surface!==`addon-card`).flatMap(e=>e.fieldKeys??[])}}function Je({addonId:e,onOpen:n}){let{t:r}=G(),i=qe(e),o=Ke(e).length>0;return t(u,{children:[a(Ye,{addonId:e,onOpen:n}),a(K,{nodeId:null,addonIds:[e],level:`global`,fieldScope:`cluster`,omitCapabilities:i.capabilities,omitFieldKeys:i.fieldKeys,emptyMessage:o?r(`addons.addonCard.allClusterSettingsElsewhere`,`Its cluster-wide settings are on the page linked above.`):r(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)})]})}function Ye({addonId:e,onOpen:n}){let{t:r}=G(),i=[...new Set(Ke(e).map(e=>e.surface))];if(i.length===0)return null;let o=e=>{switch(e){case`pipeline`:return r(`addons.addonCard.surface.pipeline`,`Pipeline → Settings`);case`pipeline-roles`:return r(`addons.addonCard.surface.pipelineRoles`,`Pipeline → Roles & nodes`);case`history`:return r(`addons.addonCard.surface.history`,`History`);case`notifications`:return r(`addons.addonCard.surface.notifications`,`Notifications → Settings`);case`nodes`:return r(`addons.addonCard.surface.nodes`,`Nodes`);default:return e}};return t(`div`,{className:`mb-2 flex flex-wrap items-center gap-2 text-[10px] text-foreground-subtle`,children:[a(`span`,{children:r(`addons.addonCard.settingsElsewhere`,`More of this addon's settings are on:`)}),i.map(e=>{let t=Z[e];return t===void 0?null:a(U,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>n(t),children:o(e)},e)})]})}var Xe={queued:{icon:p,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:k,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:E,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:j,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Ze({item:e}){let{t:n}=G(),r=Xe[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Q=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Qe=new Set([`done`,`failed`,`skipped`]);function $e(e){return!Qe.has(e.phase)&&!Q.has(e.jobState)}function et(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Q.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 tt(){let{data:e}=ye({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=N(A.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return et([...n.values()],Date.now())},[e,t])}var nt={queued:{icon:p,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:k,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:k,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:k,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:k,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:k,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:k,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:E,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:j,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:g,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function rt({progress:e}){let{t:n}=G(),r=nt[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function it(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 at(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ot(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(at)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function st(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 ct={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function lt(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)}: ${ct[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 ut={},dt=3e4,ft=`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 pt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=G(),c=l(),u=ee(),d=T(),f=H(ut,{staleTime:dt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=it(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=ce({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:lt(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:st(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},x=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=it(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:ot(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(D,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(M,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function mt(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function ht(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!mt(e))}function gt(e){return e.length-ht(e,!1).length}c();function _t({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=G(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:v,isError:y}=z({name:e}),b=g?ht(g,m):[],x=g?gt(g):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(U,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3 w-3`})})]}),p&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(f,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Le,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(k,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),y&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),b.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:b.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),mt(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(U,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(E,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(U,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(O,{className:`h-3 w-3`})})]},e.version)})}),!v&&!y&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),x>0&&a(U,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:m?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:x})})]})}c();var vt=`device-export`;function yt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===vt)}function bt(e){return e!==`local`&&e!==`upload`}function xt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?h(`/api/addon-assets/${r}/${i}`):null,m=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?te:S,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),bt(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(f,{className:`h-2.5 w-2.5 text-white`})})]})}function St({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=G();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(k,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(O,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(ne,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(ne,{className:`h-3 w-3 opacity-50`})]}),u]})}function Ct({addonId:e}){let t=l(),{data:n=`inherit`}=P({addonId:e}),r=je({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(U,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var wt={id:`hub`,name:`Hub`,isHub:!0};function Tt({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:d,onUpdate:f,isUpdating:p,jobProgress:h,bundle:g,bulkItem:y,disabledByBulk:x,isSystem:ee,selectedNode:S}){let{t:C}=G(),[T,E]=s(!1),[D,O]=s(!1),[k,A]=s(null);o(()=>{A(null)},[i]);let M=k??i,[re,oe]=s(!1),[se,ce]=s(!1),[N,pe]=s(`logs`),P=l(),me=Pe(),{manifest:F}=e,he=!g&&!F.protected&&F.removable!==!1,I=!!g,ge=g?.displayName??F.name,L=g?.packageName??F.packageName,_e=g?.version??F.packageVersion??F.version,R=g?.installSource??e.installSource,z=g?g.bundle?.description??g.addons[0]?.manifest.description:F.description,B=fe({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),ye=Oe({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=Ne({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),V=e.health,Se=V?.phase===`failed`&&!V.inGracePeriod,H=Se&&V?.nextRetryAt&&!V.retrying,W=We(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${Se?`border-red-500/50`:`border-border`}`,children:[Se&&V&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(j,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.failedToLoad`,{attempt:V.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:V.lastError?.message??C(`addons.addonCard.unknownError`,`Unknown error`)}),H&&V.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:C(`addons.addonCard.autoRetryAt`,{time:new Date(V.nextRetryAt).toLocaleTimeString()})})]}),t(U,{variant:`unstyled`,type:`button`,disabled:xe.isPending||V.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:L})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:C(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(b,{className:`h-3 w-3 ${xe.isPending||V.retrying?`animate-spin`:``}`}),C(`addons.addonCard.retryNow`,`Retry now`)]})]}),W!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(j,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.processProblem.${W.kind}`)}),W.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:W.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(xt,{isBundle:I||!!F.components&&F.components.length>1,installSource:R,addonId:I?g.addons[0]?.manifest.id:F.id,iconPath:I?g.bundle?.icon??g.addons[0]?.manifest.icon:F.icon,color:I?g.addons[0]?.manifest.color:F.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:ge}),!r&&a(St,{version:_e,availableUpdate:i,...M===void 0?{}:{selectedVersion:M},isUpdating:p,installSource:R,disabled:x,...f&&M!==void 0?{onUpdate:()=>f(M)}:{},onOpenPicker:()=>O(e=>!e),children:D&&a(_t,{packageName:L,currentVersion:_e,...R?{installSource:R}:{},...i!==void 0&&M!==void 0?{selectedVersion:M,onSelect:e=>{A(e),O(!1)}}:{},onInstall:e=>{O(!1),ye.mutate({packageName:L,version:e})},onClose:()=>O(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[L!==ge&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:L}),I&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(te,{className:`h-3 w-3`}),g.addons.length]}),ee&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:C(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(b,{className:`h-3 w-3`}),C(`addons.addonCard.system`,`System`)]}),y!=null&&a(Ze,{item:y}),c!==void 0&&a(ve,{variant:`warning`,title:C(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:C(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&d!==void 0&&a(U,{type:`button`,size:`sm`,variant:`secondary`,onClick:d,children:C(`clusterUpdate.updateServer`,`Update server`)}),h!=null&&a(rt,{progress:h})]}),z&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:z}),!I&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?C(`addons.addonCard.forked`):C(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:W===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!I&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),B.mutate({addonId:F.id})},disabled:B.isPending||x,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(b,{className:`h-3 w-3 ${B.isPending?`animate-spin`:``}`}),C(`addons.addonCard.restart`,`Restart`)]}),t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${re?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(v,{className:`h-3 w-3`}),C(`addons.addonCard.logs`,`Logs`)]}),!I&&t(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ce(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${se?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(m,{className:`h-3 w-3`}),C(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),he&&a(pt,{packageName:F.packageName,displayName:F.name,selectedNode:S??wt,disabled:x})]}),n&&n.nodes.length>1&&!I&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:C(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:C(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:C(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:C(`common.synced`)})]},e.nodeId))})]}),re&&!I&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(U,{variant:`unstyled`,type:`button`,onClick:()=>pe(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.logs`,`Logs`)}),a(U,{variant:`unstyled`,type:`button`,onClick:()=>pe(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${N===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(U,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&a(be,{addonId:F.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&a(Ce,{addonId:F.id,category:`addon.*`,maxHeight:`max-h-64`})]}),I&&t(u,{children:[a(U,{variant:`unstyled`,type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(T?w:ne,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),T&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(Tt,{addon:e,hideVersion:!0},e.manifest.id))})]}),se&&!I&&a(le,{open:!0,onOpenChange:e=>!e&&ce(!1),children:t(ie,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ae,{children:t(de,{className:`flex items-center gap-2`,children:[a(m,{className:`h-4 w-4 text-primary`}),C(`addons.addonCard.settingsTitle`,{name:ge})]})}),t(ue,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:C(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Je,{addonId:F.id,onOpen:e=>me(e)}),yt(F)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.deviceExport`,`Device export`)}),a(ke,{addonId:F.id,onOpenDevice:e=>me(`/devices/${e}`)})]}),bt(R)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(Ct,{addonId:F.id})]}),F.components&&F.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.components`,{count:F.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:F.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(we,{children:a(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>ce(!1),children:C(`common.close`,`Close`)})})]})})]})}c();var Et=`.tgz,.tar.gz,.zip`;function Dt({onUploadSuccess:e}){let{t:r}=G(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(h(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(B,{ref:l,accept:Et,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(U,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(k,{className:`w-3.5 h-3.5 animate-spin`}):a(f,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var Ot=/```[^\n]*\n([\s\S]*?)```/g;function kt(e){let t=[],n=0;for(let r of e.matchAll(Ot)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function At(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function jt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?At(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function Mt(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:jt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:jt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=jt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Nt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:kt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:Mt(e.body,`b${t}`)},`text-${t}`))})}c();function Pt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Ft(e,t,n){let r=ht(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function It({pending:e,failed:n,body:r,missing:i}){let{t:o}=G();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(k,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Nt,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function Lt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=G(),[l,u]=s(e.version),[d,f]=s(!1),p=z({name:e.name}),m=he({name:e.name,version:l}),h=p.data??[],g=gt(h),_=Ft(h,l,d),v=m.data;return a(le,{open:!0,onOpenChange:e=>!e&&i(),children:t(ie,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ae,{children:a(de,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:Pt(e.name)})})}),t(ue,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(C,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:mt(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(U,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(pe,{defaultValue:`readme`,children:[t(W,{children:[a(F,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(F,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(V,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(It,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(V,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(It,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(we,{children:[a(U,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(U,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(k,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}function Rt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Fe(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 zt({selectedNode:e}){let{t:n}=G(),{data:r}=H(ut,{staleTime:dt});if(r===void 0)return null;let i=Rt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(x,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(pt,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Bt({addon:e,installing:n,onInstall:r}){let{t:i}=G();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(ve,{variant:`success`,icon:a(E,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(U,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(k,{className:`h-3 w-3 animate-spin`}):a(O,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Vt({capability:e,installing:n,onInstall:r}){let{t:i}=G(),{data:o,isPending:s,isError:c}=me({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(k,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Bt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Ht(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`,Wt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,Gt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Kt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function qt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Jt(e){return e===`local`?`dev`:`npm`}function Yt(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 Xt(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 Zt({addons:c,clusterStatus:u,selectedNode:f,onRefresh:p,listPhase:m}){let{t:h}=G(),g=l(),[_,v]=s(``),[x,S]=s(!1),te=e(_),[w,T]=s(!1),E=n(null);o(()=>{if(!w)return;let e=e=>{E.current&&!E.current.contains(e.target)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let{data:D}=_e({nodeId:f.id}),A=r(()=>{let e=new Map;for(let t of D??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[D]),ne=r(()=>{let e=new Map;for(let t of D??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[D]),j=r(()=>(D??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[D]),[M,ie]=s(()=>new Set),[ae,oe]=s(()=>new Map),ce=i(e=>{ie(t=>new Set(t).add(e))},[]),le=i(e=>{ie(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),ue=i((e,t)=>{oe(n=>new Map(n).set(e,t))},[]),de=i(e=>{oe(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),N=re({onMutate:e=>{ce(e.name),de(e.name)},onSuccess:(e,t)=>{le(t.name);let n=e;if(n&&n.success===!1){ue(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{le(t.name),ue(t.name,e instanceof Error?e.message:String(e))}}),fe=tt(),pe=n(new Set);o(()=>{let e=new Set;for(let[t,n]of fe)$e(n)&&e.add(t);let t=[...pe.current].some(t=>!e.has(t));pe.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[fe,g]);let{data:P}=Se(void 0),F=xe({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),he=se({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:I,isFetching:ge}=me({query:te||void 0},{enabled:w}),L=Ae(),{data:R}=Ee(void 0),ve=R?.requestedAt,[z,B]=s(null),[ye,be]=s(!1);o(()=>{if(R?.kind===`framework-bulk-update`&&R.requestedAt!==z){B(R.requestedAt),be(!0);let e=window.setTimeout(()=>be(!1),6e3);return()=>window.clearTimeout(e)}},[ve,z,R]),ee();let V=i(async()=>{let e=(D??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!f.isHub){for(let t of e)await N.mutateAsync({name:t.name,version:t.latestVersion,nodeId:f.id});return}await L.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[f.id]})}},[D,f.id,f.isHub,L,N]),[H,Ce]=s(null),[we,W]=s(null),De=e=>{W(null),Ce(e)},ke=Oe({onSuccess:()=>{Ce(null),W(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{W(e instanceof Error?e.message:`Install failed`)}}),[je,Ne]=s(`type`),[Pe,Fe]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Le=e=>{Fe(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[K,q]=Re(),J=K.get(`capability`),Ue=K.get(`updatable`)===`1`,Y=K.get(`error`)===`1`,X=Ht(K.get(`source`)),Z=ze(K.get(Ve))===`integration`,{data:Ge}=Te(void 0,{enabled:Z}),Ke=r(()=>Ge===void 0?null:new Set(Ge.map(e=>e.addonId)),[Ge]),qe=i(e=>{let t=new URLSearchParams(K);e?t.set(Ve,`integration`):t.delete(Ve),q(t,{replace:!0})},[K,q]),Je=i(e=>{let t=new URLSearchParams(K);e?t.set(`updatable`,`1`):t.delete(`updatable`),q(t,{replace:!0})},[K,q]),Ye=i(e=>{let t=new URLSearchParams(K);e?t.set(`error`,`1`):t.delete(`error`),q(t,{replace:!0})},[K,q]),Xe=i(e=>{let t=new URLSearchParams(K);e===null?t.delete(`source`):t.set(`source`,e),q(t,{replace:!0})},[K,q]),Ze=r(()=>c.filter(e=>We(e.process)!==null).length,[c]),Q=r(()=>{let e=c.filter(e=>!Ie(e.manifest.packageName));return f.isHub||(e=e.filter(e=>qt(e.placement,f.isHub))),J&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===J))),Z&&(e=[...Be(e,Ke)]),Ue&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&A.has(t)})),X!==null&&(e=e.filter(e=>Jt(e.installSource)===X)),Y&&(e=e.filter(e=>We(e.process)!==null)),e},[c,f.isHub,J,Ue,X,Y,Z,Ke,A]),Qe=()=>{let e=new URLSearchParams(K);e.delete(`capability`),q(e,{replace:!0})},et=Pe===`flat`?Q:Xt(Q),nt=r(()=>{let e=[...et];switch(je){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},[et,je]);return t(`div`,{className:`space-y-3`,children:[a(He,{open:x,onOpenChange:S}),[...ae.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(U,{variant:`unstyled`,type:`button`,onClick:()=>de(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(C,{wrapperClassName:`inline-block w-auto`,value:je,onChange:e=>Ne(e.target.value),children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(U,{variant:`unstyled`,type:`button`,onClick:()=>Le(e),className:`px-2 py-1 transition-colors capitalize ${Pe===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),f.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(b,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(U,{variant:`unstyled`,type:`button`,onClick:()=>F.mutate({channel:e}),disabled:F.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),f.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(C,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:he.isPending||P===void 0,onChange:e=>{P!==void 0&&he.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:Gt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),j>0&&t(U,{variant:`unstyled`,type:`button`,onClick:()=>void V(),disabled:L.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[L.isPending?a(k,{className:`w-3 h-3 animate-spin`}):a(O,{className:`w-3 h-3`}),L.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:j})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:h(`admin.system.addons.integrations`,`Integrations`),pressed:Z,toggle:()=>qe(!Z)},{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:Ue,toggle:()=>Je(!Ue)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ze}),pressed:Y,toggle:()=>Ye(!Y)},{id:`npm`,label:`npm`,pressed:X===`npm`,toggle:()=>Xe(X===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:X===`dev`,toggle:()=>Xe(X===`dev`?null:`dev`)}].map(e=>a(U,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ut:Wt,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:E,children:[a(Me,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{v(e.target.value),T(!0)},onFocus:()=>T(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:L.isPending,leftSlot:a(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:ge?a(k,{className:`h-3 w-3 animate-spin`}):void 0}),w&&I&&I.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[I.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:I.length})}),I&&I.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:I.map(e=>a(Bt,{addon:e,installing:ke.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(Dt,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),J&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:J}),a(U,{variant:`unstyled`,type:`button`,onClick:Qe,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),J&&a(Vt,{capability:J,installing:ke.isPending,onInstall:e=>De({name:e.name,version:e.version,description:e.description})}),J&&Q.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),ye&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(y,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(k,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Q.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):J?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:J}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:f.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&nt.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=A.get(t),r=ne.get(t),i=$(e)?e.representative:e,o=n?e=>N.mutate({name:t,version:e,nodeId:f.id}):void 0,s=fe.get(t)??null,c=s!==null&&$e(s);return a(Tt,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},...r===void 0?{}:{onUpdateServer:()=>S(!0)},isUpdating:M.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:L.isPending,selectedNode:f},$(e)?t:e.manifest.id)})}),H!==null&&a(Lt,{target:H,installing:ke.isPending,installError:we,onClose:()=>Ce(null),onInstall:(e,t)=>ke.mutate({packageName:e,version:t})})]})}function Qt(){let{t:e}=G(),r=l(),{data:i}=De(void 0),{nodes:s}=oe(),{selection:c,selectNode:u,requestedNodeId:d}=Ue(s.length>0?s:[Kt]),f=c.node??Kt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=ge({nodeId:p}),v=R(),y=L(),x=v.isPending||y.isPending,ee=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},S=n(v);S.current=v;let C=n(d??`hub`);o(()=>{S.current.mutate({nodeId:C.current})},[]);let te=(h??[]).map(Yt).filter(e=>e!==null);return t(q,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(I,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:te.length})}),t(U,{variant:`unstyled`,type:`button`,onClick:()=>void ee(),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:[a(b,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(J,{staleNodeId:m,shownNodeName:f.name}),a(zt,{selectedNode:f}),a(Zt,{addons:te,clusterStatus:i,selectedNode:f,onRefresh:()=>void ee(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{Qt as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,D as f,G as p,L as m,Q as h,Rn as g,Tt as _,ba as v,ci as y,fa as b,ft as x,mn as S,tn as C,wi as w,yn as T,yt as E,zn as D,zr as O}from"./player-overlays-D546iNTv.js";import{Di as k}from"./client-DQzHwaNb.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{Aa as M,Br as N,Ca as P,Da as F,Gp as I,Ia as ee,Ir as L,Sa as te,Sp as ne,Zs as R,gi as re,ka as z,la as B,pp as V,q as ie,ut as H,xp as ae,zr as U}from"./src-C9_yKHH3.js";import{t as W}from"./i18n-HSlX-YO0.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-CVOfqhXA.js";import{St as K,b as q,wi as J}from"./index-BN2PojUq.js";import{t as Y}from"./AdminSectionedPage-3F0XiS4h.js";import{t as oe}from"./InstancesTable-BzPfQPuA.js";import{t as se}from"./AdminPage-Dvziohv2.js";import{a as ce,c as le,d as ue,f as de,i as fe,l as X,n as pe,o as me,p as he,r as ge,s as Z,t as _e,u as ve}from"./ai-page.helpers-BfJpXMnt.js";c();function ye(){let{t}=G(),n=E(),r=P({functionCap:`llm`}).data??[],a=s({queryKey:pe,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(L,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:ge.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(X):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(x,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:Z(e)===``?e.name:`${e.name} · ${Z(e)}`}))]}),u!==``&&d===void 0&&i(`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&&i(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},n)})})})}var be=2e3;function Q(e){return W.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=G(),l=E(),[f,p]=o(``),[m,h]=o(null),[g,_]=o(!1),v=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),S=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),C=s({queryKey:fe,enabled:S.isPending,refetchInterval:S.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,T=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Q(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,m,t,c]),D=e=>{if(e===``){a(null);return}if(e===`custom`){if(m?.ok!==!0)return;a({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&b.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(H,{label:c(`ai.model`,`Model`),required:!0,children:i(x,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:T,onChange:e=>D(e.target.value)})}),i(H,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`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:e(`div`,{className:`flex gap-2`,children:[i(ae,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:f,onChange:e=>p(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),k())}}),e(V,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||b.isPending,onClick:()=>k(),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(F,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(F,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(V,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),b.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(V,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(m.requiredBytes)})})]})}),m?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:m.label}),i(z,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(z,{variant:`default`,children:Q(m.totalBytes)})]}),m.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(V,{size:`sm`,type:`button`,disabled:S.isPending||g,onClick:()=>S.mutate(m.model),children:[S.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),C!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:C.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:C.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:C.file,index:C.fileIndex,count:C.fileCount,done:Q(C.downloadedBytes),total:C.totalBytes===void 0?``:` / ${Q(C.totalBytes)}`})})]}),S.isError&&i(F,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=G(),a=E(),o=s({queryKey:fe,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=me(a),s=o.nodeId===t;return e(V,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.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 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(z,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`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 we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=k.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Se,{nodeId:we(e,`nodeId`)??`hub`,value:o,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 De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=G(),d=E(),f=l(),p=s({queryKey:n(()=>[K,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,h]=o({}),g=t({}),_=t(!1),v=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[K]}),await f.invalidateQueries({queryKey:[te]}),h({})}}),y=r(e=>{g.current={...g.current,...e},h(t=>({...t,...e})),!_.current&&(_.current=!0,queueMicrotask(()=>{let e=g.current;g.current={},_.current=!1,v.mutate(e)}))},[v]),b=p.data?.description.kinds?.find(e=>e.id===a.kindId),S=p.data?.instance?.formValues,C=n(()=>({...S,...m}),[S,m]),w=b?.widgets??[],T=w.some(e=>e.placement===`model`),D=n(()=>({...$(C,`nodeId`)===``?{}:{nodeId:$(C,`nodeId`)},...typeof C.modelRef==`object`&&C.modelRef!==null?{model:C.modelRef}:{}}),[C]),k={id:$(C,`model`),supportsVision:C.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(F,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);y({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[w.map(({id:e})=>{let t=Oe(e);return t===null?i(F,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:D,onProviderConfigChange:e=>y({...$(e,`nodeId`)===$(D,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==D.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>y({model:e.id,supportsVision:e.supportsVision})},e)}),!T&&e(H,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(V,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(x,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),v.isError&&i(F,{variant:`warning`,message:v.error.message})]})}c();var Ae=5e3;function je(e){return W.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=G(),r=E(),a=s({queryKey:fe,refetchInterval:Ae,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(z,{variant:he(n),children:t(de(n))}),n.status?.downloadProgress!==void 0&&i(z,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=ue(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(z,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(L,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(F,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(B,{icon:g,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(U,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:N})})}var Ne=h(`/addon/ai/test-chat`),Pe=h(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(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 ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.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:Re(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:W.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(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=Be(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Be(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function He(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ue(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function We(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 Ge(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 Ke(e,t){switch(e){case`resolving-image`:return W.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return W.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?W.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):W.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return W.t(`helpers.aiTestChat.phaseAnswering`)}}c();var qe=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Je=360*60*1e3,Ye=40,Xe=160,Ze={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=G();E();let[c,l]=o(``),[u,d]=o(``),[p,h]=o(``),[g,y]=o([]),[w,T]=o(null),[O,k]=o(`none`),[A,M]=o(`throwaway`),[N,I]=o(null),[ee,te]=o([]),[R,z]=o(null),[B,H]=o(null),U=t(null);a(()=>()=>U.current?.abort(),[]);let W=r(async()=>{let e=await fetch(Pe,{credentials:`same-origin`});e.ok&&te((await e.json()).chats??[])},[]);a(()=>{A===`persistent`&&W()},[A,W]);let K=P({functionCap:`llm`}),q=n(()=>(K.data??[]).filter(e=>e.enabled),[K.data]),J=q.find(e=>e.id===c)??null,Y=B!==null,oe=r(async(e,t)=>{let n=new AbortController;U.current=n,z(null);let r=Ie(J===null?{}:ve(J));H({...Ze,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Ne,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...A===`persistent`?{persist:!0,...N===null?{}:{conversationId:N}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of Ve(s.body))switch(e.kind){case`status`:H(t=>({...t??Ze,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,H(t=>({...t??Ze,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,H(e=>({...e??Ze,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||z(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{U.current=null,H(null)}f!==void 0&&(I(f),W());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||y(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[A,N,J,c,W,u,s]),se=r(()=>{let e=p.trim();if(e===``||c===``||Y)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...w===null?{}:{attachmentLabel:w.label,attachmentKind:w.ref.kind}},n=[...g,t];y(n),h(``);let r=w?.ref;T(null),k(`none`),oe(A===`persistent`&&N!==null?[{role:`user`,content:e}]:He(n),r)},[A,N,p,w,c,oe,Y,g]),ce=()=>U.current?.abort(),le=()=>{U.current?.abort(),y([]),T(null),h(``),z(null),H(null),I(null)},ue=async e=>{U.current?.abort();let t=await fetch(`${Pe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();I(e),y(We(n)),H(null),z(null)};return e(`div`,{className:m,children:[i(L,{headingId:`ai-test-setup`,title:s(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${f} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(x,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...q.map(e=>({value:e.id,label:`${e.name} · ${Z(e)}${X(e)?` · vision`:``}`}))]}),q.length===0&&!K.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(ae,{id:`ai-test-system`,value:u,onChange:e=>d(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ie,{label:s(`ai.chatMode`,`Conversation mode`),value:A,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{M(e),e===`throwaway`&&I(null)}}),A===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(V,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),ee.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:ee.map(e=>i(`button`,{type:`button`,onClick:()=>void ue(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===N?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`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.`)}),J!==null&&!X(J)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),R!==null&&i(F,{title:s(`ai.chatFailed`,`The test call failed`),message:R}),e(L,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(V,{size:`sm`,variant:`ghost`,type:`button`,disabled:g.length===0&&w===null,onClick:le,children:[i(C,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:g,live:B}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[w!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[w.ref.kind===`snapshot`?i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:w.label}),i(ne,{size:`sm`,variant:`ghost`,type:`button`,icon:_,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(V,{size:`sm`,variant:O===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`snapshot`?`none`:`snapshot`),children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(V,{size:`sm`,variant:O===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`track`?`none`:`track`),children:[i(v,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),O===`snapshot`&&i(nt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),k(`none`)}}),O===`track`&&i(it,{onPick:(e,t)=>{T({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),k(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ae,{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),Y?e(V,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[i(S,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(V,{size:`sm`,type:`button`,disabled:p.trim()===``||c===``,onClick:se,children:[i(D,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=G();return t.length===0&&n===null?i(B,{icon:A,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${f}`,children:[t.map(e=>i(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),Ke(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=G(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(tt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(v,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(b,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),Ge(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function tt({attachment:e}){let{t}=G(),n=Ue(e);return n===null?null:i(`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 nt({onPick:e}){let{t}=G(),n=R({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=G(),a=ee(t,`compact`),{src:o}=p(t.id,{width:Xe});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(z,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=G(),a=E(),o=R({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...qe,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Je,limit:Ye,projection:`slim`})});if(o.isLoading||u.isLoading)return i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=G(),r=E(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=P({functionCap:`llm`}),d=s({queryKey:[...ce,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=d.data??[],g=i(`div`,{className:`w-36`,children:i(x,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(L,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:d.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(F,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?i(B,{icon:y,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(U,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:N})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=G(),t=I(ct),[n]=J(),r=q(`/system/ai`,{t:e,isAdmin:!0})??{icon:T,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(se,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={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.`)};return i(Y,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Me,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,Z)??``,r=t=>pt(t,e,X)??!1,a=t=>pt(t,e,le)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(z,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=G(),r=P({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:m,children:[i(ye,{}),i(oe,{functionCap:ct,icon:T,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(ke,{row:e})})]})}function gt({presence:t}){let{t:n}=G();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(M,{className:`h-8 w-64`}),i(M,{className:`h-40 w-full`})]}):t===`unknown`?i(F,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(B,{icon:T,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};